[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - accessibility/source include/vcl vcl/source
Tamás Zolnai
tamas.zolnai at collabora.com
Sat Dec 10 20:35:11 UTC 2016
accessibility/source/standard/vclxaccessibleedit.cxx | 15 ++++++++++++++
include/vcl/texteng.hxx | 2 +
vcl/source/edit/texteng.cxx | 20 +++++++++++++++++++
3 files changed, 37 insertions(+)
New commits:
commit b88a5657a95e1b94498ed238e2b4e0fb0418d40b
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date: Sat Dec 10 11:23:38 2016 +0000
tdf#93430: Return the right offsets for runs
MultiLineEdit is a special control which can have
more text portions with different text attributes.
Change-Id: Iab51dba0d0344fad4358f4961c968c031b1660b6
Reviewed-on: https://gerrit.libreoffice.org/31813
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 8d52045853cecb716138d51b8b6ad0272a86af86)
Reviewed-on: https://gerrit.libreoffice.org/31832
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
diff --git a/accessibility/source/standard/vclxaccessibleedit.cxx b/accessibility/source/standard/vclxaccessibleedit.cxx
index 750ce0a..2eff38f 100644
--- a/accessibility/source/standard/vclxaccessibleedit.cxx
+++ b/accessibility/source/standard/vclxaccessibleedit.cxx
@@ -30,6 +30,7 @@
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/accessibility/AccessibleRole.hpp>
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/accessibility/AccessibleTextType.hpp>
#include <cppuhelper/typeprovider.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/string.hxx>
@@ -475,6 +476,20 @@ css::accessibility::TextSegment VCLXAccessibleEdit::getTextAtIndex( sal_Int32 nI
{
OExternalLockGuard aGuard( this );
+ // Override general text component behavior: MultiLineEdit can have more text portions
+ if ( aTextType == AccessibleTextType::ATTRIBUTE_RUN )
+ {
+ VclPtr<VclMultiLineEdit> pMulitLineEdit = GetAsDynamic< VclMultiLineEdit >();
+ if ( pMulitLineEdit )
+ {
+ ExtTextEngine* pTextEngine = pMulitLineEdit->GetTextEngine();
+ TextPaM aCursor( 0, nIndex );
+ TextSegment aResult;
+ pTextEngine->GetTextPortionRange( aCursor, aResult.SegmentStart, aResult.SegmentEnd );
+ return aResult;
+ }
+ }
+
return VCLXAccessibleTextComponent::getTextAtIndex( nIndex, aTextType );
}
diff --git a/include/vcl/texteng.hxx b/include/vcl/texteng.hxx
index 96ac426..4c6c3df 100644
--- a/include/vcl/texteng.hxx
+++ b/include/vcl/texteng.hxx
@@ -257,6 +257,8 @@ public:
sal_Int32 GetTextLen( sal_uInt32 nParagraph ) const;
long GetTextHeight( sal_uInt32 nParagraph ) const;
+ void GetTextPortionRange(const TextPaM& rPaM, sal_Int32& nStart, sal_Int32& nEnd);
+
sal_uInt16 GetLineCount( sal_uInt32 nParagraph ) const;
sal_Int32 GetLineLen( sal_uInt32 nParagraph, sal_uInt16 nLine ) const;
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index f91e69d..3ac06dd 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -1212,6 +1212,26 @@ long TextEngine::CalcTextWidth( sal_uInt32 nPara, sal_Int32 nPortionStart, sal_I
return nWidth;
}
+void TextEngine::GetTextPortionRange(const TextPaM& rPaM, sal_Int32& nStart, sal_Int32& nEnd)
+{
+ nStart = 0;
+ nEnd = 0;
+ TEParaPortion* pParaPortion = mpTEParaPortions->GetObject( rPaM.GetPara() );
+ for ( size_t i = 0; i < pParaPortion->GetTextPortions().size(); ++i )
+ {
+ TETextPortion* pTextPortion = pParaPortion->GetTextPortions()[ i ];
+ if (nStart + pTextPortion->GetLen() > rPaM.GetIndex())
+ {
+ nEnd = nStart + pTextPortion->GetLen();
+ return;
+ }
+ else
+ {
+ nStart += pTextPortion->GetLen();
+ }
+ }
+}
+
sal_uInt16 TextEngine::GetLineCount( sal_uInt32 nParagraph ) const
{
SAL_WARN_IF( nParagraph >= mpTEParaPortions->Count(), "vcl", "GetLineCount: Out of range" );
More information about the Libreoffice-commits
mailing list