[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - 2 commits - sw/source writerfilter/source

Cédric Bosdonnat cedric.bosdonnat at free.fr
Mon Jul 22 10:01:04 PDT 2013


 sw/source/core/tox/tox.cxx                        |    8 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |  102 +++++++++++++---------
 2 files changed, 69 insertions(+), 41 deletions(-)

New commits:
commit 3b8d2fe1382618ab247db89a6c508f537e416098
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Thu Jul 18 16:38:39 2013 +0200

    n#825976: Table of Illustration has hyperlinks by default like TOC
    
    ...and that fixes the formatting of hyperlinks in docx Tableoof
    Illustrations.
    
    (cherry picked from commit c1fac43432891bf9f396ff1ec7a1c2ed042bce54)
    (cherry picked from commit 49d077b80c15ec9d069435da08bbfe38cdd57c5a)
    
    Change-Id: I990f31a8c9d0d56f58b7b87e368010576d8c8c0d
    (cherry picked from commit fb7b24dc5affb4f29f61a8716c97370951ccba80)
    Reviewed-on: https://gerrit.libreoffice.org/5028
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx
index 677d84f..8b98989 100644
--- a/sw/source/core/tox/tox.cxx
+++ b/sw/source/core/tox/tox.cxx
@@ -310,11 +310,15 @@ SwForm::SwForm( TOXTypes eTyp ) // #i21237#
     }
 
     SwFormTokens aTokens;
-    if (TOX_CONTENT == eType)
+    if (TOX_CONTENT == eType || TOX_ILLUSTRATIONS == eType )
     {
         SwFormToken aLinkStt (TOKEN_LINK_START);
         aLinkStt.sCharStyleName = String(SW_RES(STR_POOLCHR_TOXJUMP));
         aTokens.push_back(aLinkStt);
+    }
+
+    if (TOX_CONTENT == eType)
+    {
         aTokens.push_back(SwFormToken(TOKEN_ENTRY_NO));
         aTokens.push_back(SwFormToken(TOKEN_ENTRY_TEXT));
     }
@@ -334,7 +338,7 @@ SwForm::SwForm( TOXTypes eTyp ) // #i21237#
         aTokens.push_back(SwFormToken(TOKEN_PAGE_NUMS));
     }
 
-    if (TOX_CONTENT == eType)
+    if (TOX_CONTENT == eType || TOX_ILLUSTRATIONS == eType)
         aTokens.push_back(SwFormToken(TOKEN_LINK_END));
 
     SetTemplate( 0, SW_RESSTR( nPoolId++ ));
commit fdb5bd8e1af6796ab3436aba4fa903c0fdb6c221
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Thu Jul 18 15:04:00 2013 +0200

    n#825976: handle TOC \h field for illustrations tables in writerfilter
    
    Change-Id: I9ebc91d5f0e706dc1e316e0aa8494af7aec4da4e
    (cherry picked from commit 43f7bc96c0117a77610bfa5e1edfa870123f56f1)
    (cherry picked from commit f494d9dfd1c0c40eae7aa69a86c3aa4c45971a29)
    Reviewed-on: https://gerrit.libreoffice.org/5027
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index c437471..a1a4d66 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2540,6 +2540,53 @@ void DomainMapper_Impl::handleAuthor
 #undef SET_DATE
 }
 
