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 #include <sal/config.h>
21
22 #include <vector>
23 #include <string_view>
24
25 #include <ReportDefinition.hxx>
26
27 #include <Functions.hxx>
28 #include <Groups.hxx>
29 #include <ReportComponent.hxx>
30 #include <ReportHelperImpl.hxx>
31 #include <RptDef.hxx>
32 #include <RptModel.hxx>
33 #include <Section.hxx>
34 #include <Tools.hxx>
35 #include <UndoEnv.hxx>
36 #include <strings.hrc>
37 #include <core_resource.hxx>
38 #include <strings.hxx>
39
40 #include <com/sun/star/beans/PropertyAttribute.hpp>
41 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
42 #include <com/sun/star/chart2/data/DatabaseDataProvider.hpp>
43 #include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp>
44 #include <com/sun/star/document/DocumentProperties.hpp>
45 #include <com/sun/star/document/IndexedPropertyValues.hpp>
46 #include <com/sun/star/document/EventObject.hpp>
47 #include <com/sun/star/document/XEventListener.hpp>
48 #include <com/sun/star/document/XExporter.hpp>
49 #include <com/sun/star/document/XFilter.hpp>
50 #include <com/sun/star/document/XImporter.hpp>
51 #include <com/sun/star/embed/Aspects.hpp>
52 #include <com/sun/star/embed/ElementModes.hpp>
53 #include <com/sun/star/embed/EmbedMapUnits.hpp>
54 #include <com/sun/star/embed/XTransactedObject.hpp>
55 #include <com/sun/star/embed/StorageFactory.hpp>
56 #include <com/sun/star/frame/Desktop.hpp>
57 #include <com/sun/star/io/IOException.hpp>
58 #include <com/sun/star/io/XSeekable.hpp>
59 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
60 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
61 #include <com/sun/star/report/GroupKeepTogether.hpp>
62 #include <com/sun/star/report/ReportPrintOption.hpp>
63 #include <com/sun/star/sdb/CommandType.hpp>
64 #include <com/sun/star/style/GraphicLocation.hpp>
65 #include <com/sun/star/style/NumberingType.hpp>
66 #include <com/sun/star/style/PageStyleLayout.hpp>
67 #include <com/sun/star/style/XStyle.hpp>
68 #include <com/sun/star/table/BorderLine2.hpp>
69 #include <com/sun/star/table/ShadowFormat.hpp>
70 #include <com/sun/star/task/InteractionHandler.hpp>
71 #include <com/sun/star/task/XStatusIndicator.hpp>
72 #include <com/sun/star/ui/UIConfigurationManager.hpp>
73 #include <com/sun/star/util/CloseVetoException.hpp>
74 #include <com/sun/star/util/NumberFormatsSupplier.hpp>
75 #include <com/sun/star/xml/AttributeData.hpp>
76 #include <com/sun/star/xml/sax/Writer.hpp>
77
78 #include <comphelper/broadcasthelper.hxx>
79 #include <comphelper/documentconstants.hxx>
80 #include <comphelper/genericpropertyset.hxx>
81 #include <unotools/mediadescriptor.hxx>
82 #include <comphelper/namecontainer.hxx>
83 #include <comphelper/namedvaluecollection.hxx>
84 #include <comphelper/numberedcollection.hxx>
85 #include <comphelper/proparrhlp.hxx>
86 #include <comphelper/propertysetinfo.hxx>
87 #include <comphelper/propertystatecontainer.hxx>
88 #include <comphelper/seqstream.hxx>
89 #include <comphelper/sequence.hxx>
90 #include <comphelper/servicehelper.hxx>
91 #include <comphelper/storagehelper.hxx>
92 #include <comphelper/uno3.hxx>
93 #include <connectivity/CommonTools.hxx>
94 #include <connectivity/dbtools.hxx>
95 #include <cppuhelper/exc_hlp.hxx>
96 #include <cppuhelper/implbase.hxx>
97 #include <cppuhelper/interfacecontainer.h>
98 #include <cppuhelper/supportsservice.hxx>
99 #include <cppuhelper/typeprovider.hxx>
100 #include <comphelper/types.hxx>
101 #include <dbaccess/dbaundomanager.hxx>
102 #include <editeng/paperinf.hxx>
103 #include <framework/titlehelper.hxx>
104 #include <svl/itempool.hxx>
105 #include <svl/undo.hxx>
106 #include <svx/svdlayer.hxx>
107 #include <svx/unofill.hxx>
108 #include <svx/xmleohlp.hxx>
109 #include <svx/xmlgrhlp.hxx>
110 #include <tools/diagnose_ex.h>
111 #include <unotools/saveopt.hxx>
112 #include <vcl/svapp.hxx>
113
114 // page styles
115 #define SC_UNO_PAGE_LEFTBORDER "LeftBorder"
116 #define SC_UNO_PAGE_RIGHTBORDER "RightBorder"
117 #define SC_UNO_PAGE_BOTTBORDER "BottomBorder"
118 #define SC_UNO_PAGE_TOPBORDER "TopBorder"
119 #define SC_UNO_PAGE_LEFTBRDDIST "LeftBorderDistance"
120 #define SC_UNO_PAGE_RIGHTBRDDIST "RightBorderDistance"
121 #define SC_UNO_PAGE_BOTTBRDDIST "BottomBorderDistance"
122 #define SC_UNO_PAGE_TOPBRDDIST "TopBorderDistance"
123 #define SC_UNO_PAGE_BORDERDIST "BorderDistance"
124 #define SC_UNO_PAGE_SHADOWFORM "ShadowFormat"
125 #define SC_UNO_PAGE_PAPERTRAY "PrinterPaperTray"
126 #define SC_UNO_PAGE_SCALEVAL "PageScale"
127 #define SC_UNO_PAGE_SCALETOPAG "ScaleToPages"
128 #define SC_UNO_PAGE_SCALETOX "ScaleToPagesX"
129 #define SC_UNO_PAGE_SCALETOY "ScaleToPagesY"
130 #define SC_UNO_PAGE_HDRBACKCOL "HeaderBackColor"
131 #define SC_UNO_PAGE_HDRBACKTRAN "HeaderBackTransparent"
132 #define SC_UNO_PAGE_HDRGRFFILT "HeaderBackGraphicFilter"
133 #define SC_UNO_PAGE_HDRGRFLOC "HeaderBackGraphicLocation"
134 #define SC_UNO_PAGE_HDRGRF "HeaderBackGraphic"
135 #define SC_UNO_PAGE_HDRLEFTBOR "HeaderLeftBorder"
136 #define SC_UNO_PAGE_HDRRIGHTBOR "HeaderRightBorder"
137 #define SC_UNO_PAGE_HDRBOTTBOR "HeaderBottomBorder"
138 #define SC_UNO_PAGE_HDRTOPBOR "HeaderTopBorder"
139 #define SC_UNO_PAGE_HDRLEFTBDIS "HeaderLeftBorderDistance"
140 #define SC_UNO_PAGE_HDRRIGHTBDIS "HeaderRightBorderDistance"
141 #define SC_UNO_PAGE_HDRBOTTBDIS "HeaderBottomBorderDistance"
142 #define SC_UNO_PAGE_HDRTOPBDIS "HeaderTopBorderDistance"
143 #define SC_UNO_PAGE_HDRBRDDIST "HeaderBorderDistance"
144 #define SC_UNO_PAGE_HDRSHADOW "HeaderShadowFormat"
145 #define SC_UNO_PAGE_HDRLEFTMAR "HeaderLeftMargin"
146 #define SC_UNO_PAGE_HDRRIGHTMAR "HeaderRightMargin"
147 #define SC_UNO_PAGE_HDRBODYDIST "HeaderBodyDistance"
148 #define SC_UNO_PAGE_HDRHEIGHT "HeaderHeight"
149 #define SC_UNO_PAGE_HDRON "HeaderIsOn"
150 #define SC_UNO_PAGE_HDRDYNAMIC "HeaderIsDynamicHeight"
151 #define SC_UNO_PAGE_HDRSHARED "HeaderIsShared"
152 #define SC_UNO_PAGE_FIRSTHDRSHARED "FirstPageHeaderIsShared"
153 #define SC_UNO_PAGE_FTRBACKCOL "FooterBackColor"
154 #define SC_UNO_PAGE_FTRBACKTRAN "FooterBackTransparent"
155 #define SC_UNO_PAGE_FTRGRFFILT "FooterBackGraphicFilter"
156 #define SC_UNO_PAGE_FTRGRFLOC "FooterBackGraphicLocation"
157 #define SC_UNO_PAGE_FTRGRF "FooterBackGraphic"
158 #define SC_UNO_PAGE_FTRLEFTBOR "FooterLeftBorder"
159 #define SC_UNO_PAGE_FTRRIGHTBOR "FooterRightBorder"
160 #define SC_UNO_PAGE_FTRBOTTBOR "FooterBottomBorder"
161 #define SC_UNO_PAGE_FTRTOPBOR "FooterTopBorder"
162 #define SC_UNO_PAGE_FTRLEFTBDIS "FooterLeftBorderDistance"
163 #define SC_UNO_PAGE_FTRRIGHTBDIS "FooterRightBorderDistance"
164 #define SC_UNO_PAGE_FTRBOTTBDIS "FooterBottomBorderDistance"
165 #define SC_UNO_PAGE_FTRTOPBDIS "FooterTopBorderDistance"
166 #define SC_UNO_PAGE_FTRBRDDIST "FooterBorderDistance"
167 #define SC_UNO_PAGE_FTRSHADOW "FooterShadowFormat"
168 #define SC_UNO_PAGE_FTRLEFTMAR "FooterLeftMargin"
169 #define SC_UNO_PAGE_FTRRIGHTMAR "FooterRightMargin"
170 #define SC_UNO_PAGE_FTRBODYDIST "FooterBodyDistance"
171 #define SC_UNO_PAGE_FTRHEIGHT "FooterHeight"
172 #define SC_UNO_PAGE_FTRON "FooterIsOn"
173 #define SC_UNO_PAGE_FTRDYNAMIC "FooterIsDynamicHeight"
174 #define SC_UNO_PAGE_FTRSHARED "FooterIsShared"
175 #define SC_UNO_PAGE_FIRSTFTRSHARED "FirstPageFooterIsShared"
176
177 namespace reportdesign
178 {
179 using namespace com::sun::star;
180 using namespace rptui;
181
lcl_setModelReadOnly(const uno::Reference<embed::XStorage> & _xStorage,std::shared_ptr<rptui::OReportModel> const & _rModel)182 static void lcl_setModelReadOnly(const uno::Reference< embed::XStorage >& _xStorage,std::shared_ptr<rptui::OReportModel> const & _rModel)
183 {
184 uno::Reference<beans::XPropertySet> xProp(_xStorage,uno::UNO_QUERY);
185 sal_Int32 nOpenMode = embed::ElementModes::READ;
186 if ( xProp.is() )
187 xProp->getPropertyValue("OpenMode") >>= nOpenMode;
188
189 _rModel->SetReadOnly((nOpenMode & embed::ElementModes::WRITE) != embed::ElementModes::WRITE);
190 }
lcl_stripLoadArguments(utl::MediaDescriptor & _rDescriptor,uno::Sequence<beans::PropertyValue> & _rArgs)191 static void lcl_stripLoadArguments( utl::MediaDescriptor& _rDescriptor, uno::Sequence< beans::PropertyValue >& _rArgs )
192 {
193 _rDescriptor.erase( "StatusIndicator" );
194 _rDescriptor.erase( "InteractionHandler" );
195 _rDescriptor.erase( "Model" );
196 _rDescriptor >> _rArgs;
197 }
198
lcl_extractAndStartStatusIndicator(const utl::MediaDescriptor & _rDescriptor,uno::Reference<task::XStatusIndicator> & _rxStatusIndicator,uno::Sequence<uno::Any> & _rCallArgs)199 static void lcl_extractAndStartStatusIndicator( const utl::MediaDescriptor& _rDescriptor, uno::Reference< task::XStatusIndicator >& _rxStatusIndicator,
200 uno::Sequence< uno::Any >& _rCallArgs )
201 {
202 try
203 {
204 _rxStatusIndicator = _rDescriptor.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_STATUSINDICATOR(), _rxStatusIndicator );
205 if ( _rxStatusIndicator.is() )
206 {
207 _rxStatusIndicator->start( OUString(), sal_Int32(1000000) );
208
209 sal_Int32 nLength = _rCallArgs.getLength();
210 _rCallArgs.realloc( nLength + 1 );
211 _rCallArgs[ nLength ] <<= _rxStatusIndicator;
212 }
213 }
214 catch (const uno::Exception&)
215 {
216 TOOLS_WARN_EXCEPTION( "reportdesign", "lcl_extractAndStartStatusIndicator" );
217 }
218 }
219
220 typedef ::comphelper::OPropertyStateContainer OStyle_PBASE;
221
222 namespace {
223
224 class OStyle;
225
226 }
227
228 typedef ::comphelper::OPropertyArrayUsageHelper < OStyle
229 > OStyle_PABASE;
230 typedef ::cppu::WeakImplHelper< style::XStyle, beans::XMultiPropertyStates> TStyleBASE;
231
232 namespace {
233
234 class OStyle : public ::comphelper::OMutexAndBroadcastHelper
235 ,public TStyleBASE
236 ,public OStyle_PBASE
237 ,public OStyle_PABASE
238 {
239 awt::Size m_aSize;
240
241 protected:
242 void getPropertyDefaultByHandle( sal_Int32 _nHandle, uno::Any& _rDefault ) const override;
~OStyle()243 virtual ~OStyle() override {}
244 public:
245 OStyle();
246
247
248 DECLARE_XINTERFACE( )
249
250 // XPropertySet
251 css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
252 ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
253 ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
254
255 // XStyle
256 sal_Bool SAL_CALL isUserDefined( ) override;
257 sal_Bool SAL_CALL isInUse( ) override;
258 OUString SAL_CALL getParentStyle( ) override;
259 void SAL_CALL setParentStyle( const OUString& aParentStyle ) override;
260
261 // XNamed
262 OUString SAL_CALL getName( ) override;
263 void SAL_CALL setName( const OUString& aName ) override;
264
265 // XMultiPropertyState
getPropertyStates(const uno::Sequence<OUString> & aPropertyNames)266 uno::Sequence< beans::PropertyState > SAL_CALL getPropertyStates( const uno::Sequence< OUString >& aPropertyNames ) override
267 {
268 return OStyle_PBASE::getPropertyStates(aPropertyNames);
269 }
270 void SAL_CALL setAllPropertiesToDefault( ) override;
271 void SAL_CALL setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames ) override;
272 uno::Sequence< uno::Any > SAL_CALL getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames ) override;
273 };
274
275 }
276
OStyle()277 OStyle::OStyle()
278 :OStyle_PBASE(m_aBHelper)
279 ,m_aSize(21000,29700)
280 {
281 const ::Size aDefaultSize = SvxPaperInfo::GetDefaultPaperSize( MapUnit::Map100thMM );
282 m_aSize.Height = aDefaultSize.Height();
283 m_aSize.Width = aDefaultSize.Width();
284
285 const sal_Int32 nMargin = 2000;
286 const sal_Int32 nBound = beans::PropertyAttribute::BOUND;
287 const sal_Int32 nMayBeVoid = beans::PropertyAttribute::MAYBEVOID;
288
289 sal_Int32 i = 0;
290 registerPropertyNoMember( PROPERTY_NAME, ++i, nBound, cppu::UnoType<OUString>::get(), css::uno::Any(OUString("Default")) );
291
292 registerPropertyNoMember(PROPERTY_BACKCOLOR, ++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny(COL_TRANSPARENT));
293
294 registerPropertyNoMember(PROPERTY_BACKGRAPHICLOCATION, ++i,nBound, cppu::UnoType<style::GraphicLocation>::get(), css::uno::Any(style::GraphicLocation_NONE));
295 registerPropertyNoMember(PROPERTY_BACKTRANSPARENT, ++i,nBound,cppu::UnoType<bool>::get(), css::uno::Any(true));
296 registerPropertyNoMember(SC_UNO_PAGE_BORDERDIST, ++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
297 registerPropertyNoMember(SC_UNO_PAGE_BOTTBORDER, ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), css::uno::Any(table::BorderLine2()));
298 registerPropertyNoMember(SC_UNO_PAGE_BOTTBRDDIST, ++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
299 registerPropertyNoMember(PROPERTY_BOTTOMMARGIN, ++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::Any(nMargin));
300 registerPropertyNoMember("DisplayName", ++i,nBound, cppu::UnoType<OUString>::get(), css::uno::Any(OUString()));
301 registerPropertyNoMember(SC_UNO_PAGE_FTRBACKCOL, ++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny(COL_TRANSPARENT));
302 registerPropertyNoMember(SC_UNO_PAGE_FTRGRFFILT, ++i,nBound, cppu::UnoType<OUString>::get(), css::uno::Any(OUString()));
303 registerPropertyNoMember(SC_UNO_PAGE_FTRGRFLOC, ++i,nBound, cppu::UnoType<style::GraphicLocation>::get(), css::uno::Any(style::GraphicLocation_NONE));
304 registerPropertyNoMember(SC_UNO_PAGE_FTRGRF, ++i,nBound|nMayBeVoid, cppu::UnoType<graphic::XGraphic>::get(), css::uno::Any(uno::Reference<graphic::XGraphic>()));
305 registerPropertyNoMember(SC_UNO_PAGE_FTRBACKTRAN, ++i,nBound,cppu::UnoType<bool>::get(), css::uno::Any(true));
306 registerPropertyNoMember(SC_UNO_PAGE_FTRBODYDIST, ++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
307 registerPropertyNoMember(SC_UNO_PAGE_FTRBRDDIST, ++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
308 registerPropertyNoMember(SC_UNO_PAGE_FTRBOTTBOR, ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), css::uno::Any(table::BorderLine2()));
309 registerPropertyNoMember(SC_UNO_PAGE_FTRBOTTBDIS, ++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
310 registerPropertyNoMember(SC_UNO_PAGE_FTRHEIGHT, ++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
311 registerPropertyNoMember(SC_UNO_PAGE_FTRDYNAMIC, ++i,nBound,cppu::UnoType<bool>::get(), css::uno::Any(false));
312 registerPropertyNoMember(SC_UNO_PAGE_FTRON, ++i,nBound,cppu::UnoType<bool>::get(), css::uno::Any(false));
313 registerPropertyNoMember(SC_UNO_PAGE_FTRSHARED, ++i,nBound,cppu::UnoType<bool>::get(), css::uno::Any(false));
314 registerPropertyNoMember(SC_UNO_PAGE_FIRSTFTRSHARED, ++i,nBound,cppu::UnoType<bool>::get(), css::uno::Any(false));
315 registerPropertyNoMember(SC_UNO_PAGE_FTRLEFTBOR, ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), css::uno::Any(table::BorderLine2()));
316 registerPropertyNoMember(SC_UNO_PAGE_FTRLEFTBDIS, ++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
317 registerPropertyNoMember(SC_UNO_PAGE_FTRLEFTMAR, ++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
318 registerPropertyNoMember(SC_UNO_PAGE_FTRRIGHTBOR, ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), css::uno::Any(table::BorderLine2()));
319 registerPropertyNoMember(SC_UNO_PAGE_FTRRIGHTBDIS,++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
320 registerPropertyNoMember(SC_UNO_PAGE_FTRRIGHTMAR, ++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
321 registerPropertyNoMember(SC_UNO_PAGE_FTRSHADOW, ++i,nBound, cppu::UnoType<table::ShadowFormat>::get(), css::uno::Any(table::ShadowFormat()));
322 registerPropertyNoMember(SC_UNO_PAGE_FTRTOPBOR, ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), css::uno::Any(table::BorderLine2()));
323 registerPropertyNoMember(SC_UNO_PAGE_FTRTOPBDIS, ++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
324
325 registerPropertyNoMember(SC_UNO_PAGE_HDRBACKCOL, ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny(COL_TRANSPARENT));
326 registerPropertyNoMember(SC_UNO_PAGE_HDRGRFFILT, ++i,nBound|nMayBeVoid, cppu::UnoType<OUString>::get(), css::uno::Any(OUString()));
327 registerPropertyNoMember(SC_UNO_PAGE_HDRGRFLOC, ++i,nBound|nMayBeVoid, cppu::UnoType<style::GraphicLocation>::get(), css::uno::Any(style::GraphicLocation_NONE));
328 registerPropertyNoMember(SC_UNO_PAGE_HDRGRF, ++i,nBound|nMayBeVoid, cppu::UnoType<graphic::XGraphic>::get(), css::uno::Any(uno::Reference<graphic::XGraphic>()));
329 registerPropertyNoMember(SC_UNO_PAGE_HDRBACKTRAN, ++i,nBound|nMayBeVoid,cppu::UnoType<bool>::get(), css::uno::Any(true));
330 registerPropertyNoMember(SC_UNO_PAGE_HDRBODYDIST, ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
331 registerPropertyNoMember(SC_UNO_PAGE_HDRBRDDIST, ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
332 registerPropertyNoMember(SC_UNO_PAGE_HDRBOTTBOR, ++i,nBound|nMayBeVoid, cppu::UnoType<table::BorderLine2>::get(), css::uno::Any(table::BorderLine2()));
333 registerPropertyNoMember(SC_UNO_PAGE_HDRBOTTBDIS, ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
334 registerPropertyNoMember(SC_UNO_PAGE_HDRHEIGHT, ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
335 registerPropertyNoMember(SC_UNO_PAGE_HDRDYNAMIC, ++i,nBound|nMayBeVoid,cppu::UnoType<bool>::get(), css::uno::Any(false));
336 registerPropertyNoMember(SC_UNO_PAGE_HDRON, ++i,nBound|nMayBeVoid,cppu::UnoType<bool>::get(), css::uno::Any(false));
337 registerPropertyNoMember(SC_UNO_PAGE_HDRSHARED, ++i,nBound|nMayBeVoid,cppu::UnoType<bool>::get(), css::uno::Any(false));
338 registerPropertyNoMember(SC_UNO_PAGE_FIRSTHDRSHARED, ++i,nBound|nMayBeVoid,cppu::UnoType<bool>::get(), css::uno::Any(false));
339 registerPropertyNoMember(SC_UNO_PAGE_HDRLEFTBOR, ++i,nBound|nMayBeVoid, cppu::UnoType<table::BorderLine2>::get(), css::uno::Any(table::BorderLine2()));
340 registerPropertyNoMember(SC_UNO_PAGE_HDRLEFTBDIS, ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
341 registerPropertyNoMember(SC_UNO_PAGE_HDRLEFTMAR, ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
342 registerPropertyNoMember(SC_UNO_PAGE_HDRRIGHTBOR, ++i,nBound|nMayBeVoid, cppu::UnoType<table::BorderLine2>::get(), css::uno::Any(table::BorderLine2()));
343 registerPropertyNoMember(SC_UNO_PAGE_HDRRIGHTBDIS,++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
344 registerPropertyNoMember(SC_UNO_PAGE_HDRRIGHTMAR, ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
345 registerPropertyNoMember(SC_UNO_PAGE_HDRSHADOW, ++i,nBound|nMayBeVoid, cppu::UnoType<table::ShadowFormat>::get(), css::uno::Any(table::ShadowFormat()));
346 registerPropertyNoMember(SC_UNO_PAGE_HDRTOPBOR, ++i,nBound|nMayBeVoid, cppu::UnoType<table::BorderLine2>::get(), css::uno::Any(table::BorderLine2()));
347 registerPropertyNoMember(SC_UNO_PAGE_HDRTOPBDIS, ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
348
349 registerProperty(PROPERTY_HEIGHT, ++i,nBound,&m_aSize.Height, ::cppu::UnoType<sal_Int32>::get() );
350 registerPropertyNoMember(PROPERTY_ISLANDSCAPE, ++i,nBound, cppu::UnoType<bool>::get(), css::uno::Any(false));
351 registerPropertyNoMember(SC_UNO_PAGE_LEFTBORDER, ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), css::uno::Any(table::BorderLine2()));
352 registerPropertyNoMember(SC_UNO_PAGE_LEFTBRDDIST, ++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
353 registerPropertyNoMember(PROPERTY_LEFTMARGIN, ++i,beans::PropertyAttribute::BOUND, ::cppu::UnoType<sal_Int32>::get(), css::uno::Any(nMargin));
354 registerPropertyNoMember(PROPERTY_NUMBERINGTYPE, ++i,nBound, cppu::UnoType<sal_Int16>::get(), css::uno::Any(style::NumberingType::ARABIC));
355 registerPropertyNoMember(SC_UNO_PAGE_SCALEVAL, ++i,nBound, cppu::UnoType<sal_Int16>::get(), css::uno::makeAny<sal_Int16>(0));
356 registerPropertyNoMember(PROPERTY_PAGESTYLELAYOUT, ++i,nBound, cppu::UnoType<style::PageStyleLayout>::get(), css::uno::Any(style::PageStyleLayout_ALL));
357 registerPropertyNoMember(SC_UNO_PAGE_PAPERTRAY, ++i,nBound, cppu::UnoType<OUString>::get(), css::uno::Any(OUString("[From printer settings]")));
358 registerPropertyNoMember(SC_UNO_PAGE_RIGHTBORDER, ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), css::uno::Any(table::BorderLine2()));
359 registerPropertyNoMember(SC_UNO_PAGE_RIGHTBRDDIST,++i,nBound, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
360 registerPropertyNoMember(PROPERTY_RIGHTMARGIN, ++i,beans::PropertyAttribute::BOUND,::cppu::UnoType<sal_Int32>::get(), css::uno::Any(nMargin));
361 registerPropertyNoMember(SC_UNO_PAGE_SCALETOPAG, ++i,nBound, cppu::UnoType<sal_Int16>::get(), css::uno::makeAny<sal_Int16>(0));
362 registerPropertyNoMember(SC_UNO_PAGE_SCALETOX, ++i,nBound, cppu::UnoType<sal_Int16>::get(), css::uno::makeAny<sal_Int16>(0));
363 registerPropertyNoMember(SC_UNO_PAGE_SCALETOY, ++i,nBound, cppu::UnoType<sal_Int16>::get(), css::uno::makeAny<sal_Int16>(0));
364 registerPropertyNoMember(SC_UNO_PAGE_SHADOWFORM, ++i,nBound, cppu::UnoType<table::ShadowFormat>::get(), css::uno::Any(table::ShadowFormat()));
365 registerProperty(PROPERTY_PAPERSIZE, ++i,beans::PropertyAttribute::BOUND,&m_aSize, cppu::UnoType<awt::Size>::get() );
366 registerPropertyNoMember(SC_UNO_PAGE_TOPBORDER, ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), css::uno::Any(table::BorderLine2()));
367 registerPropertyNoMember(SC_UNO_PAGE_TOPBRDDIST, ++i,nBound,::cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0));
368 registerPropertyNoMember(PROPERTY_TOPMARGIN, ++i,nBound,::cppu::UnoType<sal_Int32>::get(), css::uno::Any(nMargin));
369 registerPropertyNoMember("UserDefinedAttributes", ++i,nBound, cppu::UnoType<container::XNameContainer>::get(), css::uno::Any(comphelper::NameContainer_createInstance(cppu::UnoType<xml::AttributeData>::get())));
370 registerProperty(PROPERTY_WIDTH, ++i,nBound,&m_aSize.Width, cppu::UnoType<sal_Int32>::get() );
371 registerPropertyNoMember("PrinterName", ++i,nBound, cppu::UnoType<OUString>::get(), css::uno::Any(OUString()));
372 registerPropertyNoMember("PrinterSetup", ++i,nBound,cppu::UnoType<uno::Sequence<sal_Int8>>::get(), css::uno::Any(uno::Sequence<sal_Int8>()));
373
374
375 }
376
IMPLEMENT_FORWARD_XINTERFACE2(OStyle,TStyleBASE,OStyle_PBASE)377 IMPLEMENT_FORWARD_XINTERFACE2(OStyle,TStyleBASE,OStyle_PBASE)
378
379 uno::Reference< beans::XPropertySetInfo> SAL_CALL OStyle::getPropertySetInfo()
380 {
381 return createPropertySetInfo( getInfoHelper() );
382 }
383
getPropertyDefaultByHandle(sal_Int32,uno::Any &) const384 void OStyle::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, uno::Any& /*_rDefault*/ ) const
385 {
386 }
387
getInfoHelper()388 ::cppu::IPropertyArrayHelper& OStyle::getInfoHelper()
389 {
390 return *getArrayHelper();
391 }
392
createArrayHelper() const393 ::cppu::IPropertyArrayHelper* OStyle::createArrayHelper( ) const
394 {
395 uno::Sequence< beans::Property > aProps;
396 describeProperties(aProps);
397 return new ::cppu::OPropertyArrayHelper(aProps);
398 }
399
400 // XStyle
isUserDefined()401 sal_Bool SAL_CALL OStyle::isUserDefined( )
402 {
403 return false;
404 }
405
isInUse()406 sal_Bool SAL_CALL OStyle::isInUse( )
407 {
408 return true;
409 }
410
getParentStyle()411 OUString SAL_CALL OStyle::getParentStyle( )
412 {
413 return OUString();
414 }
415
setParentStyle(const OUString &)416 void SAL_CALL OStyle::setParentStyle( const OUString& /*aParentStyle*/ )
417 {
418 }
419
420 // XNamed
getName()421 OUString SAL_CALL OStyle::getName( )
422 {
423 OUString sName;
424 getPropertyValue(PROPERTY_NAME) >>= sName;
425 return sName;
426 }
427
setName(const OUString & aName)428 void SAL_CALL OStyle::setName( const OUString& aName )
429 {
430 setPropertyValue(PROPERTY_NAME,uno::makeAny(aName));
431 }
432
setAllPropertiesToDefault()433 void SAL_CALL OStyle::setAllPropertiesToDefault( )
434 {
435 }
436
setPropertiesToDefault(const uno::Sequence<OUString> & aPropertyNames)437 void SAL_CALL OStyle::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames )
438 {
439 for(const OUString& rName : aPropertyNames)
440 setPropertyToDefault(rName);
441 }
442
getPropertyDefaults(const uno::Sequence<OUString> & aPropertyNames)443 uno::Sequence< uno::Any > SAL_CALL OStyle::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames )
444 {
445 uno::Sequence< uno::Any > aRet(aPropertyNames.getLength());
446 std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.begin(),
447 [this](const OUString& rName) -> uno::Any { return getPropertyDefault(rName); });
448 return aRet;
449 }
450
451 struct OReportDefinitionImpl
452 {
453 uno::WeakReference< uno::XInterface > m_xParent;
454 ::comphelper::OInterfaceContainerHelper2 m_aStorageChangeListeners;
455 ::comphelper::OInterfaceContainerHelper2 m_aCloseListener;
456 ::comphelper::OInterfaceContainerHelper2 m_aModifyListeners;
457 ::comphelper::OInterfaceContainerHelper2 m_aLegacyEventListeners;
458 ::comphelper::OInterfaceContainerHelper2 m_aDocEventListeners;
459 ::std::vector< uno::Reference< frame::XController> > m_aControllers;
460 uno::Sequence< beans::PropertyValue > m_aArgs;
461
462 uno::Reference< report::XGroups > m_xGroups;
463 uno::Reference< report::XSection> m_xReportHeader;
464 uno::Reference< report::XSection> m_xReportFooter;
465 uno::Reference< report::XSection> m_xPageHeader;
466 uno::Reference< report::XSection> m_xPageFooter;
467 uno::Reference< report::XSection> m_xDetail;
468 uno::Reference< embed::XStorage > m_xStorage;
469 uno::Reference< frame::XController > m_xCurrentController;
470 uno::Reference< container::XIndexAccess > m_xViewData;
471 uno::Reference< container::XNameAccess > m_xStyles;
472 uno::Reference< container::XNameAccess> m_xXMLNamespaceMap;
473 uno::Reference< container::XNameAccess> m_xGradientTable;
474 uno::Reference< container::XNameAccess> m_xHatchTable;
475 uno::Reference< container::XNameAccess> m_xBitmapTable;
476 uno::Reference< container::XNameAccess> m_xTransparencyGradientTable;
477 uno::Reference< container::XNameAccess> m_xDashTable;
478 uno::Reference< container::XNameAccess> m_xMarkerTable;
479 uno::Reference< report::XFunctions > m_xFunctions;
480 uno::Reference< ui::XUIConfigurationManager2> m_xUIConfigurationManager;
481 uno::Reference< util::XNumberFormatsSupplier> m_xNumberFormatsSupplier;
482 uno::Reference< sdbc::XConnection> m_xActiveConnection;
483 uno::Reference< frame::XTitle > m_xTitleHelper;
484 uno::Reference< frame::XUntitledNumbers > m_xNumberedControllers;
485 uno::Reference< document::XDocumentProperties > m_xDocumentProperties;
486
487 std::shared_ptr< ::comphelper::EmbeddedObjectContainer>
488 m_pObjectContainer;
489 std::shared_ptr<rptui::OReportModel> m_pReportModel;
490 ::rtl::Reference< ::dbaui::UndoManager > m_pUndoManager;
491 OUString m_sCaption;
492 OUString m_sCommand;
493 OUString m_sFilter;
494 OUString m_sMimeType;
495 OUString m_sIdentifier;
496 OUString m_sDataSourceName;
497 awt::Size m_aVisualAreaSize;
498 ::sal_Int64 m_nAspect;
499 ::sal_Int16 m_nGroupKeepTogether;
500 ::sal_Int16 m_nPageHeaderOption;
501 ::sal_Int16 m_nPageFooterOption;
502 ::sal_Int32 m_nCommandType;
503 bool m_bControllersLocked;
504 bool m_bModified;
505 bool m_bEscapeProcessing;
506 bool m_bSetModifiedEnabled;
507
OReportDefinitionImplreportdesign::OReportDefinitionImpl508 explicit OReportDefinitionImpl(::osl::Mutex& _aMutex)
509 :m_aStorageChangeListeners(_aMutex)
510 ,m_aCloseListener(_aMutex)
511 ,m_aModifyListeners(_aMutex)
512 ,m_aLegacyEventListeners(_aMutex)
513 ,m_aDocEventListeners(_aMutex)
514 ,m_sMimeType(MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII)
515 ,m_sIdentifier(SERVICE_REPORTDEFINITION)
516 // default visual area is 8 x 7 cm
517 ,m_aVisualAreaSize( 8000, 7000 )
518 ,m_nAspect(embed::Aspects::MSOLE_CONTENT)
519 ,m_nGroupKeepTogether(0)
520 ,m_nPageHeaderOption(0)
521 ,m_nPageFooterOption(0)
522 ,m_nCommandType(sdb::CommandType::TABLE)
523 ,m_bControllersLocked(false)
524 ,m_bModified(false)
525 ,m_bEscapeProcessing(true)
526 ,m_bSetModifiedEnabled( true )
527 {}
528 };
529
OReportDefinition(uno::Reference<uno::XComponentContext> const & _xContext)530 OReportDefinition::OReportDefinition(uno::Reference< uno::XComponentContext > const & _xContext)
531 : ::cppu::BaseMutex(),
532 ReportDefinitionBase(m_aMutex),
533 ReportDefinitionPropertySet(_xContext,IMPLEMENTS_PROPERTY_SET,uno::Sequence< OUString >()),
534 ::comphelper::IEmbeddedHelper(),
535 m_aProps(std::make_shared<OReportComponentProperties>(_xContext)),
536 m_pImpl(std::make_shared<OReportDefinitionImpl>(m_aMutex))
537 {
538 m_aProps->m_sName = RptResId(RID_STR_REPORT);
539 osl_atomic_increment(&m_refCount);
540 {
541 init();
542 m_pImpl->m_xGroups = new OGroups(this,m_aProps->m_xContext);
543 m_pImpl->m_xDetail = OSection::createOSection(this,m_aProps->m_xContext);
544 m_pImpl->m_xDetail->setName(RptResId(RID_STR_DETAIL));
545 }
546 osl_atomic_decrement( &m_refCount );
547 }
548
OReportDefinition(uno::Reference<uno::XComponentContext> const & _xContext,const uno::Reference<lang::XMultiServiceFactory> & _xFactory,uno::Reference<drawing::XShape> & _xShape)549 OReportDefinition::OReportDefinition(
550 uno::Reference< uno::XComponentContext > const & _xContext,
551 const uno::Reference< lang::XMultiServiceFactory>& _xFactory,
552 uno::Reference< drawing::XShape >& _xShape)
553 : ::cppu::BaseMutex(),
554 ReportDefinitionBase(m_aMutex),
555 ReportDefinitionPropertySet(_xContext,IMPLEMENTS_PROPERTY_SET,uno::Sequence< OUString >()),
556 ::comphelper::IEmbeddedHelper(),
557 m_aProps(std::make_shared<OReportComponentProperties>(_xContext)),
558 m_pImpl(std::make_shared<OReportDefinitionImpl>(m_aMutex))
559 {
560 m_aProps->m_sName = RptResId(RID_STR_REPORT);
561 m_aProps->m_xFactory = _xFactory;
562 osl_atomic_increment(&m_refCount);
563 {
564 m_aProps->setShape(_xShape,this,m_refCount);
565 init();
566 m_pImpl->m_xGroups = new OGroups(this,m_aProps->m_xContext);
567 m_pImpl->m_xDetail = OSection::createOSection(this,m_aProps->m_xContext);
568 m_pImpl->m_xDetail->setName(RptResId(RID_STR_DETAIL));
569 }
570 osl_atomic_decrement( &m_refCount );
571 }
572
~OReportDefinition()573 OReportDefinition::~OReportDefinition()
574 {
575 if ( !ReportDefinitionBase::rBHelper.bInDispose && !ReportDefinitionBase::rBHelper.bDisposed )
576 {
577 acquire();
578 dispose();
579 }
580 }
581
IMPLEMENT_FORWARD_REFCOUNT(OReportDefinition,ReportDefinitionBase)582 IMPLEMENT_FORWARD_REFCOUNT( OReportDefinition, ReportDefinitionBase )
583 void OReportDefinition::init()
584 {
585 try
586 {
587 m_pImpl->m_pReportModel = std::make_shared<OReportModel>(this);
588 m_pImpl->m_pReportModel->GetItemPool().FreezeIdRanges();
589 m_pImpl->m_pReportModel->SetScaleUnit( MapUnit::Map100thMM );
590 SdrLayerAdmin& rAdmin = m_pImpl->m_pReportModel->GetLayerAdmin();
591 rAdmin.NewLayer("front", sal_uInt8(RPT_LAYER_FRONT));
592 rAdmin.NewLayer("back", sal_uInt8(RPT_LAYER_BACK));
593 rAdmin.NewLayer("HiddenLayer", sal_uInt8(RPT_LAYER_HIDDEN));
594
595 m_pImpl->m_pUndoManager = new ::dbaui::UndoManager( *this, m_aMutex );
596 m_pImpl->m_pReportModel->SetSdrUndoManager( &m_pImpl->m_pUndoManager->GetSfxUndoManager() );
597
598 m_pImpl->m_xFunctions = new OFunctions(this,m_aProps->m_xContext);
599 if ( !m_pImpl->m_xStorage.is() )
600 m_pImpl->m_xStorage = ::comphelper::OStorageHelper::GetTemporaryStorage();
601
602 uno::Reference<beans::XPropertySet> xStorProps(m_pImpl->m_xStorage,uno::UNO_QUERY);
603 if ( xStorProps.is())
604 {
605 OUString sMediaType;
606 xStorProps->getPropertyValue("MediaType") >>= sMediaType;
607 if ( sMediaType.isEmpty() )
608 xStorProps->setPropertyValue("MediaType",uno::makeAny<OUString>(MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII));
609 }
610 m_pImpl->m_pObjectContainer = std::make_shared<comphelper::EmbeddedObjectContainer>(m_pImpl->m_xStorage , static_cast<cppu::OWeakObject*>(this) );
611 }
612 catch (const uno::Exception&)
613 {
614 DBG_UNHANDLED_EXCEPTION("reportdesign");
615 }
616 }
617
dispose()618 void SAL_CALL OReportDefinition::dispose()
619 {
620 ReportDefinitionPropertySet::dispose();
621 cppu::WeakComponentImplHelperBase::dispose();
622 }
623
disposing()624 void SAL_CALL OReportDefinition::disposing()
625 {
626 notifyEvent("OnUnload");
627
628 uno::Reference< frame::XModel > xHoldAlive( this );
629
630 lang::EventObject aDisposeEvent( static_cast< ::cppu::OWeakObject* >( this ) );
631 m_pImpl->m_aModifyListeners.disposeAndClear( aDisposeEvent );
632 m_pImpl->m_aCloseListener.disposeAndClear( aDisposeEvent );
633 m_pImpl->m_aLegacyEventListeners.disposeAndClear( aDisposeEvent );
634 m_pImpl->m_aDocEventListeners.disposeAndClear( aDisposeEvent );
635 m_pImpl->m_aStorageChangeListeners.disposeAndClear( aDisposeEvent );
636
637 // SYNCHRONIZED --->
638 {
639 SolarMutexGuard aSolarGuard;
640 osl::MutexGuard aGuard(m_aMutex);
641
642 m_pImpl->m_aControllers.clear();
643
644 ::comphelper::disposeComponent(m_pImpl->m_xGroups);
645 m_pImpl->m_xReportHeader.clear();
646 m_pImpl->m_xReportFooter.clear();
647 m_pImpl->m_xPageHeader.clear();
648 m_pImpl->m_xPageFooter.clear();
649 m_pImpl->m_xDetail.clear();
650 ::comphelper::disposeComponent(m_pImpl->m_xFunctions);
651
652 //::comphelper::disposeComponent(m_pImpl->m_xStorage);
653 // don't dispose, this currently is the task of either the ref count going to
654 // 0, or of the embedded object (if we're embedded, which is the only possible
655 // case so far)
656 // #i78366#
657 m_pImpl->m_xStorage.clear();
658 m_pImpl->m_xViewData.clear();
659 m_pImpl->m_xCurrentController.clear();
660 m_pImpl->m_xNumberFormatsSupplier.clear();
661 m_pImpl->m_xStyles.clear();
662 m_pImpl->m_xXMLNamespaceMap.clear();
663 m_pImpl->m_xGradientTable.clear();
664 m_pImpl->m_xHatchTable.clear();
665 m_pImpl->m_xBitmapTable.clear();
666 m_pImpl->m_xTransparencyGradientTable.clear();
667 m_pImpl->m_xDashTable.clear();
668 m_pImpl->m_xMarkerTable.clear();
669 m_pImpl->m_xUIConfigurationManager.clear();
670 m_pImpl->m_pReportModel.reset();
671 m_pImpl->m_pObjectContainer.reset();
672 m_pImpl->m_aArgs.realloc(0);
673 m_pImpl->m_xTitleHelper.clear();
674 m_pImpl->m_xNumberedControllers.clear();
675 }
676 // <--- SYNCHRONIZED
677 }
678
679
getImplementationName_Static()680 OUString OReportDefinition::getImplementationName_Static( )
681 {
682 return "com.sun.star.comp.report.OReportDefinition";
683 }
684
getImplementationName()685 OUString SAL_CALL OReportDefinition::getImplementationName( )
686 {
687 return getImplementationName_Static();
688 }
689
getSupportedServiceNames_Static()690 uno::Sequence< OUString > OReportDefinition::getSupportedServiceNames_Static( )
691 {
692 uno::Sequence< OUString > aServices { SERVICE_REPORTDEFINITION };
693
694 return aServices;
695 }
696
getSupportedServiceNames()697 uno::Sequence< OUString > SAL_CALL OReportDefinition::getSupportedServiceNames( )
698 {
699 // first collect the services which are supported by our aggregate
700 uno::Sequence< OUString > aSupported;
701 if ( m_aProps->m_xServiceInfo.is() )
702 aSupported = m_aProps->m_xServiceInfo->getSupportedServiceNames();
703
704 // append our own service, if necessary
705 if ( ::comphelper::findValue( aSupported, SERVICE_REPORTDEFINITION ) == -1 )
706 {
707 sal_Int32 nLen = aSupported.getLength();
708 aSupported.realloc( nLen + 1 );
709 aSupported[ nLen ] = SERVICE_REPORTDEFINITION;
710 }
711
712 // outta here
713 return aSupported;
714 }
715
supportsService(const OUString & _rServiceName)716 sal_Bool SAL_CALL OReportDefinition::supportsService( const OUString& _rServiceName )
717 {
718 return cppu::supportsService(this, _rServiceName);
719 }
720
queryInterface(const uno::Type & _rType)721 uno::Any SAL_CALL OReportDefinition::queryInterface( const uno::Type& _rType )
722 {
723 uno::Any aReturn = ReportDefinitionBase::queryInterface(_rType);
724 if ( !aReturn.hasValue() )
725 aReturn = ReportDefinitionPropertySet::queryInterface(_rType);
726
727 return aReturn.hasValue() ? aReturn : (m_aProps->m_xProxy.is() ? m_aProps->m_xProxy->queryAggregation(_rType) : aReturn);
728 }
getTypes()729 uno::Sequence< uno::Type > SAL_CALL OReportDefinition::getTypes( )
730 {
731 if ( m_aProps->m_xTypeProvider.is() )
732 return ::comphelper::concatSequences(
733 ReportDefinitionBase::getTypes(),
734 m_aProps->m_xTypeProvider->getTypes()
735 );
736 return ReportDefinitionBase::getTypes();
737 }
738
create(uno::Reference<uno::XComponentContext> const & xContext)739 uno::Reference< uno::XInterface > OReportDefinition::create(uno::Reference< uno::XComponentContext > const & xContext)
740 {
741 return *(new OReportDefinition(xContext));
742 }
743
744 // XReportDefinition
getCaption()745 OUString SAL_CALL OReportDefinition::getCaption()
746 {
747 ::osl::MutexGuard aGuard(m_aMutex);
748 return m_pImpl->m_sCaption;
749 }
750
setCaption(const OUString & _caption)751 void SAL_CALL OReportDefinition::setCaption( const OUString& _caption )
752 {
753 set(PROPERTY_CAPTION,_caption,m_pImpl->m_sCaption);
754 }
755
getGroupKeepTogether()756 ::sal_Int16 SAL_CALL OReportDefinition::getGroupKeepTogether()
757 {
758 ::osl::MutexGuard aGuard(m_aMutex);
759 return m_pImpl->m_nGroupKeepTogether;
760 }
761
setGroupKeepTogether(::sal_Int16 _groupkeeptogether)762 void SAL_CALL OReportDefinition::setGroupKeepTogether( ::sal_Int16 _groupkeeptogether )
763 {
764 if ( _groupkeeptogether < report::GroupKeepTogether::PER_PAGE || _groupkeeptogether > report::GroupKeepTogether::PER_COLUMN )
765 throwIllegallArgumentException("css::report::GroupKeepTogether"
766 ,*this
767 ,1);
768 set(PROPERTY_GROUPKEEPTOGETHER,_groupkeeptogether,m_pImpl->m_nGroupKeepTogether);
769 }
770
getPageHeaderOption()771 ::sal_Int16 SAL_CALL OReportDefinition::getPageHeaderOption()
772 {
773 ::osl::MutexGuard aGuard(m_aMutex);
774 return m_pImpl->m_nPageHeaderOption;
775 }
776
setPageHeaderOption(::sal_Int16 _pageheaderoption)777 void SAL_CALL OReportDefinition::setPageHeaderOption( ::sal_Int16 _pageheaderoption )
778 {
779 if ( _pageheaderoption < report::ReportPrintOption::ALL_PAGES || _pageheaderoption > report::ReportPrintOption::NOT_WITH_REPORT_HEADER_FOOTER )
780 throwIllegallArgumentException("css::report::ReportPrintOption"
781 ,*this
782 ,1);
783 set(PROPERTY_PAGEHEADEROPTION,_pageheaderoption,m_pImpl->m_nPageHeaderOption);
784 }
785
getPageFooterOption()786 ::sal_Int16 SAL_CALL OReportDefinition::getPageFooterOption()
787 {
788 ::osl::MutexGuard aGuard(m_aMutex);
789 return m_pImpl->m_nPageFooterOption;
790 }
791
setPageFooterOption(::sal_Int16 _pagefooteroption)792 void SAL_CALL OReportDefinition::setPageFooterOption( ::sal_Int16 _pagefooteroption )
793 {
794 if ( _pagefooteroption < report::ReportPrintOption::ALL_PAGES || _pagefooteroption > report::ReportPrintOption::NOT_WITH_REPORT_HEADER_FOOTER )
795 throwIllegallArgumentException("css::report::ReportPrintOption"
796 ,*this
797 ,1);
798 set(PROPERTY_PAGEFOOTEROPTION,_pagefooteroption,m_pImpl->m_nPageFooterOption);
799 }
800
getCommand()801 OUString SAL_CALL OReportDefinition::getCommand()
802 {
803 ::osl::MutexGuard aGuard(m_aMutex);
804 return m_pImpl->m_sCommand;
805 }
806
setCommand(const OUString & _command)807 void SAL_CALL OReportDefinition::setCommand( const OUString& _command )
808 {
809 set(PROPERTY_COMMAND,_command,m_pImpl->m_sCommand);
810 }
811
getCommandType()812 ::sal_Int32 SAL_CALL OReportDefinition::getCommandType()
813 {
814 ::osl::MutexGuard aGuard(m_aMutex);
815 return m_pImpl->m_nCommandType;
816 }
817
setCommandType(::sal_Int32 _commandtype)818 void SAL_CALL OReportDefinition::setCommandType( ::sal_Int32 _commandtype )
819 {
820 if ( _commandtype < sdb::CommandType::TABLE || _commandtype > sdb::CommandType::COMMAND )
821 throwIllegallArgumentException("css::sdb::CommandType"
822 ,*this
823 ,1);
824 set(PROPERTY_COMMANDTYPE,_commandtype,m_pImpl->m_nCommandType);
825 }
826
getFilter()827 OUString SAL_CALL OReportDefinition::getFilter()
828 {
829 ::osl::MutexGuard aGuard(m_aMutex);
830 return m_pImpl->m_sFilter;
831 }
832
setFilter(const OUString & _filter)833 void SAL_CALL OReportDefinition::setFilter( const OUString& _filter )
834 {
835 set(PROPERTY_FILTER,_filter,m_pImpl->m_sFilter);
836 }
837
getEscapeProcessing()838 sal_Bool SAL_CALL OReportDefinition::getEscapeProcessing()
839 {
840 ::osl::MutexGuard aGuard(m_aMutex);
841 return m_pImpl->m_bEscapeProcessing;
842 }
843
setEscapeProcessing(sal_Bool _escapeprocessing)844 void SAL_CALL OReportDefinition::setEscapeProcessing( sal_Bool _escapeprocessing )
845 {
846 set(PROPERTY_ESCAPEPROCESSING,_escapeprocessing,m_pImpl->m_bEscapeProcessing);
847 }
848
getReportHeaderOn()849 sal_Bool SAL_CALL OReportDefinition::getReportHeaderOn()
850 {
851 ::osl::MutexGuard aGuard(m_aMutex);
852 return m_pImpl->m_xReportHeader.is();
853 }
854
setReportHeaderOn(sal_Bool _reportheaderon)855 void SAL_CALL OReportDefinition::setReportHeaderOn( sal_Bool _reportheaderon )
856 {
857 if ( bool(_reportheaderon) != m_pImpl->m_xReportHeader.is() )
858 {
859 setSection(PROPERTY_REPORTHEADERON,_reportheaderon,RptResId(RID_STR_REPORT_HEADER),m_pImpl->m_xReportHeader);
860 }
861 }
862
getReportFooterOn()863 sal_Bool SAL_CALL OReportDefinition::getReportFooterOn()
864 {
865 ::osl::MutexGuard aGuard(m_aMutex);
866 return m_pImpl->m_xReportFooter.is();
867 }
868
setReportFooterOn(sal_Bool _reportfooteron)869 void SAL_CALL OReportDefinition::setReportFooterOn( sal_Bool _reportfooteron )
870 {
871 if ( bool(_reportfooteron) != m_pImpl->m_xReportFooter.is() )
872 {
873 setSection(PROPERTY_REPORTFOOTERON,_reportfooteron,RptResId(RID_STR_REPORT_FOOTER),m_pImpl->m_xReportFooter);
874 }
875 }
876
getPageHeaderOn()877 sal_Bool SAL_CALL OReportDefinition::getPageHeaderOn()
878 {
879 ::osl::MutexGuard aGuard(m_aMutex);
880 return m_pImpl->m_xPageHeader.is();
881 }
882
setPageHeaderOn(sal_Bool _pageheaderon)883 void SAL_CALL OReportDefinition::setPageHeaderOn( sal_Bool _pageheaderon )
884 {
885 if ( bool(_pageheaderon) != m_pImpl->m_xPageHeader.is() )
886 {
887 setSection(PROPERTY_PAGEHEADERON,_pageheaderon,RptResId(RID_STR_PAGE_HEADER),m_pImpl->m_xPageHeader);
888 }
889 }
890
getPageFooterOn()891 sal_Bool SAL_CALL OReportDefinition::getPageFooterOn()
892 {
893 ::osl::MutexGuard aGuard(m_aMutex);
894 return m_pImpl->m_xPageFooter.is();
895 }
896
setPageFooterOn(sal_Bool _pagefooteron)897 void SAL_CALL OReportDefinition::setPageFooterOn( sal_Bool _pagefooteron )
898 {
899 if ( bool(_pagefooteron) != m_pImpl->m_xPageFooter.is() )
900 {
901 setSection(PROPERTY_PAGEFOOTERON,_pagefooteron,RptResId(RID_STR_PAGE_FOOTER),m_pImpl->m_xPageFooter);
902 }
903 }
904
getGroups()905 uno::Reference< report::XGroups > SAL_CALL OReportDefinition::getGroups()
906 {
907 ::osl::MutexGuard aGuard(m_aMutex);
908 return m_pImpl->m_xGroups;
909 }
910
getReportHeader()911 uno::Reference< report::XSection > SAL_CALL OReportDefinition::getReportHeader()
912 {
913 ::osl::MutexGuard aGuard(m_aMutex);
914 if ( !m_pImpl->m_xReportHeader.is() )
915 throw container::NoSuchElementException();
916 return m_pImpl->m_xReportHeader;
917 }
918
getPageHeader()919 uno::Reference< report::XSection > SAL_CALL OReportDefinition::getPageHeader()
920 {
921 ::osl::MutexGuard aGuard(m_aMutex);
922 if ( !m_pImpl->m_xPageHeader.is() )
923 throw container::NoSuchElementException();
924 return m_pImpl->m_xPageHeader;
925 }
926
getDetail()927 uno::Reference< report::XSection > SAL_CALL OReportDefinition::getDetail()
928 {
929 ::osl::MutexGuard aGuard(m_aMutex);
930 return m_pImpl->m_xDetail;
931 }
932
getPageFooter()933 uno::Reference< report::XSection > SAL_CALL OReportDefinition::getPageFooter()
934 {
935 ::osl::MutexGuard aGuard(m_aMutex);
936 if ( !m_pImpl->m_xPageFooter.is() )
937 throw container::NoSuchElementException();
938 return m_pImpl->m_xPageFooter;
939 }
940
getReportFooter()941 uno::Reference< report::XSection > SAL_CALL OReportDefinition::getReportFooter()
942 {
943 ::osl::MutexGuard aGuard(m_aMutex);
944 if ( !m_pImpl->m_xReportFooter.is() )
945 throw container::NoSuchElementException();
946 return m_pImpl->m_xReportFooter;
947 }
948
getEventBroadcaster()949 uno::Reference< document::XEventBroadcaster > SAL_CALL OReportDefinition::getEventBroadcaster( )
950 {
951 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
952 return this;
953 }
954
955 // XReportComponent
956 REPORTCOMPONENT_MASTERDETAIL(OReportDefinition,*m_aProps)
957 REPORTCOMPONENT_IMPL(OReportDefinition,*m_aProps)
958 REPORTCOMPONENT_IMPL2(OReportDefinition,*m_aProps)
959
getPropertySetInfo()960 uno::Reference< beans::XPropertySetInfo > SAL_CALL OReportDefinition::getPropertySetInfo( )
961 {
962 return ReportDefinitionPropertySet::getPropertySetInfo();
963 }
964
setPropertyValue(const OUString & aPropertyName,const uno::Any & aValue)965 void SAL_CALL OReportDefinition::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
966 {
967 ReportDefinitionPropertySet::setPropertyValue( aPropertyName, aValue );
968 }
969
getPropertyValue(const OUString & PropertyName)970 uno::Any SAL_CALL OReportDefinition::getPropertyValue( const OUString& PropertyName )
971 {
972 return ReportDefinitionPropertySet::getPropertyValue( PropertyName);
973 }
974
addPropertyChangeListener(const OUString & aPropertyName,const uno::Reference<beans::XPropertyChangeListener> & xListener)975 void SAL_CALL OReportDefinition::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener )
976 {
977 ReportDefinitionPropertySet::addPropertyChangeListener( aPropertyName, xListener );
978 }
979
removePropertyChangeListener(const OUString & aPropertyName,const uno::Reference<beans::XPropertyChangeListener> & aListener)980 void SAL_CALL OReportDefinition::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener )
981 {
982 ReportDefinitionPropertySet::removePropertyChangeListener( aPropertyName, aListener );
983 }
984
addVetoableChangeListener(const OUString & PropertyName,const uno::Reference<beans::XVetoableChangeListener> & aListener)985 void SAL_CALL OReportDefinition::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
986 {
987 ReportDefinitionPropertySet::addVetoableChangeListener( PropertyName, aListener );
988 }
989
removeVetoableChangeListener(const OUString & PropertyName,const uno::Reference<beans::XVetoableChangeListener> & aListener)990 void SAL_CALL OReportDefinition::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
991 {
992 ReportDefinitionPropertySet::removeVetoableChangeListener( PropertyName, aListener );
993 }
994
995 // XChild
getParent()996 uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::getParent( )
997 {
998 ::osl::MutexGuard aGuard(m_aMutex);
999 uno::Reference< container::XChild > xChild;
1000 comphelper::query_aggregation(m_aProps->m_xProxy,xChild);
1001 if ( xChild.is() )
1002 return xChild->getParent();
1003 return m_pImpl->m_xParent;
1004 }
1005
setParent(const uno::Reference<uno::XInterface> & Parent)1006 void SAL_CALL OReportDefinition::setParent( const uno::Reference< uno::XInterface >& Parent )
1007 {
1008 ::osl::MutexGuard aGuard(m_aMutex);
1009 m_aProps->m_xParent = uno::Reference< container::XChild >(Parent,uno::UNO_QUERY);
1010 m_pImpl->m_xParent = Parent;
1011 uno::Reference< container::XChild > xChild;
1012 comphelper::query_aggregation(m_aProps->m_xProxy,xChild);
1013 if ( xChild.is() )
1014 xChild->setParent(Parent);
1015 }
1016
1017 // XCloneable
createClone()1018 uno::Reference< util::XCloneable > SAL_CALL OReportDefinition::createClone( )
1019 {
1020 OSL_FAIL("Not yet implemented correctly");
1021 uno::Reference< report::XReportComponent> xSource = this;
1022 uno::Reference< report::XReportDefinition> xSet(cloneObject(xSource,m_aProps->m_xFactory,SERVICE_REPORTDEFINITION),uno::UNO_QUERY_THROW);
1023 return xSet;
1024 }
1025
setSection(const OUString & _sProperty,bool _bOn,const OUString & _sName,uno::Reference<report::XSection> & _member)1026 void OReportDefinition::setSection( const OUString& _sProperty
1027 ,bool _bOn
1028 ,const OUString& _sName
1029 ,uno::Reference< report::XSection>& _member)
1030 {
1031 BoundListeners l;
1032 {
1033 ::osl::MutexGuard aGuard(m_aMutex);
1034 prepareSet(_sProperty, uno::makeAny(_member), uno::makeAny(_bOn), &l);
1035
1036 // create section if needed
1037 if ( _bOn && !_member.is() )
1038 _member = OSection::createOSection(this, getContext(), _sProperty == PROPERTY_PAGEHEADERON || _sProperty == PROPERTY_PAGEFOOTERON);
1039 else if ( !_bOn )
1040 ::comphelper::disposeComponent(_member);
1041
1042 if ( _member.is() )
1043 _member->setName(_sName);
1044 }
1045 l.notify();
1046 }
1047
1048 // XCloseBroadcaster
addCloseListener(const uno::Reference<util::XCloseListener> & _xListener)1049 void SAL_CALL OReportDefinition::addCloseListener( const uno::Reference< util::XCloseListener >& _xListener )
1050 {
1051 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1052 if ( _xListener.is() )
1053 m_pImpl->m_aCloseListener.addInterface(_xListener);
1054 }
1055
removeCloseListener(const uno::Reference<util::XCloseListener> & _xListener)1056 void SAL_CALL OReportDefinition::removeCloseListener( const uno::Reference< util::XCloseListener >& _xListener )
1057 {
1058 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1059 m_pImpl->m_aCloseListener.removeInterface(_xListener);
1060 }
1061
1062 // XCloseable
close(sal_Bool bDeliverOwnership)1063 void SAL_CALL OReportDefinition::close(sal_Bool bDeliverOwnership)
1064 {
1065 SolarMutexGuard aSolarGuard;
1066
1067 ::osl::ResettableMutexGuard aGuard(m_aMutex);
1068 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1069 // notify our container listeners
1070 lang::EventObject aEvt( static_cast< ::cppu::OWeakObject* >( this ) );
1071 aGuard.clear();
1072 m_pImpl->m_aCloseListener.forEach<util::XCloseListener>(
1073 [&aEvt, &bDeliverOwnership] (uno::Reference<util::XCloseListener> const& xListener) {
1074 return xListener->queryClosing(aEvt, bDeliverOwnership);
1075 });
1076 aGuard.reset();
1077
1078
1079 ::std::vector< uno::Reference< frame::XController> > aCopy = m_pImpl->m_aControllers;
1080 for (auto& rxController : aCopy)
1081 {
1082 if ( rxController.is() )
1083 {
1084 try
1085 {
1086 uno::Reference< util::XCloseable> xFrame( rxController->getFrame(), uno::UNO_QUERY );
1087 if ( xFrame.is() )
1088 xFrame->close( bDeliverOwnership );
1089 }
1090 catch (const util::CloseVetoException&) { throw; }
1091 catch (const uno::Exception&)
1092 {
1093 TOOLS_WARN_EXCEPTION( "reportdesign", "ODatabaseDocument::impl_closeControllerFrames" );
1094 }
1095 }
1096 }
1097
1098 aGuard.clear();
1099 m_pImpl->m_aCloseListener.notifyEach(&util::XCloseListener::notifyClosing,aEvt);
1100 aGuard.reset();
1101
1102 dispose();
1103 }
1104
1105 // XModel
attachResource(const OUString &,const uno::Sequence<beans::PropertyValue> & _aArguments)1106 sal_Bool SAL_CALL OReportDefinition::attachResource( const OUString& /*_rURL*/, const uno::Sequence< beans::PropertyValue >& _aArguments )
1107 {
1108 // LLA: we had a deadlock problem in our context, so we get the SolarMutex earlier.
1109 SolarMutexGuard aSolarGuard;
1110
1111 ::osl::MutexGuard aGuard(m_aMutex);
1112 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed );
1113 utl::MediaDescriptor aDescriptor( _aArguments );
1114
1115 m_pImpl->m_pUndoManager->GetSfxUndoManager().EnableUndo( false );
1116 try
1117 {
1118 fillArgs(aDescriptor);
1119 m_pImpl->m_pReportModel->SetModified(false);
1120 }
1121 catch (...)
1122 {
1123 m_pImpl->m_pUndoManager->GetSfxUndoManager().EnableUndo( true );
1124 throw;
1125 }
1126 m_pImpl->m_pUndoManager->GetSfxUndoManager().EnableUndo( true );
1127 return true;
1128 }
1129
fillArgs(utl::MediaDescriptor & _aDescriptor)1130 void OReportDefinition::fillArgs(utl::MediaDescriptor& _aDescriptor)
1131 {
1132 uno::Sequence<beans::PropertyValue> aComponentData;
1133 aComponentData = _aDescriptor.getUnpackedValueOrDefault("ComponentData",aComponentData);
1134 if ( aComponentData.hasElements() && (!m_pImpl->m_xActiveConnection.is() || !m_pImpl->m_xNumberFormatsSupplier.is()) )
1135 {
1136 ::comphelper::SequenceAsHashMap aComponentDataMap( aComponentData );
1137 m_pImpl->m_xActiveConnection = aComponentDataMap.getUnpackedValueOrDefault("ActiveConnection",m_pImpl->m_xActiveConnection);
1138 m_pImpl->m_xNumberFormatsSupplier = dbtools::getNumberFormats(m_pImpl->m_xActiveConnection);
1139 }
1140 if ( !m_pImpl->m_xNumberFormatsSupplier.is() )
1141 {
1142 m_pImpl->m_xNumberFormatsSupplier.set( util::NumberFormatsSupplier::createWithDefaultLocale( m_aProps->m_xContext ) );
1143 }
1144 lcl_stripLoadArguments( _aDescriptor, m_pImpl->m_aArgs );
1145 OUString sCaption;
1146 sCaption = _aDescriptor.getUnpackedValueOrDefault("DocumentTitle",sCaption);
1147 setCaption(sCaption);
1148 }
1149
getURL()1150 OUString SAL_CALL OReportDefinition::getURL( )
1151 {
1152 return OUString();
1153 }
1154
getArgs()1155 uno::Sequence< beans::PropertyValue > SAL_CALL OReportDefinition::getArgs( )
1156 {
1157 ::osl::MutexGuard aGuard(m_aMutex);
1158 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1159 return m_pImpl->m_aArgs;
1160 }
1161
connectController(const uno::Reference<frame::XController> & _xController)1162 void SAL_CALL OReportDefinition::connectController( const uno::Reference< frame::XController >& _xController )
1163 {
1164 ::osl::MutexGuard aGuard(m_aMutex);
1165 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1166 m_pImpl->m_aControllers.push_back(_xController);
1167 if ( _xController.is() && m_pImpl->m_xViewData.is() )
1168 {
1169 sal_Int32 nCount = m_pImpl->m_xViewData->getCount();
1170 if (nCount)
1171 _xController->restoreViewData(m_pImpl->m_xViewData->getByIndex(nCount - 1));
1172 }
1173 }
1174
disconnectController(const uno::Reference<frame::XController> & _xController)1175 void SAL_CALL OReportDefinition::disconnectController( const uno::Reference< frame::XController >& _xController )
1176 {
1177 ::osl::MutexGuard aGuard(m_aMutex);
1178 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1179 ::std::vector< uno::Reference< frame::XController> >::iterator aFind = ::std::find(m_pImpl->m_aControllers.begin(),m_pImpl->m_aControllers.end(),_xController);
1180 if ( aFind != m_pImpl->m_aControllers.end() )
1181 m_pImpl->m_aControllers.erase(aFind);
1182 if ( m_pImpl->m_xCurrentController == _xController )
1183 m_pImpl->m_xCurrentController.clear();
1184 }
1185
lockControllers()1186 void SAL_CALL OReportDefinition::lockControllers( )
1187 {
1188 ::osl::MutexGuard aGuard(m_aMutex);
1189 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1190 m_pImpl->m_bControllersLocked = true;
1191 }
1192
unlockControllers()1193 void SAL_CALL OReportDefinition::unlockControllers( )
1194 {
1195 ::osl::MutexGuard aGuard(m_aMutex);
1196 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1197 m_pImpl->m_bControllersLocked = false;
1198 }
1199
hasControllersLocked()1200 sal_Bool SAL_CALL OReportDefinition::hasControllersLocked( )
1201 {
1202 ::osl::MutexGuard aGuard(m_aMutex);
1203 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1204 return m_pImpl->m_bControllersLocked;
1205 }
1206
getCurrentController()1207 uno::Reference< frame::XController > SAL_CALL OReportDefinition::getCurrentController( )
1208 {
1209 ::osl::MutexGuard aGuard(m_aMutex);
1210 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1211 return m_pImpl->m_xCurrentController;
1212 }
1213
setCurrentController(const uno::Reference<frame::XController> & _xController)1214 void SAL_CALL OReportDefinition::setCurrentController( const uno::Reference< frame::XController >& _xController )
1215 {
1216 ::osl::MutexGuard aGuard(m_aMutex);
1217 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1218 if ( ::std::find(m_pImpl->m_aControllers.begin(),m_pImpl->m_aControllers.end(),_xController) == m_pImpl->m_aControllers.end() )
1219 throw container::NoSuchElementException();
1220 m_pImpl->m_xCurrentController = _xController;
1221 }
1222
getCurrentSelection()1223 uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::getCurrentSelection( )
1224 {
1225 return uno::Reference< uno::XInterface >();
1226 }
1227
impl_loadFromStorage_nolck_throw(const uno::Reference<embed::XStorage> & _xStorageToLoadFrom,const uno::Sequence<beans::PropertyValue> & _aMediaDescriptor)1228 void OReportDefinition::impl_loadFromStorage_nolck_throw( const uno::Reference< embed::XStorage >& _xStorageToLoadFrom,
1229 const uno::Sequence< beans::PropertyValue >& _aMediaDescriptor )
1230 {
1231 m_pImpl->m_xStorage = _xStorageToLoadFrom;
1232
1233 utl::MediaDescriptor aDescriptor( _aMediaDescriptor );
1234 fillArgs(aDescriptor);
1235 aDescriptor.createItemIfMissing("Storage",uno::makeAny(_xStorageToLoadFrom));
1236
1237 uno::Sequence< uno::Any > aDelegatorArguments(_aMediaDescriptor.getLength());
1238 uno::Any* pIter = aDelegatorArguments.getArray();
1239 uno::Any* pEnd = pIter + aDelegatorArguments.getLength();
1240 for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
1241 {
1242 *pIter <<= _aMediaDescriptor[i];
1243 }
1244 sal_Int32 nPos = aDelegatorArguments.getLength();
1245 aDelegatorArguments.realloc(nPos+1);
1246 beans::PropertyValue aPropVal;
1247 aPropVal.Name = "Storage";
1248 aPropVal.Value <<= _xStorageToLoadFrom;
1249 aDelegatorArguments[nPos] <<= aPropVal;
1250
1251 rptui::OXUndoEnvironment& rEnv = m_pImpl->m_pReportModel->GetUndoEnv();
1252 rptui::OXUndoEnvironment::OUndoEnvLock aLock(rEnv);
1253 {
1254 uno::Reference< document::XFilter > xFilter(
1255 m_aProps->m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.comp.report.OReportFilter",aDelegatorArguments,m_aProps->m_xContext),
1256 uno::UNO_QUERY_THROW );
1257
1258 uno::Reference< document::XImporter> xImporter(xFilter,uno::UNO_QUERY_THROW);
1259 uno::Reference<XComponent> xComponent(static_cast<OWeakObject*>(this),uno::UNO_QUERY);
1260 xImporter->setTargetDocument(xComponent);
1261
1262 utl::MediaDescriptor aTemp;
1263 aTemp << aDelegatorArguments;
1264 xFilter->filter(aTemp.getAsConstPropertyValueList());
1265
1266 lcl_setModelReadOnly(m_pImpl->m_xStorage,m_pImpl->m_pReportModel);
1267 m_pImpl->m_pObjectContainer->SwitchPersistence(m_pImpl->m_xStorage);
1268 }
1269 }
1270
1271 // XStorageBasedDocument
loadFromStorage(const uno::Reference<embed::XStorage> & _xStorageToLoadFrom,const uno::Sequence<beans::PropertyValue> & _aMediaDescriptor)1272 void SAL_CALL OReportDefinition::loadFromStorage( const uno::Reference< embed::XStorage >& _xStorageToLoadFrom
1273 , const uno::Sequence< beans::PropertyValue >& _aMediaDescriptor )
1274 {
1275 ::osl::MutexGuard aGuard(m_aMutex);
1276 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1277
1278 impl_loadFromStorage_nolck_throw( _xStorageToLoadFrom, _aMediaDescriptor );
1279 }
1280
storeToStorage(const uno::Reference<embed::XStorage> & _xStorageToSaveTo,const uno::Sequence<beans::PropertyValue> & _aMediaDescriptor)1281 void SAL_CALL OReportDefinition::storeToStorage( const uno::Reference< embed::XStorage >& _xStorageToSaveTo, const uno::Sequence< beans::PropertyValue >& _aMediaDescriptor )
1282 {
1283 if ( !_xStorageToSaveTo.is() )
1284 throw lang::IllegalArgumentException(RptResId(RID_STR_ARGUMENT_IS_NULL),*this,1);
1285
1286 SolarMutexGuard aSolarGuard;
1287 ::osl::MutexGuard aGuard(m_aMutex);
1288 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1289 // create XStatusIndicator
1290 uno::Reference<task::XStatusIndicator> xStatusIndicator;
1291 uno::Sequence< uno::Any > aDelegatorArguments;
1292 utl::MediaDescriptor aDescriptor( _aMediaDescriptor );
1293 lcl_extractAndStartStatusIndicator( aDescriptor, xStatusIndicator, aDelegatorArguments );
1294
1295 // properties
1296 uno::Sequence < beans::PropertyValue > aProps;
1297
1298 // export sub streams for package, else full stream into a file
1299 uno::Reference< beans::XPropertySet> xProp(_xStorageToSaveTo,uno::UNO_QUERY);
1300 if ( xProp.is() )
1301 {
1302 static constexpr OUStringLiteral sPropName = u"MediaType";
1303 OUString sOldMediaType;
1304 xProp->getPropertyValue(sPropName) >>= sOldMediaType;
1305 if ( !xProp->getPropertyValue(sPropName).hasValue() || sOldMediaType.isEmpty() || MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII != sOldMediaType )
1306 xProp->setPropertyValue( sPropName, uno::makeAny<OUString>(MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII) );
1307 }
1308
1309 /** property map for export info set */
1310 comphelper::PropertyMapEntry const aExportInfoMap[] =
1311 {
1312 { OUString("UsePrettyPrinting") , 0, cppu::UnoType<sal_Bool>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
1313 { OUString("StreamName") , 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
1314 { OUString("StreamRelPath") , 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
1315 { OUString("BaseURI") , 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
1316 { OUString(), 0, css::uno::Type(), 0, 0 }
1317 };
1318 uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) );
1319
1320 SvtSaveOptions aSaveOpt;
1321 xInfoSet->setPropertyValue("UsePrettyPrinting", uno::makeAny(aSaveOpt.IsPrettyPrinting()));
1322 if ( aSaveOpt.IsSaveRelFSys() )
1323 {
1324 const OUString sVal( aDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_DOCUMENTBASEURL(),OUString()) );
1325 xInfoSet->setPropertyValue("BaseURI", uno::makeAny(sVal));
1326 }
1327 const OUString sHierarchicalDocumentName( aDescriptor.getUnpackedValueOrDefault("HierarchicalDocumentName",OUString()) );
1328 xInfoSet->setPropertyValue("StreamRelPath", uno::makeAny(sHierarchicalDocumentName));
1329
1330
1331 sal_Int32 nArgsLen = aDelegatorArguments.getLength();
1332 aDelegatorArguments.realloc(nArgsLen+1);
1333 aDelegatorArguments[nArgsLen++] <<= xInfoSet;
1334
1335 uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
1336 uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler;
1337 rtl::Reference<SvXMLGraphicHelper> xGraphicHelper = SvXMLGraphicHelper::Create(_xStorageToSaveTo,SvXMLGraphicHelperMode::Write);
1338 xGraphicStorageHandler = xGraphicHelper.get();
1339 xGraphicHelper.clear();
1340 xObjectResolver = SvXMLEmbeddedObjectHelper::Create( _xStorageToSaveTo,*this, SvXMLEmbeddedObjectHelperMode::Write ).get();
1341
1342 aDelegatorArguments.realloc(nArgsLen+2);
1343 aDelegatorArguments[nArgsLen++] <<= xGraphicStorageHandler;
1344 aDelegatorArguments[nArgsLen++] <<= xObjectResolver;
1345
1346 uno::Reference<XComponent> xCom(static_cast<OWeakObject*>(this),uno::UNO_QUERY);
1347 // Try to write to settings.xml, meta.xml, and styles.xml; only really care about success of
1348 // write to content.xml (keeping logic of commit 94ccba3eebc83b58e74e18f0e028c6a995ce6aa6)
1349 xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("settings.xml")));
1350 WriteThroughComponent(xCom, "settings.xml", "com.sun.star.comp.report.XMLSettingsExporter",
1351 aDelegatorArguments, aProps, _xStorageToSaveTo);
1352
1353 xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("meta.xml")));
1354 WriteThroughComponent(xCom, "meta.xml", "com.sun.star.comp.report.XMLMetaExporter",
1355 aDelegatorArguments, aProps, _xStorageToSaveTo);
1356
1357 xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("styles.xml")));
1358 WriteThroughComponent(xCom, "styles.xml", "com.sun.star.comp.report.XMLStylesExporter",
1359 aDelegatorArguments, aProps, _xStorageToSaveTo);
1360
1361 xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("content.xml")));
1362 bool bOk = WriteThroughComponent(xCom, "content.xml", "com.sun.star.comp.report.ExportFilter",
1363 aDelegatorArguments, aProps, _xStorageToSaveTo);
1364
1365 uno::Any aImage;
1366 uno::Reference< embed::XVisualObject > xCurrentController(getCurrentController(),uno::UNO_QUERY);
1367 if ( xCurrentController.is() )
1368 {
1369 xCurrentController->setVisualAreaSize(m_pImpl->m_nAspect,m_pImpl->m_aVisualAreaSize);
1370 aImage = xCurrentController->getPreferredVisualRepresentation( m_pImpl->m_nAspect ).Data;
1371 }
1372 if ( aImage.hasValue() )
1373 {
1374 uno::Sequence<sal_Int8> aSeq;
1375 aImage >>= aSeq;
1376 uno::Reference<io::XInputStream> xStream = new ::comphelper::SequenceInputStream( aSeq );
1377 m_pImpl->m_pObjectContainer->InsertGraphicStreamDirectly(xStream, "report", "image/png");
1378 }
1379
1380 if (bOk)
1381 {
1382 bool bPersist = false;
1383 if ( _xStorageToSaveTo == m_pImpl->m_xStorage )
1384 bPersist = m_pImpl->m_pObjectContainer->StoreChildren(true,false);
1385 else
1386 bPersist = m_pImpl->m_pObjectContainer->StoreAsChildren(true,true,_xStorageToSaveTo);
1387
1388 if( bPersist )
1389 m_pImpl->m_pObjectContainer->SetPersistentEntries(m_pImpl->m_xStorage);
1390 try
1391 {
1392 uno::Reference<embed::XTransactedObject> xTransact(_xStorageToSaveTo,uno::UNO_QUERY);
1393 if ( xTransact.is() )
1394 xTransact->commit();
1395 }
1396 catch (const uno::Exception&)
1397 {
1398 TOOLS_WARN_EXCEPTION( "reportdesign", "Could not commit report storage!");
1399 throw io::IOException();
1400 }
1401
1402 if ( _xStorageToSaveTo == m_pImpl->m_xStorage )
1403 setModified(false);
1404 }
1405 if ( xStatusIndicator.is() )
1406 xStatusIndicator->end();
1407 }
1408
switchToStorage(const uno::Reference<embed::XStorage> & xStorage)1409 void SAL_CALL OReportDefinition::switchToStorage(
1410 const uno::Reference< embed::XStorage >& xStorage)
1411 {
1412 if (!xStorage.is())
1413 throw lang::IllegalArgumentException(RptResId(RID_STR_ARGUMENT_IS_NULL),*this,1);
1414 {
1415 ::osl::MutexGuard aGuard(m_aMutex);
1416 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1417 m_pImpl->m_xStorage = xStorage;
1418 lcl_setModelReadOnly(m_pImpl->m_xStorage,m_pImpl->m_pReportModel);
1419 m_pImpl->m_pObjectContainer->SwitchPersistence(m_pImpl->m_xStorage);
1420 }
1421 // notify our container listeners
1422 m_pImpl->m_aStorageChangeListeners.forEach<document::XStorageChangeListener>(
1423 [this, &xStorage] (uno::Reference<document::XStorageChangeListener> const& xListener) {
1424 return xListener->notifyStorageChange(static_cast<OWeakObject*>(this), xStorage);
1425 });
1426 }
1427
getDocumentStorage()1428 uno::Reference< embed::XStorage > SAL_CALL OReportDefinition::getDocumentStorage( )
1429 {
1430 ::osl::MutexGuard aGuard(m_aMutex);
1431 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1432 return m_pImpl->m_xStorage;
1433 }
1434
addStorageChangeListener(const uno::Reference<document::XStorageChangeListener> & xListener)1435 void SAL_CALL OReportDefinition::addStorageChangeListener( const uno::Reference< document::XStorageChangeListener >& xListener )
1436 {
1437 ::osl::MutexGuard aGuard(m_aMutex);
1438 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1439 if ( xListener.is() )
1440 m_pImpl->m_aStorageChangeListeners.addInterface(xListener);
1441 }
1442
removeStorageChangeListener(const uno::Reference<document::XStorageChangeListener> & xListener)1443 void SAL_CALL OReportDefinition::removeStorageChangeListener( const uno::Reference< document::XStorageChangeListener >& xListener )
1444 {
1445 ::osl::MutexGuard aGuard(m_aMutex);
1446 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1447 m_pImpl->m_aStorageChangeListeners.removeInterface(xListener);
1448 }
1449
WriteThroughComponent(const uno::Reference<lang::XComponent> & xComponent,const char * pStreamName,const char * pServiceName,const uno::Sequence<uno::Any> & rArguments,const uno::Sequence<beans::PropertyValue> & rMediaDesc,const uno::Reference<embed::XStorage> & _xStorageToSaveTo)1450 bool OReportDefinition::WriteThroughComponent(
1451 const uno::Reference<lang::XComponent> & xComponent,
1452 const char* pStreamName,
1453 const char* pServiceName,
1454 const uno::Sequence<uno::Any> & rArguments,
1455 const uno::Sequence<beans::PropertyValue> & rMediaDesc,
1456 const uno::Reference<embed::XStorage>& _xStorageToSaveTo)
1457 {
1458 OSL_ENSURE( nullptr != pStreamName, "Need stream name!" );
1459 OSL_ENSURE( nullptr != pServiceName, "Need service name!" );
1460
1461 // open stream
1462 OUString sStreamName = OUString::createFromAscii( pStreamName );
1463 uno::Reference<io::XStream> xStream = _xStorageToSaveTo->openStreamElement( sStreamName,embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
1464 if ( !xStream.is() )
1465 return false;
1466 uno::Reference<io::XOutputStream> xOutputStream = xStream->getOutputStream();
1467 OSL_ENSURE(xOutputStream.is(), "Can't create output stream in package!");
1468 if ( ! xOutputStream.is() )
1469 return false;
1470
1471 uno::Reference<beans::XPropertySet> xStreamProp(xOutputStream,uno::UNO_QUERY);
1472 OSL_ENSURE(xStreamProp.is(),"No valid property set for the output stream!");
1473
1474 uno::Reference<io::XSeekable> xSeek(xStreamProp,uno::UNO_QUERY);
1475 if ( xSeek.is() )
1476 {
1477 xSeek->seek(0);
1478 }
1479
1480 xStreamProp->setPropertyValue( "MediaType", uno::Any(OUString("text/xml")) );
1481
1482 // encrypt all streams
1483 xStreamProp->setPropertyValue( "UseCommonStoragePasswordEncryption",
1484 uno::makeAny( true ) );
1485
1486 // set buffer and create outputstream
1487
1488 // write the stuff
1489 bool bRet = WriteThroughComponent(
1490 xOutputStream, xComponent,
1491 pServiceName, rArguments, rMediaDesc );
1492 // finally, commit stream.
1493 return bRet;
1494 }
1495
WriteThroughComponent(const uno::Reference<io::XOutputStream> & xOutputStream,const uno::Reference<lang::XComponent> & xComponent,const char * pServiceName,const uno::Sequence<uno::Any> & rArguments,const uno::Sequence<beans::PropertyValue> & rMediaDesc)1496 bool OReportDefinition::WriteThroughComponent(
1497 const uno::Reference<io::XOutputStream> & xOutputStream,
1498 const uno::Reference<lang::XComponent> & xComponent,
1499 const char* pServiceName,
1500 const uno::Sequence<uno::Any> & rArguments,
1501 const uno::Sequence<beans::PropertyValue> & rMediaDesc)
1502 {
1503 OSL_ENSURE( xOutputStream.is(), "I really need an output stream!" );
1504 OSL_ENSURE( xComponent.is(), "Need component!" );
1505 OSL_ENSURE( nullptr != pServiceName, "Need component name!" );
1506
1507 // get component
1508 uno::Reference< xml::sax::XWriter > xSaxWriter(
1509 xml::sax::Writer::create(m_aProps->m_xContext) );
1510
1511 // connect XML writer to output stream
1512 xSaxWriter->setOutputStream( xOutputStream );
1513
1514 // prepare arguments (prepend doc handler to given arguments)
1515 uno::Sequence<uno::Any> aArgs( 1 + rArguments.getLength() );
1516 aArgs[0] <<= xSaxWriter;
1517 std::copy(rArguments.begin(), rArguments.end(), std::next(aArgs.begin()));
1518
1519 // get filter component
1520 uno::Reference< document::XExporter > xExporter(
1521 m_aProps->m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
1522 OUString::createFromAscii(pServiceName), aArgs,m_aProps->m_xContext), uno::UNO_QUERY);
1523 OSL_ENSURE( xExporter.is(),
1524 "can't instantiate export filter component" );
1525 if( !xExporter.is() )
1526 return false;
1527
1528 // connect model and filter
1529 xExporter->setSourceDocument( xComponent );
1530
1531 // filter!
1532 uno::Reference<document::XFilter> xFilter( xExporter, uno::UNO_QUERY );
1533 return xFilter->filter( rMediaDesc );
1534 }
1535
1536 // XLoadable
initNew()1537 void SAL_CALL OReportDefinition::initNew( )
1538 {
1539 setPageHeaderOn( true );
1540 setPageFooterOn( true );
1541 }
1542
load(const uno::Sequence<beans::PropertyValue> & _rArguments)1543 void SAL_CALL OReportDefinition::load( const uno::Sequence< beans::PropertyValue >& _rArguments )
1544 {
1545 ::osl::MutexGuard aGuard(m_aMutex);
1546 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1547
1548 // TODO: this code is pretty similar to what happens in ODatabaseModelImpl::getOrCreateRootStorage,
1549 // perhaps we can share code here.
1550
1551 ::comphelper::NamedValueCollection aArguments( _rArguments );
1552
1553 // the source for the to-be-created storage: either a URL, or a stream
1554 uno::Reference< io::XInputStream > xStream;
1555 OUString sURL;
1556
1557 if ( aArguments.has( "Stream" ) )
1558 {
1559 aArguments.get_ensureType( "Stream", xStream );
1560 aArguments.remove( "Stream" );
1561 }
1562 else if ( aArguments.has( "InputStream" ) )
1563 {
1564 aArguments.get_ensureType( "InputStream", xStream );
1565 aArguments.remove( "InputStream" );
1566 }
1567
1568 if ( aArguments.has( "FileName" ) )
1569 {
1570 aArguments.get_ensureType( "FileName", sURL );
1571 aArguments.remove( "FileName" );
1572 }
1573 else if ( aArguments.has( "URL" ) )
1574 {
1575 aArguments.get_ensureType( "URL", sURL );
1576 aArguments.remove( "URL" );
1577 }
1578
1579 uno::Any aStorageSource;
1580 if ( xStream.is() )
1581 aStorageSource <<= xStream;
1582 else if ( !sURL.isEmpty() )
1583 aStorageSource <<= sURL;
1584 else
1585 throw lang::IllegalArgumentException(
1586 "No input source (URL or InputStream) found.",
1587 // TODO: resource
1588 *this,
1589 1
1590 );
1591
1592 uno::Reference< lang::XSingleServiceFactory > xStorageFactory( embed::StorageFactory::create( m_aProps->m_xContext ) );
1593
1594 // open read-write per default, unless told otherwise in the MediaDescriptor
1595 uno::Reference< embed::XStorage > xDocumentStorage;
1596 const sal_Int32 nOpenModes[2] = {
1597 embed::ElementModes::READWRITE,
1598 embed::ElementModes::READ
1599 };
1600 size_t nFirstOpenMode = 0;
1601 if ( aArguments.has( "ReadOnly" ) )
1602 {
1603 bool bReadOnly = false;
1604 aArguments.get_ensureType( "ReadOnly", bReadOnly );
1605 nFirstOpenMode = bReadOnly ? 1 : 0;
1606 }
1607 const size_t nLastOpenMode = SAL_N_ELEMENTS( nOpenModes ) - 1;
1608 for ( size_t i=nFirstOpenMode; i <= nLastOpenMode; ++i )
1609 {
1610 uno::Sequence< uno::Any > aStorageCreationArgs(2);
1611 aStorageCreationArgs[0] = aStorageSource;
1612 aStorageCreationArgs[1] <<= nOpenModes[i];
1613
1614 try
1615 {
1616 xDocumentStorage.set( xStorageFactory->createInstanceWithArguments( aStorageCreationArgs ), uno::UNO_QUERY_THROW );
1617 }
1618 catch (const uno::Exception&)
1619 {
1620 if ( i == nLastOpenMode )
1621 {
1622 css::uno::Any anyEx = cppu::getCaughtException();
1623 throw lang::WrappedTargetException(
1624 "An error occurred while creating the document storage.",
1625 // TODO: resource
1626 *this,
1627 anyEx
1628 );
1629 }
1630 }
1631 }
1632
1633 if ( !xDocumentStorage.is() )
1634 {
1635 throw uno::RuntimeException();
1636 }
1637
1638 if (!aArguments.has("DocumentBaseURL") && !sURL.isEmpty())
1639 {
1640 aArguments.put("DocumentBaseURL", sURL);
1641 }
1642
1643 impl_loadFromStorage_nolck_throw( xDocumentStorage, aArguments.getPropertyValues() );
1644 // TODO: do we need to take ownership of the storage? In opposite to loadFromStorage, we created the storage
1645 // ourself here, and perhaps this means we're also responsible for it ...?
1646 }
1647
1648 // XVisualObject
setVisualAreaSize(::sal_Int64 _nAspect,const awt::Size & _aSize)1649 void SAL_CALL OReportDefinition::setVisualAreaSize( ::sal_Int64 _nAspect, const awt::Size& _aSize )
1650 {
1651 ::osl::MutexGuard aGuard(m_aMutex);
1652 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1653 bool bChanged =
1654 (m_pImpl->m_aVisualAreaSize.Width != _aSize.Width ||
1655 m_pImpl->m_aVisualAreaSize.Height != _aSize.Height);
1656 m_pImpl->m_aVisualAreaSize = _aSize;
1657 if( bChanged )
1658 setModified( true );
1659 m_pImpl->m_nAspect = _nAspect;
1660 }
1661
getVisualAreaSize(::sal_Int64)1662 awt::Size SAL_CALL OReportDefinition::getVisualAreaSize( ::sal_Int64 /*_nAspect*/ )
1663 {
1664 ::osl::MutexGuard aGuard(m_aMutex);
1665 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1666 return m_pImpl->m_aVisualAreaSize;
1667 }
1668
getPreferredVisualRepresentation(::sal_Int64)1669 embed::VisualRepresentation SAL_CALL OReportDefinition::getPreferredVisualRepresentation( ::sal_Int64 /*_nAspect*/ )
1670 {
1671 ::osl::MutexGuard aGuard(m_aMutex);
1672 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1673 embed::VisualRepresentation aResult;
1674 OUString sMimeType;
1675 uno::Reference<io::XInputStream> xStream = m_pImpl->m_pObjectContainer->GetGraphicStream("report", &sMimeType);
1676 if ( xStream.is() )
1677 {
1678 uno::Sequence<sal_Int8> aSeq;
1679 xStream->readBytes(aSeq,xStream->available());
1680 xStream->closeInput();
1681 aResult.Data <<= aSeq;
1682 aResult.Flavor.MimeType = sMimeType;
1683 aResult.Flavor.DataType = cppu::UnoType<decltype(aSeq)>::get();
1684 }
1685
1686 return aResult;
1687 }
1688
getMapUnit(::sal_Int64)1689 ::sal_Int32 SAL_CALL OReportDefinition::getMapUnit( ::sal_Int64 /*nAspect*/ )
1690 {
1691 return embed::EmbedMapUnits::ONE_100TH_MM;
1692 }
1693
1694 // XModifiable
disableSetModified()1695 sal_Bool SAL_CALL OReportDefinition::disableSetModified( )
1696 {
1697 ::osl::MutexGuard aGuard( m_aMutex );
1698 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed );
1699
1700 const bool bWasEnabled = m_pImpl->m_bSetModifiedEnabled;
1701 m_pImpl->m_bSetModifiedEnabled = false;
1702 return bWasEnabled;
1703 }
1704
enableSetModified()1705 sal_Bool SAL_CALL OReportDefinition::enableSetModified( )
1706 {
1707 ::osl::MutexGuard aGuard( m_aMutex );
1708 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed );
1709
1710 const bool bWasEnabled = m_pImpl->m_bSetModifiedEnabled;
1711 m_pImpl->m_bSetModifiedEnabled = true;
1712 return bWasEnabled;
1713 }
1714
isSetModifiedEnabled()1715 sal_Bool SAL_CALL OReportDefinition::isSetModifiedEnabled( )
1716 {
1717 ::osl::MutexGuard aGuard( m_aMutex );
1718 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed );
1719
1720 return m_pImpl->m_bSetModifiedEnabled;
1721 }
1722
1723 // XModifiable
isModified()1724 sal_Bool SAL_CALL OReportDefinition::isModified( )
1725 {
1726 ::osl::MutexGuard aGuard(m_aMutex);
1727 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1728 return m_pImpl->m_bModified;
1729 }
1730
setModified(sal_Bool _bModified)1731 void SAL_CALL OReportDefinition::setModified( sal_Bool _bModified )
1732 {
1733 osl::ClearableMutexGuard aGuard(m_aMutex);
1734 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1735
1736 if ( !m_pImpl->m_bSetModifiedEnabled )
1737 return;
1738
1739 if ( m_pImpl->m_pReportModel->IsReadOnly() && _bModified )
1740 throw beans::PropertyVetoException();
1741 if ( m_pImpl->m_bModified != bool(_bModified) )
1742 {
1743 m_pImpl->m_bModified = _bModified;
1744 if ( m_pImpl->m_pReportModel->IsChanged() != bool(_bModified) )
1745 m_pImpl->m_pReportModel->SetChanged(_bModified);
1746
1747 lang::EventObject aEvent(*this);
1748 aGuard.clear();
1749 m_pImpl->m_aModifyListeners.notifyEach(&util::XModifyListener::modified,aEvent);
1750 notifyEvent("OnModifyChanged");
1751 }
1752 }
1753
1754 // XModifyBroadcaster
addModifyListener(const uno::Reference<util::XModifyListener> & _xListener)1755 void SAL_CALL OReportDefinition::addModifyListener( const uno::Reference< util::XModifyListener >& _xListener )
1756 {
1757 ::osl::MutexGuard aGuard(m_aMutex);
1758 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1759 if ( _xListener.is() )
1760 m_pImpl->m_aModifyListeners.addInterface(_xListener);
1761 }
1762
removeModifyListener(const uno::Reference<util::XModifyListener> & _xListener)1763 void SAL_CALL OReportDefinition::removeModifyListener( const uno::Reference< util::XModifyListener >& _xListener )
1764 {
1765 ::osl::MutexGuard aGuard(m_aMutex);
1766 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1767 m_pImpl->m_aModifyListeners.removeInterface(_xListener);
1768 }
1769
notifyEvent(const OUString & _sEventName)1770 void OReportDefinition::notifyEvent(const OUString& _sEventName)
1771 {
1772 try
1773 {
1774 osl::ClearableMutexGuard aGuard(m_aMutex);
1775 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1776 document::EventObject aEvt(*this, _sEventName);
1777 aGuard.clear();
1778 m_pImpl->m_aLegacyEventListeners.notifyEach(&document::XEventListener::notifyEvent,aEvt);
1779 }
1780 catch (const uno::Exception&)
1781 {
1782 }
1783
1784 notifyDocumentEvent(_sEventName, nullptr, css::uno::Any());
1785 }
1786
1787 // document::XDocumentEventBroadcaster
notifyDocumentEvent(const OUString & rEventName,const uno::Reference<frame::XController2> & rViewController,const uno::Any & rSupplement)1788 void SAL_CALL OReportDefinition::notifyDocumentEvent( const OUString& rEventName, const uno::Reference< frame::XController2 >& rViewController, const uno::Any& rSupplement )
1789 {
1790 try
1791 {
1792 osl::ClearableMutexGuard aGuard(m_aMutex);
1793 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1794 document::DocumentEvent aEvt(*this, rEventName, rViewController, rSupplement);
1795 aGuard.clear();
1796 m_pImpl->m_aDocEventListeners.notifyEach(&document::XDocumentEventListener::documentEventOccured,aEvt);
1797 }
1798 catch (const uno::Exception&)
1799 {
1800 }
1801 }
1802
addDocumentEventListener(const uno::Reference<document::XDocumentEventListener> & rListener)1803 void SAL_CALL OReportDefinition::addDocumentEventListener( const uno::Reference< document::XDocumentEventListener >& rListener )
1804 {
1805 ::osl::MutexGuard aGuard(m_aMutex);
1806 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1807 if ( rListener.is() )
1808 m_pImpl->m_aDocEventListeners.addInterface(rListener);
1809 }
1810
removeDocumentEventListener(const uno::Reference<document::XDocumentEventListener> & rListener)1811 void SAL_CALL OReportDefinition::removeDocumentEventListener( const uno::Reference< document::XDocumentEventListener >& rListener )
1812 {
1813 ::osl::MutexGuard aGuard(m_aMutex);
1814 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1815 m_pImpl->m_aDocEventListeners.removeInterface(rListener);
1816 }
1817
1818 // document::XEventBroadcaster
addEventListener(const uno::Reference<document::XEventListener> & _xListener)1819 void SAL_CALL OReportDefinition::addEventListener(const uno::Reference< document::XEventListener >& _xListener )
1820 {
1821 ::osl::MutexGuard aGuard(m_aMutex);
1822 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1823 if ( _xListener.is() )
1824 m_pImpl->m_aLegacyEventListeners.addInterface(_xListener);
1825 }
1826
removeEventListener(const uno::Reference<document::XEventListener> & _xListener)1827 void SAL_CALL OReportDefinition::removeEventListener( const uno::Reference< document::XEventListener >& _xListener )
1828 {
1829 ::osl::MutexGuard aGuard(m_aMutex);
1830 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1831 m_pImpl->m_aLegacyEventListeners.removeInterface(_xListener);
1832 }
1833
1834 // document::XViewDataSupplier
getViewData()1835 uno::Reference< container::XIndexAccess > SAL_CALL OReportDefinition::getViewData( )
1836 {
1837 ::osl::MutexGuard aGuard(m_aMutex);
1838 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1839 if ( !m_pImpl->m_xViewData.is() )
1840 {
1841 m_pImpl->m_xViewData = document::IndexedPropertyValues::create(m_aProps->m_xContext);
1842 uno::Reference< container::XIndexContainer > xContainer(m_pImpl->m_xViewData,uno::UNO_QUERY);
1843 for (const auto& rxController : m_pImpl->m_aControllers)
1844 {
1845 if ( rxController.is() )
1846 {
1847 try
1848 {
1849 xContainer->insertByIndex(xContainer->getCount(), rxController->getViewData());
1850 }
1851 catch (const uno::Exception&)
1852 {
1853 }
1854 }
1855 }
1856
1857 }
1858 return m_pImpl->m_xViewData;
1859 }
1860
setViewData(const uno::Reference<container::XIndexAccess> & Data)1861 void SAL_CALL OReportDefinition::setViewData( const uno::Reference< container::XIndexAccess >& Data )
1862 {
1863 ::osl::MutexGuard aGuard(m_aMutex);
1864 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1865 m_pImpl->m_xViewData = Data;
1866 }
1867
getFunctions()1868 uno::Reference< report::XFunctions > SAL_CALL OReportDefinition::getFunctions()
1869 {
1870 ::osl::MutexGuard aGuard(m_aMutex);
1871 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1872 return m_pImpl->m_xFunctions;
1873 }
1874
getUIConfigurationManager()1875 uno::Reference< ui::XUIConfigurationManager > SAL_CALL OReportDefinition::getUIConfigurationManager( )
1876 {
1877 return uno::Reference< ui::XUIConfigurationManager >( getUIConfigurationManager2(), uno::UNO_QUERY_THROW );
1878 }
1879
getUIConfigurationManager2()1880 uno::Reference< ui::XUIConfigurationManager2 > OReportDefinition::getUIConfigurationManager2( )
1881 {
1882 ::osl::MutexGuard aGuard(m_aMutex);
1883 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1884
1885 if ( !m_pImpl->m_xUIConfigurationManager.is() )
1886 {
1887 m_pImpl->m_xUIConfigurationManager = ui::UIConfigurationManager::create(m_aProps->m_xContext);
1888
1889 uno::Reference< embed::XStorage > xConfigStorage;
1890 // initialize ui configuration manager with document substorage
1891 m_pImpl->m_xUIConfigurationManager->setStorage( xConfigStorage );
1892 }
1893
1894 return m_pImpl->m_xUIConfigurationManager;
1895 }
1896
getDocumentSubStorage(const OUString & aStorageName,sal_Int32 nMode)1897 uno::Reference< embed::XStorage > SAL_CALL OReportDefinition::getDocumentSubStorage( const OUString& aStorageName, sal_Int32 nMode )
1898 {
1899 ::osl::MutexGuard aGuard(m_aMutex);
1900 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1901 return m_pImpl->m_xStorage->openStorageElement(aStorageName, nMode);
1902 }
1903
getDocumentSubStoragesNames()1904 uno::Sequence< OUString > SAL_CALL OReportDefinition::getDocumentSubStoragesNames( )
1905 {
1906 ::osl::MutexGuard aGuard(m_aMutex);
1907 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1908 uno::Reference<container::XNameAccess> xNameAccess = m_pImpl->m_xStorage;
1909 return xNameAccess.is() ? xNameAccess->getElementNames() : uno::Sequence< OUString >();
1910 }
1911
getMimeType()1912 OUString SAL_CALL OReportDefinition::getMimeType()
1913 {
1914 ::osl::MutexGuard aGuard(m_aMutex);
1915 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1916 return m_pImpl->m_sMimeType;
1917 }
1918
setMimeType(const OUString & _mimetype)1919 void SAL_CALL OReportDefinition::setMimeType( const OUString& _mimetype )
1920 {
1921 ::osl::MutexGuard aGuard(m_aMutex);
1922 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1923 uno::Sequence< OUString > aList = getAvailableMimeTypes();
1924 if ( ::std::find(aList.begin(), aList.end(), _mimetype) == aList.end() )
1925 throwIllegallArgumentException("getAvailableMimeTypes()"
1926 ,*this
1927 ,1);
1928 set(PROPERTY_MIMETYPE,_mimetype,m_pImpl->m_sMimeType);
1929 }
1930
getAvailableMimeTypes()1931 uno::Sequence< OUString > SAL_CALL OReportDefinition::getAvailableMimeTypes( )
1932 {
1933 return { MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII, MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII };
1934 }
1935
1936 // css::XUnoTunnel
getSomething(const uno::Sequence<sal_Int8> & rId)1937 sal_Int64 SAL_CALL OReportDefinition::getSomething( const uno::Sequence< sal_Int8 >& rId )
1938 {
1939 sal_Int64 nRet = 0;
1940 if (isUnoTunnelId<OReportDefinition>(rId) )
1941 nRet = reinterpret_cast<sal_Int64>(this);
1942 else
1943 {
1944 uno::Reference< lang::XUnoTunnel> xUnoTunnel(m_pImpl->m_xNumberFormatsSupplier,uno::UNO_QUERY);
1945 if ( xUnoTunnel.is() )
1946 nRet = xUnoTunnel->getSomething(rId);
1947 }
1948 if ( !nRet )
1949 {
1950 uno::Reference< lang::XUnoTunnel> xTunnel;
1951 ::comphelper::query_aggregation(m_aProps->m_xProxy,xTunnel);
1952 if ( xTunnel.is() )
1953 nRet = xTunnel->getSomething(rId);
1954 }
1955
1956 return nRet;
1957 }
1958
getImplementationId()1959 uno::Sequence< sal_Int8 > SAL_CALL OReportDefinition::getImplementationId( )
1960 {
1961 return css::uno::Sequence<sal_Int8>();
1962 }
1963
getUnoTunnelId()1964 uno::Sequence< sal_Int8 > OReportDefinition::getUnoTunnelId()
1965 {
1966 static ::cppu::OImplementationId implId;
1967
1968 return implId.getImplementationId();
1969 }
1970
getContext()1971 uno::Reference< uno::XComponentContext > OReportDefinition::getContext()
1972 {
1973 ::osl::MutexGuard aGuard(m_aMutex);
1974 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1975 return m_aProps->m_xContext;
1976 }
1977
getSdrModel(const uno::Reference<report::XReportDefinition> & _xReportDefinition)1978 std::shared_ptr<rptui::OReportModel> OReportDefinition::getSdrModel(const uno::Reference< report::XReportDefinition >& _xReportDefinition)
1979 {
1980 std::shared_ptr<rptui::OReportModel> pReportModel;
1981 auto pReportDefinition = comphelper::getUnoTunnelImplementation<OReportDefinition>(_xReportDefinition);
1982 if (pReportDefinition)
1983 pReportModel = pReportDefinition->m_pImpl->m_pReportModel;
1984 return pReportModel;
1985 }
1986
getSdrModelFromUnoModel() const1987 SdrModel& OReportDefinition::getSdrModelFromUnoModel() const
1988 {
1989 OSL_ENSURE(m_pImpl->m_pReportModel, "No SdrModel in ReportDesign, should not happen");
1990 return *m_pImpl->m_pReportModel;
1991 }
1992
createInstanceWithArguments(const OUString & aServiceSpecifier,const uno::Sequence<uno::Any> & _aArgs)1993 uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstanceWithArguments( const OUString& aServiceSpecifier, const uno::Sequence< uno::Any >& _aArgs)
1994 {
1995 ::osl::MutexGuard aGuard(m_aMutex);
1996 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1997
1998 uno::Reference< uno::XInterface > xRet;
1999 if ( aServiceSpecifier.startsWith( "com.sun.star.document.ImportEmbeddedObjectResolver") )
2000 {
2001 uno::Reference< embed::XStorage > xStorage;
2002 for(const uno::Any& rArg : _aArgs)
2003 {
2004 beans::NamedValue aValue;
2005 rArg >>= aValue;
2006 if ( aValue.Name == "Storage" )
2007 aValue.Value >>= xStorage;
2008 }
2009 m_pImpl->m_pObjectContainer->SwitchPersistence(xStorage);
2010 xRet = static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( xStorage,*this, SvXMLEmbeddedObjectHelperMode::Read ).get());
2011 }
2012 return xRet;
2013 }
2014
createInstance(const OUString & aServiceSpecifier)2015 uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstance( const OUString& aServiceSpecifier )
2016 {
2017 ::osl::MutexGuard aGuard(m_aMutex);
2018 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2019 uno::Reference< drawing::XShape > xShape;
2020 if ( aServiceSpecifier.startsWith( "com.sun.star.report." ) )
2021 {
2022 if ( aServiceSpecifier == SERVICE_SHAPE )
2023 xShape.set(SvxUnoDrawMSFactory::createInstance("com.sun.star.drawing.CustomShape"),uno::UNO_QUERY_THROW);
2024 else if ( aServiceSpecifier == SERVICE_FORMATTEDFIELD
2025 || aServiceSpecifier == SERVICE_FIXEDTEXT
2026 || aServiceSpecifier == SERVICE_FIXEDLINE
2027 || aServiceSpecifier == SERVICE_IMAGECONTROL )
2028 xShape.set(SvxUnoDrawMSFactory::createInstance("com.sun.star.drawing.ControlShape"),uno::UNO_QUERY_THROW);
2029 else
2030 xShape.set(SvxUnoDrawMSFactory::createInstance("com.sun.star.drawing.OLE2Shape"),uno::UNO_QUERY_THROW);
2031 }
2032 else if ( aServiceSpecifier.startsWith( "com.sun.star.form.component." ) )
2033 {
2034 xShape.set(m_aProps->m_xContext->getServiceManager()->createInstanceWithContext(aServiceSpecifier,m_aProps->m_xContext),uno::UNO_QUERY);
2035 }
2036 else if ( aServiceSpecifier == "com.sun.star.style.PageStyle" ||
2037 aServiceSpecifier == "com.sun.star.style.FrameStyle" ||
2038 aServiceSpecifier == "com.sun.star.style.GraphicStyle"
2039 )
2040 {
2041 uno::Reference< style::XStyle> xStyle = new OStyle();
2042 xStyle->setName("Default");
2043 return xStyle;
2044 }
2045 else if ( aServiceSpecifier == "com.sun.star.document.Settings" )
2046 {
2047 uno::Reference<beans::XPropertySet> xProp = new OStyle();
2048
2049 return xProp;
2050 }
2051 else if ( aServiceSpecifier == "com.sun.star.drawing.Defaults" )
2052 {
2053 uno::Reference<beans::XPropertySet> xProp = new OStyle();
2054 return xProp;
2055 }
2056 else if ( aServiceSpecifier == "com.sun.star.drawing.GradientTable" )
2057 {
2058 if ( !m_pImpl->m_xGradientTable.is() )
2059 m_pImpl->m_xGradientTable.set(SvxUnoGradientTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
2060 return m_pImpl->m_xGradientTable;
2061 }
2062 else if ( aServiceSpecifier == "com.sun.star.drawing.HatchTable" )
2063 {
2064 if ( !m_pImpl->m_xHatchTable.is() )
2065 m_pImpl->m_xHatchTable.set(SvxUnoHatchTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
2066 return m_pImpl->m_xHatchTable;
2067 }
2068 else if ( aServiceSpecifier == "com.sun.star.drawing.BitmapTable" )
2069 {
2070 if ( !m_pImpl->m_xBitmapTable.is() )
2071 m_pImpl->m_xBitmapTable.set(SvxUnoBitmapTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
2072 return m_pImpl->m_xBitmapTable;
2073 }
2074 else if ( aServiceSpecifier == "com.sun.star.drawing.TransparencyGradientTable" )
2075 {
2076 if ( !m_pImpl->m_xTransparencyGradientTable.is() )
2077 m_pImpl->m_xTransparencyGradientTable.set(SvxUnoTransGradientTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
2078 return m_pImpl->m_xTransparencyGradientTable;
2079 }
2080 else if ( aServiceSpecifier == "com.sun.star.drawing.DashTable" )
2081 {
2082 if ( !m_pImpl->m_xDashTable.is() )
2083 m_pImpl->m_xDashTable.set(SvxUnoDashTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
2084 return m_pImpl->m_xDashTable;
2085 }
2086 else if( aServiceSpecifier == "com.sun.star.drawing.MarkerTable" )
2087 {
2088 if( !m_pImpl->m_xMarkerTable.is() )
2089 m_pImpl->m_xMarkerTable.set(SvxUnoMarkerTable_createInstance( m_pImpl->m_pReportModel.get() ),uno::UNO_QUERY);
2090 return m_pImpl->m_xMarkerTable;
2091 }
2092 else if ( aServiceSpecifier == "com.sun.star.document.ImportEmbeddedObjectResolver" )
2093 return static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( m_pImpl->m_xStorage,*this, SvXMLEmbeddedObjectHelperMode::Read ).get());
2094 else if ( aServiceSpecifier == "com.sun.star.document.ExportEmbeddedObjectResolver" )
2095 return static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( m_pImpl->m_xStorage,*this, SvXMLEmbeddedObjectHelperMode::Write ).get());
2096 else if (aServiceSpecifier == "com.sun.star.document.ImportGraphicStorageHandler")
2097 {
2098 rtl::Reference<SvXMLGraphicHelper> xGraphicHelper = SvXMLGraphicHelper::Create(m_pImpl->m_xStorage,SvXMLGraphicHelperMode::Write);
2099 uno::Reference< uno::XInterface> xRet(static_cast< ::cppu::OWeakObject* >(xGraphicHelper.get()));
2100 return xRet;
2101 }
2102 else if (aServiceSpecifier == "com.sun.star.document.ExportGraphicStorageHandler")
2103 {
2104 rtl::Reference<SvXMLGraphicHelper> xGraphicHelper = SvXMLGraphicHelper::Create(m_pImpl->m_xStorage,SvXMLGraphicHelperMode::Write);
2105 uno::Reference< uno::XInterface> xRet(static_cast< ::cppu::OWeakObject* >(xGraphicHelper.get()));
2106 return xRet;
2107 }
2108 else if ( aServiceSpecifier == "com.sun.star.chart2.data.DataProvider" )
2109 {
2110 uno::Reference<chart2::data::XDatabaseDataProvider> xDataProvider(chart2::data::DatabaseDataProvider::createWithConnection( m_aProps->m_xContext, m_pImpl->m_xActiveConnection ));
2111 xDataProvider->setRowLimit(10);
2112 uno::Reference< container::XChild > xChild(xDataProvider,uno::UNO_QUERY);
2113 if ( xChild.is() )
2114 xChild->setParent(*this);
2115 return uno::Reference< uno::XInterface >(xDataProvider,uno::UNO_QUERY);
2116 }
2117 else if ( aServiceSpecifier == "com.sun.star.xml.NamespaceMap" )
2118 {
2119 if ( !m_pImpl->m_xXMLNamespaceMap.is() )
2120 m_pImpl->m_xXMLNamespaceMap = comphelper::NameContainer_createInstance( cppu::UnoType<OUString>::get() ).get();
2121 return m_pImpl->m_xXMLNamespaceMap;
2122 }
2123 else
2124 xShape.set(SvxUnoDrawMSFactory::createInstance( aServiceSpecifier ),uno::UNO_QUERY_THROW);
2125
2126 return m_pImpl->m_pReportModel->createShape(aServiceSpecifier,xShape);
2127 }
2128
getAvailableServiceNames()2129 uno::Sequence< OUString > SAL_CALL OReportDefinition::getAvailableServiceNames()
2130 {
2131 static const std::u16string_view aSvxComponentServiceNameList[] =
2132 {
2133 u"com.sun.star.form.component.FixedText",
2134 u"com.sun.star.form.component.DatabaseImageControl",
2135 u"com.sun.star.style.PageStyle",
2136 u"com.sun.star.style.GraphicStyle",
2137 u"com.sun.star.style.FrameStyle",
2138 u"com.sun.star.drawing.Defaults",
2139 u"com.sun.star.document.ImportEmbeddedObjectResolver",
2140 u"com.sun.star.document.ExportEmbeddedObjectResolver",
2141 u"com.sun.star.document.ImportGraphicStorageHandler",
2142 u"com.sun.star.document.ExportGraphicStorageHandler",
2143 u"com.sun.star.chart2.data.DataProvider",
2144 u"com.sun.star.xml.NamespaceMap",
2145 u"com.sun.star.document.Settings",
2146 u"com.sun.star.drawing.GradientTable",
2147 u"com.sun.star.drawing.HatchTable",
2148 u"com.sun.star.drawing.BitmapTable",
2149 u"com.sun.star.drawing.TransparencyGradientTable",
2150 u"com.sun.star.drawing.DashTable",
2151 u"com.sun.star.drawing.MarkerTable"
2152 };
2153
2154 static const sal_uInt16 nSvxComponentServiceNameListCount = SAL_N_ELEMENTS(aSvxComponentServiceNameList);
2155
2156 uno::Sequence< OUString > aSeq( nSvxComponentServiceNameListCount );
2157 OUString* pStrings = aSeq.getArray();
2158 for( sal_uInt16 nIdx = 0; nIdx < nSvxComponentServiceNameListCount; nIdx++ )
2159 pStrings[nIdx] = aSvxComponentServiceNameList[nIdx];
2160
2161 uno::Sequence< OUString > aParentSeq( SvxUnoDrawMSFactory::getAvailableServiceNames() );
2162 return comphelper::concatSequences( aParentSeq, aSeq );
2163 }
2164
2165 // XShape
getPosition()2166 awt::Point SAL_CALL OReportDefinition::getPosition( )
2167 {
2168 ::osl::MutexGuard aGuard(m_aMutex);
2169 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2170 if ( m_aProps->m_xShape.is() )
2171 return m_aProps->m_xShape->getPosition();
2172 return awt::Point(m_aProps->m_nPosX,m_aProps->m_nPosY);
2173 }
2174
setPosition(const awt::Point & aPosition)2175 void SAL_CALL OReportDefinition::setPosition( const awt::Point& aPosition )
2176 {
2177 ::osl::MutexGuard aGuard(m_aMutex);
2178 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2179 if ( m_aProps->m_xShape.is() )
2180 m_aProps->m_xShape->setPosition(aPosition);
2181 set(PROPERTY_POSITIONX,aPosition.X,m_aProps->m_nPosX);
2182 set(PROPERTY_POSITIONY,aPosition.Y,m_aProps->m_nPosY);
2183 }
2184
getSize()2185 awt::Size SAL_CALL OReportDefinition::getSize( )
2186 {
2187 ::osl::MutexGuard aGuard(m_aMutex);
2188 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2189 if ( m_aProps->m_xShape.is() )
2190 return m_aProps->m_xShape->getSize();
2191 return awt::Size(m_aProps->m_nWidth,m_aProps->m_nHeight);
2192 }
2193
setSize(const awt::Size & aSize)2194 void SAL_CALL OReportDefinition::setSize( const awt::Size& aSize )
2195 {
2196 ::osl::MutexGuard aGuard(m_aMutex);
2197 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2198 if ( m_aProps->m_xShape.is() )
2199 m_aProps->m_xShape->setSize(aSize);
2200 set(PROPERTY_WIDTH,aSize.Width,m_aProps->m_nWidth);
2201 set(PROPERTY_HEIGHT,aSize.Height,m_aProps->m_nHeight);
2202 }
2203
2204
2205 // XShapeDescriptor
getShapeType()2206 OUString SAL_CALL OReportDefinition::getShapeType( )
2207 {
2208 ::osl::MutexGuard aGuard(m_aMutex);
2209 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2210 if ( m_aProps->m_xShape.is() )
2211 return m_aProps->m_xShape->getShapeType();
2212 return "com.sun.star.drawing.OLE2Shape";
2213 }
2214
2215 typedef ::cppu::WeakImplHelper< container::XNameContainer,
2216 container::XIndexAccess
2217 > TStylesBASE;
2218
2219 namespace {
2220
2221 class OStylesHelper:
2222 public cppu::BaseMutex, public TStylesBASE
2223 {
2224 typedef ::std::map< OUString, uno::Any , ::comphelper::UStringMixLess> TStyleElements;
2225 TStyleElements m_aElements;
2226 ::std::vector<TStyleElements::iterator> m_aElementsPos;
2227 uno::Type m_aType;
2228
2229 protected:
~OStylesHelper()2230 virtual ~OStylesHelper() override {}
2231 public:
2232 explicit OStylesHelper(const uno::Type& rType = cppu::UnoType<container::XElementAccess>::get());
2233 OStylesHelper(const OStylesHelper&) = delete;
2234 OStylesHelper& operator=(const OStylesHelper&) = delete;
2235
2236 // XNameContainer
2237 virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) override;
2238 virtual void SAL_CALL removeByName( const OUString& Name ) override;
2239
2240 // XNameReplace
2241 virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) override;
2242
2243 // container::XElementAccess
2244 virtual uno::Type SAL_CALL getElementType( ) override;
2245 virtual sal_Bool SAL_CALL hasElements( ) override;
2246 // container::XIndexAccess
2247 virtual sal_Int32 SAL_CALL getCount( ) override;
2248 virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
2249
2250 // container::XNameAccess
2251 virtual uno::Any SAL_CALL getByName( const OUString& aName ) override;
2252 virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
2253 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
2254 };
2255
2256 }
2257
OStylesHelper(const uno::Type & rType)2258 OStylesHelper::OStylesHelper(const uno::Type& rType)
2259 : cppu::BaseMutex()
2260 , m_aType(rType)
2261 {
2262 }
2263 ;
2264
2265 // container::XElementAccess
getElementType()2266 uno::Type SAL_CALL OStylesHelper::getElementType( )
2267 {
2268 return m_aType;
2269 }
2270
hasElements()2271 sal_Bool SAL_CALL OStylesHelper::hasElements( )
2272 {
2273 ::osl::MutexGuard aGuard(m_aMutex);
2274 return !m_aElementsPos.empty();
2275 }
2276
2277 // container::XIndexAccess
getCount()2278 sal_Int32 SAL_CALL OStylesHelper::getCount( )
2279 {
2280 ::osl::MutexGuard aGuard(m_aMutex);
2281 return m_aElementsPos.size();
2282 }
2283
getByIndex(sal_Int32 Index)2284 uno::Any SAL_CALL OStylesHelper::getByIndex( sal_Int32 Index )
2285 {
2286 ::osl::MutexGuard aGuard(m_aMutex);
2287 if ( Index < 0 || Index >= static_cast<sal_Int32>(m_aElementsPos.size()) )
2288 throw lang::IndexOutOfBoundsException();
2289 return m_aElementsPos[Index]->second;
2290 }
2291
2292 // container::XNameAccess
getByName(const OUString & aName)2293 uno::Any SAL_CALL OStylesHelper::getByName( const OUString& aName )
2294 {
2295 ::osl::MutexGuard aGuard(m_aMutex);
2296 TStyleElements::const_iterator aFind = m_aElements.find(aName);
2297 if ( aFind == m_aElements.end() )
2298 throw container::NoSuchElementException();
2299 return aFind->second;
2300 }
2301
getElementNames()2302 uno::Sequence< OUString > SAL_CALL OStylesHelper::getElementNames( )
2303 {
2304 ::osl::MutexGuard aGuard(m_aMutex);
2305 uno::Sequence< OUString > aNameList(m_aElementsPos.size());
2306
2307 OUString* pStringArray = aNameList.getArray();
2308 for(const auto& rIter : m_aElementsPos)
2309 {
2310 *pStringArray = rIter->first;
2311 ++pStringArray;
2312 }
2313
2314 return aNameList;
2315 }
2316
hasByName(const OUString & aName)2317 sal_Bool SAL_CALL OStylesHelper::hasByName( const OUString& aName )
2318 {
2319 ::osl::MutexGuard aGuard(m_aMutex);
2320 return m_aElements.find(aName) != m_aElements.end();
2321 }
2322
2323 // XNameContainer
insertByName(const OUString & aName,const uno::Any & aElement)2324 void SAL_CALL OStylesHelper::insertByName( const OUString& aName, const uno::Any& aElement )
2325 {
2326 ::osl::MutexGuard aGuard(m_aMutex);
2327 if ( m_aElements.find(aName) != m_aElements.end() )
2328 throw container::ElementExistException();
2329
2330 if ( !aElement.isExtractableTo(m_aType) )
2331 throw lang::IllegalArgumentException();
2332
2333 m_aElementsPos.push_back(m_aElements.emplace(aName,aElement).first);
2334 }
2335
removeByName(const OUString & aName)2336 void SAL_CALL OStylesHelper::removeByName( const OUString& aName )
2337 {
2338 ::osl::MutexGuard aGuard(m_aMutex);
2339 TStyleElements::const_iterator aFind = m_aElements.find(aName);
2340 if ( aFind != m_aElements.end() )
2341 throw container::NoSuchElementException();
2342 m_aElementsPos.erase(::std::find(m_aElementsPos.begin(),m_aElementsPos.end(),aFind));
2343 m_aElements.erase(aFind);
2344 }
2345
2346 // XNameReplace
replaceByName(const OUString & aName,const uno::Any & aElement)2347 void SAL_CALL OStylesHelper::replaceByName( const OUString& aName, const uno::Any& aElement )
2348 {
2349 ::osl::MutexGuard aGuard(m_aMutex);
2350 TStyleElements::iterator aFind = m_aElements.find(aName);
2351 if ( aFind == m_aElements.end() )
2352 throw container::NoSuchElementException();
2353 if ( !aElement.isExtractableTo(m_aType) )
2354 throw lang::IllegalArgumentException();
2355 aFind->second = aElement;
2356 }
2357
getStyleFamilies()2358 uno::Reference< container::XNameAccess > SAL_CALL OReportDefinition::getStyleFamilies( )
2359 {
2360 ::osl::MutexGuard aGuard(m_aMutex);
2361 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2362 if ( !m_pImpl->m_xStyles.is() )
2363 {
2364 m_pImpl->m_xStyles = new OStylesHelper();
2365 uno::Reference< container::XNameContainer> xStyles(m_pImpl->m_xStyles,uno::UNO_QUERY);
2366
2367 uno::Reference< container::XNameContainer> xPageStyles = new OStylesHelper(cppu::UnoType<style::XStyle>::get());
2368 xStyles->insertByName("PageStyles",uno::makeAny(xPageStyles));
2369 uno::Reference< style::XStyle> xPageStyle(createInstance("com.sun.star.style.PageStyle"),uno::UNO_QUERY);
2370 xPageStyles->insertByName(xPageStyle->getName(),uno::makeAny(xPageStyle));
2371
2372 uno::Reference< container::XNameContainer> xFrameStyles = new OStylesHelper(cppu::UnoType<style::XStyle>::get());
2373 xStyles->insertByName("FrameStyles",uno::makeAny(xFrameStyles));
2374 uno::Reference< style::XStyle> xFrameStyle(createInstance("com.sun.star.style.FrameStyle"),uno::UNO_QUERY);
2375 xFrameStyles->insertByName(xFrameStyle->getName(),uno::makeAny(xFrameStyle));
2376
2377 uno::Reference< container::XNameContainer> xGraphicStyles = new OStylesHelper(cppu::UnoType<style::XStyle>::get());
2378 xStyles->insertByName("graphics",uno::makeAny(xGraphicStyles));
2379 uno::Reference< style::XStyle> xGraphicStyle(createInstance("com.sun.star.style.GraphicStyle"),uno::UNO_QUERY);
2380 xGraphicStyles->insertByName(xGraphicStyle->getName(),uno::makeAny(xGraphicStyle));
2381 }
2382 return m_pImpl->m_xStyles;
2383 }
getIdentifier()2384 OUString SAL_CALL OReportDefinition::getIdentifier( )
2385 {
2386 ::osl::MutexGuard aGuard(m_aMutex);
2387 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2388 return m_pImpl->m_sIdentifier;
2389 }
2390
setIdentifier(const OUString & Identifier)2391 void SAL_CALL OReportDefinition::setIdentifier( const OUString& Identifier )
2392 {
2393 ::osl::MutexGuard aGuard(m_aMutex);
2394 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2395 m_pImpl->m_sIdentifier = Identifier;
2396 }
2397
2398 // XNumberFormatsSupplier
getNumberFormatSettings()2399 uno::Reference< beans::XPropertySet > SAL_CALL OReportDefinition::getNumberFormatSettings( )
2400 {
2401 ::osl::MutexGuard aGuard(m_aMutex);
2402 if ( m_pImpl->m_xNumberFormatsSupplier.is() )
2403 return m_pImpl->m_xNumberFormatsSupplier->getNumberFormatSettings();
2404 return uno::Reference< beans::XPropertySet >();
2405 }
2406
getNumberFormats()2407 uno::Reference< util::XNumberFormats > SAL_CALL OReportDefinition::getNumberFormats( )
2408 {
2409 ::osl::MutexGuard aGuard(m_aMutex);
2410 if ( m_pImpl->m_xNumberFormatsSupplier.is() )
2411 return m_pImpl->m_xNumberFormatsSupplier->getNumberFormats();
2412 return uno::Reference< util::XNumberFormats >();
2413 }
2414
getEmbeddedObjectContainer() const2415 ::comphelper::EmbeddedObjectContainer& OReportDefinition::getEmbeddedObjectContainer() const
2416 {
2417 return *m_pImpl->m_pObjectContainer;
2418 }
2419
getStorage() const2420 uno::Reference< embed::XStorage > OReportDefinition::getStorage() const
2421 {
2422 return m_pImpl->m_xStorage;
2423 }
2424
getInteractionHandler() const2425 uno::Reference< task::XInteractionHandler > OReportDefinition::getInteractionHandler() const
2426 {
2427 uno::Reference< task::XInteractionHandler > xRet(
2428 task::InteractionHandler::createWithParent(m_aProps->m_xContext, nullptr), uno::UNO_QUERY_THROW);
2429 return xRet;
2430 }
2431
getActiveConnection()2432 uno::Reference< sdbc::XConnection > SAL_CALL OReportDefinition::getActiveConnection()
2433 {
2434 ::osl::MutexGuard aGuard(m_aMutex);
2435 return m_pImpl->m_xActiveConnection;
2436 }
2437
setActiveConnection(const uno::Reference<sdbc::XConnection> & _activeconnection)2438 void SAL_CALL OReportDefinition::setActiveConnection( const uno::Reference< sdbc::XConnection >& _activeconnection )
2439 {
2440 if ( !_activeconnection.is() )
2441 throw lang::IllegalArgumentException();
2442 set(PROPERTY_ACTIVECONNECTION,_activeconnection,m_pImpl->m_xActiveConnection);
2443 }
2444
getDataSourceName()2445 OUString SAL_CALL OReportDefinition::getDataSourceName()
2446 {
2447 osl::MutexGuard g(m_aMutex);
2448 return m_pImpl->m_sDataSourceName;
2449 }
2450
setDataSourceName(const OUString & the_value)2451 void SAL_CALL OReportDefinition::setDataSourceName(const OUString& the_value)
2452 {
2453 set(PROPERTY_DATASOURCENAME,the_value,m_pImpl->m_sDataSourceName);
2454 }
2455
isEnableSetModified() const2456 bool OReportDefinition::isEnableSetModified() const
2457 {
2458 return true;
2459 }
2460
getDocumentBaseURL() const2461 OUString OReportDefinition::getDocumentBaseURL() const
2462 {
2463 // TODO: should this be in getURL()? not sure...
2464 uno::Reference<frame::XModel> const xParent(
2465 const_cast<OReportDefinition*>(this)->getParent(), uno::UNO_QUERY);
2466 if (xParent.is())
2467 {
2468 return xParent->getURL();
2469 }
2470
2471 ::osl::MutexGuard aGuard(m_aMutex);
2472 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2473 for (beans::PropertyValue const& it : std::as_const(m_pImpl->m_aArgs))
2474 {
2475 if (it.Name == "DocumentBaseURL")
2476 return it.Value.get<OUString>();
2477 }
2478
2479 return OUString();
2480 }
2481
impl_getTitleHelper_throw()2482 uno::Reference< frame::XTitle > OReportDefinition::impl_getTitleHelper_throw()
2483 {
2484 SolarMutexGuard aSolarGuard;
2485
2486 ::osl::MutexGuard aGuard(m_aMutex);
2487 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2488
2489 if ( ! m_pImpl->m_xTitleHelper.is ())
2490 {
2491 uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(m_aProps->m_xContext);
2492 uno::Reference< frame::XModel > xThis(static_cast< frame::XModel* >(this), uno::UNO_QUERY_THROW);
2493
2494 rtl::Reference<::framework::TitleHelper> pHelper = new ::framework::TitleHelper( m_aProps->m_xContext );
2495 m_pImpl->m_xTitleHelper = pHelper;
2496 pHelper->setOwner (xThis );
2497 pHelper->connectWithUntitledNumbers (uno::Reference<frame::XUntitledNumbers>(xDesktop, uno::UNO_QUERY_THROW));
2498 }
2499
2500 return m_pImpl->m_xTitleHelper;
2501 }
2502
impl_getUntitledHelper_throw()2503 uno::Reference< frame::XUntitledNumbers > OReportDefinition::impl_getUntitledHelper_throw()
2504 {
2505 SolarMutexGuard aSolarGuard;
2506
2507 ::osl::MutexGuard aGuard(m_aMutex);
2508 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2509
2510 if ( ! m_pImpl->m_xNumberedControllers.is ())
2511 {
2512 uno::Reference< frame::XModel > xThis(static_cast< frame::XModel* >(this), uno::UNO_QUERY_THROW);
2513 rtl::Reference<::comphelper::NumberedCollection> pHelper = new ::comphelper::NumberedCollection();
2514 m_pImpl->m_xNumberedControllers = pHelper;
2515
2516 pHelper->setOwner (xThis);
2517 pHelper->setUntitledPrefix (" : ");
2518 }
2519
2520 return m_pImpl->m_xNumberedControllers;
2521 }
2522
2523 // css.frame.XTitle
getTitle()2524 OUString SAL_CALL OReportDefinition::getTitle()
2525 {
2526 // SYNCHRONIZED ->
2527 SolarMutexGuard aSolarGuard;
2528
2529 ::osl::MutexGuard aGuard(m_aMutex);
2530 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2531
2532 return impl_getTitleHelper_throw()->getTitle ();
2533 }
2534
2535 // css.frame.XTitle
setTitle(const OUString & sTitle)2536 void SAL_CALL OReportDefinition::setTitle( const OUString& sTitle )
2537 {
2538 // SYNCHRONIZED ->
2539 SolarMutexGuard aSolarGuard;
2540
2541 ::osl::MutexGuard aGuard(m_aMutex);
2542 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2543
2544 impl_getTitleHelper_throw()->setTitle (sTitle);
2545 }
2546
2547 // css.frame.XTitleChangeBroadcaster
addTitleChangeListener(const uno::Reference<frame::XTitleChangeListener> & xListener)2548 void SAL_CALL OReportDefinition::addTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener )
2549 {
2550 // SYNCHRONIZED ->
2551 SolarMutexGuard aSolarGuard;
2552
2553 ::osl::MutexGuard aGuard(m_aMutex);
2554 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2555
2556 uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY);
2557 if (xBroadcaster.is ())
2558 xBroadcaster->addTitleChangeListener (xListener);
2559 }
2560
2561 // css.frame.XTitleChangeBroadcaster
removeTitleChangeListener(const uno::Reference<frame::XTitleChangeListener> & xListener)2562 void SAL_CALL OReportDefinition::removeTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener )
2563 {
2564 // SYNCHRONIZED ->
2565 SolarMutexGuard aSolarGuard;
2566
2567 ::osl::MutexGuard aGuard(m_aMutex);
2568 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2569
2570 uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY);
2571 if (xBroadcaster.is ())
2572 xBroadcaster->removeTitleChangeListener (xListener);
2573 }
2574
2575 // css.frame.XUntitledNumbers
leaseNumber(const uno::Reference<uno::XInterface> & xComponent)2576 ::sal_Int32 SAL_CALL OReportDefinition::leaseNumber( const uno::Reference< uno::XInterface >& xComponent )
2577 {
2578 // object already disposed?
2579 SolarMutexGuard aSolarGuard;
2580 ::osl::MutexGuard aGuard(m_aMutex);
2581 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2582
2583 return impl_getUntitledHelper_throw()->leaseNumber (xComponent);
2584 }
2585
2586 // css.frame.XUntitledNumbers
releaseNumber(::sal_Int32 nNumber)2587 void SAL_CALL OReportDefinition::releaseNumber( ::sal_Int32 nNumber )
2588 {
2589 // object already disposed?
2590 SolarMutexGuard aSolarGuard;
2591 ::osl::MutexGuard aGuard(m_aMutex);
2592 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2593
2594 impl_getUntitledHelper_throw()->releaseNumber (nNumber);
2595 }
2596
2597 // css.frame.XUntitledNumbers
releaseNumberForComponent(const uno::Reference<uno::XInterface> & xComponent)2598 void SAL_CALL OReportDefinition::releaseNumberForComponent( const uno::Reference< uno::XInterface >& xComponent )
2599 {
2600 // object already disposed?
2601 SolarMutexGuard aSolarGuard;
2602 ::osl::MutexGuard aGuard(m_aMutex);
2603 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2604
2605 impl_getUntitledHelper_throw()->releaseNumberForComponent (xComponent);
2606 }
2607
2608 // css.frame.XUntitledNumbers
getUntitledPrefix()2609 OUString SAL_CALL OReportDefinition::getUntitledPrefix()
2610 {
2611 // object already disposed?
2612 SolarMutexGuard aSolarGuard;
2613 ::osl::MutexGuard aGuard(m_aMutex);
2614 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2615
2616 return impl_getUntitledHelper_throw()->getUntitledPrefix ();
2617 }
2618
getDocumentProperties()2619 uno::Reference< document::XDocumentProperties > SAL_CALL OReportDefinition::getDocumentProperties( )
2620 {
2621 ::osl::MutexGuard aGuard(m_aMutex);
2622 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2623 if ( !m_pImpl->m_xDocumentProperties.is() )
2624 {
2625 m_pImpl->m_xDocumentProperties.set(document::DocumentProperties::create(m_aProps->m_xContext));
2626 }
2627 return m_pImpl->m_xDocumentProperties;
2628 }
2629
getTransferData(const datatransfer::DataFlavor & aFlavor)2630 uno::Any SAL_CALL OReportDefinition::getTransferData( const datatransfer::DataFlavor& aFlavor )
2631 {
2632 uno::Any aResult;
2633 if( !isDataFlavorSupported( aFlavor ) )
2634 {
2635 throw datatransfer::UnsupportedFlavorException(aFlavor.MimeType, static_cast< ::cppu::OWeakObject* >( this ));
2636 }
2637
2638 try
2639 {
2640 aResult = getPreferredVisualRepresentation(0).Data;
2641 }
2642 catch (const uno::Exception &)
2643 {
2644 DBG_UNHANDLED_EXCEPTION("reportdesign");
2645 }
2646
2647
2648 return aResult;
2649 }
2650
getTransferDataFlavors()2651 uno::Sequence< datatransfer::DataFlavor > SAL_CALL OReportDefinition::getTransferDataFlavors( )
2652 {
2653 return { { "image/png", "PNG", cppu::UnoType<uno::Sequence< sal_Int8 >>::get() } };
2654 }
2655
isDataFlavorSupported(const datatransfer::DataFlavor & aFlavor)2656 sal_Bool SAL_CALL OReportDefinition::isDataFlavorSupported( const datatransfer::DataFlavor& aFlavor )
2657 {
2658 return aFlavor.MimeType == "image/png";
2659 }
2660
2661
getUndoManager()2662 uno::Reference< document::XUndoManager > SAL_CALL OReportDefinition::getUndoManager( )
2663 {
2664 ::osl::MutexGuard aGuard( m_aMutex );
2665 return m_pImpl->m_pUndoManager;
2666 }
2667
2668 }// namespace reportdesign
2669
2670 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
2671