diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2023-03-17 14:51:25 +0200 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2023-03-22 10:16:03 +0000 |
commit | debf3e06bc5330b227dc9dd55e49930cb3da522a (patch) | |
tree | fc6a21ecf8c80c77ef84822885cb982f9d3bb311 /sc/source/ui/unoobj | |
parent | a49019618be881520a454550454c3f2d078d17fa (diff) |
sc drawstyles: Add a style UNO property to shapes
Change-Id: I5c8eb3c3e182d9efefc385020b97d768e615a20a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149278
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'sc/source/ui/unoobj')
-rw-r--r-- | sc/source/ui/unoobj/shapeuno.cxx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx index 2dfd6ca10701..67931eab9a83 100644 --- a/sc/source/ui/unoobj/shapeuno.cxx +++ b/sc/source/ui/unoobj/shapeuno.cxx @@ -33,6 +33,7 @@ #include <cppuhelper/supportsservice.hxx> #include <comphelper/diagnose_ex.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/lang/NoSupportException.hpp> @@ -44,6 +45,7 @@ #include <drwlayer.hxx> #include <userdat.hxx> #include <unonames.hxx> +#include <styleuno.hxx> using namespace ::com::sun::star; @@ -59,6 +61,7 @@ static o3tl::span<const SfxItemPropertyMapEntry> lcl_GetShapeMap() { SC_UNONAME_MOVEPROTECT, 0, cppu::UnoType<sal_Bool>::get(), 0, 0 }, { SC_UNONAME_HYPERLINK, 0, cppu::UnoType<OUString>::get(), 0, 0 }, { SC_UNONAME_URL, 0, cppu::UnoType<OUString>::get(), 0, 0 }, + { SC_UNONAME_STYLE, 0, cppu::UnoType<style::XStyle>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 }, }; return aShapeMap_Impl; } @@ -649,6 +652,22 @@ void SAL_CALL ScShapeObj::setPropertyValue(const OUString& aPropertyName, const pObj->SetMoveProtect( aProt ); } } + else if ( aPropertyName == SC_UNONAME_STYLE ) + { + if (SdrObject* pObj = GetSdrObject()) + { + uno::Reference<style::XStyle> xStyle(aValue, uno::UNO_QUERY); + auto pStyleSheetObj = dynamic_cast<ScStyleObj*>(xStyle.get()); + if (!pStyleSheetObj) + throw lang::IllegalArgumentException(); + + auto pStyleSheet = pStyleSheetObj->GetStyle_Impl(); + auto pOldStyleSheet = pObj->GetStyleSheet(); + + if (pStyleSheet != pOldStyleSheet) + pObj->SetStyleSheet(static_cast<SfxStyleSheet*>(pStyleSheet), false); + } + } else { GetShapePropertySet(); @@ -843,6 +862,20 @@ uno::Any SAL_CALL ScShapeObj::getPropertyValue( const OUString& aPropertyName ) aProt = pObj->IsMoveProtect(); aAny <<= aProt; } + else if ( aPropertyName == SC_UNONAME_STYLE ) + { + if (SdrObject* pObj = GetSdrObject()) + { + if (auto pStyleSheet = pObj->GetStyleSheet()) + { + ScDrawLayer& rModel(static_cast< ScDrawLayer& >(pObj->getSdrModelFromSdrObject())); + ScDocument* pDoc = rModel.GetDocument(); + aAny <<= uno::Reference<style::XStyle>(new ScStyleObj( + static_cast<ScDocShell*>(pDoc ? pDoc->GetDocumentShell() : nullptr), + SfxStyleFamily::Frame, pStyleSheet->GetName())); + } + } + } else { if(!pShapePropertySet) //performance consideration |