merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / core / inc / ContentHelper.hxx
blobe1657169c7380229e4cb04c36b6048801ac55e95
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ContentHelper.hxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef DBA_CONTENTHELPER_HXX
31 #define DBA_CONTENTHELPER_HXX
33 #ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
34 #include <com/sun/star/ucb/XContent.hpp>
35 #endif
36 #ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_
37 #include <com/sun/star/ucb/XCommandProcessor.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_BEANS_XPROPERTIESCHANGENOTIFIER_HPP_
40 #include <com/sun/star/beans/XPropertiesChangeNotifier.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCONTAINER_HPP_
43 #include <com/sun/star/beans/XPropertyContainer.hpp>
44 #endif
45 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
46 #include <com/sun/star/lang/XServiceInfo.hpp>
47 #endif
48 #ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
49 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
50 #endif
51 #ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
52 #include <com/sun/star/lang/XInitialization.hpp>
53 #endif
54 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
55 #include <com/sun/star/container/XNameAccess.hpp>
56 #endif
57 #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
58 #include <com/sun/star/sdbc/XRow.hpp>
59 #endif
60 #ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_
61 #include <com/sun/star/embed/XStorage.hpp>
62 #endif
63 #ifndef _COM_SUN_STAR_EMBED_XEMBEDDEDOBJECT_HPP_
64 #include <com/sun/star/embed/XEmbeddedObject.hpp>
65 #endif
66 #ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
67 #include <com/sun/star/lang/XUnoTunnel.hpp>
68 #endif
69 #ifndef _CPPUHELPER_COMPBASE9_HXX_
70 #include <cppuhelper/compbase9.hxx>
71 #endif
72 #ifndef _COMPHELPER_BROADCASTHELPER_HXX_
73 #include <comphelper/broadcasthelper.hxx>
74 #endif
75 #ifndef COMPHELPER_COMPONENTCONTEXT_HXX
76 #include <comphelper/componentcontext.hxx>
77 #endif
78 #ifndef _COMPHELPER_UNO3_HXX_
79 #include <comphelper/uno3.hxx>
80 #endif
81 #ifndef _COMPHELPER_STLTYPES_HXX_
82 #include <comphelper/stl_types.hxx>
83 #endif
84 #ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_
85 #include <com/sun/star/beans/Property.hpp>
86 #endif
87 #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
88 #include <com/sun/star/container/XChild.hpp>
89 #endif
90 #ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_
91 #include <com/sun/star/sdbcx/XRename.hpp>
92 #endif
93 #ifndef CONNECTIVITY_SQLERROR_HXX
94 #include <connectivity/sqlerror.hxx>
95 #endif
96 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
97 #include <boost/shared_ptr.hpp>
98 #endif
100 namespace dbaccess
102 class ODatabaseModelImpl;
103 struct ContentProperties
105 ::rtl::OUString aTitle; // Title
106 ::boost::optional< ::rtl::OUString >
107 aContentType; // ContentType (aka MediaType aka MimeType)
108 sal_Bool bIsDocument; // IsDocument
109 sal_Bool bIsFolder; // IsFolder
110 sal_Bool bAsTemplate; // AsTemplate
111 ::rtl::OUString sPersistentName;// persistent name of the document
113 // @@@ Add other properties supported by your content.
115 ContentProperties()
116 : bIsDocument( sal_True ), bIsFolder( sal_False ), bAsTemplate( sal_False ) {}
119 class OContentHelper_Impl
121 public:
122 OContentHelper_Impl();
123 virtual ~OContentHelper_Impl();
125 ContentProperties m_aProps;
126 ODatabaseModelImpl* m_pDataSource; // this will stay alive as long as the content exists
129 typedef ::boost::shared_ptr<OContentHelper_Impl> TContentPtr;
132 typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< ::rtl::OUString,
133 ::comphelper::UStringHash,
134 ::comphelper::UStringEqual
135 > PropertyChangeListenerContainer;
136 typedef ::comphelper::OBaseMutex OContentHelper_MBASE;
137 typedef ::cppu::WeakComponentImplHelper9 < ::com::sun::star::ucb::XContent
138 , ::com::sun::star::ucb::XCommandProcessor
139 , ::com::sun::star::lang::XServiceInfo
140 , ::com::sun::star::beans::XPropertiesChangeNotifier
141 , ::com::sun::star::beans::XPropertyContainer
142 , ::com::sun::star::lang::XInitialization
143 , ::com::sun::star::lang::XUnoTunnel
144 , ::com::sun::star::container::XChild
145 , ::com::sun::star::sdbcx::XRename
146 > OContentHelper_COMPBASE;
148 class OContentHelper : public OContentHelper_MBASE
149 ,public OContentHelper_COMPBASE
151 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
152 setPropertyValues( const ::com::sun::star::uno::Sequence<
153 ::com::sun::star::beans::PropertyValue >& rValues,
154 const ::com::sun::star::uno::Reference<
155 ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
156 com::sun::star::uno::Sequence< com::sun::star::beans::Property >
157 getProperties( const com::sun::star::uno::Reference<
158 com::sun::star::ucb::XCommandEnvironment > & xEnv );
160 void impl_rename_throw(const ::rtl::OUString& _sNewName,bool _bNotify = true);
162 protected:
163 ::cppu::OInterfaceContainerHelper m_aContentListeners;
164 PropertyChangeListenerContainer m_aPropertyChangeListeners;
165 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
166 m_xParentContainer;
167 const ::comphelper::ComponentContext m_aContext;
168 const ::connectivity::SQLError m_aErrorHelper;
169 TContentPtr m_pImpl;
170 sal_uInt32 m_nCommandId;
172 // helper
173 virtual void SAL_CALL disposing();
175 virtual void notifyDataSourceModified();
178 * This method can be used to propagate changes of property values.
180 * @param evt is a sequence of property change events.
182 void notifyPropertiesChange( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyChangeEvent >& evt ) const;
184 ::rtl::OUString impl_getHierarchicalName( bool _includingRootContainer ) const;
186 public:
188 OContentHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
189 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParentContainer
190 ,const TContentPtr& _pImpl
193 // com::sun::star::lang::XTypeProvider
194 virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
195 static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
196 // ::com::sun::star::lang::XServiceInfo
197 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
198 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
199 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
201 // XContent
202 virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier > SAL_CALL getIdentifier( ) throw (::com::sun::star::uno::RuntimeException) ;
203 virtual ::rtl::OUString SAL_CALL getContentType( ) throw (::com::sun::star::uno::RuntimeException) ;
204 virtual void SAL_CALL addContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
205 virtual void SAL_CALL removeContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
207 // XCommandProcessor
208 virtual sal_Int32 SAL_CALL createCommandIdentifier( ) throw (::com::sun::star::uno::RuntimeException) ;
209 virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::ucb::Command& aCommand, sal_Int32 CommandId, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& Environment ) throw (::com::sun::star::uno::Exception, ::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::RuntimeException) ;
210 virtual void SAL_CALL abort( sal_Int32 CommandId ) throw (::com::sun::star::uno::RuntimeException) ;
212 // XPropertiesChangeNotifier
213 virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
214 virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
216 // XPropertyContainer
217 virtual void SAL_CALL addProperty( const ::rtl::OUString& Name, sal_Int16 Attributes, const ::com::sun::star::uno::Any& DefaultValue ) throw (::com::sun::star::beans::PropertyExistException, ::com::sun::star::beans::IllegalTypeException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) ;
218 virtual void SAL_CALL removeProperty( const ::rtl::OUString& Name ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::NotRemoveableException, ::com::sun::star::uno::RuntimeException) ;
220 // XInitialization
221 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
223 // com::sun::star::lang::XUnoTunnel
224 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
225 static OContentHelper* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent );
227 // ::com::sun::star::container::XChild
228 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException);
229 virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
231 // XRename
232 virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
234 inline const ContentProperties& getContentProperties() const { return m_pImpl->m_aProps; }
235 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
236 getPropertyValues( const ::com::sun::star::uno::Sequence<
237 ::com::sun::star::beans::Property >& rProperties );
239 inline TContentPtr getImpl() const { return m_pImpl; }
241 protected:
242 virtual ::rtl::OUString determineContentType() const = 0;
245 //........................................................................
246 } // namespace dbaccess
247 //........................................................................
248 #endif // DBA_CONTENTHELPER_HXX