26#include <com/sun/star/beans/XPropertySet.hpp>
27#include <com/sun/star/container/XContainer.hpp>
28#include <com/sun/star/container/XContainerApproveBroadcaster.hpp>
29#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
30#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
31#include <com/sun/star/sdbc/XConnection.hpp>
32#include <com/sun/star/sdb/QueryDefinition.hpp>
34#include <osl/diagnose.h>
52using namespace ::
cppu;
60 const Reference< XNameContainer >& _rxCommandDefinitions
61 ,
const Reference< XConnection >& _rxConn
62 ,
const Reference< XComponentContext >& _rxORB,
65 ,m_pWarnings( _pWarnings )
66 ,m_xCommandDefinitions(_rxCommandDefinitions)
75 xContainer->addContainerListener(
this );
77 Reference< XContainerApproveBroadcaster > xContainerApprove(
m_xCommandDefinitions, UNO_QUERY_THROW );
78 xContainerApprove->addContainerApproveListener(
this );
83 const OUString* pDefinitionName = sDefinitionNames.getConstArray();
84 const OUString* pEnd = pDefinitionName + sDefinitionNames.getLength();
85 for ( ; pDefinitionName != pEnd; ++pDefinitionName )
95 const Reference< XNameContainer >& _rxCommandDefinitions
96 ,
const Reference< XConnection >& _rxConn
97 ,
const Reference< XComponentContext >& _rxORB,
102 _rxCommandDefinitions, _rxConn, _rxORB, _pWarnings));
121 if ( !m_xCommandDefinitions.is() )
125 Reference< XContainer > xContainer( m_xCommandDefinitions, UNO_QUERY );
126 xContainer->removeContainerListener(
this );
127 Reference< XContainerApproveBroadcaster > xContainerApprove( m_xCommandDefinitions, UNO_QUERY );
128 xContainerApprove->removeContainerApproveListener(
this );
130 m_xCommandDefinitions =
nullptr;
137 return "com.sun.star.sdb.dbaccess.OQueryContainer";
142 for (
const OUString& s : aSupported)
143 if (s == _rServiceName)
162 ResettableMutexGuard aGuard(
m_aMutex);
164 throw DisposedException( OUString(), *
this );
167 Reference< css::sdb::XQueryDefinition > xCommandDefinitionPart = css::sdb::QueryDefinition::create(
m_aContext);
169 ::comphelper::copyProperties( _rxDesc, Reference<XPropertySet>(xCommandDefinitionPart, UNO_QUERY_THROW) );
173 Reference< XContent > xNewObject(
implCreateWrapper( Reference< XContent>( xCommandDefinitionPart, UNO_QUERY_THROW ) ) );
175 OUString sNewObjectName;
182 catch (
const WrappedTargetException& e)
186 throw WrappedTargetRuntimeException(e.Message, e.Context, e.TargetException);
207 catch (
const WrappedTargetException& e)
209 throw WrappedTargetRuntimeException(e.Message, e.Context, e.TargetException);
218 throw NoSuchElementException(_rName,*
this);
221 throw DisposedException( OUString(), *
this );
231 if ((_nIndex<0) || (_nIndex>
getCount()))
232 throw IndexOutOfBoundsException();
235 throw DisposedException( OUString(), *
this );
247 Reference< XContent > xNewElement;
248 OUString sElementName;
249 _rEvent.Accessor >>= sElementName;
256 OSL_ENSURE(!sElementName.isEmpty(),
"OQueryContainer::elementInserted : invalid name !");
257 OSL_ENSURE(
m_aDocumentMap.find(sElementName) ==
m_aDocumentMap.end(),
"OQueryContainer::elementInserted : oops... we're inconsistent with our master container !");
258 if (sElementName.isEmpty() ||
hasByName(sElementName))
270 _rEvent.Accessor >>= sAccessor;
272 OSL_ENSURE(!sAccessor.isEmpty(),
"OQueryContainer::elementRemoved : invalid name !");
273 OSL_ENSURE(
m_aDocumentMap.find(sAccessor) !=
m_aDocumentMap.end(),
"OQueryContainer::elementRemoved : oops... we're inconsistent with our master container !");
274 if ( sAccessor.isEmpty() || !
hasByName(sAccessor) )
282 Reference< XContent > xNewElement;
284 _rEvent.Accessor >>= sAccessor;
288 OSL_ENSURE(!sAccessor.isEmpty(),
"OQueryContainer::elementReplaced : invalid name !");
289 OSL_ENSURE(
m_aDocumentMap.find(sAccessor) !=
m_aDocumentMap.end(),
"OQueryContainer::elementReplaced : oops... we're inconsistent with our master container !");
290 if (sAccessor.isEmpty() || !
hasByName(sAccessor))
302 OSL_VERIFY( Event.Accessor >>=
sName );
303 Reference< XContent > xElement( Event.Element, UNO_QUERY_THROW );
305 Reference< XVeto > xReturn;
312 xReturn =
new Veto( ::cppu::getCaughtException() );
331 OSL_FAIL(
"OQueryContainer::disposing : nobody should dispose the CommandDefinition container before disposing my connection !");
336 Reference< XContent > xSource(_rSource.Source, UNO_QUERY);
340 if ( xSource == document.second.get() )
352 return "application/vnd.org.openoffice.DatabaseQueryContainer";
363 Reference<XNameContainer> xContainer(_rxCommandDesc,UNO_QUERY);
364 Reference< XContent > xReturn;
365 if ( xContainer .is() )
373 xReturn = pNewObject;
mutable::osl::Mutex m_aMutex
const css::uno::Reference< css::uno::XComponentContext > m_aContext
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
void insert(const OUString &_rName, TContentPtr _pDefinition)
const ODefinitionContainer_Impl & getDefinitions() const
void implAppend(const OUString &_rName, const css::uno::Reference< css::ucb::XContent > &_rxNewObject)
append a new object to the container.
virtual void SAL_CALL replaceByName(const OUString &_rName, const css::uno::Any &aElement) override
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
void notifyByName(::osl::ResettableMutexGuard &_rGuard, const OUString &_rName, const css::uno::Reference< css::ucb::XContent > &_xNewElement, const css::uno::Reference< css::ucb::XContent > &xOldElement, ContainerOperation _eOperation, ListenerType _eType)
notifies our container/approve listeners
virtual void SAL_CALL insertByName(const OUString &_rName, const css::uno::Any &aElement) override
virtual void SAL_CALL disposing() override
virtual OUString SAL_CALL getImplementationName() override
const PContainerApprove & getElementApproval() const
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 _nIndex) override
virtual void SAL_CALL removeByName(const OUString &_rName) override
std::vector< Documents::iterator > m_aDocuments
void setElementApproval(PContainerApprove _pElementApproval)
Additionally to our own approvals which new elements must pass, derived classes can specify an additi...
virtual sal_Bool SAL_CALL hasElements() override
static rtl::Reference< OQueryContainer > create(const css::uno::Reference< css::container::XNameContainer > &_rxCommandDefinitions, const css::uno::Reference< css::sdbc::XConnection > &_rxConn, const css::uno::Reference< css::uno::XComponentContext > &_rxORB, ::dbtools::WarningsContainer *_pWarnings)
css::uno::Reference< css::container::XNameContainer > m_xCommandDefinitions
virtual void SAL_CALL dropByName(const OUString &elementName) override
virtual bool checkExistence(const OUString &_rName) override
quickly checks if there already is an element with a given name.
virtual css::uno::Reference< css::ucb::XContent > createObject(const OUString &_rName) override
create an object from its persistent data within the configuration.
virtual void SAL_CALL appendByDescriptor(const css::uno::Reference< css::beans::XPropertySet > &descriptor) override
css::uno::Reference< css::ucb::XContent > implCreateWrapper(const OUString &_rName)
create a query object wrapping a CommandDefinition given by name.
virtual ~OQueryContainer() override
virtual css::uno::Reference< css::util::XVeto > SAL_CALL approveRemoveElement(const css::container::ContainerEvent &Event) override
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor() override
virtual void SAL_CALL disposing() override
css::uno::Reference< css::sdbc::XConnection > m_xConnection
virtual void SAL_CALL elementInserted(const css::container::ContainerEvent &Event) override
virtual css::uno::Reference< css::util::XVeto > SAL_CALL approveReplaceElement(const css::container::ContainerEvent &Event) override
virtual sal_Int32 SAL_CALL getCount() override
virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent &Event) override
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent &Event) override
virtual void SAL_CALL dropByIndex(sal_Int32 index) override
virtual OUString determineContentType() const override
AggregateAction m_eDoingCurrently
::dbtools::WarningsContainer * m_pWarnings
OQueryContainer(const css::uno::Reference< css::container::XNameContainer > &_rxCommandDefinitions, const css::uno::Reference< css::sdbc::XConnection > &_rxConn, const css::uno::Reference< css::uno::XComponentContext > &_rxORB, ::dbtools::WarningsContainer *_pWarnings)
ctor of the container.
virtual css::uno::Reference< css::util::XVeto > SAL_CALL approveInsertElement(const css::container::ContainerEvent &Event) override
implements css::util::XVeto
void disposeComponent(css::uno::Reference< TYPE > &_rxComp)
std::shared_ptr< OContentHelper_Impl > TContentPtr
std::shared_ptr< T > make_shared(Args &&... args)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Reference< XConnection > m_xConnection
IMPLEMENT_FORWARD_XTYPEPROVIDER2(OStatement, OStatementBase, OStatement_IFACE)
IMPLEMENT_FORWARD_XINTERFACE2(OStatement, OStatementBase, OStatement_IFACE)
constexpr OUStringLiteral SERVICE_SDBCX_CONTAINER
constexpr OUStringLiteral SERVICE_SDB_QUERIES
constexpr OUStringLiteral PROPERTY_NAME(u"Name")