sd/source/console/AccessibleObject.hxx    |    2 +-
 sd/source/console/AccessibleParagraph.cxx |   27 ++-------------------------
 sd/source/console/AccessibleParagraph.hxx |    1 -
 sd/source/console/PresenterTextView.cxx   |    6 +++++-
 4 files changed, 8 insertions(+), 28 deletions(-)

New commits:
commit 440b37e3bdb59c173ca753bc9bd18a86797939b1
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Feb 27 17:06:53 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Feb 27 23:01:42 2025 +0100

    sd presenter a11y: Fix parent-relative paragraph position
    
    AccessibleParagraph used to override both,
    AccessibleObject::GetRelativeLocation
    and AccessibleObject::GetAbsoluteParentLocation.
    
    What was odd is that AccessibleParagraph::GetAbsoluteParentLocation
    was not returning the absolute location of the actual parent,
    but of the grandparent (parent's parent), because
    AccessibleObject::GetRelativeLocation didn't actually
    return the position relative to the direct parent, but to the
    grandparent as well.
    
    While this evens out in AccessibleObject::getLocationOnScreen
    where both of these are called, it doesn't in
    AccessibleObject::getLocation where only
    AccessibleObject::GetRelativeLocation gets called.
    
    Adjust the logic to let AccessibleObject::GetRelativeLocation
    return the paragraph's relative location without adding to
    that.
    
    This allows to drop AccessibleParagraph::GetAbsoluteParentLocation
    altogether because the base class implementation can be used as
    is now.
    
    Without this commit, the incorrect area would be highlighted
    by Accerciser when using the gtk3 VCL plugin and the scenario
    decribed in previous commit
    
        Change-Id: I74660a07e5660a0f1ac0cd17eff793e4e4a8979b
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Thu Feb 27 17:00:44 2025 +0100
    
            sd presenter a11y: Avoid invalid string index
    
    . With this commit in place, the correct area is highlighted
    on screen now.
    
    Change-Id: I1481cbb03e99b6f89c5222ed260477004a9db62c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182327
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/sd/source/console/AccessibleObject.hxx 
b/sd/source/console/AccessibleObject.hxx
index 0962f9c178e0..62d4c2b23874 100644
--- a/sd/source/console/AccessibleObject.hxx
+++ b/sd/source/console/AccessibleObject.hxx
@@ -161,7 +161,7 @@ protected:
 
     virtual awt::Point GetRelativeLocation();
     virtual awt::Size GetSize();
-    virtual awt::Point GetAbsoluteParentLocation();
+    awt::Point GetAbsoluteParentLocation();
 
     virtual bool GetWindowState (const sal_Int64 nType) const;
 
diff --git a/sd/source/console/AccessibleParagraph.cxx 
b/sd/source/console/AccessibleParagraph.cxx
index a4530e6abfd2..ba8ae57c9818 100644
--- a/sd/source/console/AccessibleParagraph.cxx
+++ b/sd/source/console/AccessibleParagraph.cxx
@@ -374,15 +374,10 @@ sal_Bool SAL_CALL AccessibleParagraph::scrollSubstringTo(
 
 awt::Point AccessibleParagraph::GetRelativeLocation()
 {
-    awt::Point aLocation (AccessibleObject::GetRelativeLocation());
     if (mpParagraph)
-    {
-        const awt::Point aParagraphLocation 
(mpParagraph->GetRelativeLocation());
-        aLocation.X += aParagraphLocation.X;
-        aLocation.Y += aParagraphLocation.Y;
-    }
+        return mpParagraph->GetRelativeLocation();
 
-    return aLocation;
+    return css::awt::Point(0, 0);
 }
 
 awt::Size AccessibleParagraph::GetSize()
@@ -393,24 +388,6 @@ awt::Size AccessibleParagraph::GetSize()
         return AccessibleObject::GetSize();
 }
 
-awt::Point AccessibleParagraph::GetAbsoluteParentLocation()
-{
-    if (mxParentAccessible.is())
-    {
-        Reference<XAccessibleContext> xParentContext =
-            mxParentAccessible->getAccessibleContext();
-        if (xParentContext.is())
-        {
-            Reference<XAccessibleComponent> xGrandParentComponent(
-                xParentContext->getAccessibleParent(), UNO_QUERY);
-            if (xGrandParentComponent.is())
-                return xGrandParentComponent->getLocationOnScreen();
-        }
-    }
-
-    return awt::Point();
-}
-
 bool AccessibleParagraph::GetWindowState (const sal_Int64 nType) const
 {
     switch (nType)
diff --git a/sd/source/console/AccessibleParagraph.hxx 
b/sd/source/console/AccessibleParagraph.hxx
index 68f15ced325f..916fa0a9a8ec 100644
--- a/sd/source/console/AccessibleParagraph.hxx
+++ b/sd/source/console/AccessibleParagraph.hxx
@@ -108,7 +108,6 @@ public:
 protected:
     virtual awt::Point GetRelativeLocation() override;
     virtual awt::Size GetSize() override;
-    virtual awt::Point GetAbsoluteParentLocation() override;
     virtual bool GetWindowState (const sal_Int64 nType) const override;
 
 private:
commit 477cf1ebcac5ed97c5118350a15ae6d624af6a7a
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Feb 27 17:00:44 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Feb 27 23:01:35 2025 +0100

    sd presenter a11y: Avoid invalid string index
    
    In PresenterTextParagraph::GetTextSegment, only
    use start index + 1 for the end index if the text
    has at least that many characters.
    
    This fixes an assert with the below backtrace for the following
    case:
    
    1) start Impress with the gtk3 VCL plugin, in a dual screen setup
    2) add notes for the first slide via "View" -> "Notes"
    3) make sure Presenter Console is enabled in "Slide Show" -> "Slide Show
       Settings"
    4) Start slide show (F5)
    5) start Accerciser
    6) in Accerciser's treeview of the LO a11y hierarchy, navigate to
       the first paragraph object in the slide notes object
    
    Backtrace of the assert:
    
        1  __pthread_kill_implementation                                        
pthread_kill.c          44   0x7ffff789ddcc
        2  __pthread_kill_internal                                              
pthread_kill.c          78   0x7ffff789de2f
        3  __GI_raise                                                           
raise.c                 26   0x7ffff7849d02
        4  __GI_abort                                                           
abort.c                 79   0x7ffff78324f0
        5  __assert_fail_base                                                   
assert.c                96   0x7ffff7832418
        6  __assert_fail                                                        
assert.c                105  0x7ffff7842612
        7  rtl::str::newFromSubString<_rtl_uString>                             
strtmpl.hxx             890  0x7ffff7f4ca59
        8  rtl_uString_newFromSubString                                         
ustring.cxx             1152 0x7ffff7f471c9
        9  rtl::OUString::copy                                                  
ustring.hxx             2578 0x7fff9cbec4fc
        10 sdext::presenter::PresenterTextParagraph::CreateTextSegment          
PresenterTextView.cxx   868  0x7fff9cd037ad
        11 sdext::presenter::PresenterTextParagraph::GetTextSegment             
PresenterTextView.cxx   806  0x7fff9cd030d3
        12 AccessibleParagraph::getTextAtIndex                                  
AccessibleParagraph.cxx 322  0x7fff9cc43c88
        13 non-virtual thunk to AccessibleParagraph::getTextAtIndex(int, short) 
                             0x7fff9cc43d4b
        14 text_wrapper_get_run_attributes                                      
atktext.cxx             538  0x7fffe4450b7f
        15 atk_text_get_run_attributes                                          
                             0x7fffe7045b5e
        16 ??                                                                   
                             0x7fffe3700805
        17 ??                                                                   
                             0x7fffe37034ed
        18 ??                                                                   
                             0x7ffff77dc024
        19 dbus_connection_dispatch                                             
                             0x7ffff77cb8fb
        20 ??                                                                   
                             0x7fffe359eb79
        21 ??                                                                   
                             0x7fffea103d5f
        22 ??                                                                   
                             0x7fffea105fd7
        23 g_main_context_iteration                                             
                             0x7fffea106740
        24 GtkSalData::Yield                                                    
gtkdata.cxx             405  0x7fffe4483dac
        25 GtkInstance::DoYield                                                 
gtkinst.cxx             439  0x7fffe4488cb3
        26 ImplYield                                                            
svapp.cxx               385  0x7fffeec7fae6
        27 Application::Yield                                                   
svapp.cxx               488  0x7fffeec7f3ff
        28 Application::Execute                                                 
svapp.cxx               360  0x7fffeec7f1e0
        29 desktop::Desktop::Main                                               
app.cxx                 1680 0x7ffff7b25bd9
        30 ImplSVMain                                                           
svmain.cxx              230  0x7fffeeca0fb6
        31 SVMain                                                               
svmain.cxx              248  0x7fffeeca2ba9
        32 soffice_main                                                         
sofficemain.cxx         122  0x7ffff7b9f4ba
        33 sal_main                                                             
main.c                  51   0x555555555a6d
        34 main                                                                 
main.c                  49   0x555555555a47
    
    Change-Id: I74660a07e5660a0f1ac0cd17eff793e4e4a8979b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182326
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/sd/source/console/PresenterTextView.cxx 
b/sd/source/console/PresenterTextView.cxx
index bf88685744c7..24df805dc0c8 100644
--- a/sd/source/console/PresenterTextView.cxx
+++ b/sd/source/console/PresenterTextView.cxx
@@ -803,7 +803,11 @@ TextSegment PresenterTextParagraph::GetTextSegment (
         case AccessibleTextType::CHARACTER:
         case AccessibleTextType::GLYPH:
         case AccessibleTextType::ATTRIBUTE_RUN:
-            return CreateTextSegment(nIndex+nOffset, nIndex+nOffset+1);
+        {
+            const sal_Int32 nStartIndex = nIndex + nOffset;
+            const sal_Int32 nEndIndex = nStartIndex < GetCharacterCount() ? 
nStartIndex + 1 : nStartIndex;
+            return CreateTextSegment(nStartIndex, nEndIndex);
+        }
     }
 
     return TextSegment(OUString(), 0,0);

Reply via email to