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