editeng/source/uno/unoedprx.cxx | 7 +++++++ editeng/source/uno/unofored.cxx | 6 ++++++ editeng/source/uno/unoforou.cxx | 5 +++++ editeng/source/uno/unotext.cxx | 11 +++++++++++ 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, 38 insertions(+)
New commits: commit 0d3748e5fbfb2ac8dd60d491d566075938927237 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Thu Nov 21 15:08:45 2024 -0500 Commit: Justin Luth <justin.l...@collabora.com> CommitDate: Fri Nov 22 04:52:46 2024 +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 <jl...@mail.com> diff --git a/editeng/source/uno/unoedprx.cxx b/editeng/source/uno/unoedprx.cxx index 15342e874753..8a0c6bd07445 100644 --- a/editeng/source/uno/unoedprx.cxx +++ b/editeng/source/uno/unoedprx.cxx @@ -1019,6 +1019,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 c24f9ff965b1..0c4acc7c4541 100644 --- a/editeng/source/uno/unofored.cxx +++ b/editeng/source/uno/unofored.cxx @@ -465,6 +465,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 a04885190050..43aaabffc536 100644 --- a/editeng/source/uno/unoforou.cxx +++ b/editeng/source/uno/unoforou.cxx @@ -431,6 +431,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 64c00e802888..8bc101e5c2ed 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -535,6 +535,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 ) { @@ -721,6 +724,9 @@ bool SvxUnoTextRangeBase::GetPropertyValueHelper( SfxItemSet const & rSet, cons SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr; if(pForwarder && pSelection) { + if (!pForwarder->SupportsOutlineDepth()) + return false; + sal_Int16 nLevel = pForwarder->GetDepth( pSelection->nStartPara ); if( nLevel >= 0 ) aAny <<= nLevel; @@ -2516,6 +2522,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 b3cf3f89309c..783bd965ec8f 100644 --- a/include/editeng/unoedprx.hxx +++ b/include/editeng/unoedprx.hxx @@ -82,6 +82,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 45824a4e390e..c7fd58aa90af 100644 --- a/include/editeng/unoedsrc.hxx +++ b/include/editeng/unoedsrc.hxx @@ -400,6 +400,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 ca64ca8c891a..fdb61341378b 100644 --- a/include/editeng/unofored.hxx +++ b/include/editeng/unofored.hxx @@ -78,6 +78,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 1909eb3f2f85..bcd1f39ab66a 100644 --- a/include/editeng/unoforou.hxx +++ b/include/editeng/unoforou.hxx @@ -98,6 +98,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 b5cecccbf625..4011fac9d479 100644 --- a/include/editeng/unotext.hxx +++ b/include/editeng/unotext.hxx @@ -226,6 +226,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 619c3443a42a..a0601c234946 100644 --- a/svx/source/accessibility/AccessibleEmptyEditSource.cxx +++ b/svx/source/accessibility/AccessibleEmptyEditSource.cxx @@ -158,6 +158,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 2f1ff16a862d..7728379e47d9 100644 --- a/svx/source/dialog/weldeditview.cxx +++ b/svx/source/dialog/weldeditview.cxx @@ -412,6 +412,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;