summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinaya Mandke <vinaya.mandke@synerzip.com>2014-02-14 19:13:03 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-02-26 12:18:50 +0100
commita45bdb8aa8f3a183842c715106e4f6e59f2f94c7 (patch)
tree1f65e885e4525baa80d3b95c144a4f0c97768cc3
parent9a8200e229cf18c7b773bbc7bfb454548240bbcd (diff)
fdo#73596 [DOCX] Auto Columns in Index
When number of columns in the Index is not specified by the "\c" switch, then avoid adding the section breaks explicitly before and after the Index Section and "\c '0'" in the field identifier string. Also added UT for the same. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/8104 Change-Id: I56826f72beea580d0ac5aef44d4a71fd29b77316
-rw-r--r--sw/qa/extras/ooxmlexport/data/alphabeticalIndex_AutoColumn.docxbin0 -> 15891 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx19
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx37
3 files changed, 42 insertions, 14 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/alphabeticalIndex_AutoColumn.docx b/sw/qa/extras/ooxmlexport/data/alphabeticalIndex_AutoColumn.docx
new file mode 100644
index 000000000000..e08e943ac2ba
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/alphabeticalIndex_AutoColumn.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index db7811c1c016..337a69b0528e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3696,6 +3696,25 @@ DECLARE_OOXMLEXPORT_TEST(testPageref, "testPageref.docx")
CPPUNIT_ASSERT(contents.match("PAGEREF _Toc355095261 \\h"));
}
+DECLARE_OOXMLEXPORT_TEST(testAlphabeticalIndex_AutoColumn,"alphabeticalIndex_AutoColumn.docx")
+{
+ // Bug :: fdo#73596
+ /*
+ * When the columns in Index are 0; i.e not specified by the
+ * "\c" switch, don't write back '\c "0"' or the section breaks
+ * before and after the Index Context
+ */
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+ xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc,"/w:document/w:body/w:p[2]/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 \\e \"") );
+ // check for section break doestn't appear for any paragraph
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:sectPr", 0);
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index db3270c265da..7086f7e873fc 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2058,15 +2058,6 @@ 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);
@@ -2074,9 +2065,20 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
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 ( 0 < nCol )
+ {
+ // 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 );
+ }
+
+ sStr += "\\c \"" + OUString::number( nCol ) + "\"";
+ }
+ }
if (pTOX->GetTOXForm().IsCommaSeparated())
sStr += "\\r ";
@@ -2371,9 +2373,16 @@ void AttributeOutputBase::EndTOX( const SwSection& rSect,bool bCareEnd )
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 );
+ const SwFmtCol& rCol = (const SwFmtCol&)( rSect.GetFmt()->GetFmtAttr( RES_COL ) );
+ const SwColumns& rColumns = rCol.GetColumns();
+ sal_Int32 nCol = rColumns.size();
+
+ if ( 0 < nCol )
+ {
+ sal_uLong nRstLnNum = 0;
+ WW8_SepInfo rInfo( &GetExport( ).pDoc->GetPageDesc( 0 ), rSect.GetFmt() , nRstLnNum );
+ GetExport( ).AttrOutput().SectionBreak( msword::PageBreak, &rInfo );
+ }
}
}
GetExport( ).bInWriteTOX = false;