[Libreoffice-commits] core.git: sw/qa sw/source
Mike Kaganski
mike.kaganski at collabora.com
Mon Jan 8 05:58:02 UTC 2018
sw/qa/extras/ooxmlexport/data/tdf114882.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 5 +++
sw/source/filter/ww8/docxattributeoutput.cxx | 40 ++++++++++-----------------
sw/source/filter/ww8/docxattributeoutput.hxx | 26 ++++++++++-------
sw/source/filter/ww8/docxexport.cxx | 30 ++++++++------------
5 files changed, 49 insertions(+), 52 deletions(-)
New commits:
commit 4f65853df16a599fe81576bbccbca6ea78488d54
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date: Sun Jan 7 23:53:02 2018 +0300
tdf#114882: don't try to close SDT when processing inner objects
Change-Id: Ib7e59e1a6c82d2d35a8466312a2571f76f2338b7
Reviewed-on: https://gerrit.libreoffice.org/47546
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf114882.docx b/sw/qa/extras/ooxmlexport/data/tdf114882.docx
new file mode 100644
index 000000000000..8663f6b15557
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf114882.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 00c362340ce5..46e31f89b6c8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -197,6 +197,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf113399, "tdf113399.doc")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), nPaddingValue);
}
+DECLARE_OOXMLEXPORT_TEST(testTdf114882, "tdf114882.docx")
+{
+ // fastserializer must not fail assertion because of mismatching elements
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 3f6b78ef6932..fbcc5e634f2d 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -494,10 +494,10 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
otherwise the StartParagraph function will use the previous existing
table reference attributes since the variable is being shared.
*/
- DocxTableExportContext aDMLTableExportContext;
- pushToTableExportContext(aDMLTableExportContext);
- m_rExport.SdrExporter().writeDMLTextFrame(&aFrame, m_anchorId++);
- popFromTableExportContext(aDMLTableExportContext);
+ {
+ DocxTableExportContext aDMLTableExportContext(*this);
+ m_rExport.SdrExporter().writeDMLTextFrame(&aFrame, m_anchorId++);
+ }
m_pSerializer->endElementNS(XML_mc, XML_Choice);
SetAlternateContentChoiceOpen( false );
@@ -508,10 +508,10 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
//reset the tableReference.
m_pSerializer->startElementNS(XML_mc, XML_Fallback, FSEND);
- DocxTableExportContext aVMLTableExportContext;
- pushToTableExportContext(aVMLTableExportContext);
- m_rExport.SdrExporter().writeVMLTextFrame(&aFrame);
- popFromTableExportContext(aVMLTableExportContext);
+ {
+ DocxTableExportContext aVMLTableExportContext(*this);
+ m_rExport.SdrExporter().writeVMLTextFrame(&aFrame);
+ }
m_rExport.m_pTableInfo = pOldTableInfo;
m_pSerializer->endElementNS(XML_mc, XML_Fallback);
@@ -579,12 +579,10 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
{
for ( const auto & pFrame : aFramePrTextbox )
{
- DocxTableExportContext aTableExportContext;
- pushToTableExportContext(aTableExportContext);
+ DocxTableExportContext aTableExportContext(*this);
m_pCurrentFrame = pFrame.get();
m_rExport.SdrExporter().writeOnlyTextOfFrame(pFrame.get());
m_pCurrentFrame = nullptr;
- popFromTableExportContext(aTableExportContext);
}
aFramePrTextbox.clear();
}
@@ -5310,7 +5308,6 @@ void DocxAttributeOutput::WritePostponedCustomShape()
if (!m_pPostponedCustomShape)
return;
- bool bStartedParaSdt = m_bStartedParaSdt;
for( const auto & rPostponedDrawing : *m_pPostponedCustomShape)
{
if ( IsAlternateContentChoiceOpen() )
@@ -5318,7 +5315,6 @@ void DocxAttributeOutput::WritePostponedCustomShape()
else
m_rExport.SdrExporter().writeDMLAndVMLDrawing(rPostponedDrawing.object, *rPostponedDrawing.frame, m_anchorId++);
}
- m_bStartedParaSdt = bStartedParaSdt;
m_pPostponedCustomShape.reset(nullptr);
}
@@ -5331,7 +5327,6 @@ void DocxAttributeOutput::WritePostponedDMLDrawing()
std::unique_ptr< std::vector<PostponedDrawing> > pPostponedDMLDrawings(m_pPostponedDMLDrawings.release());
std::unique_ptr< std::vector<PostponedOLE> > pPostponedOLEs(m_pPostponedOLEs.release());
- bool bStartedParaSdt = m_bStartedParaSdt;
for( const auto & rPostponedDrawing : *pPostponedDMLDrawings )
{
// Avoid w:drawing within another w:drawing.
@@ -5340,7 +5335,6 @@ void DocxAttributeOutput::WritePostponedDMLDrawing()
else
m_rExport.SdrExporter().writeDMLAndVMLDrawing(rPostponedDrawing.object, *rPostponedDrawing.frame, m_anchorId++);
}
- m_bStartedParaSdt = bStartedParaSdt;
m_pPostponedOLEs = std::move(pPostponedOLEs);
}
@@ -5393,7 +5387,6 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const ww8::Frame &rFrame, const P
{
if (!m_pPostponedDMLDrawings)
{
- bool bStartedParaSdt = m_bStartedParaSdt;
if ( IsAlternateContentChoiceOpen() )
{
// Do not write w:drawing inside w:drawing. Instead Postpone the Inner Drawing.
@@ -5404,7 +5397,6 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const ww8::Frame &rFrame, const P
}
else
m_rExport.SdrExporter().writeDMLAndVMLDrawing( pSdrObj, rFrame.GetFrameFormat(), m_anchorId++);
- m_bStartedParaSdt = bStartedParaSdt;
m_bPostponedProcessingFly = false ;
}
@@ -5579,6 +5571,9 @@ void DocxAttributeOutput::pushToTableExportContext(DocxTableExportContext& rCont
rContext.m_nTableDepth = m_tableReference->m_nTableDepth;
m_tableReference->m_nTableDepth = 0;
+
+ rContext.m_bStartedParaSdt = m_bStartedParaSdt;
+ m_bStartedParaSdt = false;
}
void DocxAttributeOutput::popFromTableExportContext(DocxTableExportContext const & rContext)
@@ -5586,32 +5581,27 @@ void DocxAttributeOutput::popFromTableExportContext(DocxTableExportContext const
m_rExport.m_pTableInfo = rContext.m_pTableInfo;
m_tableReference->m_bTableCellOpen = rContext.m_bTableCellOpen;
m_tableReference->m_nTableDepth = rContext.m_nTableDepth;
+ m_bStartedParaSdt = rContext.m_bStartedParaSdt;
}
void DocxAttributeOutput::WriteTextBox(uno::Reference<drawing::XShape> xShape)
{
- DocxTableExportContext aTableExportContext;
- pushToTableExportContext(aTableExportContext);
+ DocxTableExportContext aTableExportContext(*this);
SwFrameFormat* pTextBox = SwTextBoxHelper::getOtherTextBoxFormat(xShape);
const SwPosition* pAnchor = pTextBox->GetAnchor().GetContentAnchor();
ww8::Frame aFrame(*pTextBox, *pAnchor);
m_rExport.SdrExporter().writeDMLTextFrame(&aFrame, m_anchorId++, /*bTextBoxOnly=*/true);
-
- popFromTableExportContext(aTableExportContext);
}
void DocxAttributeOutput::WriteVMLTextBox(uno::Reference<drawing::XShape> xShape)
{
- DocxTableExportContext aTableExportContext;
- pushToTableExportContext(aTableExportContext);
+ DocxTableExportContext aTableExportContext(*this);
SwFrameFormat* pTextBox = SwTextBoxHelper::getOtherTextBoxFormat(xShape);
const SwPosition* pAnchor = pTextBox->GetAnchor().GetContentAnchor();
ww8::Frame aFrame(*pTextBox, *pAnchor);
m_rExport.SdrExporter().writeVMLTextFrame(&aFrame, /*bTextBoxOnly=*/true);
-
- popFromTableExportContext(aTableExportContext);
}
oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML()
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 7e77ba90648e..237204592766 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -104,16 +104,7 @@ struct PageMargins
PageMargins() : nPageMarginLeft(0), nPageMarginRight(0), nPageMarginTop(0), nPageMarginBottom(0) {}
};
-/**
- * All the information that should be stashed away when we're in the middle of
- * of a table export and still have to do something else, e.g. export a shape.
- */
-struct DocxTableExportContext
-{
- ww8::WW8TableInfo::Pointer_t m_pTableInfo;
- bool m_bTableCellOpen;
- sal_uInt32 m_nTableDepth;
-};
+struct DocxTableExportContext;
/**
* A structure that holds flags for the table export.
@@ -1029,6 +1020,21 @@ public:
void popFromTableExportContext(DocxTableExportContext const & rContext);
};
+/**
+* All the information that should be stashed away when we're in the middle of
+* of a table export and still have to do something else, e.g. export a shape.
+*/
+struct DocxTableExportContext
+{
+ DocxAttributeOutput& m_rOutput;
+ ww8::WW8TableInfo::Pointer_t m_pTableInfo;
+ bool m_bTableCellOpen;
+ bool m_bStartedParaSdt;
+ sal_uInt32 m_nTableDepth;
+ DocxTableExportContext(DocxAttributeOutput& rOutput) : m_rOutput(rOutput) { m_rOutput.pushToTableExportContext(*this); }
+ ~DocxTableExportContext() { m_rOutput.popFromTableExportContext(*this); }
+};
+
#endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXATTRIBUTEOUTPUT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 2a76ae0cfc40..7a851397d5d4 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -808,29 +808,25 @@ void DocxExport::WriteHeaderFooter( const SwFormat* pFormat, bool bHeader, const
m_pVMLExport->SetFS( pFS );
m_pSdrExport->setSerializer(pFS);
SetFS( pFS );
- bool bStartedParaSdt = m_pAttrOutput->IsStartedParaSdt();
- m_pAttrOutput->SetStartedParaSdt(false);
-
- DocxTableExportContext aTableExportContext;
- m_pAttrOutput->pushToTableExportContext(aTableExportContext);
- //When the stream changes the cache which is maintained for the graphics in case of alternate content is not cleared.
- //So clearing the alternate content graphic cache.
- m_pAttrOutput->PushRelIdCache();
- // do the work
- if( pFormat == nullptr )
- AttrOutput().EmptyParagraph();
- else
- WriteHeaderFooterText( *pFormat, bHeader );
- m_pAttrOutput->PopRelIdCache();
- m_pAttrOutput->popFromTableExportContext(aTableExportContext);
- m_pAttrOutput->EndParaSdtBlock();
+ {
+ DocxTableExportContext aTableExportContext(*m_pAttrOutput);
+ //When the stream changes the cache which is maintained for the graphics in case of alternate content is not cleared.
+ //So clearing the alternate content graphic cache.
+ m_pAttrOutput->PushRelIdCache();
+ // do the work
+ if (pFormat == nullptr)
+ AttrOutput().EmptyParagraph();
+ else
+ WriteHeaderFooterText(*pFormat, bHeader);
+ m_pAttrOutput->PopRelIdCache();
+ m_pAttrOutput->EndParaSdtBlock();
+ }
// switch the serializer back
m_pAttrOutput->SetSerializer( m_pDocumentFS );
m_pVMLExport->SetFS( m_pDocumentFS );
m_pSdrExport->setSerializer(m_pDocumentFS);
SetFS( m_pDocumentFS );
- m_pAttrOutput->SetStartedParaSdt(bStartedParaSdt);
// close the tag
sal_Int32 nReference;
More information about the Libreoffice-commits
mailing list