summaryrefslogtreecommitdiff
path: root/editeng/source/accessibility
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-05-08 18:12:32 +0200
committerEike Rathke <erack@redhat.com>2013-05-10 14:01:38 +0000
commit2af1f5691e8d64afd5246d245d7876b5a2cd5cd8 (patch)
treee8a51d852010730d4af4a14d445664cf8ee6475c /editeng/source/accessibility
parentebef182253e7d49c5439ab5053a7243ad24207a7 (diff)
resolved fdo#35756 import more than 64k HTML table cells
Enhanced EditEngine to be able to hold more than 64k paragraphs. Used also in RTF import Calc and Writer, so that could benefit as well. * changed all EditEngine,Outliner,... related paragraph index/count variables from sal_uInt16 to sal_Int32 * sal_Int32 instead of sal_uInt32 to match accessibility API * matched some Outliner methods' paragraph parameters from sal_uLong to sal_Int32 * containers capable to hold size_t nevertheless are limited to a maximum of sal_Int32 * changed definition of EE_PARA_NOT_FOUND and EE_PARA_ALL to SAL_MAX_INT32 + added EE_PARA_MAX_COUNT and EE_TEXTPOS_MAX_COUNT to initialize ESelection with what previously were hard coded 0xFFFF all over the place + for similar reason added EE_TEXTPOS_ALL corresponding to EE_PARA_ALL to initialize an ESelection spanning all available text like aSel(0,0,EE_PARA_ALL,EE_TEXTPOS_ALL) Change-Id: I62d1b9c399cd709a4f93dbac31b219a61c46ec00 Reviewed-on: https://gerrit.libreoffice.org/3838 Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'editeng/source/accessibility')
-rw-r--r--editeng/source/accessibility/AccessibleEditableTextPara.cxx53
-rw-r--r--editeng/source/accessibility/AccessibleHyperlink.cxx2
-rw-r--r--editeng/source/accessibility/AccessibleHyperlink.hxx5
-rw-r--r--editeng/source/accessibility/AccessibleImageBullet.cxx6
-rw-r--r--editeng/source/accessibility/AccessibleParaManager.cxx81
-rw-r--r--editeng/source/accessibility/AccessibleStaticTextBase.cxx29
6 files changed, 101 insertions, 75 deletions
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
index 634a91c287d9..9702c440e10b 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -178,11 +178,11 @@ namespace accessibility
{
DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
- DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
+ DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= SAL_MAX_INT32,
"AccessibleEditableTextPara::getLocale: paragraph index value overflow");
// return locale of first character in the paragraph
- return LanguageTag(GetTextForwarder().GetLanguage( static_cast< sal_uInt16 >( GetParagraphIndex() ), 0 )).getLocale();
+ return LanguageTag(GetTextForwarder().GetLanguage( GetParagraphIndex(), 0 )).getLocale();
}
void AccessibleEditableTextPara::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
@@ -220,16 +220,16 @@ namespace accessibility
SvxTextForwarder& rCacheTF = GetTextForwarder();
const sal_Int32 nParaIndex = GetParagraphIndex();
- DBG_ASSERT(nParaIndex >= 0 && nParaIndex <= USHRT_MAX,
+ DBG_ASSERT(nParaIndex >= 0 && nParaIndex <= SAL_MAX_INT32,
"AccessibleEditableTextPara::implGetLineBoundary: paragraph index value overflow");
- const sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) );
+ const sal_Int32 nTextLen = rCacheTF.GetTextLen( nParaIndex );
CheckPosition(nIndex);
rBoundary.startPos = rBoundary.endPos = -1;
- const sal_uInt16 nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) );
+ const sal_uInt16 nLineCount=rCacheTF.GetLineCount( nParaIndex );
if( nIndex == nTextLen )
{
@@ -237,7 +237,7 @@ namespace accessibility
if( nLineCount <= 1 )
rBoundary.startPos = 0;
else
- rBoundary.startPos = nTextLen - rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ),
+ rBoundary.startPos = nTextLen - rCacheTF.GetLineLen( nParaIndex,
nLineCount-1 );
rBoundary.endPos = nTextLen;
@@ -249,11 +249,11 @@ namespace accessibility
sal_Int32 nCurIndex;
for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine )
{
- nCurIndex += rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine);
+ nCurIndex += rCacheTF.GetLineLen( nParaIndex, nLine);
if( nCurIndex > nIndex )
{
- rBoundary.startPos = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine);
+ rBoundary.startPos = nCurIndex - rCacheTF.GetLineLen( nParaIndex, nLine);
rBoundary.endPos = nCurIndex;
break;
}
@@ -394,10 +394,10 @@ namespace accessibility
// check overflow
DBG_ASSERT(nStartEEIndex >= 0 && nStartEEIndex <= USHRT_MAX &&
nEndEEIndex >= 0 && nEndEEIndex <= USHRT_MAX &&
- GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
+ GetParagraphIndex() >= 0 && GetParagraphIndex() <= SAL_MAX_INT32,
"AccessibleEditableTextPara::MakeSelection: index value overflow");
- sal_uInt16 nParaIndex = static_cast< sal_uInt16 >( GetParagraphIndex() );
+ sal_Int32 nParaIndex = GetParagraphIndex();
return ESelection( nParaIndex, static_cast< sal_uInt16 >( nStartEEIndex ),
nParaIndex, static_cast< sal_uInt16 >( nEndEEIndex ) );
}
@@ -449,7 +449,7 @@ namespace accessibility
DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
ESelection aSelection;
- sal_uInt16 nPara = static_cast< sal_uInt16 > ( GetParagraphIndex() );
+ sal_Int32 nPara = GetParagraphIndex();
if( !GetEditViewForwarder().GetSelection( aSelection ) )
return sal_False;
@@ -620,10 +620,10 @@ namespace accessibility
{
DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
- DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
+ DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= SAL_MAX_INT32,
"AccessibleEditableTextPara::HaveChildren: paragraph index value overflow");
- return GetTextForwarder().HaveImageBullet( static_cast< sal_uInt16 >(GetParagraphIndex()) );
+ return GetTextForwarder().HaveImageBullet( GetParagraphIndex() );
}
Rectangle AccessibleEditableTextPara::LogicToPixel( const Rectangle& rRect, const MapMode& rMapMode, SvxViewForwarder& rForwarder )
@@ -729,12 +729,12 @@ namespace accessibility
DBG_ASSERT(nIndex >= 0 && nIndex <= USHRT_MAX,
"AccessibleEditableTextPara::GetAttributeRun: index value overflow");
- DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
+ DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= SAL_MAX_INT32,
"AccessibleEditableTextPara::getLocale: paragraph index value overflow");
return GetTextForwarder().GetAttributeRun( nStartIndex,
nEndIndex,
- static_cast< sal_uInt16 >(GetParagraphIndex()),
+ GetParagraphIndex(),
static_cast< sal_uInt16 >(nIndex) );
}
@@ -963,7 +963,7 @@ namespace accessibility
SolarMutexGuard aGuard;
- DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
+ DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= SAL_MAX_INT32,
"AccessibleEditableTextPara::contains: index value overflow");
awt::Rectangle aTmpRect = getBounds();
@@ -1014,11 +1014,11 @@ namespace accessibility
SolarMutexGuard aGuard;
- DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
+ DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= SAL_MAX_INT32,
"AccessibleEditableTextPara::getBounds: index value overflow");
SvxTextForwarder& rCacheTF = GetTextForwarder();
- Rectangle aRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
+ Rectangle aRect = rCacheTF.GetParaBounds( GetParagraphIndex() );
// convert to screen coordinates
Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect,
@@ -1272,7 +1272,8 @@ namespace accessibility
SolarMutexGuard aGuard;
- sal_uInt16 nPara, nIndex;
+ sal_Int32 nPara;
+ sal_uInt16 nIndex;
// offset from surrounding cell/shape
Point aOffset( GetEEOffset() );
@@ -1283,7 +1284,7 @@ namespace accessibility
Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.GetMapMode() ) );
// re-offset to parent (paragraph)
- Rectangle aParaRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
+ Rectangle aParaRect = rCacheTF.GetParaBounds( GetParagraphIndex() );
aLogPoint.Move( aParaRect.Left(), aParaRect.Top() );
if( rCacheTF.GetIndexAtPoint( aLogPoint, nPara, nIndex ) &&
@@ -1423,7 +1424,7 @@ namespace accessibility
// implGetAttributeRunBoundary() method there
case AccessibleTextType::ATTRIBUTE_RUN:
{
- const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
+ const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( GetParagraphIndex() );
if( nIndex == nTextLen )
{
@@ -1471,7 +1472,7 @@ namespace accessibility
// implGetAttributeRunBoundary() method there
case AccessibleTextType::ATTRIBUTE_RUN:
{
- const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
+ const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( GetParagraphIndex() );
sal_uInt16 nStartIndex, nEndIndex;
if( nIndex == nTextLen )
@@ -2104,8 +2105,8 @@ namespace accessibility
if (bValidPara)
{
// we explicitly allow for the index to point at the character right behind the text
- if (0 <= nIndex && nIndex <= rCacheTF.GetTextLen( static_cast< sal_uInt16 >(nPara) ))
- nRes = rCacheTF.GetLineNumberAtIndex( static_cast< sal_uInt16 >(nPara), static_cast< sal_uInt16 >(nIndex) );
+ if (0 <= nIndex && nIndex <= rCacheTF.GetTextLen( nPara ))
+ nRes = rCacheTF.GetLineNumberAtIndex( nPara, static_cast< sal_uInt16 >(nIndex) );
else
throw lang::IndexOutOfBoundsException();
}
@@ -2124,10 +2125,10 @@ namespace accessibility
DBG_ASSERT( bValidPara, "getTextAtLineNumber: current paragraph index out of range" );
if (bValidPara)
{
- if (0 <= nLineNo && nLineNo < rCacheTF.GetLineCount( static_cast< sal_uInt16 >(nPara) ))
+ if (0 <= nLineNo && nLineNo < rCacheTF.GetLineCount( nPara ))
{
sal_uInt16 nStart = 0, nEnd = 0;
- rCacheTF.GetLineBoundaries( nStart, nEnd, static_cast< sal_uInt16 >(nPara), static_cast< sal_uInt16 >(nLineNo) );
+ rCacheTF.GetLineBoundaries( nStart, nEnd, nPara, static_cast< sal_uInt16 >(nLineNo) );
if (nStart != 0xFFFF && nEnd != 0xFFFF)
{
try
diff --git a/editeng/source/accessibility/AccessibleHyperlink.cxx b/editeng/source/accessibility/AccessibleHyperlink.cxx
index 86e72d461f9f..0407c88b019c 100644
--- a/editeng/source/accessibility/AccessibleHyperlink.cxx
+++ b/editeng/source/accessibility/AccessibleHyperlink.cxx
@@ -39,7 +39,7 @@ using namespace ::com::sun::star;
namespace accessibility
{
- AccessibleHyperlink::AccessibleHyperlink( SvxAccessibleTextAdapter& r, SvxFieldItem* p, sal_uInt16 nP, sal_uInt16 nR, sal_Int32 nStt, sal_Int32 nEnd, const OUString& rD )
+ AccessibleHyperlink::AccessibleHyperlink( SvxAccessibleTextAdapter& r, SvxFieldItem* p, sal_Int32 nP, sal_uInt16 nR, sal_Int32 nStt, sal_Int32 nEnd, const OUString& rD )
: rTA( r )
{
pFld = p;
diff --git a/editeng/source/accessibility/AccessibleHyperlink.hxx b/editeng/source/accessibility/AccessibleHyperlink.hxx
index 8157a2aa1457..4e0f17825e36 100644
--- a/editeng/source/accessibility/AccessibleHyperlink.hxx
+++ b/editeng/source/accessibility/AccessibleHyperlink.hxx
@@ -43,12 +43,13 @@ namespace accessibility
SvxAccessibleTextAdapter& rTA;
SvxFieldItem* pFld;
- sal_uInt16 nPara, nRealIdx; // EE values
+ sal_Int32 nPara; // EE values
+ sal_uInt16 nRealIdx; // EE values
sal_Int32 nStartIdx, nEndIdx; // translated values
OUString aDescription;
public:
- AccessibleHyperlink( SvxAccessibleTextAdapter& r, SvxFieldItem* p, sal_uInt16 nP, sal_uInt16 nR, sal_Int32 nStt, sal_Int32 nEnd, const OUString& rD );
+ AccessibleHyperlink( SvxAccessibleTextAdapter& r, SvxFieldItem* p, sal_Int32 nP, sal_uInt16 nR, sal_Int32 nStt, sal_Int32 nEnd, const OUString& rD );
~AccessibleHyperlink();
// XAccessibleAction
diff --git a/editeng/source/accessibility/AccessibleImageBullet.cxx b/editeng/source/accessibility/AccessibleImageBullet.cxx
index 177ccef61265..3e9c2e23ed27 100644
--- a/editeng/source/accessibility/AccessibleImageBullet.cxx
+++ b/editeng/source/accessibility/AccessibleImageBullet.cxx
@@ -206,7 +206,7 @@ namespace accessibility
"AccessibleImageBullet::getLocale: paragraph index value overflow");
// return locale of first character in the paragraph
- return LanguageTag(GetTextForwarder().GetLanguage( static_cast< sal_uInt16 >( GetParagraphIndex() ), 0 )).getLocale();
+ return LanguageTag(GetTextForwarder().GetLanguage( GetParagraphIndex(), 0 )).getLocale();
}
void SAL_CALL AccessibleImageBullet::addAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException)
@@ -259,8 +259,8 @@ namespace accessibility
"AccessibleEditableTextPara::getBounds: index value overflow");
SvxTextForwarder& rCacheTF = GetTextForwarder();
- EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 > (GetParagraphIndex()) );
- Rectangle aParentRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
+ EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( GetParagraphIndex() );
+ Rectangle aParentRect = rCacheTF.GetParaBounds( GetParagraphIndex() );
if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
aBulletInfo.bVisible &&
diff --git a/editeng/source/accessibility/AccessibleParaManager.cxx b/editeng/source/accessibility/AccessibleParaManager.cxx
index c3c24d604259..08d6bf05698f 100644
--- a/editeng/source/accessibility/AccessibleParaManager.cxx
+++ b/editeng/source/accessibility/AccessibleParaManager.cxx
@@ -78,9 +78,15 @@ namespace accessibility
mnFocusedChild = -1;
}
- sal_uInt32 AccessibleParaManager::GetNum() const
+ sal_Int32 AccessibleParaManager::GetNum() const
{
- return maChildren.size();
+ size_t nSize = maChildren.size();
+ if (nSize > SAL_MAX_INT32)
+ {
+ SAL_WARN( "editeng", "AccessibleParaManager::GetNum - overflow " << nSize);
+ return SAL_MAX_INT32;
+ }
+ return static_cast<sal_Int32>(nSize);
}
AccessibleParaManager::VectorOfChildren::iterator AccessibleParaManager::begin()
@@ -103,11 +109,12 @@ namespace accessibility
return maChildren.end();
}
- void AccessibleParaManager::Release( sal_uInt32 nPara )
+ void AccessibleParaManager::Release( sal_Int32 nPara )
{
- DBG_ASSERT( maChildren.size() > nPara, "AccessibleParaManager::Release: invalid index" );
+ DBG_ASSERT( 0 <= nPara && maChildren.size() > static_cast<size_t>(nPara),
+ "AccessibleParaManager::Release: invalid index" );
- if( maChildren.size() > nPara )
+ if( 0 <= nPara && maChildren.size() > static_cast<size_t>(nPara) )
{
ShutdownPara( GetChild( nPara ) );
@@ -116,14 +123,15 @@ namespace accessibility
}
}
- void AccessibleParaManager::FireEvent( sal_uInt32 nPara,
+ void AccessibleParaManager::FireEvent( sal_Int32 nPara,
const sal_Int16 nEventId,
const uno::Any& rNewValue,
const uno::Any& rOldValue ) const
{
- DBG_ASSERT( maChildren.size() > nPara, "AccessibleParaManager::FireEvent: invalid index" );
+ DBG_ASSERT( 0 <= nPara && maChildren.size() > static_cast<size_t>(nPara),
+ "AccessibleParaManager::FireEvent: invalid index" );
- if( maChildren.size() > nPara )
+ if( 0 <= nPara && maChildren.size() > static_cast<size_t>(nPara) )
{
WeakPara::HardRefType maChild( GetChild( nPara ).first.get() );
if( maChild.is() )
@@ -136,11 +144,12 @@ namespace accessibility
return aChild.is();
}
- sal_Bool AccessibleParaManager::IsReferencable( sal_uInt32 nChild ) const
+ sal_Bool AccessibleParaManager::IsReferencable( sal_Int32 nChild ) const
{
- DBG_ASSERT( maChildren.size() > nChild, "AccessibleParaManager::IsReferencable: invalid index" );
+ DBG_ASSERT( 0 <= nChild && maChildren.size() > static_cast<size_t>(nChild),
+ "AccessibleParaManager::IsReferencable: invalid index" );
- if( maChildren.size() > nChild )
+ if( 0 <= nChild && maChildren.size() > static_cast<size_t>(nChild) )
{
// retrieve hard reference from weak one
return IsReferencable( GetChild( nChild ).first.get() );
@@ -151,11 +160,12 @@ namespace accessibility
}
}
- AccessibleParaManager::WeakChild AccessibleParaManager::GetChild( sal_uInt32 nParagraphIndex ) const
+ AccessibleParaManager::WeakChild AccessibleParaManager::GetChild( sal_Int32 nParagraphIndex ) const
{
- DBG_ASSERT( maChildren.size() > nParagraphIndex, "AccessibleParaManager::GetChild: invalid index" );
+ DBG_ASSERT( 0 <= nParagraphIndex && maChildren.size() > static_cast<size_t>(nParagraphIndex),
+ "AccessibleParaManager::GetChild: invalid index" );
- if( maChildren.size() > nParagraphIndex )
+ if( 0 <= nParagraphIndex && maChildren.size() > static_cast<size_t>(nParagraphIndex) )
{
return maChildren[ nParagraphIndex ];
}
@@ -168,11 +178,12 @@ namespace accessibility
AccessibleParaManager::Child AccessibleParaManager::CreateChild( sal_Int32 nChild,
const uno::Reference< XAccessible >& xFrontEnd,
SvxEditSourceAdapter& rEditSource,
- sal_uInt32 nParagraphIndex )
+ sal_Int32 nParagraphIndex )
{
- DBG_ASSERT( maChildren.size() > nParagraphIndex, "AccessibleParaManager::CreateChild: invalid index" );
+ DBG_ASSERT( 0 <= nParagraphIndex && maChildren.size() > static_cast<size_t>(nParagraphIndex),
+ "AccessibleParaManager::CreateChild: invalid index" );
- if( maChildren.size() > nParagraphIndex )
+ if( 0 <= nParagraphIndex && maChildren.size() > static_cast<size_t>(nParagraphIndex) )
{
// retrieve hard reference from weak one
WeakPara::HardRefType aChild( GetChild( nParagraphIndex ).first.get() );
@@ -240,7 +251,7 @@ namespace accessibility
void AccessibleParaManager::InitChild( AccessibleEditableTextPara& rChild,
SvxEditSourceAdapter& rEditSource,
sal_Int32 nChild,
- sal_uInt32 nParagraphIndex ) const
+ sal_Int32 nParagraphIndex ) const
{
rChild.SetEditSource( &rEditSource );
rChild.SetIndexInParent( nChild );
@@ -254,7 +265,7 @@ namespace accessibility
rChild.SetState( AccessibleStateType::EDITABLE );
}
- if( mnFocusedChild == static_cast<sal_Int32>(nParagraphIndex) )
+ if( mnFocusedChild == nParagraphIndex )
rChild.SetState( AccessibleStateType::FOCUSED );
// add states passed from outside
@@ -331,17 +342,20 @@ namespace accessibility
const uno::Any& mrOldValue;
};
- void AccessibleParaManager::FireEvent( sal_uInt32 nStartPara,
- sal_uInt32 nEndPara,
+ void AccessibleParaManager::FireEvent( sal_Int32 nStartPara,
+ sal_Int32 nEndPara,
const sal_Int16 nEventId,
const uno::Any& rNewValue,
const uno::Any& rOldValue ) const
{
- DBG_ASSERT( maChildren.size() > nStartPara &&
- maChildren.size() >= nEndPara , "AccessibleParaManager::FireEvent: invalid index" );
-
- if( maChildren.size() > nStartPara &&
- maChildren.size() >= nEndPara )
+ DBG_ASSERT( 0 <= nStartPara && 0 <= nEndPara &&
+ maChildren.size() > static_cast<size_t>(nStartPara) &&
+ maChildren.size() >= static_cast<size_t>(nEndPara) ,
+ "AccessibleParaManager::FireEvent: invalid index" );
+
+ if( 0 <= nStartPara && 0 <= nEndPara &&
+ maChildren.size() > static_cast<size_t>(nStartPara) &&
+ maChildren.size() >= static_cast<size_t>(nEndPara) )
{
VectorOfChildren::const_iterator front = maChildren.begin();
VectorOfChildren::const_iterator back = front;
@@ -367,13 +381,16 @@ namespace accessibility
}
};
- void AccessibleParaManager::Release( sal_uInt32 nStartPara, sal_uInt32 nEndPara )
+ void AccessibleParaManager::Release( sal_Int32 nStartPara, sal_Int32 nEndPara )
{
- DBG_ASSERT( maChildren.size() > nStartPara &&
- maChildren.size() >= nEndPara, "AccessibleParaManager::Release: invalid index" );
-
- if( maChildren.size() > nStartPara &&
- maChildren.size() >= nEndPara )
+ DBG_ASSERT( 0 <= nStartPara && 0 <= nEndPara &&
+ maChildren.size() > static_cast<size_t>(nStartPara) &&
+ maChildren.size() >= static_cast<size_t>(nEndPara),
+ "AccessibleParaManager::Release: invalid index" );
+
+ if( 0 <= nStartPara && 0 <= nEndPara &&
+ maChildren.size() > static_cast<size_t>(nStartPara) &&
+ maChildren.size() >= static_cast<size_t>(nEndPara) )
{
VectorOfChildren::iterator front = maChildren.begin();
VectorOfChildren::iterator back = front;
diff --git a/editeng/source/accessibility/AccessibleStaticTextBase.cxx b/editeng/source/accessibility/AccessibleStaticTextBase.cxx
index 0a66b4ca1bba..c7a3c9b2f346 100644
--- a/editeng/source/accessibility/AccessibleStaticTextBase.cxx
+++ b/editeng/source/accessibility/AccessibleStaticTextBase.cxx
@@ -86,14 +86,14 @@ namespace accessibility
ESelection MakeSelection( sal_Int32 nStartPara, sal_Int32 nStartIndex,
sal_Int32 nEndPara, sal_Int32 nEndIndex )
{
- DBG_ASSERT(nStartPara >= 0 && nStartPara <= USHRT_MAX &&
+ DBG_ASSERT(nStartPara >= 0 && nStartPara <= SAL_MAX_INT32 &&
nStartIndex >= 0 && nStartIndex <= USHRT_MAX &&
- nEndPara >= 0 && nEndPara <= USHRT_MAX &&
+ nEndPara >= 0 && nEndPara <= SAL_MAX_INT32 &&
nEndIndex >= 0 && nEndIndex <= USHRT_MAX ,
"AccessibleStaticTextBase_Impl::MakeSelection: index value overflow");
- return ESelection( static_cast< sal_uInt16 >(nStartPara), static_cast< sal_uInt16 >(nStartIndex),
- static_cast< sal_uInt16 >(nEndPara), static_cast< sal_uInt16 >(nEndIndex) );
+ return ESelection( nStartPara, static_cast< sal_uInt16 >(nStartIndex),
+ nEndPara, static_cast< sal_uInt16 >(nEndIndex) );
}
//------------------------------------------------------------------------
@@ -321,11 +321,18 @@ namespace accessibility
sal_Int32 AccessibleStaticTextBase_Impl::Internal2Index( EPosition nEEIndex ) const
{
+ // XXX checks for overflow and returns maximum if so
sal_Int32 aRes(0);
- int i;
- for(i=0; i<nEEIndex.nPara; ++i)
- aRes += GetParagraph(i).getCharacterCount();
+ for(sal_Int32 i=0; i<nEEIndex.nPara; ++i)
+ {
+ sal_Int32 nCount = GetParagraph(i).getCharacterCount();
+ if (SAL_MAX_INT32 - aRes > nCount)
+ return SAL_MAX_INT32;
+ aRes += nCount;
+ }
+ if (SAL_MAX_INT32 - aRes > nEEIndex.nIndex)
+ return SAL_MAX_INT32;
return aRes + nEEIndex.nIndex;
}
@@ -365,11 +372,11 @@ namespace accessibility
if( nCurrIndex > nFlatIndex )
{
// check overflow
- DBG_ASSERT(nCurrPara >= 0 && nCurrPara <= USHRT_MAX &&
+ DBG_ASSERT(nCurrPara >= 0 && nCurrPara <= SAL_MAX_INT32 &&
nFlatIndex - nCurrIndex + nCurrCount >= 0 && nFlatIndex - nCurrIndex + nCurrCount <= USHRT_MAX ,
"AccessibleStaticTextBase_Impl::Index2Internal: index value overflow");
- return EPosition( static_cast< sal_uInt16 >(nCurrPara), static_cast< sal_uInt16 >(nFlatIndex - nCurrIndex + nCurrCount) );
+ return EPosition( nCurrPara, static_cast< sal_uInt16 >(nFlatIndex - nCurrIndex + nCurrCount) );
}
}
@@ -377,11 +384,11 @@ namespace accessibility
if( bExclusive && nCurrIndex == nFlatIndex )
{
// check overflow
- DBG_ASSERT(nCurrPara >= 0 && nCurrPara <= USHRT_MAX &&
+ DBG_ASSERT(nCurrPara > 0 && nCurrPara <= SAL_MAX_INT32 &&
nFlatIndex - nCurrIndex + nCurrCount >= 0 && nFlatIndex - nCurrIndex + nCurrCount <= USHRT_MAX ,
"AccessibleStaticTextBase_Impl::Index2Internal: index value overflow");
- return EPosition( static_cast< sal_uInt16 >(nCurrPara-1), static_cast< sal_uInt16 >(nFlatIndex - nCurrIndex + nCurrCount) );
+ return EPosition( nCurrPara-1, static_cast< sal_uInt16 >(nFlatIndex - nCurrIndex + nCurrCount) );
}
// not found? Out of bounds