diff options
author | PriyankaGaikwad <priyanka.gaikwad@synerzip.com> | 2014-01-02 14:52:46 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-01-13 16:21:22 +0100 |
commit | 5b6a41f44663590a878abed3d857d762ab3c4895 (patch) | |
tree | c1541801b90898c22a4994e0c977ca4d38dd7b91 | |
parent | a66b24f3cb53269e5a453ffc6102a83344343f54 (diff) |
fdo#69613:Fix for TOC field flag 'b' should preserved after RT.
(This is partial fix for this bug)
Implementation :
Provided import & export support for TOC field flag '\b'.
XML file difference :
Before :
<w:instrText>
TOC
</w:instrText>
After :
<w:instrText>
TOC \b "bookmark111" \o "1-9" \o "1-9" \h
</w:instrText>
Conflicts:
sw/inc/tox.hxx
sw/inc/unomap.hxx
sw/inc/unoprnms.hxx
sw/source/core/unocore/unomap.cxx
sw/source/filter/ww8/ww8atr.cxx
writerfilter/source/dmapper/DomainMapper_Impl.cxx
writerfilter/source/dmapper/PropertyIds.cxx
writerfilter/source/dmapper/PropertyIds.hxx
Reviewed on:
https://gerrit.libreoffice.org/7256
Change-Id: I194ba95ca8f25234c0d2a14570fd47eac518b9c5
-rw-r--r-- | sw/inc/tox.hxx | 18 | ||||
-rw-r--r-- | sw/inc/unomap.hxx | 1 | ||||
-rw-r--r-- | sw/inc/unoprnms.hxx | 1 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/TOC_field_b.docx | bin | 0 -> 15114 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 14 | ||||
-rw-r--r-- | sw/source/core/tox/tox.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/unocore/unoidx.cxx | 25 | ||||
-rw-r--r-- | sw/source/core/unocore/unomap.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 8 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 12 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyIds.cxx | 1 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyIds.hxx | 1 |
12 files changed, 87 insertions, 3 deletions
diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx index c4252a1c84dc..4ded582d456c 100644 --- a/sw/inc/tox.hxx +++ b/sw/inc/tox.hxx @@ -65,6 +65,7 @@ class SW_DLLPUBLIC SwTOXMark SwTxtTOXMark* pTxtAttr; sal_uInt16 nLevel; + OUString m_aBookmarkName; sal_Bool bAutoGenerated : 1; // generated using a concordance file sal_Bool bMainEntry : 1; // main entry emphasized by character style @@ -103,6 +104,8 @@ public: // content or user defined index inline void SetLevel(sal_uInt16 nLevel); inline sal_uInt16 GetLevel() const; + inline void SetBookmarkName( const OUString& bName); + inline OUString GetBookmarkName() const; // for alphabetical index only inline void SetPrimaryKey(const OUString& rStr ); @@ -400,6 +403,7 @@ namespace nsSwTOXElement const SwTOXElement TOX_SEQUENCE = 128; const SwTOXElement TOX_TABLEADER = 256; const SwTOXElement TOX_TAB_IN_TOC = 512; + const SwTOXElement TOX_BOOKMARK = 1024; } typedef sal_uInt16 SwTOIOptions; @@ -443,6 +447,7 @@ class SW_DLLPUBLIC SwTOXBase : public SwClient SwForm aForm; // description of the lines OUString aName; // unique name OUString aTitle; // title + OUString m_aBookmarkName; //Bookmark Name OUString sMainEntryCharStyle; // name of the character style applied to main index entries @@ -498,12 +503,14 @@ public: void DisableKeepExpression() {mbKeepExpression = sal_False;} OUString GetTitle() const; // Title + OUString GetBookmarkName() const; OUString GetTypeName() const; // Name const SwForm& GetTOXForm() const; // description of the lines void SetCreate(sal_uInt16); void SetTitle(const OUString& rTitle); void SetTOXForm(const SwForm& rForm); + void SetBookmarkName(const OUString& bName); TOXTypes GetType() const; @@ -582,6 +589,9 @@ public: inline OUString SwTOXMark::GetAlternativeText() const { return aAltText; } +inline OUString SwTOXMark::GetBookmarkName() const + { return m_aBookmarkName; } + inline const SwTOXType* SwTOXMark::GetTOXType() const { return (SwTOXType*)GetRegisteredIn(); } @@ -593,6 +603,11 @@ inline void SwTOXMark::SetAlternativeText(const OUString& rAlt) aAltText = rAlt; } +inline void SwTOXMark::SetBookmarkName(const OUString& bName) +{ + m_aBookmarkName = bName; +} + inline void SwTOXMark::SetLevel( sal_uInt16 nLvl ) { SAL_WARN_IF( GetTOXType() && GetTOXType()->GetType() == TOX_INDEX, "sw", "Wrong type"); @@ -712,6 +727,9 @@ inline sal_uInt16 SwTOXBase::GetCreateType() const inline OUString SwTOXBase::GetTitle() const { return aTitle; } +inline OUString SwTOXBase::GetBookmarkName() const + { return m_aBookmarkName; } + inline OUString SwTOXBase::GetTypeName() const { return GetTOXType()->GetTypeName(); } diff --git a/sw/inc/unomap.hxx b/sw/inc/unomap.hxx index e9e63a78218d..f0b72598e59b 100644 --- a/sw/inc/unomap.hxx +++ b/sw/inc/unomap.hxx @@ -218,6 +218,7 @@ #define WID_TEXT_READING 1058 #define WID_PRIMARY_KEY_READING 1059 #define WID_SECONDARY_KEY_READING 1060 +#define WID_TOC_BOOKMARK 1061 // Text document #define WID_DOC_CHAR_COUNT 1000 diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index da63af3c1d96..f4fc116db19f 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -123,6 +123,7 @@ #define UNO_NAME_CHAR_COLOR "CharColor" #define UNO_NAME_HIDE_TAB_LEADER_AND_PAGE_NUMBERS "HideTabLeaderAndPageNumber" #define UNO_NAME_TAB_IN_TOC "TabInTOC" +#define UNO_NAME_TOC_BOOKMARK "TOCBookmark" #define UNO_NAME_CHAR_FLASH "CharFlash" #define UNO_NAME_CHAR_KERNING "CharKerning" diff --git a/sw/qa/extras/ooxmlexport/data/TOC_field_b.docx b/sw/qa/extras/ooxmlexport/data/TOC_field_b.docx Binary files differnew file mode 100644 index 000000000000..b8ff32b3bb61 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/TOC_field_b.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 6dd2669cceef..4fe902d0fd7a 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2370,6 +2370,20 @@ DECLARE_OOXMLEXPORT_TEST(testPreserveZfield,"preserve_Z_field_TOC.docx") CPPUNIT_ASSERT(contents.match(" TOC \\z \\w \\f \\o \"1-3\" \\h")); } +DECLARE_OOXMLEXPORT_TEST(testFieldFlagB,"TOC_field_b.docx") +{ + // This test case is to verify \b flag. + xmlDocPtr pXmlDoc = parseExport(); + 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 \\b \"bookmark111\" \\o \"1-9\" \\h")); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index 3e8ddd363ab8..9dab768942da 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -565,6 +565,7 @@ SwTOXBase& SwTOXBase::CopyTOXBase( SwDoc* pDoc, const SwTOXBase& rSource ) nCreateType = rSource.nCreateType; aTitle = rSource.aTitle; aForm = rSource.aForm; + m_aBookmarkName = rSource.m_aBookmarkName; bProtected = rSource.bProtected; bFromChapter = rSource.bFromChapter; bFromObjectNames = rSource.bFromObjectNames; @@ -603,12 +604,18 @@ SwTOXBase::~SwTOXBase() void SwTOXBase::SetTitle(const OUString& rTitle) { aTitle = rTitle; } +void SwTOXBase::SetBookmarkName(const OUString& bName) +{ + m_aBookmarkName = bName; +} + SwTOXBase & SwTOXBase::operator = (const SwTOXBase & rSource) { aForm = rSource.aForm; aName = rSource.aName; aTitle = rSource.aTitle; + m_aBookmarkName = rSource.m_aBookmarkName; sMainEntryCharStyle = rSource.sMainEntryCharStyle; for(sal_uInt16 nLevel = 0; nLevel < MAXLEVEL; nLevel++) aStyleNames[nLevel] = rSource.aStyleNames[nLevel]; diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 33942aab9d67..06a695d68472 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -649,6 +649,13 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, rTOXBase.SetLevel(lcl_AnyToInt16(rValue)); } break; + case WID_TOC_BOOKMARK: + { + rTOXBase.SetBookmarkName(lcl_AnyToString(rValue)); + nCreate = nsSwTOXElement::TOX_BOOKMARK; + rTOXBase.SetCreate(nCreate); + } + break; case WID_CREATE_FROM_MARKS: lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_MARK); break; @@ -961,6 +968,9 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, case WID_LEVEL : aRet <<= static_cast<sal_Int16>(pTOXBase->GetLevel()); break; + case WID_TOC_BOOKMARK : + aRet <<= OUString(pTOXBase->GetBookmarkName()); + break; case WID_CREATE_FROM_MARKS: lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_MARK); break; @@ -1530,6 +1540,7 @@ public: sal_Bool m_bMainEntry; sal_uInt16 m_nLevel; + OUString m_aBookmarkName; OUString m_sAltText; OUString m_sPrimaryKey; OUString m_sSecondaryKey; @@ -2122,6 +2133,9 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, aMark.SetLevel(std::min( static_cast<sal_Int8>( MAXLEVEL ), static_cast<sal_Int8>(lcl_AnyToInt16(rValue)+1))); break; + case WID_TOC_BOOKMARK : + aMark.SetBookmarkName(lcl_AnyToString(rValue)); + break; case WID_PRIMARY_KEY : aMark.SetPrimaryKey(lcl_AnyToString(rValue)); break; @@ -2176,6 +2190,11 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, } } break; + case WID_TOC_BOOKMARK : + { + m_pImpl->m_aBookmarkName = lcl_AnyToString(rValue); + } + break; case WID_PRIMARY_KEY: m_pImpl->m_sPrimaryKey = lcl_AnyToString(rValue); break; @@ -2243,6 +2262,9 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, aRet <<= static_cast<sal_Int16>( m_pImpl->m_pTOXMark->GetLevel() - 1); break; + case WID_TOC_BOOKMARK : + aRet <<= OUString(m_pImpl->m_pTOXMark->GetBookmarkName()); + break; case WID_PRIMARY_KEY : aRet <<= OUString(m_pImpl->m_pTOXMark->GetPrimaryKey()); break; @@ -2284,6 +2306,9 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, case WID_LEVEL: aRet <<= static_cast<sal_Int16>(m_pImpl->m_nLevel); break; + case WID_TOC_BOOKMARK : + aRet <<= m_pImpl->m_aBookmarkName; + break; case WID_PRIMARY_KEY: aRet <<= m_pImpl->m_sPrimaryKey; break; diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index cb371d30cc6f..e3f9d1e626af 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -1415,6 +1415,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s { OUString(UNO_NAME_CREATE_FROM_MARKS), WID_CREATE_FROM_MARKS , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, { OUString(UNO_NAME_HIDE_TAB_LEADER_AND_PAGE_NUMBERS), WID_HIDE_TABLEADER_PAGENUMBERS , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, { 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_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}, @@ -1453,6 +1454,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s { OUString(UNO_NAME_CREATE_FROM_MARKS), WID_CREATE_FROM_MARKS , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, { OUString(UNO_NAME_HIDE_TAB_LEADER_AND_PAGE_NUMBERS), WID_HIDE_TABLEADER_PAGENUMBERS , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, { 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_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 b5ad57edfdd9..d2c9dace2ad6 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -2131,6 +2131,14 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect ) sStr += sEntryEnd; } } + if(nsSwTOXElement::TOX_BOOKMARK & pTOX->GetCreateType()) + { + sStr += "\\b "; + OUString bName = pTOX->GetBookmarkName(); + sStr += bName; + sStr += sEntryEnd; + } + if( nsSwTOXElement::TOX_OUTLINELEVEL & pTOX->GetCreateType() ) { // Take the TOC value of the max level to evaluate to as diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 3b9b52618763..9071835b37b3 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -2699,10 +2699,12 @@ void DomainMapper_Impl::handleToc bool bIsTabEntry = false ; sal_Int16 nMaxLevel = 10; + bool bBookmark=false; OUString sTemplate; OUString sChapterNoSeparator; OUString sFigureSequence; uno::Reference< beans::XPropertySet > xTOC; + OUString nBookmarkName; // \a Builds a table of figures but does not include the captions's label and number if( lcl_FindInCommand( pContext->GetCommand(), 'a', sValue )) @@ -2710,9 +2712,11 @@ void DomainMapper_Impl::handleToc bTableOfFigures = true; } // \b Uses a bookmark to specify area of document from which to build table of contents -// if( lcl_FindInCommand( pContext->GetCommand(), 'b', sValue )) -// { //todo: sValue contains the bookmark name - unsupported feature -// } + if( lcl_FindInCommand( pContext->GetCommand(), 'b', sValue )) + { + bBookmark = true; + nBookmarkName = sValue; + } if( lcl_FindInCommand( pContext->GetCommand(), 'c', sValue )) // \c Builds a table of figures of the given label { @@ -2811,6 +2815,8 @@ void DomainMapper_Impl::handleToc uno::UNO_QUERY_THROW); if (xTOC.is()) xTOC->setPropertyValue(rPropNameSupplier.GetName( PROP_TITLE ), uno::makeAny(OUString())); + if(bBookmark) + xTOC->setPropertyValue(rPropNameSupplier.GetName( PROP_TOC_BOOKMARK ), uno::makeAny(nBookmarkName)); if( !bTableOfFigures && xTOC.is() ) { xTOC->setPropertyValue( rPropNameSupplier.GetName( PROP_LEVEL ), uno::makeAny( nMaxLevel ) ); diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx index 669ae071e6bc..a6bda94dcf15 100644 --- a/writerfilter/source/dmapper/PropertyIds.cxx +++ b/writerfilter/source/dmapper/PropertyIds.cxx @@ -362,6 +362,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const case PROP_HORIZONTAL_MERGE: sName = "HorizontalMerge"; break; case PROP_HIDE_TAB_LEADER_AND_PAGE_NUMBERS : sName = "HideTabLeaderAndPageNumber" ; break ; case PROP_TAB_IN_TOC : sName = "TabInTOC"; break ; + case PROP_TOC_BOOKMARK: sName = "TOCBookmark"; break; } ::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt = m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName )); diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx index b8e6ae5d5340..c6cf976ae249 100644 --- a/writerfilter/source/dmapper/PropertyIds.hxx +++ b/writerfilter/source/dmapper/PropertyIds.hxx @@ -333,6 +333,7 @@ enum PropertyIds ,PROP_HORIZONTAL_MERGE ,PROP_HIDE_TAB_LEADER_AND_PAGE_NUMBERS ,PROP_TAB_IN_TOC + ,PROP_TOC_BOOKMARK }; struct PropertyNameSupplier_Impl; class PropertyNameSupplier |