1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "ReportDefinition.hxx"
21 #include "FixedLine.hxx"
22 #include "FixedText.hxx"
23 #include "FormattedField.hxx"
24 #include "Functions.hxx"
26 #include "ImageControl.hxx"
27 #include "ReportComponent.hxx"
28 #include "ReportHelperImpl.hxx"
30 #include "RptModel.hxx"
31 #include "Section.hxx"
34 #include "UndoEnv.hxx"
35 #include "core_resource.hrc"
36 #include "core_resource.hxx"
37 #include "corestrings.hrc"
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/IndexedPropertyValues.hpp>
44 #include <com/sun/star/document/EventObject.hpp>
45 #include <com/sun/star/document/XEventListener.hpp>
46 #include <com/sun/star/document/XExporter.hpp>
47 #include <com/sun/star/document/XFilter.hpp>
48 #include <com/sun/star/document/XImporter.hpp>
49 #include <com/sun/star/embed/Aspects.hpp>
50 #include <com/sun/star/embed/ElementModes.hpp>
51 #include <com/sun/star/embed/EmbedMapUnits.hpp>
52 #include <com/sun/star/embed/EntryInitModes.hpp>
53 #include <com/sun/star/embed/XEmbedPersist.hpp>
54 #include <com/sun/star/embed/XTransactedObject.hpp>
55 #include <com/sun/star/embed/StorageFactory.hpp>
56 #include <com/sun/star/frame/Desktop.hpp>
57 #include <com/sun/star/frame/FrameSearchFlag.hpp>
58 #include <com/sun/star/frame/XComponentLoader.hpp>
59 #include <com/sun/star/io/XActiveDataSource.hpp>
60 #include <com/sun/star/io/XSeekable.hpp>
61 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
62 #include <com/sun/star/report/GroupKeepTogether.hpp>
63 #include <com/sun/star/report/ReportPrintOption.hpp>
64 #include <com/sun/star/report/XFunction.hpp>
65 #include <com/sun/star/sdb/CommandType.hpp>
66 #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
67 #include <com/sun/star/style/GraphicLocation.hpp>
68 #include <com/sun/star/style/NumberingType.hpp>
69 #include <com/sun/star/style/PageStyleLayout.hpp>
70 #include <com/sun/star/style/XStyle.hpp>
71 #include <com/sun/star/table/BorderLine2.hpp>
72 #include <com/sun/star/table/ShadowFormat.hpp>
73 #include <com/sun/star/task/InteractionHandler.hpp>
74 #include <com/sun/star/task/ErrorCodeIOException.hpp>
75 #include <com/sun/star/task/XStatusIndicator.hpp>
76 #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
77 #include <com/sun/star/ui/UIConfigurationManager.hpp>
78 #include <com/sun/star/ui/XUIConfigurationStorage.hpp>
79 #include <com/sun/star/util/NumberFormatsSupplier.hpp>
80 #include <com/sun/star/xml/AttributeData.hpp>
81 #include <com/sun/star/xml/sax/Writer.hpp>
83 #include <comphelper/broadcasthelper.hxx>
84 #include <comphelper/documentconstants.hxx>
85 #include <comphelper/genericpropertyset.hxx>
86 #include <comphelper/mediadescriptor.hxx>
87 #include <comphelper/mimeconfighelper.hxx>
88 #include <comphelper/namecontainer.hxx>
89 #include <comphelper/namedvaluecollection.hxx>
90 #include <comphelper/numberedcollection.hxx>
91 #include <comphelper/proparrhlp.hxx>
92 #include <comphelper/property.hxx>
93 #include <comphelper/propertysetinfo.hxx>
94 #include <comphelper/propertystatecontainer.hxx>
95 #include <comphelper/seqstream.hxx>
96 #include <comphelper/sequence.hxx>
97 #include <comphelper/storagehelper.hxx>
98 #include <comphelper/uno3.hxx>
99 #include <connectivity/CommonTools.hxx>
100 #include <connectivity/dbconversion.hxx>
101 #include <connectivity/dbtools.hxx>
102 #include <cppuhelper/exc_hlp.hxx>
103 #include <cppuhelper/interfacecontainer.h>
104 #include <dbaccess/dbaundomanager.hxx>
105 #include <editeng/paperinf.hxx>
106 #include <framework/titlehelper.hxx>
107 #include <osl/thread.hxx>
108 #include <svl/itempool.hxx>
109 #include <svl/undo.hxx>
110 #include <svx/svdlayer.hxx>
111 #include <svx/unofill.hxx>
112 #include <svx/xmleohlp.hxx>
113 #include <svx/xmlgrhlp.hxx>
114 #include <tools/debug.hxx>
115 #include <tools/diagnose_ex.h>
116 #include <unotools/moduleoptions.hxx>
117 #include <unotools/saveopt.hxx>
118 #include <unotools/streamwrap.hxx>
119 #include <vcl/svapp.hxx>
120 #include <vcl/virdev.hxx>
122 #include <boost/bind.hpp>
123 #include <boost/mem_fn.hpp>
124 #include <boost/utility.hpp>
126 #define MAP_LEN(x) x, sizeof(x) - 1
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_HDRBACKCOL "HeaderBackColor"
144 #define SC_UNO_PAGE_HDRBACKTRAN "HeaderBackTransparent"
145 #define SC_UNO_PAGE_HDRGRFFILT "HeaderBackGraphicFilter"
146 #define SC_UNO_PAGE_HDRGRFLOC "HeaderBackGraphicLocation"
147 #define SC_UNO_PAGE_HDRGRFURL "HeaderBackGraphicURL"
148 #define SC_UNO_PAGE_HDRLEFTBOR "HeaderLeftBorder"
149 #define SC_UNO_PAGE_HDRRIGHTBOR "HeaderRightBorder"
150 #define SC_UNO_PAGE_HDRBOTTBOR "HeaderBottomBorder"
151 #define SC_UNO_PAGE_HDRTOPBOR "HeaderTopBorder"
152 #define SC_UNO_PAGE_HDRLEFTBDIS "HeaderLeftBorderDistance"
153 #define SC_UNO_PAGE_HDRRIGHTBDIS "HeaderRightBorderDistance"
154 #define SC_UNO_PAGE_HDRBOTTBDIS "HeaderBottomBorderDistance"
155 #define SC_UNO_PAGE_HDRTOPBDIS "HeaderTopBorderDistance"
156 #define SC_UNO_PAGE_HDRBRDDIST "HeaderBorderDistance"
157 #define SC_UNO_PAGE_HDRSHADOW "HeaderShadowFormat"
158 #define SC_UNO_PAGE_HDRLEFTMAR "HeaderLeftMargin"
159 #define SC_UNO_PAGE_HDRRIGHTMAR "HeaderRightMargin"
160 #define SC_UNO_PAGE_HDRBODYDIST "HeaderBodyDistance"
161 #define SC_UNO_PAGE_HDRHEIGHT "HeaderHeight"
162 #define SC_UNO_PAGE_HDRON "HeaderIsOn"
163 #define SC_UNO_PAGE_HDRDYNAMIC "HeaderIsDynamicHeight"
164 #define SC_UNO_PAGE_HDRSHARED "HeaderIsShared"
165 #define SC_UNO_PAGE_FTRBACKCOL "FooterBackColor"
166 #define SC_UNO_PAGE_FTRBACKTRAN "FooterBackTransparent"
167 #define SC_UNO_PAGE_FTRGRFFILT "FooterBackGraphicFilter"
168 #define SC_UNO_PAGE_FTRGRFLOC "FooterBackGraphicLocation"
169 #define SC_UNO_PAGE_FTRGRFURL "FooterBackGraphicURL"
170 #define SC_UNO_PAGE_FTRLEFTBOR "FooterLeftBorder"
171 #define SC_UNO_PAGE_FTRRIGHTBOR "FooterRightBorder"
172 #define SC_UNO_PAGE_FTRBOTTBOR "FooterBottomBorder"
173 #define SC_UNO_PAGE_FTRTOPBOR "FooterTopBorder"
174 #define SC_UNO_PAGE_FTRLEFTBDIS "FooterLeftBorderDistance"
175 #define SC_UNO_PAGE_FTRRIGHTBDIS "FooterRightBorderDistance"
176 #define SC_UNO_PAGE_FTRBOTTBDIS "FooterBottomBorderDistance"
177 #define SC_UNO_PAGE_FTRTOPBDIS "FooterTopBorderDistance"
178 #define SC_UNO_PAGE_FTRBRDDIST "FooterBorderDistance"
179 #define SC_UNO_PAGE_FTRSHADOW "FooterShadowFormat"
180 #define SC_UNO_PAGE_FTRLEFTMAR "FooterLeftMargin"
181 #define SC_UNO_PAGE_FTRRIGHTMAR "FooterRightMargin"
182 #define SC_UNO_PAGE_FTRBODYDIST "FooterBodyDistance"
183 #define SC_UNO_PAGE_FTRHEIGHT "FooterHeight"
184 #define SC_UNO_PAGE_FTRON "FooterIsOn"
185 #define SC_UNO_PAGE_FTRDYNAMIC "FooterIsDynamicHeight"
186 #define SC_UNO_PAGE_FTRSHARED "FooterIsShared"
188 // =============================================================================
189 namespace reportdesign
191 // =============================================================================
192 using namespace com::sun::star
;
193 using namespace comphelper
;
194 using namespace rptui
;
195 // -----------------------------------------------------------------------------
197 // -----------------------------------------------------------------------------
198 void lcl_setModelReadOnly(const uno::Reference
< embed::XStorage
>& _xStorage
,::boost::shared_ptr
<rptui::OReportModel
>& _rModel
)
200 uno::Reference
<beans::XPropertySet
> xProp(_xStorage
,uno::UNO_QUERY
);
201 sal_Int32 nOpenMode
= embed::ElementModes::READ
;
203 xProp
->getPropertyValue(OUString("OpenMode")) >>= nOpenMode
;
205 _rModel
->SetReadOnly((nOpenMode
& embed::ElementModes::WRITE
) != embed::ElementModes::WRITE
);
207 void lcl_stripLoadArguments( ::comphelper::MediaDescriptor
& _rDescriptor
, uno::Sequence
< beans::PropertyValue
>& _rArgs
)
209 _rDescriptor
.erase( OUString( "StatusIndicator" ) );
210 _rDescriptor
.erase( OUString( "InteractionHandler" ) );
211 _rDescriptor
.erase( OUString( "Model" ) );
212 _rDescriptor
>> _rArgs
;
214 // -----------------------------------------------------------------------------
215 void lcl_extractAndStartStatusIndicator( const ::comphelper::MediaDescriptor
& _rDescriptor
, uno::Reference
< task::XStatusIndicator
>& _rxStatusIndicator
,
216 uno::Sequence
< uno::Any
>& _rCallArgs
)
220 _rxStatusIndicator
= _rDescriptor
.getUnpackedValueOrDefault( _rDescriptor
.PROP_STATUSINDICATOR(), _rxStatusIndicator
);
221 if ( _rxStatusIndicator
.is() )
223 _rxStatusIndicator
->start( OUString(), (sal_Int32
)1000000 );
225 sal_Int32 nLength
= _rCallArgs
.getLength();
226 _rCallArgs
.realloc( nLength
+ 1 );
227 _rCallArgs
[ nLength
] <<= _rxStatusIndicator
;
230 catch (const uno::Exception
&)
232 OSL_FAIL( "lcl_extractAndStartStatusIndicator: caught an exception!" );
235 // -----------------------------------------------------------------------------
236 typedef ::comphelper::OPropertyStateContainer OStyle_PBASE
;
238 typedef ::comphelper::OPropertyArrayUsageHelper
< OStyle
240 typedef ::cppu::WeakImplHelper2
< style::XStyle
, beans::XMultiPropertyStates
> TStyleBASE
;
242 class OStyle
: public ::comphelper::OMutexAndBroadcastHelper
245 ,public OStyle_PABASE
250 void getPropertyDefaultByHandle( sal_Int32 _nHandle
, uno::Any
& _rDefault
) const;
256 DECLARE_XINTERFACE( )
259 com::sun::star::uno::Reference
<com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo() throw(com::sun::star::uno::RuntimeException
);
260 ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
261 ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const;
264 ::sal_Bool SAL_CALL
isUserDefined( ) throw (uno::RuntimeException
);
265 ::sal_Bool SAL_CALL
isInUse( ) throw (uno::RuntimeException
);
266 OUString SAL_CALL
getParentStyle( ) throw (uno::RuntimeException
);
267 void SAL_CALL
setParentStyle( const OUString
& aParentStyle
) throw (container::NoSuchElementException
, uno::RuntimeException
);
270 OUString SAL_CALL
getName( ) throw (uno::RuntimeException
);
271 void SAL_CALL
setName( const OUString
& aName
) throw (uno::RuntimeException
);
273 // XMultiPropertyState
274 uno::Sequence
< beans::PropertyState
> SAL_CALL
getPropertyStates( const uno::Sequence
< OUString
>& aPropertyNames
) throw (beans::UnknownPropertyException
, uno::RuntimeException
)
276 return OStyle_PBASE::getPropertyStates(aPropertyNames
);
278 void SAL_CALL
setAllPropertiesToDefault( ) throw (uno::RuntimeException
);
279 void SAL_CALL
setPropertiesToDefault( const uno::Sequence
< OUString
>& aPropertyNames
) throw (beans::UnknownPropertyException
, uno::RuntimeException
);
280 uno::Sequence
< uno::Any
> SAL_CALL
getPropertyDefaults( const uno::Sequence
< OUString
>& aPropertyNames
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
);
282 // -----------------------------------------------------------------------------
284 :OStyle_PBASE(m_aBHelper
)
285 ,m_aSize(21000,29700)
287 const ::Size aDefaultSize
= SvxPaperInfo::GetDefaultPaperSize( MAP_100TH_MM
);
288 m_aSize
.Height
= aDefaultSize
.Height();
289 m_aSize
.Width
= aDefaultSize
.Width();
291 const style::GraphicLocation eGraphicLocation
= style::GraphicLocation_NONE
;
292 const sal_Bool bFalse
= sal_False
;
293 const sal_Bool bTrue
= sal_True
;
294 const sal_Int32 nMargin
= 2000;
295 //const sal_Int32 nColor = COL_WHITE;
296 const sal_Int32 nTransparent
= COL_TRANSPARENT
;
297 const sal_Int32 nZero
= 0;
298 const sal_Int16 n16Zero
= 0;
299 const sal_Int16 nNummeringType
= style::NumberingType::ARABIC
;
300 const OUString
sName("Default");
301 const OUString sEmpty
;
302 const table::BorderLine2
eBorderLine(0,0,0,0,0,0);
303 const table::ShadowFormat
eShadowFormat(table::ShadowLocation_NONE
,0,0,0);
304 const style::PageStyleLayout ePageStyleLayout
= style::PageStyleLayout_ALL
;
305 const sal_Int32 nBound
= beans::PropertyAttribute::BOUND
;
306 const sal_Int32 nMayBeVoid
= beans::PropertyAttribute::MAYBEVOID
;
309 registerPropertyNoMember( PROPERTY_NAME
, ++i
,nBound
,::getCppuType( static_cast< OUString
*>(NULL
) ), &sName
);
311 registerPropertyNoMember(PROPERTY_BACKCOLOR
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nTransparent
);
313 registerPropertyNoMember(PROPERTY_BACKGRAPHICLOCATION
, ++i
,nBound
,::getCppuType((const style::GraphicLocation
*)0) ,&eGraphicLocation
);
314 registerPropertyNoMember(PROPERTY_BACKTRANSPARENT
, ++i
,nBound
,::getBooleanCppuType() ,&bTrue
);
315 registerPropertyNoMember(SC_UNO_PAGE_BORDERDIST
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
316 registerPropertyNoMember(SC_UNO_PAGE_BOTTBORDER
, ++i
,nBound
,::getCppuType((const table::BorderLine2
*)0) ,&eBorderLine
);
317 registerPropertyNoMember(SC_UNO_PAGE_BOTTBRDDIST
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
318 registerPropertyNoMember(PROPERTY_BOTTOMMARGIN
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nMargin
);
319 registerPropertyNoMember("DisplayName", ++i
,nBound
,::getCppuType((OUString
*)0) ,&sEmpty
);
320 registerPropertyNoMember(SC_UNO_PAGE_FTRBACKCOL
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nTransparent
);
321 registerPropertyNoMember(SC_UNO_PAGE_FTRGRFFILT
, ++i
,nBound
,::getCppuType((const OUString
*)0) ,&sEmpty
);
322 registerPropertyNoMember(SC_UNO_PAGE_FTRGRFLOC
, ++i
,nBound
,::getCppuType((const style::GraphicLocation
*)0) ,&eGraphicLocation
);
323 registerPropertyNoMember(SC_UNO_PAGE_FTRGRFURL
, ++i
,nBound
,::getCppuType((const OUString
*)0) ,&sEmpty
);
324 registerPropertyNoMember(SC_UNO_PAGE_FTRBACKTRAN
, ++i
,nBound
,::getBooleanCppuType() ,&bTrue
);
325 registerPropertyNoMember(SC_UNO_PAGE_FTRBODYDIST
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
326 registerPropertyNoMember(SC_UNO_PAGE_FTRBRDDIST
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
327 registerPropertyNoMember(SC_UNO_PAGE_FTRBOTTBOR
, ++i
,nBound
,::getCppuType((const table::BorderLine2
*)0) ,&eBorderLine
);
328 registerPropertyNoMember(SC_UNO_PAGE_FTRBOTTBDIS
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
329 registerPropertyNoMember(SC_UNO_PAGE_FTRHEIGHT
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
330 registerPropertyNoMember(SC_UNO_PAGE_FTRDYNAMIC
, ++i
,nBound
,::getBooleanCppuType() ,&bFalse
);
331 registerPropertyNoMember(SC_UNO_PAGE_FTRON
, ++i
,nBound
,::getBooleanCppuType() ,&bFalse
);
332 registerPropertyNoMember(SC_UNO_PAGE_FTRSHARED
, ++i
,nBound
,::getBooleanCppuType() ,&bFalse
);
333 registerPropertyNoMember(SC_UNO_PAGE_FTRLEFTBOR
, ++i
,nBound
,::getCppuType((const table::BorderLine2
*)0) ,&eBorderLine
);
334 registerPropertyNoMember(SC_UNO_PAGE_FTRLEFTBDIS
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
335 registerPropertyNoMember(SC_UNO_PAGE_FTRLEFTMAR
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
336 registerPropertyNoMember(SC_UNO_PAGE_FTRRIGHTBOR
, ++i
,nBound
,::getCppuType((const table::BorderLine2
*)0) ,&eBorderLine
);
337 registerPropertyNoMember(SC_UNO_PAGE_FTRRIGHTBDIS
,++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
338 registerPropertyNoMember(SC_UNO_PAGE_FTRRIGHTMAR
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
339 registerPropertyNoMember(SC_UNO_PAGE_FTRSHADOW
, ++i
,nBound
,::getCppuType((const table::ShadowFormat
*)0) ,&eShadowFormat
);
340 registerPropertyNoMember(SC_UNO_PAGE_FTRTOPBOR
, ++i
,nBound
,::getCppuType((const table::BorderLine2
*)0) ,&eBorderLine
);
341 registerPropertyNoMember(SC_UNO_PAGE_FTRTOPBDIS
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
343 registerPropertyNoMember(SC_UNO_PAGE_HDRBACKCOL
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const sal_Int32
*)0) ,&nTransparent
);
344 registerPropertyNoMember(SC_UNO_PAGE_HDRGRFFILT
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const OUString
*)0) ,&sEmpty
);
345 registerPropertyNoMember(SC_UNO_PAGE_HDRGRFLOC
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const style::GraphicLocation
*)0) ,&eGraphicLocation
);
346 registerPropertyNoMember(SC_UNO_PAGE_HDRGRFURL
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const OUString
*)0) ,&sEmpty
);
347 registerPropertyNoMember(SC_UNO_PAGE_HDRBACKTRAN
, ++i
,nBound
|nMayBeVoid
,::getBooleanCppuType() ,&bTrue
);
348 registerPropertyNoMember(SC_UNO_PAGE_HDRBODYDIST
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
349 registerPropertyNoMember(SC_UNO_PAGE_HDRBRDDIST
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
350 registerPropertyNoMember(SC_UNO_PAGE_HDRBOTTBOR
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const table::BorderLine2
*)0) ,&eBorderLine
);
351 registerPropertyNoMember(SC_UNO_PAGE_HDRBOTTBDIS
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
352 registerPropertyNoMember(SC_UNO_PAGE_HDRHEIGHT
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
353 registerPropertyNoMember(SC_UNO_PAGE_HDRDYNAMIC
, ++i
,nBound
|nMayBeVoid
,::getBooleanCppuType() ,&bFalse
);
354 registerPropertyNoMember(SC_UNO_PAGE_HDRON
, ++i
,nBound
|nMayBeVoid
,::getBooleanCppuType() ,&bFalse
);
355 registerPropertyNoMember(SC_UNO_PAGE_HDRSHARED
, ++i
,nBound
|nMayBeVoid
,::getBooleanCppuType() ,&bFalse
);
356 registerPropertyNoMember(SC_UNO_PAGE_HDRLEFTBOR
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const table::BorderLine2
*)0) ,&eBorderLine
);
357 registerPropertyNoMember(SC_UNO_PAGE_HDRLEFTBDIS
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
358 registerPropertyNoMember(SC_UNO_PAGE_HDRLEFTMAR
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
359 registerPropertyNoMember(SC_UNO_PAGE_HDRRIGHTBOR
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const table::BorderLine2
*)0) ,&eBorderLine
);
360 registerPropertyNoMember(SC_UNO_PAGE_HDRRIGHTBDIS
,++i
,nBound
|nMayBeVoid
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
361 registerPropertyNoMember(SC_UNO_PAGE_HDRRIGHTMAR
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
362 registerPropertyNoMember(SC_UNO_PAGE_HDRSHADOW
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const table::ShadowFormat
*)0) ,&eShadowFormat
);
363 registerPropertyNoMember(SC_UNO_PAGE_HDRTOPBOR
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const table::BorderLine2
*)0) ,&eBorderLine
);
364 registerPropertyNoMember(SC_UNO_PAGE_HDRTOPBDIS
, ++i
,nBound
|nMayBeVoid
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
366 registerProperty(PROPERTY_HEIGHT
, ++i
,nBound
,&m_aSize
.Height
, ::getCppuType((const sal_Int32
*)0) );
367 registerPropertyNoMember(PROPERTY_ISLANDSCAPE
, ++i
,nBound
, ::getBooleanCppuType() ,&bFalse
);
368 registerPropertyNoMember(SC_UNO_PAGE_LEFTBORDER
, ++i
,nBound
, ::getCppuType((const table::BorderLine2
*)0) ,&eBorderLine
);
369 registerPropertyNoMember(SC_UNO_PAGE_LEFTBRDDIST
, ++i
,nBound
, ::getCppuType((const sal_Int32
*)0) ,&nZero
);
370 registerPropertyNoMember(PROPERTY_LEFTMARGIN
, ++i
,beans::PropertyAttribute::BOUND
, ::getCppuType((const sal_Int32
*)0) ,&nMargin
);
371 registerPropertyNoMember(PROPERTY_NUMBERINGTYPE
, ++i
,nBound
,::getCppuType((const sal_Int16
*)0) ,&nNummeringType
);
372 registerPropertyNoMember(SC_UNO_PAGE_SCALEVAL
, ++i
,nBound
,::getCppuType((const sal_Int16
*)0) ,&n16Zero
);
373 registerPropertyNoMember(PROPERTY_PAGESTYLELAYOUT
, ++i
,nBound
,::getCppuType((const style::PageStyleLayout
*)0) ,&ePageStyleLayout
);
374 const OUString
sPaperTray("[From printer settings]");
375 registerPropertyNoMember(SC_UNO_PAGE_PAPERTRAY
, ++i
,nBound
,::getCppuType((const OUString
*)0) ,&sPaperTray
);
376 registerPropertyNoMember(SC_UNO_PAGE_RIGHTBORDER
, ++i
,nBound
,::getCppuType((const table::BorderLine2
*)0) ,&eBorderLine
);
377 registerPropertyNoMember(SC_UNO_PAGE_RIGHTBRDDIST
,++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
378 registerPropertyNoMember(PROPERTY_RIGHTMARGIN
, ++i
,beans::PropertyAttribute::BOUND
,::getCppuType((const sal_Int32
*)0) ,&nMargin
);
379 registerPropertyNoMember(SC_UNO_PAGE_SCALETOPAG
, ++i
,nBound
,::getCppuType((const sal_Int16
*)0) ,&n16Zero
);
380 registerPropertyNoMember(SC_UNO_PAGE_SCALETOX
, ++i
,nBound
,::getCppuType((const sal_Int16
*)0) ,&n16Zero
);
381 registerPropertyNoMember(SC_UNO_PAGE_SCALETOY
, ++i
,nBound
,::getCppuType((const sal_Int16
*)0) ,&n16Zero
);
382 registerPropertyNoMember(SC_UNO_PAGE_SHADOWFORM
, ++i
,nBound
,::getCppuType((const table::ShadowFormat
*)0) ,&eShadowFormat
);
383 registerProperty(PROPERTY_PAPERSIZE
, ++i
,beans::PropertyAttribute::BOUND
,&m_aSize
,::getCppuType((const awt::Size
*)0) );
384 registerPropertyNoMember(SC_UNO_PAGE_TOPBORDER
, ++i
,nBound
,::getCppuType((const table::BorderLine2
*)0) ,&eBorderLine
);
385 registerPropertyNoMember(SC_UNO_PAGE_TOPBRDDIST
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nZero
);
386 registerPropertyNoMember(PROPERTY_TOPMARGIN
, ++i
,nBound
,::getCppuType((const sal_Int32
*)0) ,&nMargin
);
387 uno::Reference
< container::XNameContainer
> xAttribs
= ::comphelper::NameContainer_createInstance(::getCppuType(static_cast< xml::AttributeData
* >(NULL
)));
388 registerPropertyNoMember("UserDefinedAttributes", ++i
,nBound
,::getCppuType((uno::Reference
<container::XNameContainer
>*)0) ,&xAttribs
);
389 registerProperty(PROPERTY_WIDTH
, ++i
,nBound
,&m_aSize
.Width
,::getCppuType((const sal_Int32
*)0) );
390 registerPropertyNoMember("PrinterName", ++i
,nBound
,::getCppuType((const OUString
*)0),&sEmpty
);
391 uno::Sequence
<sal_Int8
> aSe
;
392 registerPropertyNoMember("PrinterSetup", ++i
,nBound
,::getCppuType((const uno::Sequence
<sal_Int8
>*)0),&aSe
);
396 // -----------------------------------------------------------------------------
397 IMPLEMENT_FORWARD_XINTERFACE2(OStyle
,TStyleBASE
,OStyle_PBASE
)
398 // -----------------------------------------------------------------------------
399 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
OStyle::getPropertySetInfo() throw(uno::RuntimeException
)
401 return createPropertySetInfo( getInfoHelper() );
403 // -----------------------------------------------------------------------------
404 void OStyle::getPropertyDefaultByHandle( sal_Int32
/*_nHandle*/, uno::Any
& /*_rDefault*/ ) const
407 //-------------------------------------------------------------------------
408 ::cppu::IPropertyArrayHelper
& OStyle::getInfoHelper()
410 return *const_cast<OStyle
*>(this)->getArrayHelper();
412 //--------------------------------------------------------------------
413 ::cppu::IPropertyArrayHelper
* OStyle::createArrayHelper( ) const
415 uno::Sequence
< beans::Property
> aProps
;
416 describeProperties(aProps
);
417 return new ::cppu::OPropertyArrayHelper(aProps
);
419 // -----------------------------------------------------------------------------
421 ::sal_Bool SAL_CALL
OStyle::isUserDefined( ) throw (uno::RuntimeException
)
425 // -----------------------------------------------------------------------------
426 ::sal_Bool SAL_CALL
OStyle::isInUse( ) throw (uno::RuntimeException
)
430 // -----------------------------------------------------------------------------
431 OUString SAL_CALL
OStyle::getParentStyle( ) throw (uno::RuntimeException
)
435 // -----------------------------------------------------------------------------
436 void SAL_CALL
OStyle::setParentStyle( const OUString
& /*aParentStyle*/ ) throw (container::NoSuchElementException
, uno::RuntimeException
)
439 // -----------------------------------------------------------------------------
441 OUString SAL_CALL
OStyle::getName( ) throw (uno::RuntimeException
)
444 getPropertyValue(PROPERTY_NAME
) >>= sName
;
447 // -----------------------------------------------------------------------------
448 void SAL_CALL
OStyle::setName( const OUString
& aName
) throw (uno::RuntimeException
)
450 setPropertyValue(PROPERTY_NAME
,uno::makeAny(aName
));
452 // -----------------------------------------------------------------------------
453 void SAL_CALL
OStyle::setAllPropertiesToDefault( ) throw (uno::RuntimeException
)
456 // -----------------------------------------------------------------------------
457 void SAL_CALL
OStyle::setPropertiesToDefault( const uno::Sequence
< OUString
>& aPropertyNames
) throw (beans::UnknownPropertyException
, uno::RuntimeException
)
459 const OUString
* pIter
= aPropertyNames
.getConstArray();
460 const OUString
* pEnd
= pIter
+ aPropertyNames
.getLength();
461 for(;pIter
!= pEnd
;++pIter
)
462 setPropertyToDefault(*pIter
);
464 // -----------------------------------------------------------------------------
465 uno::Sequence
< uno::Any
> SAL_CALL
OStyle::getPropertyDefaults( const uno::Sequence
< OUString
>& aPropertyNames
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
467 uno::Sequence
< uno::Any
> aRet(aPropertyNames
.getLength());
468 const OUString
* pIter
= aPropertyNames
.getConstArray();
469 const OUString
* pEnd
= pIter
+ aPropertyNames
.getLength();
470 for(sal_Int32 i
= 0;pIter
!= pEnd
;++pIter
,++i
)
471 aRet
[i
] = getPropertyDefault(*pIter
);
476 class FactoryLoader
: public ::osl::Thread
478 OUString m_sMimeType
;
479 uno::Reference
< uno::XComponentContext
> m_xContext
;
481 FactoryLoader(const OUString
& _sMimeType
,uno::Reference
< uno::XComponentContext
> const & _xContext
)
482 :m_sMimeType(_sMimeType
)
483 ,m_xContext(_xContext
)
487 virtual ~FactoryLoader(){}
489 /// Working method which should be overridden.
490 virtual void SAL_CALL
run();
491 virtual void SAL_CALL
onTerminated();
494 void SAL_CALL
FactoryLoader::run()
498 uno::Reference
<frame::XDesktop2
> xDesktop
= frame::Desktop::create(m_xContext
);
499 uno::Reference
<frame::XComponentLoader
> xFrameLoad(xDesktop
,uno::UNO_QUERY
);
500 OUString
sTarget("_blank");
501 sal_Int32 nFrameSearchFlag
= frame::FrameSearchFlag::TASKS
| frame::FrameSearchFlag::CREATE
;
502 uno::Reference
< frame::XFrame
> xFrame
= xDesktop
->findFrame(sTarget
,nFrameSearchFlag
);
503 xFrameLoad
.set(xFrame
,uno::UNO_QUERY
);
505 if ( xFrameLoad
.is() )
507 uno::Sequence
< beans::PropertyValue
> aArgs( 3);
509 aArgs
[nLen
].Name
= OUString("AsTemplate");
510 aArgs
[nLen
++].Value
<<= sal_False
;
512 aArgs
[nLen
].Name
= OUString("ReadOnly");
513 aArgs
[nLen
++].Value
<<= sal_True
;
515 aArgs
[nLen
].Name
= OUString("Hidden");
516 aArgs
[nLen
++].Value
<<= sal_True
;
518 ::comphelper::MimeConfigurationHelper
aHelper(m_xContext
);
519 SvtModuleOptions aModuleOptions
;
520 uno::Reference
< frame::XModel
> xModel(xFrameLoad
->loadComponentFromURL(
521 aModuleOptions
.GetFactoryEmptyDocumentURL( aModuleOptions
.ClassifyFactoryByServiceName( aHelper
.GetDocServiceNameFromMediaType(m_sMimeType
) )),
522 OUString(), // empty frame name
526 ::comphelper::disposeComponent(xModel
);
529 catch (const uno::Exception
&)
531 DBG_UNHANDLED_EXCEPTION();
534 void SAL_CALL
FactoryLoader::onTerminated()
539 // -----------------------------------------------------------------------------
540 struct OReportDefinitionImpl
542 uno::WeakReference
< uno::XInterface
> m_xParent
;
543 ::cppu::OInterfaceContainerHelper m_aStorageChangeListeners
;
544 ::cppu::OInterfaceContainerHelper m_aCloseListener
;
545 ::cppu::OInterfaceContainerHelper m_aModifyListeners
;
546 ::cppu::OInterfaceContainerHelper m_aDocEventListeners
;
547 ::std::vector
< uno::Reference
< frame::XController
> > m_aControllers
;
548 uno::Sequence
< beans::PropertyValue
> m_aArgs
;
550 uno::Reference
< report::XGroups
> m_xGroups
;
551 uno::Reference
< report::XSection
> m_xReportHeader
;
552 uno::Reference
< report::XSection
> m_xReportFooter
;
553 uno::Reference
< report::XSection
> m_xPageHeader
;
554 uno::Reference
< report::XSection
> m_xPageFooter
;
555 uno::Reference
< report::XSection
> m_xDetail
;
556 uno::Reference
< embed::XStorage
> m_xStorage
;
557 uno::Reference
< frame::XController
> m_xCurrentController
;
558 uno::Reference
< container::XIndexAccess
> m_xViewData
;
559 uno::Reference
< container::XNameAccess
> m_xStyles
;
560 uno::Reference
< container::XNameAccess
> m_xXMLNamespaceMap
;
561 uno::Reference
< container::XNameAccess
> m_xGradientTable
;
562 uno::Reference
< container::XNameAccess
> m_xHatchTable
;
563 uno::Reference
< container::XNameAccess
> m_xBitmapTable
;
564 uno::Reference
< container::XNameAccess
> m_xTransparencyGradientTable
;
565 uno::Reference
< container::XNameAccess
> m_xDashTable
;
566 uno::Reference
< container::XNameAccess
> m_xMarkerTable
;
567 uno::Reference
< report::XFunctions
> m_xFunctions
;
568 uno::Reference
< ui::XUIConfigurationManager2
> m_xUIConfigurationManager
;
569 uno::Reference
< util::XNumberFormatsSupplier
> m_xNumberFormatsSupplier
;
570 uno::Reference
< sdbc::XConnection
> m_xActiveConnection
;
571 uno::Reference
< frame::XTitle
> m_xTitleHelper
;
572 uno::Reference
< frame::XUntitledNumbers
> m_xNumberedControllers
;
573 uno::Reference
< document::XDocumentProperties
> m_xDocumentProperties
;
575 ::boost::shared_ptr
< ::comphelper::EmbeddedObjectContainer
>
577 ::boost::shared_ptr
<rptui::OReportModel
> m_pReportModel
;
578 ::rtl::Reference
< ::dbaui::UndoManager
> m_pUndoManager
;
582 OUString m_sMimeType
;
583 OUString m_sIdentifier
;
584 OUString m_sDataSourceName
;
585 awt::Size m_aVisualAreaSize
;
586 ::sal_Int64 m_nAspect
;
587 ::sal_Int16 m_nGroupKeepTogether
;
588 ::sal_Int16 m_nPageHeaderOption
;
589 ::sal_Int16 m_nPageFooterOption
;
590 ::sal_Int32 m_nCommandType
;
591 sal_Bool m_bControllersLocked
;
592 sal_Bool m_bModified
;
593 sal_Bool m_bEscapeProcessing
;
594 sal_Bool m_bSetModifiedEnabled
;
596 OReportDefinitionImpl(::osl::Mutex
& _aMutex
)
597 :m_aStorageChangeListeners(_aMutex
)
598 ,m_aCloseListener(_aMutex
)
599 ,m_aModifyListeners(_aMutex
)
600 ,m_aDocEventListeners(_aMutex
)
601 ,m_sMimeType(MIMETYPE_OASIS_OPENDOCUMENT_TEXT
)
602 ,m_sIdentifier(SERVICE_REPORTDEFINITION
)
603 // default visual area is 8 x 7 cm
604 ,m_aVisualAreaSize( 8000, 7000 )
605 ,m_nAspect(embed::Aspects::MSOLE_CONTENT
)
606 ,m_nGroupKeepTogether(0)
607 ,m_nPageHeaderOption(0)
608 ,m_nPageFooterOption(0)
609 ,m_nCommandType(sdb::CommandType::TABLE
)
610 ,m_bControllersLocked(sal_False
)
611 ,m_bModified(sal_False
)
612 ,m_bEscapeProcessing(sal_True
)
613 ,m_bSetModifiedEnabled( sal_True
)
616 OReportDefinitionImpl(::osl::Mutex
& _aMutex
,const OReportDefinitionImpl
& _aCopy
)
617 :m_aStorageChangeListeners(_aMutex
)
618 ,m_aCloseListener(_aMutex
)
619 ,m_aModifyListeners(_aMutex
)
620 ,m_aDocEventListeners(_aMutex
)
621 ,m_sMimeType(_aCopy
.m_sMimeType
)
622 ,m_sIdentifier(_aCopy
.m_sIdentifier
)
623 ,m_nGroupKeepTogether(_aCopy
.m_nGroupKeepTogether
)
624 ,m_nPageHeaderOption(_aCopy
.m_nPageHeaderOption
)
625 ,m_nPageFooterOption(_aCopy
.m_nPageFooterOption
)
626 ,m_nCommandType(_aCopy
.m_nCommandType
)
627 ,m_bControllersLocked(_aCopy
.m_bControllersLocked
)
628 ,m_bModified(_aCopy
.m_bModified
)
629 ,m_bEscapeProcessing(_aCopy
.m_bEscapeProcessing
)
631 ~OReportDefinitionImpl();
633 OReportDefinitionImpl::~OReportDefinitionImpl()
637 DBG_NAME( rpt_OReportDefinition
)
638 // -----------------------------------------------------------------------------
639 OReportDefinition::OReportDefinition(uno::Reference
< uno::XComponentContext
> const & _xContext
)
640 : ReportDefinitionBase(m_aMutex
)
641 ,ReportDefinitionPropertySet(_xContext
,static_cast< Implements
>(IMPLEMENTS_PROPERTY_SET
),uno::Sequence
< OUString
>())
642 ,m_aProps(new OReportComponentProperties(_xContext
))
643 ,m_pImpl(new OReportDefinitionImpl(m_aMutex
))
645 DBG_CTOR( rpt_OReportDefinition
,NULL
);
646 m_aProps
->m_sName
= RPT_RESSTRING(RID_STR_REPORT
,m_aProps
->m_xContext
->getServiceManager());
647 osl_atomic_increment(&m_refCount
);
650 m_pImpl
->m_xGroups
= new OGroups(this,m_aProps
->m_xContext
);
651 m_pImpl
->m_xDetail
= OSection::createOSection(this,m_aProps
->m_xContext
);
652 m_pImpl
->m_xDetail
->setName(RPT_RESSTRING(RID_STR_DETAIL
,m_aProps
->m_xContext
->getServiceManager()));
654 osl_atomic_decrement( &m_refCount
);
656 // -----------------------------------------------------------------------------
657 OReportDefinition::OReportDefinition(uno::Reference
< uno::XComponentContext
> const & _xContext
658 ,const uno::Reference
< lang::XMultiServiceFactory
>& _xFactory
659 ,uno::Reference
< drawing::XShape
>& _xShape
)
660 : ReportDefinitionBase(m_aMutex
)
661 ,ReportDefinitionPropertySet(_xContext
,static_cast< Implements
>(IMPLEMENTS_PROPERTY_SET
),uno::Sequence
< OUString
>())
662 ,m_aProps(new OReportComponentProperties(_xContext
))
663 ,m_pImpl(new OReportDefinitionImpl(m_aMutex
))
665 m_aProps
->m_sName
= RPT_RESSTRING(RID_STR_REPORT
,m_aProps
->m_xContext
->getServiceManager());
666 m_aProps
->m_xFactory
= _xFactory
;
667 osl_atomic_increment(&m_refCount
);
669 m_aProps
->setShape(_xShape
,this,m_refCount
);
671 m_pImpl
->m_xGroups
= new OGroups(this,m_aProps
->m_xContext
);
672 m_pImpl
->m_xDetail
= OSection::createOSection(this,m_aProps
->m_xContext
);
673 m_pImpl
->m_xDetail
->setName(RPT_RESSTRING(RID_STR_DETAIL
,m_aProps
->m_xContext
->getServiceManager()));
675 osl_atomic_decrement( &m_refCount
);
677 // -----------------------------------------------------------------------------
678 OReportDefinition::OReportDefinition(const OReportDefinition
& _rCopy
)
680 ,ReportDefinitionBase(m_aMutex
)
681 ,ReportDefinitionPropertySet(_rCopy
.m_aProps
->m_xContext
,static_cast< Implements
>(IMPLEMENTS_PROPERTY_SET
),uno::Sequence
< OUString
>())
682 ,comphelper::IEmbeddedHelper()
683 ,m_aProps(new OReportComponentProperties(*_rCopy
.m_aProps
))
684 ,m_pImpl(new OReportDefinitionImpl(m_aMutex
,*_rCopy
.m_pImpl
))
686 DBG_CTOR( rpt_OReportDefinition
,NULL
);
687 osl_atomic_increment(&m_refCount
);
690 OGroups
* pGroups
= new OGroups(this,m_aProps
->m_xContext
);
691 m_pImpl
->m_xGroups
= pGroups
;
692 pGroups
->copyGroups(_rCopy
.m_pImpl
->m_xGroups
);
693 m_pImpl
->m_xDetail
= OSection::createOSection(this,m_aProps
->m_xContext
);
694 OSection::lcl_copySection(_rCopy
.m_pImpl
->m_xDetail
,m_pImpl
->m_xDetail
);
696 setPageHeaderOn(_rCopy
.m_pImpl
->m_xPageHeader
.is());
697 setPageFooterOn(_rCopy
.m_pImpl
->m_xPageFooter
.is());
698 setReportHeaderOn(_rCopy
.m_pImpl
->m_xReportHeader
.is());
699 setReportFooterOn(_rCopy
.m_pImpl
->m_xReportFooter
.is());
700 OSection::lcl_copySection(_rCopy
.m_pImpl
->m_xPageHeader
,m_pImpl
->m_xPageHeader
);
701 OSection::lcl_copySection(_rCopy
.m_pImpl
->m_xPageFooter
,m_pImpl
->m_xPageFooter
);
702 OSection::lcl_copySection(_rCopy
.m_pImpl
->m_xReportHeader
,m_pImpl
->m_xReportHeader
);
703 OSection::lcl_copySection(_rCopy
.m_pImpl
->m_xReportFooter
,m_pImpl
->m_xReportFooter
);
705 osl_atomic_decrement( &m_refCount
);
707 // -----------------------------------------------------------------------------
708 OReportDefinition::~OReportDefinition()
710 DBG_DTOR( rpt_OReportDefinition
,NULL
);
711 if ( !ReportDefinitionBase::rBHelper
.bInDispose
&& !ReportDefinitionBase::rBHelper
.bDisposed
)
717 // -----------------------------------------------------------------------------
718 IMPLEMENT_FORWARD_REFCOUNT( OReportDefinition
, ReportDefinitionBase
)
719 void OReportDefinition::init()
723 static bool s_bFirstTime
= sal_True
;
726 s_bFirstTime
= false;
727 const uno::Sequence
< OUString
> aMimeTypes
= getAvailableMimeTypes();
728 const OUString
* pIter
= aMimeTypes
.getConstArray();
729 const OUString
* pEnd
= pIter
+ aMimeTypes
.getLength();
730 for ( ; pIter
!= pEnd
; ++pIter
)
732 FactoryLoader
* pCreatorThread
= new FactoryLoader(*pIter
,m_aProps
->m_xContext
);
733 pCreatorThread
->createSuspended();
734 pCreatorThread
->setPriority(osl_Thread_PriorityBelowNormal
);
735 pCreatorThread
->resume();
739 m_pImpl
->m_pReportModel
.reset(new OReportModel(this));
740 m_pImpl
->m_pReportModel
->GetItemPool().FreezeIdRanges();
741 m_pImpl
->m_pReportModel
->SetScaleUnit( MAP_100TH_MM
);
742 SdrLayerAdmin
& rAdmin
= m_pImpl
->m_pReportModel
->GetLayerAdmin();
743 rAdmin
.NewStandardLayer(RPT_LAYER_FRONT
);
744 rAdmin
.NewLayer(OUString("back"), RPT_LAYER_BACK
);
745 rAdmin
.NewLayer(OUString("HiddenLayer"), RPT_LAYER_HIDDEN
);
747 m_pImpl
->m_pUndoManager
= new ::dbaui::UndoManager( *this, m_aMutex
);
748 m_pImpl
->m_pReportModel
->SetSdrUndoManager( &m_pImpl
->m_pUndoManager
->GetSfxUndoManager() );
750 m_pImpl
->m_xFunctions
= new OFunctions(this,m_aProps
->m_xContext
);
751 if ( !m_pImpl
->m_xStorage
.is() )
752 m_pImpl
->m_xStorage
= ::comphelper::OStorageHelper::GetTemporaryStorage();
754 uno::Reference
<beans::XPropertySet
> xStorProps(m_pImpl
->m_xStorage
,uno::UNO_QUERY
);
755 if ( xStorProps
.is())
758 xStorProps
->getPropertyValue( OUString("MediaType")) >>= sMediaType
;
759 if ( sMediaType
.isEmpty() )
760 xStorProps
->setPropertyValue( OUString("MediaType"),uno::makeAny(MIMETYPE_OASIS_OPENDOCUMENT_REPORT
));
762 m_pImpl
->m_pObjectContainer
.reset( new comphelper::EmbeddedObjectContainer(m_pImpl
->m_xStorage
, static_cast<cppu::OWeakObject
*>(this) ) );
764 catch (const uno::Exception
&)
766 DBG_UNHANDLED_EXCEPTION();
769 // -----------------------------------------------------------------------------
770 void SAL_CALL
OReportDefinition::dispose() throw(uno::RuntimeException
)
772 ReportDefinitionPropertySet::dispose();
773 cppu::WeakComponentImplHelperBase::dispose();
775 // -----------------------------------------------------------------------------
776 void SAL_CALL
OReportDefinition::disposing()
778 notifyEvent(OUString("OnUnload"));
780 uno::Reference
< frame::XModel
> xHoldAlive( this );
782 lang::EventObject
aDisposeEvent( static_cast< ::cppu::OWeakObject
* >( this ) );
783 m_pImpl
->m_aModifyListeners
.disposeAndClear( aDisposeEvent
);
784 m_pImpl
->m_aCloseListener
.disposeAndClear( aDisposeEvent
);
785 m_pImpl
->m_aDocEventListeners
.disposeAndClear( aDisposeEvent
);
786 m_pImpl
->m_aStorageChangeListeners
.disposeAndClear( aDisposeEvent
);
789 SolarMutexGuard aSolarGuard
;
790 ::osl::ResettableMutexGuard
aGuard(m_aMutex
);
792 m_pImpl
->m_aControllers
.clear();
794 ::comphelper::disposeComponent(m_pImpl
->m_xGroups
);
795 m_pImpl
->m_xReportHeader
.clear();
796 m_pImpl
->m_xReportFooter
.clear();
797 m_pImpl
->m_xPageHeader
.clear();
798 m_pImpl
->m_xPageFooter
.clear();
799 m_pImpl
->m_xDetail
.clear();
800 ::comphelper::disposeComponent(m_pImpl
->m_xFunctions
);
802 //::comphelper::disposeComponent(m_pImpl->m_xStorage);
803 // don't dispose, this currently is the task of either the ref count going to
804 // 0, or of the embedded object (if we're embedded, which is the only possible
807 m_pImpl
->m_xStorage
.clear();
808 m_pImpl
->m_xViewData
.clear();
809 m_pImpl
->m_xCurrentController
.clear();
810 m_pImpl
->m_xNumberFormatsSupplier
.clear();
811 m_pImpl
->m_xStyles
.clear();
812 m_pImpl
->m_xXMLNamespaceMap
.clear();
813 m_pImpl
->m_xGradientTable
.clear();
814 m_pImpl
->m_xHatchTable
.clear();
815 m_pImpl
->m_xBitmapTable
.clear();
816 m_pImpl
->m_xTransparencyGradientTable
.clear();
817 m_pImpl
->m_xDashTable
.clear();
818 m_pImpl
->m_xMarkerTable
.clear();
819 m_pImpl
->m_xUIConfigurationManager
.clear();
820 m_pImpl
->m_pReportModel
.reset();
821 m_pImpl
->m_pObjectContainer
.reset();
822 m_pImpl
->m_aArgs
.realloc(0);
823 m_pImpl
->m_xTitleHelper
.clear();
824 m_pImpl
->m_xNumberedControllers
.clear();
828 // -----------------------------------------------------------------------------
829 OUString
OReportDefinition::getImplementationName_Static( ) throw(uno::RuntimeException
)
831 return OUString("com.sun.star.comp.report.OReportDefinition");
834 //--------------------------------------------------------------------------
835 OUString SAL_CALL
OReportDefinition::getImplementationName( ) throw(uno::RuntimeException
)
837 return getImplementationName_Static();
839 //--------------------------------------------------------------------------
840 uno::Sequence
< OUString
> OReportDefinition::getSupportedServiceNames_Static( ) throw(uno::RuntimeException
)
842 uno::Sequence
< OUString
> aServices(1);
843 aServices
.getArray()[0] = SERVICE_REPORTDEFINITION
;
847 // --------------------------------------------------------------------------------
848 uno::Sequence
< OUString
> SAL_CALL
OReportDefinition::getSupportedServiceNames( ) throw(uno::RuntimeException
)
850 // first collect the services which are supported by our aggregate
851 uno::Sequence
< OUString
> aSupported
;
852 if ( m_aProps
->m_xServiceInfo
.is() )
853 aSupported
= m_aProps
->m_xServiceInfo
->getSupportedServiceNames();
855 // append our own service, if necessary
856 if ( 0 == ::comphelper::findValue( aSupported
, SERVICE_REPORTDEFINITION
, sal_True
).getLength() )
858 sal_Int32 nLen
= aSupported
.getLength();
859 aSupported
.realloc( nLen
+ 1 );
860 aSupported
[ nLen
] = SERVICE_REPORTDEFINITION
;
867 // --------------------------------------------------------------------------------
868 sal_Bool SAL_CALL
OReportDefinition::supportsService( const OUString
& _rServiceName
) throw(uno::RuntimeException
)
870 return ::comphelper::findValue( getSupportedServiceNames(), _rServiceName
, sal_True
).getLength() != 0;
873 // --------------------------------------------------------------------------------
874 uno::Any SAL_CALL
OReportDefinition::queryInterface( const uno::Type
& _rType
) throw (uno::RuntimeException
)
876 uno::Any aReturn
= ReportDefinitionBase::queryInterface(_rType
);
877 if ( !aReturn
.hasValue() )
878 aReturn
= ReportDefinitionPropertySet::queryInterface(_rType
);
880 return aReturn
.hasValue() ? aReturn
: (m_aProps
->m_xProxy
.is() ? m_aProps
->m_xProxy
->queryAggregation(_rType
) : aReturn
);
882 // --------------------------------------------------------------------------------
883 uno::Sequence
< uno::Type
> SAL_CALL
OReportDefinition::getTypes( ) throw (uno::RuntimeException
)
885 if ( m_aProps
->m_xTypeProvider
.is() )
886 return ::comphelper::concatSequences(
887 ReportDefinitionBase::getTypes(),
888 m_aProps
->m_xTypeProvider
->getTypes()
890 return ReportDefinitionBase::getTypes();
892 //------------------------------------------------------------------------------
893 uno::Reference
< uno::XInterface
> OReportDefinition::create(uno::Reference
< uno::XComponentContext
> const & xContext
)
895 return *(new OReportDefinition(xContext
));
898 // -----------------------------------------------------------------------------
900 OUString SAL_CALL
OReportDefinition::getCaption() throw (uno::RuntimeException
)
902 ::osl::MutexGuard
aGuard(m_aMutex
);
903 return m_pImpl
->m_sCaption
;
905 // -----------------------------------------------------------------------------
906 void SAL_CALL
OReportDefinition::setCaption( const OUString
& _caption
) throw (uno::RuntimeException
)
908 set(PROPERTY_CAPTION
,_caption
,m_pImpl
->m_sCaption
);
910 // -----------------------------------------------------------------------------
911 ::sal_Int16 SAL_CALL
OReportDefinition::getGroupKeepTogether() throw (uno::RuntimeException
)
913 ::osl::MutexGuard
aGuard(m_aMutex
);
914 return m_pImpl
->m_nGroupKeepTogether
;
916 // -----------------------------------------------------------------------------
917 void SAL_CALL
OReportDefinition::setGroupKeepTogether( ::sal_Int16 _groupkeeptogether
) throw (uno::RuntimeException
)
919 if ( _groupkeeptogether
< report::GroupKeepTogether::PER_PAGE
|| _groupkeeptogether
> report::GroupKeepTogether::PER_COLUMN
)
920 throwIllegallArgumentException(OUString("com::sun::star::report::GroupKeepTogether")
923 ,m_aProps
->m_xContext
);
924 set(PROPERTY_GROUPKEEPTOGETHER
,_groupkeeptogether
,m_pImpl
->m_nGroupKeepTogether
);
926 // -----------------------------------------------------------------------------
927 ::sal_Int16 SAL_CALL
OReportDefinition::getPageHeaderOption() throw (uno::RuntimeException
)
929 ::osl::MutexGuard
aGuard(m_aMutex
);
930 return m_pImpl
->m_nPageHeaderOption
;
932 // -----------------------------------------------------------------------------
933 void SAL_CALL
OReportDefinition::setPageHeaderOption( ::sal_Int16 _pageheaderoption
) throw (uno::RuntimeException
)
935 if ( _pageheaderoption
< report::ReportPrintOption::ALL_PAGES
|| _pageheaderoption
> report::ReportPrintOption::NOT_WITH_REPORT_HEADER_FOOTER
)
936 throwIllegallArgumentException(OUString("com::sun::star::report::ReportPrintOption")
939 ,m_aProps
->m_xContext
);
940 set(PROPERTY_PAGEHEADEROPTION
,_pageheaderoption
,m_pImpl
->m_nPageHeaderOption
);
942 // -----------------------------------------------------------------------------
943 ::sal_Int16 SAL_CALL
OReportDefinition::getPageFooterOption() throw (uno::RuntimeException
)
945 ::osl::MutexGuard
aGuard(m_aMutex
);
946 return m_pImpl
->m_nPageFooterOption
;
948 // -----------------------------------------------------------------------------
949 void SAL_CALL
OReportDefinition::setPageFooterOption( ::sal_Int16 _pagefooteroption
) throw (uno::RuntimeException
)
951 if ( _pagefooteroption
< report::ReportPrintOption::ALL_PAGES
|| _pagefooteroption
> report::ReportPrintOption::NOT_WITH_REPORT_HEADER_FOOTER
)
952 throwIllegallArgumentException(OUString("com::sun::star::report::ReportPrintOption")
955 ,m_aProps
->m_xContext
);
956 set(PROPERTY_PAGEFOOTEROPTION
,_pagefooteroption
,m_pImpl
->m_nPageFooterOption
);
958 // -----------------------------------------------------------------------------
959 OUString SAL_CALL
OReportDefinition::getCommand() throw (uno::RuntimeException
)
961 ::osl::MutexGuard
aGuard(m_aMutex
);
962 return m_pImpl
->m_sCommand
;
964 // -----------------------------------------------------------------------------
965 void SAL_CALL
OReportDefinition::setCommand( const OUString
& _command
) throw (uno::RuntimeException
)
967 set(PROPERTY_COMMAND
,_command
,m_pImpl
->m_sCommand
);
969 // -----------------------------------------------------------------------------
970 ::sal_Int32 SAL_CALL
OReportDefinition::getCommandType() throw (uno::RuntimeException
)
972 ::osl::MutexGuard
aGuard(m_aMutex
);
973 return m_pImpl
->m_nCommandType
;
975 // -----------------------------------------------------------------------------
976 void SAL_CALL
OReportDefinition::setCommandType( ::sal_Int32 _commandtype
) throw (uno::RuntimeException
)
978 if ( _commandtype
< sdb::CommandType::TABLE
|| _commandtype
> sdb::CommandType::COMMAND
)
979 throwIllegallArgumentException(OUString("com::sun::star::sdb::CommandType")
982 ,m_aProps
->m_xContext
);
983 set(PROPERTY_COMMANDTYPE
,_commandtype
,m_pImpl
->m_nCommandType
);
985 // -----------------------------------------------------------------------------
986 OUString SAL_CALL
OReportDefinition::getFilter() throw (uno::RuntimeException
)
988 ::osl::MutexGuard
aGuard(m_aMutex
);
989 return m_pImpl
->m_sFilter
;
991 // -----------------------------------------------------------------------------
992 void SAL_CALL
OReportDefinition::setFilter( const OUString
& _filter
) throw (uno::RuntimeException
)
994 set(PROPERTY_FILTER
,_filter
,m_pImpl
->m_sFilter
);
996 // -----------------------------------------------------------------------------
997 ::sal_Bool SAL_CALL
OReportDefinition::getEscapeProcessing() throw (uno::RuntimeException
)
999 ::osl::MutexGuard
aGuard(m_aMutex
);
1000 return m_pImpl
->m_bEscapeProcessing
;
1002 // -----------------------------------------------------------------------------
1003 void SAL_CALL
OReportDefinition::setEscapeProcessing( ::sal_Bool _escapeprocessing
) throw (uno::RuntimeException
)
1005 set(PROPERTY_ESCAPEPROCESSING
,_escapeprocessing
,m_pImpl
->m_bEscapeProcessing
);
1007 // -----------------------------------------------------------------------------
1008 ::sal_Bool SAL_CALL
OReportDefinition::getReportHeaderOn() throw (uno::RuntimeException
)
1010 ::osl::MutexGuard
aGuard(m_aMutex
);
1011 return m_pImpl
->m_xReportHeader
.is();
1013 // -----------------------------------------------------------------------------
1014 void SAL_CALL
OReportDefinition::setReportHeaderOn( ::sal_Bool _reportheaderon
) throw (uno::RuntimeException
)
1016 if ( _reportheaderon
!= m_pImpl
->m_xReportHeader
.is() )
1018 setSection(PROPERTY_REPORTHEADERON
,_reportheaderon
,RPT_RESSTRING(RID_STR_REPORT_HEADER
,m_aProps
->m_xContext
->getServiceManager()),m_pImpl
->m_xReportHeader
);
1021 // -----------------------------------------------------------------------------
1022 ::sal_Bool SAL_CALL
OReportDefinition::getReportFooterOn() throw (uno::RuntimeException
)
1024 ::osl::MutexGuard
aGuard(m_aMutex
);
1025 return m_pImpl
->m_xReportFooter
.is();
1027 // -----------------------------------------------------------------------------
1028 void SAL_CALL
OReportDefinition::setReportFooterOn( ::sal_Bool _reportfooteron
) throw (uno::RuntimeException
)
1030 if ( _reportfooteron
!= m_pImpl
->m_xReportFooter
.is() )
1032 setSection(PROPERTY_REPORTFOOTERON
,_reportfooteron
,RPT_RESSTRING(RID_STR_REPORT_FOOTER
,m_aProps
->m_xContext
->getServiceManager()),m_pImpl
->m_xReportFooter
);
1035 // -----------------------------------------------------------------------------
1036 ::sal_Bool SAL_CALL
OReportDefinition::getPageHeaderOn() throw (uno::RuntimeException
)
1038 ::osl::MutexGuard
aGuard(m_aMutex
);
1039 return m_pImpl
->m_xPageHeader
.is();
1041 // -----------------------------------------------------------------------------
1042 void SAL_CALL
OReportDefinition::setPageHeaderOn( ::sal_Bool _pageheaderon
) throw (uno::RuntimeException
)
1044 if ( _pageheaderon
!= m_pImpl
->m_xPageHeader
.is() )
1046 setSection(PROPERTY_PAGEHEADERON
,_pageheaderon
,RPT_RESSTRING(RID_STR_PAGE_HEADER
,m_aProps
->m_xContext
->getServiceManager()),m_pImpl
->m_xPageHeader
);
1049 // -----------------------------------------------------------------------------
1050 ::sal_Bool SAL_CALL
OReportDefinition::getPageFooterOn() throw (uno::RuntimeException
)
1052 ::osl::MutexGuard
aGuard(m_aMutex
);
1053 return m_pImpl
->m_xPageFooter
.is();
1055 // -----------------------------------------------------------------------------
1056 void SAL_CALL
OReportDefinition::setPageFooterOn( ::sal_Bool _pagefooteron
) throw (uno::RuntimeException
)
1058 if ( _pagefooteron
!= m_pImpl
->m_xPageFooter
.is() )
1060 setSection(PROPERTY_PAGEFOOTERON
,_pagefooteron
,RPT_RESSTRING(RID_STR_PAGE_FOOTER
,m_aProps
->m_xContext
->getServiceManager()),m_pImpl
->m_xPageFooter
);
1063 // -----------------------------------------------------------------------------
1064 uno::Reference
< report::XGroups
> SAL_CALL
OReportDefinition::getGroups() throw (uno::RuntimeException
)
1066 ::osl::MutexGuard
aGuard(m_aMutex
);
1067 return m_pImpl
->m_xGroups
;
1069 // -----------------------------------------------------------------------------
1070 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getReportHeader() throw (container::NoSuchElementException
, uno::RuntimeException
)
1072 ::osl::MutexGuard
aGuard(m_aMutex
);
1073 if ( !m_pImpl
->m_xReportHeader
.is() )
1074 throw container::NoSuchElementException();
1075 return m_pImpl
->m_xReportHeader
;
1077 // -----------------------------------------------------------------------------
1078 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getPageHeader() throw (container::NoSuchElementException
, uno::RuntimeException
)
1080 ::osl::MutexGuard
aGuard(m_aMutex
);
1081 if ( !m_pImpl
->m_xPageHeader
.is() )
1082 throw container::NoSuchElementException();
1083 return m_pImpl
->m_xPageHeader
;
1085 // -----------------------------------------------------------------------------
1086 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getDetail() throw (uno::RuntimeException
)
1088 ::osl::MutexGuard
aGuard(m_aMutex
);
1089 return m_pImpl
->m_xDetail
;
1091 // -----------------------------------------------------------------------------
1092 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getPageFooter() throw (container::NoSuchElementException
, uno::RuntimeException
)
1094 ::osl::MutexGuard
aGuard(m_aMutex
);
1095 if ( !m_pImpl
->m_xPageFooter
.is() )
1096 throw container::NoSuchElementException();
1097 return m_pImpl
->m_xPageFooter
;
1099 // -----------------------------------------------------------------------------
1100 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getReportFooter() throw (container::NoSuchElementException
, uno::RuntimeException
)
1102 ::osl::MutexGuard
aGuard(m_aMutex
);
1103 if ( !m_pImpl
->m_xReportFooter
.is() )
1104 throw container::NoSuchElementException();
1105 return m_pImpl
->m_xReportFooter
;
1107 //------------------------------------------------------------------------------
1108 uno::Reference
< document::XEventBroadcaster
> SAL_CALL
OReportDefinition::getEventBroadcaster( ) throw (lang::DisposedException
, uno::Exception
, uno::RuntimeException
)
1110 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1113 //------------------------------------------------------------------------------
1115 REPORTCOMPONENT_MASTERDETAIL(OReportDefinition
,*m_aProps
)
1116 REPORTCOMPONENT_IMPL(OReportDefinition
,*m_aProps
)
1117 REPORTCOMPONENT_IMPL2(OReportDefinition
,*m_aProps
)
1119 // -----------------------------------------------------------------------------
1120 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
OReportDefinition::getPropertySetInfo( ) throw(uno::RuntimeException
)
1122 return ReportDefinitionPropertySet::getPropertySetInfo();
1124 // -----------------------------------------------------------------------------
1125 void SAL_CALL
OReportDefinition::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
) throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
1127 ReportDefinitionPropertySet::setPropertyValue( aPropertyName
, aValue
);
1129 // -----------------------------------------------------------------------------
1130 uno::Any SAL_CALL
OReportDefinition::getPropertyValue( const OUString
& PropertyName
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1132 return ReportDefinitionPropertySet::getPropertyValue( PropertyName
);
1134 // -----------------------------------------------------------------------------
1135 void SAL_CALL
OReportDefinition::addPropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& xListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1137 ReportDefinitionPropertySet::addPropertyChangeListener( aPropertyName
, xListener
);
1139 // -----------------------------------------------------------------------------
1140 void SAL_CALL
OReportDefinition::removePropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1142 ReportDefinitionPropertySet::removePropertyChangeListener( aPropertyName
, aListener
);
1144 // -----------------------------------------------------------------------------
1145 void SAL_CALL
OReportDefinition::addVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1147 ReportDefinitionPropertySet::addVetoableChangeListener( PropertyName
, aListener
);
1149 // -----------------------------------------------------------------------------
1150 void SAL_CALL
OReportDefinition::removeVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1152 ReportDefinitionPropertySet::removeVetoableChangeListener( PropertyName
, aListener
);
1154 // -----------------------------------------------------------------------------
1156 uno::Reference
< uno::XInterface
> SAL_CALL
OReportDefinition::getParent( ) throw (uno::RuntimeException
)
1158 ::osl::MutexGuard
aGuard(m_aMutex
);
1159 uno::Reference
< container::XChild
> xChild
;
1160 comphelper::query_aggregation(m_aProps
->m_xProxy
,xChild
);
1162 return xChild
->getParent();
1163 return m_pImpl
->m_xParent
;
1165 // -----------------------------------------------------------------------------
1166 void SAL_CALL
OReportDefinition::setParent( const uno::Reference
< uno::XInterface
>& Parent
) throw (lang::NoSupportException
, uno::RuntimeException
)
1168 ::osl::MutexGuard
aGuard(m_aMutex
);
1169 m_aProps
->m_xParent
= uno::Reference
< container::XChild
>(Parent
,uno::UNO_QUERY
);
1170 m_pImpl
->m_xParent
= Parent
;
1171 uno::Reference
< container::XChild
> xChild
;
1172 comphelper::query_aggregation(m_aProps
->m_xProxy
,xChild
);
1174 xChild
->setParent(Parent
);
1176 // -----------------------------------------------------------------------------
1178 uno::Reference
< util::XCloneable
> SAL_CALL
OReportDefinition::createClone( ) throw (uno::RuntimeException
)
1180 OSL_FAIL("Not yet implemented correctly");
1181 uno::Reference
< report::XReportComponent
> xSource
= this;
1182 uno::Reference
< report::XReportDefinition
> xSet(cloneObject(xSource
,m_aProps
->m_xFactory
,SERVICE_REPORTDEFINITION
),uno::UNO_QUERY_THROW
);
1185 // -----------------------------------------------------------------------------
1186 void OReportDefinition::setSection( const OUString
& _sProperty
1187 ,const sal_Bool
& _bOn
1188 ,const OUString
& _sName
1189 ,uno::Reference
< report::XSection
>& _member
)
1193 ::osl::MutexGuard
aGuard(m_aMutex
);
1194 prepareSet(_sProperty
, uno::makeAny(_member
), uno::makeAny(_bOn
), &l
);
1195 lcl_createSectionIfNeeded(_bOn
,this,_member
,_sProperty
== PROPERTY_PAGEHEADERON
|| _sProperty
== PROPERTY_PAGEFOOTERON
);
1197 _member
->setName(_sName
);
1201 // -----------------------------------------------------------------------------
1202 // XCloseBroadcaster
1203 void SAL_CALL
OReportDefinition::addCloseListener( const uno::Reference
< util::XCloseListener
>& _xListener
) throw (uno::RuntimeException
)
1205 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1206 if ( _xListener
.is() )
1207 m_pImpl
->m_aCloseListener
.addInterface(_xListener
);
1209 // -----------------------------------------------------------------------------
1210 void SAL_CALL
OReportDefinition::removeCloseListener( const uno::Reference
< util::XCloseListener
>& _xListener
) throw (uno::RuntimeException
)
1212 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1213 m_pImpl
->m_aCloseListener
.removeInterface(_xListener
);
1215 // -----------------------------------------------------------------------------
1217 void SAL_CALL
OReportDefinition::close( ::sal_Bool _bDeliverOwnership
) throw (util::CloseVetoException
, uno::RuntimeException
)
1219 SolarMutexGuard aSolarGuard
;
1221 ::osl::ResettableMutexGuard
aGuard(m_aMutex
);
1222 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1223 // notify our container listeners
1224 lang::EventObject
aEvt( static_cast< ::cppu::OWeakObject
* >( this ) );
1226 m_pImpl
->m_aCloseListener
.forEach
<util::XCloseListener
>(
1227 ::boost::bind(&util::XCloseListener::queryClosing
,_1
,boost::cref(aEvt
),boost::cref(_bDeliverOwnership
)));
1231 ::std::vector
< uno::Reference
< frame::XController
> > aCopy
= m_pImpl
->m_aControllers
;
1232 ::std::vector
< uno::Reference
< frame::XController
> >::iterator aIter
= aCopy
.begin();
1233 ::std::vector
< uno::Reference
< frame::XController
> >::iterator aEnd
= aCopy
.end();
1234 for (;aIter
!= aEnd
; ++aIter
)
1240 uno::Reference
< util::XCloseable
> xFrame( (*aIter
)->getFrame(), uno::UNO_QUERY
);
1242 xFrame
->close( _bDeliverOwnership
);
1244 catch (const util::CloseVetoException
&) { throw; }
1245 catch (const uno::Exception
&)
1247 OSL_FAIL( "ODatabaseDocument::impl_closeControllerFrames: caught an unexpected exception!" );
1253 m_pImpl
->m_aCloseListener
.notifyEach(&util::XCloseListener::notifyClosing
,aEvt
);
1258 // -----------------------------------------------------------------------------
1260 ::sal_Bool SAL_CALL
OReportDefinition::attachResource( const OUString
& /*_rURL*/, const uno::Sequence
< beans::PropertyValue
>& _aArguments
) throw (uno::RuntimeException
)
1262 // LLA: we had a deadlock problem in our context, so we get the SolarMutex earlier.
1263 SolarMutexGuard aSolarGuard
;
1265 ::osl::MutexGuard
aGuard(m_aMutex
);
1266 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper
.bDisposed
);
1267 ::comphelper::MediaDescriptor
aDescriptor( _aArguments
);
1269 m_pImpl
->m_pUndoManager
->GetSfxUndoManager().EnableUndo( false );
1272 fillArgs(aDescriptor
);
1273 m_pImpl
->m_pReportModel
->SetModified(sal_False
);
1277 m_pImpl
->m_pUndoManager
->GetSfxUndoManager().EnableUndo( true );
1280 m_pImpl
->m_pUndoManager
->GetSfxUndoManager().EnableUndo( true );
1283 // -----------------------------------------------------------------------------
1284 void OReportDefinition::fillArgs(::comphelper::MediaDescriptor
& _aDescriptor
)
1286 uno::Sequence
<beans::PropertyValue
> aComponentData
;
1287 aComponentData
= _aDescriptor
.getUnpackedValueOrDefault(OUString("ComponentData"),aComponentData
);
1288 if ( aComponentData
.getLength() && (!m_pImpl
->m_xActiveConnection
.is() || !m_pImpl
->m_xNumberFormatsSupplier
.is()) )
1290 ::comphelper::SequenceAsHashMap
aComponentDataMap( aComponentData
);
1291 m_pImpl
->m_xActiveConnection
= aComponentDataMap
.getUnpackedValueOrDefault(OUString("ActiveConnection"),m_pImpl
->m_xActiveConnection
);
1292 m_pImpl
->m_xNumberFormatsSupplier
= dbtools::getNumberFormats(m_pImpl
->m_xActiveConnection
);
1294 if ( !m_pImpl
->m_xNumberFormatsSupplier
.is() )
1296 m_pImpl
->m_xNumberFormatsSupplier
.set( util::NumberFormatsSupplier::createWithDefaultLocale( m_aProps
->m_xContext
) );
1298 lcl_stripLoadArguments( _aDescriptor
, m_pImpl
->m_aArgs
);
1300 sCaption
= _aDescriptor
.getUnpackedValueOrDefault(OUString("DocumentTitle"),sCaption
);
1301 setCaption(sCaption
);
1303 // -----------------------------------------------------------------------------
1304 OUString SAL_CALL
OReportDefinition::getURL( ) throw (uno::RuntimeException
)
1308 // -----------------------------------------------------------------------------
1309 uno::Sequence
< beans::PropertyValue
> SAL_CALL
OReportDefinition::getArgs( ) throw (uno::RuntimeException
)
1311 ::osl::MutexGuard
aGuard(m_aMutex
);
1312 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1313 return m_pImpl
->m_aArgs
;
1315 // -----------------------------------------------------------------------------
1316 void SAL_CALL
OReportDefinition::connectController( const uno::Reference
< frame::XController
>& _xController
) throw (uno::RuntimeException
)
1318 ::osl::MutexGuard
aGuard(m_aMutex
);
1319 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1320 m_pImpl
->m_aControllers
.push_back(_xController
);
1322 if ( _xController
.is() && m_pImpl
->m_xViewData
.is() && ( nCount
= m_pImpl
->m_xViewData
->getCount()) != 0)
1324 _xController
->restoreViewData(m_pImpl
->m_xViewData
->getByIndex(nCount
- 1));
1327 // -----------------------------------------------------------------------------
1328 void SAL_CALL
OReportDefinition::disconnectController( const uno::Reference
< frame::XController
>& _xController
) throw (uno::RuntimeException
)
1330 ::osl::MutexGuard
aGuard(m_aMutex
);
1331 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1332 ::std::vector
< uno::Reference
< frame::XController
> >::iterator aFind
= ::std::find(m_pImpl
->m_aControllers
.begin(),m_pImpl
->m_aControllers
.end(),_xController
);
1333 if ( aFind
!= m_pImpl
->m_aControllers
.end() )
1334 m_pImpl
->m_aControllers
.erase(aFind
);
1335 if ( m_pImpl
->m_xCurrentController
== _xController
)
1336 m_pImpl
->m_xCurrentController
.clear();
1338 // -----------------------------------------------------------------------------
1339 void SAL_CALL
OReportDefinition::lockControllers( ) throw (uno::RuntimeException
)
1341 ::osl::MutexGuard
aGuard(m_aMutex
);
1342 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1343 m_pImpl
->m_bControllersLocked
= sal_True
;
1345 // -----------------------------------------------------------------------------
1346 void SAL_CALL
OReportDefinition::unlockControllers( ) throw (uno::RuntimeException
)
1348 ::osl::MutexGuard
aGuard(m_aMutex
);
1349 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1350 m_pImpl
->m_bControllersLocked
= sal_False
;
1352 // -----------------------------------------------------------------------------
1353 ::sal_Bool SAL_CALL
OReportDefinition::hasControllersLocked( ) throw (uno::RuntimeException
)
1355 ::osl::MutexGuard
aGuard(m_aMutex
);
1356 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1357 return m_pImpl
->m_bControllersLocked
;
1359 // -----------------------------------------------------------------------------
1360 uno::Reference
< frame::XController
> SAL_CALL
OReportDefinition::getCurrentController( ) throw (uno::RuntimeException
)
1362 ::osl::MutexGuard
aGuard(m_aMutex
);
1363 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1364 return m_pImpl
->m_xCurrentController
;
1366 // -----------------------------------------------------------------------------
1367 void SAL_CALL
OReportDefinition::setCurrentController( const uno::Reference
< frame::XController
>& _xController
) throw (container::NoSuchElementException
, uno::RuntimeException
)
1369 ::osl::MutexGuard
aGuard(m_aMutex
);
1370 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1371 if ( ::std::find(m_pImpl
->m_aControllers
.begin(),m_pImpl
->m_aControllers
.end(),_xController
) == m_pImpl
->m_aControllers
.end() )
1372 throw container::NoSuchElementException();
1373 m_pImpl
->m_xCurrentController
= _xController
;
1375 // -----------------------------------------------------------------------------
1376 uno::Reference
< uno::XInterface
> SAL_CALL
OReportDefinition::getCurrentSelection( ) throw (uno::RuntimeException
)
1378 return uno::Reference
< uno::XInterface
>();
1380 // -----------------------------------------------------------------------------
1382 void OReportDefinition::impl_loadFromStorage_nolck_throw( const uno::Reference
< embed::XStorage
>& _xStorageToLoadFrom
,
1383 const uno::Sequence
< beans::PropertyValue
>& _aMediaDescriptor
)
1385 m_pImpl
->m_xStorage
= _xStorageToLoadFrom
;
1387 ::comphelper::MediaDescriptor
aDescriptor( _aMediaDescriptor
);
1388 fillArgs(aDescriptor
);
1389 aDescriptor
.createItemIfMissing(OUString("Storage"),uno::makeAny(_xStorageToLoadFrom
));
1391 uno::Sequence
< uno::Any
> aDelegatorArguments(_aMediaDescriptor
.getLength());
1392 uno::Any
* pIter
= aDelegatorArguments
.getArray();
1393 uno::Any
* pEnd
= pIter
+ aDelegatorArguments
.getLength();
1394 for(sal_Int32 i
= 0;pIter
!= pEnd
;++pIter
,++i
)
1396 *pIter
<<= _aMediaDescriptor
[i
];
1398 sal_Int32 nPos
= aDelegatorArguments
.getLength();
1399 aDelegatorArguments
.realloc(nPos
+1);
1400 beans::PropertyValue aPropVal
;
1401 aPropVal
.Name
= OUString("Storage");
1402 aPropVal
.Value
<<= _xStorageToLoadFrom
;
1403 aDelegatorArguments
[nPos
] <<= aPropVal
;
1405 rptui::OXUndoEnvironment
& rEnv
= m_pImpl
->m_pReportModel
->GetUndoEnv();
1406 rptui::OXUndoEnvironment::OUndoEnvLock
aLock(rEnv
);
1408 uno::Reference
< document::XFilter
> xFilter(
1409 m_aProps
->m_xContext
->getServiceManager()->createInstanceWithArgumentsAndContext(OUString("com.sun.star.comp.report.OReportFilter"),aDelegatorArguments
,m_aProps
->m_xContext
),
1410 uno::UNO_QUERY_THROW
);
1412 uno::Reference
< document::XImporter
> xImporter(xFilter
,uno::UNO_QUERY_THROW
);
1413 uno::Reference
<XComponent
> xComponent(static_cast<OWeakObject
*>(this),uno::UNO_QUERY
);
1414 xImporter
->setTargetDocument(xComponent
);
1416 ::comphelper::MediaDescriptor aTemp
;
1417 aTemp
<< aDelegatorArguments
;
1418 xFilter
->filter(aTemp
.getAsConstPropertyValueList());
1420 lcl_setModelReadOnly(m_pImpl
->m_xStorage
,m_pImpl
->m_pReportModel
);
1421 m_pImpl
->m_pObjectContainer
->SwitchPersistence(m_pImpl
->m_xStorage
);
1424 // XStorageBasedDocument
1425 // -----------------------------------------------------------------------------
1426 void SAL_CALL
OReportDefinition::loadFromStorage( const uno::Reference
< embed::XStorage
>& _xStorageToLoadFrom
1427 , const uno::Sequence
< beans::PropertyValue
>& _aMediaDescriptor
) throw (lang::IllegalArgumentException
, frame::DoubleInitializationException
, io::IOException
, uno::Exception
, uno::RuntimeException
)
1429 ::osl::MutexGuard
aGuard(m_aMutex
);
1430 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1432 impl_loadFromStorage_nolck_throw( _xStorageToLoadFrom
, _aMediaDescriptor
);
1435 // -----------------------------------------------------------------------------
1436 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
)
1438 if ( !_xStorageToSaveTo
.is() )
1439 throw lang::IllegalArgumentException(RPT_RESSTRING(RID_STR_ARGUMENT_IS_NULL
,m_aProps
->m_xContext
->getServiceManager()),*this,1);
1441 SolarMutexGuard aSolarGuard
;
1442 ::osl::MutexGuard
aGuard(m_aMutex
);
1443 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1444 // create XStatusIndicator
1445 uno::Reference
<task::XStatusIndicator
> xStatusIndicator
;
1446 uno::Sequence
< uno::Any
> aDelegatorArguments
;
1447 ::comphelper::MediaDescriptor
aDescriptor( _aMediaDescriptor
);
1448 lcl_extractAndStartStatusIndicator( aDescriptor
, xStatusIndicator
, aDelegatorArguments
);
1451 uno::Sequence
< beans::PropertyValue
> aProps
;
1453 // export sub streams for package, else full stream into a file
1454 sal_Bool bWarn
= sal_False
, bErr
= sal_False
;
1455 OUString sWarnFile
, sErrFile
;
1457 uno::Reference
< beans::XPropertySet
> xProp(_xStorageToSaveTo
,uno::UNO_QUERY
);
1460 static const OUString
sPropName("MediaType");
1461 OUString sOldMediaType
;
1462 xProp
->getPropertyValue(sPropName
) >>= sOldMediaType
;
1463 if ( !xProp
->getPropertyValue(sPropName
).hasValue() || sOldMediaType
.isEmpty() || MIMETYPE_OASIS_OPENDOCUMENT_REPORT
!= sOldMediaType
)
1464 xProp
->setPropertyValue( sPropName
, uno::makeAny(MIMETYPE_OASIS_OPENDOCUMENT_REPORT
) );
1467 /** property map for export info set */
1468 comphelper::PropertyMapEntry aExportInfoMap
[] =
1470 { MAP_LEN( "UsePrettyPrinting" ), 0, &::getCppuType((sal_Bool
*)0), beans::PropertyAttribute::MAYBEVOID
, 0 },
1471 { MAP_LEN( "StreamName") , 0,&::getCppuType( (OUString
*)0 ), beans::PropertyAttribute::MAYBEVOID
, 0 },
1472 { MAP_LEN( "StreamRelPath") , 0,&::getCppuType( (OUString
*)0 ), beans::PropertyAttribute::MAYBEVOID
, 0 },
1473 { MAP_LEN( "BaseURI") , 0,&::getCppuType( (OUString
*)0 ), beans::PropertyAttribute::MAYBEVOID
, 0 },
1474 { NULL
, 0, 0, NULL
, 0, 0 }
1476 uno::Reference
< beans::XPropertySet
> xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap
) ) );
1478 SvtSaveOptions aSaveOpt
;
1479 xInfoSet
->setPropertyValue(OUString("UsePrettyPrinting"), uno::makeAny(aSaveOpt
.IsPrettyPrinting()));
1480 if ( aSaveOpt
.IsSaveRelFSys() )
1482 const OUString
sVal( aDescriptor
.getUnpackedValueOrDefault(aDescriptor
.PROP_DOCUMENTBASEURL(),OUString()) );
1483 xInfoSet
->setPropertyValue(OUString("BaseURI"), uno::makeAny(sVal
));
1485 const OUString
sHierarchicalDocumentName( aDescriptor
.getUnpackedValueOrDefault(OUString("HierarchicalDocumentName"),OUString()) );
1486 xInfoSet
->setPropertyValue(OUString("StreamRelPath"), uno::makeAny(sHierarchicalDocumentName
));
1489 sal_Int32 nArgsLen
= aDelegatorArguments
.getLength();
1490 aDelegatorArguments
.realloc(nArgsLen
+1);
1491 aDelegatorArguments
[nArgsLen
++] <<= xInfoSet
;
1493 uno::Reference
< document::XEmbeddedObjectResolver
> xObjectResolver
;
1494 uno::Reference
< document::XGraphicObjectResolver
> xGrfResolver
;
1495 SvXMLGraphicHelper
* pGraphicHelper
= SvXMLGraphicHelper::Create(_xStorageToSaveTo
,GRAPHICHELPER_MODE_WRITE
);
1496 xGrfResolver
= pGraphicHelper
;
1497 pGraphicHelper
->release();
1498 SvXMLEmbeddedObjectHelper
* pEmbeddedObjectHelper
= SvXMLEmbeddedObjectHelper::Create( _xStorageToSaveTo
,*this, EMBEDDEDOBJECTHELPER_MODE_WRITE
);
1499 xObjectResolver
= pEmbeddedObjectHelper
;
1500 pEmbeddedObjectHelper
->release();
1502 aDelegatorArguments
.realloc(nArgsLen
+2);
1503 aDelegatorArguments
[nArgsLen
++] <<= xGrfResolver
;
1504 aDelegatorArguments
[nArgsLen
++] <<= xObjectResolver
;
1506 uno::Reference
<XComponent
> xCom(static_cast<OWeakObject
*>(this),uno::UNO_QUERY
);
1509 xInfoSet
->setPropertyValue(OUString("StreamName"), uno::makeAny(OUString("settings.xml")));
1510 if( !WriteThroughComponent(
1511 xCom
, "settings.xml",
1512 "com.sun.star.comp.report.XMLSettingsExporter",
1513 aDelegatorArguments
, aProps
, _xStorageToSaveTo
) )
1518 sWarnFile
= OUString("settings.xml");
1525 xInfoSet
->setPropertyValue(OUString("StreamName"), uno::makeAny(OUString("meta.xml")));
1526 if( !WriteThroughComponent(
1528 "com.sun.star.comp.report.XMLMetaExporter",
1529 aDelegatorArguments
, aProps
, _xStorageToSaveTo
) )
1534 sWarnFile
= OUString("meta.xml");
1541 xInfoSet
->setPropertyValue(OUString("StreamName"), uno::makeAny(OUString("styles.xml")));
1542 if( !WriteThroughComponent(
1544 "com.sun.star.comp.report.XMLStylesExporter",
1545 aDelegatorArguments
, aProps
, _xStorageToSaveTo
) )
1550 sWarnFile
= OUString("styles.xml");
1557 xInfoSet
->setPropertyValue(OUString("StreamName"), uno::makeAny(OUString("content.xml")));
1558 if( !WriteThroughComponent(
1559 xCom
, "content.xml",
1560 "com.sun.star.comp.report.ExportFilter",
1561 aDelegatorArguments
, aProps
, _xStorageToSaveTo
) )
1564 sErrFile
= OUString("content.xml");
1569 uno::Reference
< embed::XVisualObject
> xCurrentController(getCurrentController(),uno::UNO_QUERY
);
1570 if ( xCurrentController
.is() )
1572 xCurrentController
->setVisualAreaSize(m_pImpl
->m_nAspect
,m_pImpl
->m_aVisualAreaSize
);
1573 aImage
= xCurrentController
->getPreferredVisualRepresentation( m_pImpl
->m_nAspect
).Data
;
1575 if ( aImage
.hasValue() )
1577 OUString
sObject1("report");
1578 OUString
sPng("image/png");
1580 uno::Sequence
<sal_Int8
> aSeq
;
1582 uno::Reference
<io::XInputStream
> xStream
= new ::comphelper::SequenceInputStream( aSeq
);
1583 m_pImpl
->m_pObjectContainer
->InsertGraphicStreamDirectly(xStream
,sObject1
,sPng
);
1588 sal_Bool bPersist
= sal_False
;
1589 if ( _xStorageToSaveTo
== m_pImpl
->m_xStorage
)
1590 bPersist
= m_pImpl
->m_pObjectContainer
->StoreChildren(sal_True
,sal_False
);
1592 bPersist
= m_pImpl
->m_pObjectContainer
->StoreAsChildren(sal_True
,sal_True
,_xStorageToSaveTo
);
1595 m_pImpl
->m_pObjectContainer
->SetPersistentEntries(m_pImpl
->m_xStorage
);
1598 uno::Reference
<embed::XTransactedObject
> xTransact(_xStorageToSaveTo
,uno::UNO_QUERY
);
1599 if ( xTransact
.is() )
1600 xTransact
->commit();
1602 catch (const uno::Exception
&)
1604 OSL_FAIL("Exception Caught: Could not commit report storage!");
1605 throw io::IOException();
1608 if ( _xStorageToSaveTo
== m_pImpl
->m_xStorage
)
1609 setModified(sal_False
);
1611 if ( xStatusIndicator
.is() )
1612 xStatusIndicator
->end();
1614 // -----------------------------------------------------------------------------
1615 void SAL_CALL
OReportDefinition::switchToStorage( const uno::Reference
< embed::XStorage
>& _xStorage
) throw (lang::IllegalArgumentException
, io::IOException
, uno::Exception
, uno::RuntimeException
)
1617 if ( !_xStorage
.is() )
1618 throw lang::IllegalArgumentException(RPT_RESSTRING(RID_STR_ARGUMENT_IS_NULL
,m_aProps
->m_xContext
->getServiceManager()),*this,1);
1620 ::osl::MutexGuard
aGuard(m_aMutex
);
1621 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1622 m_pImpl
->m_xStorage
= _xStorage
;
1623 lcl_setModelReadOnly(m_pImpl
->m_xStorage
,m_pImpl
->m_pReportModel
);
1624 m_pImpl
->m_pObjectContainer
->SwitchPersistence(m_pImpl
->m_xStorage
);
1626 // notify our container listeners
1627 m_pImpl
->m_aStorageChangeListeners
.forEach
<document::XStorageChangeListener
>(
1628 ::boost::bind(&document::XStorageChangeListener::notifyStorageChange
,_1
,boost::cref(static_cast<OWeakObject
*>(this)),boost::cref(_xStorage
)));
1630 // -----------------------------------------------------------------------------
1631 uno::Reference
< embed::XStorage
> SAL_CALL
OReportDefinition::getDocumentStorage( ) throw (io::IOException
, uno::Exception
, uno::RuntimeException
)
1633 ::osl::MutexGuard
aGuard(m_aMutex
);
1634 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1635 return m_pImpl
->m_xStorage
;
1637 // -----------------------------------------------------------------------------
1638 void SAL_CALL
OReportDefinition::addStorageChangeListener( const uno::Reference
< document::XStorageChangeListener
>& xListener
) throw (uno::RuntimeException
)
1640 ::osl::MutexGuard
aGuard(m_aMutex
);
1641 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1642 if ( xListener
.is() )
1643 m_pImpl
->m_aStorageChangeListeners
.addInterface(xListener
);
1645 // -----------------------------------------------------------------------------
1646 void SAL_CALL
OReportDefinition::removeStorageChangeListener( const uno::Reference
< document::XStorageChangeListener
>& xListener
) throw (uno::RuntimeException
)
1648 ::osl::MutexGuard
aGuard(m_aMutex
);
1649 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1650 m_pImpl
->m_aStorageChangeListeners
.removeInterface(xListener
);
1652 // -----------------------------------------------------------------------------
1653 sal_Bool
OReportDefinition::WriteThroughComponent(
1654 const uno::Reference
<lang::XComponent
> & xComponent
,
1655 const sal_Char
* pStreamName
,
1656 const sal_Char
* pServiceName
,
1657 const uno::Sequence
<uno::Any
> & rArguments
,
1658 const uno::Sequence
<beans::PropertyValue
> & rMediaDesc
,
1659 const uno::Reference
<embed::XStorage
>& _xStorageToSaveTo
)
1661 OSL_ENSURE( NULL
!= pStreamName
, "Need stream name!" );
1662 OSL_ENSURE( NULL
!= pServiceName
, "Need service name!" );
1665 uno::Reference
<embed::XStorage
> xMyStorage
= _xStorageToSaveTo
;
1667 OUString sStreamName
= OUString::createFromAscii( pStreamName
);
1668 uno::Reference
<io::XStream
> xStream
= xMyStorage
->openStreamElement( sStreamName
,embed::ElementModes::READWRITE
| embed::ElementModes::TRUNCATE
);
1669 if ( !xStream
.is() )
1671 uno::Reference
<io::XOutputStream
> xOutputStream
= xStream
->getOutputStream();
1672 OSL_ENSURE(xOutputStream
.is(), "Can't create output stream in package!");
1673 if ( ! xOutputStream
.is() )
1676 uno::Reference
<beans::XPropertySet
> xStreamProp(xOutputStream
,uno::UNO_QUERY
);
1677 OSL_ENSURE(xStreamProp
.is(),"No valid preoperty set for the output stream!");
1679 uno::Reference
<io::XSeekable
> xSeek(xStreamProp
,uno::UNO_QUERY
);
1682 OSL_TRACE("Length of stream %i",(int)xSeek
->getPosition());
1686 OUString
aPropName("MediaType");
1687 OUString
aMime("text/xml");
1690 xStreamProp
->setPropertyValue( aPropName
, aAny
);
1692 // encrypt all streams
1693 xStreamProp
->setPropertyValue( "UseCommonStoragePasswordEncryption",
1694 uno::makeAny( (sal_Bool
)sal_True
) );
1696 // set buffer and create outputstream
1699 sal_Bool bRet
= WriteThroughComponent(
1700 xOutputStream
, xComponent
,
1701 pServiceName
, rArguments
, rMediaDesc
);
1702 // finally, commit stream.
1705 catch (const uno::Exception
&)
1710 // -----------------------------------------------------------------------------
1711 sal_Bool
OReportDefinition::WriteThroughComponent(
1712 const uno::Reference
<io::XOutputStream
> & xOutputStream
,
1713 const uno::Reference
<lang::XComponent
> & xComponent
,
1714 const sal_Char
* pServiceName
,
1715 const uno::Sequence
<uno::Any
> & rArguments
,
1716 const uno::Sequence
<beans::PropertyValue
> & rMediaDesc
)
1718 OSL_ENSURE( xOutputStream
.is(), "I really need an output stream!" );
1719 OSL_ENSURE( xComponent
.is(), "Need component!" );
1720 OSL_ENSURE( NULL
!= pServiceName
, "Need component name!" );
1723 uno::Reference
< xml::sax::XWriter
> xSaxWriter(
1724 xml::sax::Writer::create(m_aProps
->m_xContext
) );
1726 // connect XML writer to output stream
1727 xSaxWriter
->setOutputStream( xOutputStream
);
1729 // prepare arguments (prepend doc handler to given arguments)
1730 uno::Sequence
<uno::Any
> aArgs( 1 + rArguments
.getLength() );
1731 aArgs
[0] <<= xSaxWriter
;
1732 for(sal_Int32 i
= 0; i
< rArguments
.getLength(); i
++)
1733 aArgs
[i
+1] = rArguments
[i
];
1735 // get filter component
1736 uno::Reference
< document::XExporter
> xExporter(
1737 m_aProps
->m_xContext
->getServiceManager()->createInstanceWithArgumentsAndContext(
1738 OUString::createFromAscii(pServiceName
), aArgs
,m_aProps
->m_xContext
), uno::UNO_QUERY
);
1739 OSL_ENSURE( xExporter
.is(),
1740 "can't instantiate export filter component" );
1741 if( !xExporter
.is() )
1744 // connect model and filter
1745 xExporter
->setSourceDocument( xComponent
);
1748 uno::Reference
<document::XFilter
> xFilter( xExporter
, uno::UNO_QUERY
);
1749 return xFilter
->filter( rMediaDesc
);
1751 // -----------------------------------------------------------------------------
1753 void SAL_CALL
OReportDefinition::initNew( ) throw (frame::DoubleInitializationException
, io::IOException
, uno::Exception
, uno::RuntimeException
)
1755 setPageHeaderOn( sal_True
);
1756 setPageFooterOn( sal_True
);
1758 // -----------------------------------------------------------------------------
1759 void SAL_CALL
OReportDefinition::load( const uno::Sequence
< beans::PropertyValue
>& _rArguments
) throw (frame::DoubleInitializationException
, io::IOException
, uno::Exception
, uno::RuntimeException
)
1761 ::osl::MutexGuard
aGuard(m_aMutex
);
1762 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1764 // TODO: this code is pretty similar to what happens in ODatabaseModelImpl::getOrCreateRootStorage,
1765 // perhaps we can share code here.
1767 ::comphelper::NamedValueCollection
aArguments( _rArguments
);
1769 // the source for the to-be-created storage: either an URL, or a stream
1770 uno::Reference
< io::XInputStream
> xStream
;
1773 if ( aArguments
.has( "Stream" ) )
1775 aArguments
.get_ensureType( "Stream", xStream
);
1776 aArguments
.remove( "Stream" );
1778 else if ( aArguments
.has( "InputStream" ) )
1780 aArguments
.get_ensureType( "InputStream", xStream
);
1781 aArguments
.remove( "InputStream" );
1784 if ( aArguments
.has( "FileName" ) )
1786 aArguments
.get_ensureType( "FileName", sURL
);
1787 aArguments
.remove( "FileName" );
1789 else if ( aArguments
.has( "URL" ) )
1791 aArguments
.get_ensureType( "URL", sURL
);
1792 aArguments
.remove( "URL" );
1795 uno::Any aStorageSource
;
1797 aStorageSource
<<= aStorageSource
;
1798 else if ( !sURL
.isEmpty() )
1799 aStorageSource
<<= sURL
;
1801 throw lang::IllegalArgumentException(
1802 OUString( "No input source (URL or InputStream) found." ),
1808 uno::Reference
< lang::XSingleServiceFactory
> xStorageFactory( embed::StorageFactory::create( m_aProps
->m_xContext
) );
1810 // open read-write per default, unless told otherwise in the MediaDescriptor
1811 uno::Reference
< embed::XStorage
> xDocumentStorage
;
1812 const sal_Int32 nOpenModes
[2] = {
1813 embed::ElementModes::READWRITE
,
1814 embed::ElementModes::READ
1816 size_t nFirstOpenMode
= 0;
1817 if ( aArguments
.has( "ReadOnly" ) )
1819 sal_Bool bReadOnly
= sal_False
;
1820 aArguments
.get_ensureType( "ReadOnly", bReadOnly
);
1821 nFirstOpenMode
= bReadOnly
? 1 : 0;
1823 const size_t nLastOpenMode
= sizeof( nOpenModes
) / sizeof( nOpenModes
[0] ) - 1;
1824 for ( size_t i
=nFirstOpenMode
; i
<= nLastOpenMode
; ++i
)
1826 uno::Sequence
< uno::Any
> aStorageCreationArgs(2);
1827 aStorageCreationArgs
[0] = aStorageSource
;
1828 aStorageCreationArgs
[1] <<= nOpenModes
[i
];
1832 xDocumentStorage
.set( xStorageFactory
->createInstanceWithArguments( aStorageCreationArgs
), uno::UNO_QUERY_THROW
);
1834 catch (const uno::Exception
&)
1836 if ( i
== nLastOpenMode
)
1837 throw lang::WrappedTargetException(
1838 OUString( "An error occurred while creating the document storage." ),
1841 ::cppu::getCaughtException()
1846 if ( !xDocumentStorage
.is() )
1848 throw uno::RuntimeException();
1851 impl_loadFromStorage_nolck_throw( xDocumentStorage
, aArguments
.getPropertyValues() );
1852 // TODO: do we need to take ownership of the storage? In opposite to loadFromStorage, we created the storage
1853 // ourself here, and perhaps this means we're also responsible for it ...?
1855 // -----------------------------------------------------------------------------
1857 void SAL_CALL
OReportDefinition::setVisualAreaSize( ::sal_Int64 _nAspect
, const awt::Size
& _aSize
) throw (lang::IllegalArgumentException
, embed::WrongStateException
, uno::Exception
, uno::RuntimeException
)
1859 ::osl::MutexGuard
aGuard(m_aMutex
);
1860 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1862 (m_pImpl
->m_aVisualAreaSize
.Width
!= _aSize
.Width
||
1863 m_pImpl
->m_aVisualAreaSize
.Height
!= _aSize
.Height
);
1864 m_pImpl
->m_aVisualAreaSize
= _aSize
;
1866 setModified( sal_True
);
1867 m_pImpl
->m_nAspect
= _nAspect
;
1869 // -----------------------------------------------------------------------------
1870 awt::Size SAL_CALL
OReportDefinition::getVisualAreaSize( ::sal_Int64
/*_nAspect*/ ) throw (lang::IllegalArgumentException
, embed::WrongStateException
, uno::Exception
, uno::RuntimeException
)
1872 ::osl::MutexGuard
aGuard(m_aMutex
);
1873 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1874 return m_pImpl
->m_aVisualAreaSize
;
1876 // -----------------------------------------------------------------------------
1877 embed::VisualRepresentation SAL_CALL
OReportDefinition::getPreferredVisualRepresentation( ::sal_Int64
/*_nAspect*/ ) throw (lang::IllegalArgumentException
, embed::WrongStateException
, uno::Exception
, uno::RuntimeException
)
1879 ::osl::MutexGuard
aGuard(m_aMutex
);
1880 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1881 embed::VisualRepresentation aResult
;
1882 OUString
sImageName("report");
1884 uno::Reference
<io::XInputStream
> xStream
= m_pImpl
->m_pObjectContainer
->GetGraphicStream(sImageName
,&sMimeType
);
1887 uno::Sequence
<sal_Int8
> aSeq
;
1888 xStream
->readBytes(aSeq
,xStream
->available());
1889 xStream
->closeInput();
1890 aResult
.Data
<<= aSeq
;
1891 aResult
.Flavor
.MimeType
= sMimeType
;
1892 aResult
.Flavor
.DataType
= ::getCppuType( &aSeq
);
1897 // -----------------------------------------------------------------------------
1898 ::sal_Int32 SAL_CALL
OReportDefinition::getMapUnit( ::sal_Int64
/*nAspect*/ ) throw (uno::Exception
, uno::RuntimeException
)
1900 return embed::EmbedMapUnits::ONE_100TH_MM
;
1902 // -----------------------------------------------------------------------------
1904 ::sal_Bool SAL_CALL
OReportDefinition::disableSetModified( ) throw (uno::RuntimeException
)
1906 ::osl::MutexGuard
aGuard( m_aMutex
);
1907 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper
.bDisposed
);
1909 const sal_Bool bWasEnabled
= m_pImpl
->m_bSetModifiedEnabled
;
1910 m_pImpl
->m_bSetModifiedEnabled
= sal_False
;
1914 // -----------------------------------------------------------------------------
1915 ::sal_Bool SAL_CALL
OReportDefinition::enableSetModified( ) throw (uno::RuntimeException
)
1917 ::osl::MutexGuard
aGuard( m_aMutex
);
1918 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper
.bDisposed
);
1920 const sal_Bool bWasEnabled
= m_pImpl
->m_bSetModifiedEnabled
;
1921 m_pImpl
->m_bSetModifiedEnabled
= sal_True
;
1925 // -----------------------------------------------------------------------------
1926 ::sal_Bool SAL_CALL
OReportDefinition::isSetModifiedEnabled( ) throw (uno::RuntimeException
)
1928 ::osl::MutexGuard
aGuard( m_aMutex
);
1929 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper
.bDisposed
);
1931 return m_pImpl
->m_bSetModifiedEnabled
;
1934 // -----------------------------------------------------------------------------
1936 ::sal_Bool SAL_CALL
OReportDefinition::isModified( ) throw (uno::RuntimeException
)
1938 ::osl::MutexGuard
aGuard(m_aMutex
);
1939 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1940 return m_pImpl
->m_bModified
;
1942 // -----------------------------------------------------------------------------
1943 void SAL_CALL
OReportDefinition::setModified( ::sal_Bool _bModified
) throw (beans::PropertyVetoException
, uno::RuntimeException
)
1945 ::osl::ResettableMutexGuard
aGuard(m_aMutex
);
1946 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1948 if ( !m_pImpl
->m_bSetModifiedEnabled
)
1951 if ( m_pImpl
->m_pReportModel
->IsReadOnly() && _bModified
)
1952 throw beans::PropertyVetoException();
1953 if ( m_pImpl
->m_bModified
!= _bModified
)
1955 m_pImpl
->m_bModified
= _bModified
;
1956 if ( m_pImpl
->m_pReportModel
->IsChanged() != _bModified
)
1957 m_pImpl
->m_pReportModel
->SetChanged(_bModified
);
1959 lang::EventObject
aEvent(*this);
1961 m_pImpl
->m_aModifyListeners
.notifyEach(&util::XModifyListener::modified
,aEvent
);
1962 notifyEvent(OUString("OnModifyChanged"));
1965 // -----------------------------------------------------------------------------
1966 // XModifyBroadcaster
1967 void SAL_CALL
OReportDefinition::addModifyListener( const uno::Reference
< util::XModifyListener
>& _xListener
) throw (uno::RuntimeException
)
1969 ::osl::MutexGuard
aGuard(m_aMutex
);
1970 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1971 if ( _xListener
.is() )
1972 m_pImpl
->m_aModifyListeners
.addInterface(_xListener
);
1974 // -----------------------------------------------------------------------------
1975 void SAL_CALL
OReportDefinition::removeModifyListener( const uno::Reference
< util::XModifyListener
>& _xListener
) throw (uno::RuntimeException
)
1977 ::osl::MutexGuard
aGuard(m_aMutex
);
1978 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1979 m_pImpl
->m_aModifyListeners
.removeInterface(_xListener
);
1981 // -----------------------------------------------------------------------------
1982 void OReportDefinition::notifyEvent(const OUString
& _sEventName
)
1986 ::osl::ResettableMutexGuard
aGuard(m_aMutex
);
1987 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1988 document::EventObject
aEvt(*this, _sEventName
);
1990 m_pImpl
->m_aDocEventListeners
.notifyEach(&document::XEventListener::notifyEvent
,aEvt
);
1992 catch (const uno::Exception
&)
1996 // -----------------------------------------------------------------------------
1997 // document::XEventBroadcaster
1998 void SAL_CALL
OReportDefinition::addEventListener(const uno::Reference
< document::XEventListener
>& _xListener
) throw (uno::RuntimeException
)
2000 ::osl::MutexGuard
aGuard(m_aMutex
);
2001 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2002 if ( _xListener
.is() )
2003 m_pImpl
->m_aDocEventListeners
.addInterface(_xListener
);
2005 // -----------------------------------------------------------------------------
2006 void SAL_CALL
OReportDefinition::removeEventListener( const uno::Reference
< document::XEventListener
>& _xListener
) throw (uno::RuntimeException
)
2008 ::osl::MutexGuard
aGuard(m_aMutex
);
2009 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2010 m_pImpl
->m_aDocEventListeners
.removeInterface(_xListener
);
2012 // -----------------------------------------------------------------------------
2013 // document::XEventListener
2014 void SAL_CALL
OReportDefinition::notifyEvent( const document::EventObject
& aEvent
) throw (uno::RuntimeException
)
2016 // used only to forward external events (e.g. for doc creation) from the frame loader
2017 // to the global event broadcaster and all other interested doc event listener.
2018 notifyEvent(aEvent
.EventName
);
2020 // -----------------------------------------------------------------------------
2021 // document::XViewDataSupplier
2022 uno::Reference
< container::XIndexAccess
> SAL_CALL
OReportDefinition::getViewData( ) throw (uno::RuntimeException
)
2024 ::osl::MutexGuard
aGuard(m_aMutex
);
2025 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2026 if ( !m_pImpl
->m_xViewData
.is() )
2028 m_pImpl
->m_xViewData
.set( document::IndexedPropertyValues::create(m_aProps
->m_xContext
), uno::UNO_QUERY
);
2029 uno::Reference
< container::XIndexContainer
> xContainer(m_pImpl
->m_xViewData
,uno::UNO_QUERY
);
2030 ::std::vector
< uno::Reference
< frame::XController
> >::iterator aIter
= m_pImpl
->m_aControllers
.begin();
2031 ::std::vector
< uno::Reference
< frame::XController
> >::iterator aEnd
= m_pImpl
->m_aControllers
.end();
2032 for (;aIter
!= aEnd
; ++aIter
)
2038 xContainer
->insertByIndex(xContainer
->getCount(),(*aIter
)->getViewData());
2040 catch (const uno::Exception
&)
2047 return m_pImpl
->m_xViewData
;
2049 // -----------------------------------------------------------------------------
2050 void SAL_CALL
OReportDefinition::setViewData( const uno::Reference
< container::XIndexAccess
>& Data
) throw (uno::RuntimeException
)
2052 ::osl::MutexGuard
aGuard(m_aMutex
);
2053 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2054 m_pImpl
->m_xViewData
= Data
;
2056 // -----------------------------------------------------------------------------
2057 uno::Reference
< report::XFunctions
> SAL_CALL
OReportDefinition::getFunctions() throw (uno::RuntimeException
)
2059 ::osl::MutexGuard
aGuard(m_aMutex
);
2060 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2061 return m_pImpl
->m_xFunctions
;
2063 // -----------------------------------------------------------------------------
2064 uno::Reference
< ui::XUIConfigurationManager
> SAL_CALL
OReportDefinition::getUIConfigurationManager( ) throw (uno::RuntimeException
)
2066 return uno::Reference
< ui::XUIConfigurationManager
>( getUIConfigurationManager2(), uno::UNO_QUERY_THROW
);
2068 // -----------------------------------------------------------------------------
2069 uno::Reference
< ui::XUIConfigurationManager2
> OReportDefinition::getUIConfigurationManager2( ) throw (uno::RuntimeException
)
2071 ::osl::MutexGuard
aGuard(m_aMutex
);
2072 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2074 if ( !m_pImpl
->m_xUIConfigurationManager
.is() )
2076 m_pImpl
->m_xUIConfigurationManager
= ui::UIConfigurationManager::create(m_aProps
->m_xContext
);
2078 uno::Reference
< embed::XStorage
> xConfigStorage
;
2079 // initialize ui configuration manager with document substorage
2080 m_pImpl
->m_xUIConfigurationManager
->setStorage( xConfigStorage
);
2083 return m_pImpl
->m_xUIConfigurationManager
;
2085 // -----------------------------------------------------------------------------
2086 uno::Reference
< embed::XStorage
> SAL_CALL
OReportDefinition::getDocumentSubStorage( const OUString
& aStorageName
, sal_Int32 nMode
) throw (uno::RuntimeException
)
2088 ::osl::MutexGuard
aGuard(m_aMutex
);
2089 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2090 return m_pImpl
->m_xStorage
->openStorageElement(aStorageName
, nMode
);
2092 // -----------------------------------------------------------------------------
2093 uno::Sequence
< OUString
> SAL_CALL
OReportDefinition::getDocumentSubStoragesNames( ) throw (io::IOException
, uno::RuntimeException
)
2095 ::osl::MutexGuard
aGuard(m_aMutex
);
2096 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2097 uno::Reference
<container::XNameAccess
> xNameAccess(m_pImpl
->m_xStorage
,uno::UNO_QUERY
);
2098 return xNameAccess
.is() ? xNameAccess
->getElementNames() : uno::Sequence
< OUString
>();
2100 // -----------------------------------------------------------------------------
2101 OUString SAL_CALL
OReportDefinition::getMimeType() throw (uno::RuntimeException
)
2103 ::osl::MutexGuard
aGuard(m_aMutex
);
2104 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2105 return m_pImpl
->m_sMimeType
;
2107 // -----------------------------------------------------------------------------
2108 void SAL_CALL
OReportDefinition::setMimeType( const OUString
& _mimetype
) throw (lang::IllegalArgumentException
, uno::RuntimeException
)
2110 ::osl::MutexGuard
aGuard(m_aMutex
);
2111 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2112 uno::Sequence
< OUString
> aList
= getAvailableMimeTypes();
2113 const OUString
* pEnd
= aList
.getConstArray()+aList
.getLength();
2114 if ( ::std::find(aList
.getConstArray(),pEnd
,_mimetype
) == pEnd
)
2115 throwIllegallArgumentException(OUString("getAvailableMimeTypes()")
2118 ,m_aProps
->m_xContext
);
2119 set(PROPERTY_MIMETYPE
,_mimetype
,m_pImpl
->m_sMimeType
);
2121 // -----------------------------------------------------------------------------
2122 uno::Sequence
< OUString
> SAL_CALL
OReportDefinition::getAvailableMimeTypes( ) throw (lang::DisposedException
, uno::Exception
, uno::RuntimeException
)
2124 uno::Sequence
< OUString
> s_aList(2);
2125 s_aList
[0] = MIMETYPE_OASIS_OPENDOCUMENT_TEXT
;
2126 s_aList
[1] = MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET
;
2129 // -----------------------------------------------------------------------------
2130 // com::sun::star::XUnoTunnel
2131 sal_Int64 SAL_CALL
OReportDefinition::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw(uno::RuntimeException
)
2134 if (rId
.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
2135 nRet
= reinterpret_cast<sal_Int64
>(this);
2138 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel(m_pImpl
->m_xNumberFormatsSupplier
,uno::UNO_QUERY
);
2139 if ( xUnoTunnel
.is() )
2140 nRet
= xUnoTunnel
->getSomething(rId
);
2144 uno::Reference
< lang::XUnoTunnel
> xTunnel
;
2145 ::comphelper::query_aggregation(m_aProps
->m_xProxy
,xTunnel
);
2147 nRet
= xTunnel
->getSomething(rId
);
2152 // -----------------------------------------------------------------------------
2153 uno::Sequence
< sal_Int8
> SAL_CALL
OReportDefinition::getImplementationId( ) throw (uno::RuntimeException
)
2155 return OReportDefinition::getUnoTunnelImplementationId();
2157 //--------------------------------------------------------------------------
2158 uno::Sequence
< sal_Int8
> OReportDefinition::getUnoTunnelImplementationId()
2160 static ::cppu::OImplementationId
* pId
= 0;
2163 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
2166 static ::cppu::OImplementationId aId
;
2170 return pId
->getImplementationId();
2172 // -----------------------------------------------------------------------------
2173 uno::Reference
< uno::XComponentContext
> OReportDefinition::getContext()
2175 ::osl::MutexGuard
aGuard(m_aMutex
);
2176 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2177 return m_aProps
->m_xContext
;
2179 // -----------------------------------------------------------------------------
2180 ::boost::shared_ptr
<rptui::OReportModel
> OReportDefinition::getSdrModel() const
2182 return m_pImpl
->m_pReportModel
;
2184 // -----------------------------------------------------------------------------
2185 ::boost::shared_ptr
<rptui::OReportModel
> OReportDefinition::getSdrModel(const uno::Reference
< report::XReportDefinition
>& _xReportDefinition
)
2187 ::boost::shared_ptr
<rptui::OReportModel
> pReportModel
;
2188 uno::Reference
< lang::XUnoTunnel
> xUT( _xReportDefinition
, uno::UNO_QUERY
);
2190 pReportModel
= reinterpret_cast<OReportDefinition
*>(sal::static_int_cast
<sal_uIntPtr
>(xUT
->getSomething( OReportDefinition::getUnoTunnelImplementationId())))->getSdrModel();
2191 return pReportModel
;
2193 // -----------------------------------------------------------------------------
2194 uno::Reference
< uno::XInterface
> SAL_CALL
OReportDefinition::createInstanceWithArguments( const OUString
& aServiceSpecifier
, const uno::Sequence
< uno::Any
>& _aArgs
)
2195 throw( uno::Exception
, uno::RuntimeException
)
2197 ::osl::MutexGuard
aGuard(m_aMutex
);
2198 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2200 uno::Reference
< uno::XInterface
> xRet
;
2201 if ( aServiceSpecifier
.indexOf( "com.sun.star.document.ImportEmbeddedObjectResolver") == 0 )
2203 uno::Reference
< embed::XStorage
> xStorage
;
2204 const uno::Any
* pIter
= _aArgs
.getConstArray();
2205 const uno::Any
* pEnd
= pIter
+ _aArgs
.getLength();
2206 for(;pIter
!= pEnd
;++pIter
)
2208 beans::NamedValue aValue
;
2210 if ( aValue
.Name
== "Storage" )
2211 aValue
.Value
>>= xStorage
;
2213 m_pImpl
->m_pObjectContainer
->SwitchPersistence(xStorage
);
2214 xRet
= static_cast< ::cppu::OWeakObject
* >(SvXMLEmbeddedObjectHelper::Create( xStorage
,*this, EMBEDDEDOBJECTHELPER_MODE_READ
));
2218 // -----------------------------------------------------------------------------
2219 uno::Reference
< uno::XInterface
> SAL_CALL
OReportDefinition::createInstance( const OUString
& aServiceSpecifier
) throw(uno::Exception
, uno::RuntimeException
)
2221 ::osl::MutexGuard
aGuard(m_aMutex
);
2222 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2223 uno::Reference
< drawing::XShape
> xShape
;
2224 if ( aServiceSpecifier
.indexOf( "com.sun.star.report." ) == 0 )
2226 if ( aServiceSpecifier
== SERVICE_SHAPE
)
2227 xShape
.set(SvxUnoDrawMSFactory::createInstance( OUString("com.sun.star.drawing.CustomShape") ),uno::UNO_QUERY_THROW
);
2228 else if ( aServiceSpecifier
== SERVICE_FORMATTEDFIELD
2229 || aServiceSpecifier
== SERVICE_FIXEDTEXT
2230 || aServiceSpecifier
== SERVICE_FIXEDLINE
2231 || aServiceSpecifier
== SERVICE_IMAGECONTROL
)
2232 xShape
.set(SvxUnoDrawMSFactory::createInstance( OUString("com.sun.star.drawing.ControlShape") ),uno::UNO_QUERY_THROW
);
2234 xShape
.set(SvxUnoDrawMSFactory::createInstance( OUString("com.sun.star.drawing.OLE2Shape") ),uno::UNO_QUERY_THROW
);
2236 else if ( aServiceSpecifier
.indexOf( "com.sun.star.form.component." ) == 0 )
2238 xShape
.set(m_aProps
->m_xContext
->getServiceManager()->createInstanceWithContext(aServiceSpecifier
,m_aProps
->m_xContext
),uno::UNO_QUERY
);
2240 else if ( aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.style.PageStyle") ) == 0 ||
2241 aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.style.FrameStyle") ) == 0 ||
2242 aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.style.GraphicStyle") ) == 0
2245 uno::Reference
< style::XStyle
> xStyle
= new OStyle();
2246 xStyle
->setName(OUString("Default"));
2247 uno::Reference
<beans::XPropertySet
> xProp(xStyle
,uno::UNO_QUERY
);
2249 xProp
->getPropertyValue(OUString("PrinterPaperTray"))>>= sTray
;
2251 return xStyle
.get();
2253 else if ( aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.Settings") ) == 0 )
2255 uno::Reference
<beans::XPropertySet
> xProp
= new OStyle();
2259 else if ( aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Defaults") ) == 0 )
2261 uno::Reference
<beans::XPropertySet
> xProp
= new OStyle();
2264 else if ( aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) == 0 )
2266 if ( !m_pImpl
->m_xGradientTable
.is() )
2267 m_pImpl
->m_xGradientTable
.set(SvxUnoGradientTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2268 return m_pImpl
->m_xGradientTable
;
2270 else if ( aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) == 0 )
2272 if ( !m_pImpl
->m_xHatchTable
.is() )
2273 m_pImpl
->m_xHatchTable
.set(SvxUnoHatchTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2274 return m_pImpl
->m_xHatchTable
;
2276 else if ( aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) == 0 )
2278 if ( !m_pImpl
->m_xBitmapTable
.is() )
2279 m_pImpl
->m_xBitmapTable
.set(SvxUnoBitmapTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2280 return m_pImpl
->m_xBitmapTable
;
2282 else if ( aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) == 0 )
2284 if ( !m_pImpl
->m_xTransparencyGradientTable
.is() )
2285 m_pImpl
->m_xTransparencyGradientTable
.set(SvxUnoTransGradientTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2286 return m_pImpl
->m_xTransparencyGradientTable
;
2288 else if ( aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) == 0 )
2290 if ( !m_pImpl
->m_xDashTable
.is() )
2291 m_pImpl
->m_xDashTable
.set(SvxUnoDashTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2292 return m_pImpl
->m_xDashTable
;
2294 else if( 0 == aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) )
2296 if( !m_pImpl
->m_xMarkerTable
.is() )
2297 m_pImpl
->m_xMarkerTable
.set(SvxUnoMarkerTable_createInstance( m_pImpl
->m_pReportModel
.get() ),uno::UNO_QUERY
);
2298 return m_pImpl
->m_xMarkerTable
;
2300 else if ( aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver")) == 0 )
2301 return static_cast< ::cppu::OWeakObject
* >(SvXMLEmbeddedObjectHelper::Create( m_pImpl
->m_xStorage
,*this, EMBEDDEDOBJECTHELPER_MODE_READ
));
2302 else if ( aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ExportEmbeddedObjectResolver")) == 0 )
2303 return static_cast< ::cppu::OWeakObject
* >(SvXMLEmbeddedObjectHelper::Create( m_pImpl
->m_xStorage
,*this, EMBEDDEDOBJECTHELPER_MODE_WRITE
));
2304 else if ( aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportGraphicObjectResolver")) == 0 )
2306 SvXMLGraphicHelper
* pGraphicHelper
= SvXMLGraphicHelper::Create(m_pImpl
->m_xStorage
,GRAPHICHELPER_MODE_WRITE
);
2307 uno::Reference
< uno::XInterface
> xRet(static_cast< ::cppu::OWeakObject
* >(pGraphicHelper
));
2308 pGraphicHelper
->release();
2311 else if ( aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ExportGraphicObjectResolver")) == 0 )
2313 SvXMLGraphicHelper
* pGraphicHelper
= SvXMLGraphicHelper::Create(m_pImpl
->m_xStorage
,GRAPHICHELPER_MODE_WRITE
);
2314 uno::Reference
< uno::XInterface
> xRet(static_cast< ::cppu::OWeakObject
* >(pGraphicHelper
));
2315 pGraphicHelper
->release();
2318 else if ( aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.data.DataProvider")) == 0 )
2320 uno::Reference
<chart2::data::XDatabaseDataProvider
> xDataProvider(chart2::data::DatabaseDataProvider::createWithConnection( m_aProps
->m_xContext
, m_pImpl
->m_xActiveConnection
));
2321 xDataProvider
->setRowLimit(10);
2322 uno::Reference
< container::XChild
> xChild(xDataProvider
,uno::UNO_QUERY
);
2324 xChild
->setParent(*this);
2325 return uno::Reference
< uno::XInterface
>(xDataProvider
,uno::UNO_QUERY
);
2327 else if ( aServiceSpecifier
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.xml.NamespaceMap")) == 0 )
2329 if ( !m_pImpl
->m_xXMLNamespaceMap
.is() )
2330 m_pImpl
->m_xXMLNamespaceMap
= comphelper::NameContainer_createInstance( ::getCppuType( (const OUString
*) 0 ) ).get();
2331 return m_pImpl
->m_xXMLNamespaceMap
;
2334 xShape
.set(SvxUnoDrawMSFactory::createInstance( aServiceSpecifier
),uno::UNO_QUERY_THROW
);
2336 return m_pImpl
->m_pReportModel
->createShape(aServiceSpecifier
,xShape
);
2338 //-----------------------------------------------------------------------------
2339 uno::Sequence
< OUString
> SAL_CALL
OReportDefinition::getAvailableServiceNames(void) throw( uno::RuntimeException
)
2341 static const OUString aSvxComponentServiceNameList
[] =
2343 OUString("com.sun.star.form.component.FixedText"),
2344 OUString("com.sun.star.form.component.DatabaseImageControl"),
2345 OUString("com.sun.star.style.PageStyle"),
2346 OUString("com.sun.star.style.GraphicStyle"),
2347 OUString("com.sun.star.style.FrameStyle"),
2348 OUString("com.sun.star.drawing.Defaults"),
2349 OUString("com.sun.star.document.ImportEmbeddedObjectResolver"),
2350 OUString("com.sun.star.document.ExportEmbeddedObjectResolver"),
2351 OUString("com.sun.star.document.ImportGraphicObjectResolver"),
2352 OUString("com.sun.star.document.ExportGraphicObjectResolver"),
2353 OUString("com.sun.star.chart2.data.DataProvider"),
2354 OUString("com.sun.star.xml.NamespaceMap"),
2355 OUString("com.sun.star.document.Settings"),
2356 OUString("com.sun.star.drawing.GradientTable"),
2357 OUString("com.sun.star.drawing.HatchTable"),
2358 OUString("com.sun.star.drawing.BitmapTable"),
2359 OUString("com.sun.star.drawing.TransparencyGradientTable"),
2360 OUString("com.sun.star.drawing.DashTable"),
2361 OUString("com.sun.star.drawing.MarkerTable")
2364 static const sal_uInt16 nSvxComponentServiceNameListCount
= sizeof(aSvxComponentServiceNameList
) / sizeof ( aSvxComponentServiceNameList
[0] );
2366 uno::Sequence
< OUString
> aSeq( nSvxComponentServiceNameListCount
);
2367 OUString
* pStrings
= aSeq
.getArray();
2368 for( sal_uInt16 nIdx
= 0; nIdx
< nSvxComponentServiceNameListCount
; nIdx
++ )
2369 pStrings
[nIdx
] = aSvxComponentServiceNameList
[nIdx
];
2371 uno::Sequence
< OUString
> aParentSeq( SvxUnoDrawMSFactory::getAvailableServiceNames() );
2372 return concatServiceNames( aParentSeq
, aSeq
);
2374 // -----------------------------------------------------------------------------
2376 awt::Point SAL_CALL
OReportDefinition::getPosition( ) throw (uno::RuntimeException
)
2378 ::osl::MutexGuard
aGuard(m_aMutex
);
2379 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2380 if ( m_aProps
->m_xShape
.is() )
2381 return m_aProps
->m_xShape
->getPosition();
2382 return awt::Point(m_aProps
->m_nPosX
,m_aProps
->m_nPosY
);
2384 // -----------------------------------------------------------------------------
2385 void SAL_CALL
OReportDefinition::setPosition( const awt::Point
& aPosition
) throw (uno::RuntimeException
)
2387 ::osl::MutexGuard
aGuard(m_aMutex
);
2388 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2389 if ( m_aProps
->m_xShape
.is() )
2390 m_aProps
->m_xShape
->setPosition(aPosition
);
2391 set(PROPERTY_POSITIONX
,aPosition
.X
,m_aProps
->m_nPosX
);
2392 set(PROPERTY_POSITIONY
,aPosition
.Y
,m_aProps
->m_nPosY
);
2394 // -----------------------------------------------------------------------------
2395 awt::Size SAL_CALL
OReportDefinition::getSize( ) throw (uno::RuntimeException
)
2397 ::osl::MutexGuard
aGuard(m_aMutex
);
2398 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2399 if ( m_aProps
->m_xShape
.is() )
2400 return m_aProps
->m_xShape
->getSize();
2401 return awt::Size(m_aProps
->m_nWidth
,m_aProps
->m_nHeight
);
2403 // -----------------------------------------------------------------------------
2404 void SAL_CALL
OReportDefinition::setSize( const awt::Size
& aSize
) throw (beans::PropertyVetoException
, uno::RuntimeException
)
2406 ::osl::MutexGuard
aGuard(m_aMutex
);
2407 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2408 if ( m_aProps
->m_xShape
.is() )
2409 m_aProps
->m_xShape
->setSize(aSize
);
2410 set(PROPERTY_WIDTH
,aSize
.Width
,m_aProps
->m_nWidth
);
2411 set(PROPERTY_HEIGHT
,aSize
.Height
,m_aProps
->m_nHeight
);
2413 // -----------------------------------------------------------------------------
2416 OUString SAL_CALL
OReportDefinition::getShapeType( ) throw (uno::RuntimeException
)
2418 ::osl::MutexGuard
aGuard(m_aMutex
);
2419 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2420 if ( m_aProps
->m_xShape
.is() )
2421 return m_aProps
->m_xShape
->getShapeType();
2422 return OUString("com.sun.star.drawing.OLE2Shape");
2424 // -----------------------------------------------------------------------------
2425 typedef ::cppu::WeakImplHelper2
< container::XNameContainer
,
2426 container::XIndexAccess
2428 class OStylesHelper
: public ::cppu::BaseMutex
, public TStylesBASE
2430 typedef ::std::map
< OUString
, uno::Any
, ::comphelper::UStringMixLess
> TStyleElements
;
2431 TStyleElements m_aElements
;
2432 ::std::vector
<TStyleElements::iterator
> m_aElementsPos
;
2435 OStylesHelper(const OStylesHelper
&);
2436 void operator =(const OStylesHelper
&);
2438 virtual ~OStylesHelper(){}
2440 OStylesHelper(const uno::Type _aType
= ::getCppuType(static_cast< uno::Reference
< container::XElementAccess
>* >(NULL
)));
2443 virtual void SAL_CALL
insertByName( const OUString
& aName
, const uno::Any
& aElement
) throw(lang::IllegalArgumentException
, container::ElementExistException
,lang::WrappedTargetException
, uno::RuntimeException
);
2444 virtual void SAL_CALL
removeByName( const OUString
& Name
) throw(container::NoSuchElementException
, lang::WrappedTargetException
,uno::RuntimeException
);
2447 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const uno::Any
& aElement
) throw(lang::IllegalArgumentException
, container::NoSuchElementException
,lang::WrappedTargetException
, uno::RuntimeException
);
2449 // container::XElementAccess
2450 virtual uno::Type SAL_CALL
getElementType( ) throw(uno::RuntimeException
);
2451 virtual sal_Bool SAL_CALL
hasElements( ) throw(uno::RuntimeException
);
2452 // container::XIndexAccess
2453 virtual sal_Int32 SAL_CALL
getCount( ) throw(uno::RuntimeException
);
2454 virtual uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) throw(lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
);
2456 // container::XNameAccess
2457 virtual uno::Any SAL_CALL
getByName( const OUString
& aName
) throw(container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
);
2458 virtual uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) throw(uno::RuntimeException
);
2459 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) throw(uno::RuntimeException
);
2462 OStylesHelper::OStylesHelper(const uno::Type _aType
)
2467 // -----------------------------------------------------------------------------;
2468 // container::XElementAccess
2469 uno::Type SAL_CALL
OStylesHelper::getElementType( ) throw(uno::RuntimeException
)
2473 // -----------------------------------------------------------------------------
2474 sal_Bool SAL_CALL
OStylesHelper::hasElements( ) throw(uno::RuntimeException
)
2476 ::osl::MutexGuard
aGuard(m_aMutex
);
2477 return !m_aElementsPos
.empty();
2479 // -----------------------------------------------------------------------------
2480 // container::XIndexAccess
2481 sal_Int32 SAL_CALL
OStylesHelper::getCount( ) throw(uno::RuntimeException
)
2483 ::osl::MutexGuard
aGuard(m_aMutex
);
2484 return m_aElementsPos
.size();
2486 // -----------------------------------------------------------------------------
2487 uno::Any SAL_CALL
OStylesHelper::getByIndex( sal_Int32 Index
) throw(lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
)
2489 ::osl::MutexGuard
aGuard(m_aMutex
);
2490 if ( Index
< 0 || Index
>= static_cast<sal_Int32
>(m_aElementsPos
.size()) )
2491 throw lang::IndexOutOfBoundsException();
2492 return uno::makeAny(m_aElementsPos
[Index
]->second
);
2494 // -----------------------------------------------------------------------------
2495 // container::XNameAccess
2496 uno::Any SAL_CALL
OStylesHelper::getByName( const OUString
& aName
) throw(container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
2498 ::osl::MutexGuard
aGuard(m_aMutex
);
2499 TStyleElements::iterator aFind
= m_aElements
.find(aName
);
2500 if ( aFind
== m_aElements
.end() )
2501 throw container::NoSuchElementException();
2502 return uno::makeAny(aFind
->second
);
2504 // -----------------------------------------------------------------------------
2505 uno::Sequence
< OUString
> SAL_CALL
OStylesHelper::getElementNames( ) throw(uno::RuntimeException
)
2507 ::osl::MutexGuard
aGuard(m_aMutex
);
2508 uno::Sequence
< OUString
> aNameList(m_aElementsPos
.size());
2510 OUString
* pStringArray
= aNameList
.getArray();
2511 ::std::vector
<TStyleElements::iterator
>::const_iterator aEnd
= m_aElementsPos
.end();
2512 for(::std::vector
<TStyleElements::iterator
>::const_iterator aIter
= m_aElementsPos
.begin(); aIter
!= aEnd
;++aIter
,++pStringArray
)
2513 *pStringArray
= (*aIter
)->first
;
2517 // -----------------------------------------------------------------------------
2518 sal_Bool SAL_CALL
OStylesHelper::hasByName( const OUString
& aName
) throw(uno::RuntimeException
)
2520 ::osl::MutexGuard
aGuard(m_aMutex
);
2521 return m_aElements
.find(aName
) != m_aElements
.end();
2523 // -----------------------------------------------------------------------------
2525 void SAL_CALL
OStylesHelper::insertByName( const OUString
& aName
, const uno::Any
& aElement
) throw(lang::IllegalArgumentException
, container::ElementExistException
,lang::WrappedTargetException
, uno::RuntimeException
)
2527 ::osl::MutexGuard
aGuard(m_aMutex
);
2528 if ( m_aElements
.find(aName
) != m_aElements
.end() )
2529 throw container::ElementExistException();
2531 if ( !aElement
.isExtractableTo(m_aType
) )
2532 throw lang::IllegalArgumentException();
2534 m_aElementsPos
.push_back(m_aElements
.insert(TStyleElements::value_type(aName
,aElement
)).first
);
2536 // -----------------------------------------------------------------------------
2537 void SAL_CALL
OStylesHelper::removeByName( const OUString
& aName
) throw(container::NoSuchElementException
, lang::WrappedTargetException
,uno::RuntimeException
)
2539 ::osl::MutexGuard
aGuard(m_aMutex
);
2540 TStyleElements::iterator aFind
= m_aElements
.find(aName
);
2541 if ( aFind
!= m_aElements
.end() )
2542 throw container::NoSuchElementException();
2543 m_aElementsPos
.erase(::std::find(m_aElementsPos
.begin(),m_aElementsPos
.end(),aFind
));
2544 m_aElements
.erase(aFind
);
2546 // -----------------------------------------------------------------------------
2548 void SAL_CALL
OStylesHelper::replaceByName( const OUString
& aName
, const uno::Any
& aElement
) throw(lang::IllegalArgumentException
, container::NoSuchElementException
,lang::WrappedTargetException
, uno::RuntimeException
)
2550 ::osl::MutexGuard
aGuard(m_aMutex
);
2551 TStyleElements::iterator aFind
= m_aElements
.find(aName
);
2552 if ( aFind
== m_aElements
.end() )
2553 throw container::NoSuchElementException();
2554 if ( !aElement
.isExtractableTo(m_aType
) )
2555 throw lang::IllegalArgumentException();
2556 aFind
->second
= aElement
;
2558 // -----------------------------------------------------------------------------
2559 uno::Reference
< container::XNameAccess
> SAL_CALL
OReportDefinition::getStyleFamilies( ) throw (uno::RuntimeException
)
2561 ::osl::MutexGuard
aGuard(m_aMutex
);
2562 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2563 if ( !m_pImpl
->m_xStyles
.is() )
2565 m_pImpl
->m_xStyles
= new OStylesHelper();
2566 uno::Reference
< container::XNameContainer
> xStyles(m_pImpl
->m_xStyles
,uno::UNO_QUERY
);
2568 uno::Reference
< container::XNameContainer
> xPageStyles
= new OStylesHelper(::getCppuType(static_cast< uno::Reference
<style::XStyle
>* >(NULL
)));
2569 xStyles
->insertByName(OUString("PageStyles"),uno::makeAny(xPageStyles
));
2570 uno::Reference
< style::XStyle
> xPageStyle(createInstance(OUString("com.sun.star.style.PageStyle")),uno::UNO_QUERY
);
2571 xPageStyles
->insertByName(xPageStyle
->getName(),uno::makeAny(xPageStyle
));
2573 uno::Reference
< container::XNameContainer
> xFrameStyles
= new OStylesHelper(::getCppuType(static_cast< uno::Reference
<style::XStyle
>* >(NULL
)));
2574 xStyles
->insertByName(OUString("FrameStyles"),uno::makeAny(xFrameStyles
));
2575 uno::Reference
< style::XStyle
> xFrameStyle(createInstance(OUString("com.sun.star.style.FrameStyle")),uno::UNO_QUERY
);
2576 xFrameStyles
->insertByName(xFrameStyle
->getName(),uno::makeAny(xFrameStyle
));
2578 uno::Reference
< container::XNameContainer
> xGraphicStyles
= new OStylesHelper(::getCppuType(static_cast< uno::Reference
<style::XStyle
>* >(NULL
)));
2579 xStyles
->insertByName(OUString("graphics"),uno::makeAny(xGraphicStyles
));
2580 uno::Reference
< style::XStyle
> xGraphicStyle(createInstance(OUString("com.sun.star.style.GraphicStyle")),uno::UNO_QUERY
);
2581 xGraphicStyles
->insertByName(xGraphicStyle
->getName(),uno::makeAny(xGraphicStyle
));
2583 return m_pImpl
->m_xStyles
;
2585 OUString SAL_CALL
OReportDefinition::getIdentifier( ) throw (uno::RuntimeException
)
2587 ::osl::MutexGuard
aGuard(m_aMutex
);
2588 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2589 return m_pImpl
->m_sIdentifier
;
2591 // -----------------------------------------------------------------------------
2592 void SAL_CALL
OReportDefinition::setIdentifier( const OUString
& Identifier
) throw (uno::RuntimeException
)
2594 ::osl::MutexGuard
aGuard(m_aMutex
);
2595 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2596 m_pImpl
->m_sIdentifier
= Identifier
;
2598 // -----------------------------------------------------------------------------
2599 // XNumberFormatsSupplier
2600 uno::Reference
< beans::XPropertySet
> SAL_CALL
OReportDefinition::getNumberFormatSettings( ) throw (uno::RuntimeException
)
2602 ::osl::MutexGuard
aGuard(m_aMutex
);
2603 if ( m_pImpl
->m_xNumberFormatsSupplier
.is() )
2604 return m_pImpl
->m_xNumberFormatsSupplier
->getNumberFormatSettings();
2605 return uno::Reference
< beans::XPropertySet
>();
2607 // -----------------------------------------------------------------------------
2608 uno::Reference
< util::XNumberFormats
> SAL_CALL
OReportDefinition::getNumberFormats( ) throw (uno::RuntimeException
)
2610 ::osl::MutexGuard
aGuard(m_aMutex
);
2611 if ( m_pImpl
->m_xNumberFormatsSupplier
.is() )
2612 return m_pImpl
->m_xNumberFormatsSupplier
->getNumberFormats();
2613 return uno::Reference
< util::XNumberFormats
>();
2615 // -----------------------------------------------------------------------------
2616 ::comphelper::EmbeddedObjectContainer
& OReportDefinition::getEmbeddedObjectContainer() const
2618 return *m_pImpl
->m_pObjectContainer
;
2620 // -----------------------------------------------------------------------------
2621 uno::Reference
< embed::XStorage
> OReportDefinition::getStorage() const
2623 return m_pImpl
->m_xStorage
;
2625 // -----------------------------------------------------------------------------
2626 uno::Reference
< task::XInteractionHandler
> OReportDefinition::getInteractionHandler() const
2628 uno::Reference
< task::XInteractionHandler
> xRet(
2629 task::InteractionHandler::createWithParent(m_aProps
->m_xContext
, 0), uno::UNO_QUERY_THROW
);
2632 // -----------------------------------------------------------------------------
2633 uno::Reference
< sdbc::XConnection
> SAL_CALL
OReportDefinition::getActiveConnection() throw (uno::RuntimeException
)
2635 ::osl::MutexGuard
aGuard(m_aMutex
);
2636 return m_pImpl
->m_xActiveConnection
;
2638 // -----------------------------------------------------------------------------
2639 void SAL_CALL
OReportDefinition::setActiveConnection( const uno::Reference
< sdbc::XConnection
>& _activeconnection
) throw (lang::IllegalArgumentException
, uno::RuntimeException
)
2641 if ( !_activeconnection
.is() )
2642 throw lang::IllegalArgumentException();
2643 set(PROPERTY_ACTIVECONNECTION
,_activeconnection
,m_pImpl
->m_xActiveConnection
);
2645 // -----------------------------------------------------------------------------
2646 OUString SAL_CALL
OReportDefinition::getDataSourceName() throw (uno::RuntimeException
)
2648 osl::MutexGuard
g(m_aMutex
);
2649 return m_pImpl
->m_sDataSourceName
;
2651 // -----------------------------------------------------------------------------
2652 void SAL_CALL
OReportDefinition::setDataSourceName(const OUString
& the_value
) throw (uno::RuntimeException
)
2654 set(PROPERTY_DATASOURCENAME
,the_value
,m_pImpl
->m_sDataSourceName
);
2656 // -----------------------------------------------------------------------------
2657 bool OReportDefinition::isEnableSetModified() const
2661 uno::Reference
< frame::XTitle
> OReportDefinition::impl_getTitleHelper_throw()
2663 SolarMutexGuard aSolarGuard
;
2665 ::osl::MutexGuard
aGuard(m_aMutex
);
2666 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2668 if ( ! m_pImpl
->m_xTitleHelper
.is ())
2670 uno::Reference
< frame::XDesktop2
> xDesktop
= frame::Desktop::create(m_aProps
->m_xContext
);
2671 uno::Reference
< frame::XModel
> xThis(static_cast< frame::XModel
* >(this), uno::UNO_QUERY_THROW
);
2673 ::framework::TitleHelper
* pHelper
= new ::framework::TitleHelper( m_aProps
->m_xContext
);
2674 m_pImpl
->m_xTitleHelper
= uno::Reference
< frame::XTitle
>(static_cast< ::cppu::OWeakObject
* >(pHelper
), uno::UNO_QUERY_THROW
);
2675 pHelper
->setOwner (xThis
);
2676 pHelper
->connectWithUntitledNumbers (uno::Reference
<frame::XUntitledNumbers
>(xDesktop
, uno::UNO_QUERY_THROW
));
2679 return m_pImpl
->m_xTitleHelper
;
2681 // -----------------------------------------------------------------------------
2682 uno::Reference
< frame::XUntitledNumbers
> OReportDefinition::impl_getUntitledHelper_throw()
2684 SolarMutexGuard aSolarGuard
;
2686 ::osl::MutexGuard
aGuard(m_aMutex
);
2687 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2689 if ( ! m_pImpl
->m_xNumberedControllers
.is ())
2691 uno::Reference
< frame::XModel
> xThis (static_cast< frame::XModel
* >(this), uno::UNO_QUERY_THROW
);
2692 ::comphelper::NumberedCollection
* pHelper
= new ::comphelper::NumberedCollection();
2693 m_pImpl
->m_xNumberedControllers
= uno::Reference
< frame::XUntitledNumbers
>(static_cast< ::cppu::OWeakObject
* >(pHelper
), uno::UNO_QUERY_THROW
);
2695 pHelper
->setOwner (xThis
);
2696 pHelper
->setUntitledPrefix (OUString(" : "));
2699 return m_pImpl
->m_xNumberedControllers
;
2701 // -----------------------------------------------------------------------------
2703 OUString SAL_CALL
OReportDefinition::getTitle()
2704 throw (uno::RuntimeException
)
2707 SolarMutexGuard aSolarGuard
;
2709 ::osl::MutexGuard
aGuard(m_aMutex
);
2710 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2712 return impl_getTitleHelper_throw()->getTitle ();
2714 // -----------------------------------------------------------------------------
2716 void SAL_CALL
OReportDefinition::setTitle( const OUString
& sTitle
)
2717 throw (uno::RuntimeException
)
2720 SolarMutexGuard aSolarGuard
;
2722 ::osl::MutexGuard
aGuard(m_aMutex
);
2723 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2725 impl_getTitleHelper_throw()->setTitle (sTitle
);
2727 // -----------------------------------------------------------------------------
2728 // css.frame.XTitleChangeBroadcaster
2729 void SAL_CALL
OReportDefinition::addTitleChangeListener( const uno::Reference
< frame::XTitleChangeListener
>& xListener
)
2730 throw (uno::RuntimeException
)
2733 SolarMutexGuard aSolarGuard
;
2735 ::osl::MutexGuard
aGuard(m_aMutex
);
2736 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2738 uno::Reference
< frame::XTitleChangeBroadcaster
> xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY
);
2739 if (xBroadcaster
.is ())
2740 xBroadcaster
->addTitleChangeListener (xListener
);
2742 // -----------------------------------------------------------------------------
2743 // css.frame.XTitleChangeBroadcaster
2744 void SAL_CALL
OReportDefinition::removeTitleChangeListener( const uno::Reference
< frame::XTitleChangeListener
>& xListener
)
2745 throw (uno::RuntimeException
)
2748 SolarMutexGuard aSolarGuard
;
2750 ::osl::MutexGuard
aGuard(m_aMutex
);
2751 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2753 uno::Reference
< frame::XTitleChangeBroadcaster
> xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY
);
2754 if (xBroadcaster
.is ())
2755 xBroadcaster
->removeTitleChangeListener (xListener
);
2757 // -----------------------------------------------------------------------------
2758 // css.frame.XUntitledNumbers
2759 ::sal_Int32 SAL_CALL
OReportDefinition::leaseNumber( const uno::Reference
< uno::XInterface
>& xComponent
)
2760 throw (lang::IllegalArgumentException
,
2761 uno::RuntimeException
)
2763 // object already disposed?
2764 SolarMutexGuard aSolarGuard
;
2765 ::osl::MutexGuard
aGuard(m_aMutex
);
2766 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2768 return impl_getUntitledHelper_throw()->leaseNumber (xComponent
);
2770 // -----------------------------------------------------------------------------
2771 // css.frame.XUntitledNumbers
2772 void SAL_CALL
OReportDefinition::releaseNumber( ::sal_Int32 nNumber
)
2773 throw (lang::IllegalArgumentException
,
2774 uno::RuntimeException
)
2776 // object already disposed?
2777 SolarMutexGuard aSolarGuard
;
2778 ::osl::MutexGuard
aGuard(m_aMutex
);
2779 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2781 impl_getUntitledHelper_throw()->releaseNumber (nNumber
);
2783 // -----------------------------------------------------------------------------
2784 // css.frame.XUntitledNumbers
2785 void SAL_CALL
OReportDefinition::releaseNumberForComponent( const uno::Reference
< uno::XInterface
>& xComponent
)
2786 throw (lang::IllegalArgumentException
,
2787 uno::RuntimeException
)
2789 // object already disposed?
2790 SolarMutexGuard aSolarGuard
;
2791 ::osl::MutexGuard
aGuard(m_aMutex
);
2792 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2794 impl_getUntitledHelper_throw()->releaseNumberForComponent (xComponent
);
2796 // -----------------------------------------------------------------------------
2797 // css.frame.XUntitledNumbers
2798 OUString SAL_CALL
OReportDefinition::getUntitledPrefix()
2799 throw (uno::RuntimeException
)
2801 // object already disposed?
2802 SolarMutexGuard aSolarGuard
;
2803 ::osl::MutexGuard
aGuard(m_aMutex
);
2804 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2806 return impl_getUntitledHelper_throw()->getUntitledPrefix ();
2808 // -----------------------------------------------------------------------------
2809 uno::Reference
< document::XDocumentProperties
> SAL_CALL
OReportDefinition::getDocumentProperties( ) throw (uno::RuntimeException
)
2811 ::osl::MutexGuard
aGuard(m_aMutex
);
2812 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2813 if ( !m_pImpl
->m_xDocumentProperties
.is() )
2815 m_pImpl
->m_xDocumentProperties
.set(document::DocumentProperties::create(m_aProps
->m_xContext
));
2817 return m_pImpl
->m_xDocumentProperties
;
2819 // -----------------------------------------------------------------------------
2820 uno::Reference
< uno::XComponentContext
> OReportDefinition::getContext() const
2822 return m_aProps
->m_xContext
;
2824 // -----------------------------------------------------------------------------
2825 uno::Any SAL_CALL
OReportDefinition::getTransferData( const datatransfer::DataFlavor
& aFlavor
) throw (datatransfer::UnsupportedFlavorException
, io::IOException
, uno::RuntimeException
)
2828 if( isDataFlavorSupported( aFlavor
) )
2832 aResult
<<= getPreferredVisualRepresentation(0).Data
;
2834 catch (const uno::Exception
&)
2836 DBG_UNHANDLED_EXCEPTION();
2841 throw datatransfer::UnsupportedFlavorException(aFlavor
.MimeType
, static_cast< ::cppu::OWeakObject
* >( this ));
2846 // -----------------------------------------------------------------------------
2847 uno::Sequence
< datatransfer::DataFlavor
> SAL_CALL
OReportDefinition::getTransferDataFlavors( ) throw (uno::RuntimeException
)
2849 uno::Sequence
< datatransfer::DataFlavor
> aRet(1);
2851 aRet
[0] = datatransfer::DataFlavor( OUString("image/png"),
2853 ::getCppuType( (const uno::Sequence
< sal_Int8
>*) NULL
) );
2857 // -----------------------------------------------------------------------------
2858 ::sal_Bool SAL_CALL
OReportDefinition::isDataFlavorSupported( const datatransfer::DataFlavor
& aFlavor
) throw (uno::RuntimeException
)
2860 return aFlavor
.MimeType
== "image/png";
2863 // -----------------------------------------------------------------------------
2864 uno::Reference
< document::XUndoManager
> SAL_CALL
OReportDefinition::getUndoManager( ) throw (uno::RuntimeException
)
2866 ::osl::MutexGuard
aGuard( m_aMutex
);
2867 return m_pImpl
->m_pUndoManager
.get();
2871 // =============================================================================
2872 }// namespace reportdesign
2873 // =============================================================================
2875 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */