summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorYogeshBharate <yogesh.bharate@synerzip.com>2014-03-13 20:39:28 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-03-17 09:49:53 +0000
commit5291d902b2e8bbf405dc56a03b685bd10cecabf8 (patch)
treeb473d0398d0d9d352db524f55e741c2407e092e6 /sw
parentb916fc4840ba67ef30e45ea735408237a3422b56 (diff)
fdo#76122: File Corruption-doc contains nested alternateContents.
Problem Description: - After roundtrip, files contains <mc:AlternateContent> in <mc:Choice>. - Due to this document gets corrupted when we open it in MS Office 2010. - Added unit test. Change-Id: Ic64b815eda4a42cd59f522ac4570ae145b0b38e1 Reviewed-on: https://gerrit.libreoffice.org/8575 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx20
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx3
-rw-r--r--sw/source/filter/ww8/docxsdrexport.cxx14
-rw-r--r--sw/source/filter/ww8/docxsdrexport.hxx2
4 files changed, 30 insertions, 9 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 1b3ec7424912..968fd5584728 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -302,6 +302,12 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
m_pSerializer->startElementNS(XML_mc, XML_Choice,
XML_Requires, "wps",
FSEND);
+ /**
+ This is to avoid AltenateContent within another AlternateContent.
+ So when Choice is Open, only write the DML Drawing instead of both DML
+ and VML Drawing in another AlternateContent.
+ **/
+ SetAlternateContentChoiceOpen( true );
/** FDO#71834 :
We should probably be renaming the function
switchHeaderFooter to something like SaveRetrieveTableReference.
@@ -321,6 +327,7 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
m_rExport.SdrExporter().writeDMLTextFrame(&aFrame, m_anchorId++);
m_pSerializer->endElementNS(XML_mc, XML_Choice);
+ SetAlternateContentChoiceOpen( false );
// Reset table infos, otherwise the depth of the cells will be incorrect,
// in case the text frame had table(s) and we try to export the
@@ -3897,7 +3904,10 @@ void DocxAttributeOutput::WritePostponedDMLDrawing()
it != m_postponedDMLDrawing->end();
++it )
{
- m_rExport.SdrExporter().writeDMLAndVMLDrawing(it->object, *(it->frame), *(it->point), m_anchorId++);
+ 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_postponedDMLDrawing;
m_postponedDMLDrawing = NULL;
@@ -3942,7 +3952,12 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Po
else
{
if ( m_postponedDMLDrawing == NULL )
- m_rExport.SdrExporter().writeDMLAndVMLDrawing( pSdrObj, rFrame.GetFrmFmt(), rNdTopLeft, m_anchorId++);
+ {
+ if ( IsAlternateContentChoiceOpen() )
+ m_rExport.SdrExporter().writeDMLDrawing( pSdrObj, &rFrame.GetFrmFmt(), m_anchorId++);
+ else
+ m_rExport.SdrExporter().writeDMLAndVMLDrawing( pSdrObj, rFrame.GetFrmFmt(), rNdTopLeft, m_anchorId++);
+ }
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));
@@ -6945,6 +6960,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
m_pTableWrt( NULL ),
m_bParagraphOpened( false ),
m_bIsFirstParagraph( true ),
+ m_bAlternateContentChoiceOpen( false ),
m_nColBreakStatus( COLBRK_NONE ),
m_nTextFrameLevel( 0 ),
m_closeHyperlinkInThisRun( false ),
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 6012f43e994f..042fea6b7273 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -756,6 +756,7 @@ private:
bool m_bParagraphOpened;
bool m_bIsFirstParagraph;
+ bool m_bAlternateContentChoiceOpen;
// Remember that a column break has to be opened at the
// beginning of the next paragraph
@@ -892,6 +893,8 @@ public:
void SetWritingHeaderFooter( bool bWritingHeaderFooter ) { m_bWritingHeaderFooter = bWritingHeaderFooter; }
bool GetWritingHeaderFooter( ) { return m_bWritingHeaderFooter; }
+ void SetAlternateContentChoiceOpen( bool bAltContentChoiceOpen ) { m_bAlternateContentChoiceOpen = bAltContentChoiceOpen; }
+ bool IsAlternateContentChoiceOpen( ) { return m_bAlternateContentChoiceOpen; }
};
#endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXATTRIBUTEOUTPUT_HXX
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 8e7a41270b42..aae6752bda34 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -138,7 +138,7 @@ struct DocxSdrExport::Impl
}
/// Writes wp wrapper code around an SdrObject, which itself is written using drawingML syntax.
- void writeDMLDrawing(const SdrObject* pSdrObj, const SwFrmFmt* pFrmFmt, int nAnchorId);
+
void textFrameShadow(const SwFrmFmt& rFrmFmt);
bool isSupportedDMLShape(com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape);
};
@@ -532,11 +532,11 @@ void DocxSdrExport::writeVMLDrawing(const SdrObject* sdrObj, const SwFrmFmt& rFr
const_cast< SdrObject* >(sdrObj)->SetPage(0);
}
-void DocxSdrExport::Impl::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrmFmt* pFrmFmt, int nAnchorId)
+void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrmFmt* pFrmFmt, int nAnchorId)
{
- sax_fastparser::FSHelperPtr pFS = m_pSerializer;
+ sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer;
Size aSize(pSdrObject->GetLogicRect().GetWidth(), pSdrObject->GetLogicRect().GetHeight());
- m_rSdrExport.startDMLAnchorInline(pFrmFmt, aSize);
+ m_pImpl->m_rSdrExport.startDMLAnchorInline(pFrmFmt, aSize);
sax_fastparser::FastAttributeList* pDocPrAttrList = pFS->createAttrList();
pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr());
@@ -562,7 +562,7 @@ void DocxSdrExport::Impl::writeDMLDrawing(const SdrObject* pSdrObject, const SwF
XML_uri, pNamespace,
FSEND);
- m_rExport.OutputDML(xShape);
+ m_pImpl->m_rExport.OutputDML(xShape);
pFS->endElementNS(XML_a, XML_graphicData);
pFS->endElementNS(XML_a, XML_graphic);
@@ -590,7 +590,7 @@ void DocxSdrExport::Impl::writeDMLDrawing(const SdrObject* pSdrObject, const SwF
pFS->endElementNS(XML_wp14, XML_sizeRelV);
}
- m_rSdrExport.endDMLAnchorInline(pFrmFmt);
+ m_pImpl->m_rSdrExport.endDMLAnchorInline(pFrmFmt);
}
void DocxSdrExport::Impl::textFrameShadow(const SwFrmFmt& rFrmFmt)
@@ -657,7 +657,7 @@ void DocxSdrExport::writeDMLAndVMLDrawing(const SdrObject* sdrObj, const SwFrmFm
m_pImpl->m_pSerializer->startElementNS(XML_mc, XML_Choice,
XML_Requires, (pObjGroup ? "wpg" : "wps"),
FSEND);
- m_pImpl->writeDMLDrawing(sdrObj, &rFrmFmt, nAnchorId);
+ writeDMLDrawing(sdrObj, &rFrmFmt, nAnchorId);
m_pImpl->m_pSerializer->endElementNS(XML_mc, XML_Choice);
m_pImpl->m_pSerializer->startElementNS(XML_mc, XML_Fallback, FSEND);
diff --git a/sw/source/filter/ww8/docxsdrexport.hxx b/sw/source/filter/ww8/docxsdrexport.hxx
index 8833ab924d45..1fa7fe0e7cee 100644
--- a/sw/source/filter/ww8/docxsdrexport.hxx
+++ b/sw/source/filter/ww8/docxsdrexport.hxx
@@ -77,6 +77,8 @@ public:
void endDMLAnchorInline(const SwFrmFmt* pFrmFmt);
/// Writes a drawing as VML data.
void writeVMLDrawing(const SdrObject* sdrObj, const SwFrmFmt& rFrmFmt,const Point& rNdTopLeft);
+ /// Writes a drawing as DML.
+ void writeDMLDrawing(const SdrObject* pSdrObj, const SwFrmFmt* pFrmFmt, int nAnchorId);
/// Writes shape in both DML and VML format.
void writeDMLAndVMLDrawing(const SdrObject* sdrObj, const SwFrmFmt& rFrmFmt,const Point& rNdTopLeft, int nAnchorId);
/// Write <a:effectLst>, the effect list.