include/svx/svdoashp.hxx | 7 offapi/com/sun/star/drawing/CustomShapeEngine.idl | 5 oox/qa/unit/shape.cxx | 1 sd/source/ui/dlg/sdtreelb.cxx | 20 - solenv/bin/native-code.py | 2 svx/Library_svx.mk | 4 svx/Library_svxcore.mk | 4 svx/inc/EnhancedCustomShapeEngine.hxx | 56 +++ svx/source/accessibility/ShapeTypeHandler.cxx | 1 svx/source/customshapes/EnhancedCustomShape2d.cxx | 1 svx/source/customshapes/EnhancedCustomShapeEngine.cxx | 259 ++++++++---------- svx/source/svdraw/svdoashp.cxx | 24 - svx/source/unodraw/unoshap2.cxx | 2 svx/util/svx.component | 4 svx/util/svxcore.component | 4 xmloff/source/draw/shapeexport.cxx | 30 -- 16 files changed, 217 insertions(+), 207 deletions(-)
New commits: commit 170a1dfe9b01ffea49328a3abbaeb70c725f4c90 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Sep 25 10:47:48 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Sep 26 12:53:27 2025 +0200 simplify use of EnhancedCustomShapeEngine this is an internal UNO API, and there is only one implementation, so make that obvious in the code. That required moving some classes from the svx library to the svxcore library Change-Id: Ic5c19327df271920dc1077185ff692abbf5fb091 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191494 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx index a33fce0aca7a..fe53187afc0e 100644 --- a/include/svx/svdoashp.hxx +++ b/include/svx/svdoashp.hxx @@ -24,7 +24,7 @@ #include <svx/svdhdl.hxx> #include <vector> #include <com/sun/star/uno/Reference.h> -#include <com/sun/star/drawing/XCustomShapeEngine.hpp> +#include <com/sun/star/drawing/XCustomShapeHandle.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> #include <svx/svxdllapi.h> #include <o3tl/typed_flags_set.hxx> @@ -36,6 +36,7 @@ namespace sdr class CustomShapeProperties; } } +class EnhancedCustomShapeEngine; class SdrAShapeObjGeoData final : public SdrTextObjGeoData { @@ -90,12 +91,12 @@ public: css::uno::Reference< css::drawing::XShape > mXRenderedCustomShape; - mutable css::uno::Reference< css::drawing::XCustomShapeEngine > mxCustomShapeEngine; + mutable rtl::Reference< EnhancedCustomShapeEngine > mxCustomShapeEngine; // #i37011# render geometry shadow rtl::Reference<SdrObject> mpLastShadowGeometry; - css::uno::Reference< css::drawing::XCustomShapeEngine > const & GetCustomShapeEngine() const; + rtl::Reference< EnhancedCustomShapeEngine > const & GetCustomShapeEngine() const; std::vector< SdrCustomShapeInteraction > GetInteractionHandles() const; // needed in unit test SVX_DLLPRIVATE void DragCreateObject( SdrDragStat& rDrag ); diff --git a/offapi/com/sun/star/drawing/CustomShapeEngine.idl b/offapi/com/sun/star/drawing/CustomShapeEngine.idl index 28395f661162..04872e11b1c4 100644 --- a/offapi/com/sun/star/drawing/CustomShapeEngine.idl +++ b/offapi/com/sun/star/drawing/CustomShapeEngine.idl @@ -25,11 +25,6 @@ module com { module sun { module star { module drawing { */ service CustomShapeEngine { - /** initializing the CustomShapeEngine - - */ - interface ::com::sun::star::lang::XInitialization; - interface com::sun::star::drawing::XCustomShapeEngine; }; diff --git a/oox/qa/unit/shape.cxx b/oox/qa/unit/shape.cxx index 5d9bb299e72d..1b51efe3c226 100644 --- a/oox/qa/unit/shape.cxx +++ b/oox/qa/unit/shape.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/drawing/TextHorizontalAdjust.hpp> #include <com/sun/star/drawing/TextVerticalAdjust.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> #include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/text/XTextFrame.hpp> diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx index 0ff5a7bd271b..9877054ee700 100644 --- a/sd/source/ui/dlg/sdtreelb.cxx +++ b/sd/source/ui/dlg/sdtreelb.cxx @@ -910,17 +910,17 @@ OUString SdPageObjsTLV::GetObjectName( OUString sObjName; if (pObject->GetObjIdentifier() == SdrObjKind::CustomShape) { - // taken from SdrObjCustomShape::GetCustomShapeName +#ifndef NDEBUG OUString aEngine(pObject->GetMergedItem(SDRATTR_CUSTOMSHAPE_ENGINE).GetValue()); - if (aEngine.isEmpty() || aEngine == "com.sun.star.drawing.EnhancedCustomShapeEngine") - { - OUString sShapeType; - const SdrCustomShapeGeometryItem& rGeometryItem - = pObject->GetMergedItem(SDRATTR_CUSTOMSHAPE_GEOMETRY); - const uno::Any* pAny = rGeometryItem.GetPropertyValueByName(u"Type"_ustr); - if (pAny && (*pAny >>= sShapeType)) - sObjName = SdResId(STR_NAVIGATOR_CUSTOMSHAPE) + u": " + sShapeType; - } + assert(aEngine.isEmpty() || aEngine == "com.sun.star.drawing.EnhancedCustomShapeEngine"); +#endif + // taken from SdrObjCustomShape::GetCustomShapeName + OUString sShapeType; + const SdrCustomShapeGeometryItem& rGeometryItem + = pObject->GetMergedItem(SDRATTR_CUSTOMSHAPE_GEOMETRY); + const uno::Any* pAny = rGeometryItem.GetPropertyValueByName(u"Type"_ustr); + if (pAny && (*pAny >>= sShapeType)) + sObjName = SdResId(STR_NAVIGATOR_CUSTOMSHAPE) + u": " + sShapeType; } else sObjName = pObject->TakeObjNameSingul(); diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index 3976c02fdb06..cb4cfa0ec732 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -381,7 +381,6 @@ core_constructor_list = [ "com_sun_star_comp_svx_NumberingToolBoxControl_get_implementation", "com_sun_star_comp_svx_SmartTagMenuController_get_implementation", "com_sun_star_comp_svx_UnderlineToolBoxControl_get_implementation", - "com_sun_star_drawing_EnhancedCustomShapeEngine_get_implementation", "com_sun_star_drawing_SvxShapeCollection_get_implementation", "com_sun_star_svx_FontHeightToolBoxController_get_implementation", "org_apache_openoffice_comp_svx_sidebar_PanelFactory_get_implementation", @@ -397,6 +396,7 @@ core_constructor_list = [ "com_sun_star_comp_svx_LineStyleToolBoxControl_get_implementation", "com_sun_star_comp_svx_StyleToolBoxControl_get_implementation", "com_sun_star_comp_svx_StylesPreviewToolBoxControl_get_implementation", + "com_sun_star_drawing_EnhancedCustomShapeEngine_get_implementation", # toolkit/util/tk.component "com_sun_star_comp_embed_HatchWindowFactory_get_implementation", "stardiv_Toolkit_StdTabController_get_implementation", diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index 0117fa9f061a..c60463c3ad93 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -121,10 +121,6 @@ $(eval $(call gb_Library_add_exception_objects,svx,\ svx/source/accessibility/charmapacc \ svx/source/accessibility/svxpixelctlaccessiblecontext \ svx/source/accessibility/svxrectctaccessiblecontext \ - svx/source/customshapes/EnhancedCustomShape3d \ - svx/source/customshapes/EnhancedCustomShapeEngine \ - svx/source/customshapes/EnhancedCustomShapeFontWork \ - svx/source/customshapes/EnhancedCustomShapeHandle \ svx/source/dialog/GenericCheckDialog \ svx/source/dialog/GenericDropDownFieldDialog \ svx/source/dialog/_bmpmask \ diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk index 496b6ccd17d7..cf48f318363a 100644 --- a/svx/Library_svxcore.mk +++ b/svx/Library_svxcore.mk @@ -485,6 +485,10 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\ svx/source/xoutdev/xtabptrn \ svx/source/xoutdev/XPropertyEntry \ svx/source/xoutdev/xtablend \ + svx/source/customshapes/EnhancedCustomShape3d \ + svx/source/customshapes/EnhancedCustomShapeEngine \ + svx/source/customshapes/EnhancedCustomShapeFontWork \ + svx/source/customshapes/EnhancedCustomShapeHandle \ )) $(eval $(call gb_SdiTarget_SdiTarget,svx/sdi/svxslots,svx/sdi/svx)) diff --git a/svx/inc/EnhancedCustomShapeEngine.hxx b/svx/inc/EnhancedCustomShapeEngine.hxx new file mode 100644 index 000000000000..9105057e2981 --- /dev/null +++ b/svx/inc/EnhancedCustomShapeEngine.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <cppuhelper/implbase.hxx> +#include <com/sun/star/drawing/XCustomShapeEngine.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <svx/svxdllapi.h> + +class SVXCORE_DLLPUBLIC EnhancedCustomShapeEngine + : public cppu::WeakImplHelper<css::lang::XServiceInfo, css::drawing::XCustomShapeEngine> +{ + css::uno::Reference<css::drawing::XShape> mxShape; + bool mbForceGroupWithText; + + rtl::Reference<SdrObject> ImplForceGroupWithText(const SdrObjCustomShape& rSdrObjCustomShape, + SdrObject* pRenderedShape); + +public: + EnhancedCustomShapeEngine(const css::uno::Sequence<css::uno::Any>& aArguments); + EnhancedCustomShapeEngine(const css::uno::Reference<css::drawing::XShape>& xShape); + + // XInterface + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + // XCustomShapeEngine + virtual css::uno::Reference<css::drawing::XShape> SAL_CALL render() override; + virtual css::awt::Rectangle SAL_CALL getTextBounds() override; + virtual css::drawing::PolyPolygonBezierCoords SAL_CALL getLineGeometry() override; + virtual css::uno::Sequence<css::uno::Reference<css::drawing::XCustomShapeHandle>> + SAL_CALL getInteraction() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/accessibility/ShapeTypeHandler.cxx b/svx/source/accessibility/ShapeTypeHandler.cxx index d1f41da29338..96e0dbb23914 100644 --- a/svx/source/accessibility/ShapeTypeHandler.cxx +++ b/svx/source/accessibility/ShapeTypeHandler.cxx @@ -28,6 +28,7 @@ #include <svx/svdoashp.hxx> #include <svx/strings.hrc> +#include <com/sun/star/drawing/XShape.hpp> using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index ac16404301ad..f09780ddcc7f 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -44,6 +44,7 @@ #include <svx/xhatch.hxx> #include <svx/sdshitm.hxx> #include <comphelper/configuration.hxx> +#include <com/sun/star/awt/Rectangle.hpp> #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp> diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx index 19a277219273..eb1e1b5a7436 100644 --- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx @@ -26,6 +26,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/drawing/XCustomShapeEngine.hpp> #include <svx/EnhancedCustomShape2d.hxx> +#include <EnhancedCustomShapeEngine.hxx> #include "EnhancedCustomShape3d.hxx" #include "EnhancedCustomShapeFontWork.hxx" #include "EnhancedCustomShapeHandle.hxx" @@ -52,46 +53,29 @@ using namespace css::uno; class SdrObject; class SdrObjCustomShape; -namespace { - -class EnhancedCustomShapeEngine : public cppu::WeakImplHelper -< - css::lang::XInitialization, - css::lang::XServiceInfo, - css::drawing::XCustomShapeEngine -> +EnhancedCustomShapeEngine::EnhancedCustomShapeEngine(const css::uno::Sequence< css::uno::Any >& aArguments) : + mbForceGroupWithText ( false ) { - css::uno::Reference< css::drawing::XShape > mxShape; - bool mbForceGroupWithText; - - rtl::Reference<SdrObject> ImplForceGroupWithText( - const SdrObjCustomShape& rSdrObjCustomShape, - SdrObject* pRenderedShape); - -public: - EnhancedCustomShapeEngine(); - - // XInterface - virtual void SAL_CALL acquire() noexcept override; - virtual void SAL_CALL release() noexcept override; - - // XInitialization - virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() override; - virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - - // XCustomShapeEngine - virtual css::uno::Reference< css::drawing::XShape > SAL_CALL render() override; - virtual css::awt::Rectangle SAL_CALL getTextBounds() override; - virtual css::drawing::PolyPolygonBezierCoords SAL_CALL getLineGeometry() override; - virtual css::uno::Sequence< css::uno::Reference< css::drawing::XCustomShapeHandle > > SAL_CALL getInteraction() override; -}; + for (const css::uno::Any& rArg : aArguments) + { + beans::PropertyValue aProp; + if (rArg >>= aProp) + { + if ( aProp.Name == "CustomShape" ) + aProp.Value >>= mxShape; + else if ( aProp.Name == "ForceGroupWithText" ) + aProp.Value >>= mbForceGroupWithText; + else + assert(false); + } + else + assert(false); + } +} -EnhancedCustomShapeEngine::EnhancedCustomShapeEngine() : - mbForceGroupWithText ( false ) +EnhancedCustomShapeEngine::EnhancedCustomShapeEngine(const css::uno::Reference< css::drawing::XShape >& xShape) : + mxShape(xShape), + mbForceGroupWithText(false) { } @@ -105,24 +89,6 @@ void SAL_CALL EnhancedCustomShapeEngine::release() noexcept OWeakObject::release(); } -// XInitialization -void SAL_CALL EnhancedCustomShapeEngine::initialize( const Sequence< Any >& aArguments ) -{ - Sequence< beans::PropertyValue > aParameter; - for ( const auto& rArgument : aArguments ) - { - if ( rArgument >>= aParameter ) - break; - } - for (const beans::PropertyValue& rProp : aParameter) - { - if ( rProp.Name == "CustomShape" ) - rProp.Value >>= mxShape; - else if ( rProp.Name == "ForceGroupWithText" ) - rProp.Value >>= mbForceGroupWithText; - } -} - // XServiceInfo OUString SAL_CALL EnhancedCustomShapeEngine::getImplementationName() { @@ -250,12 +216,14 @@ rtl::Reference<SdrObject> EnhancedCustomShapeEngine::ImplForceGroupWithText( Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render() { - SdrObjCustomShape* pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxShape)); + SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape(mxShape); + if (!pSdrObj) + return Reference< drawing::XShape >(); - if(!pSdrObjCustomShape) - { + // the only two subclasses of SdrObject we see here are SdrObjCustomShape and SwDrawVirtObj + SdrObjCustomShape* pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(pSdrObj); + if (!pSdrObjCustomShape) return Reference< drawing::XShape >(); - } // retrieving the TextPath property to check if feature is enabled const SdrCustomShapeGeometryItem& rGeometryItem(pSdrObjCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY )); @@ -346,20 +314,25 @@ Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render() awt::Rectangle SAL_CALL EnhancedCustomShapeEngine::getTextBounds() { + SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape(mxShape); + if (!pSdrObj) + return awt::Rectangle(); + + // the only two subclasses of SdrObject we see here are SdrObjCustomShape and SwDrawVirtObj + SdrObjCustomShape* pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(pSdrObj); + if (!pSdrObjCustomShape) + return awt::Rectangle(); + awt::Rectangle aTextRect; - if (SdrObjCustomShape* pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxShape))) + uno::Reference< document::XActionLockable > xLockable( mxShape, uno::UNO_QUERY ); + if(xLockable.is() && !xLockable->isActionLocked()) { - uno::Reference< document::XActionLockable > xLockable( mxShape, uno::UNO_QUERY ); - - if(xLockable.is() && !xLockable->isActionLocked()) - { - EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape); - tools::Rectangle aRect( aCustomShape2d.GetTextRect() ); - aTextRect.X = aRect.Left(); - aTextRect.Y = aRect.Top(); - aTextRect.Width = aRect.GetWidth(); - aTextRect.Height = aRect.GetHeight(); - } + EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape); + tools::Rectangle aRect( aCustomShape2d.GetTextRect() ); + aTextRect.X = aRect.Left(); + aTextRect.Y = aRect.Top(); + aTextRect.Width = aRect.GetWidth(); + aTextRect.Height = aRect.GetHeight(); } return aTextRect; @@ -367,75 +340,80 @@ awt::Rectangle SAL_CALL EnhancedCustomShapeEngine::getTextBounds() drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeometry() { + SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape(mxShape); + if (!pSdrObj) + return drawing::PolyPolygonBezierCoords(); + + // the only two subclasses of SdrObject we see here are SdrObjCustomShape and SwDrawVirtObj + SdrObjCustomShape* pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(pSdrObj); + if (!pSdrObjCustomShape) + return drawing::PolyPolygonBezierCoords(); + drawing::PolyPolygonBezierCoords aPolyPolygonBezierCoords; - SdrObjCustomShape* pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxShape)); - if(pSdrObjCustomShape) + EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape); + rtl::Reference<SdrObject> pObj = aCustomShape2d.CreateLineGeometry(); + + if ( pObj ) { - EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape); - rtl::Reference<SdrObject> pObj = aCustomShape2d.CreateLineGeometry(); + tools::Rectangle aRect(pSdrObjCustomShape->GetSnapRect()); + bool bFlipV = aCustomShape2d.IsFlipVert(); + bool bFlipH = aCustomShape2d.IsFlipHorz(); + const GeoStat& rGeoStat(pSdrObjCustomShape->GetGeoStat()); - if ( pObj ) + if ( rGeoStat.m_nShearAngle ) { - tools::Rectangle aRect(pSdrObjCustomShape->GetSnapRect()); - bool bFlipV = aCustomShape2d.IsFlipVert(); - bool bFlipH = aCustomShape2d.IsFlipHorz(); - const GeoStat& rGeoStat(pSdrObjCustomShape->GetGeoStat()); - - if ( rGeoStat.m_nShearAngle ) + Degree100 nShearAngle = rGeoStat.m_nShearAngle; + double nTan = rGeoStat.mfTanShearAngle; + if (bFlipV != bFlipH) { - Degree100 nShearAngle = rGeoStat.m_nShearAngle; - double nTan = rGeoStat.mfTanShearAngle; - if (bFlipV != bFlipH) - { - nShearAngle = -nShearAngle; - nTan = -nTan; - } - pObj->Shear( aRect.Center(), nShearAngle, nTan, false); + nShearAngle = -nShearAngle; + nTan = -nTan; } - Degree100 nRotateAngle = aCustomShape2d.GetRotateAngle(); - if( nRotateAngle ) - pObj->NbcRotate( aRect.Center(), nRotateAngle ); - if ( bFlipH ) + pObj->Shear( aRect.Center(), nShearAngle, nTan, false); + } + Degree100 nRotateAngle = aCustomShape2d.GetRotateAngle(); + if( nRotateAngle ) + pObj->NbcRotate( aRect.Center(), nRotateAngle ); + if ( bFlipH ) + { + Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() ); + Point aBottom( aTop.X(), aTop.Y() + 1000 ); + pObj->NbcMirror( aTop, aBottom ); + } + if ( bFlipV ) + { + Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 ); + Point aRight( aLeft.X() + 1000, aLeft.Y() ); + pObj->NbcMirror( aLeft, aRight ); + } + + basegfx::B2DPolyPolygon aPolyPolygon; + SdrObjListIter aIter( *pObj, SdrIterMode::DeepWithGroups ); + + while ( aIter.IsMore() ) + { + basegfx::B2DPolyPolygon aPP; + const SdrObject* pNext = aIter.Next(); + + if ( auto pPathObj = dynamic_cast<const SdrPathObj*>(pNext) ) { - Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() ); - Point aBottom( aTop.X(), aTop.Y() + 1000 ); - pObj->NbcMirror( aTop, aBottom ); + aPP = pPathObj->GetPathPoly(); } - if ( bFlipV ) + else { - Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 ); - Point aRight( aLeft.X() + 1000, aLeft.Y() ); - pObj->NbcMirror( aLeft, aRight ); + rtl::Reference<SdrObject> pNewObj = pNext->ConvertToPolyObj( false, false ); + SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pNewObj.get() ); + if ( pPath ) + aPP = pPath->GetPathPoly(); } - basegfx::B2DPolyPolygon aPolyPolygon; - SdrObjListIter aIter( *pObj, SdrIterMode::DeepWithGroups ); - - while ( aIter.IsMore() ) - { - basegfx::B2DPolyPolygon aPP; - const SdrObject* pNext = aIter.Next(); - - if ( auto pPathObj = dynamic_cast<const SdrPathObj*>(pNext) ) - { - aPP = pPathObj->GetPathPoly(); - } - else - { - rtl::Reference<SdrObject> pNewObj = pNext->ConvertToPolyObj( false, false ); - SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pNewObj.get() ); - if ( pPath ) - aPP = pPath->GetPathPoly(); - } - - if ( aPP.count() ) - aPolyPolygon.append(aPP); - } - pObj.clear(); - basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( aPolyPolygon, - aPolyPolygonBezierCoords ); + if ( aPP.count() ) + aPolyPolygon.append(aPP); } + pObj.clear(); + basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( aPolyPolygon, + aPolyPolygonBezierCoords ); } return aPolyPolygonBezierCoords; @@ -443,31 +421,32 @@ drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeom Sequence< Reference< drawing::XCustomShapeHandle > > SAL_CALL EnhancedCustomShapeEngine::getInteraction() { - sal_uInt32 i, nHdlCount = 0; - SdrObjCustomShape* pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxShape)); + SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape(mxShape); + if (!pSdrObj) + return {}; - if(pSdrObjCustomShape) - { - EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape); - nHdlCount = aCustomShape2d.GetHdlCount(); - } + // the only two subclasses of SdrObject we see here are SdrObjCustomShape and SwDrawVirtObj + SdrObjCustomShape* pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(pSdrObj); + if (!pSdrObjCustomShape) + return {}; + + EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape); + sal_uInt32 nHdlCount = aCustomShape2d.GetHdlCount(); Sequence< Reference< drawing::XCustomShapeHandle > > aSeq( nHdlCount ); auto aSeqRange = asNonConstRange(aSeq); - for ( i = 0; i < nHdlCount; i++ ) + for ( sal_uInt32 i = 0; i < nHdlCount; i++ ) aSeqRange[ i ] = new EnhancedCustomShapeHandle( mxShape, i ); return aSeq; } -} - extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_drawing_EnhancedCustomShapeEngine_get_implementation( css::uno::XComponentContext *, - css::uno::Sequence<css::uno::Any> const &) + css::uno::Sequence<css::uno::Any> const & args) { - return cppu::acquire(new EnhancedCustomShapeEngine); + return cppu::acquire(new EnhancedCustomShapeEngine(args)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index ef5d6eeca657..d327e1536473 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -87,6 +87,7 @@ #include <o3tl/string_view.hxx> #include "presetooxhandleadjustmentrelations.hxx" #include <editeng/frmdiritem.hxx> +#include <EnhancedCustomShapeEngine.hxx> using namespace ::com::sun::star; @@ -369,7 +370,7 @@ static rtl::Reference<SdrObject> ImpCreateShadowObjectClone(const SdrObject& rOr } -uno::Reference<drawing::XCustomShapeEngine> const & SdrObjCustomShape::GetCustomShapeEngine() const +rtl::Reference<EnhancedCustomShapeEngine> const & SdrObjCustomShape::GetCustomShapeEngine() const { if (mxCustomShapeEngine.is()) return mxCustomShapeEngine; @@ -378,27 +379,10 @@ uno::Reference<drawing::XCustomShapeEngine> const & SdrObjCustomShape::GetCustom if ( !aXShape ) return mxCustomShapeEngine; - const uno::Reference<uno::XComponentContext>& xContext( ::comphelper::getProcessComponentContext() ); - OUString aEngine(GetMergedItem( SDRATTR_CUSTOMSHAPE_ENGINE ).GetValue()); - static constexpr OUStringLiteral sEnhancedCustomShapeEngine = u"com.sun.star.drawing.EnhancedCustomShapeEngine"; - if ( aEngine.isEmpty() ) - aEngine = sEnhancedCustomShapeEngine; - + if ( aEngine.isEmpty() || aEngine == "com.sun.star.drawing.EnhancedCustomShapeEngine") { - static constexpr OUString sCustomShape = u"CustomShape"_ustr; - uno::Sequence<beans::PropertyValue> aPropValues{ comphelper::makePropertyValue(sCustomShape, - aXShape) }; - uno::Sequence<uno::Any> aArgument{ uno::Any(aPropValues) }; - try - { - uno::Reference<uno::XInterface> xInterface(xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aEngine, aArgument, xContext)); - if (xInterface.is()) - mxCustomShapeEngine.set(xInterface, uno::UNO_QUERY); - } - catch (const loader::CannotActivateFactoryException&) - { - } + mxCustomShapeEngine = new EnhancedCustomShapeEngine(aXShape); } return mxCustomShapeEngine; diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx index d1a8c86d0f6c..3c9b7a0e953b 100644 --- a/svx/source/unodraw/unoshap2.cxx +++ b/svx/source/unodraw/unoshap2.cxx @@ -64,7 +64,7 @@ #include <sal/log.hxx> #include <cppuhelper/queryinterface.hxx> #include <tools/stream.hxx> - +#include <EnhancedCustomShapeEngine.hxx> #include <memory> diff --git a/svx/util/svx.component b/svx/util/svx.component index 54d1c0b220f7..4788ab737145 100644 --- a/svx/util/svx.component +++ b/svx/util/svx.component @@ -42,10 +42,6 @@ constructor="com_sun_star_comp_svx_SafeModeUI_get_implementation"> <service name="com.sun.star.dialog.SafeModeUI"/> </implementation> - <implementation name="com.sun.star.drawing.EnhancedCustomShapeEngine" - constructor="com_sun_star_drawing_EnhancedCustomShapeEngine_get_implementation"> - <service name="com.sun.star.drawing.CustomShapeEngine"/> - </implementation> <implementation name="com.sun.star.drawing.SvxShapeCollection" constructor="com_sun_star_drawing_SvxShapeCollection_get_implementation"> <service name="com.sun.star.drawing.ShapeCollection"/> diff --git a/svx/util/svxcore.component b/svx/util/svxcore.component index d3b0942f4a84..d218e1292b5a 100644 --- a/svx/util/svxcore.component +++ b/svx/util/svxcore.component @@ -97,4 +97,8 @@ constructor="com_sun_star_comp_svx_TextColumns_get_implementation"> <service name="com.sun.star.text.TextColumns"/> </implementation> + <implementation name="com.sun.star.drawing.EnhancedCustomShapeEngine" + constructor="com_sun_star_drawing_EnhancedCustomShapeEngine_get_implementation"> + <service name="com.sun.star.drawing.CustomShapeEngine"/> + </implementation> </component> diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 00f65adc7c76..bcdc447b79df 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -233,28 +233,20 @@ uno::Reference< drawing::XShape > XMLShapeExport::checkForCustomShapeReplacement { OUString aEngine; xSet->getPropertyValue(u"CustomShapeEngine"_ustr) >>= aEngine; - if ( aEngine.isEmpty() ) + if ( aEngine.isEmpty() || aEngine == "com.sun.star.drawing.EnhancedCustomShapeEngine") { - aEngine = "com.sun.star.drawing.EnhancedCustomShapeEngine"; - } - const uno::Reference< uno::XComponentContext >& xContext( ::comphelper::getProcessComponentContext() ); + const uno::Reference< uno::XComponentContext >& xContext( ::comphelper::getProcessComponentContext() ); - if ( !aEngine.isEmpty() ) - { - uno::Sequence< beans::PropertyValue > aPropValues{ - comphelper::makePropertyValue(u"CustomShape"_ustr, xShape), - comphelper::makePropertyValue(u"ForceGroupWithText"_ustr, true) - }; - uno::Sequence< uno::Any > aArgument = { uno::Any(aPropValues) }; + uno::Sequence< uno::Any > aArguments { + uno::Any(comphelper::makePropertyValue(u"CustomShape"_ustr, xShape)), + uno::Any(comphelper::makePropertyValue(u"ForceGroupWithText"_ustr, true)) }; uno::Reference< uno::XInterface > xInterface( - xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aEngine, aArgument, xContext) ); - if ( xInterface.is() ) - { - uno::Reference< drawing::XCustomShapeEngine > xCustomShapeEngine( - uno::Reference< drawing::XCustomShapeEngine >( xInterface, uno::UNO_QUERY ) ); - if ( xCustomShapeEngine.is() ) - xCustomShapeReplacement = xCustomShapeEngine->render(); - } + xContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.drawing.EnhancedCustomShapeEngine", aArguments, xContext) ); + assert( xInterface && "should never fail" ); + uno::Reference< drawing::XCustomShapeEngine > xCustomShapeEngine( + uno::Reference< drawing::XCustomShapeEngine >( xInterface, uno::UNO_QUERY ) ); + assert(xCustomShapeEngine && "should never fail"); + xCustomShapeReplacement = xCustomShapeEngine->render(); } } }