Compare commits

...

34 Commits

Author SHA1 Message Date
1602843aa6 fix color alpha 2017-04-26 12:58:51 +03:00
cdb7fb8ea6 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  pivotButton; AddNoWrite defDir
  OdfFormat - fix after testing
  save pivotTables to xlsx
  windows sign (worked version)
  .
2017-04-26 12:46:48 +03:00
6387e9fa69 fix build converter ios 2017-04-26 12:46:41 +03:00
4e8097c93d pivotButton; AddNoWrite defDir 2017-04-26 11:10:58 +03:00
65254b57b2 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-04-25 19:31:42 +03:00
95899e23a8 OdfFormat - fix after testing 2017-04-25 19:30:40 +03:00
5c8757d346 save pivotTables to xlsx 2017-04-25 19:25:45 +03:00
234e19d68a Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-04-25 16:06:04 +03:00
62145b7204 windows sign (worked version) 2017-04-25 15:22:19 +03:00
8bcc6d1501 . 2017-04-25 15:05:58 +03:00
09ef46f333 fix bug #34836 2017-04-25 11:33:31 +03:00
1839350526 . 2017-04-24 19:57:38 +03:00
d7587e91b1 windows sign 2017-04-24 18:57:37 +03:00
7b0a342cf9 . 2017-04-24 17:49:47 +03:00
3d01b0782e . 2017-04-24 15:30:57 +03:00
fecfcfa7d2 . 2017-04-24 14:32:57 +03:00
29b5fa513a . 2017-04-24 13:26:50 +03:00
f9a19badbf DocFormatReader - fix embedded docx formula 2017-04-24 13:20:23 +03:00
d2630ea73c toXml - writer instead string; refreshedDate 2017-04-24 10:54:56 +03:00
a4a58c4782 x2t version up 2017-04-24 10:33:47 +03:00
29a3d80071 . 2017-04-23 16:36:12 +03:00
598bb419c0 OdfFormatWriter - presentation - fields 2017-04-23 16:31:00 +03:00
087da9d2ce . 2017-04-23 14:21:07 +03:00
c505aced48 . 2017-04-22 18:34:10 +03:00
959d5e5fcd OdfFormatWriter - presentation - fix multi-level list, master list styles 2017-04-22 13:05:10 +03:00
8ee0cf4b2c . 2017-04-21 19:26:01 +03:00
426342074e . 2017-04-21 19:08:59 +03:00
d2c092fe62 pivot 2017-04-21 15:05:23 +03:00
a336917338 OdfFormatWriter - image bullet presentation list style 2017-04-21 14:12:50 +03:00
8925ddeee5 big integer from buffer bug 2017-04-21 10:24:17 +03:00
84824631b2 OdfFormatWriter - presentation styled list 2017-04-20 19:55:18 +03:00
dc3ecb1fc0 BigInteger as string realization 2017-04-20 18:13:10 +03:00
266cef8c49 tests windows 2017-04-20 14:10:38 +03:00
a5e821cd21 . 2017-04-19 20:06:58 +03:00
81 changed files with 4679 additions and 1115 deletions

View File

@ -136,14 +136,18 @@ namespace DocFileFormat
}
return btWin32;
}
bool ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString)
bool VMLPictureMapping::ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString)
{
newXmlString.clear();
std::wstring sTempXmlFile = NSDirectory::CreateTempFileWithUniqueName(
NSDirectory::GetTempPath(), L"emb");
sTempXmlFile += L".xml";
std::wstring sTempFolder = m_ctx->_doc->m_sTempFolder;
if (sTempFolder.empty())
{
sTempFolder = NSFile::CFileBinary::GetTempPath();
}
std::wstring sTempXmlFile = NSDirectory::CreateTempFileWithUniqueName(sTempFolder, L"emb");
NSFile::CFileBinary file;
file.CreateFileW(sTempXmlFile);
file.WriteFile((BYTE*)xmlString.c_str(), xmlString.size());
@ -186,6 +190,7 @@ namespace DocFileFormat
if (res) break;
}
}
NSFile::CFileBinary::Remove(sTempXmlFile);
return res;
}
//---------------------------------------------------------------
@ -297,8 +302,13 @@ namespace DocFileFormat
case metroBlob:
{
//встроенная неведомая хуйня
m_isEmbedded = true;
m_embeddedData = std::string((char*)iter->opComplex, iter->op);
m_isEmbedded = true;
m_embeddedData = std::string((char*)iter->opComplex, iter->op);
//if (ParseEmbeddedBlob( m_embeddedData, m_blobXml)) // todoooo
//{
// m_isEmbedded = false;
//}
}break;
//BORDERS
case borderBottomColor:

View File

@ -46,7 +46,6 @@ namespace DocFileFormat
{
class OleObject;
bool ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString );
class VMLPictureMapping: public PropertiesMapping, public IMapping
{
@ -58,6 +57,7 @@ namespace DocFileFormat
/// Writes a border element
void writePictureBorder (const std::wstring & name, const BorderCode* brc);
void appendStyleProperty( std::wstring* b, const std::wstring& propName, const std::wstring& propValue ) const;
bool ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString );
protected:
/// Copies the picture from the binary stream to the zip archive
/// and creates the relationships for the image.

View File

@ -86,6 +86,7 @@ namespace DocFileFormat
friend class Table;
friend class TableRow;
friend class VMLShapeMapping;
friend class VMLPictureMapping;
friend class OpenXmlPackage;
friend class TextboxMapping;

View File

@ -54,7 +54,7 @@ int _tmain(int argc, _TCHAR* argv[])
HRESULT hr = S_OK;
//////////////////////////////////////////////////////////////////////////
std::wstring srcFileName = argv[1];
std::wstring dstPath = argc > 2 ? argv[2] : srcFileName + L"-my.pptx"; //xlsx pptx docx
std::wstring dstPath = argc > 2 ? argv[2] : srcFileName + L"-my.docx"; //xlsx pptx docx
std::wstring outputDir = NSDirectory::GetFolderPath(dstPath);

View File

