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

Matteo Casalin matteo.casalin at yahoo.com
Sun Nov 24 05:47:41 PST 2013


 sw/source/core/access/accportions.cxx |    6 +--
 sw/source/core/crsr/callnk.cxx        |   54 +++++++++++++++-------------------
 sw/source/core/doc/docbm.cxx          |   22 +++++--------
 sw/source/core/doc/doccorr.cxx        |    2 -
 sw/source/core/doc/docedt.cxx         |   12 +++----
 sw/source/core/docnode/ndcopy.cxx     |    4 +-
 sw/source/core/docnode/ndsect.cxx     |   10 +++---
 sw/source/core/fields/ddefld.cxx      |    3 -
 sw/source/core/inc/UndoTable.hxx      |    2 -
 sw/source/core/inc/mvsave.hxx         |   12 +++----
 sw/source/core/txtnode/ndtxt.cxx      |    4 +-
 sw/source/core/undo/untbl.cxx         |   12 +++----
 sw/source/filter/ascii/ascatr.cxx     |   17 +++++-----
 13 files changed, 72 insertions(+), 88 deletions(-)

New commits:
commit 5cad3ba0bf5cb2e77ac565ca855ccf39626297d7
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Nov 24 14:34:45 2013 +0100

    Remove temporary and update assertion condition
    
    Change-Id: I0714b21cfda04bbaee0a7bd9ec485b3569a7ea4d

diff --git a/sw/source/core/access/accportions.cxx b/sw/source/core/access/accportions.cxx
index 102fb4d..2d0c6a4 100644
--- a/sw/source/core/access/accportions.cxx
+++ b/sw/source/core/access/accportions.cxx
@@ -354,13 +354,11 @@ sal_Int32 SwAccessiblePortionData::GetModelPosition( sal_Int32 nPos ) const
                       aAccessiblePositions[nPortionNo] ),
                     "accesability portion disagrees with text model" );
 
-        sal_Int32 nWithinPortion = nPos - aAccessiblePositions[nPortionNo];
-        nStartPos += nWithinPortion;
+        nStartPos += nPos - aAccessiblePositions[nPortionNo];
     }
     // else: return nStartPos unmodified
 
-    OSL_ENSURE( (nStartPos >= 0) && (nStartPos < USHRT_MAX),
-                "How can the SwTxtNode have so many characters?" );
+    OSL_ENSURE( nStartPos >= 0, "There's something weird in number of characters of SwTxtNode" );
     return nStartPos;
 }
 
commit 77768f585af39029fb2ec9df4f976b31593f447a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Nov 24 14:18:40 2013 +0100

    Bail out early
    
    Change-Id: Ic0bb06e3d64933df4887ce1402f62c16e917fdbd

diff --git a/sw/source/core/crsr/callnk.cxx b/sw/source/core/crsr/callnk.cxx
index 690c501..65eb900 100644
--- a/sw/source/core/crsr/callnk.cxx
+++ b/sw/source/core/crsr/callnk.cxx
@@ -74,32 +74,30 @@ SwCallLink::SwCallLink( SwCrsrShell & rSh )
 
 static void lcl_notifyRow(const SwCntntNode* pNode, SwCrsrShell& rShell)
 {
-    if ( pNode != NULL )
+    if ( !pNode )
+        return;
+
+    SwFrm *const pMyFrm = pNode->getLayoutFrm( rShell.GetLayout() );
+    if ( !pMyFrm )
+        return;
+
+    // We need to emulated a change of the row height in order
+    // to have the complete row redrawn
+    SwRowFrm *const pRow = pMyFrm->FindRowFrm();
+    if ( !pRow )
+        return;
+
+    const SwTableLine* pLine = pRow->GetTabLine( );
+    // Avoid redrawing the complete row if there are no nested tables
+    for (SwFrm *pCell = pRow->GetLower(); pCell; pCell = pCell->GetNext())
     {
-        SwFrm *myFrm = pNode->getLayoutFrm( rShell.GetLayout() );
-        if (myFrm!=NULL)
+        for (SwFrm *pContent = pCell->GetLower(); pContent; pContent = pContent->GetNext())
         {
-            // We need to emulated a change of the row height in order
-            // to have the complete row redrawn
-            SwRowFrm* pRow = myFrm->FindRowFrm();
-            if ( pRow )
+            if (pContent->GetType() == FRM_TAB)
             {
-                const SwTableLine* pLine = pRow->GetTabLine( );
-                // Avoid redrawing the complete row if there are no nested tables
-                bool bHasTable = false;
-                SwFrm *pCell = pRow->GetLower();
-                for (; pCell && !bHasTable; pCell = pCell->GetNext())
-                {
-                    SwFrm *pContent = pCell->GetLower();
-                    for (; pContent && !bHasTable; pContent = pContent->GetNext())
-                        if (pContent->GetType() == FRM_TAB)
-                            bHasTable = true;
-                }
-                if (bHasTable)
-                {
-                    SwFmtFrmSize pSize = pLine->GetFrmFmt()->GetFrmSize();
-                    pRow->ModifyNotification(NULL, &pSize);
-                }
+                SwFmtFrmSize pSize = pLine->GetFrmFmt()->GetFrmSize();
+                pRow->ModifyNotification(NULL, &pSize);
+                return;
             }
         }
     }
commit 9236d8242386965a9cd744fb64193d4e909e3519
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Nov 24 13:12:40 2013 +0100

    Reduce scope of some variables
    
    Change-Id: I2e2b10f95582c2c155ca78d4c7818ac38faa7a61

diff --git a/sw/source/core/crsr/callnk.cxx b/sw/source/core/crsr/callnk.cxx
index 44c84b3..690c501 100644
--- a/sw/source/core/crsr/callnk.cxx
+++ b/sw/source/core/crsr/callnk.cxx
@@ -164,15 +164,12 @@ SwCallLink::~SwCallLink()
             if ( ((SwTxtNode*)pCNd)->HasHints() )
             {
                 const SwpHints &rHts = ((SwTxtNode*)pCNd)->GetSwpHints();
-                sal_uInt16 n;
-                sal_Int32 nStart;
-                const sal_Int32 *pEnd;
 
-                for( n = 0; n < rHts.Count(); n++ )
+                for( sal_uInt16 n = 0; n < rHts.Count(); n++ )
                 {
                     const SwTxtAttr* pHt = rHts[ n ];
-                    pEnd = pHt->End();
-                    nStart = *pHt->GetStart();
+                    const sal_Int32 *pEnd = pHt->End();
+                    const sal_Int32 nStart = *pHt->GetStart();
 
                     // If "only start" or "start and end equal" then call on
                     // every overflow of start.
@@ -193,7 +190,6 @@ SwCallLink::~SwCallLink()
                         rShell.CallChgLnk();
                         return;
                     }
-                    nStart = 0;
                 }
             }
 
commit 12bdbfbc43b66b671d83deb6ddf8dfb09a9f5749
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Nov 24 13:05:05 2013 +0100

    STRING_LEN is no more the maximum string length + some cleanups
    
    Change-Id: Idbdfb4dd39ce5e419f7b9338db39ddda186d014d

diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index d33dead..35d6291 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -1223,22 +1223,20 @@ static std::vector<sal_uInt16> * lcl_RangesToVector(sal_uInt16 * pRanges)
 
 static bool lcl_StrLenOverFlow( const SwPaM& rPam )
 {
-    // If we try to merge two paragraph we have to test if afterwards
+    // If we try to merge two paragraphs we have to test if afterwards
     // the string doesn't exceed the allowed string length
-    bool bRet = false;
     if( rPam.GetPoint()->nNode != rPam.GetMark()->nNode )
     {
         const SwPosition* pStt = rPam.Start(), *pEnd = rPam.End();
         const SwTxtNode* pEndNd = pEnd->nNode.GetNode().GetTxtNode();
         if( (0 != pEndNd) && pStt->nNode.GetNode().IsTxtNode() )
         {
-            sal_uInt64 nSum = pStt->nContent.GetIndex() +
+            const sal_uInt64 nSum = pStt->nContent.GetIndex() +
                 pEndNd->GetTxt().getLength() - pEnd->nContent.GetIndex();
-            if( nSum > STRING_LEN )
-                bRet = true;
+            return nSum > static_cast<sal_uInt64>(SAL_MAX_INT32);
         }
     }
-    return bRet;
+    return false;
 }
 
 void sw_GetJoinFlags( SwPaM& rPam, sal_Bool& rJoinTxt, sal_Bool& rJoinPrev )
commit 2dda972cb91923333abb854be7a9d44a38a9fa36
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Nov 24 11:28:30 2013 +0100

    xub_StrLen to sal_Int32
    
    Change-Id: I8ad8cade0b2cbc29a934a983c72d25f7f00af6bc

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index b2e07d7..0c04ec9 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -926,14 +926,14 @@ namespace
             struct { sal_uInt16 nType, nCount; } TC;
             sal_uLong nTypeCount;
             } TYPECOUNT;
-        xub_StrLen nContent;
+        sal_Int32 nContent;
 
     public:
         _SwSaveTypeCountContent() { TYPECOUNT.nTypeCount = 0; nContent = 0; }
         _SwSaveTypeCountContent( const std::vector<sal_uLong> &rArr, sal_uInt16& rPos )
             {
                 TYPECOUNT.nTypeCount = rArr[ rPos++ ];
-                nContent = static_cast<xub_StrLen>(rArr[ rPos++ ]);
+                nContent = static_cast<sal_Int32>(rArr[ rPos++ ]);
             }
         void Add( std::vector<sal_uLong> &rArr )
         {
@@ -954,8 +954,8 @@ namespace
         void SetTypeAndCount( sal_uInt16 nT, sal_uInt16 nC )
             { TYPECOUNT.TC.nCount = nC; TYPECOUNT.TC.nType = nT; }
 
-        void SetContent( xub_StrLen n )     { nContent = n; }
-        xub_StrLen GetContent() const       { return nContent; }
+        void SetContent( sal_Int32 n )     { nContent = n; }
+        sal_Int32 GetContent() const       { return nContent; }
     };
 
     // #i59534: If a paragraph will be splitted we have to restore some redline positions
@@ -1235,7 +1235,7 @@ void _DelBookmarks(
 
 void _SaveCntntIdx(SwDoc* pDoc,
     sal_uLong nNode,
-    xub_StrLen nCntnt,
+    sal_Int32 nCntnt,
     std::vector<sal_uLong> &rSaveArr,
     sal_uInt8 nSaveFly)
 {
@@ -1454,7 +1454,7 @@ void _SaveCntntIdx(SwDoc* pDoc,
 void _RestoreCntntIdx(SwDoc* pDoc,
     std::vector<sal_uLong> &rSaveArr,
     sal_uLong nNode,
-    xub_StrLen nOffset,
+    sal_Int32 nOffset,
     bool bAuto)
 {
     SwCntntNode* pCNd = pDoc->GetNodes()[ nNode ]->GetCntntNode();
@@ -1616,8 +1616,8 @@ void _RestoreCntntIdx(SwDoc* pDoc,
 
 void _RestoreCntntIdx(std::vector<sal_uLong> &rSaveArr,
     const SwNode& rNd,
-    xub_StrLen nLen,
-    xub_StrLen nChkLen)
+    sal_Int32 nLen,
+    sal_Int32 nChkLen)
 {
     const SwDoc* pDoc = rNd.GetDoc();
     const SwRedlineTbl& rRedlTbl = pDoc->GetRedlineTbl();
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index 07984d9..7b59c1f 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -245,7 +245,7 @@ void SwDoc::CorrAbs(const SwNodeIndex& rStartNode,
 
 void PaMCorrRel( const SwNodeIndex &rOldNode,
                  const SwPosition &rNewPos,
-                 const xub_StrLen nOffset )
+                 const sal_Int32 nOffset )
 {
     const SwNode* pOldNode = &rOldNode.GetNode();
     SwPosition aNewPos( rNewPos );
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index d9bd0ca..d33dead 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -628,7 +628,7 @@ static void lcl_RestoreRedlines( SwDoc* pDoc, sal_uInt32 nInsPos, _SaveRedlines&
 // because of unnecessary expanded redlines
 // From now on this class saves the redline positions of all redlines which ends exact at the
 // insert position (node _and_ content index)
-_SaveRedlEndPosForRestore::_SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, xub_StrLen nCnt )
+_SaveRedlEndPosForRestore::_SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, sal_Int32 nCnt )
     : pSavArr( 0 ), pSavIdx( 0 ), nSavCntnt( nCnt )
 {
     SwNode& rNd = rInsIdx.GetNode();
diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index 0fd2613..27507ee 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -124,7 +124,7 @@ public:
 
     void SetRange( const SwNodeRange& );
     void AddBoxPos( SwDoc& rDoc, sal_uLong nNdIdx, sal_uLong nEndIdx,
-                    xub_StrLen nCntntIdx = STRING_MAXLEN);
+                    sal_Int32 nCntntIdx = SAL_MAX_INT32);
 };
 
 class SwUndoAttrTbl : public SwUndo
diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx
index 1cf3c6f..e79d83e 100644
--- a/sw/source/core/inc/mvsave.hxx
+++ b/sw/source/core/inc/mvsave.hxx
@@ -80,13 +80,13 @@ void _DelBookmarks(const SwNodeIndex& rStt,
     ::std::vector< ::sw::mark::SaveBookmark> * SaveBkmk =0,
     const SwIndex* pSttIdx =0,
     const SwIndex* pEndIdx =0);
-void _SaveCntntIdx( SwDoc* pDoc, sal_uLong nNode, xub_StrLen nCntnt,
+void _SaveCntntIdx( SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt,
                     std::vector<sal_uLong>& rSaveArr, sal_uInt8 nSaveFly = 0 );
 void _RestoreCntntIdx( SwDoc* pDoc, std::vector<sal_uLong>& rSaveArr,
-                        sal_uLong nNode, xub_StrLen nOffset = 0,
+                        sal_uLong nNode, sal_Int32 nOffset = 0,
                         bool bAuto = false );
 void _RestoreCntntIdx( std::vector<sal_uLong>& rSaveArr, const SwNode& rNd,
-                        xub_StrLen nLen, xub_StrLen nCorrLen );
+                        sal_Int32 nLen, sal_Int32 nCorrLen );
 
 
 /** data structure to temporarily hold fly anchor positions relative to some
@@ -143,7 +143,7 @@ void PaMCorrAbs( const SwPaM& rRange,
     // Setzt alle PaMs in OldNode auf relative Pos
 void PaMCorrRel( const SwNodeIndex &rOldNode,
                  const SwPosition &rNewPos,
-                 const xub_StrLen nOffset = 0 );
+                 const sal_Int32 nOffset = 0 );
 
 
 // Hilfsklasse zum kopieren von absatzgebundenen Flys. Durch die Sortierung
@@ -186,11 +186,11 @@ class _SaveRedlEndPosForRestore
 {
     std::vector<SwPosition*>* pSavArr;
     SwNodeIndex* pSavIdx;
-    xub_StrLen nSavCntnt;
+    sal_Int32 nSavCntnt;
 
     void _Restore();
 public:
-    _SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, xub_StrLen nCntnt );
+    _SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, sal_Int32 nCntnt );
     ~_SaveRedlEndPosForRestore();
     void Restore() { if( pSavArr ) _Restore(); }
 };
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 619e203..cc2b5de 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -626,7 +626,7 @@ SwCntntNode *SwTxtNode::JoinNext()
     {
         SwDoc* pDoc = rNds.GetDoc();
         std::vector<sal_uLong> aBkmkArr;
-        _SaveCntntIdx( pDoc, aIdx.GetIndex(), USHRT_MAX, aBkmkArr, SAVEFLY );
+        _SaveCntntIdx( pDoc, aIdx.GetIndex(), SAL_MAX_INT32, aBkmkArr, SAVEFLY );
         SwTxtNode *pTxtNode = aIdx.GetNode().GetTxtNode();
         sal_Int32 nOldLen = m_Text.getLength();
 
@@ -721,7 +721,7 @@ SwCntntNode *SwTxtNode::JoinPrev()
     {
         SwDoc* pDoc = rNds.GetDoc();
         std::vector<sal_uLong> aBkmkArr;
-        _SaveCntntIdx( pDoc, aIdx.GetIndex(), USHRT_MAX, aBkmkArr, SAVEFLY );
+        _SaveCntntIdx( pDoc, aIdx.GetIndex(), SAL_MAX_INT32, aBkmkArr, SAVEFLY );
         SwTxtNode *pTxtNode = aIdx.GetNode().GetTxtNode();
         const sal_Int32 nLen = pTxtNode->Len();
 
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 1b37616..f247ada 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -202,13 +202,13 @@ struct SwTblToTxtSave
 {
     sal_uLong m_nSttNd;
     sal_uLong m_nEndNd;
-    xub_StrLen m_nCntnt;
+    sal_Int32 m_nCntnt;
     SwHistory* m_pHstry;
     // metadata references for first and last paragraph in cell
     ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart;
     ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd;
 
-    SwTblToTxtSave( SwDoc& rDoc, sal_uLong nNd, sal_uLong nEndIdx, xub_StrLen nCntnt );
+    SwTblToTxtSave( SwDoc& rDoc, sal_uLong nNd, sal_uLong nEndIdx, sal_Int32 nCntnt );
     ~SwTblToTxtSave() { delete m_pHstry; }
 };
 
@@ -359,7 +359,7 @@ SwRewriter SwUndoInsTbl::GetRewriter() const
     return aRewriter;
 }
 
-SwTblToTxtSave::SwTblToTxtSave( SwDoc& rDoc, sal_uLong nNd, sal_uLong nEndIdx, xub_StrLen nCnt )
+SwTblToTxtSave::SwTblToTxtSave( SwDoc& rDoc, sal_uLong nNd, sal_uLong nEndIdx, sal_Int32 nCnt )
     : m_nSttNd( nNd ), m_nEndNd( nEndIdx), m_nCntnt( nCnt ), m_pHstry( 0 )
 {
     // keep attributes of the joined node
@@ -550,10 +550,10 @@ SwTableNode* SwNodes::UndoTableToText( sal_uLong nSttNd, sal_uLong nEndNd,
         const SwTblToTxtSave* pSave = &rSavedData[ --n ];
         // if the start node was merged with last from prev. cell,
         // subtract 1 from index to get the merged paragraph, and split that
-        aSttIdx = pSave->m_nSttNd - ( ( USHRT_MAX != pSave->m_nCntnt ) ? 1 : 0);
+        aSttIdx = pSave->m_nSttNd - ( ( SAL_MAX_INT32 != pSave->m_nCntnt ) ? 1 : 0);
         SwTxtNode* pTxtNd = aSttIdx.GetNode().GetTxtNode();
 
-        if( USHRT_MAX != pSave->m_nCntnt )
+        if( SAL_MAX_INT32 != pSave->m_nCntnt )
         {
             // split at ContentPosition, delete previous char (= separator)
             OSL_ENSURE( pTxtNd, "Where is my TextNode?" );
@@ -681,7 +681,7 @@ void SwUndoTblToTxt::SetRange( const SwNodeRange& rRg )
     nEndNd = rRg.aEnd.GetIndex();
 }
 
-void SwUndoTblToTxt::AddBoxPos( SwDoc& rDoc, sal_uLong nNdIdx, sal_uLong nEndIdx, xub_StrLen nCntntIdx )
+void SwUndoTblToTxt::AddBoxPos( SwDoc& rDoc, sal_uLong nNdIdx, sal_uLong nEndIdx, sal_Int32 nCntntIdx )
 {
     SwTblToTxtSave* pNew = new SwTblToTxtSave( rDoc, nNdIdx, nEndIdx, nCntntIdx );
     pBoxSaves->push_back( pNew );
commit 188886a3dcbe9b2ea156976dc61d870a47f59cf2
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Nov 23 16:37:53 2013 +0100

    Avoid temporary, just return the result
    
    Change-Id: I644abe042175168dab489476a41254fba6883982

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 554e3ae..b2e07d7 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -295,15 +295,11 @@ OUString IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix()
 
 bool IDocumentMarkAccess::IsLegalPaMForCrossRefHeadingBookmark( const SwPaM& rPaM )
 {
-    bool bRet( false );
-
-    bRet = rPaM.Start()->nNode.GetNode().IsTxtNode() &&
+    return rPaM.Start()->nNode.GetNode().IsTxtNode() &&
            rPaM.Start()->nContent.GetIndex() == 0 &&
            ( !rPaM.HasMark() ||
              ( rPaM.GetMark()->nNode == rPaM.GetPoint()->nNode &&
                rPaM.End()->nContent.GetIndex() == rPaM.End()->nNode.GetNode().GetTxtNode()->Len() ) );
-
-    return bRet;
 }
 
 namespace sw { namespace mark
commit 48264d6d478b54859482198a84afb3906ed40cb7
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Nov 23 16:35:21 2013 +0100

    Improve formatting
    
    Change-Id: I0cb8eb5b78ef5ca10d6b8765bff387ca09ec291c

diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index f45e374..30cb489 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -385,8 +385,8 @@ sal_uInt16 SwDoc::IsInsRegionAvailable( const SwPaM& rRange,
     if( rRange.HasMark() )
     {
         // See if we have a valid Section
-        const SwPosition* pStt = rRange.Start(),
-                        * pEnd = rRange.End();
+        const SwPosition* pStt = rRange.Start();
+        const SwPosition* pEnd = rRange.End();
 
         const SwCntntNode* pCNd = pEnd->nNode.GetNode().GetCntntNode();
         const SwNode* pNd = &pStt->nNode.GetNode();
@@ -397,9 +397,9 @@ sal_uInt16 SwDoc::IsInsRegionAvailable( const SwPaM& rRange,
             // Try to create an enclosing Section, but only if Start is
             // located at the Section's beginning and End at it's end
             nRet = 0;
-            if( !pStt->nContent.GetIndex() && pSectNd->GetIndex()
-                == pStt->nNode.GetIndex() - 1 && pEnd->nContent.GetIndex() ==
-                pCNd->Len() )
+            if( !pStt->nContent.GetIndex()
+                && pSectNd->GetIndex() == pStt->nNode.GetIndex() - 1
+                && pEnd->nContent.GetIndex() == pCNd->Len() )
             {
                 SwNodeIndex aIdx( pStt->nNode, -1 );
                 sal_uLong nCmp = pEnd->nNode.GetIndex();
commit 0215305c13b081ab929997cbd51e829f66425afb
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Nov 23 16:21:57 2013 +0100

    Prefer += and -=
    
    Change-Id: I0b1ba2e7c8287340eebec7eb9b3e1aea8945d82f

diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx
index b08e4b5..20796cc 100644
--- a/sw/source/core/docnode/ndcopy.cxx
+++ b/sw/source/core/docnode/ndcopy.cxx
@@ -114,10 +114,10 @@ namespace
         {
             // dann nur den Content anpassen
             if( nCntntPos > rOrigStt.nContent.GetIndex() )
-                nCntntPos = nCntntPos - rOrigStt.nContent.GetIndex();
+                nCntntPos -= rOrigStt.nContent.GetIndex();
             else
                 nCntntPos = 0;
-            nCntntPos = nCntntPos + rCpyStt.nContent.GetIndex();
+            nCntntPos += rCpyStt.nContent.GetIndex();
         }
         rChgPos.nContent.Assign( rChgPos.nNode.GetNode().GetCntntNode(), nCntntPos );
     }
commit 5294e6313c17bc83e2ae9442a2ce2fff9ae53625
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Nov 23 16:03:41 2013 +0100

    Use std::min + rename Ende to End
    
    Change-Id: I835d661a5bd30c235fdf61a94ad73f85b57bf9ed

diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx
index 7a3cf92..41e8475 100644
--- a/sw/source/filter/ascii/ascatr.cxx
+++ b/sw/source/filter/ascii/ascatr.cxx
@@ -35,6 +35,8 @@
 #include <fldbas.hxx>
 #include <ftninfo.hxx>
 
+#include <algorithm>
+
 /*
  * This file contains all output functions of the ASCII-Writer;
  * For all nodes, attributes, formats and chars.
@@ -175,11 +177,11 @@ static Writer& OutASC_SwTxtNode( Writer& rWrt, SwCntntNode& rNode )
     const SwTxtNode& rNd = (SwTxtNode&)rNode;
 
     sal_Int32 nStrPos = rWrt.pCurPam->GetPoint()->nContent.GetIndex();
-    const sal_Int32 nNodeEnde = rNd.Len();
-    sal_Int32 nEnde = nNodeEnde;
+    const sal_Int32 nNodeEnd = rNd.Len();
+    sal_Int32 nEnd = nNodeEnd;
     bool bLastNd =  rWrt.pCurPam->GetPoint()->nNode == rWrt.pCurPam->GetMark()->nNode;
     if( bLastNd )
-        nEnde = rWrt.pCurPam->GetMark()->nContent.GetIndex();
+        nEnd = rWrt.pCurPam->GetMark()->nContent.GetIndex();
 
     SwASC_AttrIter aAttrIter( (SwASCWriter&)rWrt, rNd, nStrPos );
 
@@ -201,10 +203,7 @@ static Writer& OutASC_SwTxtNode( Writer& rWrt, SwCntntNode& rNode )
                                     RTL_TEXTENCODING_UTF8 == rWrt.GetAsciiOptions().GetCharSet();
 
     do {
-        sal_Int32 nNextAttr = aAttrIter.WhereNext();
-
-        if( nNextAttr > nEnde )
-            nNextAttr = nEnde;
+        const sal_Int32 nNextAttr = std::min(aAttrIter.WhereNext(), nEnd);
 
         if( !aAttrIter.OutAttr( nStrPos ))
         {
@@ -216,11 +215,11 @@ static Writer& OutASC_SwTxtNode( Writer& rWrt, SwCntntNode& rNode )
         }
         nStrPos = nNextAttr;
         aAttrIter.NextPos();
-    } while( nStrPos < nEnde );
+    } while( nStrPos < nEnd );
 
     if( !bLastNd ||
         ( ( !rWrt.bWriteClipboardDoc && !rWrt.bASCII_NoLastLineEnd )
-            && !nStrPos && nEnde == nNodeEnde ) )
+            && !nStrPos && nEnd == nNodeEnd ) )
         rWrt.Strm().WriteUnicodeOrByteText( ((SwASCWriter&)rWrt).GetLineEnd());
 
     return rWrt;
commit 485331b1cdf588f3d2da657723c88ed243367f55
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Nov 23 15:45:58 2013 +0100

    Remove unneeded xub_StrLen cast
    
    Change-Id: Ia26f220fa7857f14dfc89b2929f60669ade3b4ea

diff --git a/sw/source/core/fields/ddefld.cxx b/sw/source/core/fields/ddefld.cxx
index 9b0bf97..981997c 100644
--- a/sw/source/core/fields/ddefld.cxx
+++ b/sw/source/core/fields/ddefld.cxx
@@ -63,8 +63,7 @@ public:
         {
             uno::Sequence< sal_Int8 > aSeq;
             rValue >>= aSeq;
-            OUString sStr( (sal_Char*)aSeq.getConstArray(), static_cast<xub_StrLen>(aSeq.getLength()),
-                               DDE_TXT_ENCODING  );
+            OUString sStr( (sal_Char*)aSeq.getConstArray(), aSeq.getLength(), DDE_TXT_ENCODING );
 
             // remove not needed CR-LF at the end
             sal_Int32 n = sStr.getLength();


More information about the Libreoffice-commits mailing list