Modified: openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleEditableTextPara.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleEditableTextPara.cxx?rev=1463840&r1=1463839&r2=1463840&view=diff
==============================================================================
--- openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleEditableTextPara.cxx (original)
+++ openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleEditableTextPara.cxx Wed Apr 3 07:04:20 2013
@@ -56,6 +56,7 @@
#include <editeng/unoprnms.hxx>
#include <editeng/unoipset.hxx>
#include <editeng/outliner.hxx>
+#include <svl/intitem.hxx>
//------------------------------------------------------------------------
//
@@ -75,7 +76,16 @@
#include "AccessibleHyperlink.hxx"
#include <svtools/colorcfg.hxx>
-
+//IAccessibility2 Implementation 2009-----
+#ifndef _ACCESSIBLEHYPERLINK_HXX
+#include <Accessiblehyperlink.hxx>
+#endif
+#include <algorithm>
+using namespace std;
+//-----IAccessibility2 Implementation 2009
+#include <editeng/numitem.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/viewsh.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::beans;
@@ -90,12 +100,16 @@ using namespace ::com::sun::star::access
namespace accessibility
{
+//IAccessibility2 Implementation 2009-----
+ //Window* GetCurrentEditorWnd();
+//-----IAccessibility2 Implementation 2009
const SvxItemPropertySet* ImplGetSvxCharAndParaPropertiesSet()
{
// PropertyMap for character and paragraph properties
static const SfxItemPropertyMapEntry aPropMap[] =
{
+ SVX_UNOEDIT_OUTLINER_PROPERTIES,
SVX_UNOEDIT_CHAR_PROPERTIES,
SVX_UNOEDIT_PARA_PROPERTIES,
SVX_UNOEDIT_NUMBERING_PROPERTIE,
@@ -215,7 +229,12 @@ namespace accessibility
DBG_WARNING( "AccessibleEditableTextPara::implGetParagraphBoundary: only a base implementation, ignoring the index" );
rBoundary.startPos = 0;
- rBoundary.endPos = GetTextLen();
+ //IAccessibility2 Implementation 2009-----
+ //rBoundary.endPos = GetTextLen();
+ ::rtl::OUString sText( implGetText() );
+ sal_Int32 nLength = sText.getLength();
+ rBoundary.endPos = nLength;
+ //-----IAccessibility2 Implementation 2009
}
void AccessibleEditableTextPara::implGetLineBoundary( ::com::sun::star::i18n::Boundary& rBoundary, sal_Int32 nIndex )
@@ -359,13 +378,11 @@ namespace accessibility
{
DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
- mpEditSource = pEditSource;
-
WeakBullet::HardRefType aChild( maImageBullet.get() );
if( aChild.is() )
aChild->SetEditSource(pEditSource);
- if( !mpEditSource )
+ if( !pEditSource )
{
// going defunc
UnSetState( AccessibleStateType::SHOWING );
@@ -375,7 +392,9 @@ namespace accessibility
Dispose();
}
-
+//IAccessibility2 Implementation 2009-----
+ mpEditSource = pEditSource;
+//-----IAccessibility2 Implementation 2009
// #108900# Init last text content
try
{
@@ -751,7 +770,11 @@ namespace accessibility
!pStateSet->contains(nStateId) )
{
pStateSet->AddState( nStateId );
+//IAccessibility2 Implementation 2009-----
+ // MT: Removed method IsShapeParaFocusable which was introduced with IA2 - basically it was only about figuring out wether or not the window has the focus, should be solved differently
+ // if(IsShapeParaFocusable())
GotPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED );
+//-----IAccessibility2 Implementation 2009
}
}
@@ -806,7 +829,10 @@ namespace accessibility
// must provide XAccesibleText by hand, since it comes publicly inherited by XAccessibleEditableText
if ( rType == ::getCppuType((uno::Reference< XAccessibleText > *)0) )
{
+ //IAccessibility2 Implementation 2009-----
+ // uno::Reference< XAccessibleText > aAccText = this;
uno::Reference< XAccessibleText > aAccText = static_cast< XAccessibleEditableText * >(this);
+ //-----IAccessibility2 Implementation 2009
aRet <<= aAccText;
}
else if ( rType == ::getCppuType((uno::Reference< XAccessibleEditableText > *)0) )
@@ -814,11 +840,13 @@ namespace accessibility
uno::Reference< XAccessibleEditableText > aAccEditText = this;
aRet <<= aAccEditText;
}
- else if ( rType == ::getCppuType((uno::Reference< XAccessibleHypertext > *)0) )
+ //IAccessibility2 Implementation 2009-----
+ else if ( rType == ::getCppuType((uno::Reference< XAccessibleHypertext > *)0) )
{
uno::Reference< XAccessibleHypertext > aAccHyperText = this;
aRet <<= aAccHyperText;
}
+ //-----IAccessibility2 Implementation 2009
else
{
aRet = AccessibleTextParaInterfaceBase::queryInterface(rType);
@@ -987,7 +1015,18 @@ namespace accessibility
if( !pStateSet )
return uno::Reference<XAccessibleStateSet>();
-
+//IAccessibility2 Implementation 2009-----
+ uno::Reference<XAccessibleStateSet> xParentStates;
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
+ xParentStates = xParentContext->getAccessibleStateSet();
+ }
+ if (xParentStates.is() && xParentStates->contains(AccessibleStateType::EDITABLE) )
+ {
+ pStateSet->AddState(AccessibleStateType::EDITABLE);
+ }
+//-----IAccessibility2 Implementation 2009
return uno::Reference<XAccessibleStateSet>( new ::utl::AccessibleStateSetHelper (*pStateSet) );
}
@@ -1209,6 +1248,17 @@ namespace accessibility
GetParagraphIndex() == aSelection.nEndPara )
{
// caret is always nEndPara,nEndPos
+ //IAccessibility2 Implementation 2009-----
+ EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
+ if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
+ aBulletInfo.bVisible &&
+ aBulletInfo.nType != SVX_NUM_BITMAP )
+ {
+ sal_Int32 nBulletLen = aBulletInfo.aText.Len();
+ if( aSelection.nEndPos - nBulletLen >= 0 )
+ return aSelection.nEndPos - nBulletLen;
+ }
+ //-----IAccessibility2 Implementation 2009
return aSelection.nEndPos;
}
@@ -1234,19 +1284,173 @@ namespace accessibility
return OCommonAccessibleText::getCharacter( nIndex );
}
+ //IAccessibility2 Implementation 2009-----
+ static uno::Sequence< ::rtl::OUString > getAttributeNames()
+ {
+ static uno::Sequence< ::rtl::OUString >* pNames = NULL;
+
+ if( pNames == NULL )
+ {
+ uno::Sequence< ::rtl::OUString >* pSeq = new uno::Sequence< ::rtl::OUString >( 21 );
+ ::rtl::OUString* pStrings = pSeq->getArray();
+ sal_Int32 i = 0;
+ #define STR(x) pStrings[i++] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(x))
+ //STR("CharBackColor");
+ STR("CharColor");
+ STR("CharContoured");
+ STR("CharEmphasis");
+ STR("CharEscapement");
+ STR("CharFontName");
+ STR("CharHeight");
+ STR("CharPosture");
+ STR("CharShadowed");
+ STR("CharStrikeout");
+ STR("CharUnderline");
+ STR("CharUnderlineColor");
+ STR("CharWeight");
+ STR("NumberingLevel");
+ STR("NumberingRules");
+ STR("ParaAdjust");
+ STR("ParaBottomMargin");
+ STR("ParaFirstLineIndent");
+ STR("ParaLeftMargin");
+ STR("ParaLineSpacing");
+ STR("ParaRightMargin");
+ STR("ParaTabStops");
+ #undef STR
+ DBG_ASSERT( i == pSeq->getLength(), "Please adjust length" );
+ if( i != pSeq->getLength() )
+ pSeq->realloc( i );
+ pNames = pSeq;
+ }
+ return *pNames;
+ }
+//-----IAccessibility2 Implementation 2009
+ struct IndexCompare
+ {
+ const PropertyValue* pValues;
+ IndexCompare( const PropertyValue* pVals ) : pValues(pVals) {}
+ bool operator() ( const sal_Int32& a, const sal_Int32& b ) const
+ {
+ return (pValues[a].Name < pValues[b].Name) ? true : false;
+ }
+ };
+
+ String AccessibleEditableTextPara::GetFieldTypeNameAtIndex(sal_Int32 nIndex)
+ {
+ String strFldType;
+ SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();
+ //For field object info
+ sal_Int32 nParaIndex = GetParagraphIndex();
+ sal_Int32 nAllFieldLen = 0;
+ sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1;
+ EFieldInfo ree;
+ sal_Int32 reeBegin, reeEnd;
+ sal_Int32 nFieldType = -1;
+ for(sal_uInt16 j = 0; j < nField; j++)
+ {
+ ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j);
+ reeBegin = ree.aPosition.nIndex + nAllFieldLen;
+ reeEnd = reeBegin + ree.aCurrentText.Len();
+ nAllFieldLen += (ree.aCurrentText.Len() - 1);
+ if( reeBegin > nIndex )
+ {
+ break;
+ }
+ if( nIndex >= reeBegin && nIndex < reeEnd )
+ {
+ nFoundFieldIndex = j;
+ break;
+ }
+ }
+ if( nFoundFieldIndex >= 0 )
+ {
+ // So we get a field, check its type now.
+ nFieldType = ree.pFieldItem->GetField()->GetClassId() ;
+ }
+ switch(nFieldType)
+ {
+ case SVX_DATEFIELD:
+ {
+ const SvxDateField* pDateField = static_cast< const SvxDateField* >(ree.pFieldItem->GetField());
+ if (pDateField)
+ {
+ if (pDateField->GetType() == SVXDATETYPE_FIX)
+ strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("date (fixed)"));
+ else if (pDateField->GetType() == SVXDATETYPE_VAR)
+ strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("date (variable)"));
+ }
+ }
+ break;
+ case SVX_PAGEFIELD:
+ strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("page-number"));
+ break;
+ //Sym2_8508, support the sheet name & pages fields
+ case SVX_PAGESFIELD:
+ strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("page-count"));
+ break;
+ case SVX_TABLEFIELD:
+ strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sheet-name"));
+ break;
+ //End of Sym2_8508
+ case SVX_TIMEFIELD:
+ strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time"));
+ break;
+ case SVX_EXT_TIMEFIELD:
+ {
+ const SvxExtTimeField* pTimeField = static_cast< const SvxExtTimeField* >(ree.pFieldItem->GetField());
+ if (pTimeField)
+ {
+ if (pTimeField->GetType() == SVXTIMETYPE_FIX)
+ strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time (fixed)"));
+ else if (pTimeField->GetType() == SVXTIMETYPE_VAR)
+ strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time (variable)"));
+ }
+ }
+ break;
+ case SVX_AUTHORFIELD:
+ strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("author"));
+ break;
+ case SVX_EXT_FILEFIELD:
+ case SVX_FILEFIELD:
+ strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file name"));
+ default:
+ break;
+ }
+ return strFldType;
+ }
uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rRequestedAttributes ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
{
DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
::vos::OGuard aGuard( Application::GetSolarMutex() );
-
- CheckIndex(nIndex); // may throw IndexOutOfBoundsException
-
+
+ //IAccessibility2 Implementation 2009-----
+ //Skip the bullet range to ingnore the bullet text
+ SvxTextForwarder& rCacheTF = GetTextForwarder();
+ EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
+ if (aBulletInfo.bVisible)
+ nIndex += aBulletInfo.aText.Len();
+ if (nIndex != 0 && nIndex >= getCharacterCount())
+ nIndex = getCharacterCount()-1;
+ //
+ if (nIndex != 0)
+ CheckIndex(nIndex); // may throw IndexOutOfBoundsException
+
+ // refactored by Steve Yin
+ bool bSupplementalMode = false;
+ uno::Sequence< ::rtl::OUString > aPropertyNames = rRequestedAttributes;
+ if (aPropertyNames.getLength() == 0)
+ {
+ bSupplementalMode = true;
+ aPropertyNames = getAttributeNames();
+ }
// get default attribues...
- ::comphelper::SequenceAsHashMap aPropHashMap( getDefaultAttributes( rRequestedAttributes ) );
+ ::comphelper::SequenceAsHashMap aPropHashMap( getDefaultAttributes( aPropertyNames ) );
// ... and override them with the direct attributes from the specific position
- uno::Sequence< beans::PropertyValue > aRunAttribs( getRunAttributes( nIndex, rRequestedAttributes ) );
+ uno::Sequence< beans::PropertyValue > aRunAttribs( getRunAttributes( nIndex, aPropertyNames ) );
+ //-----IAccessibility2 Implementation 2009
sal_Int32 nRunAttribs = aRunAttribs.getLength();
const beans::PropertyValue *pRunAttrib = aRunAttribs.getConstArray();
for (sal_Int32 k = 0; k < nRunAttribs; ++k)
@@ -1294,8 +1498,58 @@ namespace accessibility
rRes.Handle = -1;
rRes.State = bIsDirectVal ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;
}
-
- return aRes;
+ //IAccessibility2 Implementation 2009-----
+ if( bSupplementalMode )
+ {
+ _correctValues( nIndex, aRes );
+ // NumberingPrefix
+ nRes = aRes.getLength();
+ aRes.realloc( nRes + 1 );
+ pRes = aRes.getArray();
+ beans::PropertyValue &rRes = pRes[nRes];
+ rRes.Name = rtl::OUString::createFromAscii("NumberingPrefix");
+ ::rtl::OUString numStr;
+ if (aBulletInfo.nType != SVX_NUM_CHAR_SPECIAL && aBulletInfo.nType != SVX_NUM_BITMAP)
+ numStr = (::rtl::OUString)aBulletInfo.aText;
+ rRes.Value <<= numStr;
+ rRes.Handle = -1;
+ rRes.State = PropertyState_DIRECT_VALUE;
+ //-----IAccessibility2 Implementation 2009
+ //For field object.
+ String strFieldType = GetFieldTypeNameAtIndex(nIndex);
+ if (strFieldType.Len() > 0)
+ {
+ nRes = aRes.getLength();
+ aRes.realloc( nRes + 1 );
+ pRes = aRes.getArray();
+ beans::PropertyValue &rResField = pRes[nRes];
+ beans::PropertyValue aFieldType;
+ rResField.Name = rtl::OUString::createFromAscii("FieldType");
+ rResField.Value <<= rtl::OUString(strFieldType.ToLowerAscii());
+ rResField.Handle = -1;
+ rResField.State = PropertyState_DIRECT_VALUE;
+ }
+ //sort property values
+ // build sorted index array
+ sal_Int32 nLength = aRes.getLength();
+ const beans::PropertyValue* pPairs = aRes.getConstArray();
+ sal_Int32* pIndices = new sal_Int32[nLength];
+ sal_Int32 i = 0;
+ for( i = 0; i < nLength; i++ )
+ pIndices[i] = i;
+ sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) );
+ // create sorted sequences accoring to index array
+ uno::Sequence<beans::PropertyValue> aNewValues( nLength );
+ beans::PropertyValue* pNewValues = aNewValues.getArray();
+ for( i = 0; i < nLength; i++ )
+ {
+ pNewValues[i] = pPairs[pIndices[i]];
+ }
+ delete[] pIndices;
+ //
+ return aNewValues;
+ }
+ return aRes;
}
awt::Rectangle SAL_CALL AccessibleEditableTextPara::getCharacterBounds( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
@@ -1350,7 +1604,10 @@ namespace accessibility
DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
::vos::OGuard aGuard( Application::GetSolarMutex() );
-
+ //IAccessibility2 Implementation 2009-----
+ if ((rPoint.X <= 0) && (rPoint.Y <= 0))
+ return 0;
+ //-----IAccessibility2 Implementation 2009
sal_uInt16 nPara, nIndex;
// offset from surrounding cell/shape
@@ -1482,7 +1739,279 @@ namespace accessibility
return OCommonAccessibleText::getTextRange(nStartIndex, nEndIndex);
}
-
+//IAccessibility2 Implementation 2009-----
+ void AccessibleEditableTextPara::_correctValues( const sal_Int32 nIndex,
+ uno::Sequence< PropertyValue >& rValues)
+ {
+ SvxTextForwarder& rCacheTF = GetTextForwarder();
+ sal_Int32 nRes = rValues.getLength();
+ beans::PropertyValue *pRes = rValues.getArray();
+ for (sal_Int32 i = 0; i < nRes; ++i)
+ {
+ beans::PropertyValue &rRes = pRes[i];
+ // Char color
+ if (rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharColor"))==0)
+ {
+ uno::Any &anyChar = rRes.Value;
+ sal_uInt32 crChar = (sal_uInt32)(anyChar.pReserved);
+ if (COL_AUTO == crChar )
+ {
+ uno::Reference< ::com::sun::star::accessibility::XAccessibleComponent > xComponent;
+ if (mxParent.is())
+ {
+ xComponent.set(mxParent,uno::UNO_QUERY);
+ }
+ else
+ {
+ xComponent.set(m_xAccInfo,uno::UNO_QUERY);
+ }
+ if (xComponent.is())
+ {
+ uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > xContext(xComponent,uno::UNO_QUERY);
+ if (xContext->getAccessibleRole() == AccessibleRole::SHAPE
+ || xContext->getAccessibleRole() == AccessibleRole::TABLE_CELL)
+ {
+ anyChar <<= COL_BLACK;
+ }
+ else
+ {
+ Color cr(xComponent->getBackground());
+ crChar = cr.IsDark() ? COL_WHITE : COL_BLACK;
+ anyChar <<= crChar;
+ }
+ }
+ }
+ continue;
+ }
+ // Underline
+ if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharUnderline"))==0)
+ {
+ /*
+ // MT: Implement XAccessibleTextMarkup, mark with TextMarkupType::SPELLCHECK. This way done in SW.
+ if (IsCurrentEditorEnableAutoSpell( mxParent ))
+ {
+ try
+ {
+ SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_False );
+ sal_Bool bWrong = rCacheVF.IsWrongSpelledWordAtPos( GetParagraphIndex(), nIndex );
+ if ( bWrong )
+ {
+ uno::Any &anyUnderLine = pRes[9].Value;
+ // MT IA2: Not needed? sal_uInt16 crUnderLine = (sal_uInt16)(anyUnderLine.pReserved);
+ anyUnderLine <<= (sal_uInt16)UNDERLINE_WAVE;
+ }
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ }
+ */
+ continue;
+ }
+ // Underline color && Mis-spell
+ if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharUnderlineColor"))==0)
+ {
+ uno::Any &anyCharUnderLine = rRes.Value;
+ sal_uInt32 crCharUnderLine = (sal_uInt32)(anyCharUnderLine.pReserved);
+ if (COL_AUTO == crCharUnderLine )
+ {
+ uno::Reference< ::com::sun::star::accessibility::XAccessibleComponent > xComponent;
+ if (mxParent.is())
+ {
+ xComponent.set(mxParent,uno::UNO_QUERY);
+ }
+ else
+ {
+ xComponent.set(m_xAccInfo,uno::UNO_QUERY);
+ }
+ if (xComponent.is())
+ {
+ uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > xContext(xComponent,uno::UNO_QUERY);
+ if (xContext->getAccessibleRole() == AccessibleRole::SHAPE
+ || xContext->getAccessibleRole() == AccessibleRole::TABLE_CELL)
+ {
+ anyCharUnderLine <<= COL_BLACK;
+ }
+ else
+ {
+ Color cr(xComponent->getBackground());
+ crCharUnderLine = cr.IsDark() ? COL_WHITE : COL_BLACK;
+ anyCharUnderLine <<= crCharUnderLine;
+ }
+ }
+ }
+ // MT: Implement XAccessibleTextMarkup, mark with TextMarkupType::SPELLCHECK. This way done in SW.
+ /*
+ if (IsCurrentEditorEnableAutoSpell( mxParent ))
+ {
+ try
+ {
+ SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_False );
+ sal_Bool bWrong = rCacheVF.IsWrongSpelledWordAtPos( GetParagraphIndex(), nIndex );
+ if ( bWrong )
+ {
+ uno::Any &anyUnderLineColor = rRes.Value;
+ // MT IA2: Not needed? sal_uInt16 crUnderLineColor = (sal_uInt16)(anyUnderLineColor.pReserved);
+ anyUnderLineColor <<= COL_LIGHTRED;
+ }
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ }
+ */
+ continue;
+ }
+ // NumberingLevel
+ if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("NumberingLevel"))==0)
+ {
+ const SvxNumBulletItem& rNumBullet = ( SvxNumBulletItem& )rCacheTF.GetParaAttribs(static_cast< sal_uInt16 >(GetParagraphIndex())).Get(EE_PARA_NUMBULLET);
+ if(rNumBullet.GetNumRule()->GetLevelCount()==0)
+ {
+ rRes.Value <<= (sal_Int16)-1;
+ rRes.Handle = -1;
+ rRes.State = PropertyState_DIRECT_VALUE;
+ }
+ else
+ {
+// SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
+// ImplGetSvxCharAndParaPropertiesMap() );
+ // MT IA2 TODO: Check if this is the correct replacement for ImplGetSvxCharAndParaPropertiesMap
+ SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() );
+
+ aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) );
+ rRes.Value = aPropSet._getPropertyValue( rRes.Name, mnParagraphIndex );
+ rRes.State = aPropSet._getPropertyState( rRes.Name, mnParagraphIndex );
+ rRes.Handle = -1;
+ }
+ continue;
+ }
+ // NumberingRules
+ if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("NumberingRules"))==0)
+ {
+ SfxItemSet aAttribs = rCacheTF.GetParaAttribs( static_cast< sal_uInt16 >(GetParagraphIndex()) );
+ sal_Bool bVis = ((const SfxUInt16Item&)aAttribs.Get( EE_PARA_BULLETSTATE )).GetValue() ? sal_True : sal_False;
+ if(bVis)
+ {
+ rRes.Value <<= (sal_Int16)-1;
+ rRes.Handle = -1;
+ rRes.State = PropertyState_DIRECT_VALUE;
+ }
+ else
+ {
+ // MT IA2 TODO: Check if this is the correct replacement for ImplGetSvxCharAndParaPropertiesMap
+ SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() );
+ aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) );
+ rRes.Value = aPropSet._getPropertyValue( rRes.Name, mnParagraphIndex );
+ rRes.State = aPropSet._getPropertyState( rRes.Name, mnParagraphIndex );
+ rRes.Handle = -1;
+ }
+ continue;
+ }
+ }
+ }
+ sal_Int32 AccessibleEditableTextPara::SkipField(sal_Int32 nIndex, sal_Bool bForward)
+ {
+ sal_Int32 nParaIndex = GetParagraphIndex();
+ SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();
+ sal_Int32 nAllFieldLen = 0;
+ sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1;
+ EFieldInfo ree;
+ sal_Int32 reeBegin=0, reeEnd=0;
+ for(sal_uInt16 j = 0; j < nField; j++)
+ {
+ ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j);
+ reeBegin = ree.aPosition.nIndex + nAllFieldLen;
+ reeEnd = reeBegin + ree.aCurrentText.Len();
+ nAllFieldLen += (ree.aCurrentText.Len() - 1);
+ if( reeBegin > nIndex )
+ {
+ break;
+ }
+ if( nIndex >= reeBegin && nIndex < reeEnd )
+ {
+ if(ree.pFieldItem->GetField()->GetClassId() != SVX_URLFIELD)
+ {
+ nFoundFieldIndex = j;
+ break;
+ }
+ }
+ }
+ if( nFoundFieldIndex >= 0 )
+ {
+ if( bForward )
+ return reeEnd - 1;
+ else
+ return reeBegin;
+ }
+ return nIndex;
+ }
+ sal_Bool AccessibleEditableTextPara::ExtendByField( ::com::sun::star::accessibility::TextSegment& Segment )
+ {
+ sal_Int32 nParaIndex = GetParagraphIndex();
+ SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();
+ sal_Int32 nAllFieldLen = 0;
+ sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1;
+ EFieldInfo ree;
+ sal_Int32 reeBegin=0, reeEnd=0;
+ for(sal_uInt16 j = 0; j < nField; j++)
+ {
+ ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j);
+ reeBegin = ree.aPosition.nIndex + nAllFieldLen;
+ reeEnd = reeBegin + ree.aCurrentText.Len();
+ nAllFieldLen += (ree.aCurrentText.Len() - 1);
+ if( reeBegin > Segment.SegmentEnd )
+ {
+ break;
+ }
+ if( (Segment.SegmentEnd > reeBegin && Segment.SegmentEnd <= reeEnd) ||
+ (Segment.SegmentStart >= reeBegin && Segment.SegmentStart < reeEnd) )
+ {
+ if(ree.pFieldItem->GetField()->GetClassId() != SVX_URLFIELD)
+ {
+ nFoundFieldIndex = j;
+ break;
+ }
+ }
+ }
+ sal_Bool bExtend = sal_False;
+ if( nFoundFieldIndex >= 0 )
+ {
+ if( Segment.SegmentEnd < reeEnd )
+ {
+ Segment.SegmentEnd = reeEnd;
+ bExtend = sal_True;
+ }
+ if( Segment.SegmentStart > reeBegin )
+ {
+ Segment.SegmentStart = reeBegin;
+ bExtend = sal_True;
+ }
+ if( bExtend )
+ {
+ //Modified by yanjun for sym2_7393
+ //If there is a bullet before the field, should add the bullet length into the segment.
+ EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo(sal_uInt16(nParaIndex));
+ int nBulletLen = aBulletInfo.aText.Len();
+ if (nBulletLen > 0)
+ {
+ Segment.SegmentEnd += nBulletLen;
+ if (nFoundFieldIndex > 0)
+ Segment.SegmentStart += nBulletLen;
+ Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd);
+ //After get the correct field name, should restore the offset value which don't contain the bullet.
+ Segment.SegmentEnd -= nBulletLen;
+ if (nFoundFieldIndex > 0)
+ Segment.SegmentStart -= nBulletLen;
+ }
+ else
+ Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd);
+ //End
+ }
+ }
+ return bExtend;
+ }
+//-----IAccessibility2 Implementation 2009
::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
{
DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
@@ -1498,6 +2027,15 @@ namespace accessibility
switch( aTextType )
{
+ //IAccessibility2 Implementation 2009-----
+ case AccessibleTextType::CHARACTER:
+ case AccessibleTextType::WORD:
+ {
+ aResult = OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
+ ExtendByField( aResult );
+ break;
+ }
+ //-----IAccessibility2 Implementation 2009
// Not yet handled by OCommonAccessibleText. Missing
// implGetAttributeRunBoundary() method there
case AccessibleTextType::ATTRIBUTE_RUN:
@@ -1512,17 +2050,86 @@ namespace accessibility
else
{
sal_uInt16 nStartIndex, nEndIndex;
-
+ //For the bullet paragraph, the bullet string is ingnored for IAText::attributes() function.
+ SvxTextForwarder& rCacheTF = GetTextForwarder();
+ // MT IA2: Not used? sal_Int32 nBulletLen = 0;
+ EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
+ if (aBulletInfo.bVisible)
+ nIndex += aBulletInfo.aText.Len();
+ if (nIndex != 0 && nIndex >= getCharacterCount())
+ nIndex = getCharacterCount()-1;
+ CheckPosition(nIndex);
if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) )
{
aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
+ if (aBulletInfo.bVisible)
+ {
+ nStartIndex -= aBulletInfo.aText.Len();
+ nEndIndex -= aBulletInfo.aText.Len();
+ }
aResult.SegmentStart = nStartIndex;
aResult.SegmentEnd = nEndIndex;
}
+ }
+ break;
+ }
+//IAccessibility2 Implementation 2009-----
+ case AccessibleTextType::LINE:
+ {
+ SvxTextForwarder& rCacheTF = GetTextForwarder();
+ sal_Int32 nParaIndex = GetParagraphIndex();
+ // MT IA2: Not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) );
+ CheckPosition(nIndex);
+ if (nIndex != 0 && nIndex == getCharacterCount())
+ --nIndex;
+ sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) );
+ sal_Int32 nCurIndex;
+ //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line,
+ //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed
+ //by the IAText::attributes(). So here must do special support for bullet line.
+ sal_Int32 nBulletLen = 0;
+ for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine )
+ {
+ if (nLine == 0)
+ {
+ EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) );
+ if (aBulletInfo.bVisible)
+ {
+ //in bullet or numbering;
+ nBulletLen = aBulletInfo.aText.Len();
+ }
+ }
+ //nCurIndex += rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine);
+ sal_Int32 nLineLen = rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine);
+ if (nLine == 0)
+ nCurIndex += nLineLen - nBulletLen;
+ else
+ nCurIndex += nLineLen;
+ if( nCurIndex > nIndex )
+ {
+ if (nLine ==0)
+ {
+ //aResult.SegmentStart = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine);
+ aResult.SegmentStart = 0;
+ aResult.SegmentEnd = nCurIndex;
+ //aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd );
+ aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd + nBulletLen);
+ break;
+ }
+ else
+ {
+ //aResult.SegmentStart = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine);
+ aResult.SegmentStart = nCurIndex - nLineLen;
+ aResult.SegmentEnd = nCurIndex;
+ //aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd );
+ aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen);
+ break;
+ }
+ }
}
break;
}
-
+//-----IAccessibility2 Implementation 2009
default:
aResult = OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
break;
@@ -1543,7 +2150,9 @@ namespace accessibility
::com::sun::star::accessibility::TextSegment aResult;
aResult.SegmentStart = -1;
aResult.SegmentEnd = -1;
-
+//IAccessibility2 Implementation 2009-----
+ i18n::Boundary aBoundary;
+//-----IAccessibility2 Implementation 2009
switch( aTextType )
{
// Not yet handled by OCommonAccessibleText. Missing
@@ -1581,7 +2190,118 @@ namespace accessibility
}
break;
}
+ //IAccessibility2 Implementation 2009-----
+ case AccessibleTextType::LINE:
+ {
+ SvxTextForwarder& rCacheTF = GetTextForwarder();
+ sal_Int32 nParaIndex = GetParagraphIndex();
+ // MT IA2 not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) );
+
+ CheckPosition(nIndex);
+
+ sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) );
+ //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line,
+ //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed
+ //by the IAText::attributes(). So here must do special support for bullet line.
+ sal_Int32 nCurIndex=0, nLastIndex=0, nCurLineLen=0;
+ sal_Int32 nLastLineLen = 0, nBulletLen = 0;;
+ // get the line before the line the index points into
+ for( nLine=0, nCurIndex=0, nLastIndex=0; nLine<nLineCount; ++nLine )
+ {
+ nLastIndex = nCurIndex;
+ if (nLine == 0)
+ {
+ EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) );
+ if (aBulletInfo.bVisible)
+ {
+ //in bullet or numbering;
+ nBulletLen = aBulletInfo.aText.Len();
+ }
+ }
+ if (nLine == 1)
+ nLastLineLen = nCurLineLen - nBulletLen;
+ else
+ nLastLineLen = nCurLineLen;
+ nCurLineLen = rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine);
+ //nCurIndex += nCurLineLen;
+ if (nLine == 0)
+ nCurIndex += nCurLineLen - nBulletLen;
+ else
+ nCurIndex += nCurLineLen;
+
+ //if( nCurIndex > nIndex &&
+ //nLastIndex > nCurLineLen )
+ if (nCurIndex > nIndex)
+ {
+ if (nLine == 0)
+ {
+ break;
+ }
+ else if (nLine == 1)
+ {
+ aResult.SegmentStart = 0;
+ aResult.SegmentEnd = static_cast< sal_uInt16 >( nLastIndex );
+ aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd + nBulletLen);
+ break;
+ }
+ else
+ {
+ //aResult.SegmentStart = nLastIndex - nCurLineLen;
+ aResult.SegmentStart = nLastIndex - nLastLineLen;
+ aResult.SegmentEnd = static_cast< sal_uInt16 >( nLastIndex );
+ aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen);
+ break;
+ }
+ }
+ }
+ break;
+ }
+ case AccessibleTextType::WORD:
+ {
+ nIndex = SkipField( nIndex, sal_False);
+ ::rtl::OUString sText( implGetText() );
+ sal_Int32 nLength = sText.getLength();
+
+ // get word at index
+ implGetWordBoundary( aBoundary, nIndex );
+
+
+ //sal_Int32 curWordStart = aBoundary.startPos;
+ //sal_Int32 preWordStart = curWordStart;
+ sal_Int32 curWordStart , preWordStart;
+ if( aBoundary.startPos == -1 || aBoundary.startPos > nIndex)
+ curWordStart = preWordStart = nIndex;
+ else
+ curWordStart = preWordStart = aBoundary.startPos;
+
+ // get previous word
+
+ sal_Bool bWord = sal_False;
+
+ //while ( preWordStart > 0 && aBoundary.startPos == curWordStart)
+ while ( (preWordStart >= 0 && !bWord ) || ( aBoundary.endPos > curWordStart ) )
+ {
+ preWordStart--;
+ bWord = implGetWordBoundary( aBoundary, preWordStart );
+ }
+ if ( bWord && implIsValidBoundary( aBoundary, nLength ) )
+ {
+ aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
+ aResult.SegmentStart = aBoundary.startPos;
+ aResult.SegmentEnd = aBoundary.endPos;
+ ExtendByField( aResult );
+ }
+ }
+ break;
+ case AccessibleTextType::CHARACTER:
+ {
+ nIndex = SkipField( nIndex, sal_False);
+ aResult = OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
+ ExtendByField( aResult );
+ break;
+ }
+ //-----IAccessibility2 Implementation 2009
default:
aResult = OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
break;
@@ -1602,7 +2322,9 @@ namespace accessibility
::com::sun::star::accessibility::TextSegment aResult;
aResult.SegmentStart = -1;
aResult.SegmentEnd = -1;
-
+//IAccessibility2 Implementation 2009-----
+ i18n::Boundary aBoundary;
+//-----IAccessibility2 Implementation 2009
switch( aTextType )
{
case AccessibleTextType::ATTRIBUTE_RUN:
@@ -1625,6 +2347,93 @@ namespace accessibility
break;
}
+//IAccessibility2 Implementation 2009-----
+ case AccessibleTextType::LINE:
+ {
+ SvxTextForwarder& rCacheTF = GetTextForwarder();
+ sal_Int32 nParaIndex = GetParagraphIndex();
+ // MT IA2 not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) );
+
+ CheckPosition(nIndex);
+
+ sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) );
+ sal_Int32 nCurIndex;
+ //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line,
+ //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed
+ //by the IAText::attributes(). So here must do special support for bullet line.
+ sal_Int32 nBulletLen = 0;
+ // get the line after the line the index points into
+ for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine )
+ {
+ if (nLine == 0)
+ {
+ EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) );
+ if (aBulletInfo.bVisible)
+ {
+ //in bullet or numbering;
+ nBulletLen = aBulletInfo.aText.Len();
+ }
+ }
+ //nCurIndex += rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine);
+ sal_Int32 nLineLen = rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine);
+
+ if (nLine == 0)
+ nCurIndex += nLineLen - nBulletLen;
+ else
+ nCurIndex += nLineLen;
+
+ if( nCurIndex > nIndex &&
+ nLine < nLineCount-1 )
+ {
+ aResult.SegmentStart = nCurIndex;
+ aResult.SegmentEnd = nCurIndex + rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine+1);
+ aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen);
+ break;
+ }
+ }
+
+ break;
+ }
+ case AccessibleTextType::WORD:
+ {
+ nIndex = SkipField( nIndex, sal_True);
+ ::rtl::OUString sText( implGetText() );
+ sal_Int32 nLength = sText.getLength();
+
+ // get word at index
+ sal_Bool bWord = implGetWordBoundary( aBoundary, nIndex );
+
+ // real current world
+ sal_Int32 nextWord = nIndex;
+ //if( nIndex >= aBoundary.startPos && nIndex <= aBoundary.endPos )
+ if( nIndex <= aBoundary.endPos )
+ {
+ nextWord = aBoundary.endPos;
+ if( sText.getStr()[nextWord] == sal_Unicode(' ') ) nextWord++;
+ bWord = implGetWordBoundary( aBoundary, nextWord );
+ }
+
+ if ( bWord && implIsValidBoundary( aBoundary, nLength ) )
+ {
+ aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
+ aResult.SegmentStart = aBoundary.startPos;
+ aResult.SegmentEnd = aBoundary.endPos;
+
+ // If the end position of aBoundary is inside a field, extend the result to the end of the field
+
+ ExtendByField( aResult );
+ }
+ }
+ break;
+
+ case AccessibleTextType::CHARACTER:
+ {
+ nIndex = SkipField( nIndex, sal_True);
+ aResult = OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
+ ExtendByField( aResult );
+ break;
+ }
+ //-----IAccessibility2 Implementation 2009
default:
aResult = OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
break;
@@ -1656,11 +2465,17 @@ namespace accessibility
CheckRange(nStartIndex, nEndIndex);
+ //Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet
+ sal_Int32 nBulletLen = 0;
+ EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
+ if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible )
+ nBulletLen = aBulletInfo.aText.Len();
// save current selection
ESelection aOldSelection;
rCacheVF.GetSelection( aOldSelection );
- rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
+ //rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
+ rCacheVF.SetSelection( MakeSelection(nStartIndex + nBulletLen, nEndIndex + nBulletLen) );
aRetVal = rCacheVF.Copy();
rCacheVF.SetSelection( aOldSelection ); // restore
@@ -1689,11 +2504,19 @@ namespace accessibility
CheckRange(nStartIndex, nEndIndex);
- if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
+ // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet
+ sal_Int32 nBulletLen = 0;
+ EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
+ if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible )
+ nBulletLen = aBulletInfo.aText.Len();
+ ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen);
+ //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
+ if( !rCacheTF.IsEditable( aSelection ) )
return sal_False; // non-editable area selected
// don't save selection, might become invalid after cut!
- rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
+ //rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
+ rCacheVF.SetSelection( aSelection );
return rCacheVF.Cut();
}
@@ -1719,11 +2542,18 @@ namespace accessibility
CheckPosition(nIndex);
- if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) )
+ // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet
+ sal_Int32 nBulletLen = 0;
+ EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
+ if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible )
+ nBulletLen = aBulletInfo.aText.Len();
+ //if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) )
+ if( !rCacheTF.IsEditable( MakeSelection(nIndex + nBulletLen) ) )
return sal_False; // non-editable area selected
// #104400# set empty selection (=> cursor) to given index
- rCacheVF.SetSelection( MakeCursor(nIndex) );
+ //rCacheVF.SetSelection( MakeCursor(nIndex) );
+ rCacheVF.SetSelection( MakeCursor(nIndex + nBulletLen) );
return rCacheVF.Paste();
}
@@ -1751,10 +2581,19 @@ namespace accessibility
CheckRange(nStartIndex, nEndIndex);
- if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
+ // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet
+ sal_Int32 nBulletLen = 0;
+ EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
+ if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible )
+ nBulletLen = aBulletInfo.aText.Len();
+ ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen);
+
+ //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
+ if( !rCacheTF.IsEditable( aSelection ) )
return sal_False; // non-editable area selected
- sal_Bool bRet = rCacheTF.Delete( MakeSelection(nStartIndex, nEndIndex) );
+ //sal_Bool bRet = rCacheTF.Delete( MakeSelection(nStartIndex, nEndIndex) );
+ sal_Bool bRet = rCacheTF.Delete( aSelection );
GetEditSource().UpdateData();
@@ -1784,11 +2623,19 @@ namespace accessibility
CheckPosition(nIndex);
- if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) )
+ // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet
+ sal_Int32 nBulletLen = 0;
+ EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
+ if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible )
+ nBulletLen = aBulletInfo.aText.Len();
+
+ //if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) )
+ if( !rCacheTF.IsEditable( MakeSelection(nIndex + nBulletLen) ) )
return sal_False; // non-editable area selected
// #104400# insert given text at empty selection (=> cursor)
- sal_Bool bRet = rCacheTF.InsertText( sText, MakeCursor(nIndex) );
+ //sal_Bool bRet = rCacheTF.InsertText( sText, MakeCursor(nIndex) );
+ sal_Bool bRet = rCacheTF.InsertText( sText, MakeCursor(nIndex + nBulletLen) );
rCacheTF.QuickFormatDoc();
GetEditSource().UpdateData();
@@ -1819,11 +2666,20 @@ namespace accessibility
CheckRange(nStartIndex, nEndIndex);
- if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
+ // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet
+ sal_Int32 nBulletLen = 0;
+ EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
+ if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible )
+ nBulletLen = aBulletInfo.aText.Len();
+ ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen);
+
+ //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
+ if( !rCacheTF.IsEditable( aSelection ) )
return sal_False; // non-editable area selected
// insert given text into given range => replace
- sal_Bool bRet = rCacheTF.InsertText( sReplacement, MakeSelection(nStartIndex, nEndIndex) );
+ //sal_Bool bRet = rCacheTF.InsertText( sReplacement, MakeSelection(nStartIndex, nEndIndex) );
+ sal_Bool bRet = rCacheTF.InsertText( sReplacement, aSelection );
rCacheTF.QuickFormatDoc();
GetEditSource().UpdateData();
@@ -2024,7 +2880,10 @@ namespace accessibility
DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
"AccessibleEditableTextPara::getCharacterAttributes: index value overflow");
- CheckIndex(nIndex);
+ if( getCharacterCount() > 0 )
+ CheckIndex(nIndex);
+ else
+ CheckPosition(nIndex);
SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
ImplGetSvxCharAndParaPropertiesSet() );
Modified: openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleHyperlink.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleHyperlink.cxx?rev=1463840&r1=1463839&r2=1463840&view=diff
==============================================================================
--- openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleHyperlink.cxx (original)
+++ openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleHyperlink.cxx Wed Apr 3 07:04:20 2013
@@ -137,3 +137,310 @@ namespace accessibility
} // end of namespace accessibility
//------------------------------------------------------------------------
+
+// MT IA2: Accessiblehyperlink.hxx from IA2 CWS - meanwhile we also introduced one in DEV300 (above)
+// Keeping this for reference - we probably should get support for image maps in our implementation...
+
+//IAccessibility2 Implementation 2009-----
+
+/*
+
+class SVX_DLLPUBLIC SvxAccessibleHyperlink :
+ public ::cppu::WeakImplHelper1<
+ ::com::sun::star::accessibility::XAccessibleHyperlink >
+{
+ SvxURLField* mpField;
+ sal_Int32 nStartIdx;
+ sal_Int32 nEndIdx;
+
+ ImageMap* mpImageMap;
+ SdrObject* m_pShape;
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > shapeParent;
+
+public:
+
+ SvxAccessibleHyperlink(){};
+ //SvxAccessibleHyperlink(::rtl::OUString name, const Imagemap* pImageMap);
+ SvxAccessibleHyperlink(const SvxURLField* p, sal_Int32 nStt, sal_Int32 nEnd);
+ SvxAccessibleHyperlink(SdrObject* p, ::accessibility::AccessibleShape* pAcc);
+ virtual ~SvxAccessibleHyperlink();
+ //void setImageMap(ImageMap* pMap);
+ //void setXAccessibleImage(::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > parent);
+ ::rtl::OUString GetHyperlinkURL(sal_Int32 nIndex) throw (::com::sun::star::lang::IndexOutOfBoundsException);
+ sal_Bool IsValidHyperlink();
+
+ // XAccessibleAction
+ virtual sal_Int32 SAL_CALL getAccessibleActionCount()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL doAccessibleAction( sal_Int32 nIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleActionDescription(
+ sal_Int32 nIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL
+ getAccessibleActionKeyBinding( sal_Int32 nIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleHyperlink
+ virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleActionAnchor(
+ sal_Int32 nIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleActionObject(
+ sal_Int32 nIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getStartIndex()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getEndIndex()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isValid( )
+ throw (::com::sun::star::uno::RuntimeException);
+};
+
+
+SvxAccessibleHyperlink::SvxAccessibleHyperlink( const SvxURLField *p,
+ sal_Int32 nStt, sal_Int32 nEnd ) :
+ nStartIdx( nStt ),
+ nEndIdx( nEnd ),
+ m_pShape(NULL),
+ shapeParent(NULL)
+{
+ if(p)
+ mpField = (SvxURLField*)p->Clone();
+ else
+ mpField = NULL;
+}
+
+SvxAccessibleHyperlink::SvxAccessibleHyperlink(SdrObject* p,
+ ::accessibility::AccessibleShape* pAcc) :
+ nStartIdx( -1 ),
+ nEndIdx( -1 ),
+ mpField(NULL),
+ m_pShape(p)
+{
+ mpImageMap = m_pShape->GetModel()->GetImageMapForObject(m_pShape);
+ shapeParent = dynamic_cast< XAccessible* >(pAcc);
+}
+
+SvxAccessibleHyperlink::~SvxAccessibleHyperlink()
+{
+ if(mpField)
+ delete mpField;
+}
+
+::rtl::OUString SvxAccessibleHyperlink::GetHyperlinkURL(sal_Int32 nIndex) throw (::com::sun::star::lang::IndexOutOfBoundsException)
+{
+ if( mpField )
+ {
+ if (nIndex != 0)
+ throw ::com::sun::star::lang::IndexOutOfBoundsException();
+ return ::rtl::OUString( mpField->GetURL() );
+ }
+ else if (mpImageMap)
+ {
+ if (nIndex < 0 || nIndex >=mpImageMap->GetIMapObjectCount())
+ throw IndexOutOfBoundsException();
+
+ IMapObject* pMapObj = mpImageMap->GetIMapObject(sal_uInt16(nIndex));
+ if (pMapObj->GetURL().Len())
+ return ::rtl::OUString( pMapObj->GetURL() );
+ }
+ else
+ {
+ if (nIndex != 0)
+ throw ::com::sun::star::lang::IndexOutOfBoundsException();
+
+ SdrUnoObj* pUnoCtrl = dynamic_cast< SdrUnoObj* >( m_pShape );
+
+ if(pUnoCtrl)
+ {
+ try
+ {
+ uno::Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySetInfo > xPropInfo( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
+
+ form::FormButtonType eButtonType = form::FormButtonType_URL;
+ const ::rtl::OUString sButtonType( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" ) );
+ if(xPropInfo->hasPropertyByName( sButtonType ) && (xPropSet->getPropertyValue( sButtonType ) >>= eButtonType ) )
+ {
+ ::rtl::OUString aString;
+
+ // URL
+ const ::rtl::OUString sTargetURL(RTL_CONSTASCII_USTRINGPARAM( "TargetURL" ));
+ if(xPropInfo->hasPropertyByName(sTargetURL))
+ {
+ if( xPropSet->getPropertyValue(sTargetURL) >>= aString )
+ return aString;
+ }
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+ // If hyperlink can't be got from sdrobject, query the corresponding document to retrieve the link info
+ uno::Reference< XAccessibleGroupPosition > xGroupPosition (shapeParent, uno::UNO_QUERY);
+ if (xGroupPosition.is())
+ return xGroupPosition->getObjectLink( uno::makeAny( shapeParent ) );
+ }
+ return ::rtl::OUString();
+}
+
+// Just check whether the first hyperlink is valid
+sal_Bool SvxAccessibleHyperlink::IsValidHyperlink()
+{
+ ::rtl::OUString url = GetHyperlinkURL(0);
+ if (url.getLength() > 0)
+ return sal_True;
+ else
+ return sal_False;
+}
+// XAccessibleAction
+sal_Int32 SAL_CALL SvxAccessibleHyperlink::getAccessibleActionCount()
+ throw (RuntimeException)
+{
+ if (mpImageMap)
+ return mpImageMap->GetIMapObjectCount();
+ else
+ return 1; // only shape link or url field
+
+ //return mpField ? 1 : (mpImageMap ? mpImageMap->GetIMapObjectCount() : 0);
+}
+
+sal_Bool SAL_CALL SvxAccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex )
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ vos::OGuard aGuard(Application::GetSolarMutex());
+
+ sal_Bool bRet = sal_False;
+
+ OUString url = GetHyperlinkURL(nIndex);
+
+ if( url.getLength() > 0 )
+ {
+ SfxStringItem aStrItem(SID_FILE_NAME, url);
+ const SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ if( pDocSh )
+ {
+ SfxMedium* pSfxMedium = pDocSh->GetMedium();
+ if( pSfxMedium)
+ {
+ SfxStringItem aReferer(SID_REFERER, pSfxMedium->GetName());
+ SfxBoolItem aBrowseItem( SID_BROWSE, TRUE );
+ SfxViewFrame* pFrame = SfxViewFrame::Current();
+ if( pFrame )
+ {
+ pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aStrItem, &aBrowseItem, &aReferer, 0L);
+ bRet = sal_True;
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+
+OUString SAL_CALL SvxAccessibleHyperlink::getAccessibleActionDescription(
+ sal_Int32 nIndex )
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ return GetHyperlinkURL(nIndex);
+}
+
+::com::sun::star::uno::Reference< XAccessibleKeyBinding > SAL_CALL
+ SvxAccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 )
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ ::com::sun::star::uno::Reference< XAccessibleKeyBinding > xKeyBinding;
+
+ if( mpField || m_pShape)
+ {
+ ::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper =
+ new ::comphelper::OAccessibleKeyBindingHelper();
+ xKeyBinding = pKeyBindingHelper;
+
+ ::com::sun::star::awt::KeyStroke aKeyStroke;
+ aKeyStroke.Modifiers = 0;
+ aKeyStroke.KeyCode = KEY_RETURN;
+ aKeyStroke.KeyChar = 0;
+ aKeyStroke.KeyFunc = 0;
+ pKeyBindingHelper->AddKeyBinding( aKeyStroke );
+ }
+
+ return xKeyBinding;
+}
+
+// XAccessibleHyperlink
+Any SAL_CALL SvxAccessibleHyperlink::getAccessibleActionAnchor(
+ sal_Int32 nIndex )
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ Any aRet;
+
+ ::rtl::OUString retText;
+ if(mpField && nIndex == 0)
+ {
+ retText = mpField->GetRepresentation();
+ aRet <<= retText;
+ return aRet;
+ }
+ else if(mpImageMap)
+ {
+ IMapObject* pMapObj = mpImageMap->GetIMapObject(sal_uInt16(nIndex));
+ if(pMapObj && pMapObj->GetURL().Len())
+ aRet <<= shapeParent;
+ return aRet;
+ }
+ else if (nIndex == 0)
+ {
+ aRet <<= shapeParent;
+ return aRet;
+ }
+ return aRet;
+}
+
+Any SAL_CALL SvxAccessibleHyperlink::getAccessibleActionObject(
+ sal_Int32 nIndex )
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ ::rtl::OUString retText = GetHyperlinkURL(nIndex);
+ Any aRet;
+ aRet <<= retText;
+ return aRet;
+}
+
+sal_Int32 SAL_CALL SvxAccessibleHyperlink::getStartIndex()
+ throw (RuntimeException)
+{
+ return nStartIdx;
+}
+
+sal_Int32 SAL_CALL SvxAccessibleHyperlink::getEndIndex()
+ throw (RuntimeException)
+{
+ return nEndIdx;
+}
+
+sal_Bool SAL_CALL SvxAccessibleHyperlink::isValid( )
+ throw (RuntimeException)
+{
+ vos::OGuard aGuard(Application::GetSolarMutex());
+ //return mpField ? sal_True: ( mpImageMap ? sal_True : sal_False );
+ if (mpField || m_pShape)
+ return sal_True;
+ else
+ return sal_False;
+}
+
+*/
+
+//-----IAccessibility2 Implementation 2009
+
+
Modified: openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleParaManager.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleParaManager.cxx?rev=1463840&r1=1463839&r2=1463840&view=diff
==============================================================================
--- openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleParaManager.cxx (original)
+++ openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleParaManager.cxx Wed Apr 3 07:04:20 2013
@@ -356,10 +356,10 @@ namespace accessibility
const uno::Any& rOldValue ) const
{
DBG_ASSERT( maChildren.size() > nStartPara &&
- maChildren.size() >= nEndPara , "AccessibleParaManager::FireEvent: invalid index" );
+ maChildren.size() >= nEndPara &&
+ nEndPara >= nStartPara , "AccessibleParaManager::FireEvent: invalid index" );
- if( maChildren.size() > nStartPara &&
- maChildren.size() >= nEndPara )
+ if( maChildren.size() > nStartPara && maChildren.size() >= nEndPara && nEndPara >= nStartPara)
{
VectorOfChildren::const_iterator front = maChildren.begin();
VectorOfChildren::const_iterator back = front;
Modified: openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleStaticTextBase.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleStaticTextBase.cxx?rev=1463840&r1=1463839&r2=1463840&view=diff
==============================================================================
--- openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleStaticTextBase.cxx (original)
+++ openoffice/branches/ia2/main/editeng/source/accessibility/AccessibleStaticTextBase.cxx Wed Apr 3 07:04:20 2013
@@ -83,7 +83,9 @@ namespace accessibility
return ( lhs.Name == rhs.Name && lhs.Value == rhs.Value );
}
};
-
+//IAccessibility2 Implementation 2009-----
+sal_Unicode cNewLine(0x0a);
+//-----IAccessibility2 Implementation 2009
//------------------------------------------------------------------------
//
// Static Helper
@@ -120,7 +122,9 @@ namespace accessibility
*/
class AccessibleStaticTextBase_Impl
{
-
+ //IAccessibility2 Implementation 2009-----
+ friend class AccessibleStaticTextBase;
+ //-----IAccessibility2 Implementation 2009
public:
// receive pointer to our frontend class and view window
@@ -194,6 +198,9 @@ namespace accessibility
sal_Int32 nEndPara, sal_Int32 nEndIndex );
Rectangle GetParagraphBoundingBox() const;
+ //IAccessibility2 Implementation 2009-----
+ sal_Bool RemoveLineBreakCount( sal_Int32& rIndex );
+ //-----IAccessibility2 Implementation 2009
private:
@@ -386,8 +393,9 @@ namespace accessibility
{
nCurrCount = GetParagraph( nCurrPara ).getCharacterCount();
nCurrIndex += nCurrCount;
-
- if( nCurrIndex > nFlatIndex )
+ //IAccessibility2 Implementation 2009-----
+ if( nCurrIndex >= nFlatIndex )
+ //-----IAccessibility2 Implementation 2009
{
// check overflow
DBG_ASSERT(nCurrPara >= 0 && nCurrPara <= USHRT_MAX &&
@@ -477,7 +485,59 @@ namespace accessibility
}
return aRect;
}
-
+ //IAccessibility2 Implementation 2009-----
+ //the input argument is the index(including "\n" ) in the string.
+ //the function will calculate the actual index(not including "\n") in the string.
+ //and return true if the index is just at a "\n"
+ sal_Bool AccessibleStaticTextBase_Impl::RemoveLineBreakCount( sal_Int32& rIndex )
+ {
+ // get the total char number inside the cell.
+ sal_Int32 i, nCount, nParas;
+ for( i=0, nCount=0, nParas=GetParagraphCount(); i<nParas; ++i )
+ nCount += GetParagraph(i).getCharacterCount();
+ nCount = nCount + (nParas-1);
+ if( nCount == 0 && rIndex == 0) return sal_False;
+
+
+ sal_Int32 nCurrPara, nCurrCount;
+ sal_Int32 nLineBreakPos = 0, nLineBreakCount = 0;
+ sal_Int32 nParaCount = GetParagraphCount();
+ for ( nCurrCount = 0, nCurrPara = 0; nCurrPara < nParaCount; nCurrPara++ )
+ {
+ nCurrCount += GetParagraph( nCurrPara ).getCharacterCount();
+ nLineBreakPos = nCurrCount++;
+ if ( rIndex == nLineBreakPos )
+ {
+ rIndex -= (++nLineBreakCount);//(++nLineBreakCount);
+ if ( rIndex < 0)
+ {
+ rIndex = 0;
+ }
+ //if the index is at the last position of the last paragraph
+ //there is no "\n" , so we should increase rIndex by 1 and return false.
+ if ( (nCurrPara+1) == nParaCount )
+ {
+ rIndex++;
+ return sal_False;
+ }
+ else
+ {
+ return sal_True;
+ }
+ }
+ else if ( rIndex < nLineBreakPos )
+ {
+ rIndex -= nLineBreakCount;
+ return sal_False;
+ }
+ else
+ {
+ nLineBreakCount++;
+ }
+ }
+ return sal_False;
+ }
+ //-----IAccessibility2 Implementation 2009
//------------------------------------------------------------------------
//
// AccessibleStaticTextBase implementation
@@ -666,6 +726,10 @@ namespace accessibility
uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleStaticTextBase::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRequestedAttributes ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
{
::vos::OGuard aGuard( Application::GetSolarMutex() );
+ //IAccessibility2 Implementation 2009-----
+ //get the actual index without "\n"
+ mpImpl->RemoveLineBreakCount( nIndex );
+ //IAccessibility2 Implementation 2009-----
EPosition aPos( mpImpl->Index2Internal(nIndex) );
@@ -697,7 +761,10 @@ namespace accessibility
sal_Int32 i, nCount, nParas;
for( i=0, nCount=0, nParas=mpImpl->GetParagraphCount(); i<nParas; ++i )
nCount += mpImpl->GetParagraph(i).getCharacterCount();
-
+ //IAccessibility2 Implementation 2009-----
+ //count on the number of "\n" which equals number of paragraphs decrease 1.
+ nCount = nCount + (nParas-1);
+ //IAccessibility2 Implementation 2009-----
return nCount;
}
@@ -800,37 +867,99 @@ namespace accessibility
if( nStartIndex > nEndIndex )
::std::swap(nStartIndex, nEndIndex);
-
+ //IAccessibility2 Implementation 2009-----
+ //if startindex equals endindex we will get nothing. So return an empty string directly.
+ if ( nStartIndex == nEndIndex )
+ {
+ ::rtl::OUString sEmptyStr;
+ return sEmptyStr;
+ }
+ sal_Bool bStart = mpImpl->RemoveLineBreakCount( nStartIndex );
+ //if the start index is just at a "\n", we need to begin from the next char
+ if ( bStart )
+ {
+ nStartIndex++;
+ }
+ //we need to find out whether the previous position of the current endindex is at "\n" or not
+ //if yes we need to mark it and add "\n" at the end of the result
+ sal_Int32 nTemp = nEndIndex - 1;
+ sal_Bool bEnd = mpImpl->RemoveLineBreakCount( nTemp );
+ sal_Bool bTemp = mpImpl->RemoveLineBreakCount( nEndIndex );
+ //if the below condition is true it indicates an empty paragraph with just a "\n"
+ //so we need to set one "\n" flag to avoid duplication.
+ if ( bStart && bEnd && ( nStartIndex == nEndIndex) )
+ {
+ bEnd = sal_False;
+ }
+ //if the current endindex is at a "\n", we need to increase endindex by 1 to make sure
+ //the char before "\n" is included. Because string returned by this function will not include
+ //the char at the endindex.
+ if ( bTemp )
+ {
+ nEndIndex++;
+ }
+ ::rtl::OUString aRes;
EPosition aStartIndex( mpImpl->Range2Internal(nStartIndex) );
EPosition aEndIndex( mpImpl->Range2Internal(nEndIndex) );
// #102170# Special case: start and end paragraph are identical
if( aStartIndex.nPara == aEndIndex.nPara )
{
- return mpImpl->GetParagraph( aStartIndex.nPara ).getTextRange( aStartIndex.nIndex, aEndIndex.nIndex );
+ //we don't return the string directly now for that we have to do some further process for "\n"
+ aRes = mpImpl->GetParagraph( aStartIndex.nPara ).getTextRange( aStartIndex.nIndex, aEndIndex.nIndex );
+ //return mpImpl->GetParagraph( aStartIndex.nPara ).getTextRange( aStartIndex.nIndex, aEndIndex.nIndex );
+ //-----IAccessibility2 Implementation 2009
}
else
{
sal_Int32 i( aStartIndex.nPara );
- ::rtl::OUString aRes( mpImpl->GetParagraph(i).getTextRange( aStartIndex.nIndex,
- mpImpl->GetParagraph(i).getCharacterCount()-1) );
+ //IAccessibility2 Implementation 2009-----
+ aRes = mpImpl->GetParagraph(i).getTextRange( aStartIndex.nIndex,
+ mpImpl->GetParagraph(i).getCharacterCount()/*-1*/);
+ //-----IAccessibility2 Implementation 2009
++i;
// paragraphs inbetween are fully included
for( ; i<aEndIndex.nPara; ++i )
+ //IAccessibility2 Implementation 2009-----
+ {
+ aRes += rtl::OUString(cNewLine);
aRes += mpImpl->GetParagraph(i).getText();
+ }
if( i<=aEndIndex.nPara )
+ {
+ //if the below condition is mathed it means the endindex is at mid of the last paragraph
+ //we need to add a "\n" before we add the last part of the string.
+ if ( !bEnd && aEndIndex.nIndex )
+ {
+ aRes += rtl::OUString(cNewLine);
+ }
aRes += mpImpl->GetParagraph(i).getTextRange( 0, aEndIndex.nIndex );
-
- return aRes;
+ }
+ //return aRes;
}
+ //According the the flag we marked before, we have to add "\n" at the beginning
+ //or at the end of the result string.
+ if ( bStart )
+ {
+ aRes = rtl::OUString(cNewLine) + aRes;
+ }
+ if ( bEnd )
+ {
+ aRes += rtl::OUString(cNewLine);
+ }
+ return aRes;
+ //-----IAccessibility2 Implementation 2009
}
::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleStaticTextBase::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
{
+ //IAccessibility2 Implementation 2009-----
::vos::OGuard aGuard( Application::GetSolarMutex() );
+ sal_Bool bLineBreak = mpImpl->RemoveLineBreakCount( nIndex );
+ //-----IAccessibility2 Implementation 2009
EPosition aPos( mpImpl->Range2Internal(nIndex) );
::com::sun::star::accessibility::TextSegment aResult;
@@ -850,6 +979,19 @@ namespace accessibility
aResult.SegmentStart = mpImpl->Internal2Index( EPosition( aPos.nPara, 0 ) );
aResult.SegmentEnd = aResult.SegmentStart + aResult.SegmentText.getLength();
}
+ //IAccessibility2 Implementation 2009-----
+ else if ( AccessibleTextType::ATTRIBUTE_RUN == aTextType )
+ {
+ SvxAccessibleTextAdapter& rTextForwarder = mpImpl->GetParagraph( aPos.nIndex ).GetTextForwarder();
+ sal_uInt16 nStartIndex, nEndIndex;
+ if ( rTextForwarder.GetAttributeRun( nStartIndex, nEndIndex, aPos.nPara, aPos.nIndex, sal_True ) )
+ {
+ aResult.SegmentText = getTextRange( nStartIndex, nEndIndex );
+ aResult.SegmentStart = nStartIndex;
+ aResult.SegmentEnd = nEndIndex;
+ }
+ }
+ //-----IAccessibility2 Implementation 2009
else
{
// No special handling required, forward to wrapped class
@@ -857,6 +999,12 @@ namespace accessibility
// #112814# Adapt the start index with the paragraph offset
mpImpl->CorrectTextSegment( aResult, aPos.nPara );
+ //IAccessibility2 Implementation 2009-----
+ if ( bLineBreak )
+ {
+ aResult.SegmentText = rtl::OUString(cNewLine);
+ }
+ //-----IAccessibility2 Implementation 2009
}
return aResult;
@@ -865,7 +1013,10 @@ namespace accessibility
::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleStaticTextBase::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
{
::vos::OGuard aGuard( Application::GetSolarMutex() );
-
+ //IAccessibility2 Implementation 2009-----
+ sal_Int32 nOldIdx = nIndex;
+ sal_Bool bLineBreak = mpImpl->RemoveLineBreakCount( nIndex );
+ //-----IAccessibility2 Implementation 2009
EPosition aPos( mpImpl->Range2Internal(nIndex) );
::com::sun::star::accessibility::TextSegment aResult;
@@ -897,6 +1048,12 @@ namespace accessibility
// #112814# Adapt the start index with the paragraph offset
mpImpl->CorrectTextSegment( aResult, aPos.nPara );
+ //IAccessibility2 Implementation 2009-----
+ if ( bLineBreak && (nOldIdx-1) >= 0)
+ {
+ aResult = getTextAtIndex( nOldIdx-1, aTextType );
+ }
+ //-----IAccessibility2 Implementation 2009
}
return aResult;
@@ -905,7 +1062,11 @@ namespace accessibility
::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleStaticTextBase::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
{
::vos::OGuard aGuard( Application::GetSolarMutex() );
-
+ //IAccessibility2 Implementation 2009-----
+ sal_Int32 nTemp = nIndex+1;
+ sal_Bool bLineBreak = mpImpl->RemoveLineBreakCount( nTemp );
+ mpImpl->RemoveLineBreakCount( nIndex );
+ //-----IAccessibility2 Implementation 2009
EPosition aPos( mpImpl->Range2Internal(nIndex) );
::com::sun::star::accessibility::TextSegment aResult;
@@ -931,6 +1092,12 @@ namespace accessibility
// #112814# Adapt the start index with the paragraph offset
mpImpl->CorrectTextSegment( aResult, aPos.nPara );
+ //IAccessibility2 Implementation 2009-----
+ if ( bLineBreak )
+ {
+ aResult.SegmentText = rtl::OUString(cNewLine) + aResult.SegmentText;
+ }
+ //-----IAccessibility2 Implementation 2009
}
return aResult;
Modified: openoffice/branches/ia2/main/editeng/source/editeng/editdoc.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/ia2/main/editeng/source/editeng/editdoc.hxx?rev=1463840&r1=1463839&r2=1463840&view=diff
==============================================================================
Files openoffice/branches/ia2/main/editeng/source/editeng/editdoc.hxx (original) and openoffice/branches/ia2/main/editeng/source/editeng/editdoc.hxx Wed Apr 3 07:04:20 2013 differ
Modified: openoffice/branches/ia2/main/editeng/source/editeng/edtspell.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/ia2/main/editeng/source/editeng/edtspell.cxx?rev=1463840&r1=1463839&r2=1463840&view=diff
==============================================================================
--- openoffice/branches/ia2/main/editeng/source/editeng/edtspell.cxx (original)
+++ openoffice/branches/ia2/main/editeng/source/editeng/edtspell.cxx Wed Apr 3 07:04:20 2013
@@ -140,6 +140,9 @@ sal_Bool __EXPORT EditSpellWrapper::Spel
if ( pSpellInfo->bMultipleDoc )
{
bMore = pImpEE->GetEditEnginePtr()->SpellNextDocument();
+ //IAccessibility2 Implementation 2009-----
+ SetCurTextObj( pImpEE->GetEditEnginePtr()->GetCurTextObj() );
+ //-----IAccessibility2 Implementation 2009
if ( bMore )
{
// Der Text wurde in diese Engine getreten, bei Rueckwaerts
Modified: openoffice/branches/ia2/main/editeng/source/editeng/impedit.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/ia2/main/editeng/source/editeng/impedit.cxx?rev=1463840&r1=1463839&r2=1463840&view=diff
==============================================================================
--- openoffice/branches/ia2/main/editeng/source/editeng/impedit.cxx (original)
+++ openoffice/branches/ia2/main/editeng/source/editeng/impedit.cxx Wed Apr 3 07:04:20 2013
@@ -122,7 +122,23 @@ void ImpEditView::SetEditSelection( cons
if ( pEditEngine->pImpEditEngine->GetNotifyHdl().IsSet() )
{
- EENotify aNotify( EE_NOTIFY_TEXTVIEWSELECTIONCHANGED );
+ //IAccessibility2 Implementation 2009-----
+ const EditDoc& rDoc = pEditEngine->pImpEditEngine->GetEditDoc();
+ const EditPaM pmEnd = rDoc.GetEndPaM();
+ EENotifyType eNotifyType;
+ if (rDoc.Count() > 1 &&
+ pmEnd == rEditSelection.Min() &&
+ pmEnd == rEditSelection.Max())//if move cursor to the last para.
+ {
+ eNotifyType = EE_NOTIFY_TEXTVIEWSELECTIONCHANGED_ENDD_PARA;
+ }
+ else
+ {
+ eNotifyType = EE_NOTIFY_TEXTVIEWSELECTIONCHANGED;
+ }
+ //EENotify aNotify( EE_NOTIFY_TEXTVIEWSELECTIONCHANGED );
+ EENotify aNotify( eNotifyType );
+ //-----IAccessibility2 Implementation 2009
aNotify.pEditEngine = pEditEngine;
aNotify.pEditView = GetEditViewPtr();
pEditEngine->pImpEditEngine->CallNotify( aNotify );
Modified: openoffice/branches/ia2/main/editeng/source/editeng/impedit.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/ia2/main/editeng/source/editeng/impedit.hxx?rev=1463840&r1=1463839&r2=1463840&view=diff
==============================================================================
--- openoffice/branches/ia2/main/editeng/source/editeng/impedit.hxx (original)
+++ openoffice/branches/ia2/main/editeng/source/editeng/impedit.hxx Wed Apr 3 07:04:20 2013
@@ -480,6 +480,8 @@ private:
sal_Bool bInSelection;
sal_Bool bIsInUndo;
sal_Bool bUpdate;
+ //Sym2_5587, IAccessible2 migration fix
+ sal_Bool bUpdateForAcc;
sal_Bool bUndoEnabled;
sal_Bool bOwnerOfRefDev;
sal_Bool bDowning;
@@ -713,6 +715,9 @@ public:
void SetUpdateMode( sal_Bool bUp, EditView* pCurView = 0, sal_Bool bForceUpdate = sal_False );
sal_Bool GetUpdateMode() const { return bUpdate; }
+ // IAccessible2 migration fix
+ void SetUpdateModeForAcc( sal_Bool bUp);
+ sal_Bool GetUpdateModeForAcc();
const ParaPortionList& GetParaPortions() const { return aParaPortionList; }
ParaPortionList& GetParaPortions() { return aParaPortionList; }
Modified: openoffice/branches/ia2/main/editeng/source/editeng/impedit2.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/ia2/main/editeng/source/editeng/impedit2.cxx?rev=1463840&r1=1463839&r2=1463840&view=diff
==============================================================================
--- openoffice/branches/ia2/main/editeng/source/editeng/impedit2.cxx (original)
+++ openoffice/branches/ia2/main/editeng/source/editeng/impedit2.cxx Wed Apr 3 07:04:20 2013
@@ -136,6 +136,7 @@ ImpEditEngine::ImpEditEngine( EditEngine
bIsFormatting = sal_False;
bFormatted = sal_False;
bUpdate = sal_True;
+ bUpdateForAcc = TRUE; //IAccessible2 implementation 2009
bUseAutoColor = sal_True;
bForceAutoColor = sal_False;
bAddExtLeading = sal_False;
Modified: openoffice/branches/ia2/main/editeng/source/editeng/impedit3.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/ia2/main/editeng/source/editeng/impedit3.cxx?rev=1463840&r1=1463839&r2=1463840&view=diff
==============================================================================
--- openoffice/branches/ia2/main/editeng/source/editeng/impedit3.cxx (original)
+++ openoffice/branches/ia2/main/editeng/source/editeng/impedit3.cxx Wed Apr 3 07:04:20 2013
@@ -368,7 +368,9 @@ void ImpEditEngine::FormatFullDoc()
void ImpEditEngine::FormatDoc()
{
- if ( !GetUpdateMode() || IsFormatting() )
+ // IAccessible2 migration fix
+ //if ( !GetUpdateMode() || IsFormatting() )
+ if ( !GetUpdateMode() || IsFormatting() || !GetUpdateModeForAcc())
return;
EnterBlockNotifications();
@@ -3860,6 +3862,16 @@ EditPaM ImpEditEngine::ConnectContents(
DBG_ASSERT( IsInUndo(), "ConnectContent nur fuer Undo()!" );
return ImpConnectParagraphs( pLeftNode, pRightNode, bBackward );
}
+//IAccessible2 migration fix
+void ImpEditEngine::SetUpdateModeForAcc( sal_Bool bUp)
+{
+ bUpdateForAcc = bUp;
+}
+sal_Bool ImpEditEngine::GetUpdateModeForAcc()
+{
+ return bUpdateForAcc;
+}
+//End
void ImpEditEngine::SetUpdateMode( sal_Bool bUp, EditView* pCurView, sal_Bool bForceUpdate )
{
Modified: openoffice/branches/ia2/main/editeng/source/misc/splwrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/ia2/main/editeng/source/misc/splwrap.cxx?rev=1463840&r1=1463839&r2=1463840&view=diff
==============================================================================
--- openoffice/branches/ia2/main/editeng/source/misc/splwrap.cxx (original)
+++ openoffice/branches/ia2/main/editeng/source/misc/splwrap.cxx Wed Apr 3 07:04:20 2013
@@ -170,6 +170,7 @@ SvxSpellWrapper::SvxSpellWrapper( Window
bAuto ( sal_False ),
bStartChk ( bOther ),
bRevAllowed ( bRevAllow ),
+ mpTextObj( NULL),
bAllRight ( bIsAllRight )
{
Reference< beans::XPropertySet > xProp( SvxGetLinguPropertySet() );
@@ -198,6 +199,7 @@ SvxSpellWrapper::SvxSpellWrapper( Window
bEndDone ( bReverse && bStart && !bOther ),
bStartChk ( bOther ),
bRevAllowed ( sal_False ),
+ mpTextObj( NULL),
bAllRight ( sal_True )
{
}
Modified: openoffice/branches/ia2/main/editeng/source/outliner/outliner.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/ia2/main/editeng/source/outliner/outliner.cxx?rev=1463840&r1=1463839&r2=1463840&view=diff
==============================================================================
--- openoffice/branches/ia2/main/editeng/source/outliner/outliner.cxx (original)
+++ openoffice/branches/ia2/main/editeng/source/outliner/outliner.cxx Wed Apr 3 07:04:20 2013
@@ -1463,6 +1463,13 @@ sal_Bool Outliner::HasChilds( Paragraph*
sal_Bool Outliner::ImplHasBullet( sal_uInt16 nPara ) const
{
return GetNumberFormat(nPara) != 0;
+ if ( GetNumberFormat(nPara) )
+ {
+ const SfxBoolItem& rBulletState = (const SfxBoolItem&) pEditEngine->GetParaAttrib( nPara, EE_PARA_BULLETSTATE );
+ return rBulletState.GetValue();
+ }
+ else
+ return sal_False;
}
const SvxNumberFormat* Outliner::GetNumberFormat( sal_uInt16 nPara ) const
Modified: openoffice/branches/ia2/main/editeng/source/outliner/outlvw.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/ia2/main/editeng/source/outliner/outlvw.cxx?rev=1463840&r1=1463839&r2=1463840&view=diff
==============================================================================
--- openoffice/branches/ia2/main/editeng/source/outliner/outlvw.cxx (original)
+++ openoffice/branches/ia2/main/editeng/source/outliner/outlvw.cxx Wed Apr 3 07:04:20 2013
@@ -1579,7 +1579,6 @@ sal_Bool OutlinerView::IsWrongSpelledWor
return pEditView->IsWrongSpelledWordAtPos( rPosPixel, bMarkIfWrong );
}
-
void OutlinerView::SpellIgnoreWord()
{
DBG_CHKTHIS(OutlinerView,0);
Modified: openoffice/branches/ia2/main/editeng/source/uno/unoedhlp.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/ia2/main/editeng/source/uno/unoedhlp.cxx?rev=1463840&r1=1463839&r2=1463840&view=diff
==============================================================================
--- openoffice/branches/ia2/main/editeng/source/uno/unoedhlp.cxx (original)
+++ openoffice/branches/ia2/main/editeng/source/uno/unoedhlp.cxx Wed Apr 3 07:04:20 2013
@@ -28,7 +28,10 @@
#include <editeng/unoedhlp.hxx>
#include <editeng/editdata.hxx>
#include <editeng/editeng.hxx>
+//IAccessibility2 Implementation 2009-----
+#include <svl/itemset.hxx>
+//-----IAccessibility2 Implementation 2009
//------------------------------------------------------------------------
TYPEINIT1( SvxEditSourceHint, TextHint );
@@ -76,7 +79,9 @@ void SvxEditSourceHint::SetEndValue( sal
{
mnEnd = n;
}
-
+//IAccessibility2 Implementation 2009-----
+TYPEINIT1( SvxEditSourceHintEndPara , SvxEditSourceHint );
+//-----IAccessibility2 Implementation 2009
//------------------------------------------------------------------------
::std::auto_ptr<SfxHint> SvxEditSourceHelper::EENotification2Hint( EENotify* aNotify )
@@ -117,7 +122,10 @@ void SvxEditSourceHint::SetEndValue( sal
case EE_NOTIFY_INPUT_END:
return ::std::auto_ptr<SfxHint>( new TextHint( TEXT_HINT_INPUT_END, 0 ) );
-
+ //IAccessibility2 Implementation 2009-----
+ case EE_NOTIFY_TEXTVIEWSELECTIONCHANGED_ENDD_PARA:
+ return ::std::auto_ptr<SfxHint>( new SvxEditSourceHintEndPara( EDITSOURCE_HINT_SELECTIONCHANGED ) );
+ //-----IAccessibility2 Implementation 2009
default:
DBG_ERROR( "SvxEditSourceHelper::EENotification2Hint unknown notification" );
break;
@@ -126,9 +134,166 @@ void SvxEditSourceHint::SetEndValue( sal
return ::std::auto_ptr<SfxHint>( new SfxHint() );
}
-
-sal_Bool SvxEditSourceHelper::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, const EditEngine& rEE, sal_uInt16 nPara, sal_uInt16 nIndex )
+sal_Bool SvxEditSourceHelper::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, const EditEngine& rEE, sal_uInt16 nPara, sal_uInt16 nIndex, sal_Bool bInCell )
{
+ // IA2 CWS introduced bInCell, but also did many other changes here.
+ // Need to verify implementation with AT (IA2 and ATK)
+ // Old implementation at the end of the method for reference...
+
+#if 1 // IA2 CWS
+
+ //added dummy attributes for the default text
+ EECharAttribArray aCharAttribs, aTempCharAttribs;
+ rEE.GetCharAttribs( nPara, aTempCharAttribs );
+ if ( aTempCharAttribs.Count() )
+ {
+ sal_uInt32 nIndex2 = 0;
+ sal_uInt32 nParaLen = rEE.GetTextLen(nPara);
+ for ( sal_uInt16 nAttr = 0; nAttr < aTempCharAttribs.Count(); nAttr++ )
+ {
+ if ( nIndex2 < aTempCharAttribs[nAttr].nStart )
+ {
+ EECharAttrib aEEAttr;
+ aEEAttr.nStart = sal_uInt16(nIndex2);
+ aEEAttr.nEnd = aTempCharAttribs[nAttr].nStart;
+ aCharAttribs.Insert( aEEAttr, nAttr );
+ }
+ nIndex2 = aTempCharAttribs[nAttr].nEnd;
+ aCharAttribs.Insert( aTempCharAttribs[nAttr], aCharAttribs.Count() );
+ }
+ if ( nIndex2 != nParaLen )
+ {
+ EECharAttrib aEEAttr;
+ aEEAttr.nStart = sal_uInt16(nIndex2);
+ aEEAttr.nEnd = sal_uInt16(nParaLen);
+ aCharAttribs.Insert( aEEAttr, aCharAttribs.Count() );
+ }
+ }
+ // find closest index in front of nIndex
+ sal_uInt16 nAttr, nCurrIndex;
+ sal_Int32 nClosestStartIndex;
+ sal_Int32 nClosestStartIndex_s, nClosestStartIndex_e;
+ for( nAttr=0, nClosestStartIndex_s=0, nClosestStartIndex_e=0; nAttr<aCharAttribs.Count(); ++nAttr )
+ {
+ nCurrIndex = aCharAttribs[nAttr].nStart;
+
+ //if( nCurrIndex > nIndex )
+ // break; // aCharAttribs array is sorted in increasing order for nStart values
+
+ if( nCurrIndex > nClosestStartIndex_s &&
+ nCurrIndex <= nIndex)
+ {
+ nClosestStartIndex_s = nCurrIndex;
+ }
+ nCurrIndex = aCharAttribs[nAttr].nEnd;
+ if ( nCurrIndex > nClosestStartIndex_e &&
+ nCurrIndex < nIndex )
+ {
+ nClosestStartIndex_e = nCurrIndex;
+ }
+ }
+ nClosestStartIndex = nClosestStartIndex_s > nClosestStartIndex_e ? nClosestStartIndex_s : nClosestStartIndex_e;
+
+ // find closest index behind of nIndex
+ sal_Int32 nClosestEndIndex;
+ sal_Int32 nClosestEndIndex_s, nClosestEndIndex_e;
+ for( nAttr=0, nClosestEndIndex_s=nClosestEndIndex_e=rEE.GetTextLen(nPara); nAttr<aCharAttribs.Count(); ++nAttr )
+ {
+ nCurrIndex = aCharAttribs[nAttr].nEnd;
+
+ if( nCurrIndex > nIndex &&
+ nCurrIndex < nClosestEndIndex_e )
+ {
+ nClosestEndIndex_e = nCurrIndex;
+ }
+ nCurrIndex = aCharAttribs[nAttr].nStart;
+ if ( nCurrIndex > nIndex &&
+ nCurrIndex < nClosestEndIndex_s)
+ {
+ nClosestEndIndex_s = nCurrIndex;
+ }
+ }
+ nClosestEndIndex = nClosestEndIndex_s < nClosestEndIndex_e ? nClosestEndIndex_s : nClosestEndIndex_e;
+
+ nStartIndex = static_cast<sal_uInt16>( nClosestStartIndex );
+ nEndIndex = static_cast<sal_uInt16>( nClosestEndIndex );
+ if ( bInCell )
+ {
+ EPosition aStartPos( nPara, nStartIndex ), aEndPos( nPara, nEndIndex );
+ sal_uInt32 nParaCount = rEE.GetParagraphCount();
+ sal_uInt32 nCrrntParaLen = rEE.GetTextLen(nPara);
+ //need to find closest index in front of nIndex in the previous paragraphs
+ if ( aStartPos.nIndex == 0 )
+ {
+ SfxItemSet aCrrntSet = rEE.GetAttribs( nPara, 0, 1, GETATTRIBS_CHARATTRIBS );
+ for ( sal_Int32 nParaIdx = nPara-1; nParaIdx >= 0; nParaIdx-- )
+ {
+ sal_uInt32 nLen = rEE.GetTextLen( sal_uInt16(nParaIdx) );
+ if ( nLen )
+ {
+ sal_uInt16 nStartIdx, nEndIdx;
+ GetAttributeRun( nStartIdx, nEndIdx, rEE, sal_uInt16(nParaIdx), sal_uInt16(nLen), sal_False );
+ SfxItemSet aSet = rEE.GetAttribs( sal_uInt16(nParaIdx), sal_uInt16(nLen-1), sal_uInt16(nLen), GETATTRIBS_CHARATTRIBS );
+ if ( aSet == aCrrntSet )
+ {
+ aStartPos.nPara = sal_uInt16(nParaIdx);
+ aStartPos.nIndex = nStartIdx;
+ if ( aStartPos.nIndex != 0 )
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+ //need find closest index behind nIndex in the following paragrphs
+ if ( aEndPos.nIndex == nCrrntParaLen )
+ {
+ SfxItemSet aCrrntSet = rEE.GetAttribs( nPara, sal_uInt16(nCrrntParaLen-1), sal_uInt16(nCrrntParaLen), GETATTRIBS_CHARATTRIBS );
+ for ( sal_uInt32 nParaIdx = nPara+1; nParaIdx < nParaCount; nParaIdx++ )
+ {
+ sal_uInt32 nLen = rEE.GetTextLen( sal_uInt16(nParaIdx) );
+ if ( nLen )
+ {
+ sal_uInt16 nStartIdx, nEndIdx;
+ GetAttributeRun( nStartIdx, nEndIdx, rEE, sal_uInt16(nParaIdx), 0, sal_False );
+ SfxItemSet aSet = rEE.GetAttribs( sal_uInt16(nParaIdx), 0, 1, GETATTRIBS_CHARATTRIBS );
+ if ( aSet == aCrrntSet )
+ {
+ aEndPos.nPara = sal_uInt16(nParaIdx);
+ aEndPos.nIndex = nEndIdx;
+ if ( aEndPos.nIndex != nLen )
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+ nStartIndex = 0;
+ if ( aStartPos.nPara > 0 )
+ {
+ for ( sal_uInt16 i = 0; i < aStartPos.nPara; i++ )
+ {
+ nStartIndex += rEE.GetTextLen(i)+1;
+ }
+ }
+ nStartIndex += aStartPos.nIndex;
+ nEndIndex = 0;
+ if ( aEndPos.nPara > 0 )
+ {
+ for ( sal_uInt16 i = 0; i < aEndPos.nPara; i++ )
+ {
+ nEndIndex += rEE.GetTextLen(i)+1;
+ }
+ }
+ nEndIndex += aEndPos.nIndex;
+ }
+
+ return sal_True;
+
+#else // old implementation
+
EECharAttribArray aCharAttribs;
rEE.GetCharAttribs( nPara, aCharAttribs );
@@ -166,6 +331,8 @@ sal_Bool SvxEditSourceHelper::GetAttribu
nEndIndex = static_cast<sal_uInt16>( nClosestEndIndex );
return sal_True;
+
+#endif
}
Point SvxEditSourceHelper::EEToUserSpace( const Point& rPoint, const Size& rEESize, bool bIsVertical )
|