summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinaya Mandke <vinaya.mandke@synerzip.com>2014-02-13 20:02:53 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-02-26 11:27:58 +0100
commit263938c4a8789d881f8e736d317b6bcc09c3bce5 (patch)
treece438c02296f8c3cd307ba9852e6c12e098fa031
parent45261b88c4935c0a6dd57e8a47438b799d091957 (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
-rw-r--r--sw/qa/extras/ooxmlexport/data/alphabeticalIndex_MultipleColumns.docxbin0 -> 15937 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx22
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx6
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx1
-rw-r--r--sw/source/filter/ww8/docxexport.hxx2
-rw-r--r--sw/source/filter/ww8/rtfexport.hxx3
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx10
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx5
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx24
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx2
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx14
11 files changed, 80 insertions, 9 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/alphabeticalIndex_MultipleColumns.docx b/sw/qa/extras/ooxmlexport/data/alphabeticalIndex_MultipleColumns.docx
new file mode 100644
index 000000000000..970166ad48cd
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/alphabeticalIndex_MultipleColumns.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 73d3393d8f2d..6826a4df9d67 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3661,6 +3661,28 @@ DECLARE_OOXMLEXPORT_TEST(testPageBreak,"fdo74566.docx")
getRun(xParagraph4, 1, "Second Page First line after Page Break");
}
+DECLARE_OOXMLEXPORT_TEST(testAlphabeticalIndex_MultipleColumns,"alphabeticalIndex_MultipleColumns.docx")
+{
+ // Bug :: fdo#73596
+ /*
+ * Index with multiple columns was not imported correctly and
+ * hence not exported correctly...
+ * The column count is given by the \c switch.
+ * If the column count is explicitly specified,
+ * MS Office adds section breaks before and after the Index.
+ */
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+ xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc,"/w:document/w:body/w:p[3]/w:r[2]/w:instrText");
+ xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
+ OUString contents = OUString::createFromAscii((const char*)((pXmlNode->children[0]).content));
+ CPPUNIT_ASSERT( contents.match(" INDEX \\c \"4\"\\e \"") );
+ // check for section breaks after and before the Index Section
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:sectPr/w:type","val","continuous");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:sectPr/w:type","val","continuous");
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
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)
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index cc4eec7dc6e4..c4e3a9f6f163 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1936,7 +1936,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
SectionColumnHandlerPtr pSectHdl( new SectionColumnHandler );
pProperties->resolve(*pSectHdl);
- if(pSectionContext)
+ if(pSectionContext && !m_pImpl->isInIndexContext())
{
if( pSectHdl->IsEqualWidth() )
{
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index b66b7f3fc899..0d98781f5fa4 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -57,6 +57,7 @@
#include <com/sun/star/awt/XControlModel.hpp>
#include <com/sun/star/drawing/XControlShape.hpp>
#include <com/sun/star/text/ControlCharacter.hpp>
+#include <com/sun/star/text/XTextColumns.hpp>
#include <oox/mathml/import.hxx>
#ifdef DEBUG_DOMAINMAPPER
@@ -2847,6 +2848,19 @@ void DomainMapper_Impl::handleIndex
uno::Reference< text::XTextContent > xToInsert( xTOC, uno::UNO_QUERY );
appendTextContent(xToInsert, uno::Sequence< beans::PropertyValue >() );
+
+ OUString sValue;
+ if( lcl_FindInCommand( pContext->GetCommand(), 'c', sValue ))
+ {
+ sValue = sValue.replaceAll("\"", "");
+ uno::Reference<text::XTextColumns> xTextColumns;
+ xTOC->getPropertyValue(rPropNameSupplier.GetName( PROP_TEXT_COLUMNS )) >>= xTextColumns;
+ if (xTextColumns.is())
+ {
+ xTextColumns->setColumnCount( sValue.toInt32() );
+ xTOC->setPropertyValue( rPropNameSupplier.GetName( PROP_TEXT_COLUMNS ), uno::makeAny( xTextColumns ) );
+ }
+ }
}
/*-------------------------------------------------------------------------