LibreOffice Module dbaccess (master) 1
ContentHelper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#pragma once
20
21#include <com/sun/star/ucb/XContent.hpp>
22#include <com/sun/star/ucb/XCommandProcessor.hpp>
23#include <com/sun/star/beans/XPropertiesChangeNotifier.hpp>
24#include <com/sun/star/beans/XPropertyContainer.hpp>
25#include <com/sun/star/lang/XServiceInfo.hpp>
26#include <com/sun/star/lang/XInitialization.hpp>
27#include <com/sun/star/sdbc/XRow.hpp>
28#include <com/sun/star/uno/XComponentContext.hpp>
33#include <com/sun/star/beans/Property.hpp>
34#include <com/sun/star/container/XChild.hpp>
35#include <com/sun/star/sdbcx/XRename.hpp>
37#include <memory>
38
39namespace com::sun::star::beans { struct PropertyValue; }
40
41namespace dbaccess
42{
43 class ODatabaseModelImpl;
45 {
46 OUString aTitle; // Title
47 ::std::optional< OUString >
48 aContentType; // ContentType (aka MediaType aka MimeType)
49 bool bIsDocument; // IsDocument
50 bool bIsFolder; // IsFolder
51 bool bAsTemplate; // AsTemplate
52 OUString sPersistentName;// persistent name of the document
53
55 :bIsDocument( true )
56 ,bIsFolder( false )
57 ,bAsTemplate( false )
58 {
59 }
60 };
61
63 {
64 public:
66 virtual ~OContentHelper_Impl();
67
69 ODatabaseModelImpl* m_pDataSource; // this will stay alive as long as the content exists
70 };
71
72 typedef std::shared_ptr<OContentHelper_Impl> TContentPtr;
73
76 typedef ::cppu::WeakComponentImplHelper< css::ucb::XContent
77 , css::ucb::XCommandProcessor
78 , css::lang::XServiceInfo
79 , css::beans::XPropertiesChangeNotifier
80 , css::beans::XPropertyContainer
81 , css::lang::XInitialization
82 , css::container::XChild
83 , css::sdbcx::XRename
85
88 {
89 css::uno::Sequence< css::uno::Any >
90 setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& rValues );
91
92 void impl_rename_throw(const OUString& _sNewName,bool _bNotify = true);
93
94 protected:
97 css::uno::Reference< css::uno::XInterface >
99 const css::uno::Reference< css::uno::XComponentContext >
101 const ::connectivity::SQLError m_aErrorHelper;
103 sal_uInt32 m_nCommandId;
104
105 // helper
106 virtual void SAL_CALL disposing() override;
107
109
115 void notifyPropertiesChange( const css::uno::Sequence< css::beans::PropertyChangeEvent >& evt ) const;
116
117 OUString impl_getHierarchicalName( bool _includingRootContainer ) const;
118
119 public:
120
121 OContentHelper( const css::uno::Reference< css::uno::XComponentContext >& _xORB
122 ,const css::uno::Reference< css::uno::XInterface >& _xParentContainer
123 ,TContentPtr _pImpl
124 );
125
126 // css::lang::XTypeProvider
127 virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) override;
128
129 // css::lang::XServiceInfo
130 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
131 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
132 virtual OUString SAL_CALL getImplementationName( ) override;
133
134 // XContent
135 virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL getIdentifier( ) override ;
136 virtual OUString SAL_CALL getContentType( ) override ;
137 virtual void SAL_CALL addContentEventListener( const css::uno::Reference< css::ucb::XContentEventListener >& Listener ) override ;
138 virtual void SAL_CALL removeContentEventListener( const css::uno::Reference< css::ucb::XContentEventListener >& Listener ) override ;
139
140 // XCommandProcessor
141 virtual sal_Int32 SAL_CALL createCommandIdentifier( ) override ;
142 virtual css::uno::Any SAL_CALL execute( const css::ucb::Command& aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override ;
143 virtual void SAL_CALL abort( sal_Int32 CommandId ) override ;
144
145 // XPropertiesChangeNotifier
146 virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) override ;
147 virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Sequence< OUString >& PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) override ;
148
149 // XPropertyContainer
150 virtual void SAL_CALL addProperty( const OUString& Name, sal_Int16 Attributes, const css::uno::Any& DefaultValue ) override ;
151 virtual void SAL_CALL removeProperty( const OUString& Name ) override ;
152
153 // XInitialization
154 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
155
156 // css::container::XChild
157 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override;
158 virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override;
159
160 // XRename
161 virtual void SAL_CALL rename( const OUString& newName ) override;
162
163 const ContentProperties& getContentProperties() const { return m_pImpl->m_aProps; }
164 css::uno::Reference< css::sdbc::XRow >
165 getPropertyValues( const css::uno::Sequence< css::beans::Property >& rProperties );
166
167 const css::uno::Reference< css::uno::XComponentContext >& getContext() const { return m_aContext; }
168
169 const TContentPtr& getImpl() const { return m_pImpl; }
170
171 protected:
172 virtual OUString determineContentType() const = 0;
173 };
174
175} // namespace dbaccess
176
177/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ODatabaseModelImpl * m_pDataSource
virtual void SAL_CALL addContentEventListener(const css::uno::Reference< css::ucb::XContentEventListener > &Listener) override
virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface > &Parent) override
css::uno::Sequence< css::uno::Any > setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &rValues)
const ContentProperties & getContentProperties() const
OUString impl_getHierarchicalName(bool _includingRootContainer) const
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
::comphelper::OInterfaceContainerHelper3< css::ucb::XContentEventListener > m_aContentListeners
const TContentPtr & getImpl() const
virtual OUString determineContentType() const =0
void notifyPropertiesChange(const css::uno::Sequence< css::beans::PropertyChangeEvent > &evt) const
This method can be used to propagate changes of property values.
virtual void SAL_CALL disposing() override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
virtual sal_Int32 SAL_CALL createCommandIdentifier() override
const css::uno::Reference< css::uno::XComponentContext > m_aContext
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual css::uno::Any SAL_CALL execute(const css::ucb::Command &aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment) override
virtual void SAL_CALL removeContentEventListener(const css::uno::Reference< css::ucb::XContentEventListener > &Listener) override
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) override
virtual OUString SAL_CALL getImplementationName() override
const ::connectivity::SQLError m_aErrorHelper
virtual void SAL_CALL addProperty(const OUString &Name, sal_Int16 Attributes, const css::uno::Any &DefaultValue) override
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL getIdentifier() override
OContentHelper(const css::uno::Reference< css::uno::XComponentContext > &_xORB, const css::uno::Reference< css::uno::XInterface > &_xParentContainer, TContentPtr _pImpl)
virtual void SAL_CALL abort(sal_Int32 CommandId) override
virtual OUString SAL_CALL getContentType() override
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Sequence< OUString > &PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) override
PropertyChangeListenerContainer m_aPropertyChangeListeners
void impl_rename_throw(const OUString &_sNewName, bool _bNotify=true)
virtual void SAL_CALL rename(const OUString &newName) override
css::uno::Reference< css::uno::XInterface > m_xParentContainer
virtual void SAL_CALL removeProperty(const OUString &Name) override
const css::uno::Reference< css::uno::XComponentContext > & getContext() const
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Reference< css::sdbc::XRow > getPropertyValues(const css::uno::Sequence< css::beans::Property > &rProperties)
Sequence< PropertyValue > aArguments
Definition: intercept.cxx:88
std::shared_ptr< OContentHelper_Impl > TContentPtr
comphelper::OMultiTypeInterfaceContainerHelperVar3< css::beans::XPropertiesChangeListener, OUString > PropertyChangeListenerContainer
::cppu::WeakComponentImplHelper< css::ucb::XContent, css::ucb::XCommandProcessor, css::lang::XServiceInfo, css::beans::XPropertiesChangeNotifier, css::beans::XPropertyContainer, css::lang::XInitialization, css::container::XChild, css::sdbcx::XRename > OContentHelper_COMPBASE
::std::optional< OUString > aContentType
unsigned char sal_Bool