+uno::Sequence< beans::PropertyValues > lcl_createTOXLevelHyperlinks( bool bHyperlinks, OUString sChapterNoSeparator,
+                                   uno::Sequence< beans::PropertyValues >aLevel,
+                                   PropertyNameSupplier& rPropNameSupplier )
+{
+    //create a copy of the level and add two new entries - hyperlink start and end
+    bool bChapterNoSeparator  = !sChapterNoSeparator.isEmpty();
+    sal_Int32 nAdd = (bHyperlinks && bChapterNoSeparator) ? 4 : 2;
+    uno::Sequence< beans::PropertyValues > aNewLevel( aLevel.getLength() + nAdd);
+    beans::PropertyValues* pNewLevel = aNewLevel.getArray();
+    if( bHyperlinks )
+    {
+        beans::PropertyValues aHyperlink(1);
+        aHyperlink[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
+        aHyperlink[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_HYPERLINK_START );
+        pNewLevel[0] = aHyperlink;
+        aHyperlink[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_HYPERLINK_END );
+        pNewLevel[aNewLevel.getLength() -1] = aHyperlink;
+    }
+    if( bChapterNoSeparator )
+    {
+        beans::PropertyValues aChapterNo(2);
+        aChapterNo[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
+        aChapterNo[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_CHAPTER_INFO );
+        aChapterNo[1].Name = rPropNameSupplier.GetName( PROP_CHAPTER_FORMAT );
+        //todo: is ChapterFormat::Number correct?
+        aChapterNo[1].Value <<= (sal_Int16)text::ChapterFormat::NUMBER;
+        pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 4 : 2) ] = aChapterNo;
+
+        beans::PropertyValues aChapterSeparator(2);
+        aChapterSeparator[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
+        aChapterSeparator[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_TEXT );
+        aChapterSeparator[1].Name = rPropNameSupplier.GetName( PROP_TEXT );
+        aChapterSeparator[1].Value <<= sChapterNoSeparator;
+        pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 3 : 1)] = aChapterSeparator;
+    }
+    //copy the 'old' entries except the last (page no)
+    for( sal_Int32 nToken = 0; nToken < aLevel.getLength() - 1; ++nToken)
+    {
+        pNewLevel[nToken + 1] = aLevel[nToken];
+    }
+    //copy page no entry (last or last but one depending on bHyperlinks
+    sal_Int32 nPageNo = aNewLevel.getLength() - (bHyperlinks ? 2 : 3);
+    pNewLevel[nPageNo] = aLevel[aLevel.getLength() - 1];
+
+    return aNewLevel;
+}
+
 void DomainMapper_Impl::handleToc
     (FieldContextPtr pContext,
     PropertyNameSupplier& rPropNameSupplier,
@@ -2716,46 +2763,10 @@ void DomainMapper_Impl::handleToc
             {
                 uno::Sequence< beans::PropertyValues > aLevel;
                 xLevelFormats->getByIndex( nLevel ) >>= aLevel;
-                                //create a copy of the level and add two new entries - hyperlink start and end
-                bool bChapterNoSeparator  = !sChapterNoSeparator.isEmpty();
-                sal_Int32 nAdd = (bHyperlinks && bChapterNoSeparator) ? 4 : 2;
-                uno::Sequence< beans::PropertyValues > aNewLevel( aLevel.getLength() + nAdd);
-                beans::PropertyValues* pNewLevel = aNewLevel.getArray();
-                if( bHyperlinks )
-                {
-                    beans::PropertyValues aHyperlink(1);
-                    aHyperlink[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
-                    aHyperlink[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_HYPERLINK_START );
-                    pNewLevel[0] = aHyperlink;
-                    aHyperlink[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_HYPERLINK_END );
-                    pNewLevel[aNewLevel.getLength() -1] = aHyperlink;
-                }
-                if( bChapterNoSeparator )
-                {
-                    beans::PropertyValues aChapterNo(2);
-                    aChapterNo[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
-                    aChapterNo[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_CHAPTER_INFO );
-                    aChapterNo[1].Name = rPropNameSupplier.GetName( PROP_CHAPTER_FORMAT );
-                                    //todo: is ChapterFormat::Number correct?
-                    aChapterNo[1].Value <<= (sal_Int16)text::ChapterFormat::NUMBER;
-                    pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 4 : 2) ] = aChapterNo;
-
-                    beans::PropertyValues aChapterSeparator(2);
-                    aChapterSeparator[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
-                    aChapterSeparator[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_TEXT );
-                    aChapterSeparator[1].Name = rPropNameSupplier.GetName( PROP_TEXT );
-                    aChapterSeparator[1].Value <<= sChapterNoSeparator;
-                    pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 3 : 1)] = aChapterSeparator;
-                }
-                                //copy the 'old' entries except the last (page no)
-                for( sal_Int32 nToken = 0; nToken < aLevel.getLength() - 1; ++nToken)
-                {
-                    pNewLevel[nToken + 1] = aLevel[nToken];
-                }
-                                //copy page no entry (last or last but one depending on bHyperlinks
-                sal_Int32 nPageNo = aNewLevel.getLength() - (bHyperlinks ? 2 : 3);
-                pNewLevel[nPageNo] = aLevel[aLevel.getLength() - 1];
 
+                uno::Sequence< beans::PropertyValues > aNewLevel = lcl_createTOXLevelHyperlinks(
+                                                    bHyperlinks, sChapterNoSeparator,
+                                                    aLevel, rPropNameSupplier );
                 xLevelFormats->replaceByIndex( nLevel, uno::makeAny( aNewLevel ) );
             }
         }
@@ -2765,6 +2776,19 @@ void DomainMapper_Impl::handleToc
         if (!sFigureSequence.isEmpty())
             xTOC->setPropertyValue(rPropNameSupplier.GetName(PROP_LABEL_CATEGORY),
                                    uno::makeAny(sFigureSequence));
+
+        if ( bHyperlinks )
+        {
+            uno::Reference< container::XIndexReplace> xLevelFormats;
+            xTOC->getPropertyValue(rPropNameSupplier.GetName(PROP_LEVEL_FORMAT)) >>= xLevelFormats;
+            uno::Sequence< beans::PropertyValues > aLevel;
+            xLevelFormats->getByIndex( 1 ) >>= aLevel;
+
+            uno::Sequence< beans::PropertyValues > aNewLevel = lcl_createTOXLevelHyperlinks(
+                                                bHyperlinks, sChapterNoSeparator,
+                                                aLevel, rPropNameSupplier );
+            xLevelFormats->replaceByIndex( 1, uno::makeAny( aNewLevel ) );
+        }
     }
     pContext->SetTOC( xTOC );
 }


More information about the Libreoffice-commits mailing list