LibreOffice Module reportdesign (master)  1
ReportDefinition.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 #ifndef INCLUDED_REPORTDESIGN_INC_REPORTDEFINITION_HXX
21 #define INCLUDED_REPORTDESIGN_INC_REPORTDEFINITION_HXX
22 
23 #include "dllapi.h"
24 
25 #include "ReportHelperDefines.hxx"
26 
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/XUnoTunnel.hpp>
37 #include <com/sun/star/report/XReportDefinition.hpp>
38 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
39 #include <com/sun/star/ui/XUIConfigurationManager2.hpp>
40 
42 #include <comphelper/uno3.hxx>
43 #include <cppuhelper/basemutex.hxx>
44 #include <cppuhelper/compbase.hxx>
46 #include <svx/unomod.hxx>
47 
48 #include <memory>
49 
50 
51 namespace rptui
52 {
53  class OReportModel;
54 }
55 namespace utl
56 {
57  class MediaDescriptor;
58 }
59 namespace reportdesign
60 {
62  typedef cppu::PartialWeakComponentImplHelper< css::report::XReportDefinition
63  , css::document::XEventBroadcaster
64  , css::document::XDocumentEventBroadcaster
65  , css::lang::XServiceInfo
66  , css::frame::XModule
67  , css::lang::XUnoTunnel
68  , css::util::XNumberFormatsSupplier
69  , css::frame::XTitle
70  , css::frame::XTitleChangeBroadcaster
71  , css::frame::XUntitledNumbers
72  , css::document::XDocumentPropertiesSupplier
73  , css::datatransfer::XTransferable
74  , css::document::XUndoManagerSupplier
77 
78  typedef ::cppu::PropertySetMixin< css::report::XReportDefinition > ReportDefinitionPropertySet;
79 
80  struct OReportDefinitionImpl;
86  ,public ReportDefinitionBase
87  ,public ReportDefinitionPropertySet
89  {
90  std::shared_ptr<OReportComponentProperties> m_aProps;
91  std::shared_ptr<OReportDefinitionImpl> m_pImpl;
92 
93  OReportDefinition(const OReportDefinition&) = delete;
94  OReportDefinition& operator=(const OReportDefinition&) = delete;
95 
96  void setSection( const OUString& _sProperty
97  ,bool _bOn
98  ,const OUString& _sName
99  ,css::uno::Reference< css::report::XSection>& _member);
100 
101  template <typename T> void set( const OUString& _sProperty
102  ,const T& Value
103  ,T& _member)
104  {
105  BoundListeners l;
106  {
107  ::osl::MutexGuard aGuard(m_aMutex);
108  prepareSet(_sProperty, css::uno::makeAny(_member), css::uno::makeAny(Value), &l);
109  _member = Value;
110  }
111  l.notify();
112  }
113 
114  void set( const OUString& _sProperty
115  ,bool Value
116  ,bool& _member)
117  {
118  BoundListeners l;
119  {
120  ::osl::MutexGuard aGuard(m_aMutex);
121  prepareSet(_sProperty, css::uno::makeAny(_member), css::uno::makeAny(Value), &l);
122  _member = Value;
123  }
124  l.notify();
125  }
126 
128  bool WriteThroughComponent(
130  const css::uno::Reference< css::lang::XComponent> & xComponent,
131  const char* pStreamName,
132  const char* pServiceName,
133  const css::uno::Sequence< css::uno::Any> & rArguments,
136  const css::uno::Sequence< css::beans::PropertyValue> & rMediaDesc,
137  const css::uno::Reference< css::embed::XStorage >& _xStorageToSaveTo);
138 
141  bool WriteThroughComponent(
142  const css::uno::Reference< css::io::XOutputStream> & xOutputStream,
143  const css::uno::Reference< css::lang::XComponent> & xComponent,
144  const char* pServiceName,
145  const css::uno::Sequence< css::uno::Any> & rArguments,
146  const css::uno::Sequence< css::beans::PropertyValue> & rMediaDesc);
147 
148  void notifyEvent(const OUString& _sEventName);
149  void init();
150  void fillArgs(utl::MediaDescriptor& _aDescriptor);
151 
152  css::uno::Reference< css::frame::XTitle > impl_getTitleHelper_throw();
153  css::uno::Reference< css::frame::XUntitledNumbers > impl_getUntitledHelper_throw();
154 
160  void impl_loadFromStorage_nolck_throw(
161  const css::uno::Reference< css::embed::XStorage >& _rxStorage,
162  const css::uno::Sequence< css::beans::PropertyValue >& _rArguments
163  );
164 
165  virtual ~OReportDefinition() override;
166 
169  virtual void SAL_CALL disposing() override;
170  public:
171  explicit OReportDefinition(css::uno::Reference< css::uno::XComponentContext > const & _xContext);
172  explicit OReportDefinition(css::uno::Reference< css::uno::XComponentContext > const & _xContext
173  ,const css::uno::Reference< css::lang::XMultiServiceFactory > & _xFactory
174  ,css::uno::Reference< css::drawing::XShape >& _xShape);
175 
176  css::uno::Reference< css::uno::XComponentContext > getContext();
177 
178  private:
180  virtual SdrModel& getSdrModelFromUnoModel() const override;
181 
182  public:
183  //TTTT Needed? Or same as above?
184  static css::uno::Sequence< sal_Int8 > getUnoTunnelId();
185  static std::shared_ptr<rptui::OReportModel> getSdrModel(const css::uno::Reference< css::report::XReportDefinition >& _xReportDefinition);
186 
187  private:
189  DECLARE_XTYPEPROVIDER( )
190  // css::lang::XServiceInfo
191  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
192  virtual OUString SAL_CALL getImplementationName( ) override;
193  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
194 
195  // css::beans::XPropertySet
196  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
197  virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
198  virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
199  virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
200  virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
201  virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
202  virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
203 
204  // XReportDefinition
205  virtual OUString SAL_CALL getMimeType() override;
206  virtual void SAL_CALL setMimeType( const OUString& _mimetype ) override;
207  virtual OUString SAL_CALL getCaption() override;
208  virtual void SAL_CALL setCaption( const OUString& _caption ) override;
209  virtual ::sal_Int16 SAL_CALL getGroupKeepTogether() override;
210  virtual void SAL_CALL setGroupKeepTogether( ::sal_Int16 _groupkeeptogether ) override;
211  virtual ::sal_Int16 SAL_CALL getPageHeaderOption() override;
212  virtual void SAL_CALL setPageHeaderOption( ::sal_Int16 _pageheaderoption ) override;
213  virtual ::sal_Int16 SAL_CALL getPageFooterOption() override;
214  virtual void SAL_CALL setPageFooterOption( ::sal_Int16 _pagefooteroption ) override;
215  virtual OUString SAL_CALL getCommand() override;
216  virtual void SAL_CALL setCommand( const OUString& _command ) override;
217  virtual ::sal_Int32 SAL_CALL getCommandType() override;
218  virtual void SAL_CALL setCommandType( ::sal_Int32 _commandtype ) override;
219  virtual OUString SAL_CALL getFilter() override;
220  virtual void SAL_CALL setFilter( const OUString& _filter ) override;
221  virtual sal_Bool SAL_CALL getEscapeProcessing() override;
222  virtual void SAL_CALL setEscapeProcessing( sal_Bool _escapeprocessing ) override;
223  virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getActiveConnection() override;
224  virtual void SAL_CALL setActiveConnection( const css::uno::Reference< css::sdbc::XConnection >& _activeconnection ) override;
225  virtual OUString SAL_CALL getDataSourceName() override;
226  virtual void SAL_CALL setDataSourceName( const OUString& _datasourcename ) override;
227  virtual sal_Bool SAL_CALL getReportHeaderOn() override;
228  virtual void SAL_CALL setReportHeaderOn( sal_Bool _reportheaderon ) override;
229  virtual sal_Bool SAL_CALL getReportFooterOn() override;
230  virtual void SAL_CALL setReportFooterOn( sal_Bool _reportfooteron ) override;
231  virtual sal_Bool SAL_CALL getPageHeaderOn() override;
232  virtual void SAL_CALL setPageHeaderOn( sal_Bool _pageheaderon ) override;
233  virtual sal_Bool SAL_CALL getPageFooterOn() override;
234  virtual void SAL_CALL setPageFooterOn( sal_Bool _pagefooteron ) override;
235  virtual css::uno::Reference< css::report::XGroups > SAL_CALL getGroups() override;
236  virtual css::uno::Reference< css::report::XSection > SAL_CALL getReportHeader() override;
237  virtual css::uno::Reference< css::report::XSection > SAL_CALL getPageHeader() override;
238  virtual css::uno::Reference< css::report::XSection > SAL_CALL getDetail() override;
239  virtual css::uno::Reference< css::report::XSection > SAL_CALL getPageFooter() override;
240  virtual css::uno::Reference< css::report::XSection > SAL_CALL getReportFooter() override;
241  virtual css::uno::Reference< css::document::XEventBroadcaster > SAL_CALL getEventBroadcaster( ) override;
242  virtual css::uno::Sequence< OUString > SAL_CALL getAvailableMimeTypes( ) override;
243 
244  // XReportComponent
246 
247  // XShape
248  SHAPE_HEADER()
249 
250  // XShapeDescriptor
251  virtual OUString SAL_CALL getShapeType( ) override;
252 
253  //XFunctionsSupplier
254  virtual css::uno::Reference< css::report::XFunctions > SAL_CALL getFunctions() override;
255 
256  // XCloneable
257  virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override;
258 
259  // XComponent
260  virtual void SAL_CALL dispose() override;
261  virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override
262  {
263  cppu::WeakComponentImplHelperBase::addEventListener(aListener);
264  }
265  virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override
266  {
267  cppu::WeakComponentImplHelperBase::removeEventListener(aListener);
268  }
269 
270  // XChild
271  virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override;
272  virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override;
273 
274  // XCloseBroadcaster
275  virtual void SAL_CALL addCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) override;
276  virtual void SAL_CALL removeCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) override;
277 
278  // XCloseable
279  virtual void SAL_CALL close( sal_Bool DeliverOwnership ) override;
280 
281  // XModel
282  virtual sal_Bool SAL_CALL attachResource( const OUString& URL, const css::uno::Sequence< css::beans::PropertyValue >& Arguments ) override;
283  virtual OUString SAL_CALL getURL( ) override;
284  virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getArgs( ) override;
285  virtual void SAL_CALL connectController( const css::uno::Reference< css::frame::XController >& Controller ) override;
286  virtual void SAL_CALL disconnectController( const css::uno::Reference< css::frame::XController >& Controller ) override;
287  virtual void SAL_CALL lockControllers( ) override;
288  virtual void SAL_CALL unlockControllers( ) override;
289  virtual sal_Bool SAL_CALL hasControllersLocked( ) override;
290  virtual css::uno::Reference< css::frame::XController > SAL_CALL getCurrentController( ) override;
291  virtual void SAL_CALL setCurrentController( const css::uno::Reference< css::frame::XController >& Controller ) override;
292  virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getCurrentSelection( ) override;
293 
294  // XStorageBasedDocument
295  virtual void SAL_CALL loadFromStorage( const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescriptor ) override;
296  virtual void SAL_CALL storeToStorage( const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescriptor ) override;
297  virtual void SAL_CALL switchToStorage( const css::uno::Reference< css::embed::XStorage >& xStorage ) override;
298  virtual css::uno::Reference< css::embed::XStorage > SAL_CALL getDocumentStorage( ) override;
299  virtual void SAL_CALL addStorageChangeListener( const css::uno::Reference< css::document::XStorageChangeListener >& xListener ) override;
300  virtual void SAL_CALL removeStorageChangeListener( const css::uno::Reference< css::document::XStorageChangeListener >& xListener ) override;
301 
302  // XViewDataSupplier
303  virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getViewData( ) override;
304  virtual void SAL_CALL setViewData( const css::uno::Reference< css::container::XIndexAccess >& Data ) override;
305 
306  // XLoadable
307  virtual void SAL_CALL initNew( ) override;
308  virtual void SAL_CALL load( const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override;
309 
310  // XVisualObject
311  virtual void SAL_CALL setVisualAreaSize( ::sal_Int64 nAspect, const css::awt::Size& aSize ) override;
312  virtual css::awt::Size SAL_CALL getVisualAreaSize( ::sal_Int64 nAspect ) override;
313  virtual css::embed::VisualRepresentation SAL_CALL getPreferredVisualRepresentation( ::sal_Int64 nAspect ) override;
314  virtual ::sal_Int32 SAL_CALL getMapUnit( ::sal_Int64 nAspect ) override;
315 
316  // XModifiable2
317  virtual sal_Bool SAL_CALL disableSetModified( ) override;
318  virtual sal_Bool SAL_CALL enableSetModified( ) override;
319  virtual sal_Bool SAL_CALL isSetModifiedEnabled( ) override;
320 
321  // XModifiable
322  virtual sal_Bool SAL_CALL isModified( ) override;
323  virtual void SAL_CALL setModified( sal_Bool bModified ) override;
324 
325  // XModifyBroadcaster
326  virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
327  virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
328 
329  // document::XEventBroadcaster
330  virtual void SAL_CALL addEventListener( const css::uno::Reference< css::document::XEventListener >& aListener ) override;
331  virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::document::XEventListener >& aListener ) override;
332 
333  // document::XDocumentEventBroadcaster
334  virtual void SAL_CALL addDocumentEventListener( const css::uno::Reference< css::document::XDocumentEventListener >& rListener ) override;
335  virtual void SAL_CALL removeDocumentEventListener( const css::uno::Reference< css::document::XDocumentEventListener >& rListener ) override;
336  virtual void SAL_CALL notifyDocumentEvent( const OUString& rEventName, const css::uno::Reference< css::frame::XController2 >& rViewController, const css::uno::Any& rSupplement ) override;
337 
338  // XUIConfigurationManagerSupplier
339  virtual css::uno::Reference< css::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager( ) override;
340 
341  // XDocumentSubStorageSupplier
342  virtual css::uno::Reference< css::embed::XStorage > SAL_CALL getDocumentSubStorage( const OUString& aStorageName, sal_Int32 nMode ) override;
343  virtual css::uno::Sequence< OUString > SAL_CALL getDocumentSubStoragesNames( ) override;
344 
345  // css::lang::XUnoTunnel
346  virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
347 
348  // SvxUnoDrawMSFactory
349  virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override;
350  virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) override;
351  css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override;
352 
353  // XStyleFamiliesSupplier
354  virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getStyleFamilies( ) override;
355 
356  // XModule
357  virtual void SAL_CALL setIdentifier( const OUString& Identifier ) override;
358  virtual OUString SAL_CALL getIdentifier( ) override;
359 
360  // XNumberFormatsSupplier
361  virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getNumberFormatSettings( ) override;
362  virtual css::uno::Reference< css::util::XNumberFormats > SAL_CALL getNumberFormats( ) override;
363 
364  // XTitle
365  virtual OUString SAL_CALL getTitle( ) override;
366  virtual void SAL_CALL setTitle( const OUString& sTitle ) override;
367 
368  // XTitleChangeBroadcaster
369  virtual void SAL_CALL addTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener ) override;
370  virtual void SAL_CALL removeTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener ) override;
371 
372  // XUntitledNumbers
373  virtual ::sal_Int32 SAL_CALL leaseNumber( const css::uno::Reference< css::uno::XInterface >& xComponent ) override;
374  virtual void SAL_CALL releaseNumber( ::sal_Int32 nNumber ) override;
375  virtual void SAL_CALL releaseNumberForComponent( const css::uno::Reference< css::uno::XInterface >& xComponent ) override;
376  virtual OUString SAL_CALL getUntitledPrefix( ) override;
377 
378  // XDocumentPropertiesSupplier
379  virtual css::uno::Reference< css::document::XDocumentProperties > SAL_CALL getDocumentProperties( ) override;
380 
381  // XTransferable
382  virtual css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) override;
383  virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) override;
384  virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) override;
385 
386  // XUndoManagerSupplier
387  virtual css::uno::Reference< css::document::XUndoManager > SAL_CALL getUndoManager( ) override;
388 
389  // comphelper::IEmbeddedHelper
390  virtual css::uno::Reference < css::embed::XStorage > getStorage() const override;
391  virtual ::comphelper::EmbeddedObjectContainer& getEmbeddedObjectContainer() const override;
392  virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const override;
393  virtual bool isEnableSetModified() const override;
394  virtual OUString getDocumentBaseURL() const override;
395 
397  css::uno::Reference< css::ui::XUIConfigurationManager2 > getUIConfigurationManager2( );
398  };
399 
400 } // namespace reportdesign
401 
402 #endif // INCLUDED_REPORTDESIGN_INC_REPORTDEFINITION_HXX
403 
404 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
osl::Mutex m_aMutex
#define REPORTDESIGN_DLLPUBLIC
Definition: dllapi.h:28
Reference< XNumberFormatsSupplier > getNumberFormats(const Reference< XConnection > &_rxConn, bool _bAlloweDefault, const Reference< XComponentContext > &_rxContext)
#define REPORTCOMPONENT_HEADER()
cppu::PartialWeakComponentImplHelper< css::report::XReportDefinition, css::document::XEventBroadcaster, css::document::XDocumentEventBroadcaster, css::lang::XServiceInfo, css::frame::XModule, css::lang::XUnoTunnel, css::util::XNumberFormatsSupplier, css::frame::XTitle, css::frame::XTitleChangeBroadcaster, css::frame::XUntitledNumbers, css::document::XDocumentPropertiesSupplier, css::datatransfer::XTransferable, css::document::XUndoManagerSupplier, SvxUnoDrawMSFactory > ReportDefinitionBase
#define SHAPE_HEADER()
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
unsigned char sal_Bool
OUString getTitle(const OUString &aPath)
bool close
FILE * init(int, char **)
void set(const OUString &_sProperty, bool Value, bool &_member)
std::shared_ptr< OReportComponentProperties > m_aProps
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString getIdentifier(css::uno::Reference< css::deployment::XPackage > const &package)
::cppu::PropertySetMixin< css::report::XReportDefinition > ReportDefinitionPropertySet
void set(const OUString &_sProperty, const T &Value, T &_member)
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
std::shared_ptr< OReportDefinitionImpl > m_pImpl
#define DECLARE_XINTERFACE()