[Libreoffice-commits] core.git: 6 commits - editeng/source sw/source
Matteo Casalin
matteo.casalin at yahoo.com
Sat Dec 28 13:44:03 PST 2013
editeng/source/editeng/editdoc.cxx | 57 +++++++---------
editeng/source/editeng/editdoc.hxx | 75 +++++++++++++--------
editeng/source/editeng/editundo.cxx | 20 ++---
editeng/source/editeng/editview.cxx | 4 -
editeng/source/editeng/impedit.cxx | 8 +-
editeng/source/editeng/impedit2.cxx | 127 +++++++++++++++---------------------
editeng/source/editeng/impedit3.cxx | 35 ++++-----
editeng/source/editeng/impedit4.cxx | 85 +++++++++++-------------
editeng/source/editeng/impedit5.cxx | 24 +-----
sw/source/core/inc/scriptinfo.hxx | 11 +--
sw/source/core/text/pormulti.cxx | 6 +
11 files changed, 216 insertions(+), 236 deletions(-)
New commits:
commit 2bd59981116128639765602f92db2c6a07a1128d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Dec 28 22:37:24 2013 +0100
Remove unread variable
Change-Id: I6271e8f977d5c112223d14744830c8101099613d
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 5cc25b6..31deb76 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -2278,7 +2278,6 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC
const sal_Int32 nInvStart = pWrongList->GetInvalidStart();
const sal_Int32 nInvEnd = pWrongList->GetInvalidEnd();
- sal_uInt16 nWrongs = 0; // Lose control also in the paragraphs
sal_Int32 nPaintFrom = -1;
sal_Int32 nPaintTo = 0;
bool bSimpleRepaint = true;
@@ -2316,7 +2315,6 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC
if ( !xSpeller->isValid( aWord, GetLanguage( EditPaM( aSel.Min().GetNode(), nWStart+1 ) ), aEmptySeq ) )
{
// Check if already marked correctly...
- nWrongs++;
const sal_Int32 nXEnd = bDottAdded ? nWEnd -1 : nWEnd;
if ( !pWrongList->HasWrong( nWStart, nXEnd ) )
{
commit 5d00bab62b255342f00ce31d7390f8ed5a1c6501
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Dec 28 22:30:40 2013 +0100
Use OUString constructor for constant ASCII
Change-Id: Ifc80743c748c2542055cfe825ad322b83958d976
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index dc0a644..0b45180 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -2013,10 +2013,6 @@ void EditDoc::CreateDefFont( sal_Bool bUseStyles )
}
}
-static const sal_Unicode aCR[] = { 0x0d, 0x00 };
-static const sal_Unicode aLF[] = { 0x0a, 0x00 };
-static const sal_Unicode aCRLF[] = { 0x0d, 0x0a, 0x00 };
-
sal_Int32 EditDoc::GetPos(const ContentNode* p) const
{
return FastGetPos(maContents, p, nLastCache);
@@ -2085,14 +2081,11 @@ sal_Int32 EditDoc::Count() const
OUString EditDoc::GetSepStr( LineEnd eEnd )
{
- OUString aSep;
if ( eEnd == LINEEND_CR )
- aSep = aCR;
- else if ( eEnd == LINEEND_LF )
- aSep = aLF;
- else
- aSep = aCRLF;
- return aSep;
+ return OUString("\015"); // 0x0d
+ if ( eEnd == LINEEND_LF )
+ return OUString("\012"); // 0x0a
+ return OUString("\015\012"); // 0x0d, 0x0a
}
OUString EditDoc::GetText( LineEnd eEnd ) const
@@ -3044,7 +3037,7 @@ SvxColorItem* SvxColorList::GetObject( size_t nIndex )
}
EditEngineItemPool::EditEngineItemPool( sal_Bool bPersistenRefCounts )
- : SfxItemPool( OUString( "EditEngineItemPool" ), EE_ITEMS_START, EE_ITEMS_END,
+ : SfxItemPool( "EditEngineItemPool", EE_ITEMS_START, EE_ITEMS_END,
aItemInfos, 0, bPersistenRefCounts )
{
SetVersionMap( 1, 3999, 4015, aV1Map );
commit b78146b4db3b31919f133c84db9b23fdb7c8ddf4
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Dec 28 22:18:21 2013 +0100
Use member initialization list in some constructors
Change-Id: Ie0c9720966ca42373bec7a1697b72c5a17f49644
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 5cb90b5..dc0a644 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -504,17 +504,17 @@ sal_uInt16 TextPortionList::GetStartPos(size_t nPortion)
return nPos;
}
-
ExtraPortionInfo::ExtraPortionInfo()
+: nOrgWidth(0)
+, nWidthFullCompression(0)
+, nPortionOffsetX(0)
+, nMaxCompression100thPercent(0)
+, nAsianCompressionTypes(0)
+, bFirstCharIsRightPunktuation(sal_False)
+, bCompressed(sal_False)
+, pOrgDXArray(NULL)
+, lineBreaksList()
{
- nOrgWidth = 0;
- nWidthFullCompression = 0;
- nMaxCompression100thPercent = 0;
- nAsianCompressionTypes = 0;
- nPortionOffsetX = 0;
- bFirstCharIsRightPunktuation = sal_False;
- bCompressed = sal_False;
- pOrgDXArray = NULL;
}
ExtraPortionInfo::~ExtraPortionInfo()
@@ -1765,16 +1765,16 @@ void ContentNode::DestroyWrongList()
mpWrongList.reset();
}
-ContentAttribs::ContentAttribs( SfxItemPool& rPool ) :
- aAttribSet( rPool, EE_PARA_START, EE_CHAR_END )
+ContentAttribs::ContentAttribs( SfxItemPool& rPool )
+: pStyle(0)
+, aAttribSet( rPool, EE_PARA_START, EE_CHAR_END )
{
- pStyle = 0;
}
-ContentAttribs::ContentAttribs( const ContentAttribs& rRef ) :
- aAttribSet( rRef.aAttribSet )
+ContentAttribs::ContentAttribs( const ContentAttribs& rRef )
+: pStyle(rRef.pStyle)
+, aAttribSet( rRef.aAttribSet )
{
- pStyle = rRef.pStyle;
}
ContentAttribs::~ContentAttribs()
@@ -2698,9 +2698,11 @@ struct LessByStart : std::binary_function<EditCharAttrib, EditCharAttrib, bool>
}
CharAttribList::CharAttribList()
+: aAttribs()
+, aDefFont()
+, bHasEmptyAttribs(false)
{
DBG_CTOR( EE_CharAttribList, 0 );
- bHasEmptyAttribs = sal_False;
}
CharAttribList::~CharAttribList()
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 5fe635b..aebbd04 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -59,9 +59,9 @@ struct EPaM
sal_Int32 nPara;
sal_Int32 nIndex;
- EPaM() { nPara = 0; nIndex = 0; }
- EPaM( sal_Int32 nP, sal_Int32 nI ) { nPara = nP; nIndex = nI; }
- EPaM( const EPaM& r) { nPara = r.nPara; nIndex = r.nIndex; }
+ EPaM() : nPara(0), nIndex(0) {}
+ 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;
inline sal_Bool operator < ( const EPaM& r ) const;
@@ -85,10 +85,10 @@ struct ScriptTypePosInfo
sal_uInt16 nEndPos;
ScriptTypePosInfo( short _Type, sal_uInt16 _Start, sal_uInt16 _End )
+ : nScriptType(_Type)
+ , nStartPos(_Start)
+ , nEndPos(_End)
{
- nScriptType = _Type;
- nStartPos = _Start;
- nEndPos = _End;
}
};
@@ -101,10 +101,10 @@ struct WritingDirectionInfo
sal_uInt16 nEndPos;
WritingDirectionInfo( sal_uInt8 _Type, sal_uInt16 _Start, sal_uInt16 _End )
+ : nType(_Type)
+ , nStartPos(_Start)
+ , nEndPos(_End)
{
- nType = _Type;
- nStartPos = _Start;
- nEndPos = _End;
}
};
@@ -391,16 +391,39 @@ private:
sal_Unicode nExtraValue;
- TextPortion() { DBG_CTOR( EE_TextPortion, 0 );
- pExtraInfos = NULL; nLen = 0; nKind = PORTIONKIND_TEXT; nExtraValue = 0; nRightToLeft = sal_False;}
+ TextPortion()
+ : pExtraInfos( NULL )
+ , nLen( 0 )
+ , aOutSz()
+ , nKind( PORTIONKIND_TEXT )
+ , nRightToLeft( sal_False )
+ , nExtraValue( 0 )
+ {
+ DBG_CTOR( EE_TextPortion, 0 );
+ }
public:
- TextPortion( sal_uInt16 nL ) : aOutSz( -1, -1 )
- { DBG_CTOR( EE_TextPortion, 0 );
- pExtraInfos = NULL; nLen = nL; nKind = PORTIONKIND_TEXT; nExtraValue = 0; nRightToLeft = sal_False;}
- TextPortion( const TextPortion& r ) : aOutSz( r.aOutSz )
- { DBG_CTOR( EE_TextPortion, 0 );
- pExtraInfos = NULL; nLen = r.nLen; nKind = r.nKind; nExtraValue = r.nExtraValue; nRightToLeft = r.nRightToLeft; }
+ TextPortion( sal_uInt16 nL )
+ : pExtraInfos( NULL )
+ , nLen( nL )
+ , aOutSz( -1, -1 )
+ , nKind( PORTIONKIND_TEXT )
+ , nRightToLeft( sal_False )
+ , nExtraValue( 0 )
+ {
+ DBG_CTOR( EE_TextPortion, 0 );
+ }
+
+ TextPortion( const TextPortion& r )
+ : pExtraInfos( NULL )
+ , nLen( r.nLen )
+ , aOutSz( r.aOutSz )
+ , nKind( r.nKind )
+ , nRightToLeft( r.nRightToLeft )
+ , nExtraValue( r.nExtraValue )
+ {
+ DBG_CTOR( EE_TextPortion, 0 );
+ }
~TextPortion() { DBG_DTOR( EE_TextPortion, 0 ); delete pExtraInfos; }
@@ -716,8 +739,10 @@ private:
public:
DeletedNodeInfo( sal_uIntPtr nInvAdr, sal_Int32 nPos )
- { nInvalidAdressPtr = nInvAdr;
- nInvalidParagraph = nPos; }
+ : nInvalidAdressPtr(nInvAdr)
+ , nInvalidParagraph(nPos)
+ {
+ }
sal_uIntPtr GetInvalidAdress() const { return nInvalidAdressPtr; }
sal_Int32 GetPosition() const { return nInvalidParagraph; }
commit 7da8245f2621a52de8548976dda73d38d5bf027a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Dec 28 18:07:13 2013 +0100
Do not use Getters as Setters
Change-Id: Ie465e768f07f6e0ebf10042ca389b4941ba84a2a
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 0ec7b0d..5cb90b5 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -2275,7 +2275,7 @@ EditPaM EditDoc::InsertText( EditPaM aPaM, const OUString& rStr )
aPaM.GetNode()->Insert( rStr, aPaM.GetIndex() );
aPaM.GetNode()->ExpandAttribs( aPaM.GetIndex(), rStr.getLength(), GetItemPool() );
- aPaM.GetIndex() = aPaM.GetIndex() + rStr.getLength();
+ aPaM.SetIndex( aPaM.GetIndex() + rStr.getLength() );
SetModified( sal_True );
@@ -2338,7 +2338,7 @@ EditPaM EditDoc::InsertFeature( EditPaM aPaM, const SfxPoolItem& rItem )
SetModified( sal_True );
- aPaM.GetIndex()++;
+ aPaM.SetIndex( aPaM.GetIndex() + 1 );
return aPaM;
}
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 4d2479a..5fe635b 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -326,7 +326,6 @@ public:
void SetNode(ContentNode* p);
sal_Int32 GetIndex() const { return nIndex; }
- sal_Int32& GetIndex() { return nIndex; }
void SetIndex( sal_Int32 n ) { nIndex = n; }
sal_Bool DbgIsBuggy( EditDoc& rDoc );
@@ -406,7 +405,6 @@ public:
~TextPortion() { DBG_DTOR( EE_TextPortion, 0 ); delete pExtraInfos; }
sal_uInt16 GetLen() const { return nLen; }
- sal_uInt16& GetLen() { return nLen; }
void SetLen( sal_uInt16 nL ) { nLen = nL; }
Size& GetSize() { return aOutSz; }
diff --git a/editeng/source/editeng/editundo.cxx b/editeng/source/editeng/editundo.cxx
index 02989df..48aacd8 100644
--- a/editeng/source/editeng/editundo.cxx
+++ b/editeng/source/editeng/editundo.cxx
@@ -305,7 +305,7 @@ void EditUndoInsertChars::Undo()
DBG_ASSERT( GetEditEngine()->GetActiveView(), "Undo/Redo: No Active View!" );
EditPaM aPaM = GetEditEngine()->CreateEditPaM(aEPaM);
EditSelection aSel( aPaM, aPaM );
- aSel.Max().GetIndex() = aSel.Max().GetIndex() + aText.getLength();
+ aSel.Max().SetIndex( aSel.Max().GetIndex() + aText.getLength() );
EditPaM aNewPaM( GetEditEngine()->DeleteSelection(aSel) );
GetEditEngine()->GetActiveView()->GetImpEditView()->SetEditSelection( EditSelection( aNewPaM, aNewPaM ) );
}
@@ -316,7 +316,7 @@ void EditUndoInsertChars::Redo()
EditPaM aPaM = GetEditEngine()->CreateEditPaM(aEPaM);
GetEditEngine()->InsertText(EditSelection(aPaM, aPaM), aText);
EditPaM aNewPaM( aPaM );
- aNewPaM.GetIndex() = aNewPaM.GetIndex() + aText.getLength();
+ aNewPaM.SetIndex( aNewPaM.GetIndex() + aText.getLength() );
GetEditEngine()->GetActiveView()->GetImpEditView()->SetEditSelection( EditSelection( aPaM, aNewPaM ) );
}
@@ -348,7 +348,7 @@ void EditUndoRemoveChars::Undo()
EditPaM aPaM = GetEditEngine()->CreateEditPaM(aEPaM);
EditSelection aSel( aPaM, aPaM );
GetEditEngine()->InsertText(aSel, aText);
- aSel.Max().GetIndex() = aSel.Max().GetIndex() + aText.getLength();
+ aSel.Max().SetIndex( aSel.Max().GetIndex() + aText.getLength() );
GetEditEngine()->GetActiveView()->GetImpEditView()->SetEditSelection(aSel);
}
@@ -357,7 +357,7 @@ void EditUndoRemoveChars::Redo()
DBG_ASSERT( GetEditEngine()->GetActiveView(), "Undo/Redo: No Active View!" );
EditPaM aPaM = GetEditEngine()->CreateEditPaM(aEPaM);
EditSelection aSel( aPaM, aPaM );
- aSel.Max().GetIndex() = aSel.Max().GetIndex() + aText.getLength();
+ aSel.Max().SetIndex( aSel.Max().GetIndex() + aText.getLength() );
EditPaM aNewPaM = GetEditEngine()->DeleteSelection(aSel);
GetEditEngine()->GetActiveView()->GetImpEditView()->SetEditSelection(aNewPaM);
}
@@ -381,9 +381,9 @@ void EditUndoInsertFeature::Undo()
EditPaM aPaM = GetEditEngine()->CreateEditPaM(aEPaM);
EditSelection aSel( aPaM, aPaM );
// Attributes are then corrected implicitly by the document ...
- aSel.Max().GetIndex()++;
+ aSel.Max().SetIndex( aSel.Max().GetIndex()+1 );
GetEditEngine()->DeleteSelection(aSel);
- aSel.Max().GetIndex()--; // For Selection
+ aSel.Max().SetIndex( aSel.Max().GetIndex()-1 ); // For Selection
GetEditEngine()->GetActiveView()->GetImpEditView()->SetEditSelection(aSel);
}
@@ -395,7 +395,7 @@ void EditUndoInsertFeature::Redo()
GetEditEngine()->InsertFeature(aSel, *pFeature);
if ( pFeature->Which() == EE_FEATURE_FIELD )
GetEditEngine()->UpdateFieldsOnly();
- aSel.Max().GetIndex()++;
+ aSel.Max().SetIndex( aSel.Max().GetIndex()+1 );
GetEditEngine()->GetActiveView()->GetImpEditView()->SetEditSelection(aSel);
}
@@ -617,14 +617,12 @@ void EditUndoTransliteration::Undo()
if ( aNewSel.Min().GetNode() == aDelSel.Max().GetNode() )
{
aNewSel.Min().SetNode( aDelSel.Min().GetNode() );
- aNewSel.Min().GetIndex() =
- aNewSel.Min().GetIndex() + aDelSel.Min().GetIndex();
+ aNewSel.Min().SetIndex( aNewSel.Min().GetIndex() + aDelSel.Min().GetIndex() );
}
if ( aNewSel.Max().GetNode() == aDelSel.Max().GetNode() )
{
aNewSel.Max().SetNode( aDelSel.Min().GetNode() );
- aNewSel.Max().GetIndex() =
- aNewSel.Max().GetIndex() + aDelSel.Min().GetIndex();
+ aNewSel.Max().SetIndex( aNewSel.Max().GetIndex() + aDelSel.Min().GetIndex() );
}
pEE->DeleteSelected( aDelSel );
pEE->GetActiveView()->GetImpEditView()->SetEditSelection( aNewSel );
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index bd07d8a..7895f92 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -880,7 +880,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack )
pInsertMenu->SetMenuFlags( MENU_FLAG_NOAUTOMNEMONICS ); //! necessary to retrieve the correct dictionary names later
EditPaM aPaM2( aPaM );
- aPaM2.GetIndex()++;
+ aPaM2.SetIndex( aPaM2.GetIndex()+1 );
// Are there any replace suggestions?
OUString aSelected( GetSelected() );
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index cbf6c0e..556bf80 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -1581,7 +1581,7 @@ void ImpEditView::dragGestureRecognized( const ::com::sun::star::datatransfer::d
break;
}
}
- aEndPaM.GetIndex() = aEndPaM.GetNode()->Len();
+ aEndPaM.SetIndex( aEndPaM.GetNode()->Len() );
SetEditSelection( EditSelection( aStartPaM, aEndPaM ) );
}
}
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 5813cfc..14df4f3 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -372,9 +372,8 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
if ( mpIMEInfos->nLen )
{
EditSelection aSel( mpIMEInfos->aPos );
- aSel.Min().GetIndex() += mpIMEInfos->nLen-1;
- aSel.Max().GetIndex() =
- aSel.Max().GetIndex() + mpIMEInfos->nLen;
+ aSel.Min().SetIndex( aSel.Min().GetIndex() + mpIMEInfos->nLen-1 );
+ aSel.Max().SetIndex( aSel.Max().GetIndex() + mpIMEInfos->nLen );
// #102812# convert quotes in IME text
// works on the last input character, this is escpecially in Korean text often done
// quotes that are inside of the string are not replaced!
@@ -411,8 +410,7 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
if ( !pData->IsOnlyCursorChanged() )
{
EditSelection aSel( mpIMEInfos->aPos );
- aSel.Max().GetIndex() =
- aSel.Max().GetIndex() + mpIMEInfos->nLen;
+ aSel.Max().SetIndex( aSel.Max().GetIndex() + mpIMEInfos->nLen );
aSel = DeleteSelected( aSel );
aSel = ImpInsertText( aSel, pData->GetText() );
@@ -427,7 +425,7 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
// restore old characters
sal_Int32 nRestore = nOldIMETextLen - nNewIMETextLen;
EditPaM aPaM( mpIMEInfos->aPos );
- aPaM.GetIndex() = aPaM.GetIndex() + nNewIMETextLen;
+ aPaM.SetIndex( aPaM.GetIndex() + nNewIMETextLen );
ImpInsertText( aPaM, mpIMEInfos->aOldTextAfterStartPos.copy( nNewIMETextLen, nRestore ) );
}
else if ( ( nOldIMETextLen < nNewIMETextLen ) &&
@@ -439,10 +437,9 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
nOverwrite = mpIMEInfos->aOldTextAfterStartPos.getLength() - nOldIMETextLen;
OSL_ENSURE( nOverwrite && (nOverwrite < 0xFF00), "IME Overwrite?!" );
EditPaM aPaM( mpIMEInfos->aPos );
- aPaM.GetIndex() = aPaM.GetIndex() + nNewIMETextLen;
+ aPaM.SetIndex( aPaM.GetIndex() + nNewIMETextLen );
EditSelection _aSel( aPaM );
- _aSel.Max().GetIndex() =
- _aSel.Max().GetIndex() + nOverwrite;
+ _aSel.Max().SetIndex( _aSel.Max().GetIndex() + nOverwrite );
DeleteSelected( _aSel );
}
}
@@ -943,7 +940,7 @@ EditPaM ImpEditEngine::CursorVisualStartEnd( EditView* pEditView, const EditPaM&
ubidi_close( pBidi );
- aPaM.GetIndex() = nLogPos + pLine->GetStart();
+ aPaM.SetIndex( nLogPos + pLine->GetStart() );
sal_uInt16 nTmp;
sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTmp, sal_True );
@@ -956,13 +953,13 @@ EditPaM ImpEditEngine::CursorVisualStartEnd( EditView* pEditView, const EditPaM&
pEditView->pImpEditView->SetCursorBidiLevel( bPortionRTL ? 0 : 1 );
// Maybe we must be *behind* the character
if ( bPortionRTL && pEditView->IsInsertMode() )
- aPaM.GetIndex()++;
+ aPaM.SetIndex( aPaM.GetIndex()+1 );
}
else
{
pEditView->pImpEditView->SetCursorBidiLevel( bPortionRTL ? 1 : 0 );
if ( !bPortionRTL && pEditView->IsInsertMode() )
- aPaM.GetIndex()++;
+ aPaM.SetIndex( aPaM.GetIndex()+1 );
}
}
@@ -1077,8 +1074,7 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
if ( !bGotoEndOfPrevLine && !bGotoStartOfNextLine )
{
- sal_uInt16 nLogPos = (sal_uInt16)ubidi_getLogicalIndex( pBidi, nVisPos, &nError );
- aPaM.GetIndex() = pLine->GetStart() + nLogPos;
+ aPaM.SetIndex( pLine->GetStart() + ubidi_getLogicalIndex( pBidi, nVisPos, &nError ) );
pEditView->pImpEditView->SetCursorBidiLevel( 0 );
}
}
@@ -1112,9 +1108,7 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
if ( !bGotoEndOfPrevLine && !bGotoStartOfNextLine )
{
- sal_uInt16 nLogPos = (sal_uInt16)ubidi_getLogicalIndex( pBidi, nVisPos, &nError );
-
- aPaM.GetIndex() = pLine->GetStart() + nLogPos;
+ aPaM.SetIndex( pLine->GetStart() + ubidi_getLogicalIndex( pBidi, nVisPos, &nError ) );
// RTL portion, stay visually on the left side.
sal_uInt16 _nPortionStart;
@@ -1122,9 +1116,9 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
sal_uInt16 _nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), _nPortionStart, sal_True );
const TextPortion* _pTextPortion = pParaPortion->GetTextPortions()[_nTextPortion];
if ( bVisualToLeft && !bRTLPortion && ( _pTextPortion->GetRightToLeft() % 2 ) )
- aPaM.GetIndex()++;
+ aPaM.SetIndex( aPaM.GetIndex()+1 );
else if ( !bVisualToLeft && bRTLPortion && ( bWasBehind || !(_pTextPortion->GetRightToLeft() % 2 )) )
- aPaM.GetIndex()++;
+ aPaM.SetIndex( aPaM.GetIndex()+1 );
pEditView->pImpEditView->SetCursorBidiLevel( _nPortionStart );
}
@@ -2059,7 +2053,7 @@ void ImpEditEngine::ImpRemoveChars( const EditPaM& rPaM, sal_uInt16 nChars, Edit
if (rAttr.GetEnd() >= nStart && rAttr.GetStart() < nEnd)
{
EditSelection aSel( rPaM );
- aSel.Max().GetIndex() = aSel.Max().GetIndex() + nChars;
+ aSel.Max().SetIndex( aSel.Max().GetIndex() + nChars );
EditUndoSetAttribs* pAttrUndo = CreateAttribUndo( aSel, GetEmptyItemSet() );
InsertUndo( pAttrUndo );
break; // for
@@ -2567,7 +2561,7 @@ EditPaM ImpEditEngine::InsertText( const EditSelection& rCurSel,
{
// If selected, then do not also overwrite a character!
EditSelection aTmpSel( aPaM );
- aTmpSel.Max().GetIndex()++;
+ aTmpSel.Max().SetIndex( aTmpSel.Max().GetIndex()+1 );
OSL_ENSURE( !aTmpSel.DbgIsBuggy( aEditDoc ), "Overwrite: Wrong selection! ");
ImpDeleteSelection( aTmpSel );
}
@@ -2636,7 +2630,7 @@ EditPaM ImpEditEngine::InsertText( const EditSelection& rCurSel,
ParaPortion* pPortion = FindParaPortion( aPaM.GetNode() );
OSL_ENSURE( pPortion, "Blind Portion in InsertText" );
pPortion->MarkInvalid( aPaM.GetIndex(), 1 );
- aPaM.GetIndex()++; // does not do EditDoc-Method anymore
+ aPaM.SetIndex( aPaM.GetIndex()+1 ); // does not do EditDoc-Method anymore
}
TextModified();
@@ -3349,12 +3343,12 @@ void ImpEditEngine::UpdateSelections()
// Check Index if node shrunk.
if ( aCurSel.Min().GetIndex() > aCurSel.Min().GetNode()->Len() )
{
- aCurSel.Min().GetIndex() = aCurSel.Min().GetNode()->Len();
+ aCurSel.Min().SetIndex( aCurSel.Min().GetNode()->Len() );
pView->pImpEditView->SetEditSelection( aCurSel );
}
if ( aCurSel.Max().GetIndex() > aCurSel.Max().GetNode()->Len() )
{
- aCurSel.Max().GetIndex() = aCurSel.Max().GetNode()->Len();
+ aCurSel.Max().SetIndex( aCurSel.Max().GetNode()->Len() );
pView->pImpEditView->SetEditSelection( aCurSel );
}
}
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 38a84c1..5fc405c 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -2111,18 +2111,18 @@ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_uInt16 nStart, sal_
EditSelection aWordSel( EditPaM( pNode, nStart ) );
aWordSel = SelectWord( aWordSel, ::com::sun::star::i18n::WordType::DICTIONARY_WORD );
if ( aWordSel.Min().GetIndex() < nStart )
- aWordSel.Min().GetIndex() = nStart;
+ aWordSel.Min().SetIndex( nStart );
while ( ( aWordSel.Min().GetNode() == pNode ) && ( aWordSel.Min().GetIndex() < nEnd ) )
{
const sal_Int32 nSavPos = aWordSel.Max().GetIndex();
if ( aWordSel.Max().GetIndex() > nEnd )
- aWordSel.Max().GetIndex() = nEnd;
+ aWordSel.Max().SetIndex( nEnd );
OUString aWord = GetSelected( aWordSel );
// restore selection for proper iteration at the end of the function
- aWordSel.Max().GetIndex() = nSavPos;
+ aWordSel.Max().SetIndex( nSavPos );
sal_Int32 nIdx = 0;
sal_Int32 nKashidaPos = -1;
@@ -2252,7 +2252,7 @@ sal_uInt16 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_uInt16 nP
DBG_ASSERT( pTextPortion->GetKind() == PORTIONKIND_TEXT, "SplitTextPortion: No TextPortion!" );
sal_uInt16 nOverlapp = nTmpPos - nPos;
- pTextPortion->GetLen() = pTextPortion->GetLen() - nOverlapp;
+ pTextPortion->SetLen( pTextPortion->GetLen() - nOverlapp );
TextPortion* pNewPortion = new TextPortion( nOverlapp );
pPortion->GetTextPortions().Insert(nSplitPortion+1, pNewPortion);
// Set sizes
@@ -2399,10 +2399,9 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nSt
if ( ( nNewPortionPos < pParaPortion->GetTextPortions().Count() ) &&
!pParaPortion->GetTextPortions()[nNewPortionPos]->GetLen() )
{
- DBG_ASSERT( pParaPortion->GetTextPortions()[nNewPortionPos]->GetKind() == PORTIONKIND_TEXT, "the empty portion was no TextPortion!" );
- sal_uInt16 & r =
- pParaPortion->GetTextPortions()[nNewPortionPos]->GetLen();
- r = r + nNewChars;
+ TextPortion* const pTP = pParaPortion->GetTextPortions()[nNewPortionPos];
+ DBG_ASSERT( pTP->GetKind() == PORTIONKIND_TEXT, "the empty portion was no TextPortion!" );
+ pTP->SetLen( pTP->GetLen() + nNewChars );
}
else
{
@@ -2417,7 +2416,7 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nSt
FindPortion( nStartPos, nPortionStart );
TextPortion* const pTP = pParaPortion->GetTextPortions()[ nTP ];
DBG_ASSERT( pTP, "RecalcTextPortion: Portion not found" );
- pTP->GetLen() = pTP->GetLen() + nNewChars;
+ pTP->SetLen( pTP->GetLen() + nNewChars );
pTP->GetSize().Width() = (-1);
}
}
@@ -2465,7 +2464,7 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nSt
else
{
DBG_ASSERT( pTP->GetLen() > (-nNewChars), "Portion too small to shrink! ");
- pTP->GetLen() = pTP->GetLen() + nNewChars;
+ pTP->SetLen( pTP->GetLen() + nNewChars );
}
sal_uInt16 nPortionCount = pParaPortion->GetTextPortions().Count();
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 414fd58..5cc25b6 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1490,7 +1490,7 @@ EESpellState ImpEditEngine::Spell( EditView* pEditView, sal_Bool bMultipleDoc )
{
pEditView->pImpEditView->DrawSelection();
if ( aCurSel.Max().GetIndex() > aCurSel.Max().GetNode()->Len() )
- aCurSel.Max().GetIndex() = aCurSel.Max().GetNode()->Len();
+ aCurSel.Max().SetIndex( aCurSel.Max().GetNode()->Len() );
aCurSel.Min() = aCurSel.Max();
pEditView->pImpEditView->SetEditSelection( aCurSel );
pEditView->pImpEditView->DrawSelection();
@@ -1615,7 +1615,7 @@ void ImpEditEngine::Convert( EditView* pEditView,
{
pEditView->pImpEditView->DrawSelection();
if ( aCurSel.Max().GetIndex() > aCurSel.Max().GetNode()->Len() )
- aCurSel.Max().GetIndex() = aCurSel.Max().GetNode()->Len();
+ aCurSel.Max().SetIndex( aCurSel.Max().GetNode()->Len() );
aCurSel.Min() = aCurSel.Max();
pEditView->pImpEditView->SetEditSelection( aCurSel );
pEditView->pImpEditView->DrawSelection();
@@ -1870,7 +1870,7 @@ Reference< XSpellAlternatives > ImpEditEngine::ImpSpell( EditView* pEditView )
sal_Unicode cNext = aCurSel.Max().GetNode()->GetChar( aCurSel.Max().GetIndex() );
if ( cNext == '.' )
{
- aCurSel.Max().GetIndex()++;
+ aCurSel.Max().SetIndex( aCurSel.Max().GetIndex()+1 );
aWord += OUString(cNext);
}
}
@@ -1929,7 +1929,7 @@ Reference< XSpellAlternatives > ImpEditEngine::ImpFindNextError(EditSelection& r
sal_Unicode cNext = aCurSel.Max().GetNode()->GetChar( aCurSel.Max().GetIndex() );
if ( cNext == '.' )
{
- aCurSel.Max().GetIndex()++;
+ aCurSel.Max().SetIndex( aCurSel.Max().GetIndex()+1 );
aWord += OUString(cNext);
}
}
@@ -2302,7 +2302,7 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC
sal_Unicode cNext = aSel.Max().GetNode()->GetChar( aSel.Max().GetIndex() );
if ( cNext == '.' )
{
- aSel.Max().GetIndex()++;
+ aSel.Max().SetIndex( aSel.Max().GetIndex()+1 );
bDottAdded = true;
}
}
@@ -2554,7 +2554,7 @@ sal_uInt16 ImpEditEngine::StartSearchAndReplace( EditView* pEditView, const SvxS
{
EditPaM aNewPaM( aFoundSel.Max() );
if ( aNewPaM.GetIndex() > aNewPaM.GetNode()->Len() )
- aNewPaM.GetIndex() = aNewPaM.GetNode()->Len();
+ aNewPaM.SetIndex( aNewPaM.GetNode()->Len() );
pEditView->pImpEditView->SetEditSelection( aNewPaM );
FormatAndUpdate( pEditView );
UndoActionEnd( EDITUNDO_REPLACEALL );
@@ -2993,7 +2993,7 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection,
// adjust selection in end node to possibly changed size
if (aSel.Max().GetNode() == rData.aSelection.Max().GetNode())
- aNewSel.Max().GetIndex() = aNewSel.Max().GetIndex() + nDiffs;
+ aNewSel.Max().SetIndex( aNewSel.Max().GetIndex() + nDiffs );
sal_Int32 nSelNode = aEditDoc.GetPos( rData.aSelection.Min().GetNode() );
ParaPortion* pParaPortion = GetParaPortions()[nSelNode];
commit 73f0b3bd5553c5d023d0a1dbfdc00836e2937961
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Dec 28 13:37:26 2013 +0100
xub_StrLen to sal_Int32 + some const
Change-Id: Ieae0940d3d072c3214b4fa2280dd0e01dc328cb7
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 26c2b24..0ec7b0d 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 40676d5..4d2479a 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 18b0c9a..bd07d8a 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 0736d05..cbf6c0e 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 c7fca54d..5813cfc 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 d5fec02..38a84c1 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 68cddec..414fd58 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 3f2a195..c92af79 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 );
commit 4b9f28c87fec24978b3e43765b8aa312ab5a8817
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Dec 22 21:50:19 2013 +0100
Avoid obscure and almost unused typedef
Change-Id: Ia57b39c770adcb506fb8457ca6cdbd3c6a2b0a76
diff --git a/sw/source/core/inc/scriptinfo.hxx b/sw/source/core/inc/scriptinfo.hxx
index 2d06862..090f6db 100644
--- a/sw/source/core/inc/scriptinfo.hxx
+++ b/sw/source/core/inc/scriptinfo.hxx
@@ -29,7 +29,6 @@ class SwTxtNode;
class Point;
class MultiSelection;
typedef std::list< xub_StrLen > PositionList;
-typedef std::deque< xub_StrLen > SvXub_StrLens;
#define SPACING_PRECISION_FACTOR 100
@@ -60,11 +59,11 @@ private:
inline DirectionChangeInfo(xub_StrLen pos, sal_uInt8 typ) : position(pos), type(typ) {};
};
std::vector<DirectionChangeInfo> aDirectionChanges;
- SvXub_StrLens aKashida;
- SvXub_StrLens aKashidaInvalid;
- SvXub_StrLens aNoKashidaLine;
- SvXub_StrLens aNoKashidaLineEnd;
- SvXub_StrLens aHiddenChg;
+ std::deque< xub_StrLen > aKashida;
+ std::deque< xub_StrLen > aKashidaInvalid;
+ std::deque< xub_StrLen > aNoKashidaLine;
+ std::deque< xub_StrLen > aNoKashidaLineEnd;
+ std::deque< xub_StrLen > aHiddenChg;
//! Records a single change in compression.
struct CompressionChangeInfo
{
diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx
index 6bff0b6..fdbe3dd 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <deque>
+
#include <hintids.hxx>
#include <com/sun/star/i18n/ScriptType.hpp>
@@ -984,7 +986,7 @@ SwMultiCreator* SwTxtSizeInfo::GetMultiCreator( xub_StrLen &rPos,
SwMultiCreator *pRet = new SwMultiCreator;
// We note the endpositions of the 2-line attributes in aEnd as stack
- SvXub_StrLens aEnd;
+ std::deque< xub_StrLen > aEnd;
// The bOn flag signs the state of the last 2-line attribute in the
// aEnd-stack, it is compatible with the winner-attribute or
@@ -1101,7 +1103,7 @@ SwMultiCreator* SwTxtSizeInfo::GetMultiCreator( xub_StrLen &rPos,
pRet->nId = SW_MC_ROTATE;
// We note the endpositions of the 2-line attributes in aEnd as stack
- SvXub_StrLens aEnd;
+ std::deque< xub_StrLen > aEnd;
// The bOn flag signs the state of the last 2-line attribute in the
// aEnd-stack, which could interrupts the winning rotation attribute.
More information about the Libreoffice-commits
mailing list