editeng/source/uno/unoedprx.cxx                        |    7 +++++++
 editeng/source/uno/unofored.cxx                        |    6 ++++++
 editeng/source/uno/unoforou.cxx                        |    5 +++++
 editeng/source/uno/unotext.cxx                         |   13 ++++++++++++-
 include/editeng/unoedprx.hxx                           |    1 +
 include/editeng/unoedsrc.hxx                           |    3 +++
 include/editeng/unofored.hxx                           |    1 +
 include/editeng/unoforou.hxx                           |    1 +
 include/editeng/unotext.hxx                            |    1 +
 svx/source/accessibility/AccessibleEmptyEditSource.cxx |    1 +
 svx/source/dialog/weldeditview.cxx                     |    1 +
 11 files changed, 39 insertions(+), 1 deletion(-)

New commits:
commit 7e3ff600df386aa7dfbbc061c80cd932aa5c5e03
Author:     Justin Luth <[email protected]>
AuthorDate: Thu Nov 21 15:08:45 2024 -0500
Commit:     Gabor Kelemen <[email protected]>
CommitDate: Tue Jan 14 16:37:11 2025 +0100

    tdf#163598 editeng: avoid using fake outline depth
    
    Most implementations do not actually
    do anything meaningful with Get/SetDepth,
    so don't exception or accept their values.
    
    To fix the bug, I could have just checked for
    dynamic_cast<SvxEditEngineForwarder*>
    (since it supports EE_PARA_OUTLLEVEL directly)
    but this way seemed more encompassing.
    
    The potential downside is that EE_PARA_OUTLLEVEL
    will be requested as a real property
    after GetPropertyValueHelper
    with some of these dummy providers,
    and who knows what UNO might do about that...
    
    IF this patch causes problems,
    then I need to implement Get/SetDepth
    in SvxEditEngineForwarder
    (or consider the dummy providers as SupportsOutlineDepth).
    
    Change-Id: I74bf5e39a13bb1d588c39634347eb0982bda66b9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176981
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <[email protected]>
    (cherry picked from commit 0d3748e5fbfb2ac8dd60d491d566075938927237)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180023
    Tested-by: allotropia jenkins <[email protected]>
    Reviewed-by: Gabor Kelemen <[email protected]>

diff --git a/editeng/source/uno/unoedprx.cxx b/editeng/source/uno/unoedprx.cxx
index ded8eb4e742d..03801ed1577f 100644
--- a/editeng/source/uno/unoedprx.cxx
+++ b/editeng/source/uno/unoedprx.cxx
@@ -1029,6 +1029,13 @@ bool SvxAccessibleTextAdapter::QuickFormatDoc( bool 
bFull )
     return mpTextForwarder->QuickFormatDoc( bFull );
 }
 
+bool SvxAccessibleTextAdapter::SupportsOutlineDepth() const
+{
+    assert(mpTextForwarder && "SvxAccessibleTextAdapter: no forwarder");
+
+    return mpTextForwarder->SupportsOutlineDepth();
+}
+
 sal_Int16 SvxAccessibleTextAdapter::GetDepth( sal_Int32 nPara ) const
 {
     assert(mpTextForwarder && "SvxAccessibleTextAdapter: no forwarder");
diff --git a/editeng/source/uno/unofored.cxx b/editeng/source/uno/unofored.cxx
index 1b56ad1859b0..cc2d350fbec2 100644
--- a/editeng/source/uno/unofored.cxx
+++ b/editeng/source/uno/unofored.cxx
@@ -470,6 +470,12 @@ bool SvxEditEngineForwarder::InsertText( const OUString& 
rStr, const ESelection&
     return true;
 }
 
+bool SvxEditEngineForwarder::SupportsOutlineDepth() const
+{
+    // EditEngine does not support outline depth indirectly - directly 
supports EE_PARA_OUTLLEVEL
+    return false;
+}
+
 sal_Int16 SvxEditEngineForwarder::GetDepth( sal_Int32 ) const
 {
     // EditEngine does not support outline depth
diff --git a/editeng/source/uno/unoforou.cxx b/editeng/source/uno/unoforou.cxx
index 7b2f98b1ede0..14061b18a5da 100644
--- a/editeng/source/uno/unoforou.cxx
+++ b/editeng/source/uno/unoforou.cxx
@@ -436,6 +436,11 @@ bool SvxOutlinerForwarder::InsertText( const OUString& 
rStr, const ESelection& r
     return true;
 }
 
+bool SvxOutlinerForwarder::SupportsOutlineDepth() const
+{
+    return true;
+}
+
 sal_Int16 SvxOutlinerForwarder::GetDepth( sal_Int32 nPara ) const
 {
     DBG_ASSERT( 0 <= nPara && nPara < GetParagraphCount(), 
"SvxOutlinerForwarder::GetDepth: Invalid paragraph index");
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index b9af24bae93c..be990e70d3af 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -529,6 +529,9 @@ bool SvxUnoTextRangeBase::SetPropertyValueHelper( const 
SfxItemPropertyMapEntry*
             SvxTextForwarder* pForwarder = pEditSource? 
pEditSource->GetTextForwarder() : nullptr;
             if(pForwarder && pSelection)
             {
+                if (!pForwarder->SupportsOutlineDepth())
+                    return false;
+
                 sal_Int16 nLevel = sal_Int16();
                 if( aValue >>= nLevel )
                 {
@@ -714,7 +717,10 @@ bool SvxUnoTextRangeBase::GetPropertyValueHelper(  
SfxItemSet const & rSet, cons
             SvxTextForwarder* pForwarder = pEditSource? 
pEditSource->GetTextForwarder() : nullptr;
             if(pForwarder && pSelection)
             {
-                sal_Int16 nLevel = 
pForwarder->GetDepth(pSelection->start.nPara);
+                if (!pForwarder->SupportsOutlineDepth())
+                    return false;
+
+                sal_Int16 nLevel = pForwarder->GetDepth( 
pSelection->start.nPara );
                 if( nLevel >= 0 )
                     aAny <<= nLevel;
             }
@@ -2489,6 +2495,11 @@ bool SvxDummyTextSource::QuickFormatDoc( bool )
     return false;
 }
 
+bool SvxDummyTextSource::SupportsOutlineDepth() const
+{
+    return false;
+}
+
 sal_Int16 SvxDummyTextSource::GetDepth( sal_Int32 ) const
 {
     return -1;
diff --git a/include/editeng/unoedprx.hxx b/include/editeng/unoedprx.hxx
index 22b6be0c91e3..fe29d2489d69 100644
--- a/include/editeng/unoedprx.hxx
+++ b/include/editeng/unoedprx.hxx
@@ -83,6 +83,7 @@ public:
     virtual bool            Delete( const ESelection& ) override;
     virtual bool            InsertText( const OUString&, const ESelection& ) 
override;
     virtual bool            QuickFormatDoc( bool bFull = false ) override;
+    virtual bool SupportsOutlineDepth() const override;
     virtual sal_Int16       GetDepth( sal_Int32 nPara ) const override;
     virtual bool            SetDepth( sal_Int32 nPara, sal_Int16 nNewDepth ) 
override;
 
diff --git a/include/editeng/unoedsrc.hxx b/include/editeng/unoedsrc.hxx
index 1537f00a743c..0f32c606de49 100644
--- a/include/editeng/unoedsrc.hxx
+++ b/include/editeng/unoedsrc.hxx
@@ -410,6 +410,9 @@ public:
       */
     virtual bool            QuickFormatDoc( bool bFull = false ) = 0;
 
+    // Is able to use Outline depth functions (GetDepth and SetDepth) 
meaningfully
+    virtual bool SupportsOutlineDepth() const = 0;
+
     /** Get the outline depth of given paragraph
 
         @param nPara
diff --git a/include/editeng/unofored.hxx b/include/editeng/unofored.hxx
index 323095f85f0b..7045876f97f7 100644
--- a/include/editeng/unofored.hxx
+++ b/include/editeng/unofored.hxx
@@ -79,6 +79,7 @@ public:
     virtual bool            Delete( const ESelection& ) override;
     virtual bool            InsertText( const OUString&, const ESelection& ) 
override;
     virtual bool            QuickFormatDoc( bool bFull = false ) override;
+    virtual bool SupportsOutlineDepth() const override;
     virtual sal_Int16       GetDepth( sal_Int32 nPara ) const override;
     virtual bool            SetDepth( sal_Int32 nPara, sal_Int16 nNewDepth ) 
override;
 
diff --git a/include/editeng/unoforou.hxx b/include/editeng/unoforou.hxx
index 0abb982cf62d..e93114252ac2 100644
--- a/include/editeng/unoforou.hxx
+++ b/include/editeng/unoforou.hxx
@@ -99,6 +99,7 @@ public:
     virtual bool            Delete( const ESelection& ) override final;
     virtual bool            InsertText( const OUString&, const ESelection& ) 
override final;
     virtual bool            QuickFormatDoc( bool bFull = false ) override 
final;
+    virtual bool SupportsOutlineDepth() const override final;
     virtual sal_Int16       GetDepth( sal_Int32 nPara ) const override final;
     virtual bool            SetDepth( sal_Int32 nPara, sal_Int16 nNewDepth ) 
override final;
     virtual sal_Int32       GetNumberingStartValue( sal_Int32 nPara ) override 
final;
diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx
index bb3d8c708606..df43a3d7b43a 100644
--- a/include/editeng/unotext.hxx
+++ b/include/editeng/unotext.hxx
@@ -225,6 +225,7 @@ public:
     virtual bool            Delete( const ESelection& ) override;
     virtual bool            InsertText( const OUString&, const ESelection& ) 
override;
     virtual bool            QuickFormatDoc( bool bFull = false ) override;
+    virtual bool SupportsOutlineDepth() const override;
     virtual sal_Int16       GetDepth( sal_Int32 nPara ) const override;
     virtual bool            SetDepth( sal_Int32 nPara, sal_Int16 nNewDepth ) 
override;
 
diff --git a/svx/source/accessibility/AccessibleEmptyEditSource.cxx 
b/svx/source/accessibility/AccessibleEmptyEditSource.cxx
index 7ff9ec6610f7..cabcfd5942a9 100644
--- a/svx/source/accessibility/AccessibleEmptyEditSource.cxx
+++ b/svx/source/accessibility/AccessibleEmptyEditSource.cxx
@@ -159,6 +159,7 @@ namespace accessibility
         bool            Delete( const ESelection& ) override { return false; }
         bool            InsertText( const OUString&, const ESelection& ) 
override { return false; }
         bool            QuickFormatDoc( bool ) override { return true; }
+        bool SupportsOutlineDepth() const override { return false; }
         sal_Int16       GetDepth( sal_Int32 ) const override { return -1; }
         bool            SetDepth( sal_Int32, sal_Int16 ) override { return 
true; }
 
diff --git a/svx/source/dialog/weldeditview.cxx 
b/svx/source/dialog/weldeditview.cxx
index 8b7322b79d43..6f8f586c790a 100644
--- a/svx/source/dialog/weldeditview.cxx
+++ b/svx/source/dialog/weldeditview.cxx
@@ -410,6 +410,7 @@ public:
     virtual bool InsertText(const OUString&, const ESelection&) override;
     virtual bool QuickFormatDoc(bool bFull = false) override;
 
+    virtual bool SupportsOutlineDepth() const override { return false; };
     virtual sal_Int16 GetDepth(sal_Int32 nPara) const override;
     virtual bool SetDepth(sal_Int32 nPara, sal_Int16 nNewDepth) override;
 

Reply via email to