1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
23 #include <string_view>
25 #include <officecfg/Office/Common.hxx>
26 #include <ReportDefinition.hxx>
28 #include <Functions.hxx>
30 #include <ReportComponent.hxx>
31 #include <ReportHelperImpl.hxx>
33 #include <RptModel.hxx>
34 #include <Section.hxx>
36 #include <UndoEnv.hxx>
37 #include <strings.hrc>
38 #include <core_resource.hxx>
39 #include <strings.hxx>
41 #include <com/sun/star/beans/PropertyAttribute.hpp>
42 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
43 #include <com/sun/star/chart2/data/DatabaseDataProvider.hpp>
44 #include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp>
45 #include <com/sun/star/document/DocumentProperties.hpp>
46 #include <com/sun/star/document/IndexedPropertyValues.hpp>
47 #include <com/sun/star/document/EventObject.hpp>
48 #include <com/sun/star/document/XEventListener.hpp>
49 #include <com/sun/star/document/XExporter.hpp>
50 #include <com/sun/star/document/XFilter.hpp>
51 #include <com/sun/star/document/XImporter.hpp>
52 #include <com/sun/star/embed/Aspects.hpp>
53 #include <com/sun/star/embed/ElementModes.hpp>
54 #include <com/sun/star/embed/EmbedMapUnits.hpp>
55 #include <com/sun/star/embed/XTransactedObject.hpp>
56 #include <com/sun/star/embed/StorageFactory.hpp>
57 #include <com/sun/star/frame/Desktop.hpp>
58 #include <com/sun/star/io/IOException.hpp>
59 #include <com/sun/star/io/XSeekable.hpp>
60 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
61 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
62 #include <com/sun/star/report/GroupKeepTogether.hpp>
63 #include <com/sun/star/report/ReportPrintOption.hpp>
64 #include <com/sun/star/sdb/CommandType.hpp>
65 #include <com/sun/star/style/GraphicLocation.hpp>
66 #include <com/sun/star/style/NumberingType.hpp>
67 #include <com/sun/star/style/PageStyleLayout.hpp>
68 #include <com/sun/star/style/XStyle.hpp>
69 #include <com/sun/star/table/BorderLine2.hpp>
70 #include <com/sun/star/table/ShadowFormat.hpp>
71 #include <com/sun/star/task/InteractionHandler.hpp>
72 #include <com/sun/star/task/XStatusIndicator.hpp>
73 #include <com/sun/star/ui/UIConfigurationManager.hpp>
74 #include <com/sun/star/util/CloseVetoException.hpp>
75 #include <com/sun/star/util/NumberFormatsSupplier.hpp>
76 #include <com/sun/star/xml/AttributeData.hpp>
77 #include <com/sun/star/xml/sax/Writer.hpp>
79 #include <comphelper/broadcasthelper.hxx>
80 #include <comphelper/documentconstants.hxx>
81 #include <comphelper/genericpropertyset.hxx>
82 #include <comphelper/indexedpropertyvalues.hxx>
83 #include <unotools/mediadescriptor.hxx>
84 #include <comphelper/namecontainer.hxx>
85 #include <comphelper/namedvaluecollection.hxx>
86 #include <comphelper/numberedcollection.hxx>
87 #include <comphelper/proparrhlp.hxx>
88 #include <comphelper/propertysetinfo.hxx>
89 #include <comphelper/propertystatecontainer.hxx>
90 #include <comphelper/seqstream.hxx>
91 #include <comphelper/sequence.hxx>
92 #include <comphelper/servicehelper.hxx>
93 #include <comphelper/storagehelper.hxx>
94 #include <comphelper/uno3.hxx>
95 #include <comphelper/interfacecontainer3.hxx>
96 #include <connectivity/CommonTools.hxx>
97 #include <connectivity/dbtools.hxx>
98 #include <cppuhelper/exc_hlp.hxx>
99 #include <cppuhelper/implbase.hxx>
100 #include <cppuhelper/interfacecontainer.h>
101 #include <cppuhelper/supportsservice.hxx>
102 #include <comphelper/types.hxx>
103 #include <dbaccess/dbaundomanager.hxx>
104 #include <editeng/paperinf.hxx>
105 #include <framework/titlehelper.hxx>
106 #include <o3tl/safeint.hxx>
107 #include <svl/itempool.hxx>
108 #include <svl/undo.hxx>
109 #include <svx/svdlayer.hxx>
110 #include <svx/unofill.hxx>
111 #include <svx/xmleohlp.hxx>
112 #include <svx/xmlgrhlp.hxx>
113 #include <comphelper/diagnose_ex.hxx>
114 #include <vcl/svapp.hxx>
117 constexpr OUStringLiteral SC_UNO_PAGE_LEFTBORDER
= u
"LeftBorder";
118 constexpr OUStringLiteral SC_UNO_PAGE_RIGHTBORDER
= u
"RightBorder";
119 constexpr OUStringLiteral SC_UNO_PAGE_BOTTBORDER
= u
"BottomBorder";
120 constexpr OUStringLiteral SC_UNO_PAGE_TOPBORDER
= u
"TopBorder";
121 constexpr OUStringLiteral SC_UNO_PAGE_LEFTBRDDIST
= u
"LeftBorderDistance";
122 constexpr OUStringLiteral SC_UNO_PAGE_RIGHTBRDDIST
= u
"RightBorderDistance";
123 constexpr OUStringLiteral SC_UNO_PAGE_BOTTBRDDIST
= u
"BottomBorderDistance";
124 constexpr OUStringLiteral SC_UNO_PAGE_TOPBRDDIST
= u
"TopBorderDistance";
125 constexpr OUStringLiteral SC_UNO_PAGE_BORDERDIST
= u
"BorderDistance";
126 constexpr OUStringLiteral SC_UNO_PAGE_SHADOWFORM
= u
"ShadowFormat";
127 constexpr OUStringLiteral SC_UNO_PAGE_PAPERTRAY
= u
"PrinterPaperTray";
128 constexpr OUStringLiteral SC_UNO_PAGE_SCALEVAL
= u
"PageScale";
129 constexpr OUStringLiteral SC_UNO_PAGE_SCALETOPAG
= u
"ScaleToPages";
130 constexpr OUStringLiteral SC_UNO_PAGE_SCALETOX
= u
"ScaleToPagesX";
131 constexpr OUStringLiteral SC_UNO_PAGE_SCALETOY
= u
"ScaleToPagesY";
132 constexpr OUStringLiteral SC_UNO_PAGE_HDRBACKCOL
= u
"HeaderBackColor";
133 constexpr OUStringLiteral SC_UNO_PAGE_HDRBACKTRAN
= u
"HeaderBackTransparent";
134 constexpr OUStringLiteral SC_UNO_PAGE_HDRGRFFILT
= u
"HeaderBackGraphicFilter";
135 constexpr OUStringLiteral SC_UNO_PAGE_HDRGRFLOC
= u
"HeaderBackGraphicLocation";
136 constexpr OUStringLiteral SC_UNO_PAGE_HDRGRF
= u
"HeaderBackGraphic";
137 constexpr OUStringLiteral SC_UNO_PAGE_HDRLEFTBOR
= u
"HeaderLeftBorder";
138 constexpr OUStringLiteral SC_UNO_PAGE_HDRRIGHTBOR
= u
"HeaderRightBorder";
139 constexpr OUStringLiteral SC_UNO_PAGE_HDRBOTTBOR
= u
"HeaderBottomBorder";
140 constexpr OUStringLiteral SC_UNO_PAGE_HDRTOPBOR
= u
"HeaderTopBorder";
141 constexpr OUStringLiteral SC_UNO_PAGE_HDRLEFTBDIS
= u
"HeaderLeftBorderDistance";
142 constexpr OUStringLiteral SC_UNO_PAGE_HDRRIGHTBDIS
= u
"HeaderRightBorderDistance";
143 constexpr OUStringLiteral SC_UNO_PAGE_HDRBOTTBDIS
= u
"HeaderBottomBorderDistance";
144 constexpr OUStringLiteral SC_UNO_PAGE_HDRTOPBDIS
= u
"HeaderTopBorderDistance";
145 constexpr OUStringLiteral SC_UNO_PAGE_HDRBRDDIST
= u
"HeaderBorderDistance";
146 constexpr OUStringLiteral SC_UNO_PAGE_HDRSHADOW
= u
"HeaderShadowFormat";
147 constexpr OUStringLiteral SC_UNO_PAGE_HDRLEFTMAR
= u
"HeaderLeftMargin";
148 constexpr OUStringLiteral SC_UNO_PAGE_HDRRIGHTMAR
= u
"HeaderRightMargin";
149 constexpr OUStringLiteral SC_UNO_PAGE_HDRBODYDIST
= u
"HeaderBodyDistance";
150 constexpr OUStringLiteral SC_UNO_PAGE_HDRHEIGHT
= u
"HeaderHeight";
151 constexpr OUStringLiteral SC_UNO_PAGE_HDRON
= u
"HeaderIsOn";
152 constexpr OUStringLiteral SC_UNO_PAGE_HDRDYNAMIC
= u
"HeaderIsDynamicHeight";
153 constexpr OUStringLiteral SC_UNO_PAGE_HDRSHARED
= u
"HeaderIsShared";
154 constexpr OUStringLiteral SC_UNO_PAGE_FIRSTHDRSHARED
= u
"FirstPageHeaderIsShared";
155 constexpr OUStringLiteral SC_UNO_PAGE_FTRBACKCOL
= u
"FooterBackColor";
156 constexpr OUStringLiteral SC_UNO_PAGE_FTRBACKTRAN
= u
"FooterBackTransparent";
157 constexpr OUStringLiteral SC_UNO_PAGE_FTRGRFFILT
= u
"FooterBackGraphicFilter";
158 constexpr OUStringLiteral SC_UNO_PAGE_FTRGRFLOC
= u
"FooterBackGraphicLocation";
159 constexpr OUStringLiteral SC_UNO_PAGE_FTRGRF
= u
"FooterBackGraphic";
160 constexpr OUStringLiteral SC_UNO_PAGE_FTRLEFTBOR
= u
"FooterLeftBorder";
161 constexpr OUStringLiteral SC_UNO_PAGE_FTRRIGHTBOR
= u
"FooterRightBorder";
162 constexpr OUStringLiteral SC_UNO_PAGE_FTRBOTTBOR
= u
"FooterBottomBorder";
163 constexpr OUStringLiteral SC_UNO_PAGE_FTRTOPBOR
= u
"FooterTopBorder";
164 constexpr OUStringLiteral SC_UNO_PAGE_FTRLEFTBDIS
= u
"FooterLeftBorderDistance";
165 constexpr OUStringLiteral SC_UNO_PAGE_FTRRIGHTBDIS
= u
"FooterRightBorderDistance";
166 constexpr OUStringLiteral SC_UNO_PAGE_FTRBOTTBDIS
= u
"FooterBottomBorderDistance";
167 constexpr OUStringLiteral SC_UNO_PAGE_FTRTOPBDIS
= u
"FooterTopBorderDistance";
168 constexpr OUStringLiteral SC_UNO_PAGE_FTRBRDDIST
= u
"FooterBorderDistance";
169 constexpr OUStringLiteral SC_UNO_PAGE_FTRSHADOW
= u
"FooterShadowFormat";
170 constexpr OUStringLiteral SC_UNO_PAGE_FTRLEFTMAR
= u
"FooterLeftMargin";
171 constexpr OUStringLiteral SC_UNO_PAGE_FTRRIGHTMAR
= u
"FooterRightMargin";
172 constexpr OUStringLiteral SC_UNO_PAGE_FTRBODYDIST
= u
"FooterBodyDistance";
173 constexpr OUStringLiteral SC_UNO_PAGE_FTRHEIGHT
= u
"FooterHeight";
174 constexpr OUStringLiteral SC_UNO_PAGE_FTRON
= u
"FooterIsOn";
175 constexpr OUStringLiteral SC_UNO_PAGE_FTRDYNAMIC
= u
"FooterIsDynamicHeight";
176 constexpr OUStringLiteral SC_UNO_PAGE_FTRSHARED
= u
"FooterIsShared";
177 constexpr OUStringLiteral SC_UNO_PAGE_FIRSTFTRSHARED
= u
"FirstPageFooterIsShared";
179 namespace reportdesign
181 using namespace com::sun::star
;
182 using namespace rptui
;
184 static void lcl_setModelReadOnly(const uno::Reference
< embed::XStorage
>& _xStorage
,std::shared_ptr
<rptui::OReportModel
> const & _rModel
)
186 uno::Reference
<beans::XPropertySet
> xProp(_xStorage
,uno::UNO_QUERY
);
187 sal_Int32 nOpenMode
= embed::ElementModes::READ
;
189 xProp
->getPropertyValue("OpenMode") >>= nOpenMode
;
191 _rModel
->SetReadOnly((nOpenMode
& embed::ElementModes::WRITE
) != embed::ElementModes::WRITE
);
193 static void lcl_stripLoadArguments( utl::MediaDescriptor
& _rDescriptor
, uno::Sequence
< beans::PropertyValue
>& _rArgs
)
195 _rDescriptor
.erase( "StatusIndicator" );
196 _rDescriptor
.erase( "InteractionHandler" );
197 _rDescriptor
.erase( "Model" );
198 _rDescriptor
>> _rArgs
;
201 static void lcl_extractAndStartStatusIndicator( const utl::MediaDescriptor
& _rDescriptor
, uno::Reference
< task::XStatusIndicator
>& _rxStatusIndicator
,
202 uno::Sequence
< uno::Any
>& _rCallArgs
)
206 _rxStatusIndicator
= _rDescriptor
.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_STATUSINDICATOR
, _rxStatusIndicator
);
207 if ( _rxStatusIndicator
.is() )
209 _rxStatusIndicator
->start( OUString(), sal_Int32(1000000) );
211 sal_Int32 nLength
= _rCallArgs
.getLength();
212 _rCallArgs
.realloc( nLength
+ 1 );
213 _rCallArgs
.getArray()[ nLength
] <<= _rxStatusIndicator
;
216 catch (const uno::Exception
&)
218 TOOLS_WARN_EXCEPTION( "reportdesign", "lcl_extractAndStartStatusIndicator" );
222 typedef ::comphelper::OPropertyStateContainer OStyle_PBASE
;
230 typedef ::comphelper::OPropertyArrayUsageHelper
< OStyle
232 typedef ::cppu::WeakImplHelper
< style::XStyle
, beans::XMultiPropertyStates
> TStyleBASE
;
236 class OStyle
: public ::comphelper::OMutexAndBroadcastHelper
239 ,public OStyle_PABASE
244 void getPropertyDefaultByHandle( sal_Int32 _nHandle
, uno::Any
& _rDefault
) const override
;
245 virtual ~OStyle() override
{}
250 DECLARE_XINTERFACE( )
253 css::uno::Reference
<css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo() override
;
254 ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
255 ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const override
;
258 sal_Bool SAL_CALL
isUserDefined( ) override
;
259 sal_Bool SAL_CALL
isInUse( ) override
;
260 OUString SAL_CALL
getParentStyle( ) override
;
261 void SAL_CALL
setParentStyle( const OUString
& aParentStyle
) override
;
264 OUString SAL_CALL
getName( ) override
;
265 void SAL_CALL
setName( const OUString
& aName
) override
;
267 // XMultiPropertyState
268 uno::Sequence
< beans::PropertyState
> SAL_CALL
getPropertyStates( const uno::Sequence
< OUString
>& aPropertyNames
) override
270 return OStyle_PBASE::getPropertyStates(aPropertyNames
);
272 void SAL_CALL
setAllPropertiesToDefault( ) override
;
273 void SAL_CALL
setPropertiesToDefault( const uno::Sequence
< OUString
>& aPropertyNames
) override
;
274 uno::Sequence
< uno::Any
> SAL_CALL
getPropertyDefaults( const uno::Sequence
< OUString
>& aPropertyNames
) override
;
280 :OStyle_PBASE(m_aBHelper
)
281 ,m_aSize(21000,29700)
283 const ::Size aDefaultSize
= SvxPaperInfo::GetDefaultPaperSize( MapUnit::Map100thMM
);
284 m_aSize
.Height
= aDefaultSize
.Height();
285 m_aSize
.Width
= aDefaultSize
.Width();
287 const sal_Int32 nMargin
= 2000;
288 const sal_Int32 nBound
= beans::PropertyAttribute::BOUND
;
289 const sal_Int32 nMayBeVoid
= beans::PropertyAttribute::MAYBEVOID
;
292 registerPropertyNoMember( PROPERTY_NAME
, ++i
, nBound
, cppu::UnoType
<OUString
>::get(), css::uno::Any(OUString("Default")) );
294 registerPropertyNoMember(PROPERTY_BACKCOLOR
, ++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(COL_TRANSPARENT
));
296 registerPropertyNoMember(PROPERTY_BACKGRAPHICLOCATION
, ++i
,nBound
, cppu::UnoType
<style::GraphicLocation
>::get(), css::uno::Any(style::GraphicLocation_NONE
));
297 registerPropertyNoMember(PROPERTY_BACKTRANSPARENT
, ++i
,nBound
,cppu::UnoType
<bool>::get(), css::uno::Any(true));
298 registerPropertyNoMember(SC_UNO_PAGE_BORDERDIST
, ++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
299 registerPropertyNoMember(SC_UNO_PAGE_BOTTBORDER
, ++i
,nBound
, cppu::UnoType
<table::BorderLine2
>::get(), css::uno::Any(table::BorderLine2()));
300 registerPropertyNoMember(SC_UNO_PAGE_BOTTBRDDIST
, ++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
301 registerPropertyNoMember(PROPERTY_BOTTOMMARGIN
, ++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(nMargin
));
302 registerPropertyNoMember("DisplayName", ++i
,nBound
, cppu::UnoType
<OUString
>::get(), css::uno::Any(OUString()));
303 registerPropertyNoMember(SC_UNO_PAGE_FTRBACKCOL
, ++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(COL_TRANSPARENT
));
304 registerPropertyNoMember(SC_UNO_PAGE_FTRGRFFILT
, ++i
,nBound
, cppu::UnoType
<OUString
>::get(), css::uno::Any(OUString()));
305 registerPropertyNoMember(SC_UNO_PAGE_FTRGRFLOC
, ++i
,nBound
, cppu::UnoType
<style::GraphicLocation
>::get(), css::uno::Any(style::GraphicLocation_NONE
));
306 registerPropertyNoMember(SC_UNO_PAGE_FTRGRF
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<graphic::XGraphic
>::get(), css::uno::Any(uno::Reference
<graphic::XGraphic
>()));
307 registerPropertyNoMember(SC_UNO_PAGE_FTRBACKTRAN
, ++i
,nBound
,cppu::UnoType
<bool>::get(), css::uno::Any(true));
308 registerPropertyNoMember(SC_UNO_PAGE_FTRBODYDIST
, ++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
309 registerPropertyNoMember(SC_UNO_PAGE_FTRBRDDIST
, ++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
310 registerPropertyNoMember(SC_UNO_PAGE_FTRBOTTBOR
, ++i
,nBound
, cppu::UnoType
<table::BorderLine2
>::get(), css::uno::Any(table::BorderLine2()));
311 registerPropertyNoMember(SC_UNO_PAGE_FTRBOTTBDIS
, ++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
312 registerPropertyNoMember(SC_UNO_PAGE_FTRHEIGHT
, ++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
313 registerPropertyNoMember(SC_UNO_PAGE_FTRDYNAMIC
, ++i
,nBound
,cppu::UnoType
<bool>::get(), css::uno::Any(false));
314 registerPropertyNoMember(SC_UNO_PAGE_FTRON
, ++i
,nBound
,cppu::UnoType
<bool>::get(), css::uno::Any(false));
315 registerPropertyNoMember(SC_UNO_PAGE_FTRSHARED
, ++i
,nBound
,cppu::UnoType
<bool>::get(), css::uno::Any(false));
316 registerPropertyNoMember(SC_UNO_PAGE_FIRSTFTRSHARED
, ++i
,nBound
,cppu::UnoType
<bool>::get(), css::uno::Any(false));
317 registerPropertyNoMember(SC_UNO_PAGE_FTRLEFTBOR
, ++i
,nBound
, cppu::UnoType
<table::BorderLine2
>::get(), css::uno::Any(table::BorderLine2()));
318 registerPropertyNoMember(SC_UNO_PAGE_FTRLEFTBDIS
, ++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
319 registerPropertyNoMember(SC_UNO_PAGE_FTRLEFTMAR
, ++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
320 registerPropertyNoMember(SC_UNO_PAGE_FTRRIGHTBOR
, ++i
,nBound
, cppu::UnoType
<table::BorderLine2
>::get(), css::uno::Any(table::BorderLine2()));
321 registerPropertyNoMember(SC_UNO_PAGE_FTRRIGHTBDIS
,++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
322 registerPropertyNoMember(SC_UNO_PAGE_FTRRIGHTMAR
, ++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
323 registerPropertyNoMember(SC_UNO_PAGE_FTRSHADOW
, ++i
,nBound
, cppu::UnoType
<table::ShadowFormat
>::get(), css::uno::Any(table::ShadowFormat()));
324 registerPropertyNoMember(SC_UNO_PAGE_FTRTOPBOR
, ++i
,nBound
, cppu::UnoType
<table::BorderLine2
>::get(), css::uno::Any(table::BorderLine2()));
325 registerPropertyNoMember(SC_UNO_PAGE_FTRTOPBDIS
, ++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
327 registerPropertyNoMember(SC_UNO_PAGE_HDRBACKCOL
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(COL_TRANSPARENT
));
328 registerPropertyNoMember(SC_UNO_PAGE_HDRGRFFILT
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<OUString
>::get(), css::uno::Any(OUString()));
329 registerPropertyNoMember(SC_UNO_PAGE_HDRGRFLOC
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<style::GraphicLocation
>::get(), css::uno::Any(style::GraphicLocation_NONE
));
330 registerPropertyNoMember(SC_UNO_PAGE_HDRGRF
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<graphic::XGraphic
>::get(), css::uno::Any(uno::Reference
<graphic::XGraphic
>()));
331 registerPropertyNoMember(SC_UNO_PAGE_HDRBACKTRAN
, ++i
,nBound
|nMayBeVoid
,cppu::UnoType
<bool>::get(), css::uno::Any(true));
332 registerPropertyNoMember(SC_UNO_PAGE_HDRBODYDIST
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
333 registerPropertyNoMember(SC_UNO_PAGE_HDRBRDDIST
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
334 registerPropertyNoMember(SC_UNO_PAGE_HDRBOTTBOR
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<table::BorderLine2
>::get(), css::uno::Any(table::BorderLine2()));
335 registerPropertyNoMember(SC_UNO_PAGE_HDRBOTTBDIS
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
336 registerPropertyNoMember(SC_UNO_PAGE_HDRHEIGHT
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
337 registerPropertyNoMember(SC_UNO_PAGE_HDRDYNAMIC
, ++i
,nBound
|nMayBeVoid
,cppu::UnoType
<bool>::get(), css::uno::Any(false));
338 registerPropertyNoMember(SC_UNO_PAGE_HDRON
, ++i
,nBound
|nMayBeVoid
,cppu::UnoType
<bool>::get(), css::uno::Any(false));
339 registerPropertyNoMember(SC_UNO_PAGE_HDRSHARED
, ++i
,nBound
|nMayBeVoid
,cppu::UnoType
<bool>::get(), css::uno::Any(false));
340 registerPropertyNoMember(SC_UNO_PAGE_FIRSTHDRSHARED
, ++i
,nBound
|nMayBeVoid
,cppu::UnoType
<bool>::get(), css::uno::Any(false));
341 registerPropertyNoMember(SC_UNO_PAGE_HDRLEFTBOR
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<table::BorderLine2
>::get(), css::uno::Any(table::BorderLine2()));
342 registerPropertyNoMember(SC_UNO_PAGE_HDRLEFTBDIS
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
343 registerPropertyNoMember(SC_UNO_PAGE_HDRLEFTMAR
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
344 registerPropertyNoMember(SC_UNO_PAGE_HDRRIGHTBOR
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<table::BorderLine2
>::get(), css::uno::Any(table::BorderLine2()));
345 registerPropertyNoMember(SC_UNO_PAGE_HDRRIGHTBDIS
,++i
,nBound
|nMayBeVoid
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
346 registerPropertyNoMember(SC_UNO_PAGE_HDRRIGHTMAR
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
347 registerPropertyNoMember(SC_UNO_PAGE_HDRSHADOW
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<table::ShadowFormat
>::get(), css::uno::Any(table::ShadowFormat()));
348 registerPropertyNoMember(SC_UNO_PAGE_HDRTOPBOR
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<table::BorderLine2
>::get(), css::uno::Any(table::BorderLine2()));
349 registerPropertyNoMember(SC_UNO_PAGE_HDRTOPBDIS
, ++i
,nBound
|nMayBeVoid
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
351 registerProperty(PROPERTY_HEIGHT
, ++i
,nBound
,&m_aSize
.Height
, ::cppu::UnoType
<sal_Int32
>::get() );
352 registerPropertyNoMember(PROPERTY_ISLANDSCAPE
, ++i
,nBound
, cppu::UnoType
<bool>::get(), css::uno::Any(false));
353 registerPropertyNoMember(SC_UNO_PAGE_LEFTBORDER
, ++i
,nBound
, cppu::UnoType
<table::BorderLine2
>::get(), css::uno::Any(table::BorderLine2()));
354 registerPropertyNoMember(SC_UNO_PAGE_LEFTBRDDIST
, ++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
355 registerPropertyNoMember(PROPERTY_LEFTMARGIN
, ++i
,beans::PropertyAttribute::BOUND
, ::cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(nMargin
));
356 registerPropertyNoMember(PROPERTY_NUMBERINGTYPE
, ++i
,nBound
, cppu::UnoType
<sal_Int16
>::get(), css::uno::Any(style::NumberingType::ARABIC
));
357 registerPropertyNoMember(SC_UNO_PAGE_SCALEVAL
, ++i
,nBound
, cppu::UnoType
<sal_Int16
>::get(), css::uno::Any(sal_Int16(0)));
358 registerPropertyNoMember(PROPERTY_PAGESTYLELAYOUT
, ++i
,nBound
, cppu::UnoType
<style::PageStyleLayout
>::get(), css::uno::Any(style::PageStyleLayout_ALL
));
359 registerPropertyNoMember(SC_UNO_PAGE_PAPERTRAY
, ++i
,nBound
, cppu::UnoType
<OUString
>::get(), css::uno::Any(OUString("[From printer settings]")));
360 registerPropertyNoMember(SC_UNO_PAGE_RIGHTBORDER
, ++i
,nBound
, cppu::UnoType
<table::BorderLine2
>::get(), css::uno::Any(table::BorderLine2()));
361 registerPropertyNoMember(SC_UNO_PAGE_RIGHTBRDDIST
,++i
,nBound
, cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
362 registerPropertyNoMember(PROPERTY_RIGHTMARGIN
, ++i
,beans::PropertyAttribute::BOUND
,::cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(nMargin
));
363 registerPropertyNoMember(SC_UNO_PAGE_SCALETOPAG
, ++i
,nBound
, cppu::UnoType
<sal_Int16
>::get(), css::uno::Any(sal_Int16(0)));
364 registerPropertyNoMember(SC_UNO_PAGE_SCALETOX
, ++i
,nBound
, cppu::UnoType
<sal_Int16
>::get(), css::uno::Any(sal_Int16(0)));
365 registerPropertyNoMember(SC_UNO_PAGE_SCALETOY
, ++i
,nBound
, cppu::UnoType
<sal_Int16
>::get(), css::uno::Any(sal_Int16(0)));
366 registerPropertyNoMember(SC_UNO_PAGE_SHADOWFORM
, ++i
,nBound
, cppu::UnoType
<table::ShadowFormat
>::get(), css::uno::Any(table::ShadowFormat()));
367 registerProperty(PROPERTY_PAPERSIZE
, ++i
,beans::PropertyAttribute::BOUND
,&m_aSize
, cppu::UnoType
<awt::Size
>::get() );
368 registerPropertyNoMember(SC_UNO_PAGE_TOPBORDER
, ++i
,nBound
, cppu::UnoType
<table::BorderLine2
>::get(), css::uno::Any(table::BorderLine2()));
369 registerPropertyNoMember(SC_UNO_PAGE_TOPBRDDIST
, ++i
,nBound
,::cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(sal_Int32(0)));
370 registerPropertyNoMember(PROPERTY_TOPMARGIN
, ++i
,nBound
,::cppu::UnoType
<sal_Int32
>::get(), css::uno::Any(nMargin
));
371 registerPropertyNoMember("UserDefinedAttributes", ++i
,nBound
, cppu::UnoType
<container::XNameContainer
>::get(), css::uno::Any(comphelper::NameContainer_createInstance(cppu::UnoType
<xml::AttributeData
>::get())));
372 registerProperty(PROPERTY_WIDTH
, ++i
,nBound
,&m_aSize
.Width
, cppu::UnoType
<sal_Int32
>::get() );
373 registerPropertyNoMember("PrinterName", ++i
,nBound
, cppu::UnoType
<OUString
>::get(), css::uno::Any(OUString()));
374 registerPropertyNoMember("PrinterSetup", ++i
,nBound
,cppu::UnoType
<uno::Sequence
<sal_Int8
>>::get(), css::uno::Any(uno::Sequence
<sal_Int8
>()));
379 IMPLEMENT_FORWARD_XINTERFACE2(OStyle
,TStyleBASE
,OStyle_PBASE
)
381 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
OStyle::getPropertySetInfo()
383 return createPropertySetInfo( getInfoHelper() );
386 void OStyle::getPropertyDefaultByHandle( sal_Int32
/*_nHandle*/, uno::Any
& /*_rDefault*/ ) const
390 ::cppu::IPropertyArrayHelper
& OStyle::getInfoHelper()
392 return *getArrayHelper();
395 ::cppu::IPropertyArrayHelper
* OStyle::createArrayHelper( ) const
397 uno::Sequence
< beans::Property
> aProps
;
398 describeProperties(aProps
);
399 return new ::cppu::OPropertyArrayHelper(aProps
);
403 sal_Bool SAL_CALL
OStyle::isUserDefined( )
408 sal_Bool SAL_CALL
OStyle::isInUse( )
413 OUString SAL_CALL
OStyle::getParentStyle( )
418 void SAL_CALL
OStyle::setParentStyle( const OUString
& /*aParentStyle*/ )
423 OUString SAL_CALL
OStyle::getName( )
426 getPropertyValue(PROPERTY_NAME
) >>= sName
;
430 void SAL_CALL
OStyle::setName( const OUString
& aName
)
432 setPropertyValue(PROPERTY_NAME
,uno::Any(aName
));
435 void SAL_CALL
OStyle::setAllPropertiesToDefault( )
439 void SAL_CALL
OStyle::setPropertiesToDefault( const uno::Sequence
< OUString
>& aPropertyNames
)
441 for(const OUString
& rName
: aPropertyNames
)
442 setPropertyToDefault(rName
);
445 uno::Sequence
< uno::Any
> SAL_CALL
OStyle::getPropertyDefaults( const uno::Sequence
< OUString
>& aPropertyNames
)
447 uno::Sequence
< uno::Any
> aRet(aPropertyNames
.getLength());
448 std::transform(aPropertyNames
.begin(), aPropertyNames
.end(), aRet
.getArray(),
449 [this](const OUString
& rName
) -> uno::Any
{ return getPropertyDefault(rName
); });
453 struct OReportDefinitionImpl
455 uno::WeakReference
< uno::XInterface
> m_xParent
;
456 ::comphelper::OInterfaceContainerHelper3
<document::XStorageChangeListener
> m_aStorageChangeListeners
;
457 ::comphelper::OInterfaceContainerHelper3
<util::XCloseListener
> m_aCloseListener
;
458 ::comphelper::OInterfaceContainerHelper3
<util::XModifyListener
> m_aModifyListeners
;
459 ::comphelper::OInterfaceContainerHelper3
<document::XEventListener
> m_aLegacyEventListeners
;
460 ::comphelper::OInterfaceContainerHelper3
<document::XDocumentEventListener
> m_aDocEventListeners
;
461 ::std::vector
< uno::Reference
< frame::XController
> > m_aControllers
;
462 uno::Sequence
< beans::PropertyValue
> m_aArgs
;
464 uno::Reference
< report::XGroups
> m_xGroups
;
465 uno::Reference
< report::XSection
> m_xReportHeader
;
466 uno::Reference
< report::XSection
> m_xReportFooter
;
467 uno::Reference
< report::XSection
> m_xPageHeader
;
468 uno::Reference
< report::XSection
> m_xPageFooter
;
469 uno::Reference
< report::XSection
> m_xDetail
;
470 uno::Reference
< embed::XStorage
> m_xStorage
;
471 uno::Reference
< frame::XController
> m_xCurrentController
;
472 uno::Reference
< container::XIndexAccess
> m_xViewData
;
473 uno::Reference
< container::XNameAccess
> m_xStyles
;
474 uno::Reference
< container::XNameAccess
> m_xXMLNamespaceMap
;
475 uno::Reference
< container::XNameAccess
> m_xGradientTable
;
476 uno::Reference
< container::XNameAccess
> m_xHatchTable
;
477 uno::Reference
< container::XNameAccess
> m_xBitmapTable
;
478 uno::Reference
< container::XNameAccess
> m_xTransparencyGradientTable
;
479 uno::Reference
< container::XNameAccess
> m_xDashTable
;
480 uno::Reference
< container::XNameAccess
> m_xMarkerTable
;
481 uno::Reference
< report::XFunctions
> m_xFunctions
;
482 uno::Reference
< ui::XUIConfigurationManager2
> m_xUIConfigurationManager
;
483 uno::Reference
< util::XNumberFormatsSupplier
> m_xNumberFormatsSupplier
;
484 uno::Reference
< sdbc::XConnection
> m_xActiveConnection
;
485 uno::Reference
< frame::XTitle
> m_xTitleHelper
;
486 uno::Reference
< frame::XUntitledNumbers
> m_xNumberedControllers
;
487 uno::Reference
< document::XDocumentProperties
> m_xDocumentProperties
;
489 std::shared_ptr
< ::comphelper::EmbeddedObjectContainer
>
491 std::shared_ptr
<rptui::OReportModel
> m_pReportModel
;
492 ::rtl::Reference
< ::dbaui::UndoManager
> m_pUndoManager
;
496 OUString m_sMimeType
;
497 OUString m_sIdentifier
;
498 OUString m_sDataSourceName
;
499 awt::Size m_aVisualAreaSize
;
500 ::sal_Int64 m_nAspect
;
501 ::sal_Int16 m_nGroupKeepTogether
;
502 ::sal_Int16 m_nPageHeaderOption
;
503 ::sal_Int16 m_nPageFooterOption
;
504 ::sal_Int32 m_nCommandType
;
505 bool m_bControllersLocked
;
507 bool m_bEscapeProcessing
;
508 bool m_bSetModifiedEnabled
;
510 explicit OReportDefinitionImpl(::osl::Mutex
& _aMutex
)
511 :m_aStorageChangeListeners(_aMutex
)
512 ,m_aCloseListener(_aMutex
)
513 ,m_aModifyListeners(_aMutex
)
514 ,m_aLegacyEventListeners(_aMutex
)
515 ,m_aDocEventListeners(_aMutex
)
516 ,m_sMimeType(MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII
)
517 ,m_sIdentifier(SERVICE_REPORTDEFINITION
)
518 // default visual area is 8 x 7 cm
519 ,m_aVisualAreaSize( 8000, 7000 )
520 ,m_nAspect(embed::Aspects::MSOLE_CONTENT
)
521 ,m_nGroupKeepTogether(0)
522 ,m_nPageHeaderOption(0)
523 ,m_nPageFooterOption(0)
524 ,m_nCommandType(sdb::CommandType::TABLE
)
525 ,m_bControllersLocked(false)
527 ,m_bEscapeProcessing(true)
528 ,m_bSetModifiedEnabled( true )
532 OReportDefinition::OReportDefinition(uno::Reference
< uno::XComponentContext
> const & _xContext
)
533 : ::cppu::BaseMutex(),
534 ReportDefinitionBase(m_aMutex
),
535 ReportDefinitionPropertySet(_xContext
,IMPLEMENTS_PROPERTY_SET
,uno::Sequence
< OUString
>()),
536 ::comphelper::IEmbeddedHelper(),
537 m_aProps(std::make_shared
<OReportComponentProperties
>(_xContext
)),
538 m_pImpl(std::make_shared
<OReportDefinitionImpl
>(m_aMutex
))
540 m_aProps
->m_sName
= RptResId(RID_STR_REPORT
);
541 osl_atomic_increment(&m_refCount
);
544 m_pImpl
->m_xGroups
= new OGroups(this,m_aProps
->m_xContext
);
545 m_pImpl
->m_xDetail
= OSection::createOSection(this,m_aProps
->m_xContext
);
546 m_pImpl
->m_xDetail
->setName(RptResId(RID_STR_DETAIL
));
548 osl_atomic_decrement( &m_refCount
);
551 OReportDefinition::OReportDefinition(
552 uno::Reference
< uno::XComponentContext
> const & _xContext
,
553 const uno::Reference
< lang::XMultiServiceFactory
>& _xFactory
,
554 uno::Reference
< drawing::XShape
>& _xShape
)
555 : ::cppu::BaseMutex(),
556 ReportDefinitionBase(m_aMutex
),
557 ReportDefinitionPropertySet(_xContext
,IMPLEMENTS_PROPERTY_SET
,uno::Sequence
< OUString
>()),
558 ::comphelper::IEmbeddedHelper(),
559 m_aProps(std::make_shared
<OReportComponentProperties
>(_xContext
)),
560 m_pImpl(std::make_shared
<OReportDefinitionImpl
>(m_aMutex
))
562 m_aProps
->m_sName
= RptResId(RID_STR_REPORT
);
563 m_aProps
->m_xFactory
= _xFactory
;
564 osl_atomic_increment(&m_refCount
);
566 m_aProps
->setShape(_xShape
,this,m_refCount
);
568 m_pImpl
->m_xGroups
= new OGroups(this,m_aProps
->m_xContext
);
569 m_pImpl
->m_xDetail
= OSection::createOSection(this,m_aProps
->m_xContext
);
570 m_pImpl
->m_xDetail
->setName(RptResId(RID_STR_DETAIL
));
572 osl_atomic_decrement( &m_refCount
);
575 OReportDefinition::~OReportDefinition()
577 if ( !ReportDefinitionBase::rBHelper
.bInDispose
&& !ReportDefinitionBase::rBHelper
.bDisposed
)
584 IMPLEMENT_FORWARD_REFCOUNT( OReportDefinition
, ReportDefinitionBase
)
585 void OReportDefinition::init()
589 m_pImpl
->m_pReportModel
= std::make_shared
<OReportModel
>(this);
590 m_pImpl
->m_pReportModel
->GetItemPool().FreezeIdRanges();
591 m_pImpl
->m_pReportModel
->SetScaleUnit( MapUnit::Map100thMM
);
592 SdrLayerAdmin
& rAdmin
= m_pImpl
->m_pReportModel
->GetLayerAdmin();
593 rAdmin
.NewLayer("front", RPT_LAYER_FRONT
.get());
594 rAdmin
.NewLayer("back", RPT_LAYER_BACK
.get());
595 rAdmin
.NewLayer("HiddenLayer", RPT_LAYER_HIDDEN
.get());
597 m_pImpl
->m_pUndoManager
= new ::dbaui::UndoManager( *this, m_aMutex
);
598 m_pImpl
->m_pReportModel
->SetSdrUndoManager( &m_pImpl
->m_pUndoManager
->GetSfxUndoManager() );
600 m_pImpl
->m_xFunctions
= new OFunctions(this,m_aProps
->m_xContext
);
601 if ( !m_pImpl
->m_xStorage
.is() )
602 m_pImpl
->m_xStorage
= ::comphelper::OStorageHelper::GetTemporaryStorage();
604 uno::Reference
<beans::XPropertySet
> xStorProps(m_pImpl
->m_xStorage
,uno::UNO_QUERY
);
605 if ( xStorProps
.is())
608 xStorProps
->getPropertyValue("MediaType") >>= sMediaType
;
609 if ( sMediaType
.isEmpty() )
610 xStorProps
->setPropertyValue("MediaType",uno::Any(OUString(MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII
)));
612 m_pImpl
->m_pObjectContainer
= std::make_shared
<comphelper::EmbeddedObjectContainer
>(m_pImpl
->m_xStorage
, getXWeak() );
614 catch (const uno::Exception
&)
616 DBG_UNHANDLED_EXCEPTION("reportdesign");
620 void SAL_CALL
OReportDefinition::dispose()
622 ReportDefinitionPropertySet::dispose();
623 cppu::WeakComponentImplHelperBase::dispose();
626 void SAL_CALL
OReportDefinition::disposing()
628 notifyEvent("OnUnload");
630 uno::Reference
< frame::XModel
> xHoldAlive( this );
632 lang::EventObject
aDisposeEvent( getXWeak() );
633 m_pImpl
->m_aModifyListeners
.disposeAndClear( aDisposeEvent
);
634 m_pImpl
->m_aCloseListener
.disposeAndClear( aDisposeEvent
);
635 m_pImpl
->m_aLegacyEventListeners
.disposeAndClear( aDisposeEvent
);
636 m_pImpl
->m_aDocEventListeners
.disposeAndClear( aDisposeEvent
);
637 m_pImpl
->m_aStorageChangeListeners
.disposeAndClear( aDisposeEvent
);
641 SolarMutexGuard aSolarGuard
;
642 osl::MutexGuard
aGuard(m_aMutex
);
644 m_pImpl
->m_aControllers
.clear();
646 ::comphelper::disposeComponent(m_pImpl
->m_xGroups
);
647 m_pImpl
->m_xReportHeader
.clear();
648 m_pImpl
->m_xReportFooter
.clear();
649 m_pImpl
->m_xPageHeader
.clear();
650 m_pImpl
->m_xPageFooter
.clear();
651 m_pImpl
->m_xDetail
.clear();
652 ::comphelper::disposeComponent(m_pImpl
->m_xFunctions
);
654 //::comphelper::disposeComponent(m_pImpl->m_xStorage);
655 // don't dispose, this currently is the task of either the ref count going to
656 // 0, or of the embedded object (if we're embedded, which is the only possible
659 m_pImpl
->m_xStorage
.clear();
660 m_pImpl
->m_xViewData
.clear();
661 m_pImpl
->m_xCurrentController
.clear();
662 m_pImpl
->m_xNumberFormatsSupplier
.clear();
663 m_pImpl
->m_xStyles
.clear();
664 m_pImpl
->m_xXMLNamespaceMap
.clear();
665 m_pImpl
->m_xGradientTable
.clear();
666 m_pImpl
->m_xHatchTable
.clear();
667 m_pImpl
->m_xBitmapTable
.clear();
668 m_pImpl
->m_xTransparencyGradientTable
.clear();
669 m_pImpl
->m_xDashTable
.clear();
670 m_pImpl
->m_xMarkerTable
.clear();
671 m_pImpl
->m_xUIConfigurationManager
.clear();
672 m_pImpl
->m_pReportModel
.reset();
673 m_pImpl
->m_pObjectContainer
.reset();
674 m_pImpl
->m_aArgs
.realloc(0);
675 m_pImpl
->m_xTitleHelper
.clear();
676 m_pImpl
->m_xNumberedControllers
.clear();
682 OUString
OReportDefinition::getImplementationName_Static( )
684 return "com.sun.star.comp.report.OReportDefinition";
687 OUString SAL_CALL
OReportDefinition::getImplementationName( )
689 return getImplementationName_Static();
692 uno::Sequence
< OUString
> OReportDefinition::getSupportedServiceNames_Static( )
694 uno::Sequence
< OUString
> aServices
{ SERVICE_REPORTDEFINITION
};
699 uno::Sequence
< OUString
> SAL_CALL
OReportDefinition::getSupportedServiceNames( )
701 // first collect the services which are supported by our aggregate
702 uno::Sequence
< OUString
> aSupported
;
703 if ( m_aProps
->m_xServiceInfo
.is() )
704 aSupported
= m_aProps
->m_xServiceInfo
->getSupportedServiceNames();
706 // append our own service, if necessary
707 if ( ::comphelper::findValue( aSupported
, SERVICE_REPORTDEFINITION
) == -1 )
709 sal_Int32 nLen
= aSupported
.getLength();
710 aSupported
.realloc( nLen
+ 1 );
711 aSupported
.getArray()[ nLen
] = SERVICE_REPORTDEFINITION
;
718 sal_Bool SAL_CALL
OReportDefinition::supportsService( const OUString
& _rServiceName
)
720 return cppu::supportsService(this, _rServiceName
);
723 uno::Any SAL_CALL
OReportDefinition::queryInterface( const uno::Type
& _rType
)
725 uno::Any aReturn
= ReportDefinitionBase::queryInterface(_rType
);
726 if ( !aReturn
.hasValue() )
727 aReturn
= ReportDefinitionPropertySet::queryInterface(_rType
);
729 return aReturn
.hasValue() ? aReturn
: (m_aProps
->m_xProxy
.is() ? m_aProps
->m_xProxy
->queryAggregation(_rType
) : aReturn
);
731 uno::Sequence
< uno::Type
> SAL_CALL
OReportDefinition::getTypes( )
733 if ( m_aProps
->m_xTypeProvider
.is() )
734 return ::comphelper::concatSequences(
735 ReportDefinitionBase::getTypes(),
736 m_aProps
->m_xTypeProvider
->getTypes()
738 return ReportDefinitionBase::getTypes();
741 uno::Reference
< uno::XInterface
> OReportDefinition::create(uno::Reference
< uno::XComponentContext
> const & xContext
)
743 return *(new OReportDefinition(xContext
));
747 OUString SAL_CALL
OReportDefinition::getCaption()
749 ::osl::MutexGuard
aGuard(m_aMutex
);
750 return m_pImpl
->m_sCaption
;
753 void SAL_CALL
OReportDefinition::setCaption( const OUString
& _caption
)
755 set(PROPERTY_CAPTION
,_caption
,m_pImpl
->m_sCaption
);
758 ::sal_Int16 SAL_CALL
OReportDefinition::getGroupKeepTogether()
760 ::osl::MutexGuard
aGuard(m_aMutex
);
761 return m_pImpl
->m_nGroupKeepTogether
;
764 void SAL_CALL
OReportDefinition::setGroupKeepTogether( ::sal_Int16 _groupkeeptogether
)
766 if ( _groupkeeptogether
< report::GroupKeepTogether::PER_PAGE
|| _groupkeeptogether
> report::GroupKeepTogether::PER_COLUMN
)
767 throwIllegallArgumentException(u
"css::report::GroupKeepTogether"
770 set(PROPERTY_GROUPKEEPTOGETHER
,_groupkeeptogether
,m_pImpl
->m_nGroupKeepTogether
);
773 ::sal_Int16 SAL_CALL
OReportDefinition::getPageHeaderOption()
775 ::osl::MutexGuard
aGuard(m_aMutex
);
776 return m_pImpl
->m_nPageHeaderOption
;
779 void SAL_CALL
OReportDefinition::setPageHeaderOption( ::sal_Int16 _pageheaderoption
)
781 if ( _pageheaderoption
< report::ReportPrintOption::ALL_PAGES
|| _pageheaderoption
> report::ReportPrintOption::NOT_WITH_REPORT_HEADER_FOOTER
)
782 throwIllegallArgumentException(u
"css::report::ReportPrintOption"
785 set(PROPERTY_PAGEHEADEROPTION
,_pageheaderoption
,m_pImpl
->m_nPageHeaderOption
);
788 ::sal_Int16 SAL_CALL
OReportDefinition::getPageFooterOption()
790 ::osl::MutexGuard
aGuard(m_aMutex
);
791 return m_pImpl
->m_nPageFooterOption
;
794 void SAL_CALL
OReportDefinition::setPageFooterOption( ::sal_Int16 _pagefooteroption
)
796 if ( _pagefooteroption
< report::ReportPrintOption::ALL_PAGES
|| _pagefooteroption
> report::ReportPrintOption::NOT_WITH_REPORT_HEADER_FOOTER
)
797 throwIllegallArgumentException(u
"css::report::ReportPrintOption"
800 set(PROPERTY_PAGEFOOTEROPTION
,_pagefooteroption
,m_pImpl
->m_nPageFooterOption
);
803 OUString SAL_CALL
OReportDefinition::getCommand()
805 ::osl::MutexGuard
aGuard(m_aMutex
);
806 return m_pImpl
->m_sCommand
;
809 void SAL_CALL
OReportDefinition::setCommand( const OUString
& _command
)
811 set(PROPERTY_COMMAND
,_command
,m_pImpl
->m_sCommand
);
814 ::sal_Int32 SAL_CALL
OReportDefinition::getCommandType()
816 ::osl::MutexGuard
aGuard(m_aMutex
);
817 return m_pImpl
->m_nCommandType
;
820 void SAL_CALL
OReportDefinition::setCommandType( ::sal_Int32 _commandtype
)
822 if ( _commandtype
< sdb::CommandType::TABLE
|| _commandtype
> sdb::CommandType::COMMAND
)
823 throwIllegallArgumentException(u
"css::sdb::CommandType"
826 set(PROPERTY_COMMANDTYPE
,_commandtype
,m_pImpl
->m_nCommandType
);
829 OUString SAL_CALL
OReportDefinition::getFilter()
831 ::osl::MutexGuard
aGuard(m_aMutex
);
832 return m_pImpl
->m_sFilter
;
835 void SAL_CALL
OReportDefinition::setFilter( const OUString
& _filter
)
837 set(PROPERTY_FILTER
,_filter
,m_pImpl
->m_sFilter
);
840 sal_Bool SAL_CALL
OReportDefinition::getEscapeProcessing()
842 ::osl::MutexGuard
aGuard(m_aMutex
);
843 return m_pImpl
->m_bEscapeProcessing
;
846 void SAL_CALL
OReportDefinition::setEscapeProcessing( sal_Bool _escapeprocessing
)
848 set(PROPERTY_ESCAPEPROCESSING
,_escapeprocessing
,m_pImpl
->m_bEscapeProcessing
);
851 sal_Bool SAL_CALL
OReportDefinition::getReportHeaderOn()
853 ::osl::MutexGuard
aGuard(m_aMutex
);
854 return m_pImpl
->m_xReportHeader
.is();
857 void SAL_CALL
OReportDefinition::setReportHeaderOn( sal_Bool _reportheaderon
)
859 if ( bool(_reportheaderon
) != m_pImpl
->m_xReportHeader
.is() )
861 setSection(PROPERTY_REPORTHEADERON
,_reportheaderon
,RptResId(RID_STR_REPORT_HEADER
),m_pImpl
->m_xReportHeader
);
865 sal_Bool SAL_CALL
OReportDefinition::getReportFooterOn()
867 ::osl::MutexGuard
aGuard(m_aMutex
);
868 return m_pImpl
->m_xReportFooter
.is();
871 void SAL_CALL
OReportDefinition::setReportFooterOn( sal_Bool _reportfooteron
)
873 if ( bool(_reportfooteron
) != m_pImpl
->m_xReportFooter
.is() )
875 setSection(PROPERTY_REPORTFOOTERON
,_reportfooteron
,RptResId(RID_STR_REPORT_FOOTER
),m_pImpl
->m_xReportFooter
);
879 sal_Bool SAL_CALL
OReportDefinition::getPageHeaderOn()
881 ::osl::MutexGuard
aGuard(m_aMutex
);
882 return m_pImpl
->m_xPageHeader
.is();
885 void SAL_CALL
OReportDefinition::setPageHeaderOn( sal_Bool _pageheaderon
)
887 if ( bool(_pageheaderon
) != m_pImpl
->m_xPageHeader
.is() )
889 setSection(PROPERTY_PAGEHEADERON
,_pageheaderon
,RptResId(RID_STR_PAGE_HEADER
),m_pImpl
->m_xPageHeader
);
893 sal_Bool SAL_CALL
OReportDefinition::getPageFooterOn()
895 ::osl::MutexGuard
aGuard(m_aMutex
);
896 return m_pImpl
->m_xPageFooter
.is();
899 void SAL_CALL
OReportDefinition::setPageFooterOn( sal_Bool _pagefooteron
)
901 if ( bool(_pagefooteron
) != m_pImpl
->m_xPageFooter
.is() )
903 setSection(PROPERTY_PAGEFOOTERON
,_pagefooteron
,RptResId(RID_STR_PAGE_FOOTER
),m_pImpl
->m_xPageFooter
);
907 uno::Reference
< report::XGroups
> SAL_CALL
OReportDefinition::getGroups()
909 ::osl::MutexGuard
aGuard(m_aMutex
);
910 return m_pImpl
->m_xGroups
;
913 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getReportHeader()
915 ::osl::MutexGuard
aGuard(m_aMutex
);
916 if ( !m_pImpl
->m_xReportHeader
.is() )
917 throw container::NoSuchElementException();
918 return m_pImpl
->m_xReportHeader
;
921 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getPageHeader()
923 ::osl::MutexGuard
aGuard(m_aMutex
);
924 if ( !m_pImpl
->m_xPageHeader
.is() )
925 throw container::NoSuchElementException();
926 return m_pImpl
->m_xPageHeader
;
929 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getDetail()
931 ::osl::MutexGuard
aGuard(m_aMutex
);
932 return m_pImpl
->m_xDetail
;
935 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getPageFooter()
937 ::osl::MutexGuard
aGuard(m_aMutex
);
938 if ( !m_pImpl
->m_xPageFooter
.is() )
939 throw container::NoSuchElementException();
940 return m_pImpl
->m_xPageFooter
;
943 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getReportFooter()
945 ::osl::MutexGuard
aGuard(m_aMutex
);
946 if ( !m_pImpl
->m_xReportFooter
.is() )
947 throw container::NoSuchElementException();
948 return m_pImpl
->m_xReportFooter
;
951 uno::Reference
< document::XEventBroadcaster
> SAL_CALL
OReportDefinition::getEventBroadcaster( )
953 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
958 REPORTCOMPONENT_MASTERDETAIL(OReportDefinition
,*m_aProps
)
959 REPORTCOMPONENT_IMPL(OReportDefinition
,*m_aProps
)
960 REPORTCOMPONENT_IMPL2(OReportDefinition
,*m_aProps
)
962 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
OReportDefinition::getPropertySetInfo( )
964 return ReportDefinitionPropertySet::getPropertySetInfo();
967 void SAL_CALL
OReportDefinition::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
)
969 ReportDefinitionPropertySet::setPropertyValue( aPropertyName
, aValue
);
972 uno::Any SAL_CALL
OReportDefinition::getPropertyValue( const OUString
& PropertyName
)
974 return ReportDefinitionPropertySet::getPropertyValue( PropertyName
);
977 void SAL_CALL
OReportDefinition::addPropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& xListener
)
979 ReportDefinitionPropertySet::addPropertyChangeListener( aPropertyName
, xListener
);
982 void SAL_CALL
OReportDefinition::removePropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& aListener
)
984 ReportDefinitionPropertySet::removePropertyChangeListener( aPropertyName
, aListener
);
987 void SAL_CALL
OReportDefinition::addVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
)
989 ReportDefinitionPropertySet::addVetoableChangeListener( PropertyName
, aListener
);
992 void SAL_CALL
OReportDefinition::removeVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
)
994 ReportDefinitionPropertySet::removeVetoableChangeListener( PropertyName
, aListener
);
998 uno::Reference
< uno::XInterface
> SAL_CALL
OReportDefinition::getParent( )
1000 ::osl::MutexGuard
aGuard(m_aMutex
);
1001 uno::Reference
< container::XChild
> xChild
;
1002 comphelper::query_aggregation(m_aProps
->m_xProxy
,xChild
);
1004 return xChild
->getParent();
1005 return m_pImpl
->m_xParent
;
1008 void SAL_CALL
OReportDefinition::setParent( const uno::Reference
< uno::XInterface
>& Parent
)
1010 ::osl::MutexGuard
aGuard(m_aMutex
);
1011 m_aProps
->m_xParent
= uno::Reference
< container::XChild
>(Parent
,uno::UNO_QUERY
);
1012 m_pImpl
->m_xParent
= Parent
;
1013 uno::Reference
< container::XChild
> xChild
;
1014 comphelper::query_aggregation(m_aProps
->m_xProxy
,xChild
);
1016 xChild
->setParent(Parent
);
1020 uno::Reference
< util::XCloneable
> SAL_CALL
OReportDefinition::createClone( )
1022 OSL_FAIL("Not yet implemented correctly");
1023 uno::Reference
< report::XReportComponent
> xSource
= this;
1024 uno::Reference
< report::XReportDefinition
> xSet(cloneObject(xSource
,m_aProps
->m_xFactory
,SERVICE_REPORTDEFINITION
),uno::UNO_QUERY_THROW
);
1028 void OReportDefinition::setSection( const OUString
& _sProperty
1030 ,const OUString
& _sName
1031 ,uno::Reference
< report::XSection
>& _member
)
1035 ::osl::MutexGuard
aGuard(m_aMutex
);
1036 prepareSet(_sProperty
, uno::Any(_member
), uno::Any(_bOn
), &l
);
1038 // create section if needed
1039 if ( _bOn
&& !_member
.is() )
1040 _member
= OSection::createOSection(this, getContext(), _sProperty
== PROPERTY_PAGEHEADERON
|| _sProperty
== PROPERTY_PAGEFOOTERON
);
1042 ::comphelper::disposeComponent(_member
);
1045 _member
->setName(_sName
);
1050 // XCloseBroadcaster
1051 void SAL_CALL
OReportDefinition::addCloseListener( const uno::Reference
< util::XCloseListener
>& _xListener
)
1053 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1054 if ( _xListener
.is() )
1055 m_pImpl
->m_aCloseListener
.addInterface(_xListener
);
1058 void SAL_CALL
OReportDefinition::removeCloseListener( const uno::Reference
< util::XCloseListener
>& _xListener
)
1060 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1061 m_pImpl
->m_aCloseListener
.removeInterface(_xListener
);
1065 void SAL_CALL
OReportDefinition::close(sal_Bool bDeliverOwnership
)
1067 SolarMutexGuard aSolarGuard
;
1069 ::osl::ResettableMutexGuard
aGuard(m_aMutex
);
1070 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1071 // notify our container listeners
1072 lang::EventObject
aEvt( getXWeak() );
1074 m_pImpl
->m_aCloseListener
.forEach(
1075 [&aEvt
, &bDeliverOwnership
] (uno::Reference
<util::XCloseListener
> const& xListener
) {
1076 return xListener
->queryClosing(aEvt
, bDeliverOwnership
);
1081 ::std::vector
< uno::Reference
< frame::XController
> > aCopy
= m_pImpl
->m_aControllers
;
1082 for (auto& rxController
: aCopy
)
1084 if ( rxController
.is() )
1088 uno::Reference
< util::XCloseable
> xFrame( rxController
->getFrame(), uno::UNO_QUERY
);
1090 xFrame
->close( bDeliverOwnership
);
1092 catch (const util::CloseVetoException
&) { throw; }
1093 catch (const uno::Exception
&)
1095 TOOLS_WARN_EXCEPTION( "reportdesign", "ODatabaseDocument::impl_closeControllerFrames" );
1101 m_pImpl
->m_aCloseListener
.notifyEach(&util::XCloseListener::notifyClosing
,aEvt
);
1108 sal_Bool SAL_CALL
OReportDefinition::attachResource( const OUString
& /*_rURL*/, const uno::Sequence
< beans::PropertyValue
>& _aArguments
)
1110 // LLA: we had a deadlock problem in our context, so we get the SolarMutex earlier.
1111 SolarMutexGuard aSolarGuard
;
1113 ::osl::MutexGuard
aGuard(m_aMutex
);
1114 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper
.bDisposed
);
1115 utl::MediaDescriptor
aDescriptor( _aArguments
);
1117 m_pImpl
->m_pUndoManager
->GetSfxUndoManager().EnableUndo( false );
1120 fillArgs(aDescriptor
);
1121 m_pImpl
->m_pReportModel
->SetModified(false);
1125 m_pImpl
->m_pUndoManager
->GetSfxUndoManager().EnableUndo( true );
1128 m_pImpl
->m_pUndoManager
->GetSfxUndoManager().EnableUndo( true );
1132 void OReportDefinition::fillArgs(utl::MediaDescriptor
& _aDescriptor
)
1134 uno::Sequence
<beans::PropertyValue
> aComponentData
;
1135 aComponentData
= _aDescriptor
.getUnpackedValueOrDefault("ComponentData",aComponentData
);
1136 if ( aComponentData
.hasElements() && (!m_pImpl
->m_xActiveConnection
.is() || !m_pImpl
->m_xNumberFormatsSupplier
.is()) )
1138 ::comphelper::SequenceAsHashMap
aComponentDataMap( aComponentData
);
1139 m_pImpl
->m_xActiveConnection
= aComponentDataMap
.getUnpackedValueOrDefault("ActiveConnection",m_pImpl
->m_xActiveConnection
);
1140 m_pImpl
->m_xNumberFormatsSupplier
= dbtools::getNumberFormats(m_pImpl
->m_xActiveConnection
);
1142 if ( !m_pImpl
->m_xNumberFormatsSupplier
.is() )
1144 m_pImpl
->m_xNumberFormatsSupplier
.set( util::NumberFormatsSupplier::createWithDefaultLocale( m_aProps
->m_xContext
) );
1146 lcl_stripLoadArguments( _aDescriptor
, m_pImpl
->m_aArgs
);
1148 sCaption
= _aDescriptor
.getUnpackedValueOrDefault("DocumentTitle",sCaption
);
1149 setCaption(sCaption
);
1152 OUString SAL_CALL
OReportDefinition::getURL( )
1157 uno::Sequence
< beans::PropertyValue
> SAL_CALL
OReportDefinition::getArgs( )
1159 ::osl::MutexGuard
aGuard(m_aMutex
);
1160 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1161 return m_pImpl
->m_aArgs
;
1164 void SAL_CALL
OReportDefinition::connectController( const uno::Reference
< frame::XController
>& _xController
)
1166 ::osl::MutexGuard
aGuard(m_aMutex
);
1167 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1168 m_pImpl
->m_aControllers
.push_back(_xController
);
1169 if ( _xController
.is() && m_pImpl
->m_xViewData
.is() )
1171 sal_Int32 nCount
= m_pImpl
->m_xViewData
->getCount();
1173 _xController
->restoreViewData(m_pImpl
->m_xViewData
->getByIndex(nCount
- 1));
1177 void SAL_CALL
OReportDefinition::disconnectController( const uno::Reference
< frame::XController
>& _xController
)
1179 ::osl::MutexGuard
aGuard(m_aMutex
);
1180 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1181 ::std::vector
< uno::Reference
< frame::XController
> >::iterator aFind
= ::std::find(m_pImpl
->m_aControllers
.begin(),m_pImpl
->m_aControllers
.end(),_xController
);
1182 if ( aFind
!= m_pImpl
->m_aControllers
.end() )
1183 m_pImpl
->m_aControllers
.erase(aFind
);
1184 if ( m_pImpl
->m_xCurrentController
== _xController
)
1185 m_pImpl
->m_xCurrentController
.clear();
1188 void SAL_CALL
OReportDefinition::lockControllers( )
1190 ::osl::MutexGuard
aGuard(m_aMutex
);
1191 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1192 m_pImpl
->m_bControllersLocked
= true;
1195 void SAL_CALL
OReportDefinition::unlockControllers( )
1197 ::osl::MutexGuard
aGuard(m_aMutex
);
1198 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1199 m_pImpl
->m_bControllersLocked
= false;
1202 sal_Bool SAL_CALL
OReportDefinition::hasControllersLocked( )
1204 ::osl::MutexGuard
aGuard(m_aMutex
);
1205 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1206 return m_pImpl
->m_bControllersLocked
;
1209 uno::Reference
< frame::XController
> SAL_CALL
OReportDefinition::getCurrentController( )
1211 ::osl::MutexGuard
aGuard(m_aMutex
);
1212 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1213 return m_pImpl
->m_xCurrentController
;
1216 void SAL_CALL
OReportDefinition::setCurrentController( const uno::Reference
< frame::XController
>& _xController
)
1218 ::osl::MutexGuard
aGuard(m_aMutex
);
1219 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1220 if ( ::std::find(m_pImpl
->m_aControllers
.begin(),m_pImpl
->m_aControllers
.end(),_xController
) == m_pImpl
->m_aControllers
.end() )
1221 throw container::NoSuchElementException();
1222 m_pImpl
->m_xCurrentController
= _xController
;
1225 uno::Reference
< uno::XInterface
> SAL_CALL
OReportDefinition::getCurrentSelection( )
1227 return uno::Reference
< uno::XInterface
>();
1230 void OReportDefinition::impl_loadFromStorage_nolck_throw( const uno::Reference
< embed::XStorage
>& _xStorageToLoadFrom
,
1231 const uno::Sequence
< beans::PropertyValue
>& _aMediaDescriptor
)
1233 m_pImpl
->m_xStorage
= _xStorageToLoadFrom
;
1235 utl::MediaDescriptor
aDescriptor( _aMediaDescriptor
);
1236 fillArgs(aDescriptor
);
1237 aDescriptor
.createItemIfMissing("Storage",uno::Any(_xStorageToLoadFrom
));
1239 uno::Sequence
< uno::Any
> aDelegatorArguments(_aMediaDescriptor
.getLength());
1240 uno::Any
* pIter
= aDelegatorArguments
.getArray();
1241 uno::Any
* pEnd
= pIter
+ aDelegatorArguments
.getLength();
1242 for(sal_Int32 i
= 0;pIter
!= pEnd
;++pIter
,++i
)
1244 *pIter
<<= _aMediaDescriptor
[i
];
1246 sal_Int32 nPos
= aDelegatorArguments
.getLength();
1247 aDelegatorArguments
.realloc(nPos
+1);
1248 beans::PropertyValue aPropVal
;
1249 aPropVal
.Name
= "Storage";
1250 aPropVal
.Value
<<= _xStorageToLoadFrom
;
1251 aDelegatorArguments
.getArray()[nPos
] <<= aPropVal
;
1253 rptui::OXUndoEnvironment
& rEnv
= m_pImpl
->m_pReportModel
->GetUndoEnv();
1254 rptui::OXUndoEnvironment::OUndoEnvLock
aLock(rEnv
);
1256 uno::Reference
< document::XFilter
> xFilter(
1257 m_aProps
->m_xContext
->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.comp.report.OReportFilter",aDelegatorArguments
,m_aProps
->m_xContext
),
1258 uno::UNO_QUERY_THROW
);
1260 uno::Reference
< document::XImporter
> xImporter(xFilter
,uno::UNO_QUERY_THROW
);
1261 uno::Reference
<XComponent
> xComponent(getXWeak(),uno::UNO_QUERY
);
1262 xImporter
->setTargetDocument(xComponent
);
1264 utl::MediaDescriptor aTemp
;
1265 aTemp
<< aDelegatorArguments
;
1266 xFilter
->filter(aTemp
.getAsConstPropertyValueList());
1268 lcl_setModelReadOnly(m_pImpl
->m_xStorage
,m_pImpl
->m_pReportModel
);
1269 m_pImpl
->m_pObjectContainer
->SwitchPersistence(m_pImpl
->m_xStorage
);
1273 // XStorageBasedDocument
1274 void SAL_CALL
OReportDefinition::loadFromStorage( const uno::Reference
< embed::XStorage
>& _xStorageToLoadFrom
1275 , const uno::Sequence
< beans::PropertyValue
>& _aMediaDescriptor
)
1277 ::osl::MutexGuard
aGuard(m_aMutex
);
1278 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1280 impl_loadFromStorage_nolck_throw( _xStorageToLoadFrom
, _aMediaDescriptor
);
1283 void SAL_CALL
OReportDefinition::storeToStorage( const uno::Reference
< embed::XStorage
>& _xStorageToSaveTo
, const uno::Sequence
< beans::PropertyValue
>& _aMediaDescriptor
)
1285 if ( !_xStorageToSaveTo
.is() )
1286 throw lang::IllegalArgumentException(RptResId(RID_STR_ARGUMENT_IS_NULL
),*this,1);
1288 SolarMutexGuard aSolarGuard
;
1289 ::osl::MutexGuard
aGuard(m_aMutex
);
1290 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1291 // create XStatusIndicator
1292 uno::Reference
<task::XStatusIndicator
> xStatusIndicator
;
1293 uno::Sequence
< uno::Any
> aDelegatorArguments
;
1294 utl::MediaDescriptor
aDescriptor( _aMediaDescriptor
);
1295 lcl_extractAndStartStatusIndicator( aDescriptor
, xStatusIndicator
, aDelegatorArguments
);
1296 bool AutoSaveEvent
= false;
1297 aDescriptor
[utl::MediaDescriptor::PROP_AUTOSAVEEVENT
] >>= AutoSaveEvent
;
1300 uno::Sequence
< beans::PropertyValue
> aProps
;
1302 // export sub streams for package, else full stream into a file
1303 uno::Reference
< beans::XPropertySet
> xProp(_xStorageToSaveTo
,uno::UNO_QUERY
);
1306 static constexpr OUStringLiteral sPropName
= u
"MediaType";
1307 OUString sOldMediaType
;
1308 xProp
->getPropertyValue(sPropName
) >>= sOldMediaType
;
1309 if ( !xProp
->getPropertyValue(sPropName
).hasValue() || sOldMediaType
.isEmpty() || MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII
!= sOldMediaType
)
1310 xProp
->setPropertyValue( sPropName
, uno::Any(OUString(MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII
)) );
1313 /** property map for export info set */
1314 static comphelper::PropertyMapEntry
const aExportInfoMap
[] =
1316 { OUString("UsePrettyPrinting") , 0, cppu::UnoType
<sal_Bool
>::get(), beans::PropertyAttribute::MAYBEVOID
, 0 },
1317 { OUString("StreamName") , 0, cppu::UnoType
<OUString
>::get(), beans::PropertyAttribute::MAYBEVOID
, 0 },
1318 { OUString("StreamRelPath") , 0, cppu::UnoType
<OUString
>::get(), beans::PropertyAttribute::MAYBEVOID
, 0 },
1319 { OUString("BaseURI") , 0, cppu::UnoType
<OUString
>::get(), beans::PropertyAttribute::MAYBEVOID
, 0 },
1321 uno::Reference
< beans::XPropertySet
> xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap
) ) );
1323 xInfoSet
->setPropertyValue("UsePrettyPrinting", uno::Any(officecfg::Office::Common::Save::Document::PrettyPrinting::get()));
1324 if ( officecfg::Office::Common::Save::URL::FileSystem::get() )
1326 const OUString
sVal( aDescriptor
.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_DOCUMENTBASEURL
, OUString()) );
1327 xInfoSet
->setPropertyValue("BaseURI", uno::Any(sVal
));
1329 const OUString
sHierarchicalDocumentName( aDescriptor
.getUnpackedValueOrDefault("HierarchicalDocumentName",OUString()) );
1330 xInfoSet
->setPropertyValue("StreamRelPath", uno::Any(sHierarchicalDocumentName
));
1333 sal_Int32 nArgsLen
= aDelegatorArguments
.getLength();
1334 aDelegatorArguments
.realloc(nArgsLen
+3);
1335 auto pDelegatorArguments
= aDelegatorArguments
.getArray();
1336 pDelegatorArguments
[nArgsLen
++] <<= xInfoSet
;
1338 uno::Reference
< document::XEmbeddedObjectResolver
> xObjectResolver
;
1339 uno::Reference
<document::XGraphicStorageHandler
> xGraphicStorageHandler
;
1340 rtl::Reference
<SvXMLGraphicHelper
> xGraphicHelper
= SvXMLGraphicHelper::Create(_xStorageToSaveTo
,SvXMLGraphicHelperMode::Write
);
1341 xGraphicStorageHandler
= xGraphicHelper
.get();
1342 xGraphicHelper
.clear();
1343 xObjectResolver
= SvXMLEmbeddedObjectHelper::Create( _xStorageToSaveTo
,*this, SvXMLEmbeddedObjectHelperMode::Write
).get();
1345 pDelegatorArguments
[nArgsLen
++] <<= xGraphicStorageHandler
;
1346 pDelegatorArguments
[nArgsLen
++] <<= xObjectResolver
;
1348 uno::Reference
<XComponent
> xCom(getXWeak(),uno::UNO_QUERY
);
1349 // Try to write to settings.xml, meta.xml, and styles.xml; only really care about success of
1350 // write to content.xml (keeping logic of commit 94ccba3eebc83b58e74e18f0e028c6a995ce6aa6)
1351 xInfoSet
->setPropertyValue("StreamName", uno::Any(OUString("settings.xml")));
1352 WriteThroughComponent(xCom
, "settings.xml", "com.sun.star.comp.report.XMLSettingsExporter",
1353 aDelegatorArguments
, aProps
, _xStorageToSaveTo
);
1355 xInfoSet
->setPropertyValue("StreamName", uno::Any(OUString("meta.xml")));
1356 WriteThroughComponent(xCom
, "meta.xml", "com.sun.star.comp.report.XMLMetaExporter",
1357 aDelegatorArguments
, aProps
, _xStorageToSaveTo
);
1359 xInfoSet
->setPropertyValue("StreamName", uno::Any(OUString("styles.xml")));
1360 WriteThroughComponent(xCom
, "styles.xml", "com.sun.star.comp.report.XMLStylesExporter",
1361 aDelegatorArguments
, aProps
, _xStorageToSaveTo
);
1363 xInfoSet
->setPropertyValue("StreamName", uno::Any(OUString("content.xml")));
1364 bool bOk
= WriteThroughComponent(xCom
, "content.xml", "com.sun.star.comp.report.ExportFilter",
1365 aDelegatorArguments
, aProps
, _xStorageToSaveTo
);
1368 uno::Reference
< embed::XVisualObject
> xCurrentController(getCurrentController(),uno::UNO_QUERY
);
1369 if ( xCurrentController
.is() )
1371 xCurrentController
->setVisualAreaSize(m_pImpl
->m_nAspect
,m_pImpl
->m_aVisualAreaSize
);
1372 aImage
= xCurrentController
->getPreferredVisualRepresentation( m_pImpl
->m_nAspect
).Data
;
1374 if ( aImage
.hasValue() )
1376 uno::Sequence
<sal_Int8
> aSeq
;
1378 uno::Reference
<io::XInputStream
> xStream
= new ::comphelper::SequenceInputStream( aSeq
);
1379 m_pImpl
->m_pObjectContainer
->InsertGraphicStreamDirectly(xStream
, "report", "image/png");
1384 bool bPersist
= false;
1385 if ( _xStorageToSaveTo
== m_pImpl
->m_xStorage
)
1386 bPersist
= m_pImpl
->m_pObjectContainer
->StoreChildren(true,false);
1388 bPersist
= m_pImpl
->m_pObjectContainer
->StoreAsChildren(true,true,AutoSaveEvent
,_xStorageToSaveTo
);
1391 m_pImpl
->m_pObjectContainer
->SetPersistentEntries(m_pImpl
->m_xStorage
);
1394 uno::Reference
<embed::XTransactedObject
> xTransact(_xStorageToSaveTo
,uno::UNO_QUERY
);
1395 if ( xTransact
.is() )
1396 xTransact
->commit();
1398 catch (const uno::Exception
&)
1400 TOOLS_WARN_EXCEPTION( "reportdesign", "Could not commit report storage!");
1401 throw io::IOException();
1404 if ( _xStorageToSaveTo
== m_pImpl
->m_xStorage
)
1407 if ( xStatusIndicator
.is() )
1408 xStatusIndicator
->end();
1411 void SAL_CALL
OReportDefinition::switchToStorage(
1412 const uno::Reference
< embed::XStorage
>& xStorage
)
1415 throw lang::IllegalArgumentException(RptResId(RID_STR_ARGUMENT_IS_NULL
),*this,1);
1417 ::osl::MutexGuard
aGuard(m_aMutex
);
1418 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1419 m_pImpl
->m_xStorage
= xStorage
;
1420 lcl_setModelReadOnly(m_pImpl
->m_xStorage
,m_pImpl
->m_pReportModel
);
1421 m_pImpl
->m_pObjectContainer
->SwitchPersistence(m_pImpl
->m_xStorage
);
1423 // notify our container listeners
1424 m_pImpl
->m_aStorageChangeListeners
.forEach(
1425 [this, &xStorage
] (uno::Reference
<document::XStorageChangeListener
> const& xListener
) {
1426 return xListener
->notifyStorageChange(getXWeak(), xStorage
);
1430 uno::Reference
< embed::XStorage
> SAL_CALL
OReportDefinition::getDocumentStorage( )
1432 ::osl::MutexGuard
aGuard(m_aMutex
);
1433 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1434 return m_pImpl
->m_xStorage
;
1437 void SAL_CALL
OReportDefinition::addStorageChangeListener( const uno::Reference
< document::XStorageChangeListener
>& xListener
)
1439 ::osl::MutexGuard
aGuard(m_aMutex
);
1440 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1441 if ( xListener
.is() )
1442 m_pImpl
->m_aStorageChangeListeners
.addInterface(xListener
);
1445 void SAL_CALL
OReportDefinition::removeStorageChangeListener( const uno::Reference
< document::XStorageChangeListener
>& xListener
)
1447 ::osl::MutexGuard
aGuard(m_aMutex
);
1448 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1449 m_pImpl
->m_aStorageChangeListeners
.removeInterface(xListener
);
1452 bool OReportDefinition::WriteThroughComponent(
1453 const uno::Reference
<lang::XComponent
> & xComponent
,
1454 const char* pStreamName
,
1455 const char* pServiceName
,
1456 const uno::Sequence
<uno::Any
> & rArguments
,
1457 const uno::Sequence
<beans::PropertyValue
> & rMediaDesc
,
1458 const uno::Reference
<embed::XStorage
>& _xStorageToSaveTo
)
1460 OSL_ENSURE( nullptr != pStreamName
, "Need stream name!" );
1461 OSL_ENSURE( nullptr != pServiceName
, "Need service name!" );
1464 OUString sStreamName
= OUString::createFromAscii( pStreamName
);
1465 uno::Reference
<io::XStream
> xStream
= _xStorageToSaveTo
->openStreamElement( sStreamName
,embed::ElementModes::READWRITE
| embed::ElementModes::TRUNCATE
);
1466 if ( !xStream
.is() )
1468 uno::Reference
<io::XOutputStream
> xOutputStream
= xStream
->getOutputStream();
1469 OSL_ENSURE(xOutputStream
.is(), "Can't create output stream in package!");
1470 if ( ! xOutputStream
.is() )
1473 uno::Reference
<beans::XPropertySet
> xStreamProp(xOutputStream
,uno::UNO_QUERY
);
1474 OSL_ENSURE(xStreamProp
.is(),"No valid property set for the output stream!");
1476 uno::Reference
<io::XSeekable
> xSeek(xStreamProp
,uno::UNO_QUERY
);
1482 xStreamProp
->setPropertyValue( "MediaType", uno::Any(OUString("text/xml")) );
1484 // encrypt all streams
1485 xStreamProp
->setPropertyValue( "UseCommonStoragePasswordEncryption",
1488 // set buffer and create outputstream
1491 bool bRet
= WriteThroughComponent(
1492 xOutputStream
, xComponent
,
1493 pServiceName
, rArguments
, rMediaDesc
);
1494 // finally, commit stream.
1498 bool OReportDefinition::WriteThroughComponent(
1499 const uno::Reference
<io::XOutputStream
> & xOutputStream
,
1500 const uno::Reference
<lang::XComponent
> & xComponent
,
1501 const char* pServiceName
,
1502 const uno::Sequence
<uno::Any
> & rArguments
,
1503 const uno::Sequence
<beans::PropertyValue
> & rMediaDesc
)
1505 OSL_ENSURE( xOutputStream
.is(), "I really need an output stream!" );
1506 OSL_ENSURE( xComponent
.is(), "Need component!" );
1507 OSL_ENSURE( nullptr != pServiceName
, "Need component name!" );
1510 uno::Reference
< xml::sax::XWriter
> xSaxWriter(
1511 xml::sax::Writer::create(m_aProps
->m_xContext
) );
1513 // connect XML writer to output stream
1514 xSaxWriter
->setOutputStream( xOutputStream
);
1516 // prepare arguments (prepend doc handler to given arguments)
1517 uno::Sequence
<uno::Any
> aArgs( 1 + rArguments
.getLength() );
1518 auto pArgs
= aArgs
.getArray();
1519 *pArgs
<<= xSaxWriter
;
1520 std::copy(rArguments
.begin(), rArguments
.end(), std::next(pArgs
));
1522 // get filter component
1523 uno::Reference
< document::XExporter
> xExporter(
1524 m_aProps
->m_xContext
->getServiceManager()->createInstanceWithArgumentsAndContext(
1525 OUString::createFromAscii(pServiceName
), aArgs
,m_aProps
->m_xContext
), uno::UNO_QUERY
);
1526 OSL_ENSURE( xExporter
.is(),
1527 "can't instantiate export filter component" );
1528 if( !xExporter
.is() )
1531 // connect model and filter
1532 xExporter
->setSourceDocument( xComponent
);
1535 uno::Reference
<document::XFilter
> xFilter( xExporter
, uno::UNO_QUERY
);
1536 return xFilter
->filter( rMediaDesc
);
1540 void SAL_CALL
OReportDefinition::initNew( )
1542 setPageHeaderOn( true );
1543 setPageFooterOn( true );
1546 void SAL_CALL
OReportDefinition::load( const uno::Sequence
< beans::PropertyValue
>& _rArguments
)
1548 ::osl::MutexGuard
aGuard(m_aMutex
);
1549 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1551 // TODO: this code is pretty similar to what happens in ODatabaseModelImpl::getOrCreateRootStorage,
1552 // perhaps we can share code here.
1554 ::comphelper::NamedValueCollection
aArguments( _rArguments
);
1556 // the source for the to-be-created storage: either a URL, or a stream
1557 uno::Reference
< io::XInputStream
> xStream
;
1560 if ( aArguments
.has( "Stream" ) )
1562 aArguments
.get_ensureType( "Stream", xStream
);
1563 aArguments
.remove( "Stream" );
1565 else if ( aArguments
.has( "InputStream" ) )
1567 aArguments
.get_ensureType( "InputStream", xStream
);
1568 aArguments
.remove( "InputStream" );
1571 if ( aArguments
.has( "FileName" ) )
1573 aArguments
.get_ensureType( "FileName", sURL
);
1574 aArguments
.remove( "FileName" );
1576 else if ( aArguments
.has( "URL" ) )
1578 aArguments
.get_ensureType( "URL", sURL
);
1579 aArguments
.remove( "URL" );
1582 uno::Any aStorageSource
;
1584 aStorageSource
<<= xStream
;
1585 else if ( !sURL
.isEmpty() )
1586 aStorageSource
<<= sURL
;
1588 throw lang::IllegalArgumentException(
1589 "No input source (URL or InputStream) found.",
1595 uno::Reference
< lang::XSingleServiceFactory
> xStorageFactory( embed::StorageFactory::create( m_aProps
->m_xContext
) );
1597 // open read-write per default, unless told otherwise in the MediaDescriptor
1598 uno::Reference
< embed::XStorage
> xDocumentStorage
;
1599 const sal_Int32 nOpenModes
[2] = {
1600 embed::ElementModes::READWRITE
,
1601 embed::ElementModes::READ
1603 size_t nFirstOpenMode
= 0;
1604 if ( aArguments
.has( "ReadOnly" ) )
1606 bool bReadOnly
= false;
1607 aArguments
.get_ensureType( "ReadOnly", bReadOnly
);
1608 nFirstOpenMode
= bReadOnly
? 1 : 0;
1610 const size_t nLastOpenMode
= SAL_N_ELEMENTS( nOpenModes
) - 1;
1611 for ( size_t i
=nFirstOpenMode
; i
<= nLastOpenMode
; ++i
)
1613 uno::Sequence
< uno::Any
> aStorageCreationArgs
{ aStorageSource
, uno::Any(nOpenModes
[i
]) };
1617 xDocumentStorage
.set( xStorageFactory
->createInstanceWithArguments( aStorageCreationArgs
), uno::UNO_QUERY_THROW
);
1619 catch (const uno::Exception
&)
1621 if ( i
== nLastOpenMode
)
1623 css::uno::Any anyEx
= cppu::getCaughtException();
1624 throw lang::WrappedTargetException(
1625 "An error occurred while creating the document storage.",
1634 if ( !xDocumentStorage
.is() )
1636 throw uno::RuntimeException();
1639 if (!aArguments
.has("DocumentBaseURL") && !sURL
.isEmpty())
1641 aArguments
.put("DocumentBaseURL", sURL
);
1644 impl_loadFromStorage_nolck_throw( xDocumentStorage
, aArguments
.getPropertyValues() );
1645 // TODO: do we need to take ownership of the storage? In opposite to loadFromStorage, we created the storage
1646 // ourself here, and perhaps this means we're also responsible for it ...?
1650 void SAL_CALL
OReportDefinition::setVisualAreaSize( ::sal_Int64 _nAspect
, const awt::Size
& _aSize
)
1652 ::osl::MutexGuard
aGuard(m_aMutex
);
1653 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1655 (m_pImpl
->m_aVisualAreaSize
.Width
!= _aSize
.Width
||
1656 m_pImpl
->m_aVisualAreaSize
.Height
!= _aSize
.Height
);
1657 m_pImpl
->m_aVisualAreaSize
= _aSize
;
1659 setModified( true );
1660 m_pImpl
->m_nAspect
= _nAspect
;
1663 awt::Size SAL_CALL
OReportDefinition::getVisualAreaSize( ::sal_Int64
/*_nAspect*/ )
1665 ::osl::MutexGuard
aGuard(m_aMutex
);
1666 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1667 return m_pImpl
->m_aVisualAreaSize
;
1670 embed::VisualRepresentation SAL_CALL
OReportDefinition::getPreferredVisualRepresentation( ::sal_Int64
/*_nAspect*/ )
1672 ::osl::MutexGuard
aGuard(m_aMutex
);
1673 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1674 embed::VisualRepresentation aResult
;
1676 uno::Reference
<io::XInputStream
> xStream
= m_pImpl
->m_pObjectContainer
->GetGraphicStream("report", &sMimeType
);
1679 uno::Sequence
<sal_Int8
> aSeq
;
1680 xStream
->readBytes(aSeq
,xStream
->available());
1681 xStream
->closeInput();
1682 aResult
.Data
<<= aSeq
;
1683 aResult
.Flavor
.MimeType
= sMimeType
;
1684 aResult
.Flavor
.DataType
= cppu::UnoType
<decltype(aSeq
)>::get();
1690 ::sal_Int32 SAL_CALL
OReportDefinition::getMapUnit( ::sal_Int64
/*nAspect*/ )
1692 return embed::EmbedMapUnits::ONE_100TH_MM
;
1696 sal_Bool SAL_CALL
OReportDefinition::disableSetModified( )
1698 ::osl::MutexGuard
aGuard( m_aMutex
);
1699 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper
.bDisposed
);
1701 const bool bWasEnabled
= m_pImpl
->m_bSetModifiedEnabled
;
1702 m_pImpl
->m_bSetModifiedEnabled
= false;
1706 sal_Bool SAL_CALL
OReportDefinition::enableSetModified( )
1708 ::osl::MutexGuard
aGuard( m_aMutex
);
1709 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper
.bDisposed
);
1711 const bool bWasEnabled
= m_pImpl
->m_bSetModifiedEnabled
;
1712 m_pImpl
->m_bSetModifiedEnabled
= true;
1716 sal_Bool SAL_CALL
OReportDefinition::isSetModifiedEnabled( )
1718 ::osl::MutexGuard
aGuard( m_aMutex
);
1719 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper
.bDisposed
);
1721 return m_pImpl
->m_bSetModifiedEnabled
;
1725 sal_Bool SAL_CALL
OReportDefinition::isModified( )
1727 ::osl::MutexGuard
aGuard(m_aMutex
);
1728 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1729 return m_pImpl
->m_bModified
;
1732 void SAL_CALL
OReportDefinition::setModified( sal_Bool _bModified
)
1734 osl::ClearableMutexGuard
aGuard(m_aMutex
);
1735 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1737 if ( !m_pImpl
->m_bSetModifiedEnabled
)
1740 if ( m_pImpl
->m_pReportModel
->IsReadOnly() && _bModified
)
1741 throw beans::PropertyVetoException();
1742 if ( m_pImpl
->m_bModified
!= bool(_bModified
) )
1744 m_pImpl
->m_bModified
= _bModified
;
1745 if ( m_pImpl
->m_pReportModel
->IsChanged() != bool(_bModified
) )
1746 m_pImpl
->m_pReportModel
->SetChanged(_bModified
);
1748 lang::EventObject
aEvent(*this);
1750 m_pImpl
->m_aModifyListeners
.notifyEach(&util::XModifyListener::modified
,aEvent
);
1751 notifyEvent("OnModifyChanged");
1755 // XModifyBroadcaster
1756 void SAL_CALL
OReportDefinition::addModifyListener( const uno::Reference
< util::XModifyListener
>& _xListener
)
1758 ::osl::MutexGuard
aGuard(m_aMutex
);
1759 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1760 if ( _xListener
.is() )
1761 m_pImpl
->m_aModifyListeners
.addInterface(_xListener
);
1764 void SAL_CALL
OReportDefinition::removeModifyListener( const uno::Reference
< util::XModifyListener
>& _xListener
)
1766 ::osl::MutexGuard
aGuard(m_aMutex
);
1767 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1768 m_pImpl
->m_aModifyListeners
.removeInterface(_xListener
);
1771 void OReportDefinition::notifyEvent(const OUString
& _sEventName
)
1775 osl::ClearableMutexGuard
aGuard(m_aMutex
);
1776 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1777 document::EventObject
aEvt(*this, _sEventName
);
1779 m_pImpl
->m_aLegacyEventListeners
.notifyEach(&document::XEventListener::notifyEvent
,aEvt
);
1781 catch (const uno::Exception
&)
1785 notifyDocumentEvent(_sEventName
, nullptr, css::uno::Any());
1788 // document::XDocumentEventBroadcaster
1789 void SAL_CALL
OReportDefinition::notifyDocumentEvent( const OUString
& rEventName
, const uno::Reference
< frame::XController2
>& rViewController
, const uno::Any
& rSupplement
)
1793 osl::ClearableMutexGuard
aGuard(m_aMutex
);
1794 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1795 document::DocumentEvent
aEvt(*this, rEventName
, rViewController
, rSupplement
);
1797 m_pImpl
->m_aDocEventListeners
.notifyEach(&document::XDocumentEventListener::documentEventOccured
,aEvt
);
1799 catch (const uno::Exception
&)
1804 void SAL_CALL
OReportDefinition::addDocumentEventListener( const uno::Reference
< document::XDocumentEventListener
>& rListener
)
1806 ::osl::MutexGuard
aGuard(m_aMutex
);
1807 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1808 if ( rListener
.is() )
1809 m_pImpl
->m_aDocEventListeners
.addInterface(rListener
);
1812 void SAL_CALL
OReportDefinition::removeDocumentEventListener( const uno::Reference
< document::XDocumentEventListener
>& rListener
)
1814 ::osl::MutexGuard
aGuard(m_aMutex
);
1815 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1816 m_pImpl
->m_aDocEventListeners
.removeInterface(rListener
);
1819 // document::XEventBroadcaster
1820 void SAL_CALL
OReportDefinition::addEventListener(const uno::Reference
< document::XEventListener
>& _xListener
)
1822 ::osl::MutexGuard
aGuard(m_aMutex
);
1823 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1824 if ( _xListener
.is() )
1825 m_pImpl
->m_aLegacyEventListeners
.addInterface(_xListener
);
1828 void SAL_CALL
OReportDefinition::removeEventListener( const uno::Reference
< document::XEventListener
>& _xListener
)
1830 ::osl::MutexGuard
aGuard(m_aMutex
);
1831 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1832 m_pImpl
->m_aLegacyEventListeners
.removeInterface(_xListener
);
1835 // document::XViewDataSupplier
1836 uno::Reference
< container::XIndexAccess
> SAL_CALL
OReportDefinition::getViewData( )
1838 ::osl::MutexGuard
aGuard(m_aMutex
);
1839 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1840 if ( !m_pImpl
->m_xViewData
.is() )
1842 rtl::Reference
<comphelper::IndexedPropertyValuesContainer
> xNewViewData
= new comphelper::IndexedPropertyValuesContainer();
1843 m_pImpl
->m_xViewData
= xNewViewData
;
1844 for (const auto& rxController
: m_pImpl
->m_aControllers
)
1846 if ( rxController
.is() )
1850 xNewViewData
->insertByIndex(xNewViewData
->getCount(), rxController
->getViewData());
1852 catch (const uno::Exception
&)
1859 return m_pImpl
->m_xViewData
;
1862 void SAL_CALL
OReportDefinition::setViewData( const uno::Reference
< container::XIndexAccess
>& Data
)
1864 ::osl::MutexGuard
aGuard(m_aMutex
);
1865 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1866 m_pImpl
->m_xViewData
= Data
;
1869 uno::Reference
< report::XFunctions
> SAL_CALL
OReportDefinition::getFunctions()
1871 ::osl::MutexGuard
aGuard(m_aMutex
);
1872 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1873 return m_pImpl
->m_xFunctions
;
1876 uno::Reference
< ui::XUIConfigurationManager
> SAL_CALL
OReportDefinition::getUIConfigurationManager( )
1878 return uno::Reference
< ui::XUIConfigurationManager
>( getUIConfigurationManager2(), uno::UNO_QUERY_THROW
);
1881 uno::Reference
< ui::XUIConfigurationManager2
> OReportDefinition::getUIConfigurationManager2( )
1883 ::osl::MutexGuard
aGuard(m_aMutex
);
1884 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1886 if ( !m_pImpl
->m_xUIConfigurationManager
.is() )
1888 m_pImpl
->m_xUIConfigurationManager
= ui::UIConfigurationManager::create(m_aProps
->m_xContext
);
1890 uno::Reference
< embed::XStorage
> xConfigStorage
;
1891 // initialize ui configuration manager with document substorage
1892 m_pImpl
->m_xUIConfigurationManager
->setStorage( xConfigStorage
);
1895 return m_pImpl
->m_xUIConfigurationManager
;
1898 uno::Reference
< embed::XStorage
> SAL_CALL
OReportDefinition::getDocumentSubStorage( const OUString
& aStorageName
, sal_Int32 nMode
)
1900 ::osl::MutexGuard
aGuard(m_aMutex
);
1901 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1902 return m_pImpl
->m_xStorage
->openStorageElement(aStorageName
, nMode
);
1905 uno::Sequence
< OUString
> SAL_CALL
OReportDefinition::getDocumentSubStoragesNames( )
1907 ::osl::MutexGuard
aGuard(m_aMutex
);
1908 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1909 uno::Reference
<container::XNameAccess
> xNameAccess
= m_pImpl
->m_xStorage
;
1910 return xNameAccess
.is() ? xNameAccess
->getElementNames() : uno::Sequence
< OUString
>();
1913 OUString SAL_CALL
OReportDefinition::getMimeType()
1915 ::osl::MutexGuard
aGuard(m_aMutex
);
1916 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1917 return m_pImpl
->m_sMimeType
;
1920 void SAL_CALL
OReportDefinition::setMimeType( const OUString
& _mimetype
)
1922 ::osl::MutexGuard
aGuard(m_aMutex
);
1923 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1924 const uno::Sequence
< OUString
> aList
= getAvailableMimeTypes();
1925 if ( ::std::find(aList
.begin(), aList
.end(), _mimetype
) == aList
.end() )
1926 throwIllegallArgumentException(u
"getAvailableMimeTypes()"
1929 set(PROPERTY_MIMETYPE
,_mimetype
,m_pImpl
->m_sMimeType
);
1932 uno::Sequence
< OUString
> SAL_CALL
OReportDefinition::getAvailableMimeTypes( )
1934 return { MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII
, MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII
};
1938 sal_Int64 SAL_CALL
OReportDefinition::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
1941 if (comphelper::isUnoTunnelId
<OReportDefinition
>(rId
) )
1942 nRet
= comphelper::getSomething_cast(this);
1945 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel(m_pImpl
->m_xNumberFormatsSupplier
,uno::UNO_QUERY
);
1946 if ( xUnoTunnel
.is() )
1947 nRet
= xUnoTunnel
->getSomething(rId
);
1951 uno::Reference
< lang::XUnoTunnel
> xTunnel
;
1952 ::comphelper::query_aggregation(m_aProps
->m_xProxy
,xTunnel
);
1954 nRet
= xTunnel
->getSomething(rId
);
1960 uno::Sequence
< sal_Int8
> SAL_CALL
OReportDefinition::getImplementationId( )
1962 return css::uno::Sequence
<sal_Int8
>();
1965 const uno::Sequence
< sal_Int8
> & OReportDefinition::getUnoTunnelId()
1967 static const comphelper::UnoIdInit implId
;
1968 return implId
.getSeq();
1971 uno::Reference
< uno::XComponentContext
> OReportDefinition::getContext()
1973 ::osl::MutexGuard
aGuard(m_aMutex
);
1974 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1975 return m_aProps
->m_xContext
;
1978 std::shared_ptr
<rptui::OReportModel
> OReportDefinition::getSdrModel(const uno::Reference
< report::XReportDefinition
>& _xReportDefinition
)
1980 std::shared_ptr
<rptui::OReportModel
> pReportModel
;
1981 auto pReportDefinition
= comphelper::getFromUnoTunnel
<OReportDefinition
>(_xReportDefinition
);
1982 if (pReportDefinition
)
1983 pReportModel
= pReportDefinition
->m_pImpl
->m_pReportModel
;
1984 return pReportModel
;
1987 SdrModel
& OReportDefinition::getSdrModelFromUnoModel() const
1989 OSL_ENSURE(m_pImpl
->m_pReportModel
, "No SdrModel in ReportDesign, should not happen");
1990 return *m_pImpl
->m_pReportModel
;
1993 uno::Reference
< uno::XInterface
> SAL_CALL
OReportDefinition::createInstanceWithArguments( const OUString
& aServiceSpecifier
, const uno::Sequence
< uno::Any
>& _aArgs
)
1995 ::osl::MutexGuard
aGuard(m_aMutex
);
1996 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1998 uno::Reference
< uno::XInterface
> xRet
;
1999 if ( aServiceSpecifier
.startsWith( "com.sun.star.document.ImportEmbeddedObjectResolver") )
2001 uno::Reference
< embed::XStorage
> xStorage
;
2002 for(const uno::Any
& rArg
: _aArgs
)
2004 beans::NamedValue aValue
;
2006 if ( aValue
.Name
== "Storage" )
2007 aValue
.Value
>>= xStorage
;
2009 m_pImpl
->m_pObjectContainer
->SwitchPersistence(xStorage
);
2010 xRet
= cppu::getXWeak(SvXMLEmbeddedObjectHelper::Create( xStorage
,*this, SvXMLEmbeddedObjectHelperMode::Read
).get());
2012 else if (aServiceSpecifier
== "com.sun.star.drawing.OLE2Shape")
2014 uno::Reference
<drawing::XShape
> xShape(SvxUnoDrawMSFactory::createInstanceWithArguments(aServiceSpecifier
, _aArgs
), uno::UNO_QUERY_THROW
);
2015 xRet
= m_pImpl
->m_pReportModel
->createShape(aServiceSpecifier
, xShape
);
2021 uno::Reference
< uno::XInterface
> SAL_CALL
OReportDefinition::createInstance( const OUString
& aServiceSpecifier
)
2023 ::osl::MutexGuard
aGuard(m_aMutex
);
2024 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2025 uno::Reference
< drawing::XShape
> xShape
;
2026 if ( aServiceSpecifier
.startsWith( "com.sun.star.report." ) )
2028 if ( aServiceSpecifier
== SERVICE_SHAPE
)
2029 xShape
.set(SvxUnoDrawMSFactory::createInstance("com.sun.star.drawing.CustomShape"),uno::UNO_QUERY_THROW
);
2030 else if ( aServiceSpecifier
== SERVICE_FORMATTEDFIELD
2031 || aServiceSpecifier
== SERVICE_FIXEDTEXT
2032 || aServiceSpecifier
== SERVICE_FIXEDLINE
2033 || aServiceSpecifier
== SERVICE_IMAGECONTROL
)
2034 xShape
.set(SvxUnoDrawMSFactory::createInstance("com.sun.star.drawing.ControlShape"),uno::UNO_QUERY_THROW
);
2036 xShape
.set(SvxUnoDrawMSFactory::createInstance("com.sun.star.drawing.OLE2Shape"),uno::UNO_QUERY_THROW
);
2038 else if ( aServiceSpecifier
.startsWith( "com.sun.star.form.component." ) )
2040 xShape
.set(m_aProps
->m_xContext
->getServiceManager()->createInstanceWithContext(aServiceSpecifier
,m_aProps
->m_xContext
),uno::UNO_QUERY
);
2042 else if ( aServiceSpecifier
== "com.sun.star.style.PageStyle" ||
2043 aServiceSpecifier
== "com.sun.star.style.FrameStyle" ||
2044 aServiceSpecifier
== "com.sun.star.style.GraphicStyle"
2047 uno::Reference
< style::XStyle
> xStyle
= new OStyle();
2048 xStyle
->setName("Default");
2051 else if ( aServiceSpecifier
== "com.sun.star.document.Settings" )
2053 uno::Reference
<beans::XPropertySet
> xProp
= new OStyle();
2057 else if ( aServiceSpecifier
== "com.sun.star.drawing.Defaults" )
2059 uno::Reference
<beans::XPropertySet
> xProp
= new OStyle();
2062 else if ( aServiceSpecifier
== "com.sun.star.drawing.GradientTable" )
2064 if ( !m_pImpl
->m_xGradientTable
.is() )
2065 m_pImpl
->m_xGradientTable
.set(SvxUnoGradientTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2066 return m_pImpl
->m_xGradientTable
;
2068 else if ( aServiceSpecifier
== "com.sun.star.drawing.HatchTable" )
2070 if ( !m_pImpl
->m_xHatchTable
.is() )
2071 m_pImpl
->m_xHatchTable
.set(SvxUnoHatchTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2072 return m_pImpl
->m_xHatchTable
;
2074 else if ( aServiceSpecifier
== "com.sun.star.drawing.BitmapTable" )
2076 if ( !m_pImpl
->m_xBitmapTable
.is() )
2077 m_pImpl
->m_xBitmapTable
.set(SvxUnoBitmapTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2078 return m_pImpl
->m_xBitmapTable
;
2080 else if ( aServiceSpecifier
== "com.sun.star.drawing.TransparencyGradientTable" )
2082 if ( !m_pImpl
->m_xTransparencyGradientTable
.is() )
2083 m_pImpl
->m_xTransparencyGradientTable
.set(SvxUnoTransGradientTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2084 return m_pImpl
->m_xTransparencyGradientTable
;
2086 else if ( aServiceSpecifier
== "com.sun.star.drawing.DashTable" )
2088 if ( !m_pImpl
->m_xDashTable
.is() )
2089 m_pImpl
->m_xDashTable
.set(SvxUnoDashTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2090 return m_pImpl
->m_xDashTable
;
2092 else if( aServiceSpecifier
== "com.sun.star.drawing.MarkerTable" )
2094 if( !m_pImpl
->m_xMarkerTable
.is() )
2095 m_pImpl
->m_xMarkerTable
.set(SvxUnoMarkerTable_createInstance( m_pImpl
->m_pReportModel
.get() ),uno::UNO_QUERY
);
2096 return m_pImpl
->m_xMarkerTable
;
2098 else if ( aServiceSpecifier
== "com.sun.star.document.ImportEmbeddedObjectResolver" )
2099 return cppu::getXWeak(SvXMLEmbeddedObjectHelper::Create( m_pImpl
->m_xStorage
,*this, SvXMLEmbeddedObjectHelperMode::Read
).get());
2100 else if ( aServiceSpecifier
== "com.sun.star.document.ExportEmbeddedObjectResolver" )
2101 return cppu::getXWeak(SvXMLEmbeddedObjectHelper::Create( m_pImpl
->m_xStorage
,*this, SvXMLEmbeddedObjectHelperMode::Write
).get());
2102 else if (aServiceSpecifier
== "com.sun.star.document.ImportGraphicStorageHandler")
2104 rtl::Reference
<SvXMLGraphicHelper
> xGraphicHelper
= SvXMLGraphicHelper::Create(m_pImpl
->m_xStorage
,SvXMLGraphicHelperMode::Write
);
2105 return cppu::getXWeak(xGraphicHelper
.get());
2107 else if (aServiceSpecifier
== "com.sun.star.document.ExportGraphicStorageHandler")
2109 rtl::Reference
<SvXMLGraphicHelper
> xGraphicHelper
= SvXMLGraphicHelper::Create(m_pImpl
->m_xStorage
,SvXMLGraphicHelperMode::Write
);
2110 return cppu::getXWeak(xGraphicHelper
.get());
2112 else if ( aServiceSpecifier
== "com.sun.star.chart2.data.DataProvider" )
2114 uno::Reference
<chart2::data::XDatabaseDataProvider
> xDataProvider(chart2::data::DatabaseDataProvider::createWithConnection( m_aProps
->m_xContext
, m_pImpl
->m_xActiveConnection
));
2115 xDataProvider
->setRowLimit(10);
2116 uno::Reference
< container::XChild
> xChild(xDataProvider
,uno::UNO_QUERY
);
2118 xChild
->setParent(*this);
2119 return uno::Reference
< uno::XInterface
>(xDataProvider
,uno::UNO_QUERY
);
2121 else if ( aServiceSpecifier
== "com.sun.star.xml.NamespaceMap" )
2123 if ( !m_pImpl
->m_xXMLNamespaceMap
.is() )
2124 m_pImpl
->m_xXMLNamespaceMap
= comphelper::NameContainer_createInstance( cppu::UnoType
<OUString
>::get() ).get();
2125 return m_pImpl
->m_xXMLNamespaceMap
;
2128 xShape
.set(SvxUnoDrawMSFactory::createInstance( aServiceSpecifier
),uno::UNO_QUERY_THROW
);
2130 return m_pImpl
->m_pReportModel
->createShape(aServiceSpecifier
,xShape
);
2133 uno::Sequence
< OUString
> SAL_CALL
OReportDefinition::getAvailableServiceNames()
2135 static const std::u16string_view aSvxComponentServiceNameList
[] =
2137 u
"com.sun.star.form.component.FixedText",
2138 u
"com.sun.star.form.component.DatabaseImageControl",
2139 u
"com.sun.star.style.PageStyle",
2140 u
"com.sun.star.style.GraphicStyle",
2141 u
"com.sun.star.style.FrameStyle",
2142 u
"com.sun.star.drawing.Defaults",
2143 u
"com.sun.star.document.ImportEmbeddedObjectResolver",
2144 u
"com.sun.star.document.ExportEmbeddedObjectResolver",
2145 u
"com.sun.star.document.ImportGraphicStorageHandler",
2146 u
"com.sun.star.document.ExportGraphicStorageHandler",
2147 u
"com.sun.star.chart2.data.DataProvider",
2148 u
"com.sun.star.xml.NamespaceMap",
2149 u
"com.sun.star.document.Settings",
2150 u
"com.sun.star.drawing.GradientTable",
2151 u
"com.sun.star.drawing.HatchTable",
2152 u
"com.sun.star.drawing.BitmapTable",
2153 u
"com.sun.star.drawing.TransparencyGradientTable",
2154 u
"com.sun.star.drawing.DashTable",
2155 u
"com.sun.star.drawing.MarkerTable"
2158 static const sal_uInt16 nSvxComponentServiceNameListCount
= SAL_N_ELEMENTS(aSvxComponentServiceNameList
);
2160 uno::Sequence
< OUString
> aSeq( nSvxComponentServiceNameListCount
);
2161 OUString
* pStrings
= aSeq
.getArray();
2162 for( sal_uInt16 nIdx
= 0; nIdx
< nSvxComponentServiceNameListCount
; nIdx
++ )
2163 pStrings
[nIdx
] = aSvxComponentServiceNameList
[nIdx
];
2165 uno::Sequence
< OUString
> aParentSeq( SvxUnoDrawMSFactory::getAvailableServiceNames() );
2166 return comphelper::concatSequences( aParentSeq
, aSeq
);
2170 awt::Point SAL_CALL
OReportDefinition::getPosition( )
2172 ::osl::MutexGuard
aGuard(m_aMutex
);
2173 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2174 if ( m_aProps
->m_xShape
.is() )
2175 return m_aProps
->m_xShape
->getPosition();
2176 return awt::Point(m_aProps
->m_nPosX
,m_aProps
->m_nPosY
);
2179 void SAL_CALL
OReportDefinition::setPosition( const awt::Point
& aPosition
)
2181 ::osl::MutexGuard
aGuard(m_aMutex
);
2182 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2183 if ( m_aProps
->m_xShape
.is() )
2184 m_aProps
->m_xShape
->setPosition(aPosition
);
2185 set(PROPERTY_POSITIONX
,aPosition
.X
,m_aProps
->m_nPosX
);
2186 set(PROPERTY_POSITIONY
,aPosition
.Y
,m_aProps
->m_nPosY
);
2189 awt::Size SAL_CALL
OReportDefinition::getSize( )
2191 ::osl::MutexGuard
aGuard(m_aMutex
);
2192 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2193 if ( m_aProps
->m_xShape
.is() )
2194 return m_aProps
->m_xShape
->getSize();
2195 return awt::Size(m_aProps
->m_nWidth
,m_aProps
->m_nHeight
);
2198 void SAL_CALL
OReportDefinition::setSize( const awt::Size
& aSize
)
2200 ::osl::MutexGuard
aGuard(m_aMutex
);
2201 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2202 if ( m_aProps
->m_xShape
.is() )
2203 m_aProps
->m_xShape
->setSize(aSize
);
2204 set(PROPERTY_WIDTH
,aSize
.Width
,m_aProps
->m_nWidth
);
2205 set(PROPERTY_HEIGHT
,aSize
.Height
,m_aProps
->m_nHeight
);
2210 OUString SAL_CALL
OReportDefinition::getShapeType( )
2212 ::osl::MutexGuard
aGuard(m_aMutex
);
2213 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2214 if ( m_aProps
->m_xShape
.is() )
2215 return m_aProps
->m_xShape
->getShapeType();
2216 return "com.sun.star.drawing.OLE2Shape";
2219 typedef ::cppu::WeakImplHelper
< container::XNameContainer
,
2220 container::XIndexAccess
2225 class OStylesHelper
:
2226 public cppu::BaseMutex
, public TStylesBASE
2228 typedef ::std::map
< OUString
, uno::Any
, ::comphelper::UStringMixLess
> TStyleElements
;
2229 TStyleElements m_aElements
;
2230 ::std::vector
<TStyleElements::iterator
> m_aElementsPos
;
2234 virtual ~OStylesHelper() override
{}
2236 explicit OStylesHelper(const uno::Type
& rType
= cppu::UnoType
<container::XElementAccess
>::get());
2237 OStylesHelper(const OStylesHelper
&) = delete;
2238 OStylesHelper
& operator=(const OStylesHelper
&) = delete;
2241 virtual void SAL_CALL
insertByName( const OUString
& aName
, const uno::Any
& aElement
) override
;
2242 virtual void SAL_CALL
removeByName( const OUString
& Name
) override
;
2245 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const uno::Any
& aElement
) override
;
2247 // container::XElementAccess
2248 virtual uno::Type SAL_CALL
getElementType( ) override
;
2249 virtual sal_Bool SAL_CALL
hasElements( ) override
;
2250 // container::XIndexAccess
2251 virtual sal_Int32 SAL_CALL
getCount( ) override
;
2252 virtual uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
2254 // container::XNameAccess
2255 virtual uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
2256 virtual uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) override
;
2257 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
2262 OStylesHelper::OStylesHelper(const uno::Type
& rType
)
2269 // container::XElementAccess
2270 uno::Type SAL_CALL
OStylesHelper::getElementType( )
2275 sal_Bool SAL_CALL
OStylesHelper::hasElements( )
2277 ::osl::MutexGuard
aGuard(m_aMutex
);
2278 return !m_aElementsPos
.empty();
2281 // container::XIndexAccess
2282 sal_Int32 SAL_CALL
OStylesHelper::getCount( )
2284 ::osl::MutexGuard
aGuard(m_aMutex
);
2285 return m_aElementsPos
.size();
2288 uno::Any SAL_CALL
OStylesHelper::getByIndex( sal_Int32 Index
)
2290 ::osl::MutexGuard
aGuard(m_aMutex
);
2291 if ( Index
< 0 || o3tl::make_unsigned(Index
) >= m_aElementsPos
.size() )
2292 throw lang::IndexOutOfBoundsException();
2293 return m_aElementsPos
[Index
]->second
;
2296 // container::XNameAccess
2297 uno::Any SAL_CALL
OStylesHelper::getByName( const OUString
& aName
)
2299 ::osl::MutexGuard
aGuard(m_aMutex
);
2300 TStyleElements::const_iterator aFind
= m_aElements
.find(aName
);
2301 if ( aFind
== m_aElements
.end() )
2302 throw container::NoSuchElementException();
2303 return aFind
->second
;
2306 uno::Sequence
< OUString
> SAL_CALL
OStylesHelper::getElementNames( )
2308 ::osl::MutexGuard
aGuard(m_aMutex
);
2309 uno::Sequence
< OUString
> aNameList(m_aElementsPos
.size());
2311 OUString
* pStringArray
= aNameList
.getArray();
2312 for(const auto& rIter
: m_aElementsPos
)
2314 *pStringArray
= rIter
->first
;
2321 sal_Bool SAL_CALL
OStylesHelper::hasByName( const OUString
& aName
)
2323 ::osl::MutexGuard
aGuard(m_aMutex
);
2324 return m_aElements
.find(aName
) != m_aElements
.end();
2328 void SAL_CALL
OStylesHelper::insertByName( const OUString
& aName
, const uno::Any
& aElement
)
2330 ::osl::MutexGuard
aGuard(m_aMutex
);
2331 if ( m_aElements
.find(aName
) != m_aElements
.end() )
2332 throw container::ElementExistException();
2334 if ( !aElement
.isExtractableTo(m_aType
) )
2335 throw lang::IllegalArgumentException();
2337 m_aElementsPos
.push_back(m_aElements
.emplace(aName
,aElement
).first
);
2340 void SAL_CALL
OStylesHelper::removeByName( const OUString
& aName
)
2342 ::osl::MutexGuard
aGuard(m_aMutex
);
2343 TStyleElements::const_iterator aFind
= m_aElements
.find(aName
);
2344 if ( aFind
!= m_aElements
.end() )
2345 throw container::NoSuchElementException();
2346 m_aElementsPos
.erase(::std::find(m_aElementsPos
.begin(),m_aElementsPos
.end(),aFind
));
2347 m_aElements
.erase(aFind
);
2351 void SAL_CALL
OStylesHelper::replaceByName( const OUString
& aName
, const uno::Any
& aElement
)
2353 ::osl::MutexGuard
aGuard(m_aMutex
);
2354 TStyleElements::iterator aFind
= m_aElements
.find(aName
);
2355 if ( aFind
== m_aElements
.end() )
2356 throw container::NoSuchElementException();
2357 if ( !aElement
.isExtractableTo(m_aType
) )
2358 throw lang::IllegalArgumentException();
2359 aFind
->second
= aElement
;
2362 uno::Reference
< container::XNameAccess
> SAL_CALL
OReportDefinition::getStyleFamilies( )
2364 ::osl::MutexGuard
aGuard(m_aMutex
);
2365 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2366 if ( !m_pImpl
->m_xStyles
.is() )
2368 m_pImpl
->m_xStyles
= new OStylesHelper();
2369 uno::Reference
< container::XNameContainer
> xStyles(m_pImpl
->m_xStyles
,uno::UNO_QUERY
);
2371 uno::Reference
< container::XNameContainer
> xPageStyles
= new OStylesHelper(cppu::UnoType
<style::XStyle
>::get());
2372 xStyles
->insertByName("PageStyles",uno::Any(xPageStyles
));
2373 uno::Reference
< style::XStyle
> xPageStyle(createInstance("com.sun.star.style.PageStyle"),uno::UNO_QUERY
);
2374 xPageStyles
->insertByName(xPageStyle
->getName(),uno::Any(xPageStyle
));
2376 uno::Reference
< container::XNameContainer
> xFrameStyles
= new OStylesHelper(cppu::UnoType
<style::XStyle
>::get());
2377 xStyles
->insertByName("FrameStyles",uno::Any(xFrameStyles
));
2378 uno::Reference
< style::XStyle
> xFrameStyle(createInstance("com.sun.star.style.FrameStyle"),uno::UNO_QUERY
);
2379 xFrameStyles
->insertByName(xFrameStyle
->getName(),uno::Any(xFrameStyle
));
2381 uno::Reference
< container::XNameContainer
> xGraphicStyles
= new OStylesHelper(cppu::UnoType
<style::XStyle
>::get());
2382 xStyles
->insertByName("graphics",uno::Any(xGraphicStyles
));
2383 uno::Reference
< style::XStyle
> xGraphicStyle(createInstance("com.sun.star.style.GraphicStyle"),uno::UNO_QUERY
);
2384 xGraphicStyles
->insertByName(xGraphicStyle
->getName(),uno::Any(xGraphicStyle
));
2386 return m_pImpl
->m_xStyles
;
2388 OUString SAL_CALL
OReportDefinition::getIdentifier( )
2390 ::osl::MutexGuard
aGuard(m_aMutex
);
2391 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2392 return m_pImpl
->m_sIdentifier
;
2395 void SAL_CALL
OReportDefinition::setIdentifier( const OUString
& Identifier
)
2397 ::osl::MutexGuard
aGuard(m_aMutex
);
2398 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2399 m_pImpl
->m_sIdentifier
= Identifier
;
2402 // XNumberFormatsSupplier
2403 uno::Reference
< beans::XPropertySet
> SAL_CALL
OReportDefinition::getNumberFormatSettings( )
2405 ::osl::MutexGuard
aGuard(m_aMutex
);
2406 if ( m_pImpl
->m_xNumberFormatsSupplier
.is() )
2407 return m_pImpl
->m_xNumberFormatsSupplier
->getNumberFormatSettings();
2408 return uno::Reference
< beans::XPropertySet
>();
2411 uno::Reference
< util::XNumberFormats
> SAL_CALL
OReportDefinition::getNumberFormats( )
2413 ::osl::MutexGuard
aGuard(m_aMutex
);
2414 if ( m_pImpl
->m_xNumberFormatsSupplier
.is() )
2415 return m_pImpl
->m_xNumberFormatsSupplier
->getNumberFormats();
2416 return uno::Reference
< util::XNumberFormats
>();
2419 ::comphelper::EmbeddedObjectContainer
& OReportDefinition::getEmbeddedObjectContainer() const
2421 return *m_pImpl
->m_pObjectContainer
;
2424 uno::Reference
< embed::XStorage
> OReportDefinition::getStorage() const
2426 return m_pImpl
->m_xStorage
;
2429 uno::Reference
< task::XInteractionHandler
> OReportDefinition::getInteractionHandler() const
2431 uno::Reference
< task::XInteractionHandler
> xRet(
2432 task::InteractionHandler::createWithParent(m_aProps
->m_xContext
, nullptr), uno::UNO_QUERY_THROW
);
2436 uno::Reference
< sdbc::XConnection
> SAL_CALL
OReportDefinition::getActiveConnection()
2438 ::osl::MutexGuard
aGuard(m_aMutex
);
2439 return m_pImpl
->m_xActiveConnection
;
2442 void SAL_CALL
OReportDefinition::setActiveConnection( const uno::Reference
< sdbc::XConnection
>& _activeconnection
)
2444 if ( !_activeconnection
.is() )
2445 throw lang::IllegalArgumentException();
2446 set(PROPERTY_ACTIVECONNECTION
,_activeconnection
,m_pImpl
->m_xActiveConnection
);
2449 OUString SAL_CALL
OReportDefinition::getDataSourceName()
2451 osl::MutexGuard
g(m_aMutex
);
2452 return m_pImpl
->m_sDataSourceName
;
2455 void SAL_CALL
OReportDefinition::setDataSourceName(const OUString
& the_value
)
2457 set(PROPERTY_DATASOURCENAME
,the_value
,m_pImpl
->m_sDataSourceName
);
2460 bool OReportDefinition::isEnableSetModified() const
2465 OUString
OReportDefinition::getDocumentBaseURL() const
2467 // TODO: should this be in getURL()? not sure...
2468 uno::Reference
<frame::XModel
> const xParent(
2469 const_cast<OReportDefinition
*>(this)->getParent(), uno::UNO_QUERY
);
2472 return xParent
->getURL();
2475 ::osl::MutexGuard
aGuard(m_aMutex
);
2476 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2477 for (beans::PropertyValue
const& it
: std::as_const(m_pImpl
->m_aArgs
))
2479 if (it
.Name
== "DocumentBaseURL")
2480 return it
.Value
.get
<OUString
>();
2486 uno::Reference
< frame::XTitle
> OReportDefinition::impl_getTitleHelper_throw()
2488 SolarMutexGuard aSolarGuard
;
2490 ::osl::MutexGuard
aGuard(m_aMutex
);
2491 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2493 if ( ! m_pImpl
->m_xTitleHelper
.is ())
2495 uno::Reference
< frame::XDesktop2
> xDesktop
= frame::Desktop::create(m_aProps
->m_xContext
);
2497 m_pImpl
->m_xTitleHelper
= new ::framework::TitleHelper( m_aProps
->m_xContext
, uno::Reference
< frame::XModel
>(this),
2498 uno::Reference
<frame::XUntitledNumbers
>(xDesktop
, uno::UNO_QUERY_THROW
) );
2501 return m_pImpl
->m_xTitleHelper
;
2504 uno::Reference
< frame::XUntitledNumbers
> OReportDefinition::impl_getUntitledHelper_throw()
2506 SolarMutexGuard aSolarGuard
;
2508 ::osl::MutexGuard
aGuard(m_aMutex
);
2509 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2511 if ( ! m_pImpl
->m_xNumberedControllers
.is ())
2513 rtl::Reference
<::comphelper::NumberedCollection
> pHelper
= new ::comphelper::NumberedCollection();
2514 m_pImpl
->m_xNumberedControllers
= pHelper
;
2516 pHelper
->setOwner (uno::Reference
< frame::XModel
>(this));
2517 pHelper
->setUntitledPrefix (" : ");
2520 return m_pImpl
->m_xNumberedControllers
;
2524 OUString SAL_CALL
OReportDefinition::getTitle()
2527 SolarMutexGuard aSolarGuard
;
2529 ::osl::MutexGuard
aGuard(m_aMutex
);
2530 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2532 return impl_getTitleHelper_throw()->getTitle ();
2536 void SAL_CALL
OReportDefinition::setTitle( const OUString
& sTitle
)
2539 SolarMutexGuard aSolarGuard
;
2541 ::osl::MutexGuard
aGuard(m_aMutex
);
2542 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2544 impl_getTitleHelper_throw()->setTitle (sTitle
);
2547 // css.frame.XTitleChangeBroadcaster
2548 void SAL_CALL
OReportDefinition::addTitleChangeListener( const uno::Reference
< frame::XTitleChangeListener
>& xListener
)
2551 SolarMutexGuard aSolarGuard
;
2553 ::osl::MutexGuard
aGuard(m_aMutex
);
2554 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2556 uno::Reference
< frame::XTitleChangeBroadcaster
> xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY
);
2557 if (xBroadcaster
.is ())
2558 xBroadcaster
->addTitleChangeListener (xListener
);
2561 // css.frame.XTitleChangeBroadcaster
2562 void SAL_CALL
OReportDefinition::removeTitleChangeListener( const uno::Reference
< frame::XTitleChangeListener
>& xListener
)
2565 SolarMutexGuard aSolarGuard
;
2567 ::osl::MutexGuard
aGuard(m_aMutex
);
2568 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2570 uno::Reference
< frame::XTitleChangeBroadcaster
> xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY
);
2571 if (xBroadcaster
.is ())
2572 xBroadcaster
->removeTitleChangeListener (xListener
);
2575 // css.frame.XUntitledNumbers
2576 ::sal_Int32 SAL_CALL
OReportDefinition::leaseNumber( const uno::Reference
< uno::XInterface
>& xComponent
)
2578 // object already disposed?
2579 SolarMutexGuard aSolarGuard
;
2580 ::osl::MutexGuard
aGuard(m_aMutex
);
2581 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2583 return impl_getUntitledHelper_throw()->leaseNumber (xComponent
);
2586 // css.frame.XUntitledNumbers
2587 void SAL_CALL
OReportDefinition::releaseNumber( ::sal_Int32 nNumber
)
2589 // object already disposed?
2590 SolarMutexGuard aSolarGuard
;
2591 ::osl::MutexGuard
aGuard(m_aMutex
);
2592 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2594 impl_getUntitledHelper_throw()->releaseNumber (nNumber
);
2597 // css.frame.XUntitledNumbers
2598 void SAL_CALL
OReportDefinition::releaseNumberForComponent( const uno::Reference
< uno::XInterface
>& xComponent
)
2600 // object already disposed?
2601 SolarMutexGuard aSolarGuard
;
2602 ::osl::MutexGuard
aGuard(m_aMutex
);
2603 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2605 impl_getUntitledHelper_throw()->releaseNumberForComponent (xComponent
);
2608 // css.frame.XUntitledNumbers
2609 OUString SAL_CALL
OReportDefinition::getUntitledPrefix()
2611 // object already disposed?
2612 SolarMutexGuard aSolarGuard
;
2613 ::osl::MutexGuard
aGuard(m_aMutex
);
2614 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2616 return impl_getUntitledHelper_throw()->getUntitledPrefix ();
2619 uno::Reference
< document::XDocumentProperties
> SAL_CALL
OReportDefinition::getDocumentProperties( )
2621 ::osl::MutexGuard
aGuard(m_aMutex
);
2622 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2623 if ( !m_pImpl
->m_xDocumentProperties
.is() )
2625 m_pImpl
->m_xDocumentProperties
.set(document::DocumentProperties::create(m_aProps
->m_xContext
));
2627 return m_pImpl
->m_xDocumentProperties
;
2630 uno::Any SAL_CALL
OReportDefinition::getTransferData( const datatransfer::DataFlavor
& aFlavor
)
2633 if( !isDataFlavorSupported( aFlavor
) )
2635 throw datatransfer::UnsupportedFlavorException(aFlavor
.MimeType
, getXWeak());
2640 aResult
= getPreferredVisualRepresentation(0).Data
;
2642 catch (const uno::Exception
&)
2644 DBG_UNHANDLED_EXCEPTION("reportdesign");
2651 uno::Sequence
< datatransfer::DataFlavor
> SAL_CALL
OReportDefinition::getTransferDataFlavors( )
2653 return { { "image/png", "PNG", cppu::UnoType
<uno::Sequence
< sal_Int8
>>::get() } };
2656 sal_Bool SAL_CALL
OReportDefinition::isDataFlavorSupported( const datatransfer::DataFlavor
& aFlavor
)
2658 return aFlavor
.MimeType
== "image/png";
2662 uno::Reference
< document::XUndoManager
> SAL_CALL
OReportDefinition::getUndoManager( )
2664 ::osl::MutexGuard
aGuard( m_aMutex
);
2665 return m_pImpl
->m_pUndoManager
;
2668 }// namespace reportdesign
2670 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */