diff options
author | sushil_shinde <sushil.shinde@synerzip.com> | 2013-10-21 16:19:50 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-11-11 11:19:17 +0100 |
commit | 7944301424aac0943e4ecc0410f495b210ad3b79 (patch) | |
tree | 6b92214b6433ebd7207e70c1c4fdcb809b9f5d39 | |
parent | 768608c4cbc464bff50de8e83eee3eb54bf42f2d (diff) |
w:pict element was wrongly exported as child of w:rPr element.
-added postpone method for vml export in docxattributeoutput
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/6366
Change-Id: I37586447547e2e09028f7ae5009bcfaa87a35678
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/TestVMLData.docx | bin | 0 -> 50255 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 8 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 89 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 13 |
4 files changed, 82 insertions, 28 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/TestVMLData.docx b/sw/qa/extras/ooxmlexport/data/TestVMLData.docx Binary files differnew file mode 100644 index 000000000000..a2f89b146c7e --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/TestVMLData.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index ecbabb45e5ac..c19a70aa61e8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -1580,6 +1580,14 @@ DECLARE_OOXML_TEST(testPgMargin, "testPgMargin.docx") assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgMar", "left", "1440"); } +DECLARE_OOXML_TEST(testVMLData, "TestVMLData.docx") +{ + // The problem was exporter was exporting vml data for shape in w:rPr element. + // vml data shoud not come under w:rPr element. + xmlDocPtr pXmlDoc = parseExport("word/header1.xml"); + CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:hdr/w:p/w:r/w:pict/v:shape", "stroked").match("f")); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 2ff5e613b2a9..19f80e7dae1f 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1038,6 +1038,9 @@ void DocxAttributeOutput::StartRunProperties() OSL_ASSERT( m_postponedDiagram == NULL ); m_postponedDiagram = new std::list< PostponedDiagram >; + + OSL_ASSERT( m_postponedVMLDrawing == NULL ); + m_postponedVMLDrawing = new std::list< PostponedVMLDrawing >; } void DocxAttributeOutput::InitCollectedRunProperties() @@ -1155,6 +1158,9 @@ void DocxAttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData ) //We need to write w:drawing tag after the w:rPr. WritePostponedChart(); + //We need to write w:drawing tag after the w:rPr. + WritePostponedVMLDrawing(); + // merge the properties _before_ the run text (strictly speaking, just // after the start of the run) m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND ); @@ -3220,6 +3226,55 @@ void DocxAttributeOutput::WritePostponedMath() m_postponedMath = NULL; } +/* + * Write w:pict hierarchy end element of w:rPr tag. + */ +void DocxAttributeOutput::WritePostponedVMLDrawing() +{ + if(m_postponedVMLDrawing == NULL) + return; + + for( std::list< PostponedVMLDrawing >::iterator it = m_postponedVMLDrawing->begin(); + it != m_postponedVMLDrawing->end(); + ++it ) + { + WriteVMLDrawing(it->object, *(it->frame), *(it->vpt)); + } + delete m_postponedVMLDrawing; + m_postponedVMLDrawing = NULL; +} + +void DocxAttributeOutput::WriteVMLDrawing( const SdrObject* sdrObj, const SwFrmFmt& rFrmFmt,const Point& rNdTopLeft ) +{ + bool bSwapInPage = false; + if ( !(sdrObj)->GetPage() ) + { + if ( SdrModel* pModel = m_rExport.pDoc->GetDrawModel() ) + { + if ( SdrPage *pPage = pModel->GetPage( 0 ) ) + { + bSwapInPage = true; + const_cast< SdrObject* >( sdrObj )->SetPage( pPage ); + } + } + } + + m_pSerializer->startElementNS( XML_w, XML_pict, FSEND ); + + // See WinwordAnchoring::SetAnchoring(), these are not part of the SdrObject, have to be passed around manually. + + SwFmtHoriOrient rHoriOri = (rFrmFmt).GetHoriOrient(); + SwFmtVertOrient rVertOri = (rFrmFmt).GetVertOrient(); + m_rExport.VMLExporter().AddSdrObject( *(sdrObj), + rHoriOri.GetHoriOrient(), rVertOri.GetVertOrient(), + rHoriOri.GetRelationOrient(), + rVertOri.GetRelationOrient(), (&rNdTopLeft) ); + m_pSerializer->endElementNS( XML_w, XML_pict ); + + if ( bSwapInPage ) + const_cast< SdrObject* >( sdrObj )->SetPage( 0 ); +} + void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Point& rNdTopLeft ) { m_pSerializer->mark(); @@ -3257,35 +3312,12 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Po } else { - bool bSwapInPage = false; - if ( !pSdrObj->GetPage() ) - { - if ( SdrModel* pModel = m_rExport.pDoc->GetDrawModel() ) - { - if ( SdrPage *pPage = pModel->GetPage( 0 ) ) - { - bSwapInPage = true; - const_cast< SdrObject* >( pSdrObj )->SetPage( pPage ); - } - } + if ( m_postponedVMLDrawing == NULL ) + WriteVMLDrawing( pSdrObj, rFrame.GetFrmFmt(), rNdTopLeft); + else // we are writing out attributes, but w:pict should not be inside w:rPr, + { // so write it out later + m_postponedVMLDrawing->push_back( PostponedVMLDrawing( pSdrObj, &(rFrame.GetFrmFmt()), &rNdTopLeft ) ); } - - m_pSerializer->startElementNS( XML_w, XML_pict, - FSEND ); - - // See WinwordAnchoring::SetAnchoring(), these are not part of the SdrObject, have to be passed around manually. - const SwFrmFmt& rFrmFmt = rFrame.GetFrmFmt(); - SwFmtHoriOrient rHoriOri = rFrmFmt.GetHoriOrient(); - SwFmtVertOrient rVertOri = rFrmFmt.GetVertOrient(); - m_rExport.VMLExporter().AddSdrObject( *pSdrObj, - rHoriOri.GetHoriOrient(), rVertOri.GetVertOrient(), - rHoriOri.GetRelationOrient(), - rVertOri.GetRelationOrient(), &rNdTopLeft ); - - m_pSerializer->endElementNS( XML_w, XML_pict ); - - if ( bSwapInPage ) - const_cast< SdrObject* >( pSdrObj )->SetPage( 0 ); } } } @@ -6120,6 +6152,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_startedHyperlink( false ), m_postponedGraphic( NULL ), m_postponedDiagram( NULL ), + m_postponedVMLDrawing(NULL), m_postponedMath( NULL ), m_postponedChart( NULL ), pendingPlaceholder( NULL ), diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 9cb14f5a97d5..02f7761e2404 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -371,6 +371,8 @@ private: /// writes a diagram void WriteDiagram(const SdrObject* sdrObject, const Size& size); + /// writes VML data + void WriteVMLDrawing( const SdrObject* sdrObj, const SwFrmFmt& rFrmFmt,const Point& rNdTopLeft ); void InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); void StartTable( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); void StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); @@ -637,6 +639,7 @@ private: void WritePostponedMath(); void WritePostponedDiagram(); void WritePostponedChart(); + void WritePostponedVMLDrawing(); void WriteCommentRanges(); void StartField_Impl( FieldInfos& rInfos, bool bWriteRun = sal_False ); @@ -736,6 +739,16 @@ private: Size size; }; std::list< PostponedDiagram >* m_postponedDiagram; + + struct PostponedVMLDrawing + { + PostponedVMLDrawing( const SdrObject* sdrObj, const SwFrmFmt* frm, const Point* pt ) : object( sdrObj ), frame( frm ), vpt( pt ) {}; + const SdrObject* object; + const SwFrmFmt* frame; + const Point* vpt; + }; + std::list< PostponedVMLDrawing >* m_postponedVMLDrawing; + const SwOLENode* m_postponedMath; const SdrObject* m_postponedChart; Size m_postponedChartSize; |