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(u
"OpenMode"_ustr
) >>= 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( u
"StatusIndicator"_ustr
);
196 _rDescriptor
.erase( u
"InteractionHandler"_ustr
);
197 _rDescriptor
.erase( u
"Model"_ustr
);
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(u
"Default"_ustr
) );
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(u
"DisplayName"_ustr
, ++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(u
"[From printer settings]"_ustr
));
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(u
"UserDefinedAttributes"_ustr
, ++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(u
"PrinterName"_ustr
, ++i
,nBound
, cppu::UnoType
<OUString
>::get(), css::uno::Any(OUString()));
374 registerPropertyNoMember(u
"PrinterSetup"_ustr
, ++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 namespace { class OStylesHelper
; }
455 struct OReportDefinitionImpl
457 uno::WeakReference
< uno::XInterface
> m_xParent
;
458 ::comphelper::OInterfaceContainerHelper3
<document::XStorageChangeListener
> m_aStorageChangeListeners
;
459 ::comphelper::OInterfaceContainerHelper3
<util::XCloseListener
> m_aCloseListener
;
460 ::comphelper::OInterfaceContainerHelper3
<util::XModifyListener
> m_aModifyListeners
;
461 ::comphelper::OInterfaceContainerHelper3
<document::XEventListener
> m_aLegacyEventListeners
;
462 ::comphelper::OInterfaceContainerHelper3
<document::XDocumentEventListener
> m_aDocEventListeners
;
463 ::std::vector
< uno::Reference
< frame::XController
> > m_aControllers
;
464 uno::Sequence
< beans::PropertyValue
> m_aArgs
;
466 rtl::Reference
< OGroups
> m_xGroups
;
467 uno::Reference
< report::XSection
> m_xReportHeader
;
468 uno::Reference
< report::XSection
> m_xReportFooter
;
469 uno::Reference
< report::XSection
> m_xPageHeader
;
470 uno::Reference
< report::XSection
> m_xPageFooter
;
471 uno::Reference
< report::XSection
> m_xDetail
;
472 uno::Reference
< embed::XStorage
> m_xStorage
;
473 uno::Reference
< frame::XController
> m_xCurrentController
;
474 uno::Reference
< container::XIndexAccess
> m_xViewData
;
475 rtl::Reference
< OStylesHelper
> m_xStyles
;
476 uno::Reference
< container::XNameAccess
> m_xXMLNamespaceMap
;
477 uno::Reference
< container::XNameAccess
> m_xGradientTable
;
478 uno::Reference
< container::XNameAccess
> m_xHatchTable
;
479 uno::Reference
< container::XNameAccess
> m_xBitmapTable
;
480 uno::Reference
< container::XNameAccess
> m_xTransparencyGradientTable
;
481 uno::Reference
< container::XNameAccess
> m_xDashTable
;
482 uno::Reference
< container::XNameAccess
> m_xMarkerTable
;
483 rtl::Reference
< OFunctions
> m_xFunctions
;
484 uno::Reference
< ui::XUIConfigurationManager2
> m_xUIConfigurationManager
;
485 uno::Reference
< util::XNumberFormatsSupplier
> m_xNumberFormatsSupplier
;
486 uno::Reference
< sdbc::XConnection
> m_xActiveConnection
;
487 rtl::Reference
< ::framework::TitleHelper
> m_xTitleHelper
;
488 rtl::Reference
< ::comphelper::NumberedCollection
> m_xNumberedControllers
;
489 uno::Reference
< document::XDocumentProperties
> m_xDocumentProperties
;
491 std::shared_ptr
< ::comphelper::EmbeddedObjectContainer
>
493 std::shared_ptr
<rptui::OReportModel
> m_pReportModel
;
494 ::rtl::Reference
< ::dbaui::UndoManager
> m_pUndoManager
;
498 OUString m_sMimeType
;
499 OUString m_sIdentifier
;
500 OUString m_sDataSourceName
;
501 awt::Size m_aVisualAreaSize
;
502 ::sal_Int64 m_nAspect
;
503 ::sal_Int16 m_nGroupKeepTogether
;
504 ::sal_Int16 m_nPageHeaderOption
;
505 ::sal_Int16 m_nPageFooterOption
;
506 ::sal_Int32 m_nCommandType
;
507 bool m_bControllersLocked
;
509 bool m_bEscapeProcessing
;
510 bool m_bSetModifiedEnabled
;
512 explicit OReportDefinitionImpl(::osl::Mutex
& _aMutex
)
513 :m_aStorageChangeListeners(_aMutex
)
514 ,m_aCloseListener(_aMutex
)
515 ,m_aModifyListeners(_aMutex
)
516 ,m_aLegacyEventListeners(_aMutex
)
517 ,m_aDocEventListeners(_aMutex
)
518 ,m_sMimeType(MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII
)
519 ,m_sIdentifier(SERVICE_REPORTDEFINITION
)
520 // default visual area is 8 x 7 cm
521 ,m_aVisualAreaSize( 8000, 7000 )
522 ,m_nAspect(embed::Aspects::MSOLE_CONTENT
)
523 ,m_nGroupKeepTogether(0)
524 ,m_nPageHeaderOption(0)
525 ,m_nPageFooterOption(0)
526 ,m_nCommandType(sdb::CommandType::TABLE
)
527 ,m_bControllersLocked(false)
529 ,m_bEscapeProcessing(true)
530 ,m_bSetModifiedEnabled( true )
534 OReportDefinition::OReportDefinition(uno::Reference
< uno::XComponentContext
> const & _xContext
)
535 : ::cppu::BaseMutex(),
536 ReportDefinitionBase(m_aMutex
),
537 ReportDefinitionPropertySet(_xContext
,IMPLEMENTS_PROPERTY_SET
,uno::Sequence
< OUString
>()),
538 ::comphelper::IEmbeddedHelper(),
539 m_aProps(std::make_shared
<OReportComponentProperties
>(_xContext
)),
540 m_pImpl(std::make_shared
<OReportDefinitionImpl
>(m_aMutex
))
542 m_aProps
->m_sName
= RptResId(RID_STR_REPORT
);
543 osl_atomic_increment(&m_refCount
);
546 m_pImpl
->m_xGroups
= new OGroups(this,m_aProps
->m_xContext
);
547 m_pImpl
->m_xDetail
= OSection::createOSection(this,m_aProps
->m_xContext
);
548 m_pImpl
->m_xDetail
->setName(RptResId(RID_STR_DETAIL
));
550 osl_atomic_decrement( &m_refCount
);
553 OReportDefinition::OReportDefinition(
554 uno::Reference
< uno::XComponentContext
> const & _xContext
,
555 const uno::Reference
< lang::XMultiServiceFactory
>& _xFactory
,
556 uno::Reference
< drawing::XShape
>& _xShape
)
557 : ::cppu::BaseMutex(),
558 ReportDefinitionBase(m_aMutex
),
559 ReportDefinitionPropertySet(_xContext
,IMPLEMENTS_PROPERTY_SET
,uno::Sequence
< OUString
>()),
560 ::comphelper::IEmbeddedHelper(),
561 m_aProps(std::make_shared
<OReportComponentProperties
>(_xContext
)),
562 m_pImpl(std::make_shared
<OReportDefinitionImpl
>(m_aMutex
))
564 m_aProps
->m_sName
= RptResId(RID_STR_REPORT
);
565 m_aProps
->m_xFactory
= _xFactory
;
566 osl_atomic_increment(&m_refCount
);
568 m_aProps
->setShape(_xShape
,this,m_refCount
);
570 m_pImpl
->m_xGroups
= new OGroups(this,m_aProps
->m_xContext
);
571 m_pImpl
->m_xDetail
= OSection::createOSection(this,m_aProps
->m_xContext
);
572 m_pImpl
->m_xDetail
->setName(RptResId(RID_STR_DETAIL
));
574 osl_atomic_decrement( &m_refCount
);
577 OReportDefinition::~OReportDefinition()
579 if ( !ReportDefinitionBase::rBHelper
.bInDispose
&& !ReportDefinitionBase::rBHelper
.bDisposed
)
586 IMPLEMENT_FORWARD_REFCOUNT( OReportDefinition
, ReportDefinitionBase
)
587 void OReportDefinition::init()
591 m_pImpl
->m_pReportModel
= std::make_shared
<OReportModel
>(this);
592 m_pImpl
->m_pReportModel
->SetScaleUnit( MapUnit::Map100thMM
);
593 SdrLayerAdmin
& rAdmin
= m_pImpl
->m_pReportModel
->GetLayerAdmin();
594 rAdmin
.NewLayer(u
"front"_ustr
, RPT_LAYER_FRONT
.get());
595 rAdmin
.NewLayer(u
"back"_ustr
, RPT_LAYER_BACK
.get());
596 rAdmin
.NewLayer(u
"HiddenLayer"_ustr
, RPT_LAYER_HIDDEN
.get());
598 m_pImpl
->m_pUndoManager
= new ::dbaui::UndoManager( *this, m_aMutex
);
599 m_pImpl
->m_pReportModel
->SetSdrUndoManager( &m_pImpl
->m_pUndoManager
->GetSfxUndoManager() );
601 m_pImpl
->m_xFunctions
= new OFunctions(this,m_aProps
->m_xContext
);
602 if ( !m_pImpl
->m_xStorage
.is() )
603 m_pImpl
->m_xStorage
= ::comphelper::OStorageHelper::GetTemporaryStorage();
605 uno::Reference
<beans::XPropertySet
> xStorProps(m_pImpl
->m_xStorage
,uno::UNO_QUERY
);
606 if ( xStorProps
.is())
609 xStorProps
->getPropertyValue(u
"MediaType"_ustr
) >>= sMediaType
;
610 if ( sMediaType
.isEmpty() )
611 xStorProps
->setPropertyValue(u
"MediaType"_ustr
,uno::Any(MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII
));
613 m_pImpl
->m_pObjectContainer
= std::make_shared
<comphelper::EmbeddedObjectContainer
>(m_pImpl
->m_xStorage
, getXWeak() );
615 catch (const uno::Exception
&)
617 DBG_UNHANDLED_EXCEPTION("reportdesign");
621 void SAL_CALL
OReportDefinition::dispose()
623 ReportDefinitionPropertySet::dispose();
624 cppu::WeakComponentImplHelperBase::dispose();
627 void SAL_CALL
OReportDefinition::disposing()
629 notifyEvent(u
"OnUnload"_ustr
);
631 uno::Reference
< frame::XModel
> xHoldAlive( this );
633 lang::EventObject
aDisposeEvent( getXWeak() );
634 m_pImpl
->m_aModifyListeners
.disposeAndClear( aDisposeEvent
);
635 m_pImpl
->m_aCloseListener
.disposeAndClear( aDisposeEvent
);
636 m_pImpl
->m_aLegacyEventListeners
.disposeAndClear( aDisposeEvent
);
637 m_pImpl
->m_aDocEventListeners
.disposeAndClear( aDisposeEvent
);
638 m_pImpl
->m_aStorageChangeListeners
.disposeAndClear( aDisposeEvent
);
642 SolarMutexGuard aSolarGuard
;
643 osl::MutexGuard
aGuard(m_aMutex
);
645 m_pImpl
->m_aControllers
.clear();
647 ::comphelper::disposeComponent(m_pImpl
->m_xGroups
);
648 m_pImpl
->m_xReportHeader
.clear();
649 m_pImpl
->m_xReportFooter
.clear();
650 m_pImpl
->m_xPageHeader
.clear();
651 m_pImpl
->m_xPageFooter
.clear();
652 m_pImpl
->m_xDetail
.clear();
653 ::comphelper::disposeComponent(m_pImpl
->m_xFunctions
);
655 //::comphelper::disposeComponent(m_pImpl->m_xStorage);
656 // don't dispose, this currently is the task of either the ref count going to
657 // 0, or of the embedded object (if we're embedded, which is the only possible
660 m_pImpl
->m_xStorage
.clear();
661 m_pImpl
->m_xViewData
.clear();
662 m_pImpl
->m_xCurrentController
.clear();
663 m_pImpl
->m_xNumberFormatsSupplier
.clear();
664 m_pImpl
->m_xStyles
.clear();
665 m_pImpl
->m_xXMLNamespaceMap
.clear();
666 m_pImpl
->m_xGradientTable
.clear();
667 m_pImpl
->m_xHatchTable
.clear();
668 m_pImpl
->m_xBitmapTable
.clear();
669 m_pImpl
->m_xTransparencyGradientTable
.clear();
670 m_pImpl
->m_xDashTable
.clear();
671 m_pImpl
->m_xMarkerTable
.clear();
672 m_pImpl
->m_xUIConfigurationManager
.clear();
673 m_pImpl
->m_pReportModel
.reset();
674 m_pImpl
->m_pObjectContainer
.reset();
675 m_pImpl
->m_aArgs
.realloc(0);
676 m_pImpl
->m_xTitleHelper
.clear();
677 m_pImpl
->m_xNumberedControllers
.clear();
683 OUString
OReportDefinition::getImplementationName_Static( )
685 return u
"com.sun.star.comp.report.OReportDefinition"_ustr
;
688 OUString SAL_CALL
OReportDefinition::getImplementationName( )
690 return getImplementationName_Static();
693 uno::Sequence
< OUString
> OReportDefinition::getSupportedServiceNames_Static( )
695 uno::Sequence
< OUString
> aServices
{ SERVICE_REPORTDEFINITION
};
700 uno::Sequence
< OUString
> SAL_CALL
OReportDefinition::getSupportedServiceNames( )
702 // first collect the services which are supported by our aggregate
703 uno::Sequence
< OUString
> aSupported
;
704 if ( m_aProps
->m_xServiceInfo
.is() )
705 aSupported
= m_aProps
->m_xServiceInfo
->getSupportedServiceNames();
707 // append our own service, if necessary
708 if ( ::comphelper::findValue( aSupported
, SERVICE_REPORTDEFINITION
) == -1 )
710 sal_Int32 nLen
= aSupported
.getLength();
711 aSupported
.realloc( nLen
+ 1 );
712 aSupported
.getArray()[ nLen
] = SERVICE_REPORTDEFINITION
;
719 sal_Bool SAL_CALL
OReportDefinition::supportsService( const OUString
& _rServiceName
)
721 return cppu::supportsService(this, _rServiceName
);
724 uno::Any SAL_CALL
OReportDefinition::queryInterface( const uno::Type
& _rType
)
726 uno::Any aReturn
= ReportDefinitionBase::queryInterface(_rType
);
727 if ( !aReturn
.hasValue() )
728 aReturn
= ReportDefinitionPropertySet::queryInterface(_rType
);
730 return aReturn
.hasValue() ? aReturn
: (m_aProps
->m_xProxy
.is() ? m_aProps
->m_xProxy
->queryAggregation(_rType
) : aReturn
);
732 uno::Sequence
< uno::Type
> SAL_CALL
OReportDefinition::getTypes( )
734 if ( m_aProps
->m_xTypeProvider
.is() )
735 return ::comphelper::concatSequences(
736 ReportDefinitionBase::getTypes(),
737 m_aProps
->m_xTypeProvider
->getTypes()
739 return ReportDefinitionBase::getTypes();
742 uno::Reference
< uno::XInterface
> OReportDefinition::create(uno::Reference
< uno::XComponentContext
> const & xContext
)
744 return *(new OReportDefinition(xContext
));
748 OUString SAL_CALL
OReportDefinition::getCaption()
750 ::osl::MutexGuard
aGuard(m_aMutex
);
751 return m_pImpl
->m_sCaption
;
754 void SAL_CALL
OReportDefinition::setCaption( const OUString
& _caption
)
756 set(PROPERTY_CAPTION
,_caption
,m_pImpl
->m_sCaption
);
759 ::sal_Int16 SAL_CALL
OReportDefinition::getGroupKeepTogether()
761 ::osl::MutexGuard
aGuard(m_aMutex
);
762 return m_pImpl
->m_nGroupKeepTogether
;
765 void SAL_CALL
OReportDefinition::setGroupKeepTogether( ::sal_Int16 _groupkeeptogether
)
767 if ( _groupkeeptogether
< report::GroupKeepTogether::PER_PAGE
|| _groupkeeptogether
> report::GroupKeepTogether::PER_COLUMN
)
768 throwIllegallArgumentException(u
"css::report::GroupKeepTogether"
771 set(PROPERTY_GROUPKEEPTOGETHER
,_groupkeeptogether
,m_pImpl
->m_nGroupKeepTogether
);
774 ::sal_Int16 SAL_CALL
OReportDefinition::getPageHeaderOption()
776 ::osl::MutexGuard
aGuard(m_aMutex
);
777 return m_pImpl
->m_nPageHeaderOption
;
780 void SAL_CALL
OReportDefinition::setPageHeaderOption( ::sal_Int16 _pageheaderoption
)
782 if ( _pageheaderoption
< report::ReportPrintOption::ALL_PAGES
|| _pageheaderoption
> report::ReportPrintOption::NOT_WITH_REPORT_HEADER_FOOTER
)
783 throwIllegallArgumentException(u
"css::report::ReportPrintOption"
786 set(PROPERTY_PAGEHEADEROPTION
,_pageheaderoption
,m_pImpl
->m_nPageHeaderOption
);
789 ::sal_Int16 SAL_CALL
OReportDefinition::getPageFooterOption()
791 ::osl::MutexGuard
aGuard(m_aMutex
);
792 return m_pImpl
->m_nPageFooterOption
;
795 void SAL_CALL
OReportDefinition::setPageFooterOption( ::sal_Int16 _pagefooteroption
)
797 if ( _pagefooteroption
< report::ReportPrintOption::ALL_PAGES
|| _pagefooteroption
> report::ReportPrintOption::NOT_WITH_REPORT_HEADER_FOOTER
)
798 throwIllegallArgumentException(u
"css::report::ReportPrintOption"
801 set(PROPERTY_PAGEFOOTEROPTION
,_pagefooteroption
,m_pImpl
->m_nPageFooterOption
);
804 OUString SAL_CALL
OReportDefinition::getCommand()
806 ::osl::MutexGuard
aGuard(m_aMutex
);
807 return m_pImpl
->m_sCommand
;
810 void SAL_CALL
OReportDefinition::setCommand( const OUString
& _command
)
812 set(PROPERTY_COMMAND
,_command
,m_pImpl
->m_sCommand
);
815 ::sal_Int32 SAL_CALL
OReportDefinition::getCommandType()
817 ::osl::MutexGuard
aGuard(m_aMutex
);
818 return m_pImpl
->m_nCommandType
;
821 void SAL_CALL
OReportDefinition::setCommandType( ::sal_Int32 _commandtype
)
823 if ( _commandtype
< sdb::CommandType::TABLE
|| _commandtype
> sdb::CommandType::COMMAND
)
824 throwIllegallArgumentException(u
"css::sdb::CommandType"
827 set(PROPERTY_COMMANDTYPE
,_commandtype
,m_pImpl
->m_nCommandType
);
830 OUString SAL_CALL
OReportDefinition::getFilter()
832 ::osl::MutexGuard
aGuard(m_aMutex
);
833 return m_pImpl
->m_sFilter
;
836 void SAL_CALL
OReportDefinition::setFilter( const OUString
& _filter
)
838 set(PROPERTY_FILTER
,_filter
,m_pImpl
->m_sFilter
);
841 sal_Bool SAL_CALL
OReportDefinition::getEscapeProcessing()
843 ::osl::MutexGuard
aGuard(m_aMutex
);
844 return m_pImpl
->m_bEscapeProcessing
;
847 void SAL_CALL
OReportDefinition::setEscapeProcessing( sal_Bool _escapeprocessing
)
849 set(PROPERTY_ESCAPEPROCESSING
,_escapeprocessing
,m_pImpl
->m_bEscapeProcessing
);
852 sal_Bool SAL_CALL
OReportDefinition::getReportHeaderOn()
854 ::osl::MutexGuard
aGuard(m_aMutex
);
855 return m_pImpl
->m_xReportHeader
.is();
858 void SAL_CALL
OReportDefinition::setReportHeaderOn( sal_Bool _reportheaderon
)
860 if ( bool(_reportheaderon
) != m_pImpl
->m_xReportHeader
.is() )
862 setSection(PROPERTY_REPORTHEADERON
,_reportheaderon
,RptResId(RID_STR_REPORT_HEADER
),m_pImpl
->m_xReportHeader
);
866 sal_Bool SAL_CALL
OReportDefinition::getReportFooterOn()
868 ::osl::MutexGuard
aGuard(m_aMutex
);
869 return m_pImpl
->m_xReportFooter
.is();
872 void SAL_CALL
OReportDefinition::setReportFooterOn( sal_Bool _reportfooteron
)
874 if ( bool(_reportfooteron
) != m_pImpl
->m_xReportFooter
.is() )
876 setSection(PROPERTY_REPORTFOOTERON
,_reportfooteron
,RptResId(RID_STR_REPORT_FOOTER
),m_pImpl
->m_xReportFooter
);
880 sal_Bool SAL_CALL
OReportDefinition::getPageHeaderOn()
882 ::osl::MutexGuard
aGuard(m_aMutex
);
883 return m_pImpl
->m_xPageHeader
.is();
886 void SAL_CALL
OReportDefinition::setPageHeaderOn( sal_Bool _pageheaderon
)
888 if ( bool(_pageheaderon
) != m_pImpl
->m_xPageHeader
.is() )
890 setSection(PROPERTY_PAGEHEADERON
,_pageheaderon
,RptResId(RID_STR_PAGE_HEADER
),m_pImpl
->m_xPageHeader
);
894 sal_Bool SAL_CALL
OReportDefinition::getPageFooterOn()
896 ::osl::MutexGuard
aGuard(m_aMutex
);
897 return m_pImpl
->m_xPageFooter
.is();
900 void SAL_CALL
OReportDefinition::setPageFooterOn( sal_Bool _pagefooteron
)
902 if ( bool(_pagefooteron
) != m_pImpl
->m_xPageFooter
.is() )
904 setSection(PROPERTY_PAGEFOOTERON
,_pagefooteron
,RptResId(RID_STR_PAGE_FOOTER
),m_pImpl
->m_xPageFooter
);
908 uno::Reference
< report::XGroups
> SAL_CALL
OReportDefinition::getGroups()
910 ::osl::MutexGuard
aGuard(m_aMutex
);
911 return m_pImpl
->m_xGroups
;
914 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getReportHeader()
916 ::osl::MutexGuard
aGuard(m_aMutex
);
917 if ( !m_pImpl
->m_xReportHeader
.is() )
918 throw container::NoSuchElementException();
919 return m_pImpl
->m_xReportHeader
;
922 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getPageHeader()
924 ::osl::MutexGuard
aGuard(m_aMutex
);
925 if ( !m_pImpl
->m_xPageHeader
.is() )
926 throw container::NoSuchElementException();
927 return m_pImpl
->m_xPageHeader
;
930 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getDetail()
932 ::osl::MutexGuard
aGuard(m_aMutex
);
933 return m_pImpl
->m_xDetail
;
936 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getPageFooter()
938 ::osl::MutexGuard
aGuard(m_aMutex
);
939 if ( !m_pImpl
->m_xPageFooter
.is() )
940 throw container::NoSuchElementException();
941 return m_pImpl
->m_xPageFooter
;
944 uno::Reference
< report::XSection
> SAL_CALL
OReportDefinition::getReportFooter()
946 ::osl::MutexGuard
aGuard(m_aMutex
);
947 if ( !m_pImpl
->m_xReportFooter
.is() )
948 throw container::NoSuchElementException();
949 return m_pImpl
->m_xReportFooter
;
952 uno::Reference
< document::XEventBroadcaster
> SAL_CALL
OReportDefinition::getEventBroadcaster( )
954 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
959 REPORTCOMPONENT_MASTERDETAIL(OReportDefinition
,*m_aProps
)
960 REPORTCOMPONENT_IMPL(OReportDefinition
,*m_aProps
)
961 REPORTCOMPONENT_IMPL2(OReportDefinition
,*m_aProps
)
963 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
OReportDefinition::getPropertySetInfo( )
965 return ReportDefinitionPropertySet::getPropertySetInfo();
968 void SAL_CALL
OReportDefinition::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
)
970 ReportDefinitionPropertySet::setPropertyValue( aPropertyName
, aValue
);
973 uno::Any SAL_CALL
OReportDefinition::getPropertyValue( const OUString
& PropertyName
)
975 return ReportDefinitionPropertySet::getPropertyValue( PropertyName
);
978 void SAL_CALL
OReportDefinition::addPropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& xListener
)
980 ReportDefinitionPropertySet::addPropertyChangeListener( aPropertyName
, xListener
);
983 void SAL_CALL
OReportDefinition::removePropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& aListener
)
985 ReportDefinitionPropertySet::removePropertyChangeListener( aPropertyName
, aListener
);
988 void SAL_CALL
OReportDefinition::addVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
)
990 ReportDefinitionPropertySet::addVetoableChangeListener( PropertyName
, aListener
);
993 void SAL_CALL
OReportDefinition::removeVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
)
995 ReportDefinitionPropertySet::removeVetoableChangeListener( PropertyName
, aListener
);
999 uno::Reference
< uno::XInterface
> SAL_CALL
OReportDefinition::getParent( )
1001 ::osl::MutexGuard
aGuard(m_aMutex
);
1002 if (auto xChild
= comphelper::query_aggregation
<container::XChild
>(m_aProps
->m_xProxy
))
1003 return xChild
->getParent();
1004 return m_pImpl
->m_xParent
;
1007 void SAL_CALL
OReportDefinition::setParent( const uno::Reference
< uno::XInterface
>& Parent
)
1009 ::osl::MutexGuard
aGuard(m_aMutex
);
1010 m_aProps
->m_xParent
= uno::Reference
< container::XChild
>(Parent
,uno::UNO_QUERY
);
1011 m_pImpl
->m_xParent
= Parent
;
1012 if (auto xChild
= comphelper::query_aggregation
<container::XChild
>(m_aProps
->m_xProxy
))
1013 xChild
->setParent(Parent
);
1017 uno::Reference
< util::XCloneable
> SAL_CALL
OReportDefinition::createClone( )
1019 OSL_FAIL("Not yet implemented correctly");
1020 uno::Reference
< report::XReportComponent
> xSource
= this;
1021 uno::Reference
< report::XReportDefinition
> xSet(cloneObject(xSource
,m_aProps
->m_xFactory
,SERVICE_REPORTDEFINITION
),uno::UNO_QUERY_THROW
);
1025 void OReportDefinition::setSection( const OUString
& _sProperty
1027 ,const OUString
& _sName
1028 ,uno::Reference
< report::XSection
>& _member
)
1032 ::osl::MutexGuard
aGuard(m_aMutex
);
1033 prepareSet(_sProperty
, uno::Any(_member
), uno::Any(_bOn
), &l
);
1035 // create section if needed
1036 if ( _bOn
&& !_member
.is() )
1037 _member
= OSection::createOSection(this, getContext(), _sProperty
== PROPERTY_PAGEHEADERON
|| _sProperty
== PROPERTY_PAGEFOOTERON
);
1039 ::comphelper::disposeComponent(_member
);
1042 _member
->setName(_sName
);
1047 // XCloseBroadcaster
1048 void SAL_CALL
OReportDefinition::addCloseListener( const uno::Reference
< util::XCloseListener
>& _xListener
)
1050 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1051 if ( _xListener
.is() )
1052 m_pImpl
->m_aCloseListener
.addInterface(_xListener
);
1055 void SAL_CALL
OReportDefinition::removeCloseListener( const uno::Reference
< util::XCloseListener
>& _xListener
)
1057 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1058 m_pImpl
->m_aCloseListener
.removeInterface(_xListener
);
1062 void SAL_CALL
OReportDefinition::close(sal_Bool bDeliverOwnership
)
1064 SolarMutexGuard aSolarGuard
;
1066 ::osl::ResettableMutexGuard
aGuard(m_aMutex
);
1067 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1068 // notify our container listeners
1069 lang::EventObject
aEvt( getXWeak() );
1071 m_pImpl
->m_aCloseListener
.forEach(
1072 [&aEvt
, &bDeliverOwnership
] (uno::Reference
<util::XCloseListener
> const& xListener
) {
1073 return xListener
->queryClosing(aEvt
, bDeliverOwnership
);
1078 ::std::vector
< uno::Reference
< frame::XController
> > aCopy
= m_pImpl
->m_aControllers
;
1079 for (auto& rxController
: aCopy
)
1081 if ( rxController
.is() )
1085 uno::Reference
< util::XCloseable
> xFrame( rxController
->getFrame(), uno::UNO_QUERY
);
1087 xFrame
->close( bDeliverOwnership
);
1089 catch (const util::CloseVetoException
&) { throw; }
1090 catch (const uno::Exception
&)
1092 TOOLS_WARN_EXCEPTION( "reportdesign", "ODatabaseDocument::impl_closeControllerFrames" );
1098 m_pImpl
->m_aCloseListener
.notifyEach(&util::XCloseListener::notifyClosing
,aEvt
);
1105 sal_Bool SAL_CALL
OReportDefinition::attachResource( const OUString
& /*_rURL*/, const uno::Sequence
< beans::PropertyValue
>& _aArguments
)
1107 // LLA: we had a deadlock problem in our context, so we get the SolarMutex earlier.
1108 SolarMutexGuard aSolarGuard
;
1110 ::osl::MutexGuard
aGuard(m_aMutex
);
1111 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper
.bDisposed
);
1112 utl::MediaDescriptor
aDescriptor( _aArguments
);
1114 m_pImpl
->m_pUndoManager
->GetSfxUndoManager().EnableUndo( false );
1117 fillArgs(aDescriptor
);
1118 m_pImpl
->m_pReportModel
->SetModified(false);
1122 m_pImpl
->m_pUndoManager
->GetSfxUndoManager().EnableUndo( true );
1125 m_pImpl
->m_pUndoManager
->GetSfxUndoManager().EnableUndo( true );
1129 void OReportDefinition::fillArgs(utl::MediaDescriptor
& _aDescriptor
)
1131 uno::Sequence
<beans::PropertyValue
> aComponentData
;
1132 aComponentData
= _aDescriptor
.getUnpackedValueOrDefault(u
"ComponentData"_ustr
,aComponentData
);
1133 if ( aComponentData
.hasElements() && (!m_pImpl
->m_xActiveConnection
.is() || !m_pImpl
->m_xNumberFormatsSupplier
.is()) )
1135 ::comphelper::SequenceAsHashMap
aComponentDataMap( aComponentData
);
1136 m_pImpl
->m_xActiveConnection
= aComponentDataMap
.getUnpackedValueOrDefault(u
"ActiveConnection"_ustr
,m_pImpl
->m_xActiveConnection
);
1137 m_pImpl
->m_xNumberFormatsSupplier
= dbtools::getNumberFormats(m_pImpl
->m_xActiveConnection
);
1139 if ( !m_pImpl
->m_xNumberFormatsSupplier
.is() )
1141 m_pImpl
->m_xNumberFormatsSupplier
.set( util::NumberFormatsSupplier::createWithDefaultLocale( m_aProps
->m_xContext
) );
1143 lcl_stripLoadArguments( _aDescriptor
, m_pImpl
->m_aArgs
);
1145 sCaption
= _aDescriptor
.getUnpackedValueOrDefault(u
"DocumentTitle"_ustr
,sCaption
);
1146 setCaption(sCaption
);
1149 OUString SAL_CALL
OReportDefinition::getURL( )
1154 uno::Sequence
< beans::PropertyValue
> SAL_CALL
OReportDefinition::getArgs( )
1156 ::osl::MutexGuard
aGuard(m_aMutex
);
1157 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1158 return m_pImpl
->m_aArgs
;
1161 void SAL_CALL
OReportDefinition::connectController( const uno::Reference
< frame::XController
>& _xController
)
1163 ::osl::MutexGuard
aGuard(m_aMutex
);
1164 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1165 m_pImpl
->m_aControllers
.push_back(_xController
);
1166 if ( _xController
.is() && m_pImpl
->m_xViewData
.is() )
1168 sal_Int32 nCount
= m_pImpl
->m_xViewData
->getCount();
1170 _xController
->restoreViewData(m_pImpl
->m_xViewData
->getByIndex(nCount
- 1));
1174 void SAL_CALL
OReportDefinition::disconnectController( const uno::Reference
< frame::XController
>& _xController
)
1176 ::osl::MutexGuard
aGuard(m_aMutex
);
1177 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1178 ::std::vector
< uno::Reference
< frame::XController
> >::iterator aFind
= ::std::find(m_pImpl
->m_aControllers
.begin(),m_pImpl
->m_aControllers
.end(),_xController
);
1179 if ( aFind
!= m_pImpl
->m_aControllers
.end() )
1180 m_pImpl
->m_aControllers
.erase(aFind
);
1181 if ( m_pImpl
->m_xCurrentController
== _xController
)
1182 m_pImpl
->m_xCurrentController
.clear();
1185 void SAL_CALL
OReportDefinition::lockControllers( )
1187 ::osl::MutexGuard
aGuard(m_aMutex
);
1188 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1189 m_pImpl
->m_bControllersLocked
= true;
1192 void SAL_CALL
OReportDefinition::unlockControllers( )
1194 ::osl::MutexGuard
aGuard(m_aMutex
);
1195 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1196 m_pImpl
->m_bControllersLocked
= false;
1199 sal_Bool SAL_CALL
OReportDefinition::hasControllersLocked( )
1201 ::osl::MutexGuard
aGuard(m_aMutex
);
1202 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1203 return m_pImpl
->m_bControllersLocked
;
1206 uno::Reference
< frame::XController
> SAL_CALL
OReportDefinition::getCurrentController( )
1208 ::osl::MutexGuard
aGuard(m_aMutex
);
1209 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1210 return m_pImpl
->m_xCurrentController
;
1213 void SAL_CALL
OReportDefinition::setCurrentController( const uno::Reference
< frame::XController
>& _xController
)
1215 ::osl::MutexGuard
aGuard(m_aMutex
);
1216 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1217 if ( ::std::find(m_pImpl
->m_aControllers
.begin(),m_pImpl
->m_aControllers
.end(),_xController
) == m_pImpl
->m_aControllers
.end() )
1218 throw container::NoSuchElementException();
1219 m_pImpl
->m_xCurrentController
= _xController
;
1222 uno::Reference
< uno::XInterface
> SAL_CALL
OReportDefinition::getCurrentSelection( )
1224 return uno::Reference
< uno::XInterface
>();
1227 void OReportDefinition::impl_loadFromStorage_nolck_throw( const uno::Reference
< embed::XStorage
>& _xStorageToLoadFrom
,
1228 const uno::Sequence
< beans::PropertyValue
>& _aMediaDescriptor
)
1230 m_pImpl
->m_xStorage
= _xStorageToLoadFrom
;
1232 utl::MediaDescriptor
aDescriptor( _aMediaDescriptor
);
1233 fillArgs(aDescriptor
);
1234 aDescriptor
.createItemIfMissing(u
"Storage"_ustr
,uno::Any(_xStorageToLoadFrom
));
1236 uno::Sequence
< uno::Any
> aDelegatorArguments(_aMediaDescriptor
.getLength());
1237 uno::Any
* pIter
= aDelegatorArguments
.getArray();
1238 uno::Any
* pEnd
= pIter
+ aDelegatorArguments
.getLength();
1239 for(sal_Int32 i
= 0;pIter
!= pEnd
;++pIter
,++i
)
1241 *pIter
<<= _aMediaDescriptor
[i
];
1243 sal_Int32 nPos
= aDelegatorArguments
.getLength();
1244 aDelegatorArguments
.realloc(nPos
+1);
1245 beans::PropertyValue aPropVal
;
1246 aPropVal
.Name
= "Storage";
1247 aPropVal
.Value
<<= _xStorageToLoadFrom
;
1248 aDelegatorArguments
.getArray()[nPos
] <<= aPropVal
;
1250 rptui::OXUndoEnvironment
& rEnv
= m_pImpl
->m_pReportModel
->GetUndoEnv();
1251 rptui::OXUndoEnvironment::OUndoEnvLock
aLock(rEnv
);
1253 uno::Reference
< document::XFilter
> xFilter(
1254 m_aProps
->m_xContext
->getServiceManager()->createInstanceWithArgumentsAndContext(u
"com.sun.star.comp.report.OReportFilter"_ustr
,aDelegatorArguments
,m_aProps
->m_xContext
),
1255 uno::UNO_QUERY_THROW
);
1257 uno::Reference
< document::XImporter
> xImporter(xFilter
,uno::UNO_QUERY_THROW
);
1258 uno::Reference
<XComponent
> xComponent(getXWeak(),uno::UNO_QUERY
);
1259 xImporter
->setTargetDocument(xComponent
);
1261 utl::MediaDescriptor aTemp
;
1262 aTemp
<< aDelegatorArguments
;
1263 xFilter
->filter(aTemp
.getAsConstPropertyValueList());
1265 lcl_setModelReadOnly(m_pImpl
->m_xStorage
,m_pImpl
->m_pReportModel
);
1266 m_pImpl
->m_pObjectContainer
->SwitchPersistence(m_pImpl
->m_xStorage
);
1270 // XStorageBasedDocument
1271 void SAL_CALL
OReportDefinition::loadFromStorage( const uno::Reference
< embed::XStorage
>& _xStorageToLoadFrom
1272 , const uno::Sequence
< beans::PropertyValue
>& _aMediaDescriptor
)
1274 ::osl::MutexGuard
aGuard(m_aMutex
);
1275 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1277 impl_loadFromStorage_nolck_throw( _xStorageToLoadFrom
, _aMediaDescriptor
);
1280 void SAL_CALL
OReportDefinition::storeToStorage( const uno::Reference
< embed::XStorage
>& _xStorageToSaveTo
, const uno::Sequence
< beans::PropertyValue
>& _aMediaDescriptor
)
1282 if ( !_xStorageToSaveTo
.is() )
1283 throw lang::IllegalArgumentException(RptResId(RID_STR_ARGUMENT_IS_NULL
),*this,1);
1285 SolarMutexGuard aSolarGuard
;
1286 ::osl::MutexGuard
aGuard(m_aMutex
);
1287 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1288 // create XStatusIndicator
1289 uno::Reference
<task::XStatusIndicator
> xStatusIndicator
;
1290 uno::Sequence
< uno::Any
> aDelegatorArguments
;
1291 utl::MediaDescriptor
aDescriptor( _aMediaDescriptor
);
1292 lcl_extractAndStartStatusIndicator( aDescriptor
, xStatusIndicator
, aDelegatorArguments
);
1293 bool AutoSaveEvent
= false;
1294 aDescriptor
[utl::MediaDescriptor::PROP_AUTOSAVEEVENT
] >>= AutoSaveEvent
;
1297 uno::Sequence
< beans::PropertyValue
> aProps
;
1299 // export sub streams for package, else full stream into a file
1300 uno::Reference
< beans::XPropertySet
> xProp(_xStorageToSaveTo
,uno::UNO_QUERY
);
1303 static constexpr OUString sPropName
= u
"MediaType"_ustr
;
1304 OUString sOldMediaType
;
1305 xProp
->getPropertyValue(sPropName
) >>= sOldMediaType
;
1306 if ( !xProp
->getPropertyValue(sPropName
).hasValue() || sOldMediaType
.isEmpty() || MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII
!= sOldMediaType
)
1307 xProp
->setPropertyValue( sPropName
, uno::Any(MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII
) );
1310 /** property map for export info set */
1311 static comphelper::PropertyMapEntry
const aExportInfoMap
[] =
1313 { u
"UsePrettyPrinting"_ustr
, 0, cppu::UnoType
<sal_Bool
>::get(), beans::PropertyAttribute::MAYBEVOID
, 0 },
1314 { u
"StreamName"_ustr
, 0, cppu::UnoType
<OUString
>::get(), beans::PropertyAttribute::MAYBEVOID
, 0 },
1315 { u
"StreamRelPath"_ustr
, 0, cppu::UnoType
<OUString
>::get(), beans::PropertyAttribute::MAYBEVOID
, 0 },
1316 { u
"BaseURI"_ustr
, 0, cppu::UnoType
<OUString
>::get(), beans::PropertyAttribute::MAYBEVOID
, 0 },
1318 uno::Reference
< beans::XPropertySet
> xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap
) ) );
1320 xInfoSet
->setPropertyValue(u
"UsePrettyPrinting"_ustr
, uno::Any(officecfg::Office::Common::Save::Document::PrettyPrinting::get()));
1321 if ( officecfg::Office::Common::Save::URL::FileSystem::get() )
1323 const OUString
sVal( aDescriptor
.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_DOCUMENTBASEURL
, OUString()) );
1324 xInfoSet
->setPropertyValue(u
"BaseURI"_ustr
, uno::Any(sVal
));
1326 const OUString
sHierarchicalDocumentName( aDescriptor
.getUnpackedValueOrDefault(u
"HierarchicalDocumentName"_ustr
,OUString()) );
1327 xInfoSet
->setPropertyValue(u
"StreamRelPath"_ustr
, uno::Any(sHierarchicalDocumentName
));
1330 sal_Int32 nArgsLen
= aDelegatorArguments
.getLength();
1331 aDelegatorArguments
.realloc(nArgsLen
+3);
1332 auto pDelegatorArguments
= aDelegatorArguments
.getArray();
1333 pDelegatorArguments
[nArgsLen
++] <<= xInfoSet
;
1335 uno::Reference
< document::XEmbeddedObjectResolver
> xObjectResolver
;
1336 uno::Reference
<document::XGraphicStorageHandler
> xGraphicStorageHandler
;
1337 rtl::Reference
<SvXMLGraphicHelper
> xGraphicHelper
= SvXMLGraphicHelper::Create(_xStorageToSaveTo
,SvXMLGraphicHelperMode::Write
);
1338 xGraphicStorageHandler
= xGraphicHelper
.get();
1339 xGraphicHelper
.clear();
1340 xObjectResolver
= SvXMLEmbeddedObjectHelper::Create( _xStorageToSaveTo
,*this, SvXMLEmbeddedObjectHelperMode::Write
).get();
1342 pDelegatorArguments
[nArgsLen
++] <<= xGraphicStorageHandler
;
1343 pDelegatorArguments
[nArgsLen
++] <<= xObjectResolver
;
1345 uno::Reference
<XComponent
> xCom(getXWeak(),uno::UNO_QUERY
);
1346 // Try to write to settings.xml, meta.xml, and styles.xml; only really care about success of
1347 // write to content.xml (keeping logic of commit 94ccba3eebc83b58e74e18f0e028c6a995ce6aa6)
1348 xInfoSet
->setPropertyValue(u
"StreamName"_ustr
, uno::Any(u
"settings.xml"_ustr
));
1349 WriteThroughComponent(xCom
, "settings.xml", "com.sun.star.comp.report.XMLSettingsExporter",
1350 aDelegatorArguments
, aProps
, _xStorageToSaveTo
);
1352 xInfoSet
->setPropertyValue(u
"StreamName"_ustr
, uno::Any(u
"meta.xml"_ustr
));
1353 WriteThroughComponent(xCom
, "meta.xml", "com.sun.star.comp.report.XMLMetaExporter",
1354 aDelegatorArguments
, aProps
, _xStorageToSaveTo
);
1356 xInfoSet
->setPropertyValue(u
"StreamName"_ustr
, uno::Any(u
"styles.xml"_ustr
));
1357 WriteThroughComponent(xCom
, "styles.xml", "com.sun.star.comp.report.XMLStylesExporter",
1358 aDelegatorArguments
, aProps
, _xStorageToSaveTo
);
1360 xInfoSet
->setPropertyValue(u
"StreamName"_ustr
, uno::Any(u
"content.xml"_ustr
));
1361 bool bOk
= WriteThroughComponent(xCom
, "content.xml", "com.sun.star.comp.report.ExportFilter",
1362 aDelegatorArguments
, aProps
, _xStorageToSaveTo
);
1365 uno::Reference
< embed::XVisualObject
> xCurrentController(getCurrentController(),uno::UNO_QUERY
);
1366 if ( xCurrentController
.is() )
1368 xCurrentController
->setVisualAreaSize(m_pImpl
->m_nAspect
,m_pImpl
->m_aVisualAreaSize
);
1369 aImage
= xCurrentController
->getPreferredVisualRepresentation( m_pImpl
->m_nAspect
).Data
;
1371 if ( aImage
.hasValue() )
1373 uno::Sequence
<sal_Int8
> aSeq
;
1375 uno::Reference
<io::XInputStream
> xStream
= new ::comphelper::SequenceInputStream( aSeq
);
1376 m_pImpl
->m_pObjectContainer
->InsertGraphicStreamDirectly(xStream
, u
"report"_ustr
, u
"image/png"_ustr
);
1381 bool bPersist
= false;
1382 if ( _xStorageToSaveTo
== m_pImpl
->m_xStorage
)
1383 bPersist
= m_pImpl
->m_pObjectContainer
->StoreChildren(true,false);
1385 bPersist
= m_pImpl
->m_pObjectContainer
->StoreAsChildren(true,true,AutoSaveEvent
,_xStorageToSaveTo
);
1388 m_pImpl
->m_pObjectContainer
->SetPersistentEntries(m_pImpl
->m_xStorage
);
1391 uno::Reference
<embed::XTransactedObject
> xTransact(_xStorageToSaveTo
,uno::UNO_QUERY
);
1392 if ( xTransact
.is() )
1393 xTransact
->commit();
1395 catch (const uno::Exception
&)
1397 TOOLS_WARN_EXCEPTION( "reportdesign", "Could not commit report storage!");
1398 throw io::IOException();
1401 if ( _xStorageToSaveTo
== m_pImpl
->m_xStorage
)
1404 if ( xStatusIndicator
.is() )
1405 xStatusIndicator
->end();
1408 void SAL_CALL
OReportDefinition::switchToStorage(
1409 const uno::Reference
< embed::XStorage
>& xStorage
)
1412 throw lang::IllegalArgumentException(RptResId(RID_STR_ARGUMENT_IS_NULL
),*this,1);
1414 ::osl::MutexGuard
aGuard(m_aMutex
);
1415 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1416 m_pImpl
->m_xStorage
= xStorage
;
1417 lcl_setModelReadOnly(m_pImpl
->m_xStorage
,m_pImpl
->m_pReportModel
);
1418 m_pImpl
->m_pObjectContainer
->SwitchPersistence(m_pImpl
->m_xStorage
);
1420 // notify our container listeners
1421 m_pImpl
->m_aStorageChangeListeners
.forEach(
1422 [this, &xStorage
] (uno::Reference
<document::XStorageChangeListener
> const& xListener
) {
1423 return xListener
->notifyStorageChange(getXWeak(), xStorage
);
1427 uno::Reference
< embed::XStorage
> SAL_CALL
OReportDefinition::getDocumentStorage( )
1429 ::osl::MutexGuard
aGuard(m_aMutex
);
1430 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1431 return m_pImpl
->m_xStorage
;
1434 void SAL_CALL
OReportDefinition::addStorageChangeListener( const uno::Reference
< document::XStorageChangeListener
>& xListener
)
1436 ::osl::MutexGuard
aGuard(m_aMutex
);
1437 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1438 if ( xListener
.is() )
1439 m_pImpl
->m_aStorageChangeListeners
.addInterface(xListener
);
1442 void SAL_CALL
OReportDefinition::removeStorageChangeListener( const uno::Reference
< document::XStorageChangeListener
>& xListener
)
1444 ::osl::MutexGuard
aGuard(m_aMutex
);
1445 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1446 m_pImpl
->m_aStorageChangeListeners
.removeInterface(xListener
);
1449 bool OReportDefinition::WriteThroughComponent(
1450 const uno::Reference
<lang::XComponent
> & xComponent
,
1451 const char* pStreamName
,
1452 const char* pServiceName
,
1453 const uno::Sequence
<uno::Any
> & rArguments
,
1454 const uno::Sequence
<beans::PropertyValue
> & rMediaDesc
,
1455 const uno::Reference
<embed::XStorage
>& _xStorageToSaveTo
)
1457 OSL_ENSURE( nullptr != pStreamName
, "Need stream name!" );
1458 OSL_ENSURE( nullptr != pServiceName
, "Need service name!" );
1461 OUString sStreamName
= OUString::createFromAscii( pStreamName
);
1462 uno::Reference
<io::XStream
> xStream
= _xStorageToSaveTo
->openStreamElement( sStreamName
,embed::ElementModes::READWRITE
| embed::ElementModes::TRUNCATE
);
1463 if ( !xStream
.is() )
1465 uno::Reference
<io::XOutputStream
> xOutputStream
= xStream
->getOutputStream();
1466 OSL_ENSURE(xOutputStream
.is(), "Can't create output stream in package!");
1467 if ( ! xOutputStream
.is() )
1470 uno::Reference
<beans::XPropertySet
> xStreamProp(xOutputStream
,uno::UNO_QUERY
);
1471 OSL_ENSURE(xStreamProp
.is(),"No valid property set for the output stream!");
1473 uno::Reference
<io::XSeekable
> xSeek(xStreamProp
,uno::UNO_QUERY
);
1479 xStreamProp
->setPropertyValue( u
"MediaType"_ustr
, uno::Any(u
"text/xml"_ustr
) );
1481 // encrypt all streams
1482 xStreamProp
->setPropertyValue( u
"UseCommonStoragePasswordEncryption"_ustr
,
1485 // set buffer and create outputstream
1488 bool bRet
= WriteThroughComponent(
1489 xOutputStream
, xComponent
,
1490 pServiceName
, rArguments
, rMediaDesc
);
1491 // finally, commit stream.
1495 bool OReportDefinition::WriteThroughComponent(
1496 const uno::Reference
<io::XOutputStream
> & xOutputStream
,
1497 const uno::Reference
<lang::XComponent
> & xComponent
,
1498 const char* pServiceName
,
1499 const uno::Sequence
<uno::Any
> & rArguments
,
1500 const uno::Sequence
<beans::PropertyValue
> & rMediaDesc
)
1502 OSL_ENSURE( xOutputStream
.is(), "I really need an output stream!" );
1503 OSL_ENSURE( xComponent
.is(), "Need component!" );
1504 OSL_ENSURE( nullptr != pServiceName
, "Need component name!" );
1507 uno::Reference
< xml::sax::XWriter
> xSaxWriter(
1508 xml::sax::Writer::create(m_aProps
->m_xContext
) );
1510 // connect XML writer to output stream
1511 xSaxWriter
->setOutputStream( xOutputStream
);
1513 // prepare arguments (prepend doc handler to given arguments)
1514 uno::Sequence
<uno::Any
> aArgs( 1 + rArguments
.getLength() );
1515 auto pArgs
= aArgs
.getArray();
1516 *pArgs
<<= xSaxWriter
;
1517 std::copy(rArguments
.begin(), rArguments
.end(), std::next(pArgs
));
1519 // get filter component
1520 uno::Reference
< document::XExporter
> xExporter(
1521 m_aProps
->m_xContext
->getServiceManager()->createInstanceWithArgumentsAndContext(
1522 OUString::createFromAscii(pServiceName
), aArgs
,m_aProps
->m_xContext
), uno::UNO_QUERY
);
1523 OSL_ENSURE( xExporter
.is(),
1524 "can't instantiate export filter component" );
1525 if( !xExporter
.is() )
1528 // connect model and filter
1529 xExporter
->setSourceDocument( xComponent
);
1532 uno::Reference
<document::XFilter
> xFilter( xExporter
, uno::UNO_QUERY
);
1533 return xFilter
->filter( rMediaDesc
);
1537 void SAL_CALL
OReportDefinition::initNew( )
1539 setPageHeaderOn( true );
1540 setPageFooterOn( true );
1543 void SAL_CALL
OReportDefinition::load( const uno::Sequence
< beans::PropertyValue
>& _rArguments
)
1545 ::osl::MutexGuard
aGuard(m_aMutex
);
1546 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1548 // TODO: this code is pretty similar to what happens in ODatabaseModelImpl::getOrCreateRootStorage,
1549 // perhaps we can share code here.
1551 ::comphelper::NamedValueCollection
aArguments( _rArguments
);
1553 // the source for the to-be-created storage: either a URL, or a stream
1554 uno::Reference
< io::XInputStream
> xStream
;
1557 if ( aArguments
.has( u
"Stream"_ustr
) )
1559 aArguments
.get_ensureType( u
"Stream"_ustr
, xStream
);
1560 aArguments
.remove( u
"Stream"_ustr
);
1562 else if ( aArguments
.has( u
"InputStream"_ustr
) )
1564 aArguments
.get_ensureType( u
"InputStream"_ustr
, xStream
);
1565 aArguments
.remove( u
"InputStream"_ustr
);
1568 if ( aArguments
.has( u
"FileName"_ustr
) )
1570 aArguments
.get_ensureType( u
"FileName"_ustr
, sURL
);
1571 aArguments
.remove( u
"FileName"_ustr
);
1573 else if ( aArguments
.has( u
"URL"_ustr
) )
1575 aArguments
.get_ensureType( u
"URL"_ustr
, sURL
);
1576 aArguments
.remove( u
"URL"_ustr
);
1579 uno::Any aStorageSource
;
1581 aStorageSource
<<= xStream
;
1582 else if ( !sURL
.isEmpty() )
1583 aStorageSource
<<= sURL
;
1585 throw lang::IllegalArgumentException(
1586 u
"No input source (URL or InputStream) found."_ustr
,
1592 uno::Reference
< lang::XSingleServiceFactory
> xStorageFactory( embed::StorageFactory::create( m_aProps
->m_xContext
) );
1594 // open read-write per default, unless told otherwise in the MediaDescriptor
1595 uno::Reference
< embed::XStorage
> xDocumentStorage
;
1596 const sal_Int32 nOpenModes
[2] = {
1597 embed::ElementModes::READWRITE
,
1598 embed::ElementModes::READ
1600 size_t nFirstOpenMode
= 0;
1601 if ( aArguments
.has( u
"ReadOnly"_ustr
) )
1603 bool bReadOnly
= false;
1604 aArguments
.get_ensureType( u
"ReadOnly"_ustr
, bReadOnly
);
1605 nFirstOpenMode
= bReadOnly
? 1 : 0;
1607 const size_t nLastOpenMode
= SAL_N_ELEMENTS( nOpenModes
) - 1;
1608 for ( size_t i
=nFirstOpenMode
; i
<= nLastOpenMode
; ++i
)
1610 uno::Sequence
< uno::Any
> aStorageCreationArgs
{ aStorageSource
, uno::Any(nOpenModes
[i
]) };
1614 xDocumentStorage
.set( xStorageFactory
->createInstanceWithArguments( aStorageCreationArgs
), uno::UNO_QUERY_THROW
);
1616 catch (const uno::Exception
&)
1618 if ( i
== nLastOpenMode
)
1620 css::uno::Any anyEx
= cppu::getCaughtException();
1621 throw lang::WrappedTargetException(
1622 u
"An error occurred while creating the document storage."_ustr
,
1631 if ( !xDocumentStorage
.is() )
1633 throw uno::RuntimeException();
1636 if (!aArguments
.has(u
"DocumentBaseURL"_ustr
) && !sURL
.isEmpty())
1638 aArguments
.put(u
"DocumentBaseURL"_ustr
, sURL
);
1641 impl_loadFromStorage_nolck_throw( xDocumentStorage
, aArguments
.getPropertyValues() );
1642 // TODO: do we need to take ownership of the storage? In opposite to loadFromStorage, we created the storage
1643 // ourself here, and perhaps this means we're also responsible for it ...?
1647 void SAL_CALL
OReportDefinition::setVisualAreaSize( ::sal_Int64 _nAspect
, const awt::Size
& _aSize
)
1649 ::osl::MutexGuard
aGuard(m_aMutex
);
1650 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1652 (m_pImpl
->m_aVisualAreaSize
.Width
!= _aSize
.Width
||
1653 m_pImpl
->m_aVisualAreaSize
.Height
!= _aSize
.Height
);
1654 m_pImpl
->m_aVisualAreaSize
= _aSize
;
1656 setModified( true );
1657 m_pImpl
->m_nAspect
= _nAspect
;
1660 awt::Size SAL_CALL
OReportDefinition::getVisualAreaSize( ::sal_Int64
/*_nAspect*/ )
1662 ::osl::MutexGuard
aGuard(m_aMutex
);
1663 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1664 return m_pImpl
->m_aVisualAreaSize
;
1667 embed::VisualRepresentation SAL_CALL
OReportDefinition::getPreferredVisualRepresentation( ::sal_Int64
/*_nAspect*/ )
1669 ::osl::MutexGuard
aGuard(m_aMutex
);
1670 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1671 embed::VisualRepresentation aResult
;
1673 uno::Reference
<io::XInputStream
> xStream
= m_pImpl
->m_pObjectContainer
->GetGraphicStream(u
"report"_ustr
, &sMimeType
);
1676 uno::Sequence
<sal_Int8
> aSeq
;
1677 xStream
->readBytes(aSeq
,xStream
->available());
1678 xStream
->closeInput();
1679 aResult
.Data
<<= aSeq
;
1680 aResult
.Flavor
.MimeType
= sMimeType
;
1681 aResult
.Flavor
.DataType
= cppu::UnoType
<decltype(aSeq
)>::get();
1687 ::sal_Int32 SAL_CALL
OReportDefinition::getMapUnit( ::sal_Int64
/*nAspect*/ )
1689 return embed::EmbedMapUnits::ONE_100TH_MM
;
1693 sal_Bool SAL_CALL
OReportDefinition::disableSetModified( )
1695 ::osl::MutexGuard
aGuard( m_aMutex
);
1696 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper
.bDisposed
);
1698 const bool bWasEnabled
= m_pImpl
->m_bSetModifiedEnabled
;
1699 m_pImpl
->m_bSetModifiedEnabled
= false;
1703 sal_Bool SAL_CALL
OReportDefinition::enableSetModified( )
1705 ::osl::MutexGuard
aGuard( m_aMutex
);
1706 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper
.bDisposed
);
1708 const bool bWasEnabled
= m_pImpl
->m_bSetModifiedEnabled
;
1709 m_pImpl
->m_bSetModifiedEnabled
= true;
1713 sal_Bool SAL_CALL
OReportDefinition::isSetModifiedEnabled( )
1715 ::osl::MutexGuard
aGuard( m_aMutex
);
1716 ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper
.bDisposed
);
1718 return m_pImpl
->m_bSetModifiedEnabled
;
1722 sal_Bool SAL_CALL
OReportDefinition::isModified( )
1724 ::osl::MutexGuard
aGuard(m_aMutex
);
1725 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1726 return m_pImpl
->m_bModified
;
1729 void SAL_CALL
OReportDefinition::setModified( sal_Bool _bModified
)
1731 osl::ClearableMutexGuard
aGuard(m_aMutex
);
1732 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1734 if ( !m_pImpl
->m_bSetModifiedEnabled
)
1737 if ( m_pImpl
->m_pReportModel
->IsReadOnly() && _bModified
)
1738 throw beans::PropertyVetoException();
1739 if ( m_pImpl
->m_bModified
!= bool(_bModified
) )
1741 m_pImpl
->m_bModified
= _bModified
;
1742 if ( m_pImpl
->m_pReportModel
->IsChanged() != bool(_bModified
) )
1743 m_pImpl
->m_pReportModel
->SetChanged(_bModified
);
1745 lang::EventObject
aEvent(*this);
1747 m_pImpl
->m_aModifyListeners
.notifyEach(&util::XModifyListener::modified
,aEvent
);
1748 notifyEvent(u
"OnModifyChanged"_ustr
);
1752 // XModifyBroadcaster
1753 void SAL_CALL
OReportDefinition::addModifyListener( const uno::Reference
< util::XModifyListener
>& _xListener
)
1755 ::osl::MutexGuard
aGuard(m_aMutex
);
1756 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1757 if ( _xListener
.is() )
1758 m_pImpl
->m_aModifyListeners
.addInterface(_xListener
);
1761 void SAL_CALL
OReportDefinition::removeModifyListener( const uno::Reference
< util::XModifyListener
>& _xListener
)
1763 ::osl::MutexGuard
aGuard(m_aMutex
);
1764 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1765 m_pImpl
->m_aModifyListeners
.removeInterface(_xListener
);
1768 void OReportDefinition::notifyEvent(const OUString
& _sEventName
)
1772 osl::ClearableMutexGuard
aGuard(m_aMutex
);
1773 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1774 document::EventObject
aEvt(*this, _sEventName
);
1776 m_pImpl
->m_aLegacyEventListeners
.notifyEach(&document::XEventListener::notifyEvent
,aEvt
);
1778 catch (const uno::Exception
&)
1782 notifyDocumentEvent(_sEventName
, nullptr, css::uno::Any());
1785 // document::XDocumentEventBroadcaster
1786 void SAL_CALL
OReportDefinition::notifyDocumentEvent( const OUString
& rEventName
, const uno::Reference
< frame::XController2
>& rViewController
, const uno::Any
& rSupplement
)
1790 osl::ClearableMutexGuard
aGuard(m_aMutex
);
1791 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1792 document::DocumentEvent
aEvt(*this, rEventName
, rViewController
, rSupplement
);
1794 m_pImpl
->m_aDocEventListeners
.notifyEach(&document::XDocumentEventListener::documentEventOccured
,aEvt
);
1796 catch (const uno::Exception
&)
1801 void SAL_CALL
OReportDefinition::addDocumentEventListener( const uno::Reference
< document::XDocumentEventListener
>& rListener
)
1803 ::osl::MutexGuard
aGuard(m_aMutex
);
1804 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1805 if ( rListener
.is() )
1806 m_pImpl
->m_aDocEventListeners
.addInterface(rListener
);
1809 void SAL_CALL
OReportDefinition::removeDocumentEventListener( const uno::Reference
< document::XDocumentEventListener
>& rListener
)
1811 ::osl::MutexGuard
aGuard(m_aMutex
);
1812 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1813 m_pImpl
->m_aDocEventListeners
.removeInterface(rListener
);
1816 // document::XEventBroadcaster
1817 void SAL_CALL
OReportDefinition::addEventListener(const uno::Reference
< document::XEventListener
>& _xListener
)
1819 ::osl::MutexGuard
aGuard(m_aMutex
);
1820 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1821 if ( _xListener
.is() )
1822 m_pImpl
->m_aLegacyEventListeners
.addInterface(_xListener
);
1825 void SAL_CALL
OReportDefinition::removeEventListener( const uno::Reference
< document::XEventListener
>& _xListener
)
1827 ::osl::MutexGuard
aGuard(m_aMutex
);
1828 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1829 m_pImpl
->m_aLegacyEventListeners
.removeInterface(_xListener
);
1832 // document::XViewDataSupplier
1833 uno::Reference
< container::XIndexAccess
> SAL_CALL
OReportDefinition::getViewData( )
1835 ::osl::MutexGuard
aGuard(m_aMutex
);
1836 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1837 if ( !m_pImpl
->m_xViewData
.is() )
1839 rtl::Reference
<comphelper::IndexedPropertyValuesContainer
> xNewViewData
= new comphelper::IndexedPropertyValuesContainer();
1840 m_pImpl
->m_xViewData
= xNewViewData
;
1841 for (const auto& rxController
: m_pImpl
->m_aControllers
)
1843 if ( rxController
.is() )
1847 xNewViewData
->insertByIndex(xNewViewData
->getCount(), rxController
->getViewData());
1849 catch (const uno::Exception
&)
1856 return m_pImpl
->m_xViewData
;
1859 void SAL_CALL
OReportDefinition::setViewData( const uno::Reference
< container::XIndexAccess
>& Data
)
1861 ::osl::MutexGuard
aGuard(m_aMutex
);
1862 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1863 m_pImpl
->m_xViewData
= Data
;
1866 uno::Reference
< report::XFunctions
> SAL_CALL
OReportDefinition::getFunctions()
1868 ::osl::MutexGuard
aGuard(m_aMutex
);
1869 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1870 return m_pImpl
->m_xFunctions
;
1873 uno::Reference
< ui::XUIConfigurationManager
> SAL_CALL
OReportDefinition::getUIConfigurationManager( )
1875 return uno::Reference
< ui::XUIConfigurationManager
>( getUIConfigurationManager2(), uno::UNO_QUERY_THROW
);
1878 uno::Reference
< ui::XUIConfigurationManager2
> OReportDefinition::getUIConfigurationManager2( )
1880 ::osl::MutexGuard
aGuard(m_aMutex
);
1881 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1883 if ( !m_pImpl
->m_xUIConfigurationManager
.is() )
1885 m_pImpl
->m_xUIConfigurationManager
= ui::UIConfigurationManager::create(m_aProps
->m_xContext
);
1887 uno::Reference
< embed::XStorage
> xConfigStorage
;
1888 // initialize ui configuration manager with document substorage
1889 m_pImpl
->m_xUIConfigurationManager
->setStorage( xConfigStorage
);
1892 return m_pImpl
->m_xUIConfigurationManager
;
1895 uno::Reference
< embed::XStorage
> SAL_CALL
OReportDefinition::getDocumentSubStorage( const OUString
& aStorageName
, sal_Int32 nMode
)
1897 ::osl::MutexGuard
aGuard(m_aMutex
);
1898 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1899 return m_pImpl
->m_xStorage
->openStorageElement(aStorageName
, nMode
);
1902 uno::Sequence
< OUString
> SAL_CALL
OReportDefinition::getDocumentSubStoragesNames( )
1904 ::osl::MutexGuard
aGuard(m_aMutex
);
1905 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1906 uno::Reference
<container::XNameAccess
> xNameAccess
= m_pImpl
->m_xStorage
;
1907 return xNameAccess
.is() ? xNameAccess
->getElementNames() : uno::Sequence
< OUString
>();
1910 OUString SAL_CALL
OReportDefinition::getMimeType()
1912 ::osl::MutexGuard
aGuard(m_aMutex
);
1913 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1914 return m_pImpl
->m_sMimeType
;
1917 void SAL_CALL
OReportDefinition::setMimeType( const OUString
& _mimetype
)
1919 ::osl::MutexGuard
aGuard(m_aMutex
);
1920 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1921 const uno::Sequence
< OUString
> aList
= getAvailableMimeTypes();
1922 if ( ::std::find(aList
.begin(), aList
.end(), _mimetype
) == aList
.end() )
1923 throwIllegallArgumentException(u
"getAvailableMimeTypes()"
1926 set(PROPERTY_MIMETYPE
,_mimetype
,m_pImpl
->m_sMimeType
);
1929 uno::Sequence
< OUString
> SAL_CALL
OReportDefinition::getAvailableMimeTypes( )
1931 return { MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII
, MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII
};
1935 sal_Int64 SAL_CALL
OReportDefinition::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
1938 if (comphelper::isUnoTunnelId
<OReportDefinition
>(rId
) )
1939 nRet
= comphelper::getSomething_cast(this);
1942 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel(m_pImpl
->m_xNumberFormatsSupplier
,uno::UNO_QUERY
);
1943 if ( xUnoTunnel
.is() )
1944 nRet
= xUnoTunnel
->getSomething(rId
);
1948 if (auto xTunnel
= comphelper::query_aggregation
<lang::XUnoTunnel
>(m_aProps
->m_xProxy
))
1949 nRet
= xTunnel
->getSomething(rId
);
1955 uno::Sequence
< sal_Int8
> SAL_CALL
OReportDefinition::getImplementationId( )
1957 return css::uno::Sequence
<sal_Int8
>();
1960 const uno::Sequence
< sal_Int8
> & OReportDefinition::getUnoTunnelId()
1962 static const comphelper::UnoIdInit implId
;
1963 return implId
.getSeq();
1966 uno::Reference
< uno::XComponentContext
> OReportDefinition::getContext()
1968 ::osl::MutexGuard
aGuard(m_aMutex
);
1969 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1970 return m_aProps
->m_xContext
;
1973 std::shared_ptr
<rptui::OReportModel
> OReportDefinition::getSdrModel(const uno::Reference
< report::XReportDefinition
>& _xReportDefinition
)
1975 std::shared_ptr
<rptui::OReportModel
> pReportModel
;
1976 auto pReportDefinition
= comphelper::getFromUnoTunnel
<OReportDefinition
>(_xReportDefinition
);
1977 if (pReportDefinition
)
1978 pReportModel
= pReportDefinition
->m_pImpl
->m_pReportModel
;
1979 return pReportModel
;
1982 SdrModel
& OReportDefinition::getSdrModelFromUnoModel() const
1984 OSL_ENSURE(m_pImpl
->m_pReportModel
, "No SdrModel in ReportDesign, should not happen");
1985 return *m_pImpl
->m_pReportModel
;
1988 uno::Reference
< uno::XInterface
> SAL_CALL
OReportDefinition::createInstanceWithArguments( const OUString
& aServiceSpecifier
, const uno::Sequence
< uno::Any
>& _aArgs
)
1990 ::osl::MutexGuard
aGuard(m_aMutex
);
1991 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
1993 uno::Reference
< uno::XInterface
> xRet
;
1994 if ( aServiceSpecifier
.startsWith( "com.sun.star.document.ImportEmbeddedObjectResolver") )
1996 uno::Reference
< embed::XStorage
> xStorage
;
1997 for(const uno::Any
& rArg
: _aArgs
)
1999 beans::NamedValue aValue
;
2001 if ( aValue
.Name
== "Storage" )
2002 aValue
.Value
>>= xStorage
;
2004 m_pImpl
->m_pObjectContainer
->SwitchPersistence(xStorage
);
2005 xRet
= cppu::getXWeak(SvXMLEmbeddedObjectHelper::Create( xStorage
,*this, SvXMLEmbeddedObjectHelperMode::Read
).get());
2007 else if (aServiceSpecifier
== "com.sun.star.drawing.OLE2Shape")
2009 uno::Reference
<drawing::XShape
> xShape(SvxUnoDrawMSFactory::createInstanceWithArguments(aServiceSpecifier
, _aArgs
), uno::UNO_QUERY_THROW
);
2010 xRet
= m_pImpl
->m_pReportModel
->createShape(aServiceSpecifier
, xShape
);
2016 uno::Reference
< uno::XInterface
> SAL_CALL
OReportDefinition::createInstance( const OUString
& aServiceSpecifier
)
2018 ::osl::MutexGuard
aGuard(m_aMutex
);
2019 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2020 uno::Reference
< drawing::XShape
> xShape
;
2021 if ( aServiceSpecifier
.startsWith( "com.sun.star.report." ) )
2023 if ( aServiceSpecifier
== SERVICE_SHAPE
)
2024 xShape
.set(SvxUnoDrawMSFactory::createInstance(u
"com.sun.star.drawing.CustomShape"_ustr
),uno::UNO_QUERY_THROW
);
2025 else if ( aServiceSpecifier
== SERVICE_FORMATTEDFIELD
2026 || aServiceSpecifier
== SERVICE_FIXEDTEXT
2027 || aServiceSpecifier
== SERVICE_FIXEDLINE
2028 || aServiceSpecifier
== SERVICE_IMAGECONTROL
)
2029 xShape
.set(SvxUnoDrawMSFactory::createInstance(u
"com.sun.star.drawing.ControlShape"_ustr
),uno::UNO_QUERY_THROW
);
2031 xShape
.set(SvxUnoDrawMSFactory::createInstance(u
"com.sun.star.drawing.OLE2Shape"_ustr
),uno::UNO_QUERY_THROW
);
2033 else if ( aServiceSpecifier
.startsWith( "com.sun.star.form.component." ) )
2035 xShape
.set(m_aProps
->m_xContext
->getServiceManager()->createInstanceWithContext(aServiceSpecifier
,m_aProps
->m_xContext
),uno::UNO_QUERY
);
2037 else if ( aServiceSpecifier
== "com.sun.star.style.PageStyle" ||
2038 aServiceSpecifier
== "com.sun.star.style.FrameStyle" ||
2039 aServiceSpecifier
== "com.sun.star.style.GraphicStyle"
2042 uno::Reference
< style::XStyle
> xStyle
= new OStyle();
2043 xStyle
->setName(u
"Default"_ustr
);
2046 else if ( aServiceSpecifier
== "com.sun.star.document.Settings" )
2048 uno::Reference
<beans::XPropertySet
> xProp
= new OStyle();
2052 else if ( aServiceSpecifier
== "com.sun.star.drawing.Defaults" )
2054 uno::Reference
<beans::XPropertySet
> xProp
= new OStyle();
2057 else if ( aServiceSpecifier
== "com.sun.star.drawing.GradientTable" )
2059 if ( !m_pImpl
->m_xGradientTable
.is() )
2060 m_pImpl
->m_xGradientTable
.set(SvxUnoGradientTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2061 return m_pImpl
->m_xGradientTable
;
2063 else if ( aServiceSpecifier
== "com.sun.star.drawing.HatchTable" )
2065 if ( !m_pImpl
->m_xHatchTable
.is() )
2066 m_pImpl
->m_xHatchTable
.set(SvxUnoHatchTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2067 return m_pImpl
->m_xHatchTable
;
2069 else if ( aServiceSpecifier
== "com.sun.star.drawing.BitmapTable" )
2071 if ( !m_pImpl
->m_xBitmapTable
.is() )
2072 m_pImpl
->m_xBitmapTable
.set(SvxUnoBitmapTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2073 return m_pImpl
->m_xBitmapTable
;
2075 else if ( aServiceSpecifier
== "com.sun.star.drawing.TransparencyGradientTable" )
2077 if ( !m_pImpl
->m_xTransparencyGradientTable
.is() )
2078 m_pImpl
->m_xTransparencyGradientTable
.set(SvxUnoTransGradientTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2079 return m_pImpl
->m_xTransparencyGradientTable
;
2081 else if ( aServiceSpecifier
== "com.sun.star.drawing.DashTable" )
2083 if ( !m_pImpl
->m_xDashTable
.is() )
2084 m_pImpl
->m_xDashTable
.set(SvxUnoDashTable_createInstance(m_pImpl
->m_pReportModel
.get()),uno::UNO_QUERY
);
2085 return m_pImpl
->m_xDashTable
;
2087 else if( aServiceSpecifier
== "com.sun.star.drawing.MarkerTable" )
2089 if( !m_pImpl
->m_xMarkerTable
.is() )
2090 m_pImpl
->m_xMarkerTable
.set(SvxUnoMarkerTable_createInstance( m_pImpl
->m_pReportModel
.get() ),uno::UNO_QUERY
);
2091 return m_pImpl
->m_xMarkerTable
;
2093 else if ( aServiceSpecifier
== "com.sun.star.document.ImportEmbeddedObjectResolver" )
2094 return cppu::getXWeak(SvXMLEmbeddedObjectHelper::Create( m_pImpl
->m_xStorage
,*this, SvXMLEmbeddedObjectHelperMode::Read
).get());
2095 else if ( aServiceSpecifier
== "com.sun.star.document.ExportEmbeddedObjectResolver" )
2096 return cppu::getXWeak(SvXMLEmbeddedObjectHelper::Create( m_pImpl
->m_xStorage
,*this, SvXMLEmbeddedObjectHelperMode::Write
).get());
2097 else if (aServiceSpecifier
== "com.sun.star.document.ImportGraphicStorageHandler")
2099 rtl::Reference
<SvXMLGraphicHelper
> xGraphicHelper
= SvXMLGraphicHelper::Create(m_pImpl
->m_xStorage
,SvXMLGraphicHelperMode::Write
);
2100 return cppu::getXWeak(xGraphicHelper
.get());
2102 else if (aServiceSpecifier
== "com.sun.star.document.ExportGraphicStorageHandler")
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.chart2.data.DataProvider" )
2109 uno::Reference
<chart2::data::XDatabaseDataProvider
> xDataProvider(chart2::data::DatabaseDataProvider::createWithConnection( m_aProps
->m_xContext
, m_pImpl
->m_xActiveConnection
));
2110 xDataProvider
->setRowLimit(10);
2111 uno::Reference
< container::XChild
> xChild(xDataProvider
,uno::UNO_QUERY
);
2113 xChild
->setParent(*this);
2114 return uno::Reference
< uno::XInterface
>(xDataProvider
,uno::UNO_QUERY
);
2116 else if ( aServiceSpecifier
== "com.sun.star.xml.NamespaceMap" )
2118 if ( !m_pImpl
->m_xXMLNamespaceMap
.is() )
2119 m_pImpl
->m_xXMLNamespaceMap
= comphelper::NameContainer_createInstance( cppu::UnoType
<OUString
>::get() ).get();
2120 return m_pImpl
->m_xXMLNamespaceMap
;
2123 xShape
.set(SvxUnoDrawMSFactory::createInstance( aServiceSpecifier
),uno::UNO_QUERY_THROW
);
2125 return m_pImpl
->m_pReportModel
->createShape(aServiceSpecifier
,xShape
);
2128 uno::Sequence
< OUString
> SAL_CALL
OReportDefinition::getAvailableServiceNames()
2130 static const std::u16string_view aSvxComponentServiceNameList
[] =
2132 u
"com.sun.star.form.component.FixedText",
2133 u
"com.sun.star.form.component.DatabaseImageControl",
2134 u
"com.sun.star.style.PageStyle",
2135 u
"com.sun.star.style.GraphicStyle",
2136 u
"com.sun.star.style.FrameStyle",
2137 u
"com.sun.star.drawing.Defaults",
2138 u
"com.sun.star.document.ImportEmbeddedObjectResolver",
2139 u
"com.sun.star.document.ExportEmbeddedObjectResolver",
2140 u
"com.sun.star.document.ImportGraphicStorageHandler",
2141 u
"com.sun.star.document.ExportGraphicStorageHandler",
2142 u
"com.sun.star.chart2.data.DataProvider",
2143 u
"com.sun.star.xml.NamespaceMap",
2144 u
"com.sun.star.document.Settings",
2145 u
"com.sun.star.drawing.GradientTable",
2146 u
"com.sun.star.drawing.HatchTable",
2147 u
"com.sun.star.drawing.BitmapTable",
2148 u
"com.sun.star.drawing.TransparencyGradientTable",
2149 u
"com.sun.star.drawing.DashTable",
2150 u
"com.sun.star.drawing.MarkerTable"
2153 static const sal_uInt16 nSvxComponentServiceNameListCount
= SAL_N_ELEMENTS(aSvxComponentServiceNameList
);
2155 uno::Sequence
< OUString
> aSeq( nSvxComponentServiceNameListCount
);
2156 OUString
* pStrings
= aSeq
.getArray();
2157 for( sal_uInt16 nIdx
= 0; nIdx
< nSvxComponentServiceNameListCount
; nIdx
++ )
2158 pStrings
[nIdx
] = aSvxComponentServiceNameList
[nIdx
];
2160 uno::Sequence
< OUString
> aParentSeq( SvxUnoDrawMSFactory::getAvailableServiceNames() );
2161 return comphelper::concatSequences( aParentSeq
, aSeq
);
2165 awt::Point SAL_CALL
OReportDefinition::getPosition( )
2167 ::osl::MutexGuard
aGuard(m_aMutex
);
2168 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2169 if ( m_aProps
->m_xShape
.is() )
2170 return m_aProps
->m_xShape
->getPosition();
2171 return awt::Point(m_aProps
->m_nPosX
,m_aProps
->m_nPosY
);
2174 void SAL_CALL
OReportDefinition::setPosition( const awt::Point
& aPosition
)
2176 ::osl::MutexGuard
aGuard(m_aMutex
);
2177 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2178 if ( m_aProps
->m_xShape
.is() )
2179 m_aProps
->m_xShape
->setPosition(aPosition
);
2180 set(PROPERTY_POSITIONX
,aPosition
.X
,m_aProps
->m_nPosX
);
2181 set(PROPERTY_POSITIONY
,aPosition
.Y
,m_aProps
->m_nPosY
);
2184 awt::Size SAL_CALL
OReportDefinition::getSize( )
2186 ::osl::MutexGuard
aGuard(m_aMutex
);
2187 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2188 if ( m_aProps
->m_xShape
.is() )
2189 return m_aProps
->m_xShape
->getSize();
2190 return awt::Size(m_aProps
->m_nWidth
,m_aProps
->m_nHeight
);
2193 void SAL_CALL
OReportDefinition::setSize( const awt::Size
& aSize
)
2195 ::osl::MutexGuard
aGuard(m_aMutex
);
2196 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2197 if ( m_aProps
->m_xShape
.is() )
2198 m_aProps
->m_xShape
->setSize(aSize
);
2199 set(PROPERTY_WIDTH
,aSize
.Width
,m_aProps
->m_nWidth
);
2200 set(PROPERTY_HEIGHT
,aSize
.Height
,m_aProps
->m_nHeight
);
2205 OUString SAL_CALL
OReportDefinition::getShapeType( )
2207 ::osl::MutexGuard
aGuard(m_aMutex
);
2208 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2209 if ( m_aProps
->m_xShape
.is() )
2210 return m_aProps
->m_xShape
->getShapeType();
2211 return u
"com.sun.star.drawing.OLE2Shape"_ustr
;
2214 typedef ::cppu::WeakImplHelper
< container::XNameContainer
,
2215 container::XIndexAccess
2220 class OStylesHelper
:
2221 public cppu::BaseMutex
, public TStylesBASE
2223 typedef ::std::map
< OUString
, uno::Any
, ::comphelper::UStringMixLess
> TStyleElements
;
2224 TStyleElements m_aElements
;
2225 ::std::vector
<TStyleElements::iterator
> m_aElementsPos
;
2229 virtual ~OStylesHelper() override
{}
2231 explicit OStylesHelper(const uno::Type
& rType
= cppu::UnoType
<container::XElementAccess
>::get());
2232 OStylesHelper(const OStylesHelper
&) = delete;
2233 OStylesHelper
& operator=(const OStylesHelper
&) = delete;
2236 virtual void SAL_CALL
insertByName( const OUString
& aName
, const uno::Any
& aElement
) override
;
2237 virtual void SAL_CALL
removeByName( const OUString
& Name
) override
;
2240 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const uno::Any
& aElement
) override
;
2242 // container::XElementAccess
2243 virtual uno::Type SAL_CALL
getElementType( ) override
;
2244 virtual sal_Bool SAL_CALL
hasElements( ) override
;
2245 // container::XIndexAccess
2246 virtual sal_Int32 SAL_CALL
getCount( ) override
;
2247 virtual uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
2249 // container::XNameAccess
2250 virtual uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
2251 virtual uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) override
;
2252 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
2257 OStylesHelper::OStylesHelper(const uno::Type
& rType
)
2264 // container::XElementAccess
2265 uno::Type SAL_CALL
OStylesHelper::getElementType( )
2270 sal_Bool SAL_CALL
OStylesHelper::hasElements( )
2272 ::osl::MutexGuard
aGuard(m_aMutex
);
2273 return !m_aElementsPos
.empty();
2276 // container::XIndexAccess
2277 sal_Int32 SAL_CALL
OStylesHelper::getCount( )
2279 ::osl::MutexGuard
aGuard(m_aMutex
);
2280 return m_aElementsPos
.size();
2283 uno::Any SAL_CALL
OStylesHelper::getByIndex( sal_Int32 Index
)
2285 ::osl::MutexGuard
aGuard(m_aMutex
);
2286 if ( Index
< 0 || o3tl::make_unsigned(Index
) >= m_aElementsPos
.size() )
2287 throw lang::IndexOutOfBoundsException();
2288 return m_aElementsPos
[Index
]->second
;
2291 // container::XNameAccess
2292 uno::Any SAL_CALL
OStylesHelper::getByName( const OUString
& aName
)
2294 ::osl::MutexGuard
aGuard(m_aMutex
);
2295 TStyleElements::const_iterator aFind
= m_aElements
.find(aName
);
2296 if ( aFind
== m_aElements
.end() )
2297 throw container::NoSuchElementException();
2298 return aFind
->second
;
2301 uno::Sequence
< OUString
> SAL_CALL
OStylesHelper::getElementNames( )
2303 ::osl::MutexGuard
aGuard(m_aMutex
);
2304 uno::Sequence
< OUString
> aNameList(m_aElementsPos
.size());
2306 OUString
* pStringArray
= aNameList
.getArray();
2307 for(const auto& rIter
: m_aElementsPos
)
2309 *pStringArray
= rIter
->first
;
2316 sal_Bool SAL_CALL
OStylesHelper::hasByName( const OUString
& aName
)
2318 ::osl::MutexGuard
aGuard(m_aMutex
);
2319 return m_aElements
.find(aName
) != m_aElements
.end();
2323 void SAL_CALL
OStylesHelper::insertByName( const OUString
& aName
, const uno::Any
& aElement
)
2325 ::osl::MutexGuard
aGuard(m_aMutex
);
2326 if ( m_aElements
.find(aName
) != m_aElements
.end() )
2327 throw container::ElementExistException();
2329 if ( !aElement
.isExtractableTo(m_aType
) )
2330 throw lang::IllegalArgumentException();
2332 m_aElementsPos
.push_back(m_aElements
.emplace(aName
,aElement
).first
);
2335 void SAL_CALL
OStylesHelper::removeByName( const OUString
& aName
)
2337 ::osl::MutexGuard
aGuard(m_aMutex
);
2338 TStyleElements::const_iterator aFind
= m_aElements
.find(aName
);
2339 if ( aFind
!= m_aElements
.end() )
2340 throw container::NoSuchElementException();
2341 m_aElementsPos
.erase(::std::find(m_aElementsPos
.begin(),m_aElementsPos
.end(),aFind
));
2342 m_aElements
.erase(aFind
);
2346 void SAL_CALL
OStylesHelper::replaceByName( const OUString
& aName
, const uno::Any
& aElement
)
2348 ::osl::MutexGuard
aGuard(m_aMutex
);
2349 TStyleElements::iterator aFind
= m_aElements
.find(aName
);
2350 if ( aFind
== m_aElements
.end() )
2351 throw container::NoSuchElementException();
2352 if ( !aElement
.isExtractableTo(m_aType
) )
2353 throw lang::IllegalArgumentException();
2354 aFind
->second
= aElement
;
2357 uno::Reference
< container::XNameAccess
> SAL_CALL
OReportDefinition::getStyleFamilies( )
2359 ::osl::MutexGuard
aGuard(m_aMutex
);
2360 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2361 if ( !m_pImpl
->m_xStyles
.is() )
2363 m_pImpl
->m_xStyles
= new OStylesHelper();
2365 uno::Reference
< container::XNameContainer
> xPageStyles
= new OStylesHelper(cppu::UnoType
<style::XStyle
>::get());
2366 m_pImpl
->m_xStyles
->insertByName(u
"PageStyles"_ustr
,uno::Any(xPageStyles
));
2367 uno::Reference
< style::XStyle
> xPageStyle(createInstance(u
"com.sun.star.style.PageStyle"_ustr
),uno::UNO_QUERY
);
2368 xPageStyles
->insertByName(xPageStyle
->getName(),uno::Any(xPageStyle
));
2370 uno::Reference
< container::XNameContainer
> xFrameStyles
= new OStylesHelper(cppu::UnoType
<style::XStyle
>::get());
2371 m_pImpl
->m_xStyles
->insertByName(u
"FrameStyles"_ustr
,uno::Any(xFrameStyles
));
2372 uno::Reference
< style::XStyle
> xFrameStyle(createInstance(u
"com.sun.star.style.FrameStyle"_ustr
),uno::UNO_QUERY
);
2373 xFrameStyles
->insertByName(xFrameStyle
->getName(),uno::Any(xFrameStyle
));
2375 uno::Reference
< container::XNameContainer
> xGraphicStyles
= new OStylesHelper(cppu::UnoType
<style::XStyle
>::get());
2376 m_pImpl
->m_xStyles
->insertByName(u
"graphics"_ustr
,uno::Any(xGraphicStyles
));
2377 uno::Reference
< style::XStyle
> xGraphicStyle(createInstance(u
"com.sun.star.style.GraphicStyle"_ustr
),uno::UNO_QUERY
);
2378 xGraphicStyles
->insertByName(xGraphicStyle
->getName(),uno::Any(xGraphicStyle
));
2380 return m_pImpl
->m_xStyles
;
2382 OUString SAL_CALL
OReportDefinition::getIdentifier( )
2384 ::osl::MutexGuard
aGuard(m_aMutex
);
2385 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2386 return m_pImpl
->m_sIdentifier
;
2389 void SAL_CALL
OReportDefinition::setIdentifier( const OUString
& Identifier
)
2391 ::osl::MutexGuard
aGuard(m_aMutex
);
2392 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2393 m_pImpl
->m_sIdentifier
= Identifier
;
2396 // XNumberFormatsSupplier
2397 uno::Reference
< beans::XPropertySet
> SAL_CALL
OReportDefinition::getNumberFormatSettings( )
2399 ::osl::MutexGuard
aGuard(m_aMutex
);
2400 if ( m_pImpl
->m_xNumberFormatsSupplier
.is() )
2401 return m_pImpl
->m_xNumberFormatsSupplier
->getNumberFormatSettings();
2402 return uno::Reference
< beans::XPropertySet
>();
2405 uno::Reference
< util::XNumberFormats
> SAL_CALL
OReportDefinition::getNumberFormats( )
2407 ::osl::MutexGuard
aGuard(m_aMutex
);
2408 if ( m_pImpl
->m_xNumberFormatsSupplier
.is() )
2409 return m_pImpl
->m_xNumberFormatsSupplier
->getNumberFormats();
2410 return uno::Reference
< util::XNumberFormats
>();
2413 ::comphelper::EmbeddedObjectContainer
& OReportDefinition::getEmbeddedObjectContainer() const
2415 return *m_pImpl
->m_pObjectContainer
;
2418 uno::Reference
< embed::XStorage
> OReportDefinition::getStorage() const
2420 return m_pImpl
->m_xStorage
;
2423 uno::Reference
< task::XInteractionHandler
> OReportDefinition::getInteractionHandler() const
2425 uno::Reference
< task::XInteractionHandler
> xRet(
2426 task::InteractionHandler::createWithParent(m_aProps
->m_xContext
, nullptr), uno::UNO_QUERY_THROW
);
2430 uno::Reference
< sdbc::XConnection
> SAL_CALL
OReportDefinition::getActiveConnection()
2432 ::osl::MutexGuard
aGuard(m_aMutex
);
2433 return m_pImpl
->m_xActiveConnection
;
2436 void SAL_CALL
OReportDefinition::setActiveConnection( const uno::Reference
< sdbc::XConnection
>& _activeconnection
)
2438 if ( !_activeconnection
.is() )
2439 throw lang::IllegalArgumentException();
2440 set(PROPERTY_ACTIVECONNECTION
,_activeconnection
,m_pImpl
->m_xActiveConnection
);
2443 OUString SAL_CALL
OReportDefinition::getDataSourceName()
2445 osl::MutexGuard
g(m_aMutex
);
2446 return m_pImpl
->m_sDataSourceName
;
2449 void SAL_CALL
OReportDefinition::setDataSourceName(const OUString
& the_value
)
2451 set(PROPERTY_DATASOURCENAME
,the_value
,m_pImpl
->m_sDataSourceName
);
2454 bool OReportDefinition::isEnableSetModified() const
2459 OUString
OReportDefinition::getDocumentBaseURL() const
2461 // TODO: should this be in getURL()? not sure...
2462 uno::Reference
<frame::XModel
> const xParent(
2463 const_cast<OReportDefinition
*>(this)->getParent(), uno::UNO_QUERY
);
2466 return xParent
->getURL();
2469 ::osl::MutexGuard
aGuard(m_aMutex
);
2470 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2471 for (beans::PropertyValue
const& it
: m_pImpl
->m_aArgs
)
2473 if (it
.Name
== "DocumentBaseURL")
2474 return it
.Value
.get
<OUString
>();
2480 uno::Reference
< frame::XTitle
> OReportDefinition::impl_getTitleHelper_throw()
2482 SolarMutexGuard aSolarGuard
;
2484 ::osl::MutexGuard
aGuard(m_aMutex
);
2485 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2487 if ( ! m_pImpl
->m_xTitleHelper
.is ())
2489 uno::Reference
< frame::XDesktop2
> xDesktop
= frame::Desktop::create(m_aProps
->m_xContext
);
2491 m_pImpl
->m_xTitleHelper
= new ::framework::TitleHelper( m_aProps
->m_xContext
, uno::Reference
< frame::XModel
>(this),
2492 uno::Reference
<frame::XUntitledNumbers
>(xDesktop
, uno::UNO_QUERY_THROW
) );
2495 return m_pImpl
->m_xTitleHelper
;
2498 uno::Reference
< frame::XUntitledNumbers
> OReportDefinition::impl_getUntitledHelper_throw()
2500 SolarMutexGuard aSolarGuard
;
2502 ::osl::MutexGuard
aGuard(m_aMutex
);
2503 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2505 if ( ! m_pImpl
->m_xNumberedControllers
.is ())
2507 rtl::Reference
<::comphelper::NumberedCollection
> pHelper
= new ::comphelper::NumberedCollection();
2508 m_pImpl
->m_xNumberedControllers
= pHelper
;
2510 pHelper
->setOwner (uno::Reference
< frame::XModel
>(this));
2511 pHelper
->setUntitledPrefix (u
" : "_ustr
);
2514 return m_pImpl
->m_xNumberedControllers
;
2518 OUString SAL_CALL
OReportDefinition::getTitle()
2521 SolarMutexGuard aSolarGuard
;
2523 ::osl::MutexGuard
aGuard(m_aMutex
);
2524 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2526 return impl_getTitleHelper_throw()->getTitle ();
2530 void SAL_CALL
OReportDefinition::setTitle( const OUString
& sTitle
)
2533 SolarMutexGuard aSolarGuard
;
2535 ::osl::MutexGuard
aGuard(m_aMutex
);
2536 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2538 impl_getTitleHelper_throw()->setTitle (sTitle
);
2541 // css.frame.XTitleChangeBroadcaster
2542 void SAL_CALL
OReportDefinition::addTitleChangeListener( const uno::Reference
< frame::XTitleChangeListener
>& xListener
)
2545 SolarMutexGuard aSolarGuard
;
2547 ::osl::MutexGuard
aGuard(m_aMutex
);
2548 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2550 uno::Reference
< frame::XTitleChangeBroadcaster
> xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY
);
2551 if (xBroadcaster
.is ())
2552 xBroadcaster
->addTitleChangeListener (xListener
);
2555 // css.frame.XTitleChangeBroadcaster
2556 void SAL_CALL
OReportDefinition::removeTitleChangeListener( const uno::Reference
< frame::XTitleChangeListener
>& xListener
)
2559 SolarMutexGuard aSolarGuard
;
2561 ::osl::MutexGuard
aGuard(m_aMutex
);
2562 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2564 uno::Reference
< frame::XTitleChangeBroadcaster
> xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY
);
2565 if (xBroadcaster
.is ())
2566 xBroadcaster
->removeTitleChangeListener (xListener
);
2569 // css.frame.XUntitledNumbers
2570 ::sal_Int32 SAL_CALL
OReportDefinition::leaseNumber( const uno::Reference
< uno::XInterface
>& xComponent
)
2572 // object already disposed?
2573 SolarMutexGuard aSolarGuard
;
2574 ::osl::MutexGuard
aGuard(m_aMutex
);
2575 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2577 return impl_getUntitledHelper_throw()->leaseNumber (xComponent
);
2580 // css.frame.XUntitledNumbers
2581 void SAL_CALL
OReportDefinition::releaseNumber( ::sal_Int32 nNumber
)
2583 // object already disposed?
2584 SolarMutexGuard aSolarGuard
;
2585 ::osl::MutexGuard
aGuard(m_aMutex
);
2586 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2588 impl_getUntitledHelper_throw()->releaseNumber (nNumber
);
2591 // css.frame.XUntitledNumbers
2592 void SAL_CALL
OReportDefinition::releaseNumberForComponent( const uno::Reference
< uno::XInterface
>& xComponent
)
2594 // object already disposed?
2595 SolarMutexGuard aSolarGuard
;
2596 ::osl::MutexGuard
aGuard(m_aMutex
);
2597 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2599 impl_getUntitledHelper_throw()->releaseNumberForComponent (xComponent
);
2602 // css.frame.XUntitledNumbers
2603 OUString SAL_CALL
OReportDefinition::getUntitledPrefix()
2605 // object already disposed?
2606 SolarMutexGuard aSolarGuard
;
2607 ::osl::MutexGuard
aGuard(m_aMutex
);
2608 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2610 return impl_getUntitledHelper_throw()->getUntitledPrefix ();
2613 uno::Reference
< document::XDocumentProperties
> SAL_CALL
OReportDefinition::getDocumentProperties( )
2615 ::osl::MutexGuard
aGuard(m_aMutex
);
2616 ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper
.bDisposed
);
2617 if ( !m_pImpl
->m_xDocumentProperties
.is() )
2619 m_pImpl
->m_xDocumentProperties
.set(document::DocumentProperties::create(m_aProps
->m_xContext
));
2621 return m_pImpl
->m_xDocumentProperties
;
2624 uno::Any SAL_CALL
OReportDefinition::getTransferData( const datatransfer::DataFlavor
& aFlavor
)
2627 if( !isDataFlavorSupported( aFlavor
) )
2629 throw datatransfer::UnsupportedFlavorException(aFlavor
.MimeType
, getXWeak());
2634 aResult
= getPreferredVisualRepresentation(0).Data
;
2636 catch (const uno::Exception
&)
2638 DBG_UNHANDLED_EXCEPTION("reportdesign");
2645 uno::Sequence
< datatransfer::DataFlavor
> SAL_CALL
OReportDefinition::getTransferDataFlavors( )
2647 return { { u
"image/png"_ustr
, u
"PNG"_ustr
, cppu::UnoType
<uno::Sequence
< sal_Int8
>>::get() } };
2650 sal_Bool SAL_CALL
OReportDefinition::isDataFlavorSupported( const datatransfer::DataFlavor
& aFlavor
)
2652 return aFlavor
.MimeType
== "image/png";
2656 uno::Reference
< document::XUndoManager
> SAL_CALL
OReportDefinition::getUndoManager( )
2658 ::osl::MutexGuard
aGuard( m_aMutex
);
2659 return m_pImpl
->m_pUndoManager
;
2662 }// namespace reportdesign
2664 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */