diff options
author | Rajashri <rajashri.udhoji@synerzip.com> | 2014-05-17 18:53:52 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-05-21 11:56:38 +0200 |
commit | b349d2483e1fe64316d87b55d0b3b4c8f2293e2e (patch) | |
tree | 31683239d95ece5cc5e458fca0a40397c5a24b2d /sw | |
parent | cae2376f6fb8451d7b6a9e68edf4b97627d8fde4 (diff) |
fdo#78663 : Corrupt: 2007 WordArt whithin a Drawing tool
A file contains a 2007 word art within a drawing tool.
In Original file, the xml structure is as below:
sample xml:
<p> <r> <ac> <drawing> <txbx> <txbxContent> .. <pict> </pict> </txbxContent></txbx> </drawing> </ac> </r> </p>
LO was preserving this as :
<p> <r> <ac> <drawing> <txbx> <txbxContent> .. <drawing> <txbx> <txbxContent> ..
</txbxContent></txbx> </drawing> .. </txbxContent></txbx> </drawing> </ac> </r> </p>
Now after this fix, If there is a custom shape within a text box, then we should postpone it and write it in
a separate run.
This approach is followed on the fact that LO writes nested TextBoxes in separate run.
NOTE1 :Due to this fix, xpath related to the below UT needs to be updated.
testFdo76249 in ooxmlsdrexport.cxx
NOTE2: In docxsdrexport.cxx : 'm_bIsInDMLTextFrame' is no more required.
For adding LockedCanvas, we only need to check if the property exists in the property set.
Therefoew removing the above bool variable.
Reviewed on:
https://gerrit.libreoffice.org/9392
Change-Id: I00e94712e912ad1977fcb65a945fefb927795d77
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/testWordArtWithinDraingtool.docx | bin | 0 -> 45324 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 19 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 41 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 10 |
6 files changed, 67 insertions, 8 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/testWordArtWithinDraingtool.docx b/sw/qa/extras/ooxmlexport/data/testWordArtWithinDraingtool.docx Binary files differnew file mode 100644 index 000000000000..c860828fa8df --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/testWordArtWithinDraingtool.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 22b144e0f4b6..7a69e6769e5f 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -3437,6 +3437,25 @@ DECLARE_OOXMLEXPORT_TEST(testFdo78651, "fdo78651.docx") // ensure that there are only two tables assertXPath(pXmlDoc, "//w:tbl", 2); } +DECLARE_OOXMLEXPORT_TEST(testWordArtWithinDraingtool, "testWordArtWithinDraingtool.docx") +{ +/* * Within a file, there is a 2007 wordArt enclosed in a drawing tool + * LO was exporting it as below: + * Sample XML as in Original file: + * <p> <r> <ac> <drawing> <txbx> <txbxContent> .. <pict> </pict> </txbxContent></txbx> </drawing> </ac> </r> </p> + * After RT : + * <p> <r> <ac> <drawing> <txbx> <txbxContent> .. <drawing> <txbx> <txbxContent> .. </txbxContent></txbx> </drawing> .. </txbxContent></txbx> </drawing> </ac> </r> </p> + * Expected : As there is nesting of a 2007 Word Art within a draing tool, then can be separated in two different runs. + * */ + + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[2]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:txbx[1]/w:txbxContent[1]",1); + assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[2]/mc:AlternateContent[1]/mc:Fallback[1]/w:pict[1]/v:rect[1]/v:textbox[1]/w:txbxContent[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:txbx[1]/w:txbxContent[1]",1); + assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[3]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:txbx[1]",1); + assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[4]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:txbx[1]/w:txbxContent[1]",1); +} #endif diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx index 21eff8e09ac2..fc5c8d78c66b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx @@ -1017,7 +1017,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo76249, "fdo76249.docx") xmlDocPtr pXmlDoc = parseExport("word/document.xml"); if (!pXmlDoc) return; - assertXPath(pXmlDoc, "//mc:Choice/w:drawing//w:txbxContent//w:drawing//lc:lockedCanvas", 1); + assertXPath(pXmlDoc, "//mc:Choice[2]/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/lc:lockedCanvas[1]",1); } DECLARE_OOXMLEXPORT_TEST(testFdo76979, "fdo76979.docx") diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 9e3bcd710b62..96602c3ff468 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -297,8 +297,11 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT ++m_nTextFrameLevel; if( m_nTextFrameLevel == 1 ) { + assert(!m_postponedCustomShape); + m_postponedCustomShape = new std::list< PostponedDrawing >; for (size_t nIndex = 0; nIndex < m_aFramesOfParagraph.size(); ++nIndex) { + m_bParagraphFrameOpen = true; sw::Frame aFrame = m_aFramesOfParagraph[nIndex]; m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); @@ -352,7 +355,16 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT m_pSerializer->endElementNS(XML_mc, XML_AlternateContent); m_pSerializer->endElementNS( XML_w, XML_r ); + m_bParagraphFrameOpen = false; } + if (m_postponedCustomShape) + { + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); + WritePostponedCustomShape(); + m_pSerializer->endElementNS( XML_w, XML_r ); + } + delete m_postponedCustomShape; + m_postponedCustomShape = NULL; m_aFramesOfParagraph.clear(); } @@ -4207,6 +4219,24 @@ void DocxAttributeOutput::WritePostponedVMLDrawing() m_postponedVMLDrawing = NULL; } +void DocxAttributeOutput::WritePostponedCustomShape() +{ + if(m_postponedCustomShape == NULL) + return; + + for( std::list< PostponedDrawing >::iterator it = m_postponedCustomShape->begin(); + it != m_postponedCustomShape->end(); + ++it ) + { + if ( IsAlternateContentChoiceOpen() ) + m_rExport.SdrExporter().writeDMLDrawing(it->object, (it->frame), m_anchorId++); + else + m_rExport.SdrExporter().writeDMLAndVMLDrawing(it->object, *(it->frame), *(it->point), m_anchorId++); + } + delete m_postponedCustomShape; + m_postponedCustomShape = NULL; +} + void DocxAttributeOutput::WritePostponedDMLDrawing() { if(m_postponedDMLDrawing == NULL) @@ -4264,6 +4294,8 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Po } else { + uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pSdrObj)->getUnoShape(), uno::UNO_QUERY_THROW); + OUString sShapeType = xShape->getShapeType(); if ( m_postponedDMLDrawing == NULL ) { if ( IsAlternateContentChoiceOpen() ) @@ -4271,6 +4303,13 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Po else m_rExport.SdrExporter().writeDMLAndVMLDrawing( pSdrObj, rFrame.GetFrmFmt(), rNdTopLeft, m_anchorId++); } + // IsAlternateContentChoiceOpen() : check is to ensure that only one object is getting added. Without this check, plus one obejct gets added + // m_bParagraphFrameOpen : Check if the frame is open. + // sShapeType : This check is to ensure that if the custom shape is within a text frame then only we should postpone it. + else if (IsAlternateContentChoiceOpen() && m_bParagraphFrameOpen && sShapeType == "com.sun.star.drawing.CustomShape") + { + m_postponedCustomShape->push_back(PostponedDrawing(pSdrObj, &(rFrame.GetFrmFmt()), &rNdTopLeft)); + } else // we are writing out attributes, but w:drawing should not be inside w:rPr, so write it out later m_postponedDMLDrawing->push_back(PostponedDrawing(pSdrObj, &(rFrame.GetFrmFmt()), &rNdTopLeft)); @@ -7398,6 +7437,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_nNextAnnotationMarkId( 0 ), m_pTableWrt( NULL ), m_bParagraphOpened( false ), + m_bParagraphFrameOpen( false ), m_bIsFirstParagraph( true ), m_bAlternateContentChoiceOpen( false ), m_nColBreakStatus( COLBRK_NONE ), @@ -7411,6 +7451,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_postponedDiagram( NULL ), m_postponedVMLDrawing(NULL), m_postponedDMLDrawing(NULL), + m_postponedCustomShape(NULL), m_postponedOLE( NULL ), m_postponedMath( NULL ), m_postponedChart( NULL ), diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 8095d2f9bb4c..2c0472d5cab6 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -684,6 +684,7 @@ private: void WritePostponedOLE(); void WritePostponedVMLDrawing(); void WritePostponedDMLDrawing(); + void WritePostponedCustomShape(); void WriteSdtBlock( sal_Int32& nSdtPrToken, ::sax_fastparser::FastAttributeList* &pSdtPrTokenChildren, ::sax_fastparser::FastAttributeList* &pSdtPrDataBindingAttrs ); @@ -763,6 +764,7 @@ private: SwWriteTable *m_pTableWrt; bool m_bParagraphOpened; + bool m_bParagraphFrameOpen; bool m_bIsFirstParagraph; bool m_bAlternateContentChoiceOpen; @@ -810,6 +812,7 @@ private: }; std::list< PostponedDrawing >* m_postponedVMLDrawing; std::list< PostponedDrawing >* m_postponedDMLDrawing; + std::list< PostponedDrawing >* m_postponedCustomShape; struct PostponedOLE { diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 6f26ae7ef533..29c119500e42 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -151,7 +151,6 @@ struct DocxSdrExport::Impl sax_fastparser::FastAttributeList* m_pFlyWrapAttrList; sax_fastparser::FastAttributeList* m_pBodyPrAttrList; sax_fastparser::FastAttributeList* m_pDashLineStyleAttr; - bool m_bIsInDMLTextFrame; sal_Int32 m_nId ; sal_Int32 m_nSeq ; @@ -173,7 +172,6 @@ struct DocxSdrExport::Impl m_pFlyWrapAttrList(0), m_pBodyPrAttrList(0), m_pDashLineStyleAttr(0), - m_bIsInDMLTextFrame(false), m_nId(0), m_nSeq(0) { @@ -657,10 +655,10 @@ void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrmFmt* if (propName == "LockedCanvas") { /* - * Export as Locked Canvas only if the drawing - * was originally a Locked Canvas and is now inside a Text Frame. + * Export as Locked Canvas only if the property + * is in the PropertySet */ - bLockedCanvas = m_pImpl->m_bIsInDMLTextFrame; + bLockedCanvas = true; break; } } @@ -1104,7 +1102,6 @@ void DocxSdrExport::writeDiagram(const SdrObject* sdrObject, const SwFrmFmt& rFr void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId) { - m_pImpl->m_bIsInDMLTextFrame = true; sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer; const SwFrmFmt& rFrmFmt = pParentFrame->GetFrmFmt(); const SwNodeIndex* pNodeIndex = rFrmFmt.GetCntnt().GetCntntIdx(); @@ -1320,7 +1317,6 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId) } endDMLAnchorInline(&rFrmFmt); - m_pImpl->m_bIsInDMLTextFrame = false; } void DocxSdrExport::writeVMLTextFrame(sw::Frame* pParentFrame) |