summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2013-12-28 13:37:26 +0100
committerMatteo Casalin <matteo.casalin@yahoo.com>2013-12-28 22:40:42 +0100
commit73f0b3bd5553c5d023d0a1dbfdc00836e2937961 (patch)
tree96d2f32a4fc4af9fca6da594e11097df4af64f47 /editeng
parent4b9f28c87fec24978b3e43765b8aa312ab5a8817 (diff)
xub_StrLen to sal_Int32 + some const
Change-Id: Ieae0940d3d072c3214b4fa2280dd0e01dc328cb7
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editdoc.cxx2
-rw-r--r--editeng/source/editeng/editdoc.hxx14
-rw-r--r--editeng/source/editeng/editview.cxx2
-rw-r--r--editeng/source/editeng/impedit.cxx6
-rw-r--r--editeng/source/editeng/impedit2.cxx85
-rw-r--r--editeng/source/editeng/impedit3.cxx16
-rw-r--r--editeng/source/editeng/impedit4.cxx69
-rw-r--r--editeng/source/editeng/impedit5.cxx24
8 files changed, 95 insertions, 123 deletions
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 26c2b24d58c3..0ec7b0d8ddf3 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -1165,7 +1165,7 @@ void EditLineList::Insert(size_t nPos, EditLine* p)
EditPaM::EditPaM() : pNode(NULL), nIndex(0) {}
EditPaM::EditPaM(const EditPaM& r) : pNode(r.pNode), nIndex(r.nIndex) {}
-EditPaM::EditPaM(ContentNode* p, sal_uInt16 n) : pNode(p), nIndex(n) {}
+EditPaM::EditPaM(ContentNode* p, sal_Int32 n) : pNode(p), nIndex(n) {}
const ContentNode* EditPaM::GetNode() const
{
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 40676d5da5c8..4d2479a30e7b 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -57,10 +57,10 @@ class EditDoc;
struct EPaM
{
sal_Int32 nPara;
- sal_uInt16 nIndex;
+ sal_Int32 nIndex;
EPaM() { nPara = 0; nIndex = 0; }
- EPaM( sal_Int32 nP, sal_uInt16 nI ) { nPara = nP; nIndex = nI; }
+ EPaM( sal_Int32 nP, sal_Int32 nI ) { nPara = nP; nIndex = nI; }
EPaM( const EPaM& r) { nPara = r.nPara; nIndex = r.nIndex; }
EPaM& operator = ( const EPaM& r ) { nPara = r.nPara; nIndex = r.nIndex; return *this; }
inline sal_Bool operator == ( const EPaM& r ) const;
@@ -314,20 +314,20 @@ class EditPaM
{
private:
ContentNode* pNode;
- sal_uInt16 nIndex;
+ sal_Int32 nIndex;
public:
EditPaM();
EditPaM(const EditPaM& r);
- EditPaM(ContentNode* p, sal_uInt16 n);
+ EditPaM(ContentNode* p, sal_Int32 n);
const ContentNode* GetNode() const;
ContentNode* GetNode();
void SetNode(ContentNode* p);
- sal_uInt16 GetIndex() const { return nIndex; }
- sal_uInt16& GetIndex() { return nIndex; }
- void SetIndex( sal_uInt16 n ) { nIndex = n; }
+ sal_Int32 GetIndex() const { return nIndex; }
+ sal_Int32& GetIndex() { return nIndex; }
+ void SetIndex( sal_Int32 n ) { nIndex = n; }
sal_Bool DbgIsBuggy( EditDoc& rDoc );
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 18b0c9a15686..bd07d8a7b869 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1208,7 +1208,7 @@ const SvxFieldItem* EditView::GetFieldAtSelection() const
{
EditPaM aPaM = aSel.Min();
const CharAttribList::AttribsType& rAttrs = aPaM.GetNode()->GetCharAttribs().GetAttribs();
- sal_uInt16 nXPos = aPaM.GetIndex();
+ const sal_Int32 nXPos = aPaM.GetIndex();
for (size_t nAttr = rAttrs.size(); nAttr; )
{
const EditCharAttrib& rAttr = rAttrs[--nAttr];
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 0736d05c7060..cbf6c0e2e286 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -215,8 +215,8 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, Region* pRegion, OutputD
DBG_ASSERT( pLine, "Line not found: DrawSelection()" );
sal_Bool bPartOfLine = sal_False;
- sal_uInt16 nStartIndex = pLine->GetStart();
- sal_uInt16 nEndIndex = pLine->GetEnd();
+ sal_Int32 nStartIndex = pLine->GetStart();
+ sal_Int32 nEndIndex = pLine->GetEnd();
if ( ( nPara == nStartPara ) && ( nLine == nStartLine ) && ( nStartIndex != aTmpSel.Min().GetIndex() ) )
{
nStartIndex = aTmpSel.Min().GetIndex();
@@ -1188,7 +1188,7 @@ const SvxFieldItem* ImpEditView::GetField( const Point& rPos, sal_Int32* pPara,
}
const CharAttribList::AttribsType& rAttrs = aPaM.GetNode()->GetCharAttribs().GetAttribs();
- sal_uInt16 nXPos = aPaM.GetIndex();
+ const sal_Int32 nXPos = aPaM.GetIndex();
for (size_t nAttr = rAttrs.size(); nAttr; )
{
const EditCharAttrib& rAttr = rAttrs[--nAttr];
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index c7fca54d8c54..5813cfc77001 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -65,6 +65,8 @@
#include <boost/scoped_ptr.hpp>
+#include <algorithm>
+
using namespace ::com::sun::star;
static sal_uInt16 lcl_CalcExtraSpace( ParaPortion*, const SvxLineSpacingItem& rLSItem )
@@ -290,12 +292,8 @@ OUString ImpEditEngine::GetSelected( const EditSelection& rSel, const LineEnd eE
OSL_ENSURE( aEditDoc.GetObject( nNode ), "Node not found: GetSelected" );
const ContentNode* pNode = aEditDoc.GetObject( nNode );
- xub_StrLen nStartPos = 0;
- xub_StrLen nEndPos = pNode->Len();
- if ( nNode == nStartNode )
- nStartPos = aSel.Min().GetIndex();
- if ( nNode == nEndNode ) // can also be == nStart!
- nEndPos = aSel.Max().GetIndex();
+ const sal_Int32 nStartPos = nNode==nStartNode ? aSel.Min().GetIndex() : 0;
+ const sal_Int32 nEndPos = nNode==nEndNode ? aSel.Max().GetIndex() : pNode->Len(); // can also be == nStart!
aText += aEditDoc.GetParaAsString( pNode, nStartPos, nEndPos );
if ( nNode < nEndNode )
@@ -941,7 +939,7 @@ EditPaM ImpEditEngine::CursorVisualStartEnd( EditView* pEditView, const EditPaM&
ubidi_setPara( pBidi, reinterpret_cast<const UChar *>(pLineString), aLine.getLength(), nBidiLevel, NULL, &nError ); // UChar != sal_Unicode in MinGW
sal_uInt16 nVisPos = bStart ? 0 : aLine.getLength()-1;
- sal_uInt16 nLogPos = (sal_uInt16)ubidi_getLogicalIndex( pBidi, nVisPos, &nError );
+ const sal_Int32 nLogPos = ubidi_getLogicalIndex( pBidi, nVisPos, &nError );
ubidi_close( pBidi );
@@ -1050,7 +1048,7 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
sal_Bool bGotoEndOfPrevLine = sal_False;
OUString aLine = aPaM.GetNode()->GetString().copy(pLine->GetStart(), pLine->GetEnd() - pLine->GetStart());
- sal_uInt16 nPosInLine = aPaM.GetIndex() - pLine->GetStart();
+ const sal_Int32 nPosInLine = aPaM.GetIndex() - pLine->GetStart();
const sal_Unicode* pLineString = aLine.getStr();
@@ -1063,7 +1061,7 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
if ( !pEditView->IsInsertMode() )
{
sal_Bool bEndOfLine = nPosInLine == aLine.getLength();
- sal_uInt16 nVisPos = (sal_uInt16)ubidi_getVisualIndex( pBidi, !bEndOfLine ? nPosInLine : nPosInLine-1, &nError );
+ sal_Int32 nVisPos = ubidi_getVisualIndex( pBidi, !bEndOfLine ? nPosInLine : nPosInLine-1, &nError );
if ( bVisualToLeft )
{
bGotoEndOfPrevLine = nVisPos == 0;
@@ -1161,7 +1159,7 @@ EditPaM ImpEditEngine::CursorLeft( const EditPaM& rPaM, sal_uInt16 nCharacterIte
sal_Int32 nCount = 1;
uno::Reference < i18n::XBreakIterator > _xBI( ImplGetBreakIterator() );
aNewPaM.SetIndex(
- (sal_uInt16)_xBI->previousCharacters(
+ _xBI->previousCharacters(
aNewPaM.GetNode()->GetString(), aNewPaM.GetIndex(), GetLocale( aNewPaM ), nCharacterIteratorMode, nCount, nCount));
}
else
@@ -1188,7 +1186,7 @@ EditPaM ImpEditEngine::CursorRight( const EditPaM& rPaM, sal_uInt16 nCharacterIt
uno::Reference < i18n::XBreakIterator > _xBI( ImplGetBreakIterator() );
sal_Int32 nCount = 1;
aNewPaM.SetIndex(
- (sal_uInt16)_xBI->nextCharacters(
+ _xBI->nextCharacters(
aNewPaM.GetNode()->GetString(), aNewPaM.GetIndex(), GetLocale( aNewPaM ), nCharacterIteratorMode, nCount, nCount));
}
else
@@ -1406,7 +1404,7 @@ EditPaM ImpEditEngine::PageDown( const EditPaM& rPaM, EditView* pView )
EditPaM ImpEditEngine::WordLeft( const EditPaM& rPaM, sal_Int16 nWordType )
{
- sal_uInt16 nCurrentPos = rPaM.GetIndex();
+ const sal_Int32 nCurrentPos = rPaM.GetIndex();
EditPaM aNewPaM( rPaM );
if ( nCurrentPos == 0 )
{
@@ -1424,8 +1422,7 @@ EditPaM ImpEditEngine::WordLeft( const EditPaM& rPaM, sal_Int16 nWordType )
// we need to increase the position by 1 when retrieving the locale
// since the attribute for the char left to the cursor position is returned
EditPaM aTmpPaM( aNewPaM );
- xub_StrLen nMax = rPaM.GetNode()->Len();
- if ( aTmpPaM.GetIndex() < nMax )
+ if ( aTmpPaM.GetIndex() < rPaM.GetNode()->Len() )
aTmpPaM.SetIndex( aTmpPaM.GetIndex() + 1 );
lang::Locale aLocale( GetLocale( aTmpPaM ) );
@@ -1435,7 +1432,7 @@ EditPaM ImpEditEngine::WordLeft( const EditPaM& rPaM, sal_Int16 nWordType )
if ( aBoundary.startPos >= nCurrentPos )
aBoundary = _xBI->previousWord(
aNewPaM.GetNode()->GetString(), nCurrentPos, aLocale, nWordType);
- aNewPaM.SetIndex( ( aBoundary.startPos != (-1) ) ? (sal_uInt16)aBoundary.startPos : 0 );
+ aNewPaM.SetIndex( ( aBoundary.startPos != (-1) ) ? aBoundary.startPos : 0 );
}
return aNewPaM;
@@ -1443,7 +1440,7 @@ EditPaM ImpEditEngine::WordLeft( const EditPaM& rPaM, sal_Int16 nWordType )
EditPaM ImpEditEngine::WordRight( const EditPaM& rPaM, sal_Int16 nWordType )
{
- xub_StrLen nMax = rPaM.GetNode()->Len();
+ const sal_Int32 nMax = rPaM.GetNode()->Len();
EditPaM aNewPaM( rPaM );
if ( aNewPaM.GetIndex() < nMax )
{
@@ -1456,7 +1453,7 @@ EditPaM ImpEditEngine::WordRight( const EditPaM& rPaM, sal_Int16 nWordType )
uno::Reference < i18n::XBreakIterator > _xBI( ImplGetBreakIterator() );
i18n::Boundary aBoundary = _xBI->nextWord(
aNewPaM.GetNode()->GetString(), aNewPaM.GetIndex(), aLocale, nWordType);
- aNewPaM.SetIndex( (sal_uInt16)aBoundary.startPos );
+ aNewPaM.SetIndex( aBoundary.startPos );
}
// not 'else', maybe the index reached nMax now...
if ( aNewPaM.GetIndex() >= nMax )
@@ -1480,8 +1477,7 @@ EditPaM ImpEditEngine::StartOfWord( const EditPaM& rPaM, sal_Int16 nWordType )
// we need to increase the position by 1 when retrieving the locale
// since the attribute for the char left to the cursor position is returned
EditPaM aTmpPaM( aNewPaM );
- xub_StrLen nMax = rPaM.GetNode()->Len();
- if ( aTmpPaM.GetIndex() < nMax )
+ if ( aTmpPaM.GetIndex() < rPaM.GetNode()->Len() )
aTmpPaM.SetIndex( aTmpPaM.GetIndex() + 1 );
lang::Locale aLocale( GetLocale( aTmpPaM ) );
@@ -1489,7 +1485,7 @@ EditPaM ImpEditEngine::StartOfWord( const EditPaM& rPaM, sal_Int16 nWordType )
i18n::Boundary aBoundary = _xBI->getWordBoundary(
rPaM.GetNode()->GetString(), rPaM.GetIndex(), aLocale, nWordType, true);
- aNewPaM.SetIndex( (sal_uInt16)aBoundary.startPos );
+ aNewPaM.SetIndex( aBoundary.startPos );
return aNewPaM;
}
@@ -1500,8 +1496,7 @@ EditPaM ImpEditEngine::EndOfWord( const EditPaM& rPaM, sal_Int16 nWordType )
// we need to increase the position by 1 when retrieving the locale
// since the attribute for the char left to the cursor position is returned
EditPaM aTmpPaM( aNewPaM );
- xub_StrLen nMax = rPaM.GetNode()->Len();
- if ( aTmpPaM.GetIndex() < nMax )
+ if ( aTmpPaM.GetIndex() < rPaM.GetNode()->Len() )
aTmpPaM.SetIndex( aTmpPaM.GetIndex() + 1 );
lang::Locale aLocale( GetLocale( aTmpPaM ) );
@@ -1509,7 +1504,7 @@ EditPaM ImpEditEngine::EndOfWord( const EditPaM& rPaM, sal_Int16 nWordType )
i18n::Boundary aBoundary = _xBI->getWordBoundary(
rPaM.GetNode()->GetString(), rPaM.GetIndex(), aLocale, nWordType, true);
- aNewPaM.SetIndex( (sal_uInt16)aBoundary.endPos );
+ aNewPaM.SetIndex( aBoundary.endPos );
return aNewPaM;
}
@@ -1521,8 +1516,7 @@ EditSelection ImpEditEngine::SelectWord( const EditSelection& rCurSel, sal_Int16
// we need to increase the position by 1 when retrieving the locale
// since the attribute for the char left to the cursor position is returned
EditPaM aTmpPaM( aPaM );
- xub_StrLen nMax = aPaM.GetNode()->Len();
- if ( aTmpPaM.GetIndex() < nMax )
+ if ( aTmpPaM.GetIndex() < aPaM.GetNode()->Len() )
aTmpPaM.SetIndex( aTmpPaM.GetIndex() + 1 );
lang::Locale aLocale( GetLocale( aTmpPaM ) );
@@ -1539,8 +1533,8 @@ EditSelection ImpEditEngine::SelectWord( const EditSelection& rCurSel, sal_Int16
if ( ( aBoundary.endPos > aPaM.GetIndex() ) &&
( ( aBoundary.startPos < aPaM.GetIndex() ) || ( bAcceptStartOfWord && ( aBoundary.startPos == aPaM.GetIndex() ) ) ) )
{
- aNewSel.Min().SetIndex( (sal_uInt16)aBoundary.startPos );
- aNewSel.Max().SetIndex( (sal_uInt16)aBoundary.endPos );
+ aNewSel.Min().SetIndex( aBoundary.startPos );
+ aNewSel.Max().SetIndex( aBoundary.endPos );
}
}
@@ -1565,8 +1559,8 @@ EditSelection ImpEditEngine::SelectSentence( const EditSelection& rCurSel )
EditSelection aNewSel( rCurSel );
OSL_ENSURE(pNode->Len() ? (nStart < pNode->Len()) : (nStart == 0), "sentence start index out of range");
OSL_ENSURE(nEnd <= pNode->Len(), "sentence end index out of range");
- aNewSel.Min().SetIndex( (sal_uInt16)nStart );
- aNewSel.Max().SetIndex( (sal_uInt16)nEnd );
+ aNewSel.Min().SetIndex( nStart );
+ aNewSel.Max().SetIndex( nEnd );
return aNewSel;
}
@@ -1577,10 +1571,7 @@ sal_Bool ImpEditEngine::IsInputSequenceCheckingRequired( sal_Unicode nChar, cons
pCTLOptions = new SvtCTLOptions;
// get the index that really is first
- sal_uInt16 nFirstPos = rCurSel.Min().GetIndex();
- sal_uInt16 nMaxPos = rCurSel.Max().GetIndex();
- if (nMaxPos < nFirstPos)
- nFirstPos = nMaxPos;
+ const sal_Int32 nFirstPos = std::min(rCurSel.Min().GetIndex(), rCurSel.Max().GetIndex());
sal_Bool bIsSequenceChecking =
pCTLOptions->IsCTLFontEnabled() &&
@@ -1774,7 +1765,7 @@ sal_uInt16 ImpEditEngine::GetI18NScriptType( const EditPaM& rPaM, sal_uInt16* pE
const ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos;
- sal_uInt16 nPos = rPaM.GetIndex();
+ const sal_Int32 nPos = rPaM.GetIndex();
ScriptTypePosInfos::const_iterator itr = std::find_if(rTypes.begin(), rTypes.end(), FindByPos(nPos));
if(itr != rTypes.end())
{
@@ -1847,7 +1838,7 @@ sal_Bool ImpEditEngine::IsScriptChange( const EditPaM& rPaM ) const
((ImpEditEngine*)this)->InitScriptTypes( nPara );
const ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos;
- sal_uInt16 nPos = rPaM.GetIndex();
+ const sal_Int32 nPos = rPaM.GetIndex();
for ( size_t n = 0; n < rTypes.size(); n++ )
{
if ( rTypes[n].nStartPos == nPos )
@@ -2059,8 +2050,8 @@ void ImpEditEngine::ImpRemoveChars( const EditPaM& rPaM, sal_uInt16 nChars, Edit
OUString aStr( rPaM.GetNode()->Copy( rPaM.GetIndex(), nChars ) );
// Check whether attributes are deleted or changed:
- sal_uInt16 nStart = rPaM.GetIndex();
- sal_uInt16 nEnd = nStart + nChars;
+ const sal_Int32 nStart = rPaM.GetIndex();
+ const sal_Int32 nEnd = nStart + nChars;
const CharAttribList::AttribsType& rAttribs = rPaM.GetNode()->GetCharAttribs().GetAttribs();
for (size_t i = 0, n = rAttribs.size(); i < n; ++i)
{
@@ -2337,7 +2328,7 @@ EditPaM ImpEditEngine::DeleteLeftOrRight( const EditSelection& rSel, sal_uInt8 n
if (aDelEnd.GetIndex() == aCurPos.GetIndex())
{
- const xub_StrLen nLen(aCurPos.GetNode()->Len());
+ const sal_Int32 nLen(aCurPos.GetNode()->Len());
// #i120020# when 0 == nLen, aDelStart needs to be adapted, not
// aDelEnd. This would (and did) lead to a wrong order in the
@@ -2424,15 +2415,13 @@ EditPaM ImpEditEngine::ImpDeleteSelection(const EditSelection& rCurSel)
if ( aStartPaM.GetNode() != aEndPaM.GetNode() )
{
// The Rest of the StartNodes...
- sal_uInt16 nChars;
- nChars = aStartPaM.GetNode()->Len() - aStartPaM.GetIndex();
- ImpRemoveChars( aStartPaM, nChars );
+ ImpRemoveChars( aStartPaM, aStartPaM.GetNode()->Len() - aStartPaM.GetIndex() );
ParaPortion* pPortion = FindParaPortion( aStartPaM.GetNode() );
OSL_ENSURE( pPortion, "Blind Portion in ImpDeleteSelection(3)" );
pPortion->MarkSelectionInvalid( aStartPaM.GetIndex(), aStartPaM.GetNode()->Len() );
// The beginning of the EndNodes....
- nChars = aEndPaM.GetIndex();
+ const sal_Int32 nChars = aEndPaM.GetIndex();
aEndPaM.SetIndex( 0 );
ImpRemoveChars( aEndPaM, nChars );
pPortion = FindParaPortion( aEndPaM.GetNode() );
@@ -2443,9 +2432,7 @@ EditPaM ImpEditEngine::ImpDeleteSelection(const EditSelection& rCurSel)
}
else
{
- sal_uInt16 nChars;
- nChars = aEndPaM.GetIndex() - aStartPaM.GetIndex();
- ImpRemoveChars( aStartPaM, nChars );
+ ImpRemoveChars( aStartPaM, aEndPaM.GetIndex() - aStartPaM.GetIndex() );
ParaPortion* pPortion = FindParaPortion( aStartPaM.GetNode() );
OSL_ENSURE( pPortion, "Blind Portion in ImpDeleteSelection(5)" );
pPortion->MarkInvalid( aEndPaM.GetIndex(), aStartPaM.GetIndex() - aEndPaM.GetIndex() );
@@ -2540,7 +2527,7 @@ EditPaM ImpEditEngine::AutoCorrect( const EditSelection& rCurSel, sal_Unicode c,
}
ContentNode* pNode = aSel.Max().GetNode();
- sal_uInt16 nIndex = aSel.Max().GetIndex();
+ const sal_Int32 nIndex = aSel.Max().GetIndex();
EdtAutoCorrDoc aAuto(pEditEngine, pNode, nIndex, c);
// FIXME: this _must_ be called with reference to the actual node text!
OUString const& rNodeString(pNode->GetString());
@@ -2595,7 +2582,7 @@ EditPaM ImpEditEngine::InsertText( const EditSelection& rCurSel,
if (_xISC.is() || pCTLOptions)
{
- xub_StrLen nTmpPos = aPaM.GetIndex();
+ const sal_Int32 nTmpPos = aPaM.GetIndex();
sal_Int16 nCheckMode = pCTLOptions->IsCTLSequenceCheckingRestricted() ?
i18n::InputSequenceCheckMode::STRICT : i18n::InputSequenceCheckMode::BASIC;
@@ -2620,7 +2607,7 @@ EditPaM ImpEditEngine::InsertText( const EditSelection& rCurSel,
OUString aChgText( aNewText.copy( nChgPos ) );
// select text from first pos to be changed to current pos
- EditSelection aSel( EditPaM( aPaM.GetNode(), (sal_uInt16) nChgPos ), aPaM );
+ EditSelection aSel( EditPaM( aPaM.GetNode(), nChgPos ), aPaM );
if (!aChgText.isEmpty())
return InsertText( aSel, aChgText ); // implicitly handles undo
@@ -2785,7 +2772,7 @@ EditPaM ImpEditEngine::ImpInsertFeature(const EditSelection& rCurSel, const SfxP
else
aPaM = rCurSel.Max();
- if ( aPaM.GetIndex() >= 0xfffe )
+ if ( aPaM.GetIndex() >= SAL_MAX_INT32-1 )
return aPaM;
if ( IsUndoEnabled() && !IsInUndo() )
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index d5fec025bc93..38a84c15c98d 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -1989,8 +1989,8 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine,
if ( ( nRemainingSpace < 0 ) || pLine->IsEmpty() )
return ;
- const sal_uInt16 nFirstChar = pLine->GetStart();
- const sal_uInt16 nLastChar = pLine->GetEnd() -1; // Last points behind
+ const sal_Int32 nFirstChar = pLine->GetStart();
+ const sal_Int32 nLastChar = pLine->GetEnd() -1; // Last points behind
ContentNode* pNode = pParaPortion->GetNode();
DBG_ASSERT( nLastChar < pNode->Len(), "AdjustBlocks: Out of range!" );
@@ -1998,7 +1998,7 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine,
// Search blanks or Kashidas...
std::vector<sal_uInt16> aPositions;
sal_uInt16 nLastScript = i18n::ScriptType::LATIN;
- for ( sal_uInt16 nChar = nFirstChar; nChar <= nLastChar; nChar++ )
+ for ( sal_Int32 nChar = nFirstChar; nChar <= nLastChar; nChar++ )
{
EditPaM aPaM( pNode, nChar+1 );
LanguageType eLang = GetLanguage(aPaM);
@@ -2115,7 +2115,7 @@ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_uInt16 nStart, sal_
while ( ( aWordSel.Min().GetNode() == pNode ) && ( aWordSel.Min().GetIndex() < nEnd ) )
{
- sal_uInt16 nSavPos = aWordSel.Max().GetIndex();
+ const sal_Int32 nSavPos = aWordSel.Max().GetIndex();
if ( aWordSel.Max().GetIndex() > nEnd )
aWordSel.Max().GetIndex() = nEnd;
@@ -2124,8 +2124,8 @@ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_uInt16 nStart, sal_
// restore selection for proper iteration at the end of the function
aWordSel.Max().GetIndex() = nSavPos;
- xub_StrLen nIdx = 0;
- xub_StrLen nKashidaPos = STRING_LEN;
+ sal_Int32 nIdx = 0;
+ sal_Int32 nKashidaPos = -1;
sal_Unicode cCh;
sal_Unicode cPrevCh = 0;
@@ -2198,7 +2198,7 @@ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_uInt16 nStart, sal_
{
// only choose this position if we did not find
// a better one:
- if ( STRING_LEN == nKashidaPos )
+ if ( nKashidaPos<0 )
nKashidaPos = aWordSel.Min().GetIndex() + nIdx - 1;
break;
}
@@ -2213,7 +2213,7 @@ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_uInt16 nStart, sal_
++nIdx;
} // end of current word
- if ( STRING_LEN != nKashidaPos )
+ if ( nKashidaPos>=0 )
rArray.push_back( nKashidaPos );
aWordSel = WordRight( aWordSel.Max(), ::com::sun::star::i18n::WordType::DICTIONARY_WORD );
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 68cddecbea3d..414fd58021a2 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -251,8 +251,8 @@ sal_uInt32 ImpEditEngine::WriteText( SvStream& rOutput, EditSelection aSel )
ContentNode* pNode = aEditDoc.GetObject( nNode );
DBG_ASSERT( pNode, "Node not founden: Search&Replace" );
- sal_uInt16 nStartPos = 0;
- sal_uInt16 nEndPos = pNode->Len();
+ sal_Int32 nStartPos = 0;
+ sal_Int32 nEndPos = pNode->Len();
if ( bRange )
{
if ( nNode == nStartNode )
@@ -1228,7 +1228,7 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject
{
const ContentInfo* pC = &rTextObject.mpImpl->GetContents()[n];
sal_Bool bNewContent = aPaM.GetNode()->Len() ? sal_False: sal_True;
- sal_uInt16 nStartPos = aPaM.GetIndex();
+ const sal_Int32 nStartPos = aPaM.GetIndex();
aPaM = ImpFastInsertText( aPaM, pC->GetText() );
@@ -1572,9 +1572,8 @@ void ImpEditEngine::Convert( EditView* pEditView,
// not work. Thus since chinese conversion is not interactive we start
// at the begin of the paragraph to solve the problem, i.e. have the
// TextConversion service get those characters together in the same call.
- sal_uInt16 nStartIdx = ( editeng::HangulHanjaConversion::IsChinese( nSrcLang ) ) ?
- 0 : aWordStartPaM.GetIndex();
- pConvInfo->aConvStart.nIndex = nStartIdx;
+ pConvInfo->aConvStart.nIndex = editeng::HangulHanjaConversion::IsChinese( nSrcLang )
+ ? 0 : aWordStartPaM.GetIndex();
}
//
pConvInfo->aConvContinue = pConvInfo->aConvStart;
@@ -1698,22 +1697,22 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang,
pConvInfo->aConvContinue.nIndex >= pConvInfo->aConvTo.nIndex)
break;
- sal_uInt16 nAttribStart = USHRT_MAX;
- sal_uInt16 nAttribEnd = USHRT_MAX;
- sal_uInt16 nCurPos = USHRT_MAX;
+ sal_Int32 nAttribStart = -1;
+ sal_Int32 nAttribEnd = -1;
+ sal_Int32 nCurPos = -1;
EPaM aCurStart = CreateEPaM( aCurSel.Min() );
std::vector<sal_uInt16> aPortions;
pEditEngine->GetPortions( aCurStart.nPara, aPortions );
for ( size_t nPos = 0; nPos < aPortions.size(); ++nPos )
{
- sal_uInt16 nEnd = aPortions[ nPos ];
- sal_uInt16 nStart = nPos > 0 ? aPortions[ nPos - 1 ] : 0;
+ const sal_Int32 nEnd = aPortions[ nPos ];
+ const sal_Int32 nStart = nPos > 0 ? aPortions[ nPos - 1 ] : 0;
// the language attribute is obtained from the left character
// (like usually all other attributes)
// thus we usually have to add 1 in order to get the language
// of the text right to the cursor position
- sal_uInt16 nLangIdx = nEnd > nStart ? nStart + 1 : nStart;
+ const sal_Int32 nLangIdx = nEnd > nStart ? nStart + 1 : nStart;
LanguageType nLangFound = pEditEngine->GetLanguage( aCurStart.nPara, nLangIdx );
#ifdef DEBUG
lang::Locale aLocale( LanguageTag::convertToLocale( nLangFound ) );
@@ -1722,7 +1721,7 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang,
(editeng::HangulHanjaConversion::IsChinese( nLangFound ) &&
editeng::HangulHanjaConversion::IsChinese( nSrcLang ));
- if (nAttribEnd != USHRT_MAX) // start already found?
+ if (nAttribEnd>=0) // start already found?
{
DBG_ASSERT(nEnd >= aCurStart.nIndex, "error while scanning attributes (a)" );
DBG_ASSERT(nEnd >= nAttribEnd, "error while scanning attributes (b)" );
@@ -1731,7 +1730,7 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang,
else // language attrib has changed
break;
}
- if (nAttribStart == USHRT_MAX && // start not yet found?
+ if (nAttribStart<0 && // start not yet found?
nEnd > aCurStart.nIndex && bLangOk)
{
nAttribStart = nStart;
@@ -1743,7 +1742,7 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang,
//! attribute!)
//! But since we don't want to start in the already processed part
//! we clip the start accordingly.
- if (nAttribStart < aCurStart.nIndex)
+ if (nAttribStart >= 0 && nAttribStart < aCurStart.nIndex)
{
nAttribStart = aCurStart.nIndex;
}
@@ -1770,12 +1769,12 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang,
nCurPos = nEnd;
}
- if (nAttribStart != USHRT_MAX && nAttribEnd != USHRT_MAX)
+ if (nAttribStart>=0 && nAttribEnd>=0)
{
aCurSel.Min().SetIndex( nAttribStart );
aCurSel.Max().SetIndex( nAttribEnd );
}
- else if (nCurPos != USHRT_MAX)
+ else if (nCurPos>=0)
{
// set selection to end of scanned text
// (used to set the position where to continue from later on)
@@ -2217,8 +2216,8 @@ void ImpEditEngine::ApplyChangedSentence(EditView& rEditView,
// restore cursor position to the end of the modified sentence.
// (This will define the continuation position for spell/grammar checking)
// First: check if the sentence/para length changed
- sal_Int32 nDelta = rEditView.pImpEditView->GetEditSelection().Max().GetNode()->Len() - nOldLen;
- xub_StrLen nEndOfSentence = aOldSel.Max().GetIndex() + nDelta;
+ const sal_Int32 nDelta = rEditView.pImpEditView->GetEditSelection().Max().GetNode()->Len() - nOldLen;
+ const sal_Int32 nEndOfSentence = aOldSel.Max().GetIndex() + nDelta;
aNext = EditPaM( aOldSel.Max().GetNode(), nEndOfSentence );
}
rEditView.pImpEditView->SetEditSelection( aNext );
@@ -2276,11 +2275,12 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC
if (!pNode->GetWrongList()->IsValid())
{
WrongList* pWrongList = pNode->GetWrongList();
- sal_uInt16 nInvStart = pWrongList->GetInvalidStart();
- sal_uInt16 nInvEnd = pWrongList->GetInvalidEnd();
+ const sal_Int32 nInvStart = pWrongList->GetInvalidStart();
+ const sal_Int32 nInvEnd = pWrongList->GetInvalidEnd();
sal_uInt16 nWrongs = 0; // Lose control also in the paragraphs
- sal_uInt16 nPaintFrom = 0xFFFF, nPaintTo = 0;
+ sal_Int32 nPaintFrom = -1;
+ sal_Int32 nPaintTo = 0;
bool bSimpleRepaint = true;
pWrongList->SetValid();
@@ -2311,13 +2311,13 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC
bool bChanged = false;
if (!aWord.isEmpty())
{
- sal_uInt16 nWStart = aSel.Min().GetIndex();
- sal_uInt16 nWEnd= aSel.Max().GetIndex();
+ const sal_Int32 nWStart = aSel.Min().GetIndex();
+ const sal_Int32 nWEnd = aSel.Max().GetIndex();
if ( !xSpeller->isValid( aWord, GetLanguage( EditPaM( aSel.Min().GetNode(), nWStart+1 ) ), aEmptySeq ) )
{
// Check if already marked correctly...
nWrongs++;
- sal_uInt16 nXEnd = bDottAdded ? nWEnd -1 : nWEnd;
+ const sal_Int32 nXEnd = bDottAdded ? nWEnd -1 : nWEnd;
if ( !pWrongList->HasWrong( nWStart, nXEnd ) )
{
// Mark Word as wrong...
@@ -2357,7 +2357,7 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC
}
if ( bChanged )
{
- if ( nPaintFrom == 0xFFFF )
+ if ( nPaintFrom<0 )
nPaintFrom = nWStart;
nPaintTo = nWEnd;
}
@@ -2376,7 +2376,7 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC
}
// Invalidate?
- if ( ( nPaintFrom != 0xFFFF ) )
+ if ( nPaintFrom>=0 )
{
aStatus.GetStatusWord() |= EE_STAT_WRONGWORDCHANGED;
CallStatusHdl();
@@ -2736,12 +2736,8 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection,
{
ContentNode* pNode = aEditDoc.GetObject( nNode );
const OUString& aNodeStr = pNode->GetString();
- xub_StrLen nStartPos = 0;
- xub_StrLen nEndPos = aNodeStr.getLength();
- if ( nNode == nStartNode )
- nStartPos = aSel.Min().GetIndex();
- if ( nNode == nEndNode ) // can also be == nStart!
- nEndPos = aSel.Max().GetIndex();
+ const sal_Int32 nStartPos = nNode==nStartNode ? aSel.Min().GetIndex() : 0;
+ const sal_Int32 nEndPos = nNode==nEndNode ? aSel.Max().GetIndex() : aNodeStr.getLength(); // can also be == nStart!
sal_uInt16 nCurrentStart = nStartPos;
sal_uInt16 nCurrentEnd = nEndPos;
@@ -2888,7 +2884,7 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection,
while (nCurrentStart < nLastEnd)
{
- sal_Int32 nLen = nCurrentEnd - nCurrentStart;
+ const sal_Int32 nLen = nCurrentEnd - nCurrentStart;
DBG_ASSERT( nLen > 0, "invalid word length of 0" );
#if OSL_DEBUG_LEVEL > 1
OUString aText( aNodeStr.copy( nCurrentStart, nLen ) );
@@ -2932,7 +2928,7 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection,
nCurrentEnd = nEndPos;
}
- xub_StrLen nLen = nCurrentEnd - nCurrentStart;
+ const sal_Int32 nLen = nCurrentEnd - nCurrentStart;
Sequence< sal_Int32 > aOffsets;
OUString aNewText( aTranslitarationWrapper.transliterate( aNodeStr, nLanguage, nCurrentStart, nLen, &aOffsets ) );
@@ -2991,7 +2987,8 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection,
bLenChanged = sal_True;
// Change text without loosing the attributes
- sal_uInt16 nDiffs = ReplaceTextOnly( rData.aSelection.Min().GetNode(),
+ const sal_Int32 nDiffs =
+ ReplaceTextOnly( rData.aSelection.Min().GetNode(),
rData.nStart, rData.nLen, rData.aNewText, rData.aOffsets );
// adjust selection in end node to possibly changed size
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index 3f2a195e0560..c92af7915d7a 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -321,12 +321,8 @@ SfxItemSet ImpEditEngine::GetAttribs( EditSelection aSel, sal_Bool bOnlyHardAttr
ContentNode* pNode = aEditDoc.GetObject( nNode );
DBG_ASSERT( aEditDoc.GetObject( nNode ), "Node not found: GetAttrib" );
- xub_StrLen nStartPos = 0;
- xub_StrLen nEndPos = pNode->Len();
- if ( nNode == nStartNode )
- nStartPos = aSel.Min().GetIndex();
- if ( nNode == nEndNode ) // Can also be == nStart!
- nEndPos = aSel.Max().GetIndex();
+ const sal_Int32 nStartPos = nNode==nStartNode ? aSel.Min().GetIndex() : 0;
+ const sal_Int32 nEndPos = nNode==nEndNode ? aSel.Max().GetIndex() : pNode->Len(); // Can also be == nStart!
// Problem: Templates ....
// => Other way:
@@ -528,12 +524,8 @@ void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, sal_
ContentNode* pNode = aEditDoc.GetObject( nNode );
ParaPortion* pPortion = GetParaPortions()[nNode];
- xub_StrLen nStartPos = 0;
- xub_StrLen nEndPos = pNode->Len();
- if ( nNode == nStartNode )
- nStartPos = aSel.Min().GetIndex();
- if ( nNode == nEndNode ) // can also be == nStart!
- nEndPos = aSel.Max().GetIndex();
+ const sal_Int32 nStartPos = nNode==nStartNode ? aSel.Min().GetIndex() : 0;
+ const sal_Int32 nEndPos = nNode==nEndNode ? aSel.Max().GetIndex() : pNode->Len(); // can also be == nStart!
// Iterate over the Items...
for ( sal_uInt16 nWhich = EE_ITEMS_START; nWhich <= EE_CHAR_END; nWhich++)
@@ -615,12 +607,8 @@ void ImpEditEngine::RemoveCharAttribs( EditSelection aSel, sal_Bool bRemoveParaA
DBG_ASSERT( aEditDoc.GetObject( nNode ), "Node not found: SetAttribs" );
DBG_ASSERT( GetParaPortions().SafeGetObject( nNode ), "Portion not found: SetAttribs" );
- xub_StrLen nStartPos = 0;
- xub_StrLen nEndPos = pNode->Len();
- if ( nNode == nStartNode )
- nStartPos = aSel.Min().GetIndex();
- if ( nNode == nEndNode ) // can also be == nStart!
- nEndPos = aSel.Max().GetIndex();
+ const sal_Int32 nStartPos = nNode==nStartNode ? aSel.Min().GetIndex() : 0;
+ const sal_Int32 nEndPos = nNode==nEndNode ? aSel.Max().GetIndex() : pNode->Len(); // can also be == nStart!
// Optimize: If whole paragraph, then RemoveCharAttribs (nPara)?
sal_Bool bChanged = aEditDoc.RemoveAttribs( pNode, nStartPos, nEndPos, nWhich );