@ -72,8 +72,8 @@ public:
void start_base_style(const std::wstring baseStyleName, const odf_types::style_family::type baseStyleType);
void end_base_style();
void ApplyTextProperties (std::wstring style,odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type);
void ApplyParagraphProperties (std::wstring style,odf_reader::paragraph_format_properties & propertiesOut, odf_types::style_family::type Type);
void ApplyTextProperties (std::wstring style, std::wstring para_style, odf_reader::text_format_properties_content & propertiesOut);
void ApplyParagraphProperties (std::wstring para_style, odf_reader::paragraph_format_properties & propertiesOut);
void ApplyListProperties (odf_reader::paragraph_format_properties & propertiesOut, int Level);
void set_local_styles_container(odf_reader::styles_container* local_styles_);//это если стили объектов содержатся в другом документе
@ -239,32 +239,37 @@ void pptx_text_context::Impl::end_hyperlink(std::wstring hId)
dump_run();
hyperlink_hId = L"";
}
void pptx_text_context::Impl::ApplyTextProperties(std::wstring style_name,odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type)
void pptx_text_context::Impl::ApplyTextProperties(std::wstring style_name, std::wstring para_style_name, odf_reader::text_format_properties_content & propertiesOut)
{
std::vector<const odf_reader::style_instance *> instances;
odf_reader::style_instance* defaultStyle = NULL;
odf_reader::style_instance* style = NULL;
odf_reader::style_instance* baseStyle = NULL;
odf_reader::style_instance* defaultStyle = NULL;
odf_reader::style_instance* para_style = NULL;
odf_reader::style_instance* text_style = NULL;
odf_reader::style_instance* baseStyle = NULL;
if (local_styles_ptr_)
{
style = local_styles_ptr_->style_by_name(style_name, Type,false/*process_headers_footers_*/);
defaultStyle = local_styles_ptr_->style_default_by_type(Type);
baseStyle = local_styles_ptr_->style_by_name(base_style_name_, base_style_family_,false/*process_headers_footers_*/);
para_style = local_styles_ptr_->style_by_name (para_style_name, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
text_style = local_styles_ptr_->style_by_name (style_name, odf_types::style_family::Text, false/*process_headers_footers_*/);
defaultStyle = local_styles_ptr_->style_default_by_type (odf_types::style_family::Text);
baseStyle = local_styles_ptr_->style_by_name (base_style_name_, base_style_family_, false/*process_headers_footers_*/);
}
else
{
style = odf_context_.styleContainer().style_by_name(style_name, Type,false/*process_headers_footers_*/);
defaultStyle = odf_context_.styleContainer().style_default_by_type(Type);
baseStyle = odf_context_.styleContainer().style_by_name(base_style_name_, base_style_family_,false/*process_headers_footers_*/);
para_style = odf_context_.styleContainer().style_by_name (para_style_name, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
text_style = odf_context_.styleContainer().style_by_name (style_name, odf_types::style_family::Text, false/*process_headers_footers_*/);
defaultStyle = odf_context_.styleContainer().style_default_by_type (odf_types::style_family::Text);
baseStyle = odf_context_.styleContainer().style_by_name (base_style_name_, base_style_family_, false/*process_headers_footers_*/);
}
if (defaultStyle) instances.push_back(defaultStyle);
if (baseStyle) instances.push_back(baseStyle);
if (style) instances.push_back(style);
if (para_style) instances.push_back(para_style);
if (text_style) instances.push_back(text_style);
if (style)get_styles_context().start_process_style(style);
else get_styles_context().start_process_style(baseStyle);
if (text_style) get_styles_context().start_process_style(text_style);
else if (para_style) get_styles_context().start_process_style(para_style);
else get_styles_context().start_process_style(baseStyle);
propertiesOut.apply_from(calc_text_properties_content(instances));
}
@ -323,33 +328,33 @@ void pptx_text_context::Impl::ApplyListProperties(odf_reader::paragraph_format_p
}
void pptx_text_context::Impl::ApplyParagraphProperties(std::wstring style_name,odf_reader::paragraph_format_properties & propertiesOut, odf_types::style_family::type Type)
void pptx_text_context::Impl::ApplyParagraphProperties(std::wstring style_name, odf_reader::paragraph_format_properties & propertiesOut)
{
std::vector<const odf_reader::style_instance *> instances;
odf_reader::style_instance* style = NULL;
odf_reader::style_instance * defaultStyle = NULL;
odf_reader::style_instance * baseStyle = NULL;
odf_reader::style_instance* style = NULL;
odf_reader::style_instance* defaultStyle = NULL;
odf_reader::style_instance* baseStyle = NULL;
if (local_styles_ptr_)
{
style = local_styles_ptr_->style_by_name(style_name, Type,false/*process_headers_footers_*/);
defaultStyle = local_styles_ptr_->style_default_by_type(Type);
baseStyle = local_styles_ptr_->style_by_name(base_style_name_, base_style_family_,false/*process_headers_footers_*/);
style = local_styles_ptr_->style_by_name (style_name, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
defaultStyle = local_styles_ptr_->style_default_by_type (odf_types::style_family::Paragraph);
baseStyle = local_styles_ptr_->style_by_name (base_style_name_, base_style_family_, false/*process_headers_footers_*/);
}
else
{
style = odf_context_.styleContainer().style_by_name(style_name, Type,false/*process_headers_footers_*/);
defaultStyle = odf_context_.styleContainer().style_default_by_type(Type);
baseStyle= odf_context_.styleContainer().style_by_name(base_style_name_, base_style_family_,false/*process_headers_footers_*/);
style = odf_context_.styleContainer().style_by_name (style_name, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
defaultStyle = odf_context_.styleContainer().style_default_by_type (odf_types::style_family::Paragraph);
baseStyle = odf_context_.styleContainer().style_by_name (base_style_name_, base_style_family_,false/*process_headers_footers_*/);
}
if (defaultStyle) instances.push_back(defaultStyle);
if (baseStyle) instances.push_back(baseStyle);
if (style) instances.push_back(style);
if (style)get_styles_context().start_process_style(style);
else get_styles_context().start_process_style(baseStyle);
if (style) get_styles_context().start_process_style(style);
else get_styles_context().start_process_style(baseStyle);
propertiesOut.apply_from(calc_paragraph_properties_content(instances));
}
@ -360,9 +365,9 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm)
int level = list_style_stack_.size()-1;
odf_reader::paragraph_format_properties paragraph_properties_;
odf_reader::paragraph_format_properties paragraph_properties_;
ApplyParagraphProperties (paragraph_style_name_, paragraph_properties_,odf_types::style_family::Paragraph);
ApplyParagraphProperties (paragraph_style_name_, paragraph_properties_);
ApplyListProperties (paragraph_properties_, level);//выравнивания листа накатим на свойства параграфа
paragraph_properties_.pptx_convert(pptx_context_);
@ -403,16 +408,9 @@ void pptx_text_context::Impl::write_rPr(std::wostream & strm)
if (paragraph_style_name_.empty() && span_style_name_.empty() && !(!hyperlink_hId.empty()) && base_style_name_.empty())
return;
odf_reader::text_format_properties_content text_properties_paragraph_;
ApplyTextProperties (paragraph_style_name_, text_properties_paragraph_,odf_types::style_family::Paragraph);
odf_reader::text_format_properties_content text_properties_span_;
ApplyTextProperties(span_style_name_, text_properties_span_,odf_types::style_family::Text);
odf_reader::text_format_properties_content text_properties_;
text_properties_.apply_from(text_properties_paragraph_);
text_properties_.apply_from(text_properties_span_);
ApplyTextProperties(span_style_name_, paragraph_style_name_, text_properties_);
get_styles_context().start();

View File

@ -84,10 +84,10 @@ public:
void serialize_shared_strings(std::wostream & strm);
void ApplyTextProperties (std::wstring style, odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type);
void ApplyParagraphProperties (std::wstring style, odf_reader::paragraph_format_properties & propertiesOut, odf_types::style_family::type Type);
void ApplyTextProperties (std::wstring style, std::wstring para_style, odf_reader::text_format_properties_content & propertiesOut);
void ApplyParagraphProperties (std::wstring style, odf_reader::paragraph_format_properties & propertiesOut);
void set_local_styles_container(odf_reader::styles_container* local_styles_);//это если стили объектов содержатся в другом документе
void set_local_styles_container (odf_reader::styles_container* local_styles_);//это если стили объектов содержатся в другом документе
bool is_drawing_context(){return in_draw;}
@ -237,48 +237,54 @@ void xlsx_text_context::Impl::end_hyperlink(std::wstring hId)
hyperlink_hId = hId;
}
void xlsx_text_context::Impl::ApplyParagraphProperties (std::wstring style, odf_reader::paragraph_format_properties & propertiesOut, odf_types::style_family::type Type)
void xlsx_text_context::Impl::ApplyParagraphProperties (std::wstring style, odf_reader::paragraph_format_properties & propertiesOut)
{
std::vector<const odf_reader::style_instance *> instances;
odf_reader::style_instance* defaultStyle = NULL;
odf_reader::style_instance* paraStyle = NULL;
if (local_styles_ptr_)
{
odf_reader::style_instance * defaultStyle = local_styles_ptr_->style_default_by_type(Type);
if (defaultStyle)instances.push_back(defaultStyle);
odf_reader::style_instance* styleInst = local_styles_ptr_->style_by_name(style, Type,false/*process_headers_footers_*/);
if(styleInst)instances.push_back(styleInst);
defaultStyle = local_styles_ptr_->style_default_by_type(odf_types::style_family::Paragraph);
paraStyle = local_styles_ptr_->style_by_name(style, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
}
else
{
odf_reader::style_instance * defaultStyle = styles_.style_default_by_type(Type);
if (defaultStyle)instances.push_back(defaultStyle);
odf_reader::style_instance* styleInst = styles_.style_by_name(style, Type,false/*process_headers_footers_*/);
if(styleInst)instances.push_back(styleInst);
defaultStyle = styles_.style_default_by_type(odf_types::style_family::Paragraph);
paraStyle = styles_.style_by_name(style, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
}
if (defaultStyle) instances.push_back(defaultStyle);
if (paraStyle) instances.push_back(paraStyle);
propertiesOut.apply_from(calc_paragraph_properties_content(instances));
}
void xlsx_text_context::Impl::ApplyTextProperties(std::wstring style, odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type)
void xlsx_text_context::Impl::ApplyTextProperties(std::wstring style, std::wstring para_style, odf_reader::text_format_properties_content & propertiesOut)
{
std::vector<const odf_reader::style_instance *> instances;
odf_reader::style_instance* defaultStyle = NULL;
odf_reader::style_instance* textStyle = NULL;
odf_reader::style_instance* paraStyle = NULL;
if (local_styles_ptr_)
{
odf_reader::style_instance * defaultStyle = local_styles_ptr_->style_default_by_type(Type);
if (defaultStyle)instances.push_back(defaultStyle);
odf_reader::style_instance* styleInst = local_styles_ptr_->style_by_name(style, Type,false/*process_headers_footers_*/);
if(styleInst)instances.push_back(styleInst);
defaultStyle = local_styles_ptr_->style_default_by_type(odf_types::style_family::Text);
paraStyle = local_styles_ptr_->style_by_name(para_style, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
textStyle = local_styles_ptr_->style_by_name(style, odf_types::style_family::Text, false/*process_headers_footers_*/);
}
else
{
odf_reader::style_instance * defaultStyle = styles_.style_default_by_type(Type);
if (defaultStyle)instances.push_back(defaultStyle);
odf_reader::style_instance* styleInst = styles_.style_by_name(style, Type,false/*process_headers_footers_*/);
if(styleInst)instances.push_back(styleInst);
defaultStyle = styles_.style_default_by_type(odf_types::style_family::Text);
paraStyle = styles_.style_by_name(para_style, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
textStyle = styles_.style_by_name(style, odf_types::style_family::Text, false/*process_headers_footers_*/);
}
if (defaultStyle) instances.push_back(defaultStyle);
if (paraStyle) instances.push_back(paraStyle);
if (textStyle) instances.push_back(textStyle);
propertiesOut.apply_from(calc_text_properties_content(instances));
}
@ -291,10 +297,10 @@ void xlsx_text_context::Impl::write_pPr (std::wostream & strm)
{
if (paragraph_style_name_.empty())return;
odf_reader::paragraph_format_properties paragraph_format_properties_;
odf_reader::paragraph_format_properties paragraph_format_properties_;
ApplyParagraphProperties (paragraph_style_name_, paragraph_format_properties_ , odf_types::style_family::Paragraph);
paragraph_format_properties_.xlsx_convert(strm, in_draw);
ApplyParagraphProperties (paragraph_style_name_, paragraph_format_properties_);
paragraph_format_properties_.xlsx_convert (strm, in_draw);
}
void xlsx_text_context::Impl::write_rPr(std::wostream & strm)
@ -303,20 +309,13 @@ void xlsx_text_context::Impl::write_rPr(std::wostream & strm)
&& !(!hyperlink_hId.empty() && in_draw)
&& !(text_properties_cell_ && in_cell_content))return;
odf_reader::text_format_properties_content text_properties_paragraph_;
odf_reader::text_format_properties_content text_properties_span_;
ApplyTextProperties (paragraph_style_name_, text_properties_paragraph_ , odf_types::style_family::Paragraph);
ApplyTextProperties (span_style_name_, text_properties_span_ , odf_types::style_family::Text);
odf_reader::text_format_properties_content text_properties_;
if (in_cell_content && text_properties_cell_)
{
text_properties_.apply_from(*text_properties_cell_);
}
text_properties_.apply_from(text_properties_paragraph_);
text_properties_.apply_from(text_properties_span_);
}
ApplyTextProperties (span_style_name_, paragraph_style_name_, text_properties_);
_CP_OPT(double) dValFontSize;
if (text_properties_.fo_font_size_)

View File

@ -41,22 +41,22 @@ std::wostream & operator << (std::wostream & _Wostream, const presentation_class
std::wstring res = L"";
switch(_Val.get_type())
{
case presentation_class::title: _Wostream << L"title" ; break;
case presentation_class::subtitle: _Wostream << L"subtitle" ; break;
case presentation_class::graphic: _Wostream << L"graphic" ; break;
case presentation_class::object: _Wostream << L"object" ; break;
case presentation_class::chart: _Wostream << L"chart" ; break;
case presentation_class::table: _Wostream << L"table" ; break;
case presentation_class::orgchart: _Wostream << L"orgchart" ; break;
case presentation_class::header: _Wostream << L"header" ; break;
case presentation_class::footer: _Wostream << L"footer" ; break;
case presentation_class::date_time: _Wostream << L"date_time" ; break;
case presentation_class::page_number: _Wostream << L"page_number" ; break;
case presentation_class::page: _Wostream << L"page" ; break;
case presentation_class::notes: _Wostream << L"notes" ; break;
case presentation_class::handout: _Wostream << L"handout" ; break;
case presentation_class::outline: _Wostream << L"outline" ; break;
case presentation_class::text: _Wostream << L"text" ; break;
case presentation_class::title: _Wostream << L"title"; break;
case presentation_class::subtitle: _Wostream << L"subtitle"; break;
case presentation_class::graphic: _Wostream << L"graphic"; break;
case presentation_class::object: _Wostream << L"object"; break;
case presentation_class::chart: _Wostream << L"chart"; break;
case presentation_class::table: _Wostream << L"table"; break;
case presentation_class::orgchart: _Wostream << L"orgchart"; break;
case presentation_class::header: _Wostream << L"header"; break;
case presentation_class::footer: _Wostream << L"footer"; break;
case presentation_class::date_time: _Wostream << L"date-time"; break;
case presentation_class::page_number: _Wostream << L"page-number";break;
case presentation_class::page: _Wostream << L"page"; break;
case presentation_class::notes: _Wostream << L"notes"; break;
case presentation_class::handout: _Wostream << L"handout"; break;
case presentation_class::outline: _Wostream << L"outline"; break;
case presentation_class::text: _Wostream << L"text"; break;
}
return _Wostream;
}
@ -65,41 +65,24 @@ presentation_class presentation_class::parse(const std::wstring & Str)
std::wstring tmp = Str;
boost::algorithm::to_lower(tmp);
if (tmp == L"page")
return presentation_class( page );
else if (tmp == L"title")
return presentation_class( title);
else if (tmp == L"outline")
return presentation_class( outline );
else if (tmp == L"subtitle")
return presentation_class( subtitle);
else if (tmp == L"text")
return presentation_class( text);
else if (tmp == L"graphic")
return presentation_class( graphic );
else if (tmp == L"object")
return presentation_class( object );
else if (tmp == L"chart")
return presentation_class( chart );
else if (tmp == L"table")
return presentation_class( table );
else if (tmp == L"orgchart")
return presentation_class( orgchart );
else if (tmp == L"notes")
return presentation_class( notes );
else if (tmp == L"handout")
return presentation_class( handout );
else if (tmp == L"header")
return presentation_class( header );
else if (tmp == L"footer")
return presentation_class( footer );
else if (tmp == L"date-time")
return presentation_class( date_time );
else if (tmp == L"page-number")
return presentation_class( page_number );
else
if (tmp == L"page") return presentation_class( page );
else if (tmp == L"title") return presentation_class( title);
else if (tmp == L"outline") return presentation_class( outline );
else if (tmp == L"subtitle") return presentation_class( subtitle);
else if (tmp == L"text") return presentation_class( text);
else if (tmp == L"graphic") return presentation_class( graphic );
else if (tmp == L"object") return presentation_class( object );
else if (tmp == L"chart") return presentation_class( chart );
else if (tmp == L"table") return presentation_class( table );
else if (tmp == L"orgchart") return presentation_class( orgchart );
else if (tmp == L"notes") return presentation_class( notes );
else if (tmp == L"handout") return presentation_class( handout );
else if (tmp == L"header") return presentation_class( header );
else if (tmp == L"footer") return presentation_class( footer );
else if (tmp == L"date-time") return presentation_class( date_time );
else if (tmp == L"page-number") return presentation_class( page_number );
else
{
BOOST_THROW_EXCEPTION( errors::invalid_attribute() );
return presentation_class( page );
}
}

View File

@ -453,6 +453,7 @@ void draw_enhanced_geometry_attlist::add_attributes( const xml::attributes_wc_pt
CP_APPLY_ATTR(L"draw:modifiers" , draw_modifiers_);
CP_APPLY_ATTR(L"draw:text-path" , draw_text_path_);
CP_APPLY_ATTR(L"draw:enhanced-path" , draw_enhanced_path_);
CP_APPLY_ATTR(L"drawooo:enhanced-path" , drawooo_enhanced_path_);
CP_APPLY_ATTR(L"drawooo:sub-view-size" , drawooo_sub_view_size_);
}
// draw:enhanced_geometry
@ -485,6 +486,9 @@ void draw_enhanced_geometry::add_child_element( xml::sax * Reader, const std::ws
}
void draw_enhanced_geometry::find_draw_type_oox()
{
word_art_ = false;
bOoxType_ = false;
if (draw_enhanced_geometry_attlist_.draw_text_path_ &&
*draw_enhanced_geometry_attlist_.draw_text_path_ == true)
{
@ -501,7 +505,7 @@ void draw_enhanced_geometry::find_draw_type_oox()
{
int count = sizeof(_OO_OOX_wordart) / sizeof(_shape_converter);
for (long i=0; i< count; i++)
for (int i = 0; i < count; i++)
{
if (_OO_OOX_wordart[i].odf_reader == odf_type)
{
@ -518,7 +522,7 @@ void draw_enhanced_geometry::find_draw_type_oox()
if (pos < 0)
{
for (long i=0; i< count; i++)
for (long i = 0; i< count; i++)
{
if (_OO_OOX_custom_shapes[i].odf_reader == odf_type)
{
@ -529,8 +533,9 @@ void draw_enhanced_geometry::find_draw_type_oox()
}
else
{
bOoxType_ = true;
std::wstring oox_type = odf_type.substr(pos + 6);
for (long i=0; i< count; i++)
for (long i = 0; i< count; i++)
{
if (_OO_OOX_custom_shapes[i].oox == oox_type)
{
@ -547,18 +552,18 @@ void draw_enhanced_geometry::find_draw_type_oox()
}
std::wstringstream str;
BOOST_FOREACH(const office_element_ptr & parElement, draw_handle_)
for (size_t i = 0; i < draw_handle_.size(); i++)
{
draw_handle * handle = dynamic_cast<draw_handle *>(parElement.get());
int min = -1;
int max = -1;
draw_handle * handle = dynamic_cast<draw_handle *>(draw_handle_[i].get());
if (!handle) continue;
int min = -1, max = -1;
try
{
min = parsing(handle->draw_handle_attlist_.draw_handle_range_y_minimum_);//пока статик .. и выдается только цыфровое значение
if (min<0)min = parsing(handle->draw_handle_attlist_.draw_handle_range_x_minimum_);
if (min<0)min = parsing(handle->draw_handle_attlist_.draw_handle_radius_range_minimum_);
if (min < 0) min = parsing(handle->draw_handle_attlist_.draw_handle_range_x_minimum_);
if (min < 0) min = parsing(handle->draw_handle_attlist_.draw_handle_radius_range_minimum_);
}
catch(...)
{
@ -574,7 +579,7 @@ void draw_enhanced_geometry::find_draw_type_oox()
catch(...)
{
}
draw_handle_geometry elm={min, max};
draw_handle_geometry elm = {min, max};
draw_handle_geometry_.push_back(elm);
}
}

View File

@ -437,6 +437,7 @@ public:
_CP_OPT(std::wstring) draw_modifiers_;
_CP_OPT(bool) draw_text_path_;
_CP_OPT(std::wstring) draw_enhanced_path_;
_CP_OPT(std::wstring) drawooo_enhanced_path_;
_CP_OPT(std::wstring) drawooo_sub_view_size_;
};
/////////////////////////////////////////////////////////////////////////
@ -464,7 +465,9 @@ public:
_CP_OPT(int) sub_type_;
_CP_OPT(int) draw_type_oox_index_;
_CP_OPT(std::wstring) svg_viewbox_;
bool word_art_;
bool bOoxType_;
typedef std::pair<std::wstring,std::wstring> pair_string_value;

View File

@ -253,13 +253,19 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
set_shape = true;
}
if (sub_type_)
{
shape->sub_type_ = sub_type_.get();
set_shape = true;
}
std::wstring odf_path;
if (draw_enhanced_geometry_attlist_.drawooo_enhanced_path_)
odf_path = draw_enhanced_geometry_attlist_.drawooo_enhanced_path_.get();
else if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
odf_path = draw_enhanced_geometry_attlist_.draw_enhanced_path_.get();
if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
if (!odf_path.empty())
{
std::vector<::svg_path::_polyline> o_Polyline;
@ -267,7 +273,7 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
try
{
res = ::svg_path::parseSvgD(o_Polyline, draw_enhanced_geometry_attlist_.draw_enhanced_path_.get(), true);
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true);
}
catch(...)
{
@ -316,8 +322,8 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
{
if (draw_handle_geometry_[0].min < draw_handle_geometry_[0].max)
{
shape->additional_.push_back(_property(L"draw-modifiers-min",draw_handle_geometry_[0].min));
shape->additional_.push_back(_property(L"draw-modifiers-max",draw_handle_geometry_[0].max));
shape->additional_.push_back(_property(L"draw-modifiers-min", draw_handle_geometry_[0].min));
shape->additional_.push_back(_property(L"draw-modifiers-max", draw_handle_geometry_[0].max));
}
}
}
@ -326,7 +332,6 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
{
shape->bad_shape_ = true;
}
}
}
}

View File

@ -458,7 +458,7 @@ void paragraph_format_properties::pptx_convert(oox::pptx_conversion_context & Co
{
CP_XML_NODE(L"a:spcBef")
{
if (fo_margin_bottom_->get_type() == length_or_percent::Length)
if (fo_margin_top_->get_type() == length_or_percent::Length)
{
std::wstring w_before = pptx_process_margin(fo_margin_top_, length::pt, 100.0);
CP_XML_NODE(L"a:spcPts")

View File

@ -67,30 +67,41 @@ public:
odf_type_name =L"ooxml-snip2DiagRect";
modifiers = L"0 16667";
enhanced_path = L"M ?f9 ?f2 L ?f13 ?f2 ?f1 ?f12 ?f1 ?f11 ?f10 ?f3 ?f12 ?f3 ?f0 ?f14 ?f0 ?f9 Z N";
text_areas = L"?f17 ?f17 ?f18 ?f19";
view_box = L"0 0 21600 21600";
enhanced_path = L"M ?f3 0 L ?f7 0 ?f14 ?f6 ?f14 ?f5 ?f4 ?f17 ?f6 ?f17 0 ?f8 0 ?f3 Z N";
text_areas = L"?f11 ?f11 ?f12 ?f13";
view_box = L"0 0 0 0";
add(L"f0", L"left");
add(L"f1", L"right");
add(L"f2", L"top");
add(L"f3", L"bottom");
add(L"f4", L"?f3 - ?f2");
add(L"f5", L"?f1 - ?f0");
add(L"f6", L"min(?f5, ?f4)");
add(L"f7", L"$0");
add(L"f8", L"$1");
add(L"f9", L"?f6 * ?f7 / 100000");
add(L"f10", L"?f1 - ?f9");
add(L"f11", L"?f3 - ?f9");
add(L"f12", L"?f6 * ?f8 / 100000");
add(L"f13", L"?f1 - ?f12");
add(L"f14", L"?f3 - ?f12");
add(L"f15", L"?f9 - ?f12");
add(L"f16", L"if(?f15, ?f9, ?f12)");
add(L"f17", L"?f16 / 2");
add(L"f18", L"?f1 - ?f17");
add(L"f19", L"?f3 - ?f17");
add(L"f0", L"if(0-$0 ,0,if(50000-$0 ,$0 ,50000))");
add(L"f1", L"if(0-$1 ,0,if(50000-$1 ,$1 ,50000))");
add(L"f2", L"min(logwidth,logheight)");
add(L"f3", L"?f2 *?f0 /100000");
add(L"f4", L"logwidth+0-?f3 ");
add(L"f5", L"logheight+0-?f3 ");
add(L"f6", L"?f2 *?f1 /100000");
add(L"f7", L"logwidth+0-?f6 ");
add(L"f8", L"logheight+0-?f6 ");
add(L"f9", L"?f3 +0-?f6 ");
add(L"f10", L"if(?f9 ,?f3 ,?f6 )");
add(L"f11", L"?f10 *1/2");
add(L"f12", L"logwidth+0-?f11 ");
add(L"f13", L"logheight+0-?f11 ");
add(L"f14", L"logwidth");
add(L"f15", L"logheight/2");
add(L"f16", L"logwidth/2");
add(L"f17", L"logheight");
_handle h;
h.position = L"?f3 0";
h.x_maximum= L"50000";
h.x_minimum= L"0";
handles.push_back(h);
h.position = L"?f7 0";
h.x_maximum= L"50000";
h.x_minimum= L"0";
handles.push_back(h);
}
};
class oox_shape_snip2SameRect : public oox_shape

View File

@ -262,6 +262,7 @@ void odf_conversion_context::process_settings(_object & object, bool isRoot)
void odf_conversion_context::process_styles(_object & object, bool isRoot)
{
create_element(L"office", L"styles", object.styles, this, true);//общие стили
object.style_context->process_office_styles(object.styles.back());
page_layout_context()->process_office_styles(object.styles.back());
@ -288,7 +289,15 @@ office_element_ptr odf_conversion_context::start_tabs()
create_element(L"style", L"tab-stops", temporary_.elm, this,true);
return temporary_.elm;
}
std::wstring odf_conversion_context::add_image(const std::wstring & image_file_name)
{
if (image_file_name.empty()) return L"";
std::wstring odf_ref_name ;
mediaitems()->add_or_find(image_file_name,_mediaitems::typeImage, odf_ref_name);
return odf_ref_name;
}
void odf_conversion_context::add_tab(_CP_OPT(int) type, _CP_OPT(length) _length, _CP_OPT(int) leader)
{
if (!temporary_.elm) return;

View File

@ -95,7 +95,7 @@ public:
virtual void start_text_context() = 0;
virtual void end_text_context() = 0;
virtual void start_image(const std::wstring & image_file_name) = 0;
std::wstring add_image(const std::wstring & image_file_name);
virtual odf_style_context * styles_context();

View File

@ -76,7 +76,7 @@ struct odf_group_state
scale_cx = scale_cy = 1.;
flipH = flipV = false;
elm = elm_;
elm = elm_;
level = level_;
prev_group = prev;
@ -185,19 +185,19 @@ struct odf_drawing_state
presentation_class_ = boost::none;
presentation_placeholder_ = boost::none;
rotateAngle = boost::none;
rotateAngle_ = boost::none;
path_ = L"";
view_box_ = L"";
path_last_command_ = L"";
oox_shape_preset = -1;
oox_shape_preset_ = -1;
oox_shape_.reset();
in_group = false;
text_box_tableframe = false;
in_group_ = false;
text_box_tableframe_= false;
flipH = flipV = false;
flipH_ = flipV_ = false;
}
std::vector<odf_element_state> elements_;
@ -207,28 +207,29 @@ struct odf_drawing_state
_CP_OPT(length) svg_height_;
_CP_OPT(length) svg_width_;
bool flipH_;
bool flipV_;
std::wstring name_;
std::wstring description_;
int z_order_;
bool hidden_;
_CP_OPT(double) rotateAngle;
_CP_OPT(double) rotateAngle_;
_CP_OPT(unsigned int) fill_color_;
_CP_OPT(presentation_class) presentation_class_;
_CP_OPT(std::wstring) presentation_placeholder_;
bool flipH;
bool flipV;
std::wstring path_;
std::wstring view_box_;
std::wstring path_last_command_;
oox_shape_ptr oox_shape_;
///////////////////////
int oox_shape_preset;
bool in_group;
bool text_box_tableframe;
int oox_shape_preset_;
bool in_group_;
bool text_box_tableframe_;
};
class odf_drawing_context::Impl
@ -316,6 +317,11 @@ void odf_drawing_context::set_presentation (bool bMaster)
impl_->is_presentation_ = bMaster;
}
_CP_OPT(bool) odf_drawing_context::get_presentation ()
{
return impl_->is_presentation_;
}
void odf_drawing_context::set_footer_state(bool Val)
{
impl_->is_footer_ = Val;
@ -330,6 +336,7 @@ void odf_drawing_context::set_background_state(bool Val)
impl_->is_background_ = Val;
impl_->current_graphic_properties = new graphic_format_properties();
start_area_properties();
}
void odf_drawing_context::check_anchor()
@ -461,12 +468,13 @@ void odf_drawing_context::start_drawing()
//else
if (impl_->current_level_.size() > 0)
{
impl_->current_drawing_state_.in_group = true;
impl_->current_drawing_state_.in_group_ = true;
}
}
void odf_drawing_context::end_drawing_background(odf_types::common_draw_fill_attlist & common_draw_attlist)
{
end_area_properties();
if (impl_->current_drawing_state_.elements_.empty() == false) return;
if (!impl_->is_background_ || !impl_->current_graphic_properties) return;
@ -485,19 +493,23 @@ void odf_drawing_context::end_drawing()
draw_base* draw = dynamic_cast<draw_base*>(impl_->current_drawing_state_.elements_[0].elm.get());
if (draw)
{
if (impl_->is_presentation_)
if (impl_->current_drawing_state_.presentation_class_ || impl_->current_drawing_state_.presentation_placeholder_)
{
_CP_OPT(std::wstring) draw_layer;
if (impl_->is_presentation_.get() == true)
{//master
if (impl_->current_drawing_state_.presentation_class_)
draw_layer = L"backgroundobjects";
else draw_layer = L"layout";
draw_layer = L"backgroundobjects";
if (!impl_->current_drawing_state_.presentation_class_)
impl_->current_drawing_state_.presentation_class_ = presentation_class::outline;
draw->common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_.presentation_user_transformed_ = true;
draw->common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_.presentation_placeholder_ = false;
}
else
{//slide
if (impl_->current_drawing_state_.presentation_class_)
draw_layer = L"layout";
draw_layer = L"layout";
}
draw->common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_.presentation_class_ = impl_->current_drawing_state_.presentation_class_;
draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_layer_ = draw_layer;
@ -509,20 +521,20 @@ void odf_drawing_context::end_drawing()
std::wstring strTransform;
if (impl_->current_drawing_state_.in_group && impl_->current_group_)
if (impl_->current_drawing_state_.in_group_ && impl_->current_group_)
{
double rotate = impl_->current_group_->rotate;
if (impl_->current_drawing_state_.rotateAngle )
rotate += *impl_->current_drawing_state_.rotateAngle;
if (impl_->current_drawing_state_.rotateAngle_)
rotate += *impl_->current_drawing_state_.rotateAngle_;
if (fabs(rotate)>0.001)impl_->current_drawing_state_.rotateAngle = rotate;
if (fabs(rotate)>0.001)impl_->current_drawing_state_.rotateAngle_ = rotate;
}
double x = impl_->current_drawing_state_.svg_x_ ? impl_->current_drawing_state_.svg_x_->get_value() : 0;
double y = impl_->current_drawing_state_.svg_y_ ? impl_->current_drawing_state_.svg_y_->get_value() : 0;
if (impl_->current_drawing_state_.rotateAngle)
if (impl_->current_drawing_state_.rotateAngle_)
{
if (impl_->current_drawing_state_.in_group)
if (impl_->current_drawing_state_.in_group_)
{
if (impl_->current_drawing_state_.svg_width_ && impl_->current_drawing_state_.svg_height_)
{
@ -532,7 +544,7 @@ void odf_drawing_context::end_drawing()
}
}
strTransform += std::wstring(L"rotate(") + boost::lexical_cast<std::wstring>(impl_->current_drawing_state_.rotateAngle.get()) + std::wstring(L")");
strTransform += std::wstring(L"rotate(") + boost::lexical_cast<std::wstring>(impl_->current_drawing_state_.rotateAngle_.get()) + std::wstring(L")");
//так как вращения все в мс относительно центра фигуры, а не от начала координат - убираем смещение
if (impl_->current_drawing_state_.svg_x_ && impl_->current_drawing_state_.svg_y_)
@ -576,14 +588,14 @@ void odf_drawing_context::end_drawing()
placeholder->svg_height_ = impl_->current_drawing_state_.svg_height_;
placeholder->svg_width_ = impl_->current_drawing_state_.svg_width_;
}
if (impl_->current_drawing_state_.in_group)
if (impl_->current_drawing_state_.in_group_)
{
odf_group_state_ptr gr = impl_->current_group_;
while(gr)
{
impl_->current_drawing_state_.flipH = impl_->current_drawing_state_.flipH ^ gr->flipH;
impl_->current_drawing_state_.flipV = impl_->current_drawing_state_.flipV ^ gr->flipV;
impl_->current_drawing_state_.flipH_ = impl_->current_drawing_state_.flipH_ ^ gr->flipH;
impl_->current_drawing_state_.flipV_ = impl_->current_drawing_state_.flipV_ ^ gr->flipV;
gr = gr->prev_group;
}
@ -594,8 +606,8 @@ void odf_drawing_context::end_drawing()
draw_enhanced_geometry* enhan = dynamic_cast<draw_enhanced_geometry*>(custom->draw_enhanced_geometry_.get());
if(enhan)
{
if (impl_->current_drawing_state_.flipV) enhan->draw_enhanced_geometry_attlist_.draw_mirror_vertical_ = true;
if (impl_->current_drawing_state_.flipH) enhan->draw_enhanced_geometry_attlist_.draw_mirror_horizontal_ = true;
if (impl_->current_drawing_state_.flipV_) enhan->draw_enhanced_geometry_attlist_.draw_mirror_vertical_ = true;
if (impl_->current_drawing_state_.flipH_) enhan->draw_enhanced_geometry_attlist_.draw_mirror_horizontal_ = true;
}
}else
{
@ -615,7 +627,7 @@ void odf_drawing_context::end_drawing()
impl_->current_graphic_properties->common_horizontal_margin_attlist_.fo_margin_right_ = impl_->anchor_settings_.fo_margin_right_;
impl_->current_graphic_properties->common_vertical_margin_attlist_.fo_margin_bottom_ = impl_->anchor_settings_.fo_margin_bottom_;
if (draw && !impl_->current_drawing_state_.in_group)
if (draw && !impl_->current_drawing_state_.in_group_)
draw->common_draw_attlists_.shape_with_text_and_styles_.common_text_anchor_attlist_.type_ = impl_->anchor_settings_.anchor_type_;
impl_->current_graphic_properties->style_wrap_ = impl_->anchor_settings_.style_wrap_;
@ -695,7 +707,10 @@ void odf_drawing_context::Impl::create_draw_base(int type)
draw_base* draw = dynamic_cast<draw_base*>(draw_elm.get());
if (draw == NULL)return;
//////////
styles_context_->create_style(L"", style_family::Graphic, true, false, -1);
if (is_presentation_ && current_drawing_state_.presentation_class_)
styles_context_->create_style(L"", style_family::Presentation, true, false, -1);
else
styles_context_->create_style(L"", style_family::Graphic, true, false, -1);
office_element_ptr & style_shape_elm = styles_context_->last_state()->get_office_element();
std::wstring style_name;
@ -707,7 +722,10 @@ void odf_drawing_context::Impl::create_draw_base(int type)
current_graphic_properties = style_->content_.get_graphic_properties();
}
draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_ = style_name;
if (is_presentation_ && current_drawing_state_.presentation_class_)
draw->common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_.presentation_style_name_ = style_name;
else
draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_ = style_name;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int level = current_level_.size();
@ -728,7 +746,7 @@ void odf_drawing_context::Impl::create_draw_base(int type)
void odf_drawing_context::start_shape(int type)
{
impl_->current_drawing_state_.oox_shape_preset = type;
impl_->current_drawing_state_.oox_shape_preset_ = type;
if (type < sizeof(Shape_Types_Mapping)/sizeof(_sh_typ))
{
@ -756,12 +774,21 @@ void odf_drawing_context::start_shape(int type)
}
}
bool odf_drawing_context::change_text_box_2_wordart()
bool odf_drawing_context::is_wordart()
{
if (impl_->current_drawing_state_.oox_shape_preset > 2000 && impl_->current_drawing_state_.oox_shape_preset < 3000)
if (impl_->current_drawing_state_.oox_shape_preset_ > 2000 && impl_->current_drawing_state_.oox_shape_preset_ < 3000)
return true;
if (impl_->current_drawing_state_.text_box_tableframe) return false;
return false;
}
bool odf_drawing_context::change_text_box_2_wordart()
{
if (impl_->current_drawing_state_.oox_shape_preset_ > 2000 && impl_->current_drawing_state_.oox_shape_preset_ < 3000)
return true;
if (impl_->current_drawing_state_.presentation_class_) return false;
if (impl_->current_drawing_state_.text_box_tableframe_) return false;
if (impl_->current_drawing_state_.elements_.empty()) return false;
draw_text_box* t = dynamic_cast<draw_text_box*>(impl_->current_drawing_state_.elements_.back().elm.get());
@ -799,7 +826,7 @@ bool odf_drawing_context::change_text_box_2_wordart()
impl_->current_drawing_state_.elements_.erase(impl_->current_drawing_state_.elements_.end() - 2, impl_->current_drawing_state_.elements_.end());
impl_->current_drawing_state_.elements_.push_back( state);
impl_->current_drawing_state_.oox_shape_preset = 2031;//plain text
impl_->current_drawing_state_.oox_shape_preset_ = 2031;//plain text
if (sz == 2) impl_->root_element_ = draw_elm;
return true;
@ -810,8 +837,8 @@ void odf_drawing_context::end_shape()
if (impl_->current_drawing_state_.elements_.empty())
return;
if (impl_->current_drawing_state_.oox_shape_preset == 2000) return end_text_box();
if (impl_->current_drawing_state_.oox_shape_preset == 3000) return end_image();
if (impl_->current_drawing_state_.oox_shape_preset_ == 2000) return end_text_box();
if (impl_->current_drawing_state_.oox_shape_preset_ == 3000) return end_image();
//вторичные, вычисляемые свойства шейпов
if (isLineShape())
@ -848,7 +875,7 @@ void odf_drawing_context::end_shape()
impl_->current_drawing_state_.svg_x_ = boost::none;
impl_->current_drawing_state_.svg_y_ = boost::none;
if (impl_->current_drawing_state_.flipV)
if (impl_->current_drawing_state_.flipV_)
{
_CP_OPT(length) tmp;
@ -856,7 +883,7 @@ void odf_drawing_context::end_shape()
line->draw_line_attlist_.svg_y1_ = line->draw_line_attlist_.svg_y2_;
line->draw_line_attlist_.svg_y2_ = tmp;
}
if (impl_->current_drawing_state_.flipH)
if (impl_->current_drawing_state_.flipH_)
{
_CP_OPT(length) tmp;
@ -881,11 +908,11 @@ void odf_drawing_context::end_shape()
std::wstring sub_type;
bool text_shape = false;
if (impl_->current_drawing_state_.oox_shape_preset < sizeof(Shape_Types_Mapping)/sizeof(_sh_typ))
if (impl_->current_drawing_state_.oox_shape_preset_ < sizeof(Shape_Types_Mapping)/sizeof(_sh_typ))
{
sub_type = Shape_Types_Mapping[impl_->current_drawing_state_.oox_shape_preset].first;
sub_type = Shape_Types_Mapping[impl_->current_drawing_state_.oox_shape_preset_].first;
}
else if (impl_->current_drawing_state_.oox_shape_preset > 2000 && impl_->current_drawing_state_.oox_shape_preset < 3000)// 3000 - все равно сюда не попадет
else if (impl_->current_drawing_state_.oox_shape_preset_ > 2000 && impl_->current_drawing_state_.oox_shape_preset_ < 3000)// 3000 - все равно сюда не попадет
{
text_shape = true;
}
@ -925,7 +952,7 @@ void odf_drawing_context::end_shape()
}
else
{
oox_shape_ptr shape_define = oox_shape::create(impl_->current_drawing_state_.oox_shape_preset);
oox_shape_ptr shape_define = oox_shape::create(impl_->current_drawing_state_.oox_shape_preset_);
if (!shape_define) shape_define = impl_->current_drawing_state_.oox_shape_;
@ -1001,7 +1028,7 @@ bool odf_drawing_context::isLineShape()
draw_path* path = dynamic_cast<draw_path*>(impl_->current_level_.back().get());
if (path) return true;
switch(impl_->current_drawing_state_.oox_shape_preset)
switch(impl_->current_drawing_state_.oox_shape_preset_)
{
case 20: //SimpleTypes::shapetypeBentConnector2:
case 21: //SimpleTypes::shapetypeBentConnector3:
@ -1159,22 +1186,26 @@ void odf_drawing_context::set_shadow(int type, std::wstring hexColor, _CP_OPT(do
void odf_drawing_context::set_placeholder_id (std::wstring val)
{
if (!impl_->is_presentation_) return;
impl_->current_drawing_state_.presentation_placeholder_ = val;
}
void odf_drawing_context::set_placeholder_type (int val)
{
if (!impl_->is_presentation_) return;
switch(val)
{
case 0: impl_->current_drawing_state_.presentation_class_ = presentation_class::text; break;
case 1: impl_->current_drawing_state_.presentation_class_ = presentation_class::chart; break;
case 0: impl_->current_drawing_state_.presentation_class_ = presentation_class::outline; break;
case 1: impl_->current_drawing_state_.presentation_class_ = presentation_class::chart; break;
case 2: impl_->current_drawing_state_.presentation_class_ = presentation_class::graphic; break;
case 3: impl_->current_drawing_state_.presentation_class_ = presentation_class::title; break;
case 4: impl_->current_drawing_state_.presentation_class_ = presentation_class::graphic; break;
case 5: impl_->current_drawing_state_.presentation_class_ = presentation_class::date_time; break;
case 6: impl_->current_drawing_state_.presentation_class_ = presentation_class::footer; break;
case 7: impl_->current_drawing_state_.presentation_class_ = presentation_class::header; break;
case 8: impl_->current_drawing_state_.presentation_class_ = presentation_class::object; break;
case 9: impl_->current_drawing_state_.presentation_class_ = presentation_class::object; break;
case 6: impl_->current_drawing_state_.presentation_class_ = presentation_class::footer; break;
case 7: impl_->current_drawing_state_.presentation_class_ = presentation_class::header; break;
case 8: impl_->current_drawing_state_.presentation_class_ = presentation_class::object; break;
case 9: impl_->current_drawing_state_.presentation_class_ = presentation_class::object; break;
case 10: impl_->current_drawing_state_.presentation_class_ = presentation_class::graphic; break;
case 11: impl_->current_drawing_state_.presentation_class_ = presentation_class::graphic; break;
case 12: impl_->current_drawing_state_.presentation_class_ = presentation_class::page_number;break;
@ -1182,7 +1213,7 @@ void odf_drawing_context::set_placeholder_type (int val)
case 14: impl_->current_drawing_state_.presentation_class_ = presentation_class::table; break;
case 15: impl_->current_drawing_state_.presentation_class_ = presentation_class::title; break;
default:
impl_->current_drawing_state_.presentation_class_ = presentation_class::text; break;
impl_->current_drawing_state_.presentation_class_ = presentation_class::outline; break;
}
//todooo draw_layer for master for sldnum, datetime ...
}
@ -1229,7 +1260,8 @@ _CP_OPT(odf_types::color) odf_drawing_context::get_line_color()
}
void odf_drawing_context::set_solid_fill(std::wstring hexColor)
{
if (!impl_->current_graphic_properties)return;
if (!impl_->current_graphic_properties) return;
if (hexColor.empty()) return;
int res = 0;
if ((res = hexColor.find(L"#")) < 0) hexColor = std::wstring(L"#") + hexColor;
@ -1486,7 +1518,7 @@ void odf_drawing_context::set_viewBox (double W, double H)
}
void odf_drawing_context::set_flip_H(bool bVal)
{
impl_->current_drawing_state_.flipH = bVal;
impl_->current_drawing_state_.flipH_ = bVal;
if (impl_->current_graphic_properties == NULL) return;
if (bVal == false)return;
@ -1498,7 +1530,7 @@ void odf_drawing_context::set_flip_H(bool bVal)
}
void odf_drawing_context::set_flip_V(bool bVal)
{
impl_->current_drawing_state_.flipV = bVal;
impl_->current_drawing_state_.flipV_ = bVal;
if (impl_->current_graphic_properties == NULL) return;
if (bVal == false)return;
@ -1513,7 +1545,7 @@ void odf_drawing_context::set_rotate(double dVal)
{
if (dVal > 180) dVal = dVal - 360;
double dRotate = dVal / 180. * 3.14159265358979323846;
impl_->current_drawing_state_.rotateAngle = dRotate;
impl_->current_drawing_state_.rotateAngle_ = dRotate;
}
void odf_drawing_context::set_drawings_rect(_CP_OPT(double) x_pt, _CP_OPT(double) y_pt, _CP_OPT(double) width_pt, _CP_OPT(double) height_pt)// "- 1" не задано
@ -1720,8 +1752,8 @@ void odf_drawing_context::set_group_position(_CP_OPT(double) x, _CP_OPT(double)
impl_->current_group_->x = *change_x ;
impl_->current_group_->y = *change_y ;
impl_->current_group_->shift_x = (*x - *change_x) ;
impl_->current_group_->shift_y = (*y - *change_y) ;
impl_->current_group_->shift_x = (*x /impl_->current_group_->scale_cx - *change_x) ;
impl_->current_group_->shift_y = (*y /impl_->current_group_->scale_cy - *change_y) ;
}
void odf_drawing_context::set_group_size( _CP_OPT(double) cx, _CP_OPT(double) cy, _CP_OPT(double) change_cx, _CP_OPT(double) change_cy)
@ -1742,7 +1774,7 @@ void odf_drawing_context::set_group_flip_V(bool bVal)
{
if ( impl_->group_list_.empty() )return;
impl_->current_group_->flipV= bVal;
impl_->current_group_->flipV = bVal;
}
void odf_drawing_context::set_group_z_order(int Val)
{
@ -1767,7 +1799,7 @@ void odf_drawing_context::set_group_flip_H(bool bVal)
{
if ( impl_->group_list_.empty() )return;
impl_->current_group_->flipH= bVal;
impl_->current_group_->flipH = bVal;
}
void odf_drawing_context::set_group_rotate(int iVal)
@ -1794,14 +1826,14 @@ void odf_drawing_context::set_position_line(_CP_OPT(double) & x_pt, _CP_OPT(doub
draw_line* line = dynamic_cast<draw_line*>(impl_->current_level_.back().get());
if (line == NULL) return;
if (impl_->current_drawing_state_.in_group && impl_->current_group_ && x_pt)
if (impl_->current_drawing_state_.in_group_ && impl_->current_group_ && x_pt)
x_pt = *x_pt * impl_->current_group_->scale_cx + impl_->current_group_->shift_x ;
// + (impl_->current_group_->flipH ? (impl_->current_group_->cx - 2 * x_pt): 0);
if (x_pt && !line->draw_line_attlist_.svg_x1_)
line->draw_line_attlist_.svg_x1_ = length(length(*x_pt,length::pt).get_value_unit(length::cm),length::cm);
if (impl_->current_drawing_state_.in_group && impl_->current_group_ && y_pt)
if (impl_->current_drawing_state_.in_group_ && impl_->current_group_ && y_pt)
y_pt = *y_pt * impl_->current_group_->scale_cy + impl_->current_group_->shift_y;
//+ (impl_->current_group_->flipV ? (impl_->current_group_->cy - 2 * y_pt): 0);
@ -1809,13 +1841,13 @@ void odf_drawing_context::set_position_line(_CP_OPT(double) & x_pt, _CP_OPT(doub
line->draw_line_attlist_.svg_y1_ = length(length(*y_pt,length::pt).get_value_unit(length::cm),length::cm);
///////////////////////////////////////
if (impl_->current_drawing_state_.in_group && impl_->current_group_ && x2_pt)
if (impl_->current_drawing_state_.in_group_ && impl_->current_group_ && x2_pt)
x2_pt = *x2_pt * impl_->current_group_->scale_cx + impl_->current_group_->shift_x ;
// + (impl_->current_group_->flipH ? (impl_->current_group_->cx - 2 * x_pt): 0);
if (x2_pt && !line->draw_line_attlist_.svg_x2_) line->draw_line_attlist_.svg_x2_ = length(length(*x2_pt,length::pt).get_value_unit(length::cm),length::cm);
if (impl_->current_drawing_state_.in_group && impl_->current_group_ && y2_pt)
if (impl_->current_drawing_state_.in_group_ && impl_->current_group_ && y2_pt)
y2_pt = *y2_pt * impl_->current_group_->scale_cy + impl_->current_group_->shift_y;
//+ (impl_->current_group_->flipV ? (impl_->current_group_->cy - 2 * y_pt): 0);
@ -1841,14 +1873,14 @@ void odf_drawing_context::set_position(_CP_OPT(double) & x_pt, _CP_OPT(double) &
{
double x = *x_pt;
if (impl_->current_drawing_state_.in_group)
if (impl_->current_drawing_state_.in_group_)
{
for( int i = impl_->group_list_.size() - 1; i >= 0 ; i--)
{
x = (x + impl_->group_list_[i]->shift_x) * impl_->group_list_[i]->scale_cx ;
}
}
if (!impl_->current_drawing_state_.svg_x_ || impl_->current_drawing_state_.in_group)
if (!impl_->current_drawing_state_.svg_x_ || impl_->current_drawing_state_.in_group_)
{
impl_->current_drawing_state_.svg_x_ = length(length(x , length::pt).get_value_unit(length::cm), length::cm);
}
@ -1858,7 +1890,7 @@ void odf_drawing_context::set_position(_CP_OPT(double) & x_pt, _CP_OPT(double) &
{
double y = *y_pt;
if (impl_->current_drawing_state_.in_group)
if (impl_->current_drawing_state_.in_group_)
{
for( int i = impl_->group_list_.size() - 1; i >= 0 ; i--)
{
@ -1866,7 +1898,7 @@ void odf_drawing_context::set_position(_CP_OPT(double) & x_pt, _CP_OPT(double) &
}
}
if (!impl_->current_drawing_state_.svg_y_ || impl_->current_drawing_state_.in_group)
if (!impl_->current_drawing_state_.svg_y_ || impl_->current_drawing_state_.in_group_)
{
impl_->current_drawing_state_.svg_y_ = length(length(y, length::pt).get_value_unit(length::cm),length::cm);
}
@ -1887,7 +1919,7 @@ void odf_drawing_context::get_size( _CP_OPT(double) & width_pt, _CP_OPT(double)
}
void odf_drawing_context::set_size( _CP_OPT(double) & width_pt, _CP_OPT(double) & height_pt)
{
if (impl_->current_drawing_state_.in_group)
if (impl_->current_drawing_state_.in_group_)
{
if (width_pt)
{
@ -2129,7 +2161,7 @@ void odf_drawing_context::set_textarea_writing_mode(int mode)
style* style_ = NULL;
if(!draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_text_style_name_)
{
impl_->styles_context_->create_style(L"",style_family::Paragraph, true, false, -1);
impl_->styles_context_->create_style(L"", style_family::Paragraph, true, false, -1);
office_element_ptr & style_shape_elm = impl_->styles_context_->last_state()->get_office_element();
style_ = dynamic_cast<style*>(style_shape_elm.get());
@ -2146,32 +2178,79 @@ void odf_drawing_context::set_textarea_writing_mode(int mode)
paragraph_properties = style_->content_.get_style_paragraph_properties();
}
}
if (paragraph_properties == NULL && impl_->current_paragraph_properties == NULL)return;
switch(mode)
if (paragraph_properties)
{
case 5://textverticaltypeWordArtVert:
case 6://textverticaltypeWordArtVertRtl:
case 4://SimpleTypes::textverticaltypeVert270: //нужно отзеркалить по горизонтали текст
case 3://SimpleTypes::textverticaltypeVert:
case 2://SimpleTypes::textverticaltypeMongolianVert:
paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
impl_->current_paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
break;
case 0://SimpleTypes::textverticaltypeEaVert:
paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
impl_->current_paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
break;
case 1://SimpleTypes::textverticaltypeHorz:
default:
paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::LrTb);
impl_->current_paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::LrTb);
break;
switch(mode)
{
case 5://textverticaltypeWordArtVert:
case 6://textverticaltypeWordArtVertRtl:
case 4://SimpleTypes::textverticaltypeVert270: //нужно отзеркалить по горизонтали текст
case 3://SimpleTypes::textverticaltypeVert:
case 2://SimpleTypes::textverticaltypeMongolianVert:
paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
break;
case 0://SimpleTypes::textverticaltypeEaVert:
paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
break;
case 1://SimpleTypes::textverticaltypeHorz:
default:
paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::LrTb);
break;
}
}
if (impl_->current_paragraph_properties)
{
switch(mode)
{
case 5://textverticaltypeWordArtVert:
case 6://textverticaltypeWordArtVertRtl:
case 4://SimpleTypes::textverticaltypeVert270: //нужно отзеркалить по горизонтали текст
case 3://SimpleTypes::textverticaltypeVert:
case 2://SimpleTypes::textverticaltypeMongolianVert:
impl_->current_paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
break;
case 0://SimpleTypes::textverticaltypeEaVert:
impl_->current_paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
break;
case 1://SimpleTypes::textverticaltypeHorz:
default:
impl_->current_paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::LrTb);
break;
}
}
}
void odf_drawing_context::set_paragraph_properties(style_paragraph_properties *paragraph_properties)
{
if (impl_->current_drawing_state_.elements_.empty()) return;
if (!impl_->current_paragraph_properties)
{
draw_base* draw = dynamic_cast<draw_base*>(impl_->current_drawing_state_.elements_[0].elm.get());
if (draw)
{
if(!draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_text_style_name_)
{
impl_->styles_context_->create_style(L"", style_family::Paragraph, true, false, -1);
office_element_ptr & style_shape_elm = impl_->styles_context_->last_state()->get_office_element();
style* style_ = dynamic_cast<style*>(style_shape_elm.get());
if (style_)
{
impl_->current_paragraph_properties = style_->content_.get_style_paragraph_properties();
draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_text_style_name_ = style_->style_name_;
}
}
else
{
//??? find by name
}
}
}
if (impl_->current_paragraph_properties)
impl_->current_paragraph_properties ->apply_from(paragraph_properties);
}
void odf_drawing_context::set_textarea_padding(_CP_OPT(double) & left, _CP_OPT(double) & top, _CP_OPT(double) & right, _CP_OPT(double) & bottom)//in pt
{
if (!impl_->current_graphic_properties)return;
@ -2200,7 +2279,7 @@ void odf_drawing_context::start_image(std::wstring odf_path)
return;
}
impl_->current_drawing_state_.oox_shape_preset = 3000;
impl_->current_drawing_state_.oox_shape_preset_ = 3000;
start_frame();
@ -2247,7 +2326,7 @@ void odf_drawing_context::start_object(std::wstring name)
void odf_drawing_context::start_text_box()
{
impl_->current_drawing_state_.oox_shape_preset = 2000;
impl_->current_drawing_state_.oox_shape_preset_ = 2000;
start_frame();
@ -2292,7 +2371,7 @@ void odf_drawing_context::set_text_box_tableframe(bool val)
{
if (impl_->current_drawing_state_.elements_.empty()) return;
impl_->current_drawing_state_.text_box_tableframe = val;
impl_->current_drawing_state_.text_box_tableframe_ = val;
}
void odf_drawing_context::set_text_box_parent_style(std::wstring style_name)
@ -2418,7 +2497,7 @@ void odf_drawing_context::set_text(odf_text_context* text_context)
{
if (text_context == NULL || impl_->current_level_.size() < 1 ) return;
if (impl_->is_presentation_ && *impl_->is_presentation_) return;
//if (impl_->is_presentation_ && *impl_->is_presentation_) return;
for (size_t i = 0; i < text_context->text_elements_list_.size(); i++)
{
@ -2437,7 +2516,7 @@ void odf_drawing_context::set_text(odf_text_context* text_context)
}
if (impl_->current_drawing_state_.oox_shape_preset > 2000 && impl_->current_drawing_state_.oox_shape_preset < 3000)
if (impl_->current_drawing_state_.oox_shape_preset_ > 2000 && impl_->current_drawing_state_.oox_shape_preset_ < 3000)
{
//настройки цвета - перетащить в линии и заливки - так уж нужно wordart-у оо
style_text_properties *text_properties_ = text_context->get_text_properties();
@ -2947,7 +3026,7 @@ void odf_drawing_context::end_hatch_style()
void odf_drawing_context::start_bitmap_style()
{
if (!impl_->current_graphic_properties) return;
if (impl_->current_drawing_state_.oox_shape_preset == 3000) return;
if (impl_->current_drawing_state_.oox_shape_preset_ == 3000) return;
odf_writer::office_element_ptr fill_image_element;
@ -3043,7 +3122,7 @@ void odf_drawing_context::set_bitmap_link(std::wstring file_path)
std::wstring odf_ref_name ;
impl_->odf_context_->mediaitems()->add_or_find(file_path, _mediaitems::typeImage, odf_ref_name);
if (impl_->current_drawing_state_.oox_shape_preset == 3000)
if (impl_->current_drawing_state_.oox_shape_preset_ == 3000)
{
if (impl_->current_level_.size() < 1) return;

View File

@ -52,6 +52,7 @@ namespace odf_writer
class odf_conversion_context;
class odf_style_context;
class odf_text_context;
class style_paragraph_properties;
class odf_drawing_context
{
@ -59,7 +60,8 @@ public:
odf_drawing_context (odf_conversion_context *odf_context);
~odf_drawing_context ();
void set_presentation (bool bMaster);
void set_presentation (bool bMaster);
_CP_OPT(bool) get_presentation ();
void set_drawings_rect (_CP_OPT(double) x_pt, _CP_OPT(double) y_pt, _CP_OPT(double) width_pt, _CP_OPT(double) height_pt);
void clear ();
@ -124,16 +126,18 @@ public:
void start_frame ();
void end_frame ();
bool change_text_box_2_wordart();
void start_image (std::wstring file_path);
void start_image (std::wstring odf_file_path);
void end_image ();
bool change_text_box_2_wordart ();
bool is_wordart ();
void set_paragraph_properties (style_paragraph_properties *paragraph_properties);
void start_text_box ();
void set_text_box_min_size (bool val);
void set_text_box_min_size (double w_pt, double h_pt);
void set_text_box_parent_style (std::wstring style_name);
void set_text_box_tableframe (bool val);
void set_text_box_tableframe (bool val);
void end_text_box ();
void start_object(std::wstring name);

View File

@ -54,11 +54,12 @@ void odf_lists_styles_context::set_odf_context(odf_conversion_context * Context)
odf_context_ = Context;
}
void odf_lists_styles_context::process_styles(office_element_ptr root )
void odf_lists_styles_context::process_styles(office_element_ptr root, bool automatic)
{
for (size_t i = 0; i < lists_format_array_.size(); i++)
{
if (lists_format_array_[i].elements.size() < 1) continue;
if (lists_format_array_[i].elements.size() < 1) continue;
if (lists_format_array_[i].automatic != automatic) continue;
root->add_child_element(lists_format_array_[i].elements[0]);
}
@ -92,7 +93,13 @@ std::wstring odf_lists_styles_context::get_style_name1(int oox_style_num)
}
std::wstring odf_lists_styles_context::get_style_name(int oox_style_num)
{
if (link_format_map_.count(oox_style_num) > 0)
if (lists_format_array_.empty()) return L"";
if (oox_style_num < 0)
{
return lists_format_array_.back().odf_list_style_name;
}
else if (link_format_map_.count(oox_style_num) > 0)
{
return link_format_map_.at(oox_style_num);
}
@ -101,7 +108,7 @@ std::wstring odf_lists_styles_context::get_style_name(int oox_style_num)
return L"";
}
}
void odf_lists_styles_context::start_style(int based_number)
void odf_lists_styles_context::start_style(bool bMaster, int based_number)
{
list_format_state state;
@ -109,21 +116,29 @@ void odf_lists_styles_context::start_style(int based_number)
create_element(L"text", L"list-style", elm, odf_context_);
state.elements.push_back(elm);
state.oox_based_number = based_number;
state.odf_list_style_name = std::wstring(L"WWNum") + boost::lexical_cast<std::wstring>(based_number + 1);
if (based_number < 0)
{
state.oox_based_number = lists_format_array_.size();
state.odf_list_style_name = std::wstring(L"L") + boost::lexical_cast<std::wstring>(state.oox_based_number + 1);
}
else
{
state.oox_based_number = based_number;
state.odf_list_style_name = std::wstring(L"WWNum") + boost::lexical_cast<std::wstring>(state.oox_based_number + 1);
}
state.automatic = !bMaster;
text_list_style *style = dynamic_cast<text_list_style *>(elm.get());
if (style == NULL)return;
style->text_list_style_attr_.style_name_ = state.odf_list_style_name;
lists_format_array_.push_back(state); //перенести в end??
}
style_list_level_properties * odf_lists_styles_context::get_list_level_properties()
{
if (lists_format_array_.size() < 1) return NULL;
if (lists_format_array_.back().elements.size() <1) return NULL;
if (lists_format_array_.empty()) return NULL;
if (lists_format_array_.back().elements.empty()) return NULL;
text_list_level_style_number *style_number_ = dynamic_cast<text_list_level_style_number *>(lists_format_array_.back().elements.back().get());
text_list_level_style_bullet *style_bullet_ = dynamic_cast<text_list_level_style_bullet *>(lists_format_array_.back().elements.back().get());
@ -156,8 +171,8 @@ style_list_level_properties * odf_lists_styles_context::get_list_level_propertie
}
style_text_properties * odf_lists_styles_context::get_text_properties()
{
if (lists_format_array_.size() < 1) return NULL;
if (lists_format_array_.back().elements.size() <1) return NULL;
if (lists_format_array_.empty()) return NULL;
if (lists_format_array_.back().elements.empty()) return NULL;
text_list_level_style_number *style_number_ = dynamic_cast<text_list_level_style_number *>(lists_format_array_.back().elements.back().get());
text_list_level_style_bullet *style_bullet_ = dynamic_cast<text_list_level_style_bullet *>(lists_format_array_.back().elements.back().get());
@ -167,14 +182,14 @@ style_text_properties * odf_lists_styles_context::get_text_properties()
if (style_number_)
{
if (!style_number_->style_text_properties_)
create_element(L"style", L"text-properties",style_number_->style_text_properties_,odf_context_);
create_element(L"style", L"text-properties", style_number_->style_text_properties_, odf_context_);
props = dynamic_cast<style_text_properties *>(style_number_->style_text_properties_.get());
}
if (style_bullet_)
{
if (!style_bullet_->style_text_properties_)
create_element(L"style", L"text-properties",style_bullet_->style_text_properties_,odf_context_);
create_element(L"style", L"text-properties", style_bullet_->style_text_properties_, odf_context_);
props = dynamic_cast<style_text_properties *>(style_bullet_->style_text_properties_.get());
}
@ -190,8 +205,8 @@ style_text_properties * odf_lists_styles_context::get_text_properties()
style_list_level_label_alignment * odf_lists_styles_context::get_list_level_alignment_properties()
{
if (lists_format_array_.size() < 1) return NULL;
if (lists_format_array_.back().elements.size() <1) return NULL;
if (lists_format_array_.empty()) return NULL;
if (lists_format_array_.back().elements.empty()) return NULL;
text_list_level_style_number *style_number_ = dynamic_cast<text_list_level_style_number *>(lists_format_array_.back().elements.back().get());
text_list_level_style_bullet *style_bullet_ = dynamic_cast<text_list_level_style_bullet *>(lists_format_array_.back().elements.back().get());
@ -201,21 +216,21 @@ style_list_level_label_alignment * odf_lists_styles_context::get_list_level_alig
if (style_number_)
{
if (!style_number_->style_list_level_properties_)
create_element(L"style", L"list-level-properties",style_number_->style_list_level_properties_,odf_context_);
create_element(L"style", L"list-level-properties", style_number_->style_list_level_properties_, odf_context_);
props = dynamic_cast<style_list_level_properties *>(style_number_->style_list_level_properties_.get());
}
if (style_bullet_)
{
if (!style_bullet_->style_list_level_properties_)
create_element(L"style", L"list-level-properties",style_bullet_->style_list_level_properties_,odf_context_);
create_element(L"style", L"list-level-properties", style_bullet_->style_list_level_properties_, odf_context_);
props = dynamic_cast<style_list_level_properties *>(style_bullet_->style_list_level_properties_.get());
}
if (style_image_)
{
if (!style_image_->style_list_level_properties_)
create_element(L"style", L"list-level-properties",style_image_->style_list_level_properties_,odf_context_);
create_element(L"style", L"list-level-properties", style_image_->style_list_level_properties_, odf_context_);
props = dynamic_cast<style_list_level_properties *>(style_image_->style_list_level_properties_.get());
}
@ -223,14 +238,15 @@ style_list_level_label_alignment * odf_lists_styles_context::get_list_level_alig
if (!props->style_list_level_label_alignment_)
{
create_element(L"style", L"list-level-label-alignment" ,props->style_list_level_label_alignment_,odf_context_);
create_element(L"style", L"list-level-label-alignment" , props->style_list_level_label_alignment_, odf_context_);
}
return dynamic_cast<style_list_level_label_alignment *>(props->style_list_level_label_alignment_.get());
}
int odf_lists_styles_context::start_style_level(int level, int type)
{
if (lists_format_array_.size() < 1) return -1;
if (lists_format_array_.empty()) return -1;
int odf_type =1;
int format_type = -1;
@ -451,10 +467,10 @@ wchar_t convert_bullet_char(wchar_t c)
}
void odf_lists_styles_context::set_numeric_format(std::wstring val)
{
if (lists_format_array_.size() < 1) return;
if (lists_format_array_.back().elements.size() <1) return ;
if ( val.length() <1 )
return;
if ( lists_format_array_.empty() ) return;
if ( lists_format_array_.back().elements.empty() ) return;
if ( val.empty() ) return;
text_list_level_style_number *style_number_ = dynamic_cast<text_list_level_style_number *>(lists_format_array_.back().elements.back().get());
if (style_number_)
@ -522,10 +538,10 @@ void odf_lists_styles_context::set_numeric_format(std::wstring val)
}
void odf_lists_styles_context::set_bullet_char(std::wstring val)
{
if (lists_format_array_.size() < 1) return;
if (lists_format_array_.back().elements.size() <1) return ;
if ( val.length() <1 )
return;
if ( lists_format_array_.empty() ) return;
if ( lists_format_array_.back().elements.empty() ) return ;
if ( val.empty() ) return;
text_list_level_style_bullet *style_bullet_ = dynamic_cast<text_list_level_style_bullet *>(lists_format_array_.back().elements.back().get());
@ -536,20 +552,20 @@ void odf_lists_styles_context::set_bullet_char(std::wstring val)
void odf_lists_styles_context::set_bullet_image_size(double size)
{
if (size < 0.1) return;
if (lists_format_array_.size() < 1) return;
if (lists_format_array_.back().elements.size() <1) return ;
if (lists_format_array_.empty()) return;
if (lists_format_array_.back().elements.empty()) return ;
style_list_level_properties *props = get_list_level_properties();
if(!props) return;
props->fo_width_ = length(length(size,length::pt).get_value_unit(length::cm),length::cm);
props->fo_height_ = length(length(size,length::pt).get_value_unit(length::cm),length::cm);
props->fo_width_ = length(length(size, length::pt).get_value_unit(length::cm), length::cm);
props->fo_height_ = length(length(size, length::pt).get_value_unit(length::cm), length::cm);
}
void odf_lists_styles_context::set_bullet_image (std::wstring ref)
{
if (lists_format_array_.size() < 1) return;
if (lists_format_array_.back().elements.size() <1) return ;
if (lists_format_array_.empty()) return;
if (lists_format_array_.back().elements.empty()) return ;
text_list_level_style_image *style_image_ = dynamic_cast<text_list_level_style_image *>(lists_format_array_.back().elements.back().get());
@ -557,14 +573,14 @@ void odf_lists_styles_context::set_bullet_image (std::wstring ref)
style_image_->text_list_level_style_image_attr_.common_xlink_attlist_.href_ = ref;
style_image_->text_list_level_style_image_attr_.common_xlink_attlist_.type_= xlink_type::Simple;
style_image_->text_list_level_style_image_attr_.common_xlink_attlist_.show_ = xlink_show::Embed;
style_image_->text_list_level_style_image_attr_.common_xlink_attlist_.actuate_= xlink_actuate::OnLoad;
style_image_->text_list_level_style_image_attr_.common_xlink_attlist_.type_ = xlink_type::Simple;
style_image_->text_list_level_style_image_attr_.common_xlink_attlist_.show_ = xlink_show::Embed;
style_image_->text_list_level_style_image_attr_.common_xlink_attlist_.actuate_ = xlink_actuate::OnLoad;
}
void odf_lists_styles_context::set_start_number(int val)
{
if (lists_format_array_.size() < 1) return;
if (lists_format_array_.back().elements.size() <1) return ;
if (lists_format_array_.empty()) return;
if (lists_format_array_.back().elements.empty()) return ;
text_list_level_style_number *style_number_ = dynamic_cast<text_list_level_style_number *>(lists_format_array_.back().elements.back().get());
@ -574,8 +590,8 @@ void odf_lists_styles_context::set_start_number(int val)
}
void odf_lists_styles_context::set_text_style_name(std::wstring name)
{
if (lists_format_array_.size() < 1) return;
if (lists_format_array_.back().elements.size() <1) return ;
if (lists_format_array_.empty()) return;
if (lists_format_array_.back().elements.empty()) return ;
text_list_level_style_number *style_number_ = dynamic_cast<text_list_level_style_number *>(lists_format_array_.back().elements.back().get());
text_list_level_style_bullet *style_bullet_ = dynamic_cast<text_list_level_style_bullet *>(lists_format_array_.back().elements.back().get());

View File

@ -55,7 +55,7 @@ struct list_format_state
std::vector<office_element_ptr> elements;
std::wstring odf_list_style_name;
bool automatic;
};
class odf_lists_styles_context
@ -64,7 +64,7 @@ public:
odf_lists_styles_context();
void set_odf_context(odf_conversion_context * Context);
void start_style(int abstract_number);
void start_style(bool bMaster, int abstract_number = -1);
int start_style_level(int level, int type);
style_list_level_properties * get_list_level_properties();
style_list_level_label_alignment * get_list_level_alignment_properties();
@ -84,9 +84,9 @@ public:
void add_style(int oox_style_num, int oox_based_num);
void process_styles(office_element_ptr root );
void process_styles(office_element_ptr root, bool automatic);
std::wstring get_style_name(int oox_style_num);
std::wstring get_style_name(int oox_style_num = -1);
std::wstring get_style_name1(int oox_style_num);
private:
std::vector<list_format_state> lists_format_array_;

View File

@ -161,6 +161,7 @@ void odf_style_context::process_automatic_styles(office_element_ptr root )
if (/*it->automatic_== true && */style_state_list_[i]->root_== false && style_state_list_[i]->odf_style_)
root->add_child_element(style_state_list_[i]->odf_style_);
}
lists_styles_context_.process_styles(root, true);
}
void odf_style_context::process_office_styles(office_element_ptr root )
@ -175,7 +176,7 @@ void odf_style_context::process_office_styles(office_element_ptr root )
root->add_child_element(style_state_list_[i]->odf_style_);
}
lists_styles_context_.process_styles(root );
lists_styles_context_.process_styles(root, false);
}
std::wstring odf_style_context::find_odf_style_name(int oox_id_style, style_family::type family, bool root, bool automatic)
{

View File

@ -154,13 +154,35 @@ void odf_text_context::add_text_content(const std::wstring & text)
std::wstring last = text.substr(pos);
if (last.length() > 0)current_level_.back().elm->add_text(last);
}
void odf_text_context::add_text_date(const std::wstring & text)
{
office_element_ptr s_elm;
create_element(L"text", L"date", s_elm, odf_context_);
text_date* s = dynamic_cast<text_date*>(s_elm.get());
if (s) s->add_text(text);
if (current_level_.size()>0)
current_level_.back().elm->add_child_element(s_elm);
}
void odf_text_context::add_text_page_number(const std::wstring & text)
{
office_element_ptr s_elm;
create_element(L"text", L"page-number", s_elm, odf_context_);
text_page_number* s = dynamic_cast<text_page_number*>(s_elm.get());
if (s) s->add_text(text);
if (current_level_.size()>0)
current_level_.back().elm->add_child_element(s_elm);
}
void odf_text_context::add_text_space(int count)
{
office_element_ptr s_elm;
create_element(L"text", L"s", s_elm, odf_context_);
text_s* s = dynamic_cast<text_s*>(s_elm.get());
if (s)s->text_c_ = count;
if (s) s->text_c_ = count;
//необязательно хранить..
//int level = current_level_.size();

View File

@ -67,8 +67,10 @@ public:
void add_text_content (const std::wstring & text);
void add_text_space (int count);
void set_symbol_font (const std::wstring & font);
void add_text_date (const std::wstring & text);
void add_text_page_number(const std::wstring & text);
void set_symbol_font (const std::wstring & font);
void set_symbol_text (int sym);
void start_paragraph (bool styled = false);

View File

@ -56,7 +56,26 @@ odp_conversion_context::odp_conversion_context(package::odf_document * outputDoc
: odf_conversion_context (PresentationDocument, outputDocument), slide_context_(*this), text_context_(NULL)
{
}
odf_text_context* odp_conversion_context::text_context()
{
return text_context_;
}
odp_slide_context* odp_conversion_context::slide_context()
{
return &slide_context_;
}
odf_drawing_context* odp_conversion_context::drawing_context()
{
if (slide_context_.page_state_list_.empty()) return NULL;
return slide_context_.state().drawing_context();
}
odf_comment_context* odp_conversion_context::comment_context()
{
if (slide_context_.page_state_list_.empty()) return NULL;
return slide_context_.state().comment_context();
}
void odp_conversion_context::start_document()
{
@ -128,14 +147,7 @@ void odp_conversion_context::end_drawings()
{
current_slide().drawing_context()->clear();
}
void odp_conversion_context::start_image(const std::wstring & image_file_name)
{
std::wstring odf_ref_name ;
mediaitems()->add_or_find(image_file_name,_mediaitems::typeImage,odf_ref_name);
current_slide().drawing_context()->start_image(odf_ref_name);
}
void odp_conversion_context::start_comment(int oox_comm_id)
{
office_element_ptr comm_elm;

View File

@ -64,16 +64,14 @@ public:
virtual void start_text_context();
virtual void end_text_context();
virtual odf_drawing_context * drawing_context() {return current_slide().drawing_context();}
virtual odf_text_context * text_context() {return text_context_; }
odp_slide_context * slide_context() {return &slide_context_;}
odf_comment_context * comment_context() {return current_slide().comment_context();}
virtual odf_drawing_context * drawing_context();
virtual odf_text_context * text_context();
odp_slide_context * slide_context();
odf_comment_context * comment_context();
void start_drawings();
void end_drawings();
virtual void start_image(const std::wstring & image_file_name);
void start_comment (int oox_comment_id);
void end_comment ();
void start_comment_content ();

View File

@ -527,14 +527,7 @@ void ods_conversion_context::end_drawings()
{
current_table().drawing_context()->clear();
}
void ods_conversion_context::start_image(const std::wstring & image_file_name)
{
std::wstring odf_ref_name ;
mediaitems()->add_or_find(image_file_name,_mediaitems::typeImage,odf_ref_name);
current_table().drawing_context()->start_image(odf_ref_name);
}
double ods_conversion_context::convert_symbol_width(double val)
{
//width = ((int)((column_width * Digit_Width + 5) / Digit_Width * 256 )) / 256.;

View File

@ -101,8 +101,6 @@ public:
void start_drawings();
void end_drawings();
virtual void start_image(const std::wstring & image_file_name);
double convert_symbol_width(double val);
void add_defined_range (const std::wstring & name, const std::wstring & cell_range, int sheet_id, bool printable = false);

View File

@ -266,8 +266,11 @@ void odt_conversion_context::end_drawings()
}
else
{
text_context()->start_element(elm);
text_context()->end_element();
if (elm)
{
text_context()->start_element(elm);
text_context()->end_element();
}
drawing_context()->clear();
drawing_context_.pop_back();
@ -915,14 +918,6 @@ void odt_conversion_context::end_change (int id, int type)
// return (text_changes_state_.current_types.back() == 2);
//}
//--------------------------------------------------------------------------------------------------------
void odt_conversion_context::start_image(const std::wstring & image_file_name)
{
std::wstring odf_ref_name ;
mediaitems()->add_or_find(image_file_name, _mediaitems::typeImage,odf_ref_name);
drawing_context()->start_image(odf_ref_name);
}
void odt_conversion_context::start_drop_cap(style_paragraph_properties *paragraph_properties)
{

View File

@ -82,8 +82,7 @@ public:
void start_drawings ();
void end_drawings ();
virtual void start_image(const std::wstring & image_file_name);
void add_text_content (const std::wstring & text);
void add_text_content (const std::wstring & text);
void start_paragraph (bool styled = false);
void end_paragraph ();

View File

@ -207,6 +207,8 @@ void text_list::create_child_element(const std::wstring & Ns, const std::wstring
}
void text_list::add_child_element( const office_element_ptr & child_element)
{
if (!child_element) return;
ElementType type = child_element->get_type();
if (type == typeTextListHeader)

View File

@ -30,11 +30,12 @@
*
*/
#include "PptxConverter.h"
#include "DocxConverter.h"
#include "../utils.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h"
@ -46,6 +47,7 @@
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SrgbClr.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/PrstClr.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/TextFont.h"
#include "../../../Common/DocxFormat/Source/Common/SimpleTypes_Drawing.h"
#include "../../../Common/DocxFormat/Source/Common/SimpleTypes_Word.h"
@ -55,6 +57,7 @@
#include "../OdfFormat/odf_drawing_context.h"
#include "../OdfFormat/style_text_properties.h"
#include "../OdfFormat/style_paragraph_properties.h"
#include "../OdfFormat/styles_list.h"
using namespace cpdoccore;
@ -75,6 +78,22 @@ void OoxConverter::convert(PPTX::Logic::SpTreeElem *oox_element)
convert (elem.operator->());
}
void OoxConverter::convert_font(PPTX::Theme *theme, std::wstring & font)
{
if (font == L"+mj-lt")
font = theme ? theme->themeElements.fontScheme.majorFont.latin.typeface : L"";
else if (font == L"+mn-lt")
font = theme ? theme->themeElements.fontScheme.minorFont.latin.typeface : L"";
else if (font == L"+mj-ea")
font = theme ? theme->themeElements.fontScheme.majorFont.ea.typeface : L"";
else if (font == L"+mn-ea")
font = theme ? theme->themeElements.fontScheme.minorFont.ea.typeface : L"";
else if (font == L"+mj-cs")
font = theme ? theme->themeElements.fontScheme.majorFont.cs.typeface : L"";
else if (font == L"+mn-cs")
font = theme ? theme->themeElements.fontScheme.minorFont.cs.typeface : L"";
}
void OoxConverter::convert(PPTX::Logic::GraphicFrame *oox_graphic_frame)
{
if (!oox_graphic_frame)return;
@ -156,28 +175,66 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
{
if (!oox_picture)return;
odf_context()->drawing_context()->start_drawing();
bool bImage = true;
if (oox_picture->spPr.Geometry.is_init())
{
int type = SimpleTypes::shapetypeRect;
if ( oox_picture->spPr.Geometry.is<PPTX::Logic::CustGeom>() )
{
type = 1000;
}
else if ( oox_picture->spPr.Geometry.is<PPTX::Logic::PrstGeom>() )
{
const PPTX::Logic::PrstGeom& prstGeom = oox_picture->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
SimpleTypes::CShapeType<> preset;
preset.FromString(prstGeom.prst.get());
type = preset.GetValue();
}
std::wstring pathImage;
double Width=0, Height = 0;
if (type != SimpleTypes::shapetypeRect)
{
odf_context()->drawing_context()->start_drawing();
odf_context()->drawing_context()->start_shape(type);
convert(&oox_picture->spPr, oox_picture->style.GetPointer());
convert(&oox_picture->nvPicPr);
odf_context()->drawing_context()->start_area_properties();
convert(&oox_picture->blipFill);
odf_context()->drawing_context()->end_area_properties();
odf_context()->drawing_context()->end_shape();
odf_context()->drawing_context()->end_drawing();
return;
}
}
std::wstring odf_ref;
std::wstring pathImage;
if (oox_picture->blipFill.blip.IsInit())
{
std::wstring sID;
bool bEmbedded = true;
if (oox_picture->blipFill.blip->embed.IsInit())
{
sID = oox_picture->blipFill.blip->embed->get();
std::wstring sID = oox_picture->blipFill.blip->embed->get();
pathImage = find_link_by_id(sID, 1);
odf_ref = odf_context()->add_image(pathImage);
}
else if (oox_picture->blipFill.blip->link.IsInit())
{
pathImage = oox_picture->blipFill.blip->link->get();
odf_ref = oox_picture->blipFill.blip->link->get();
bEmbedded = false;
}
_graphics_utils_::GetResolution(pathImage.c_str(), Width, Height);
}
odf_context()->start_image(pathImage);
odf_context()->drawing_context()->start_drawing();
odf_context()->drawing_context()->start_image(odf_ref);
{
double Width = 0, Height = 0;
_graphics_utils_::GetResolution(pathImage.c_str(), Width, Height);
if (oox_picture->blipFill.tile.IsInit())
{
odf_context()->drawing_context()->set_image_style_repeat(2);
@ -196,24 +253,7 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
}
OoxConverter::convert(&oox_picture->nvPicPr.cNvPr);
//oox_picture->m_oNvPicPr.m_oCNvPicPr
//oox_picture->m_oNvPicPr.m_oCNvPicPr.m_oPicLocks
{
//if (oox_picture->m_oNvPicPr.m_oCNvPicPr.m_oPicLocks->m_oNoChangeAspect)
//{
//}
//if (oox_picture->m_oNvPicPr.m_oCNvPicPr.m_oPicLocks->m_oNoCrop))
//{
//}
//if (oox_picture->m_oNvPicPr.m_oCNvPicPr.m_oPicLocks->m_oNoResize)
//{
//}
}
//m_oExtLst
OoxConverter::convert(&oox_picture->spPr, NULL);
OoxConverter::convert(&oox_picture->spPr, oox_picture->style.GetPointer());
}
odf_context()->drawing_context()->end_image();
@ -229,7 +269,7 @@ void OoxConverter::convert(PPTX::Logic::SmartArt *oox_smart_art)
if (oox_smart_art->m_diag.IsInit())
{
_CP_OPT(double) x, y, width, height, cx, cy;
_CP_OPT(double) x, y, width, height, cx = 1., cy= 1.;
odf_context()->drawing_context()->get_size (width, height);
odf_context()->drawing_context()->get_position (x, y);
@ -395,13 +435,14 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
{
if (oox_shape == NULL) return;
_CP_OPT(bool) bMasterPresentation = odf_context()->drawing_context()->get_presentation();
odf_context()->drawing_context()->start_drawing();
int type = 1000; //custom
if (oox_shape->spPr.Geometry.is_init())
{
if ( oox_shape->spPr.Geometry.is<PPTX::Logic::PrstGeom>() )
{
const PPTX::Logic::PrstGeom& prstGeom = oox_shape->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
@ -411,14 +452,20 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
type = preset.GetValue();
}
if (type == SimpleTypes::shapetypeRect && oox_shape->txBody.IsInit()) type = 2000;
if (type == SimpleTypes::shapetypeRect && (oox_shape->txBody.IsInit() || oox_shape->oTextBoxShape.IsInit()))
type = 2000;
if (type == 2000 && oox_shape->txBody->bodyPr.IsInit()
&& oox_shape->txBody->bodyPr->fromWordArt.get_value_or(false))
if (type == 2000)
{
int wordart_type = convert(oox_shape->txBody->bodyPr->prstTxWarp.GetPointer());
if (wordart_type > 0) type = wordart_type;
PPTX::Logic::BodyPr *bodyPr = NULL;
if (oox_shape->txBody.IsInit()) bodyPr = oox_shape->txBody->bodyPr.GetPointer();
else bodyPr = oox_shape->oTextBoxBodyPr.GetPointer();
if (bodyPr && bodyPr->fromWordArt.get_value_or(false))
{
int wordart_type = convert(bodyPr->prstTxWarp.GetPointer());
if (wordart_type > 0) type = wordart_type;
}
}
}
else if (oox_shape->nvSpPr.nvPr.ph.is_init())
@ -436,7 +483,24 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
if (oox_shape->txXfrm.IsInit() == false)
{
convert(oox_shape->txBody.GetPointer(), oox_shape->style.GetPointer());
if (oox_shape->oTextBoxShape.IsInit()) //docx sdt
{
DocxConverter *docx_converter = dynamic_cast<DocxConverter*>(this);
if (docx_converter)
{
odf_context()->start_text_context();
docx_converter->convert(oox_shape->oTextBoxShape.GetPointer());
odf_context()->drawing_context()->set_text( odf_context()->text_context());
convert(oox_shape->oTextBoxBodyPr.GetPointer());
if (oox_shape->style.IsInit())
convert(&oox_shape->style->fontRef);
odf_context()->end_text_context();
}
}
else
convert(oox_shape->txBody.GetPointer(), oox_shape->style.GetPointer());
}
odf_context()->drawing_context()->end_shape();
@ -812,11 +876,11 @@ void OoxConverter::convert(PPTX::Logic::GradFill *oox_grad_fill, DWORD nARGB)
odf_context()->drawing_context()->set_opacity_start (*opacityStart);
odf_context()->drawing_context()->set_opacity_end (*opacityEnd);
if (grad_style == odf_types::gradient_style::linear)
if (oox_grad_fill->lin.is_init())
{
odf_context()->drawing_context()->set_opacity_angle(oox_grad_fill->lin->ang.get()/60000.);
}
else
else if (oox_grad_fill->path.is_init())
{
odf_context()->drawing_context()->set_opacity_rect ( XmlUtils::GetInteger(oox_grad_fill->path->rect->l.get_value_or(L"")),
XmlUtils::GetInteger(oox_grad_fill->path->rect->t.get_value_or(L"")),
@ -847,12 +911,19 @@ void OoxConverter::convert(PPTX::Logic::UniColor * color, std::wstring & hexStri
if (!color) return;
convert(color, nARGB);
hexString = XmlUtils::IntToString(nARGB & 0x00FFFFFF, L"#%06X");
if ((nARGB >> 24) != 0xff)
if (nARGB != 0)
{
hexString = XmlUtils::IntToString(nARGB & 0x00FFFFFF, L"#%06X");
if ((nARGB >> 24) != 0xff)
{
opacity = 100 - ((nARGB >> 24) /255.) * 100.;
}
}
else
{
opacity = ((nARGB >> 24) /255.) * 100.;
//not found in theme
}
}
@ -1063,176 +1134,396 @@ void OoxConverter::convert(PPTX::Logic::NvPr *oox_nvPr)
{
if (!oox_nvPr) return;
if (oox_nvPr->ph.is_init())
{
if (oox_nvPr->ph->type.IsInit())
odf_context()->drawing_context()->set_placeholder_type(oox_nvPr->ph->type->GetBYTECode());
if (oox_nvPr->ph->idx.IsInit())
odf_context()->drawing_context()->set_placeholder_id(oox_nvPr->ph->idx.get());
//nullable_bool hasCustomPrompt;
//nullable_limit<Limit::Orient> orient;
//nullable_limit<Limit::PlaceholderSize> sz;
}
//ph уровнем выше
}
void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_props, int level)
{//одномерные списки тока
//if (!oox_list)return;
if (!oox_para_props) return;
PPTX::Theme *theme = oox_theme();
PPTX::Logic::Bullet & bullet = oox_para_props->ParagraphBullet;
if (bullet.is<PPTX::Logic::BuNone>())return;
int odf_list_type = 13; // 1, 2, 3 ...
if (bullet.is<PPTX::Logic::BuAutoNum>())
{
const PPTX::Logic::BuAutoNum & buAutoNum = bullet.as<PPTX::Logic::BuAutoNum>();
int pptx_type = buAutoNum.type.GetBYTECode();
if ( pptx_type < 3) odf_list_type = 46;
if (pptx_type > 2 && pptx_type < 6) odf_list_type = 60;
if (pptx_type > 28 && pptx_type < 32) odf_list_type = 47;
if (pptx_type > 31 && pptx_type < 35) odf_list_type = 61;
odf_context()->styles_context()->lists_styles().start_style_level(level, odf_list_type);
if (buAutoNum.startAt.IsInit())
{
int start_value = *buAutoNum.startAt;
if (start_value > 1)
odf_context()->styles_context()->lists_styles().set_start_number(start_value);
}
}
if (bullet.is<PPTX::Logic::BuChar>())
{
odf_list_type = 5;
const PPTX::Logic::BuChar & buChar = bullet.as<PPTX::Logic::BuChar>();
odf_context()->styles_context()->lists_styles().start_style_level(level, odf_list_type);
odf_context()->styles_context()->lists_styles().set_bullet_char(buChar.Char);
}
if (bullet.is<PPTX::Logic::BuBlip>())
{
const PPTX::Logic::BuBlip & buBlip = bullet.as<PPTX::Logic::BuBlip>();
std::wstring odf_ref;
bool bEmbedded = true;
if (buBlip.blip.embed.IsInit())
{
std::wstring sID = buBlip.blip.embed->get();
std::wstring pathImage = find_link_by_id(sID, 1);
if (pathImage.empty())
pathImage = buBlip.blip.GetFullPicName(); // only for presentation merge shapes !!
odf_ref = odf_context()->add_image(pathImage);
}
else if (buBlip.blip.link.IsInit())
{
odf_ref = buBlip.blip.link->get();
bEmbedded = false;
}
if (!odf_ref.empty())
{
odf_list_type = 1000;
odf_context()->styles_context()->lists_styles().start_style_level(level, odf_list_type );
odf_context()->styles_context()->lists_styles().set_bullet_image(odf_ref);
}
else
{
odf_list_type = 5;
odf_context()->styles_context()->lists_styles().start_style_level(level, odf_list_type );
odf_context()->styles_context()->lists_styles().set_bullet_char(L"\x2022");
}
}
//odf_writer::style_list_level_label_alignment * aligment_props = odf_context()->styles_context()->lists_styles().get_list_level_alignment_properties();
odf_writer::style_list_level_properties * level_props = odf_context()->styles_context()->lists_styles().get_list_level_properties();
odf_writer::style_text_properties * text_properties = odf_context()->styles_context()->lists_styles().get_text_properties();
convert(oox_para_props->defRPr.GetPointer(), text_properties);
if (oox_para_props->indent.IsInit() && level_props)
{
level_props->text_min_label_width_ = odf_types::length(- oox_para_props->indent.get() / 12700., odf_types::length::pt);
level_props->text_space_before_ = odf_types::length(1, odf_types::length::pt);
}else
{
//aligment_props->fo_text_indent_ = odf_types::length(0, odf_types::length::cm);
//aligment_props->fo_margin_left_ = odf_types::length(0, odf_types::length::cm);
}
if (oox_para_props->buColor.is<PPTX::Logic::BuClrTx>())
{
const PPTX::Logic::BuClrTx & buClrTx = oox_para_props->buColor.as<PPTX::Logic::BuClrTx>();
}
if (oox_para_props->buColor.is<PPTX::Logic::BuClr>())
{
PPTX::Logic::BuClr & buClr = oox_para_props->buColor.as<PPTX::Logic::BuClr>();
std::wstring hexColor;
_CP_OPT(double) opacity;
convert(&buClr.Color, hexColor, opacity);
if (!hexColor.empty())
{
int res = 0;
if ((res = hexColor.find(L"#")) < 0) hexColor = std::wstring(L"#") + hexColor;
if (text_properties) text_properties->content_.fo_color_ = odf_types::color(hexColor);
}
}
//-----------------------------------
if (oox_para_props->buSize.is<PPTX::Logic::BuSzPts>())
{
const PPTX::Logic::BuSzPts & buSzPts = oox_para_props->buSize.as<PPTX::Logic::BuSzPts>();
if (buSzPts.val.IsInit())
{
if (text_properties)
text_properties->content_.fo_font_size_ = odf_types::length(*buSzPts.val, odf_types::length::pt);
else if (odf_list_type == 1000)
odf_context()->styles_context()->lists_styles().set_bullet_image_size(*buSzPts.val);
}
}
else
{
double size_pt = oox_para_props->defRPr.IsInit() ? (oox_para_props->defRPr->sz.IsInit() ? *oox_para_props->defRPr->sz /100. : 0) : 0;
if (size_pt < 0.001 && odf_list_type == 1000)
{
odf_writer::style_text_properties * text_props = odf_context()->styles_context()->last_state(odf_types::style_family::Paragraph)->get_text_properties();
if (text_props && text_props->content_.fo_font_size_)
{
size_pt = text_props->content_.fo_font_size_->get_length().get_value_unit(odf_types::length::pt);
}
if (size_pt < 0.001)
{
odf_writer::odf_style_state_ptr style_state;
odf_context()->styles_context()->find_odf_default_style_state(odf_types::style_family::Text, style_state);
if (style_state)
text_props = style_state->get_text_properties();
if (text_props && text_props->content_.fo_font_size_)
{
size_pt = text_props->content_.fo_font_size_->get_length().get_value_unit(odf_types::length::pt);
}
}
}
if (oox_para_props->buSize.is<PPTX::Logic::BuSzTx>())
{
//equal tet size
}
if (oox_para_props->buSize.is<PPTX::Logic::BuSzPct>())
{
const PPTX::Logic::BuSzPct & buSzPct = oox_para_props->buSize.as<PPTX::Logic::BuSzPct>();
if (buSzPct.val.IsInit())
{
if (text_properties)
text_properties->content_.fo_font_size_ = odf_types::percent(*buSzPct.val / 1000.);
size_pt *= *buSzPct.val / 100000.;
}
}
if (text_properties && !text_properties->content_.fo_font_size_)
text_properties->content_.fo_font_size_ = odf_types::percent(100.);
else if (odf_list_type == 1000)
{
odf_context()->styles_context()->lists_styles().set_bullet_image_size(size_pt);
}
}
//----------------
if (oox_para_props->buTypeface.is<PPTX::Logic::BuFontTx>())
{
const PPTX::Logic::BuFontTx & buFontTx = oox_para_props->buTypeface.as<PPTX::Logic::BuFontTx>();
}
if (oox_para_props->buTypeface.is<PPTX::Logic::TextFont>())
{
const PPTX::Logic::TextFont & textFont = oox_para_props->buTypeface.as<PPTX::Logic::TextFont>();
std::wstring font = textFont.typeface;
convert_font(theme, font);
if (!font.empty() && text_properties)
text_properties->content_.fo_font_family_ = font;
}
odf_context()->styles_context()->lists_styles().end_style_level();
}
void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::TextListStyle *oox_list_style)
{
if (!oox_paragraph)return;
bool styled = false;
bool list_local = false;
bool list_present = false;
std::wstring list_style_name;
int list_level = 0;
int list_level = 0;//-1;
NSCommon::nullable<PPTX::Logic::TextParagraphPr> paraPr;
if (oox_paragraph->pPr.IsInit() || oox_list_style)
if (oox_paragraph->pPr.IsInit())
{
if (oox_paragraph->pPr.IsInit())
{
if (oox_paragraph->pPr->ParagraphBullet.is_init())
{
list_present = true;
list_level = 1;
}
if (oox_paragraph->pPr->lvl.IsInit())
{
list_level = *oox_paragraph->pPr->lvl;
if (list_level > 0)
list_present = true;
}
}
if (oox_paragraph->pPr->lvl.IsInit())
list_level = *oox_paragraph->pPr->lvl;
if (oox_paragraph->pPr->ParagraphBullet.is_init())
list_local = true;
}
odf_writer::style_paragraph_properties * paragraph_properties = odf_context()->text_context()->get_paragraph_properties();
//свойства могут быть приписаны не только к параграфу, но и к самому объекту
if (oox_list_style)
{
int i = (list_level >= 0 && list_level < 10) ? list_level : 0;
if (oox_list_style->levels[i].IsInit())
oox_list_style->levels[i]->Merge(paraPr);
}
if (oox_paragraph->pPr.IsInit())
oox_paragraph->pPr->Merge(paraPr);
if (paraPr.IsInit())
{
list_level = paraPr->lvl.IsInit() ? *paraPr->lvl : 0;
if (list_level > 0) list_present = true;
if (paraPr->ParagraphBullet.is_init())
{
list_present = true;
if (paraPr->ParagraphBullet.is<PPTX::Logic::BuNone>())
list_present = false;
}
//свойства могут быть приписаны не только к параграфу, но и к самому объекту
odf_writer::style_paragraph_properties* paragraph_properties = odf_context()->text_context()->get_paragraph_properties();
odf_writer::style_text_properties* text_properties = NULL;
if (!paragraph_properties)
{
odf_context()->text_context()->get_styles_context()->create_style(L"", odf_types::style_family::Paragraph, true, false, -1);
paragraph_properties = odf_context()->text_context()->get_styles_context()->last_state()->get_paragraph_properties();
paragraph_properties = odf_context()->text_context()->get_styles_context()->last_state()->get_paragraph_properties();
text_properties = odf_context()->text_context()->get_styles_context()->last_state()->get_text_properties();
//if(list_present && oox_list_style)
//{
// list_style_name = odf_context->styles_context()->lists_styles().get_style_name(list_style_id);
// odf_context->styles_context()->last_state()->set_list_style_name(list_style_name);
//}
styled = true;
}
convert(oox_list_style, list_level, paragraph_properties);
convert(oox_paragraph->pPr.GetPointer(), paragraph_properties);
}
convert(paraPr.GetPointer(), paragraph_properties, text_properties);
if (odf_context()->drawing_context()->is_wordart())
odf_context()->drawing_context()->set_paragraph_properties(paragraph_properties);
}
if (oox_paragraph->RunElems.empty() && list_present) list_present = false; // ms не обозначает присутствие списка, libra - показывает значек
while (odf_context()->text_context()->list_state_.levels.size() > list_level)
{
odf_context()->text_context()->end_list();
}
if(list_present)
{
while (odf_context()->text_context()->list_state_.levels.size() > list_level)
{
odf_context()->text_context()->end_list();
}
if (odf_context()->text_context()->list_state_.levels.size() < 1)
if (odf_context()->text_context()->list_state_.levels.empty())
{
odf_context()->text_context()->list_state_.started_list = false;
odf_context()->text_context()->list_state_.style_name = L"";
odf_context()->text_context()->list_state_.style_name = L"";
}
if (odf_context()->text_context()->list_state_.started_list == false)
if (list_local)
{
odf_context()->text_context()->start_list(list_style_name);
//text_context()->set_list_continue(true); //??? держать в памяти все списки????
_CP_OPT(bool) inStyles = odf_context()->drawing_context()->get_presentation();
odf_context()->styles_context()->lists_styles().start_style(inStyles && *inStyles);
convert_list_level(oox_paragraph->pPr.GetPointer(), list_level /*- 1*/);
odf_context()->styles_context()->lists_styles().end_style();
}
list_style_name = odf_context()->styles_context()->lists_styles().get_style_name(); //last added
list_level++;
if (odf_context()->text_context()->list_state_.levels.size() < list_level)
{
while (odf_context()->text_context()->list_state_.levels.size() < list_level)
{
odf_context()->text_context()->start_list(list_style_name);
odf_context()->text_context()->start_list_item();
if (odf_context()->text_context()->list_state_.style_name == list_style_name)
list_style_name = L"";
}
}
odf_context()->text_context()->start_list_item();
if (odf_context()->text_context()->list_state_.style_name == list_style_name)
list_style_name = L"";
while (odf_context()->text_context()->list_state_.levels.size() < list_level)
{
odf_context()->text_context()->start_list(list_style_name);
else
odf_context()->text_context()->start_list_item();
}
}
}
else if (odf_context()->text_context()->list_state_.started_list == true)
{
odf_context()->text_context()->end_list();
}
odf_context()->text_context()->start_paragraph(styled);
for (size_t i=0; i< oox_paragraph->RunElems.size();i++)
for (size_t i=0; i< oox_paragraph->RunElems.size(); i++)
{
convert(&oox_paragraph->RunElems[i].as<OOX::WritingElement>());
}
odf_context()->text_context()->end_paragraph();
if(list_present)
{
odf_context()->text_context()->end_list_item();
}
//if(list_present)
//{
// odf_context()->text_context()->end_list_item();
//}
}
void OoxConverter::convert(PPTX::Logic::TextListStyle *oox_list_style, int level, odf_writer::style_paragraph_properties * paragraph_properties)
void OoxConverter::convert(PPTX::Logic::TextListStyle *oox_list_style, int level, odf_writer::style_paragraph_properties * paragraph_properties
, odf_writer::style_text_properties * text_properties)
{
if (!oox_list_style) return;
if (!paragraph_properties) return;
convert(oox_list_style->levels[9].GetPointer(), paragraph_properties);
convert(oox_list_style->levels[9].GetPointer(), paragraph_properties, text_properties);
if (level < 0 || level > 9) return;
convert(oox_list_style->levels[level].GetPointer(), paragraph_properties);
convert(oox_list_style->levels[level].GetPointer(), paragraph_properties, text_properties);
}
void OoxConverter::convert(PPTX::Logic::TextParagraphPr *oox_paragraph_pr, odf_writer::style_paragraph_properties * paragraph_properties)
void OoxConverter::convert(PPTX::Logic::TextParagraphPr *oox_paragraph_pr , odf_writer::style_paragraph_properties * paragraph_properties
, odf_writer::style_text_properties * text_properties)
{
if (!oox_paragraph_pr) return;
if (!paragraph_properties) return;
if (oox_paragraph_pr->lnSpc.IsInit())
if (!oox_paragraph_pr) return;
if (paragraph_properties)
{
odf_types::length_or_percent length;
convert(oox_paragraph_pr->lnSpc.GetPointer(), length);
paragraph_properties->content_.fo_line_height_ = odf_types::line_width(length);
}
if (oox_paragraph_pr->spcAft.IsInit())
{
odf_types::length_or_percent length;
convert(oox_paragraph_pr->spcAft.GetPointer(), length);
paragraph_properties->content_.fo_margin_bottom_ = length;
}
if (oox_paragraph_pr->spcBef.IsInit())
{
odf_types::length_or_percent length;
convert(oox_paragraph_pr->spcBef.GetPointer(), length);
paragraph_properties->content_.fo_margin_top_ = length;
}
if (oox_paragraph_pr->algn.IsInit())
{
switch(oox_paragraph_pr->algn->GetBYTECode())
if (oox_paragraph_pr->lnSpc.IsInit())
{
case 0 : paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Center); break;
case 1 :
case 2 :
case 3 : paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Justify); break;
case 5 : paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Right); break;
case 4 :
default:
paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Left); break;
odf_types::length_or_percent length;
convert(oox_paragraph_pr->lnSpc.GetPointer(), length);
paragraph_properties->content_.fo_line_height_ = odf_types::line_width(length);
}
if (oox_paragraph_pr->spcAft.IsInit())
{
odf_types::length_or_percent length;
convert(oox_paragraph_pr->spcAft.GetPointer(), length);
paragraph_properties->content_.fo_margin_bottom_ = length;
}
if (oox_paragraph_pr->spcBef.IsInit())
{
odf_types::length_or_percent length;
convert(oox_paragraph_pr->spcBef.GetPointer(), length);
paragraph_properties->content_.fo_margin_top_ = length;
}
if (oox_paragraph_pr->algn.IsInit())
{
switch(oox_paragraph_pr->algn->GetBYTECode())
{
case 0 : paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Center); break;
case 1 :
case 2 :
case 3 : paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Justify); break;
case 5 : paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Right); break;
case 4 :
default:
paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Left); break;
}
}
if (oox_paragraph_pr->marL.IsInit())
{
paragraph_properties->content_.fo_margin_left_ = odf_types::length_or_percent(odf_types::length(oox_paragraph_pr->marL.get() / 12700., odf_types::length::pt));
}
if (oox_paragraph_pr->marR.IsInit())
{
paragraph_properties->content_.fo_margin_right_ = odf_types::length_or_percent(odf_types::length(oox_paragraph_pr->marR.get() / 12700., odf_types::length::pt));
}
if (oox_paragraph_pr->indent.IsInit())
{
paragraph_properties->content_.fo_text_indent_ = odf_types::length_or_percent(odf_types::length(oox_paragraph_pr->indent.get() / 12700., odf_types::length::pt));
}
if (oox_paragraph_pr->rtl.IsInit())
{
}
}
if (oox_paragraph_pr->marL.IsInit())
{
paragraph_properties->content_.fo_margin_left_ = odf_types::length_or_percent(odf_types::length(oox_paragraph_pr->marL.get() / 12700., odf_types::length::pt));
}
if (oox_paragraph_pr->marR.IsInit())
{
paragraph_properties->content_.fo_margin_right_ = odf_types::length_or_percent(odf_types::length(oox_paragraph_pr->marR.get() / 12700., odf_types::length::pt));
}
if (oox_paragraph_pr->indent.IsInit())
{
paragraph_properties->content_.fo_text_indent_ = odf_types::length_or_percent(odf_types::length(oox_paragraph_pr->indent.get() / 12700., odf_types::length::pt));
}
if (oox_paragraph_pr->rtl.IsInit())
{
}
//nullable<SimpleTypes::CDecimalNumber<> > m_oLvl;
//nullable<SimpleTypes::CCoordinate32<> > m_oDefTabSz;
//nullable<SimpleTypes::CTextFontAlignType<>> m_oFontAlgn;
if (oox_paragraph_pr->defRPr.IsInit())
{
odf_writer::style_text_properties * text_properties = odf_context()->text_context()->get_styles_context()->last_state()->get_text_properties();
if (text_properties)
convert(oox_paragraph_pr->defRPr.GetPointer(), text_properties);
convert(oox_paragraph_pr->defRPr.GetPointer(), text_properties);
//надо подумать как брать последний по family !!!
//convert(oox_paragraph_pr->m_oDefRunProperty.GetPointer());
@ -1251,7 +1542,7 @@ void OoxConverter::convert(PPTX::Logic::TextSpacing *oox_spacing, cpdoccore::odf
}
if ( oox_spacing->spcPts.IsInit() )
{
odf_types::length length = odf_types::length(oox_spacing->GetVal() / 12700., odf_types::length::pt);
odf_types::length length = odf_types::length(-oox_spacing->GetVal() / 100., odf_types::length::pt);
length_or_percent = odf_types::length_or_percent(length);
}
}
@ -1263,43 +1554,59 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
PPTX::Theme *theme = oox_theme();
PPTX::Logic::GradFill* gradFill = &oox_run_pr->Fill.as<PPTX::Logic::GradFill>();
if (gradFill)
{
if (odf_context()->drawing_context()->change_text_box_2_wordart())
//------------------------------------------------------
odf_writer::odf_drawing_context *drawing = odf_context()->drawing_context();
if (drawing) //from styles impossible(
{
if ((oox_run_pr->Fill.is<PPTX::Logic::GradFill>()) ||
((oox_run_pr->ln.IsInit()) && (oox_run_pr->ln->Fill.is_init() && oox_run_pr->ln->Fill.getType() != OOX::et_a_noFill)))
{
odf_context()->drawing_context()->start_area_properties();
{
convert(gradFill);
}
odf_context()->drawing_context()->end_area_properties();
drawing->change_text_box_2_wordart();
}
if (drawing->is_wordart())
{
if (oox_run_pr->Fill.is_init())
{
drawing->start_area_properties();
convert(&oox_run_pr->Fill);
drawing->end_area_properties();
}
if (oox_run_pr->ln.is_init())
{
drawing->start_line_properties();
if (oox_run_pr->ln->Fill.is_init() && oox_run_pr->ln->Fill.getType() != OOX::et_a_noFill )
{
drawing->set_line_dash_preset(6);
convert(oox_run_pr->ln.GetPointer());
}
else if (drawing->is_wordart())
drawing->set_no_fill();
drawing->end_line_properties();
}
}
}
//---------------------------------------
_CP_OPT(double) opacityText;
std::wstring hexColorText;
PPTX::Logic::GradFill* gradFill = &oox_run_pr->Fill.as<PPTX::Logic::GradFill>();
if (gradFill && !gradFill->GsLst.empty())
{
convert(&gradFill->GsLst[0].color, hexColorText, opacityText);
}
PPTX::Logic::SolidFill* solidFill = &oox_run_pr->Fill.as<PPTX::Logic::SolidFill>();
if (solidFill)
{
std::wstring hexColor;
_CP_OPT(double) opacity;
convert(&solidFill->Color, hexColor, opacity);
convert(&solidFill->Color, hexColorText, opacityText);
}
if (!hexColorText.empty())
{
int res = 0;
if ((res = hexColor.find(L"#")) < 0) hexColor = std::wstring(L"#") + hexColor;
text_properties->content_.fo_color_ = odf_types::color(hexColor);
if ((res = hexColorText.find(L"#")) < 0) hexColorText = std::wstring(L"#") + hexColorText;
text_properties->content_.fo_color_ = odf_types::color(hexColorText);
}
if (oox_run_pr->ln.IsInit() && oox_run_pr->ln->Fill.getType() != OOX::et_a_noFill)
{
if (odf_context()->drawing_context()->change_text_box_2_wordart())
{
odf_context()->drawing_context()->start_line_properties();
{
odf_context()->drawing_context()->set_line_dash_preset(6);
convert(oox_run_pr->ln.GetPointer());
}
odf_context()->drawing_context()->end_line_properties();
}
}
//---------------------------------------
if (oox_run_pr->b.IsInit())
{
if (oox_run_pr->b.get() == true)
@ -1326,12 +1633,8 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
if (!oox_run_pr->latin->typeface.empty())
{
std::wstring font = oox_run_pr->latin->typeface;
if (font == L"+mj-lt")
font = theme->themeElements.fontScheme.majorFont.latin.typeface;
else if (font == L"+mn-lt")
font = theme->themeElements.fontScheme.minorFont.latin.typeface;
convert_font(theme, font);
if (!font.empty())
text_properties->content_.fo_font_family_ = font;
}
@ -1345,11 +1648,7 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
if (!oox_run_pr->ea->typeface.empty())
{
std::wstring font = oox_run_pr->ea->typeface;
if (font == L"+mj-ea")
font = theme->themeElements.fontScheme.majorFont.ea.typeface;
else if (font == L"+mn-ea")
font = theme->themeElements.fontScheme.minorFont.ea.typeface;
convert_font(theme, font);
if (!font.empty())
text_properties->content_.style_font_family_asian_ = font;
@ -1363,11 +1662,7 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
if (!oox_run_pr->cs->typeface.empty())
{
std::wstring font = oox_run_pr->cs->typeface;
if (font == L"+mj-cs")
font = theme->themeElements.fontScheme.majorFont.cs.typeface;
else if (font == L"+mn-cs")
font = theme->themeElements.fontScheme.minorFont.cs.typeface;
convert_font(theme, font);
if (!font.empty())
text_properties->content_.style_font_family_complex_ = font;
@ -1382,12 +1677,12 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
int res = oox_language.find(L"-");
if (res >= 0)
{
oox_country = oox_language.substr(res);
oox_country = oox_language.substr(res + 1);
oox_language = oox_language.substr(0, res);
}
text_properties->content_.fo_language_ = oox_language;
if (oox_country.length() > 0)
if (!oox_country.empty())
text_properties->content_.fo_country_ = oox_country;
}
@ -1466,6 +1761,45 @@ void OoxConverter::convert(PPTX::Logic::Run *oox_run)
void OoxConverter::convert(PPTX::Logic::Fld *oox_fld)
{
if (!oox_fld) return;
bool styled = false;
if (oox_fld->rPr.IsInit())
{
odf_writer::style_text_properties * text_properties = odf_context()->text_context()->get_text_properties();
if (!text_properties)
{
odf_context()->styles_context()->create_style(L"", odf_types::style_family::Text, true, false, -1);
text_properties = odf_context()->styles_context()->last_state()->get_text_properties();
styled = true;
}
convert(oox_fld->rPr.GetPointer(), text_properties);
}
odf_context()->text_context()->start_span(styled);
std::wstring fld_type = oox_fld->type.get_value_or(L"");
if ((oox_fld->rPr.IsInit()) && (oox_fld->rPr->hlinkClick.IsInit()) && (oox_fld->rPr->hlinkClick->id.IsInit()))
{
std::wstring hlink = find_link_by_id(oox_fld->rPr->hlinkClick->id.get(), 2);
odf_context()->text_context()->add_hyperlink(hlink, oox_fld->GetText());
}
else if (fld_type == L"slidenum")
{
odf_context()->text_context()->add_text_page_number( oox_fld->GetText());
}
else if (fld_type == L"datetime1")
{
odf_context()->text_context()->add_text_date( oox_fld->GetText());
}
else
{
odf_context()->text_context()->add_text_content( oox_fld->GetText());
}
odf_context()->text_context()->end_span();
}
void OoxConverter::convert(PPTX::Logic::Br *oox_br)
{
@ -1492,15 +1826,28 @@ void OoxConverter::convert(PPTX::Logic::MoveTo *oox_geom_path)
odf_context()->drawing_context()->add_path_element(std::wstring(L"M"), path_elm);
}
void OoxConverter::convert(PPTX::Logic::TextListStyle *oox_list_style)
{
if (!oox_list_style) return;
if (oox_list_style->IsListStyleEmpty()) return;
_CP_OPT(bool) inStyles = odf_context()->drawing_context()->get_presentation();
odf_context()->styles_context()->lists_styles().start_style(inStyles && *inStyles);
for (int i = 0; i < 9; i++)
{
OoxConverter::convert_list_level(oox_list_style->levels[i].GetPointer(), i);
}
odf_context()->styles_context()->lists_styles().end_style();
}
void OoxConverter::convert(PPTX::Logic::TxBody *oox_txBody, PPTX::Logic::ShapeStyle* oox_style)
{
if (!oox_txBody) return;
if (oox_txBody->Paragrs.empty()) return;
odf_context()->start_text_context();
convert(oox_txBody->lstStyle.GetPointer());
for (size_t i = 0; i < oox_txBody->Paragrs.size(); i++)
{

View File

@ -70,7 +70,7 @@ void OoxConverter::convert(OOX::Vml::CShapeType *vml_shape_type)
}
//m_oPreferRelative//типо можно менять размер
for (unsigned int i=0 ; i < vml_shape_type->m_arrItems.size();i++)
for (size_t i = 0; i < vml_shape_type->m_arrItems.size(); i++)
{
convert(vml_shape_type->m_arrItems[i]);
}
@ -86,6 +86,18 @@ void OoxConverter::convert(OOX::Vml::CShapeType *vml_shape_type)
//m_arrItems
//CVmlCommonElements
}
void OoxConverter::convert(OOX::Vml::CFormulas *vml_formulas)
{
if (vml_formulas == NULL) return;
for (size_t i = 0; i < vml_formulas->m_arrItems.size(); i++)
{
OOX::Vml::CF *cf = dynamic_cast<OOX::Vml::CF *>(vml_formulas->m_arrItems[i]);
if (cf == NULL) continue;
//odf_context()->drawing_context()->add_formula(L"", cf->m_sEqn);
}
}
void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style, bool group)
{
@ -95,7 +107,7 @@ void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style, bool group)
_CP_OPT(int) anchor_type_x, anchor_type_y;
for (unsigned int i=0; i < vml_style->m_arrProperties.size(); i++)
for (size_t i = 0; i < vml_style->m_arrProperties.size(); i++)
{
if (vml_style->m_arrProperties[i] == NULL) continue;
@ -693,17 +705,18 @@ void OoxConverter::convert(OOX::Vml::CTextbox *vml_textbox)
odf_context()->drawing_context()->set_textarea_wrap(true);
DocxConverter *docx_converter = dynamic_cast<DocxConverter*>(this);
odf_context()->start_text_context();
if (docx_converter)
{
for (unsigned int i=0 ; i < vml_textbox->m_oTxtbxContent->m_arrItems.size();i++)
odf_context()->start_text_context();
{
if (docx_converter)
for (size_t i = 0; i < vml_textbox->m_oTxtbxContent->m_arrItems.size(); i++)
{
docx_converter->convert(vml_textbox->m_oTxtbxContent->m_arrItems[i]);
}
odf_context()->drawing_context()->set_text( odf_context()->text_context());
}
odf_context()->drawing_context()->set_text( odf_context()->text_context());
odf_context()->end_text_context();
}
odf_context()->end_text_context();
}
void OoxConverter::convert(OOX::Vml::CTextPath *vml_textpath)
@ -869,7 +882,7 @@ void OoxConverter::convert(OOX::Vml::CVmlCommonElements *vml_common)
delete oRgbColor;
}
}
for (unsigned int i=0 ; i < vml_common->m_arrItems.size();i++)
for (size_t i = 0; i < vml_common->m_arrItems.size(); i++)
{
convert(vml_common->m_arrItems[i]);
}
@ -899,7 +912,7 @@ void OoxConverter::convert(OOX::Vml::CGroup *vml_group)
odf_context()->drawing_context()->set_group_shift(vml_group->m_oCoordOrigin->GetX(), vml_group->m_oCoordOrigin->GetY());
}
for (unsigned int i=0; i < vml_group->m_arrItems.size(); i++)
for (size_t i = 0; i < vml_group->m_arrItems.size(); i++)
{
if (vml_group->m_arrItems[i] == NULL) continue;

View File

@ -130,6 +130,8 @@ bool OoxConverter::UpdateProgress(long nComplete)
void OoxConverter::set_fonts_directory(const std::wstring &fontsPath)
{
if (odf_context() == NULL) return;
odf_context()->set_fonts_directory(fontsPath);
}
@ -143,18 +145,15 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown)
{
case OOX::et_graphicFrame:
{
PPTX::Logic::GraphicFrame* pGraphicFrame= dynamic_cast<PPTX::Logic::GraphicFrame*>(oox_unknown);
convert(pGraphicFrame);
convert(dynamic_cast<PPTX::Logic::GraphicFrame*>(oox_unknown));
}break;
case OOX::et_pic:
{
PPTX::Logic::Pic* pPic= dynamic_cast<PPTX::Logic::Pic*>(oox_unknown);
convert(pPic);
convert(dynamic_cast<PPTX::Logic::Pic*>(oox_unknown));
}break;
case OOX::et_dgm_DiagrammParts:
{
PPTX::Logic::SmartArt* pDiagrammParts = dynamic_cast<PPTX::Logic::SmartArt*>(oox_unknown);
convert(pDiagrammParts);
convert(dynamic_cast<PPTX::Logic::SmartArt*>(oox_unknown));
}break;
case OOX::et_a_Shape:
case OOX::et_p_Shape:
@ -266,18 +265,19 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown)
}break;
case OOX::et_v_fill:
{
OOX::Vml::CFill *vml = dynamic_cast<OOX::Vml::CFill*>(oox_unknown);
convert(vml);
convert(dynamic_cast<OOX::Vml::CFill*>(oox_unknown));
}break;
case OOX::et_v_stroke:
{
OOX::Vml::CStroke *vml = dynamic_cast<OOX::Vml::CStroke*>(oox_unknown);
convert(vml);
convert(dynamic_cast<OOX::Vml::CStroke*>(oox_unknown));
}break;
case OOX::et_v_formulas:
{
convert(dynamic_cast<OOX::Vml::CFormulas*>(oox_unknown));
}break;
case OOX::et_v_shadow:
{
OOX::Vml::CShadow *vml = dynamic_cast<OOX::Vml::CShadow*>(oox_unknown);
convert(vml);
convert(dynamic_cast<OOX::Vml::CShadow*>(oox_unknown));
}break;
case OOX::et_v_image:
{

View File

@ -245,6 +245,7 @@ namespace OOX
class CTextPath;
class CGroup;
class CVmlCommonElements;
class CFormulas;
}
namespace VmlWord
{
@ -263,6 +264,7 @@ namespace PPTX
class Theme;
namespace Logic
{
class Bullet;
class ClrMap;
class SpTreeElem;
class GraphicFrame;
@ -364,6 +366,7 @@ public:
void convert (double oox_font_size, _CP_OPT(cpdoccore::odf_types::font_size) & odf_font_size);
bool convert (std::wstring sSchemeColor, DWORD & argb);
void convert_font(PPTX::Theme *theme, std::wstring & font);
//.......................................................................................................................
void convert(OOX::WritingElement *oox_unknown);
//drawingML & pptx................................................................................................................................
@ -402,10 +405,16 @@ public:
void convert(PPTX::Logic::NvCxnSpPr *oox_nvSpPr);
void convert(PPTX::Logic::NvGrpSpPr *oox_nvSpPr);
void convert(PPTX::Logic::NvPr *oox_nvPr);
void convert(PPTX::Logic::Paragraph *oox_para, PPTX::Logic::TextListStyle *oox_list_style = NULL);
void convert(PPTX::Logic::TextListStyle *oox_list_style, int level, cpdoccore::odf_writer::style_paragraph_properties * paragraph_properties);
void convert(PPTX::Logic::TextParagraphPr *oox_para_props, cpdoccore::odf_writer::style_paragraph_properties * paragraph_properties);
void convert(PPTX::Logic::RunProperties *oox_run_props, cpdoccore::odf_writer::style_text_properties * text_properties);
void convert(PPTX::Logic::Paragraph *oox_para, PPTX::Logic::TextListStyle *oox_list_style = NULL);
void convert(PPTX::Logic::TextListStyle *oox_list_style);
void convert_list_level (PPTX::Logic::TextParagraphPr *oox_para_props, int level);
void convert(PPTX::Logic::TextListStyle *oox_list_style, int level, cpdoccore::odf_writer::style_paragraph_properties *paragraph_properties,
cpdoccore::odf_writer::style_text_properties *text_properties);
void convert(PPTX::Logic::TextParagraphPr *oox_para_props, cpdoccore::odf_writer::style_paragraph_properties *paragraph_properties,
cpdoccore::odf_writer::style_text_properties *text_properties);
void convert(PPTX::Logic::RunProperties *oox_run_props, cpdoccore::odf_writer::style_text_properties *text_properties);
void convert(PPTX::Logic::Run *oox_run);
void convert(PPTX::Logic::Fld *oox_fld);
void convert(PPTX::Logic::Br *oox_br);
@ -502,6 +511,7 @@ public:
void convert(OOX::VmlWord::CWrap *vml_wrap);
void convert(OOX::Vml::CGroup *vml_group);
void convert(OOX::Vml::CVmlCommonElements *vml_attr);
void convert(OOX::Vml::CFormulas *vml_formulas);
};
} // namespace Oox2Odf

View File

@ -317,16 +317,16 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown)
// OOX::Logic::CShape* pShape = dynamic_cast<OOX::Logic::CShape*>(oox_unknown);
// convert(pShape);
//}break;
//case OOX::et_w_pict:
//{
// OOX::Logic::CPicture* pPic = dynamic_cast<OOX::Logic::CPicture*>(oox_unknown);
// convert(pPic);
//}break;
//case OOX::et_w_object:
//{
// OOX::Logic::CObject* pObj = dynamic_cast<OOX::Logic::CObject*>(oox_unknown);
// convert(pObj);
//}break;
case OOX::et_w_pict:
{
OOX::Logic::CPicture* pPic = dynamic_cast<OOX::Logic::CPicture*>(oox_unknown);
convert(pPic);
}break;
case OOX::et_w_object:
{
OOX::Logic::CObject* pObj = dynamic_cast<OOX::Logic::CObject*>(oox_unknown);
convert(pObj);
}break;
case OOX::et_pic_pic:
case OOX::et_pic:
case OOX::et_p_pic:
@ -353,23 +353,27 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown)
}break;
case OOX::et_w_commentReference:
{
OOX::Logic::CCommentReference* pCommRef = dynamic_cast<OOX::Logic::CCommentReference*>(oox_unknown);
convert(pCommRef); //если нет Start - означает начало с предыдущего Run
convert(dynamic_cast<OOX::Logic::CCommentReference*>(oox_unknown)); //если нет Start - означает начало с предыдущего Run
}break;
case OOX::et_w_footnoteReference:
{
OOX::Logic::CFootnoteReference* pRef= dynamic_cast<OOX::Logic::CFootnoteReference*>(oox_unknown);
convert(pRef);
convert(dynamic_cast<OOX::Logic::CFootnoteReference*>(oox_unknown));
}break;
case OOX::et_w_endnoteReference:
{
OOX::Logic::CEndnoteReference* pRef= dynamic_cast<OOX::Logic::CEndnoteReference*>(oox_unknown);
convert(pRef);
convert(dynamic_cast<OOX::Logic::CEndnoteReference*>(oox_unknown));
}break;
case OOX::et_w_endnoteRef:
{
//add ref ??? todoooo
}break;
case OOX::et_w_footnoteRef:
{
//add ref
}break;
case OOX::et_w_tbl:
{
OOX::Logic::CTbl* pTable= dynamic_cast<OOX::Logic::CTbl*>(oox_unknown);
convert(pTable);
convert(dynamic_cast<OOX::Logic::CTbl*>(oox_unknown));
}break;
case OOX::et_w_tr:
{
@ -381,6 +385,12 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown)
OOX::Logic::CTc* pCell= dynamic_cast<OOX::Logic::CTc*>(oox_unknown);
convert(pCell);
}break;
case OOX::et_w_bookmarkStart:
{
}break;
case OOX::et_w_bookmarkEnd:
{
}break;
default:
{
OoxConverter::convert(oox_unknown);
@ -394,12 +404,15 @@ void DocxConverter::convert(OOX::Logic::CSdt *oox_sdt)
//nullable<OOX::Logic::CSdtEndPr > m_oSdtEndPr;
//nullable<OOX::Logic::CSdtPr > m_oSdtPr;
if (oox_sdt->m_oSdtContent.IsInit())
convert(oox_sdt->m_oSdtContent.GetPointer());
}
void DocxConverter::convert(OOX::Logic::CSdtContent *oox_sdt)
{
if (oox_sdt == NULL) return;
for (size_t i = 0; i < oox_sdt->m_arrItems.size(); i++)
{
for (unsigned int i=0; i< oox_sdt->m_oSdtContent->m_arrItems.size(); i++)
{
convert(oox_sdt->m_oSdtContent->m_arrItems[i]);
}
convert(oox_sdt->m_arrItems[i]);
}
}
void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
@ -3017,7 +3030,7 @@ void DocxConverter::convert(OOX::Numbering::CAbstractNum* oox_num_style)
if (oox_num_style->m_oAbstractNumId.IsInit() == false) return;
odt_context->styles_context()->lists_styles().start_style(oox_num_style->m_oAbstractNumId->GetValue());
odt_context->styles_context()->lists_styles().start_style(true, oox_num_style->m_oAbstractNumId->GetValue());
//// Childs
//std::vector<OOX::Numbering::CLvl > m_arrLvl;
//nullable<ComplexTypes::Word::CMultiLevelType > m_oMultiLevelType;
@ -3049,7 +3062,7 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl)
int type_list = odt_context->styles_context()->lists_styles().start_style_level(oox_num_lvl->m_oIlvl->GetValue(), oox_type_list );
if (type_list < 0) return;
odf_writer::style_list_level_properties * level_props = odt_context->styles_context()->lists_styles().get_list_level_properties();
odf_writer::style_list_level_properties * level_props = odt_context->styles_context()->lists_styles().get_list_level_properties();
odf_writer::style_list_level_label_alignment * aligment_props = odt_context->styles_context()->lists_styles().get_list_level_alignment_properties();
if (level_props == NULL)return;
@ -3101,8 +3114,8 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl)
}
}else
{
aligment_props->fo_text_indent_ = odf_types::length(0,odf_types::length::cm);
aligment_props->fo_margin_left_ = odf_types::length(0,odf_types::length::cm);
aligment_props->fo_text_indent_ = odf_types::length(0, odf_types::length::cm);
aligment_props->fo_margin_left_ = odf_types::length(0, odf_types::length::cm);
}
}
@ -3114,7 +3127,7 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl)
convert(oox_num_lvl->m_oRPr.GetPointer(), text_props);
//create text style for symbols list НА ЛОКАЛЬНОМ контексте - иначе пересечение имен стилей (todoo вытащить генерацию имен в общую часть)
styles_context->create_style(L"",odf_types::style_family::Text, false, true, -1);
styles_context->create_style(L"", odf_types::style_family::Text, false, true, -1);
odf_writer::odf_style_state_ptr style_state = styles_context->last_state(odf_types::style_family::Text);
if (style_state)
{
@ -3184,7 +3197,9 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl)
}
if (type_list == 2 || type_list == 3)
{
odt_context->styles_context()->lists_styles().set_bullet_image_size(size_bullet_number_marker);
}
if (oox_num_lvl->m_oLvlRestart.IsInit() && oox_num_lvl->m_oLvlRestart->m_oVal.IsInit() && type_list == 1)
{

View File

@ -95,6 +95,7 @@ namespace OOX
class CTcBorders;
class CTblBorders;
class CSdt;
class CSdtContent;
class CBackground;
class CLockedCanvas;
@ -151,7 +152,8 @@ namespace Oox2Odf
virtual std::wstring find_link_by_id (std::wstring sId, int t);
virtual NSCommon::smart_ptr<OOX::File> find_file_by_id(std::wstring sId);
void convert(OOX::WritingElement *oox_unknown);
void convert(OOX::WritingElement *oox_unknown);
void convert(OOX::Logic::CSdtContent *oox_sdt);
private:
struct _section
{
@ -220,7 +222,7 @@ namespace Oox2Odf
void convert(OOX::Drawing::CAnchor *oox_anchor);
void convert(OOX::Drawing::CInline *oox_inline);
void convert(SimpleTypes::CTheme<> *oox_font_theme,_CP_OPT(std::wstring) & odf_font_name);
void convert(ComplexTypes::Word::CColor *color, _CP_OPT(odf_types::color) & odf_color);
void convert(SimpleTypes::CUniversalMeasure *oox_size, _CP_OPT(odf_types::length) & odf_size);

View File

@ -60,7 +60,18 @@ namespace Oox2Odf
{
PptxConverter::PptxConverter(const std::wstring & path, const ProgressCallback* CallBack)
{
const OOX::CPath oox_path(std::wstring(path.c_str()));
current_clrMap = NULL;
current_slide = NULL;
current_theme = NULL;
current_tableStyles = NULL;
presentation = NULL;
output_document = NULL;
odp_context = NULL;
pCallBack = CallBack;
const OOX::CPath oox_path(std::wstring(path.c_str()));
pptx_document = new PPTX::Folder();
if (!pptx_document->isValid(oox_path.GetPath())) // true ???
@ -82,13 +93,6 @@ PptxConverter::PptxConverter(const std::wstring & path, const ProgressCallback*
output_document = new odf_writer::package::odf_document(L"presentation");
odp_context = new odf_writer::odp_conversion_context(output_document);
current_clrMap = NULL;
current_slide = NULL;
current_theme = NULL;
current_tableStyles = NULL;
pCallBack = CallBack;
if (UpdateProgress(290000))return;
}
PptxConverter::~PptxConverter()
@ -219,21 +223,20 @@ void PptxConverter::convert_styles()
odf_writer::style_paragraph_properties * paragraph_properties = odp_context->styles_context()->last_state()->get_paragraph_properties();
odf_writer::style_text_properties * text_properties = odp_context->styles_context()->last_state()->get_text_properties();
if (text_properties)
if (presentation->defaultTextStyle.IsInit())
{
text_properties->content_.fo_font_size_ = odf_types::font_size(odf_types::length(18, odf_types::length::pt));
}
if (slide->theme.IsInit() && text_properties)
{
if (slide->theme->themeElements.fontScheme.majorFont.latin.typeface.empty() == false)
text_properties->content_.fo_font_family_ = slide->theme->themeElements.fontScheme.majorFont.latin.typeface;
if (slide->theme->themeElements.fontScheme.majorFont.cs.typeface.empty() == false)
text_properties->content_.style_font_family_complex_ = slide->theme->themeElements.fontScheme.majorFont.cs.typeface;
OoxConverter::convert(presentation->defaultTextStyle->levels[9].GetPointer(), paragraph_properties, text_properties); //defPPr
OoxConverter::convert(presentation->defaultTextStyle->levels[0].GetPointer(), paragraph_properties, text_properties); //default text
if (slide->theme->themeElements.fontScheme.majorFont.ea.typeface.empty() == false)
text_properties->content_.style_font_family_asian_ = slide->theme->themeElements.fontScheme.majorFont.ea.typeface;
odp_context->styles_context()->create_default_style(odf_types::style_family::Paragraph);
paragraph_properties = odp_context->styles_context()->last_state()->get_paragraph_properties();
OoxConverter::convert(presentation->defaultTextStyle->levels[0].GetPointer(), paragraph_properties, text_properties); //default text
odp_context->styles_context()->create_default_style(odf_types::style_family::Text);
text_properties = odp_context->styles_context()->last_state()->get_text_properties();
OoxConverter::convert(presentation->defaultTextStyle->levels[0].GetPointer(), paragraph_properties, text_properties); //default text
}
//convert(presentation->defaultTextStyle.GetPointer()); //стили дефалтовых списков
@ -260,6 +263,8 @@ void PptxConverter::convert_styles()
odp_context->page_layout_context()->create_layer_sets();
}
void PptxConverter::convert_settings()
{
@ -302,20 +307,31 @@ void PptxConverter::convert_slides()
std::wstring master_style_name;
std::wstring layout_style_name;
bool bShow = slide->show.get_value_or(true);
bool bShowMasterAnim = slide->showMasterPhAnim.get_value_or(true);
bool bShowMasterSp = slide->showMasterSp.get_value_or(true);
PPTX::Logic::TxStyles* current_txStyles = NULL;
if (slide->Master.IsInit())
{
current_clrMap = &slide->Master->clrMap;
current_txStyles = slide->Master->txStyles.GetPointer();
std::map<std::wstring, std::wstring>::iterator pFind = m_mapMasters.find(slide->Master->m_sOutputFilename + slide->Layout->m_sOutputFilename);
std::wstring master_name = (bShowMasterSp ? slide->Master->m_sOutputFilename : L"") + slide->Layout->m_sOutputFilename;
std::map<std::wstring, std::wstring>::iterator pFind = m_mapMasters.find(master_name);
if (pFind == m_mapMasters.end())
{
master_style_name = L"MasterPage";
bool bShowLayoutMasterAnim = slide->Layout->showMasterPhAnim.get_value_or(true);
bool bShowLayoutMasterSp = slide->Layout->showMasterSp.get_value_or(true);
if (slide->Master->cSld.attrName.IsInit()) master_style_name = slide->Master->cSld.attrName.get();
else if (current_theme->name.IsInit()) master_style_name = current_theme->name.get();
master_style_name += L"_" ;
if (slide->Layout->cSld.attrName.IsInit()) master_style_name += slide->Layout->cSld.attrName.get();
else if (slide->Layout->attrType.IsInit()) master_style_name += slide->Layout->attrType->get();
else
@ -323,18 +339,23 @@ void PptxConverter::convert_slides()
odp_context->start_master_slide(master_style_name);
convert_common();
//if (slide->Layout->showMasterSp.IsInit() ? *slide->Layout->showMasterSp : true)
{
current_slide = slide->Master.operator->();
convert_slide(&slide->Master->cSld, current_txStyles, false);
}
current_slide = slide->Master.operator->();
if (bShowLayoutMasterSp && bShowMasterSp)
convert_slide(&slide->Master->cSld, current_txStyles, false, true);
else
convert(slide->Master->cSld.bg.GetPointer());
if (slide->Layout->clrMapOvr.IsInit() && slide->Layout->clrMapOvr->overrideClrMapping.IsInit())
current_clrMap = slide->Layout->clrMapOvr->overrideClrMapping.GetPointer();
current_slide = slide->Layout.operator->();
convert_slide(&slide->Layout->cSld, current_txStyles, true);
convert_slide(&slide->Layout->cSld, current_txStyles, true, bShowLayoutMasterSp);
//add note master
odp_context->end_master_slide();
m_mapMasters.insert(std::make_pair(slide->Master->m_sOutputFilename + slide->Layout->m_sOutputFilename, master_style_name));
m_mapMasters.insert(std::make_pair(master_name, master_style_name));
}
else
{
@ -369,11 +390,8 @@ void PptxConverter::convert_slides()
odp_context->current_slide().set_master_page (master_style_name);
odp_context->current_slide().set_layout_page (layout_style_name);
//nullable_bool show;
//nullable_bool showMasterPhAnim;
//nullable_bool showMasterSp;
convert_slide (slide->cSld.GetPointer(), current_txStyles, true);
convert_slide (slide->cSld.GetPointer(), current_txStyles, true, bShowMasterSp);
convert (slide->comments.operator->());
convert (slide->Note.operator->());
@ -929,7 +947,7 @@ void PptxConverter::convert(PPTX::Logic::Bg *oox_background)
odp_context->end_drawings();
}
void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxStyles* txStyles, bool bPlaceholders)
void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxStyles* txStyles, bool bPlaceholders, bool bFillUp)
{
if (oox_slide == NULL) return;
@ -940,56 +958,87 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS
odp_context->current_slide().set_page_name(oox_slide->attrName.get());
convert(oox_slide->bg.GetPointer());
bool bMaster = *odf_context()->drawing_context()->get_presentation();
for (size_t i = 0 ; i < oox_slide->spTree.SpTreeElems.size(); i++)
{
smart_ptr<PPTX::WrapperWritingElement> pElem = oox_slide->spTree.SpTreeElems[i].GetElem();
smart_ptr<PPTX::Logic::Shape> pShape = pElem.smart_dynamic_cast<PPTX::Logic::Shape>();
if (pShape.IsInit() && pShape->nvSpPr.nvPr.ph.is_init())
if (pShape.IsInit())
{
pShape->FillLevelUp();
if (!bPlaceholders)
continue;
PPTX::Logic::TextListStyle * listMasterStyle = NULL;
if (txStyles)
if (pShape->nvSpPr.nvPr.ph.is_init())
{
std::wstring type = pShape->nvSpPr.nvPr.ph->type.get_value_or(_T("body"));
if ((type == L"title") || (type == L"ctrTitle"))
listMasterStyle = txStyles->titleStyle.GetPointer();
else if ((type == L"body") || (type == L"subTitle") || (type == L"obj"))
listMasterStyle = txStyles->bodyStyle.GetPointer();
else if (type != L"")
listMasterStyle = txStyles->otherStyle.GetPointer();
}
PPTX::Logic::Shape update_shape;
if (listMasterStyle)
{
update_shape.txBody = new PPTX::Logic::TxBody();
if (bFillUp)
pShape->FillLevelUp();
PPTX::Logic::TextListStyle *newListStyle = new PPTX::Logic::TextListStyle();
for (int i = 0; i < 10; i++)
if (pShape->nvSpPr.nvPr.ph->type.IsInit())
{
if(listMasterStyle->levels[i].is_init())
listMasterStyle->levels[i]->Merge(newListStyle->levels[i]);
int ph_type = pShape->nvSpPr.nvPr.ph->type->GetBYTECode();
//if (!bMaster && (ph_type == 5 || ph_type == 6 || ph_type == 7 || ph_type == 12))
// continue;
odf_context()->drawing_context()->set_placeholder_type(ph_type);
}
update_shape.txBody->lstStyle.reset(newListStyle);
else
odf_context()->drawing_context()->set_placeholder_type(0);
if (pShape->nvSpPr.nvPr.ph->idx.IsInit())
odf_context()->drawing_context()->set_placeholder_id(pShape->nvSpPr.nvPr.ph->idx.get());
if (!bPlaceholders)
continue;
PPTX::Logic::TextListStyle * listMasterStyle = NULL;
if (txStyles)
{
std::wstring type = pShape->nvSpPr.nvPr.ph->type.get_value_or(_T("body"));
if ((type == L"title") || (type == L"ctrTitle"))
listMasterStyle = txStyles->titleStyle.GetPointer();
else if ((type == L"body") || (type == L"subTitle") || (type == L"obj"))
listMasterStyle = txStyles->bodyStyle.GetPointer();
else if (type != L"")
listMasterStyle = txStyles->otherStyle.GetPointer();
}
PPTX::Logic::Shape update_shape;
if (listMasterStyle)
{
update_shape.txBody = new PPTX::Logic::TxBody();
PPTX::Logic::TextListStyle *newListStyle = new PPTX::Logic::TextListStyle();
for (int i = 0; i < 10; i++)
{
if(listMasterStyle->levels[i].is_init())
listMasterStyle->levels[i]->Merge(newListStyle->levels[i]);
}
update_shape.txBody->lstStyle.reset(newListStyle);
}
pShape->Merge(update_shape);
OoxConverter::convert(&update_shape);
}
else if (pShape->txBody.IsInit() && presentation->defaultTextStyle.IsInit())
{//default text style with master clrScheme
PPTX::Logic::Shape update_shape;
update_shape.txBody = new PPTX::Logic::TxBody();
pShape->Merge(update_shape);
presentation->defaultTextStyle->Merge(update_shape.txBody->lstStyle);
OoxConverter::convert(&update_shape);
pShape->Merge(update_shape);
OoxConverter::convert(&update_shape);
}
else
OoxConverter::convert(pShape.operator->());
}
else
{
OoxConverter::convert(pElem.operator->());
}
//convert(oox_slide->spTree.SpTreeElems[i].GetElem().operator->());
}
convert(oox_slide->controls.GetPointer());
}
@ -1017,7 +1066,11 @@ void PptxConverter::convert_layout(PPTX::Logic::CSld *oox_slide)
odf_context()->drawing_context()->start_drawing();
odf_context()->drawing_context()->start_element(elm);
OoxConverter::convert(&pShape->nvSpPr.nvPr);
odf_context()->drawing_context()->set_placeholder_type(type);
if (pShape->nvSpPr.nvPr.ph->idx.IsInit())
odf_context()->drawing_context()->set_placeholder_id(*pShape->nvSpPr.nvPr.ph->idx);
OoxConverter::convert(pShape->spPr.xfrm.GetPointer());
odf_context()->drawing_context()->end_element();

View File

@ -106,7 +106,7 @@ namespace Oox2Odf
void convert(OOX::WritingElement *oox_unknown);
void convert_slide (PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxStyles* txStyles, bool bPlaceholders = true);
void convert_slide (PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxStyles* txStyles, bool bPlaceholders, bool bFillUp);
void convert_layout (PPTX::Logic::CSld *oox_slide);
void convert (PPTX::Comments *oox_comments);
void convert (PPTX::NotesSlide *oox_note);

View File

@ -1748,236 +1748,6 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFromTo* oox_from_to, oox_table_po
if (oox_from_to->m_oColOff.IsInit()) pos->col_off = oox_from_to->m_oColOff->GetValue();//pt
}
//void XlsxConverter::convert(OOX::Spreadsheet::CGroupShape* oox_group_shape)
//{
// if (!oox_group_shape)return;
// if (oox_group_shape->m_arrItems.size() < 1) return;
//
// ods_context->drawing_context()->start_group();
//
// if (oox_group_shape->m_oNvGroupSpPr.IsInit())
// {
// if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr.IsInit())
// {
// if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_sName.IsInit())
// ods_context->drawing_context()->set_group_name(*oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_sName);
// if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_oId.IsInit())
// ods_context->drawing_context()->set_group_z_order(oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_oId->GetValue());
// }
// }
//
// OoxConverter::convert(oox_group_shape->m_oGroupSpPr.GetPointer());
//
// for (unsigned int i=0; i < oox_group_shape->m_arrItems.size(); i++)
// {
// switch(oox_group_shape->m_arrItems[i]->getType())
// {
// case OOX::et_x_Shape:
// {
// OOX::Spreadsheet::CShape* item = dynamic_cast<OOX::Spreadsheet::CShape*>(oox_group_shape->m_arrItems[i]);
// convert(item);
// }break;
// case OOX::et_x_ConnShape:
// {
// OOX::Spreadsheet::CConnShape* item = dynamic_cast<OOX::Spreadsheet::CConnShape*>(oox_group_shape->m_arrItems[i]);
// convert(item);
// }break;
// case OOX::et_x_GroupShape:
// {
// OOX::Spreadsheet::CGroupShape* item = dynamic_cast<OOX::Spreadsheet::CGroupShape*>(oox_group_shape->m_arrItems[i]);
// convert(item);
// }break;
// case OOX::et_x_Pic:
// {
// OOX::Spreadsheet::CPic* item = dynamic_cast<OOX::Spreadsheet::CPic*>(oox_group_shape->m_arrItems[i]);
// convert(item);
// }break;
// }
// }
// ods_context->drawing_context()->end_group();
//}
//
//void XlsxConverter::convert(OOX::Spreadsheet::CShape* oox_shape)
//{
// if (!oox_shape)return;
// if (!oox_shape->m_oSpPr.IsInit()) return;
//
// ods_context->drawing_context()->start_drawing();
//
// int type = -1;
// if (oox_shape->m_oSpPr->m_oCustGeom.IsInit())
// {
// type = 1000;//6???
// }
// if (oox_shape->m_oSpPr->m_oPrstGeom.IsInit())
// {
// OOX::Drawing::CPresetGeometry2D * geometry = oox_shape->m_oSpPr->m_oPrstGeom.GetPointer();
// type =(geometry->m_oPrst.GetValue());
// }
//
// if ((oox_shape->m_oNvSpPr.IsInit()) && (oox_shape->m_oNvSpPr->m_oCNvSpPr.IsInit()))
// {
// if (oox_shape->m_oNvSpPr->m_oCNvSpPr->m_otxBox.GetValue() == 1)
// type = 2000; //textBox
// }
//
// if (type < 0)return;
///////////////////////////////////////////////////////////////////////////////////
// if (type == 2000) ods_context->drawing_context()->start_text_box();
// else ods_context->drawing_context()->start_shape(type);
//
// {
// OoxConverter::convert(oox_shape->m_oSpPr.GetPointer(), oox_shape->m_oShapeStyle.GetPointer());
//
// if (oox_shape->m_oNvSpPr.IsInit())
// {
// OoxConverter::convert(oox_shape->m_oNvSpPr->m_oCNvPr.GetPointer()); //имя, описалово, номер ...
// convert(oox_shape->m_oNvSpPr->m_oCNvSpPr.GetPointer()); //заблокированности ... todooo
// }
// if (oox_shape->m_oShapeStyle.IsInit())
// {
// //доп эффекты
//
// }
// if (oox_shape->m_oTxBody.IsInit())
// {
// ods_context->start_text_context();
// OoxConverter::convert(oox_shape->m_oTxBody->m_oBodyPr.GetPointer());
//
// for (unsigned int i=0 ; i < oox_shape->m_oTxBody->m_arrItems.size();i++)
// {
// OoxConverter::convert(oox_shape->m_oTxBody->m_arrItems[i]);
// }
// ods_context->drawing_context()->set_text( ods_context->text_context());
// ods_context->end_text_context();
//
// }
// }
// if (type == 2000)ods_context->drawing_context()->end_text_box();
// else ods_context->drawing_context()->end_shape();
//
// ods_context->drawing_context()->end_drawing();
//
//}
//
//void XlsxConverter::convert(OOX::Spreadsheet::CConnShape* oox_shape)
//{
// if (!oox_shape)return;
// if (!oox_shape->m_oSpPr.IsInit()) return;
//
// ods_context->drawing_context()->start_drawing();
//
// int type = -1;
// if (oox_shape->m_oSpPr->m_eGeomType == OOX::Drawing::geomtypeCustom)
// {
// type = 1000;//?????
// }
// else if (oox_shape->m_oSpPr->m_eGeomType == OOX::Drawing::geomtypePreset)
// {
// if (oox_shape->m_oSpPr->m_oPrstGeom.IsInit())
// {
// OOX::Drawing::CPresetGeometry2D * geometry = oox_shape->m_oSpPr->m_oPrstGeom.GetPointer();
// type = (int)(geometry->m_oPrst.GetValue());
// }
// }
// if (type < 0)return;
////////////////////////////////////////////////////////////////////////////////
// ods_context->drawing_context()->start_shape(type);
// {
// OoxConverter::convert(oox_shape->m_oSpPr.GetPointer(), oox_shape->m_oShapeStyle.GetPointer());
//
// //частенько приплывает из стиля заполенение объекта .. а он то одномерный :)
// odf_context()->drawing_context()->start_area_properties();
// odf_context()->drawing_context()->set_no_fill();
// odf_context()->drawing_context()->end_area_properties();
//
// if (oox_shape->m_oNvConnSpPr.IsInit())
// {
// if (oox_shape->m_oNvConnSpPr->m_oCNvPr.IsInit())
// {
// OoxConverter::convert(oox_shape->m_oNvConnSpPr->m_oCNvPr.GetPointer());
// }
//
// if (oox_shape->m_oNvConnSpPr->m_oCNvConnSpPr.IsInit())
// {
// }
// }
// //avLst
// }
// ods_context->drawing_context()->end_shape();
// ods_context->drawing_context()->end_drawing();
//}
//
//
//void XlsxConverter::convert(OOX::Spreadsheet::CPic* oox_picture)
//{
// if (!oox_picture)return;
// if (!oox_picture->m_oBlipFill.IsInit()) return; // невeрная структура оох
//
// ods_context->drawing_context()->start_drawing();
//
// std::wstring pathImage;
// double Width=0, Height = 0;
//
// if (oox_picture->m_oBlipFill->m_oBlip.IsInit())
// {
// std::wstring sID = oox_picture->m_oBlipFill->m_oBlip->m_oEmbed.GetValue();
// pathImage = find_link_by_id(sID,1);
//
// if (pathImage.empty())
// {
// sID = oox_picture->m_oBlipFill->m_oBlip->m_oLink.GetValue();
// //???
// }
// _graphics_utils_::GetResolution(pathImage.c_str(), Width, Height);
// }
// ods_context->start_image(pathImage);
// {
// if (oox_picture->m_oBlipFill->m_oTile.IsInit())
// {
// ods_context->drawing_context()->set_image_style_repeat(2);
// }
// if (oox_picture->m_oBlipFill->m_oStretch.IsInit())
// {
// ods_context->drawing_context()->set_image_style_repeat(1);
// }
// if (oox_picture->m_oBlipFill->m_oSrcRect.IsInit() && Width >0 && Height >0)
// {
// ods_context->drawing_context()->set_image_client_rect_inch(
// oox_picture->m_oBlipFill->m_oSrcRect->m_oL.GetValue()/100. * Width / currentSystemDPI ,
// oox_picture->m_oBlipFill->m_oSrcRect->m_oT.GetValue()/100. * Height / currentSystemDPI ,
// oox_picture->m_oBlipFill->m_oSrcRect->m_oR.GetValue()/100. * Width / currentSystemDPI ,
// oox_picture->m_oBlipFill->m_oSrcRect->m_oB.GetValue()/100. * Height / currentSystemDPI );
// }
// if (oox_picture->m_oNvPicPr.IsInit())
// {
// OoxConverter::convert(oox_picture->m_oNvPicPr->m_oCNvPr.GetPointer());
//
// if (oox_picture->m_oNvPicPr->m_oCNvPicPr.IsInit())
// {
// if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks.IsInit())
// {
// //if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks->m_oNoChangeAspect)
// //{
// //}
// //if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks->m_oNoCrop))
// //{
// //}
// //if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks->m_oNoResize)
// //{
// //}
// }
// //m_oExtLst
// }
// }
//
// OoxConverter::convert(oox_picture->m_oSpPr.GetPointer(), oox_picture->m_oShapeStyle.GetPointer());
//
// }
// ods_context->drawing_context()->end_image();
// ods_context->drawing_context()->end_drawing();
//}
//
void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_fmt)
{
if (!oox_cond_fmt)return;

View File

@ -120,21 +120,29 @@ namespace PPTX
oAttr.Write(_T("noResize"), noResize);
oAttr.Write(_T("noSelect"), noSelect);
return XmlUtils::CreateNode(m_namespace + L":cNvGraphicFramePr", oAttr.m_strValue.empty() ? L"" : XmlUtils::CreateNode(L"a:graphicFrameLocks", oAttr));
std::wstring namespaceLocks = L"a";
if (m_namespace == L"wp") namespaceLocks = L"wp";
return XmlUtils::CreateNode(m_namespace + L":cNvGraphicFramePr", oAttr.m_strValue.empty() ? L"" : XmlUtils::CreateNode(namespaceLocks + L":graphicFrameLocks", oAttr));
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
std::wstring namespace_ = m_namespace;
std::wstring namespace_ = m_namespace;
std::wstring namespaceLock_ = L"a";
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"wp";
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
{
namespaceLock_ = L"wp";
namespace_ = L"wp";
}
pWriter->StartNode(namespace_ + L":cNvGraphicFramePr");
pWriter->EndAttributes();
pWriter->StartNode(_T("a:graphicFrameLocks"));
pWriter->StartNode(namespaceLock_ + L"graphicFrameLocks");
pWriter->StartAttributes();
@ -147,7 +155,7 @@ namespace PPTX
pWriter->EndAttributes();
pWriter->EndNode(_T("a:graphicFrameLocks"));
pWriter->EndNode(namespaceLock_ + L":graphicFrameLocks");
pWriter->EndNode(namespace_ + L":cNvGraphicFramePr");
}

View File

@ -53,12 +53,14 @@ namespace PPTX
{
name = oReader.GetName();
ReadAttributes( oReader );
if (XmlUtils::GetNameNoNS(name) == _T("alpha"))
{
ReadAttributes2( oReader );
}
else
{
ReadAttributes( oReader );
}
}
void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader)
{
@ -67,8 +69,14 @@ namespace PPTX
WritingElement_ReadAttributes_ReadSingle ( oReader, _T("val"), sTmp)
WritingElement_ReadAttributes_End( oReader )
if (val.is_init() && sTmp.is_init() && sTmp->find(wchar_t('%')) != -1)
*val = (*val) * 1000;
if (sTmp.is_init())
{
val = sTmp.get();
if (val.is_init() && std::wstring::npos != sTmp->find(L"%"))
{
*val = (*val) * 1000;
}
}
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
@ -86,7 +94,7 @@ namespace PPTX
nullable_string sTmp;
node.ReadAttributeBase(L"val", sTmp);
if (val.is_init() && sTmp.is_init() && sTmp->find(wchar_t('%')) != -1)
if (val.is_init() && sTmp.is_init() && std::wstring::npos != sTmp->find(L"%"))
*val = (*val) * 1000;
}
}

View File

@ -122,8 +122,8 @@ namespace PPTX
if (L"xfrm" == strName && strNamespace != L"xdr")
xfrm = oReader;
else if (L"nvGraphicFramePr" == strName)
nvGraphicFramePr.fromXML( oReader );
else if (L"cNvGraphicFramePr" == strName)
nvGraphicFramePr.cNvGraphicFramePr.fromXML( oReader );
else if (L"graphic" == strName)
{

View File

@ -437,7 +437,6 @@ namespace PPTX
pWriter->EndRecord();
}
void Shape::FillLevelUp()
{
if ((m_pLevelUp == NULL) && (nvSpPr.nvPr.ph.IsInit()))
@ -452,6 +451,16 @@ namespace PPTX
}
}
bool Shape::IsListStyleEmpty()
{
if ((m_pLevelUp) && (m_pLevelUp->IsListStyleEmpty() == false)) return false;
if (txBody.IsInit() == false) return true;
if (txBody->lstStyle.IsInit() == false) return true;
return txBody->lstStyle->IsListStyleEmpty();
}
void Shape::Merge(Shape& shape, bool bIsSlidePlaceholder)
{
if (m_pLevelUp)

View File

@ -303,6 +303,7 @@ namespace PPTX
void FillLevelUp();
void Merge(Shape& shape, bool bIsSlidePlaceholder = false);
bool IsListStyleEmpty();
void SetLevelUpElement( Shape* p){m_pLevelUp = p;};

View File

@ -171,6 +171,20 @@ namespace PPTX
pReader->Seek(_end_rec);
}
bool IsListStyleEmpty()
{
for (int i = 0; i < 10; i++)
{
if (levels[i].IsInit())
{
if (levels[i]->ParagraphBullet.is_init() == false) continue;
if (levels[i]->ParagraphBullet.is<PPTX::Logic::BuNone>())continue;
return false;
}
}
return true;
}
void Merge(nullable<TextListStyle>& lstStyle)const
{

View File

@ -156,6 +156,16 @@ namespace PPTX
}
}
}
if (pShape->nvSpPr.nvPr.ph->idx.IsInit())
{
//not found in layout !! 100818_건강보험과_보건의료_김용익_최종.pptx
bool bShapeMaster = showMasterSp.get_value_or(true);
if (Master.IsInit() && bShapeMaster)
{
Master->GetLevelUp(pShape);
}
}
}
}
virtual std::wstring GetMediaFullPathNameFromRId(const OOX::RId& rid)const

View File

@ -26,10 +26,8 @@
17C1FCBE1ACC429D006B99B3 /* EffectProperties.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A443D1AC57B83005A27F7 /* EffectProperties.cpp */; };
17C1FCBF1ACC429D006B99B3 /* EffectLst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A443B1AC57B83005A27F7 /* EffectLst.cpp */; };
17C1FCC11ACC429D006B99B3 /* FileMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A43A31AC57B83005A27F7 /* FileMap.cpp */; };
17C1FCC21ACC429D006B99B3 /* ShapeTextProperties.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A44AC1AC57B83005A27F7 /* ShapeTextProperties.cpp */; };
17C1FCC31ACC429D006B99B3 /* TransitionBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A45051AC57B83005A27F7 /* TransitionBase.cpp */; };
17C1FCC51ACC429D006B99B3 /* Shape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A44A71AC57B83005A27F7 /* Shape.cpp */; };
17C1FCC61ACC429D006B99B3 /* ShapeProperties.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A44A91AC57B83005A27F7 /* ShapeProperties.cpp */; };
17C1FCC71ACC429D006B99B3 /* BuildNodeBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A44DE1AC57B83005A27F7 /* BuildNodeBase.cpp */; };
17C1FCC81ACC429D006B99B3 /* ContentPart.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A44311AC57B83005A27F7 /* ContentPart.cpp */; };
17C1FCC91ACC429D006B99B3 /* CNvGrpSpPr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A44241AC57B83005A27F7 /* CNvGrpSpPr.cpp */; };
@ -306,7 +304,6 @@
17C1FDFE1ACC429D006B99B3 /* XfrmEffect.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A445C1AC57B83005A27F7 /* XfrmEffect.h */; };
17C1FDFF1ACC429D006B99B3 /* ChartBuildType.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A43B51AC57B83005A27F7 /* ChartBuildType.h */; };
17C1FE001ACC429D006B99B3 /* SndAc.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A45011AC57B83005A27F7 /* SndAc.h */; };
17C1FE011ACC429D006B99B3 /* ShapeProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A44AA1AC57B83005A27F7 /* ShapeProperties.h */; };
17C1FE021ACC429D006B99B3 /* AlphaModFix.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A44451AC57B83005A27F7 /* AlphaModFix.h */; };
17C1FE041ACC429D006B99B3 /* Duotone.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A444D1AC57B83005A27F7 /* Duotone.h */; };
17C1FE061ACC429D006B99B3 /* ColorBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A442A1AC57B83005A27F7 /* ColorBase.h */; };
@ -396,7 +393,6 @@
17C1FE601ACC429D006B99B3 /* Set.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A44EB1AC57B83005A27F7 /* Set.h */; };
17C1FE611ACC429D006B99B3 /* ShapeStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A44AB1AC57B83005A27F7 /* ShapeStyle.h */; };
17C1FE621ACC429D006B99B3 /* BaseLimit.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A43AE1AC57B83005A27F7 /* BaseLimit.h */; };
17C1FE631ACC429D006B99B3 /* ShapeTextProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A44AD1AC57B83005A27F7 /* ShapeTextProperties.h */; };
17C1FE641ACC429D006B99B3 /* BinReaderWriterDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = 17D91A171AC5A4DF0096D788 /* BinReaderWriterDefines.h */; };
17C1FE651ACC429D006B99B3 /* ClrMapOvr.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A44211AC57B83005A27F7 /* ClrMapOvr.h */; };
17C1FE661ACC429D006B99B3 /* Glow.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A44511AC57B83005A27F7 /* Glow.h */; };
@ -705,11 +701,7 @@
179A44A61AC57B83005A27F7 /* Scene3d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Scene3d.h; sourceTree = "<group>"; };
179A44A71AC57B83005A27F7 /* Shape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Shape.cpp; sourceTree = "<group>"; };
179A44A81AC57B83005A27F7 /* Shape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Shape.h; sourceTree = "<group>"; };
179A44A91AC57B83005A27F7 /* ShapeProperties.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShapeProperties.cpp; sourceTree = "<group>"; };
179A44AA1AC57B83005A27F7 /* ShapeProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShapeProperties.h; sourceTree = "<group>"; };
179A44AB1AC57B83005A27F7 /* ShapeStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShapeStyle.h; sourceTree = "<group>"; };
179A44AC1AC57B83005A27F7 /* ShapeTextProperties.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShapeTextProperties.cpp; sourceTree = "<group>"; };
179A44AD1AC57B83005A27F7 /* ShapeTextProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShapeTextProperties.h; sourceTree = "<group>"; };
179A44AE1AC57B83005A27F7 /* SmartArt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmartArt.cpp; sourceTree = "<group>"; };
179A44AF1AC57B83005A27F7 /* SmartArt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmartArt.h; sourceTree = "<group>"; };
179A44B01AC57B83005A27F7 /* Sp3d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sp3d.h; sourceTree = "<group>"; };
@ -1176,11 +1168,7 @@
179A44A61AC57B83005A27F7 /* Scene3d.h */,
179A44A71AC57B83005A27F7 /* Shape.cpp */,
179A44A81AC57B83005A27F7 /* Shape.h */,
179A44A91AC57B83005A27F7 /* ShapeProperties.cpp */,
179A44AA1AC57B83005A27F7 /* ShapeProperties.h */,
179A44AB1AC57B83005A27F7 /* ShapeStyle.h */,
179A44AC1AC57B83005A27F7 /* ShapeTextProperties.cpp */,
179A44AD1AC57B83005A27F7 /* ShapeTextProperties.h */,
179A44AE1AC57B83005A27F7 /* SmartArt.cpp */,
179A44AF1AC57B83005A27F7 /* SmartArt.h */,
179A44B01AC57B83005A27F7 /* Sp3d.h */,
@ -1783,7 +1771,6 @@
17C1FDFE1ACC429D006B99B3 /* XfrmEffect.h in Headers */,
17C1FDFF1ACC429D006B99B3 /* ChartBuildType.h in Headers */,
17C1FE001ACC429D006B99B3 /* SndAc.h in Headers */,
17C1FE011ACC429D006B99B3 /* ShapeProperties.h in Headers */,
17C1FE021ACC429D006B99B3 /* AlphaModFix.h in Headers */,
17C1FE041ACC429D006B99B3 /* Duotone.h in Headers */,
17C1FE061ACC429D006B99B3 /* ColorBase.h in Headers */,
@ -1873,7 +1860,6 @@
17C1FE601ACC429D006B99B3 /* Set.h in Headers */,
17C1FE611ACC429D006B99B3 /* ShapeStyle.h in Headers */,
17C1FE621ACC429D006B99B3 /* BaseLimit.h in Headers */,
17C1FE631ACC429D006B99B3 /* ShapeTextProperties.h in Headers */,
17C1FE641ACC429D006B99B3 /* BinReaderWriterDefines.h in Headers */,
17C1FE651ACC429D006B99B3 /* ClrMapOvr.h in Headers */,
17C1FE661ACC429D006B99B3 /* Glow.h in Headers */,
@ -1981,11 +1967,9 @@
17C1FCBF1ACC429D006B99B3 /* EffectLst.cpp in Sources */,
695BC03A1C070DEF00817D7E /* ASCSVGWriter.cpp in Sources */,
17C1FCC11ACC429D006B99B3 /* FileMap.cpp in Sources */,
17C1FCC21ACC429D006B99B3 /* ShapeTextProperties.cpp in Sources */,
696791821D9E8B81002CA4BA /* MathParaWrapper.cpp in Sources */,
17C1FCC31ACC429D006B99B3 /* TransitionBase.cpp in Sources */,
17C1FCC51ACC429D006B99B3 /* Shape.cpp in Sources */,
17C1FCC61ACC429D006B99B3 /* ShapeProperties.cpp in Sources */,
17C1FCC71ACC429D006B99B3 /* BuildNodeBase.cpp in Sources */,
17C1FCC81ACC429D006B99B3 /* ContentPart.cpp in Sources */,
17C1FCC91ACC429D006B99B3 /* CNvGrpSpPr.cpp in Sources */,

View File

@ -246,4 +246,7 @@ HEADERS += docxformatlib.h \
../Source/XlsxFormat/Worksheets/Sparkline.h \
../Source/XlsxFormat/Ole/OleObjects.h \
../Source/DocxFormat/Diagram/DiagramData.h \
../Source/DocxFormat/Diagram/DiagramDrawing.h
../Source/DocxFormat/Diagram/DiagramDrawing.h \
../Source/XlsxFormat/Pivot/PivotTable.h \
../Source/XlsxFormat/Pivot/PivotCacheDefinition.h \
../Source/XlsxFormat/Pivot/PivotCacheRecords.h

View File

@ -110,9 +110,16 @@ namespace OOX
OOX::CPath oName = pFile->DefaultFileName();
if(false == pFile->m_sOutputFilename.empty())
oName.SetName(pFile->m_sOutputFilename, false);
OOX::CSystemUtility::CreateDirectories( oCurrent / oDefDir );
pFile->write( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
std::map<std::wstring, std::wstring>::const_iterator itFind = m_mNoWriteContainer.find(pPair->first);
if(m_mNoWriteContainer.end() == itFind)
{
OOX::CSystemUtility::CreateDirectories( oCurrent / oDefDir );
pFile->write( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
}
else if(itFind->second.length() > 0)
{
oDefDir = itFind->second;
}
if(true != pFile->m_bDoNotAddRels)
{
if (oDefDir.GetPath().length() > 0)//todooo перенести в CPath
@ -187,16 +194,23 @@ namespace OOX
mNamepair [oName.m_strFilename] = 1;
else
oName = oName + pNamePair->first;
OOX::CSystemUtility::CreateDirectories( oCurrent / oDefDir );
smart_ptr<OOX::IFileBuilder> pFileBuilder = pFile.smart_dynamic_cast<OOX::IFileBuilder>();
if ( pFileBuilder.is_init() )
std::map<std::wstring, std::wstring>::const_iterator itFind = m_mNoWriteContainer.find(it->first);
if(m_mNoWriteContainer.end() == itFind)
{
pFileBuilder->Finalize( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
OOX::CSystemUtility::CreateDirectories( oCurrent / oDefDir );
smart_ptr<OOX::IFileBuilder> pFileBuilder = pFile.smart_dynamic_cast<OOX::IFileBuilder>();
if ( pFileBuilder.is_init() )
{
pFileBuilder->Finalize( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
}
else
{
pFile->write( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
}
}
else
else if(itFind->second.length() > 0)
{
pFile->write( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
oDefDir = itFind->second;
}
oRels.Registration( it->first, pFile->type(), oDefDir / oName );
@ -386,6 +400,20 @@ namespace OOX
m_mContainer [rId.get()] = pFile;
}
const RId IFileContainer::AddNoWrite(const smart_ptr<OOX::File>& pFile, const std::wstring& oDefDir)
{
const RId rId = GetMaxRId().next();
AddNoWrite( rId, pFile, oDefDir );
return rId;
}
void IFileContainer::AddNoWrite (const OOX::RId& rId, const smart_ptr<OOX::File>& pFile, const std::wstring& oDefDir)
{
m_lMaxRid = (std::max)( m_lMaxRid, rId.getNumber() );
m_mContainer [rId.get()] = pFile;
m_mNoWriteContainer[rId.get()] = oDefDir;
}
smart_ptr<OOX::File> IFileContainer::Find(const FileType& oType) const
{
for (std::map<std::wstring, smart_ptr<OOX::File>>::const_iterator pPair = m_mContainer.begin(); pPair != m_mContainer.end(); ++pPair)

View File

@ -67,6 +67,7 @@ namespace OOX
static std::map<std::wstring, size_t> m_mapEnumeratedGlobal;
protected:
std::map<std::wstring, smart_ptr<OOX::File>> m_mContainer;
std::map<std::wstring, std::wstring> m_mNoWriteContainer;
size_t m_lMaxRid;
void Read (const OOX::CRels& oRels, const OOX::CPath& oRootPath, const CPath& oPath);
@ -103,6 +104,8 @@ namespace OOX
const RId Add(smart_ptr<OOX::File>& pFile);
void Add(const OOX::RId& rId, smart_ptr<OOX::File>& pFile);
const RId AddNoWrite(const smart_ptr<OOX::File>& pFile, const std::wstring& oDefDir);
void AddNoWrite(const OOX::RId& rId, const smart_ptr<OOX::File>& pFile, const std::wstring& oDefDir);
template<typename T>
T& Find();

View File

@ -81,6 +81,18 @@ namespace OOX
const FileType ExternalLinks (L"externalLinks", L"externalLink.xml",
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink"), true, true);
const FileType PivotTable (L"../pivotTables", L"pivotTable.xml",
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable"), true, true);
const FileType PivotCacheDefinition(L"pivotCache", L"pivotCacheDefinition.xml",
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition"), true);
const FileType PivotCacheRecords(L"", L"pivotCacheRecords.xml",
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords"), true, true);
} // namespace FileTypes

View File

@ -0,0 +1,142 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_PIVOTCACHEDEFINITION_FILE_INCLUDE_H_
#define OOX_PIVOTCACHEDEFINITION_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CPivotCacheDefinition : public OOX::File, public OOX::IFileContainer
{
public:
CPivotCacheDefinition()
{
m_bSpreadsheets = true;
bIsWritten = false;
m_pData = NULL;
m_nDataLength = 0;
}
CPivotCacheDefinition(const CPath& oRootPath, const CPath& oPath)
{
m_bSpreadsheets = true;
bIsWritten = false;
m_pData = NULL;
m_nDataLength = 0;
read( oRootPath, oPath );
}
virtual ~CPivotCacheDefinition()
{
ClearItems();
}
public:
virtual void read(const CPath& oPath)
{
}
virtual void read(const CPath& oRootPath, const CPath& oPath)
{
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
if(m_nDataLength > 0 && !bIsWritten)
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(oPath.GetPath());
oFile.WriteFile(m_pData, m_nDataLength);
oFile.CloseFile();
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
IFileContainer::Write( oPath, oDirectory, oContent );
//prevent repeated write
bIsWritten = true;
}
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::PivotCacheDefinition;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
const CPath& GetReadPath()
{
return m_oReadPath;
}
void setData(BYTE* pData, long length, const std::wstring& srIdRecords)
{
if(srIdRecords.length() > 0)
{
const std::string srIdRecordsA( srIdRecords.begin(), srIdRecords.end() );
std::string rIdAttr = " r:id=\""+ srIdRecordsA +"\"";
m_nDataLength = length + rIdAttr.length();
m_pData = new BYTE[m_nDataLength];
long nTreshold = 220;
memcpy(m_pData, pData, nTreshold);
memcpy(m_pData + nTreshold, rIdAttr.c_str(), rIdAttr.length());
memcpy(m_pData + nTreshold + rIdAttr.length(), pData + nTreshold, length - nTreshold);
}
else
{
m_nDataLength = length;
memcpy(m_pData, pData, length);
}
}
private:
CPath m_oReadPath;
void ClearItems()
{
m_nDataLength = 0;
RELEASEARRAYOBJECTS(m_pData)
}
public:
mutable bool bIsWritten;
BYTE* m_pData;
long m_nDataLength;
};
} //Spreadsheet
} // namespace OOX
#endif // OOX_PIVOTCACHEDEFINITION_FILE_INCLUDE_H_

View File

@ -0,0 +1,124 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_PIVOTCACHERECORDS_FILE_INCLUDE_H_
#define OOX_PIVOTCACHERECORDS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CPivotCacheRecords : public OOX::File, public OOX::IFileContainer
{
public:
CPivotCacheRecords()
{
m_bSpreadsheets = true;
m_pData = NULL;
m_nDataLength = 0;
}
CPivotCacheRecords(const CPath& oRootPath, const CPath& oPath)
{
m_bSpreadsheets = true;
m_pData = NULL;
m_nDataLength = 0;
read( oRootPath, oPath );
}
virtual ~CPivotCacheRecords()
{
ClearItems();
}
public:
virtual void read(const CPath& oPath)
{
}
virtual void read(const CPath& oRootPath, const CPath& oPath)
{
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
if(m_nDataLength > 0)
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(oPath.GetPath());
oFile.WriteFile(m_pData, m_nDataLength);
oFile.CloseFile();
oContent.Registration(type().OverrideType(), oDirectory, oPath.GetFilename());
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
IFileContainer::Write( oPath, oDirectory, oContent );
}
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::PivotCacheRecords;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
const CPath& GetReadPath()
{
return m_oReadPath;
}
void setData(BYTE* pData, long length)
{
m_nDataLength = length;
m_pData = new BYTE[length];
memcpy(m_pData, pData, length);
}
private:
CPath m_oReadPath;
void ClearItems()
{
m_nDataLength = 0;
RELEASEARRAYOBJECTS(m_pData)
}
public:
BYTE* m_pData;
long m_nDataLength;
};
} //Spreadsheet
} // namespace OOX
#endif // OOX_PIVOTCACHERECORDS_FILE_INCLUDE_H_

View File

@ -0,0 +1,122 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_PIVOTTABLE_FILE_INCLUDE_H_
#define OOX_PIVOTTABLE_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CPivotTable : public OOX::File, public OOX::IFileContainer
{
public:
CPivotTable()
{
m_bSpreadsheets = true;
m_pData = NULL;
m_nDataLength = 0;
}
CPivotTable(const CPath& oRootPath, const CPath& oPath)
{
m_bSpreadsheets = true;
m_pData = NULL;
m_nDataLength = 0;
read( oRootPath, oPath );
}
virtual ~CPivotTable()
{
ClearItems();
}
public:
virtual void read(const CPath& oPath)
{
}
virtual void read(const CPath& oRootPath, const CPath& oPath)
{
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
if(m_nDataLength > 0)
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(oPath.GetPath());
oFile.WriteFile(m_pData, m_nDataLength);
oFile.CloseFile();
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
IFileContainer::Write( oPath, oDirectory, oContent );
}
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::PivotTable;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
const CPath& GetReadPath()
{
return m_oReadPath;
}
void setData(BYTE* pData, long length)
{
m_nDataLength = length;
m_pData = new BYTE[length];
memcpy(m_pData, pData, length);
}
private:
CPath m_oReadPath;
void ClearItems()
{
m_nDataLength = 0;
RELEASEARRAYOBJECTS(m_pData)
}
public:
BYTE* m_pData;
long m_nDataLength;
};
} //Spreadsheet
} // namespace OOX
#endif // OOX_PIVOTTABLE_FILE_INCLUDE_H_

View File

@ -198,6 +198,7 @@ namespace OOX
WritingStringNullableAttrBool(L"applyBorder", m_oApplyBorder);
WritingStringNullableAttrBool(L"applyAlignment", m_oApplyAlignment);
WritingStringNullableAttrBool(L"quotePrefix", m_oQuotePrefix);
WritingStringNullableAttrBool(L"pivotButton", m_oPivotButton);
if(m_oAligment.IsInit())
{
writer.WriteString(_T(">"));

View File

@ -137,6 +137,8 @@ namespace OOX
m_oDefinedNames->toXML(sXml);
sXml.WriteString(_T("<calcPr calcId=\"145621\"/>"));
if(m_oPivotCachesXml.IsInit())
sXml.WriteString(m_oPivotCachesXml.get());
sXml.WriteString(_T("</workbook>"));
std::wstring sPath = oPath.GetPath();
@ -208,7 +210,7 @@ namespace OOX
nullable<OOX::Spreadsheet::CSheets> m_oSheets;
nullable<OOX::Spreadsheet::CWorkbookPr> m_oWorkbookPr;
nullable<OOX::Spreadsheet::CExternalReferences> m_oExternalReferences;
nullable<std::wstring> m_oPivotCachesXml;
};
} //Spreadsheet
} // namespace OOX

View File

@ -47,6 +47,9 @@
#include "CalcChain/CalcChain.h"
#include "ExternalLinks/ExternalLinks.h"
#include "ExternalLinks/ExternalLinkPath.h"
#include "Pivot/PivotTable.h"
#include "Pivot/PivotCacheDefinition.h"
#include "Pivot/PivotCacheRecords.h"
#include "../../../DesktopEditor/common/Directory.h"

View File

@ -0,0 +1,427 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef _BUILD_BIGINTEGER_CROSSPLATFORM_H_
#define _BUILD_BIGINTEGER_CROSSPLATFORM_H_
#include <string>
class CBigInteger
{
protected:
std::string m_value;
bool m_isNegative;
public:
CBigInteger()
{
m_value = "0";
m_isNegative = false;
}
CBigInteger(unsigned char* data, int size)
{
m_isNegative = false;
m_value = "0";
for (int i = 0; i < size; i++)
{
CBigInteger tmp((int)data[i]);
for (int j = size - 1 - i; j > 0; --j)
tmp *= 256;
*this += tmp;
}
}
CBigInteger(std::string data, int nBase = 10)
{
m_isNegative = false;
if (10 == nBase)
{
m_value = data;
}
else
{
m_value = "0";
int len = (int)data.length();
for (int i = 0; i < len; i++)
{
int val = 0;
char _c = data[i];
if (_c >= '0' && _c <= '9')
val = _c - '0';
else if (_c >= 'A' && _c <= 'F')
val = 10 + _c - 'A';
else if (_c >= 'a' && _c <= 'f')
val = 10 + _c - 'a';
CBigInteger tmp(val);
for (int j = len - 1 - i; j > 0; --j)
tmp *= nBase;
*this += tmp;
}
}
}
CBigInteger(int value)
{
if (value < 0)
{
m_isNegative = true;
m_value = std::to_string(-value);
}
else
{
m_isNegative = false;
m_value = std::to_string(value);
}
}
std::string GetValue()
{
return m_value;
}
bool IsNegative()
{
return m_isNegative;
}
void operator = (CBigInteger b)
{
m_value = b.m_value;
m_isNegative = b.m_isNegative;
}
bool operator == (CBigInteger b)
{
return equals((*this) , b);
}
bool operator != (CBigInteger b)
{
return !equals((*this) , b);
}
bool operator > (CBigInteger b)
{
return greater((*this) , b);
}
bool operator < (CBigInteger b)
{
return less((*this) , b);
}
bool operator >= (CBigInteger b)
{
return equals((*this) , b) || greater((*this), b);
}
bool operator <= (CBigInteger b)
{
return equals((*this) , b) || less((*this) , b);
}
CBigInteger absolute()
{
return CBigInteger(m_value); // +ve by default
}
CBigInteger& operator ++()
{
// prefix
(*this) = (*this) + 1;
return (*this);
}
CBigInteger operator ++(int)
{
// postfix
CBigInteger before = (*this);
(*this) = (*this) + 1;
return before;
}
CBigInteger& operator --()
{
// prefix
(*this) = (*this) - 1;
return (*this);
}
CBigInteger operator --(int)
{
// postfix
CBigInteger before = (*this);
(*this) = (*this) - 1;
return before;
}
CBigInteger operator + (CBigInteger b)
{
CBigInteger addition;
if (m_isNegative == b.m_isNegative)
{
// both +ve or -ve
addition.m_value = (add(m_value, b.m_value));
addition.m_isNegative = m_isNegative;
}
else
{
// sign different
if (absolute() > b.absolute())
{
addition.m_value = subtract(m_value, b.m_value);
addition.m_isNegative = m_isNegative;
}
else
{
addition.m_value = subtract(b.m_value, m_value);
addition.m_isNegative = b.m_isNegative;
}
}
if (addition.m_value == "0") // avoid (-0) problem
addition.m_isNegative = false;
return addition;
}
CBigInteger operator - (CBigInteger b)
{
b.m_isNegative = !b.m_isNegative; // x - y = x + (-y)
return (*this) + b;
}
CBigInteger operator * (CBigInteger b)
{
CBigInteger mul;
mul.m_value = multiply(m_value, b.m_value);
mul.m_isNegative = (m_isNegative != b.m_isNegative);
if (mul.m_value == "0") // avoid (-0) problem
mul.m_isNegative = false;
return mul;
}
CBigInteger& operator += (CBigInteger b)
{
(*this) = (*this) + b;
return (*this);
}
CBigInteger& operator -= (CBigInteger b)
{
(*this) = (*this) - b;
return (*this);
}
CBigInteger& operator *= (CBigInteger b)
{
(*this) = (*this) * b;
return (*this);
}
CBigInteger operator -() { // unary minus sign
return (*this) * -1;
}
std::string ToString()
{
// for conversion from BigInteger to string
std::string signedString = ( m_isNegative ) ? "-" : ""; // if +ve, don't print + sign
signedString += m_value;
return signedString;
}
private:
bool equals(CBigInteger n1, CBigInteger n2)
{
return ((n1.m_value == n2.m_value) && (n1.m_isNegative == n2.m_isNegative));
}
bool less(CBigInteger n1, CBigInteger n2)
{
bool sign1 = n1.m_isNegative;
bool sign2 = n2.m_isNegative;
if (sign1 && !sign2)
return true;
else if (!sign1 && sign2)
return false;
else if (!sign1)
{
std::string::size_type _size1 = n1.m_value.length();
std::string::size_type _size2 = n2.m_value.length();
if (_size1 < _size2)
return true;
if (_size1 > _size2)
return false;
return n1.m_value < n2.m_value;
}
else
{
std::string::size_type _size1 = n1.m_value.length();
std::string::size_type _size2 = n2.m_value.length();
if (_size1 > _size2)
return true;
if (_size1 < _size2)
return false;
return n1.m_value.compare(n2.m_value) > 0;
}
}
bool greater(CBigInteger n1, CBigInteger n2)
{
return !equals(n1, n2) && !less(n1, n2);
}
std::string add(std::string number1, std::string number2)
{
std::string add = (number1.length() > number2.length()) ? number1 : number2;
char carry = '0';
int differenceInLength = (int)(number1.size() - number2.size());
if (differenceInLength > 0)
number2.insert(0, differenceInLength, '0');
else
number1.insert(0, -differenceInLength, '0');
if (differenceInLength < 0)
differenceInLength = -differenceInLength;
for (int i = number1.size() - 1; i >= 0; --i)
{
add[i] = ((carry-'0')+(number1[i]-'0')+(number2[i]-'0')) + '0';
if(i != 0)
{
if(add[i] > '9')
{
add[i] -= 10;
carry = '1';
}
else
{
carry = '0';
}
}
}
if (add[0] > '9')
{
add[0] -= 10;
add.insert(0, 1, '1');
}
return add;
}
std::string subtract(std::string number1, std::string number2)
{
std::string sub = (number1.length() > number2.length()) ? number1 : number2;
int differenceInLength = (int)(number1.size() - number2.size());
if (differenceInLength > 0)
number2.insert(0, differenceInLength, '0');
else
number1.insert(0, -differenceInLength, '0');
if (differenceInLength < 0)
differenceInLength = -differenceInLength;
for (int i = number1.length() - 1; i >= 0; --i)
{
if (number1[i] < number2[i])
{
number1[i] += 10;
number1[i-1]--;
}
sub[i] = ((number1[i]-'0')-(number2[i]-'0')) + '0';
}
while (sub[0]=='0' && sub.length() != 1) // erase leading zeros
sub.erase(0, 1);
return sub;
}
std::string multiply(std::string n1, std::string n2)
{
if (n1.length() > n2.length())
n1.swap(n2);
std::string res = "0";
for (int i = n1.length() - 1; i >= 0; --i)
{
std::string temp = n2;
int currentDigit = n1[i] - '0';
int carry = 0;
for (int j = temp.length() - 1; j >= 0; --j)
{
temp[j] = ((temp[j]-'0') * currentDigit) + carry;
if (temp[j] > 9)
{
carry = (temp[j] / 10);
temp[j] -= (carry * 10);
}
else
{
carry = 0;
}
temp[j] += '0'; // back to string mood
}
if (carry > 0)
temp.insert(0, 1, (carry+'0'));
temp.append((n1.length() - i - 1), '0'); // as like mult by 10, 100, 1000, 10000 and so on
res = add(res, temp); // O(n)
}
while (res[0] == '0' && res.length() != 1) // erase leading zeros
res.erase(0,1);
return res;
}
};
#endif //_BUILD_BIGINTEGER_CROSSPLATFORM_H_

View File

@ -45,7 +45,8 @@
#include <windows.h>
#endif
#define U_TO_UTF8(val) NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(val.c_str(), val.length())
#define U_TO_UTF8(val) NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(val.c_str(), (LONG)val.length())
#define UTF8_TO_U(val) NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)val.c_str(), (LONG)val.length())
#if defined(__linux__) || defined(_MAC) && !defined(_IOS)
#include <unistd.h>

View File

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sha1_C14N", "ConsoleApplication1\Sha1_C14N.csproj", "{A945E071-111A-41E0-8BB0-4F7755EBB77B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A945E071-111A-41E0-8BB0-4F7755EBB77B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A945E071-111A-41E0-8BB0-4F7755EBB77B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A945E071-111A-41E0-8BB0-4F7755EBB77B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A945E071-111A-41E0-8BB0-4F7755EBB77B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

View File

@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;
using System.Security.Cryptography.X509Certificates;
using System.IO;
namespace Sha1_C14N
{
class Program
{
static void Main(string[] args)
{
XmlDocument docStripped = new XmlDocument();
//docStripped.Load(@"D:\GIT\core\DesktopEditor\xmlsec\test\windows_list_serts\Debug\debug\document.xml");
docStripped.Load("D:\\444.txt");
XmlDsigC14NTransform t = new XmlDsigC14NTransform();
t.LoadInput(docStripped);
Stream s = (Stream)t.GetOutput(typeof(Stream));
BinaryReader br = new BinaryReader(s);
byte[] b = br.ReadBytes((int)s.Length);
File.Delete("D:\\1.txt");
var fileStream = File.Create("D:\\1.txt");
s.Seek(0, SeekOrigin.Begin);
s.CopyTo(fileStream);
fileStream.Close();
s.Seek(0, SeekOrigin.Begin);
SHA1 sha1 = SHA1.Create();
byte[] hash = sha1.ComputeHash(s);
string base64String = Convert.ToBase64String(hash);
FileStream fRes = File.Create("D:\\res.bin");
fRes.Write(hash, 0, hash.Length);
fRes.Close();
SHA1 sha33 = SHA1.Create();
byte[] hash33 = sha33.ComputeHash(b);
string base64String2 = Convert.ToBase64String(hash33);
FileStream s1 = File.OpenRead(@"D:\GIT\core\DesktopEditor\xmlsec\test\windows_list_serts\Debug\debug\document2.xml");
SHA1 sha11 = SHA1.Create();
byte[] hash11 = sha11.ComputeHash(s1);
string base64_11 = Convert.ToBase64String(hash11);
X509Store my = new X509Store(StoreName.My, StoreLocation.CurrentUser);
my.Open(OpenFlags.ReadOnly);
// Find the certificate well use to sign
RSACryptoServiceProvider csp = null;
foreach (X509Certificate2 cert in my.Certificates)
{
string sName = cert.Subject;
if (cert.Subject.Contains("Oleg.Korshul"))
{
csp = (RSACryptoServiceProvider)cert.PrivateKey;
break;
}
}
byte[] signedData = csp.SignHash(hash11, CryptoConfig.MapNameToOID("SHA1"));
string signedDataBase64 = Convert.ToBase64String(signedData);
Console.WriteLine(base64_11);
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Управление общими сведениями о сборке осуществляется с помощью
// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
// связанные со сборкой.
[assembly: AssemblyTitle("Sha1_C14N")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Sha1_C14N")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Параметр ComVisible со значением FALSE делает типы в сборке невидимыми
// для COM-компонентов. Если требуется обратиться к типу в этой сборке через
// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("a945e071-111a-41e0-8bb0-4f7755ebb77b")]
// Сведения о версии сборки состоят из следующих четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A945E071-111A-41E0-8BB0-4F7755EBB77B}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleApplication1</RootNamespace>
<AssemblyName>ConsoleApplication1</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Security" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -7,21 +7,355 @@
#include <string>
#include "../../../common/File.h"
#include "../../../common/Directory.h"
#include "../../../common/BigInteger.h"
#include "../../../xml/include/xmlutils.h"
#include "../../../xml/libxml2/include/libxml/c14n.h"
#include <vector>
#pragma comment (lib, "crypt32.lib")
#pragma comment (lib, "cryptui.lib")
#pragma comment (lib, "Advapi32.lib")
//#define ENUMS_CERTS
class CXmlCanonicalizator
{
private:
class CXmlBuffer
{
public:
NSStringUtils::CStringBuilderA builder;
public:
CXmlBuffer()
{
}
~CXmlBuffer()
{
}
};
static int buffer_xmlBufferIOWrite(CXmlBuffer* buf, const char* buffer, int len)
{
buf->builder.WriteString(buffer, (size_t)len);
return len;
}
static int buffer_xmlBufferIOClose(CXmlBuffer* buf)
{
return 0;
}
static int buffer_xmlC14NIsVisibleCallback(void * user_data, xmlNodePtr node, xmlNodePtr parent)
{
if (node->type == XML_TEXT_NODE)
{
const char* cur = (char*)node->content;
size_t size = strlen(cur);
for (size_t i = 0; i < size; ++i, ++cur)
{
if (*cur != '\n' && *cur != '\r' && *cur != '\t')
return 1;
}
return 0;
}
return 1;
}
public:
static std::string Execute(const std::string& sXml, int mode)
{
xmlDocPtr xmlDoc = xmlParseMemory((char*)sXml.c_str(), (int)sXml.length());
CXmlBuffer bufferC14N;
xmlOutputBufferPtr _buffer = xmlOutputBufferCreateIO((xmlOutputWriteCallback)buffer_xmlBufferIOWrite,
(xmlOutputCloseCallback)buffer_xmlBufferIOClose,
&bufferC14N,
NULL);
xmlC14NExecute(xmlDoc, buffer_xmlC14NIsVisibleCallback, NULL, mode, NULL, 0, _buffer);
xmlOutputBufferClose(_buffer);
return bufferC14N.builder.GetData();
}
static std::string Execute(const std::wstring& sXmlFile, int mode)
{
std::string sXml;
NSFile::CFileBinary::ReadAllTextUtf8A(sXmlFile, sXml);
xmlDocPtr xmlDoc = xmlParseMemory((char*)sXml.c_str(), (int)sXml.length());
return Execute(sXml, mode);
}
};
class CXmlSigner
{
private:
PCCERT_CONTEXT m_context;
public:
CXmlSigner(PCCERT_CONTEXT pCertContext)
{
m_context = pCertContext;
}
~CXmlSigner()
{
}
public:
std::string Sign(std::string sXml)
{
BOOL bResult = TRUE;
DWORD dwKeySpec = 0;
HCRYPTHASH hHash = NULL;
HCRYPTPROV hCryptProv = NULL;
bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
if (!bResult)
return "";
bResult = CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash);
if (!bResult)
{
CryptReleaseContext(hCryptProv, 0);
return "";
}
bResult = CryptHashData(hHash, (BYTE*)sXml.c_str(), (DWORD)sXml.length(), 0);
if (!bResult)
{
CryptDestroyHash(hHash);
CryptReleaseContext(hCryptProv, 0);
return "";
}
DWORD dwSigLen = 0;
BYTE* pbSignature = NULL;
bResult = CryptSignHash(hHash, dwKeySpec, NULL, 0, NULL, &dwSigLen);
if (!bResult)
{
CryptDestroyHash(hHash);
CryptReleaseContext(hCryptProv, 0);
return "";
}
pbSignature = new BYTE[dwSigLen];
bResult = CryptSignHash(hHash, dwKeySpec, NULL, 0, pbSignature, &dwSigLen);
if (!bResult)
{
CryptDestroyHash(hHash);
CryptReleaseContext(hCryptProv, 0);
return "";
}
BYTE* pbSignatureMem = new BYTE[dwSigLen];
ConvertEndian(pbSignature, pbSignatureMem, dwSigLen);
char* pBase64 = NULL;
int nBase64Len = 0;
NSFile::CBase64Converter::Encode(pbSignatureMem, (int)dwSigLen, pBase64, nBase64Len, NSBase64::B64_BASE64_FLAG_NONE);
delete[] pbSignature;
delete[] pbSignatureMem;
bResult = CryptDestroyHash(hHash);
std::string sReturn(pBase64, nBase64Len);
delete[] pBase64;
CryptReleaseContext(hCryptProv, 0);
return sReturn;
}
std::string GetHash(BYTE* pData, DWORD dwSize)
{
BOOL bResult = TRUE;
DWORD dwKeySpec = 0;
HCRYPTHASH hHash = NULL;
HCRYPTPROV hCryptProv = NULL;
bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
if (!bResult)
return "";
bResult = CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash);
if (!bResult)
{
CryptReleaseContext(hCryptProv, 0);
return "";
}
bResult = CryptHashData(hHash, pData, dwSize, 0);
if (!bResult)
{
CryptDestroyHash(hHash);
CryptReleaseContext(hCryptProv, 0);
return "";
}
DWORD cbHashSize = 0, dwCount = sizeof(DWORD);
bResult = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&cbHashSize, &dwCount, 0);
if (!bResult)
{
CryptDestroyHash(hHash);
CryptReleaseContext(hCryptProv, 0);
return "";
}
BYTE* pDataHashRaw = new BYTE[dwCount];
bResult = CryptGetHashParam(hHash, HP_HASHVAL, pDataHashRaw, &cbHashSize, 0);
if (!bResult)
{
CryptDestroyHash(hHash);
CryptReleaseContext(hCryptProv, 0);
return "";
}
char* pBase64_hash = NULL;
int nBase64Len_hash = 0;
NSFile::CBase64Converter::Encode(pDataHashRaw, (int)cbHashSize, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NOCRLF);
std::string sReturn(pBase64_hash, nBase64Len_hash);
delete [] pBase64_hash;
//delete [] pDataHashRaw;
CryptDestroyHash(hHash);
CryptReleaseContext(hCryptProv, 0);
return sReturn;
}
std::string GetHash(std::string& sXml)
{
return GetHash((BYTE*)sXml.c_str(), (DWORD)sXml.length());
}
std::string GetHash(std::wstring& sXmlFile)
{
BYTE* pFileData = NULL;
DWORD dwFileDataLen = 0;
NSFile::CFileBinary::ReadAllBytes(sXmlFile, &pFileData, dwFileDataLen);
if (0 == dwFileDataLen)
return "";
std::string sReturn = GetHash(pFileData, dwFileDataLen);
RELEASEARRAYOBJECTS(pFileData);
return sReturn;
}
BOOL Verify(std::string& sXml, std::string& sXmlSignature)
{
DWORD dwKeySpec = 0;
HCRYPTHASH hHash = NULL;
HCRYPTKEY hPubKey = NULL;
HCRYPTPROV hCryptProv = NULL;
BOOL bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
if (!bResult)
return FALSE;
bResult = CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash);
if (!bResult)
{
CryptReleaseContext(hCryptProv, 0);
return FALSE;
}
BYTE* pDataHash = NULL;
DWORD dwHashLen = 0;
int nTmp = 0;
NSFile::CBase64Converter::Decode((char*)sXmlSignature.c_str(), (int)sXmlSignature.length(), pDataHash, nTmp);
dwHashLen = (DWORD)nTmp;
BYTE* pDataHashMem = new BYTE[dwHashLen];
ConvertEndian(pDataHash, pDataHashMem, dwHashLen);
RELEASEARRAYOBJECTS(pDataHash);
bResult = CryptHashData(hHash, (BYTE*)sXml.c_str(), (DWORD)sXml.length(), 0);
// Get the public key from the certificate
CryptImportPublicKeyInfo(hCryptProv, m_context->dwCertEncodingType, &m_context->pCertInfo->SubjectPublicKeyInfo, &hPubKey);
BOOL bResultRet = CryptVerifySignature(hHash, pDataHashMem, dwHashLen, hPubKey, NULL, 0);
delete[] pDataHashMem;
bResult = CryptDestroyHash(hHash);
CryptDestroyKey(hPubKey);
CryptReleaseContext(hCryptProv, 0);
return bResultRet && bResult;
}
std::string GetCertificateBase64()
{
char* pData = NULL;
int nDataLen = 0;
NSFile::CBase64Converter::Encode(m_context->pbCertEncoded, (int)m_context->cbCertEncoded, pData, nDataLen, NSBase64::B64_BASE64_FLAG_NOCRLF);
std::string sReturn(pData, nDataLen);
RELEASEARRAYOBJECTS(pData);
return sReturn;
}
std::string GetCertificateHash()
{
return GetHash(m_context->pbCertEncoded, (int)m_context->cbCertEncoded);
}
public:
static void ConvertEndian(const BYTE* src, BYTE* dst, DWORD size)
{
for(BYTE* p = dst + size - 1; p >= dst; ++src, --p)
(*p) = (*src);
}
};
#define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)
void MyHandleError(char *s);
bool Sign(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
bool Verify(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
bool Sign(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
bool Verify(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
bool SignDocument(std::wstring sFolderOOXML, PCCERT_CONTEXT pCertContext);
void main(void)
{
if (false)
{
CBigInteger int1("345097");
CBigInteger int2("87960324");
CBigInteger val1 = int1 + int2;
CBigInteger val2 = int1 - int2;
CBigInteger val3 = int1 * int2;
CBigInteger int3("66A1F302407647974D18D489855371B5", 16);
unsigned char buffer[16] = { 0x66, 0xA1, 0xF3, 0x02, 0x40, 0x76, 0x47, 0x97, 0x4D, 0x18, 0xD4, 0x89, 0x85, 0x53, 0x71, 0xB5 };
CBigInteger val4(buffer, 16);
std::string sValue = int3.ToString();
}
//-------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
@ -310,10 +644,19 @@ void main(void)
MyHandleError("Select UI failed." );
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool bRes = true;
bRes = Sign(hCertStore, pCertContext, NSFile::GetProcessDirectory() + L"/document.xml", NSFile::GetProcessDirectory() + L"/result.txt");
bRes = Verify(hCertStore, pCertContext, NSFile::GetProcessDirectory() + L"/document.xml", NSFile::GetProcessDirectory() + L"/result.txt");
if (false)
{
bool bRes = true;
bRes = Sign(pCertContext, NSFile::GetProcessDirectory() + L"/test.xml", NSFile::GetProcessDirectory() + L"/result.txt");
bRes = Verify(pCertContext, NSFile::GetProcessDirectory() + L"/test.xml", NSFile::GetProcessDirectory() + L"/result.txt");
CXmlSigner oSigner(pCertContext);
std::string sCertBase64 = oSigner.GetCertificateBase64();
std::string sCertHash = oSigner.GetCertificateHash();
}
SignDocument(NSFile::GetProcessDirectory() + L"/ImageStamp", pCertContext);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CertFreeCertificateContext(pCertContext);
@ -330,97 +673,325 @@ void MyHandleError(LPTSTR psz)
exit(1);
} // End of MyHandleError.
bool Sign(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile)
bool Sign(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile)
{
// Variables
HCRYPTPROV hCryptProv = NULL;
DWORD dwKeySpec = 0;
HCRYPTHASH hHash = NULL;
std::string sXmlPrepare = CXmlCanonicalizator::Execute(sFileXml, XML_C14N_1_0);
BOOL bResult = FALSE;
DWORD dwSigLen = 0;
BYTE* pbSignature = NULL;
// Open the certificate store.
bResult = CryptAcquireCertificatePrivateKey(pCertContext, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
bool bIsResult = ((dwKeySpec & AT_SIGNATURE) == AT_SIGNATURE);
// Create the hash object.
bResult = CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash);
BYTE* pDataSrc = NULL;
DWORD dwFileSrcLen = 0;
NSFile::CFileBinary::ReadAllBytes(sFileXml, &pDataSrc, dwFileSrcLen);
bResult = CryptHashData(hHash, pDataSrc, dwFileSrcLen, 0);
// Sign the hash object
dwSigLen = 0;
bResult = CryptSignHash(hHash, dwKeySpec, NULL, 0, NULL, &dwSigLen);
pbSignature = new BYTE[dwSigLen];
bResult = CryptSignHash(hHash, dwKeySpec, NULL, 0, pbSignature, &dwSigLen);
CXmlSigner oSigner(pCertContext);
std::string sXmlSigned = oSigner.Sign(sXmlPrepare);
NSFile::CFileBinary oFile;
oFile.CreateFileW(sSignatureFile);
//oFile.WriteFile(pbSignature, dwSigLen);
char* pBase64 = NULL;
int nBase64Len = 0;
NSFile::CBase64Converter::Encode(pbSignature, (int)dwSigLen, pBase64, nBase64Len, NSBase64::B64_BASE64_FLAG_NONE);
oFile.WriteFile((BYTE*)pBase64, (DWORD)nBase64Len);
oFile.WriteFile((BYTE*)sXmlSigned.c_str(), (DWORD)sXmlSigned.length());
oFile.CloseFile();
delete[] pbSignature;
delete[] pDataSrc;
bResult = CryptDestroyHash(hHash);
return (bResult == TRUE);
return (!sXmlSigned.empty());
}
bool Verify(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile)
bool Verify(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile)
{
DWORD dwKeySpec = 0;
HCRYPTPROV hCryptProv = NULL;
HCRYPTHASH hHash = NULL;
HCRYPTKEY hPubKey = NULL;
std::string sXmlUtf8;
NSFile::CFileBinary::ReadAllTextUtf8A(sFileXml, sXmlUtf8);
BOOL bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
std::string sXmlUtf8Prepare = CXmlCanonicalizator::Execute(sXmlUtf8, XML_C14N_1_0);
// Create the hash object.
bResult = CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash);
std::string sXmlUtf8Signature;
NSFile::CFileBinary::ReadAllTextUtf8A(sSignatureFile, sXmlUtf8Signature);
BYTE* pDataSrc = NULL;
DWORD dwFileSrcLen = 0;
NSFile::CFileBinary::ReadAllBytes(sFileXml, &pDataSrc, dwFileSrcLen);
if (sXmlUtf8Prepare.empty() || sXmlUtf8Signature.empty())
return false;
BYTE* pDataHashBase64 = NULL;
DWORD dwFileHashSrcLenBase64 = 0;
NSFile::CFileBinary::ReadAllBytes(sSignatureFile, &pDataHashBase64, dwFileHashSrcLenBase64);
BYTE* pDataHash = NULL;
DWORD dwHashLen = 0;
int nTmp = 0;
NSFile::CBase64Converter::Decode((char*)pDataHashBase64, (int)dwFileHashSrcLenBase64, pDataHash, nTmp);
dwHashLen = (DWORD)nTmp;
bResult = CryptHashData(hHash, pDataSrc, dwFileSrcLen, 0);
// Get the public key from the certificate
CryptImportPublicKeyInfo(hCryptProv, PKCS_7_ASN_ENCODING | X509_ASN_ENCODING, &pCertContext->pCertInfo->SubjectPublicKeyInfo, &hPubKey);
bResult = CryptVerifySignature(hHash, pDataHash, dwHashLen, hPubKey, NULL, 0);
delete[] pDataSrc;
delete[] pDataHash;
delete[] pDataHashBase64;
bResult = CryptDestroyHash(hHash);
return bResult;
CXmlSigner oSigner(pCertContext);
return (TRUE == oSigner.Verify(sXmlUtf8Prepare, sXmlUtf8Signature));
}
class COOXMLSigner
{
public:
PCCERT_CONTEXT m_context;
std::wstring m_sFolder;
CXmlSigner* m_signer;
public:
COOXMLSigner(const std::wstring& sFolder, PCCERT_CONTEXT pContext)
{
m_sFolder = sFolder;
m_context = pContext;
m_signer = new CXmlSigner(pContext);
}
~COOXMLSigner()
{
RELEASEOBJECT(m_signer);
}
std::wstring GetReference(const std::wstring& file, const std::wstring& content_type)
{
std::wstring sXml = L"<Reference URI=\"" + file + L"?ContentType=" + content_type + L"\">";
sXml += L"<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>";
sXml += L"<DigestValue>";
sXml += UTF8_TO_U(m_signer->GetHash(m_sFolder + file));
sXml += L"</DigestValue>";
sXml += L"</Reference>";
return sXml;
}
std::string GetHashXml(const std::wstring& xml)
{
std::string sXmlSigned = U_TO_UTF8(xml);
sXmlSigned = CXmlCanonicalizator::Execute(sXmlSigned, XML_C14N_1_0);
return m_signer->GetHash(sXmlSigned);
}
std::string GetReferenceMain(const std::wstring& xml, const std::wstring& id, const bool& isCannon = true)
{
std::wstring sXml1 = L"<Object xmlns=\"http://www.w3.org/2000/09/xmldsig#\"";
if (id.empty())
sXml1 += L">";
else
sXml1 += (L" Id=\"" + id + L"\">");
sXml1 += xml;
sXml1 += L"</Object>";
std::string sHash = GetHashXml(sXml1);
std::string sRet;
if (isCannon)
sRet = "<Transforms><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/></Transforms>";
sRet += ("<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>" + sHash + "</DigestValue>");
return sRet;
}
std::wstring GetImageBase64(const std::wstring& file)
{
BYTE* pData = NULL;
DWORD dwLen = 0;
if (!NSFile::CFileBinary::ReadAllBytes(file, &pData, dwLen))
return L"";
char* pDataC = NULL;
int nLen = 0;
NSFile::CBase64Converter::Encode(pData, (int)dwLen, pDataC, nLen, NSBase64::B64_BASE64_FLAG_NOCRLF);
std::wstring sReturn = NSFile::CUtf8Converter::GetUnicodeFromCharPtr(pDataC, (LONG)nLen, FALSE);
RELEASEARRAYOBJECTS(pData);
RELEASEARRAYOBJECTS(pDataC);
return sReturn;
}
};
bool SignDocument(std::wstring sFolderOOXML, PCCERT_CONTEXT pCertContext)
{
std::wstring sFolder = NSFile::GetProcessDirectory();
COOXMLSigner oOOXMLSigner(sFolderOOXML, pCertContext);
std::string sSignedData;
std::wstring sXmlData;
std::wstring sDataSign = L"2017-04-21T08:30:21Z";
sSignedData += "<CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/>\
<SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/>";
if (true)
{
// idPackageObject
std::wstring sXml = L"<Manifest>";
// TODO: rels
if (true)
{
sXml += L"<Reference URI=\"/_rels/.rels?ContentType=application/vnd.openxmlformats-package.relationships+xml\">\
<Transforms><Transform Algorithm=\"http://schemas.openxmlformats.org/package/2006/RelationshipTransform\">\
<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"rId1\"/>\
</Transform><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/></Transforms>\
<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>\
<DigestValue>1vWU/YTF/7t6ZjnE44gAFTbZvvA=</DigestValue>\
</Reference>";
sXml += L"<Reference URI=\"/word/_rels/document.xml.rels?ContentType=application/vnd.openxmlformats-package.relationships+xml\">\
<Transforms><Transform Algorithm=\"http://schemas.openxmlformats.org/package/2006/RelationshipTransform\">\
<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"rId3\"/>\
<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"rId2\"/>\
<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"rId1\"/>\
<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"rId6\"/>\
<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"rId5\"/>\
<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"rId4\"/>\
</Transform><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/></Transforms>\
<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>\
<DigestValue>kVYCpjZZG3SU5+sOsB1PRnQSCzk=</DigestValue>\
</Reference>";
}
sXml += oOOXMLSigner.GetReference(L"/word/document.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml");
sXml += oOOXMLSigner.GetReference(L"/word/fontTable.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml");
sXml += oOOXMLSigner.GetReference(L"/word/media/image1.emf", L"image/x-emf");
sXml += oOOXMLSigner.GetReference(L"/word/settings.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml");
sXml += oOOXMLSigner.GetReference(L"/word/styles.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml");
sXml += oOOXMLSigner.GetReference(L"/word/theme/theme1.xml", L"application/vnd.openxmlformats-officedocument.theme+xml");
sXml += oOOXMLSigner.GetReference(L"/word/webSettings.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml");
sXml += L"</Manifest>";
sXml += L"<SignatureProperties><SignatureProperty Id=\"idSignatureTime\" Target=\"#idPackageSignature\">";
sXml += (L"<mdssi:SignatureTime xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\">\
<mdssi:Format>YYYY-MM-DDThh:mm:ssTZD</mdssi:Format>\
<mdssi:Value>" + sDataSign + L"</mdssi:Value>\
</mdssi:SignatureTime></SignatureProperty></SignatureProperties>");
sXmlData += (L"<Object Id=\"idPackageObject\">" + sXml + L"</Object>");
sSignedData += ("<Reference Type=\"http://www.w3.org/2000/09/xmldsig#Object\" URI=\"#idPackageObject\">" +
oOOXMLSigner.GetReferenceMain(sXml, L"idPackageObject", false) + "</Reference>");
}
std::wstring sImageValid = oOOXMLSigner.GetImageBase64(sFolder + L"/../../../resources/valid.png");
std::wstring sImageInValid = oOOXMLSigner.GetImageBase64(sFolder + L"/../../../resources/invalid.png");
if (true)
{
// idOfficeObject
std::wstring sXml = L"<SignatureProperties>\
<SignatureProperty Id=\"idOfficeV1Details\" Target=\"#idPackageSignature\">\
<SignatureInfoV1 xmlns=\"http://schemas.microsoft.com/office/2006/digsig\">\
<SetupID>{39B6B9C7-60AD-45A2-9F61-40C74A24042E}</SetupID>\
<SignatureText></SignatureText>\
<SignatureImage>" + sImageValid + L"</SignatureImage>\
<SignatureComments/>\
<WindowsVersion>10.0</WindowsVersion>\
<OfficeVersion>16.0</OfficeVersion>\
<ApplicationVersion>16.0</ApplicationVersion>\
<Monitors>2</Monitors>\
<HorizontalResolution>1680</HorizontalResolution>\
<VerticalResolution>1050</VerticalResolution>\
<ColorDepth>32</ColorDepth>\
<SignatureProviderId>{00000000-0000-0000-0000-000000000000}</SignatureProviderId>\
<SignatureProviderUrl/>\
<SignatureProviderDetails>9</SignatureProviderDetails>\
<SignatureType>2</SignatureType>\
</SignatureInfoV1>\
</SignatureProperty>\
</SignatureProperties>";
sXmlData += (L"<Object Id=\"idOfficeObject\">" + sXml + L"</Object>");
sSignedData += ("<Reference Type=\"http://www.w3.org/2000/09/xmldsig#Object\" URI=\"#idOfficeObject\">" +
oOOXMLSigner.GetReferenceMain(sXml, L"idOfficeObject", false) + "</Reference>");
}
if (true)
{
DWORD dwNameLen = CertGetNameStringW(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, CERT_NAME_ISSUER_FLAG, NULL, NULL, 0);
wchar_t* pNameData = new wchar_t[dwNameLen];
CertGetNameStringW(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, CERT_NAME_ISSUER_FLAG, NULL, pNameData, dwNameLen);
std::wstring sName(pNameData);
RELEASEARRAYOBJECTS(pNameData);
int nNumberLen = (int)pCertContext->pCertInfo->SerialNumber.cbData;
BYTE* pNumberData = new BYTE[nNumberLen];
CXmlSigner::ConvertEndian(pCertContext->pCertInfo->SerialNumber.pbData, pNumberData, (DWORD)nNumberLen);
CBigInteger oInteger(pNumberData, nNumberLen);
delete[] pNumberData;
std::string sKeyA = oInteger.ToString();
std::wstring sKey = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sKeyA.c_str(), (LONG)sKeyA.length());
std::wstring sXml = (L"<xd:SignedSignatureProperties>\
<xd:SigningTime>" + sDataSign + L"</xd:SigningTime>\
<xd:SigningCertificate>\
<xd:Cert>\
<xd:CertDigest>\
<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>\
<DigestValue>MJJT2Y0iMxaPGVXBmOLb9bY60pA=</DigestValue>\
</xd:CertDigest>\
<xd:IssuerSerial>\
<X509IssuerName>CN=" + sName + L"</X509IssuerName>\
<X509SerialNumber>" + sKey + L"</X509SerialNumber>\
</xd:IssuerSerial>\
</xd:Cert>\
</xd:SigningCertificate>\
<xd:SignaturePolicyIdentifier>\
<xd:SignaturePolicyImplied/>\
</xd:SignaturePolicyIdentifier>\
</xd:SignedSignatureProperties>");
std::wstring sSignedXml = L"<xd:SignedProperties xmlns=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:xd=\"http://uri.etsi.org/01903/v1.3.2#\" Id=\"idSignedProperties\">";
sSignedXml += sXml;
sSignedXml += L"</xd:SignedProperties>";
sXmlData += L"<Object><xd:QualifyingProperties xmlns:xd=\"http://uri.etsi.org/01903/v1.3.2#\" Target=\"#idPackageSignature\">\
<xd:SignedProperties Id=\"idSignedProperties\">";
sXmlData += sXml;
sXmlData += L"</xd:SignedProperties></xd:QualifyingProperties></Object>";
sSignedData += "<Reference Type=\"http://uri.etsi.org/01903#SignedProperties\" URI=\"#idSignedProperties\">\
<Transforms><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/></Transforms>\
<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>";
std::string sXmlTmp = CXmlCanonicalizator::Execute(U_TO_UTF8(sSignedXml), XML_C14N_1_0);
sSignedData += oOOXMLSigner.m_signer->GetHash(sXmlTmp);
sSignedData += "</DigestValue></Reference>";
}
if (true)
{
std::wstring sXml = sImageValid;
sXmlData += (L"<Object Id=\"idValidSigLnImg\">" + sXml + L"</Object>");
sSignedData += ("<Reference Type=\"http://www.w3.org/2000/09/xmldsig#Object\" URI=\"#idValidSigLnImg\">" +
oOOXMLSigner.GetReferenceMain(sXml, L"idValidSigLnImg", false) + "</Reference>");
}
if (true)
{
std::wstring sXml = sImageInValid;
sXmlData += (L"<Object Id=\"idInvalidSigLnImg\">" + sXml + L"</Object>");
sSignedData += ("<Reference Type=\"http://www.w3.org/2000/09/xmldsig#Object\" URI=\"#idInvalidSigLnImg\">" +
oOOXMLSigner.GetReferenceMain(sXml, L"idInvalidSigLnImg", false) + "</Reference>");
}
std::string sXmlPrepend = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\" Id=\"idPackageSignature\"><SignedInfo>");
sXmlPrepend += sSignedData;
sXmlPrepend += "</SignedInfo>";
sXmlPrepend += "<SignatureValue>";
std::string sSignedInfo = "<SignedInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + sSignedData + "</SignedInfo>";
sSignedInfo = CXmlCanonicalizator::Execute(sSignedInfo, XML_C14N_1_0);
sXmlPrepend += oOOXMLSigner.m_signer->Sign(sSignedInfo);
sXmlPrepend += "</SignatureValue>";
sXmlPrepend += ("<KeyInfo><X509Data><X509Certificate>" + oOOXMLSigner.m_signer->GetCertificateBase64() + "</X509Certificate></X509Data></KeyInfo>");
sXmlData = (UTF8_TO_U(sXmlPrepend) + sXmlData);
sXmlData += L"</Signature>";
std::wstring sDirectory = sFolderOOXML + L"/_xmlsignatures";
NSDirectory::CreateDirectory(sDirectory);
NSFile::CFileBinary oFile;
oFile.CreateFileW(sDirectory + L"/origin.sigs");
oFile.CloseFile();
NSFile::CFileBinary::SaveToFile(sDirectory + L"/sig1.xml", sXmlData, false);
NSDirectory::CreateDirectory(sDirectory + L"/_rels");
std::wstring sRels = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\
<Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature\" Target=\"sig1.xml\"/>\
</Relationships>";
NSFile::CFileBinary::SaveToFile(sDirectory + L"/_rels/origin.sigs.rels", sRels, false);
return true;
}

View File

@ -6,6 +6,30 @@ TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CORE_ROOT_DIR = $$PWD/../../../../
PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
DEFINES -= UNICODE
DEFINES += \
LIBXML_READER_ENABLED \
LIBXML_PUSH_ENABLED \
LIBXML_HTML_ENABLED \
LIBXML_XPATH_ENABLED \
LIBXML_OUTPUT_ENABLED \
LIBXML_C14N_ENABLED \
LIBXML_SAX1_ENABLED \
LIBXML_TREE_ENABLED \
LIBXML_XPTR_ENABLED \
LIBXML_STATIC
SOURCES += main.cpp
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -llibxml
INCLUDEPATH += \
$$CORE_ROOT_DIR/DesktopEditor/xml/libxml2/include \
$$CORE_ROOT_DIR/DesktopEditor/xml/libxml2/include/libxml

View File

@ -1,6 +1,8 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C# Express 2008
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "codegen", "codegen\codegen.csproj", "{B3AE10A0-6AB5-42EC-A83B-92012431B445}"
EndProject
Global

View File

@ -0,0 +1,494 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.IO;
using System.Collections;
using System.CodeDom;
using System.CodeDom.Compiler;
namespace codegen
{
public class GenMemberPivot
{
public string sName;
public string sNamespace;
public string sType;
public Type oSystemType;
public bool? bIsAttribute;
public string sDefAttribute;
public bool? bQualified;//нужно ли при записи в xml писать prefix
public int? nArrayRank;
public List<GenMemberPivot> aArrayTypes;
public bool? bIsArrayTypesHidden;
public GenMemberPivot(string _sName)
{
sName = _sName;
sNamespace = null;
sType = null;
oSystemType = null;
bIsAttribute = null;
sDefAttribute = null;
bQualified = null;
nArrayRank = null;
bIsArrayTypesHidden = null;
aArrayTypes = null;
}
public void merge(GenMemberPivot val)
{
if (string.IsNullOrEmpty(this.sName))
sName = val.sName;
if (string.IsNullOrEmpty(this.sNamespace))
sNamespace = val.sNamespace;
if (string.IsNullOrEmpty(this.sType))
sType = val.sType;
if (null == this.oSystemType)
oSystemType = val.oSystemType;
if (!this.bIsAttribute.HasValue)
bIsAttribute = val.bIsAttribute;
if (string.IsNullOrEmpty(this.sDefAttribute))
sDefAttribute = val.sDefAttribute;
if (!this.bQualified.HasValue)
bQualified = val.bQualified;
if (!this.nArrayRank.HasValue)
nArrayRank = val.nArrayRank;
if (!this.bIsArrayTypesHidden.HasValue)
bIsArrayTypesHidden = val.bIsArrayTypesHidden;
}
public void completeDefaults()
{
if (!bIsAttribute.HasValue)
bIsAttribute = false;
if (!bQualified.HasValue)
bQualified = true;
}
}
//[System.Xml.Serialization.XmlElementAttribute("c")]
//public CT_CalcCell[] c {
//nArrayRank=0;aArrayTypes=[CT_CalcCell];bIsArrayTypesHidden=true
//[System.Xml.Serialization.XmlElementAttribute("b", typeof(CT_Boolean))]
//[System.Xml.Serialization.XmlElementAttribute("d", typeof(CT_DateTime))]
//[System.Xml.Serialization.XmlElementAttribute("e", typeof(CT_Error))]
//[System.Xml.Serialization.XmlElementAttribute("m", typeof(CT_Missing))]
//[System.Xml.Serialization.XmlElementAttribute("n", typeof(CT_Number))]
//[System.Xml.Serialization.XmlElementAttribute("s", typeof(CT_String))]
//public object[] Items {
//nArrayRank=0;aArrayTypes=[CT_Boolean, CT_DateTime, CT_Error, CT_Missing, CT_Number, CT_String];bIsArrayTypesHidden=true
//[System.Xml.Serialization.XmlElementAttribute("consolidation", typeof(CT_Consolidation))]
//[System.Xml.Serialization.XmlElementAttribute("extLst", typeof(CT_ExtensionList))]
//[System.Xml.Serialization.XmlElementAttribute("worksheetSource", typeof(CT_WorksheetSource))]
//public object Item
//{
//nArrayRank=null;aArrayTypes=[CT_Consolidation, CT_ExtensionList, CT_WorksheetSource];bIsArrayTypesHidden=true
//[System.Xml.Serialization.XmlArrayItemAttribute("author", IsNullable=false)]
//public string[] authors {
//nArrayRank=0;aArrayTypes=[string];bIsArrayTypesHidden=false
//[System.Xml.Serialization.XmlArrayItemAttribute("b", typeof(CT_Boolean), IsNullable=false)]
//[System.Xml.Serialization.XmlArrayItemAttribute("d", typeof(CT_DateTime), IsNullable=false)]
//[System.Xml.Serialization.XmlArrayItemAttribute("e", typeof(CT_Error), IsNullable=false)]
//[System.Xml.Serialization.XmlArrayItemAttribute("m", typeof(CT_Missing), IsNullable=false)]
//[System.Xml.Serialization.XmlArrayItemAttribute("n", typeof(CT_Number), IsNullable=false)]
//[System.Xml.Serialization.XmlArrayItemAttribute("s", typeof(CT_String), IsNullable=false)]
//[System.Xml.Serialization.XmlArrayItemAttribute("x", typeof(CT_Index), IsNullable=false)]
//public object[][] r {
//nArrayRank=1;aArrayTypes=[CT_Boolean, CT_DateTime, CT_Error, CT_Missing, CT_Number, CT_String, CT_Index];bIsArrayTypesHidden=false
public class GenClassPivot
{
public string sName;
public string sNamespace;
public bool bIsEnum;
public List<GenMemberPivot> aMembers = new List<GenMemberPivot>();
public string sRootName;
public GenClassPivot(string _sName, string _sNamespace)
{
sName = _sName;
sNamespace = _sNamespace;
bIsEnum = false;
sRootName = "";
}
public bool isRoot()
{
return !string.IsNullOrEmpty(this.sRootName);
}
}
class CodeGenPivot
{
Dictionary<string, GenClassPivot> m_mapGeneratedClasses = new Dictionary<string, GenClassPivot>();
int m_nItemsChoiceTypeCount = 0;
public void Start(string sDirIn, string sDirCppXmlOut, string sDirCppBinOut, string sDirJsBinOut, ValidationEventHandler oValidationEventHandler)
{
string sChartNamespace = "http://purl.oclc.org/ooxml/spreadsheetml/main";
string[] aFiles = Directory.GetFiles(sDirIn);
XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.ValidationEventHandler += oValidationEventHandler;
for (int i = 0; i < aFiles.Length; i++)
{
string sFile = aFiles[i];
if (".xsd" == Path.GetExtension(sFile))
schemaSet.Add(null, sFile);
}
schemaSet.Compile();
XmlSchema chartSchema = null;
XmlSchemas schemas = new XmlSchemas();
foreach (XmlSchema schema in schemaSet.Schemas())
{
if (schema.TargetNamespace == sChartNamespace)
{
chartSchema = schema;
schemas.Add(schema);
}
}
if (null != chartSchema)
{
CodeNamespace ns = new CodeNamespace();
XmlCodeExporter exporter = new XmlCodeExporter(ns);
CodeGenerationOptions generationOptions = CodeGenerationOptions.GenerateProperties;
XmlSchemaImporter importer = new XmlSchemaImporter(schemas, generationOptions, new ImportContext(new CodeIdentifiers(), false));
foreach (XmlSchemaElement element in chartSchema.Elements.Values)
{
XmlTypeMapping mapping = importer.ImportTypeMapping(element.QualifiedName);
exporter.ExportTypeMapping(mapping);
}
CodeGenerator.ValidateIdentifiers(ns);
////Microsoft.CSharp.CSharpCodeProvider oProvider;
//// output the C# code
//Microsoft.CSharp.CSharpCodeProvider codeProvider = new Microsoft.CSharp.CSharpCodeProvider();
//using (StringWriter writer = new StringWriter())
//{
// codeProvider.GenerateCodeFromNamespace(ns, writer, new CodeGeneratorOptions());
// string sCode = writer.GetStringBuilder().ToString();
//}
List<GenClassPivot> aGenClasses = PreProcess(ns, chartSchema);
aGenClasses = FilterClassesPivot(aGenClasses);
//(new CodegenCPP()).Process(sDirCppXmlOut, sDirCppBinOut, aGenClasses);
//(new CodegenJS()).Process(sDirJsBinOut, aGenClasses);
(new CodegenJSXml()).Process(sDirJsBinOut, aGenClasses);
}
}
List<GenClassPivot> FilterClassesPivot(List<GenClassPivot> aInput)
{
Queue<GenClassPivot> aTemp = new Queue<GenClassPivot>();
List<GenClassPivot> aRes = new List<GenClassPivot>();
string[] aTargetTypes = new string[] { "CT_PivotCacheDefinition", "CT_PivotCacheRecords", "CT_pivotTableDefinition" };
//string[] aTargetTypes = new string[] { "CT_Workbook" };
//string[] aTargetTypes = new string[] { "CT_Comments" };
Dictionary<string, bool> mapTargetSubTypes = new Dictionary<string, bool>();
Dictionary<string, bool> namspaces = new Dictionary<string, bool>();
Dictionary<string, GenClassPivot> mapAllClasses = new Dictionary<string, GenClassPivot>();
for (int i = 0; i < aInput.Count; ++i)
{
GenClassPivot oGenClass = aInput[i];
if (0 == aTargetTypes.Length || -1 != Array.IndexOf(aTargetTypes, oGenClass.sName))
aTemp.Enqueue(oGenClass);
mapAllClasses[oGenClass.sName] = oGenClass;
}
while (aTemp.Count > 0)
{
GenClassPivot oGenClass = aTemp.Dequeue();
if (!mapTargetSubTypes.ContainsKey(oGenClass.sName))
{
mapTargetSubTypes.Add(oGenClass.sName, true);
aRes.Add(oGenClass);
for (int j = 0; j < oGenClass.aMembers.Count; ++j)
{
GenMemberPivot oGenMember = oGenClass.aMembers[j];
GenClassPivot oTempClass;
if (null != oGenMember.sType && mapAllClasses.TryGetValue(oGenMember.sType, out oTempClass))
{
namspaces[oTempClass.sNamespace] = true;
aTemp.Enqueue(oTempClass);
}
if (null != oGenMember.aArrayTypes)
{
for (int k = 0; k < oGenMember.aArrayTypes.Count; ++k)
{
GenMemberPivot oGenMemberArrayTypes = oGenMember.aArrayTypes[k];
if (null != oGenMemberArrayTypes.sType && mapAllClasses.TryGetValue(oGenMemberArrayTypes.sType, out oTempClass))
{
aTemp.Enqueue(oTempClass);
}
}
}
}
}
}
return aRes;
}
List<GenClassPivot> PreProcess(CodeNamespace code, XmlSchema schema)
{
List<GenClassPivot> aGenClasses = new List<GenClassPivot>();
for (int i = 0; i < code.Types.Count; ++i)
{
GenClassPivot oNewClass = PreProcessClass(aGenClasses, code.Types[i]);
if (null != oNewClass)
aGenClasses.Add(oNewClass);
}
return aGenClasses;
}
GenClassPivot PreProcessClass(List<GenClassPivot> aGenClasses, CodeTypeDeclaration type)
{
GenClassPivot oGenClass = null;
//получаем xml namespace
string sNamespace = null;
bool bIncludeInSchema = true;
string sRootName = "";
for (int i = 0; i < type.CustomAttributes.Count; i++)
{
CodeAttributeDeclaration attribute = type.CustomAttributes[i];
if (attribute.Name == "System.Xml.Serialization.XmlTypeAttribute")
{
foreach (CodeAttributeArgument argument in attribute.Arguments)
{
if (argument.Name == "Namespace")
sNamespace = ((CodePrimitiveExpression)argument.Value).Value.ToString();
else if (argument.Name == "IncludeInSchema")
bIncludeInSchema = Convert.ToBoolean(((CodePrimitiveExpression)argument.Value).Value);
//todo argument.Name == "TypeName"
}
}
else if (attribute.Name == "System.Xml.Serialization.XmlRootAttribute")
{
foreach (CodeAttributeArgument argument in attribute.Arguments)
{
if (argument.Name == "Namespace")
sNamespace = ((CodePrimitiveExpression)argument.Value).Value.ToString();
else if ("" == argument.Name)
sRootName = ((CodePrimitiveExpression)argument.Value).Value.ToString();
}
}
}
if (bIncludeInSchema)
{
oGenClass = new GenClassPivot(type.Name, sNamespace);
oGenClass.sRootName = sRootName;
int nItemsElementName = 0;
if (type.IsEnum)
{
oGenClass.bIsEnum = true;
for (int i = 0; i < type.Members.Count; ++i)
{
CodeTypeMember member = type.Members[i];
GenMemberPivot oGenMember = new GenMemberPivot(member.Name);
for (int j = 0; j < member.CustomAttributes.Count; j++)
{
CodeAttributeDeclaration attribute = member.CustomAttributes[j];
if (attribute.Name == "System.Xml.Serialization.XmlEnumAttribute")
ParseArguments(attribute.Arguments, oGenMember);
}
oGenClass.aMembers.Add(oGenMember);
}
}
else
{
for (int i = 0; i < type.Members.Count; ++i)
{
CodeTypeMember member = type.Members[i];
//CodeMemberField пропускаем
CodeMemberProperty codeMemberProperty = member as CodeMemberProperty;
if (codeMemberProperty != null)
{
GenMemberPivot oNewGenMember = PreProcessProperty(aGenClasses, codeMemberProperty, oGenClass, ref nItemsElementName);
if (null != oNewGenMember)
oGenClass.aMembers.Add(oNewGenMember);
}
}
}
}
return oGenClass;
}
GenMemberPivot PreProcessProperty(List<GenClassPivot> aGenClasses, CodeMemberProperty codeMemberProperty, GenClassPivot oGenClass, ref int nItemsElementName)
{
GenMemberPivot oGenMember = new GenMemberPivot(codeMemberProperty.Name);
bool bIgnore = false;
InitMemberType(oGenMember, codeMemberProperty.Type.BaseType);
if (null != codeMemberProperty.Type.ArrayElementType)
{
oGenMember.nArrayRank = codeMemberProperty.Type.ArrayElementType.ArrayRank;
}
bool bXmlElementAttribute = false;
List<GenMemberPivot> aTempMemebers = new List<GenMemberPivot>();
for (int i = 0; i < codeMemberProperty.CustomAttributes.Count; i++)
{
CodeAttributeDeclaration attribute = codeMemberProperty.CustomAttributes[i];
if (attribute.Name == "System.Xml.Serialization.XmlAttributeAttribute")
{
oGenMember.bQualified = false;
oGenMember.bIsAttribute = true;
ParseArguments(attribute.Arguments, oGenMember);
//todo могут быть повторы имен атрибутов и child nodes.
}
else if (attribute.Name == "System.ComponentModel.DefaultValueAttribute")
{
if (attribute.Arguments.Count > 0)
{
CodeExpression oCodeExpression = attribute.Arguments[attribute.Arguments.Count - 1].Value;
//todo other
if (oCodeExpression is CodePrimitiveExpression)
oGenMember.sDefAttribute = ((oCodeExpression as CodePrimitiveExpression)).Value.ToString();
else if (oCodeExpression is CodeFieldReferenceExpression)
oGenMember.sDefAttribute = ((oCodeExpression as CodeFieldReferenceExpression)).FieldName;
}
}
else if (attribute.Name == "System.Xml.Serialization.XmlIgnoreAttribute")
bIgnore = true;
else if (attribute.Name == "System.Xml.Serialization.XmlElementAttribute")
{
bXmlElementAttribute = true;
GenMemberPivot oTemp = new GenMemberPivot(null);
ParseArguments(attribute.Arguments, oTemp);
aTempMemebers.Add(oTemp);
}
else if (attribute.Name == "System.Xml.Serialization.XmlArrayItemAttribute")
{
GenMemberPivot oTemp = new GenMemberPivot(null);
ParseArguments(attribute.Arguments, oTemp);
aTempMemebers.Add(oTemp);
}
else if (attribute.Name == "System.Xml.Serialization.XmlArrayAttribute")
{
ParseArguments(attribute.Arguments, oGenMember);
}
//todo не всегда прописан
//else if (attribute.Name == "System.Xml.Serialization.XmlChoiceIdentifierAttribute")
//{
// if (attribute.Arguments.Count > 0)
// {
// CodePrimitiveExpression oPrimitiveExpression = attribute.Arguments[0].Value as CodePrimitiveExpression;
// oGenMember.sChoiceIdentifier = oPrimitiveExpression.Value.ToString();
// }
//}
}
if (bIgnore)
return null;
else
{
if (aTempMemebers.Count > 0)
{
if (1 == aTempMemebers.Count)
{
GenMemberPivot TempMember = aTempMemebers[0];
TempMember.merge(oGenMember);
TempMember.nArrayRank = null;
}
oGenMember.aArrayTypes = aTempMemebers;
if (bXmlElementAttribute)
oGenMember.bIsArrayTypesHidden = true;
else
oGenMember.bIsArrayTypesHidden = false;
}
else
{
oGenMember.nArrayRank = null;
}
oGenMember.completeDefaults();
return oGenMember;
}
}
void ParseArguments(CodeAttributeArgumentCollection oArguments, GenMemberPivot oGenMember)
{
CodePrimitiveExpression oPrimitiveExpression = null;
CodeTypeOfExpression oTypeOfExpression = null;
string sNamespace = null;
bool? bForm = null;
foreach (CodeAttributeArgument argument in oArguments)
{
if ("" == argument.Name)
{
if (argument.Value is CodePrimitiveExpression)
oPrimitiveExpression = argument.Value as CodePrimitiveExpression;
else if (argument.Value is CodeTypeOfExpression)
oTypeOfExpression = argument.Value as CodeTypeOfExpression;
}
else if ("Namespace" == argument.Name)
sNamespace = ((CodePrimitiveExpression)argument.Value).Value.ToString();
else if ("Form" == argument.Name)
{
string sValue = ((CodeFieldReferenceExpression)argument.Value).FieldName;
if ("Qualified" == sValue)
bForm = true;
else if ("Unqualified" == sValue)
bForm = false;
}
}
if (null != oPrimitiveExpression)
oGenMember.sName = oPrimitiveExpression.Value.ToString();
if (null != oTypeOfExpression)
InitMemberType(oGenMember, oTypeOfExpression.Type.BaseType);
if (null != sNamespace)
oGenMember.sNamespace = sNamespace;
if (bForm.HasValue)
oGenMember.bQualified = bForm.Value;
}
void InitMemberType(GenMemberPivot oGenMember, string sBaseType)
{
if (-1 != sBaseType.IndexOf("System."))
{
oGenMember.oSystemType = Type.GetType(sBaseType);
if (null == oGenMember.oSystemType)
oGenMember.oSystemType = typeof(string);
}
else
oGenMember.sType = sBaseType;
}
}
}

View File

@ -51,7 +51,6 @@ namespace codegen
StringBuilder m_oDocxFromToBinaryCPP = new StringBuilder();
StringBuilder m_oDocxTypesH = new StringBuilder();
Dictionary<string, GenClass> m_mapProcessedClasses = new Dictionary<string, GenClass>();
Dictionary<string, string> m_mapNamespaceToPrefix = new Dictionary<string, string>() { { "http://purl.oclc.org/ooxml/drawingml/chart", "c:" }, { "http://purl.oclc.org/ooxml/drawingml/main", "a:" }, { "http://purl.oclc.org/ooxml/officeDocument/relationships", "r:" }, { "http://schemas.openxmlformats.org/markup-compatibility/2006", "mc:" }, { "http://schemas.microsoft.com/office/drawing/2007/8/2/chart", "c14:" } };
string gc_sNamespaceToXml = " xmlns:c=\\\"http://schemas.openxmlformats.org/drawingml/2006/chart\\\" xmlns:a=\\\"http://schemas.openxmlformats.org/drawingml/2006/main\\\" xmlns:r=\\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\\\" xmlns:mc=\\\"http://schemas.openxmlformats.org/markup-compatibility/2006\\\" xmlns:c14=\\\"http://schemas.microsoft.com/office/drawing/2007/8/2/chart\\\"";
string gc_sTypePattern = "et_";
@ -573,7 +572,7 @@ namespace codegen
if (null != sMemberNamespace && oGenMember.bQualified)
{
string sShortNamespace;
if (m_mapNamespaceToPrefix.TryGetValue(sMemberNamespace, out sShortNamespace))
if (Utils.m_mapNamespaceToPrefix.TryGetValue(sMemberNamespace, out sShortNamespace))
sElemName = sShortNamespace + sElemName;
}

View File

@ -0,0 +1,793 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace codegen
{
class CodegenJSXml
{
Dictionary<string, GenClassPivot> m_mapProcessedClasses = new Dictionary<string, GenClassPivot>();
string gc_sEnumFromXmlPrefix = "FromXml_";
string gc_sEnumToXmlPrefix = "ToXml_";
string gc_sNamespaceToXml = " xmlns=\\\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\\\" xmlns:r=\\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\\\"";
public void Process(string sOutputDir, List<GenClassPivot> aGenClasses)
{
StringBuilder oJsSer = new StringBuilder();
List<GenClassPivot> aEnums = new List<GenClassPivot>();
List<GenClassPivot> aClasses = new List<GenClassPivot>();
for (int i = 0; i < aGenClasses.Count; ++i)
{
GenClassPivot oGenClass = aGenClasses[i];
if (oGenClass.bIsEnum)
aEnums.Add(oGenClass);
else
aClasses.Add(oGenClass);
m_mapProcessedClasses[oGenClass.sName] = oGenClass;
}
string sFileJs = "PivotTables.js";
//string sFileJs = "Workbook.js";
oJsSer.AppendFormat("\"use strict\";\r\n");
oJsSer.AppendFormat(Utils.gc_sFilePrefix);
oJsSer.AppendFormat("function getBoolFromXml(val){{return \"0\"!==val && \"false\"!==val && \"off\"!==val;}}\r\n");
//enums
ProcessEnums(oJsSer, aEnums);
//FromXml
for (int i = 0; i < aClasses.Count; ++i)
ProcessClass(oJsSer, aClasses[i]);
File.WriteAllText(Path.Combine(sOutputDir, sFileJs), oJsSer.ToString());
}
public void ProcessEnums(StringBuilder sb, List<GenClassPivot> aGenClasses)
{
for (int i = 0; i < aGenClasses.Count; ++i)
{
GenClassPivot oGenClass = aGenClasses[i];
for (int j = 0; j < oGenClass.aMembers.Count; ++j)
{
GenMemberPivot oGenMember = oGenClass.aMembers[j];
sb.AppendFormat("var {0} = {1};\r\n", Utils.GetEnumElemName(oGenClass.sName, oGenMember.sName), j);
}
sb.AppendFormat("\r\n");
}
for (int i = 0; i < aGenClasses.Count; ++i)
{
GenClassPivot oGenClass = aGenClasses[i];
sb.AppendFormat("function {0}{1}(val)\r\n{{\r\n", gc_sEnumFromXmlPrefix, oGenClass.sName);
sb.AppendFormat("var res = -1;\r\n");
for (int j = 0; j < oGenClass.aMembers.Count; ++j)
{
GenMemberPivot member = oGenClass.aMembers[j];
if (0 == j)
sb.AppendFormat("if(\"{0}\"===val)\r\nres={1};\r\n", member.sName, Utils.GetEnumElemName(oGenClass.sName, member.sName));
else
sb.AppendFormat("else if(\"{0}\"===val)\r\nres={1};\r\n", member.sName, Utils.GetEnumElemName(oGenClass.sName, member.sName));
}
sb.AppendFormat("return res;\r\n}}\r\n");
sb.AppendFormat("function {0}{1}(val)\r\n{{\r\n", gc_sEnumToXmlPrefix, oGenClass.sName);
sb.AppendFormat("var res = \"\";\r\n");
for (int j = 0; j < oGenClass.aMembers.Count; ++j)
{
GenMemberPivot member = oGenClass.aMembers[j];
if (0 == j)
sb.AppendFormat("if({0}===val)\r\nres=\"{1}\";\r\n", Utils.GetEnumElemName(oGenClass.sName, member.sName), member.sName);
else
sb.AppendFormat("else if({0}===val)\r\nres=\"{1}\";\r\n", Utils.GetEnumElemName(oGenClass.sName, member.sName), member.sName);
}
sb.AppendFormat("return res;\r\n}}\r\n");
sb.AppendFormat("\r\n");
}
}
public void ProcessClass(StringBuilder sb, GenClassPivot oGenClass)
{
List<GenMemberPivot> aAttributes = new List<GenMemberPivot>();
List<GenMemberPivot> aMembers = new List<GenMemberPivot>();
bool bNeedTextNode = false;
bool bNeedDoubleArray = false;
InfoFromMember(oGenClass, ref aAttributes, ref aMembers, ref bNeedTextNode, ref bNeedDoubleArray);
sb.AppendFormat("function {0}(){{\r\n", oGenClass.sName);
ProcessProperty(sb, aAttributes, aMembers, bNeedTextNode, bNeedDoubleArray);
sb.AppendFormat("}}\r\n");
if (aAttributes.Count > 0)
{
sb.AppendFormat("{0}.prototype.readAttributes = function(attr, uq) {{\r\n", oGenClass.sName);
ProcessAttributesFromXml(sb, oGenClass, aAttributes);
sb.AppendFormat("}};\r\n");
}
if (aMembers.Count > 0)
{
sb.AppendFormat("{0}.prototype.onStartNode = function(elem, attr, uq) {{\r\n", oGenClass.sName);
sb.AppendFormat("var newContext = this;\r\n");
int nCounter = 0;
if (oGenClass.isRoot() && ProcessRootFromXml(sb, oGenClass, "elem"))
{
nCounter++;
}
ProcessOnStartNodeFromXml(sb, oGenClass, aMembers, nCounter, "elem");
sb.AppendFormat("else {{\r\n");
sb.AppendFormat("newContext = null;\r\n");
sb.AppendFormat("}}\r\n");
sb.AppendFormat("return newContext;\r\n");
sb.AppendFormat("}};\r\n");
if (bNeedTextNode)
{
sb.AppendFormat("{0}.prototype.onTextNode = function(text, uq) {{\r\n", oGenClass.sName);
ProcessOnTextNodeFromXml(sb, oGenClass, aMembers);
sb.AppendFormat("}};\r\n");
}
if (bNeedDoubleArray)
{
sb.AppendFormat("{0}.prototype.onEndNode = function(prevContext, elem) {{\r\n", oGenClass.sName);
ProcessOnEndNodeFromXml(sb, oGenClass, aMembers);
sb.AppendFormat("}};\r\n");
}
}
if (aAttributes.Count > 0 || aMembers.Count > 0)
{
if (oGenClass.isRoot())
{
sb.AppendFormat("{0}.prototype.toXml = function(writer) {{\r\n", oGenClass.sName);
}
else
{
sb.AppendFormat("{0}.prototype.toXml = function(writer, name) {{\r\n", oGenClass.sName);
}
sb.AppendFormat("var res = \"\";\r\n");
ProcessToXml(sb, oGenClass);
sb.AppendFormat("return res;\r\n");
sb.AppendFormat("}};\r\n");
}
}
public void InfoFromMember(GenClassPivot oGenClass, ref List<GenMemberPivot> aAttributes, ref List<GenMemberPivot> aMembers, ref bool bNeedTextNode, ref bool bNeedDoubleArray)
{
for (int i = 0; i < oGenClass.aMembers.Count; ++i)
{
GenMemberPivot oGenMember = oGenClass.aMembers[i];
if (true == oGenMember.bIsAttribute)
{
aAttributes.Add(oGenMember);
}
else
{
if (oGenMember.nArrayRank.HasValue && oGenMember.nArrayRank > 0)
{
bNeedDoubleArray = true;
}
if (null != oGenMember.aArrayTypes)
{
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
{
InfoFromMemberElem(oGenMember.aArrayTypes[j], ref bNeedTextNode);
}
}
else
{
InfoFromMemberElem(oGenMember, ref bNeedTextNode);
}
aMembers.Add(oGenMember);
}
}
}
public void InfoFromMemberElem(GenMemberPivot oGenMember, ref bool bNeedTextNode)
{
if (null != oGenMember.oSystemType)
{
bNeedTextNode = true;
}
else if (null != oGenMember.sType)
{
GenClassPivot oTemp;
if (m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oTemp))
{
if (oTemp.bIsEnum)
{
bNeedTextNode = true;
}
}
}
}
void ProcessProperty(StringBuilder sb, List<GenMemberPivot> aAttributes, List<GenMemberPivot> aMembers, bool bNeedTextNode, bool bNeedDoubleArray)
{
if (aAttributes.Count > 0)
{
sb.AppendFormat("//Attributes\r\n");
for (int i = 0; i < aAttributes.Count; ++i)
{
GenMemberPivot oGenMember = aAttributes[i];
if (!string.IsNullOrEmpty(oGenMember.sDefAttribute))
{
sb.AppendFormat("this.{0} = null;//{1}\r\n", oGenMember.sName, oGenMember.sDefAttribute.ToLower());
}
else
{
sb.AppendFormat("this.{0} = null;\r\n", oGenMember.sName);
}
}
}
if (aMembers.Count > 0)
{
sb.AppendFormat("//Members\r\n");
for (int i = 0; i < aMembers.Count; ++i)
{
GenMemberPivot oGenMember = aMembers[i];
if (oGenMember.nArrayRank.HasValue)
{
if (false != oGenMember.bIsArrayTypesHidden)
sb.AppendFormat("this.{0} = [];\r\n", oGenMember.sName);
else
sb.AppendFormat("this.{0} = null;\r\n", oGenMember.sName);
}
else
{
if (null != oGenMember.aArrayTypes)
{
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
{
GenMemberPivot oTempMember = oGenMember.aArrayTypes[j];
if (!string.IsNullOrEmpty(oTempMember.sDefAttribute))
{
sb.AppendFormat("this.{0} = null;//{1}\r\n", oTempMember.sName, oTempMember.sDefAttribute.ToLower());
}
else
{
sb.AppendFormat("this.{0} = null;\r\n", oTempMember.sName);
}
}
}
else
{
if (!string.IsNullOrEmpty(oGenMember.sDefAttribute))
{
sb.AppendFormat("this.{0} = null;//{1}\r\n", oGenMember.sName, oGenMember.sDefAttribute.ToLower());
}
else
{
sb.AppendFormat("this.{0} = null;\r\n", oGenMember.sName);
}
}
}
}
}
if (bNeedTextNode || bNeedDoubleArray)
{
sb.AppendFormat("//internal\r\n");
if (bNeedTextNode)
sb.AppendFormat("this._curElem = null;\r\n");
if (bNeedDoubleArray)
sb.AppendFormat("this._curArray = null;\r\n");
}
}
bool ProcessRootFromXml(StringBuilder sb, GenClassPivot oGenClass, string sCodeName)
{
string sName = oGenClass.sRootName;
if (!string.IsNullOrEmpty(sName))
{
sb.AppendFormat("if(\"{0}\" === {1}){{\r\n", sName, sCodeName);
sb.AppendFormat("if(newContext.readAttributes){{\r\n");
sb.AppendFormat("newContext.readAttributes(attr, uq);\r\n");
sb.AppendFormat("}}\r\n");
sb.AppendFormat("}}\r\n", sName, sCodeName);
return true;
}
return false;
}
void ProcessOnStartNodeFromXml(StringBuilder sb, GenClassPivot oGenClass, List<GenMemberPivot> aMembers, int nCounter, string sCodeName)
{
for (int i = 0; i < aMembers.Count; ++i)
{
GenMemberPivot oGenMember = aMembers[i];
if (null != oGenMember.aArrayTypes)
{
if (false == oGenMember.bIsArrayTypesHidden)
{
if (0 != nCounter)
sb.AppendFormat("else ");
//todo rework
sb.AppendFormat("if(\"{0}\" === {1}){{\r\n", getNameWithPrefix(oGenClass, oGenMember), sCodeName);
if (oGenMember.nArrayRank > 0)
{
sb.AppendFormat("this._curArray = [];\r\n", getNameWithPrefix(oGenClass, oGenMember), sCodeName);
}
else
{
sb.AppendFormat("//todo check name duplication\r\n", getNameWithPrefix(oGenClass, oGenMember), sCodeName);
sb.AppendFormat("this.{0} = [];\r\n", oGenMember.sName);
}
sb.AppendFormat("}}\r\n", getNameWithPrefix(oGenClass, oGenMember), sCodeName);
nCounter++;
}
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
{
nCounter = ProcessOnStartNodeFromXmlMember(sb, oGenClass, oGenMember.aArrayTypes[j], oGenMember, sCodeName, nCounter);
}
}
else
{
nCounter = ProcessOnStartNodeFromXmlMember(sb, oGenClass, oGenMember, null, sCodeName, nCounter);
}
}
}
int ProcessOnStartNodeFromXmlMember(StringBuilder sb, GenClassPivot oGenClass, GenMemberPivot oGenMember, GenMemberPivot oGenMemberContainer, string sCodeName, int nCounter)
{
if (0 != nCounter)
sb.AppendFormat("else ");
sb.AppendFormat("if(\"{0}\" === {1}){{\r\n", getNameWithPrefix(oGenClass, oGenMember), sCodeName);
if (null != oGenMember.oSystemType)
{
sb.AppendFormat("this._curElem = {0};\r\n", sCodeName);
}
else if (null != oGenMember.sType)
{
GenClassPivot oTemp;
if (m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oTemp))
{
if (oTemp.bIsEnum)
{
sb.AppendFormat("this._curElem = {0};\r\n", sCodeName);
}
else
{
sb.AppendFormat("newContext = new {0}();\r\n", oGenMember.sType);
sb.AppendFormat("if(newContext.readAttributes){{\r\n");
sb.AppendFormat("newContext.readAttributes(attr, uq);\r\n", oGenMember.sType);
sb.AppendFormat("}}\r\n");
GenMemberPivot oTargetMember = null != oGenMemberContainer ? oGenMemberContainer : oGenMember;
if (oTargetMember.nArrayRank.HasValue)
{
if (oTargetMember.nArrayRank > 0)
{
sb.AppendFormat("this._curArray.push(newContext);\r\n");
}
else
{
sb.AppendFormat("this.{0}.push(newContext);\r\n", oTargetMember.sName);
}
}
else
{
//oGenMember not mistake
//right way to store oGenMemberContainer in one object, but we prefer separete types
sb.AppendFormat("this.{0} = newContext;\r\n", oGenMember.sName);
}
}
}
}
sb.AppendFormat("}}\r\n");
nCounter++;
return nCounter;
}
void ProcessOnTextNodeFromXml(StringBuilder sb, GenClassPivot oGenClass, List<GenMemberPivot> aMembers)
{
int nCounter = 0;
for (int i = 0; i < aMembers.Count; ++i)
{
GenMemberPivot oGenMember = aMembers[i];
if (null != oGenMember.aArrayTypes)
{
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
{
nCounter = ProcessOnTextNodeFromXmlMember(sb, oGenClass, oGenMember.aArrayTypes[j], nCounter);
}
}
else
{
nCounter = ProcessOnTextNodeFromXmlMember(sb, oGenClass, oGenMember, nCounter);
}
}
}
int ProcessOnTextNodeFromXmlMember(StringBuilder sb, GenClassPivot oGenClass, GenMemberPivot oGenMember, int nCounter)
{
if (null != oGenMember.oSystemType)
{
ProcessOnTextNodeFromXmlMemberPrefix(sb, oGenClass, oGenMember, nCounter);
ProcessOnTextNodeFromXmlMemberElem(sb, oGenMember, ProcessJsTypeFromXml(oGenMember.oSystemType, "text"));
nCounter = ProcessOnTextNodeFromXmlMemberPostfix(sb, nCounter);
}
else if (null != oGenMember.sType)
{
GenClassPivot oTemp;
if (m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oTemp))
{
if (oTemp.bIsEnum)
{
ProcessOnTextNodeFromXmlMemberPrefix(sb, oGenClass, oGenMember, nCounter);
sb.AppendFormat("var val = {0}(text);\r\n", gc_sEnumFromXmlPrefix + oTemp.sName);
sb.AppendFormat("if(-1 !== val){{\r\n");
ProcessOnTextNodeFromXmlMemberElem(sb, oGenMember, "val");
sb.AppendFormat("}}\r\n");
nCounter = ProcessOnTextNodeFromXmlMemberPostfix(sb, nCounter);
}
}
}
return nCounter;
}
void ProcessOnTextNodeFromXmlMemberPrefix(StringBuilder sb, GenClassPivot oGenClass, GenMemberPivot oGenMember, int nCounter)
{
if (0 != nCounter)
sb.AppendFormat("else ");
sb.AppendFormat("if(\"{0}\" === this._curElem){{\r\n", getNameWithPrefix(oGenClass, oGenMember));
}
int ProcessOnTextNodeFromXmlMemberPostfix(StringBuilder sb, int nCounter)
{
sb.AppendFormat("}}\r\n");
nCounter++;
return nCounter;
}
void ProcessOnTextNodeFromXmlMemberElem(StringBuilder sb, GenMemberPivot oGenMember, string sCodeName)
{
if (oGenMember.nArrayRank.HasValue)
{
if (oGenMember.nArrayRank > 0)
{
sb.AppendFormat("this._curArray.push({0});\r\n", sCodeName);
}
else
{
sb.AppendFormat("this.{0}.push({1});\r\n", oGenMember.sName, sCodeName);
}
}
else
sb.AppendFormat("this.{0} = {1};\r\n", oGenMember.sName, sCodeName);
}
void ProcessOnEndNodeFromXml(StringBuilder sb, GenClassPivot oGenClass, List<GenMemberPivot> aMembers)
{
int nCounter = 0;
for (int i = 0; i < aMembers.Count; ++i)
{
GenMemberPivot oGenMember = aMembers[i];
if (oGenMember.nArrayRank > 0)
{
if (0 != nCounter)
sb.AppendFormat("else ");
sb.AppendFormat("if(\"{0}\" === elem){{\r\n", getNameWithPrefix(oGenClass, oGenMember));
sb.AppendFormat("if(this._curArray && this._curArray.length > 0){{\r\n");
sb.AppendFormat("if(!this.{0}){{\r\n", oGenMember.sName);
sb.AppendFormat("this.{0} = [];\r\n", oGenMember.sName);
sb.AppendFormat("}}\r\n");
sb.AppendFormat("this.{0}.push(this._curArray);\r\n", oGenMember.sName);
sb.AppendFormat("this._curArray = null;\r\n");
sb.AppendFormat("}}\r\n");
sb.AppendFormat("}}\r\n");
nCounter++;
}
}
}
void ProcessAttributesFromXml(StringBuilder sb, GenClassPivot oGenClass, List<GenMemberPivot> aAttributes)
{
sb.AppendFormat("if(attr()){{\r\n");
sb.AppendFormat("var vals = attr();\r\n");
sb.AppendFormat("var val;\r\n");
for (int i = 0; i < aAttributes.Count; ++i)
{
GenMemberPivot oGenMember = aAttributes[i];
sb.AppendFormat("val = vals[\"{0}\"];\r\n", getNameWithPrefix(oGenClass, oGenMember));
sb.AppendFormat("if(undefined !== val){{\r\n");
if (null != oGenMember.oSystemType)
{
sb.AppendFormat("this.{0} = {1};\r\n", oGenMember.sName, ProcessJsTypeFromXml(oGenMember.oSystemType, "val"));
}
else if (null != oGenMember.sType)
{
GenClassPivot oTemp;
if (m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oTemp))
{
if (oTemp.bIsEnum)
{
sb.AppendFormat("val = {0}(val);\r\n", gc_sEnumFromXmlPrefix + oTemp.sName);
sb.AppendFormat("if(-1 !== val){{\r\n");
sb.AppendFormat("this.{0} = val;\r\n", oGenMember.sName);
sb.AppendFormat("}}\r\n");
}
//else
// sb.AppendFormat("pNewElem->fromXML(oReader);\r\n");
}
}
sb.AppendFormat("}}\r\n");
}
sb.AppendFormat("}}\r\n");
}
string ProcessJsTypeFromXml(Type oType, string sVal)
{
string sRes;
//todo
switch (Type.GetTypeCode(oType))
{
case TypeCode.Boolean:
sRes = "getBoolFromXml(" + sVal + ")";
break;
case TypeCode.Byte:
case TypeCode.SByte:
case TypeCode.Int16:
case TypeCode.Int32:
case TypeCode.Int64:
case TypeCode.UInt16:
case TypeCode.UInt32:
case TypeCode.UInt64:
case TypeCode.Single:
case TypeCode.Double:
sRes = sVal + " - 0";
break;
default: sRes = "uq(" + sVal + ")"; break;
}
return sRes;
}
void ProcessToXml(StringBuilder sb, GenClassPivot oGenClass)
{
List<GenMemberPivot> aAttributes = new List<GenMemberPivot>();
List<GenMemberPivot> aMembers = new List<GenMemberPivot>();
bool bNeedTextNode = false;
bool bNeedDoubleArray = false;
InfoFromMember(oGenClass, ref aAttributes, ref aMembers, ref bNeedTextNode, ref bNeedDoubleArray);
string sCodeName;
if (oGenClass.isRoot())
{
sCodeName = "\"" + oGenClass.sRootName + "\"";
sb.AppendFormat("writer.WriteXmlString(\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\");\r\n");
sb.AppendFormat("writer.WriteXmlNodeStart({0});\r\n", sCodeName);
sb.AppendFormat("writer.WriteXmlString(\"{0}\");\r\n", gc_sNamespaceToXml);
}
else
{
sCodeName = "name";
sb.AppendFormat("writer.WriteXmlNodeStart({0});\r\n", sCodeName);
}
for (int i = 0; i < aAttributes.Count; ++i)
{
GenMemberPivot oGenMember = aAttributes[i];
ProcessMemberToXml(sb, oGenClass, oGenMember, "this." + oGenMember.sName, true);
}
if (aMembers.Count > 0)
{
sb.AppendFormat("writer.WriteXmlNodeEnd({0}, true);\r\n", sCodeName);
for (int i = 0; i < aMembers.Count; ++i)
{
GenMemberPivot oGenMember = aMembers[i];
bool bNullCheck = true;
string sCodeElem = "this." + oGenMember.sName;
if (oGenMember.nArrayRank > 0)
{
if (false == oGenMember.bIsArrayTypesHidden)
{
sb.AppendFormat("if(null !== {0}){{\r\n", sCodeElem);
}
sb.AppendFormat("for(var i = 0; i < {0}.length; ++i){{\r\n", sCodeElem);
sb.AppendFormat("var elem = {0}[i];\r\n", sCodeElem);
sCodeElem = "elem";
bNullCheck = false;
}
if (null != oGenMember.aArrayTypes)
{
if (false == oGenMember.bIsArrayTypesHidden)
{
if (bNullCheck)
sb.AppendFormat("if(null !== {0}){{\r\n", sCodeElem);
sb.AppendFormat("writer.WriteXmlNodeStart(\"{0}\", true);\r\n", getNameWithPrefix(oGenClass, oGenMember));
}
if (oGenMember.nArrayRank.HasValue)
{
string sCodeSubElem;
if (oGenMember.nArrayRank > 0)
{
sb.AppendFormat("for(var j = 0; j < {0}.length; ++j){{\r\n", sCodeElem);
sb.AppendFormat("var subelem = {0}[j];\r\n", sCodeElem);
sCodeSubElem = "subelem";
}
else
{
sb.AppendFormat("for(var i = 0; i < {0}.length; ++i){{\r\n", sCodeElem);
sb.AppendFormat("var elem = {0}[i];\r\n", sCodeElem);
sCodeSubElem = "elem";
}
if (1 == oGenMember.aArrayTypes.Count)
{
GenMemberPivot oTempMember = oGenMember.aArrayTypes[0];
ProcessMemberToXml(sb, oGenClass, oTempMember, sCodeSubElem, false);
}
else
{
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
{
GenMemberPivot oTempMember = oGenMember.aArrayTypes[j];
if (0 != j)
sb.AppendFormat("else ");
sb.AppendFormat("if({0} instanceof {1}){{\r\n", sCodeSubElem, oTempMember.sType);
sb.AppendFormat("{0}.toXml(writer, \"{1}\");\r\n", sCodeSubElem, getNameWithPrefix(oGenClass, oTempMember));
sb.AppendFormat("}}\r\n");
}
}
sb.AppendFormat("}}\r\n");
}
else
{
//right way to store oGenMemberContainer in one object, but we prefer separete types
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
{
GenMemberPivot oTempMember = oGenMember.aArrayTypes[j];
ProcessMemberToXml(sb, oGenClass, oTempMember, "this." + oTempMember.sName, true);
}
}
if (false == oGenMember.bIsArrayTypesHidden)
{
sb.AppendFormat("writer.WriteXmlNodeEnd(\"{0}\");\r\n", getNameWithPrefix(oGenClass, oGenMember));
if (bNullCheck)
sb.AppendFormat("}}\r\n");
}
}
else
{
ProcessMemberToXml(sb, oGenClass, oGenMember, sCodeElem, true);
}
if (oGenMember.nArrayRank > 0)
{
sb.AppendFormat("}}\r\n");
if (false == oGenMember.bIsArrayTypesHidden)
{
sb.AppendFormat("}}\r\n");
}
}
}
sb.AppendFormat("writer.WriteXmlNodeEnd({0});\r\n", sCodeName);
}
else
sb.AppendFormat("writer.WriteXmlNodeEnd({0}, true, true);\r\n", sCodeName);
}
void ProcessMemberToXml(StringBuilder sb, GenClassPivot oGenClass, GenMemberPivot oGenMember, string sElemName, bool checkNull)
{
string sElemXmlName = getNameWithPrefix(oGenClass, oGenMember);
bool bIsAttribute = true == oGenMember.bIsAttribute;
if (checkNull)
{
sb.AppendFormat("if(null !== {0}){{\r\n", sElemName);
}
if (null != oGenMember.oSystemType)
{
ProcessJsTypeToXml(sb, sElemXmlName, oGenMember.oSystemType, sElemName, bIsAttribute);
}
else if (null != oGenMember.sType)
{
GenClassPivot oGenClassMember = null;
m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oGenClassMember);
if (null != oGenClassMember || m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oGenClassMember))
{
if (oGenClassMember.bIsEnum)
{
string sElemNameEnum = gc_sEnumToXmlPrefix + oGenClassMember.sName + "("+ sElemName + ")";
ProcessJsTypeToXml(sb, sElemXmlName, oGenMember.oSystemType, sElemNameEnum, bIsAttribute);
}
else
{
if (!bIsAttribute)
sb.AppendFormat("res += {0}.toXml(writer, \"{1}\");\r\n", sElemName, sElemXmlName);
}
}
}
if (checkNull)
{
sb.AppendFormat("}}\r\n");
}
}
void ProcessJsTypeToXml(StringBuilder sb, string sName, Type oType, string sVal, bool bAttribute)
{
switch (Type.GetTypeCode(oType))
{
case TypeCode.Boolean:
if(bAttribute)
{
sb.AppendFormat("writer.WriteXmlAttributeBool(\"{0}\", {1});\r\n", sName, sVal);
}
else
{
sb.AppendFormat("writer.WriteXmlNodeStart(\"{0}\", true);\r\n", sName);
sb.AppendFormat("writer.WriteXmlBool({0});\r\n", sVal);
sb.AppendFormat("writer.WriteXmlNodeEnd(\"{0}\");\r\n", sName);
}
break;
case TypeCode.Byte:
case TypeCode.SByte:
case TypeCode.Int16:
case TypeCode.Int32:
case TypeCode.Int64:
case TypeCode.UInt16:
case TypeCode.UInt32:
case TypeCode.UInt64:
case TypeCode.Single:
case TypeCode.Double:
if (bAttribute)
{
sb.AppendFormat("writer.WriteXmlAttributeNumber(\"{0}\", {1});\r\n", sName, sVal);
}
else
{
sb.AppendFormat("writer.WriteXmlNodeStart(\"{0}\", true);\r\n", sName);
sb.AppendFormat("writer.WriteXmlNumber({0});\r\n", sVal);
sb.AppendFormat("writer.WriteXmlNodeEnd(\"{0}\");\r\n", sName);
}
break;
default:
if (bAttribute)
{
sb.AppendFormat("writer.WriteXmlAttributeStringEncode(\"{0}\", {1});\r\n", sName, sVal);
}
else
{
sb.AppendFormat("writer.WriteXmlNodeStart(\"{0}\", true);\r\n", sName);
sb.AppendFormat("writer.WriteXmlStringEncode({0});\r\n", sVal);
sb.AppendFormat("writer.WriteXmlNodeEnd(\"{0}\");\r\n", sName);
}
break;
}
}
string getNameWithPrefix(GenClassPivot oGenClass, GenMemberPivot oGenMember)
{
string sShortNamespace = "";
if (true == oGenMember.bQualified)
{
string sMemberNamespace = null;
GenClassPivot oGenClassMember = null;
if (null != oGenMember.sNamespace)
sMemberNamespace = oGenMember.sNamespace;
else if (null != oGenMember.sType && m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oGenClassMember))
sMemberNamespace = oGenClassMember.sNamespace;
else
sMemberNamespace = oGenClass.sNamespace;
if (null != sMemberNamespace)
{
Utils.m_mapNamespaceToPrefix.TryGetValue(sMemberNamespace, out sShortNamespace);
}
}
return sShortNamespace + oGenMember.sName;
}
}
}

