mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-16 12:56:09 +08:00
Compare commits
12 Commits
core-windo
...
core/devel
| Author | SHA1 | Date | |
|---|---|---|---|
| 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")
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
@ -462,7 +462,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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -510,20 +510,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 +533,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 +577,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 +595,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 +616,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_;
|
||||
@ -713,7 +713,7 @@ void odf_drawing_context::Impl::create_draw_base(int type)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
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 +722,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 +741,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 +751,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 +809,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 +820,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 +836,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 +858,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 +866,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 +874,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 +891,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 +917,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 +974,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 +997,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;
|
||||
|
||||
@ -1246,10 +1286,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 +1300,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 +1484,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 +1508,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 +1523,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" не задано
|
||||
@ -1542,7 +1752,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 +1777,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 +1804,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 +1819,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 +1851,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 +1868,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 +1876,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 +1897,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 +2139,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 +2178,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 +2237,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 +2284,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 +2329,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)
|
||||
@ -2237,7 +2474,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 +2984,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 +3080,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
|
||||
{
|
||||
@ -124,21 +125,24 @@ public:
|
||||
void start_frame ();
|
||||
void end_frame ();
|
||||
|
||||
bool change_text_box_2_wordart();
|
||||
|
||||
void start_image (std::wstring 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 +153,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);
|
||||
|
||||
|
||||
@ -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()
|
||||
{
|
||||
@ -136,5 +155,40 @@ void odp_conversion_context::start_image(const std::wstring & image_file_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,15 +64,21 @@ 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)
|
||||
|
||||
@ -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_;
|
||||
|
||||
@ -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;
|
||||
};
|
||||
};
|
||||
@ -75,6 +75,22 @@ void OoxConverter::convert(PPTX::Logic::SpTreeElem *oox_element)
|
||||
convert (elem.operator->());
|
||||
}
|
||||
|
||||
void OoxConverter::convert_font(PPTX::Theme *theme, std::wstring & font)
|
||||
{
|
||||
if (font == L"+mj-lt")
|
||||
font = theme ? theme->themeElements.fontScheme.majorFont.latin.typeface : L"";
|
||||
else if (font == L"+mn-lt")
|
||||
font = theme ? theme->themeElements.fontScheme.minorFont.latin.typeface : L"";
|
||||
else if (font == L"+mj-ea")
|
||||
font = theme ? theme->themeElements.fontScheme.majorFont.ea.typeface : L"";
|
||||
else if (font == L"+mn-ea")
|
||||
font = theme ? theme->themeElements.fontScheme.minorFont.ea.typeface : L"";
|
||||
else if (font == L"+mj-cs")
|
||||
font = theme ? theme->themeElements.fontScheme.majorFont.cs.typeface : L"";
|
||||
else if (font == L"+mn-cs")
|
||||
font = theme ? theme->themeElements.fontScheme.minorFont.cs.typeface : L"";
|
||||
}
|
||||
|
||||
void OoxConverter::convert(PPTX::Logic::GraphicFrame *oox_graphic_frame)
|
||||
{
|
||||
if (!oox_graphic_frame)return;
|
||||
@ -156,11 +172,42 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
{
|
||||
if (!oox_picture)return;
|
||||
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
bool bImage = true;
|
||||
if (oox_picture->spPr.Geometry.is_init())
|
||||
{
|
||||
int type = SimpleTypes::shapetypeRect;
|
||||
if ( oox_picture->spPr.Geometry.is<PPTX::Logic::CustGeom>() )
|
||||
{
|
||||
type = 1000;
|
||||
}
|
||||
else if ( oox_picture->spPr.Geometry.is<PPTX::Logic::PrstGeom>() )
|
||||
{
|
||||
const PPTX::Logic::PrstGeom& prstGeom = oox_picture->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
|
||||
|
||||
SimpleTypes::CShapeType<> preset;
|
||||
preset.FromString(prstGeom.prst.get());
|
||||
type = preset.GetValue();
|
||||
}
|
||||
|
||||
if (type != SimpleTypes::shapetypeRect)
|
||||
{
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
odf_context()->drawing_context()->start_shape(type);
|
||||
|
||||
convert(&oox_picture->spPr, oox_picture->style.GetPointer());
|
||||
convert(&oox_picture->nvPicPr);
|
||||
|
||||
odf_context()->drawing_context()->start_area_properties();
|
||||
convert(&oox_picture->blipFill);
|
||||
odf_context()->drawing_context()->end_area_properties();
|
||||
|
||||
odf_context()->drawing_context()->end_shape();
|
||||
odf_context()->drawing_context()->end_drawing();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring pathImage;
|
||||
double Width=0, Height = 0;
|
||||
|
||||
if (oox_picture->blipFill.blip.IsInit())
|
||||
{
|
||||
std::wstring sID;
|
||||
@ -174,10 +221,13 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
{
|
||||
pathImage = oox_picture->blipFill.blip->link->get();
|
||||
}
|
||||
_graphics_utils_::GetResolution(pathImage.c_str(), Width, Height);
|
||||
}
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
odf_context()->start_image(pathImage);
|
||||
{
|
||||
double Width = 0, Height = 0;
|
||||
_graphics_utils_::GetResolution(pathImage.c_str(), Width, Height);
|
||||
|
||||
if (oox_picture->blipFill.tile.IsInit())
|
||||
{
|
||||
odf_context()->drawing_context()->set_image_style_repeat(2);
|
||||
@ -196,24 +246,7 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
}
|
||||
|
||||
OoxConverter::convert(&oox_picture->nvPicPr.cNvPr);
|
||||
|
||||
//oox_picture->m_oNvPicPr.m_oCNvPicPr
|
||||
//oox_picture->m_oNvPicPr.m_oCNvPicPr.m_oPicLocks
|
||||
{
|
||||
//if (oox_picture->m_oNvPicPr.m_oCNvPicPr.m_oPicLocks->m_oNoChangeAspect)
|
||||
//{
|
||||
//}
|
||||
//if (oox_picture->m_oNvPicPr.m_oCNvPicPr.m_oPicLocks->m_oNoCrop))
|
||||
//{
|
||||
//}
|
||||
//if (oox_picture->m_oNvPicPr.m_oCNvPicPr.m_oPicLocks->m_oNoResize)
|
||||
//{
|
||||
//}
|
||||
}
|
||||
//m_oExtLst
|
||||
|
||||
|
||||
OoxConverter::convert(&oox_picture->spPr, NULL);
|
||||
OoxConverter::convert(&oox_picture->spPr, oox_picture->style.GetPointer());
|
||||
|
||||
}
|
||||
odf_context()->drawing_context()->end_image();
|
||||
@ -372,7 +405,17 @@ void OoxConverter::convert(PPTX::Logic::CxnSp *oox_connect)
|
||||
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
|
||||
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeLine);
|
||||
int type = SimpleTypes::shapetypeLine;
|
||||
|
||||
if ( oox_connect->spPr.Geometry.is<PPTX::Logic::PrstGeom>() )
|
||||
{
|
||||
const PPTX::Logic::PrstGeom& prstGeom = oox_connect->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
|
||||
|
||||
SimpleTypes::CShapeType<> preset;
|
||||
preset.FromString(prstGeom.prst.get());
|
||||
type = preset.GetValue();
|
||||
}
|
||||
odf_context()->drawing_context()->start_shape(type);
|
||||
|
||||
convert(&oox_connect->spPr, oox_connect->style.GetPointer());
|
||||
convert(&oox_connect->nvCxnSpPr);
|
||||
@ -391,7 +434,6 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
|
||||
|
||||
if (oox_shape->spPr.Geometry.is_init())
|
||||
{
|
||||
|
||||
if ( oox_shape->spPr.Geometry.is<PPTX::Logic::PrstGeom>() )
|
||||
{
|
||||
const PPTX::Logic::PrstGeom& prstGeom = oox_shape->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
|
||||
@ -462,7 +504,7 @@ void OoxConverter::convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle*
|
||||
convert(prstGeom);
|
||||
convert(custGeom);
|
||||
|
||||
bool bLine = prstGeom ? (prstGeom->prst.get() == L"line") : false;
|
||||
bool bLine = odf_context()->drawing_context()->isLineShape();
|
||||
|
||||
if (!bLine)
|
||||
{
|
||||
@ -526,19 +568,52 @@ void OoxConverter::convert(PPTX::Logic::PrstGeom *oox_geom)
|
||||
|
||||
for (size_t i = 0; i < oox_geom->avLst.size(); i++)
|
||||
{
|
||||
if (oox_geom->avLst[i].fmla.IsInit())
|
||||
odf_context()->drawing_context()->add_modifier(oox_geom->avLst[i].fmla.get());
|
||||
odf_context()->drawing_context()->add_modifier(oox_geom->avLst[i].fmla.get_value_or(L"0"));
|
||||
}
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::CustGeom *oox_cust_geom)
|
||||
{
|
||||
if (!oox_cust_geom) return;
|
||||
|
||||
for (size_t i = 0; i < oox_cust_geom->gdLst.size(); i++)
|
||||
{
|
||||
odf_context()->drawing_context()->add_formula(oox_cust_geom->gdLst[i].name.get_value_or(L""), oox_cust_geom->gdLst[i].fmla.get_value_or(L""));
|
||||
}
|
||||
for (size_t i = 0; i < oox_cust_geom->pathLst.size(); i++)
|
||||
{
|
||||
convert(&oox_cust_geom->pathLst[i]);
|
||||
}
|
||||
for (size_t i = 0; i < oox_cust_geom->avLst.size(); i++)
|
||||
{
|
||||
odf_context()->drawing_context()->add_modifier(oox_cust_geom->avLst[i].fmla.get_value_or(L"0"));
|
||||
}
|
||||
for (size_t i = 0; i < oox_cust_geom->ahLst.size(); i++)
|
||||
{
|
||||
convert(oox_cust_geom->ahLst[i].ah.operator->());
|
||||
}
|
||||
if (oox_cust_geom->rect.IsInit())
|
||||
{
|
||||
odf_context()->drawing_context()->set_textarea (oox_cust_geom->rect->l.get_value_or(L"0"),
|
||||
oox_cust_geom->rect->t.get_value_or(L"0"),
|
||||
oox_cust_geom->rect->r.get_value_or(L"0"),
|
||||
oox_cust_geom->rect->b.get_value_or(L"0"));
|
||||
}
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::AhXY *oox_handle)
|
||||
{
|
||||
if (!oox_handle) return;
|
||||
|
||||
odf_context()->drawing_context()->add_handle(oox_handle->x, oox_handle->y,
|
||||
oox_handle->gdRefX.get_value_or(L""), oox_handle->gdRefY.get_value_or(L""),
|
||||
oox_handle->minX.get_value_or(L""), oox_handle->maxX.get_value_or(L""),
|
||||
oox_handle->minX.get_value_or(L""), oox_handle->maxY.get_value_or(L""));
|
||||
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::AhPolar *oox_handle)
|
||||
{
|
||||
if (!oox_handle) return;
|
||||
}
|
||||
|
||||
void OoxConverter::convert(PPTX::Logic::EffectLst *oox_effect_list)
|
||||
{
|
||||
if (!oox_effect_list) return;
|
||||
@ -609,6 +684,9 @@ void OoxConverter::convert(PPTX::Logic::Path2D *oox_geom_path)
|
||||
convert(pathBase);
|
||||
}
|
||||
|
||||
if (oox_geom_path->stroke.IsInit() && *oox_geom_path->stroke == false)
|
||||
odf_context()->drawing_context()->add_path_element(std::wstring(L"S"), L"");
|
||||
|
||||
odf_context()->drawing_context()->add_path_element(std::wstring(L"N"), L"");
|
||||
}
|
||||
|
||||
@ -616,44 +694,20 @@ void OoxConverter::convert(PPTX::Logic::PathBase *oox_path)
|
||||
{
|
||||
if (!oox_path) return;
|
||||
|
||||
PPTX::Logic::MoveTo* moveTo = dynamic_cast<PPTX::Logic::MoveTo*> (oox_path);
|
||||
PPTX::Logic::LineTo* lineTo = dynamic_cast<PPTX::Logic::LineTo*> (oox_path);
|
||||
PPTX::Logic::CubicBezTo* cubicBezTo = dynamic_cast<PPTX::Logic::CubicBezTo*> (oox_path);
|
||||
PPTX::Logic::MoveTo* moveTo = dynamic_cast<PPTX::Logic::MoveTo*> (oox_path);
|
||||
PPTX::Logic::LineTo* lineTo = dynamic_cast<PPTX::Logic::LineTo*> (oox_path);
|
||||
PPTX::Logic::CubicBezTo* cubicBezTo = dynamic_cast<PPTX::Logic::CubicBezTo*>(oox_path);
|
||||
PPTX::Logic::Close* close = dynamic_cast<PPTX::Logic::Close*> (oox_path);
|
||||
PPTX::Logic::ArcTo* arcTo = dynamic_cast<PPTX::Logic::ArcTo*> (oox_path);
|
||||
PPTX::Logic::QuadBezTo* quadBezTo = dynamic_cast<PPTX::Logic::QuadBezTo*> (oox_path);
|
||||
|
||||
if (moveTo)
|
||||
{
|
||||
std::wstring path_elm = moveTo->x + L" " + moveTo->y;
|
||||
odf_context()->drawing_context()->add_path_element(std::wstring(L"M"), path_elm);
|
||||
}
|
||||
if (lineTo)
|
||||
{
|
||||
std::wstring path_elm = lineTo->x + L" " + lineTo->y;
|
||||
odf_context()->drawing_context()->add_path_element(std::wstring(L"L"), path_elm);
|
||||
}
|
||||
if (cubicBezTo)
|
||||
{
|
||||
std::wstring path_elm = cubicBezTo->x[0] + L" " + cubicBezTo->y[0] + L" " +
|
||||
cubicBezTo->x[1] + L" " + cubicBezTo->y[1] + L" " +
|
||||
cubicBezTo->x[2] + L" " + cubicBezTo->y[2];
|
||||
odf_context()->drawing_context()->add_path_element(std::wstring(L"C"), path_elm);
|
||||
}
|
||||
if (quadBezTo)
|
||||
{
|
||||
std::wstring path_elm = quadBezTo->x[0] + L" " + quadBezTo->y[0] + L" " +
|
||||
quadBezTo->x[1] + L" " + quadBezTo->y[1];
|
||||
odf_context()->drawing_context()->add_path_element(std::wstring(L"S"), path_elm);
|
||||
}
|
||||
if (arcTo)
|
||||
{
|
||||
}
|
||||
if (close)
|
||||
{
|
||||
std::wstring path_elm ;
|
||||
odf_context()->drawing_context()->add_path_element(std::wstring(L"Z"), path_elm);
|
||||
}
|
||||
if (moveTo) convert(moveTo);
|
||||
if (lineTo) convert(lineTo);
|
||||
if (cubicBezTo) convert(cubicBezTo);
|
||||
if (quadBezTo) convert(quadBezTo);
|
||||
if (arcTo) convert(arcTo);
|
||||
if (close) convert(close);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -790,11 +844,11 @@ void OoxConverter::convert(PPTX::Logic::GradFill *oox_grad_fill, DWORD nARGB)
|
||||
odf_context()->drawing_context()->set_opacity_start (*opacityStart);
|
||||
odf_context()->drawing_context()->set_opacity_end (*opacityEnd);
|
||||
|
||||
if (grad_style == odf_types::gradient_style::linear)
|
||||
if (oox_grad_fill->lin.is_init())
|
||||
{
|
||||
odf_context()->drawing_context()->set_opacity_angle(oox_grad_fill->lin->ang.get()/60000.);
|
||||
}
|
||||
else
|
||||
else if (oox_grad_fill->path.is_init())
|
||||
{
|
||||
odf_context()->drawing_context()->set_opacity_rect ( XmlUtils::GetInteger(oox_grad_fill->path->rect->l.get_value_or(L"")),
|
||||
XmlUtils::GetInteger(oox_grad_fill->path->rect->t.get_value_or(L"")),
|
||||
@ -810,7 +864,7 @@ void OoxConverter::convert(PPTX::Logic::GradFill *oox_grad_fill, DWORD nARGB)
|
||||
|
||||
}
|
||||
|
||||
void OoxConverter::convert(PPTX::Logic::UniColor * color, std::wstring & hexString, _CP_OPT(double) & opacity, DWORD nARGB)
|
||||
void OoxConverter::convert(PPTX::Logic::UniColor * color, DWORD & nARGB)
|
||||
{
|
||||
if (!color) return;
|
||||
|
||||
@ -818,6 +872,13 @@ void OoxConverter::convert(PPTX::Logic::UniColor * color, std::wstring & hexStri
|
||||
smart_ptr<PPTX::Theme> theme(oox_theme()); theme.AddRef();
|
||||
|
||||
nARGB = color->GetRGBColor(theme, clrMap, nARGB);
|
||||
}
|
||||
|
||||
void OoxConverter::convert(PPTX::Logic::UniColor * color, std::wstring & hexString, _CP_OPT(double) & opacity, DWORD nARGB)
|
||||
{
|
||||
if (!color) return;
|
||||
|
||||
convert(color, nARGB);
|
||||
|
||||
hexString = XmlUtils::IntToString(nARGB & 0x00FFFFFF, L"#%06X");
|
||||
|
||||
@ -896,7 +957,7 @@ void OoxConverter::convert(PPTX::Logic::Ln *oox_line_prop, DWORD ARGB, PPTX::Log
|
||||
{
|
||||
if (oox_line_prop->headEnd->len.IsInit() || oox_line_prop->headEnd->type.IsInit() || oox_line_prop->headEnd->w.IsInit())
|
||||
{
|
||||
int type = 0, w=1, len =1;//medium arrow
|
||||
int type = 0, w = 1, len = 1;//medium arrow
|
||||
if (oox_line_prop->headEnd->len.IsInit()) len = oox_line_prop->headEnd->len->GetBYTECode();
|
||||
if (oox_line_prop->headEnd->type.IsInit()) type = oox_line_prop->headEnd->type->GetBYTECode();
|
||||
if (oox_line_prop->headEnd->w.IsInit()) w = oox_line_prop->headEnd->w->GetBYTECode();
|
||||
@ -908,7 +969,7 @@ void OoxConverter::convert(PPTX::Logic::Ln *oox_line_prop, DWORD ARGB, PPTX::Log
|
||||
{
|
||||
if (oox_line_prop->tailEnd->len.IsInit() || oox_line_prop->tailEnd->type.IsInit() || oox_line_prop->tailEnd->w.IsInit())
|
||||
{
|
||||
int type =0, w=1, len =1;//medium arrow
|
||||
int type = 0, w = 1, len = 1;//medium arrow
|
||||
if (oox_line_prop->tailEnd->len.IsInit()) len = oox_line_prop->tailEnd->len->GetBYTECode();
|
||||
if (oox_line_prop->tailEnd->type.IsInit()) type = oox_line_prop->tailEnd->type->GetBYTECode();
|
||||
if (oox_line_prop->tailEnd->w.IsInit()) w = oox_line_prop->tailEnd->w->GetBYTECode();
|
||||
@ -1058,21 +1119,30 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
|
||||
|
||||
if (oox_paragraph->pPr.IsInit() || oox_list_style)
|
||||
{
|
||||
if (oox_paragraph->pPr.IsInit() && (oox_paragraph->pPr->lvl.IsInit() || oox_paragraph->pPr->ParagraphBullet.is_init()))
|
||||
if (oox_paragraph->pPr.IsInit())
|
||||
{
|
||||
list_present = true;
|
||||
|
||||
list_level = 1;
|
||||
if (oox_paragraph->pPr->ParagraphBullet.is_init())
|
||||
{
|
||||
list_present = true;
|
||||
list_level = 1;
|
||||
}
|
||||
if (oox_paragraph->pPr->lvl.IsInit())
|
||||
list_level = *oox_paragraph->pPr->lvl;
|
||||
{
|
||||
list_level = *oox_paragraph->pPr->lvl;
|
||||
if (list_level > 0)
|
||||
list_present = true;
|
||||
}
|
||||
}
|
||||
|
||||
odf_writer::style_paragraph_properties * paragraph_properties = odf_context()->text_context()->get_paragraph_properties();
|
||||
//свойства могут быть приписаны не только к параграфу, но и к самому объекту
|
||||
odf_writer::style_paragraph_properties* paragraph_properties = odf_context()->text_context()->get_paragraph_properties();
|
||||
odf_writer::style_text_properties* text_properties = NULL;
|
||||
if (!paragraph_properties)
|
||||
{
|
||||
odf_context()->text_context()->get_styles_context()->create_style(L"", odf_types::style_family::Paragraph, true, false, -1);
|
||||
paragraph_properties = odf_context()->text_context()->get_styles_context()->last_state()->get_paragraph_properties();
|
||||
|
||||
paragraph_properties = odf_context()->text_context()->get_styles_context()->last_state()->get_paragraph_properties();
|
||||
text_properties = odf_context()->text_context()->get_styles_context()->last_state()->get_text_properties();
|
||||
|
||||
//if(list_present && oox_list_style)
|
||||
//{
|
||||
@ -1081,8 +1151,11 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
|
||||
//}
|
||||
styled = true;
|
||||
}
|
||||
convert(oox_list_style, list_level, paragraph_properties);
|
||||
convert(oox_paragraph->pPr.GetPointer(), paragraph_properties);
|
||||
convert(oox_list_style, list_level, paragraph_properties, text_properties);
|
||||
convert(oox_paragraph->pPr.GetPointer(), paragraph_properties, text_properties);
|
||||
|
||||
if (odf_context()->drawing_context()->is_wordart())
|
||||
odf_context()->drawing_context()->set_paragraph_properties(paragraph_properties);
|
||||
}
|
||||
|
||||
if(list_present)
|
||||
@ -1127,77 +1200,79 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
|
||||
odf_context()->text_context()->end_list_item();
|
||||
}
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::TextListStyle *oox_list_style, int level, odf_writer::style_paragraph_properties * paragraph_properties)
|
||||
void OoxConverter::convert(PPTX::Logic::TextListStyle *oox_list_style, int level, odf_writer::style_paragraph_properties * paragraph_properties
|
||||
, odf_writer::style_text_properties * text_properties)
|
||||
{
|
||||
if (!oox_list_style) return;
|
||||
if (!paragraph_properties) return;
|
||||
|
||||
convert(oox_list_style->levels[9].GetPointer(), paragraph_properties);
|
||||
convert(oox_list_style->levels[9].GetPointer(), paragraph_properties, text_properties);
|
||||
if (level < 0 || level > 9) return;
|
||||
|
||||
convert(oox_list_style->levels[level].GetPointer(), paragraph_properties);
|
||||
convert(oox_list_style->levels[level].GetPointer(), paragraph_properties, text_properties);
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::TextParagraphPr *oox_paragraph_pr, odf_writer::style_paragraph_properties * paragraph_properties)
|
||||
void OoxConverter::convert(PPTX::Logic::TextParagraphPr *oox_paragraph_pr , odf_writer::style_paragraph_properties * paragraph_properties
|
||||
, odf_writer::style_text_properties * text_properties)
|
||||
{
|
||||
if (!oox_paragraph_pr) return;
|
||||
if (!paragraph_properties) return;
|
||||
|
||||
if (oox_paragraph_pr->lnSpc.IsInit())
|
||||
if (!oox_paragraph_pr) return;
|
||||
|
||||
if (paragraph_properties)
|
||||
{
|
||||
odf_types::length_or_percent length;
|
||||
convert(oox_paragraph_pr->lnSpc.GetPointer(), length);
|
||||
paragraph_properties->content_.fo_line_height_ = odf_types::line_width(length);
|
||||
}
|
||||
if (oox_paragraph_pr->spcAft.IsInit())
|
||||
{
|
||||
odf_types::length_or_percent length;
|
||||
convert(oox_paragraph_pr->spcAft.GetPointer(), length);
|
||||
paragraph_properties->content_.fo_margin_bottom_ = length;
|
||||
}
|
||||
if (oox_paragraph_pr->spcBef.IsInit())
|
||||
{
|
||||
odf_types::length_or_percent length;
|
||||
convert(oox_paragraph_pr->spcBef.GetPointer(), length);
|
||||
paragraph_properties->content_.fo_margin_top_ = length;
|
||||
}
|
||||
if (oox_paragraph_pr->algn.IsInit())
|
||||
{
|
||||
switch(oox_paragraph_pr->algn->GetBYTECode())
|
||||
if (oox_paragraph_pr->lnSpc.IsInit())
|
||||
{
|
||||
case 0 : paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Center); break;
|
||||
case 1 :
|
||||
case 2 :
|
||||
case 3 : paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Justify); break;
|
||||
case 5 : paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Right); break;
|
||||
case 4 :
|
||||
default:
|
||||
paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Left); break;
|
||||
odf_types::length_or_percent length;
|
||||
convert(oox_paragraph_pr->lnSpc.GetPointer(), length);
|
||||
paragraph_properties->content_.fo_line_height_ = odf_types::line_width(length);
|
||||
}
|
||||
if (oox_paragraph_pr->spcAft.IsInit())
|
||||
{
|
||||
odf_types::length_or_percent length;
|
||||
convert(oox_paragraph_pr->spcAft.GetPointer(), length);
|
||||
paragraph_properties->content_.fo_margin_bottom_ = length;
|
||||
}
|
||||
if (oox_paragraph_pr->spcBef.IsInit())
|
||||
{
|
||||
odf_types::length_or_percent length;
|
||||
convert(oox_paragraph_pr->spcBef.GetPointer(), length);
|
||||
paragraph_properties->content_.fo_margin_top_ = length;
|
||||
}
|
||||
if (oox_paragraph_pr->algn.IsInit())
|
||||
{
|
||||
switch(oox_paragraph_pr->algn->GetBYTECode())
|
||||
{
|
||||
case 0 : paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Center); break;
|
||||
case 1 :
|
||||
case 2 :
|
||||
case 3 : paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Justify); break;
|
||||
case 5 : paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Right); break;
|
||||
case 4 :
|
||||
default:
|
||||
paragraph_properties->content_.fo_text_align_ = odf_types::text_align(odf_types::text_align::Left); break;
|
||||
}
|
||||
}
|
||||
if (oox_paragraph_pr->marL.IsInit())
|
||||
{
|
||||
paragraph_properties->content_.fo_margin_left_ = odf_types::length_or_percent(odf_types::length(oox_paragraph_pr->marL.get() / 12700., odf_types::length::pt));
|
||||
}
|
||||
if (oox_paragraph_pr->marR.IsInit())
|
||||
{
|
||||
paragraph_properties->content_.fo_margin_right_ = odf_types::length_or_percent(odf_types::length(oox_paragraph_pr->marR.get() / 12700., odf_types::length::pt));
|
||||
}
|
||||
if (oox_paragraph_pr->indent.IsInit())
|
||||
{
|
||||
paragraph_properties->content_.fo_text_indent_ = odf_types::length_or_percent(odf_types::length(oox_paragraph_pr->indent.get() / 12700., odf_types::length::pt));
|
||||
}
|
||||
if (oox_paragraph_pr->rtl.IsInit())
|
||||
{
|
||||
}
|
||||
}
|
||||
if (oox_paragraph_pr->marL.IsInit())
|
||||
{
|
||||
paragraph_properties->content_.fo_margin_left_ = odf_types::length_or_percent(odf_types::length(oox_paragraph_pr->marL.get() / 12700., odf_types::length::pt));
|
||||
}
|
||||
if (oox_paragraph_pr->marR.IsInit())
|
||||
{
|
||||
paragraph_properties->content_.fo_margin_right_ = odf_types::length_or_percent(odf_types::length(oox_paragraph_pr->marR.get() / 12700., odf_types::length::pt));
|
||||
}
|
||||
if (oox_paragraph_pr->indent.IsInit())
|
||||
{
|
||||
paragraph_properties->content_.fo_text_indent_ = odf_types::length_or_percent(odf_types::length(oox_paragraph_pr->indent.get() / 12700., odf_types::length::pt));
|
||||
}
|
||||
if (oox_paragraph_pr->rtl.IsInit())
|
||||
{
|
||||
}
|
||||
//nullable<SimpleTypes::CDecimalNumber<> > m_oLvl;
|
||||
//nullable<SimpleTypes::CCoordinate32<> > m_oDefTabSz;
|
||||
//nullable<SimpleTypes::CTextFontAlignType<>> m_oFontAlgn;
|
||||
|
||||
if (oox_paragraph_pr->defRPr.IsInit())
|
||||
{
|
||||
odf_writer::style_text_properties * text_properties = odf_context()->text_context()->get_styles_context()->last_state()->get_text_properties();
|
||||
if (text_properties)
|
||||
convert(oox_paragraph_pr->defRPr.GetPointer(), text_properties);
|
||||
convert(oox_paragraph_pr->defRPr.GetPointer(), text_properties);
|
||||
|
||||
//надо подумать как брать последний по family !!!
|
||||
//convert(oox_paragraph_pr->m_oDefRunProperty.GetPointer());
|
||||
@ -1216,7 +1291,7 @@ void OoxConverter::convert(PPTX::Logic::TextSpacing *oox_spacing, cpdoccore::odf
|
||||
}
|
||||
if ( oox_spacing->spcPts.IsInit() )
|
||||
{
|
||||
odf_types::length length = odf_types::length(oox_spacing->GetVal() / 12700., odf_types::length::pt);
|
||||
odf_types::length length = odf_types::length(-oox_spacing->GetVal() / 100., odf_types::length::pt);
|
||||
length_or_percent = odf_types::length_or_percent(length);
|
||||
}
|
||||
}
|
||||
@ -1228,43 +1303,59 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
|
||||
|
||||
PPTX::Theme *theme = oox_theme();
|
||||
|
||||
PPTX::Logic::GradFill* gradFill = &oox_run_pr->Fill.as<PPTX::Logic::GradFill>();
|
||||
if (gradFill)
|
||||
{
|
||||
if (odf_context()->drawing_context()->change_text_box_2_wordart())
|
||||
//------------------------------------------------------
|
||||
odf_writer::odf_drawing_context *drawing = odf_context()->drawing_context();
|
||||
if (drawing) //from styles impossible(
|
||||
{
|
||||
if ((oox_run_pr->Fill.is<PPTX::Logic::GradFill>()) ||
|
||||
((oox_run_pr->ln.IsInit()) && (oox_run_pr->ln->Fill.is_init() && oox_run_pr->ln->Fill.getType() != OOX::et_a_noFill)))
|
||||
{
|
||||
odf_context()->drawing_context()->start_area_properties();
|
||||
{
|
||||
convert(gradFill);
|
||||
}
|
||||
odf_context()->drawing_context()->end_area_properties();
|
||||
drawing->change_text_box_2_wordart();
|
||||
}
|
||||
|
||||
if (drawing->is_wordart())
|
||||
{
|
||||
if (oox_run_pr->Fill.is_init())
|
||||
{
|
||||
drawing->start_area_properties();
|
||||
convert(&oox_run_pr->Fill);
|
||||
drawing->end_area_properties();
|
||||
}
|
||||
if (oox_run_pr->ln.is_init())
|
||||
{
|
||||
drawing->start_line_properties();
|
||||
if (oox_run_pr->ln->Fill.is_init() && oox_run_pr->ln->Fill.getType() != OOX::et_a_noFill )
|
||||
{
|
||||
drawing->set_line_dash_preset(6);
|
||||
convert(oox_run_pr->ln.GetPointer());
|
||||
}
|
||||
else if (drawing->is_wordart())
|
||||
drawing->set_no_fill();
|
||||
drawing->end_line_properties();
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------
|
||||
_CP_OPT(double) opacityText;
|
||||
std::wstring hexColorText;
|
||||
|
||||
PPTX::Logic::GradFill* gradFill = &oox_run_pr->Fill.as<PPTX::Logic::GradFill>();
|
||||
if (gradFill && !gradFill->GsLst.empty())
|
||||
{
|
||||
convert(&gradFill->GsLst[0].color, hexColorText, opacityText);
|
||||
}
|
||||
PPTX::Logic::SolidFill* solidFill = &oox_run_pr->Fill.as<PPTX::Logic::SolidFill>();
|
||||
if (solidFill)
|
||||
{
|
||||
std::wstring hexColor;
|
||||
_CP_OPT(double) opacity;
|
||||
convert(&solidFill->Color, hexColor, opacity);
|
||||
|
||||
convert(&solidFill->Color, hexColorText, opacityText);
|
||||
}
|
||||
if (!hexColorText.empty())
|
||||
{
|
||||
int res = 0;
|
||||
if ((res = hexColor.find(L"#")) < 0) hexColor = std::wstring(L"#") + hexColor;
|
||||
text_properties->content_.fo_color_ = odf_types::color(hexColor);
|
||||
if ((res = hexColorText.find(L"#")) < 0) hexColorText = std::wstring(L"#") + hexColorText;
|
||||
text_properties->content_.fo_color_ = odf_types::color(hexColorText);
|
||||
}
|
||||
|
||||
if (oox_run_pr->ln.IsInit() && oox_run_pr->ln->Fill.getType() != OOX::et_a_noFill)
|
||||
{
|
||||
if (odf_context()->drawing_context()->change_text_box_2_wordart())
|
||||
{
|
||||
odf_context()->drawing_context()->start_line_properties();
|
||||
{
|
||||
odf_context()->drawing_context()->set_line_dash_preset(6);
|
||||
convert(oox_run_pr->ln.GetPointer());
|
||||
}
|
||||
odf_context()->drawing_context()->end_line_properties();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
if (oox_run_pr->b.IsInit())
|
||||
{
|
||||
if (oox_run_pr->b.get() == true)
|
||||
@ -1291,12 +1382,8 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
|
||||
if (!oox_run_pr->latin->typeface.empty())
|
||||
{
|
||||
std::wstring font = oox_run_pr->latin->typeface;
|
||||
|
||||
if (font == L"+mj-lt")
|
||||
font = theme->themeElements.fontScheme.majorFont.latin.typeface;
|
||||
else if (font == L"+mn-lt")
|
||||
font = theme->themeElements.fontScheme.minorFont.latin.typeface;
|
||||
|
||||
convert_font(theme, font);
|
||||
|
||||
if (!font.empty())
|
||||
text_properties->content_.fo_font_family_ = font;
|
||||
}
|
||||
@ -1310,11 +1397,7 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
|
||||
if (!oox_run_pr->ea->typeface.empty())
|
||||
{
|
||||
std::wstring font = oox_run_pr->ea->typeface;
|
||||
|
||||
if (font == L"+mj-ea")
|
||||
font = theme->themeElements.fontScheme.majorFont.ea.typeface;
|
||||
else if (font == L"+mn-ea")
|
||||
font = theme->themeElements.fontScheme.minorFont.ea.typeface;
|
||||
convert_font(theme, font);
|
||||
|
||||
if (!font.empty())
|
||||
text_properties->content_.style_font_family_asian_ = font;
|
||||
@ -1328,11 +1411,7 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
|
||||
if (!oox_run_pr->cs->typeface.empty())
|
||||
{
|
||||
std::wstring font = oox_run_pr->cs->typeface;
|
||||
|
||||
if (font == L"+mj-cs")
|
||||
font = theme->themeElements.fontScheme.majorFont.cs.typeface;
|
||||
else if (font == L"+mn-cs")
|
||||
font = theme->themeElements.fontScheme.minorFont.cs.typeface;
|
||||
convert_font(theme, font);
|
||||
|
||||
if (!font.empty())
|
||||
text_properties->content_.style_font_family_complex_ = font;
|
||||
@ -1347,12 +1426,12 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
|
||||
int res = oox_language.find(L"-");
|
||||
if (res >= 0)
|
||||
{
|
||||
oox_country = oox_language.substr(res);
|
||||
oox_country = oox_language.substr(res + 1);
|
||||
oox_language = oox_language.substr(0, res);
|
||||
}
|
||||
|
||||
text_properties->content_.fo_language_ = oox_language;
|
||||
if (oox_country.length() > 0)
|
||||
if (!oox_country.empty())
|
||||
text_properties->content_.fo_country_ = oox_country;
|
||||
|
||||
}
|
||||
@ -1416,7 +1495,7 @@ void OoxConverter::convert(PPTX::Logic::Run *oox_run)
|
||||
|
||||
odf_context()->text_context()->start_span(styled);
|
||||
|
||||
if ((oox_run->rPr->hlinkClick.IsInit()) && (oox_run->rPr->hlinkClick->id.IsInit()))
|
||||
if ((oox_run->rPr.IsInit()) && (oox_run->rPr->hlinkClick.IsInit()) && (oox_run->rPr->hlinkClick->id.IsInit()))
|
||||
{
|
||||
std::wstring hlink = find_link_by_id(oox_run->rPr->hlinkClick->id.get(), 2);
|
||||
odf_context()->text_context()->add_hyperlink(hlink, oox_run->GetText());
|
||||
@ -1464,8 +1543,6 @@ void OoxConverter::convert(PPTX::Logic::TxBody *oox_txBody, PPTX::Logic::ShapeSt
|
||||
if (oox_txBody->Paragrs.empty()) return;
|
||||
|
||||
odf_context()->start_text_context();
|
||||
|
||||
|
||||
|
||||
for (size_t i = 0; i < oox_txBody->Paragrs.size(); i++)
|
||||
{
|
||||
@ -1487,10 +1564,9 @@ void OoxConverter::convert(PPTX::Logic::ArcTo *oox_geom_path)
|
||||
{
|
||||
if (!oox_geom_path) return;
|
||||
|
||||
//std::wstring path_elm = std::to_wstring ((int)pt2emu(oox_geom_path->m_oPt.m_oX.GetValue())) +
|
||||
// std::wstring(L" ")+ std::to_wstring ((int)pt2emu(oox_geom_path->m_oPt.m_oY.GetValue()));
|
||||
//
|
||||
//odf_context()->drawing_context()->add_path_element(std::wstring(L"A"), path_elm);
|
||||
std::wstring path_elm = oox_geom_path->hR + L" " + oox_geom_path->wR + L" " + oox_geom_path->swAng + L" " + oox_geom_path->stAng;
|
||||
|
||||
odf_context()->drawing_context()->add_path_element(std::wstring(L"G"), path_elm);
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::QuadBezTo *oox_geom_path)
|
||||
{
|
||||
@ -1521,14 +1597,19 @@ void OoxConverter::convert(PPTX::Logic::Close *oox_geom_path)
|
||||
void OoxConverter::convert(PPTX::Logic::StyleRef *style_ref, int type)
|
||||
{
|
||||
if (!style_ref) return;
|
||||
|
||||
|
||||
DWORD nARGB = 0;
|
||||
convert(&style_ref->Color, nARGB);
|
||||
|
||||
if (style_ref->idx.IsInit() == false)
|
||||
{
|
||||
std::wstring hexColor;
|
||||
std::wstring hexColor = XmlUtils::IntToString(nARGB & 0x00FFFFFF, L"#%06X");
|
||||
_CP_OPT(double) opacity;
|
||||
|
||||
convert(&style_ref->Color, hexColor, opacity);
|
||||
if ((nARGB >> 24) != 0xff)
|
||||
{
|
||||
opacity = ((nARGB >> 24) /255.) * 100.;
|
||||
}
|
||||
|
||||
if (type != 3) //?? todooo
|
||||
{
|
||||
@ -1568,14 +1649,14 @@ void OoxConverter::convert(PPTX::Logic::StyleRef *style_ref, int type)
|
||||
}
|
||||
}
|
||||
|
||||
convert(fill, style_ref->Color.GetARGB());
|
||||
convert(fill, nARGB);
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
index -= 1;
|
||||
if ((index >= 0) || (index < theme->themeElements.fmtScheme.lnStyleLst.size()))
|
||||
{
|
||||
convert(&theme->themeElements.fmtScheme.lnStyleLst[index], style_ref->Color.GetARGB());
|
||||
convert(&theme->themeElements.fmtScheme.lnStyleLst[index], nARGB);
|
||||
}
|
||||
}
|
||||
else if (type == 3)
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -322,6 +322,8 @@ namespace PPTX
|
||||
class InnerShdw;
|
||||
class OuterShdw;
|
||||
class PrstShdw;
|
||||
class AhXY;
|
||||
class AhPolar;
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,6 +364,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 +393,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);
|
||||
@ -400,9 +404,12 @@ public:
|
||||
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::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 +424,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);
|
||||
|
||||
@ -3392,7 +3392,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()); //стили дефалтовых списков
|
||||
|
||||
@ -294,23 +294,34 @@ 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";
|
||||
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();
|
||||
|
||||
if (bShowMasterSp)
|
||||
{
|
||||
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();
|
||||
@ -319,18 +330,20 @@ 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 (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);
|
||||
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 +378,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, true);
|
||||
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 +406,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,14 +935,13 @@ 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());
|
||||
|
||||
@ -897,13 +952,41 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, bool bPlaceholde
|
||||
smart_ptr<PPTX::WrapperWritingElement> pElem = oox_slide->spTree.SpTreeElems[i].GetElem();
|
||||
smart_ptr<PPTX::Logic::Shape> pShape = pElem.smart_dynamic_cast<PPTX::Logic::Shape>();
|
||||
|
||||
if (pShape.IsInit())
|
||||
if (pShape.IsInit() && pShape->nvSpPr.nvPr.ph.is_init())
|
||||
{
|
||||
pShape->FillLevelUp();
|
||||
if (!bPlaceholders && pShape->nvSpPr.nvPr.ph.is_init())
|
||||
|
||||
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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
@ -462,52 +457,10 @@ namespace PPTX
|
||||
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;
|
||||
|
||||
@ -316,7 +316,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();
|
||||
|
||||
@ -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"
|
||||
|
||||
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
|
||||
426
DesktopEditor/xmlsec/test/windows_list_serts/main.cpp
Normal file
426
DesktopEditor/xmlsec/test/windows_list_serts/main.cpp
Normal file
@ -0,0 +1,426 @@
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
#include <cryptuiapi.h>
|
||||
|
||||
#include <tchar.h>
|
||||
#include <string>
|
||||
|
||||
#include "../../../common/File.h"
|
||||
|
||||
#pragma comment (lib, "crypt32.lib")
|
||||
#pragma comment (lib, "cryptui.lib")
|
||||
#pragma comment (lib, "Advapi32.lib")
|
||||
|
||||
//#define ENUMS_CERTS
|
||||
|
||||
#define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)
|
||||
void MyHandleError(char *s);
|
||||
|
||||
bool Sign(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
|
||||
bool Verify(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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(hCertStore, pCertContext, NSFile::GetProcessDirectory() + L"/document.xml", NSFile::GetProcessDirectory() + L"/result.txt");
|
||||
bRes = Verify(hCertStore, pCertContext, NSFile::GetProcessDirectory() + L"/document.xml", NSFile::GetProcessDirectory() + L"/result.txt");
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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(HCERTSTORE hStoreHandle, 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;
|
||||
|
||||
// Open the certificate store.
|
||||
|
||||
bResult = CryptAcquireCertificatePrivateKey(pCertContext, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
|
||||
|
||||
bool bIsResult = ((dwKeySpec & AT_SIGNATURE) == AT_SIGNATURE);
|
||||
|
||||
// Create the hash object.
|
||||
bResult = CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash);
|
||||
|
||||
BYTE* pDataSrc = NULL;
|
||||
DWORD dwFileSrcLen = 0;
|
||||
NSFile::CFileBinary::ReadAllBytes(sFileXml, &pDataSrc, dwFileSrcLen);
|
||||
|
||||
bResult = CryptHashData(hHash, pDataSrc, dwFileSrcLen, 0);
|
||||
|
||||
// Sign the hash object
|
||||
dwSigLen = 0;
|
||||
bResult = CryptSignHash(hHash, dwKeySpec, NULL, 0, NULL, &dwSigLen);
|
||||
|
||||
pbSignature = new BYTE[dwSigLen];
|
||||
bResult = CryptSignHash(hHash, dwKeySpec, NULL, 0, pbSignature, &dwSigLen);
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(sSignatureFile);
|
||||
|
||||
//oFile.WriteFile(pbSignature, dwSigLen);
|
||||
char* pBase64 = NULL;
|
||||
int nBase64Len = 0;
|
||||
NSFile::CBase64Converter::Encode(pbSignature, (int)dwSigLen, pBase64, nBase64Len, NSBase64::B64_BASE64_FLAG_NONE);
|
||||
oFile.WriteFile((BYTE*)pBase64, (DWORD)nBase64Len);
|
||||
|
||||
oFile.CloseFile();
|
||||
|
||||
delete[] pbSignature;
|
||||
delete[] pDataSrc;
|
||||
|
||||
bResult = CryptDestroyHash(hHash);
|
||||
|
||||
return (bResult == TRUE);
|
||||
}
|
||||
|
||||
bool Verify(HCERTSTORE hStoreHandle, 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;
|
||||
|
||||
bResult = CryptHashData(hHash, pDataSrc, dwFileSrcLen, 0);
|
||||
|
||||
// Get the public key from the certificate
|
||||
CryptImportPublicKeyInfo(hCryptProv, PKCS_7_ASN_ENCODING | X509_ASN_ENCODING, &pCertContext->pCertInfo->SubjectPublicKeyInfo, &hPubKey);
|
||||
|
||||
bResult = CryptVerifySignature(hHash, pDataHash, dwHashLen, hPubKey, NULL, 0);
|
||||
|
||||
delete[] pDataSrc;
|
||||
delete[] pDataHash;
|
||||
delete[] pDataHashBase64;
|
||||
|
||||
bResult = CryptDestroyHash(hHash);
|
||||
|
||||
return bResult;
|
||||
}
|
||||
11
DesktopEditor/xmlsec/test/windows_list_serts/test.pro
Normal file
11
DesktopEditor/xmlsec/test/windows_list_serts/test.pro
Normal file
@ -0,0 +1,11 @@
|
||||
QT -= core gui
|
||||
|
||||
TARGET = test
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
DEFINES -= UNICODE
|
||||
|
||||
SOURCES += main.cpp
|
||||
Reference in New Issue
Block a user