21#include <com/sun/star/awt/TextAlign.hpp>
22#include <com/sun/star/beans/XPropertySet.hpp>
23#include <com/sun/star/container/XIndexContainer.hpp>
24#include <com/sun/star/drawing/XControlShape.hpp>
25#include <com/sun/star/frame/XModel.hpp>
26#include <com/sun/star/script/ScriptEventDescriptor.hpp>
27#include <com/sun/star/script/XEventAttacherManager.hpp>
28#include <com/sun/star/style/VerticalAlignment.hpp>
31#include <ooo/vba/excel/Constants.hpp>
32#include <ooo/vba/excel/XlOrientation.hpp>
33#include <ooo/vba/excel/XlPlacement.hpp>
54 const uno::Reference< XHelperInterface >& rxParent,
55 const uno::Reference< uno::XComponentContext >& rxContext,
56 const uno::Reference< beans::XPropertySet >& rxPropSet,
61 maPalette( rPalette ),
62 mxPropSet( rxPropSet,
uno::UNO_SET_THROW )
84 sal_Int32 nStart = ::std::min(
mnStart, aString.getLength() );
85 sal_Int32
nLength = ::std::min(
mnLength, aString.getLength() - nStart );
86 return aString.copy( nStart,
nLength );
99 sal_Int32 nStart = ::std::min(
mnStart, aString.getLength() );
100 sal_Int32
nLength = ::std::min(
mnLength, aString.getLength() - nStart );
159 return mxPropSet->getPropertyValue(
"Label" ).get< OUString >();
168 const uno::Reference< XHelperInterface >& rxParent,
169 const uno::Reference< uno::XComponentContext >& rxContext,
170 const uno::Reference< frame::XModel >& rxModel,
171 const uno::Reference< drawing::XShape >& rxShape ) :
173 maPalette( rxModel ),
176 mxShapeProps( rxShape,
uno::UNO_QUERY_THROW )
190 throw uno::RuntimeException();
202 throw uno::RuntimeException();
214 throw uno::RuntimeException();
226 throw uno::RuntimeException();
232 return mxShapeProps->getPropertyValue(
"Name" ).get< OUString >();
242 sal_Int32
const nRet = excel::XlPlacement::xlMoveAndSize;
252 nRet = excel::XlPlacement::xlFreeFloating;
269 if ( nPlacement == excel::XlPlacement::xlFreeFloating )
274 ScDrawLayer::SetAnchor(pObj,
eType);
305 const uno::Reference< XHelperInterface >& rxParent,
306 const uno::Reference< uno::XComponentContext >& rxContext,
307 const uno::Reference< frame::XModel >& rxModel,
308 const uno::Reference< container::XIndexContainer >& rxFormIC,
309 const uno::Reference< drawing::XControlShape >& rxControlShape ) :
311 mxFormIC( rxFormIC,
uno::UNO_SET_THROW ),
312 mxControlProps( rxControlShape->getControl(),
uno::UNO_QUERY_THROW ),
313 mbNotifyMacroEventRead(false)
321 return mxControlProps->getPropertyValue(
"Name" ).get< OUString >();
331 uno::Reference< script::XEventAttacherManager > xEventMgr(
mxFormIC, uno::UNO_QUERY_THROW );
333 const uno::Sequence< script::ScriptEventDescriptor > aEvents = xEventMgr->getScriptEvents(
nIndex );
334 if( aEvents.hasElements() )
336 const script::ScriptEventDescriptor* pEvent = std::find_if(aEvents.begin(), aEvents.end(),
337 [](
const script::ScriptEventDescriptor& rEvent) {
338 return (rEvent.ListenerType == gaListenerType)
339 && (rEvent.EventMethod == gaEventMethod)
340 && (rEvent.ScriptType ==
"Script");
342 if (pEvent != aEvents.end())
358 uno::Reference< script::XEventAttacherManager > xEventMgr(
mxFormIC, uno::UNO_QUERY_THROW );
365 if( rMacroName.isEmpty() )
369 if( !aResolvedMacro.mbFound )
370 throw uno::RuntimeException();
371 script::ScriptEventDescriptor aDescriptor;
374 aDescriptor.ScriptType =
"Script";
375 aDescriptor.ScriptCode =
makeMacroURL( aResolvedMacro.msResolvedMacro );
377 xEventMgr->registerScriptEvent(
nIndex, aDescriptor );
382 return mxControlProps->getPropertyValue(
"Printable" ).get<
bool>();
409 uno::Reference< beans::XPropertySet > xProps(
mxFormIC->getByIndex(
nIndex ), uno::UNO_QUERY_THROW );
413 throw uno::RuntimeException();
417 const uno::Reference< XHelperInterface >& rxParent,
418 const uno::Reference< uno::XComponentContext >& rxContext,
419 const uno::Reference< frame::XModel >& rxModel,
420 const uno::Reference< container::XIndexContainer >& rxFormIC,
421 const uno::Reference< drawing::XControlShape >& rxControlShape ) :
430 return mxControlProps->getPropertyValue(
"Label" ).get< OUString >();
435 mxControlProps->setPropertyValue(
"Label",
uno::Any( rCaption ) );
450 switch( mxControlProps->getPropertyValue(
"Align" ).get< sal_Int16 >() )
452 case awt::TextAlign::LEFT:
return excel::Constants::xlLeft;
453 case awt::TextAlign::RIGHT:
return excel::Constants::xlRight;
454 case awt::TextAlign::CENTER:
return excel::Constants::xlCenter;
456 return excel::Constants::xlCenter;
461 sal_Int32 nAwtAlign = awt::TextAlign::CENTER;
464 case excel::Constants::xlLeft: nAwtAlign = awt::TextAlign::LEFT;
break;
465 case excel::Constants::xlRight: nAwtAlign = awt::TextAlign::RIGHT;
break;
466 case excel::Constants::xlCenter: nAwtAlign = awt::TextAlign::CENTER;
break;
469 mxControlProps->setPropertyValue(
"Align",
uno::Any(
static_cast< sal_Int16
>( nAwtAlign ) ) );
474 switch( mxControlProps->getPropertyValue(
"VerticalAlign" ).get< style::VerticalAlignment >() )
476 case style::VerticalAlignment_TOP:
return excel::Constants::xlTop;
477 case style::VerticalAlignment_BOTTOM:
return excel::Constants::xlBottom;
478 case style::VerticalAlignment_MIDDLE:
return excel::Constants::xlCenter;
481 return excel::Constants::xlCenter;
486 style::VerticalAlignment eAwtAlign = style::VerticalAlignment_MIDDLE;
489 case excel::Constants::xlTop: eAwtAlign = style::VerticalAlignment_TOP;
break;
490 case excel::Constants::xlBottom: eAwtAlign = style::VerticalAlignment_BOTTOM;
break;
491 case excel::Constants::xlCenter: eAwtAlign = style::VerticalAlignment_MIDDLE;
break;
493 mxControlProps->setPropertyValue(
"VerticalAlign",
uno::Any( eAwtAlign ) );
499 return excel::XlOrientation::xlHorizontal;
509 return mxControlProps->getPropertyValue(
"State" );
514 return mxControlProps->setPropertyValue(
"State",
nValue );
519 return mxControlProps->getPropertyValue(
"Label" ).get< OUString >();
524 return mxControlProps->setPropertyValue(
"Label",
uno::Any( aText ) );
css::uno::Reference< css::frame::XModel2 > mxModel
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual void SAL_CALL setAutoSize(sal_Bool bAutoSize) override
virtual sal_Bool SAL_CALL getAutoSize() override
sal_Int32 getModelIndexInForm() const
ScVbaControlObjectBase(const css::uno::Reference< ov::XHelperInterface > &rxParent, const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XModel > &rxModel, const css::uno::Reference< css::container::XIndexContainer > &rxFormIC, const css::uno::Reference< css::drawing::XControlShape > &rxControlShape)
virtual void SAL_CALL setPrintObject(sal_Bool bPrintObject) override
css::uno::Reference< css::beans::XPropertySet > mxControlProps
virtual OUString SAL_CALL getOnAction() override
virtual OUString SAL_CALL getName() override
virtual sal_Bool SAL_CALL getPrintObject() override
virtual void SAL_CALL setName(const OUString &rName) override
bool mbNotifyMacroEventRead
void NotifyMacroEventRead()
Notify that the document contains a macro event handler.
css::uno::Reference< css::container::XIndexContainer > mxFormIC
virtual void SAL_CALL setOnAction(const OUString &rMacroName) override
virtual sal_Int32 SAL_CALL getPlacement() override
virtual void SAL_CALL setName(const OUString &rName) override
virtual void SAL_CALL setTop(double fTop) override
virtual void implSetDefaultProperties()
Derived classes set default properties for new drawing objects.
css::uno::Reference< css::drawing::XShape > mxShape
virtual double SAL_CALL getHeight() override
virtual OUString SAL_CALL getName() override
void setDefaultProperties(sal_Int32 nIndex)
Sets default properties after a new object has been created.
virtual double SAL_CALL getLeft() override
css::uno::Reference< css::beans::XPropertySet > mxShapeProps
virtual double SAL_CALL getWidth() override
virtual void SAL_CALL setWidth(double fWidth) override
virtual sal_Bool SAL_CALL getPrintObject() override
virtual void SAL_CALL setPrintObject(sal_Bool bPrintObject) override
virtual OUString implGetBaseName() const =0
Derived classes return the base name used for new objects.
virtual void SAL_CALL setLeft(double fLeft) override
virtual void SAL_CALL setHeight(double fHeight) override
virtual double SAL_CALL getTop() override
ScVbaSheetObjectBase(const css::uno::Reference< ov::XHelperInterface > &rxParent, const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XModel > &rxModel, const css::uno::Reference< css::drawing::XShape > &rxShape)
virtual void SAL_CALL setPlacement(sal_Int32 nPlacement) override
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
SdrObject * GetSdrObject() const
COMPHELPER_DLLPUBLIC void notifyMacroEventRead(const css::uno::Reference< css::frame::XModel > &_rxDocument)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
OUString makeMacroURL(std::u16string_view sMacroName)
VBAHELPER_DLLPUBLIC SfxObjectShell * getSfxObjShell(const css::uno::Reference< css::frame::XModel > &xModel)
OUString extractMacroName(std::u16string_view rMacroUrl)
OUString resolveVBAMacro(SfxObjectShell const *pShell, const OUString &rLibName, const OUString &rModuleName, const OUString &rMacroName, bool bOnlyPublic, const OUString &sSkipModule)
uno::Reference< drawing::XShape > const mxShape
#define VBAHELPER_IMPL_XHELPERINTERFACE(classname, servicename)
constexpr OUStringLiteral gaEventMethod
static double HmmToPoints(double nHmm)
static sal_Int32 PointsToHmm(double fPoints)
constexpr OUStringLiteral gaListenerType
::cppu::ImplInheritanceHelper< ScVbaControlObjectBase, ov::excel::XButton > ScVbaButton_BASE
::cppu::ImplInheritanceHelper< ScVbaSheetObjectBase, ov::excel::XControlObject > ScVbaControlObject_BASE