Commit e08b6542 authored by ElenaSubbotina's avatar ElenaSubbotina

XlsFormat - ctrlProps

parent 4b122c0b
...@@ -115,17 +115,33 @@ void CompoundFile::copy_stream(std::wstring streamNameOpen, std::wstring streamN ...@@ -115,17 +115,33 @@ void CompoundFile::copy_stream(std::wstring streamNameOpen, std::wstring streamN
POLE::Stream *streamNew = new POLE::Stream(storageOut, streamNameCreate, true, size_stream); POLE::Stream *streamNew = new POLE::Stream(storageOut, streamNameCreate, true, size_stream);
if (!streamNew) return; if (!streamNew) return;
unsigned char* data_stream = new unsigned char[size_stream + 64]; unsigned char buffer[4096];
memset(data_stream, 0, size_stream + 64); int bytesRead = 0;
if (data_stream)
while(true)
{ {
stream->read(data_stream, size_stream); int bytesToRead = size_stream - bytesRead;
if (bytesToRead <= 0)
break;
if (bytesToRead > 4096)
bytesToRead = 4096;
stream->read(buffer, bytesToRead);
streamNew->write(buffer, bytesToRead);
bytesRead += bytesToRead;
}
//unsigned char* data_stream = new unsigned char[size_stream + 64];
//memset(data_stream, 0, size_stream + 64);
//if (data_stream)
//{
// stream->read(data_stream, size_stream);
streamNew->write(data_stream, size_stream); // streamNew->write(data_stream, size_stream);
delete []data_stream; // delete []data_stream;
data_stream = NULL; // data_stream = NULL;
} //}
streamNew->flush(); streamNew->flush();
...@@ -152,25 +168,26 @@ void CompoundFile::copy( int indent, std::wstring path, POLE::Storage * storageO ...@@ -152,25 +168,26 @@ void CompoundFile::copy( int indent, std::wstring path, POLE::Storage * storageO
entries_files.push_front(*it); entries_files.push_front(*it);
} }
} }
for( std::list<std::wstring>::iterator it = entries_dir.begin(); it != entries_dir.end(); it++ ) for( std::list<std::wstring>::iterator it = entries_dir.begin(); it != entries_dir.end(); it++ )
{ {
std::wstring fullname = path + *it; std::wstring fullname = path + *it;
copy( indent + 1, fullname + L"/", storageOut, bWithRoot, bSortFiles ); copy( indent + 1, fullname + L"/", storageOut, bWithRoot, bSortFiles );
} }
//if (bSortFiles)
entries_files.sort(); //entries_files.sort();
for( std::list<std::wstring>::iterator it = entries_files.begin(); it != entries_files.end(); it++ ) for( std::list<std::wstring>::iterator it = entries_files.begin(); it != entries_files.end(); it++ )
{ {
std::wstring createName = path + *it; std::wstring createName = path + *it;
std::wstring openName; std::wstring openName;
if (it->at(0) < 32) openName = path + it->substr(1); if (it->at(0) < 32) openName = path + it->substr(1);
else openName = path + *it; else openName = path + *it;
copy_stream(openName, createName, storageOut, bWithRoot); copy_stream(openName, createName, storageOut, bWithRoot);
} }
} }
CFStreamPtr CompoundFile::getWorkbookStream() CFStreamPtr CompoundFile::getWorkbookStream()
{ {
......
...@@ -98,7 +98,10 @@ void DConn::readFields(CFRecord& record) ...@@ -98,7 +98,10 @@ void DConn::readFields(CFRecord& record)
grbitDbt->load(record); grbitDbt->load(record);
record >> bVerDbqueryEdit >> bVerDbqueryRefreshed >> bVerDbqueryRefreshableMin >> wRefreshInterval >> wHtmlFmt >> rcc >> credMethod >> reserved3; record >> bVerDbqueryEdit >> bVerDbqueryRefreshed >> bVerDbqueryRefreshableMin >> wRefreshInterval >> wHtmlFmt >> rcc >> credMethod >> reserved3;
//wHtmlFmt
//0x0001 No formatting is applied
//0x0002 Rich text formatting only
//0x0003 Full HTML formatting, including cell formatting
if (dbt == 5) if (dbt == 5)
{ {
record >> rgchSourceDataFile; record >> rgchSourceDataFile;
...@@ -140,12 +143,12 @@ void DConn::readFields(CFRecord& record) ...@@ -140,12 +143,12 @@ void DConn::readFields(CFRecord& record)
record >> rgbSQL; record >> rgbSQL;
} }
if (dbt == 1) if (dbt == 1 || dbt == 5)//7183958.xls
{ {
record >> rgbSQLSav; record >> rgbSQLSav;
} }
if (dbt == 4) if (dbt == 4 || dbt == 5)
{ {
record >> rgbEditWebPage; record >> rgbEditWebPage;
} }
......
...@@ -59,9 +59,11 @@ void DConnConnectionOleDb::load(CFRecord& record) ...@@ -59,9 +59,11 @@ void DConnConnectionOleDb::load(CFRecord& record)
record >> val; record >> val;
rgIOleDbValid.push_back(val); rgIOleDbValid.push_back(val);
} }
int skip_unused = 2 * (4 - cOleDb) + 2; int skip_unused = 2 * (4 - cOleDb);
record.skipNunBytes(skip_unused); record.skipNunBytes(skip_unused);
record.skipNunBytes(2);
for (unsigned short i = 0; i < cOleDb; i++) for (unsigned short i = 0; i < cOleDb; i++)
{ {
......
...@@ -276,6 +276,7 @@ namespace oox ...@@ -276,6 +276,7 @@ namespace oox
case msosptRoundRectangle : return L"roundRect"; case msosptRoundRectangle : return L"roundRect";
case msosptEllipse : return L"ellipse"; case msosptEllipse : return L"ellipse";
case msosptPictureFrame : return L"rect"; case msosptPictureFrame : return L"rect";
case msosptHostControl : return L"rect";
//case msosptDiamond : return L"diamond"; //case msosptDiamond : return L"diamond";
case msosptIsocelesTriangle : return L"triangle"; case msosptIsocelesTriangle : return L"triangle";
//case msosptRightTriangle : return L"rtTriangle"; //case msosptRightTriangle : return L"rtTriangle";
......
...@@ -1033,9 +1033,7 @@ void XlsConverter::convert(XLS::OBJECTS* objects, XLS::WorksheetSubstream * shee ...@@ -1033,9 +1033,7 @@ void XlsConverter::convert(XLS::OBJECTS* objects, XLS::WorksheetSubstream * shee
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
if (type_object < 0)continue; if (type_object < 0) continue;
ODRAW::OfficeArtSpContainer *sp = NULL;
if (type_object == 0) if (type_object == 0)
{ {
...@@ -1043,12 +1041,16 @@ void XlsConverter::convert(XLS::OBJECTS* objects, XLS::WorksheetSubstream * shee ...@@ -1043,12 +1041,16 @@ void XlsConverter::convert(XLS::OBJECTS* objects, XLS::WorksheetSubstream * shee
if (group_objects.back().ind < group_objects.back().spgr->child_records.size()) if (group_objects.back().ind < group_objects.back().spgr->child_records.size())
{ {
gr.spgr = dynamic_cast<ODRAW::OfficeArtSpgrContainer*>(group_objects.back().spgr->child_records[group_objects.back().ind++].get()); gr.spgr = dynamic_cast<ODRAW::OfficeArtSpgrContainer*>(group_objects.back().spgr->child_records[group_objects.back().ind++].get());
gr.count = gr.spgr->child_records.size(); gr.count = gr.spgr ? gr.spgr->child_records.size() : 0;
group_objects.push_back(gr); group_objects.push_back(gr);
} }
else //сюда попадать не должно !!!! else //сюда попадать не должно !!!!
continue; continue;
} }
if (obj->cmo.fUIObj) continue; // automatically inserted by the application
ODRAW::OfficeArtSpContainer *sp = NULL;
if ((group_objects.size() > 0) && (group_objects.back().spgr ) && ( group_objects.back().ind < group_objects.back().count)) if ((group_objects.size() > 0) && (group_objects.back().spgr ) && ( group_objects.back().ind < group_objects.back().count))
{ {
sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(group_objects.back().spgr->child_records[group_objects.back().ind++].get()); sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(group_objects.back().spgr->child_records[group_objects.back().ind++].get());
...@@ -1944,23 +1946,22 @@ void XlsConverter::convert(XLS::Obj * obj) ...@@ -1944,23 +1946,22 @@ void XlsConverter::convert(XLS::Obj * obj)
} }
if (obj->pictFlags.fCtl && obj->pictFlags.fPrstm)//Controls Storage if (obj->pictFlags.fCtl && obj->pictFlags.fPrstm)//Controls Storage
{ {
xlsx_context->start_activeX();
xlsx_context->get_mediaitems().create_activeX_path(xlsx_path);
//binary data //binary data
std::wstring target; xlsx_context->get_mediaitems().create_activeX_path(xlsx_path);
std::wstring objectId = xlsx_context->get_mediaitems().add_activeX(target);
std::wstring target_bin;
std::wstring objectId_bin = xlsx_context->get_mediaitems().add_control_activeX(target_bin);
NSFile::CFileBinary file; NSFile::CFileBinary file;
if ( file.CreateFileW(xlsx_context->get_mediaitems().activeX_path() + target) ) if ( file.CreateFileW(xlsx_context->get_mediaitems().activeX_path() + target_bin) )
{ {
file.WriteFile(xls_global_info->controls_data.first.get() + obj->pictFmla.lPosInCtlStm, obj->pictFmla.cbBufInCtlStm); file.WriteFile(xls_global_info->controls_data.first.get() + obj->pictFmla.lPosInCtlStm, obj->pictFmla.cbBufInCtlStm);
file.CloseFile(); file.CloseFile();
} }
std::wstring objectId_xml = xlsx_context->start_activeX();
xlsx_context->get_drawing_context().set_control(objectId); xlsx_context->get_drawing_context().set_control_activeX(objectId_xml);
xlsx_context->current_activeX().setDataBinRid(objectId, target); xlsx_context->current_activeX().setDataBinRid(objectId_bin, target_bin);
xlsx_context->current_activeX().setProgId(info); xlsx_context->current_activeX().setProgId(info);
xlsx_context->current_activeX().setLicense(obj->pictFmla.key.keyBuf); xlsx_context->current_activeX().setLicense(obj->pictFmla.key.keyBuf);
...@@ -1994,6 +1995,16 @@ void XlsConverter::convert(XLS::Obj * obj) ...@@ -1994,6 +1995,16 @@ void XlsConverter::convert(XLS::Obj * obj)
xlsx_context->get_drawing_context().set_ole_object(objectId, info); xlsx_context->get_drawing_context().set_ole_object(objectId, info);
} }
} }
if (obj->pictFmla.key.fmlaLinkedCell.bFmlaExist)
{
std::wstring link = obj->pictFmla.key.fmlaLinkedCell.fmla.getAssembledFormula(true);
xlsx_context->get_drawing_context().set_object_link(link);
}
if (obj->pictFmla.key.fmlaListFillRange.bFmlaExist)
{
std::wstring link = obj->pictFmla.key.fmlaListFillRange.fmla.getAssembledFormula(true);
xlsx_context->get_drawing_context().set_object_fmlaRange(link);
}
} }
if (obj->sbs.fExist) if (obj->sbs.fExist)
{ {
......
...@@ -63,6 +63,8 @@ std::wstring static get_default_file_name(external_items::Type type) ...@@ -63,6 +63,8 @@ std::wstring static get_default_file_name(external_items::Type type)
return L"media"; return L"media";
case external_items::typeActiveX: case external_items::typeActiveX:
return L"activeX"; return L"activeX";
case external_items::typeControlProps:
return L"ctrlProp";
default: default:
return L""; return L"";
} }
...@@ -92,7 +94,20 @@ std::wstring external_items::add_chart(std::wstring & oox_target) ...@@ -92,7 +94,20 @@ std::wstring external_items::add_chart(std::wstring & oox_target)
return rId; return rId;
} }
std::wstring external_items::add_activeX(std::wstring & oox_target) std::wstring external_items::add_control_activeX(std::wstring & oox_target_bin)
{
const bool isMediaInternal = true;
count_activeX++;
std::wstring rId = std::wstring(L"ocxId") + std::to_wstring(count_activeX);
oox_target_bin = std::wstring(L"activeX") + std::to_wstring(count_activeX) + L".bin";
items_.push_back( item(oox_target_bin, typeActiveX, isMediaInternal, -1, rId) );
return rId;
}
std::wstring external_items::add_control_props(std::wstring & oox_target)
{ {
const bool isMediaInternal = true; const bool isMediaInternal = true;
...@@ -100,12 +115,11 @@ std::wstring external_items::add_activeX(std::wstring & oox_target) ...@@ -100,12 +115,11 @@ std::wstring external_items::add_activeX(std::wstring & oox_target)
std::wstring rId = std::wstring(L"ctrlId") + std::to_wstring(count_controls); std::wstring rId = std::wstring(L"ctrlId") + std::to_wstring(count_controls);
oox_target = std::wstring(L"activeX") + std::to_wstring(count_controls) + L".bin"; oox_target = std::wstring(L"ctrlProp") + std::to_wstring(count_controls) + L".xml";
items_.push_back( item(oox_target, typeActiveX, isMediaInternal, -1, rId) ); items_.push_back( item(oox_target, typeControlProps, isMediaInternal, -1, rId) );
return rId; return rId;
} }
std::wstring external_items::add_embedding(std::wstring & oox_target, const std::wstring & info) std::wstring external_items::add_embedding(std::wstring & oox_target, const std::wstring & info)
{ {
const bool isMediaInternal = true; const bool isMediaInternal = true;
......
...@@ -55,7 +55,8 @@ public: ...@@ -55,7 +55,8 @@ public:
typeExternalLink, typeExternalLink,
typeOleObject, typeOleObject,
typeActiveX, typeActiveX,
typeControl typeControl,
typeControlProps
}; };
external_items() external_items()
...@@ -100,8 +101,10 @@ public: ...@@ -100,8 +101,10 @@ public:
//std::wstring add_or_find(const std::wstring & href, Type type, bool & isInternal);//возможны ссылки на один и тот же объект //std::wstring add_or_find(const std::wstring & href, Type type, bool & isInternal);//возможны ссылки на один и тот же объект
std::wstring add_image (const std::wstring & file_name, int bin_id); std::wstring add_image (const std::wstring & file_name, int bin_id);
std::wstring add_chart (std::wstring & oox_target); std::wstring add_chart (std::wstring & oox_target);
std::wstring add_activeX (std::wstring & oox_target);
std::wstring add_embedding (std::wstring & oox_target, const std::wstring & info); std::wstring add_embedding (std::wstring & oox_target, const std::wstring & info);
std::wstring add_control_activeX(std::wstring & oox_target);
std::wstring add_control_props (std::wstring & oox_target);
std::wstring find_image (int id, std::wstring & oox_target, bool & isExternal); std::wstring find_image (int id, std::wstring & oox_target, bool & isExternal);
std::wstring find_image ( const std::wstring & oox_target, bool & isExternal); std::wstring find_image ( const std::wstring & oox_target, bool & isExternal);
......
...@@ -32,11 +32,6 @@ ...@@ -32,11 +32,6 @@
#include "mediaitems_utils.h" #include "mediaitems_utils.h"
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
#include "../../../Common/DocxFormat/Source/Base/Base.h"
#include "../../../DesktopEditor/common/Directory.h" #include "../../../DesktopEditor/common/Directory.h"
namespace oox { namespace oox {
...@@ -64,22 +59,12 @@ std::wstring get_rel_type(external_items::Type type) ...@@ -64,22 +59,12 @@ std::wstring get_rel_type(external_items::Type type)
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath"; return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath";
case external_items::typeActiveX: case external_items::typeActiveX:
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/control"; return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/control";
case external_items::typeControlProps:
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp";
default: default:
return L""; return L"";
} }
} }
std::wstring replace_extension(const std::wstring & ext)
{
// TODO
if (ext == L"jpg")
return L"jpeg";
else
return ext;
}
} }
} }
......
...@@ -205,6 +205,10 @@ void oox_activeX_context::write_to(std::wostream & strm) ...@@ -205,6 +205,10 @@ void oox_activeX_context::write_to(std::wostream & strm)
classId = L"{8BD21D10-EC42-11CE-9E0D-00AA006002F3}"; classId = L"{8BD21D10-EC42-11CE-9E0D-00AA006002F3}";
} }
} }
else if (std::wstring::npos != impl_->progId.find(L"ShockwaveFlash."))
{
classId = L"{D27CDB6E-AE6D-11CF-96B8-444553540000}";
}
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
if (classId.empty()) if (classId.empty())
{ {
......
...@@ -67,7 +67,16 @@ public: ...@@ -67,7 +67,16 @@ public:
for (size_t i = 0; i < chartRels_.size(); i++) for (size_t i = 0; i < chartRels_.size(); i++)
{ {
rel_ & r = chartRels_[i]; rel_ & r = chartRels_[i];
if (r.type_ == external_items::typeImage) if (r.type_ == external_items::typeHyperlink)
{
Rels.add(relationship(
r.rid_,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
r.target_,
L"External")
);
}
else
{ {
Rels.add(relationship( Rels.add(relationship(
r.rid_, r.rid_,
...@@ -77,15 +86,6 @@ public: ...@@ -77,15 +86,6 @@ public:
) )
); );
} }
else if (r.type_ == external_items::typeHyperlink)
{
Rels.add(relationship(
r.rid_,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
r.target_,
L"External")
);
}
} }
} }
......
...@@ -149,16 +149,19 @@ void xlsx_conversion_context::start_chart() ...@@ -149,16 +149,19 @@ void xlsx_conversion_context::start_chart()
} }
void xlsx_conversion_context::start_activeX() std::wstring xlsx_conversion_context::start_activeX()
{ {
activeXs_.push_back(oox_activeX_context::create()); activeXs_.push_back(oox_activeX_context::create());
size_t index = activeXs_.size(); size_t index = activeXs_.size();
current_sheet().sheet_rels().add(oox::relationship(L"ctrlId" + std::to_wstring(index), std::wstring rid = L"ocxId" + std::to_wstring(index);
current_sheet().sheet_rels().add(oox::relationship(rid,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/control", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/control",
L"../activeX/activeX" + std::to_wstring(index) +L".xml")); L"../activeX/activeX" + std::to_wstring(index) +L".xml"));
return rid;
} }
void xlsx_conversion_context::start_external() void xlsx_conversion_context::start_external()
{ {
...@@ -171,8 +174,9 @@ void xlsx_conversion_context::end_external() ...@@ -171,8 +174,9 @@ void xlsx_conversion_context::end_external()
void xlsx_conversion_context::end_table() void xlsx_conversion_context::end_table()
{ {
get_table_context().serialize_ole_objects(current_sheet().ole_objects()); get_table_context().serialize_ole_objects (current_sheet().ole_objects());
get_table_context().serialize_activeXs_controls(current_sheet().activeXs()); get_table_context().serialize_controls (current_sheet().activeXs());
get_table_context().dump_rels_drawing(current_sheet().sheet_rels()); get_table_context().dump_rels_drawing(current_sheet().sheet_rels());
get_table_context().serialize_hyperlinks(current_sheet().hyperlinks()); get_table_context().serialize_hyperlinks(current_sheet().hyperlinks());
...@@ -186,16 +190,25 @@ xlsx_drawing_context_handle & xlsx_conversion_context::get_drawing_context_handl ...@@ -186,16 +190,25 @@ xlsx_drawing_context_handle & xlsx_conversion_context::get_drawing_context_handl
return xlsx_drawing_context_handle_; return xlsx_drawing_context_handle_;
} }
void xlsx_conversion_context::add_connections(std::wstring connections) void xlsx_conversion_context::add_connections(const std::wstring & connections)
{ {
if (connections.empty()) return; if (connections.empty()) return;
connections_ = connections; connections_ = connections;
} }
void xlsx_conversion_context::add_query_table (std::wstring query_table) void xlsx_conversion_context::add_query_table (const std::wstring & query_table)
{ {
if (query_table.empty()) return; if (query_table.empty()) return;
query_tables_.push_back(query_table);
std::wstring target = L"queryTable" + std::to_wstring(query_tables_.size() + 1) + L".xml";
query_tables_.insert(std::make_pair(target, query_table));
}
void xlsx_conversion_context::add_control_props(const std::wstring & target, const std::wstring & props)
{
if (props.empty()) return;
control_props_.insert(std::make_pair(target, props));
} }
void xlsx_conversion_context::end_document() void xlsx_conversion_context::end_document()
...@@ -299,12 +312,15 @@ void xlsx_conversion_context::end_document() ...@@ -299,12 +312,15 @@ void xlsx_conversion_context::end_document()
} }
output_document_->get_xl_files().set_connections( package::simple_element::create(L"connections.xml", strm.str()) ); output_document_->get_xl_files().set_connections( package::simple_element::create(L"connections.xml", strm.str()) );
} }
for (size_t i = 0; i < query_tables_.size(); i++) for (std::map<std::wstring, std::wstring>::iterator it = query_tables_.begin(); it != query_tables_.end(); it++)
{
output_document_->get_xl_files().add_query_table( package::simple_element::create(it->first, it->second) );
}
for (std::map<std::wstring, std::wstring>::iterator it = control_props_.begin(); it != control_props_.end(); it++)
{ {
std::wstring file_name = L"queryTable" + std::to_wstring(i+1) + L".xml"; output_document_->get_xl_files().add_control_props( package::simple_element::create(it->first, it->second) );
output_document_->get_xl_files().add_query_table( package::simple_element::create(file_name, query_tables_[i]) );
} }
//workbook_content << L"<calcPr iterateCount=\"100\" refMode=\"A1\" iterate=\"false\" iterateDelta=\"0.0001\" />"; //workbook_content << L"<calcPr iterateCount=\"100\" refMode=\"A1\" iterate=\"false\" iterateDelta=\"0.0001\" />";
output_document_->get_xl_files().set_sharedStrings( package::simple_element::create(L"sharedStrings.xml", xlsx_shared_strings_.str()) ); output_document_->get_xl_files().set_sharedStrings( package::simple_element::create(L"sharedStrings.xml", xlsx_shared_strings_.str()) );
......
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
void start_chart(); void start_chart();
void end_chart(){} void end_chart(){}
void start_activeX(); std::wstring start_activeX();
void end_activeX(){} void end_activeX(){}
void start_external(); void start_external();
...@@ -102,9 +102,9 @@ public: ...@@ -102,9 +102,9 @@ public:
external_items & get_mediaitems() { return mediaitems_; } external_items & get_mediaitems() { return mediaitems_; }
void add_exteranal_content (std::wstring content); void add_connections (const std::wstring & connections);
void add_connections (std::wstring connections); void add_query_table (const std::wstring & query_table);
void add_query_table (std::wstring query_table); void add_control_props (const std::wstring & target, const std::wstring &props);
private: private:
void create_new_sheet(std::wstring const & name); void create_new_sheet(std::wstring const & name);
...@@ -112,8 +112,7 @@ private: ...@@ -112,8 +112,7 @@ private:
package::xlsx_document *output_document_; package::xlsx_document *output_document_;
external_items mediaitems_; external_items mediaitems_;
xlsx_table_context xlsx_table_context table_context_;
table_context_;
xlsx_text_context text_context_; xlsx_text_context text_context_;
xlsx_pivots_context pivots_context_; xlsx_pivots_context pivots_context_;
...@@ -125,7 +124,8 @@ private: ...@@ -125,7 +124,8 @@ private:
std::vector<xlsx_xml_worksheet_ptr> sheets_; std::vector<xlsx_xml_worksheet_ptr> sheets_;
std::wstring connections_; std::wstring connections_;
std::vector<std::wstring> query_tables_; std::map<std::wstring, std::wstring>query_tables_;
std::map<std::wstring, std::wstring>control_props_;
std::wstringstream xlsx_shared_strings_; std::wstringstream xlsx_shared_strings_;
std::wstringstream xlsx_defined_names_; std::wstringstream xlsx_defined_names_;
......
...@@ -295,11 +295,12 @@ public: ...@@ -295,11 +295,12 @@ public:
}line; }line;
struct _object struct _object
{ {
_object() {visible = true; col = row = 0; id = 0;} int id = 0;
int id; bool bVisible = true;
bool visible; int col = 0;
int col; int row = 0;
int row; bool bAutoLine = false;
bool bAutoPict = false;
std::wstring macro; std::wstring macro;
std::wstring link; std::wstring link;
_CP_OPT(int) x_val; _CP_OPT(int) x_val;
...@@ -365,7 +366,7 @@ public: ...@@ -365,7 +366,7 @@ public:
void set_description (const std::wstring & str); void set_description (const std::wstring & str);
void set_macro (const std::wstring & str); void set_macro (const std::wstring & str);
void set_ole_object (const std::wstring & id, const std::wstring & info); void set_ole_object (const std::wstring & id, const std::wstring & info);
void set_control (const std::wstring & id); void set_control_activeX (const std::wstring & id);
void set_crop_top (double val); void set_crop_top (double val);
void set_crop_bottom (double val); void set_crop_bottom (double val);
...@@ -464,22 +465,22 @@ public: ...@@ -464,22 +465,22 @@ public:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void serialize_group (); void serialize_group ();
void serialize_shape (_drawing_state_ptr & drawing_state); void serialize_shape (_drawing_state_ptr & drawing_state);
void serialize_chart (_drawing_state_ptr & drawing_state, std::wstring rId ); void serialize_chart (_drawing_state_ptr & drawing_state);
void serialize_pic (_drawing_state_ptr & drawing_state, std::wstring rId ); void serialize_pic (_drawing_state_ptr & drawing_state);
void serialize_object (_drawing_state_ptr & drawing_state, std::wstring rId );
void serialize_control (_drawing_state_ptr & drawing_state); void serialize_control (_drawing_state_ptr & drawing_state);
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
void serialize_vml_shape (_drawing_state_ptr & drawing_state); void serialize_vml_shape (_drawing_state_ptr & drawing_state);
void serialize_vml_pic (_drawing_state_ptr & drawing_state, std::wstring rId ); void serialize_vml_pic (_drawing_state_ptr & drawing_state);
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
void serialize_fill (std::wostream & strm, _drawing_state_ptr & drawing_state); void serialize_fill (std::wostream & strm, _drawing_state_ptr & drawing_state);
void serialize_fill (std::wostream & strm); void serialize_fill (std::wostream & strm);
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
void serialize (std::wostream & strm, _drawing_state_ptr & drawing_state); void serialize (std::wostream & strm, _drawing_state_ptr & drawing_state);
void serialize_object (std::wostream & strm, _drawing_state_ptr & drawing_state); void serialize_object (std::wostream & strm, _drawing_state_ptr & drawing_state);
void serialize_activeX_control(std::wostream & strm, _drawing_state_ptr & drawing_state); void serialize_control (std::wostream & strm, _drawing_state_ptr & drawing_state);
void serialize_control_props(std::wostream & strm, _drawing_state_ptr & drawing_state);
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
void serialize_activeXs_controls(std::wostream & strm); void serialize_controls (std::wostream & strm);
void serialize_objects (std::wostream & strm); void serialize_objects (std::wostream & strm);
void serialize_vml_HF (std::wostream & strm); void serialize_vml_HF (std::wostream & strm);
void serialize_vml (std::wostream & strm); void serialize_vml (std::wostream & strm);
...@@ -511,7 +512,7 @@ private: ...@@ -511,7 +512,7 @@ private:
std::vector<_drawing_state_ptr>* current_drawing_states; std::vector<_drawing_state_ptr>* current_drawing_states;
std::vector<_drawing_state_ptr> drawing_states_objects;//копии для сериализации ole std::vector<_drawing_state_ptr> drawing_states_objects;//копии для сериализации ole
std::vector<_drawing_state_ptr> drawing_states_activeX;//копии для сериализации activeX std::vector<_drawing_state_ptr> drawing_states_controls;//копии для сериализации control
void end_drawing (_drawing_state_ptr & drawing_state); void end_drawing (_drawing_state_ptr & drawing_state);
void reset_fill_pattern (_drawing_state_ptr & drawing_state); void reset_fill_pattern (_drawing_state_ptr & drawing_state);
......
...@@ -84,35 +84,25 @@ public: ...@@ -84,35 +84,25 @@ public:
{ {
BOOST_FOREACH(rel_ const & r, rels_) BOOST_FOREACH(rel_ const & r, rels_)
{ {
if (r.type_ == external_items::typeChart) if (r.type_ == external_items::typeHyperlink)
{ {
Rels.add(relationship( Rels.add(relationship(
r.rid_, r.rid_,
utils::media::get_rel_type(r.type_), L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
(r.is_internal_ ? std::wstring(L"../") + r.target_ : r.target_), r.target_,
(r.is_internal_ ? L"" : L"External") (r.is_internal_ ? L"" : L"External"))
) );
);
} }
else if (r.type_ == external_items::typeImage) else
{ {
Rels.add(relationship( Rels.add(relationship(
r.rid_, r.rid_,
utils::media::get_rel_type(r.type_), utils::media::get_rel_type(r.type_),
r.is_internal_ ? std::wstring(L"../") + r.target_ : r.target_, (r.is_internal_ ? std::wstring(L"../") + r.target_ : r.target_),
(r.is_internal_ ? L"" : L"External") (r.is_internal_ ? L"" : L"External")
) )
); );
} }
else if (r.type_ == external_items::typeHyperlink)
{
Rels.add(relationship(
r.rid_,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
r.target_,
(r.is_internal_ ? L"" : L"External"))
);
}
} }
} }
......
...@@ -249,6 +249,9 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm) ...@@ -249,6 +249,9 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->ole_objects_.str(); CP_XML_STREAM() << impl_->ole_objects_.str();
} }
} }
CP_XML_STREAM() << impl_->picture_background_.str();
if (!impl_->activeXs_.str().empty()) if (!impl_->activeXs_.str().empty())
{ {
CP_XML_NODE(L"controls") CP_XML_NODE(L"controls")
...@@ -256,7 +259,6 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm) ...@@ -256,7 +259,6 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->activeXs_.str(); CP_XML_STREAM() << impl_->activeXs_.str();
} }
} }
CP_XML_STREAM() << impl_->picture_background_.str();
//CP_XML_NODE(L"rowBreaks){} //CP_XML_NODE(L"rowBreaks){}
......
...@@ -210,11 +210,14 @@ void xl_files::write(const std::wstring & RootPath) ...@@ -210,11 +210,14 @@ void xl_files::write(const std::wstring & RootPath)
sheets_files_.set_main_document( this->get_main_document() ); sheets_files_.set_main_document( this->get_main_document() );
sheets_files_.write(path); sheets_files_.write(path);
} }
{
control_props_files_.set_main_document( this->get_main_document() );
control_props_files_.write(path);
}
{ {
query_tables_files_.set_main_document( this->get_main_document() ); query_tables_files_.set_main_document( this->get_main_document() );
query_tables_files_.write(path); query_tables_files_.write(path);
} }
if (sharedStrings_) if (sharedStrings_)
{ {
sharedStrings_->write(path); sharedStrings_->write(path);
...@@ -368,6 +371,10 @@ void xl_files::add_query_table (simple_element_ptr element) ...@@ -368,6 +371,10 @@ void xl_files::add_query_table (simple_element_ptr element)
{ {
query_tables_files_.add_query_table(element); query_tables_files_.add_query_table(element);
} }
void xl_files::add_control_props (simple_element_ptr element)
{
control_props_files_.add_control_props(element);
}
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
void xl_pivot_cache_files::add_pivot_cache(pivot_cache_content_ptr pivot_cache) void xl_pivot_cache_files::add_pivot_cache(pivot_cache_content_ptr pivot_cache)
{ {
...@@ -597,7 +604,33 @@ void xl_query_table_files::write(const std::wstring & RootPath) ...@@ -597,7 +604,33 @@ void xl_query_table_files::write(const std::wstring & RootPath)
query_tables_[i]->write(path); query_tables_[i]->write(path);
} }
} }
//----------------------------------------------------------------------------------------
void xl_control_props_files::add_control_props(simple_element_ptr query_table)
{
control_props_.push_back(query_table);
}
void xl_control_props_files::write(const std::wstring & RootPath)
{
if (control_props_.empty()) return;
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"ctrlProps";
NSDirectory::CreateDirectory(path);
content_type & contentTypes = this->get_main_document()->content_type().get_content_type();
static const std::wstring kWSConType = L"application/vnd.ms-excel.controlproperties+xml";
for (size_t i = 0; i < control_props_.size(); i++)
{
if (!control_props_[i])continue;
const std::wstring fileName = control_props_[i]->get_filename();
contentTypes.add_override(std::wstring(L"/xl/ctrlProps/") + fileName, kWSConType);
control_props_[i]->write(path);
}
}
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
xl_drawings_ptr xl_drawings::create(const std::vector<drawing_elm> & elms) xl_drawings_ptr xl_drawings::create(const std::vector<drawing_elm> & elms)
{ {
......
...@@ -170,6 +170,16 @@ public: ...@@ -170,6 +170,16 @@ public:
std::vector<simple_element_ptr> query_tables_; std::vector<simple_element_ptr> query_tables_;
}; };
class xl_control_props_files : public element
{
public:
xl_control_props_files(){}
void add_control_props(simple_element_ptr props);
virtual void write(const std::wstring & RootPath);
std::vector<simple_element_ptr> control_props_;
};
class xl_externals_files : public element class xl_externals_files : public element
{ {
public: public:
...@@ -212,8 +222,6 @@ public: ...@@ -212,8 +222,6 @@ public:
rels_files * rels_; rels_files * rels_;
}; };
///////////////////////////////////////////////////////////
class xl_comments; class xl_comments;
typedef _CP_PTR(xl_comments) xl_comments_ptr; typedef _CP_PTR(xl_comments) xl_comments_ptr;
...@@ -283,7 +291,7 @@ public: ...@@ -283,7 +291,7 @@ public:
void add_pivot_cache (pivot_cache_content_ptr cache); void add_pivot_cache (pivot_cache_content_ptr cache);
void add_pivot_table (pivot_table_content_ptr table); void add_pivot_table (pivot_table_content_ptr table);
void add_query_table (simple_element_ptr element); void add_query_table (simple_element_ptr element);
void add_control_props (simple_element_ptr element);
void add_vba_project (); void add_vba_project ();
private: private:
rels_files rels_files_; rels_files rels_files_;
...@@ -294,6 +302,7 @@ private: ...@@ -294,6 +302,7 @@ private:
xl_pivot_table_files pivot_table_files_; xl_pivot_table_files pivot_table_files_;
xl_activeX_files activeXs_files_; xl_activeX_files activeXs_files_;
xl_query_table_files query_tables_files_; xl_query_table_files query_tables_files_;
xl_control_props_files control_props_files_;
element_ptr theme_; element_ptr theme_;
element_ptr workbook_; element_ptr workbook_;
......
...@@ -160,8 +160,8 @@ void xlsx_table_context::serialize_ole_objects(std::wostream & strm) ...@@ -160,8 +160,8 @@ void xlsx_table_context::serialize_ole_objects(std::wostream & strm)
{ {
state()->drawing_context_.serialize_objects(strm); state()->drawing_context_.serialize_objects(strm);
} }
void xlsx_table_context::serialize_activeXs_controls(std::wostream & strm) void xlsx_table_context::serialize_controls(std::wostream & strm)
{ {
state()->drawing_context_.serialize_activeXs_controls(strm); state()->drawing_context_.serialize_controls(strm);
} }
} }
...@@ -69,11 +69,12 @@ public: ...@@ -69,11 +69,12 @@ public:
table_state_ptr & state(); table_state_ptr & state();
std::wstring add_hyperlink(std::wstring const & ref, std::wstring const & target, std::wstring const & display, bool bExternal); std::wstring add_hyperlink(std::wstring const & ref, std::wstring const & target, std::wstring const & display, bool bExternal);
void dump_rels_hyperlinks(rels & Rels);
void serialize_hyperlinks(std::wostream & _Wostream); void serialize_hyperlinks(std::wostream & _Wostream);
void dump_rels_hyperlinks(rels & Rels);
void serialize_ole_objects(std::wostream & _Wostream); void serialize_ole_objects(std::wostream & _Wostream);
void serialize_activeXs_controls(std::wostream & _Wostream); void serialize_controls(std::wostream & _Wostream);
void dump_rels_drawing(rels & Rels); void dump_rels_drawing(rels & Rels);
private: private:
xlsx_conversion_context & context_; xlsx_conversion_context & context_;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment