From b1ac01de06262bda39be7f970fbceeda9b267fe4 Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sat, 14 Dec 2013 22:46:05 +0100 Subject: xub_StrLen/sal_uLong to sal_Int32 + minor optimizations Change-Id: Ibbca8e2d2a4742247648a611337bd8a75db7ee2f --- sw/inc/ndtxt.hxx | 65 +++++++++++++++++----------------- sw/source/core/doc/docedt.cxx | 3 +- sw/source/core/doc/doclay.cxx | 14 ++++---- sw/source/core/docnode/node.cxx | 2 +- sw/source/core/layout/layact.cxx | 2 +- sw/source/core/table/swtable.cxx | 2 +- sw/source/core/text/itratr.cxx | 17 ++++----- sw/source/core/txtnode/ndtxt.cxx | 49 ++++++++++++------------- sw/source/core/txtnode/thints.cxx | 29 ++++++++------- sw/source/core/txtnode/txtedt.cxx | 41 ++++++++++----------- sw/source/core/undo/undel.cxx | 2 +- sw/source/core/undo/undraw.cxx | 4 +-- sw/source/core/unocore/unoportenum.cxx | 14 ++++---- 13 files changed, 123 insertions(+), 121 deletions(-) diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 545cd8f1f163..3268232673a8 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -67,12 +67,11 @@ namespace com { namespace sun { namespace star { namespace text { class XTextContent; } } } } -typedef std::set< xub_StrLen > SwSoftPageBreakList; +typedef std::set< sal_Int32 > SwSoftPageBreakList; // do not fill the String up to the max - need to be able to have a // SwPosition "behind" the last character, i.e., at index TXTNODE_MAX + 1 -// (also STRING_LEN is often used for "not found") -const xub_StrLen TXTNODE_MAX = STRING_LEN - 2; +static const sal_Int32 TXTNODE_MAX = SAL_MAX_INT32 - 2; /// SwTxtNode is a paragraph in the document model. class SW_DLLPUBLIC SwTxtNode: public SwCntntNode, public ::sfx2::Metadatable @@ -124,14 +123,14 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode, public ::sfx2::Metadatable const SfxItemSet* pAutoAttr = 0 ); /// Copies the attributes at nStart to pDest. - SW_DLLPRIVATE void CopyAttr( SwTxtNode *pDest, const xub_StrLen nStart, const xub_StrLen nOldPos); + SW_DLLPRIVATE void CopyAttr( SwTxtNode *pDest, const sal_Int32 nStart, const sal_Int32 nOldPos); SW_DLLPRIVATE SwTxtNode* _MakeNewTxtNode( const SwNodeIndex&, sal_Bool bNext = sal_True, sal_Bool bChgFollow = sal_True ); SW_DLLPRIVATE void CutImpl( SwTxtNode * const pDest, const SwIndex & rDestStart, - const SwIndex & rStart, /*const*/ xub_StrLen nLen, + const SwIndex & rStart, /*const*/ sal_Int32 nLen, const bool bUpdate = true ); /// Move all comprising hard attributes to the AttrSet of the paragraph. @@ -251,7 +250,7 @@ public: ATTENTION: must not be called with a range that overlaps the start of an attribute with both extent and dummy char */ - void EraseText ( const SwIndex &rIdx, const xub_StrLen nCount = STRING_LEN, + void EraseText ( const SwIndex &rIdx, const sal_Int32 nCount = SAL_MAX_INT32, const enum IDocumentContentOperations::InsertFlags nMode = IDocumentContentOperations::INS_DEFAULT ); @@ -268,7 +267,7 @@ public: */ void RstTxtAttr( const SwIndex &rIdx, - const xub_StrLen nLen, + const sal_Int32 nLen, const sal_uInt16 nWhich = 0, const SfxItemSet* pSet = 0, const sal_Bool bInclRefToxMark = sal_False ); @@ -286,13 +285,13 @@ public: /// create new text attribute from rAttr and insert it /// @return inserted hint; 0 if not sure the hint is inserted SwTxtAttr* InsertItem( SfxPoolItem& rAttr, - const xub_StrLen nStart, const xub_StrLen nEnd, + const sal_Int32 nStart, const sal_Int32 nEnd, const SetAttrMode nMode = nsSetAttrMode::SETATTR_DEFAULT ); /** Set these attributes at TextNode. If the whole range is comprised set them only in AutoAttrSet (SwCntntNode::SetAttr). */ sal_Bool SetAttr( const SfxItemSet& rSet, - xub_StrLen nStt, xub_StrLen nEnd, + sal_Int32 nStt, sal_Int32 nEnd, const SetAttrMode nMode = nsSetAttrMode::SETATTR_DEFAULT ); /** Query the attributes of textnode over the range. Introduce 4th optional parameter . @@ -301,7 +300,7 @@ public: the requested item set as a LR-SPACE item, if == sal_False, corresponding node has not its own indent attributes and the position-and-space mode of the list level is SvxNumberFormat::LABEL_ALIGNMENT. */ - sal_Bool GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, + sal_Bool GetAttr( SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd, sal_Bool bOnlyTxtAttr = sal_False, sal_Bool bGetFromChrFmt = sal_True, const bool bMergeIndentValuesOfNumRule = false ) const; @@ -311,7 +310,7 @@ public: /// delete all attributes of type nWhich at nStart (opt. end nEnd) void DeleteAttributes( const sal_uInt16 nWhich, - const xub_StrLen nStart, const xub_StrLen nEnd = 0 ); + const sal_Int32 nStart, const sal_Int32 nEnd = 0 ); /// delete the attribute pTxtAttr void DeleteAttribute ( SwTxtAttr * const pTxtAttr ); @@ -319,25 +318,25 @@ public: introduce optional parameter to control, if all attributes have to be copied. */ void CopyText( SwTxtNode * const pDest, const SwIndex &rStart, - const xub_StrLen nLen, + const sal_Int32 nLen, const bool bForceCopyOfAllAttrs = false ); void CopyText( SwTxtNode * const pDest, const SwIndex &rDestStart, const SwIndex &rStart, - xub_StrLen nLen, + sal_Int32 nLen, const bool bForceCopyOfAllAttrs = false ); void CutText(SwTxtNode * const pDest, - const SwIndex & rStart, const xub_StrLen nLen); + const SwIndex & rStart, const sal_Int32 nLen); inline void CutText(SwTxtNode * const pDest, const SwIndex &rDestStart, - const SwIndex & rStart, const xub_StrLen nLen); + const SwIndex & rStart, const sal_Int32 nLen); /// replace nDelLen characters at rStart with rText /// in case the replacement does not fit, it is partially inserted up to /// TXTNODE_MAX - void ReplaceText( const SwIndex& rStart, const xub_StrLen nDelLen, + void ReplaceText( const SwIndex& rStart, const sal_Int32 nDelLen, const OUString & rText ); - void ReplaceTextOnly( xub_StrLen nPos, xub_StrLen nLen, + void ReplaceTextOnly( sal_Int32 nPos, sal_Int32 nLen, const OUString& rText, const ::com::sun::star::uno::Sequence& rOffsets ); @@ -368,7 +367,7 @@ public: RES_TXTATR_CHARFMT, RES_TXTATR_REFMARK, RES_TXTATR_TOXMARK */ SwTxtAttr *GetTxtAttrAt( - xub_StrLen const nIndex, + sal_Int32 const nIndex, RES_TXTATR const nWhich, enum GetTxtAttrMode const eMode = DEFAULT ) const; @@ -377,7 +376,7 @@ public: @param eMode the predicate for matching (@see GetTxtAttrMode). */ ::std::vector GetTxtAttrsAt( - xub_StrLen const nIndex, + sal_Int32 const nIndex, RES_TXTATR const nWhich, enum GetTxtAttrMode const eMode = DEFAULT ) const; @@ -389,14 +388,14 @@ public: @return the text attribute at nIndex of type nWhich, if it exists */ SwTxtAttr *GetTxtAttrForCharAt( - const xub_StrLen nIndex, + const sal_Int32 nIndex, const RES_TXTATR nWhich = RES_TXTATR_END ) const; SwTxtFld* GetFldTxtAttrAt( - const xub_StrLen nIndex, + const sal_Int32 nIndex, const bool bIncludeInputFldAtStart = false ) const; - OUString GetCurWord(xub_StrLen) const; + OUString GetCurWord(sal_Int32) const; sal_uInt16 Spell(SwSpellArgs*); sal_uInt16 Convert( SwConversionArgs & ); @@ -665,12 +664,12 @@ public: sal_uInt16 nScript = 0 ) const; /// in ndcopy.cxx - sal_Bool IsSymbol( const xub_StrLen nBegin ) const; // In itratr.cxx. + sal_Bool IsSymbol( const sal_Int32 nBegin ) const; // In itratr.cxx. virtual SwCntntNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const; /// Interactive hyphenation: we find TxtFrm and call its CalcHyph. sal_Bool Hyphenate( SwInterHyphInfo &rHyphInf ); - void DelSoftHyph( const xub_StrLen nStart, const xub_StrLen nEnd ); + void DelSoftHyph( const sal_Int32 nStart, const sal_Int32 nEnd ); /** add 4th optional parameter indicating, when that a space is inserted after the string for @@ -689,8 +688,8 @@ public: bool bWithNum = false, bool bWithFtn = true, bool bReplaceTabsWithSpaces = false ) const; - OUString GetRedlineTxt( xub_StrLen nIdx = 0, - xub_StrLen nLen = STRING_LEN, + OUString GetRedlineTxt( sal_Int32 nIdx = 0, + sal_Int32 nLen = SAL_MAX_INT32, sal_Bool bExpandFlds = sal_False, sal_Bool bWithNum = sal_False ) const; @@ -742,11 +741,11 @@ public: /// change text to Upper/Lower/Hiragana/Katagana/... void TransliterateText( utl::TransliterationWrapper& rTrans, - xub_StrLen nStart, xub_StrLen nEnd, + sal_Int32 nStart, sal_Int32 nEnd, SwUndoTransliterate* pUndo = 0 ); /// count words in given range - returns true if we refreshed out count - bool CountWords( SwDocStat& rStat, xub_StrLen nStart, xub_StrLen nEnd ) const; + bool CountWords( SwDocStat& rStat, sal_Int32 nStart, sal_Int32 nEnd ) const; /** Checks some global conditions like loading or destruction of document to economize notifications */ @@ -772,7 +771,7 @@ public: bool IsFirstOfNumRule() const; - sal_uInt16 GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd ) const; + sal_uInt16 GetScalingOfSelectedText( sal_Int32 nStt, sal_Int32 nEnd ) const; SW_DLLPRIVATE ::com::sun::star::uno::WeakReference< ::com::sun::star::text::XTextContent> const& GetXParagraph() const @@ -793,11 +792,11 @@ public: virtual void dumpAsXml( xmlTextWriterPtr writer = NULL ); - sal_uInt32 GetRsid( xub_StrLen nStt, xub_StrLen nEnd ) const; + sal_uInt32 GetRsid( sal_Int32 nStt, sal_Int32 nEnd ) const; sal_uInt32 GetParRsid() const; - bool CompareRsid( const SwTxtNode &rTxtNode, xub_StrLen nStt1, xub_StrLen nStt2, - xub_StrLen nEnd1 = 0, xub_StrLen nEnd2 = 0 ) const; + bool CompareRsid( const SwTxtNode &rTxtNode, sal_Int32 nStt1, sal_Int32 nStt2, + sal_Int32 nEnd1 = 0, sal_Int32 nEnd2 = 0 ) const; bool CompareParRsid( const SwTxtNode &rTxtNode ) const; DECL_FIXEDMEMPOOL_NEWDEL(SwTxtNode) @@ -851,7 +850,7 @@ inline const SwTxtNode *SwNode::GetTxtNode() const inline void SwTxtNode::CutText(SwTxtNode * const pDest, const SwIndex & rDestStart, - const SwIndex & rStart, const xub_StrLen nLen) + const SwIndex & rStart, const sal_Int32 nLen) { CutImpl( pDest, rDestStart, rStart, nLen, true ); } diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index a1d3e2ef219e..8171500b0c6e 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -714,7 +714,8 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const OUString &rStr ) SwTxtNode *pNode = rPt.nNode.GetNode().GetTxtNode(); if (!pNode || ( static_cast(rStr.getLength()) // worst case: no erase - + static_cast(pNode->GetTxt().getLength()) > TXTNODE_MAX)) + + static_cast(pNode->GetTxt().getLength()) + > static_cast(TXTNODE_MAX))) { return false; } diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 2ea2fb95d1fd..f41864fe2c78 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -633,8 +633,8 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, if (pTxtNode != NULL) { SwFmtFlyCnt aFmt( pFmt ); - bool const bSuccess( pTxtNode->InsertItem(aFmt, nStt, nStt) ); - if (!bSuccess) // may fail if there's no space left or header/ftr + // may fail if there's no space left or header/ftr + if (!pTxtNode->InsertItem(aFmt, nStt, nStt)) { // pFmt is dead now return 0; } @@ -925,10 +925,8 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, { const sal_Int32 nStt = rRg.GetPoint()->nContent.GetIndex(); SwFmtFlyCnt aFmt( pFmt ); - bool const bSuccess( // may fail if there's no space left - rRg.GetPoint()->nNode.GetNode().GetTxtNode()->InsertItem( - aFmt, nStt, nStt)); - if (!bSuccess) + // may fail if there's no space left + if (!rRg.GetPoint()->nNode.GetNode().GetTxtNode()->InsertItem(aFmt, nStt, nStt)) { // pFmt is dead now return 0; } @@ -1385,7 +1383,7 @@ lcl_InsertLabel(SwDoc & rDoc, SwTxtFmtColls *const pTxtFmtCollTbl, { aTxt += rSeparator; } - sal_Int32 nSepIdx = aTxt.getLength(); + const sal_Int32 nSepIdx = aTxt.getLength(); aTxt += rTxt; // Insert string @@ -1677,7 +1675,7 @@ lcl_InsertDrawLabel( SwDoc & rDoc, SwTxtFmtColls *const pTxtFmtCollTbl, } sal_Int32 nIdx = aTxt.getLength(); aTxt += rSeparator; - sal_Int32 nSepIdx = aTxt.getLength(); + const sal_Int32 nSepIdx = aTxt.getLength(); aTxt += rTxt; // insert text diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index e474cb6ae07b..acdc7c736c49 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1648,7 +1648,7 @@ static bool lcl_CheckMaxLength(SwNode const& rPrev, SwNode const& rNext) } size_t const nSum(static_cast(rPrev).GetTxt().getLength() + static_cast(rNext).GetTxt().getLength()); - return (nSum <= TXTNODE_MAX); + return (nSum <= static_cast(TXTNODE_MAX)); } /// Can we join two Nodes? diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index e9418cfadc33..4325e382c0ec 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -2080,7 +2080,7 @@ sal_Bool SwLayIdle::_DoIdleJob( const SwCntntFrm *pCnt, IdleJobType eJob ) break; case WORD_COUNT : { - const xub_StrLen nEnd = pTxtNode->GetTxt().getLength(); + const sal_Int32 nEnd = pTxtNode->GetTxt().getLength(); SwDocStat aStat; pTxtNode->CountWords( aStat, 0, nEnd ); if ( Application::AnyInput( VCL_INPUT_ANY ) ) diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index b51ee42305a2..59e44878fdd0 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2161,7 +2161,7 @@ void ChgNumToText( SwTableBox& rBox, sal_uLong nFmt ) // Reset DontExpand-Flags before exchange, to retrigger expansion pTNd->DontExpandFmt( aIdx, false, false ); aIdx = 0; - pTNd->EraseText( aIdx, STRING_LEN, + pTNd->EraseText( aIdx, SAL_MAX_INT32, IDocumentContentOperations::INS_EMPTYEXPAND ); pTNd->InsertText( sTmp, aIdx, IDocumentContentOperations::INS_EMPTYEXPAND ); diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index 743ce9e92ee2..a249ead0defd 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -428,7 +428,7 @@ static sal_Bool lcl_MinMaxString( SwMinMaxArgs& rArg, SwFont* pFnt, const OUStri return bRet; } -sal_Bool SwTxtNode::IsSymbol( const xub_StrLen nBegin ) const +sal_Bool SwTxtNode::IsSymbol( const sal_Int32 nBegin ) const { SwScriptInfo aScriptInfo; SwAttrIter aIter( *(SwTxtNode*)this, aScriptInfo ); @@ -819,7 +819,7 @@ void SwTxtNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rMa * changing this method very likely requires changing of "GetMinMaxSize" *************************************************************************/ -sal_uInt16 SwTxtNode::GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd ) +sal_uInt16 SwTxtNode::GetScalingOfSelectedText( sal_Int32 nStt, sal_Int32 nEnd ) const { SwViewShell* pSh = NULL; @@ -863,8 +863,8 @@ sal_uInt16 SwTxtNode::GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd return 100; } - nStt = (xub_StrLen)aBound.startPos; - nEnd = (xub_StrLen)aBound.endPos; + nStt = aBound.startPos; + nEnd = aBound.endPos; if ( nStt == nEnd ) { @@ -885,7 +885,7 @@ sal_uInt16 SwTxtNode::GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd aAttr.SetPriorityAttr( sal_True ); rAH.PushAndChg( aAttr, *(aIter.GetFnt()) ); - xub_StrLen nIdx = nStt; + sal_Int32 nIdx = nStt; sal_uLong nWidth = 0; sal_uLong nProWidth = 0; @@ -895,12 +895,9 @@ sal_uInt16 SwTxtNode::GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd aIter.SeekAndChgAttrIter( nIdx, pOut ); // scan for end of portion - xub_StrLen nNextChg = aIter.GetNextAttr(); - xub_StrLen nStop = aScriptInfo.NextScriptChg( nIdx ); - if( nNextChg > nStop ) - nNextChg = nStop; + const sal_Int32 nNextChg = std::max(aIter.GetNextAttr(), aScriptInfo.NextScriptChg( nIdx )); - nStop = nIdx; + sal_Int32 nStop = nIdx; sal_Unicode cChar = CH_BLANK; SwTxtAttr* pHint = NULL; diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 8f1a89299a17..f1aea8da3159 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -1249,7 +1249,7 @@ lcl_GetTxtAttrs( } ::std::vector -SwTxtNode::GetTxtAttrsAt(xub_StrLen const nIndex, RES_TXTATR const nWhich, +SwTxtNode::GetTxtAttrsAt(sal_Int32 const nIndex, RES_TXTATR const nWhich, enum GetTxtAttrMode const eMode) const { ::std::vector ret; @@ -1258,7 +1258,7 @@ SwTxtNode::GetTxtAttrsAt(xub_StrLen const nIndex, RES_TXTATR const nWhich, } SwTxtAttr * -SwTxtNode::GetTxtAttrAt(xub_StrLen const nIndex, RES_TXTATR const nWhich, +SwTxtNode::GetTxtAttrAt(sal_Int32 const nIndex, RES_TXTATR const nWhich, enum GetTxtAttrMode const eMode) const { assert( (nWhich == RES_TXTATR_META) @@ -1290,7 +1290,7 @@ const SwTxtInputFld* SwTxtNode::GetOverlappingInputFld( const SwTxtAttr& rTxtAtt } SwTxtFld* SwTxtNode::GetFldTxtAttrAt( - const xub_StrLen nIndex, + const sal_Int32 nIndex, const bool bIncludeInputFldAtStart ) const { SwTxtFld* pTxtFld = NULL; @@ -1456,8 +1456,8 @@ void lcl_CopyHint( |* gesetzt werden sollen. *************************************************************************/ -void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, - const xub_StrLen nOldPos ) +void SwTxtNode::CopyAttr( SwTxtNode *pDest, const sal_Int32 nTxtStartIdx, + const sal_Int32 nOldPos ) { if ( HasHints() ) // keine Attribute, keine Kekse { @@ -1519,7 +1519,7 @@ void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, // introduction of new optional parameter to control, if all attributes have to be copied. void SwTxtNode::CopyText( SwTxtNode *const pDest, const SwIndex &rStart, - const xub_StrLen nLen, + const sal_Int32 nLen, const bool bForceCopyOfAllAttrs ) { SwIndex const aIdx( pDest, pDest->m_Text.getLength() ); @@ -1530,7 +1530,7 @@ void SwTxtNode::CopyText( SwTxtNode *const pDest, void SwTxtNode::CopyText( SwTxtNode *const pDest, const SwIndex &rDestStart, const SwIndex &rStart, - xub_StrLen nLen, + sal_Int32 nLen, const bool bForceCopyOfAllAttrs ) { sal_Int32 nTxtStartIdx = rStart.GetIndex(); @@ -1644,7 +1644,7 @@ void SwTxtNode::CopyText( SwTxtNode *const pDest, // Del-Array fuer alle RefMarks ohne Ausdehnung SwpHts aRefMrkArr; - sal_uInt16 nDeletedDummyChars(0); + sal_Int32 nDeletedDummyChars(0); //Achtung: kann ungueltig sein!! for (sal_uInt16 n = 0; ( n < nSize ); ++n) { @@ -1920,7 +1920,7 @@ OUString SwTxtNode::InsertText( const OUString & rStr, const SwIndex & rIdx, *************************************************************************/ void SwTxtNode::CutText( SwTxtNode * const pDest, - const SwIndex & rStart, const xub_StrLen nLen ) + const SwIndex & rStart, const sal_Int32 nLen ) { if(pDest) { @@ -1937,7 +1937,7 @@ void SwTxtNode::CutText( SwTxtNode * const pDest, void SwTxtNode::CutImpl( SwTxtNode * const pDest, const SwIndex & rDestStart, - const SwIndex & rStart, xub_StrLen nLen, const bool bUpdate ) + const SwIndex & rStart, sal_Int32 nLen, const bool bUpdate ) { if(!pDest) { @@ -2286,13 +2286,13 @@ void SwTxtNode::CutImpl( SwTxtNode * const pDest, const SwIndex & rDestStart, } -void SwTxtNode::EraseText(const SwIndex &rIdx, const xub_StrLen nCount, +void SwTxtNode::EraseText(const SwIndex &rIdx, const sal_Int32 nCount, const IDocumentContentOperations::InsertFlags nMode ) { assert(rIdx <= m_Text.getLength()); // invalid index const sal_Int32 nStartIdx = rIdx.GetIndex(); - const sal_Int32 nCnt = (STRING_LEN == nCount) + const sal_Int32 nCnt = (nCount==SAL_MAX_INT32) ? m_Text.getLength() - nStartIdx : nCount; const sal_Int32 nEndIdx = nStartIdx + nCnt; m_Text = m_Text.replaceAt(nStartIdx, nCnt, ""); @@ -2697,7 +2697,7 @@ SwCntntNode* SwTxtNode::AppendNode( const SwPosition & rPos ) *************************************************************************/ SwTxtAttr * SwTxtNode::GetTxtAttrForCharAt( - const xub_StrLen nIndex, + const sal_Int32 nIndex, const RES_TXTATR nWhich ) const { if ( HasHints() ) @@ -2705,7 +2705,7 @@ SwTxtAttr * SwTxtNode::GetTxtAttrForCharAt( for ( sal_uInt16 i = 0; i < m_pSwpHints->Count(); ++i ) { SwTxtAttr * const pHint = m_pSwpHints->GetTextHint(i); - const xub_StrLen nStartPos = *pHint->GetStart(); + const sal_Int32 nStartPos = *pHint->GetStart(); if ( nIndex < nStartPos ) { return 0; @@ -3174,7 +3174,7 @@ bool SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, for ( sal_uInt16 i = 0; i < m_pSwpHints->Count(); i++ ) { const SwTxtAttr* pHt = (*m_pSwpHints)[i]; - const xub_StrLen nAttrStartIdx = *pHt->GetStart(); + const sal_Int32 nAttrStartIdx = *pHt->GetStart(); const sal_uInt16 nWhich = pHt->Which(); if (nIdx + nLen <= nAttrStartIdx) break; // ueber das Textende @@ -3212,7 +3212,7 @@ bool SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, SAL_INFO_IF(ins.getLength() != aExpand.getLength(), "sw.core", "GetExpandTxt lossage"); aDestIdx = nInsPos + nAttrStartIdx; - nInsPos = nInsPos + ins.getLength(); + nInsPos += ins.getLength(); } rDestNd.EraseText( aDestIdx, 1 ); --nInsPos; @@ -3247,7 +3247,7 @@ bool SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, SAL_INFO_IF(ins.getLength() != sExpand.getLength(), "sw.core", "GetExpandTxt lossage"); aDestIdx = nInsPos + nAttrStartIdx; - nInsPos = nInsPos + ins.getLength(); + nInsPos += ins.getLength(); } } rDestNd.EraseText( aDestIdx, 1 ); @@ -3308,7 +3308,7 @@ bool SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, return true; } -OUString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen, +OUString SwTxtNode::GetRedlineTxt( sal_Int32 nIdx, sal_Int32 nLen, sal_Bool bExpandFlds, sal_Bool bWithNum ) const { std::vector aRedlArr; @@ -3358,7 +3358,8 @@ OUString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen, ? GetTxt().copy(nIdx) : GetTxt().copy(nIdx, nLen)); - sal_Int32 nTxtStt = nIdx, nIdxEnd = nIdx + aTxt.getLength(); + sal_Int32 nTxtStt = nIdx; + sal_Int32 nIdxEnd = nIdx + aTxt.getLength(); for( size_t n = 0; n < aRedlArr.size(); n += 2 ) { sal_Int32 nStt = aRedlArr[ n ]; @@ -3371,7 +3372,7 @@ OUString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen, const sal_Int32 nDelCnt = nEnd - nStt; aTxt.remove(nStt - nTxtStt, nDelCnt); Replace0xFF(*this, aTxt, nTxtStt, nStt - nTxtStt, bExpandFlds); - nTxtStt = nTxtStt + nDelCnt; + nTxtStt += nDelCnt; } else if( nStt >= nIdxEnd ) break; @@ -3387,7 +3388,7 @@ OUString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen, * SwTxtNode::ReplaceText *************************************************************************/ -void SwTxtNode::ReplaceText( const SwIndex& rStart, const xub_StrLen nDelLen, +void SwTxtNode::ReplaceText( const SwIndex& rStart, const sal_Int32 nDelLen, const OUString & rStr) { assert( rStart.GetIndex() < m_Text.getLength() // index out of bounds @@ -4912,7 +4913,7 @@ sal_uInt16 SwTxtNode::ResetAllAttr() } -sal_uInt32 SwTxtNode::GetRsid( xub_StrLen nStt, xub_StrLen nEnd ) const +sal_uInt32 SwTxtNode::GetRsid( sal_Int32 nStt, sal_Int32 nEnd ) const { SfxItemSet aSet( (SfxItemPool&) (GetDoc()->GetAttrPool()), RES_CHRATR_RSID, RES_CHRATR_RSID ); if ( GetAttr(aSet, nStt, nEnd) ) @@ -4938,8 +4939,8 @@ bool SwTxtNode::CompareParRsid( const SwTxtNode &rTxtNode ) const return nThisRsid == nRsid; } -bool SwTxtNode::CompareRsid( const SwTxtNode &rTxtNode, xub_StrLen nStt1, xub_StrLen nStt2, - xub_StrLen nEnd1, xub_StrLen nEnd2 ) const +bool SwTxtNode::CompareRsid( const SwTxtNode &rTxtNode, sal_Int32 nStt1, sal_Int32 nStt2, + sal_Int32 nEnd1, sal_Int32 nEnd2 ) const { sal_uInt32 nThisRsid = GetRsid( nStt1, nEnd1 ? nEnd1 : nStt1 ); diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 64a813d29afa..f67a400176c0 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1200,7 +1200,7 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) SwTxtAttr* SwTxtNode::InsertItem( SfxPoolItem& rAttr, - const xub_StrLen nStart, const xub_StrLen nEnd, const SetAttrMode nMode ) + const sal_Int32 nStart, const sal_Int32 nEnd, const SetAttrMode nMode ) { // character attributes will be inserted as automatic styles: OSL_ENSURE( !isCHRATR(rAttr.Which()), "AUTOSTYLES - " @@ -1242,7 +1242,7 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) : IDocumentContentOperations::INS_EMPTYEXPAND; // need this after TryInsertHint, when pAttr may be deleted - const xub_StrLen nStart( *pAttr->GetStart() ); + const sal_Int32 nStart( *pAttr->GetStart() ); const bool bDummyChar( pAttr->HasDummyChar() ); if (bDummyChar) { @@ -1475,7 +1475,7 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) } // handle attributes which provide content - xub_StrLen nEnd = nStart; + sal_Int32 nEnd = nStart; bool bInputFieldStartCharInserted = false; bool bInputFieldEndCharInserted = false; const bool bHasContent( pAttr->HasContent() ); @@ -1668,8 +1668,8 @@ void SwTxtNode::DeleteAttribute( SwTxtAttr * const pAttr ) //FIXME: this does NOT respect SORT NUMBER (for CHARFMT)! void SwTxtNode::DeleteAttributes( const sal_uInt16 nWhich, - const xub_StrLen nStart, - const xub_StrLen nEnd ) + const sal_Int32 nStart, + const sal_Int32 nEnd ) { if ( !HasHints() ) return; @@ -1743,12 +1743,17 @@ void SwTxtNode::DeleteAttributes( * SwTxtNode::DelSoftHyph() *************************************************************************/ -void SwTxtNode::DelSoftHyph( const xub_StrLen nStt, const xub_StrLen nEnd ) +void SwTxtNode::DelSoftHyph( const sal_Int32 nStt, const sal_Int32 nEnd ) { - sal_Int32 nFndPos = nStt, nEndPos = nEnd; - while ((-1 != (nFndPos = m_Text.indexOf(CHAR_SOFTHYPHEN, nFndPos))) && - nFndPos < nEndPos ) + sal_Int32 nFndPos = nStt; + sal_Int32 nEndPos = nEnd; + for (;;) { + nFndPos = m_Text.indexOf(CHAR_SOFTHYPHEN, nFndPos); + if (nFndPos<0 || nFndPos>=nEndPos ) + { + break; + } const SwIndex aIdx( this, nFndPos ); EraseText( aIdx, 1 ); --nEndPos; @@ -1829,8 +1834,8 @@ bool SwTxtNode::TryCharSetExpandToNum(const SfxItemSet& aCharSet) // dann setze sie nur im AutoAttrSet (SwCntntNode:: SetAttr) sal_Bool SwTxtNode::SetAttr( const SfxItemSet& rSet, - const xub_StrLen nStt, - const xub_StrLen nEnd, + const sal_Int32 nStt, + const sal_Int32 nEnd, const SetAttrMode nMode ) { if( !rSet.Count() ) @@ -2047,7 +2052,7 @@ static void lcl_MergeListLevelIndentAsLRSpaceItem( const SwTxtNode& rTxtNode, } // erfrage die Attribute vom TextNode ueber den Bereich -sal_Bool SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, +sal_Bool SwTxtNode::GetAttr( SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd, sal_Bool bOnlyTxtAttr, sal_Bool bGetFromChrFmt, const bool bMergeIndentValuesOfNumRule ) const { diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 679a328fa210..2fba6e9e2c2b 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -371,7 +371,7 @@ static bool lcl_HaveCommonAttributes( IStyleAccess& rStyleAccess, void SwTxtNode::RstTxtAttr( const SwIndex &rIdx, - const xub_StrLen nLen, + const sal_Int32 nLen, const sal_uInt16 nWhich, const SfxItemSet* pSet, const sal_Bool bInclRefToxMark ) @@ -651,7 +651,7 @@ sal_Int32 clipIndexBounds(const OUString &rStr, sal_Int32 nPos) * Wenn dieses erste Wort nur aus Whitespaces besteht, returnen wir * einen leeren String. *************************************************************************/ -OUString SwTxtNode::GetCurWord( xub_StrLen nPos ) const +OUString SwTxtNode::GetCurWord( sal_Int32 nPos ) const { assert(nPos <= m_Text.getLength()); // invalid index @@ -682,7 +682,7 @@ OUString SwTxtNode::GetCurWord( xub_StrLen nPos ) const // check if word was found and if it uses a symbol font, if so // enforce returning an empty string - if (aBndry.endPos != aBndry.startPos && IsSymbol( (xub_StrLen)aBndry.startPos )) + if (aBndry.endPos != aBndry.startPos && IsSymbol( aBndry.startPos )) aBndry.endPos = aBndry.startPos; // can have -1 as start/end of bounds not found @@ -1618,8 +1618,8 @@ namespace { struct swTransliterationChgData { - xub_StrLen nStart; - xub_StrLen nLen; + sal_Int32 nStart; + sal_Int32 nLen; OUString sChanged; Sequence< sal_Int32 > aOffsets; }; @@ -1628,7 +1628,7 @@ namespace // change text to Upper/Lower/Hiragana/Katagana/... void SwTxtNode::TransliterateText( utl::TransliterationWrapper& rTrans, - xub_StrLen nStt, xub_StrLen nEnd, + sal_Int32 nStt, sal_Int32 nEnd, SwUndoTransliterate* pUndo ) { if (nStt < nEnd && g_pBreakIt->GetBreakIter().is()) @@ -1686,9 +1686,9 @@ void SwTxtNode::TransliterateText( Boundary aCurWordBndry( aSttBndry ); while (aCurWordBndry.startPos <= aEndBndry.startPos) { - nStt = (xub_StrLen)aCurWordBndry.startPos; - nEnd = (xub_StrLen)aCurWordBndry.endPos; - sal_Int32 nLen = nEnd - nStt; + nStt = aCurWordBndry.startPos; + nEnd = aCurWordBndry.endPos; + const sal_Int32 nLen = nEnd - nStt; OSL_ENSURE( nLen > 0, "invalid word length of 0" ); Sequence aOffsets; @@ -1812,8 +1812,8 @@ void SwTxtNode::TransliterateText( else pIter = 0; - xub_StrLen nEndPos; - sal_uInt16 nLang; + sal_Int32 nEndPos = 0; + sal_uInt16 nLang = LANGUAGE_NONE; do { if( pIter ) { @@ -1827,7 +1827,7 @@ void SwTxtNode::TransliterateText( nLang = LANGUAGE_SYSTEM; nEndPos = nEnd; } - xub_StrLen nLen = nEndPos - nStt; + const sal_Int32 nLen = nEndPos - nStt; Sequence aOffsets; OUString const sChgd( rTrans.transliterate( @@ -1860,8 +1860,8 @@ void SwTxtNode::TransliterateText( // call to ReplaceTextOnly swTransliterationChgData & rData = aChanges[ aChanges.size() - 1 - i ]; - nSum = nSum + rData.sChanged.getLength() - rData.nLen; - if (nSum > TXTNODE_MAX) + nSum += rData.sChanged.getLength() - rData.nLen; + if (nSum > static_cast(TXTNODE_MAX)) { SAL_WARN("sw.core", "SwTxtNode::ReplaceTextOnly: " "node text with insertion > TXTNODE_MAX."); @@ -1875,7 +1875,7 @@ void SwTxtNode::TransliterateText( } } -void SwTxtNode::ReplaceTextOnly( xub_StrLen nPos, xub_StrLen nLen, +void SwTxtNode::ReplaceTextOnly( sal_Int32 nPos, sal_Int32 nLen, const OUString & rText, const Sequence& rOffsets ) { @@ -1886,14 +1886,14 @@ void SwTxtNode::ReplaceTextOnly( xub_StrLen nPos, xub_StrLen nLen, sal_Int32 nTLen = rText.getLength(); const sal_Int32* pOffsets = rOffsets.getConstArray(); // now look for no 1-1 mapping -> move the indizies! - xub_StrLen nI, nMyOff; - for( nI = 0, nMyOff = nPos; nI < nTLen; ++nI, ++nMyOff ) + sal_Int32 nMyOff = nPos; + for( sal_Int32 nI = 0; nI < nTLen; ++nI ) { - xub_StrLen nOff = (xub_StrLen)pOffsets[ nI ]; + const sal_Int32 nOff = pOffsets[ nI ]; if( nOff < nMyOff ) { // something is inserted - xub_StrLen nCnt = 1; + sal_Int32 nCnt = 1; while( nI + nCnt < nTLen && nOff == pOffsets[ nI + nCnt ] ) ++nCnt; @@ -1908,6 +1908,7 @@ void SwTxtNode::ReplaceTextOnly( xub_StrLen nPos, xub_StrLen nLen, Update( SwIndex( this, nMyOff+1 ), nOff - nMyOff, sal_True ); nMyOff = nOff; } + ++nMyOff; } if( nMyOff < nLen ) // something is deleted at the end @@ -1924,7 +1925,7 @@ void SwTxtNode::ReplaceTextOnly( xub_StrLen nPos, xub_StrLen nLen, // the return values allows us to see if we did the heavy- // lifting required to actually break and count the words. bool SwTxtNode::CountWords( SwDocStat& rStat, - xub_StrLen nStt, xub_StrLen nEnd ) const + sal_Int32 nStt, sal_Int32 nEnd ) const { if( nStt > nEnd ) { // bad call diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index cb4f9a26e58b..7c427fbbb27d 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -343,7 +343,7 @@ sal_Bool SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd if( pSttTxtNd ) { bool bOneNode = nSttNode == nEndNode; - xub_StrLen nLen = bOneNode ? nEndCntnt - nSttCntnt + sal_Int32 nLen = bOneNode ? nEndCntnt - nSttCntnt : pSttTxtNd->GetTxt().getLength() - nSttCntnt; SwRegHistory aRHst( *pSttTxtNd, pHistory ); // always save all text atttibutes because of possibly overlapping diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index 948837742a5e..b766fc23f88b 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -129,7 +129,7 @@ static void lcl_SaveAnchor( SwFrmFmt* pFmt, sal_uLong& rNodePos ) (FLY_AS_CHAR == rAnchor.GetAnchorId())) { rNodePos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); - xub_StrLen nCntntPos = 0; + sal_Int32 nCntntPos = 0; if (FLY_AS_CHAR == rAnchor.GetAnchorId()) { @@ -166,7 +166,7 @@ static void lcl_RestoreAnchor( SwFrmFmt* pFmt, sal_uLong& rNodePos ) (FLY_AT_FLY == rAnchor.GetAnchorId()) || (FLY_AS_CHAR == rAnchor.GetAnchorId())) { - xub_StrLen nCntntPos = rAnchor.GetPageNum(); + const sal_Int32 nCntntPos = rAnchor.GetPageNum(); SwNodes& rNds = pFmt->GetDoc()->GetNodes(); SwNodeIndex aIdx( rNds, rNodePos ); diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 39955aa44319..f7f3c3e374ba 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -95,7 +95,7 @@ namespace , aPosition ( rPosition ) { } - sal_uLong getIndex () + sal_Int32 getIndex () { return aPosition.nContent.GetIndex(); } @@ -503,7 +503,7 @@ lcl_ExportBookmark( TextRangeList_t & rPortions, Reference const& xParent, const SwUnoCrsr * const pUnoCrsr, - SwXBookmarkPortion_ImplList& rBkmArr, const sal_uLong nIndex) + SwXBookmarkPortion_ImplList& rBkmArr, const sal_Int32 nIndex) { for ( SwXBookmarkPortion_ImplList::iterator aIter = rBkmArr.begin(), aEnd = rBkmArr.end(); aIter != aEnd; ) @@ -545,7 +545,7 @@ lcl_ExportSoftPageBreak( TextRangeList_t & rPortions, Reference const& xParent, const SwUnoCrsr * const pUnoCrsr, - SwSoftPageBreakList& rBreakArr, const sal_uLong nIndex) + SwSoftPageBreakList& rBreakArr, const sal_Int32 nIndex) { for ( SwSoftPageBreakList::iterator aIter = rBreakArr.begin(), aEnd = rBreakArr.end(); @@ -576,7 +576,7 @@ struct SwXRedlinePortion_Impl { } - sal_uLong getRealIndex () + sal_Int32 getRealIndex () { return m_bStart ? m_pRedline->Start()->nContent.GetIndex() : m_pRedline->End() ->nContent.GetIndex(); @@ -971,7 +971,7 @@ lcl_ExportRedline( TextRangeList_t & rPortions, Reference const& xParent, const SwUnoCrsr * const pUnoCrsr, - SwXRedlinePortion_ImplList& rRedlineArr, const sal_uLong nIndex) + SwXRedlinePortion_ImplList& rRedlineArr, const sal_Int32 nIndex) { // MTG: 23/11/05: We want this loop to iterate over all red lines in this @@ -980,7 +980,7 @@ lcl_ExportRedline( aIter != aEnd; ) { SwXRedlinePortion_ImplSharedPtr pPtr = (*aIter ); - sal_uLong nRealIndex = pPtr->getRealIndex(); + sal_Int32 nRealIndex = pPtr->getRealIndex(); // MTG: 23/11/05: If there are elements before nIndex, remove them if ( nIndex > nRealIndex ) rRedlineArr.erase ( aIter++ ); @@ -1005,7 +1005,7 @@ lcl_ExportBkmAndRedline( SwXBookmarkPortion_ImplList& rBkmArr, SwXRedlinePortion_ImplList& rRedlineArr, SwSoftPageBreakList& rBreakArr, - const sal_uLong nIndex) + const sal_Int32 nIndex) { if (!rBkmArr.empty()) lcl_ExportBookmark(rPortions, xParent, pUnoCrsr, rBkmArr, nIndex); -- cgit