diff options
author | Vinaya Mandke <vinaya.mandke@synerzip.com> | 2014-02-13 20:02:53 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-02-26 11:27:58 +0100 |
commit | 263938c4a8789d881f8e736d317b6bcc09c3bce5 (patch) | |
tree | ce438c02296f8c3cd307ba9852e6c12e098fa031 /sw/source/filter/ww8 | |
parent | 45261b88c4935c0a6dd57e8a47438b799d091957 (diff) |
fdo#73596 [DOCX] Multiple Columns in Index
The number of columns in an Index is given by the "\c" switch.
During export, added section breaks before and after the Index;
this is to preserve the layout of the round tripped file in MS Office.
Modified MSWordExportBase::NoPageBreakSection so that
an incorrect "nextPage" section break is not exported.
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/8047
Change-Id: I364e19d6739c4c6a60e3c605044fc1fafd9147d3
Diffstat (limited to 'sw/source/filter/ww8')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 1 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexport.hxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 10 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.hxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 24 |
7 files changed, 43 insertions, 8 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 46258f94593e..77ee13e97dd5 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -271,6 +271,7 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText m_pSectionInfo.reset(); m_bParagraphOpened = true; + m_bIsFirstParagraph = false; } void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) @@ -3969,7 +3970,9 @@ void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* pSectio case msword::PageBreak: if ( pSectionInfo ) { - if ( !m_bParagraphOpened ) + // don't add section properties if this will be the first + // paragraph in the document + if ( !m_bParagraphOpened && !m_bIsFirstParagraph) { // Create a dummy paragraph if needed m_pSerializer->startElementNS( XML_w, XML_p, FSEND ); @@ -6624,6 +6627,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_nNextAnnotationMarkId( 0 ), m_pTableWrt( NULL ), m_bParagraphOpened( false ), + m_bIsFirstParagraph( true ), 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 de98b3c8b64c..dd24e2f6c353 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -745,6 +745,7 @@ private: SwWriteTable *m_pTableWrt; bool m_bParagraphOpened; + bool m_bIsFirstParagraph; // Remember that a column break has to be opened at the // beginning of the next paragraph diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index 60779669fae0..4ce76e31d7d1 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -117,6 +117,8 @@ public: virtual bool FieldsQuoted() const { return true; } + virtual bool AddSectionBreaksForTOX() const { return true; } + virtual bool ignoreAttributeForStyles( sal_uInt16 nWhich ) const; /// Guess the script (asian/western). diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx index 21a44159a8c4..c23bff0754eb 100644 --- a/sw/source/filter/ww8/rtfexport.hxx +++ b/sw/source/filter/ww8/rtfexport.hxx @@ -65,6 +65,9 @@ public: virtual bool SupportsOneColumnBreak() const { return false; } virtual bool FieldsQuoted() const { return true; } + + virtual bool AddSectionBreaksForTOX() const { return false; } + /// Guess the script (asian/western). virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ); diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 29da65dcb30f..90d943ea524a 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -1910,7 +1910,6 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode ) bLastCR = true; } - AttrOutput().StartParagraph( pTextNodeInfo ); bool bFlyInTable = mpParentFrame && IsInTable(); @@ -1935,6 +1934,8 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode ) } } + AttrOutput().StartParagraph( pTextNodeInfo ); + const SwSection* pTOXSect = 0; if( bInWriteTOX ) { @@ -2606,15 +2607,10 @@ bool MSWordExportBase::NoPageBreakSection( const SfxItemSet* pSet ) const SfxPoolItem* pI; if( pSet) { - bool bNoPageBreak = false; + bool bNoPageBreak = true; if ( SFX_ITEM_ON != pSet->GetItemState(RES_PAGEDESC, true, &pI) || 0 == ((SwFmtPageDesc*)pI)->GetPageDesc() ) { - bNoPageBreak = true; - } - - if (bNoPageBreak) - { if (SFX_ITEM_ON != pSet->GetItemState(RES_BREAK, true, &pI)) bNoPageBreak = true; else diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index fb63531bb2ee..071808652113 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -639,6 +639,9 @@ public: /// Determines if the import filter already quoted fields or not. virtual bool FieldsQuoted() const = 0; + /// Determines the Section Breaks are to be added for TOX Section + virtual bool AddSectionBreaksForTOX() const = 0; + /// Used to filter out attributes that can be e.g. written to .doc but not to .docx virtual bool ignoreAttributeForStyles( sal_uInt16 /*nWhich*/ ) const { return false; } @@ -965,6 +968,8 @@ public: virtual bool SupportsOneColumnBreak() const { return false; } virtual bool FieldsQuoted() const { return false; } + + virtual bool AddSectionBreaksForTOX() const { return false; } private: /// Format-dependent part of the actual export. virtual void ExportDocument_Impl(); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 7178b96cd16d..db3270c265da 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -2058,9 +2058,26 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect ) switch (pTOX->GetType()) { case TOX_INDEX: + + // Add a continuous section break + if( GetExport().AddSectionBreaksForTOX() ) + { + sal_uLong nRstLnNum = 0; + WW8_SepInfo rInfo( &GetExport( ).pDoc->GetPageDesc( 0 ), rSect.GetParent()->GetFmt() , nRstLnNum ); + GetExport( ).AttrOutput().SectionBreak( msword::PageBreak, &rInfo ); + } + eCode = ww::eINDEX; sStr = FieldString(eCode); + { + const SwFmtCol& rCol = (const SwFmtCol&)( rSect.GetFmt()->GetFmtAttr( RES_COL ) ); + const SwColumns& rColumns = rCol.GetColumns(); + sal_Int32 nCol = rColumns.size(); + sStr += "\\c \"" + OUString::number( nCol ) + "\""; + } + + if (pTOX->GetTOXForm().IsCommaSeparated()) sStr += "\\r "; @@ -2351,6 +2368,13 @@ void AttributeOutputBase::EndTOX( const SwSection& rSect,bool bCareEnd ) { ww::eField eCode = TOX_INDEX == pTOX->GetType() ? ww::eINDEX : ww::eTOC; GetExport( ).OutputField( 0, eCode, OUString(), WRITEFIELD_CLOSE ); + + if ( pTOX->GetType() == TOX_INDEX && GetExport().AddSectionBreaksForTOX() ) + { + sal_uLong nRstLnNum = 0; + WW8_SepInfo rInfo( &GetExport( ).pDoc->GetPageDesc( 0 ), rSect.GetFmt() , nRstLnNum ); + GetExport( ).AttrOutput().SectionBreak( msword::PageBreak, &rInfo ); + } } GetExport( ).bInWriteTOX = false; if (bCareEnd) |