LibreOffice Module dbaccess (master) 1
documentdefinition.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
20#pragma once
21
24#include <ContentHelper.hxx>
27#include <apitools.hxx>
28#include <comphelper/uno3.hxx>
29#include <com/sun/star/awt/XTopWindow.hpp>
30#include <com/sun/star/sdbc/XConnection.hpp>
31#include <com/sun/star/frame/XController.hpp>
32#include <com/sun/star/embed/XStateChangeListener.hpp>
33#include <com/sun/star/embed/XEmbeddedObject.hpp>
34#include <com/sun/star/embed/XStorage.hpp>
35#include <com/sun/star/sdb/XSubDocument.hpp>
36#include <com/sun/star/util/XCloseListener.hpp>
37#include <com/sun/star/container/XHierarchicalName.hpp>
38#include <rtl/ref.hxx>
39
40namespace comphelper
41{
42 class NamedValueCollection;
43}
44
45namespace dbaccess
46{
47
48 class OInterceptor;
49 class OEmbeddedClientHelper;
50// ODocumentDefinition - a database "document" which is simply a link to a real
51// document
52
53typedef ::cppu::ImplHelper4 < css::embed::XComponentSupplier
54 , css::sdb::XSubDocument
55 , css::util::XCloseListener
56 , css::container::XHierarchicalName
58
60 :public OContentHelper
62 ,public ::comphelper::OPropertyArrayUsageHelper< ODocumentDefinition >
64{
65 css::uno::Reference< css::embed::XEmbeddedObject> m_xEmbeddedObject;
66 css::uno::Reference< css::embed::XStateChangeListener > m_xListener;
67 css::uno::Reference< css::sdbc::XConnection > m_xLastKnownConnection;
68
70 bool m_bForm; // <TRUE/> if it is a form
75
76protected:
77 virtual ~ODocumentDefinition() override;
78
79public:
80
82 const css::uno::Reference< css::uno::XInterface >& _rxContainer,
83 const css::uno::Reference< css::uno::XComponentContext >&,
84 const TContentPtr& _pImpl,
85 bool _bForm
86 );
87
88 void initialLoad(
89 const css::uno::Sequence< sal_Int8 >& i_rClassID,
90 const css::uno::Sequence< css::beans::PropertyValue >& i_rCreationArgs,
91 const css::uno::Reference< css::sdbc::XConnection >& i_rConnection
92 );
93
94 virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override;
95 virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() override;
96
97// css::uno::XInterface
99
100// css::beans::XPropertySet
101 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
102
103 // OPropertySetHelper
104 virtual void SAL_CALL getFastPropertyValue(
105 css::uno::Any& o_rValue,
106 sal_Int32 i_nHandle
107 ) const override;
108
109 // XComponentSupplier
110 virtual css::uno::Reference< css::util::XCloseable > SAL_CALL getComponent( ) override;
111
112 // XSubDocument
113 virtual css::uno::Reference< css::lang::XComponent > SAL_CALL open( ) override;
114 virtual css::uno::Reference< css::lang::XComponent > SAL_CALL openDesign( ) override;
115 virtual void SAL_CALL store( ) override;
116 virtual sal_Bool SAL_CALL close( ) override;
117
118 // XHierarchicalName
119 virtual OUString SAL_CALL getHierarchicalName( ) override;
120 virtual OUString SAL_CALL composeHierarchicalName( const OUString& aRelativeName ) override;
121
122// OPropertySetHelper
123 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
124
125 // XCommandProcessor
126 virtual css::uno::Any SAL_CALL execute( const css::ucb::Command& aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override ;
127
128 // XRename
129 virtual void SAL_CALL rename( const OUString& newName ) override;
130
131 // XCloseListener
132 virtual void SAL_CALL queryClosing( const css::lang::EventObject& Source, sal_Bool GetsOwnership ) override;
133 virtual void SAL_CALL notifyClosing( const css::lang::EventObject& Source ) override;
134
135 // XEventListener
136 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
137
141 css::uno::Reference< css::embed::XStorage >
142 getContainerStorage() const;
143
144 bool save(bool _bApprove, const css::uno::Reference<css::awt::XTopWindow>& rDialogParent);
145 void saveAs();
146 void closeObject();
147 bool isModified();
148 bool isNewReport() const { return !m_bForm && !m_pImpl->m_aProps.bAsTemplate; }
149
150 static void fillReportData(
151 const css::uno::Reference< css::uno::XComponentContext > & _rxContext,
152 const css::uno::Reference< css::util::XCloseable >& _rxComponent,
153 const css::uno::Reference< css::sdbc::XConnection >& _rxActiveConnection
154 );
155
156 const css::uno::Reference< css::sdbc::XConnection >&
158
167 bool prepareClose();
168
170 const OUString& _rMediaType,
171 const css::uno::Reference< css::uno::XComponentContext > & _rxContext,
172 css::uno::Sequence< sal_Int8 >& _rClassId
173 );
175 const css::uno::Reference< css::embed::XStorage >& _rxContainerStorage,
176 const OUString& _rEntityName,
177 const css::uno::Reference< css::uno::XComponentContext > & _rxContext,
178 css::uno::Sequence< sal_Int8 >& _rClassId
179 );
180
181 struct NotifierAccess { friend class NameChangeNotifier; private: NotifierAccess() { } };
182 const OUString& getCurrentName() const { return m_pImpl->m_aProps.aTitle; }
184 sal_Int32 i_nHandle,
185 const css::uno::Any& i_rNewValue,
186 const css::uno::Any& i_rOldValue,
187 bool i_bVetoable,
188 const NotifierAccess&
189 );
190
191private:
194 void impl_onActivateEmbeddedObject_nothrow( const bool i_bReactivated );
195
204 static void impl_initFormEditView( const css::uno::Reference< css::frame::XController >& _rxController );
205
210 const css::uno::Reference< css::uno::XComponentContext >& _rContext,
211 const css::uno::Reference< css::frame::XFrame >& _rxFrame
212 );
213
216 css::uno::Reference< css::lang::XComponent >
217 impl_openUI_nolck_throw( bool _bForEditing );
218
221 void impl_store_throw();
222
225 bool impl_close_throw();
226
229 css::uno::Reference< css::util::XCloseable >
230 impl_getComponent_throw( const bool i_ForceCreate = true );
231
236 void impl_showOrHideComponent_throw( const bool i_bShow );
237
238 // OPropertyArrayUsageHelper
239 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
240
241 virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, css::uno::Any& _rDefault ) const override;
242
243 // helper
244 virtual void SAL_CALL disposing() override;
245
246 // OContentHelper overridables
247 virtual OUString determineContentType() const override;
248
251 css::uno::Sequence< css::beans::PropertyValue >
253 const css::uno::Reference< css::sdbc::XConnection>& _xConnection,
254 const bool _bSuppressMacros,
255 const bool _bReadOnly,
256 const css::uno::Sequence< css::beans::PropertyValue >& i_rOpenCommandArguments,
257 css::uno::Sequence< css::beans::PropertyValue >& _out_rEmbeddedObjectDescriptor
258 );
259
275 const css::uno::Sequence< css::beans::PropertyValue >& i_rOpenCommandArguments,
276 ::comphelper::NamedValueCollection& o_rDocumentLoadArgs,
277 ::comphelper::NamedValueCollection& o_rEmbeddedObjectDescriptor
278 );
279
285 const css::uno::Reference< css::sdbc::XConnection>& _xConnection,
286 const css::uno::Sequence< sal_Int8 >& _aClassID,
287 const css::uno::Sequence< css::beans::PropertyValue >& _rAdditionalArgs,
288 const bool _bSuppressMacros,
289 const bool _bReadOnly
290 );
291
296 {
298 nullptr,
299 css::uno::Sequence< sal_Int8 >(),
300 css::uno::Sequence< css::beans::PropertyValue >(),
301 true,
302 true
303 );
304 }
305
311 void updateDocumentTitle();
312
313 void registerProperties();
314
318
319 //- commands
320
321 void onCommandGetDocumentProperties( css::uno::Any& _rProps );
323 void onCommandInsert( const OUString& _sURL, const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
324 void onCommandPreview( css::uno::Any& _rImage );
325 css::uno::Any
327 const css::uno::Any& _rArgument,
328 const bool _bActivate,
329 const css::uno::Reference< css::ucb::XCommandEnvironment >& _rxEnvironment
330 );
331private:
332 using ::cppu::OPropertySetHelper::getFastPropertyValue;
333};
334
336{
337public:
339 ODocumentDefinition& i_rDocumentDefinition,
340 const OUString& i_rNewName,
341 ::osl::ResettableMutexGuard& i_rClearForNotify
342 );
344
345private:
347 const css::uno::Any m_aOldValue;
348 const css::uno::Any m_aNewValue;
349 ::osl::ResettableMutexGuard& m_rClearForNotify;
350
351 void impl_fireEvent_throw( const bool i_bVetoable );
352};
353
354} // namespace dbaccess
355
356/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::osl::ResettableMutexGuard & m_rClearForNotify
NameChangeNotifier(ODocumentDefinition &i_rDocumentDefinition, const OUString &i_rNewName, ::osl::ResettableMutexGuard &i_rClearForNotify)
void impl_fireEvent_throw(const bool i_bVetoable)
ODocumentDefinition & m_rDocumentDefinition
virtual void SAL_CALL rename(const OUString &newName) override
static void impl_initFormEditView(const css::uno::Reference< css::frame::XController > &_rxController)
initializes a newly created view/controller of a form which is displaying our embedded object
static void impl_removeFrameFromDesktop_throw(const css::uno::Reference< css::uno::XComponentContext > &_rContext, const css::uno::Reference< css::frame::XFrame > &_rxFrame)
removes the given frame from the desktop's frame collection
bool impl_close_throw()
closes our document, if it's open
css::uno::Reference< css::sdbc::XConnection > m_xLastKnownConnection
virtual void getPropertyDefaultByHandle(sal_Int32 _nHandle, css::uno::Any &_rDefault) const override
const OUString & getCurrentName() const
void onCommandInsert(const OUString &_sURL, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
rtl::Reference< OEmbeddedClientHelper > m_pClientHelper
static OUString GetDocumentServiceFromMediaType(const css::uno::Reference< css::embed::XStorage > &_rxContainerStorage, const OUString &_rEntityName, const css::uno::Reference< css::uno::XComponentContext > &_rxContext, css::uno::Sequence< sal_Int8 > &_rClassId)
static void separateOpenCommandArguments(const css::uno::Sequence< css::beans::PropertyValue > &i_rOpenCommandArguments, ::comphelper::NamedValueCollection &o_rDocumentLoadArgs, ::comphelper::NamedValueCollection &o_rEmbeddedObjectDescriptor)
splits the given arguments to an "open*" command into arguments for loading the document,...
bool prepareClose()
prepares closing the document component
virtual css::uno::Reference< css::util::XCloseable > SAL_CALL getComponent() override
virtual void SAL_CALL disposing() override
void updateDocumentTitle()
searches for read-only flag in the args of the model and sets it to the given value,...
css::uno::Sequence< css::beans::PropertyValue > fillLoadArgs(const css::uno::Reference< css::sdbc::XConnection > &_xConnection, const bool _bSuppressMacros, const bool _bReadOnly, const css::uno::Sequence< css::beans::PropertyValue > &i_rOpenCommandArguments, css::uno::Sequence< css::beans::PropertyValue > &_out_rEmbeddedObjectDescriptor)
fills the load arguments
const css::uno::Reference< css::sdbc::XConnection > & getConnection() const
void loadEmbeddedObject(const css::uno::Reference< css::sdbc::XConnection > &_xConnection, const css::uno::Sequence< sal_Int8 > &_aClassID, const css::uno::Sequence< css::beans::PropertyValue > &_rAdditionalArgs, const bool _bSuppressMacros, const bool _bReadOnly)
loads the EmbeddedObject if not already loaded
void loadEmbeddedObjectForPreview()
loads the embedded object for preview.
static void fillReportData(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const css::uno::Reference< css::util::XCloseable > &_rxComponent, const css::uno::Reference< css::sdbc::XConnection > &_rxActiveConnection)
bool save(bool _bApprove, const css::uno::Reference< css::awt::XTopWindow > &rDialogParent)
void impl_store_throw()
stores our document, if it's already loaded
ODocumentDefinition(const css::uno::Reference< css::uno::XInterface > &_rxContainer, const css::uno::Reference< css::uno::XComponentContext > &, const TContentPtr &_pImpl, bool _bForm)
void onCommandPreview(css::uno::Any &_rImage)
virtual OUString determineContentType() const override
css::uno::Reference< css::embed::XStorage > getContainerStorage() const
returns the forms/reports container storage, depending on m_bForm.
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
rtl::Reference< OInterceptor > m_pInterceptor
css::uno::Reference< css::util::XCloseable > impl_getComponent_throw(const bool i_ForceCreate=true)
returns our component, creates it if necessary
virtual css::uno::Reference< css::lang::XComponent > SAL_CALL open() override
void firePropertyChange(sal_Int32 i_nHandle, const css::uno::Any &i_rNewValue, const css::uno::Any &i_rOldValue, bool i_bVetoable, const NotifierAccess &)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual sal_Bool SAL_CALL close() override
css::uno::Reference< css::embed::XEmbeddedObject > m_xEmbeddedObject
void impl_showOrHideComponent_throw(const bool i_bShow)
shows or hides our component
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
void impl_onActivateEmbeddedObject_nothrow(const bool i_bReactivated)
does necessary initializations after our embedded object has been switched to ACTIVE
void onCommandGetDocumentProperties(css::uno::Any &_rProps)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
bool objectSupportsEmbeddedScripts() const
determines whether the document we represent supports embedded scripts and macros
virtual css::uno::Reference< css::lang::XComponent > SAL_CALL openDesign() override
void initialLoad(const css::uno::Sequence< sal_Int8 > &i_rClassID, const css::uno::Sequence< css::beans::PropertyValue > &i_rCreationArgs, const css::uno::Reference< css::sdbc::XConnection > &i_rConnection)
css::uno::Any onCommandOpenSomething(const css::uno::Any &_rArgument, const bool _bActivate, const css::uno::Reference< css::ucb::XCommandEnvironment > &_rxEnvironment)
css::uno::Reference< css::lang::XComponent > impl_openUI_nolck_throw(bool _bForEditing)
opens the UI for this sub document
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual OUString SAL_CALL getHierarchicalName() override
virtual void SAL_CALL notifyClosing(const css::lang::EventObject &Source) override
css::uno::Reference< css::embed::XStateChangeListener > m_xListener
virtual void SAL_CALL queryClosing(const css::lang::EventObject &Source, sal_Bool GetsOwnership) 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 OUString SAL_CALL composeHierarchicalName(const OUString &aRelativeName) override
static OUString GetDocumentServiceFromMediaType(const OUString &_rMediaType, const css::uno::Reference< css::uno::XComponentContext > &_rxContext, css::uno::Sequence< sal_Int8 > &_rClassId)
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &o_rValue, sal_Int32 i_nHandle) const override
std::shared_ptr< OContentHelper_Impl > TContentPtr
::cppu::ImplHelper4< css::embed::XComponentSupplier, css::sdb::XSubDocument, css::util::XCloseListener, css::container::XHierarchicalName > ODocumentDefinition_Base
unsigned char sal_Bool
#define DECLARE_XINTERFACE()