Kaydet (Commit) a45bdb8a authored tarafından Vinaya Mandke's avatar Vinaya Mandke Kaydeden (comit) Miklos Vajna

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
üst 9a8200e2
...@@ -3696,6 +3696,25 @@ DECLARE_OOXMLEXPORT_TEST(testPageref, "testPageref.docx") ...@@ -3696,6 +3696,25 @@ DECLARE_OOXMLEXPORT_TEST(testPageref, "testPageref.docx")
CPPUNIT_ASSERT(contents.match("PAGEREF _Toc355095261 \\h")); 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 #endif
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -2058,7 +2058,16 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect ) ...@@ -2058,7 +2058,16 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
switch (pTOX->GetType()) switch (pTOX->GetType())
{ {
case TOX_INDEX: case TOX_INDEX:
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();
if ( 0 < nCol )
{
// Add a continuous section break // Add a continuous section break
if( GetExport().AddSectionBreaksForTOX() ) if( GetExport().AddSectionBreaksForTOX() )
{ {
...@@ -2067,16 +2076,9 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect ) ...@@ -2067,16 +2076,9 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
GetExport( ).AttrOutput().SectionBreak( msword::PageBreak, &rInfo ); 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 ) + "\""; sStr += "\\c \"" + OUString::number( nCol ) + "\"";
} }
}
if (pTOX->GetTOXForm().IsCommaSeparated()) if (pTOX->GetTOXForm().IsCommaSeparated())
sStr += "\\r "; sStr += "\\r ";
...@@ -2370,12 +2372,19 @@ void AttributeOutputBase::EndTOX( const SwSection& rSect,bool bCareEnd ) ...@@ -2370,12 +2372,19 @@ void AttributeOutputBase::EndTOX( const SwSection& rSect,bool bCareEnd )
GetExport( ).OutputField( 0, eCode, OUString(), WRITEFIELD_CLOSE ); GetExport( ).OutputField( 0, eCode, OUString(), WRITEFIELD_CLOSE );
if ( pTOX->GetType() == TOX_INDEX && GetExport().AddSectionBreaksForTOX() ) if ( pTOX->GetType() == TOX_INDEX && GetExport().AddSectionBreaksForTOX() )
{
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; sal_uLong nRstLnNum = 0;
WW8_SepInfo rInfo( &GetExport( ).pDoc->GetPageDesc( 0 ), rSect.GetFmt() , nRstLnNum ); WW8_SepInfo rInfo( &GetExport( ).pDoc->GetPageDesc( 0 ), rSect.GetFmt() , nRstLnNum );
GetExport( ).AttrOutput().SectionBreak( msword::PageBreak, &rInfo ); GetExport( ).AttrOutput().SectionBreak( msword::PageBreak, &rInfo );
} }
} }
}
GetExport( ).bInWriteTOX = false; GetExport( ).bInWriteTOX = false;
if (bCareEnd) if (bCareEnd)
OnTOXEnding(); OnTOXEnding();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment