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 #include "precompiled_reportdesign.hxx"
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 	OWeakObject *oWeakThis = static_cast<OWeakObject*>( this );
1675 	m_pImpl->m_aStorageChangeListeners.forEach<document::XStorageChangeListener>(
1676 			::boost::bind(&document::XStorageChangeListener::notifyStorageChange,_1,boost::cref( oWeakThis ),boost::cref(_xStorage)));
1677 }
1678 // -----------------------------------------------------------------------------
getDocumentStorage()1679 uno::Reference< embed::XStorage > SAL_CALL OReportDefinition::getDocumentStorage(  ) throw (io::IOException, uno::Exception, uno::RuntimeException)
1680 {
1681     ::osl::MutexGuard aGuard(m_aMutex);
1682     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1683 	return m_pImpl->m_xStorage;
1684 }
1685 // -----------------------------------------------------------------------------
addStorageChangeListener(const uno::Reference<document::XStorageChangeListener> & xListener)1686 void SAL_CALL OReportDefinition::addStorageChangeListener( const uno::Reference< document::XStorageChangeListener >& xListener ) throw (uno::RuntimeException)
1687 {
1688 	::osl::MutexGuard aGuard(m_aMutex);
1689     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1690 	if ( xListener.is() )
1691 		m_pImpl->m_aStorageChangeListeners.addInterface(xListener);
1692 }
1693 // -----------------------------------------------------------------------------
removeStorageChangeListener(const uno::Reference<document::XStorageChangeListener> & xListener)1694 void SAL_CALL OReportDefinition::removeStorageChangeListener( const uno::Reference< document::XStorageChangeListener >& xListener ) throw (uno::RuntimeException)
1695 {
1696 	::osl::MutexGuard aGuard(m_aMutex);
1697     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1698 	m_pImpl->m_aStorageChangeListeners.removeInterface(xListener);
1699 }
1700 // -----------------------------------------------------------------------------
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)1701 sal_Bool OReportDefinition::WriteThroughComponent(
1702 	const uno::Reference<lang::XComponent> & xComponent,
1703 	const sal_Char* pStreamName,
1704 	const sal_Char* pServiceName,
1705 	const uno::Sequence<uno::Any> & rArguments,
1706 	const uno::Sequence<beans::PropertyValue> & rMediaDesc,
1707 	sal_Bool bPlainStream
1708 	,const uno::Reference<embed::XStorage>& _xStorageToSaveTo)
1709 {
1710     OSL_ENSURE( NULL != pStreamName, "Need stream name!" );
1711     OSL_ENSURE( NULL != pServiceName, "Need service name!" );
1712     try
1713     {
1714         uno::Reference<embed::XStorage> xMyStorage = _xStorageToSaveTo;
1715         // open stream
1716         ::rtl::OUString sStreamName = ::rtl::OUString::createFromAscii( pStreamName );
1717         uno::Reference<io::XStream> xStream = xMyStorage->openStreamElement( sStreamName,embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
1718         if ( !xStream.is() )
1719             return sal_False;
1720         uno::Reference<io::XOutputStream> xOutputStream = xStream->getOutputStream();
1721         OSL_ENSURE(xOutputStream.is(), "Can't create output stream in package!");
1722         if ( ! xOutputStream.is() )
1723             return sal_False;
1724 
1725         uno::Reference<beans::XPropertySet> xStreamProp(xOutputStream,uno::UNO_QUERY);
1726         OSL_ENSURE(xStreamProp.is(),"No valid preoperty set for the output stream!");
1727 
1728         uno::Reference<io::XSeekable> xSeek(xStreamProp,uno::UNO_QUERY);
1729         if ( xSeek.is() )
1730         {
1731             OSL_TRACE("Length of stream %i",(int)xSeek->getPosition());
1732             xSeek->seek(0);
1733         }
1734 
1735         ::rtl::OUString aPropName(RTL_CONSTASCII_USTRINGPARAM("MediaType"));
1736         ::rtl::OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") );
1737         uno::Any aAny;
1738         aAny <<= aMime;
1739         xStreamProp->setPropertyValue( aPropName, aAny );
1740 
1741         if( bPlainStream )
1742         {
1743             aAny <<= sal_False;
1744             xStreamProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Compressed") ), aAny );
1745         }
1746         else
1747         {
1748             xStreamProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ), uno::makeAny(sal_True) );
1749         }
1750 
1751 
1752         // set buffer and create outputstream
1753 
1754         // write the stuff
1755         sal_Bool bRet = WriteThroughComponent(
1756             xOutputStream, xComponent,
1757             pServiceName, rArguments, rMediaDesc );
1758         // finally, commit stream.
1759         return bRet;
1760     }
1761     catch(const uno::Exception& e)
1762     {
1763         (void)e; // helper to know what e contains
1764         throw;
1765     }
1766 }
1767 // -----------------------------------------------------------------------------
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)1768 sal_Bool OReportDefinition::WriteThroughComponent(
1769 	const uno::Reference<io::XOutputStream> & xOutputStream,
1770 	const uno::Reference<lang::XComponent> & xComponent,
1771 	const sal_Char* pServiceName,
1772 	const uno::Sequence<uno::Any> & rArguments,
1773 	const uno::Sequence<beans::PropertyValue> & rMediaDesc)
1774 {
1775 	OSL_ENSURE( xOutputStream.is(), "I really need an output stream!" );
1776 	OSL_ENSURE( xComponent.is(), "Need component!" );
1777 	OSL_ENSURE( NULL != pServiceName, "Need component name!" );
1778 
1779 	// get component
1780 	uno::Reference< io::XActiveDataSource > xSaxWriter(
1781 		m_aProps->m_xContext->getServiceManager()->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer")),m_aProps->m_xContext),
1782 		uno::UNO_QUERY );
1783 	OSL_ENSURE( xSaxWriter.is(), "can't instantiate XML com.sun.star.xml.sax.Writer" );
1784 	if(!xSaxWriter.is())
1785 		return sal_False;
1786 
1787 	// connect XML writer to output stream
1788 	xSaxWriter->setOutputStream( xOutputStream );
1789 
1790 	// prepare arguments (prepend doc handler to given arguments)
1791 	uno::Reference<xml::sax::XDocumentHandler> xDocHandler( xSaxWriter,uno::UNO_QUERY);
1792 	uno::Sequence<uno::Any> aArgs( 1 + rArguments.getLength() );
1793 	aArgs[0] <<= xDocHandler;
1794 	for(sal_Int32 i = 0; i < rArguments.getLength(); i++)
1795 		aArgs[i+1] = rArguments[i];
1796 
1797 	// get filter component
1798 	uno::Reference< document::XExporter > xExporter(
1799 		m_aProps->m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
1800 			::rtl::OUString::createFromAscii(pServiceName), aArgs,m_aProps->m_xContext), uno::UNO_QUERY);
1801 	OSL_ENSURE( xExporter.is(),
1802 			"can't instantiate export filter component" );
1803 	if( !xExporter.is() )
1804 		return sal_False;
1805 
1806 	// connect model and filter
1807 	xExporter->setSourceDocument( xComponent );
1808 
1809 	// filter!
1810 	uno::Reference<document::XFilter> xFilter( xExporter, uno::UNO_QUERY );
1811 	return xFilter->filter( rMediaDesc );
1812 }
1813 // -----------------------------------------------------------------------------
1814 // XLoadable
initNew()1815 void SAL_CALL OReportDefinition::initNew(  ) throw (frame::DoubleInitializationException, io::IOException, uno::Exception, uno::RuntimeException)
1816 {
1817      setPageHeaderOn( sal_True );
1818      setPageFooterOn( sal_True );
1819 }
1820 // -----------------------------------------------------------------------------
load(const uno::Sequence<beans::PropertyValue> & _rArguments)1821 void SAL_CALL OReportDefinition::load( const uno::Sequence< beans::PropertyValue >& _rArguments ) throw (frame::DoubleInitializationException, io::IOException, uno::Exception, uno::RuntimeException)
1822 {
1823 	::osl::MutexGuard aGuard(m_aMutex);
1824 	::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1825 
1826     // TODO: this code is pretty similar to what happens in ODatabaseModelImpl::getOrCreateRootStorage,
1827     //       perhaps we can share code here.
1828 
1829     ::comphelper::NamedValueCollection aArguments( _rArguments );
1830 
1831     // the source for the to-be-created storage: either an URL, or a stream
1832     uno::Reference< io::XInputStream > xStream;
1833     ::rtl::OUString sURL;
1834 
1835     if ( aArguments.has( "Stream" ) )
1836     {
1837         aArguments.get_ensureType( "Stream", xStream );
1838         aArguments.remove( "Stream" );
1839     }
1840     else if ( aArguments.has( "InputStream" ) )
1841     {
1842         aArguments.get_ensureType( "InputStream", xStream );
1843         aArguments.remove( "InputStream" );
1844     }
1845 
1846     if ( aArguments.has( "FileName" ) )
1847     {
1848         aArguments.get_ensureType( "FileName", sURL );
1849         aArguments.remove( "FileName" );
1850     }
1851     else if ( aArguments.has( "URL" ) )
1852     {
1853         aArguments.get_ensureType( "URL", sURL );
1854         aArguments.remove( "URL" );
1855     }
1856 
1857     uno::Any aStorageSource;
1858     if ( xStream.is() )
1859         aStorageSource <<= aStorageSource;
1860     else if ( sURL.getLength() )
1861         aStorageSource <<= sURL;
1862     else
1863         throw lang::IllegalArgumentException(
1864             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No input source (URL or InputStream) found." ) ),
1865                 // TODO: resource
1866             *this,
1867             1
1868         );
1869 
1870     uno::Reference< lang::XSingleServiceFactory > xStorageFactory(
1871         m_aProps->m_xContext->getServiceManager()->createInstanceWithContext(
1872             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.StorageFactory" ) ),
1873             m_aProps->m_xContext ),
1874         uno::UNO_QUERY_THROW
1875     );
1876 
1877     // open read-write per default, unless told otherwise in the MediaDescriptor
1878     uno::Reference< embed::XStorage > xDocumentStorage;
1879     const sal_Int32 nOpenModes[2] = {
1880         embed::ElementModes::READWRITE,
1881         embed::ElementModes::READ
1882     };
1883 	size_t nFirstOpenMode = 0;
1884     if ( aArguments.has( "ReadOnly" ) )
1885     {
1886         sal_Bool bReadOnly = sal_False;
1887         aArguments.get_ensureType( "ReadOnly", bReadOnly );
1888         nFirstOpenMode = bReadOnly ? 1 : 0;
1889     }
1890     const size_t nLastOpenMode = sizeof( nOpenModes ) / sizeof( nOpenModes[0] ) - 1;
1891     for ( size_t i=nFirstOpenMode; i <= nLastOpenMode; ++i )
1892     {
1893         uno::Sequence< uno::Any > aStorageCreationArgs(2);
1894         aStorageCreationArgs[0] = aStorageSource;
1895         aStorageCreationArgs[1] <<= nOpenModes[i];
1896 
1897         try
1898         {
1899             xDocumentStorage.set( xStorageFactory->createInstanceWithArguments( aStorageCreationArgs ), uno::UNO_QUERY_THROW );
1900         }
1901         catch( const uno::Exception& )
1902         {
1903             if ( i == nLastOpenMode )
1904                 throw lang::WrappedTargetException(
1905                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "An error occurred while creating the document storage." ) ),
1906                         // TODO: resource
1907                     *this,
1908                     ::cppu::getCaughtException()
1909                 );
1910         }
1911     }
1912 
1913     if ( !xDocumentStorage.is() )
1914     {
1915         throw uno::RuntimeException();
1916     }
1917 
1918     impl_loadFromStorage_nolck_throw( xDocumentStorage, aArguments.getPropertyValues() );
1919     // TODO: do we need to take ownership of the storage? In opposite to loadFromStorage, we created the storage
1920     // ourself here, and perhaps this means we're also responsible for it ...?
1921 }
1922 // -----------------------------------------------------------------------------
1923 // XVisualObject
setVisualAreaSize(::sal_Int64 _nAspect,const awt::Size & _aSize)1924 void SAL_CALL OReportDefinition::setVisualAreaSize( ::sal_Int64 _nAspect, const awt::Size& _aSize ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException)
1925 {
1926 	::osl::MutexGuard aGuard(m_aMutex);
1927 	::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1928     //if( nAspect == embed::Aspects::MSOLE_CONTENT )
1929     {
1930         bool bChanged =
1931             (m_pImpl->m_aVisualAreaSize.Width != _aSize.Width ||
1932              m_pImpl->m_aVisualAreaSize.Height != _aSize.Height);
1933         m_pImpl->m_aVisualAreaSize = _aSize;
1934         if( bChanged )
1935             setModified( sal_True );
1936     }
1937 	m_pImpl->m_nAspect = _nAspect;
1938 }
1939 // -----------------------------------------------------------------------------
getVisualAreaSize(::sal_Int64)1940 awt::Size SAL_CALL OReportDefinition::getVisualAreaSize( ::sal_Int64 /*_nAspect*/ ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException)
1941 {
1942     ::osl::MutexGuard aGuard(m_aMutex);
1943     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1944 	return m_pImpl->m_aVisualAreaSize;
1945 }
1946 // -----------------------------------------------------------------------------
getPreferredVisualRepresentation(::sal_Int64)1947 embed::VisualRepresentation SAL_CALL OReportDefinition::getPreferredVisualRepresentation( ::sal_Int64 /*_nAspect*/ ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException)
1948 {
1949 	::osl::MutexGuard aGuard(m_aMutex);
1950 	::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
1951     embed::VisualRepresentation aResult;
1952     ::rtl::OUString sImageName(RTL_CONSTASCII_USTRINGPARAM("report"));
1953     ::rtl::OUString sMimeType;
1954     uno::Reference<io::XInputStream> xStream = m_pImpl->m_pObjectContainer->GetGraphicStream(sImageName,&sMimeType);
1955     if ( xStream.is() )
1956     {
1957         uno::Sequence<sal_Int8> aSeq;
1958         xStream->readBytes(aSeq,xStream->available());
1959         xStream->closeInput();
1960         aResult.Data <<= aSeq;
1961         aResult.Flavor.MimeType = sMimeType;
1962         aResult.Flavor.DataType = ::getCppuType( &aSeq );
1963     }
1964 
1965 	return aResult;
1966 }
1967 // -----------------------------------------------------------------------------
getMapUnit(::sal_Int64)1968 ::sal_Int32 SAL_CALL OReportDefinition::getMapUnit( ::sal_Int64 /*nAspect*/ ) throw (uno::Exception, uno::RuntimeException)
1969 {
1970 	return embed::EmbedMapUnits::ONE_100TH_MM;
1971 }
1972 // -----------------------------------------------------------------------------
1973 // XModifiable
disableSetModified()1974 ::sal_Bool SAL_CALL OReportDefinition::disableSetModified(  ) throw (uno::RuntimeException)
1975 {
1976     ::osl::MutexGuard aGuard( m_aMutex );
1977     ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed );
1978 
1979     const sal_Bool bWasEnabled = m_pImpl->m_bSetModifiedEnabled;
1980     m_pImpl->m_bSetModifiedEnabled = sal_False;
1981     return bWasEnabled;
1982 }
1983 
1984 // -----------------------------------------------------------------------------
enableSetModified()1985 ::sal_Bool SAL_CALL OReportDefinition::enableSetModified(  ) throw (uno::RuntimeException)
1986 {
1987     ::osl::MutexGuard aGuard( m_aMutex );
1988     ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed );
1989 
1990     const sal_Bool bWasEnabled = m_pImpl->m_bSetModifiedEnabled;
1991     m_pImpl->m_bSetModifiedEnabled = sal_True;
1992     return bWasEnabled;
1993 }
1994 
1995 // -----------------------------------------------------------------------------
isSetModifiedEnabled()1996 ::sal_Bool SAL_CALL OReportDefinition::isSetModifiedEnabled(  ) throw (uno::RuntimeException)
1997 {
1998     ::osl::MutexGuard aGuard( m_aMutex );
1999     ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed );
2000 
2001     return m_pImpl->m_bSetModifiedEnabled;
2002 }
2003 
2004 // -----------------------------------------------------------------------------
2005 // XModifiable
isModified()2006 ::sal_Bool SAL_CALL OReportDefinition::isModified(  ) throw (uno::RuntimeException)
2007 {
2008 	::osl::MutexGuard aGuard(m_aMutex);
2009 	::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2010 	return m_pImpl->m_bModified;
2011 }
2012 // -----------------------------------------------------------------------------
setModified(::sal_Bool _bModified)2013 void SAL_CALL OReportDefinition::setModified( ::sal_Bool _bModified ) throw (beans::PropertyVetoException, uno::RuntimeException)
2014 {
2015 	::osl::ResettableMutexGuard aGuard(m_aMutex);
2016 	::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2017 
2018     if ( !m_pImpl->m_bSetModifiedEnabled )
2019         return;
2020 
2021     if ( m_pImpl->m_pReportModel->IsReadOnly() && _bModified )
2022         throw beans::PropertyVetoException();
2023 	if ( m_pImpl->m_bModified != _bModified )
2024 	{
2025 		m_pImpl->m_bModified = _bModified;
2026         if ( m_pImpl->m_pReportModel->IsChanged() != _bModified )
2027             m_pImpl->m_pReportModel->SetChanged(_bModified);
2028 
2029 		lang::EventObject aEvent(*this);
2030 		aGuard.clear();
2031 		m_pImpl->m_aModifyListeners.notifyEach(&util::XModifyListener::modified,aEvent);
2032 		notifyEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnModifyChanged")));
2033 	}
2034 }
2035 // -----------------------------------------------------------------------------
2036 // XModifyBroadcaster
addModifyListener(const uno::Reference<util::XModifyListener> & _xListener)2037 void SAL_CALL OReportDefinition::addModifyListener( const uno::Reference< util::XModifyListener >& _xListener ) throw (uno::RuntimeException)
2038 {
2039 	::osl::MutexGuard aGuard(m_aMutex);
2040     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2041 	if ( _xListener.is() )
2042 		m_pImpl->m_aModifyListeners.addInterface(_xListener);
2043 }
2044 // -----------------------------------------------------------------------------
removeModifyListener(const uno::Reference<util::XModifyListener> & _xListener)2045 void SAL_CALL OReportDefinition::removeModifyListener( const uno::Reference< util::XModifyListener >& _xListener ) throw (uno::RuntimeException)
2046 {
2047 	::osl::MutexGuard aGuard(m_aMutex);
2048     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2049 	m_pImpl->m_aModifyListeners.removeInterface(_xListener);
2050 }
2051 // -----------------------------------------------------------------------------
notifyEvent(const::rtl::OUString & _sEventName)2052 void OReportDefinition::notifyEvent(const ::rtl::OUString& _sEventName)
2053 {
2054 	try
2055 	{
2056 		::osl::ResettableMutexGuard aGuard(m_aMutex);
2057 		::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2058 		document::EventObject aEvt(*this, _sEventName);
2059         aGuard.clear();
2060 		m_pImpl->m_aDocEventListeners.notifyEach(&document::XEventListener::notifyEvent,aEvt);
2061 	}
2062 	catch(uno::Exception&)
2063 	{
2064 	}
2065 }
2066 // -----------------------------------------------------------------------------
2067 // document::XEventBroadcaster
addEventListener(const uno::Reference<document::XEventListener> & _xListener)2068 void SAL_CALL OReportDefinition::addEventListener(const uno::Reference< document::XEventListener >& _xListener ) throw (uno::RuntimeException)
2069 {
2070 	::osl::MutexGuard aGuard(m_aMutex);
2071     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2072 	if ( _xListener.is() )
2073 		m_pImpl->m_aDocEventListeners.addInterface(_xListener);
2074 }
2075 // -----------------------------------------------------------------------------
removeEventListener(const uno::Reference<document::XEventListener> & _xListener)2076 void SAL_CALL OReportDefinition::removeEventListener( const uno::Reference< document::XEventListener >& _xListener ) throw (uno::RuntimeException)
2077 {
2078 	::osl::MutexGuard aGuard(m_aMutex);
2079     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2080 	m_pImpl->m_aDocEventListeners.removeInterface(_xListener);
2081 }
2082 // -----------------------------------------------------------------------------
2083 // document::XEventListener
notifyEvent(const document::EventObject & aEvent)2084 void SAL_CALL OReportDefinition::notifyEvent( const document::EventObject& aEvent ) throw (uno::RuntimeException)
2085 {
2086     // used only to forward external events (e.g. for doc creation) from the frame loader
2087     // to the global event broadcaster and all other interested doc event listener.
2088     notifyEvent(aEvent.EventName);
2089 }
2090 // -----------------------------------------------------------------------------
2091 // document::XViewDataSupplier
getViewData()2092 uno::Reference< container::XIndexAccess > SAL_CALL OReportDefinition::getViewData(  ) throw (uno::RuntimeException)
2093 {
2094     ::osl::MutexGuard aGuard(m_aMutex);
2095     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2096     if ( !m_pImpl->m_xViewData.is() )
2097     {
2098         m_pImpl->m_xViewData.set(m_aProps->m_xContext->getServiceManager()->createInstanceWithContext(
2099 				::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.IndexedPropertyValues")),m_aProps->m_xContext ),uno::UNO_QUERY);
2100         //uno::Sequence< beans::PropertyValue > aProps;
2101         //m_pImpl->m_xViewData->insertByIndex(m_pImpl->m_xViewData->getCount(),uno::makeAny(aProps));
2102         uno::Reference< container::XIndexContainer > xContainer(m_pImpl->m_xViewData,uno::UNO_QUERY);
2103 	    ::std::vector< uno::Reference< frame::XController> >::iterator aIter = m_pImpl->m_aControllers.begin();
2104 	    ::std::vector< uno::Reference< frame::XController> >::iterator aEnd = m_pImpl->m_aControllers.end();
2105 	    for (;aIter != aEnd ; ++aIter)
2106 	    {
2107 		    if ( aIter->is() )
2108 		    {
2109 			    try
2110                 {
2111                     xContainer->insertByIndex(xContainer->getCount(),(*aIter)->getViewData());
2112                 }
2113                 catch(uno::Exception&)
2114                 {
2115                 }
2116             } // if ( aIter->is() )
2117         }
2118 
2119     }
2120     return m_pImpl->m_xViewData;
2121 }
2122 // -----------------------------------------------------------------------------
setViewData(const uno::Reference<container::XIndexAccess> & Data)2123 void SAL_CALL OReportDefinition::setViewData( const uno::Reference< container::XIndexAccess >& Data ) throw (uno::RuntimeException)
2124 {
2125     ::osl::MutexGuard aGuard(m_aMutex);
2126     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2127     m_pImpl->m_xViewData = Data;
2128 }
2129 // -----------------------------------------------------------------------------
getFunctions()2130 uno::Reference< report::XFunctions > SAL_CALL OReportDefinition::getFunctions() throw (uno::RuntimeException)
2131 {
2132     ::osl::MutexGuard aGuard(m_aMutex);
2133     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2134     return m_pImpl->m_xFunctions;
2135 }
2136 // -----------------------------------------------------------------------------
getUIConfigurationManager()2137 uno::Reference< ui::XUIConfigurationManager > SAL_CALL OReportDefinition::getUIConfigurationManager(  ) throw (uno::RuntimeException)
2138 {
2139     ::osl::MutexGuard aGuard(m_aMutex);
2140     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2141 
2142 	if ( !m_pImpl->m_xUIConfigurationManager.is() )
2143     {
2144         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),
2145             uno::UNO_QUERY);
2146 
2147         uno::Reference< ui::XUIConfigurationStorage > xUIConfigStorage( m_pImpl->m_xUIConfigurationManager, uno::UNO_QUERY );
2148         if ( xUIConfigStorage.is() )
2149         {
2150             uno::Reference< embed::XStorage > xConfigStorage;
2151             // initialize ui configuration manager with document substorage
2152             xUIConfigStorage->setStorage( xConfigStorage );
2153         }
2154     }
2155 
2156     return m_pImpl->m_xUIConfigurationManager;
2157 }
2158 // -----------------------------------------------------------------------------
getDocumentSubStorage(const::rtl::OUString & aStorageName,sal_Int32 nMode)2159 uno::Reference< embed::XStorage > SAL_CALL OReportDefinition::getDocumentSubStorage( const ::rtl::OUString& aStorageName, sal_Int32 nMode ) throw (uno::RuntimeException)
2160 {
2161     ::osl::MutexGuard aGuard(m_aMutex);
2162     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2163     return m_pImpl->m_xStorage->openStorageElement(aStorageName, nMode);
2164 }
2165 // -----------------------------------------------------------------------------
getDocumentSubStoragesNames()2166 uno::Sequence< ::rtl::OUString > SAL_CALL OReportDefinition::getDocumentSubStoragesNames(  ) throw (io::IOException, uno::RuntimeException)
2167 {
2168     ::osl::MutexGuard aGuard(m_aMutex);
2169     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2170     uno::Reference<container::XNameAccess> xNameAccess(m_pImpl->m_xStorage,uno::UNO_QUERY);
2171     return xNameAccess.is() ? xNameAccess->getElementNames() : uno::Sequence< ::rtl::OUString >();
2172 }
2173 // -----------------------------------------------------------------------------
getMimeType()2174 ::rtl::OUString SAL_CALL OReportDefinition::getMimeType() throw (uno::RuntimeException)
2175 {
2176 	::osl::MutexGuard aGuard(m_aMutex);
2177     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2178 	return m_pImpl->m_sMimeType;
2179 }
2180 // -----------------------------------------------------------------------------
setMimeType(const::rtl::OUString & _mimetype)2181 void SAL_CALL OReportDefinition::setMimeType( const ::rtl::OUString& _mimetype ) throw (lang::IllegalArgumentException, uno::RuntimeException)
2182 {
2183     ::osl::MutexGuard aGuard(m_aMutex);
2184     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2185     uno::Sequence< ::rtl::OUString > aList = getAvailableMimeTypes();
2186     const ::rtl::OUString* pEnd = aList.getConstArray()+aList.getLength();
2187     if ( ::std::find(aList.getConstArray(),pEnd,_mimetype) == pEnd )
2188         throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("getAvailableMimeTypes()"))
2189                         ,*this
2190                         ,1
2191                         ,m_aProps->m_xContext);
2192 	set(PROPERTY_MIMETYPE,_mimetype,m_pImpl->m_sMimeType);
2193 }
2194 // -----------------------------------------------------------------------------
getAvailableMimeTypes()2195 uno::Sequence< ::rtl::OUString > SAL_CALL OReportDefinition::getAvailableMimeTypes(  ) throw (lang::DisposedException, uno::Exception, uno::RuntimeException)
2196 {
2197     static uno::Sequence< ::rtl::OUString > s_aList;
2198     if ( !s_aList.hasElements() )
2199     {
2200         s_aList.realloc(2);
2201         s_aList[0] = MIMETYPE_OASIS_OPENDOCUMENT_TEXT;
2202         s_aList[1] = MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET;
2203     }
2204 
2205     return s_aList;
2206 }
2207 // -----------------------------------------------------------------------------
2208 // com::sun::star::XUnoTunnel
getSomething(const uno::Sequence<sal_Int8> & rId)2209 sal_Int64 SAL_CALL OReportDefinition::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw(uno::RuntimeException)
2210 {
2211     sal_Int64 nRet = 0;
2212 	if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
2213 		nRet = reinterpret_cast<sal_Int64>(this);
2214     else
2215     {
2216         uno::Reference< lang::XUnoTunnel> xUnoTunnel(m_pImpl->m_xNumberFormatsSupplier,uno::UNO_QUERY);
2217         if ( xUnoTunnel.is() )
2218             nRet = xUnoTunnel->getSomething(rId);
2219     }
2220     if ( !nRet )
2221     {
2222         uno::Reference< lang::XUnoTunnel> xTunnel;
2223         ::comphelper::query_aggregation(m_aProps->m_xProxy,xTunnel);
2224         if ( xTunnel.is() )
2225 	        nRet = xTunnel->getSomething(rId);
2226     }
2227 
2228 	return nRet;
2229 }
2230 // -----------------------------------------------------------------------------
getImplementationId()2231 uno::Sequence< sal_Int8 > SAL_CALL OReportDefinition::getImplementationId(  ) throw (uno::RuntimeException)
2232 {
2233     return OReportDefinition::getUnoTunnelImplementationId();
2234 }
2235 //--------------------------------------------------------------------------
getUnoTunnelImplementationId()2236 uno::Sequence< sal_Int8 > OReportDefinition::getUnoTunnelImplementationId()
2237 {
2238 	static ::cppu::OImplementationId * pId = 0;
2239 	if (! pId)
2240 	{
2241 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
2242 		if (! pId)
2243 		{
2244 			static ::cppu::OImplementationId aId;
2245 			pId = &aId;
2246 		}
2247 	}
2248 	return pId->getImplementationId();
2249 }
2250 // -----------------------------------------------------------------------------
getContext()2251 uno::Reference< uno::XComponentContext > OReportDefinition::getContext()
2252 {
2253     ::osl::MutexGuard aGuard(m_aMutex);
2254     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2255     return m_aProps->m_xContext;
2256 }
2257 // -----------------------------------------------------------------------------
getSdrModel() const2258 ::boost::shared_ptr<rptui::OReportModel> OReportDefinition::getSdrModel() const
2259 {
2260     return m_pImpl->m_pReportModel;
2261 }
2262 // -----------------------------------------------------------------------------
getSdrModel(const uno::Reference<report::XReportDefinition> & _xReportDefinition)2263 ::boost::shared_ptr<rptui::OReportModel> OReportDefinition::getSdrModel(const uno::Reference< report::XReportDefinition >& _xReportDefinition)
2264 {
2265     ::boost::shared_ptr<rptui::OReportModel> pReportModel;
2266     uno::Reference< lang::XUnoTunnel > xUT( _xReportDefinition, uno::UNO_QUERY );
2267 	if( xUT.is() )
2268 		pReportModel = reinterpret_cast<OReportDefinition*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( OReportDefinition::getUnoTunnelImplementationId())))->getSdrModel();
2269     return pReportModel;
2270 }
2271 // -----------------------------------------------------------------------------
createInstanceWithArguments(const::rtl::OUString & aServiceSpecifier,const uno::Sequence<uno::Any> & _aArgs)2272 uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstanceWithArguments( const ::rtl::OUString& aServiceSpecifier, const uno::Sequence< uno::Any >& _aArgs)
2273 	throw( uno::Exception, uno::RuntimeException )
2274 {
2275     ::osl::MutexGuard aGuard(m_aMutex);
2276     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2277 
2278     uno::Reference< uno::XInterface > xRet;
2279     if ( aServiceSpecifier.indexOf( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver"))) == 0 )
2280     {
2281         uno::Reference< embed::XStorage > xStorage;
2282         const uno::Any* pIter = _aArgs.getConstArray();
2283         const uno::Any* pEnd  = pIter + _aArgs.getLength();
2284         for(;pIter != pEnd ;++pIter)
2285         {
2286             beans::NamedValue aValue;
2287             *pIter >>= aValue;
2288             if( aValue.Name.equalsAscii( "Storage" ) )
2289 			    aValue.Value >>= xStorage;
2290         } // for(;pIter != pEnd ;++pIter)
2291         m_pImpl->m_pObjectContainer->SwitchPersistence(xStorage);
2292         xRet = static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( xStorage,*this, EMBEDDEDOBJECTHELPER_MODE_READ ));
2293     }
2294     return xRet;
2295 }
2296 // -----------------------------------------------------------------------------
createInstance(const::rtl::OUString & aServiceSpecifier)2297 uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstance( const ::rtl::OUString& aServiceSpecifier ) throw(uno::Exception, uno::RuntimeException)
2298 {
2299     ::osl::MutexGuard aGuard(m_aMutex);
2300     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2301     uno::Reference< drawing::XShape > xShape;
2302     if ( aServiceSpecifier.indexOf( ::rtl::OUString::createFromAscii("com.sun.star.report.") ) == 0 )
2303     {
2304         if ( aServiceSpecifier == SERVICE_SHAPE )
2305             xShape.set(SvxUnoDrawMSFactory::createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CustomShape")) ),uno::UNO_QUERY_THROW);
2306         else if (   aServiceSpecifier == SERVICE_FORMATTEDFIELD
2307             ||      aServiceSpecifier == SERVICE_FIXEDTEXT
2308             ||      aServiceSpecifier == SERVICE_FIXEDLINE
2309             ||      aServiceSpecifier == SERVICE_IMAGECONTROL )
2310             xShape.set(SvxUnoDrawMSFactory::createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ControlShape")) ),uno::UNO_QUERY_THROW);
2311         else
2312             xShape.set(SvxUnoDrawMSFactory::createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape")) ),uno::UNO_QUERY_THROW);
2313     }
2314     else if ( aServiceSpecifier.indexOf( ::rtl::OUString::createFromAscii("com.sun.star.form.component.") ) == 0 )
2315 	{
2316         xShape.set(m_aProps->m_xContext->getServiceManager()->createInstanceWithContext(aServiceSpecifier,m_aProps->m_xContext),uno::UNO_QUERY);
2317 	}
2318     else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.style.PageStyle") ) == 0 ||
2319               aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.style.FrameStyle") ) == 0 ||
2320               aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.style.GraphicStyle") ) == 0
2321               )
2322     {
2323         uno::Reference< style::XStyle> xStyle = new OStyle();
2324         xStyle->setName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Default")));
2325         uno::Reference<beans::XPropertySet> xProp(xStyle,uno::UNO_QUERY);
2326         ::rtl::OUString sTray;
2327         xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrinterPaperTray")))>>= sTray;
2328 
2329         return xStyle.get();
2330     }
2331     else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.Settings") ) == 0 )
2332     {
2333         uno::Reference<beans::XPropertySet> xProp = new OStyle();
2334 
2335         return xProp.get();
2336     }
2337     else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Defaults") ) == 0 )
2338     {
2339         uno::Reference<beans::XPropertySet> xProp = new OStyle();
2340         return xProp.get();
2341     }
2342     else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) == 0 )
2343     {
2344         if ( !m_pImpl->m_xGradientTable.is() )
2345             m_pImpl->m_xGradientTable.set(SvxUnoGradientTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
2346             //comphelper::NameContainer_createInstance( ::getCppuType( (const awt::Gradient*) 0 ) ).get();
2347         return m_pImpl->m_xGradientTable;
2348     }
2349     else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) == 0 )
2350     {
2351         if ( !m_pImpl->m_xHatchTable.is() )
2352             m_pImpl->m_xHatchTable.set(SvxUnoHatchTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
2353             //comphelper::NameContainer_createInstance( ::getCppuType( (const drawing::Hatch*) 0 ) ).get();
2354         return m_pImpl->m_xHatchTable;
2355     }
2356     else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) == 0 )
2357     {
2358         if ( !m_pImpl->m_xBitmapTable.is() )
2359             m_pImpl->m_xBitmapTable.set(SvxUnoBitmapTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
2360             //comphelper::NameContainer_createInstance( ::getCppuType( (const ::rtl::OUString*) 0 ) ).get();
2361         return m_pImpl->m_xBitmapTable;
2362     }
2363     else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) == 0 )
2364     {
2365         if ( !m_pImpl->m_xTransparencyGradientTable.is() )
2366             m_pImpl->m_xTransparencyGradientTable.set(SvxUnoTransGradientTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
2367             //comphelper::NameContainer_createInstance( ::getCppuType( (const awt::Gradient*) 0 ) ).get();
2368         return m_pImpl->m_xTransparencyGradientTable;
2369     }
2370     else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) == 0 )
2371     {
2372         if ( !m_pImpl->m_xDashTable.is() )
2373             m_pImpl->m_xDashTable.set(SvxUnoDashTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
2374             //comphelper::NameContainer_createInstance( ::getCppuType( (const drawing::LineDash*) 0 ) ).get();
2375         return m_pImpl->m_xDashTable;
2376     }
2377     else if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) )
2378 	{
2379 		if( !m_pImpl->m_xMarkerTable.is() )
2380 			m_pImpl->m_xMarkerTable.set(SvxUnoMarkerTable_createInstance( m_pImpl->m_pReportModel.get() ),uno::UNO_QUERY);
2381 		return m_pImpl->m_xMarkerTable;
2382 	}
2383     else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver")) == 0 )
2384         return static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( m_pImpl->m_xStorage,*this, EMBEDDEDOBJECTHELPER_MODE_READ ));
2385     else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ExportEmbeddedObjectResolver")) == 0 )
2386         return static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( m_pImpl->m_xStorage,*this, EMBEDDEDOBJECTHELPER_MODE_WRITE ));
2387     else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportGraphicObjectResolver")) == 0 )
2388     {
2389         SvXMLGraphicHelper* pGraphicHelper = SvXMLGraphicHelper::Create(m_pImpl->m_xStorage,GRAPHICHELPER_MODE_WRITE);
2390         uno::Reference< uno::XInterface> xRet(static_cast< ::cppu::OWeakObject* >(pGraphicHelper));
2391         pGraphicHelper->release();
2392         return xRet;
2393     }
2394     else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ExportGraphicObjectResolver")) == 0 )
2395     {
2396         SvXMLGraphicHelper* pGraphicHelper = SvXMLGraphicHelper::Create(m_pImpl->m_xStorage,GRAPHICHELPER_MODE_WRITE);
2397         uno::Reference< uno::XInterface> xRet(static_cast< ::cppu::OWeakObject* >(pGraphicHelper));
2398         pGraphicHelper->release();
2399         return xRet;
2400     }
2401     else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.data.DataProvider")) == 0 )
2402     {
2403         uno::Reference<chart2::data::XDatabaseDataProvider> xDataProvider(chart2::data::DatabaseDataProvider::createWithConnection( m_aProps->m_xContext, m_pImpl->m_xActiveConnection ));
2404         xDataProvider->setRowLimit(10);
2405         uno::Reference< container::XChild > xChild(xDataProvider,uno::UNO_QUERY);
2406         if ( xChild.is() )
2407 	        xChild->setParent(*this);
2408         return uno::Reference< uno::XInterface >(xDataProvider,uno::UNO_QUERY);
2409     }
2410 	else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.xml.NamespaceMap")) == 0 )
2411 	{
2412 		if ( !m_pImpl->m_xXMLNamespaceMap.is() )
2413 			m_pImpl->m_xXMLNamespaceMap = comphelper::NameContainer_createInstance( ::getCppuType( (const ::rtl::OUString*) 0 ) ).get();
2414 		return m_pImpl->m_xXMLNamespaceMap;
2415 	}
2416     else
2417         xShape.set(SvxUnoDrawMSFactory::createInstance( aServiceSpecifier ),uno::UNO_QUERY_THROW);
2418 
2419     return m_pImpl->m_pReportModel->createShape(aServiceSpecifier,xShape);
2420 }
2421 //-----------------------------------------------------------------------------
getAvailableServiceNames(void)2422 uno::Sequence< ::rtl::OUString > SAL_CALL OReportDefinition::getAvailableServiceNames(void) throw( uno::RuntimeException )
2423 {
2424 	static const ::rtl::OUString aSvxComponentServiceNameList[] =
2425 	{
2426         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText")),
2427         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.DatabaseImageControl")),
2428         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.PageStyle")),
2429         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.GraphicStyle")),
2430         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.FrameStyle")),
2431         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults")),
2432         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver")),
2433         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportEmbeddedObjectResolver")),
2434         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportGraphicObjectResolver")),
2435         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportGraphicObjectResolver")),
2436         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DataProvider")),
2437 		::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.NamespaceMap")),
2438 		::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.Settings")),
2439         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable")),
2440         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable")),
2441         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable")),
2442         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable")),
2443         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable")),
2444         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable"))
2445     };
2446 
2447 	static const sal_uInt16 nSvxComponentServiceNameListCount = sizeof(aSvxComponentServiceNameList) / sizeof ( aSvxComponentServiceNameList[0] );
2448 
2449 	uno::Sequence< ::rtl::OUString > aSeq( nSvxComponentServiceNameListCount );
2450 	::rtl::OUString* pStrings = aSeq.getArray();
2451 	for( sal_uInt16 nIdx = 0; nIdx < nSvxComponentServiceNameListCount; nIdx++ )
2452 		pStrings[nIdx] = aSvxComponentServiceNameList[nIdx];
2453 
2454 	uno::Sequence< ::rtl::OUString > aParentSeq( SvxUnoDrawMSFactory::getAvailableServiceNames() );
2455 	return concatServiceNames( aParentSeq, aSeq );
2456 }
2457 // -----------------------------------------------------------------------------
2458 // XShape
getPosition()2459 awt::Point SAL_CALL OReportDefinition::getPosition(  ) throw (uno::RuntimeException)
2460 {
2461 	::osl::MutexGuard aGuard(m_aMutex);
2462     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2463     if ( m_aProps->m_xShape.is() )
2464         return m_aProps->m_xShape->getPosition();
2465 	return awt::Point(m_aProps->m_nPosX,m_aProps->m_nPosY);
2466 }
2467 // -----------------------------------------------------------------------------
setPosition(const awt::Point & aPosition)2468 void SAL_CALL OReportDefinition::setPosition( const awt::Point& aPosition ) throw (uno::RuntimeException)
2469 {
2470     ::osl::MutexGuard aGuard(m_aMutex);
2471     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2472     if ( m_aProps->m_xShape.is() )
2473         m_aProps->m_xShape->setPosition(aPosition);
2474     set(PROPERTY_POSITIONX,aPosition.X,m_aProps->m_nPosX);
2475     set(PROPERTY_POSITIONY,aPosition.Y,m_aProps->m_nPosY);
2476 }
2477 // -----------------------------------------------------------------------------
getSize()2478 awt::Size SAL_CALL OReportDefinition::getSize(  ) throw (uno::RuntimeException)
2479 {
2480 	::osl::MutexGuard aGuard(m_aMutex);
2481     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2482 	if ( m_aProps->m_xShape.is() )
2483         return m_aProps->m_xShape->getSize();
2484 	return awt::Size(m_aProps->m_nWidth,m_aProps->m_nHeight);
2485 }
2486 // -----------------------------------------------------------------------------
setSize(const awt::Size & aSize)2487 void SAL_CALL OReportDefinition::setSize( const awt::Size& aSize ) throw (beans::PropertyVetoException, uno::RuntimeException)
2488 {
2489     ::osl::MutexGuard aGuard(m_aMutex);
2490     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2491     if ( m_aProps->m_xShape.is() )
2492         m_aProps->m_xShape->setSize(aSize);
2493     set(PROPERTY_WIDTH,aSize.Width,m_aProps->m_nWidth);
2494     set(PROPERTY_HEIGHT,aSize.Height,m_aProps->m_nHeight);
2495 }
2496 // -----------------------------------------------------------------------------
2497 
2498 // XShapeDescriptor
getShapeType()2499 ::rtl::OUString SAL_CALL OReportDefinition::getShapeType(  ) throw (uno::RuntimeException)
2500 {
2501 	return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape"));
2502 }
2503 // -----------------------------------------------------------------------------
2504 typedef ::cppu::WeakImplHelper2< container::XNameContainer,
2505                              container::XIndexAccess
2506                             > TStylesBASE;
2507 class OStylesHelper : public ::cppu::BaseMutex, public TStylesBASE
2508 {
2509     typedef ::std::map< ::rtl::OUString, uno::Any  , ::comphelper::UStringMixLess> TStyleElements;
2510     TStyleElements                                  m_aElements;
2511     ::std::vector<TStyleElements::iterator>         m_aElementsPos;
2512     uno::Type                                       m_aType;
2513 
2514     OStylesHelper(const OStylesHelper&);
2515     void operator =(const OStylesHelper&);
2516 protected:
~OStylesHelper()2517     virtual ~OStylesHelper(){}
2518 public:
2519     OStylesHelper(const uno::Type _aType = ::getCppuType(static_cast< uno::Reference< container::XElementAccess >* >(NULL)));
2520 
2521     // XNameContainer
2522     virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::ElementExistException,lang::WrappedTargetException, uno::RuntimeException);
2523     virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) throw(container::NoSuchElementException, lang::WrappedTargetException,uno::RuntimeException);
2524 
2525 	// XNameReplace
2526     virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::NoSuchElementException,lang::WrappedTargetException, uno::RuntimeException);
2527 
2528     // container::XElementAccess
2529     virtual uno::Type SAL_CALL getElementType(  ) throw(uno::RuntimeException);
2530 	virtual sal_Bool SAL_CALL hasElements(  ) throw(uno::RuntimeException);
2531     // container::XIndexAccess
2532     virtual sal_Int32 SAL_CALL getCount(  ) throw(uno::RuntimeException);
2533     virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
2534 
2535     // container::XNameAccess
2536     virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
2537     virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw(uno::RuntimeException);
2538     virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(uno::RuntimeException);
2539 };
2540 
OStylesHelper(const uno::Type _aType)2541 OStylesHelper::OStylesHelper(const uno::Type _aType)
2542 : cppu::BaseMutex()
2543 ,m_aType(_aType)
2544 {
2545 }
2546 // -----------------------------------------------------------------------------;
2547 // container::XElementAccess
getElementType()2548 uno::Type SAL_CALL OStylesHelper::getElementType(  ) throw(uno::RuntimeException)
2549 {
2550     return m_aType;
2551 }
2552 // -----------------------------------------------------------------------------
hasElements()2553 sal_Bool SAL_CALL OStylesHelper::hasElements(  ) throw(uno::RuntimeException)
2554 {
2555     ::osl::MutexGuard aGuard(m_aMutex);
2556     return !m_aElementsPos.empty();
2557 }
2558 // -----------------------------------------------------------------------------
2559 // container::XIndexAccess
getCount()2560 sal_Int32 SAL_CALL OStylesHelper::getCount(  ) throw(uno::RuntimeException)
2561 {
2562     ::osl::MutexGuard aGuard(m_aMutex);
2563     return m_aElementsPos.size();
2564 }
2565 // -----------------------------------------------------------------------------
getByIndex(sal_Int32 Index)2566 uno::Any SAL_CALL OStylesHelper::getByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
2567 {
2568     ::osl::MutexGuard aGuard(m_aMutex);
2569     if ( Index < 0 || Index >= static_cast<sal_Int32>(m_aElementsPos.size()) )
2570         throw lang::IndexOutOfBoundsException();
2571     return uno::makeAny(m_aElementsPos[Index]->second);
2572 }
2573 // -----------------------------------------------------------------------------
2574 // container::XNameAccess
getByName(const::rtl::OUString & aName)2575 uno::Any SAL_CALL OStylesHelper::getByName( const ::rtl::OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
2576 {
2577     ::osl::MutexGuard aGuard(m_aMutex);
2578     TStyleElements::iterator aFind = m_aElements.find(aName);
2579     if ( aFind == m_aElements.end() )
2580         throw container::NoSuchElementException();
2581     return uno::makeAny(aFind->second);
2582 }
2583 // -----------------------------------------------------------------------------
getElementNames()2584 uno::Sequence< ::rtl::OUString > SAL_CALL OStylesHelper::getElementNames(  ) throw(uno::RuntimeException)
2585 {
2586     ::osl::MutexGuard aGuard(m_aMutex);
2587     uno::Sequence< ::rtl::OUString > aNameList(m_aElementsPos.size());
2588 
2589     ::rtl::OUString* pStringArray = aNameList.getArray();
2590     ::std::vector<TStyleElements::iterator>::const_iterator aEnd = m_aElementsPos.end();
2591     for(::std::vector<TStyleElements::iterator>::const_iterator aIter = m_aElementsPos.begin();         aIter != aEnd;++aIter,++pStringArray)
2592         *pStringArray = (*aIter)->first;
2593 
2594     return aNameList;
2595 }
2596 // -----------------------------------------------------------------------------
hasByName(const::rtl::OUString & aName)2597 sal_Bool SAL_CALL OStylesHelper::hasByName( const ::rtl::OUString& aName ) throw(uno::RuntimeException)
2598 {
2599     ::osl::MutexGuard aGuard(m_aMutex);
2600     return m_aElements.find(aName) != m_aElements.end();
2601 }
2602 // -----------------------------------------------------------------------------
2603 // XNameContainer
insertByName(const::rtl::OUString & aName,const uno::Any & aElement)2604 void SAL_CALL OStylesHelper::insertByName( const ::rtl::OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::ElementExistException,lang::WrappedTargetException, uno::RuntimeException)
2605 {
2606     ::osl::MutexGuard aGuard(m_aMutex);
2607     if ( m_aElements.find(aName) != m_aElements.end() )
2608         throw container::ElementExistException();
2609 
2610     if ( !aElement.isExtractableTo(m_aType) )
2611         throw lang::IllegalArgumentException();
2612 
2613     m_aElementsPos.push_back(m_aElements.insert(TStyleElements::value_type(aName,aElement)).first);
2614 }
2615 // -----------------------------------------------------------------------------
removeByName(const::rtl::OUString & aName)2616 void SAL_CALL OStylesHelper::removeByName( const ::rtl::OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException,uno::RuntimeException)
2617 {
2618     ::osl::MutexGuard aGuard(m_aMutex);
2619     TStyleElements::iterator aFind = m_aElements.find(aName);
2620     if ( aFind != m_aElements.end() )
2621         throw container::NoSuchElementException();
2622     m_aElementsPos.erase(::std::find(m_aElementsPos.begin(),m_aElementsPos.end(),aFind));
2623     m_aElements.erase(aFind);
2624 }
2625 // -----------------------------------------------------------------------------
2626 // XNameReplace
replaceByName(const::rtl::OUString & aName,const uno::Any & aElement)2627 void SAL_CALL OStylesHelper::replaceByName( const ::rtl::OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::NoSuchElementException,lang::WrappedTargetException, uno::RuntimeException)
2628 {
2629     ::osl::MutexGuard aGuard(m_aMutex);
2630     TStyleElements::iterator aFind = m_aElements.find(aName);
2631     if ( aFind != m_aElements.end() )
2632         throw container::NoSuchElementException();
2633     if ( !aElement.isExtractableTo(m_aType) )
2634         throw lang::IllegalArgumentException();
2635     aFind->second = aElement;
2636 }
2637 // -----------------------------------------------------------------------------
getStyleFamilies()2638 uno::Reference< container::XNameAccess > SAL_CALL OReportDefinition::getStyleFamilies(  ) throw (uno::RuntimeException)
2639 {
2640     ::osl::MutexGuard aGuard(m_aMutex);
2641     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2642     if ( !m_pImpl->m_xStyles.is() )
2643     {
2644         m_pImpl->m_xStyles = new OStylesHelper();
2645         uno::Reference< container::XNameContainer> xStyles(m_pImpl->m_xStyles,uno::UNO_QUERY);
2646 
2647         uno::Reference< container::XNameContainer> xPageStyles = new OStylesHelper(::getCppuType(static_cast< uno::Reference<style::XStyle>* >(NULL)));
2648         xStyles->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PageStyles")),uno::makeAny(xPageStyles));
2649         uno::Reference< style::XStyle> xPageStyle(createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.PageStyle"))),uno::UNO_QUERY);
2650         xPageStyles->insertByName(xPageStyle->getName(),uno::makeAny(xPageStyle));
2651 
2652         uno::Reference< container::XNameContainer> xFrameStyles = new OStylesHelper(::getCppuType(static_cast< uno::Reference<style::XStyle>* >(NULL)));
2653         xStyles->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameStyles")),uno::makeAny(xFrameStyles));
2654         uno::Reference< style::XStyle> xFrameStyle(createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.FrameStyle"))),uno::UNO_QUERY);
2655         xFrameStyles->insertByName(xFrameStyle->getName(),uno::makeAny(xFrameStyle));
2656 
2657         uno::Reference< container::XNameContainer> xGraphicStyles = new OStylesHelper(::getCppuType(static_cast< uno::Reference<style::XStyle>* >(NULL)));
2658         xStyles->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("graphics")),uno::makeAny(xGraphicStyles));
2659         uno::Reference< style::XStyle> xGraphicStyle(createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.GraphicStyle"))),uno::UNO_QUERY);
2660         xGraphicStyles->insertByName(xGraphicStyle->getName(),uno::makeAny(xGraphicStyle));
2661     }
2662     return m_pImpl->m_xStyles;
2663 }
getIdentifier()2664 ::rtl::OUString SAL_CALL  OReportDefinition::getIdentifier(  ) throw (uno::RuntimeException)
2665 {
2666     ::osl::MutexGuard aGuard(m_aMutex);
2667     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2668 	return m_pImpl->m_sIdentifier;
2669 }
2670 // -----------------------------------------------------------------------------
setIdentifier(const::rtl::OUString & Identifier)2671 void SAL_CALL OReportDefinition::setIdentifier( const ::rtl::OUString& Identifier ) throw (uno::RuntimeException)
2672 {
2673     ::osl::MutexGuard aGuard(m_aMutex);
2674     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2675 	m_pImpl->m_sIdentifier = Identifier;
2676 }
2677 // -----------------------------------------------------------------------------
2678 // XNumberFormatsSupplier
getNumberFormatSettings()2679 uno::Reference< beans::XPropertySet > SAL_CALL OReportDefinition::getNumberFormatSettings(  ) throw (uno::RuntimeException)
2680 {
2681     ::osl::MutexGuard aGuard(m_aMutex);
2682     if ( m_pImpl->m_xNumberFormatsSupplier.is() )
2683         return m_pImpl->m_xNumberFormatsSupplier->getNumberFormatSettings();
2684     return uno::Reference< beans::XPropertySet >();
2685 }
2686 // -----------------------------------------------------------------------------
getNumberFormats()2687 uno::Reference< util::XNumberFormats > SAL_CALL OReportDefinition::getNumberFormats(  ) throw (uno::RuntimeException)
2688 {
2689     ::osl::MutexGuard aGuard(m_aMutex);
2690     if ( m_pImpl->m_xNumberFormatsSupplier.is() )
2691         return m_pImpl->m_xNumberFormatsSupplier->getNumberFormats();
2692     return uno::Reference< util::XNumberFormats >();
2693 }
2694 // -----------------------------------------------------------------------------
getEmbeddedObjectContainer() const2695 ::comphelper::EmbeddedObjectContainer& OReportDefinition::getEmbeddedObjectContainer() const
2696 {
2697     return *m_pImpl->m_pObjectContainer;
2698 }
2699 // -----------------------------------------------------------------------------
getStorage() const2700 uno::Reference< embed::XStorage > OReportDefinition::getStorage() const
2701 {
2702     return m_pImpl->m_xStorage;
2703 }
2704 // -----------------------------------------------------------------------------
getInteractionHandler() const2705 uno::Reference< task::XInteractionHandler > OReportDefinition::getInteractionHandler() const
2706 {
2707     uno::Reference< task::XInteractionHandler > xRet( m_aProps->m_xContext->getServiceManager()->createInstanceWithContext(
2708                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.InteractionHandler")) ,m_aProps->m_xContext),uno::UNO_QUERY);
2709     return xRet;
2710 }
2711 // -----------------------------------------------------------------------------
getActiveConnection()2712 uno::Reference< sdbc::XConnection > SAL_CALL OReportDefinition::getActiveConnection() throw (uno::RuntimeException)
2713 {
2714     ::osl::MutexGuard aGuard(m_aMutex);
2715     return m_pImpl->m_xActiveConnection;
2716 }
2717 // -----------------------------------------------------------------------------
setActiveConnection(const uno::Reference<sdbc::XConnection> & _activeconnection)2718 void SAL_CALL OReportDefinition::setActiveConnection( const uno::Reference< sdbc::XConnection >& _activeconnection ) throw (lang::IllegalArgumentException, uno::RuntimeException)
2719 {
2720     if ( !_activeconnection.is() )
2721         throw lang::IllegalArgumentException();
2722     set(PROPERTY_ACTIVECONNECTION,_activeconnection,m_pImpl->m_xActiveConnection);
2723 }
2724 // -----------------------------------------------------------------------------
getDataSourceName()2725 ::rtl::OUString SAL_CALL OReportDefinition::getDataSourceName() throw (uno::RuntimeException)
2726 {
2727     osl::MutexGuard g(m_aMutex);
2728     return m_pImpl->m_sDataSourceName;
2729 }
2730 // -----------------------------------------------------------------------------
setDataSourceName(const::rtl::OUString & the_value)2731 void SAL_CALL OReportDefinition::setDataSourceName(const ::rtl::OUString& the_value) throw (uno::RuntimeException)
2732 {
2733     set(PROPERTY_DATASOURCENAME,the_value,m_pImpl->m_sDataSourceName);
2734 }
2735 // -----------------------------------------------------------------------------
isEnableSetModified() const2736 bool OReportDefinition::isEnableSetModified() const
2737 {
2738     return true;
2739 }
impl_getTitleHelper_throw()2740 uno::Reference< frame::XTitle > OReportDefinition::impl_getTitleHelper_throw()
2741 {
2742     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2743 
2744 	::osl::MutexGuard aGuard(m_aMutex);
2745     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2746 
2747     if ( ! m_pImpl->m_xTitleHelper.is ())
2748     {
2749         uno::Reference< frame::XUntitledNumbers >    xDesktop(m_aProps->m_xContext->getServiceManager()->createInstanceWithContext(
2750                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop")) ,m_aProps->m_xContext),uno::UNO_QUERY_THROW);
2751         uno::Reference< frame::XModel >              xThis   (static_cast< frame::XModel* >(this), uno::UNO_QUERY_THROW);
2752 
2753         ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(uno::Reference< lang::XMultiServiceFactory >(m_aProps->m_xContext->getServiceManager(),uno::UNO_QUERY));
2754         m_pImpl->m_xTitleHelper = uno::Reference< frame::XTitle >(static_cast< ::cppu::OWeakObject* >(pHelper), uno::UNO_QUERY_THROW);
2755         pHelper->setOwner                   (xThis   );
2756         pHelper->connectWithUntitledNumbers (xDesktop);
2757     }
2758 
2759     return m_pImpl->m_xTitleHelper;
2760 }
2761 // -----------------------------------------------------------------------------
impl_getUntitledHelper_throw()2762 uno::Reference< frame::XUntitledNumbers > OReportDefinition::impl_getUntitledHelper_throw()
2763 {
2764     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2765 
2766 	::osl::MutexGuard aGuard(m_aMutex);
2767     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2768 
2769     if ( ! m_pImpl->m_xNumberedControllers.is ())
2770     {
2771         uno::Reference< frame::XModel > xThis   (static_cast< frame::XModel* >(this), uno::UNO_QUERY_THROW);
2772         ::comphelper::NumberedCollection*         pHelper = new ::comphelper::NumberedCollection();
2773         m_pImpl->m_xNumberedControllers = uno::Reference< frame::XUntitledNumbers >(static_cast< ::cppu::OWeakObject* >(pHelper), uno::UNO_QUERY_THROW);
2774 
2775         pHelper->setOwner          (xThis);
2776         pHelper->setUntitledPrefix (::rtl::OUString::createFromAscii(" : "));
2777     }
2778 
2779     return m_pImpl->m_xNumberedControllers;
2780 }
2781 // -----------------------------------------------------------------------------
2782 // css.frame.XTitle
getTitle()2783 ::rtl::OUString SAL_CALL OReportDefinition::getTitle()
2784     throw (uno::RuntimeException)
2785 {
2786     // SYNCHRONIZED ->
2787     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2788 
2789 	::osl::MutexGuard aGuard(m_aMutex);
2790     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2791 
2792     return impl_getTitleHelper_throw()->getTitle ();
2793 }
2794 // -----------------------------------------------------------------------------
2795 // css.frame.XTitle
setTitle(const::rtl::OUString & sTitle)2796 void SAL_CALL OReportDefinition::setTitle( const ::rtl::OUString& sTitle )
2797     throw (uno::RuntimeException)
2798 {
2799     // SYNCHRONIZED ->
2800     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2801 
2802 	::osl::MutexGuard aGuard(m_aMutex);
2803     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2804 
2805     impl_getTitleHelper_throw()->setTitle (sTitle);
2806 }
2807 // -----------------------------------------------------------------------------
2808 // css.frame.XTitleChangeBroadcaster
addTitleChangeListener(const uno::Reference<frame::XTitleChangeListener> & xListener)2809 void SAL_CALL OReportDefinition::addTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener )
2810     throw (uno::RuntimeException)
2811 {
2812     // SYNCHRONIZED ->
2813     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2814 
2815 	::osl::MutexGuard aGuard(m_aMutex);
2816     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2817 
2818     uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY);
2819     if (xBroadcaster.is ())
2820         xBroadcaster->addTitleChangeListener (xListener);
2821 }
2822 // -----------------------------------------------------------------------------
2823 // css.frame.XTitleChangeBroadcaster
removeTitleChangeListener(const uno::Reference<frame::XTitleChangeListener> & xListener)2824 void SAL_CALL OReportDefinition::removeTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener )
2825     throw (uno::RuntimeException)
2826 {
2827     // SYNCHRONIZED ->
2828     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2829 
2830 	::osl::MutexGuard aGuard(m_aMutex);
2831     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2832 
2833     uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY);
2834     if (xBroadcaster.is ())
2835         xBroadcaster->removeTitleChangeListener (xListener);
2836 }
2837 // -----------------------------------------------------------------------------
2838 // css.frame.XUntitledNumbers
leaseNumber(const uno::Reference<uno::XInterface> & xComponent)2839 ::sal_Int32 SAL_CALL OReportDefinition::leaseNumber( const uno::Reference< uno::XInterface >& xComponent )
2840     throw (lang::IllegalArgumentException,
2841            uno::RuntimeException         )
2842 {
2843 	// object already disposed?
2844     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2845 	::osl::MutexGuard aGuard(m_aMutex);
2846     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2847 
2848     return impl_getUntitledHelper_throw()->leaseNumber (xComponent);
2849 }
2850 // -----------------------------------------------------------------------------
2851 // css.frame.XUntitledNumbers
releaseNumber(::sal_Int32 nNumber)2852 void SAL_CALL OReportDefinition::releaseNumber( ::sal_Int32 nNumber )
2853     throw (lang::IllegalArgumentException,
2854            uno::RuntimeException         )
2855 {
2856 	// object already disposed?
2857     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2858     ::osl::MutexGuard aGuard(m_aMutex);
2859     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2860 
2861     impl_getUntitledHelper_throw()->releaseNumber (nNumber);
2862 }
2863 // -----------------------------------------------------------------------------
2864 // css.frame.XUntitledNumbers
releaseNumberForComponent(const uno::Reference<uno::XInterface> & xComponent)2865 void SAL_CALL OReportDefinition::releaseNumberForComponent( const uno::Reference< uno::XInterface >& xComponent )
2866     throw (lang::IllegalArgumentException,
2867            uno::RuntimeException         )
2868 {
2869 	// object already disposed?
2870     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2871     ::osl::MutexGuard aGuard(m_aMutex);
2872     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2873 
2874     impl_getUntitledHelper_throw()->releaseNumberForComponent (xComponent);
2875 }
2876 // -----------------------------------------------------------------------------
2877 // css.frame.XUntitledNumbers
getUntitledPrefix()2878 ::rtl::OUString SAL_CALL OReportDefinition::getUntitledPrefix()
2879     throw (uno::RuntimeException)
2880 {
2881 	// object already disposed?
2882     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2883     ::osl::MutexGuard aGuard(m_aMutex);
2884     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2885 
2886     return impl_getUntitledHelper_throw()->getUntitledPrefix ();
2887 }
2888 // -----------------------------------------------------------------------------
getDocumentProperties()2889 uno::Reference< document::XDocumentProperties > SAL_CALL OReportDefinition::getDocumentProperties(  ) throw (uno::RuntimeException)
2890 {
2891     ::osl::MutexGuard aGuard(m_aMutex);
2892     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
2893     if ( !m_pImpl->m_xDocumentProperties.is() )
2894     {
2895         uno::Reference< lang::XInitialization > xDocProps(
2896             m_aProps->m_xContext->getServiceManager()->createInstanceWithContext(
2897                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.DocumentProperties")) ,m_aProps->m_xContext),
2898                 uno::UNO_QUERY_THROW);
2899         m_pImpl->m_xDocumentProperties.set(xDocProps, uno::UNO_QUERY_THROW);
2900     }
2901     return m_pImpl->m_xDocumentProperties;
2902 }
2903 // -----------------------------------------------------------------------------
getContext() const2904 uno::Reference< uno::XComponentContext > OReportDefinition::getContext() const
2905 {
2906     return m_aProps->m_xContext;
2907 }
2908 // -----------------------------------------------------------------------------
getTransferData(const datatransfer::DataFlavor & aFlavor)2909 uno::Any SAL_CALL OReportDefinition::getTransferData( const datatransfer::DataFlavor& aFlavor ) throw (datatransfer::UnsupportedFlavorException, io::IOException, uno::RuntimeException)
2910 {
2911     uno::Any aResult;
2912     if( isDataFlavorSupported( aFlavor ) )
2913     {
2914         try
2915         {
2916             aResult <<= getPreferredVisualRepresentation(0).Data;
2917         }
2918         catch( uno::Exception & ex )
2919         {
2920             DBG_UNHANDLED_EXCEPTION();
2921             (void)ex;
2922         }
2923     }
2924     else
2925     {
2926         throw datatransfer::UnsupportedFlavorException(aFlavor.MimeType, static_cast< ::cppu::OWeakObject* >( this ));
2927     }
2928 
2929     return aResult;
2930 }
2931 // -----------------------------------------------------------------------------
getTransferDataFlavors()2932 uno::Sequence< datatransfer::DataFlavor > SAL_CALL OReportDefinition::getTransferDataFlavors(  ) throw (uno::RuntimeException)
2933 {
2934     uno::Sequence< datatransfer::DataFlavor > aRet(1);
2935 
2936     aRet[0] = datatransfer::DataFlavor( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("image/png")),
2937         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PNG")),
2938 		::getCppuType( (const uno::Sequence< sal_Int8 >*) NULL ) );
2939 
2940 	return aRet;
2941 }
2942 // -----------------------------------------------------------------------------
isDataFlavorSupported(const datatransfer::DataFlavor & aFlavor)2943 ::sal_Bool SAL_CALL OReportDefinition::isDataFlavorSupported( const datatransfer::DataFlavor& aFlavor ) throw (uno::RuntimeException)
2944 {
2945     return aFlavor.MimeType.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("image/png")));
2946 }
2947 
2948 // -----------------------------------------------------------------------------
getUndoManager()2949 uno::Reference< document::XUndoManager > SAL_CALL OReportDefinition::getUndoManager(  ) throw (uno::RuntimeException)
2950 {
2951     ::osl::MutexGuard aGuard( m_aMutex );
2952     return m_pImpl->m_pUndoManager.get();
2953 }
2954 
2955 
2956 // =============================================================================
2957 }// namespace reportdesign
2958 // =============================================================================
2959 
2960