summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <zolnaitamas2000@gmail.com>2016-12-04 00:03:24 +0000
committerTamás Zolnai <tamas.zolnai@collabora.com>2016-12-09 15:57:22 +0000
commitb815cdf1933813a6864350ea1baade0bccee9ec4 (patch)
tree5b8dd5ac71841c69f1a11af07681e39cc1436bbd
parent653535729c9690d6d5e05e4e829e917072840e40 (diff)
tdf#93430: Cannot get accessible text attributes for 'Not in dictionary' entry
Squashed from two commits: tdf#93430: Get run attributes of text objects .. which are not paragraphs. Note: For some reason in character attributes sequence we have a wrong Any value for "CharPosture" property. Signed-off-by: Tamás Zolnai <tamas.zolnai@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/31591 (cherry picked from commit 17773e1a8dd6e97f57db111819338c418f819cef) tdf#93430: Cannot get accessible text attributes for 'Not in dictionary' entry Reviewed-on: https://gerrit.libreoffice.org/31778 Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com> (cherry picked from commit e0d8c3821b8fa1e7d00f7b4a7d007f9cb5c592a5) Change-Id: Ia45526c01cc381d3d6a1b56dbf4f03fdd38a0989 aa2b4fdb582025b763d43f0f24960e2ccee708e3 Reviewed-on: https://gerrit.libreoffice.org/31792 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
-rw-r--r--accessibility/source/standard/vclxaccessibleedit.cxx44
-rw-r--r--include/vcl/vclmedit.hxx2
-rw-r--r--vcl/unx/gtk/a11y/atktext.cxx18
-rw-r--r--vcl/unx/gtk/a11y/atktextattributes.cxx6
4 files changed, 63 insertions, 7 deletions
diff --git a/accessibility/source/standard/vclxaccessibleedit.cxx b/accessibility/source/standard/vclxaccessibleedit.cxx
index 432315a35aea..750ce0afb337 100644
--- a/accessibility/source/standard/vclxaccessibleedit.cxx
+++ b/accessibility/source/standard/vclxaccessibleedit.cxx
@@ -36,6 +36,10 @@
#include <vcl/svapp.hxx>
#include <vcl/window.hxx>
#include <vcl/edit.hxx>
+#include <vcl/vclmedit.hxx>
+#include <vcl/textdata.hxx>
+#include <vcl/txtattr.hxx>
+#include <vcl/xtextedt.hxx>
#include <sot/exchange.hxx>
#include <sot/formats.hxx>
@@ -304,8 +308,46 @@ sal_Unicode VCLXAccessibleEdit::getCharacter( sal_Int32 nIndex ) throw (IndexOut
Sequence< PropertyValue > VCLXAccessibleEdit::getCharacterAttributes( sal_Int32 nIndex, const Sequence< OUString >& aRequestedAttributes ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
{
OExternalLockGuard aGuard( this );
+ Sequence< PropertyValue > aProperties = VCLXAccessibleTextComponent::getCharacterAttributes( nIndex, aRequestedAttributes );
- return VCLXAccessibleTextComponent::getCharacterAttributes( nIndex, aRequestedAttributes );
+ // Handle multiline edit character properties
+ VclPtr<VclMultiLineEdit> pMulitLineEdit = GetAsDynamic< VclMultiLineEdit >();
+ if ( pMulitLineEdit )
+ {
+ ExtTextEngine* pTextEngine = pMulitLineEdit->GetTextEngine();
+ TextPaM aCursor( 0, nIndex );
+ const TextAttribFontColor* pFontColor = static_cast<const TextAttribFontColor* >(pTextEngine->FindAttrib( aCursor, TEXTATTR_FONTCOLOR ));
+ if ( pFontColor )
+ {
+ for (PropertyValue& aValue : aProperties )
+ {
+ if (aValue.Name == "CharColor")
+ {
+ aValue.Value = css::uno::makeAny(static_cast< sal_Int32 >(COLORDATA_RGB(pFontColor->GetColor().GetColor())));
+ break;
+ }
+ }
+ }
+ }
+
+ // Set default character color if it is not set yet to a valid value
+ for (PropertyValue& aValue : aProperties )
+ {
+ if (aValue.Name == "CharColor")
+ {
+ if ( aValue.Value == sal_Int32(-1) )
+ {
+ OutputDevice* pDev = Application::GetDefaultDevice();
+ if ( pDev )
+ {
+ aValue.Value = css::uno::makeAny(static_cast< sal_Int32 >(pDev->GetSettings().GetStyleSettings().GetFieldTextColor().GetColor()));
+ }
+ }
+ break;
+ }
+ }
+
+ return aProperties;
}
diff --git a/include/vcl/vclmedit.hxx b/include/vcl/vclmedit.hxx
index 84b5a6bea56c..8461413eec89 100644
--- a/include/vcl/vclmedit.hxx
+++ b/include/vcl/vclmedit.hxx
@@ -32,6 +32,8 @@ class TextView;
class VCL_DLLPUBLIC VclMultiLineEdit : public Edit
{
+ friend class VCLXAccessibleEdit;
+
private:
ImpVclMEdit* pImpVclMEdit;
diff --git a/vcl/unx/gtk/a11y/atktext.cxx b/vcl/unx/gtk/a11y/atktext.cxx
index 14cf91606d87..fbfd0fb41e11 100644
--- a/vcl/unx/gtk/a11y/atktext.cxx
+++ b/vcl/unx/gtk/a11y/atktext.cxx
@@ -482,12 +482,20 @@ text_wrapper_get_run_attributes( AtkText *text,
css::uno::Reference<css::accessibility::XAccessibleText> pText
= getText( text );
- css::uno::Reference<css::accessibility::XAccessibleTextAttributes>
- pTextAttributes = getTextAttributes( text );
- if( pText.is() && pTextAttributes.is() )
+ if( pText.is())
{
- uno::Sequence< beans::PropertyValue > aAttributeList =
- pTextAttributes->getRunAttributes( offset, uno::Sequence< OUString > () );
+ uno::Sequence< beans::PropertyValue > aAttributeList;
+
+ css::uno::Reference<css::accessibility::XAccessibleTextAttributes>
+ pTextAttributes = getTextAttributes( text );
+ if(pTextAttributes.is()) // Text attributes are available for paragraphs only
+ {
+ aAttributeList = pTextAttributes->getRunAttributes( offset, uno::Sequence< OUString > () );
+ }
+ else // For other text objects use character attributes
+ {
+ aAttributeList = pText->getCharacterAttributes( offset, uno::Sequence< OUString > () );
+ }
pSet = attribute_set_new_from_property_values( aAttributeList, true, text );
// #i100938#
diff --git a/vcl/unx/gtk/a11y/atktextattributes.cxx b/vcl/unx/gtk/a11y/atktextattributes.cxx
index 0620be4af6af..c31fccdbeebf 100644
--- a/vcl/unx/gtk/a11y/atktextattributes.cxx
+++ b/vcl/unx/gtk/a11y/atktextattributes.cxx
@@ -298,7 +298,11 @@ FontSlant2Style(const uno::Any& rAny)
{
const gchar * value = nullptr;
- switch( rAny.get<awt::FontSlant>() )
+ awt::FontSlant aFontSlant;
+ if(!(rAny >>= aFontSlant))
+ return nullptr;
+
+ switch( aFontSlant )
{
case awt::FontSlant_NONE:
value = "normal";