19#ifndef INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_TOOLS_HXX
20#define INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_TOOLS_HXX
22#include <com/sun/star/report/XSection.hpp>
23#include <com/sun/star/awt/Point.hpp>
24#include <com/sun/star/awt/Size.hpp>
25#include <com/sun/star/container/XChild.hpp>
26#include <com/sun/star/lang/XMultiServiceFactory.hpp>
30#include <osl/diagnose.h>
40 css::uno::Reference< css::report::XSection>
lcl_getSection(
const css::uno::Reference< css::uno::XInterface>& _xReportComponent);
49 ,
const css::uno::Reference< css::uno::XInterface >& ExceptionContext_
50 ,sal_Int16 ArgumentPosition_);
60 const css::uno::Reference< css::report::XReportComponent>& _xReportComponent
61 ,
const css::uno::Reference< css::lang::XMultiServiceFactory>& _xFactory
62 ,
const OUString& _sServiceName);
67 template<
typename T>
static void setSize(
const css::awt::Size& aSize,T* _pShape)
69 OSL_ENSURE(aSize.Width >= 0 && aSize.Height >= 0,
"Illegal width or height!");
71 ::osl::MutexGuard aGuard(_pShape->m_aMutex);
72 if ( _pShape->m_aProps.aComponent.m_xShape.is() )
74 css::awt::Size aOldSize = _pShape->m_aProps.aComponent.m_xShape->getSize();
75 if ( aOldSize.Height != aSize.Height || aOldSize.Width != aSize.Width )
77 _pShape->m_aProps.aComponent.m_nWidth = aOldSize.Width;
78 _pShape->m_aProps.aComponent.m_nHeight = aOldSize.Height;
79 _pShape->m_aProps.aComponent.m_xShape->setSize(aSize);
82 _pShape->set(
PROPERTY_WIDTH,aSize.Width,_pShape->m_aProps.aComponent.m_nWidth);
83 _pShape->set(
PROPERTY_HEIGHT,aSize.Height,_pShape->m_aProps.aComponent.m_nHeight);
85 template<
typename T>
static css::awt::Size
getSize( T* _pShape )
87 ::osl::MutexGuard aGuard(_pShape->m_aMutex);
88 if ( _pShape->m_aProps.aComponent.m_xShape.is() )
90 css::awt::Size aSize = _pShape->m_aProps.aComponent.m_xShape->getSize();
91 OSL_ENSURE(aSize.Width >= 0 && aSize.Height >= 0,
"Illegal width or height!");
94 return css::awt::Size(_pShape->m_aProps.aComponent.m_nWidth,_pShape->m_aProps.aComponent.m_nHeight);
97 template<
typename T>
static void setPosition(
const css::awt::Point& _aPosition ,T* _pShape)
102 ::osl::MutexGuard aGuard(_pShape->m_aMutex);
103 css::awt::Point aOldPos;
104 aOldPos.X = _pShape->m_aProps.aComponent.m_nPosX;
105 aOldPos.Y = _pShape->m_aProps.aComponent.m_nPosY;
107 css::awt::Point aPosition(_aPosition);
108 if ( _pShape->m_aProps.aComponent.m_xShape.is() )
110 aOldPos = _pShape->m_aProps.aComponent.m_xShape->getPosition();
111 if ( aOldPos.X != aPosition.X || aOldPos.Y != aPosition.Y )
113 _pShape->m_aProps.aComponent.m_nPosX = aOldPos.X;
114 _pShape->m_aProps.aComponent.m_nPosY = aOldPos.Y;
115 _pShape->m_aProps.aComponent.m_xShape->setPosition(aPosition);
121 template<
typename T>
static css::awt::Point
getPosition(T* _pShape)
123 ::osl::MutexGuard aGuard(_pShape->m_aMutex);
124 if ( _pShape->m_aProps.aComponent.m_xShape.is() )
126 css::awt::Point aPosition = _pShape->m_aProps.aComponent.m_xShape->getPosition();
129 return css::awt::Point(_pShape->m_aProps.aComponent.m_nPosX,_pShape->m_aProps.aComponent.m_nPosY);
131 template<
typename T>
static void setParent(
const css::uno::Reference< css::uno::XInterface >& Parent, T* _pShape)
133 ::osl::MutexGuard aGuard(_pShape->m_aMutex);
134 _pShape->m_aProps.aComponent.m_xParent = css::uno::Reference< css::container::XChild >(
Parent,css::uno::UNO_QUERY);
135 css::uno::Reference< css::container::XChild > xChild;
138 xChild->setParent(
Parent);
140 template<
typename T>
static css::uno::Reference< css::uno::XInterface >
getParent( T* _pShape )
142 ::osl::MutexGuard aGuard(_pShape->m_aMutex);
143 css::uno::Reference< css::container::XChild > xChild;
146 return xChild->getParent();
147 return _pShape->m_aProps.aComponent.m_xParent;
static void setSize(const css::awt::Size &aSize, T *_pShape)
static css::awt::Size getSize(T *_pShape)
static void setPosition(const css::awt::Point &_aPosition, T *_pShape)
static css::awt::Point getPosition(T *_pShape)
static css::uno::Reference< css::uno::XInterface > getParent(T *_pShape)
static void setParent(const css::uno::Reference< css::uno::XInterface > &Parent, T *_pShape)
bool query_aggregation(const css::uno::Reference< css::uno::XAggregation > &_rxAggregate, css::uno::Reference< iface > &_rxOut)
uno::Reference< report::XSection > lcl_getSection(const uno::Reference< uno::XInterface > &_xReportComponent)
void throwIllegallArgumentException(std::u16string_view _sTypeName, const uno::Reference< uno::XInterface > &ExceptionContext_, sal_Int16 ArgumentPosition_)
uno::Reference< util::XCloneable > cloneObject(const uno::Reference< report::XReportComponent > &_xReportComponent, const uno::Reference< lang::XMultiServiceFactory > &_xFactory, const OUString &_sServiceName)
constexpr OUStringLiteral PROPERTY_HEIGHT
constexpr OUStringLiteral PROPERTY_POSITIONX
constexpr OUStringLiteral PROPERTY_POSITIONY
constexpr OUStringLiteral PROPERTY_WIDTH