[Libreoffice-commits] core.git: sw/inc sw/source

Oliver-Rainer Wittmann orw at apache.org
Fri Mar 28 08:34:23 PDT 2014


 sw/inc/tox.hxx                   |   19 ++++------
 sw/source/core/tox/tox.cxx       |   69 +++++++++++++--------------------------
 sw/source/filter/ww8/ww8par5.cxx |   28 ++++-----------
 3 files changed, 39 insertions(+), 77 deletions(-)

New commits:
commit f5c174ac30060db5b5aec2e9764f04252b64966e
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date:   Fri Mar 28 11:13:57 2014 +0000

    Resolves: #i124451# apply correct index entry template patterns...
    
    which are used for e.g. TOC
    
    (cherry picked from commit 52c89c2aff23dbb875c9a86021145b30af463908)
    
    Conflicts:
    	sw/inc/tox.hxx
    	sw/source/core/tox/tox.cxx
    	sw/source/filter/ww8/ww8par5.cxx
    
    Change-Id: Id14cecc07d09d3461c091a6451143cbce206e308

diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx
index a3108fb..360f1d4 100644
--- a/sw/inc/tox.hxx
+++ b/sw/inc/tox.hxx
@@ -348,10 +348,8 @@ public:
     void    SetPattern(sal_uInt16 nLevel, const OUString& rStr);
     const SwFormTokens& GetPattern(sal_uInt16 nLevel) const;
 
-    // fill tab stop positions from template to pattern
-    // #i21237#
-    void                    AdjustTabStops(SwDoc& rDoc,
-                                           sal_Bool bInsertNewTabStops = sal_False);
+    // fill tab stop positions from template to pattern- #i21237#
+    void AdjustTabStops( SwDoc& rDoc );
 
     inline TOXTypes GetTOXType() const;
     inline sal_uInt16   GetFormMax() const;
@@ -565,8 +563,12 @@ public:
     OUString        GetSortAlgorithm()const {return sSortAlgorithm;}
     void            SetSortAlgorithm(const OUString& rSet) {sSortAlgorithm = rSet;}
     // #i21237#
-    void AdjustTabStops(SwDoc & rDoc, sal_Bool bDefaultRightTabStop);
-    SwTOXBase&          operator=(const SwTOXBase& rSource);
+    void AdjustTabStops( SwDoc & rDoc )
+    {
+        aForm.AdjustTabStops( rDoc );
+    }
+
+    SwTOXBase& operator=(const SwTOXBase& rSource);
     void RegisterToTOXType( SwTOXType& rMark );
 };
 
@@ -734,11 +736,6 @@ inline OUString SwTOXBase::GetTypeName() const
 inline const SwForm& SwTOXBase::GetTOXForm() const
     { return aForm; }
 
-inline void SwTOXBase::AdjustTabStops(SwDoc & rDoc, sal_Bool bDefaultRightTabStop)
-{
-    aForm.AdjustTabStops(rDoc, bDefaultRightTabStop);
-}
-
 inline void SwTOXBase::SetCreate(sal_uInt16 nCreate)
     { nCreateType = nCreate; }
 
diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx
index e4a5964..1fac01f 100644
--- a/sw/source/core/tox/tox.cxx
+++ b/sw/source/core/tox/tox.cxx
@@ -406,76 +406,53 @@ bool operator == (const SwFormToken & rToken, FormTokenType eType)
     return rToken.eTokenType == eType;
 }
 
