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