mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-11 02:16:02 +08:00
Compare commits
27 Commits
core-windo
...
core/devel
| Author | SHA1 | Date | |
|---|---|---|---|
| d2630ea73c | |||
| a4a58c4782 | |||
| 29a3d80071 | |||
| 598bb419c0 | |||
| 087da9d2ce | |||
| c505aced48 | |||
| 959d5e5fcd | |||
| 8ee0cf4b2c | |||
| 426342074e | |||
| d2c092fe62 | |||
| a336917338 | |||
| 8925ddeee5 | |||
| 84824631b2 | |||
| dc3ecb1fc0 | |||
| 266cef8c49 | |||
| a5e821cd21 | |||
| cb5d92334e | |||
| f6dbc6b9f0 | |||
| c2c6430495 | |||
| 9ecf5b7834 | |||
| 1d003863dd | |||
| 774561bd00 | |||
| d356a305b9 | |||
| 2dbec241f7 | |||
| f3c66cab50 | |||
| 51c77c3a85 | |||
| 4326a7d258 |
@ -45,13 +45,13 @@ namespace Writers
|
||||
int index;
|
||||
};
|
||||
std::vector<_chartElem> m_aCharts;
|
||||
int nChartCount;
|
||||
public:
|
||||
std::wstring m_sDir;
|
||||
int nEmbeddedCount;
|
||||
|
||||
ChartWriter(std::wstring sDir) : m_sDir(sDir)
|
||||
{
|
||||
nChartCount = 0;
|
||||
nEmbeddedCount = 1000;
|
||||
}
|
||||
~ChartWriter()
|
||||
{
|
||||
@ -80,30 +80,20 @@ namespace Writers
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void AddChart(std::wstring& content, std::wstring& sRelsName, std::wstring& sFileName, int& index)
|
||||
void AddChart(std::wstring& content, std::wstring& sRelsName, std::wstring& sFileName, int index)
|
||||
{
|
||||
_chartElem oChartElem;
|
||||
|
||||
oChartElem.content = content;
|
||||
oChartElem.index = nChartCount + 1;
|
||||
nChartCount++;
|
||||
oChartElem.index = index;
|
||||
|
||||
oChartElem.filename = L"chart" + std::to_wstring(oChartElem.index) + L".xml";
|
||||
|
||||
sRelsName = L"charts/" + oChartElem.filename;
|
||||
sFileName = oChartElem.filename;
|
||||
index = oChartElem.index;
|
||||
|
||||
m_aCharts.push_back(oChartElem);
|
||||
}
|
||||
int getChartCount()
|
||||
{
|
||||
return nChartCount;
|
||||
}
|
||||
void setChartCount(int val)
|
||||
{
|
||||
nChartCount = val;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif // #ifndef CHART_WRITER
|
||||
|
||||
@ -6292,15 +6292,11 @@ public:
|
||||
std::wstring sDrawingProperty = oCDrawingProperty.Write();
|
||||
if(false == sDrawingProperty.empty())
|
||||
{
|
||||
m_oFileWriter.m_pDrawingConverter->SetDocumentChartsCount(m_oFileWriter.m_oChartWriter.getChartCount());
|
||||
|
||||
long nCurPos = m_oBufferedStream.GetPos();
|
||||
std::wstring sDrawingXml;
|
||||
m_oFileWriter.m_pDrawingConverter->SaveObjectEx(oCDrawingProperty.DataPos, oCDrawingProperty.DataLength, sDrawingProperty, XMLWRITER_DOC_TYPE_DOCX, sDrawingXml);
|
||||
m_oBufferedStream.Seek(nCurPos);
|
||||
|
||||
m_oFileWriter.m_oChartWriter.setChartCount(m_oFileWriter.m_pDrawingConverter->GetDocumentChartsCount());
|
||||
|
||||
if( false == sDrawingXml.empty())
|
||||
{
|
||||
GetRunStringWriter().WriteString(sDrawingXml);
|
||||
@ -6606,8 +6602,11 @@ public:
|
||||
OOX::Spreadsheet::CChartSpace* pChartSpace = new OOX::Spreadsheet::CChartSpace();
|
||||
oBinaryChartReader.ReadCT_ChartSpace(length, &pChartSpace->m_oChartSpace);
|
||||
|
||||
//save xlsx
|
||||
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(m_oFileWriter.m_oChartWriter.getChartCount() + 1) + L".xlsx";
|
||||
//save xlsx
|
||||
_INT32 nChartCount = m_oFileWriter.m_pDrawingConverter->GetDocumentChartsCount();
|
||||
_INT32 nChartIndex = nChartCount + 1;
|
||||
m_oFileWriter.m_pDrawingConverter->SetDocumentChartsCount(nChartCount + 1);
|
||||
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(nChartIndex) + L".xlsx";
|
||||
std::wstring sXlsxPath = pathChartsWorksheetDir.GetPath() + FILE_SEPARATOR_STR + sXlsxFilename;
|
||||
BinXlsxRW::CXlsxSerializer oXlsxSerializer;
|
||||
oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace);
|
||||
@ -6632,7 +6631,6 @@ public:
|
||||
|
||||
std::wstring sFilename;
|
||||
std::wstring sRelsName;
|
||||
int nChartIndex;
|
||||
std::wstring sContent = sw.GetData();
|
||||
|
||||
m_oFileWriter.m_oChartWriter.AddChart(sContent, sRelsName, sFilename, nChartIndex);
|
||||
@ -6826,8 +6824,7 @@ public:
|
||||
std::wstring strDstEmbeddedTemp = strDstEmbedded + FILE_SEPARATOR_STR + L"Temp";
|
||||
NSDirectory::CreateDirectory(strDstEmbeddedTemp);
|
||||
|
||||
int id = m_oFileWriter.m_oChartWriter.getChartCount();
|
||||
m_oFileWriter.m_oChartWriter.setChartCount(id + 1);
|
||||
int id = m_oFileWriter.m_oChartWriter.nEmbeddedCount++;
|
||||
|
||||
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring( id + 1) + L".xlsx";
|
||||
BinXlsxRW::SaveParams oSaveParams(m_oFileWriter.m_sThemePath, m_oFileWriter.m_pDrawingConverter->GetContentTypes());//???
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="windows-1251"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Version="8.00"
|
||||
Name="OdfFileReaderTest"
|
||||
ProjectGUID="{C2882DDD-07E6-4314-AD4B-48F43F38D722}"
|
||||
RootNamespace="ASCOfficeOdfFileTest"
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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;}
|
||||
|
||||
@ -136,7 +136,8 @@ void xlsx_text_context::Impl::serialize_shared_strings(std::wostream & strm)
|
||||
xlsx_text_context::Impl::Impl(odf_reader::styles_container & styles): paragraphs_cout_(0),styles_(styles),
|
||||
in_comment(false),in_draw(false),in_paragraph(false),in_span(false),in_cell_content(false)
|
||||
{
|
||||
text_properties_cell_ = NULL;
|
||||
local_styles_ptr_ = NULL;
|
||||
text_properties_cell_ = NULL;
|
||||
}
|
||||
|
||||
void xlsx_text_context::Impl::add_text(const std::wstring & text)
|
||||
@ -236,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));
|
||||
}
|
||||
|
||||
@ -290,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)
|
||||
@ -302,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_)
|
||||
|
||||
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -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
|
||||
|
||||
@ -403,9 +403,11 @@ int draw_enhanced_geometry::parsing(_CP_OPT(std::wstring) val)
|
||||
void draw_enhanced_geometry_attlist::serialize(CP_ATTR_NODE)
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"draw:type", draw_type_);
|
||||
CP_XML_ATTR_OPT(L"draw:text-areas", draw_text_areas_);
|
||||
CP_XML_ATTR_OPT(L"drawooo:sub-view-size", draw_sub_view_size_);
|
||||
CP_XML_ATTR_OPT(L"draw:text-areas", draw_text_areas_);
|
||||
CP_XML_ATTR_OPT(L"draw:modifiers", draw_modifiers_);
|
||||
CP_XML_ATTR_OPT(L"draw:enhanced-path", draw_enhanced_path_);
|
||||
CP_XML_ATTR_OPT(L"drawooo:enhanced-path", draw_enhanced_path_);
|
||||
//CP_XML_ATTR_OPT(L"draw:enhanced-path", draw_enhanced_path_);
|
||||
CP_XML_ATTR_OPT(L"draw:glue-points", draw_glue_points_);
|
||||
CP_XML_ATTR_OPT(L"draw:mirror-vertical", draw_mirror_vertical_);
|
||||
CP_XML_ATTR_OPT(L"draw:mirror-horizontal", draw_mirror_horizontal_);
|
||||
|
||||
@ -316,19 +316,21 @@ CP_REGISTER_OFFICE_ELEMENT2(draw_handle);
|
||||
class draw_enhanced_geometry_attlist
|
||||
{
|
||||
public:
|
||||
_CP_OPT(std::wstring) draw_type_;
|
||||
_CP_OPT(std::wstring) draw_modifiers_;
|
||||
_CP_OPT(std::wstring) draw_enhanced_path_;
|
||||
_CP_OPT(std::wstring) draw_text_areas_;
|
||||
_CP_OPT(std::wstring) draw_glue_points_;
|
||||
_CP_OPT(std::wstring) draw_type_;
|
||||
_CP_OPT(std::wstring) draw_modifiers_;
|
||||
_CP_OPT(std::wstring) draw_enhanced_path_;
|
||||
_CP_OPT(std::wstring) draw_text_areas_;
|
||||
_CP_OPT(std::wstring) draw_glue_points_;
|
||||
|
||||
_CP_OPT(odf_types::Bool) draw_mirror_vertical_;
|
||||
_CP_OPT(odf_types::Bool) draw_mirror_horizontal_;
|
||||
_CP_OPT(std::wstring) draw_sub_view_size_;
|
||||
|
||||
_CP_OPT(odf_types::Bool) draw_mirror_vertical_;
|
||||
_CP_OPT(odf_types::Bool) draw_mirror_horizontal_;
|
||||
|
||||
_CP_OPT(odf_types::Bool) draw_text_path_;
|
||||
_CP_OPT(odf_types::Bool) draw_text_path_same_letter_heights_;
|
||||
_CP_OPT(std::wstring) draw_text_path_mode_;
|
||||
_CP_OPT(std::wstring) draw_text_path_scale_;
|
||||
_CP_OPT(odf_types::Bool) draw_text_path_;
|
||||
_CP_OPT(odf_types::Bool) draw_text_path_same_letter_heights_;
|
||||
_CP_OPT(std::wstring) draw_text_path_mode_;
|
||||
_CP_OPT(std::wstring) draw_text_path_scale_;
|
||||
|
||||
void serialize(CP_ATTR_NODE);
|
||||
};
|
||||
|
||||
@ -96,7 +96,7 @@ void odf_comment_context::start_comment(office_element_ptr &elm, int oox_id)
|
||||
|
||||
impl_->comments_.push_back(state);
|
||||
impl_->comments_.back().elements_.push_back(elm);//"0" - root comment eleemnt
|
||||
impl_->comments_.back().oox_id = oox_id;
|
||||
impl_->comments_.back().oox_id = oox_id < 0 ? impl_->comments_.back().elements_.size() : oox_id;
|
||||
impl_->comments_.back().odf_name = L"comment_" + boost::lexical_cast<std::wstring>(oox_id);
|
||||
|
||||
impl_->comments_.back().is_started = false;
|
||||
@ -159,14 +159,14 @@ std::wstring odf_comment_context::find_name_by_id(int oox_id)
|
||||
}
|
||||
bool odf_comment_context::is_started()
|
||||
{
|
||||
if (impl_->comments_.size()>0)
|
||||
if (!impl_->comments_.empty())
|
||||
return impl_->comments_.back().is_started;
|
||||
else return false;
|
||||
|
||||
}
|
||||
void odf_comment_context::set_author(std::wstring author)
|
||||
{
|
||||
if ((impl_->comments_.size()<1) || !is_started()) return;
|
||||
if ((impl_->comments_.empty()) || !is_started()) return;
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"dc", L"creator", elm, impl_->odf_context_);
|
||||
@ -178,11 +178,15 @@ void odf_comment_context::set_author(std::wstring author)
|
||||
|
||||
impl_->comments_.back().elements_[0]->add_child_element(elm);
|
||||
impl_->comments_.back().elements_.push_back(elm);
|
||||
}
|
||||
void odf_comment_context::set_initials(std::wstring initials)
|
||||
{
|
||||
if ((impl_->comments_.empty()) || !is_started()) return;
|
||||
|
||||
}
|
||||
void odf_comment_context::set_date(std::wstring _date)
|
||||
{
|
||||
if ((impl_->comments_.size()<1) || !is_started()) return;
|
||||
if ((impl_->comments_.empty()) || !is_started()) return;
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"dc", L"date", elm, impl_->odf_context_);
|
||||
@ -195,5 +199,18 @@ void odf_comment_context::set_date(std::wstring _date)
|
||||
impl_->comments_.back().elements_[0]->add_child_element(elm);
|
||||
impl_->comments_.back().elements_.push_back(elm);
|
||||
}
|
||||
void odf_comment_context::set_position (double x, double y)
|
||||
{
|
||||
if ((impl_->comments_.empty()) || !is_started()) return;
|
||||
|
||||
office_annotation* comm = dynamic_cast<office_annotation*>(impl_->comments_.back().elements_.back().get());
|
||||
|
||||
if (comm)
|
||||
{
|
||||
comm->office_annotation_attr_.svg_x_ = odf_types::length(x, odf_types::length::pt);
|
||||
comm->office_annotation_attr_.svg_y_ = odf_types::length(y, odf_types::length::pt);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -66,8 +66,11 @@ public:
|
||||
void start_comment_content ();
|
||||
void end_comment_content ();
|
||||
|
||||
void set_author (std::wstring author);
|
||||
void set_date (std::wstring author);
|
||||
void set_author (std::wstring author);
|
||||
void set_initials (std::wstring author);
|
||||
void set_date (std::wstring author);
|
||||
|
||||
void set_position (double x, double y);
|
||||
|
||||
private:
|
||||
std::wstring find_name_by_id(int oox_id);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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"";
|
||||
modifiers_ = 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,29 +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_;
|
||||
std::wstring modifiers_;
|
||||
|
||||
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
|
||||
@ -317,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;
|
||||
@ -462,7 +467,7 @@ 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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -491,14 +496,20 @@ void odf_drawing_context::end_drawing()
|
||||
_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_)
|
||||
// draw_layer = L"backgroundobjects";
|
||||
//else draw_layer = L"layout";
|
||||
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;
|
||||
@ -510,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_)
|
||||
{
|
||||
@ -533,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_)
|
||||
@ -577,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;
|
||||
}
|
||||
@ -595,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
|
||||
{
|
||||
@ -616,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_;
|
||||
@ -696,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;
|
||||
@ -708,12 +722,15 @@ 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();
|
||||
|
||||
if (current_level_.size()>0)
|
||||
if (current_level_.size() > 0)
|
||||
current_level_.back()->add_child_element(draw_elm);
|
||||
|
||||
current_level_.push_back(draw_elm);
|
||||
@ -722,11 +739,14 @@ void odf_drawing_context::Impl::create_draw_base(int type)
|
||||
|
||||
current_drawing_state_.elements_.push_back(state);
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (type == 7)
|
||||
current_drawing_state_.oox_shape_ = oox_shape_ptr(new oox_shape());
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
@ -738,7 +758,7 @@ void odf_drawing_context::start_shape(int type)
|
||||
}
|
||||
else if (type == 1001)
|
||||
{
|
||||
impl_->create_draw_base(6);//пока кастом .. потом переделать на path, что правильнее
|
||||
impl_->create_draw_base(6); //path
|
||||
}
|
||||
else if (type == 2000)
|
||||
{
|
||||
@ -748,18 +768,27 @@ void odf_drawing_context::start_shape(int type)
|
||||
{
|
||||
start_image(L"");
|
||||
}
|
||||
else if (type > 2000 && type < 3000)
|
||||
else if (type > 2000 && type < 3000) //custom text path
|
||||
{
|
||||
impl_->create_draw_base(7);
|
||||
impl_->create_draw_base(7);
|
||||
}
|
||||
}
|
||||
|
||||
bool odf_drawing_context::is_wordart()
|
||||
{
|
||||
if (impl_->current_drawing_state_.oox_shape_preset_ > 2000 && impl_->current_drawing_state_.oox_shape_preset_ < 3000)
|
||||
return true;
|
||||
|
||||
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)
|
||||
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;
|
||||
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());
|
||||
@ -797,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;
|
||||
@ -808,11 +837,14 @@ 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();
|
||||
//вторичные, вычисляемые свойства шейпов
|
||||
|
||||
bool line_always_present = false;
|
||||
if (isLineShape())
|
||||
{
|
||||
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_ = draw_fill::none;
|
||||
}
|
||||
|
||||
draw_path* path = dynamic_cast<draw_path*>(impl_->current_drawing_state_.elements_[0].elm.get());
|
||||
if (path)
|
||||
@ -821,10 +853,8 @@ void odf_drawing_context::end_shape()
|
||||
set_viewBox( impl_->current_drawing_state_.svg_width_->get_value_unit(length::cm) * 1000,
|
||||
impl_->current_drawing_state_.svg_height_->get_value_unit(length::cm) *1000);
|
||||
|
||||
if (impl_->current_drawing_state_.path_.length()>1) path->draw_path_attlist_.svg_d_ = impl_->current_drawing_state_.path_;
|
||||
if (impl_->current_drawing_state_.view_box_.length()>1) path->draw_path_attlist_.svg_viewbox_ = impl_->current_drawing_state_.view_box_;
|
||||
|
||||
line_always_present = true;
|
||||
if (!impl_->current_drawing_state_.path_.empty()) path->draw_path_attlist_.svg_d_ = impl_->current_drawing_state_.path_;
|
||||
if (!impl_->current_drawing_state_.view_box_.empty()) path->draw_path_attlist_.svg_viewbox_ = impl_->current_drawing_state_.view_box_;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
draw_line* line = dynamic_cast<draw_line*>(impl_->current_level_.back().get());
|
||||
@ -845,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;
|
||||
|
||||
@ -853,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;
|
||||
|
||||
@ -861,16 +891,14 @@ void odf_drawing_context::end_shape()
|
||||
line->draw_line_attlist_.svg_x1_ = line->draw_line_attlist_.svg_x2_;
|
||||
line->draw_line_attlist_.svg_x2_ = tmp;
|
||||
}
|
||||
|
||||
line_always_present = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
draw_connector* connector = dynamic_cast<draw_connector*>(impl_->current_level_.back().get());
|
||||
if (connector)
|
||||
{
|
||||
if (!connector->draw_connector_attlist_.draw_type_) connector->draw_connector_attlist_.draw_type_ = L"line";
|
||||
line_always_present = true;
|
||||
if (!connector->draw_connector_attlist_.draw_type_)
|
||||
connector->draw_connector_attlist_.draw_type_ = L"line";
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -880,19 +908,19 @@ 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;
|
||||
}
|
||||
else
|
||||
{
|
||||
sub_type = L"polyline";
|
||||
line_always_present = true;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// sub_type = L"polyline";
|
||||
// line_always_present = true;
|
||||
//}
|
||||
|
||||
office_element_ptr enhanced_elm;
|
||||
create_element(L"draw", L"enhanced-geometry", enhanced_elm, impl_->odf_context_);
|
||||
@ -906,52 +934,50 @@ void odf_drawing_context::end_shape()
|
||||
{
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_same_letter_heights_ = false;
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_scale_ = L"path" ;
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_mode_ = L"shape" ;
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_ = true;
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_mode_ = L"shape" ;
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_ = true;
|
||||
}
|
||||
|
||||
if (impl_->current_drawing_state_.path_.length()>1)
|
||||
if (!impl_->current_drawing_state_.path_.empty())
|
||||
{
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ =impl_->current_drawing_state_.path_;
|
||||
}
|
||||
if (impl_->current_drawing_state_.view_box_.length()>1)
|
||||
if (!impl_->current_drawing_state_.view_box_.empty())
|
||||
{
|
||||
enhanced->svg_viewbox_ = impl_->current_drawing_state_.view_box_;
|
||||
}
|
||||
if (sub_type.length()>1)
|
||||
if (!sub_type.empty())
|
||||
{
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_type_ = sub_type;
|
||||
|
||||
int res=0;
|
||||
if ((res = sub_type.find(L"ooxml")) >= 0 && impl_->current_drawing_state_.modifiers_.length()>1)
|
||||
{
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = impl_->current_drawing_state_.modifiers_;
|
||||
}
|
||||
}
|
||||
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_;
|
||||
|
||||
if (shape_define)
|
||||
{
|
||||
enhanced->svg_viewbox_ = shape_define->view_box;
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_type_ = shape_define->odf_type_name;
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_text_areas_ = shape_define->text_areas;
|
||||
if (shape_define->glue_points)
|
||||
{
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_glue_points_ = *shape_define->glue_points;
|
||||
}
|
||||
enhanced->svg_viewbox_ = shape_define->view_box;
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_type_ = shape_define->odf_type_name;
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_text_areas_ = shape_define->text_areas;
|
||||
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_glue_points_ = shape_define->glue_points;
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_sub_view_size_ = shape_define->sub_view_size;
|
||||
|
||||
if (impl_->current_drawing_state_.modifiers_.length()>1)
|
||||
if (impl_->current_drawing_state_.oox_shape_ && !impl_->current_drawing_state_.oox_shape_->modifiers.empty())
|
||||
{
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = impl_->current_drawing_state_.modifiers_;
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = impl_->current_drawing_state_.oox_shape_->modifiers;
|
||||
}
|
||||
else // обязательно нужны дефолтовые
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = shape_define->modifiers;
|
||||
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ = shape_define->enhanced_path;
|
||||
if (!shape_define->enhanced_path.empty())
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ = shape_define->enhanced_path;
|
||||
else
|
||||
enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ = impl_->current_drawing_state_.path_;
|
||||
|
||||
for (size_t i = 0; i < shape_define->equations.size();i++)
|
||||
for (size_t i = 0; i < shape_define->equations.size(); i++)
|
||||
{
|
||||
office_element_ptr elm_eq;
|
||||
create_element(L"draw", L"equation", elm_eq, impl_->odf_context_);
|
||||
@ -965,7 +991,7 @@ void odf_drawing_context::end_shape()
|
||||
end_element();
|
||||
}
|
||||
//-----------------------------
|
||||
for (size_t i = 0; i < shape_define->handles.size();i++)
|
||||
for (size_t i = 0; i < shape_define->handles.size(); i++)
|
||||
{
|
||||
office_element_ptr elm_h;
|
||||
create_element(L"draw", L"handle", elm_h, impl_->odf_context_);
|
||||
@ -988,7 +1014,38 @@ void odf_drawing_context::end_shape()
|
||||
}
|
||||
end_element();
|
||||
}
|
||||
void odf_drawing_context::corrected_line_fill()
|
||||
|
||||
bool odf_drawing_context::isLineShape()
|
||||
{
|
||||
if (impl_->current_level_.empty()) return false;
|
||||
|
||||
draw_line* line = dynamic_cast<draw_line*>(impl_->current_level_.back().get());
|
||||
if (line) return true;
|
||||
|
||||
draw_connector* connector = dynamic_cast<draw_connector*>(impl_->current_level_.back().get());
|
||||
if (connector) return true;
|
||||
|
||||
draw_path* path = dynamic_cast<draw_path*>(impl_->current_level_.back().get());
|
||||
if (path) return true;
|
||||
|
||||
switch(impl_->current_drawing_state_.oox_shape_preset_)
|
||||
{
|
||||
case 20: //SimpleTypes::shapetypeBentConnector2:
|
||||
case 21: //SimpleTypes::shapetypeBentConnector3:
|
||||
case 22: //SimpleTypes::shapetypeBentConnector4:
|
||||
case 23: //SimpleTypes::shapetypeBentConnector5:
|
||||
case 47: //SimpleTypes::shapetypeCurvedConnector2:
|
||||
case 48: //SimpleTypes::shapetypeCurvedConnector3:
|
||||
case 49: //SimpleTypes::shapetypeCurvedConnector4:
|
||||
case 50: //SimpleTypes::shapetypeCurvedConnector5:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void odf_drawing_context::corrected_line_fill() //for vml objects
|
||||
{
|
||||
if (!impl_->current_graphic_properties)return;
|
||||
|
||||
@ -1135,16 +1192,16 @@ void odf_drawing_context::set_placeholder_type (int val)
|
||||
{
|
||||
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;
|
||||
@ -1152,7 +1209,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 ...
|
||||
}
|
||||
@ -1246,10 +1303,12 @@ void odf_drawing_context::set_path(std::wstring path_string)
|
||||
//boost::replace_all(path_string, L",,", L" 0 ");
|
||||
//boost::replace_all(path_string, L" -", L"-");
|
||||
//boost::replace_all(path_string, L",", L"0"); // нужен разбор
|
||||
//impl_->current_drawing_state_.path_ = path_string;
|
||||
impl_->current_drawing_state_.path_ = path_string;
|
||||
}
|
||||
void odf_drawing_context::add_path_element(std::wstring command, const std::wstring & strE)
|
||||
void odf_drawing_context::add_path_element(std::wstring command, std::wstring strE)
|
||||
{
|
||||
XmlUtils::replace_all(strE, L"gd", L"?f");
|
||||
|
||||
if (command != impl_->current_drawing_state_.path_last_command_)
|
||||
{
|
||||
impl_->current_drawing_state_.path_ += command;
|
||||
@ -1258,19 +1317,179 @@ void odf_drawing_context::add_path_element(std::wstring command, const std::wstr
|
||||
|
||||
impl_->current_drawing_state_.path_last_command_ = command;
|
||||
}
|
||||
if (command != L"N")
|
||||
impl_->current_drawing_state_.path_ += strE + L" ";
|
||||
else
|
||||
impl_->current_drawing_state_.path_ += strE;
|
||||
|
||||
impl_->current_drawing_state_.path_ += strE + L" ";
|
||||
|
||||
if (command == L"N")
|
||||
impl_->current_drawing_state_.path_last_command_.clear();
|
||||
}
|
||||
void odf_drawing_context::add_modifier(std::wstring modifier)
|
||||
void odf_drawing_context::add_modifier (std::wstring modifier)
|
||||
{
|
||||
if (!impl_->current_drawing_state_.oox_shape_) return;
|
||||
|
||||
boost::algorithm::to_lower(modifier);
|
||||
int res = modifier.find(L"val ");
|
||||
if (res >=0) modifier = modifier.substr(4);
|
||||
impl_->current_drawing_state_.modifiers_ += modifier + L" ";
|
||||
|
||||
impl_->current_drawing_state_.oox_shape_->modifiers += modifier + L" ";
|
||||
}
|
||||
void odf_drawing_context::set_viewBox(double W, double H)
|
||||
int GetFormulaType2(const WCHAR& c1, const WCHAR& c2)
|
||||
{
|
||||
switch (c1)
|
||||
{
|
||||
case (WCHAR)'*': return 0;
|
||||
case (WCHAR)'+': return ((WCHAR)'-' == c2) ? 1 : 2;
|
||||
case (WCHAR)'?': return 3;
|
||||
case (WCHAR)'a': return ((WCHAR)'b' == c2) ? 4 : 5;
|
||||
case (WCHAR)'c': return ((WCHAR)'a' == c2) ? 6 : 7;
|
||||
case (WCHAR)'m': return ((WCHAR)'a' == c2) ? 8 : (((WCHAR)'i' == c2) ? 16 : 9);
|
||||
case (WCHAR)'p': return 10;
|
||||
case (WCHAR)'s': return ((WCHAR)'a' == c2) ? 11 : (((WCHAR)'i' == c2) ? 12 : 13);
|
||||
case (WCHAR)'t': return 14;
|
||||
case (WCHAR)'v': return 15;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void odf_drawing_context::set_textarea (std::wstring l, std::wstring t, std::wstring r, std::wstring b)
|
||||
{
|
||||
if (!impl_->current_drawing_state_.oox_shape_) return;
|
||||
|
||||
impl_->current_drawing_state_.oox_shape_->text_areas = l + L" " + t + L" " + r + L" " + b;
|
||||
|
||||
XmlUtils::replace_all(impl_->current_drawing_state_.oox_shape_->text_areas, L"gd", L"?f");
|
||||
}
|
||||
void odf_drawing_context::add_handle (std::wstring x, std::wstring y, std::wstring refX, std::wstring refY,
|
||||
std::wstring minX, std::wstring maxX, std::wstring minY, std::wstring maxY)
|
||||
{
|
||||
if (!impl_->current_drawing_state_.oox_shape_) return;
|
||||
|
||||
oox_shape::_handle h;
|
||||
|
||||
XmlUtils::replace_all(x, L"gd", L"?f");
|
||||
XmlUtils::replace_all(y, L"gd", L"?f");
|
||||
|
||||
h.position = x + L" " + y;
|
||||
|
||||
if (!maxX.empty()) h.x_maximum= maxX;
|
||||
if (!minX.empty()) h.x_minimum= minX;
|
||||
|
||||
if (!maxY.empty()) h.y_maximum= maxY;
|
||||
if (!minY.empty()) h.y_minimum= minY;
|
||||
|
||||
impl_->current_drawing_state_.oox_shape_->handles.push_back(h);
|
||||
}
|
||||
|
||||
void odf_drawing_context::add_formula (std::wstring name, std::wstring fmla)
|
||||
{
|
||||
if (!impl_->current_drawing_state_.oox_shape_) return;
|
||||
|
||||
size_t nStart = 0;
|
||||
size_t nCurrent = 0;
|
||||
|
||||
const wchar_t* pData = fmla.c_str();
|
||||
|
||||
int nFound = 0, x = 0, y = 0;
|
||||
|
||||
std::wstring val[4];
|
||||
|
||||
while (nCurrent < fmla.length())
|
||||
{
|
||||
if (pData[nCurrent] == (WCHAR)' ')
|
||||
{
|
||||
if (nStart < nCurrent)
|
||||
{
|
||||
if (0 == nFound)
|
||||
{
|
||||
if ((nCurrent - nStart) > 1)
|
||||
{
|
||||
x = GetFormulaType2(pData[nStart], pData[nStart + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
val[nFound-1] = std::wstring( pData + nStart, (ULONG)(nCurrent - nStart));
|
||||
}
|
||||
nStart = nCurrent + 1;
|
||||
++nFound;
|
||||
}
|
||||
}
|
||||
++nCurrent;
|
||||
}
|
||||
if (nStart < nCurrent)
|
||||
{
|
||||
if (0 == nFound)
|
||||
{
|
||||
if ((nCurrent - nStart) > 1)
|
||||
{
|
||||
y = GetFormulaType2(pData[nStart], pData[nStart + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
y = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
val[nFound-1] = std::wstring( pData + nStart, (ULONG)(nCurrent - nStart));
|
||||
}
|
||||
}
|
||||
std::wstring odf_fmla = L"";
|
||||
|
||||
switch(x)
|
||||
{
|
||||
case 0:
|
||||
odf_fmla = val[0] + L"*" + val[1] + L"/" + val[2];
|
||||
break;
|
||||
case 1:
|
||||
odf_fmla = val[0] + L"+" + val[1] + L"-" + val[2];
|
||||
break;
|
||||
case 2:
|
||||
odf_fmla = val[0] + L"+" + val[1];
|
||||
break;
|
||||
case 3:
|
||||
odf_fmla = L"if(";
|
||||
for (int i = 0; i < nFound - 1; i++)
|
||||
{
|
||||
odf_fmla += val[i] + L",";
|
||||
}
|
||||
odf_fmla += val[nFound-1] + L")"; break;
|
||||
case 4:
|
||||
odf_fmla = L"abs(" + val[0] + L")";
|
||||
break;
|
||||
case 7:
|
||||
odf_fmla = val[0] + L"*cos(pi*(" + val[1] + L")/10800000)";
|
||||
break;
|
||||
case 12:
|
||||
odf_fmla = val[0] + L"*sin(pi*(" + val[1] + L")/10800000)";
|
||||
break;
|
||||
case 13:
|
||||
odf_fmla = L"sqrt(" + val[0] + L")";
|
||||
break;
|
||||
case 15:
|
||||
odf_fmla = val[0];
|
||||
break;
|
||||
default:
|
||||
odf_fmla = fmla;
|
||||
break;
|
||||
}
|
||||
|
||||
//XmlUtils::replace_all(odf_fmla, L"gd", L"?f");
|
||||
XmlUtils::replace_all(odf_fmla, L"h", L"logheight");
|
||||
XmlUtils::replace_all(odf_fmla, L"w", L"logwidth");
|
||||
XmlUtils::replace_all(odf_fmla, L"adj", L"$");
|
||||
//XmlUtils::replace_all(name, L"gd", L"f");
|
||||
|
||||
impl_->current_drawing_state_.oox_shape_->add(name, odf_fmla);
|
||||
}
|
||||
|
||||
void odf_drawing_context::set_viewBox (double W, double H)
|
||||
{
|
||||
if (W < 0.01)
|
||||
{
|
||||
@ -1282,11 +1501,19 @@ void odf_drawing_context::set_viewBox(double W, double H)
|
||||
if (impl_->current_drawing_state_.svg_height_)
|
||||
H = impl_->current_drawing_state_.svg_height_->get_value_unit(length::emu);
|
||||
}
|
||||
impl_->current_drawing_state_.view_box_ = std::wstring(L"0 0 ") + boost::lexical_cast<std::wstring>((int)W) + L" " + boost::lexical_cast<std::wstring>((int)H);
|
||||
impl_->current_drawing_state_.view_box_ = std::wstring(L"0 0 ") + std::to_wstring((int)W) + L" " + std::to_wstring((int)H);
|
||||
|
||||
if (impl_->current_drawing_state_.oox_shape_)
|
||||
{
|
||||
if (impl_->current_drawing_state_.oox_shape_->sub_view_size)
|
||||
impl_->current_drawing_state_.oox_shape_->sub_view_size = *impl_->current_drawing_state_.oox_shape_->sub_view_size + L" " + std::to_wstring((int)W) + L" " + std::to_wstring((int)H);
|
||||
else
|
||||
impl_->current_drawing_state_.oox_shape_->sub_view_size = std::to_wstring((int)W) + L" " + std::to_wstring((int)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;
|
||||
@ -1298,7 +1525,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;
|
||||
@ -1313,7 +1540,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" не задано
|
||||
@ -1520,8 +1747,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)
|
||||
@ -1542,7 +1769,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)
|
||||
{
|
||||
@ -1567,7 +1794,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)
|
||||
@ -1594,14 +1821,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);
|
||||
|
||||
@ -1609,13 +1836,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);
|
||||
|
||||
@ -1641,14 +1868,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);
|
||||
}
|
||||
@ -1658,7 +1885,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--)
|
||||
{
|
||||
@ -1666,7 +1893,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);
|
||||
}
|
||||
@ -1687,7 +1914,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)
|
||||
{
|
||||
@ -1929,7 +2156,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());
|
||||
@ -1968,10 +2195,37 @@ void odf_drawing_context::set_textarea_writing_mode(int mode)
|
||||
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;
|
||||
@ -2000,7 +2254,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();
|
||||
|
||||
@ -2047,7 +2301,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();
|
||||
|
||||
@ -2092,7 +2346,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)
|
||||
@ -2218,7 +2472,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++)
|
||||
{
|
||||
@ -2237,7 +2491,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();
|
||||
@ -2747,7 +3001,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;
|
||||
|
||||
@ -2843,7 +3097,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;
|
||||
|
||||
|
||||
@ -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,21 +126,24 @@ 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);
|
||||
void end_object();
|
||||
|
||||
bool isLineShape();
|
||||
void corrected_line_fill();
|
||||
|
||||
office_element_ptr & get_root_element();
|
||||
@ -149,8 +154,12 @@ public:
|
||||
bool is_exist_content();
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
void set_path (std::wstring path_string);
|
||||
void add_path_element (std::wstring command, const std::wstring & elm);
|
||||
void add_path_element (std::wstring command, std::wstring elm);
|
||||
void add_modifier (std::wstring modifier);
|
||||
void add_formula (std::wstring name, std::wstring fmla);
|
||||
void set_textarea (std::wstring l, std::wstring t, std::wstring r, std::wstring b);
|
||||
void add_handle (std::wstring x, std::wstring y, std::wstring refX, std::wstring refY,
|
||||
std::wstring minX, std::wstring maxX, std::wstring minY, std::wstring maxY);
|
||||
|
||||
void set_viewBox (double W, double H);
|
||||
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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_;
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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,13 +147,41 @@ 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;
|
||||
create_element(L"office", L"annotation", comm_elm, this);
|
||||
|
||||
current_slide().comment_context()->start_comment(comm_elm, oox_comm_id);
|
||||
|
||||
current_slide().drawing_context()->start_drawing();
|
||||
current_slide().drawing_context()->start_element(comm_elm);
|
||||
}
|
||||
void odp_conversion_context::start_comment_content()
|
||||
{
|
||||
current_slide().comment_context()->start_comment_content();
|
||||
|
||||
office_element_ptr & root_comm_element = current_slide().drawing_context()->get_current_element();
|
||||
start_text_context();
|
||||
|
||||
text_context()->start_element(root_comm_element);
|
||||
text_context()->start_paragraph();
|
||||
}
|
||||
void odp_conversion_context::end_comment_content()
|
||||
{
|
||||
text_context()->end_paragraph();
|
||||
|
||||
current_slide().comment_context()->end_comment_content();
|
||||
|
||||
text_context()->end_element();
|
||||
end_text_context();
|
||||
}
|
||||
void odp_conversion_context::end_comment()
|
||||
{
|
||||
current_slide().drawing_context()->end_element();
|
||||
current_slide().drawing_context()->end_drawing();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,14 +64,18 @@ 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_;}
|
||||
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 ();
|
||||
void end_comment_content ();
|
||||
|
||||
private:
|
||||
odp_slide_context slide_context_;
|
||||
|
||||
@ -58,7 +58,7 @@ namespace odf_writer {
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
odp_page_state::odp_page_state(odf_conversion_context * Context, office_element_ptr & elm)
|
||||
: context_(Context), drawing_context_(Context)
|
||||
: context_(Context), drawing_context_(Context), comment_context_(Context)
|
||||
{
|
||||
page_elm_ = elm;
|
||||
|
||||
|
||||
@ -40,11 +40,11 @@
|
||||
#include"../../../Common/DocxFormat/Source/XML/Utils.h"
|
||||
|
||||
#include "odf_drawing_context.h"
|
||||
#include "odf_comment_context.h"
|
||||
|
||||
#include "office_elements_create.h"
|
||||
|
||||
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
namespace odf_types
|
||||
@ -57,7 +57,6 @@ namespace odf_writer {
|
||||
class odp_conversion_context;
|
||||
class odf_text_context;
|
||||
|
||||
//class table_table;
|
||||
class style;
|
||||
|
||||
|
||||
@ -85,6 +84,7 @@ public:
|
||||
|
||||
///////////////////////////////
|
||||
odf_drawing_context * drawing_context(){return &drawing_context_;}
|
||||
odf_comment_context * comment_context(){return &comment_context_;}
|
||||
|
||||
std::wstring office_page_name_;
|
||||
office_element_ptr page_elm_;
|
||||
@ -94,6 +94,7 @@ private:
|
||||
odf_conversion_context * context_;
|
||||
|
||||
odf_drawing_context drawing_context_;
|
||||
odf_comment_context comment_context_;
|
||||
|
||||
friend class odp_slide_context;
|
||||
|
||||
|
||||
@ -58,7 +58,6 @@ public:
|
||||
|
||||
odp_page_state & state();
|
||||
|
||||
odf_comment_context * comment_context();
|
||||
odf_table_context * table_context();
|
||||
|
||||
void start_table ();
|
||||
|
||||
@ -238,11 +238,11 @@ void ods_conversion_context::end_row()
|
||||
//////////////////////
|
||||
void ods_conversion_context::start_comment(int col, int row, std::wstring & author)
|
||||
{
|
||||
current_table().start_comment(col,row,author);
|
||||
current_table().start_comment(col, row, author);
|
||||
start_text_context();
|
||||
////////////////
|
||||
office_element_ptr paragr_elm;
|
||||
create_element(L"text", L"p",paragr_elm,this);
|
||||
create_element(L"text", L"p", paragr_elm, this);
|
||||
|
||||
current_text_context_->start_paragraph(paragr_elm);
|
||||
}
|
||||
@ -309,7 +309,7 @@ void ods_conversion_context::add_merge_cells(const std::wstring & ref)
|
||||
|
||||
void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
|
||||
{
|
||||
int col=0, row=0;
|
||||
int col = 0, row = 0;
|
||||
utils::parsing_ref ( ref, col,row);
|
||||
|
||||
if (col > current_table().current_column()+1)
|
||||
@ -389,11 +389,31 @@ void ods_conversion_context::start_rows()
|
||||
void ods_conversion_context::end_rows()
|
||||
{
|
||||
//add default last row
|
||||
int repeat = (std::max)(current_table().dimension_row,64) - current_table().current_row();
|
||||
if (repeat < 0) repeat = 1;
|
||||
int repeated = (std::max)(current_table().dimension_row, 64) - current_table().current_row();
|
||||
if (repeated < 0) repeated = 1;
|
||||
|
||||
start_row(current_table().current_row()+1,repeat,0,true);
|
||||
end_row();
|
||||
while(true)
|
||||
{
|
||||
//делим на 3 - до, с комметом, после;
|
||||
int comment_idx = current_table().is_row_comment(current_table().current_row() + 1, repeated);
|
||||
|
||||
if (comment_idx < 0) break;
|
||||
int rows = current_table().comments_[comment_idx].row - current_table().current_row() - 1;
|
||||
|
||||
start_row(current_table().current_row() + 1, rows, 0, true);
|
||||
end_row();
|
||||
|
||||
start_row(current_table().current_row() + 1, 1, 0, true);
|
||||
end_row();
|
||||
|
||||
repeated -= (1 + rows);
|
||||
}
|
||||
|
||||
if (repeated > 0)
|
||||
{
|
||||
start_row(current_table().current_row() + 1, repeated, 0, true);
|
||||
end_row();
|
||||
}
|
||||
}
|
||||
|
||||
void ods_conversion_context::add_column(int start_column, int repeated, int level, bool _default)
|
||||
@ -507,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.;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -136,8 +136,8 @@ ods_table_state::ods_table_state(odf_conversion_context * Context, office_elemen
|
||||
{
|
||||
office_table_ = elm;
|
||||
|
||||
current_table_row_ =0;
|
||||
current_table_column_ =0;
|
||||
current_table_row_ = 0;
|
||||
current_table_column_ = 0;
|
||||
|
||||
current_level_.push_back(office_table_);
|
||||
|
||||
@ -395,7 +395,7 @@ bool ods_table_state::is_cell_hyperlink()
|
||||
bool ods_table_state::is_cell_comment()
|
||||
{
|
||||
if (cells_size_ <1)return false;
|
||||
return cells_.back().comment_idx >=0 ? true : false;
|
||||
return cells_.back().comment_idx >= 0 ? true : false;
|
||||
}
|
||||
|
||||
int ods_table_state::is_cell_hyperlink(int col, int row)
|
||||
@ -413,7 +413,18 @@ int ods_table_state::is_cell_comment(int col, int row, short repeate_col)
|
||||
{
|
||||
for (size_t i = 0; i < comments_.size(); i++)
|
||||
{
|
||||
if ((comments_[i].col < col+repeate_col && comments_[i].col >= col) && comments_[i].row == row)
|
||||
if ((comments_[i].col < col + repeate_col && comments_[i].col >= col) && comments_[i].row == row)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
int ods_table_state::is_row_comment(int row, int repeate_row)
|
||||
{
|
||||
for (size_t i = 0; i < comments_.size(); i++)
|
||||
{
|
||||
if (comments_[i].row < row + repeate_row && comments_[i].row >= row)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
@ -489,10 +500,10 @@ void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr &
|
||||
|
||||
state.empty = true;
|
||||
state.elm = elm; state.repeated = 1; state.style_name = style_name; state.style_elm = style_elm;
|
||||
state.row=current_table_row_; state.col =current_table_column_+1;
|
||||
state.row = current_table_row_; state.col =current_table_column_ + 1;
|
||||
|
||||
state.hyperlink_idx = is_cell_hyperlink(state.col, state.row);
|
||||
state.comment_idx = is_cell_comment(state.col, state.row);
|
||||
state.comment_idx = is_cell_comment(state.col, state.row);
|
||||
|
||||
current_table_column_ += state.repeated;
|
||||
cells_.push_back(state);
|
||||
@ -1016,8 +1027,8 @@ void ods_table_state::end_cell()
|
||||
|
||||
void ods_table_state::add_default_cell( short repeated)
|
||||
{
|
||||
int comment_idx = is_cell_comment(current_table_column_+1 , current_table_row_, repeated);
|
||||
if (comment_idx >=0 && repeated >1)
|
||||
int comment_idx = is_cell_comment(current_table_column_ + 1 , current_table_row_, repeated);
|
||||
if (comment_idx >= 0 && repeated > 1)
|
||||
{
|
||||
//делим на 3 - до, с комметом, после;
|
||||
int c = current_table_column_;
|
||||
|
||||
@ -300,6 +300,7 @@ public:
|
||||
int is_cell_hyperlink (int col, int row);
|
||||
bool is_cell_comment ();
|
||||
int is_cell_comment (int col, int row, short repeate_col = 1);
|
||||
int is_row_comment (int row, int repeate_row = 1);
|
||||
|
||||
ods_hyperlink_state & current_hyperlink();
|
||||
|
||||
@ -316,7 +317,8 @@ public:
|
||||
|
||||
odf_drawing_context * drawing_context(){return &drawing_context_;}
|
||||
|
||||
std::wstring office_table_name_;
|
||||
std::wstring office_table_name_;
|
||||
std::vector<ods_comment_state> comments_;
|
||||
private:
|
||||
|
||||
odf_conversion_context * context_;
|
||||
@ -342,9 +344,7 @@ private:
|
||||
std::list<ods_cell_state> cells_;
|
||||
long cells_size_;
|
||||
|
||||
std::vector<ods_hyperlink_state> hyperlinks_;
|
||||
std::vector<ods_comment_state> comments_;
|
||||
|
||||
std::vector<ods_hyperlink_state> hyperlinks_;
|
||||
std::vector<ods_shared_formula_state> shared_formulas_;
|
||||
|
||||
odf_drawing_context drawing_context_;
|
||||
|
||||
@ -915,14 +915,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)
|
||||
{
|
||||
|
||||
@ -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 ();
|
||||
|
||||
@ -50,6 +50,12 @@
|
||||
namespace cpdoccore
|
||||
{
|
||||
|
||||
oox_shape::oox_shape()
|
||||
{
|
||||
odf_type_name = L"ooxml-non-primitive";
|
||||
view_box = L"0 0 0 0";
|
||||
}
|
||||
|
||||
oox_shape_ptr oox_shape::create(int ooxPrstGeomType)
|
||||
{
|
||||
switch (ooxPrstGeomType)
|
||||
@ -127,7 +133,7 @@ oox_shape_ptr oox_shape::create(int ooxPrstGeomType)
|
||||
|
||||
default:
|
||||
if (ooxPrstGeomType > 2000) return boost::make_shared<oox_shape_textPlain>();
|
||||
else return boost::make_shared<oox_shape>();
|
||||
else return oox_shape_ptr();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,6 +48,8 @@ namespace cpdoccore
|
||||
public:
|
||||
static oox_shape_ptr create(int ooxPrstGeomType);
|
||||
|
||||
oox_shape();
|
||||
|
||||
struct _equation
|
||||
{
|
||||
std::wstring name;
|
||||
@ -66,20 +68,20 @@ namespace cpdoccore
|
||||
|
||||
void add(std::wstring name,std::wstring frmla)
|
||||
{
|
||||
_equation q = {name,frmla};
|
||||
_equation q = {name, frmla};
|
||||
equations.push_back(q);
|
||||
}
|
||||
|
||||
std::vector<_equation> equations;
|
||||
std::vector<_handle> handles;
|
||||
std::vector<_equation> equations;
|
||||
std::vector<_handle> handles;
|
||||
|
||||
std::wstring enhanced_path;
|
||||
std::wstring modifiers;
|
||||
std::wstring text_areas;
|
||||
std::wstring view_box;
|
||||
std::wstring enhanced_path;
|
||||
std::wstring modifiers;
|
||||
std::wstring text_areas;
|
||||
std::wstring view_box;
|
||||
_CP_OPT(std::wstring) sub_view_size;
|
||||
_CP_OPT(std::wstring) glue_points;
|
||||
|
||||
std::wstring odf_type_name;
|
||||
|
||||
_CP_OPT(std::wstring) glue_points;
|
||||
std::wstring odf_type_name;
|
||||
};
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@ -181,6 +181,14 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown)
|
||||
{
|
||||
convert(dynamic_cast<PPTX::Logic::CustGeom*>(oox_unknown));
|
||||
}break;
|
||||
case OOX::et_a_ahXY:
|
||||
{
|
||||
convert(dynamic_cast<PPTX::Logic::AhXY*>(oox_unknown));
|
||||
}break;
|
||||
case OOX::et_a_ahPolar:
|
||||
{
|
||||
convert(dynamic_cast<PPTX::Logic::AhPolar*>(oox_unknown));
|
||||
}break;
|
||||
case OOX::et_a_lnTo:
|
||||
{
|
||||
convert(dynamic_cast<PPTX::Logic::LineTo*>(oox_unknown));
|
||||
|
||||
@ -263,6 +263,7 @@ namespace PPTX
|
||||
class Theme;
|
||||
namespace Logic
|
||||
{
|
||||
class Bullet;
|
||||
class ClrMap;
|
||||
class SpTreeElem;
|
||||
class GraphicFrame;
|
||||
@ -322,6 +323,8 @@ namespace PPTX
|
||||
class InnerShdw;
|
||||
class OuterShdw;
|
||||
class PrstShdw;
|
||||
class AhXY;
|
||||
class AhPolar;
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,6 +365,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................................................................................................................................
|
||||
@ -390,6 +394,7 @@ public:
|
||||
void convert(PPTX::Logic::PathBase *oox_path);
|
||||
void convert(PPTX::Logic::BodyPr *oox_bodyPr);
|
||||
void convert(PPTX::Logic::UniFill *oox_fill, DWORD ARGB = 0);
|
||||
void convert(PPTX::Logic::UniColor *color, DWORD & nARGB);
|
||||
void convert(PPTX::Logic::UniColor *color, std::wstring & hexString, _CP_OPT(double) & opacity, DWORD ARGB = 0);
|
||||
void convert(PPTX::Logic::NvSpPr *oox_nvSpPr);
|
||||
void convert(PPTX::Logic::CNvPr *oox_cnvPr);
|
||||
@ -399,10 +404,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);
|
||||
@ -417,6 +428,8 @@ public:
|
||||
void convert(PPTX::Logic::QuadBezTo *oox_geom_path);
|
||||
void convert(PPTX::Logic::CubicBezTo *oox_geom_path);
|
||||
void convert(PPTX::Logic::Close *oox_geom_path);
|
||||
void convert(PPTX::Logic::AhXY *oox_handle);
|
||||
void convert(PPTX::Logic::AhPolar *oox_handle);
|
||||
void convert(PPTX::Logic::EffectStyle *oox_effect);
|
||||
void convert(PPTX::Logic::EffectLst *oox_effect_list);
|
||||
void convert(PPTX::Logic::InnerShdw *oox_effect);
|
||||
|
||||
@ -3017,7 +3017,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(false, oox_num_style->m_oAbstractNumId->GetValue());
|
||||
//// Childs
|
||||
//std::vector<OOX::Numbering::CLvl > m_arrLvl;
|
||||
//nullable<ComplexTypes::Word::CMultiLevelType > m_oMultiLevelType;
|
||||
@ -3049,7 +3049,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 +3101,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 +3114,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 +3184,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)
|
||||
{
|
||||
@ -3392,7 +3394,7 @@ void DocxConverter::convert(OOX::Logic::CCommentRangeStart* oox_comm_start)
|
||||
|
||||
bool added = odt_context->start_comment(oox_comm_id);
|
||||
|
||||
if (added==false)
|
||||
if (added == false)
|
||||
{
|
||||
convert_comment(oox_comm_id);
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Folder.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Presentation.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Slide.h"
|
||||
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Table/Table.h"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
@ -218,21 +219,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()); //стили дефалтовых списков
|
||||
|
||||
@ -259,6 +259,8 @@ void PptxConverter::convert_styles()
|
||||
odp_context->page_layout_context()->create_layer_sets();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PptxConverter::convert_settings()
|
||||
{
|
||||
|
||||
@ -294,24 +296,38 @@ void PptxConverter::convert_slides()
|
||||
{
|
||||
continue;// странное ... слайд 38 в FY10_September_Partner_Call.pptx
|
||||
}
|
||||
|
||||
current_theme = slide->theme.operator->();
|
||||
current_clrMap = NULL;
|
||||
|
||||
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_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
|
||||
@ -319,18 +335,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, false);
|
||||
}
|
||||
|
||||
current_slide = slide->Master.operator->();
|
||||
|
||||
if (bShowLayoutMasterSp && bShowMasterSp)
|
||||
convert_slide(&slide->Master->cSld, current_txStyles, false);
|
||||
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, true);
|
||||
|
||||
convert_slide(&slide->Layout->cSld, current_txStyles, true);
|
||||
//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
|
||||
{
|
||||
@ -365,23 +386,22 @@ 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(), true);
|
||||
convert_slide (slide->cSld.GetPointer(), current_txStyles);
|
||||
convert (slide->comments.operator->());
|
||||
convert (slide->Note.operator->());
|
||||
|
||||
convert (slide->timing.GetPointer(), slide->transition.GetPointer());
|
||||
|
||||
|
||||
//nullable<Logic::Transition> transition;
|
||||
//nullable<Logic::Timing> timing;
|
||||
|
||||
//smart_ptr<NotesSlide> Note;
|
||||
|
||||
//smart_ptr<PPTX::Comments> comments;
|
||||
|
||||
odp_context->end_slide();
|
||||
}
|
||||
}
|
||||
void PptxConverter::convert(PPTX::NotesSlide *oox_note)
|
||||
{
|
||||
if (!oox_note) return;
|
||||
}
|
||||
|
||||
void PptxConverter::convert(OOX::WritingElement *oox_unknown)
|
||||
{
|
||||
if (oox_unknown == NULL)return;
|
||||
@ -394,7 +414,51 @@ void PptxConverter::convert(OOX::WritingElement *oox_unknown)
|
||||
}break;
|
||||
}
|
||||
}
|
||||
void PptxConverter::convert(PPTX::Comments *oox_comments)
|
||||
{
|
||||
if (!oox_comments) return;
|
||||
|
||||
for (size_t i = 0; i < oox_comments->m_arComments.size(); i++)
|
||||
{
|
||||
PPTX::Logic::Comment & oox_comment = oox_comments->m_arComments[i];
|
||||
|
||||
odp_context->start_comment(oox_comment.idx.get_value_or(-1));
|
||||
odp_context->start_comment_content();
|
||||
|
||||
if (oox_comment.pos_x.IsInit() && oox_comment.pos_y.IsInit())
|
||||
odp_context->comment_context()->set_position (*oox_comment.pos_x / 10., *oox_comment.pos_y / 10.); //pt
|
||||
|
||||
if (oox_comment.authorId.IsInit() && presentation->commentAuthors.IsInit())
|
||||
{
|
||||
for (size_t a = 0; a < presentation->commentAuthors->m_arAuthors.size(); a++)
|
||||
{
|
||||
PPTX::Logic::CommentAuthor & autor = presentation->commentAuthors->m_arAuthors[a];
|
||||
|
||||
if (autor.id.IsInit() && autor.id.get() == oox_comment.authorId.get())
|
||||
{
|
||||
odp_context->comment_context()->set_author(autor.name.get_value_or(L""));
|
||||
odp_context->comment_context()->set_initials(autor.initials.get_value_or(L""));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (oox_comment.dt.IsInit()) odp_context->comment_context()->set_date(*oox_comment.dt);
|
||||
if (oox_comment.text.IsInit()) odp_context->text_context()->add_text_content(*oox_comment.text);
|
||||
|
||||
odp_context->end_comment_content();
|
||||
odp_context->end_comment();
|
||||
}
|
||||
}
|
||||
void PptxConverter::convert(PPTX::Logic::Timing *oox_timing, PPTX::Logic::Transition *oox_transition)
|
||||
{
|
||||
if (!oox_timing) return;
|
||||
if (!oox_timing->tnLst.IsInit()) return;
|
||||
|
||||
for (size_t i = 0; i < oox_timing->tnLst->list.size(); i++)
|
||||
{
|
||||
//oox_timing->tnLst[0]
|
||||
}
|
||||
}
|
||||
void PptxConverter::convert(PPTX::Logic::TableProperties *oox_table_pr)
|
||||
{
|
||||
if (!oox_table_pr) return;
|
||||
@ -879,18 +943,19 @@ void PptxConverter::convert(PPTX::Logic::Bg *oox_background)
|
||||
odp_context->end_drawings();
|
||||
}
|
||||
|
||||
void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, bool bPlaceholders)
|
||||
void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxStyles* txStyles, bool bPlaceholders)
|
||||
{
|
||||
if (oox_slide == NULL) return;
|
||||
|
||||
if (current_theme && current_clrMap)
|
||||
current_theme->SetColorMap(*current_clrMap);
|
||||
|
||||
|
||||
if (oox_slide->attrName.IsInit())
|
||||
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++)
|
||||
{
|
||||
@ -899,20 +964,76 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, bool bPlaceholde
|
||||
|
||||
if (pShape.IsInit())
|
||||
{
|
||||
pShape->FillLevelUp();
|
||||
if (!bPlaceholders && pShape->nvSpPr.nvPr.ph.is_init())
|
||||
continue;
|
||||
if (pShape->nvSpPr.nvPr.ph.is_init())
|
||||
{
|
||||
pShape->FillLevelUp();
|
||||
|
||||
if (pShape->nvSpPr.nvPr.ph->type.IsInit())
|
||||
{
|
||||
int ph_type = pShape->nvSpPr.nvPr.ph->type->GetBYTECode();
|
||||
|
||||
PPTX::Logic::Shape update_shape;
|
||||
pShape->Merge(update_shape);
|
||||
if (!bMaster && (ph_type == 5 || ph_type == 6 || ph_type == 7 || ph_type == 12))
|
||||
continue;
|
||||
|
||||
OoxConverter::convert(&update_shape);
|
||||
odf_context()->drawing_context()->set_placeholder_type(ph_type);
|
||||
}
|
||||
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();
|
||||
|
||||
presentation->defaultTextStyle->Merge(update_shape.txBody->lstStyle);
|
||||
|
||||
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());
|
||||
}
|
||||
@ -940,7 +1061,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();
|
||||
|
||||
@ -47,7 +47,9 @@ namespace OOX
|
||||
namespace PPTX
|
||||
{
|
||||
class TableStyles;
|
||||
class NotesSlide;
|
||||
class Presentation;
|
||||
class Comments;
|
||||
class Folder;
|
||||
|
||||
namespace Logic
|
||||
@ -63,6 +65,7 @@ namespace PPTX
|
||||
class TableCell;
|
||||
class TableCellProperties;
|
||||
class TcBdr;
|
||||
class TxStyles;
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,10 +106,13 @@ namespace Oox2Odf
|
||||
|
||||
void convert(OOX::WritingElement *oox_unknown);
|
||||
|
||||
void convert_slide (PPTX::Logic::CSld *oox_slide, bool bPlaceholders = true);
|
||||
void convert_layout (PPTX::Logic::CSld *oox_slide);
|
||||
void convert_slide (PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxStyles* txStyles, bool bPlaceholders = true);
|
||||
void convert_layout (PPTX::Logic::CSld *oox_slide);
|
||||
void convert (PPTX::Comments *oox_comments);
|
||||
void convert (PPTX::NotesSlide *oox_note);
|
||||
|
||||
void convert(PPTX::Logic::Bg *oox_background);
|
||||
void convert(PPTX::Logic::Timing *oox_timing, PPTX::Logic::Transition *oox_transition);
|
||||
|
||||
void convert(PPTX::Logic::Table *oox_table);
|
||||
void convert(PPTX::Logic::TableRow *oox_table_row);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="windows-1251"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Version="8.00"
|
||||
Name="Oox2OdfConverter"
|
||||
ProjectGUID="{BEE01B53-244A-44E6-8947-ED9342D9247E}"
|
||||
RootNamespace="Oox2OdfConverter"
|
||||
|
||||
@ -44,7 +44,7 @@ namespace PPTX
|
||||
{
|
||||
public:
|
||||
PPTX_LOGIC_BASE(CommentAuthor)
|
||||
private:
|
||||
|
||||
nullable_int id;
|
||||
nullable_int last_idx;
|
||||
nullable_int clr_idx;
|
||||
@ -52,8 +52,6 @@ namespace PPTX
|
||||
nullable_string name;
|
||||
nullable_string initials;
|
||||
|
||||
public:
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
node.ReadAttributeBase(L"id", id);
|
||||
@ -138,10 +136,9 @@ namespace PPTX
|
||||
|
||||
class Authors : public WrapperFile
|
||||
{
|
||||
private:
|
||||
public:
|
||||
std::vector<PPTX::Logic::CommentAuthor> m_arAuthors;
|
||||
|
||||
public:
|
||||
Authors()
|
||||
{
|
||||
}
|
||||
@ -152,8 +149,6 @@ namespace PPTX
|
||||
virtual ~Authors()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void read(const OOX::CPath& filename, FileMap& map)
|
||||
{
|
||||
XmlUtils::CXmlNode oNode;
|
||||
@ -177,8 +172,6 @@ namespace PPTX
|
||||
{
|
||||
WrapperFile::write(filename, directory, content);
|
||||
}
|
||||
|
||||
public:
|
||||
virtual const OOX::FileType type() const
|
||||
{
|
||||
return OOX::Presentation::FileTypes::CommentAuthors;
|
||||
@ -191,8 +184,6 @@ namespace PPTX
|
||||
{
|
||||
return type().DefaultFileName();
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
pWriter->WriteRecordArray(0, 0, m_arAuthors);
|
||||
|
||||
@ -44,7 +44,7 @@ namespace PPTX
|
||||
{
|
||||
public:
|
||||
PPTX_LOGIC_BASE(Comment)
|
||||
private:
|
||||
|
||||
nullable_int authorId;
|
||||
nullable_int idx;
|
||||
nullable_string dt;
|
||||
@ -59,8 +59,6 @@ namespace PPTX
|
||||
|
||||
nullable_string additional_data; // teamlab editor information!!!
|
||||
|
||||
public:
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
node.ReadAttributeBase(L"authorId", authorId);
|
||||
@ -276,10 +274,9 @@ namespace PPTX
|
||||
|
||||
class Comments : public WrapperFile
|
||||
{
|
||||
private:
|
||||
public:
|
||||
std::vector<PPTX::Logic::Comment> m_arComments;
|
||||
|
||||
public:
|
||||
Comments()
|
||||
{
|
||||
}
|
||||
@ -291,7 +288,6 @@ namespace PPTX
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void read(const OOX::CPath& filename, FileMap& map)
|
||||
{
|
||||
XmlUtils::CXmlNode oNode;
|
||||
@ -315,7 +311,6 @@ namespace PPTX
|
||||
WrapperFile::write(filename, directory, content);
|
||||
}
|
||||
|
||||
public:
|
||||
virtual const OOX::FileType type() const
|
||||
{
|
||||
return OOX::Presentation::FileTypes::SlideComments;
|
||||
@ -328,8 +323,6 @@ namespace PPTX
|
||||
{
|
||||
return type().DefaultFileName();
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
pWriter->WriteRecordArray(0, 0, m_arComments);
|
||||
|
||||
@ -45,7 +45,6 @@ namespace PPTX
|
||||
{
|
||||
m_name = name_;
|
||||
m_pLevelUp = NULL;
|
||||
m_nMasterTextType = -1;
|
||||
}
|
||||
|
||||
Shape::~Shape()
|
||||
@ -55,21 +54,18 @@ namespace PPTX
|
||||
Shape::Shape(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
m_pLevelUp = NULL;
|
||||
m_nMasterTextType = -1;
|
||||
|
||||
fromXML(node);
|
||||
}
|
||||
Shape::Shape(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
m_pLevelUp = NULL;
|
||||
m_nMasterTextType = -1;
|
||||
|
||||
fromXML(oReader);
|
||||
}
|
||||
const Shape& Shape::operator =(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
m_pLevelUp = NULL;
|
||||
m_nMasterTextType = -1;
|
||||
|
||||
fromXML(node);
|
||||
return *this;
|
||||
@ -77,7 +73,6 @@ namespace PPTX
|
||||
const Shape& Shape::operator =(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
m_pLevelUp = NULL;
|
||||
m_nMasterTextType = -1;
|
||||
|
||||
fromXML(oReader);
|
||||
return *this;
|
||||
@ -442,7 +437,6 @@ namespace PPTX
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
|
||||
|
||||
void Shape::FillLevelUp()
|
||||
{
|
||||
if ((m_pLevelUp == NULL) && (nvSpPr.nvPr.ph.IsInit()))
|
||||
@ -457,57 +451,25 @@ 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)
|
||||
m_pLevelUp->Merge(shape, true);
|
||||
|
||||
shape.m_name = m_name;
|
||||
shape.m_nMasterTextType = m_nMasterTextType;
|
||||
|
||||
shape.nvSpPr = nvSpPr;
|
||||
shape.m_name = m_name;
|
||||
shape.nvSpPr = nvSpPr;
|
||||
spPr.Merge(shape.spPr);
|
||||
|
||||
if (parentFileIs<SlideMaster>() && (parentFileAs<SlideMaster>()).txStyles.IsInit())
|
||||
{
|
||||
TextListStyle * listMasterStyle = NULL;
|
||||
|
||||
std::wstring type = nvSpPr.nvPr.ph->type.get_value_or(_T("body"));
|
||||
if ((type == L"title") || (type == L"ctrTitle"))
|
||||
{
|
||||
m_nMasterTextType = 1;
|
||||
listMasterStyle = (parentFileAs<SlideMaster>()).txStyles->titleStyle.GetPointer();
|
||||
}
|
||||
else if ((type == L"body") || (type == L"subTitle") || (type == L"obj"))
|
||||
{
|
||||
m_nMasterTextType = 2;
|
||||
listMasterStyle = (parentFileAs<SlideMaster>()).txStyles->bodyStyle.GetPointer();
|
||||
}
|
||||
else if (type != L"")
|
||||
{
|
||||
m_nMasterTextType = 3;
|
||||
listMasterStyle = (parentFileAs<SlideMaster>()).txStyles->otherStyle.GetPointer();
|
||||
}
|
||||
|
||||
if (listMasterStyle)
|
||||
{
|
||||
if(!txBody.is_init())
|
||||
txBody = new TxBody();
|
||||
|
||||
TextListStyle *newListStyle = new TextListStyle();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
if(listMasterStyle->levels[i].is_init())
|
||||
listMasterStyle->levels[i]->Merge(newListStyle->levels[i]);
|
||||
if(txBody->lstStyle->levels[i].is_init())
|
||||
txBody->lstStyle->levels[i]->Merge(newListStyle->levels[i]);
|
||||
}
|
||||
txBody->lstStyle.reset(newListStyle);
|
||||
}
|
||||
}
|
||||
shape.m_nMasterTextType = m_nMasterTextType;
|
||||
|
||||
if (style.is_init())
|
||||
{
|
||||
shape.m_bIsFontRefInSlide = bIsSlidePlaceholder;
|
||||
|
||||
@ -303,6 +303,7 @@ namespace PPTX
|
||||
|
||||
void FillLevelUp();
|
||||
void Merge(Shape& shape, bool bIsSlidePlaceholder = false);
|
||||
bool IsListStyleEmpty();
|
||||
|
||||
void SetLevelUpElement( Shape* p){m_pLevelUp = p;};
|
||||
|
||||
@ -316,7 +317,6 @@ namespace PPTX
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
std::wstring m_name;
|
||||
Shape * m_pLevelUp;
|
||||
int m_nMasterTextType;
|
||||
bool m_bIsFontRefInSlide;
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
NvSpPr nvSpPr;
|
||||
|
||||
@ -36,8 +36,11 @@
|
||||
#include "../SlideMaster.h"
|
||||
|
||||
#include "../../ASCOfficeDrawingConverter.h"
|
||||
|
||||
#include "../../../XlsxSerializerCom/Reader/ChartFromToBinary.h"
|
||||
#include "../../../ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h"
|
||||
#include "../../../ASCOfficeDocxFile2/BinWriter/BinWriters.h"
|
||||
|
||||
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramData.h"
|
||||
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h"
|
||||
|
||||
@ -86,10 +89,10 @@ namespace PPTX
|
||||
}
|
||||
}
|
||||
|
||||
if (id_drawing.IsInit())
|
||||
if (id_drawing.IsInit() && pDiagramData)
|
||||
{
|
||||
if (parentFileIs<OOX::IFileContainer>()) oFileDrawing = parentFileAs<OOX::IFileContainer>().Find(*id_drawing);
|
||||
else if (pRels != NULL) oFileDrawing = pRels->Find(*id_data);
|
||||
else if (pRels != NULL) oFileDrawing = pRels->Find(*id_drawing);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -97,10 +100,7 @@ namespace PPTX
|
||||
//пробуем по тому же пути с номером data.xml - ниже
|
||||
}
|
||||
}
|
||||
if (oFileDrawing.IsInit())
|
||||
{
|
||||
pDiagramDrawing = dynamic_cast<OOX::CDiagramDrawing*>(oFileDrawing.operator->());
|
||||
}
|
||||
pDiagramDrawing = dynamic_cast<OOX::CDiagramDrawing*>(oFileDrawing.operator->());
|
||||
|
||||
if (!pDiagramDrawing && pDiagramData)
|
||||
{
|
||||
@ -122,7 +122,7 @@ namespace PPTX
|
||||
m_diag = pDiagramDrawing->m_oShapeTree;
|
||||
FillParentPointersForChilds();
|
||||
|
||||
m_pFileContainer = smart_ptr<OOX::IFileContainer>(pDiagramDrawing);
|
||||
m_pFileContainer = oFileDrawing.smart_dynamic_cast<OOX::IFileContainer>();
|
||||
|
||||
if (!m_diag->grpSpPr.xfrm.IsInit())
|
||||
m_diag->grpSpPr.xfrm = new PPTX::Logic::Xfrm;
|
||||
@ -132,7 +132,22 @@ namespace PPTX
|
||||
//parse pDiagramData !!
|
||||
}
|
||||
}
|
||||
|
||||
void SmartArt::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
if (m_diag.is_init())
|
||||
{
|
||||
smart_ptr<OOX::IFileContainer> old = *pWriter->m_pCurrentContainer;
|
||||
*pWriter->m_pCurrentContainer = m_pFileContainer;
|
||||
if (pWriter->m_pMainDocument)
|
||||
pWriter->m_pMainDocument->m_pParamsWriter->m_pCurRels = (OOX::IFileContainer*)m_pFileContainer.operator->();
|
||||
|
||||
m_diag->toPPTY(pWriter);
|
||||
|
||||
*pWriter->m_pCurrentContainer = old;
|
||||
if (pWriter->m_pMainDocument)
|
||||
pWriter->m_pMainDocument->m_pParamsWriter->m_pCurRels = old.operator->();
|
||||
}
|
||||
}
|
||||
void ChartRec::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
OOX::IFileContainer* pRels = NULL;
|
||||
|
||||
@ -93,19 +93,7 @@ namespace PPTX
|
||||
{
|
||||
}
|
||||
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
if (m_diag.is_init())
|
||||
{
|
||||
smart_ptr<OOX::IFileContainer> old = *pWriter->m_pCurrentContainer;
|
||||
*pWriter->m_pCurrentContainer = m_pFileContainer;
|
||||
|
||||
m_diag->toPPTY(pWriter);
|
||||
|
||||
*pWriter->m_pCurrentContainer = old;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
|
||||
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
|
||||
{
|
||||
pReader->SkipRecord();
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -47,7 +47,6 @@ namespace PPTX
|
||||
explicit TimeNodeBase(XmlUtils::CXmlNode& node);
|
||||
const TimeNodeBase& operator =(XmlUtils::CXmlNode& node);
|
||||
|
||||
public:
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node);
|
||||
virtual void GetTimeNodeFrom(XmlUtils::CXmlNode& element);
|
||||
virtual bool is_init()const{return (m_node.IsInit());};
|
||||
@ -61,7 +60,6 @@ namespace PPTX
|
||||
template<class T> AVSINLINE const T& as() const { return m_node.as<T>(); }
|
||||
|
||||
virtual std::wstring toXML() const;
|
||||
//public:
|
||||
private:
|
||||
smart_ptr<WrapperWritingElement> m_node;
|
||||
protected:
|
||||
|
||||
@ -46,7 +46,6 @@ namespace PPTX
|
||||
public:
|
||||
PPTX_LOGIC_BASE(Timing)
|
||||
|
||||
public:
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
tnLst = node.ReadNode(_T("p:tnLst"));
|
||||
@ -76,7 +75,6 @@ namespace PPTX
|
||||
pWriter->EndNode(_T("p:timing"));
|
||||
}
|
||||
|
||||
public:
|
||||
nullable<TnLst> tnLst;
|
||||
nullable<BldLst> bldLst;
|
||||
protected:
|
||||
|
||||
@ -55,8 +55,6 @@ namespace PPTX
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
name = XmlUtils::GetNameNoNS(node.GetName());
|
||||
@ -72,9 +70,8 @@ namespace PPTX
|
||||
|
||||
return XmlUtils::CreateNode(_T("p:") + name, oValue);
|
||||
}
|
||||
public:
|
||||
std::vector<TimeNodeBase> list;
|
||||
std::wstring name;
|
||||
std::wstring name;
|
||||
protected:
|
||||
virtual void FillParentPointersForChilds()
|
||||
{
|
||||
|
||||
@ -23,7 +23,7 @@ if "%platform%" == "win_64" (
|
||||
if exist "%SCRIPTPATH%%platform%\icu.zip" (
|
||||
echo "icu already downloaded"
|
||||
) else (
|
||||
Powershell.exe Invoke-WebRequest -OutFile %platform%\icu.zip "%URL%"
|
||||
Powershell.exe Invoke-WebRequest -OutFile %platform%\icu.zip -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox "%URL%"
|
||||
)
|
||||
|
||||
SET UNSIP_PROGRAMM="C:\Program Files\7-Zip\7z.exe"
|
||||
|
||||
427
DesktopEditor/common/BigInteger.h
Normal file
427
DesktopEditor/common/BigInteger.h
Normal 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_
|
||||
274
DesktopEditor/xmlsec/test/windows/main.cpp
Normal file
274
DesktopEditor/xmlsec/test/windows/main.cpp
Normal file
@ -0,0 +1,274 @@
|
||||
/**
|
||||
* XML Security Library example: Signing a file with a dynamicaly created template and an X509 certificate.
|
||||
*
|
||||
* Signs a file using a dynamicaly created template, key from PEM file and
|
||||
* an X509 certificate. The signature has one reference with one enveloped
|
||||
* transform to sign the whole document except the <dsig:Signature/> node
|
||||
* itself. The key certificate is written in the <dsig:X509Data/> node.
|
||||
*
|
||||
* This example was developed and tested with OpenSSL crypto library. The
|
||||
* certificates management policies for another crypto library may break it.
|
||||
*
|
||||
* Usage:
|
||||
* sign3 <xml-doc> <pem-key>
|
||||
*
|
||||
* Example:
|
||||
* ./sign3 sign3-doc.xml rsakey.pem rsacert.pem > sign3-res.xml
|
||||
*
|
||||
* The result signature could be validated using verify3 example:
|
||||
* ./verify3 sign3-res.xml ca2cert.pem cacert.pem
|
||||
*
|
||||
* This is free software; see Copyright file in the source
|
||||
* distribution for preciese wording.
|
||||
*
|
||||
* Copyright (C) 2002-2016 Aleksey Sanin <aleksey@aleksey.com>. All Rights Reserved.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#ifndef XMLSEC_NO_XSLT
|
||||
#include <libxslt/xslt.h>
|
||||
#include <libxslt/security.h>
|
||||
#endif /* XMLSEC_NO_XSLT */
|
||||
|
||||
#include <xmlsec/xmlsec.h>
|
||||
#include <xmlsec/xmltree.h>
|
||||
#include <xmlsec/xmldsig.h>
|
||||
#include <xmlsec/templates.h>
|
||||
#include <xmlsec/crypto.h>
|
||||
|
||||
int sign_file(const char* xml_file, const char* key_file, const char* cert_file);
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
#ifndef XMLSEC_NO_XSLT
|
||||
xsltSecurityPrefsPtr xsltSecPrefs = NULL;
|
||||
#endif /* XMLSEC_NO_XSLT */
|
||||
|
||||
assert(argv);
|
||||
|
||||
if(argc != 4) {
|
||||
fprintf(stderr, "Error: wrong number of arguments.\n");
|
||||
fprintf(stderr, "Usage: %s <xml-file> <key-file> <cert-file>\n", argv[0]);
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* Init libxml and libxslt libraries */
|
||||
xmlInitParser();
|
||||
//LIBXML_TEST_VERSION
|
||||
//xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
|
||||
xmlSubstituteEntitiesDefault(1);
|
||||
#ifndef XMLSEC_NO_XSLT
|
||||
xmlIndentTreeOutput = 1;
|
||||
#endif /* XMLSEC_NO_XSLT */
|
||||
|
||||
/* Init libxslt */
|
||||
#ifndef XMLSEC_NO_XSLT
|
||||
/* disable everything */
|
||||
xsltSecPrefs = xsltNewSecurityPrefs();
|
||||
xsltSetSecurityPrefs(xsltSecPrefs, XSLT_SECPREF_READ_FILE, xsltSecurityForbid);
|
||||
xsltSetSecurityPrefs(xsltSecPrefs, XSLT_SECPREF_WRITE_FILE, xsltSecurityForbid);
|
||||
xsltSetSecurityPrefs(xsltSecPrefs, XSLT_SECPREF_CREATE_DIRECTORY, xsltSecurityForbid);
|
||||
xsltSetSecurityPrefs(xsltSecPrefs, XSLT_SECPREF_READ_NETWORK, xsltSecurityForbid);
|
||||
xsltSetSecurityPrefs(xsltSecPrefs, XSLT_SECPREF_WRITE_NETWORK, xsltSecurityForbid);
|
||||
xsltSetDefaultSecurityPrefs(xsltSecPrefs);
|
||||
#endif /* XMLSEC_NO_XSLT */
|
||||
|
||||
/* Init xmlsec library */
|
||||
if(xmlSecInit() < 0) {
|
||||
fprintf(stderr, "Error: xmlsec initialization failed.\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Check loaded library version */
|
||||
if(xmlSecCheckVersion() != 1) {
|
||||
fprintf(stderr, "Error: loaded xmlsec library version is not compatible.\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Load default crypto engine if we are supporting dynamic
|
||||
* loading for xmlsec-crypto libraries. Use the crypto library
|
||||
* name ("openssl", "nss", etc.) to load corresponding
|
||||
* xmlsec-crypto library.
|
||||
*/
|
||||
#ifdef XMLSEC_CRYPTO_DYNAMIC_LOADING
|
||||
if(xmlSecCryptoDLLoadLibrary(NULL) < 0) {
|
||||
fprintf(stderr, "Error: unable to load default xmlsec-crypto library. Make sure\n"
|
||||
"that you have it installed and check shared libraries path\n"
|
||||
"(LD_LIBRARY_PATH) envornment variable.\n");
|
||||
return(-1);
|
||||
}
|
||||
#endif /* XMLSEC_CRYPTO_DYNAMIC_LOADING */
|
||||
|
||||
/* Init crypto library */
|
||||
if(xmlSecCryptoAppInit(NULL) < 0) {
|
||||
fprintf(stderr, "Error: crypto initialization failed.\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Init xmlsec-crypto library */
|
||||
if(xmlSecCryptoInit() < 0) {
|
||||
fprintf(stderr, "Error: xmlsec-crypto initialization failed.\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if(sign_file(argv[1], argv[2], argv[3]) < 0) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Shutdown xmlsec-crypto library */
|
||||
xmlSecCryptoShutdown();
|
||||
|
||||
/* Shutdown crypto library */
|
||||
xmlSecCryptoAppShutdown();
|
||||
|
||||
/* Shutdown xmlsec library */
|
||||
xmlSecShutdown();
|
||||
|
||||
/* Shutdown libxslt/libxml */
|
||||
#ifndef XMLSEC_NO_XSLT
|
||||
xsltFreeSecurityPrefs(xsltSecPrefs);
|
||||
xsltCleanupGlobals();
|
||||
#endif /* XMLSEC_NO_XSLT */
|
||||
xmlCleanupParser();
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* sign_file:
|
||||
* @xml_file: the XML file name.
|
||||
* @key_file: the PEM private key file name.
|
||||
* @cert_file: the x509 certificate PEM file.
|
||||
*
|
||||
* Signs the @xml_file using private key from @key_file and dynamicaly
|
||||
* created enveloped signature template. The certificate from @cert_file
|
||||
* is placed in the <dsig:X509Data/> node.
|
||||
*
|
||||
* Returns 0 on success or a negative value if an error occurs.
|
||||
*/
|
||||
int
|
||||
sign_file(const char* xml_file, const char* key_file, const char* cert_file) {
|
||||
xmlDocPtr doc = NULL;
|
||||
xmlNodePtr signNode = NULL;
|
||||
xmlNodePtr refNode = NULL;
|
||||
xmlNodePtr keyInfoNode = NULL;
|
||||
xmlNodePtr x509DataNode = NULL;
|
||||
xmlSecDSigCtxPtr dsigCtx = NULL;
|
||||
int res = -1;
|
||||
|
||||
assert(xml_file);
|
||||
assert(key_file);
|
||||
assert(cert_file);
|
||||
|
||||
/* load doc file */
|
||||
doc = xmlParseFile(xml_file);
|
||||
|
||||
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
|
||||
fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_file);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* create signature template for RSA-SHA1 enveloped signature */
|
||||
signNode = xmlSecTmplSignatureCreate(doc, xmlSecTransformExclC14NId,
|
||||
xmlSecTransformRsaSha1Id, NULL);
|
||||
if(signNode == NULL) {
|
||||
fprintf(stderr, "Error: failed to create signature template\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* add <dsig:Signature/> node to the doc */
|
||||
xmlAddChild(xmlDocGetRootElement(doc), signNode);
|
||||
|
||||
/* add reference */
|
||||
refNode = xmlSecTmplSignatureAddReference(signNode, xmlSecTransformSha1Id,
|
||||
NULL, NULL, NULL);
|
||||
if(refNode == NULL) {
|
||||
fprintf(stderr, "Error: failed to add reference to signature template\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* add enveloped transform */
|
||||
if(xmlSecTmplReferenceAddTransform(refNode, xmlSecTransformEnvelopedId) == NULL) {
|
||||
fprintf(stderr, "Error: failed to add enveloped transform to reference\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* add <dsig:KeyInfo/> and <dsig:X509Data/> */
|
||||
keyInfoNode = xmlSecTmplSignatureEnsureKeyInfo(signNode, NULL);
|
||||
if(keyInfoNode == NULL) {
|
||||
fprintf(stderr, "Error: failed to add key info\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
x509DataNode = xmlSecTmplKeyInfoAddX509Data(keyInfoNode);
|
||||
if(x509DataNode == NULL) {
|
||||
fprintf(stderr, "Error: failed to add X509Data node\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if(xmlSecTmplX509DataAddSubjectName(x509DataNode) == NULL) {
|
||||
fprintf(stderr, "Error: failed to add X509SubjectName node\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if(xmlSecTmplX509DataAddCertificate(x509DataNode) == NULL) {
|
||||
fprintf(stderr, "Error: failed to add X509Certificate node\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* create signature context, we don't need keys manager in this example */
|
||||
dsigCtx = xmlSecDSigCtxCreate(NULL);
|
||||
if(dsigCtx == NULL) {
|
||||
fprintf(stderr,"Error: failed to create signature context\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* load private key, assuming that there is not password */
|
||||
dsigCtx->signKey = xmlSecCryptoAppKeyLoad(key_file, xmlSecKeyDataFormatPem, NULL, NULL, NULL);
|
||||
if(dsigCtx->signKey == NULL) {
|
||||
fprintf(stderr,"Error: failed to load private pem key from \"%s\"\n", key_file);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* load certificate and add to the key */
|
||||
if(xmlSecCryptoAppKeyCertLoad(dsigCtx->signKey, cert_file, xmlSecKeyDataFormatPem) < 0) {
|
||||
fprintf(stderr,"Error: failed to load pem certificate \"%s\"\n", cert_file);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* set key name to the file name, this is just an example! */
|
||||
if(xmlSecKeySetName(dsigCtx->signKey, (const xmlChar*)key_file) < 0) {
|
||||
fprintf(stderr,"Error: failed to set key name for key from \"%s\"\n", key_file);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* sign the template */
|
||||
if(xmlSecDSigCtxSign(dsigCtx, signNode) < 0) {
|
||||
fprintf(stderr,"Error: signature failed\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* print signed document to stdout */
|
||||
xmlDocDump(stdout, doc);
|
||||
|
||||
/* success */
|
||||
res = 0;
|
||||
|
||||
done:
|
||||
/* cleanup */
|
||||
if(dsigCtx != NULL) {
|
||||
xmlSecDSigCtxDestroy(dsigCtx);
|
||||
}
|
||||
|
||||
if(doc != NULL) {
|
||||
xmlFreeDoc(doc);
|
||||
}
|
||||
return(res);
|
||||
}
|
||||
|
||||
45
DesktopEditor/xmlsec/test/windows/test.pro
Normal file
45
DesktopEditor/xmlsec/test/windows/test.pro
Normal file
@ -0,0 +1,45 @@
|
||||
QT -= core gui
|
||||
|
||||
TARGET = test
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
DEFINES += UNICODE
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
#DEFINES += XMLSEC_CRYPTO_DYNAMIC_LOADING
|
||||
DEFINES += XMLSEC_CRYPTO_MSCRYPTO
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$CORE_ROOT_DIR/DesktopEditor/xml/libxml2/include \
|
||||
$$CORE_ROOT_DIR/DesktopEditor/xml/libxml2/include/libxml \
|
||||
\
|
||||
$$CORE_ROOT_DIR/DesktopEditor/xmlsec/xmlsec/include
|
||||
|
||||
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
|
||||
|
||||
DEFINES += XMLSEC_NO_XSLT
|
||||
|
||||
DEFINES += XMLSEC_STATIC
|
||||
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -llibxmlsec
|
||||
|
||||
LIBS += -lcrypt32
|
||||
LIBS += -lcryptui
|
||||
LIBS += -lAdvapi32
|
||||
|
||||
SOURCES += main.cpp
|
||||
@ -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
|
||||
@ -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>
|
||||
@ -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 we’ll 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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")]
|
||||
@ -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>
|
||||
541
DesktopEditor/xmlsec/test/windows_list_serts/main.cpp
Normal file
541
DesktopEditor/xmlsec/test/windows_list_serts/main.cpp
Normal file
@ -0,0 +1,541 @@
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
#include <cryptuiapi.h>
|
||||
|
||||
#include <tchar.h>
|
||||
#include <string>
|
||||
|
||||
#include "../../../common/File.h"
|
||||
#include "../../../common/BigInteger.h"
|
||||
|
||||
#include "../../../xml/include/xmlutils.h"
|
||||
#include "../../../xml/libxml2/include/libxml/c14n.h"
|
||||
|
||||
#pragma comment (lib, "crypt32.lib")
|
||||
#pragma comment (lib, "cryptui.lib")
|
||||
#pragma comment (lib, "Advapi32.lib")
|
||||
|
||||
//#define ENUMS_CERTS
|
||||
|
||||
//////////////////////
|
||||
class CXmlBuffer
|
||||
{
|
||||
public:
|
||||
NSStringUtils::CStringBuilderA builder;
|
||||
|
||||
public:
|
||||
CXmlBuffer()
|
||||
{
|
||||
}
|
||||
~CXmlBuffer()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
static int xmlBufferIOWrite(CXmlBuffer* buf, const char* buffer, int len)
|
||||
{
|
||||
buf->builder.WriteString(buffer, (size_t)len);
|
||||
return len;
|
||||
}
|
||||
|
||||
static int xmlBufferIOClose(CXmlBuffer* buf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xmlC14NIsVisibleCallbackMy(void * user_data, xmlNodePtr node, xmlNodePtr parent)
|
||||
{
|
||||
if (node->type == XML_TEXT_NODE)
|
||||
{
|
||||
std::string sTmp((char*)node->content);
|
||||
if (std::string::npos != sTmp.find('\n') ||
|
||||
std::string::npos != sTmp.find('\r') ||
|
||||
std::string::npos != sTmp.find('\t'))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
|
||||
#define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)
|
||||
void MyHandleError(char *s);
|
||||
|
||||
bool Sign(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
|
||||
bool Verify(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
|
||||
|
||||
void ConvertEndian(const BYTE* src, BYTE* dst, DWORD size)
|
||||
{
|
||||
for(BYTE* p = dst + size - 1; p >= dst; ++src, --p)
|
||||
(*p) = (*src);
|
||||
}
|
||||
|
||||
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.
|
||||
// This program lists all of the certificates in a system certificate
|
||||
// store and all of the property identifier numbers of those
|
||||
// certificates. It also demonstrates the use of two
|
||||
// UI functions. One, CryptUIDlgSelectCertificateFromStore,
|
||||
// displays the certificates in a store
|
||||
// and allows the user to select one of them,
|
||||
// The other, CryptUIDlgViewContext,
|
||||
// displays the contents of a single certificate.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Declare and initialize variables.
|
||||
|
||||
HCERTSTORE hCertStore;
|
||||
PCCERT_CONTEXT pCertContext=NULL;
|
||||
char pszNameString[256];
|
||||
char pszStoreName[256];
|
||||
void* pvData;
|
||||
DWORD cbData;
|
||||
DWORD dwPropId = 0;
|
||||
// Zero must be used on the first
|
||||
// call to the function. After that,
|
||||
// the last returned property identifier is passed.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Begin processing and Get the name of the system certificate store
|
||||
// to be enumerated. Output here is to stderr so that the program
|
||||
// can be run from the command line and stdout can be redirected
|
||||
// to a file.
|
||||
/*
|
||||
fprintf(stderr,"Please enter the store name:");
|
||||
gets_s(pszStoreName, sizeof(pszStoreName));
|
||||
fprintf(stderr,"The store name is %s.\n",pszStoreName);
|
||||
*/
|
||||
pszStoreName[0] = 'M';
|
||||
pszStoreName[1] = 'Y';
|
||||
pszStoreName[2] = '\0';
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Open a system certificate store.
|
||||
|
||||
if ( hCertStore = CertOpenSystemStore(NULL, pszStoreName))
|
||||
{
|
||||
fprintf(stderr,"The %s store has been opened. \n", pszStoreName);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the store was not opened, exit to an error routine.
|
||||
MyHandleError("The store was not opened.");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Use CertEnumCertificatesInStore to get the certificates
|
||||
// from the open store. pCertContext must be reset to
|
||||
// NULL to retrieve the first certificate in the store.
|
||||
|
||||
// pCertContext = NULL;
|
||||
|
||||
#ifdef ENUMS_CERTS
|
||||
while(pCertContext= CertEnumCertificatesInStore(
|
||||
hCertStore,
|
||||
pCertContext))
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// A certificate was retrieved. Continue.
|
||||
//-------------------------------------------------------------------
|
||||
// Display the certificate.
|
||||
|
||||
if ( CryptUIDlgViewContext(
|
||||
CERT_STORE_CERTIFICATE_CONTEXT,
|
||||
pCertContext,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL))
|
||||
{
|
||||
// printf("OK\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
MyHandleError("UI failed.");
|
||||
}
|
||||
|
||||
if(CertGetNameString(
|
||||
pCertContext,
|
||||
CERT_NAME_SIMPLE_DISPLAY_TYPE,
|
||||
0,
|
||||
NULL,
|
||||
pszNameString,
|
||||
128))
|
||||
{
|
||||
printf("\nCertificate for %s \n",pszNameString);
|
||||
}
|
||||
else
|
||||
fprintf(stderr,"CertGetName failed. \n");
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Loop to find all of the property identifiers for the specified
|
||||
// certificate. The loop continues until
|
||||
// CertEnumCertificateContextProperties returns zero.
|
||||
|
||||
while(dwPropId = CertEnumCertificateContextProperties(
|
||||
pCertContext, // The context whose properties are to be listed.
|
||||
dwPropId)) // Number of the last property found.
|
||||
// This must be zero to find the first
|
||||
// property identifier.
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// When the loop is executed, a property identifier has been found.
|
||||
// Print the property number.
|
||||
|
||||
printf("Property # %d found->", dwPropId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Indicate the kind of property found.
|
||||
|
||||
switch(dwPropId)
|
||||
{
|
||||
case CERT_FRIENDLY_NAME_PROP_ID:
|
||||
{
|
||||
printf("Display name: ");
|
||||
break;
|
||||
}
|
||||
case CERT_SIGNATURE_HASH_PROP_ID:
|
||||
{
|
||||
printf("Signature hash identifier ");
|
||||
break;
|
||||
}
|
||||
case CERT_KEY_PROV_HANDLE_PROP_ID:
|
||||
{
|
||||
printf("KEY PROVE HANDLE");
|
||||
break;
|
||||
}
|
||||
case CERT_KEY_PROV_INFO_PROP_ID:
|
||||
{
|
||||
printf("KEY PROV INFO PROP ID ");
|
||||
break;
|
||||
}
|
||||
case CERT_SHA1_HASH_PROP_ID:
|
||||
{
|
||||
printf("SHA1 HASH identifier");
|
||||
break;
|
||||
}
|
||||
case CERT_MD5_HASH_PROP_ID:
|
||||
{
|
||||
printf("md5 hash identifier ");
|
||||
break;
|
||||
}
|
||||
case CERT_KEY_CONTEXT_PROP_ID:
|
||||
{
|
||||
printf("KEY CONTEXT PROP identifier");
|
||||
break;
|
||||
}
|
||||
case CERT_KEY_SPEC_PROP_ID:
|
||||
{
|
||||
printf("KEY SPEC PROP identifier");
|
||||
break;
|
||||
}
|
||||
case CERT_ENHKEY_USAGE_PROP_ID:
|
||||
{
|
||||
printf("ENHKEY USAGE PROP identifier");
|
||||
break;
|
||||
}
|
||||
case CERT_NEXT_UPDATE_LOCATION_PROP_ID:
|
||||
{
|
||||
printf("NEXT UPDATE LOCATION PROP identifier");
|
||||
break;
|
||||
}
|
||||
case CERT_PVK_FILE_PROP_ID:
|
||||
{
|
||||
printf("PVK FILE PROP identifier ");
|
||||
break;
|
||||
}
|
||||
case CERT_DESCRIPTION_PROP_ID:
|
||||
{
|
||||
printf("DESCRIPTION PROP identifier ");
|
||||
break;
|
||||
}
|
||||
case CERT_ACCESS_STATE_PROP_ID:
|
||||
{
|
||||
printf("ACCESS STATE PROP identifier ");
|
||||
break;
|
||||
}
|
||||
case CERT_SMART_CARD_DATA_PROP_ID:
|
||||
{
|
||||
printf("SMART_CARD DATA PROP identifier ");
|
||||
break;
|
||||
}
|
||||
case CERT_EFS_PROP_ID:
|
||||
{
|
||||
printf("EFS PROP identifier ");
|
||||
break;
|
||||
}
|
||||
case CERT_FORTEZZA_DATA_PROP_ID:
|
||||
{
|
||||
printf("FORTEZZA DATA PROP identifier ");
|
||||
break;
|
||||
}
|
||||
case CERT_ARCHIVED_PROP_ID:
|
||||
{
|
||||
printf("ARCHIVED PROP identifier ");
|
||||
break;
|
||||
}
|
||||
case CERT_KEY_IDENTIFIER_PROP_ID:
|
||||
{
|
||||
printf("KEY IDENTIFIER PROP identifier ");
|
||||
break;
|
||||
}
|
||||
case CERT_AUTO_ENROLL_PROP_ID:
|
||||
{
|
||||
printf("AUTO ENROLL identifier. ");
|
||||
break;
|
||||
}
|
||||
} // End switch.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve information on the property by first getting the
|
||||
// property size.
|
||||
// For more information, see CertGetCertificateContextProperty.
|
||||
|
||||
if(CertGetCertificateContextProperty(
|
||||
pCertContext,
|
||||
dwPropId ,
|
||||
NULL,
|
||||
&cbData))
|
||||
{
|
||||
// Continue.
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the first call to the function failed,
|
||||
// exit to an error routine.
|
||||
MyHandleError("Call #1 to GetCertContextProperty failed.");
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// The call succeeded. Use the size to allocate memory
|
||||
// for the property.
|
||||
|
||||
if(pvData = (void*)malloc(cbData))
|
||||
{
|
||||
// Memory is allocated. Continue.
|
||||
}
|
||||
else
|
||||
{
|
||||
// If memory allocation failed, exit to an error routine.
|
||||
MyHandleError("Memory allocation failed.");
|
||||
}
|
||||
//----------------------------------------------------------------
|
||||
// Allocation succeeded. Retrieve the property data.
|
||||
|
||||
if(CertGetCertificateContextProperty(
|
||||
pCertContext,
|
||||
dwPropId,
|
||||
pvData,
|
||||
&cbData))
|
||||
{
|
||||
// The data has been retrieved. Continue.
|
||||
}
|
||||
else
|
||||
{
|
||||
// If an error occurred in the second call,
|
||||
// exit to an error routine.
|
||||
MyHandleError("Call #2 failed.");
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
// Show the results.
|
||||
|
||||
printf("The Property Content is %d \n", pvData);
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Free the certificate context property memory.
|
||||
|
||||
free(pvData);
|
||||
} // End inner while.
|
||||
} // End outer while.
|
||||
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Select a new certificate by using the user interface.
|
||||
|
||||
if(!(pCertContext = CryptUIDlgSelectCertificateFromStore(hCertStore, NULL, NULL, NULL, CRYPTUI_SELECT_LOCATION_COLUMN, 0, NULL)))
|
||||
{
|
||||
MyHandleError("Select UI failed." );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
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");
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CertFreeCertificateContext(pCertContext);
|
||||
CertCloseStore(hCertStore,0);
|
||||
printf("The function completed successfully. \n");
|
||||
}
|
||||
|
||||
void MyHandleError(LPTSTR psz)
|
||||
{
|
||||
_ftprintf(stderr, TEXT("An error occurred in the program. \n"));
|
||||
_ftprintf(stderr, TEXT("%s\n"), psz);
|
||||
_ftprintf(stderr, TEXT("Error number %x.\n"), GetLastError());
|
||||
_ftprintf(stderr, TEXT("Program terminating. \n"));
|
||||
exit(1);
|
||||
} // End of MyHandleError.
|
||||
|
||||
bool Sign(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile)
|
||||
{
|
||||
// Variables
|
||||
HCRYPTPROV hCryptProv = NULL;
|
||||
DWORD dwKeySpec = 0;
|
||||
HCRYPTHASH hHash = NULL;
|
||||
|
||||
BOOL bResult = FALSE;
|
||||
|
||||
DWORD dwSigLen = 0;
|
||||
BYTE* pbSignature = NULL;
|
||||
|
||||
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);
|
||||
|
||||
xmlDocPtr xmlDoc = xmlParseMemory((char*)pDataSrc, (int)dwFileSrcLen);
|
||||
|
||||
CXmlBuffer _bufferC14N;
|
||||
xmlOutputBufferPtr _buffer = xmlOutputBufferCreateIO((xmlOutputWriteCallback)xmlBufferIOWrite,
|
||||
(xmlOutputCloseCallback)xmlBufferIOClose,
|
||||
&_bufferC14N,
|
||||
NULL);
|
||||
|
||||
xmlC14NExecute(xmlDoc, xmlC14NIsVisibleCallbackMy, NULL, XML_C14N_1_0, NULL, 0, _buffer);
|
||||
|
||||
xmlOutputBufferClose(_buffer);
|
||||
|
||||
NSFile::CFileBinary oFileDump;
|
||||
oFileDump.CreateFileW(NSFile::GetProcessDirectory() + L"/123.txt");
|
||||
oFileDump.WriteFile((BYTE*)_bufferC14N.builder.GetBuffer(), (DWORD)_bufferC14N.builder.GetCurSize());
|
||||
oFileDump.CloseFile();
|
||||
|
||||
//bResult = CryptHashData(hHash, pDataSrc, dwFileSrcLen, 0);
|
||||
bResult = CryptHashData(hHash, (BYTE*)_bufferC14N.builder.GetBuffer(), (DWORD)_bufferC14N.builder.GetCurSize(), 0);
|
||||
|
||||
if (true)
|
||||
{
|
||||
DWORD cbHashSize = 0, dwCount = sizeof(DWORD);
|
||||
|
||||
BOOL b1 = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&cbHashSize, &dwCount, 0);
|
||||
|
||||
BYTE* pDataHashRaw = new BYTE[dwCount];
|
||||
|
||||
BOOL b2 = CryptGetHashParam(hHash, HP_HASHVAL, pDataHashRaw, &cbHashSize, 0);
|
||||
|
||||
char* pBase64_hash = NULL;
|
||||
int nBase64Len_hash = 0;
|
||||
NSFile::CBase64Converter::Encode(pDataHashRaw, (int)cbHashSize, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NONE);
|
||||
|
||||
delete [] pBase64_hash;
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
NSFile::CFileBinary oFileTmp;
|
||||
oFileTmp.CreateFileW(NSFile::GetProcessDirectory() + L"/HASH.bin");
|
||||
oFileTmp.WriteFile(pbSignature, dwSigLen);
|
||||
oFileTmp.CloseFile();
|
||||
|
||||
BYTE* pbSignatureMem = new BYTE[dwSigLen];
|
||||
ConvertEndian(pbSignature, pbSignatureMem, dwSigLen);
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(sSignatureFile);
|
||||
|
||||
//oFile.WriteFile(pbSignature, dwSigLen);
|
||||
char* pBase64 = NULL;
|
||||
int nBase64Len = 0;
|
||||
NSFile::CBase64Converter::Encode(pbSignatureMem, (int)dwSigLen, pBase64, nBase64Len, NSBase64::B64_BASE64_FLAG_NONE);
|
||||
oFile.WriteFile((BYTE*)pBase64, (DWORD)nBase64Len);
|
||||
|
||||
oFile.CloseFile();
|
||||
|
||||
delete[] pbSignature;
|
||||
delete[] pbSignatureMem;
|
||||
delete[] pDataSrc;
|
||||
|
||||
bResult = CryptDestroyHash(hHash);
|
||||
|
||||
return (bResult == TRUE);
|
||||
}
|
||||
|
||||
bool Verify(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile)
|
||||
{
|
||||
DWORD dwKeySpec = 0;
|
||||
HCRYPTPROV hCryptProv = NULL;
|
||||
HCRYPTHASH hHash = NULL;
|
||||
HCRYPTKEY hPubKey = NULL;
|
||||
|
||||
BOOL bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
||||
|
||||
// Create the hash object.
|
||||
bResult = CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash);
|
||||
|
||||
BYTE* pDataSrc = NULL;
|
||||
DWORD dwFileSrcLen = 0;
|
||||
NSFile::CFileBinary::ReadAllBytes(sFileXml, &pDataSrc, dwFileSrcLen);
|
||||
|
||||
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;
|
||||
|
||||
BYTE* pDataHashMem = new BYTE[dwHashLen];
|
||||
ConvertEndian(pDataHash, pDataHashMem, dwHashLen);
|
||||
|
||||
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);
|
||||
|
||||
BOOL bResultRet = CryptVerifySignature(hHash, pDataHashMem, dwHashLen, hPubKey, NULL, 0);
|
||||
|
||||
delete[] pDataSrc;
|
||||
delete[] pDataHash;
|
||||
delete[] pDataHashMem;
|
||||
delete[] pDataHashBase64;
|
||||
|
||||
bResult = CryptDestroyHash(hHash);
|
||||
|
||||
return bResultRet && bResult;
|
||||
}
|
||||
35
DesktopEditor/xmlsec/test/windows_list_serts/test.pro
Normal file
35
DesktopEditor/xmlsec/test/windows_list_serts/test.pro
Normal file
@ -0,0 +1,35 @@
|
||||
QT -= core gui
|
||||
|
||||
TARGET = test
|
||||
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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
494
Test/Applications/DocxFormatCodeGen/codegen/CodeGenPivot.cs
Normal file
494
Test/Applications/DocxFormatCodeGen/codegen/CodeGenPivot.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
792
Test/Applications/DocxFormatCodeGen/codegen/CodegenJSPivot.cs
Normal file
792
Test/Applications/DocxFormatCodeGen/codegen/CodegenJSPivot.cs
Normal file
@ -0,0 +1,792 @@
|
||||
/*
|
||||
* (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", oGenClass.sName);
|
||||
|
||||
if (aAttributes.Count > 0)
|
||||
{
|
||||
sb.AppendFormat("{0}.prototype.readAttributes = function(attr, uq) {{\r\n", oGenClass.sName);
|
||||
ProcessAttributesFromXml(sb, oGenClass, aAttributes);
|
||||
sb.AppendFormat("}};\r\n", oGenClass.sName);
|
||||
}
|
||||
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", oGenClass.sName);
|
||||
|
||||
if (bNeedTextNode)
|
||||
{
|
||||
sb.AppendFormat("{0}.prototype.onTextNode = function(text, uq) {{\r\n", oGenClass.sName);
|
||||
ProcessOnTextNodeFromXml(sb, oGenClass, aMembers);
|
||||
sb.AppendFormat("}};\r\n", oGenClass.sName);
|
||||
}
|
||||
if (bNeedDoubleArray)
|
||||
{
|
||||
sb.AppendFormat("{0}.prototype.onEndNode = function(prevContext, elem) {{\r\n", oGenClass.sName);
|
||||
ProcessOnEndNodeFromXml(sb, oGenClass, aMembers);
|
||||
sb.AppendFormat("}};\r\n", oGenClass.sName);
|
||||
}
|
||||
}
|
||||
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("newContext.readAttributes(attr, uq);\r\n", sName, sCodeName);
|
||||
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("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;
|
||||
if (oGenMember.nArrayRank > 0)
|
||||
{
|
||||
if (false == oGenMember.bIsArrayTypesHidden)
|
||||
{
|
||||
sb.AppendFormat("if(null !== {0}){{\r\n", oGenMember.sName);
|
||||
}
|
||||
sb.AppendFormat("for(var i = 0; i < this.{0}.length; ++i){{\r\n", oGenMember.sName);
|
||||
sb.AppendFormat("var elem = this.{0}[i];\r\n", oGenMember.sName);
|
||||
sCodeElem = "elem";
|
||||
bNullCheck = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
sCodeElem = "this." + oGenMember.sName;
|
||||
}
|
||||
if (null != oGenMember.aArrayTypes)
|
||||
{
|
||||
if (false == oGenMember.bIsArrayTypesHidden)
|
||||
{
|
||||
if (bNullCheck)
|
||||
sb.AppendFormat("if(null !== {0}){{\r\n", sCodeElem);
|
||||
sb.AppendFormat("writer.WriteXmlNodeEnd(\"{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", oGenMember.sName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.WriteXmlAttributeString(\"{0}\", {1});\r\n", sName, sVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("writer.WriteXmlNodeStart(\"{0}\", true);\r\n", sName);
|
||||
sb.AppendFormat("writer.WriteXmlString({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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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"/>
|
||||
|
||||
@ -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"/>
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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"/>
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -7,11 +7,10 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
VERSION = 2.4.448.000
|
||||
VERSION = 2.4.450.0
|
||||
DEFINES += INTVER=$$VERSION
|
||||
|
||||
TARGET = x2t
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
|
||||
|
||||
Reference in New Issue
Block a user