Commit a652f5d7 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWriter - fix smart-art

parent 1602843a
...@@ -1152,7 +1152,6 @@ void odf_drawing_context::set_hidden (bool bVal) ...@@ -1152,7 +1152,6 @@ void odf_drawing_context::set_hidden (bool bVal)
void odf_drawing_context::set_opacity(double percent_) void odf_drawing_context::set_opacity(double percent_)
{ {
if (!impl_->current_graphic_properties)return; if (!impl_->current_graphic_properties)return;
if (percent_ < 0.01) return;
switch(impl_->current_drawing_part_) switch(impl_->current_drawing_part_)
{ {
...@@ -1270,7 +1269,7 @@ void odf_drawing_context::set_solid_fill(std::wstring hexColor) ...@@ -1270,7 +1269,7 @@ void odf_drawing_context::set_solid_fill(std::wstring hexColor)
{ {
case Area: case Area:
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_color_ = hexColor; impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_color_ = hexColor;
impl_->current_graphic_properties->common_background_color_attlist_.fo_background_color_ = color(hexColor); //impl_->current_graphic_properties->common_background_color_attlist_.fo_background_color_ = color(hexColor); - default transparent
//последнее нужно - что если будут вводить текст - под текстом будет цвет фона (или он поменяется в полях текста) //последнее нужно - что если будут вводить текст - под текстом будет цвет фона (или он поменяется в полях текста)
if ((impl_->is_footer_ || impl_->is_header_ || impl_->is_background_) && if ((impl_->is_footer_ || impl_->is_header_ || impl_->is_background_) &&
......
...@@ -98,9 +98,6 @@ void OoxConverter::convert(PPTX::Logic::GraphicFrame *oox_graphic_frame) ...@@ -98,9 +98,6 @@ void OoxConverter::convert(PPTX::Logic::GraphicFrame *oox_graphic_frame)
{ {
if (!oox_graphic_frame)return; if (!oox_graphic_frame)return;
//----------------------------------------------------------------------------------
odf_context()->drawing_context()->start_drawing();
convert(&oox_graphic_frame->nvGraphicFramePr); convert(&oox_graphic_frame->nvGraphicFramePr);
convert(oox_graphic_frame->xfrm.GetPointer()); convert(oox_graphic_frame->xfrm.GetPointer());
...@@ -126,7 +123,6 @@ void OoxConverter::convert(PPTX::Logic::GraphicFrame *oox_graphic_frame) ...@@ -126,7 +123,6 @@ void OoxConverter::convert(PPTX::Logic::GraphicFrame *oox_graphic_frame)
{ {
OoxConverter::convert(oox_graphic_frame->element.GetElem().operator->()); OoxConverter::convert(oox_graphic_frame->element.GetElem().operator->());
} }
odf_context()->drawing_context()->end_drawing();
} }
void OoxConverter::convert(PPTX::Logic::NvGraphicFramePr *oox_framePr) void OoxConverter::convert(PPTX::Logic::NvGraphicFramePr *oox_framePr)
{ {
...@@ -194,7 +190,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) ...@@ -194,7 +190,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
if (type != SimpleTypes::shapetypeRect) if (type != SimpleTypes::shapetypeRect)
{ {
odf_context()->drawing_context()->start_drawing();
odf_context()->drawing_context()->start_shape(type); odf_context()->drawing_context()->start_shape(type);
convert(&oox_picture->spPr, oox_picture->style.GetPointer()); convert(&oox_picture->spPr, oox_picture->style.GetPointer());
...@@ -205,7 +200,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) ...@@ -205,7 +200,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
odf_context()->drawing_context()->end_area_properties(); odf_context()->drawing_context()->end_area_properties();
odf_context()->drawing_context()->end_shape(); odf_context()->drawing_context()->end_shape();
odf_context()->drawing_context()->end_drawing();
return; return;
} }
} }
...@@ -229,7 +223,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) ...@@ -229,7 +223,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
} }
} }
odf_context()->drawing_context()->start_drawing();
odf_context()->drawing_context()->start_image(odf_ref); odf_context()->drawing_context()->start_image(odf_ref);
{ {
double Width = 0, Height = 0; double Width = 0, Height = 0;
...@@ -257,7 +250,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) ...@@ -257,7 +250,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
} }
odf_context()->drawing_context()->end_image(); odf_context()->drawing_context()->end_image();
odf_context()->drawing_context()->end_drawing();
} }
void OoxConverter::convert(PPTX::Logic::SmartArt *oox_smart_art) void OoxConverter::convert(PPTX::Logic::SmartArt *oox_smart_art)
...@@ -265,7 +257,7 @@ void OoxConverter::convert(PPTX::Logic::SmartArt *oox_smart_art) ...@@ -265,7 +257,7 @@ void OoxConverter::convert(PPTX::Logic::SmartArt *oox_smart_art)
if (oox_smart_art == NULL) return; if (oox_smart_art == NULL) return;
if (oox_smart_art->id_data.IsInit() == false) return; if (oox_smart_art->id_data.IsInit() == false) return;
oox_smart_art->LoadDrawing(); oox_smart_art->LoadDrawing(current_document());
if (oox_smart_art->m_diag.IsInit()) if (oox_smart_art->m_diag.IsInit())
{ {
...@@ -283,7 +275,9 @@ void OoxConverter::convert(PPTX::Logic::SmartArt *oox_smart_art) ...@@ -283,7 +275,9 @@ void OoxConverter::convert(PPTX::Logic::SmartArt *oox_smart_art)
for (size_t i = 0; i < oox_smart_art->m_diag->SpTreeElems.size(); i++) for (size_t i = 0; i < oox_smart_art->m_diag->SpTreeElems.size(); i++)
{ {
odf_context()->drawing_context()->start_drawing();
convert(&oox_smart_art->m_diag->SpTreeElems[i]); convert(&oox_smart_art->m_diag->SpTreeElems[i]);
odf_context()->drawing_context()->end_drawing();
} }
odf_context()->drawing_context()->end_group(); odf_context()->drawing_context()->end_group();
...@@ -400,7 +394,9 @@ void OoxConverter::convert(PPTX::Logic::SpTree *oox_shape_tree) ...@@ -400,7 +394,9 @@ void OoxConverter::convert(PPTX::Logic::SpTree *oox_shape_tree)
for (size_t i = 0; i < oox_shape_tree->SpTreeElems.size(); i++) for (size_t i = 0; i < oox_shape_tree->SpTreeElems.size(); i++)
{ {
odf_context()->drawing_context()->start_drawing();
convert(oox_shape_tree->SpTreeElems[i].GetElem().operator->()); convert(oox_shape_tree->SpTreeElems[i].GetElem().operator->());
odf_context()->drawing_context()->end_drawing();
} }
odf_context()->drawing_context()->end_group(); odf_context()->drawing_context()->end_group();
...@@ -410,8 +406,6 @@ void OoxConverter::convert(PPTX::Logic::CxnSp *oox_connect) ...@@ -410,8 +406,6 @@ void OoxConverter::convert(PPTX::Logic::CxnSp *oox_connect)
{ {
if (oox_connect == NULL) return; if (oox_connect == NULL) return;
odf_context()->drawing_context()->start_drawing();
int type = SimpleTypes::shapetypeLine; int type = SimpleTypes::shapetypeLine;
if ( oox_connect->spPr.Geometry.is<PPTX::Logic::PrstGeom>() ) if ( oox_connect->spPr.Geometry.is<PPTX::Logic::PrstGeom>() )
...@@ -428,8 +422,6 @@ void OoxConverter::convert(PPTX::Logic::CxnSp *oox_connect) ...@@ -428,8 +422,6 @@ void OoxConverter::convert(PPTX::Logic::CxnSp *oox_connect)
convert(&oox_connect->nvCxnSpPr); convert(&oox_connect->nvCxnSpPr);
odf_context()->drawing_context()->end_shape(); odf_context()->drawing_context()->end_shape();
odf_context()->drawing_context()->end_drawing();
} }
void OoxConverter::convert(PPTX::Logic::Shape *oox_shape) void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
{ {
...@@ -437,7 +429,11 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape) ...@@ -437,7 +429,11 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
_CP_OPT(bool) bMasterPresentation = odf_context()->drawing_context()->get_presentation(); _CP_OPT(bool) bMasterPresentation = odf_context()->drawing_context()->get_presentation();
if (oox_shape->txXfrm.IsInit())
{
odf_context()->drawing_context()->start_group();
odf_context()->drawing_context()->start_drawing(); odf_context()->drawing_context()->start_drawing();
}
int type = 1000; //custom int type = 1000; //custom
...@@ -505,10 +501,10 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape) ...@@ -505,10 +501,10 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
odf_context()->drawing_context()->end_shape(); odf_context()->drawing_context()->end_shape();
odf_context()->drawing_context()->end_drawing();
if (oox_shape->txXfrm.IsInit()) if (oox_shape->txXfrm.IsInit())
{ {
odf_context()->drawing_context()->end_drawing();
odf_context()->drawing_context()->start_drawing(); odf_context()->drawing_context()->start_drawing();
odf_context()->drawing_context()->start_text_box(); odf_context()->drawing_context()->start_text_box();
...@@ -521,6 +517,8 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape) ...@@ -521,6 +517,8 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
odf_context()->drawing_context()->end_text_box(); odf_context()->drawing_context()->end_text_box();
odf_context()->drawing_context()->end_drawing(); odf_context()->drawing_context()->end_drawing();
odf_context()->drawing_context()->end_group();
} }
} }
...@@ -918,7 +916,7 @@ void OoxConverter::convert(PPTX::Logic::UniColor * color, std::wstring & hexStri ...@@ -918,7 +916,7 @@ void OoxConverter::convert(PPTX::Logic::UniColor * color, std::wstring & hexStri
if ((nARGB >> 24) != 0xff) if ((nARGB >> 24) != 0xff)
{ {
opacity = 100 - ((nARGB >> 24) /255.) * 100.; opacity = ((nARGB >> 24) /255.) * 100.;
} }
} }
else else
......
...@@ -355,6 +355,7 @@ public: ...@@ -355,6 +355,7 @@ public:
double getSystemDPI(); double getSystemDPI();
//....................................................................................................................... //.......................................................................................................................
virtual OOX::IFileContainer *current_document() = 0;
virtual cpdoccore::odf_writer::odf_conversion_context *odf_context() = 0; virtual cpdoccore::odf_writer::odf_conversion_context *odf_context() = 0;
virtual PPTX::Theme *oox_theme() = 0; virtual PPTX::Theme *oox_theme() = 0;
virtual PPTX::Logic::ClrMap *oox_clrMap() {return NULL;} virtual PPTX::Logic::ClrMap *oox_clrMap() {return NULL;}
......
...@@ -103,7 +103,16 @@ PPTX::Theme* DocxConverter::oox_theme() ...@@ -103,7 +103,16 @@ PPTX::Theme* DocxConverter::oox_theme()
else else
return NULL; return NULL;
} }
OOX::IFileContainer* DocxConverter::current_document()
{
if (oox_current_child_document)
return oox_current_child_document;
else
{
OOX::CDocument *oox_doc = docx_document->GetDocument();
return dynamic_cast<OOX::IFileContainer*>(oox_doc);
}
}
NSCommon::smart_ptr<OOX::File> DocxConverter::find_file_by_id(std::wstring sId) NSCommon::smart_ptr<OOX::File> DocxConverter::find_file_by_id(std::wstring sId)
{ {
OOX::CDocument *oox_doc = docx_document->GetDocument(); OOX::CDocument *oox_doc = docx_document->GetDocument();
...@@ -2705,9 +2714,12 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor) ...@@ -2705,9 +2714,12 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
int id = oox_anchor->m_oRelativeHeight->GetValue(); int id = oox_anchor->m_oRelativeHeight->GetValue();
odf_context()->drawing_context()->set_z_order(id); odf_context()->drawing_context()->set_z_order(id);
} }
OoxConverter::convert(oox_anchor->m_oDocPr.GetPointer()); OoxConverter::convert(oox_anchor->m_oDocPr.GetPointer());
convert(&oox_anchor->m_oGraphic); odf_context()->drawing_context()->start_drawing();
OoxConverter::convert(&oox_anchor->m_oGraphic);
odf_context()->drawing_context()->end_drawing();
odf_context()->drawing_context()->check_anchor(); odf_context()->drawing_context()->check_anchor();
} }
...@@ -2739,7 +2751,10 @@ void DocxConverter::convert(OOX::Drawing::CInline *oox_inline) ...@@ -2739,7 +2751,10 @@ void DocxConverter::convert(OOX::Drawing::CInline *oox_inline)
odt_context->drawing_context()->set_vertical_pos(1);//middle odt_context->drawing_context()->set_vertical_pos(1);//middle
OoxConverter::convert(oox_inline->m_oDocPr.GetPointer()); OoxConverter::convert(oox_inline->m_oDocPr.GetPointer());
convert(&oox_inline->m_oGraphic);
odf_context()->drawing_context()->start_drawing();
OoxConverter::convert(&oox_inline->m_oGraphic);
odf_context()->drawing_context()->end_drawing();
} }
void DocxConverter::convert(SimpleTypes::CHexColor<> *color, void DocxConverter::convert(SimpleTypes::CHexColor<> *color,
......
...@@ -147,6 +147,7 @@ namespace Oox2Odf ...@@ -147,6 +147,7 @@ namespace Oox2Odf
virtual void convertDocument(); virtual void convertDocument();
virtual void write(const std::wstring & path); virtual void write(const std::wstring & path);
virtual OOX::IFileContainer *current_document();
virtual odf_writer::odf_conversion_context *odf_context(); virtual odf_writer::odf_conversion_context *odf_context();
virtual PPTX::Theme *oox_theme(); virtual PPTX::Theme *oox_theme();
virtual std::wstring find_link_by_id (std::wstring sId, int t); virtual std::wstring find_link_by_id (std::wstring sId, int t);
......
...@@ -127,7 +127,15 @@ PPTX::Logic::ClrMap* PptxConverter::oox_clrMap() ...@@ -127,7 +127,15 @@ PPTX::Logic::ClrMap* PptxConverter::oox_clrMap()
{ {
return current_clrMap; return current_clrMap;
} }
OOX::IFileContainer* PptxConverter::current_document()
{
if (oox_current_child_document)
return oox_current_child_document;
else if (current_slide)
return current_slide;
else
return pptx_document;
}
NSCommon::smart_ptr<OOX::File> PptxConverter::find_file_by_id(std::wstring sId) NSCommon::smart_ptr<OOX::File> PptxConverter::find_file_by_id(std::wstring sId)
{ {
smart_ptr<OOX::File> oFile; smart_ptr<OOX::File> oFile;
...@@ -966,6 +974,8 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS ...@@ -966,6 +974,8 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS
smart_ptr<PPTX::WrapperWritingElement> pElem = oox_slide->spTree.SpTreeElems[i].GetElem(); smart_ptr<PPTX::WrapperWritingElement> pElem = oox_slide->spTree.SpTreeElems[i].GetElem();
smart_ptr<PPTX::Logic::Shape> pShape = pElem.smart_dynamic_cast<PPTX::Logic::Shape>(); smart_ptr<PPTX::Logic::Shape> pShape = pElem.smart_dynamic_cast<PPTX::Logic::Shape>();
odf_context()->drawing_context()->start_drawing();
if (pShape.IsInit()) if (pShape.IsInit())
{ {
if (pShape->nvSpPr.nvPr.ph.is_init()) if (pShape->nvSpPr.nvPr.ph.is_init())
...@@ -1039,6 +1049,7 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS ...@@ -1039,6 +1049,7 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS
{ {
OoxConverter::convert(pElem.operator->()); OoxConverter::convert(pElem.operator->());
} }
odf_context()->drawing_context()->end_drawing();
} }
convert(oox_slide->controls.GetPointer()); convert(oox_slide->controls.GetPointer());
} }
......
...@@ -97,6 +97,7 @@ namespace Oox2Odf ...@@ -97,6 +97,7 @@ namespace Oox2Odf
virtual void convertDocument(); virtual void convertDocument();
virtual void write(const std::wstring & path); virtual void write(const std::wstring & path);
virtual OOX::IFileContainer *current_document();
virtual odf_writer::odf_conversion_context *odf_context(); virtual odf_writer::odf_conversion_context *odf_context();
virtual PPTX::Theme *oox_theme(); virtual PPTX::Theme *oox_theme();
virtual PPTX::Logic::ClrMap *oox_clrMap(); virtual PPTX::Logic::ClrMap *oox_clrMap();
......
...@@ -94,6 +94,15 @@ PPTX::Theme* XlsxConverter::oox_theme() ...@@ -94,6 +94,15 @@ PPTX::Theme* XlsxConverter::oox_theme()
else else
return NULL; return NULL;
} }
OOX::IFileContainer* XlsxConverter::current_document()
{
if (xlsx_current_container)
return xlsx_current_container;
else if (oox_current_child_document)
return oox_current_child_document;
else
return NULL;
}
smart_ptr<OOX::File> XlsxConverter::find_file_by_id(std::wstring sId) smart_ptr<OOX::File> XlsxConverter::find_file_by_id(std::wstring sId)
{ {
smart_ptr<OOX::File> oFile; smart_ptr<OOX::File> oFile;
...@@ -1718,7 +1727,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor) ...@@ -1718,7 +1727,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor)
if (oox_anchor->m_oExt.IsInit()) if (oox_anchor->m_oExt.IsInit())
{ {
} }
odf_context()->drawing_context()->start_drawing();
OoxConverter::convert(oox_anchor->m_oElement.GetPointer()); OoxConverter::convert(oox_anchor->m_oElement.GetPointer());
odf_context()->drawing_context()->end_drawing();
} }
void XlsxConverter::convert(OOX::Spreadsheet::CDrawing *oox_drawing) void XlsxConverter::convert(OOX::Spreadsheet::CDrawing *oox_drawing)
......
...@@ -130,6 +130,7 @@ namespace Oox2Odf ...@@ -130,6 +130,7 @@ namespace Oox2Odf
virtual void convertDocument(); virtual void convertDocument();
virtual void write(const std::wstring & path); virtual void write(const std::wstring & path);
virtual OOX::IFileContainer *current_document();
virtual odf_writer::odf_conversion_context *odf_context(); virtual odf_writer::odf_conversion_context *odf_context();
virtual PPTX::Theme *oox_theme(); virtual PPTX::Theme *oox_theme();
virtual std::wstring find_link_by_id (std::wstring sId, int t); virtual std::wstring find_link_by_id (std::wstring sId, int t);
......
...@@ -48,17 +48,15 @@ namespace PPTX ...@@ -48,17 +48,15 @@ namespace PPTX
{ {
namespace Logic namespace Logic
{ {
void SmartArt::LoadDrawing(NSBinPptxRW::CBinaryFileWriter* pWriter) bool SmartArt::LoadDrawing(OOX::IFileContainer* pRels)
{ {
if (m_diag.IsInit()) if (m_diag.IsInit())
return ; return true;
OOX::IFileContainer* pRels = NULL; if(id_data.IsInit() == false) return false;
if (pWriter) if (pRels == NULL) return false;
{
if (pWriter->m_pCurrentContainer->is_init()) bool result = false;
pRels = pWriter->m_pCurrentContainer->operator ->();
}
smart_ptr<OOX::File> oFileData; smart_ptr<OOX::File> oFileData;
smart_ptr<OOX::File> oFileDrawing; smart_ptr<OOX::File> oFileDrawing;
...@@ -67,15 +65,12 @@ namespace PPTX ...@@ -67,15 +65,12 @@ namespace PPTX
OOX::CDiagramData* pDiagramData = NULL; OOX::CDiagramData* pDiagramData = NULL;
OOX::CDiagramDrawing* pDiagramDrawing = NULL; OOX::CDiagramDrawing* pDiagramDrawing = NULL;
if(id_data.IsInit()) oFileData = pRels->Find(*id_data);
{
if (parentFileIs<OOX::IFileContainer>()) oFileData = parentFileAs<OOX::IFileContainer>().Find(*id_data);
else if (pRels != NULL) oFileData = pRels->Find(*id_data);
}
if (oFileData.IsInit()) if (oFileData.IsInit())
{ {
pDiagramData = dynamic_cast<OOX::CDiagramData*>(oFileData.operator->()); pDiagramData = dynamic_cast<OOX::CDiagramData*>(oFileData.operator->());
if (pDiagramData) result = true; // это smart art ..есть у него drawing или нет - неважно
if ((pDiagramData) && (pDiagramData->m_oExtLst.IsInit())) if ((pDiagramData) && (pDiagramData->m_oExtLst.IsInit()))
{ {
...@@ -131,6 +126,25 @@ namespace PPTX ...@@ -131,6 +126,25 @@ namespace PPTX
{ {
//parse pDiagramData !! //parse pDiagramData !!
} }
return true;
}
void SmartArt::LoadDrawing(NSBinPptxRW::CBinaryFileWriter* pWriter)
{
if (m_diag.IsInit())
return ;
OOX::IFileContainer & pRelsPPTX = parentFileAs<OOX::IFileContainer>();
OOX::IFileContainer * pRels = NULL;
if (pWriter)
{
if (pWriter->m_pCurrentContainer->is_init())
pRels = pWriter->m_pCurrentContainer->operator ->();
}
bool result = LoadDrawing(&pRelsPPTX);
if (!result)
result = LoadDrawing( pRels );
} }
void SmartArt::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const void SmartArt::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{ {
......
...@@ -115,6 +115,7 @@ namespace PPTX ...@@ -115,6 +115,7 @@ namespace PPTX
public: public:
void LoadDrawing(NSBinPptxRW::CBinaryFileWriter* pWriter = NULL); void LoadDrawing(NSBinPptxRW::CBinaryFileWriter* pWriter = NULL);
bool LoadDrawing(OOX::IFileContainer* pRels);
}; };
class ChartRec : public WrapperWritingElement class ChartRec : public WrapperWritingElement
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment