build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / dbaccess / source / core / inc / ContentHelper.hxx
blob287e13bc332f149bf81ef07bb5170066494eb2db
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_CONTENTHELPER_HXX
20 #define INCLUDED_DBACCESS_SOURCE_CORE_INC_CONTENTHELPER_HXX
22 #include <com/sun/star/ucb/XContent.hpp>
23 #include <com/sun/star/ucb/XCommandProcessor.hpp>
24 #include <com/sun/star/beans/XPropertiesChangeNotifier.hpp>
25 #include <com/sun/star/beans/XPropertyContainer.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
28 #include <com/sun/star/lang/XInitialization.hpp>
29 #include <com/sun/star/container/XNameAccess.hpp>
30 #include <com/sun/star/sdbc/XRow.hpp>
31 #include <com/sun/star/embed/XStorage.hpp>
32 #include <com/sun/star/embed/XEmbeddedObject.hpp>
33 #include <com/sun/star/lang/XUnoTunnel.hpp>
34 #include <cppuhelper/compbase.hxx>
35 #include <cppuhelper/basemutex.hxx>
36 #include <comphelper/interfacecontainer2.hxx>
37 #include <comphelper/uno3.hxx>
38 #include <com/sun/star/beans/Property.hpp>
39 #include <com/sun/star/container/XChild.hpp>
40 #include <com/sun/star/sdbcx/XRename.hpp>
41 #include <connectivity/sqlerror.hxx>
42 #include <memory>
44 namespace com { namespace sun { namespace star { namespace beans {
45 struct PropertyValue;
46 } } } }
48 namespace dbaccess
50 class ODatabaseModelImpl;
51 struct ContentProperties
53 OUString aTitle; // Title
54 ::boost::optional< OUString >
55 aContentType; // ContentType (aka MediaType aka MimeType)
56 bool bIsDocument; // IsDocument
57 bool bIsFolder; // IsFolder
58 bool bAsTemplate; // AsTemplate
59 OUString sPersistentName;// persistent name of the document
61 ContentProperties()
62 :bIsDocument( true )
63 ,bIsFolder( false )
64 ,bAsTemplate( false )
69 class OContentHelper_Impl
71 public:
72 OContentHelper_Impl();
73 virtual ~OContentHelper_Impl();
75 ContentProperties m_aProps;
76 ODatabaseModelImpl* m_pDataSource; // this will stay alive as long as the content exists
79 typedef std::shared_ptr<OContentHelper_Impl> TContentPtr;
81 typedef cppu::OMultiTypeInterfaceContainerHelperVar<OUString>
82 PropertyChangeListenerContainer;
83 typedef ::cppu::BaseMutex OContentHelper_MBASE;
84 typedef ::cppu::WeakComponentImplHelper< css::ucb::XContent
85 , css::ucb::XCommandProcessor
86 , css::lang::XServiceInfo
87 , css::beans::XPropertiesChangeNotifier
88 , css::beans::XPropertyContainer
89 , css::lang::XInitialization
90 , css::lang::XUnoTunnel
91 , css::container::XChild
92 , css::sdbcx::XRename
93 > OContentHelper_COMPBASE;
95 class OContentHelper : public OContentHelper_MBASE
96 ,public OContentHelper_COMPBASE
98 css::uno::Sequence< css::uno::Any >
99 setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& rValues,
100 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
102 void impl_rename_throw(const OUString& _sNewName,bool _bNotify = true);
104 protected:
105 ::comphelper::OInterfaceContainerHelper2 m_aContentListeners;
106 PropertyChangeListenerContainer m_aPropertyChangeListeners;
107 css::uno::Reference< css::uno::XInterface >
108 m_xParentContainer;
109 const css::uno::Reference< css::uno::XComponentContext >
110 m_aContext;
111 const ::connectivity::SQLError m_aErrorHelper;
112 TContentPtr m_pImpl;
113 sal_uInt32 m_nCommandId;
115 // helper
116 virtual void SAL_CALL disposing() override;
118 void notifyDataSourceModified();
121 * This method can be used to propagate changes of property values.
123 * @param evt is a sequence of property change events.
125 void notifyPropertiesChange( const css::uno::Sequence< css::beans::PropertyChangeEvent >& evt ) const;
127 OUString impl_getHierarchicalName( bool _includingRootContainer ) const;
129 public:
131 OContentHelper( const css::uno::Reference< css::uno::XComponentContext >& _xORB
132 ,const css::uno::Reference< css::uno::XInterface >& _xParentContainer
133 ,const TContentPtr& _pImpl
136 // css::lang::XTypeProvider
137 virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(css::uno::RuntimeException, std::exception) override;
138 static css::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
139 // css::lang::XServiceInfo
140 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(css::uno::RuntimeException, std::exception) override;
141 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(css::uno::RuntimeException, std::exception) override;
142 virtual OUString SAL_CALL getImplementationName( ) throw (css::uno::RuntimeException, std::exception) override;
144 // XContent
145 virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL getIdentifier( ) throw (css::uno::RuntimeException, std::exception) override ;
146 virtual OUString SAL_CALL getContentType( ) throw (css::uno::RuntimeException, std::exception) override ;
147 virtual void SAL_CALL addContentEventListener( const css::uno::Reference< css::ucb::XContentEventListener >& Listener ) throw (css::uno::RuntimeException, std::exception) override ;
148 virtual void SAL_CALL removeContentEventListener( const css::uno::Reference< css::ucb::XContentEventListener >& Listener ) throw (css::uno::RuntimeException, std::exception) override ;
150 // XCommandProcessor
151 virtual sal_Int32 SAL_CALL createCommandIdentifier( ) throw (css::uno::RuntimeException, std::exception) override ;
152 virtual css::uno::Any SAL_CALL execute( const css::ucb::Command& aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) throw (css::uno::Exception, css::ucb::CommandAbortedException, css::uno::RuntimeException, std::exception) override ;
153 virtual void SAL_CALL abort( sal_Int32 CommandId ) throw (css::uno::RuntimeException, std::exception) override ;
155 // XPropertiesChangeNotifier
156 virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) throw (css::uno::RuntimeException, std::exception) override ;
157 virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Sequence< OUString >& PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) throw (css::uno::RuntimeException, std::exception) override ;
159 // XPropertyContainer
160 virtual void SAL_CALL addProperty( const OUString& Name, sal_Int16 Attributes, const css::uno::Any& DefaultValue ) throw (css::beans::PropertyExistException, css::beans::IllegalTypeException, css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) override ;
161 virtual void SAL_CALL removeProperty( const OUString& Name ) throw (css::beans::UnknownPropertyException, css::beans::NotRemoveableException, css::uno::RuntimeException, std::exception) override ;
163 // XInitialization
164 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw(css::uno::Exception, css::uno::RuntimeException, std::exception) override;
166 // css::lang::XUnoTunnel
167 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) throw(css::uno::RuntimeException, std::exception) override;
168 static OContentHelper* getImplementation( const css::uno::Reference< css::uno::XInterface >& _rxComponent );
170 // css::container::XChild
171 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) throw (css::uno::RuntimeException, std::exception) override;
172 virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) throw (css::lang::NoSupportException, css::uno::RuntimeException, std::exception) override;
174 // XRename
175 virtual void SAL_CALL rename( const OUString& newName ) throw (css::sdbc::SQLException, css::container::ElementExistException, css::uno::RuntimeException, std::exception) override;
177 inline const ContentProperties& getContentProperties() const { return m_pImpl->m_aProps; }
178 css::uno::Reference< css::sdbc::XRow >
179 getPropertyValues( const css::uno::Sequence< css::beans::Property >& rProperties );
181 const css::uno::Reference< css::uno::XComponentContext >& getContext() const { return m_aContext; }
183 const TContentPtr& getImpl() const { return m_pImpl; }
185 protected:
186 virtual OUString determineContentType() const = 0;
189 } // namespace dbaccess
191 #endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_CONTENTHELPER_HXX
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */