summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinaya Mandke <vinaya.mandke@synerzip.com>2014-08-28 11:29:06 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-09-08 02:51:45 -0500
commite6b295e55d82f236206c24f5cf1dcc314c34b20f (patch)
tree2f52f7c4e25615b9c831660ce07a03ec067e121e
parent3bb2c23f5b03120f71ac8ed8f9a00b4d30666c82 (diff)
fdo#83057 File corrupts on save, as SDT is added incorrectly
A fly frame was attached to a para which started within a hint (run) containing an SDT. This SDT was handled while exporting the FLYFRAME and also the text of the run. So, eventhough the original file had only one sdt in the header, the RT file had two; one for a seperate run as expected, and one incorrectly exported in the alternateContent (FLYFRAME) So don't collect SDTPr from grabbag if the FLY is not processed. As, the SDT will be handled when the run is exported. Change-Id: I7b3c94208c171afbec54467fd6b756a6e30c816b Reviewed-on: https://gerrit.libreoffice.org/11161 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ooxmlexport/data/fdo83057.docxbin0 -> 25032 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport5.cxx16
-rw-r--r--sw/source/filter/ww8/attributeoutputbase.hxx2
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx8
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx3
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx1
6 files changed, 29 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo83057.docx b/sw/qa/extras/ooxmlexport/data/fdo83057.docx
new file mode 100644
index 000000000000..d4d42321de20
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo83057.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 27de7ee532e5..21b8976b59a8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -684,6 +684,22 @@ DECLARE_OOXMLEXPORT_TEST(testSdt2Run, "sdt-2-run.docx")
assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/w:t", "third");
}
+DECLARE_OOXMLEXPORT_TEST(testFD083057, "fdo83057.docx")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/header1.xml");
+ if (!pXmlDoc)
+ return;
+
+ // A fly frame was attached to a para which started with a hint (run) containing an SDT.
+ // This SDT was handled while exporting the FLYFRAME and also the text of the run.
+ // So, eventhough the original file had only one sdt in the header, the RT file had two;
+ // one for a seperate run as expected, and one incorrectly exported in the alternateContent (FLYFRAME)
+
+ // Assert that the file has only one sdt, in a seperate run
+ assertXPath(pXmlDoc, "//w:sdt", 1);
+ assertXPath(pXmlDoc, "//mc:AlternateContent//w:sdt", 0);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index a32a4bae88b3..93b6aaa85963 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -309,6 +309,8 @@ public:
/// Has different headers/footers for the title page.
virtual void SectionTitlePage() = 0;
+ /// Set the state of the Fly at current position
+ virtual void SetStateOfFlyFrame( sal_Int16 /*nStateOfFlyFrame*/ ){};
/// If the node has an anchor linked.
virtual void SetAnchorIsLinkedToNode( bool /*bAnchorLinkedToNode*/){};
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index b4587e82fe4d..518ce24aa3bc 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -969,6 +969,11 @@ void DocxAttributeOutput::EndParagraphProperties( const SfxItemSet* pParagraphMa
m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND );
}
+void DocxAttributeOutput::SetStateOfFlyFrame( sal_Int16 nStateOfFlyFrame )
+{
+ m_nStateOfFlyFrame = nStateOfFlyFrame;
+}
+
void DocxAttributeOutput::SetAnchorIsLinkedToNode( bool bAnchorLinkedToNode )
{
m_bAnchorLinkedToNode = bAnchorLinkedToNode ;
@@ -8145,7 +8150,7 @@ void DocxAttributeOutput::CharGrabBag( const SfxGrabBagItem& rItem )
if (m_bStartedCharSdt)
m_bEndCharSdt = true;
}
- else if (i->first == "SdtPr")
+ else if (i->first == "SdtPr" && FLY_NOT_PROCESSED != m_nStateOfFlyFrame )
{
uno::Sequence<beans::PropertyValue> aGrabBagSdt =
i->second.get< uno::Sequence<beans::PropertyValue> >();
@@ -8286,6 +8291,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
, m_pParagraphSdtPrTokenAttributes(NULL)
, m_pParagraphSdtPrDataBindingAttrs(NULL)
, m_nRunSdtPrToken(0)
+ , m_nStateOfFlyFrame( FLY_NOT_PROCESSED )
, m_pRunSdtPrTokenChildren(NULL)
, m_pRunSdtPrDataBindingAttrs(NULL)
, m_bParagraphSdtHasId(false)
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 12772030e315..51f775c5c41b 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -215,6 +215,7 @@ public:
/// End of the tag that encloses the run.
void EndRedline( const SwRedlineData * pRedlineData );
+ virtual void SetStateOfFlyFrame( sal_Int16 nStateOfFlyFrame ) SAL_OVERRIDE;
virtual void SetAnchorIsLinkedToNode( bool bAnchorLinkedToNode = false ) SAL_OVERRIDE;
virtual bool IsFlyProcessingPostponed() SAL_OVERRIDE;
virtual void ResetFlyProcessingFlag() SAL_OVERRIDE;
@@ -907,6 +908,8 @@ private:
::sax_fastparser::FastAttributeList *m_pParagraphSdtPrDataBindingAttrs;
/// members to control the existence of grabbagged SDT properties in the text run
sal_Int32 m_nRunSdtPrToken;
+ /// State of the Fly at current position
+ sal_Int16 m_nStateOfFlyFrame;
::sax_fastparser::FastAttributeList *m_pRunSdtPrTokenChildren;
::sax_fastparser::FastAttributeList *m_pRunSdtPrDataBindingAttrs;
/// Value of the <w:alias> paragraph SDT element.
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index c51d4ca0a2ac..d03b1b43b93b 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -2077,6 +2077,7 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode )
bPostponeWritingText = true ;
nStateOfFlyFrame = aAttrIter.OutFlys( nAktPos );
+ AttrOutput().SetStateOfFlyFrame( nStateOfFlyFrame );
AttrOutput().SetAnchorIsLinkedToNode( bPostponeWritingText && (FLY_POSTPONED != nStateOfFlyFrame) );
// Append bookmarks in this range after flys, exclusive of final
// position of this range