21#include <core_resource.hxx>
23#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
24#include <com/sun/star/lang/NoSupportException.hpp>
33OFunctions::OFunctions(
const uno::Reference< report::XFunctionsSupplier >& _xParent,uno::Reference< uno::XComponentContext > context)
43OFunctions::~OFunctions()
47void SAL_CALL OFunctions::dispose()
49 cppu::WeakComponentImplHelperBase::dispose();
54void SAL_CALL OFunctions::disposing()
56 for (
auto& rFunction : m_aFunctions)
59 lang::EventObject aDisposeEvent( getXWeak() );
60 m_aContainerListeners.disposeAndClear( aDisposeEvent );
66uno::Reference< report::XFunction > SAL_CALL OFunctions::createFunction( )
72void SAL_CALL OFunctions::insertByIndex( ::sal_Int32
Index,
const uno::Any& aElement )
76 bool bAdd = (
Index ==
static_cast<sal_Int32
>(m_aFunctions.size()));
79 uno::Reference< report::XFunction > xFunction(aElement,uno::UNO_QUERY);
80 if ( !xFunction.is() )
81 throw lang::IllegalArgumentException(
RptResId(RID_STR_ARGUMENT_IS_NULL),*
this,2);
84 m_aFunctions.push_back(xFunction);
87 TFunctions::iterator aPos = m_aFunctions.begin();
88 ::std::advance(aPos,
Index);
89 m_aFunctions.insert(aPos, xFunction);
91 xFunction->setParent(*
this);
95 m_aContainerListeners.notifyEach(&container::XContainerListener::elementInserted,
aEvent);
99void SAL_CALL OFunctions::removeByIndex( ::sal_Int32
Index )
101 uno::Reference< report::XFunction > xFunction;
105 TFunctions::iterator aPos = m_aFunctions.begin();
106 ::std::advance(aPos,
Index);
108 m_aFunctions.erase(aPos);
109 xFunction->setParent(
nullptr);
112 m_aContainerListeners.notifyEach(&container::XContainerListener::elementRemoved,
aEvent);
116void SAL_CALL OFunctions::replaceByIndex( ::sal_Int32
Index,
const uno::Any& Element )
122 uno::Reference< report::XFunction > xFunction(Element,uno::UNO_QUERY);
123 if ( !xFunction.is() )
124 throw lang::IllegalArgumentException(
RptResId(RID_STR_ARGUMENT_IS_NULL),*
this,2);
125 TFunctions::iterator aPos = m_aFunctions.begin();
126 ::std::advance(aPos,
Index);
127 aOldElement <<= *aPos;
131 container::ContainerEvent
aEvent(
static_cast<container::XContainer*
>(
this),
uno::Any(
Index), Element, aOldElement);
132 m_aContainerListeners.notifyEach(&container::XContainerListener::elementReplaced,
aEvent);
136::sal_Int32 SAL_CALL OFunctions::getCount( )
139 return m_aFunctions.size();
146 TFunctions::const_iterator aPos = m_aFunctions.begin();
147 ::std::advance(aPos,
Index);
160 return !m_aFunctions.empty();
164uno::Reference< uno::XInterface > SAL_CALL OFunctions::getParent( )
169void SAL_CALL OFunctions::setParent(
const uno::Reference< uno::XInterface >& )
171 throw lang::NoSupportException();
175void SAL_CALL OFunctions::addContainerListener(
const uno::Reference< container::XContainerListener >& xListener )
177 m_aContainerListeners.addInterface(xListener);
180void SAL_CALL OFunctions::removeContainerListener(
const uno::Reference< container::XContainerListener >& xListener )
182 m_aContainerListeners.removeInterface(xListener);
185void OFunctions::checkIndex(sal_Int32 _nIndex)
188 throw lang::IndexOutOfBoundsException();
Reference< XComponentContext > m_xContext
css::uno::Type const & get()
OFunctions(const OFunctions &)=delete
OUString RptResId(TranslateId aId)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
::cppu::WeakComponentImplHelper< css::report::XFunctions > FunctionsBase