View File

@ -45,7 +45,8 @@ namespace codegen
static string sDirJsBinOut = @"..\..\gen\";
static void Main(string[] args)
{
(new codegen.CodeGen()).Start(sDirIn, sDirCppXmlOut, sDirCppBinOut, sDirJsBinOut, ValidationCallback);
//(new codegen.CodeGen()).Start(sDirIn, sDirCppXmlOut, sDirCppBinOut, sDirJsBinOut, ValidationCallback);
(new codegen.CodeGenPivot()).Start(sDirIn, sDirCppXmlOut, sDirCppBinOut, sDirJsBinOut, ValidationCallback);
}
static void ValidationCallback(object sender, ValidationEventArgs args)
{

View File

@ -5,7 +5,6 @@
xmlns="http://purl.oclc.org/ooxml/drawingml/chart"
xmlns:cdr="http://purl.oclc.org/ooxml/drawingml/chartDrawing"
xmlns:s="http://purl.oclc.org/ooxml/officeDocument/sharedTypes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
targetNamespace="http://purl.oclc.org/ooxml/drawingml/chart" elementFormDefault="qualified"
attributeFormDefault="unqualified" blockDefault="#all">
<xsd:import namespace="http://purl.oclc.org/ooxml/officeDocument/relationships"
@ -15,7 +14,6 @@
schemaLocation="dml-chartDrawing.xsd"/>
<xsd:import namespace="http://purl.oclc.org/ooxml/officeDocument/sharedTypes"
schemaLocation="shared-commonSimpleTypes.xsd"/>
<xsd:import namespace="http://schemas.openxmlformats.org/markup-compatibility/2006" schemaLocation="mce.xsd"/>
<xsd:complexType name="CT_Boolean">
<xsd:attribute name="val" type="xsd:boolean" use="optional" default="true"/>
</xsd:complexType>
@ -1432,7 +1430,6 @@
<xsd:element name="date1904" type="CT_Boolean" minOccurs="0" maxOccurs="1"/>
<xsd:element name="lang" type="CT_TextLanguageID" minOccurs="0" maxOccurs="1"/>
<xsd:element name="roundedCorners" type="CT_Boolean" minOccurs="0" maxOccurs="1"/>
<xsd:element ref="mc:AlternateContent" minOccurs="0" maxOccurs="1"/>
<xsd:element name="style" type="CT_Style" minOccurs="0" maxOccurs="1"/>
<xsd:element name="clrMapOvr" type="a:CT_ColorMapping" minOccurs="0" maxOccurs="1"/>
<xsd:element name="pivotSource" type="CT_PivotSource" minOccurs="0" maxOccurs="1"/>

View File

@ -1441,7 +1441,7 @@
<xsd:group ref="EG_ShadeProperties" minOccurs="0" maxOccurs="1"/>
<xsd:element name="tileRect" type="CT_RelativeRect" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="flip" type="ST_TileFlipMode" use="optional"/>
<xsd:attribute name="flip" type="ST_TileFlipMode" use="optional" default="none"/>
<xsd:attribute name="rotWithShape" type="xsd:boolean" use="optional"/>
</xsd:complexType>
<xsd:complexType name="CT_TileInfoProperties">
@ -1449,7 +1449,7 @@
<xsd:attribute name="ty" type="ST_Coordinate" use="optional"/>
<xsd:attribute name="sx" type="ST_Percentage" use="optional"/>
<xsd:attribute name="sy" type="ST_Percentage" use="optional"/>
<xsd:attribute name="flip" type="ST_TileFlipMode" use="optional"/>
<xsd:attribute name="flip" type="ST_TileFlipMode" use="optional" default="none"/>
<xsd:attribute name="algn" type="ST_RectAlignment" use="optional"/>
</xsd:complexType>
<xsd:complexType name="CT_StretchInfoProperties">
@ -2118,7 +2118,7 @@
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="CT_LineEndProperties">
<xsd:attribute name="type" type="ST_LineEndType" use="optional"/>
<xsd:attribute name="type" type="ST_LineEndType" use="optional" default="none"/>
<xsd:attribute name="w" type="ST_LineEndWidth" use="optional"/>
<xsd:attribute name="len" type="ST_LineEndLength" use="optional"/>
</xsd:complexType>
@ -2896,7 +2896,7 @@
<xsd:attribute name="u" type="ST_TextUnderlineType" use="optional"/>
<xsd:attribute name="strike" type="ST_TextStrikeType" use="optional"/>
<xsd:attribute name="kern" type="ST_TextNonNegativePoint" use="optional"/>
<xsd:attribute name="cap" type="ST_TextCapsType" use="optional"/>
<xsd:attribute name="cap" type="ST_TextCapsType" use="optional" default="none"/>
<xsd:attribute name="spc" type="ST_TextPoint" use="optional"/>
<xsd:attribute name="normalizeH" type="xsd:boolean" use="optional"/>
<xsd:attribute name="baseline" type="ST_Percentage" use="optional"/>

View File

@ -518,7 +518,7 @@
<xsd:element name="cBhvr" type="CT_TLCommonBehaviorData" minOccurs="1" maxOccurs="1"/>
<xsd:element name="progress" type="CT_TLAnimVariant" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="transition" type="ST_TLAnimateEffectTransition" use="optional"/>
<xsd:attribute name="transition" type="ST_TLAnimateEffectTransition" default="in" use="optional"/>
<xsd:attribute name="filter" type="xsd:string" use="optional"/>
<xsd:attribute name="prLst" type="xsd:string" use="optional"/>
</xsd:complexType>

View File

@ -568,7 +568,7 @@
<xsd:attribute name="optimizeMemory" type="xsd:boolean" use="optional" default="false"/>
<xsd:attribute name="enableRefresh" type="xsd:boolean" use="optional" default="true"/>
<xsd:attribute name="refreshedBy" type="s:ST_Xstring" use="optional"/>
<xsd:attribute name="refreshedDateIso" type="xsd:dateTime" use="optional"/>
<xsd:attribute name="refreshedDate" type="xsd:double" use="optional"/>
<xsd:attribute name="backgroundQuery" type="xsd:boolean" default="false"/>
<xsd:attribute name="missingItemsLimit" type="xsd:unsignedInt" use="optional"/>
<xsd:attribute name="createdVersion" type="xsd:unsignedByte" use="optional" default="0"/>
@ -3374,8 +3374,8 @@
</xsd:complexType>
<xsd:complexType name="CT_CellAlignment">
<xsd:attribute name="horizontal" type="ST_HorizontalAlignment" use="optional"/>
<xsd:attribute name="vertical" type="ST_VerticalAlignment" use="optional"/>
<xsd:attribute name="textRotation" type="xsd:unsignedInt" use="optional"/>
<xsd:attribute name="vertical" type="ST_VerticalAlignment" default="bottom" use="optional"/>
<xsd:attribute name="textRotation" type="ST_TextRotation" use="optional"/>
<xsd:attribute name="wrapText" type="xsd:boolean" use="optional"/>
<xsd:attribute name="indent" type="xsd:unsignedInt" use="optional"/>
<xsd:attribute name="relativeIndent" type="xsd:int" use="optional"/>
@ -3383,6 +3383,20 @@
<xsd:attribute name="shrinkToFit" type="xsd:boolean" use="optional"/>
<xsd:attribute name="readingOrder" type="xsd:unsignedInt" use="optional"/>
</xsd:complexType>
<xsd:simpleType name="ST_TextRotation">
<xsd:union>
<xsd:simpleType>
<xsd:restriction base="xsd:nonNegativeInteger">
<xsd:maxInclusive value="180"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType>
<xsd:restriction base="xsd:nonNegativeInteger">
<xsd:enumeration value="255"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:union>
</xsd:simpleType>
<xsd:simpleType name="ST_BorderStyle">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="none"/>

View File

@ -42,7 +42,7 @@
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="CT_Charset">
<xsd:attribute name="characterSet" type="s:ST_String" use="optional"/>
<xsd:attribute name="characterSet" type="s:ST_String" use="optional" default="ISO-8859-1"/>
</xsd:complexType>
<xsd:simpleType name="ST_DecimalNumberOrPercent">
<xsd:union memberTypes="s:ST_Percentage"/>
@ -185,7 +185,7 @@
</xsd:simpleType>
<xsd:complexType name="CT_Underline">
<xsd:attribute name="val" type="ST_Underline" use="optional"/>
<xsd:attribute name="color" type="ST_HexColor" use="optional"/>
<xsd:attribute name="color" type="ST_HexColor" use="optional" default="auto"/>
<xsd:attribute name="themeColor" type="ST_ThemeColor" use="optional"/>
<xsd:attribute name="themeTint" type="ST_UcharHexNumber" use="optional"/>
<xsd:attribute name="themeShade" type="ST_UcharHexNumber" use="optional"/>
@ -403,12 +403,12 @@
</xsd:simpleType>
<xsd:complexType name="CT_Border">
<xsd:attribute name="val" type="ST_Border" use="required"/>
<xsd:attribute name="color" type="ST_HexColor" use="optional"/>
<xsd:attribute name="color" type="ST_HexColor" use="optional" default="auto"/>
<xsd:attribute name="themeColor" type="ST_ThemeColor" use="optional"/>
<xsd:attribute name="themeTint" type="ST_UcharHexNumber" use="optional"/>
<xsd:attribute name="themeShade" type="ST_UcharHexNumber" use="optional"/>
<xsd:attribute name="sz" type="ST_EighthPointMeasure" use="optional"/>
<xsd:attribute name="space" type="ST_PointMeasure" use="optional"/>
<xsd:attribute name="space" type="ST_PointMeasure" use="optional" default="0"/>
<xsd:attribute name="shadow" type="s:ST_OnOff" use="optional"/>
<xsd:attribute name="frame" type="s:ST_OnOff" use="optional"/>
</xsd:complexType>
@ -594,14 +594,14 @@
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="CT_Spacing">
<xsd:attribute name="before" type="s:ST_TwipsMeasure" use="optional"/>
<xsd:attribute name="beforeLines" type="ST_DecimalNumber" use="optional"/>
<xsd:attribute name="beforeAutospacing" type="s:ST_OnOff" use="optional"/>
<xsd:attribute name="after" type="s:ST_TwipsMeasure" use="optional"/>
<xsd:attribute name="afterLines" type="ST_DecimalNumber" use="optional"/>
<xsd:attribute name="afterAutospacing" type="s:ST_OnOff" use="optional"/>
<xsd:attribute name="line" type="ST_SignedTwipsMeasure" use="optional"/>
<xsd:attribute name="lineRule" type="ST_LineSpacingRule" use="optional"/>
<xsd:attribute name="before" type="s:ST_TwipsMeasure" use="optional" default="0"/>
<xsd:attribute name="beforeLines" type="ST_DecimalNumber" use="optional" default="0"/>
<xsd:attribute name="beforeAutospacing" type="s:ST_OnOff" use="optional" default="off"/>
<xsd:attribute name="after" type="s:ST_TwipsMeasure" use="optional" default="0"/>
<xsd:attribute name="afterLines" type="ST_DecimalNumber" use="optional" default="0"/>
<xsd:attribute name="afterAutospacing" type="s:ST_OnOff" use="optional" default="off"/>
<xsd:attribute name="line" type="ST_SignedTwipsMeasure" use="optional" default="0"/>
<xsd:attribute name="lineRule" type="ST_LineSpacingRule" use="optional" default="auto"/>
</xsd:complexType>
<xsd:complexType name="CT_Ind">
<xsd:attribute name="start" type="ST_SignedTwipsMeasure" use="optional"/>
@ -669,7 +669,7 @@
<xsd:attribute name="lang" type="s:ST_Lang" use="required"/>
<xsd:attribute name="vendorID" type="s:ST_String" use="required"/>
<xsd:attribute name="dllVersion" type="s:ST_String" use="required"/>
<xsd:attribute name="nlCheck" type="s:ST_OnOff" use="optional"/>
<xsd:attribute name="nlCheck" type="s:ST_OnOff" use="optional" default="off"/>
<xsd:attribute name="checkStyle" type="s:ST_OnOff" use="required"/>
<xsd:attribute name="appName" type="s:ST_String" use="required"/>
</xsd:complexType>
@ -1101,7 +1101,7 @@
<xsd:sequence>
<xsd:element name="drawing" type="CT_Drawing" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="color" type="ST_HexColor" use="optional"/>
<xsd:attribute name="color" type="ST_HexColor" use="optional" default="auto"/>
<xsd:attribute name="themeColor" type="ST_ThemeColor" use="optional"/>
<xsd:attribute name="themeTint" type="ST_UcharHexNumber" use="optional"/>
<xsd:attribute name="themeShade" type="ST_UcharHexNumber" use="optional"/>
@ -1405,9 +1405,9 @@
<xsd:element name="bottom" type="CT_BottomPageBorder" minOccurs="0"/>
<xsd:element name="right" type="CT_PageBorder" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="zOrder" type="ST_PageBorderZOrder" use="optional"/>
<xsd:attribute name="zOrder" type="ST_PageBorderZOrder" use="optional" default="front"/>
<xsd:attribute name="display" type="ST_PageBorderDisplay" use="optional"/>
<xsd:attribute name="offsetFrom" type="ST_PageBorderOffset" use="optional"/>
<xsd:attribute name="offsetFrom" type="ST_PageBorderOffset" use="optional" default="text"/>
</xsd:complexType>
<xsd:complexType name="CT_PageBorder">
<xsd:complexContent>
@ -1450,27 +1450,27 @@
</xsd:simpleType>
<xsd:complexType name="CT_LineNumber">
<xsd:attribute name="countBy" type="ST_DecimalNumber" use="optional"/>
<xsd:attribute name="start" type="ST_DecimalNumber" use="optional"/>
<xsd:attribute name="start" type="ST_DecimalNumber" use="optional" default="1"/>
<xsd:attribute name="distance" type="s:ST_TwipsMeasure" use="optional"/>
<xsd:attribute name="restart" type="ST_LineNumberRestart" use="optional"/>
<xsd:attribute name="restart" type="ST_LineNumberRestart" use="optional" default="newPage"/>
</xsd:complexType>
<xsd:complexType name="CT_PageNumber">
<xsd:attribute name="fmt" type="ST_NumberFormat" use="optional"/>
<xsd:attribute name="fmt" type="ST_NumberFormat" use="optional" default="decimal"/>
<xsd:attribute name="start" type="ST_DecimalNumber" use="optional"/>
<xsd:attribute name="chapStyle" type="ST_DecimalNumber" use="optional"/>
<xsd:attribute name="chapSep" type="ST_ChapterSep" use="optional"/>
<xsd:attribute name="chapSep" type="ST_ChapterSep" use="optional" default="hyphen"/>
</xsd:complexType>
<xsd:complexType name="CT_Column">
<xsd:attribute name="w" type="s:ST_TwipsMeasure" use="optional"/>
<xsd:attribute name="space" type="s:ST_TwipsMeasure" use="optional"/>
<xsd:attribute name="space" type="s:ST_TwipsMeasure" use="optional" default="0"/>
</xsd:complexType>
<xsd:complexType name="CT_Columns">
<xsd:sequence minOccurs="0">
<xsd:element name="col" type="CT_Column" maxOccurs="45"/>
</xsd:sequence>
<xsd:attribute name="equalWidth" type="s:ST_OnOff" use="optional"/>
<xsd:attribute name="space" type="s:ST_TwipsMeasure" use="optional"/>
<xsd:attribute name="num" type="ST_DecimalNumber" use="optional"/>
<xsd:attribute name="space" type="s:ST_TwipsMeasure" use="optional" default="720"/>
<xsd:attribute name="num" type="ST_DecimalNumber" use="optional" default="1"/>
<xsd:attribute name="sep" type="s:ST_OnOff" use="optional"/>
</xsd:complexType>
<xsd:simpleType name="ST_VerticalJc">
@ -1713,7 +1713,6 @@
<xsd:restriction base="xsd:string">
<xsd:enumeration value="default"/>
<xsd:enumeration value="eastAsia"/>
<xsd:enumeration value="cs"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ST_Theme">
@ -1941,7 +1940,7 @@
<xsd:sequence>
<xsd:element name="listItem" type="CT_SdtListItem" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="lastValue" type="s:ST_String" use="optional"/>
<xsd:attribute name="lastValue" type="s:ST_String" use="optional" default=""/>
</xsd:complexType>
<xsd:complexType name="CT_SdtDocPart">
<xsd:sequence>
@ -1954,7 +1953,7 @@
<xsd:sequence>
<xsd:element name="listItem" type="CT_SdtListItem" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="lastValue" type="s:ST_String" use="optional"/>
<xsd:attribute name="lastValue" type="s:ST_String" use="optional" default=""/>
</xsd:complexType>
<xsd:complexType name="CT_Placeholder">
<xsd:sequence>

View File

@ -45,6 +45,7 @@ namespace codegen
public static string gc_sSerToBinEnumPrefix = "c_oSer";
public static string gc_sItemsChoiceType = "ItemsChoiceType";
public static string gc_sItemsElementName = "ItemsElementName";
public static Dictionary<string, string> m_mapNamespaceToPrefix = new Dictionary<string, string>() { { "http://purl.oclc.org/ooxml/drawingml/chart", "c:" }, { "http://purl.oclc.org/ooxml/drawingml/main", "a:" }, { "http://purl.oclc.org/ooxml/officeDocument/relationships", "r:" }, { "http://schemas.openxmlformats.org/markup-compatibility/2006", "mc:" }, { "http://schemas.microsoft.com/office/drawing/2007/8/2/chart", "c14:" } };
public static string GetEnumElemName(string sEnumName, string sElemName)
{
return sEnumName.ToLower() + sElemName.ToUpper();

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -10,8 +10,29 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>codepeg2</RootNamespace>
<AssemblyName>codepeg2</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -21,6 +42,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -29,6 +51,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@ -48,11 +71,14 @@
<Compile Include="CodeGen.cs" />
<Compile Include="CodegenCPP.cs" />
<Compile Include="CodegenJS.cs" />
<Compile Include="CodegenJSPivot.cs" />
<Compile Include="CodeGenPivot.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Resource\chart20070802.xsd" />
<None Include="Resource\dml-chart.xsd" />
<None Include="Resource\dml-chartDrawing.xsd" />
@ -77,6 +103,13 @@
<None Include="Resource\sml.xsd" />
<None Include="Resource\wml.xsd" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -45,10 +45,35 @@ namespace TestDocsWithChart
{
static void Main(string[] args)
{
getFilesAlternateContent();
getFilesPivot();
//getFilesAlternateContent();
//getFiles();
//convertFiles();
}
static void getFilesPivot()
{
string sDirInput = @"\\192.168.3.208\allusers\Files\XLSX";
string sDirOutput = @"D:\Files\Pivot";
String[] allfiles = System.IO.Directory.GetFiles(sDirInput, "*.*", System.IO.SearchOption.AllDirectories);
for (var i = 0; i < allfiles.Length; ++i)
{
string file = allfiles[i];
try
{
ZipArchive zip = ZipFile.OpenRead(file);
foreach (ZipArchiveEntry entry in zip.Entries)
{
if (-1 != entry.FullName.IndexOf("pivotTable", StringComparison.OrdinalIgnoreCase))
{
System.IO.File.Copy(file, Path.Combine(sDirOutput, Path.GetFileName(file)), true);
break;
}
}
}
catch { }
}
}
static void getFilesAlternateContent()
{
string sAlternateContent = ":Choice ";

View File

@ -7,11 +7,10 @@
QT -= core
QT -= gui
VERSION = 2.4.448.000
VERSION = 2.4.451.0
DEFINES += INTVER=$$VERSION
TARGET = x2t
CORE_ROOT_DIR = $$PWD/../../..
PWD_ROOT_DIR = $$PWD

View File

@ -185,8 +185,9 @@ namespace BinXlsxRW
DefinedNames = 3,
DefinedName = 4,
ExternalReferences = 5,
ExternalReference = 6
ExternalReference = 6,
PivotCaches = 7,
PivotCache = 8
};}
namespace c_oSerWorkbookPrTypes{enum c_oSerWorkbookPrTypes
{
@ -232,7 +233,8 @@ namespace BinXlsxRW
SheetViews = 22,
SheetView = 23,
SheetPr = 24,
SparklineGroups = 25
SparklineGroups = 25,
PivotTable = 26
};}
namespace c_oSerWorksheetPropTypes{enum c_oSerWorksheetPropTypes
{
@ -809,6 +811,14 @@ namespace BinXlsxRW
AltText = 0,
AltTextSummary = 1
};}
namespace c_oSer_PivotTypes{enum c_oSerPivotTypes
{
id = 0,
cache = 1,
record = 2,
cacheId = 3,
table = 4
};}
}
#endif //

View File

@ -863,6 +863,13 @@ namespace BinXlsxRW
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(xfs.m_oQuotePrefix->ToBool());
}
//PivotButton
if(false != xfs.m_oPivotButton.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerXfsTypes::PivotButton);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(xfs.m_oPivotButton->ToBool());
}
//XfId
if (false != xfs.m_oXfId.IsInit())
{

View File

@ -64,6 +64,27 @@ namespace BinXlsxRW {
nIndex = _nIndex;
}
};
class PivotCachesTemp
{
public:
long nId;
BYTE* pDefinitionData;
long nDefinitionLength;
OOX::Spreadsheet::CPivotCacheRecords* pRecords;
long nCacheId;
OOX::Spreadsheet::CPivotTable* pTable;
public:
PivotCachesTemp()
{
nId = -1;
pDefinitionData = NULL;
nDefinitionLength = 0;
pRecords = NULL;
nCacheId = -1;
pTable = NULL;
}
};
class Binary_CommonReader2
{
protected:
@ -1212,6 +1233,11 @@ namespace BinXlsxRW {
pXfs->m_oQuotePrefix.Init();
pXfs->m_oQuotePrefix->SetValue(false != m_oBufferedStream.GetBool() ? SimpleTypes::onoffTrue : SimpleTypes::onoffFalse);
}
else if(c_oSerXfsTypes::PivotButton == type)
{
pXfs->m_oPivotButton.Init();
pXfs->m_oPivotButton->SetValue(false != m_oBufferedStream.GetBool() ? SimpleTypes::onoffTrue : SimpleTypes::onoffFalse);
}
else if(c_oSerXfsTypes::Aligment == type)
{
pXfs->m_oAligment.Init();
@ -1477,8 +1503,9 @@ namespace BinXlsxRW {
class BinaryWorkbookTableReader : public Binary_CommonReader<BinaryWorkbookTableReader>
{
OOX::Spreadsheet::CWorkbook& m_oWorkbook;
std::map<long, NSCommon::smart_ptr<OOX::File>>& m_mapPivotCacheDefinitions;
public:
BinaryWorkbookTableReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, OOX::Spreadsheet::CWorkbook& oWorkbook):Binary_CommonReader(oBufferedStream), m_oWorkbook(oWorkbook)
BinaryWorkbookTableReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, OOX::Spreadsheet::CWorkbook& oWorkbook, std::map<long, NSCommon::smart_ptr<OOX::File>>& mapPivotCacheDefinitions):Binary_CommonReader(oBufferedStream), m_oWorkbook(oWorkbook), m_mapPivotCacheDefinitions(mapPivotCacheDefinitions)
{
}
int Read()
@ -1508,6 +1535,13 @@ namespace BinXlsxRW {
m_oWorkbook.m_oExternalReferences.Init();
res = Read1(length, &BinaryWorkbookTableReader::ReadExternalReferences, this, poResult);
}
else if(c_oSerWorkbookTypes::PivotCaches == type)
{
m_oWorkbook.m_oPivotCachesXml.Init();
m_oWorkbook.m_oPivotCachesXml->append(L"<pivotCaches>");
res = Read1(length, &BinaryWorkbookTableReader::ReadPivotCaches, this, poResult);
m_oWorkbook.m_oPivotCachesXml->append(L"</pivotCaches>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -1633,7 +1667,67 @@ namespace BinXlsxRW {
{
pDefinedName->m_oComment.Init();
pDefinedName->m_oComment->append(m_oBufferedStream.GetString4(length));
}
}
else
res = c_oSerConstants::ReadUnknown;
return res;
};
int ReadPivotCaches(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
if(c_oSerWorkbookTypes::PivotCache == type)
{
PivotCachesTemp oPivotCachesTemp;
res = Read1(length, &BinaryWorkbookTableReader::ReadPivotCache, this, &oPivotCachesTemp);
if(-1 != oPivotCachesTemp.nId && NULL != oPivotCachesTemp.pDefinitionData)
{
OOX::Spreadsheet::CPivotCacheDefinition* pDefinition = new OOX::Spreadsheet::CPivotCacheDefinition();
std::wstring srIdRecords;
if(NULL != oPivotCachesTemp.pRecords)
{
NSCommon::smart_ptr<OOX::File> pFileRecords(oPivotCachesTemp.pRecords);
srIdRecords = pDefinition->Add(pFileRecords).ToString();
}
pDefinition->setData(oPivotCachesTemp.pDefinitionData, oPivotCachesTemp.nDefinitionLength, srIdRecords);
NSCommon::smart_ptr<OOX::File> pFileDefinition(pDefinition);
OOX::RId rIdDefinition = m_oWorkbook.Add(pFileDefinition);
m_oWorkbook.m_oPivotCachesXml->append(L"<pivotCache cacheId=\"");
m_oWorkbook.m_oPivotCachesXml->append(std::to_wstring(oPivotCachesTemp.nId));
m_oWorkbook.m_oPivotCachesXml->append(L"\" r:id=\"");
m_oWorkbook.m_oPivotCachesXml->append(rIdDefinition.ToString());
m_oWorkbook.m_oPivotCachesXml->append(L"\"/>");
m_mapPivotCacheDefinitions[oPivotCachesTemp.nId] = pFileDefinition;
}
else
{
RELEASEOBJECT(oPivotCachesTemp.pRecords);
}
}
else
res = c_oSerConstants::ReadUnknown;
return res;
};
int ReadPivotCache(BYTE type, long length, void* poResult)
{
PivotCachesTemp* pPivotCachesTemp = static_cast<PivotCachesTemp*>(poResult);
int res = c_oSerConstants::ReadOk;
if(c_oSer_PivotTypes::id == type)
{
pPivotCachesTemp->nId = m_oBufferedStream.GetLong();
}
else if(c_oSer_PivotTypes::cache == type)
{
pPivotCachesTemp->pDefinitionData = m_oBufferedStream.GetPointer(length);
pPivotCachesTemp->nDefinitionLength = length;
}
else if(c_oSer_PivotTypes::record == type)
{
pPivotCachesTemp->pRecords = new OOX::Spreadsheet::CPivotCacheRecords();
pPivotCachesTemp->pRecords->setData(m_oBufferedStream.GetPointer(length), length);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
};
};
@ -1876,14 +1970,15 @@ namespace BinXlsxRW {
NSBinPptxRW::CDrawingConverter* m_pOfficeDrawingConverter;
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& m_mapWorksheets;
std::map<long, NSCommon::smart_ptr<OOX::File>>& m_mapPivotCacheDefinitions;
public:
BinaryWorksheetsTableReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, OOX::Spreadsheet::CWorkbook& oWorkbook,
OOX::Spreadsheet::CSharedStrings* pSharedStrings, std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets,
std::map<long, ImageObject*>& mapMedia, const std::wstring& sDestinationDir, const std::wstring& sMediaDir, SaveParams& oSaveParams,
NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter)
NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, std::map<long, NSCommon::smart_ptr<OOX::File>>& mapPivotCacheDefinitions)
: Binary_CommonReader(oBufferedStream), m_oWorkbook(oWorkbook), m_oBcr2(oBufferedStream), m_sMediaDir(sMediaDir), m_oSaveParams(oSaveParams),
m_mapMedia(mapMedia), m_sDestinationDir(sDestinationDir), m_mapWorksheets(mapWorksheets), m_pSharedStrings(pSharedStrings)
m_mapMedia(mapMedia), m_sDestinationDir(sDestinationDir), m_mapWorksheets(mapWorksheets), m_pSharedStrings(pSharedStrings),m_mapPivotCacheDefinitions(mapPivotCacheDefinitions)
{
m_pCurSheet = NULL;
m_pCurWorksheet = NULL;
@ -2110,10 +2205,45 @@ namespace BinXlsxRW {
m_pCurWorksheet->m_oExtLst.Init();
m_pCurWorksheet->m_oExtLst->m_arrExt.push_back(pOfficeArtExtension);
}
else if(c_oSerWorksheetsTypes::PivotTable == type)
{
PivotCachesTemp oPivotCachesTemp;
res = Read1(length, &BinaryWorksheetsTableReader::ReadPivotTable, this, &oPivotCachesTemp);
std::map<long, NSCommon::smart_ptr<OOX::File>>::const_iterator pair = m_mapPivotCacheDefinitions.find(oPivotCachesTemp.nCacheId);
if(m_mapPivotCacheDefinitions.end() != pair && NULL != oPivotCachesTemp.pTable)
{
NSCommon::smart_ptr<OOX::File> pFileTable(oPivotCachesTemp.pTable);
oPivotCachesTemp.pTable->AddNoWrite(pair->second, L"../pivotCache");
m_pCurWorksheet->Add(pFileTable);
}
else
{
RELEASEOBJECT(oPivotCachesTemp.pTable);
}
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadPivotTable(BYTE type, long length, void* poResult)
{
PivotCachesTemp* pPivotCachesTemp = static_cast<PivotCachesTemp*>(poResult);
int res = c_oSerConstants::ReadOk;
if(c_oSer_PivotTypes::cacheId == type)
{
pPivotCachesTemp->nCacheId =m_oBufferedStream.GetLong();
}
else if(c_oSer_PivotTypes::table == type)
{
OOX::Spreadsheet::CPivotTable* pPivotTable = new OOX::Spreadsheet::CPivotTable();
pPivotTable->setData(m_oBufferedStream.GetPointer(length), length);
pPivotCachesTemp->pTable = pPivotTable;
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadWorksheetProp(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -3841,6 +3971,7 @@ namespace BinXlsxRW {
std::vector<long> aOffBits;
long nOtherOffBits = -1;
long nSharedStringsOffBits = -1;
long nWorkbookOffBits = -1;
BYTE mtLen = oBufferedStream.GetUChar();
for(int i = 0; i < mtLen; ++i)
@ -3855,6 +3986,8 @@ namespace BinXlsxRW {
nOtherOffBits = mtiOffBits;
else if(c_oSerTableTypes::SharedStrings == mtiType)
nSharedStringsOffBits = mtiOffBits;
else if(c_oSerTableTypes::Workbook == mtiType)
nWorkbookOffBits = mtiOffBits;
else
{
aTypes.push_back(mtiType);
@ -3883,8 +4016,16 @@ namespace BinXlsxRW {
if(c_oSerConstants::ReadOk != res)
return res;
}
OOX::Spreadsheet::CWorkbook* pWorkbook = oXlsx.CreateWorkbook();
std::map<long, NSCommon::smart_ptr<OOX::File>> m_mapPivotCacheDefinitions;
if(-1 != nWorkbookOffBits)
{
oBufferedStream.Seek(nWorkbookOffBits);
res = BinaryWorkbookTableReader(oBufferedStream, *pWorkbook, m_mapPivotCacheDefinitions).Read();
if(c_oSerConstants::ReadOk != res)
return res;
}
for(size_t i = 0, length = aTypes.size(); i < length; ++i)
{
BYTE mtiType = aTypes[i];
@ -3899,14 +4040,9 @@ namespace BinXlsxRW {
res = BinaryStyleTableReader(oBufferedStream, *pStyles).Read();
}
break;
case c_oSerTableTypes::Workbook:
{
res = BinaryWorkbookTableReader(oBufferedStream, *pWorkbook).Read();
}
break;
case c_oSerTableTypes::Worksheets:
{
res = BinaryWorksheetsTableReader(oBufferedStream, *pWorkbook, pSharedStrings, oXlsx.GetWorksheets(), mapMedia, sOutDir, sMediaDir, oSaveParams, pOfficeDrawingConverter).Read();
res = BinaryWorksheetsTableReader(oBufferedStream, *pWorkbook, pSharedStrings, oXlsx.GetWorksheets(), mapMedia, sOutDir, sMediaDir, oSaveParams, pOfficeDrawingConverter, m_mapPivotCacheDefinitions).Read();
}
break;
}