-void SwForm::AdjustTabStops(SwDoc& rDoc, sal_Bool bInsertNewTapStops) // #i21237#
+void SwForm::AdjustTabStops( SwDoc& rDoc ) // #i21237#
 {
     for(sal_uInt16 nLevel = 1; nLevel < GetFormMax(); nLevel++)
     {
         const OUString sTemplateName = GetTemplate(nLevel);
 
         SwTxtFmtColl* pColl = rDoc.FindTxtFmtCollByName( sTemplateName );
-        if( !pColl )
+        if( pColl == NULL )
         {
-            sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName
-                ( sTemplateName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ); // #i21237#
-            if( USHRT_MAX != nId )
+            const sal_uInt16 nId =
+                SwStyleNameMapper::GetPoolIdFromUIName( sTemplateName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
+            if ( USHRT_MAX != nId )
                 pColl = rDoc.GetTxtCollFromPool( nId );
         }
 
-        const SvxTabStopItem* pTabStops = 0;
-        sal_uInt16 nTabCount = 0;
-        if( pColl &&
-            0 != ( pTabStops = &pColl->GetTabStops(sal_False) ) &&
-            0 != ( nTabCount = pTabStops->Count() ) )
+        const SvxTabStopItem* pTabStops = pColl != NULL ? &pColl->GetTabStops(sal_False) : 0;
+        const sal_uInt16 nTabCount = pTabStops != NULL ? pTabStops->Count() : 0;
+        if( pTabStops != NULL
+            && nTabCount != 0 )
         {
-            // #i21237#
             SwFormTokens aCurrentPattern = GetPattern(nLevel);
             SwFormTokens::iterator aIt = aCurrentPattern.begin();
 
             bool bChanged = false;
-
             for(sal_uInt16 nTab = 0; nTab < nTabCount; ++nTab)
             {
                 const SvxTabStop& rTab = (*pTabStops)[nTab];
 
-                // #i29178#
-                // For Word import, we do not want to replace existing tokens,
-                // we insert new tabstop tokens without a tabstop character:
-                if ( bInsertNewTapStops )
+                aIt = find_if( aIt, aCurrentPattern.end(), SwFormTokenEqualToFormTokenType(TOKEN_TAB_STOP) );
+                if ( aIt != aCurrentPattern.end() )
                 {
-                    if ( SVX_TAB_ADJUST_DEFAULT != rTab.GetAdjustment() )
-                    {
-                        bChanged = true;
-                        SwFormToken aToken(TOKEN_TAB_STOP);
-                        aToken.bWithTab = sal_False;
-                        aToken.nTabStopPosition = rTab.GetTabPos();
-                        aToken.eTabAlign = rTab.GetAdjustment();
-                        aToken.cTabFillChar = rTab.GetFill();
-                        aCurrentPattern.push_back(aToken);
-                    }
+                    bChanged = true;
+                    aIt->nTabStopPosition = rTab.GetTabPos();
+                    aIt->eTabAlign =
+                        ( nTab == nTabCount - 1
+                          && rTab.GetAdjustment() == SVX_TAB_ADJUST_RIGHT )
+                        ? SVX_TAB_ADJUST_END
+                        : rTab.GetAdjustment();
+                    aIt->cTabFillChar = rTab.GetFill();
+                    ++aIt;
                 }
                 else
-                {
-                    aIt = find_if(aIt, aCurrentPattern.end(),
-                                  SwFormTokenEqualToFormTokenType
-                                  (TOKEN_TAB_STOP));
-                    if ( aIt != aCurrentPattern.end() )
-                    {
-                        bChanged = true;
-                        aIt->nTabStopPosition = rTab.GetTabPos();
-                        aIt->eTabAlign = nTab == nTabCount - 1 &&
-                                         SVX_TAB_ADJUST_RIGHT == rTab.GetAdjustment() ?
-                                         SVX_TAB_ADJUST_END :
-                                         rTab.GetAdjustment();
-                        aIt->cTabFillChar = rTab.GetFill();
-                        ++aIt;
-                    }
-                    else
-                        break; // no more tokens to replace
-                }
+                    break; // no more tokens to replace
             }
 
-            if(bChanged)
-                SetPattern(nLevel, aCurrentPattern); // #i21237#
+            if ( bChanged )
+                SetPattern( nLevel, aCurrentPattern );
         }
     }
 }
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index eb09b7b..562ad9e 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -3232,17 +3232,11 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
                         for(sal_uInt16 nLevel = 1; nLevel <= nNewEnd; ++nLevel)
                         {
                             SwFormTokens aPattern = aOldForm.GetPattern(nLevel);
-
-                            SwFormTokens::iterator new_end=remove_if(aPattern.begin(), aPattern.end(),
-                                      SwFormTokenEqualToFormTokenType(TOKEN_ENTRY_NO));
-
-                            // table index imported with wrong page number format
-                            aPattern.erase (new_end, aPattern.end() );
-
-                            aNewForm.SetPattern(nLevel, aPattern);
-
-                            aNewForm.SetTemplate( nLevel,
-                                aOldForm.GetTemplate(nLevel));
+                            SwFormTokens::iterator new_end =
+                                remove_if(aPattern.begin(), aPattern.end(), SwFormTokenEqualToFormTokenType(TOKEN_ENTRY_NO));
+                            aPattern.erase(new_end, aPattern.end() ); // table index imported with wrong page number format
+                            aForm.SetPattern( nLevel, aPattern );
+                            aForm.SetTemplate( nLevel, aOldForm.GetTemplate(nLevel) );
                         }
 
                         pBase->SetTOXForm( aNewForm );
@@ -3261,16 +3255,10 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
         break;
     } // ToxBase fertig
 
-    // no Update of TOC anymore as its actual content is imported and kept.
-    //rDoc.SetUpdateTOX(true);
-
-    // #i21237# - propagate tab stops from paragraph styles
-    // used in TOX to patterns of the TOX
-
-    pBase->AdjustTabStops(rDoc, sal_True);
-
-    // #i10028# - inserting a toc implictly acts like a parabreak in word and writer
+    // #i21237# - propagate tab stops from paragraph styles used in TOX to patterns of the TOX
+    pBase->AdjustTabStops( rDoc );
 
+    //#i10028# inserting a toc implicltly acts like a parabreak in word and writer
     if ( pPaM->End() &&
          pPaM->End()->nNode.GetNode().GetTxtNode() &&
          pPaM->End()->nNode.GetNode().GetTxtNode()->Len() != 0 )


More information about the Libreoffice-commits mailing list