summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorPallavi Jadhav <pallavi.jadhav@synerzip.com>2013-12-26 19:08:16 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-01-20 09:24:46 +0100
commit04a7ac6f062e9296eb643180cf54345bcdb260c4 (patch)
treecc5b41a453838afffd12eb8831ffaf318750d397 /sw
parent96bffb32ec50ecd43f2e7cc3c3df60a0c9cadfc9 (diff)
fdo#69613 : Fix for TOC with flag '\u' should get preserved after RT.
Issue : DOCX contatining TOC Code field '\u' was not getting preserved after RT. Implementation : 1] Provided import & export support for TOC field flag '\u'. 2] Written export Unit Test for code field '\u'. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/7202 Change-Id: I43872c7db21c25e0586bf874d5bb0c9115ab76af
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/tox.hxx1
-rw-r--r--sw/inc/unomap.hxx1
-rw-r--r--sw/inc/unoprnms.hxx1
-rw-r--r--sw/qa/extras/ooxmlexport/data/testTOCFlag_u.docxbin0 -> 17390 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx16
-rw-r--r--sw/source/core/unocore/unoidx.cxx3
-rw-r--r--sw/source/core/unocore/unomap.cxx2
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx227
-rw-r--r--sw/source/ui/index/cntex.cxx2
9 files changed, 140 insertions, 113 deletions
diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx
index 4a60fc3117a8..9e4efebfe05a 100644
--- a/sw/inc/tox.hxx
+++ b/sw/inc/tox.hxx
@@ -393,6 +393,7 @@ namespace nsSwTOXElement
const SwTOXElement TOX_TAB_IN_TOC = 512;
const SwTOXElement TOX_BOOKMARK = 1024;
const SwTOXElement TOX_NEWLINE = 2048;
+ const SwTOXElement TOX_PARAGRAPH_OUTLINE_LEVEL = 4096;
}
typedef sal_uInt16 SwTOIOptions;
diff --git a/sw/inc/unomap.hxx b/sw/inc/unomap.hxx
index 060d0ae95038..084abdedd81e 100644
--- a/sw/inc/unomap.hxx
+++ b/sw/inc/unomap.hxx
@@ -220,6 +220,7 @@
#define WID_SECONDARY_KEY_READING 1060
#define WID_TOC_BOOKMARK 1061
#define WID_TOC_NEWLINE 1062
+#define WID_TOC_PARAGRAPH_OUTLINE_LEVEL 1063
// Text document
#define WID_DOC_CHAR_COUNT 1000
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 85e478c59f09..0065f128afe2 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -125,6 +125,7 @@
#define UNO_NAME_TAB_IN_TOC "TabInTOC"
#define UNO_NAME_TOC_BOOKMARK "TOCBookmark"
#define UNO_NAME_TOC_NEWLINE "TOCNewLine"
+#define UNO_NAME_TOC_PARAGRAPH_OUTLINE_LEVEL "TOCParagraphOutlineLevel"
#define UNO_NAME_CHAR_FLASH "CharFlash"
#define UNO_NAME_CHAR_KERNING "CharKerning"
diff --git a/sw/qa/extras/ooxmlexport/data/testTOCFlag_u.docx b/sw/qa/extras/ooxmlexport/data/testTOCFlag_u.docx
new file mode 100644
index 000000000000..077bccfef82f
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/testTOCFlag_u.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index fe922477c9cc..56d6acb22048 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2348,7 +2348,7 @@ DECLARE_OOXMLEXPORT_TEST(testFieldFlagO,"TOC_field_f.docx")
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(" TOC \\z \\f \\o \"1-3\" \\h"));
+ CPPUNIT_ASSERT(contents.match(" TOC \\z \\f \\o \"1-3\" \\u \\h"));
}
DECLARE_OOXMLEXPORT_TEST(testTOCFlag_f, "toc_doc.docx")
@@ -2517,6 +2517,20 @@ DECLARE_OOXMLEXPORT_TEST(testShapeThemePreservation, "shape-theme-preservation.d
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00b050), getProperty<sal_Int32>(getShape(3), "FillColor"));
}
+DECLARE_OOXMLEXPORT_TEST(testTOCFlag_u,"testTOCFlag_u.docx")
+{
+ // DOCX contaning TOC should preserve code field '\u'.
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+ // FIXME "p[2]" will have to be "p[1]", once the TOC import code is fixed
+ // not to insert an empty paragraph before TOC.
+ 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(" TOC \\z \\o \"1-9\" \\u \\h"));
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index 7aa85ffcdf52..1172c8afaebe 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -662,6 +662,9 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
case WID_CREATE_FROM_OUTLINE:
lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_OUTLINELEVEL);
break;
+ case WID_TOC_PARAGRAPH_OUTLINE_LEVEL:
+ lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_PARAGRAPH_OUTLINE_LEVEL);
+ break;
case WID_TAB_IN_TOC:
lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_TAB_IN_TOC);
break;
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index da26adcddd0f..6617e7e0152b 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -1417,6 +1417,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
{ OUString(UNO_NAME_TAB_IN_TOC), WID_TAB_IN_TOC, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
{ OUString(UNO_NAME_TOC_BOOKMARK), WID_TOC_BOOKMARK, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0},
{ OUString(UNO_NAME_TOC_NEWLINE), WID_TOC_NEWLINE, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString(UNO_NAME_TOC_PARAGRAPH_OUTLINE_LEVEL), WID_TOC_PARAGRAPH_OUTLINE_LEVEL, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
{ OUString(UNO_NAME_CREATE_FROM_OUTLINE), WID_CREATE_FROM_OUTLINE , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0},
{ OUString(UNO_NAME_CREATE_FROM_CHAPTER), WID_CREATE_FROM_CHAPTER , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0},
{ OUString(UNO_NAME_IS_PROTECTED), WID_PROTECTED , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0},
@@ -1457,6 +1458,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
{ OUString(UNO_NAME_TAB_IN_TOC), WID_TAB_IN_TOC, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
{ OUString(UNO_NAME_TOC_BOOKMARK), WID_TOC_BOOKMARK, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0},
{ OUString(UNO_NAME_TOC_NEWLINE), WID_TOC_NEWLINE, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString(UNO_NAME_TOC_PARAGRAPH_OUTLINE_LEVEL), WID_TOC_PARAGRAPH_OUTLINE_LEVEL, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
{ OUString(UNO_NAME_CREATE_FROM_CHAPTER), WID_CREATE_FROM_CHAPTER , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0},
{ OUString(UNO_NAME_IS_PROTECTED), WID_PROTECTED , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0},
{ OUString(UNO_NAME_USE_LEVEL_FROM_SOURCE), WID_USE_LEVEL_FROM_SOURCE , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0},
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index a834683e503c..9dfc8dca0a73 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2143,81 +2143,86 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
sStr += sEntryEnd;
}
- if( nsSwTOXElement::TOX_OUTLINELEVEL & pTOX->GetCreateType() )
+ if( nsSwTOXElement::TOX_OUTLINELEVEL & pTOX->GetCreateType() )
+ {
+ // Take the TOC value of the max level to evaluate to as
+ // the starting point for the \o flag, but reduce it to the
+ // value of the highest outline level filled by a *standard*
+ // Heading 1 - 9 style because \o "Builds a table of
+ // contents from paragraphs formatted with built-in heading
+ // styles". And afterward fill in any outline styles left
+ // uncovered by that range to the \t flag
+ //
+ // i.e. for
+ // Heading 1
+ // Heading 2
+ // custom-style
+ // Heading 4
+ // output
+ // \o 1-2 \tcustom-style,3,Heading 3,4
+
+ // Search over all the outline styles used and figure out
+ // what is the minimum outline level (if any) filled by a
+ // non-standard style for that level, i.e. ignore headline
+ // styles 1-9 and find the lowest valid outline level
+ sal_uInt8 nPosOfLowestNonStandardLvl = MAXLEVEL;
+ const SwTxtFmtColls& rColls = *GetExport().pDoc->GetTxtFmtColls();
+ for( n = rColls.size(); n; )
{
- // Take the TOC value of the max level to evaluate to as
- // the starting point for the \o flag, but reduce it to the
- // value of the highest outline level filled by a *standard*
- // Heading 1 - 9 style because \o "Builds a table of
- // contents from paragraphs formatted with built-in heading
- // styles". And afterward fill in any outline styles left
- // uncovered by that range to the \t flag
- //
- // i.e. for
- // Heading 1
- // Heading 2
- // custom-style
- // Heading 4
- // output
- // \o 1-2 \tcustom-style,3,Heading 3,4
-
- // Search over all the outline styles used and figure out
- // what is the minimum outline level (if any) filled by a
- // non-standard style for that level, i.e. ignore headline
- // styles 1-9 and find the lowest valid outline level
- sal_uInt8 nPosOfLowestNonStandardLvl = MAXLEVEL;
- const SwTxtFmtColls& rColls = *GetExport().pDoc->GetTxtFmtColls();
- for( n = rColls.size(); n; )
+ const SwTxtFmtColl* pColl = rColls[ --n ];
+ sal_uInt16 nPoolId = pColl->GetPoolFmtId();
+ if (
+ //Is a Non-Standard Outline Style
+ (RES_POOLCOLL_HEADLINE1 > nPoolId || RES_POOLCOLL_HEADLINE9 < nPoolId) &&
+ //Has a valid outline level
+ (pColl->IsAssignedToListLevelOfOutlineStyle()) &&
+ // Is less than the lowest known non-standard level
+ (pColl->GetAssignedOutlineStyleLevel() < nPosOfLowestNonStandardLvl)
+ )
{
- const SwTxtFmtColl* pColl = rColls[ --n ];
- sal_uInt16 nPoolId = pColl->GetPoolFmtId();
- if (
- //Is a Non-Standard Outline Style
- (RES_POOLCOLL_HEADLINE1 > nPoolId || RES_POOLCOLL_HEADLINE9 < nPoolId) &&
- //Has a valid outline level
- (pColl->IsAssignedToListLevelOfOutlineStyle()) &&
- // Is less than the lowest known non-standard level
- (pColl->GetAssignedOutlineStyleLevel() < nPosOfLowestNonStandardLvl)
- )
- {
- nPosOfLowestNonStandardLvl = ::sal::static_int_cast<sal_uInt8>(pColl->GetAssignedOutlineStyleLevel());
- }
+ nPosOfLowestNonStandardLvl = ::sal::static_int_cast<sal_uInt8>(pColl->GetAssignedOutlineStyleLevel());
}
+ }
- sal_uInt8 nMaxMSAutoEvaluate = nPosOfLowestNonStandardLvl < nTOXLvl ? nPosOfLowestNonStandardLvl : (sal_uInt8)nTOXLvl;
+ sal_uInt8 nMaxMSAutoEvaluate = nPosOfLowestNonStandardLvl < nTOXLvl ? nPosOfLowestNonStandardLvl : (sal_uInt8)nTOXLvl;
- //output \o 1-X where X is the highest normal outline style to be included in the toc
- if ( nMaxMSAutoEvaluate )
- {
- if (nMaxMSAutoEvaluate > WW8ListManager::nMaxLevel)
- nMaxMSAutoEvaluate = WW8ListManager::nMaxLevel;
+ //output \o 1-X where X is the highest normal outline style to be included in the toc
+ if ( nMaxMSAutoEvaluate )
+ {
+ if (nMaxMSAutoEvaluate > WW8ListManager::nMaxLevel)
+ nMaxMSAutoEvaluate = WW8ListManager::nMaxLevel;
- sStr += "\\o \"1-";
- sStr += OUString::number(nMaxMSAutoEvaluate);
- sStr += sEntryEnd;
- }
+ sStr += "\\o \"1-";
+ sStr += OUString::number(nMaxMSAutoEvaluate);
+ sStr += sEntryEnd;
+ }
- //collect up any other styles in the writer TOC which will
- //not already appear in the MS TOC and place then into the
- //\t option
- if( nMaxMSAutoEvaluate < nTOXLvl )
+ //collect up any other styles in the writer TOC which will
+ //not already appear in the MS TOC and place then into the
+ //\t option
+ if( nMaxMSAutoEvaluate < nTOXLvl )
+ {
+ // collect this templates into the \t otion
+ for( n = rColls.size(); n;)
{
- // collect this templates into the \t otion
- for( n = rColls.size(); n;)
+ const SwTxtFmtColl* pColl = rColls[ --n ];
+ if (!pColl->IsAssignedToListLevelOfOutlineStyle())
+ continue;
+ sal_uInt8 nTestLvl = ::sal::static_int_cast<sal_uInt8>(pColl->GetAssignedOutlineStyleLevel());
+ if (nTestLvl < nTOXLvl && nTestLvl >= nMaxMSAutoEvaluate)
{
- const SwTxtFmtColl* pColl = rColls[ --n ];
- if (!pColl->IsAssignedToListLevelOfOutlineStyle())
- continue;
- sal_uInt8 nTestLvl = ::sal::static_int_cast<sal_uInt8>(pColl->GetAssignedOutlineStyleLevel());
- if (nTestLvl < nTOXLvl && nTestLvl >= nMaxMSAutoEvaluate)
- {
- if (!sTOption.isEmpty())
- sTOption += ",";
- sTOption += pColl->GetName() + "," + OUString::number( nTestLvl + 1 );
- }
+ if (!sTOption.isEmpty())
+ sTOption += ",";
+ sTOption += pColl->GetName() + "," + OUString::number( nTestLvl + 1 );
}
}
}
+ }
+
+ if( nsSwTOXElement::TOX_PARAGRAPH_OUTLINE_LEVEL & pTOX->GetCreateType() )
+ {
+ sStr +="\\u " ;
+ }
if( nsSwTOXElement::TOX_TEMPLATE & pTOX->GetCreateType() )
{
@@ -2250,63 +2255,63 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
}
}
- // No 'else' branch; why the below snippet is a block I have no idea.
+ // No 'else' branch; why the below snippet is a block I have no idea.
+ {
+ OUString aFillTxt;
+ sal_uInt8 nNoPgStt = MAXLEVEL, nNoPgEnd = MAXLEVEL;
+ bool bFirstFillTxt = true, bOnlyText = true;
+ for( n = 0; n < nTOXLvl; ++n )
{
- OUString aFillTxt;
- sal_uInt8 nNoPgStt = MAXLEVEL, nNoPgEnd = MAXLEVEL;
- bool bFirstFillTxt = true, bOnlyText = true;
- for( n = 0; n < nTOXLvl; ++n )
+ OUString aTxt;
+ int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(),
+ static_cast< sal_uInt8 >(n+1), aTxt );
+ if( 1 == nRet )
{
- OUString aTxt;
- int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(),
- static_cast< sal_uInt8 >(n+1), aTxt );
- if( 1 == nRet )
- {
- bOnlyText = false;
- if( MAXLEVEL == nNoPgStt )
- nNoPgStt = static_cast< sal_uInt8 >(n+1);
- }
- else
- {
- if( MAXLEVEL != nNoPgStt &&
- MAXLEVEL == nNoPgEnd )
- nNoPgEnd = sal_uInt8(n);
-
- bOnlyText = bOnlyText && 3 == nRet;
- if( 3 == nRet || 4 == nRet )
- {
- if( bFirstFillTxt )
- aFillTxt = aTxt;
- else if( aFillTxt != aTxt )
- aFillTxt = "";
- bFirstFillTxt = false;
- }
- }
- }
- if( MAXLEVEL != nNoPgStt )
- {
- if (WW8ListManager::nMaxLevel < nNoPgEnd)
- nNoPgEnd = WW8ListManager::nMaxLevel;
- sStr += "\\n ";
- sStr += OUString::number( nNoPgStt );
- sStr += "-";
- sStr += OUString::number( nNoPgEnd );
- sStr += " ";
+ bOnlyText = false;
+ if( MAXLEVEL == nNoPgStt )
+ nNoPgStt = static_cast< sal_uInt8 >(n+1);
}
- if( bOnlyText )
+ else
{
- sStr += "\\p \"";
- sStr += aFillTxt;
- sStr += sEntryEnd;
+ if( MAXLEVEL != nNoPgStt &&
+ MAXLEVEL == nNoPgEnd )
+ nNoPgEnd = sal_uInt8(n);
+
+ bOnlyText = bOnlyText && 3 == nRet;
+ if( 3 == nRet || 4 == nRet )
+ {
+ if( bFirstFillTxt )
+ aFillTxt = aTxt;
+ else if( aFillTxt != aTxt )
+ aFillTxt = "";
+ bFirstFillTxt = false;
+ }
}
}
-
- if( !sTOption.isEmpty() )
+ if( MAXLEVEL != nNoPgStt )
+ {
+ if (WW8ListManager::nMaxLevel < nNoPgEnd)
+ nNoPgEnd = WW8ListManager::nMaxLevel;
+ sStr += "\\n ";
+ sStr += OUString::number( nNoPgStt );
+ sStr += "-";
+ sStr += OUString::number( nNoPgEnd );
+ sStr += " ";
+ }
+ if( bOnlyText )
{
- sStr += "\\t \"";
- sStr += sTOption;
+ sStr += "\\p \"";
+ sStr += aFillTxt;
sStr += sEntryEnd;
}
+ }
+
+ if( !sTOption.isEmpty() )
+ {
+ sStr += "\\t \"";
+ sStr += sTOption;
+ sStr += sEntryEnd;
+ }
if (lcl_IsHyperlinked(pTOX->GetTOXForm(), nTOXLvl))
sStr += "\\h";
diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx
index ec6945f5782e..b7e9e05ba4a6 100644
--- a/sw/source/ui/index/cntex.cxx
+++ b/sw/source/ui/index/cntex.cxx
@@ -245,7 +245,7 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample(
lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_HIDE_TAB_LEADER_AND_PAGE_NUMBERS, 0!=(nContentOptions&nsSwTOXElement::TOX_TABLEADER ));
lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_TAB_IN_TOC, 0!=(nContentOptions&nsSwTOXElement::TOX_TAB_IN_TOC ));
lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_TOC_NEWLINE, 0!=(nContentOptions&nsSwTOXElement::TOX_NEWLINE));
-
+ lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_TOC_PARAGRAPH_OUTLINE_LEVEL, 0!=(nContentOptions&nsSwTOXElement::TOX_PARAGRAPH_OUTLINE_LEVEL));
lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_CHAPTER, rDesc.IsFromChapter());
lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_IS_PROTECTED, rDesc.IsReadonly());