fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / core / dataaccess / documentdefinition.hxx
blob60616d2f1cb3115a7ed16bdb30fc04e5ffbb1c07
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 .
20 #ifndef INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DOCUMENTDEFINITION_HXX
21 #define INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DOCUMENTDEFINITION_HXX
23 #include <cppuhelper/propshlp.hxx>
24 #include <cppuhelper/implbase4.hxx>
25 #include "ContentHelper.hxx"
26 #include <comphelper/propertystatecontainer.hxx>
27 #include <comphelper/proparrhlp.hxx>
28 #include "apitools.hxx"
29 #include <comphelper/uno3.hxx>
30 #include <com/sun/star/sdbc/XConnection.hpp>
31 #include <com/sun/star/frame/XComponentLoader.hpp>
32 #include <com/sun/star/frame/XController.hpp>
33 #include <com/sun/star/embed/XStateChangeListener.hpp>
34 #include <com/sun/star/sdb/XSubDocument.hpp>
35 #include <com/sun/star/util/XCloseListener.hpp>
36 #include <com/sun/star/container/XHierarchicalName.hpp>
38 namespace comphelper
40 class NamedValueCollection;
43 namespace dbaccess
46 class OInterceptor;
47 class OEmbeddedClientHelper;
48 // ODocumentDefinition - a database "document" which is simply a link to a real
49 // document
51 typedef ::cppu::ImplHelper4 < ::com::sun::star::embed::XComponentSupplier
52 , ::com::sun::star::sdb::XSubDocument
53 , ::com::sun::star::util::XCloseListener
54 , ::com::sun::star::container::XHierarchicalName
55 > ODocumentDefinition_Base;
57 class ODocumentDefinition
58 :public OContentHelper
59 ,public ::comphelper::OPropertyStateContainer
60 ,public ::comphelper::OPropertyArrayUsageHelper< ODocumentDefinition >
61 ,public ODocumentDefinition_Base
63 ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject> m_xEmbeddedObject;
64 ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStateChangeListener > m_xListener;
65 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xLastKnownConnection;
67 OInterceptor* m_pInterceptor;
68 bool m_bForm; // <TRUE/> if it is a form
69 bool m_bOpenInDesign;
70 bool m_bInExecute;
71 bool m_bRemoveListener;
72 OEmbeddedClientHelper* m_pClientHelper;
74 protected:
75 virtual ~ODocumentDefinition();
77 public:
79 ODocumentDefinition(
80 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContainer,
81 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&,
82 const TContentPtr& _pImpl,
83 bool _bForm
86 void initialLoad(
87 const ::com::sun::star::uno::Sequence< sal_Int8 >& i_rClassID,
88 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rCreationArgs,
89 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& i_rConnection
92 virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes()
93 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
94 virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId()
95 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
97 // ::com::sun::star::uno::XInterface
98 DECLARE_XINTERFACE( )
100 // ::com::sun::star::lang::XServiceInfo
101 DECLARE_SERVICE_INFO_STATIC();
103 // ::com::sun::star::beans::XPropertySet
104 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
106 // OPropertySetHelper
107 virtual void SAL_CALL getFastPropertyValue(
108 ::com::sun::star::uno::Any& o_rValue,
109 sal_Int32 i_nHandle
110 ) const SAL_OVERRIDE;
112 // XComponentSupplier
113 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > SAL_CALL getComponent( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 // XSubDocument
116 virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL open( ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
117 virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL openDesign( ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 virtual void SAL_CALL store( ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 virtual sal_Bool SAL_CALL close( ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
121 // XHierarchicalName
122 virtual OUString SAL_CALL getHierarchicalName( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
123 virtual OUString SAL_CALL composeHierarchicalName( const OUString& aRelativeName ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
125 // OPropertySetHelper
126 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
128 // XCommandProcessor
129 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, std::exception) SAL_OVERRIDE ;
131 // XRename
132 virtual void SAL_CALL rename( const OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
134 // XCloseListener
135 virtual void SAL_CALL queryClosing( const ::com::sun::star::lang::EventObject& Source, sal_Bool GetsOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
136 virtual void SAL_CALL notifyClosing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
138 // XEventListener
139 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 /** returns the forms/reports container storage, depending on m_bForm. Our own storage
142 inside this container storage is the one with the name as indicated by m_pImpl->m_aProps.sPersistentName.
144 ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
145 getContainerStorage() const;
147 bool save(bool _bApprove);
148 bool saveAs();
149 void closeObject();
150 bool isModified();
151 inline bool isNewReport() const { return !m_bForm && !m_pImpl->m_aProps.bAsTemplate; }
153 static void fillReportData(
154 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & _rxContext,
155 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable >& _rxComponent,
156 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActiveConnection
159 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >&
160 getConnection() const { return m_xLastKnownConnection; }
162 /** prepares closing the document component
164 The method suspends the controller associated with the document, and saves the document
165 if necessary.
167 @return
168 <TRUE/> if and only if the document component can be closed
170 bool prepareClose();
172 static ::com::sun::star::uno::Sequence< sal_Int8 > getDefaultDocumentTypeClassId();
174 static OUString GetDocumentServiceFromMediaType(
175 const OUString& _rMediaType,
176 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & _rxContext,
177 ::com::sun::star::uno::Sequence< sal_Int8 >& _rClassId
179 static OUString GetDocumentServiceFromMediaType(
180 const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxContainerStorage,
181 const OUString& _rEntityName,
182 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & _rxContext,
183 ::com::sun::star::uno::Sequence< sal_Int8 >& _rClassId
186 struct NotifierAccess { friend class NameChangeNotifier; private: NotifierAccess() { } };
187 const OUString& getCurrentName() const { return m_pImpl->m_aProps.aTitle; }
188 void firePropertyChange(
189 sal_Int32 i_nHandle,
190 const ::com::sun::star::uno::Any& i_rNewValue,
191 const ::com::sun::star::uno::Any& i_rOldValue,
192 bool i_bVetoable,
193 const NotifierAccess&
196 private:
197 /** does necessary initializations after our embedded object has been switched to ACTIVE
199 void impl_onActivateEmbeddedObject_nothrow( const bool i_bReactivated );
201 /** initializes a newly created view/controller of a form which is displaying our embedded object
203 Has only to be called if the respective embedded object has been loaded for design (and
204 not for data entry)
206 @param _rxController
207 the controller which belongs to the XModel of our (active) embedded object
209 static void impl_initFormEditView( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController );
211 /** removes the given frame from the desktop's frame collection
212 @raises ::com::sun::star::uno::RuntimeException
214 static void impl_removeFrameFromDesktop_throw(
215 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rContxt,
216 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame
219 /** opens the UI for this sub document
221 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
222 impl_openUI_nolck_throw( bool _bForEditing );
224 /** stores our document, if it's already loaded
226 void impl_store_throw();
228 /** closes our document, if it's open
230 bool impl_close_throw();
232 /** returns our component, creates it if necessary
234 ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable >
235 impl_getComponent_throw( const bool i_ForceCreate = true );
237 /** shows or hides our component
239 The embedded object must exist, and be in state LOADED, at least.
241 void impl_showOrHideComponent_throw( const bool i_bShow );
243 // OPropertyArrayUsageHelper
244 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
246 virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _rDefault ) const SAL_OVERRIDE;
248 // helper
249 virtual void SAL_CALL disposing() SAL_OVERRIDE;
251 // OContentHelper overridables
252 virtual OUString determineContentType() const SAL_OVERRIDE;
254 /** fills the load arguments
256 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
257 fillLoadArgs(
258 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
259 const bool _bSuppressMacros,
260 const bool _bReadOnly,
261 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rOpenCommandArguments,
262 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _out_rEmbeddedObjectDescriptor
265 /** splits the given arguments to an "open*" command into arguments for loading the document, and arguments to be
266 put into the EmbeddedObjectDescriptor
268 Any values already present in <code>o_rDocumentLoadArgs</code> and <code>o_rEmbeddedObjectDescriptor</code>
269 will be overwritten by values from <code>i_rOpenCommandArguments</code>, if applicable, otherwise they will
270 be preserved.
272 @param i_rOpenCommandArguments
273 the arguments passed to the "open*" command at the content
274 @param o_rDocumentLoadArgs
275 the arguments to be passed when actually loading the embedded document.
276 @param o_rEmbeddedObjectDescriptor
277 the EmbeddedObjectDescriptor to be passed when initializing the embedded object
279 static void separateOpenCommandArguments(
280 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rOpenCommandArguments,
281 ::comphelper::NamedValueCollection& o_rDocumentLoadArgs,
282 ::comphelper::NamedValueCollection& o_rEmbeddedObjectDescriptor
285 /** loads the EmbeddedObject if not already loaded
286 @param _aClassID
287 If set, it will be used to create the embedded object.
289 void loadEmbeddedObject(
290 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
291 const ::com::sun::star::uno::Sequence< sal_Int8 >& _aClassID,
292 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rAdditionalArgs,
293 const bool _bSuppressMacros,
294 const bool _bReadOnly
297 /** loads the embedded object, if not already loaded. No new object can be created with this method.
299 void loadEmbeddedObject( bool _bSuppressMacros = false )
301 loadEmbeddedObject(
302 NULL,
303 ::com::sun::star::uno::Sequence< sal_Int8 >(),
304 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >(),
305 _bSuppressMacros,
306 false
310 /** loads the embedded object for preview. Macros will be suppressed, and the document will
311 be read-only.
313 void loadEmbeddedObjectForPreview()
315 loadEmbeddedObject(
316 NULL,
317 ::com::sun::star::uno::Sequence< sal_Int8 >(),
318 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >(),
319 true,
320 true
324 /** searches for read-only flag in the args of the model and sets it to the given value,
325 if the value was not found, it will be appended.
326 @param _bReadOnly
327 If <TRUE/> the document will be switched to readonly mode
329 void updateDocumentTitle();
331 void registerProperties();
333 /** determines whether the document we represent supports embedded scripts and macros
335 bool objectSupportsEmbeddedScripts() const;
337 //- commands
339 void onCommandGetDocumentProperties( ::com::sun::star::uno::Any& _rProps );
340 void onCommandInsert( const OUString& _sURL, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& Environment ) throw( ::com::sun::star::uno::Exception );
341 void onCommandPreview( ::com::sun::star::uno::Any& _rImage );
342 ::com::sun::star::uno::Any
343 onCommandOpenSomething(
344 const ::com::sun::star::uno::Any& _rArgument,
345 const bool _bActivate,
346 const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& _rxEnvironment
348 private:
349 using ::cppu::OPropertySetHelper::getFastPropertyValue;
352 class NameChangeNotifier
354 public:
355 NameChangeNotifier(
356 ODocumentDefinition& i_rDocumentDefinition,
357 const OUString& i_rNewName,
358 ::osl::ResettableMutexGuard& i_rClearForNotify
360 ~NameChangeNotifier();
362 private:
363 ODocumentDefinition& m_rDocumentDefinition;
364 const ::com::sun::star::uno::Any m_aOldValue;
365 const ::com::sun::star::uno::Any m_aNewValue;
366 ::osl::ResettableMutexGuard& m_rClearForNotify;
368 void impl_fireEvent_throw( const bool i_bVetoable );
371 } // namespace dbaccess
373 #endif // INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DOCUMENTDEFINITION_HXX
375 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */