31#include <com/sun/star/uno/Any.hxx>
32#include <com/sun/star/uno/Reference.hxx>
33#include <com/sun/star/awt/Point.hpp>
34#include <com/sun/star/awt/Rectangle.hpp>
35#include <com/sun/star/container/XNameContainer.hpp>
36#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
37#include <com/sun/star/i18n/Boundary.hpp>
38#include <com/sun/star/accessibility/AccessibleRole.hpp>
39#include <com/sun/star/accessibility/AccessibleTextType.hpp>
40#include <com/sun/star/accessibility/AccessibleStateType.hpp>
41#include <com/sun/star/accessibility/AccessibleEventId.hpp>
46#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
63#include <com/sun/star/beans/PropertyState.hpp>
71#include <editeng/editrids.hrc>
103 AccessibleEditableTextPara::AccessibleEditableTextPara(
104 uno::Reference< XAccessible > xParent,
105 const AccessibleParaManager* _pParaManager )
107 mnIndexInParent( 0 ),
108 mpEditSource( nullptr ),
116 mnNotifierClientId(::
comphelper::AccessibleEventNotifier::registerClient()),
118 mpParaManager( _pParaManager )
125 mnStateSet |= AccessibleStateType::MULTI_LINE;
126 mnStateSet |= AccessibleStateType::FOCUSABLE;
127 mnStateSet |= AccessibleStateType::VISIBLE;
128 mnStateSet |= AccessibleStateType::SHOWING;
129 mnStateSet |= AccessibleStateType::ENABLED;
130 mnStateSet |= AccessibleStateType::SENSITIVE;
133 AccessibleEditableTextPara::~AccessibleEditableTextPara()
136 if( getNotifierClientId() != -1 )
142 catch (
const uno::Exception&)
148 OUString AccessibleEditableTextPara::implGetText()
150 return GetTextRange( 0, GetTextLen() );
153 css::lang::Locale AccessibleEditableTextPara::implGetLocale()
156 "AccessibleEditableTextPara::getLocale: paragraph index value overflow");
162 void AccessibleEditableTextPara::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
164 sal_Int32 nStart, nEnd;
168 nStartIndex = nStart;
179 void AccessibleEditableTextPara::implGetParagraphBoundary(
const OUString& rText, css::i18n::Boundary& rBoundary, sal_Int32 )
181 SAL_INFO(
"editeng",
"AccessibleEditableTextPara::implGetParagraphBoundary: only a base implementation, ignoring the index" );
183 rBoundary.startPos = 0;
184 rBoundary.endPos = rText.getLength();
187 void AccessibleEditableTextPara::implGetLineBoundary(
const OUString&, css::i18n::Boundary& rBoundary, sal_Int32 nIndex )
190 const sal_Int32 nParaIndex = GetParagraphIndex();
193 "AccessibleEditableTextPara::implGetLineBoundary: paragraph index value overflow");
195 const sal_Int32 nTextLen = rCacheTF.
GetTextLen( nParaIndex );
197 CheckPosition(nIndex);
199 rBoundary.startPos = rBoundary.endPos = -1;
201 const sal_Int32 nLineCount=rCacheTF.
GetLineCount( nParaIndex );
203 if( nIndex == nTextLen )
206 if( nLineCount <= 1 )
207 rBoundary.startPos = 0;
209 rBoundary.startPos = nTextLen - rCacheTF.
GetLineLen( nParaIndex,
212 rBoundary.endPos = nTextLen;
219 for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine )
221 nCurIndex += rCacheTF.
GetLineLen( nParaIndex, nLine);
223 if( nCurIndex > nIndex )
225 rBoundary.startPos = nCurIndex - rCacheTF.
GetLineLen( nParaIndex, nLine);
226 rBoundary.endPos = nCurIndex;
234 void AccessibleEditableTextPara::SetIndexInParent( sal_Int32 nIndex )
240 void AccessibleEditableTextPara::SetParagraphIndex( sal_Int32 nIndex )
246 auto aChild( maImageBullet.get() );
248 aChild->SetParagraphIndex(mnParagraphIndex);
252 if( nOldIndex != nIndex )
259 aOldDesc <<= getAccessibleDescription();
260 aOldName <<= getAccessibleName();
262 catch (
const uno::Exception&)
266 FireEvent( AccessibleEventId::DESCRIPTION_CHANGED,
uno::Any( getAccessibleDescription() ), aOldDesc );
267 FireEvent( AccessibleEventId::NAME_CHANGED,
uno::Any( getAccessibleName() ), aOldName );
270 catch (
const uno::Exception&)
276 void AccessibleEditableTextPara::Dispose()
278 int nClientId( getNotifierClientId() );
282 mnNotifierClientId = -1;
283 mpEditSource =
nullptr;
286 if( nClientId == -1 )
291 uno::Reference < XAccessibleContext > xThis = getAccessibleContext();
296 catch (
const uno::Exception&)
301 void AccessibleEditableTextPara::SetEditSource( SvxEditSourceAdapter* pEditSource )
303 auto aChild( maImageBullet.get() );
305 aChild->SetEditSource(pEditSource);
310 UnSetState( AccessibleStateType::SHOWING );
311 UnSetState( AccessibleStateType::VISIBLE );
312 SetState( AccessibleStateType::INVALID );
313 SetState( AccessibleStateType::DEFUNC );
317 mpEditSource = pEditSource;
323 catch (
const uno::RuntimeException&)
333 GetParagraphIndex() >= 0,
334 "AccessibleEditableTextPara::MakeSelection: index value overflow");
336 sal_Int32 nParaIndex = GetParagraphIndex();
337 return ESelection(nParaIndex, nStartEEIndex, nParaIndex, nEndEEIndex);
345 ESelection AccessibleEditableTextPara::MakeCursor( sal_Int32 nEEIndex )
350 void AccessibleEditableTextPara::CheckIndex( sal_Int32 nIndex )
352 if( nIndex < 0 || nIndex >= getCharacterCount() )
353 throw lang::IndexOutOfBoundsException(
"AccessibleEditableTextPara: character index out of bounds",
357 void AccessibleEditableTextPara::CheckPosition( sal_Int32 nIndex )
359 if( nIndex < 0 || nIndex > getCharacterCount() )
360 throw lang::IndexOutOfBoundsException(
"AccessibleEditableTextPara: character position out of bounds",
364 void AccessibleEditableTextPara::CheckRange( sal_Int32 nStart, sal_Int32 nEnd )
366 CheckPosition( nStart );
367 CheckPosition( nEnd );
373 sal_Int32 nPara = GetParagraphIndex();
374 if( !GetEditViewForwarder().
GetSelection( aSelection ) )
391 nEndPos = GetTextLen();
402 nStartPos = GetTextLen();
413 OUString AccessibleEditableTextPara::GetTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
415 return GetTextForwarder().GetText(
MakeSelection(nStartIndex, nEndIndex) );
418 sal_Int32 AccessibleEditableTextPara::GetTextLen()
const
420 return GetTextForwarder().GetTextLen(GetParagraphIndex());
423 SvxEditSourceAdapter& AccessibleEditableTextPara::GetEditSource()
const
426 throw uno::RuntimeException(
"No edit source, object is defunct",
427 const_cast< AccessibleEditableTextPara*
> (
this)->getXWeak() );
428 return *mpEditSource;
433 SvxEditSourceAdapter& rEditSource = GetEditSource();
436 if( !pTextForwarder )
437 throw uno::RuntimeException(
"Unable to fetch text forwarder, object is defunct",
438 const_cast< AccessibleEditableTextPara*
> (
this)->getXWeak() );
440 if( !pTextForwarder->
IsValid() )
441 throw uno::RuntimeException(
"Text forwarder is invalid, object is defunct",
442 const_cast< AccessibleEditableTextPara*
> (
this)->getXWeak() );
443 return *pTextForwarder;
451 if( !pViewForwarder )
453 throw uno::RuntimeException(
"Unable to fetch view forwarder, object is defunct",
454 const_cast< AccessibleEditableTextPara*
> (
this)->getXWeak() );
457 if( !pViewForwarder->
IsValid() )
458 throw uno::RuntimeException(
"View forwarder is invalid, object is defunct",
459 const_cast< AccessibleEditableTextPara*
> (
this)->getXWeak() );
460 return *pViewForwarder;
465 SvxEditSourceAdapter& rEditSource = GetEditSource();
468 if( !pTextEditViewForwarder )
471 throw uno::RuntimeException(
"Unable to fetch view forwarder, object is defunct",
472 const_cast< AccessibleEditableTextPara*
> (
this)->getXWeak() );
474 throw uno::RuntimeException(
"No view forwarder, object not in edit mode",
475 const_cast< AccessibleEditableTextPara*
> (
this)->getXWeak() );
478 if( pTextEditViewForwarder->
IsValid() )
479 return *pTextEditViewForwarder;
483 throw uno::RuntimeException(
"View forwarder is invalid, object is defunct",
484 const_cast< AccessibleEditableTextPara*
> (
this)->getXWeak() );
486 throw uno::RuntimeException(
"View forwarder is invalid, object not in edit mode",
487 const_cast< AccessibleEditableTextPara*
> (
this)->getXWeak() );
491 bool AccessibleEditableTextPara::HaveEditView()
const
496 if( !pViewForwarder )
499 if( !pViewForwarder->
IsValid() )
505 bool AccessibleEditableTextPara::HaveChildren()
508 "AccessibleEditableTextPara::HaveChildren: paragraph index value overflow");
510 return GetTextForwarder().HaveImageBullet( GetParagraphIndex() );
521 void AccessibleEditableTextPara::SetEEOffset(
const Point& rOffset )
523 auto aChild( maImageBullet.get() );
525 aChild->SetEEOffset(rOffset);
527 maEEOffset = rOffset;
530 void AccessibleEditableTextPara::FireEvent(
const sal_Int16 nEventId,
const uno::Any& rNewValue,
const uno::Any& rOldValue)
const
532 uno::Reference < XAccessibleContext > xThis(
const_cast< AccessibleEditableTextPara*
> (
this)->getAccessibleContext() );
534 AccessibleEventObject
aEvent(xThis, nEventId, rNewValue, rOldValue, -1);
537 if( getNotifierClientId() != -1 )
542 void AccessibleEditableTextPara::SetState(
const sal_Int64 nStateId )
544 if( !(mnStateSet & nStateId) )
546 mnStateSet |= nStateId;
547 FireEvent( AccessibleEventId::STATE_CHANGED,
uno::Any( nStateId ) );
551 void AccessibleEditableTextPara::UnSetState(
const sal_Int64 nStateId )
553 if( mnStateSet & nStateId )
555 mnStateSet &= ~nStateId;
556 FireEvent( AccessibleEventId::STATE_CHANGED,
uno::Any(),
uno::Any( nStateId ) );
560 void AccessibleEditableTextPara::TextChanged()
562 OUString aCurrentString( implGetText() );
565 if( OCommonAccessibleText::implInitTextChangedEvent( maLastTextString, aCurrentString,
566 aDeleted, aInserted) )
568 FireEvent( AccessibleEventId::TEXT_CHANGED, aInserted, aDeleted );
569 maLastTextString = aCurrentString;
573 bool AccessibleEditableTextPara::GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nIndex )
576 "AccessibleEditableTextPara::GetAttributeRun: index value overflow");
579 "AccessibleEditableTextPara::getLocale: paragraph index value overflow");
581 return GetTextForwarder().GetAttributeRun( nStartIndex,
587 uno::Any SAL_CALL AccessibleEditableTextPara::queryInterface (
const uno::Type & rType)
594 uno::Reference< XAccessibleText > aAccText =
static_cast< XAccessibleEditableText *
>(
this);
599 uno::Reference< XAccessibleEditableText > aAccEditText =
this;
600 aRet <<= aAccEditText;
604 uno::Reference< XAccessibleHypertext > aAccHyperText =
this;
605 aRet <<= aAccHyperText;
609 aRet = AccessibleTextParaInterfaceBase::queryInterface(rType);
616 uno::Reference< XAccessibleContext > SAL_CALL AccessibleEditableTextPara::getAccessibleContext()
619 return uno::Reference< XAccessibleContext > (
this );
623 sal_Int64 SAL_CALL AccessibleEditableTextPara::getAccessibleChildCount()
627 return HaveChildren() ? 1 : 0;
630 uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleChild( sal_Int64 i )
634 if( !HaveChildren() )
635 throw lang::IndexOutOfBoundsException(
"No children available",
639 throw lang::IndexOutOfBoundsException(
"Invalid child index",
642 auto aChild( maImageBullet.get() );
647 aChild =
new AccessibleImageBullet(
this);
649 aChild->SetEditSource( &GetEditSource() );
650 aChild->SetParagraphIndex( GetParagraphIndex() );
651 aChild->SetIndexInParent( i );
653 maImageBullet = aChild;
659 uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleParent()
661 SAL_WARN_IF(!
mxParent.is(),
"editeng",
"AccessibleEditableTextPara::getAccessibleParent: no frontend set, did somebody forgot to call AccessibleTextHelper::SetEventSource()?");
666 sal_Int64 SAL_CALL AccessibleEditableTextPara::getAccessibleIndexInParent()
668 return mnIndexInParent;
671 sal_Int16 SAL_CALL AccessibleEditableTextPara::getAccessibleRole()
673 return AccessibleRole::PARAGRAPH;
676 OUString SAL_CALL AccessibleEditableTextPara::getAccessibleDescription()
686 if( getCharacterCount() )
687 aLine = getTextAtIndex(0, AccessibleTextType::LINE).SegmentText;
690 OUString sStr(
EditResId(RID_SVXSTR_A11Y_PARAGRAPH_DESCRIPTION));
691 OUString sParaIndex = OUString::number(GetParagraphIndex());
692 sStr = sStr.replaceFirst(
"$(ARG)", sParaIndex);
694 if( aLine.getLength() > MaxDescriptionLen )
700 for( aCurrWord=getTextAtIndex(MaxDescriptionLen, AccessibleTextType::WORD).SegmentText,
706 if( getTextAtIndex(i, AccessibleTextType::WORD).SegmentText != aCurrWord )
710 aLine = getTextAtIndex(0, AccessibleTextType::WORD).SegmentText;
712 aLine = getTextRange(0, i);
720 OUString SAL_CALL AccessibleEditableTextPara::getAccessibleName()
726 uno::Reference< XAccessibleRelationSet > SAL_CALL AccessibleEditableTextPara::getAccessibleRelationSet()
734 sal_Int32 nMyParaIndex( GetParagraphIndex() );
736 if ( nMyParaIndex > 0 &&
737 mpParaManager->IsReferencable( nMyParaIndex - 1 ) )
739 uno::Sequence<uno::Reference<XInterface> > aSequence
740 { cppu::getXWeak(mpParaManager->GetChild( nMyParaIndex - 1 ).first.get().get()) };
741 AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_FROM,
743 pAccRelSetHelper->AddRelation( aAccRel );
747 if ( (nMyParaIndex + 1) < mpParaManager->GetNum() &&
748 mpParaManager->IsReferencable( nMyParaIndex + 1 ) )
750 uno::Sequence<uno::Reference<XInterface> > aSequence
751 { cppu::getXWeak(mpParaManager->GetChild( nMyParaIndex + 1 ).first.get().get()) };
752 AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_TO,
754 pAccRelSetHelper->AddRelation( aAccRel );
757 return pAccRelSetHelper;
762 return uno::Reference< XAccessibleRelationSet >();
768 static const uno::Sequence<OUString> aNames{
780 "CharUnderlineColor",
786 "ParaFirstLineIndent",
800 explicit IndexCompare(
const PropertyValue* pVals ) :
pValues(pVals) {}
801 bool operator() ( sal_Int32 a, sal_Int32 b )
const
812 OUString GetFieldTypeNameFromField(
EFieldInfo const &ree)
815 sal_Int32 nFieldType = -1;
819 nFieldType = ree.
pFieldItem->GetField()->GetClassId() ;
823 case text::textfield::Type::DATE:
829 strFldType =
"date (fixed)";
831 strFldType =
"date (variable)";
835 case text::textfield::Type::PAGE:
836 strFldType =
"page-number";
839 case text::textfield::Type::PAGES:
840 strFldType =
"page-count";
842 case text::textfield::Type::TABLE:
843 strFldType =
"sheet-name";
846 case text::textfield::Type::TIME:
849 case text::textfield::Type::EXTENDED_TIME:
855 strFldType =
"time (fixed)";
857 strFldType =
"time (variable)";
861 case text::textfield::Type::AUTHOR:
862 strFldType =
"author";
864 case text::textfield::Type::EXTENDED_FILE:
865 case text::textfield::Type::DOCINFO_TITLE:
866 strFldType =
"file name";
868 case text::textfield::Type::DOCINFO_CUSTOM:
869 strFldType =
"custom document property";
880 OUString AccessibleEditableTextPara::GetFieldTypeNameAtIndex(sal_Int32 nIndex)
884 sal_Int32 nParaIndex = GetParagraphIndex();
885 sal_Int32 nAllFieldLen = 0;
887 for (sal_Int32 j = 0; j < nField; ++j)
891 sal_Int32 reeEnd = reeBegin + ree.
aCurrentText.getLength();
893 if (nIndex < reeBegin)
896 return GetFieldTypeNameFromField(ree);
901 sal_Int64 SAL_CALL AccessibleEditableTextPara::getAccessibleStateSet()
907 sal_Int64 nParentStates = 0;
908 if (getAccessibleParent().is())
910 uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
911 nParentStates = xParentContext->getAccessibleStateSet();
913 if (nParentStates & AccessibleStateType::EDITABLE)
915 mnStateSet |= AccessibleStateType::EDITABLE;
920 lang::Locale SAL_CALL AccessibleEditableTextPara::getLocale()
924 return implGetLocale();
927 void SAL_CALL AccessibleEditableTextPara::addAccessibleEventListener(
const uno::Reference< XAccessibleEventListener >& xListener )
929 if( getNotifierClientId() != -1 )
933 void SAL_CALL AccessibleEditableTextPara::removeAccessibleEventListener(
const uno::Reference< XAccessibleEventListener >& xListener )
935 if( getNotifierClientId() == -1 )
939 if ( !nListenerCount )
946 mnNotifierClientId = -1;
952 sal_Bool SAL_CALL AccessibleEditableTextPara::containsPoint(
const awt::Point& aTmpPoint )
957 "AccessibleEditableTextPara::contains: index value overflow");
959 awt::Rectangle aTmpRect = getBounds();
961 Point aPoint( aTmpPoint.X, aTmpPoint.Y );
963 return aRect.Contains( aPoint );
966 uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleAtPoint(
const awt::Point& _aPoint )
973 Point aPoint( _aPoint.X, _aPoint.Y );
976 aPoint -= GetEEOffset();
980 Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.
GetMapMode() ) );
991 return getAccessibleChild(0);
996 return uno::Reference< XAccessible >();
999 awt::Rectangle SAL_CALL AccessibleEditableTextPara::getBounds()
1004 "AccessibleEditableTextPara::getBounds: index value overflow");
1010 tools::Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect,
1012 GetViewForwarder() );
1015 Point aOffset = GetEEOffset();
1017 return awt::Rectangle( aScreenRect.
Left() + aOffset.
X(),
1018 aScreenRect.
Top() + aOffset.
Y(),
1023 awt::Point SAL_CALL AccessibleEditableTextPara::getLocation( )
1027 awt::Rectangle aRect = getBounds();
1029 return awt::Point( aRect.X, aRect.Y );
1032 awt::Point SAL_CALL AccessibleEditableTextPara::getLocationOnScreen( )
1037 uno::Reference< XAccessible > xParent = getAccessibleParent();
1040 uno::Reference< XAccessibleComponent > xParentComponent( xParent, uno::UNO_QUERY );
1041 if( xParentComponent.is() )
1043 awt::Point aRefPoint = xParentComponent->getLocationOnScreen();
1044 awt::Point aPoint = getLocation();
1045 aPoint.X += aRefPoint.X;
1046 aPoint.Y += aRefPoint.Y;
1054 uno::Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext();
1055 if ( xParentContext.is() )
1057 uno::Reference< XAccessibleComponent > xParentContextComponent( xParentContext, uno::UNO_QUERY );
1058 if( xParentContextComponent.is() )
1060 awt::Point aRefPoint = xParentContextComponent->getLocationOnScreen();
1061 awt::Point aPoint = getLocation();
1062 aPoint.X += aRefPoint.X;
1063 aPoint.Y += aRefPoint.Y;
1071 throw uno::RuntimeException(
"Cannot access parent",
1072 uno::Reference< uno::XInterface >
1073 (
static_cast< XAccessible*
> (
this) ) );
1076 awt::Size SAL_CALL AccessibleEditableTextPara::getSize( )
1080 awt::Rectangle aRect = getBounds();
1082 return awt::Size( aRect.Width, aRect.Height );
1085 void SAL_CALL AccessibleEditableTextPara::grabFocus( )
1091 sal_Int32 SAL_CALL AccessibleEditableTextPara::getForeground( )
1096 return static_cast<sal_Int32
>(nColor);
1099 sal_Int32 SAL_CALL AccessibleEditableTextPara::getBackground( )
1107 return static_cast<sal_Int32
>( aColor );
1111 sal_Int32 SAL_CALL AccessibleEditableTextPara::getCaretPosition()
1115 if( !HaveEditView() )
1119 if( GetEditViewForwarder().
GetSelection( aSelection ) &&
1120 GetParagraphIndex() == aSelection.
nEndPara )
1123 EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo(GetParagraphIndex());
1128 sal_Int32 nBulletLen = aBulletInfo.
aText.getLength();
1129 if( aSelection.
nEndPos - nBulletLen >= 0 )
1130 return aSelection.
nEndPos - nBulletLen;
1139 sal_Bool SAL_CALL AccessibleEditableTextPara::setCaretPosition( sal_Int32 nIndex )
1141 return setSelection(nIndex, nIndex);
1144 sal_Unicode SAL_CALL AccessibleEditableTextPara::getCharacter( sal_Int32 nIndex )
1149 "AccessibleEditableTextPara::getCharacter: index value overflow");
1151 return OCommonAccessibleText::implGetCharacter( implGetText(), nIndex );
1154 uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getCharacterAttributes( sal_Int32 nIndex,
const css::uno::Sequence< OUString >& rRequestedAttributes )
1165 bool bSupplementalMode =
false;
1166 uno::Sequence< OUString > aPropertyNames = rRequestedAttributes;
1167 if (!aPropertyNames.hasElements())
1169 bSupplementalMode =
true;
1177 const uno::Sequence< beans::PropertyValue > aRunAttribs( getRunAttributes( nIndex, aPropertyNames ) );
1178 for (
auto const& rRunAttrib : aRunAttribs)
1180 aPropHashMap[ rRunAttrib.Name ] = rRunAttrib.Value;
1184 uno::Sequence< beans::PropertyValue > aRes;
1185 aPropHashMap >> aRes;
1190 for (beans::PropertyValue & rRes : asNonConstRange(aRes))
1192 bool bIsDirectVal =
false;
1193 for (
auto const& rRunAttrib : aRunAttribs)
1195 bIsDirectVal = rRes.Name == rRunAttrib.Name;
1200 rRes.State = bIsDirectVal ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;
1202 if( bSupplementalMode )
1204 _correctValues( aRes );
1206 sal_Int32 nRes = aRes.getLength();
1207 aRes.realloc( nRes + 1 );
1208 beans::PropertyValue &rRes = aRes.getArray()[nRes];
1209 rRes.Name =
"NumberingPrefix";
1212 numStr = aBulletInfo.
aText;
1213 rRes.Value <<= numStr;
1215 rRes.State = PropertyState_DIRECT_VALUE;
1217 OUString strFieldType = GetFieldTypeNameAtIndex(nIndex);
1218 if (!strFieldType.isEmpty())
1220 nRes = aRes.getLength();
1221 aRes.realloc( nRes + 1 );
1222 beans::PropertyValue &rResField = aRes.getArray()[nRes];
1223 rResField.Name =
"FieldType";
1224 rResField.Value <<= strFieldType.toAsciiLowerCase();
1225 rResField.Handle = -1;
1226 rResField.State = PropertyState_DIRECT_VALUE;
1230 sal_Int32
nLength = aRes.getLength();
1231 const beans::PropertyValue* pPairs = aRes.getConstArray();
1232 std::unique_ptr<sal_Int32[]> pIndices(
new sal_Int32[nLength]);
1236 std::sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) );
1238 uno::Sequence<beans::PropertyValue> aNewValues( nLength );
1239 beans::PropertyValue* pNewValues = aNewValues.getArray();
1242 pNewValues[
i] = pPairs[pIndices[
i]];
1250 awt::Rectangle SAL_CALL AccessibleEditableTextPara::getCharacterBounds( sal_Int32 nIndex )
1255 "AccessibleEditableTextPara::getCharacterBounds: index value overflow");
1259 CheckPosition( nIndex );
1265 tools::Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect,
1267 GetViewForwarder() );
1271 awt::Rectangle aParaRect( getBounds() );
1272 aScreenRect.
Move( -aParaRect.X, -aParaRect.Y );
1275 Point aOffset = GetEEOffset();
1277 return awt::Rectangle( aScreenRect.
Left() + aOffset.
X(),
1278 aScreenRect.
Top() + aOffset.
Y(),
1283 sal_Int32 SAL_CALL AccessibleEditableTextPara::getCharacterCount()
1288 "AccessibleEditableTextPara::getCharacterCount: index value overflow");
1290 return implGetText().getLength();
1293 sal_Int32 SAL_CALL AccessibleEditableTextPara::getIndexAtPoint(
const awt::Point& rPoint )
1301 Point aOffset( GetEEOffset() );
1302 Point aPoint( rPoint.X - aOffset.X(), rPoint.Y - aOffset.Y() );
1306 Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.
GetMapMode() ) );
1310 aLogPoint.
Move( aParaRect.
Left(), aParaRect.
Top() );
1313 GetParagraphIndex() == nPara )
1318 awt::Rectangle aRect1( getCharacterBounds(nIndex) );
1320 aRect1.Width + aRect1.X, aRect1.Height + aRect1.Y );
1321 if( aRect2.Contains(
Point( rPoint.X, rPoint.Y ) ) )
1326 catch (
const lang::IndexOutOfBoundsException&)
1339 OUString SAL_CALL AccessibleEditableTextPara::getSelectedText()
1344 "AccessibleEditableTextPara::getSelectedText: index value overflow");
1346 if( !HaveEditView() )
1349 return OCommonAccessibleText::getSelectedText();
1352 sal_Int32 SAL_CALL AccessibleEditableTextPara::getSelectionStart()
1357 "AccessibleEditableTextPara::getSelectionStart: index value overflow");
1359 if( !HaveEditView() )
1362 return OCommonAccessibleText::getSelectionStart();
1365 sal_Int32 SAL_CALL AccessibleEditableTextPara::getSelectionEnd()
1370 "AccessibleEditableTextPara::getSelectionEnd: index value overflow");
1372 if( !HaveEditView() )
1375 return OCommonAccessibleText::getSelectionEnd();
1378 sal_Bool SAL_CALL AccessibleEditableTextPara::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
1383 "AccessibleEditableTextPara::setSelection: paragraph index value overflow");
1385 CheckRange(nStartIndex, nEndIndex);
1392 catch (
const uno::RuntimeException&)
1398 OUString SAL_CALL AccessibleEditableTextPara::getText()
1403 "AccessibleEditableTextPara::getText: paragraph index value overflow");
1405 return implGetText();
1408 OUString SAL_CALL AccessibleEditableTextPara::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
1413 "AccessibleEditableTextPara::getTextRange: paragraph index value overflow");
1415 return OCommonAccessibleText::implGetTextRange(implGetText(), nStartIndex, nEndIndex);
1418 void AccessibleEditableTextPara::_correctValues( uno::Sequence< PropertyValue >& rValues)
1421 sal_Int32 nRes = rValues.getLength();
1422 beans::PropertyValue *pRes = rValues.getArray();
1423 for (sal_Int32 i = 0;
i < nRes; ++
i)
1425 beans::PropertyValue &rRes = pRes[
i];
1427 if (rRes.Name ==
"CharColor")
1430 Color crChar(ColorTransparency,
static_cast<sal_uInt32
>(
reinterpret_cast<sal_uIntPtr
>(anyChar.pReserved)));
1431 if (COL_AUTO == crChar )
1433 uno::Reference< css::accessibility::XAccessibleComponent > xComponent(mxParent,uno::UNO_QUERY);
1434 if (xComponent.is())
1436 uno::Reference< css::accessibility::XAccessibleContext > xContext(xComponent,uno::UNO_QUERY);
1437 if (xContext->getAccessibleRole() == AccessibleRole::SHAPE
1438 || xContext->getAccessibleRole() == AccessibleRole::TABLE_CELL)
1444 Color cr(ColorTransparency, xComponent->getBackground());
1453 if (rRes.Name ==
"CharUnderline")
1458 if (rRes.Name ==
"CharUnderlineColor")
1461 Color crCharUnderLine(ColorTransparency,
static_cast<sal_uInt32
>(
reinterpret_cast<sal_uIntPtr
>( anyCharUnderLine.pReserved)));
1462 if (COL_AUTO == crCharUnderLine )
1464 uno::Reference< css::accessibility::XAccessibleComponent > xComponent(mxParent,uno::UNO_QUERY);
1465 if (xComponent.is())
1467 uno::Reference< css::accessibility::XAccessibleContext > xContext(xComponent,uno::UNO_QUERY);
1468 if (xContext->getAccessibleRole() == AccessibleRole::SHAPE
1469 || xContext->getAccessibleRole() == AccessibleRole::TABLE_CELL)
1475 Color cr(ColorTransparency, xComponent->getBackground());
1477 anyCharUnderLine <<= crCharUnderLine;
1484 if (rRes.Name ==
"NumberingLevel")
1488 rRes.
Value <<= sal_Int16(-1);
1490 rRes.State = PropertyState_DIRECT_VALUE;
1500 rRes.Value = xPropSet->_getPropertyValue( rRes.Name, mnParagraphIndex );
1501 rRes.State = xPropSet->_getPropertyState( rRes.Name, mnParagraphIndex );
1507 if (rRes.Name ==
"NumberingRules")
1513 rRes.Value <<= sal_Int16(-1);
1515 rRes.State = PropertyState_DIRECT_VALUE;
1522 rRes.Value = xPropSet->_getPropertyValue( rRes.Name, mnParagraphIndex );
1523 rRes.State = xPropSet->_getPropertyState( rRes.Name, mnParagraphIndex );
1530 sal_Int32 AccessibleEditableTextPara::SkipField(sal_Int32 nIndex,
bool bForward)
1532 sal_Int32 nParaIndex = GetParagraphIndex();
1534 sal_Int32 nAllFieldLen = 0;
1535 sal_Int32 nField = rCacheTF.
GetFieldCount(nParaIndex), nFoundFieldIndex = -1;
1536 sal_Int32 reeBegin=0, reeEnd=0;
1537 for (sal_Int32 j = 0; j < nField; ++j)
1543 if (nIndex < reeBegin)
1547 if (nIndex < reeEnd)
1549 if (ree.
pFieldItem->GetField()->GetClassId() != text::textfield::Type::URL)
1551 nFoundFieldIndex = j;
1556 if( nFoundFieldIndex >= 0 )
1565 void AccessibleEditableTextPara::ExtendByField( css::accessibility::TextSegment& Segment )
1567 sal_Int32 nParaIndex = GetParagraphIndex();
1569 sal_Int32 nAllFieldLen = 0;
1570 sal_Int32 nField = rCacheTF.
GetFieldCount(nParaIndex), nFoundFieldIndex = -1;
1571 sal_Int32 reeBegin=0, reeEnd=0;
1572 for (sal_Int32 j = 0; j < nField; ++j)
1578 if( reeBegin > Segment.SegmentEnd )
1584 if( (Segment.SegmentEnd > reeBegin && Segment.SegmentEnd <= reeEnd) ||
1585 (Segment.SegmentStart >= reeBegin && Segment.SegmentStart < reeEnd) )
1587 if(ree.
pFieldItem->GetField()->GetClassId() != text::textfield::Type::URL)
1589 nFoundFieldIndex = j;
1594 if( nFoundFieldIndex < 0 )
1597 bool bExtend =
false;
1598 if( Segment.SegmentEnd < reeEnd )
1600 Segment.SegmentEnd = reeEnd;
1603 if( Segment.SegmentStart > reeBegin )
1605 Segment.SegmentStart = reeBegin;
1613 sal_Int32 nBulletLen = aBulletInfo.
aText.getLength();
1616 Segment.SegmentEnd += nBulletLen;
1617 if (nFoundFieldIndex > 0)
1618 Segment.SegmentStart += nBulletLen;
1619 Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd);
1621 Segment.SegmentEnd -= nBulletLen;
1622 if (nFoundFieldIndex > 0)
1623 Segment.SegmentStart -= nBulletLen;
1626 Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd);
1629 css::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType )
1634 "AccessibleEditableTextPara::getTextAtIndex: paragraph index value overflow");
1636 css::accessibility::TextSegment aResult;
1637 aResult.SegmentStart = -1;
1638 aResult.SegmentEnd = -1;
1642 case AccessibleTextType::CHARACTER:
1643 case AccessibleTextType::WORD:
1645 aResult = OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
1646 ExtendByField( aResult );
1651 case AccessibleTextType::ATTRIBUTE_RUN:
1653 const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( GetParagraphIndex() );
1655 if( nIndex == nTextLen )
1658 aResult.SegmentStart = aResult.SegmentEnd = nTextLen;
1662 sal_Int32 nStartIndex, nEndIndex;
1669 if (nIndex != 0 && nIndex >= getCharacterCount())
1670 nIndex = getCharacterCount()-1;
1671 CheckPosition(nIndex);
1672 if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) )
1674 aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
1677 nStartIndex -= aBulletInfo.
aText.getLength();
1678 nEndIndex -= aBulletInfo.
aText.getLength();
1680 aResult.SegmentStart = nStartIndex;
1681 aResult.SegmentEnd = nEndIndex;
1686 case AccessibleTextType::LINE:
1689 sal_Int32 nParaIndex = GetParagraphIndex();
1690 CheckPosition(nIndex);
1691 if (nIndex != 0 && nIndex == getCharacterCount())
1693 sal_Int32 nLine, nLineCount=rCacheTF.
GetLineCount( nParaIndex );
1694 sal_Int32 nCurIndex;
1698 sal_Int32 nBulletLen = 0;
1699 for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine )
1707 nBulletLen = aBulletInfo.
aText.getLength();
1710 sal_Int32 nLineLen = rCacheTF.
GetLineLen(nParaIndex, nLine);
1712 nCurIndex += nLineLen - nBulletLen;
1714 nCurIndex += nLineLen;
1715 if( nCurIndex > nIndex )
1719 aResult.SegmentStart = 0;
1720 aResult.SegmentEnd = nCurIndex;
1721 aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd + nBulletLen);
1726 aResult.SegmentStart = nCurIndex - nLineLen;
1727 aResult.SegmentEnd = nCurIndex;
1729 aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen);
1737 aResult = OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
1744 css::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType )
1749 "AccessibleEditableTextPara::getTextBeforeIndex: paragraph index value overflow");
1751 css::accessibility::TextSegment aResult;
1752 aResult.SegmentStart = -1;
1753 aResult.SegmentEnd = -1;
1754 i18n::Boundary aBoundary;
1759 case AccessibleTextType::ATTRIBUTE_RUN:
1761 const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( GetParagraphIndex() );
1762 sal_Int32 nStartIndex, nEndIndex;
1764 if( nIndex == nTextLen )
1768 GetAttributeRun(nStartIndex, nEndIndex, nIndex-1) )
1770 aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
1771 aResult.SegmentStart = nStartIndex;
1772 aResult.SegmentEnd = nEndIndex;
1777 if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) )
1781 if( nStartIndex > 0 &&
1782 GetAttributeRun(nStartIndex, nEndIndex, nStartIndex-1) )
1784 aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
1785 aResult.SegmentStart = nStartIndex;
1786 aResult.SegmentEnd = nEndIndex;
1792 case AccessibleTextType::LINE:
1795 sal_Int32 nParaIndex = GetParagraphIndex();
1797 CheckPosition(nIndex);
1799 sal_Int32 nLine, nLineCount=rCacheTF.
GetLineCount( nParaIndex );
1803 sal_Int32 nCurIndex=0, nLastIndex=0, nCurLineLen=0;
1804 sal_Int32 nLastLineLen = 0, nBulletLen = 0;
1806 for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine )
1808 nLastIndex = nCurIndex;
1815 nBulletLen = aBulletInfo.
aText.getLength();
1819 nLastLineLen = nCurLineLen - nBulletLen;
1821 nLastLineLen = nCurLineLen;
1822 nCurLineLen = rCacheTF.
GetLineLen( nParaIndex, nLine);
1825 nCurIndex += nCurLineLen - nBulletLen;
1827 nCurIndex += nCurLineLen;
1831 if (nCurIndex > nIndex)
1837 else if (nLine == 1)
1839 aResult.SegmentStart = 0;
1840 aResult.SegmentEnd = nLastIndex;
1841 aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd + nBulletLen);
1847 aResult.SegmentStart = nLastIndex - nLastLineLen;
1848 aResult.SegmentEnd = nLastIndex;
1849 aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen);
1857 case AccessibleTextType::WORD:
1859 nIndex = SkipField( nIndex,
false);
1860 OUString sText( implGetText() );
1861 sal_Int32
nLength = sText.getLength();
1864 implGetWordBoundary( sText, aBoundary, nIndex );
1869 sal_Int32 curWordStart , preWordStart;
1870 if( aBoundary.startPos == -1 || aBoundary.startPos > nIndex)
1871 curWordStart = preWordStart =
nIndex;
1873 curWordStart = preWordStart = aBoundary.startPos;
1880 while ( (preWordStart >= 0 && !bWord ) || ( aBoundary.endPos > curWordStart ) )
1883 bWord = implGetWordBoundary( sText, aBoundary, preWordStart );
1885 if ( bWord && implIsValidBoundary( aBoundary, nLength ) )
1887 aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
1888 aResult.SegmentStart = aBoundary.startPos;
1889 aResult.SegmentEnd = aBoundary.endPos;
1890 ExtendByField( aResult );
1894 case AccessibleTextType::CHARACTER:
1896 nIndex = SkipField( nIndex,
false);
1897 aResult = OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
1898 ExtendByField( aResult );
1902 aResult = OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
1909 css::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType )
1914 "AccessibleEditableTextPara::getTextBehindIndex: paragraph index value overflow");
1916 css::accessibility::TextSegment aResult;
1917 aResult.SegmentStart = -1;
1918 aResult.SegmentEnd = -1;
1919 i18n::Boundary aBoundary;
1922 case AccessibleTextType::ATTRIBUTE_RUN:
1924 sal_Int32 nStartIndex, nEndIndex;
1926 if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) )
1929 if( nEndIndex < GetTextLen() )
1931 if( GetAttributeRun(nStartIndex, nEndIndex, nEndIndex) )
1933 aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
1934 aResult.SegmentStart = nStartIndex;
1935 aResult.SegmentEnd = nEndIndex;
1942 case AccessibleTextType::LINE:
1945 sal_Int32 nParaIndex = GetParagraphIndex();
1947 CheckPosition(nIndex);
1949 sal_Int32 nLine, nLineCount = rCacheTF.
GetLineCount( nParaIndex );
1950 sal_Int32 nCurIndex;
1954 sal_Int32 nBulletLen = 0;
1956 for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine )
1964 nBulletLen = aBulletInfo.
aText.getLength();
1967 sal_Int32 nLineLen = rCacheTF.
GetLineLen( nParaIndex, nLine);
1970 nCurIndex += nLineLen - nBulletLen;
1972 nCurIndex += nLineLen;
1974 if( nCurIndex > nIndex &&
1975 nLine < nLineCount-1 )
1977 aResult.SegmentStart = nCurIndex;
1978 aResult.SegmentEnd = nCurIndex + rCacheTF.
GetLineLen( nParaIndex, nLine+1);
1979 aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen);
1986 case AccessibleTextType::WORD:
1988 nIndex = SkipField( nIndex,
true);
1989 OUString sText( implGetText() );
1990 sal_Int32
nLength = sText.getLength();
1993 bool bWord = implGetWordBoundary( sText, aBoundary, nIndex );
1996 sal_Int32 nextWord =
nIndex;
1998 if( nIndex <= aBoundary.endPos )
2000 nextWord = aBoundary.endPos;
2001 if (nextWord < sText.getLength() && sText[nextWord] == u
' ') nextWord++;
2002 bWord = implGetWordBoundary( sText, aBoundary, nextWord );
2005 if ( bWord && implIsValidBoundary( aBoundary, nLength ) )
2007 aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
2008 aResult.SegmentStart = aBoundary.startPos;
2009 aResult.SegmentEnd = aBoundary.endPos;
2013 ExtendByField( aResult );
2018 case AccessibleTextType::CHARACTER:
2020 nIndex = SkipField( nIndex,
true);
2021 aResult = OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
2022 ExtendByField( aResult );
2026 aResult = OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
2033 sal_Bool SAL_CALL AccessibleEditableTextPara::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
2045 "AccessibleEditableTextPara::copyText: index value overflow");
2047 CheckRange(nStartIndex, nEndIndex);
2050 sal_Int32 nBulletLen = 0;
2051 EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo(GetParagraphIndex());
2053 nBulletLen = aBulletInfo.
aText.getLength();
2060 aRetVal = rCacheVF.
Copy();
2065 catch (
const uno::RuntimeException&)
2071 sal_Bool SAL_CALL AccessibleEditableTextPara::scrollSubstringTo( sal_Int32, sal_Int32, AccessibleScrollType )
2077 sal_Bool SAL_CALL AccessibleEditableTextPara::cutText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
2088 "AccessibleEditableTextPara::cutText: index value overflow");
2090 CheckRange(nStartIndex, nEndIndex);
2093 sal_Int32 nBulletLen = 0;
2094 EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo(GetParagraphIndex());
2096 nBulletLen = aBulletInfo.
aText.getLength();
2106 return rCacheVF.
Cut();
2108 catch (
const uno::RuntimeException&)
2114 sal_Bool SAL_CALL AccessibleEditableTextPara::pasteText( sal_Int32 nIndex )
2125 "AccessibleEditableTextPara::pasteText: index value overflow");
2127 CheckPosition(nIndex);
2130 sal_Int32 nBulletLen = 0;
2131 EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo(GetParagraphIndex());
2133 nBulletLen = aBulletInfo.
aText.getLength();
2139 rCacheVF.
SetSelection( MakeCursor(nIndex + nBulletLen) );
2141 return rCacheVF.
Paste();
2143 catch (
const uno::RuntimeException&)
2149 sal_Bool SAL_CALL AccessibleEditableTextPara::deleteText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
2158 GetEditViewForwarder(
true );
2162 "AccessibleEditableTextPara::deleteText: index value overflow");
2164 CheckRange(nStartIndex, nEndIndex);
2167 sal_Int32 nBulletLen = 0;
2168 EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo(GetParagraphIndex());
2170 nBulletLen = aBulletInfo.
aText.getLength();
2178 bool bRet = rCacheTF.
Delete( aSelection );
2180 GetEditSource().UpdateData();
2184 catch (
const uno::RuntimeException&)
2190 sal_Bool SAL_CALL AccessibleEditableTextPara::insertText(
const OUString& sText, sal_Int32 nIndex )
2199 GetEditViewForwarder(
true );
2203 "AccessibleEditableTextPara::insertText: index value overflow");
2205 CheckPosition(nIndex);
2208 sal_Int32 nBulletLen = 0;
2209 EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo(GetParagraphIndex());
2211 nBulletLen = aBulletInfo.
aText.getLength();
2217 bool bRet = rCacheTF.
InsertText( sText, MakeCursor(nIndex + nBulletLen) );
2220 GetEditSource().UpdateData();
2224 catch (
const uno::RuntimeException&)
2230 sal_Bool SAL_CALL AccessibleEditableTextPara::replaceText( sal_Int32 nStartIndex, sal_Int32 nEndIndex,
const OUString& sReplacement )
2239 GetEditViewForwarder(
true );
2243 "AccessibleEditableTextPara::replaceText: index value overflow");
2245 CheckRange(nStartIndex, nEndIndex);
2248 sal_Int32 nBulletLen = 0;
2249 EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo(GetParagraphIndex());
2251 nBulletLen = aBulletInfo.
aText.getLength();
2260 bool bRet = rCacheTF.
InsertText( sReplacement, aSelection );
2263 GetEditSource().UpdateData();
2267 catch (
const uno::RuntimeException&)
2273 sal_Bool SAL_CALL AccessibleEditableTextPara::setAttributes( sal_Int32 nStartIndex, sal_Int32 nEndIndex,
const uno::Sequence< beans::PropertyValue >& aAttributeSet )
2282 GetEditViewForwarder(
true );
2284 sal_Int32 nPara = GetParagraphIndex();
2287 "AccessibleEditableTextPara::setAttributes: index value overflow");
2289 CheckRange(nStartIndex, nEndIndex);
2302 xPropSet->SetSelection(
MakeSelection(nStartIndex, nEndIndex) );
2305 for(
const beans::PropertyValue& rProp : aAttributeSet)
2309 xPropSet->setPropertyValue(rProp.Name, rProp.Value);
2311 catch (
const uno::Exception&)
2313 TOOLS_WARN_EXCEPTION(
"dbaccess",
"AccessibleEditableTextPara::setAttributes exception in setPropertyValue");
2318 GetEditSource().UpdateData();
2322 catch (
const uno::RuntimeException&)
2328 sal_Bool SAL_CALL AccessibleEditableTextPara::setText(
const OUString& sText )
2333 return replaceText(0, getCharacterCount(), sText);
2337 uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getDefaultAttributes(
2338 const uno::Sequence< OUString >& rRequestedAttributes )
2345 "AccessibleEditableTextPara::getCharacterAttributes: index value overflow");
2352 uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
2353 if (!xPropSetInfo.is())
2354 throw uno::RuntimeException(
"Cannot query XPropertySetInfo",
2355 uno::Reference< uno::XInterface >
2356 (
static_cast< XAccessible*
> (
this) ) );
2360 if (
const sal_Int32 nLenReqAttr = rRequestedAttributes.getLength())
2363 beans::Property *pProperties =
aProperties.getArray();
2364 sal_Int32 nCurLen = 0;
2365 for (
const OUString& rRequestedAttribute : rRequestedAttributes)
2367 beans::Property aProp;
2370 aProp = xPropSetInfo->getPropertyByName( rRequestedAttribute );
2372 catch (
const beans::UnknownPropertyException&)
2376 pProperties[ nCurLen++ ] = aProp;
2384 uno::Sequence< beans::PropertyValue > aOutSequence(
aProperties.getLength() );
2385 beans::PropertyValue* pOutSequence = aOutSequence.getArray();
2386 sal_Int32 nOutLen = 0;
2387 for (
const beans::Property& rProperty : std::as_const(aProperties))
2392 PropertyState eState = xPropSet->_getPropertyState( rProperty.Name, mnParagraphIndex );
2393 if ( eState == PropertyState_AMBIGUOUS_VALUE )
2395 OSL_FAIL(
"ambiguous property value encountered" );
2403 pOutSequence->Name = rProperty.Name;
2404 pOutSequence->Handle = rProperty.Handle;
2405 pOutSequence->Value = xPropSet->_getPropertyValue( rProperty.Name, mnParagraphIndex );
2406 pOutSequence->State = PropertyState_DEFAULT_VALUE;
2412 aOutSequence.realloc( nOutLen );
2414 return aOutSequence;
2418 uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getRunAttributes(
2420 const uno::Sequence< OUString >& rRequestedAttributes )
2428 "AccessibleEditableTextPara::getCharacterAttributes: index value overflow");
2430 if( getCharacterCount() > 0 )
2433 CheckPosition(nIndex);
2438 uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
2439 if (!xPropSetInfo.is())
2440 throw uno::RuntimeException(
"Cannot query XPropertySetInfo",
2441 uno::Reference< uno::XInterface >
2442 (
static_cast< XAccessible*
> (
this) ) );
2446 if (
const sal_Int32 nLenReqAttr = rRequestedAttributes.getLength())
2449 beans::Property *pProperties =
aProperties.getArray();
2450 sal_Int32 nCurLen = 0;
2451 for (
const OUString& rRequestedAttribute : rRequestedAttributes)
2453 beans::Property aProp;
2456 aProp = xPropSetInfo->getPropertyByName( rRequestedAttribute );
2458 catch (
const beans::UnknownPropertyException&)
2462 pProperties[ nCurLen++ ] = aProp;
2470 uno::Sequence< beans::PropertyValue > aOutSequence(
aProperties.getLength() );
2471 beans::PropertyValue* pOutSequence = aOutSequence.getArray();
2472 sal_Int32 nOutLen = 0;
2473 for (
const beans::Property& rProperty : std::as_const(aProperties))
2476 PropertyState eState = xPropSet->getPropertyState( rProperty.Name );
2477 if (eState == PropertyState_DIRECT_VALUE)
2479 pOutSequence->Name = rProperty.Name;
2480 pOutSequence->Handle = rProperty.Handle;
2481 pOutSequence->Value = xPropSet->getPropertyValue( rProperty.Name );
2482 pOutSequence->State = eState;
2488 aOutSequence.realloc( nOutLen );
2490 return aOutSequence;
2494 ::sal_Int32 SAL_CALL AccessibleEditableTextPara::getHyperLinkCount( )
2497 const sal_Int32 nPara = GetParagraphIndex();
2499 sal_Int32 nHyperLinks = 0;
2501 for (sal_Int32 n = 0;
n < nFields; ++
n)
2510 css::uno::Reference< css::accessibility::XAccessibleHyperlink > SAL_CALL AccessibleEditableTextPara::getHyperLink( ::sal_Int32 nLinkIndex )
2512 css::uno::Reference< css::accessibility::XAccessibleHyperlink > xRef;
2515 const sal_Int32 nPara = GetParagraphIndex();
2517 sal_Int32 nHyperLink = 0;
2519 for (sal_Int32 n = 0;
n < nFields; ++
n)
2524 if ( nHyperLink == nLinkIndex )
2530 sal_Int32 nEnd = nStart + aField.
aCurrentText.getLength();
2541 ::sal_Int32 SAL_CALL AccessibleEditableTextPara::getHyperLinkIndex( ::sal_Int32 nCharIndex )
2543 const sal_Int32 nPara = GetParagraphIndex();
2547 sal_Int32 nHLIndex = -1;
2548 sal_Int32 nHyperLink = 0;
2550 for (sal_Int32 n = 0;
n < nFields; ++
n)
2557 nHLIndex = nHyperLink;
2568 sal_Int32 SAL_CALL AccessibleEditableTextPara::getLineNumberAtIndex( sal_Int32 nIndex )
2571 sal_Int32 nRes = -1;
2572 sal_Int32 nPara = GetParagraphIndex();
2576 DBG_ASSERT( bValidPara,
"getLineNumberAtIndex: current paragraph index out of range" );
2580 if (0 > nIndex || nIndex > rCacheTF.
GetTextLen( nPara ))
2581 throw lang::IndexOutOfBoundsException();
2588 css::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineNumber( sal_Int32 nLineNo )
2591 css::accessibility::TextSegment aResult;
2592 sal_Int32 nPara = GetParagraphIndex();
2595 DBG_ASSERT( bValidPara,
"getTextAtLineNumber: current paragraph index out of range" );
2598 if (0 > nLineNo || nLineNo >= rCacheTF.
GetLineCount( nPara ))
2599 throw lang::IndexOutOfBoundsException();
2600 sal_Int32 nStart = 0, nEnd = 0;
2602 if (nStart >= 0 && nEnd >= 0)
2606 aResult.SegmentText = getTextRange( nStart, nEnd );
2607 aResult.SegmentStart = nStart;
2608 aResult.SegmentEnd = nEnd;
2610 catch (
const lang::IndexOutOfBoundsException&)
2621 css::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineWithCaret( )
2624 css::accessibility::TextSegment aResult;
2627 aResult = getTextAtLineNumber( getNumberOfLineWithCaret() );
2629 catch (
const lang::IndexOutOfBoundsException&)
2637 sal_Int32 SAL_CALL AccessibleEditableTextPara::getNumberOfLineWithCaret( )
2640 sal_Int32 nRes = -1;
2643 nRes = getLineNumberAtIndex( getCaretPosition() );
2645 catch (
const lang::IndexOutOfBoundsException&)
2654 OUString SAL_CALL AccessibleEditableTextPara::getImplementationName()
2657 return "AccessibleEditableTextPara";
2660 sal_Bool SAL_CALL AccessibleEditableTextPara::supportsService (
const OUString& sServiceName)
2666 uno::Sequence< OUString> SAL_CALL AccessibleEditableTextPara::getSupportedServiceNames()
2669 return { OUString(
"com.sun.star.text.AccessibleParagraphView") };
const PropertyValue * pValues
PropertiesInfo aProperties
unotools::WeakReference< AnimationNode > mxParent
static const AllSettings & GetSettings()
static SfxItemPool & GetGlobalItemPool()
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
constexpr tools::Long Y() const
constexpr tools::Long X() const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
virtual bool QuickFormatDoc(bool bFull=false) override
Updates the formatting.
virtual bool Delete(const ESelection &) override
Delete given text range and reformat text.
virtual sal_Int32 GetTextLen(sal_Int32 nParagraph) const override
virtual sal_Int32 GetFieldCount(sal_Int32 nPara) const override
Query number of fields in the underlying edit engine.
virtual EBulletInfo GetBulletInfo(sal_Int32 nPara) const override
Query information regarding bullets for given paragraph on the underlying edit engine.
bool IsEditable(const ESelection &rSelection) const
Query whether all text in given selection is editable.
sal_Int32 CalcEditEngineIndex(sal_Int32 nPara, sal_Int32 nLogicalIndex)
virtual bool InsertText(const OUString &, const ESelection &) override
Insert/Replace given text in given range and reformat text.
virtual bool IsValid() const override
Query state of forwarder.
virtual EFieldInfo GetFieldInfo(sal_Int32 nPara, sal_uInt16 nField) const override
Query information for given field number in the underlying edit engine.
virtual bool IsValid() const override
Query state of forwarder.
Wraps SvxUnoTextRangeBase and provides us with the text properties.
SvxDateType GetType() const
Wrapper class for unified EditEngine/Outliner access.
virtual SvxEditViewForwarder * GetEditViewForwarder(bool bCreate=false)
Query the edit view forwarder.
virtual SvxViewForwarder * GetViewForwarder()
Query the view forwarder.
Encapsulates EditView and OutlinerView for the purpose of unified EditEngine/Outliner access.
virtual bool Copy()=0
Copy current selection to clipboard.
virtual bool SetSelection(const ESelection &rSelection)=0
Set selection in view.
virtual bool Paste()=0
Paste clipboard into current selection.
virtual bool GetSelection(ESelection &rSelection) const =0
Query current selection.
virtual bool Cut()=0
Cut current selection to clipboard.
SvxTimeType GetType() const
This item stores a field (SvxFieldData).
Contains an EditEngine or an Outliner and unifies access to them.
virtual MapMode GetMapMode() const =0
Query the map mode of the underlying EditEngine/Outliner.
virtual SfxItemSet GetParaAttribs(sal_Int32 nPara) const =0
virtual EBulletInfo GetBulletInfo(sal_Int32 nPara) const =0
Query information regarding bullets for given paragraph on the underlying edit engine.
virtual tools::Rectangle GetParaBounds(sal_Int32 nPara) const =0
Query the bounding rectangle of the given paragraph.
virtual tools::Rectangle GetCharBounds(sal_Int32 nPara, sal_Int32 nIndex) const =0
Query the bounding rectangle of the given character.
virtual sal_Int32 GetTextLen(sal_Int32 nParagraph) const =0
virtual sal_Int32 GetLineCount(sal_Int32 nPara) const =0
Query number of lines in the formatted paragraph.
virtual bool GetIndexAtPoint(const Point &rPoint, sal_Int32 &rPara, sal_Int32 &rIndex) const =0
Query paragraph and character index of the character at the given point.
virtual void GetLineBoundaries(sal_Int32 &rStart, sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine) const =0
Query bounds of line in paragraph.
virtual sal_Int32 GetParagraphCount() const =0
virtual sal_Int32 GetLineLen(sal_Int32 nPara, sal_Int32 nLine) const =0
Query line length.
virtual sal_Int32 GetLineNumberAtIndex(sal_Int32 nPara, sal_Int32 nIndex) const =0
Query the line number for an index in the paragraphs text.
Encapsulates the document view for the purpose of unified EditEngine/Outliner access.
virtual Point LogicToPixel(const Point &rPoint, const MapMode &rMapMode) const =0
Convert from logical, EditEngine-relative coordinates to screen coordinates.
virtual bool IsValid() const =0
Query state of forwarder.
static sal_Int32 addEventListener(const TClientId _nClient, const css::uno::Reference< css::accessibility::XAccessibleEventListener > &_rxListener)
static void addEvent(const TClientId _nClient, const css::accessibility::AccessibleEventObject &_rEvent)
static sal_Int32 removeEventListener(const TClientId _nClient, const css::uno::Reference< css::accessibility::XAccessibleEventListener > &_rxListener)
static void revokeClient(const TClientId _nClient)
static void revokeClientNotifyDisposing(const TClientId _nClient, const css::uno::Reference< css::uno::XInterface > &_rxEventSource)
css::uno::Type const & get()
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
#define EE_PARA_NOT_FOUND
constexpr TypedWhichId< SfxBoolItem > EE_PARA_BULLETSTATE(EE_PARA_START+9)
constexpr TypedWhichId< SvXMLAttrContainerItem > EE_PARA_XMLATTRIBS(EE_PARA_START+1)
constexpr TypedWhichId< SvXMLAttrContainerItem > EE_CHAR_XMLATTRIBS(EE_CHAR_START+28)
constexpr TypedWhichId< SvxNumBulletItem > EE_PARA_NUMBULLET(EE_PARA_START+5)
OUString EditResId(TranslateId aId)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
SwNumRule * GetNumRule(SwTextFormatColl &rTextFormatColl)
static ESelection MakeSelection(sal_Int32 nStartPara, sal_Int32 nStartIndex, sal_Int32 nEndPara, sal_Int32 nEndIndex)
static uno::Sequence< OUString > const & getAttributeNames()
static const SvxItemPropertySet * ImplGetSvxCharAndParaPropertiesSet()
void Dispose(const T &xInterface)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
std::unique_ptr< SvxFieldItem > pFieldItem
sal_Int16 mnParagraphIndex
const SvxItemPropertySet * ImplGetSvxTextPortionSvxPropertySet()
const SvxItemPropertySet * ImplGetSvxUnoOutlinerTextCursorSvxPropertySet()
void GetSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder) noexcept
#define SVX_UNOEDIT_OUTLINER_PROPERTIES
#define SVX_UNOEDIT_CHAR_PROPERTIES
#define SVX_UNOEDIT_NUMBERING_PROPERTY
#define SVX_UNOEDIT_PARA_PROPERTIES