From e6b295e55d82f236206c24f5cf1dcc314c34b20f Mon Sep 17 00:00:00 2001 From: Vinaya Mandke Date: Thu, 28 Aug 2014 11:29:06 +0530 Subject: 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 Tested-by: Miklos Vajna --- sw/source/filter/ww8/attributeoutputbase.hxx | 2 ++ sw/source/filter/ww8/docxattributeoutput.cxx | 8 +++++++- sw/source/filter/ww8/docxattributeoutput.hxx | 3 +++ sw/source/filter/ww8/wrtw8nds.cxx | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) (limited to 'sw/source') 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 aGrabBagSdt = i->second.get< uno::Sequence >(); @@ -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 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 -- cgit