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