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)
void odf_drawing_context::set_opacity(double percent_)
{
if (!impl_->current_graphic_properties)return;
if (percent_ < 0.01) return;
switch(impl_->current_drawing_part_)
{
......@@ -1270,7 +1269,7 @@ void odf_drawing_context::set_solid_fill(std::wstring hexColor)
{
case Area:
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_) &&
......
......@@ -98,9 +98,6 @@ void OoxConverter::convert(PPTX::Logic::GraphicFrame *oox_graphic_frame)
{
if (!oox_graphic_frame)return;
//----------------------------------------------------------------------------------
odf_context()->drawing_context()->start_drawing();
convert(&oox_graphic_frame->nvGraphicFramePr);
convert(oox_graphic_frame->xfrm.GetPointer());
......@@ -126,7 +123,6 @@ void OoxConverter::convert(PPTX::Logic::GraphicFrame *oox_graphic_frame)
{
OoxConverter::convert(oox_graphic_frame->element.GetElem().operator->());
}
odf_context()->drawing_context()->end_drawing();
}
void OoxConverter::convert(PPTX::Logic::NvGraphicFramePr *oox_framePr)
{
......@@ -194,7 +190,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
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());
......@@ -205,7 +200,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
odf_context()->drawing_context()->end_area_properties();
odf_context()->drawing_context()->end_shape();
odf_context()->drawing_context()->end_drawing();
return;
}
}
......@@ -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);
{
double Width = 0, Height = 0;
......@@ -257,7 +250,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
}
odf_context()->drawing_context()->end_image();
odf_context()->drawing_context()->end_drawing();
}
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->id_data.IsInit() == false) return;
oox_smart_art->LoadDrawing();
oox_smart_art->LoadDrawing(current_document());
if (oox_smart_art->m_diag.IsInit())
{
......@@ -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++)
{
convert(&oox_smart_art->m_diag->SpTreeElems[i]);
odf_context()->drawing_context()->start_drawing();
convert(&oox_smart_art->m_diag->SpTreeElems[i]);
odf_context()->drawing_context()->end_drawing();
}
odf_context()->drawing_context()->end_group();
......@@ -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++)
{
convert(oox_shape_tree->SpTreeElems[i].GetElem().operator->());
odf_context()->drawing_context()->start_drawing();
convert(oox_shape_tree->SpTreeElems[i].GetElem().operator->());
odf_context()->drawing_context()->end_drawing();
}
odf_context()->drawing_context()->end_group();
......@@ -410,105 +406,105 @@ void OoxConverter::convert(PPTX::Logic::CxnSp *oox_connect)
{
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>() )
{
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);
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);
odf_context()->drawing_context()->end_shape();
odf_context()->drawing_context()->end_drawing();
}
void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
{
if (oox_shape == NULL) return;
_CP_OPT(bool) bMasterPresentation = odf_context()->drawing_context()->get_presentation();
odf_context()->drawing_context()->start_drawing();
int type = 1000; //custom
if (oox_shape->txXfrm.IsInit())
{
odf_context()->drawing_context()->start_group();
odf_context()->drawing_context()->start_drawing();
}
int type = 1000; //custom
if (oox_shape->spPr.Geometry.is_init())
if (oox_shape->spPr.Geometry.is_init())
{
if ( oox_shape->spPr.Geometry.is<PPTX::Logic::PrstGeom>() )
{
if ( oox_shape->spPr.Geometry.is<PPTX::Logic::PrstGeom>() )
{
const PPTX::Logic::PrstGeom& prstGeom = oox_shape->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
SimpleTypes::CShapeType<> preset;
preset.FromString(prstGeom.prst.get());
type = preset.GetValue();
}
const PPTX::Logic::PrstGeom& prstGeom = oox_shape->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
SimpleTypes::CShapeType<> preset;
preset.FromString(prstGeom.prst.get());
type = preset.GetValue();
}
if (type == SimpleTypes::shapetypeRect && (oox_shape->txBody.IsInit() || oox_shape->oTextBoxShape.IsInit()))
type = 2000;
if (type == SimpleTypes::shapetypeRect && (oox_shape->txBody.IsInit() || oox_shape->oTextBoxShape.IsInit()))
type = 2000;
if (type == 2000)
if (type == 2000)
{
PPTX::Logic::BodyPr *bodyPr = NULL;
if (oox_shape->txBody.IsInit()) bodyPr = oox_shape->txBody->bodyPr.GetPointer();
else bodyPr = oox_shape->oTextBoxBodyPr.GetPointer();
if (bodyPr && bodyPr->fromWordArt.get_value_or(false))
{
PPTX::Logic::BodyPr *bodyPr = NULL;
if (oox_shape->txBody.IsInit()) bodyPr = oox_shape->txBody->bodyPr.GetPointer();
else bodyPr = oox_shape->oTextBoxBodyPr.GetPointer();
if (bodyPr && bodyPr->fromWordArt.get_value_or(false))
{
int wordart_type = convert(bodyPr->prstTxWarp.GetPointer());
if (wordart_type > 0) type = wordart_type;
}
int wordart_type = convert(bodyPr->prstTxWarp.GetPointer());
if (wordart_type > 0) type = wordart_type;
}
}
else if (oox_shape->nvSpPr.nvPr.ph.is_init())
{
type = 2000;
}
}
else if (oox_shape->nvSpPr.nvPr.ph.is_init())
{
type = 2000;
}
if (type < 0)return;
if (type < 0)return;
//-----------------------------------------------------------------------------
odf_context()->drawing_context()->start_shape(type);
convert(&oox_shape->spPr, oox_shape->style.GetPointer());
odf_context()->drawing_context()->start_shape(type);
convert(&oox_shape->spPr, oox_shape->style.GetPointer());
convert(&oox_shape->nvSpPr);
convert(&oox_shape->nvSpPr);
if (oox_shape->txXfrm.IsInit() == false)
if (oox_shape->txXfrm.IsInit() == false)
{
if (oox_shape->oTextBoxShape.IsInit()) //docx sdt
{
if (oox_shape->oTextBoxShape.IsInit()) //docx sdt
DocxConverter *docx_converter = dynamic_cast<DocxConverter*>(this);
if (docx_converter)
{
DocxConverter *docx_converter = dynamic_cast<DocxConverter*>(this);
if (docx_converter)
{
odf_context()->start_text_context();
docx_converter->convert(oox_shape->oTextBoxShape.GetPointer());
odf_context()->drawing_context()->set_text( odf_context()->text_context());
odf_context()->start_text_context();
docx_converter->convert(oox_shape->oTextBoxShape.GetPointer());
odf_context()->drawing_context()->set_text( odf_context()->text_context());
convert(oox_shape->oTextBoxBodyPr.GetPointer());
convert(oox_shape->oTextBoxBodyPr.GetPointer());
if (oox_shape->style.IsInit())
convert(&oox_shape->style->fontRef);
odf_context()->end_text_context();
}
if (oox_shape->style.IsInit())
convert(&oox_shape->style->fontRef);
odf_context()->end_text_context();
}
else
convert(oox_shape->txBody.GetPointer(), oox_shape->style.GetPointer());
}
else
convert(oox_shape->txBody.GetPointer(), oox_shape->style.GetPointer());
}
odf_context()->drawing_context()->end_shape();
odf_context()->drawing_context()->end_drawing();
if (oox_shape->txXfrm.IsInit())
{
odf_context()->drawing_context()->end_drawing();
odf_context()->drawing_context()->start_drawing();
odf_context()->drawing_context()->start_text_box();
......@@ -521,6 +517,8 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
odf_context()->drawing_context()->end_text_box();
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
if ((nARGB >> 24) != 0xff)
{
opacity = 100 - ((nARGB >> 24) /255.) * 100.;
opacity = ((nARGB >> 24) /255.) * 100.;
}
}
else
......
......@@ -355,10 +355,11 @@ public:
double getSystemDPI();
//.......................................................................................................................
virtual OOX::IFileContainer *current_document() = 0;
virtual cpdoccore::odf_writer::odf_conversion_context *odf_context() = 0;
virtual PPTX::Theme *oox_theme() = 0;
virtual PPTX::Logic::ClrMap *oox_clrMap() {return NULL;}
virtual std::wstring find_link_by_id(std::wstring sId, int t) = 0;
virtual NSCommon::smart_ptr<OOX::File> find_file_by_id(std::wstring sId) = 0;
......
......@@ -103,7 +103,16 @@ PPTX::Theme* DocxConverter::oox_theme()
else
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)
{
OOX::CDocument *oox_doc = docx_document->GetDocument();
......@@ -2705,9 +2714,12 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
int id = oox_anchor->m_oRelativeHeight->GetValue();
odf_context()->drawing_context()->set_z_order(id);
}
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();
}
......@@ -2737,9 +2749,12 @@ void DocxConverter::convert(OOX::Drawing::CInline *oox_inline)
odt_context->drawing_context()->set_vertical_rel(2);//line
odt_context->drawing_context()->set_vertical_pos(1);//middle
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,
......
......@@ -147,6 +147,7 @@ namespace Oox2Odf
virtual void convertDocument();
virtual void write(const std::wstring & path);
virtual OOX::IFileContainer *current_document();
virtual odf_writer::odf_conversion_context *odf_context();
virtual PPTX::Theme *oox_theme();
virtual std::wstring find_link_by_id (std::wstring sId, int t);
......
......@@ -127,7 +127,15 @@ PPTX::Logic::ClrMap* PptxConverter::oox_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)
{
smart_ptr<OOX::File> oFile;
......@@ -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::Logic::Shape> pShape = pElem.smart_dynamic_cast<PPTX::Logic::Shape>();
odf_context()->drawing_context()->start_drawing();
if (pShape.IsInit())
{
if (pShape->nvSpPr.nvPr.ph.is_init())
......@@ -1039,6 +1049,7 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS
{
OoxConverter::convert(pElem.operator->());
}
odf_context()->drawing_context()->end_drawing();
}
convert(oox_slide->controls.GetPointer());
}
......
......@@ -97,10 +97,11 @@ namespace Oox2Odf
virtual void convertDocument();
virtual void write(const std::wstring & path);
virtual OOX::IFileContainer *current_document();
virtual odf_writer::odf_conversion_context *odf_context();
virtual PPTX::Theme *oox_theme();
virtual PPTX::Logic::ClrMap *oox_clrMap();
virtual std::wstring find_link_by_id (std::wstring sId, int t);
virtual NSCommon::smart_ptr<OOX::File> find_file_by_id (std::wstring sId);
......
......@@ -94,6 +94,15 @@ PPTX::Theme* XlsxConverter::oox_theme()
else
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> oFile;
......@@ -1718,7 +1727,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor)
if (oox_anchor->m_oExt.IsInit())
{
}
OoxConverter::convert(oox_anchor->m_oElement.GetPointer());
odf_context()->drawing_context()->start_drawing();
OoxConverter::convert(oox_anchor->m_oElement.GetPointer());
odf_context()->drawing_context()->end_drawing();
}
void XlsxConverter::convert(OOX::Spreadsheet::CDrawing *oox_drawing)
......
......@@ -130,6 +130,7 @@ namespace Oox2Odf
virtual void convertDocument();
virtual void write(const std::wstring & path);
virtual OOX::IFileContainer *current_document();
virtual odf_writer::odf_conversion_context *odf_context();
virtual PPTX::Theme *oox_theme();
virtual std::wstring find_link_by_id (std::wstring sId, int t);
......
......@@ -48,17 +48,15 @@ namespace PPTX
{
namespace Logic
{
void SmartArt::LoadDrawing(NSBinPptxRW::CBinaryFileWriter* pWriter)
bool SmartArt::LoadDrawing(OOX::IFileContainer* pRels)
{
if (m_diag.IsInit())
return ;
return true;
OOX::IFileContainer* pRels = NULL;
if (pWriter)
{
if (pWriter->m_pCurrentContainer->is_init())
pRels = pWriter->m_pCurrentContainer->operator ->();
}
if(id_data.IsInit() == false) return false;
if (pRels == NULL) return false;
bool result = false;
smart_ptr<OOX::File> oFileData;
smart_ptr<OOX::File> oFileDrawing;
......@@ -67,15 +65,12 @@ namespace PPTX
OOX::CDiagramData* pDiagramData = NULL;
OOX::CDiagramDrawing* pDiagramDrawing = NULL;
if(id_data.IsInit())
{
if (parentFileIs<OOX::IFileContainer>()) oFileData = parentFileAs<OOX::IFileContainer>().Find(*id_data);
else if (pRels != NULL) oFileData = pRels->Find(*id_data);
}
oFileData = pRels->Find(*id_data);
if (oFileData.IsInit())
{
pDiagramData = dynamic_cast<OOX::CDiagramData*>(oFileData.operator->());
if (pDiagramData) result = true; // это smart art ..есть у него drawing или нет - неважно
if ((pDiagramData) && (pDiagramData->m_oExtLst.IsInit()))
{
......@@ -131,6 +126,25 @@ namespace PPTX
{
//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
{
......
......@@ -115,6 +115,7 @@ namespace PPTX
public:
void LoadDrawing(NSBinPptxRW::CBinaryFileWriter* pWriter = NULL);
bool LoadDrawing(OOX::IFileContainer* pRels);
};
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