1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_REPORTDESIGN_INC_REPORTDEFINITION_HXX
21 #define INCLUDED_REPORTDESIGN_INC_REPORTDEFINITION_HXX
25 #include "ReportHelperDefines.hxx"
27 #include <com/sun/star/datatransfer/XTransferable.hpp>
28 #include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
29 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
30 #include <com/sun/star/document/XUndoManagerSupplier.hpp>
31 #include <com/sun/star/frame/XModule.hpp>
32 #include <com/sun/star/frame/XTitle.hpp>
33 #include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
34 #include <com/sun/star/frame/XUntitledNumbers.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/lang/XTypeProvider.hpp>
37 #include <com/sun/star/lang/XUnoTunnel.hpp>
38 #include <com/sun/star/report/XReportDefinition.hpp>
39 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
40 #include <com/sun/star/ui/XUIConfigurationManager2.hpp>
42 #include <comphelper/embeddedobjectcontainer.hxx>
43 #include <comphelper/uno3.hxx>
44 #include <cppuhelper/basemutex.hxx>
45 #include <cppuhelper/compbase.hxx>
46 #include <cppuhelper/propertysetmixin.hxx>
47 #include <svx/unomod.hxx>
58 class MediaDescriptor
;
60 namespace reportdesign
62 class OReportComponentProperties
;
63 typedef cppu::PartialWeakComponentImplHelper
< css::report::XReportDefinition
64 , css::document::XEventBroadcaster
65 , css::document::XDocumentEventBroadcaster
66 , css::lang::XServiceInfo
68 , css::lang::XUnoTunnel
69 , css::util::XNumberFormatsSupplier
71 , css::frame::XTitleChangeBroadcaster
72 , css::frame::XUntitledNumbers
73 , css::document::XDocumentPropertiesSupplier
74 , css::datatransfer::XTransferable
75 , css::document::XUndoManagerSupplier
77 > ReportDefinitionBase
;
79 typedef ::cppu::PropertySetMixin
< css::report::XReportDefinition
> ReportDefinitionPropertySet
;
81 struct OReportDefinitionImpl
;
82 /** \class OReportDefinition Defines the implementation of a \interface com:::sun::star::report::XReportDefinition
83 * \ingroup reportdesign_api
86 class REPORTDESIGN_DLLPUBLIC OReportDefinition
:public ::cppu::BaseMutex
87 ,public ReportDefinitionBase
88 ,public ReportDefinitionPropertySet
89 ,public ::comphelper::IEmbeddedHelper
92 std::shared_ptr
<OReportComponentProperties
> m_aProps
;
93 std::shared_ptr
<OReportDefinitionImpl
> m_pImpl
;
96 OReportDefinition(const OReportDefinition
&) = delete;
97 OReportDefinition
& operator=(const OReportDefinition
&) = delete;
99 void setSection( const OUString
& _sProperty
101 ,const OUString
& _sName
102 ,css::uno::Reference
< css::report::XSection
>& _member
);
104 template <typename T
> void set( const OUString
& _sProperty
110 ::osl::MutexGuard
aGuard(m_aMutex
);
111 prepareSet(_sProperty
, css::uno::makeAny(_member
), css::uno::makeAny(Value
), &l
);
117 void set( const OUString
& _sProperty
123 ::osl::MutexGuard
aGuard(m_aMutex
);
124 prepareSet(_sProperty
, css::uno::makeAny(_member
), css::uno::makeAny(Value
), &l
);
130 /// write a single XML stream into the package
131 bool WriteThroughComponent(
132 /// the component we export
133 const css::uno::Reference
< css::lang::XComponent
> & xComponent
,
134 const sal_Char
* pStreamName
, /// the stream name
135 const sal_Char
* pServiceName
, /// service name of the component
136 /// the argument (XInitialization)
137 const css::uno::Sequence
< css::uno::Any
> & rArguments
,
138 /// output descriptor
139 const css::uno::Sequence
< css::beans::PropertyValue
> & rMediaDesc
,
140 const css::uno::Reference
< css::embed::XStorage
>& _xStorageToSaveTo
);
142 /// write a single output stream
143 /// (to be called either directly or by WriteThroughComponent(...))
144 bool WriteThroughComponent(
145 const css::uno::Reference
< css::io::XOutputStream
> & xOutputStream
,
146 const css::uno::Reference
< css::lang::XComponent
> & xComponent
,
147 const sal_Char
* pServiceName
,
148 const css::uno::Sequence
< css::uno::Any
> & rArguments
,
149 const css::uno::Sequence
< css::beans::PropertyValue
> & rMediaDesc
);
151 void notifyEvent(const OUString
& _sEventName
);
153 void fillArgs(utl::MediaDescriptor
& _aDescriptor
);
155 css::uno::Reference
< css::frame::XTitle
> impl_getTitleHelper_throw();
156 css::uno::Reference
< css::frame::XUntitledNumbers
> impl_getUntitledHelper_throw();
158 /** loads the report definition from the given storage
163 void impl_loadFromStorage_nolck_throw(
164 const css::uno::Reference
< css::embed::XStorage
>& _rxStorage
,
165 const css::uno::Sequence
< css::beans::PropertyValue
>& _rArguments
169 virtual ~OReportDefinition() override
;
171 /** this function is called upon disposing the component
173 virtual void SAL_CALL
disposing() override
;
175 explicit OReportDefinition(css::uno::Reference
< css::uno::XComponentContext
> const & _xContext
);
176 explicit OReportDefinition(css::uno::Reference
< css::uno::XComponentContext
> const & _xContext
177 ,const css::uno::Reference
< css::lang::XMultiServiceFactory
> & _xFactory
178 ,css::uno::Reference
< css::drawing::XShape
>& _xShape
);
180 /// @throws css::uno::RuntimeException
181 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static();
182 /// @throws css::uno::RuntimeException
183 static OUString
getImplementationName_Static();
184 static css::uno::Reference
< css::uno::XInterface
>
185 create(css::uno::Reference
< css::uno::XComponentContext
> const & xContext
);
187 css::uno::Reference
< css::uno::XComponentContext
> getContext();
190 /** abstract SdrModel provider */
191 virtual SdrModel
& getSdrModelFromUnoModel() const override
;
194 //TTTT Needed? Or same as above?
195 static std::shared_ptr
<rptui::OReportModel
> getSdrModel(const css::uno::Reference
< css::report::XReportDefinition
>& _xReportDefinition
);
198 DECLARE_XINTERFACE( )
199 DECLARE_XTYPEPROVIDER( )
200 // css::lang::XServiceInfo
201 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
202 virtual OUString SAL_CALL
getImplementationName( ) override
;
203 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
205 // css::beans::XPropertySet
206 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
207 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
208 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
209 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
210 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
211 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
212 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
215 virtual OUString SAL_CALL
getMimeType() override
;
216 virtual void SAL_CALL
setMimeType( const OUString
& _mimetype
) override
;
217 virtual OUString SAL_CALL
getCaption() override
;
218 virtual void SAL_CALL
setCaption( const OUString
& _caption
) override
;
219 virtual ::sal_Int16 SAL_CALL
getGroupKeepTogether() override
;
220 virtual void SAL_CALL
setGroupKeepTogether( ::sal_Int16 _groupkeeptogether
) override
;
221 virtual ::sal_Int16 SAL_CALL
getPageHeaderOption() override
;
222 virtual void SAL_CALL
setPageHeaderOption( ::sal_Int16 _pageheaderoption
) override
;
223 virtual ::sal_Int16 SAL_CALL
getPageFooterOption() override
;
224 virtual void SAL_CALL
setPageFooterOption( ::sal_Int16 _pagefooteroption
) override
;
225 virtual OUString SAL_CALL
getCommand() override
;
226 virtual void SAL_CALL
setCommand( const OUString
& _command
) override
;
227 virtual ::sal_Int32 SAL_CALL
getCommandType() override
;
228 virtual void SAL_CALL
setCommandType( ::sal_Int32 _commandtype
) override
;
229 virtual OUString SAL_CALL
getFilter() override
;
230 virtual void SAL_CALL
setFilter( const OUString
& _filter
) override
;
231 virtual sal_Bool SAL_CALL
getEscapeProcessing() override
;
232 virtual void SAL_CALL
setEscapeProcessing( sal_Bool _escapeprocessing
) override
;
233 virtual css::uno::Reference
< css::sdbc::XConnection
> SAL_CALL
getActiveConnection() override
;
234 virtual void SAL_CALL
setActiveConnection( const css::uno::Reference
< css::sdbc::XConnection
>& _activeconnection
) override
;
235 virtual OUString SAL_CALL
getDataSourceName() override
;
236 virtual void SAL_CALL
setDataSourceName( const OUString
& _datasourcename
) override
;
237 virtual sal_Bool SAL_CALL
getReportHeaderOn() override
;
238 virtual void SAL_CALL
setReportHeaderOn( sal_Bool _reportheaderon
) override
;
239 virtual sal_Bool SAL_CALL
getReportFooterOn() override
;
240 virtual void SAL_CALL
setReportFooterOn( sal_Bool _reportfooteron
) override
;
241 virtual sal_Bool SAL_CALL
getPageHeaderOn() override
;
242 virtual void SAL_CALL
setPageHeaderOn( sal_Bool _pageheaderon
) override
;
243 virtual sal_Bool SAL_CALL
getPageFooterOn() override
;
244 virtual void SAL_CALL
setPageFooterOn( sal_Bool _pagefooteron
) override
;
245 virtual css::uno::Reference
< css::report::XGroups
> SAL_CALL
getGroups() override
;
246 virtual css::uno::Reference
< css::report::XSection
> SAL_CALL
getReportHeader() override
;
247 virtual css::uno::Reference
< css::report::XSection
> SAL_CALL
getPageHeader() override
;
248 virtual css::uno::Reference
< css::report::XSection
> SAL_CALL
getDetail() override
;
249 virtual css::uno::Reference
< css::report::XSection
> SAL_CALL
getPageFooter() override
;
250 virtual css::uno::Reference
< css::report::XSection
> SAL_CALL
getReportFooter() override
;
251 virtual css::uno::Reference
< css::document::XEventBroadcaster
> SAL_CALL
getEventBroadcaster( ) override
;
252 virtual css::uno::Sequence
< OUString
> SAL_CALL
getAvailableMimeTypes( ) override
;
255 REPORTCOMPONENT_HEADER()
261 virtual OUString SAL_CALL
getShapeType( ) override
;
264 virtual css::uno::Reference
< css::report::XFunctions
> SAL_CALL
getFunctions() override
;
267 virtual css::uno::Reference
< css::util::XCloneable
> SAL_CALL
createClone( ) override
;
270 virtual void SAL_CALL
dispose() override
;
271 virtual void SAL_CALL
addEventListener(const css::uno::Reference
< css::lang::XEventListener
> & aListener
) override
273 cppu::WeakComponentImplHelperBase::addEventListener(aListener
);
275 virtual void SAL_CALL
removeEventListener(const css::uno::Reference
< css::lang::XEventListener
> & aListener
) override
277 cppu::WeakComponentImplHelperBase::removeEventListener(aListener
);
281 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getParent( ) override
;
282 virtual void SAL_CALL
setParent( const css::uno::Reference
< css::uno::XInterface
>& Parent
) override
;
285 virtual void SAL_CALL
addCloseListener( const css::uno::Reference
< css::util::XCloseListener
>& Listener
) override
;
286 virtual void SAL_CALL
removeCloseListener( const css::uno::Reference
< css::util::XCloseListener
>& Listener
) override
;
289 virtual void SAL_CALL
close( sal_Bool DeliverOwnership
) override
;
292 virtual sal_Bool SAL_CALL
attachResource( const OUString
& URL
, const css::uno::Sequence
< css::beans::PropertyValue
>& Arguments
) override
;
293 virtual OUString SAL_CALL
getURL( ) override
;
294 virtual css::uno::Sequence
< css::beans::PropertyValue
> SAL_CALL
getArgs( ) override
;
295 virtual void SAL_CALL
connectController( const css::uno::Reference
< css::frame::XController
>& Controller
) override
;
296 virtual void SAL_CALL
disconnectController( const css::uno::Reference
< css::frame::XController
>& Controller
) override
;
297 virtual void SAL_CALL
lockControllers( ) override
;
298 virtual void SAL_CALL
unlockControllers( ) override
;
299 virtual sal_Bool SAL_CALL
hasControllersLocked( ) override
;
300 virtual css::uno::Reference
< css::frame::XController
> SAL_CALL
getCurrentController( ) override
;
301 virtual void SAL_CALL
setCurrentController( const css::uno::Reference
< css::frame::XController
>& Controller
) override
;
302 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getCurrentSelection( ) override
;
304 // XStorageBasedDocument
305 virtual void SAL_CALL
loadFromStorage( const css::uno::Reference
< css::embed::XStorage
>& xStorage
, const css::uno::Sequence
< css::beans::PropertyValue
>& aMediaDescriptor
) override
;
306 virtual void SAL_CALL
storeToStorage( const css::uno::Reference
< css::embed::XStorage
>& xStorage
, const css::uno::Sequence
< css::beans::PropertyValue
>& aMediaDescriptor
) override
;
307 virtual void SAL_CALL
switchToStorage( const css::uno::Reference
< css::embed::XStorage
>& xStorage
) override
;
308 virtual css::uno::Reference
< css::embed::XStorage
> SAL_CALL
getDocumentStorage( ) override
;
309 virtual void SAL_CALL
addStorageChangeListener( const css::uno::Reference
< css::document::XStorageChangeListener
>& xListener
) override
;
310 virtual void SAL_CALL
removeStorageChangeListener( const css::uno::Reference
< css::document::XStorageChangeListener
>& xListener
) override
;
313 virtual css::uno::Reference
< css::container::XIndexAccess
> SAL_CALL
getViewData( ) override
;
314 virtual void SAL_CALL
setViewData( const css::uno::Reference
< css::container::XIndexAccess
>& Data
) override
;
317 virtual void SAL_CALL
initNew( ) override
;
318 virtual void SAL_CALL
load( const css::uno::Sequence
< css::beans::PropertyValue
>& lArguments
) override
;
321 virtual void SAL_CALL
setVisualAreaSize( ::sal_Int64 nAspect
, const css::awt::Size
& aSize
) override
;
322 virtual css::awt::Size SAL_CALL
getVisualAreaSize( ::sal_Int64 nAspect
) override
;
323 virtual css::embed::VisualRepresentation SAL_CALL
getPreferredVisualRepresentation( ::sal_Int64 nAspect
) override
;
324 virtual ::sal_Int32 SAL_CALL
getMapUnit( ::sal_Int64 nAspect
) override
;
327 virtual sal_Bool SAL_CALL
disableSetModified( ) override
;
328 virtual sal_Bool SAL_CALL
enableSetModified( ) override
;
329 virtual sal_Bool SAL_CALL
isSetModifiedEnabled( ) override
;
332 virtual sal_Bool SAL_CALL
isModified( ) override
;
333 virtual void SAL_CALL
setModified( sal_Bool bModified
) override
;
335 // XModifyBroadcaster
336 virtual void SAL_CALL
addModifyListener( const css::uno::Reference
< css::util::XModifyListener
>& aListener
) override
;
337 virtual void SAL_CALL
removeModifyListener( const css::uno::Reference
< css::util::XModifyListener
>& aListener
) override
;
339 // document::XEventBroadcaster
340 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::document::XEventListener
>& aListener
) override
;
341 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::document::XEventListener
>& aListener
) override
;
343 // document::XDocumentEventBroadcaster
344 virtual void SAL_CALL
addDocumentEventListener( const css::uno::Reference
< css::document::XDocumentEventListener
>& rListener
) override
;
345 virtual void SAL_CALL
removeDocumentEventListener( const css::uno::Reference
< css::document::XDocumentEventListener
>& rListener
) override
;
346 virtual void SAL_CALL
notifyDocumentEvent( const OUString
& rEventName
, const css::uno::Reference
< css::frame::XController2
>& rViewController
, const css::uno::Any
& rSupplement
) override
;
348 // XUIConfigurationManagerSupplier
349 virtual css::uno::Reference
< css::ui::XUIConfigurationManager
> SAL_CALL
getUIConfigurationManager( ) override
;
351 // XDocumentSubStorageSupplier
352 virtual css::uno::Reference
< css::embed::XStorage
> SAL_CALL
getDocumentSubStorage( const OUString
& aStorageName
, sal_Int32 nMode
) override
;
353 virtual css::uno::Sequence
< OUString
> SAL_CALL
getDocumentSubStoragesNames( ) override
;
355 // css::lang::XUnoTunnel
356 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) override
;
357 static css::uno::Sequence
< sal_Int8
> getUnoTunnelImplementationId();
359 // SvxUnoDrawMSFactory
360 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
createInstance( const OUString
& aServiceSpecifier
) override
;
361 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
createInstanceWithArguments( const OUString
& ServiceSpecifier
, const css::uno::Sequence
< css::uno::Any
>& Arguments
) override
;
362 css::uno::Sequence
< OUString
> SAL_CALL
getAvailableServiceNames() override
;
364 // XStyleFamiliesSupplier
365 virtual css::uno::Reference
< css::container::XNameAccess
> SAL_CALL
getStyleFamilies( ) override
;
368 virtual void SAL_CALL
setIdentifier( const OUString
& Identifier
) override
;
369 virtual OUString SAL_CALL
getIdentifier( ) override
;
371 // XNumberFormatsSupplier
372 virtual css::uno::Reference
< css::beans::XPropertySet
> SAL_CALL
getNumberFormatSettings( ) override
;
373 virtual css::uno::Reference
< css::util::XNumberFormats
> SAL_CALL
getNumberFormats( ) override
;
376 virtual OUString SAL_CALL
getTitle( ) override
;
377 virtual void SAL_CALL
setTitle( const OUString
& sTitle
) override
;
379 // XTitleChangeBroadcaster
380 virtual void SAL_CALL
addTitleChangeListener( const css::uno::Reference
< css::frame::XTitleChangeListener
>& xListener
) override
;
381 virtual void SAL_CALL
removeTitleChangeListener( const css::uno::Reference
< css::frame::XTitleChangeListener
>& xListener
) override
;
384 virtual ::sal_Int32 SAL_CALL
leaseNumber( const css::uno::Reference
< css::uno::XInterface
>& xComponent
) override
;
385 virtual void SAL_CALL
releaseNumber( ::sal_Int32 nNumber
) override
;
386 virtual void SAL_CALL
releaseNumberForComponent( const css::uno::Reference
< css::uno::XInterface
>& xComponent
) override
;
387 virtual OUString SAL_CALL
getUntitledPrefix( ) override
;
389 // XDocumentPropertiesSupplier
390 virtual css::uno::Reference
< css::document::XDocumentProperties
> SAL_CALL
getDocumentProperties( ) override
;
393 virtual css::uno::Any SAL_CALL
getTransferData( const css::datatransfer::DataFlavor
& aFlavor
) override
;
394 virtual css::uno::Sequence
< css::datatransfer::DataFlavor
> SAL_CALL
getTransferDataFlavors( ) override
;
395 virtual sal_Bool SAL_CALL
isDataFlavorSupported( const css::datatransfer::DataFlavor
& aFlavor
) override
;
397 // XUndoManagerSupplier
398 virtual css::uno::Reference
< css::document::XUndoManager
> SAL_CALL
getUndoManager( ) override
;
400 // comphelper::IEmbeddedHelper
401 virtual css::uno::Reference
< css::embed::XStorage
> getStorage() const override
;
402 virtual ::comphelper::EmbeddedObjectContainer
& getEmbeddedObjectContainer() const override
;
403 virtual css::uno::Reference
< css::task::XInteractionHandler
> getInteractionHandler() const override
;
404 virtual bool isEnableSetModified() const override
;
405 virtual OUString
getDocumentBaseURL() const override
;
407 /// @throws css::uno::RuntimeException
408 css::uno::Reference
< css::ui::XUIConfigurationManager2
> getUIConfigurationManager2( );
411 } // namespace reportdesign
413 #endif // INCLUDED_REPORTDESIGN_INC_REPORTDEFINITION_HXX
415 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */