Bug Summary

File:home/maarten/src/libreoffice/core/include/rtl/ref.hxx
Warning:line 192, column 9
Use of memory after it is freed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name ximpstyl.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D XMLOFF_DLLIMPLEMENTATION -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/xmloff/inc -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/xmloff/generated -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx

/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx

1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "ximpstyl.hxx"
21#include <xmloff/maptype.hxx>
22#include <xmloff/XMLDrawingPageStyleContext.hxx>
23#include <xmloff/XMLShapeStyleContext.hxx>
24#include <xmloff/xmlnamespace.hxx>
25#include <xmloff/xmlprmap.hxx>
26#include <xmloff/xmltoken.hxx>
27#include <xmloff/xmluconv.hxx>
28#include "ximpnote.hxx"
29#include <xmlsdtypes.hxx>
30#include <tools/debug.hxx>
31#include <sal/log.hxx>
32#include <tools/diagnose_ex.h>
33#include <com/sun/star/frame/XModel.hpp>
34#include <com/sun/star/style/XStyle.hpp>
35#include <com/sun/star/lang/XSingleServiceFactory.hpp>
36#include <com/sun/star/presentation/XPresentationPage.hpp>
37#include <com/sun/star/drawing/XDrawPages.hpp>
38#include <com/sun/star/container/XNamed.hpp>
39#include <com/sun/star/beans/XPropertySet.hpp>
40#include <com/sun/star/beans/XPropertyState.hpp>
41#include <com/sun/star/presentation/XHandoutMasterSupplier.hpp>
42#include <comphelper/namecontainer.hxx>
43#include <xmloff/autolayout.hxx>
44#include <xmloff/xmlprcon.hxx>
45#include <xmloff/families.hxx>
46#include <com/sun/star/container/XNameContainer.hpp>
47#include <svl/zforlist.hxx>
48#include "layerimp.hxx"
49#include <xmloff/XMLGraphicsDefaultStyle.hxx>
50#include <XMLNumberStylesImport.hxx>
51#include <xmloff/xmlerror.hxx>
52#include <xmloff/table/XMLTableImport.hxx>
53
54using namespace ::com::sun::star;
55using namespace ::com::sun::star::uno;
56using namespace ::com::sun::star::xml::sax;
57using namespace ::xmloff::token;
58
59namespace {
60
61class SdXMLDrawingPagePropertySetContext : public SvXMLPropertySetContext
62{
63public:
64
65 SdXMLDrawingPagePropertySetContext( SvXMLImport& rImport, sal_Int32 nElement,
66 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
67 ::std::vector< XMLPropertyState > &rProps,
68 const rtl::Reference < SvXMLImportPropertyMapper > &rMap );
69
70 using SvXMLPropertySetContext::createFastChildContext;
71 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > createFastChildContext(
72 sal_Int32 nElement,
73 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
74 ::std::vector< XMLPropertyState > &rProperties,
75 const XMLPropertyState& rProp ) override;
76};
77
78}
79
80SdXMLDrawingPagePropertySetContext::SdXMLDrawingPagePropertySetContext(
81 SvXMLImport& rImport, sal_Int32 nElement,
82 const uno::Reference< xml::sax::XFastAttributeList > & xAttrList,
83 ::std::vector< XMLPropertyState > &rProps,
84 const rtl::Reference < SvXMLImportPropertyMapper > &rMap ) :
85 SvXMLPropertySetContext( rImport, nElement, xAttrList,
86 XML_TYPE_PROP_DRAWING_PAGE(0x2 << 14), rProps, rMap )
87{
88}
89
90css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLDrawingPagePropertySetContext::createFastChildContext(
91 sal_Int32 nElement,
92 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
93 ::std::vector< XMLPropertyState > &rProperties,
94 const XMLPropertyState& rProp )
95{
96 switch( mxMapper->getPropertySetMapper()->GetEntryContextId( rProp.mnIndex ) )
97 {
98 case CTF_PAGE_SOUND_URL1005:
99 {
100 for (auto &aIter : sax_fastparser::castToFastAttributeList(xAttrList))
101 {
102 if( aIter.getToken() == XML_ELEMENT(XLINK, XML_HREF)( NAMESPACE_TOKEN(XML_NAMESPACE_XLINK) | XML_HREF ) )
103 {
104 uno::Any aAny( GetImport().GetAbsoluteReference( aIter.toString() ) );
105 XMLPropertyState aPropState( rProp.mnIndex, aAny );
106 rProperties.push_back( aPropState );
107 }
108 else
109 SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << aIter.toString())do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "unknown attribute " <<
SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) <<
"=" << aIter.toString()) == 1) { ::sal_detail_log( (::
SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "109" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
aIter.toString()), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
aIter.toString(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "109" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken
(aIter.getToken()) << "=" << aIter.toString()) ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"
), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "109" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
aIter.toString()), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
aIter.toString(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "109" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
110 }
111 break;
112 }
113 }
114
115 return SvXMLPropertySetContext::createFastChildContext( nElement,
116 xAttrList,
117 rProperties, rProp );
118}
119
120namespace {
121
122
123class SdXMLDrawingPageStyleContext : public XMLDrawingPageStyleContext
124{
125public:
126
127 SdXMLDrawingPageStyleContext(
128 SvXMLImport& rImport,
129 SvXMLStylesContext& rStyles);
130
131 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
132 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
133
134 virtual void Finish( bool bOverwrite ) override;
135};
136
137const sal_uInt16 MAX_SPECIAL_DRAW_STYLES = 7;
138ContextID_Index_Pair const g_ContextIDs[MAX_SPECIAL_DRAW_STYLES+1] =
139{
140 { CTF_DASHNAME1012 , -1 },
141 { CTF_LINESTARTNAME1013 , -1 },
142 { CTF_LINEENDNAME1014 , -1 },
143 { CTF_FILLGRADIENTNAME1015, -1 },
144 { CTF_FILLTRANSNAME1018 , -1 },
145 { CTF_FILLHATCHNAME1016 , -1 },
146 { CTF_FILLBITMAPNAME1017 , -1 },
147 { -1, -1 }
148};
149XmlStyleFamily const g_Families[MAX_SPECIAL_DRAW_STYLES] =
150{
151 XmlStyleFamily::SD_STROKE_DASH_ID,
152 XmlStyleFamily::SD_MARKER_ID,
153 XmlStyleFamily::SD_MARKER_ID,
154 XmlStyleFamily::SD_GRADIENT_ID,
155 XmlStyleFamily::SD_GRADIENT_ID,
156 XmlStyleFamily::SD_HATCH_ID,
157 XmlStyleFamily::SD_FILL_IMAGE_ID
158};
159
160}
161
162XMLDrawingPageStyleContext::XMLDrawingPageStyleContext(
163 SvXMLImport& rImport,
164 SvXMLStylesContext& rStyles,
165 ContextID_Index_Pair const pContextIDs[],
166 XmlStyleFamily const pFamilies[])
167 : XMLPropStyleContext(rImport, rStyles, XmlStyleFamily::SD_DRAWINGPAGE_ID)
168 , m_pFamilies(pFamilies)
169{
170 size_t size(1); // for the -1 entry
171 for (ContextID_Index_Pair const* pTemp(pContextIDs); pTemp->nContextID != -1; ++size, ++pTemp);
172 m_pContextIDs.reset(new ContextID_Index_Pair[size]);
173 std::memcpy(m_pContextIDs.get(), pContextIDs, size * sizeof(ContextID_Index_Pair));
174}
175
176SdXMLDrawingPageStyleContext::SdXMLDrawingPageStyleContext(
177 SvXMLImport& rImport,
178 SvXMLStylesContext& rStyles)
179 : XMLDrawingPageStyleContext(rImport, rStyles, g_ContextIDs, g_Families)
180{
181}
182
183css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLDrawingPageStyleContext::createFastChildContext(
184 sal_Int32 nElement,
185 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
186{
187 if( nElement == XML_ELEMENT(STYLE, XML_DRAWING_PAGE_PROPERTIES)( NAMESPACE_TOKEN(XML_NAMESPACE_STYLE) | XML_DRAWING_PAGE_PROPERTIES
)
)
188 {
189 rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap =
190 GetStyles()->GetImportPropertyMapper( GetFamily() );
191 if( xImpPrMap.is() )
192 return new SdXMLDrawingPagePropertySetContext( GetImport(), nElement,
193 xAttrList,
194 GetProperties(),
195 xImpPrMap );
196 }
197
198 return XMLPropStyleContext::createFastChildContext( nElement, xAttrList );
199}
200
201void SdXMLDrawingPageStyleContext::Finish( bool bOverwrite )
202{
203 XMLPropStyleContext::Finish( bOverwrite );
204
205 ::std::vector< XMLPropertyState > &rProperties = GetProperties();
206
207 const rtl::Reference< XMLPropertySetMapper >& rImpPrMap = GetStyles()->GetImportPropertyMapper( GetFamily() )->getPropertySetMapper();
208
209 for(auto& property : rProperties)
210 {
211 if( property.mnIndex == -1 )
212 continue;
213
214 sal_Int16 nContextID = rImpPrMap->GetEntryContextId(property.mnIndex);
215 switch( nContextID )
216 {
217 case CTF_DATE_TIME_FORMAT1057:
218 {
219 OUString sStyleName;
220 property.maValue >>= sStyleName;
221
222 sal_Int32 nStyle = 0;
223
224 const SdXMLNumberFormatImportContext* pSdNumStyle =
225 dynamic_cast< const SdXMLNumberFormatImportContext*> (
226 GetStyles()->FindStyleChildContext( XmlStyleFamily::DATA_STYLE, sStyleName, true ) );
227
228 if( pSdNumStyle )
229 nStyle = pSdNumStyle->GetDrawKey();
230
231 property.maValue <<= nStyle;
232 }
233 break;
234 }
235 }
236
237}
238
239
240// #i35918#
241void XMLDrawingPageStyleContext::FillPropertySet(
242 const Reference< beans::XPropertySet > & rPropSet )
243{
244 rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap =
245 GetStyles()->GetImportPropertyMapper( GetFamily() );
246 SAL_WARN_IF( !xImpPrMap.is(), "xmloff", "There is the import prop mapper" )do { if (true && (!xImpPrMap.is())) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "xmloff")) { case SAL_DETAIL_LOG_ACTION_IGNORE
: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail
::getResult( ::sal::detail::StreamStart() << "There is the import prop mapper"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"
), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "246" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "There is the import prop mapper"), 0)
; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "There is the import prop mapper"; ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "246" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "There is the import prop mapper") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "246" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "There is the import prop mapper"), 0)
; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "There is the import prop mapper"; ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "246" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
247 if( xImpPrMap.is() )
248 xImpPrMap->FillPropertySet(GetProperties(), rPropSet, m_pContextIDs.get());
249
250 Reference< beans::XPropertySetInfo > xInfo;
251 for (size_t i=0; m_pContextIDs[i].nContextID != -1; ++i)
252 {
253 sal_Int32 nIndex = m_pContextIDs[i].nIndex;
254 if( nIndex != -1 )
255 {
256 struct XMLPropertyState& rState = GetProperties()[nIndex];
257 OUString sStyleName;
258 rState.maValue >>= sStyleName;
259 sStyleName = GetImport().GetStyleDisplayName( m_pFamilies[i],
260 sStyleName );
261 // get property set mapper
262 rtl::Reference<XMLPropertySetMapper> rPropMapper =
263 xImpPrMap->getPropertySetMapper();
264
265 // set property
266 const OUString& rPropertyName =
267 rPropMapper->GetEntryAPIName(rState.mnIndex);
268 if( !xInfo.is() )
269 xInfo = rPropSet->getPropertySetInfo();
270 if ( xInfo->hasPropertyByName( rPropertyName ) )
271 {
272 rPropSet->setPropertyValue( rPropertyName, Any( sStyleName ) );
273 }
274 }
275 }
276}
277
278
279SdXMLPageMasterStyleContext::SdXMLPageMasterStyleContext(
280 SdXMLImport& rImport,
281 sal_Int32 /*nElement*/,
282 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList)
283: SvXMLStyleContext(rImport, XmlStyleFamily::SD_PAGEMASTERSTYLECONTEXT_ID),
284 mnBorderBottom( 0 ),
285 mnBorderLeft( 0 ),
286 mnBorderRight( 0 ),
287 mnBorderTop( 0 ),
288 mnWidth( 0 ),
289 mnHeight( 0 ),
290 meOrientation(GetSdImport().IsDraw() ? view::PaperOrientation_PORTRAIT : view::PaperOrientation_LANDSCAPE)
291{
292 // set family to something special at SvXMLStyleContext
293 // for differences in search-methods
294
295 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
296 {
297 OUString sValue = aIter.toString();
298 switch(aIter.getToken())
299 {
300 case XML_ELEMENT(FO, XML_MARGIN_TOP)( NAMESPACE_TOKEN(XML_NAMESPACE_FO) | XML_MARGIN_TOP ):
301 case XML_ELEMENT(FO_COMPAT, XML_MARGIN_TOP)( NAMESPACE_TOKEN(XML_NAMESPACE_FO_COMPAT) | XML_MARGIN_TOP ):
302 {
303 GetSdImport().GetMM100UnitConverter().convertMeasureToCore(
304 mnBorderTop, sValue);
305 break;
306 }
307 case XML_ELEMENT(FO, XML_MARGIN_BOTTOM)( NAMESPACE_TOKEN(XML_NAMESPACE_FO) | XML_MARGIN_BOTTOM ):
308 case XML_ELEMENT(FO_COMPAT, XML_MARGIN_BOTTOM)( NAMESPACE_TOKEN(XML_NAMESPACE_FO_COMPAT) | XML_MARGIN_BOTTOM
)
:
309 {
310 GetSdImport().GetMM100UnitConverter().convertMeasureToCore(
311 mnBorderBottom, sValue);
312 break;
313 }
314 case XML_ELEMENT(FO, XML_MARGIN_LEFT)( NAMESPACE_TOKEN(XML_NAMESPACE_FO) | XML_MARGIN_LEFT ):
315 case XML_ELEMENT(FO_COMPAT, XML_MARGIN_LEFT)( NAMESPACE_TOKEN(XML_NAMESPACE_FO_COMPAT) | XML_MARGIN_LEFT ):
316 {
317 GetSdImport().GetMM100UnitConverter().convertMeasureToCore(
318 mnBorderLeft, sValue);
319 break;
320 }
321 case XML_ELEMENT(FO, XML_MARGIN_RIGHT)( NAMESPACE_TOKEN(XML_NAMESPACE_FO) | XML_MARGIN_RIGHT ):
322 case XML_ELEMENT(FO_COMPAT, XML_MARGIN_RIGHT)( NAMESPACE_TOKEN(XML_NAMESPACE_FO_COMPAT) | XML_MARGIN_RIGHT
)
:
323 {
324 GetSdImport().GetMM100UnitConverter().convertMeasureToCore(
325 mnBorderRight, sValue);
326 break;
327 }
328 case XML_ELEMENT(FO, XML_PAGE_WIDTH)( NAMESPACE_TOKEN(XML_NAMESPACE_FO) | XML_PAGE_WIDTH ):
329 case XML_ELEMENT(FO_COMPAT, XML_PAGE_WIDTH)( NAMESPACE_TOKEN(XML_NAMESPACE_FO_COMPAT) | XML_PAGE_WIDTH ):
330 {
331 GetSdImport().GetMM100UnitConverter().convertMeasureToCore(
332 mnWidth, sValue);
333 break;
334 }
335 case XML_ELEMENT(FO, XML_PAGE_HEIGHT)( NAMESPACE_TOKEN(XML_NAMESPACE_FO) | XML_PAGE_HEIGHT ):
336 case XML_ELEMENT(FO_COMPAT, XML_PAGE_HEIGHT)( NAMESPACE_TOKEN(XML_NAMESPACE_FO_COMPAT) | XML_PAGE_HEIGHT ):
337 {
338 GetSdImport().GetMM100UnitConverter().convertMeasureToCore(
339 mnHeight, sValue);
340 break;
341 }
342 case XML_ELEMENT(STYLE, XML_PRINT_ORIENTATION)( NAMESPACE_TOKEN(XML_NAMESPACE_STYLE) | XML_PRINT_ORIENTATION
)
:
343 {
344 if( IsXMLToken( sValue, XML_PORTRAIT ) )
345 meOrientation = view::PaperOrientation_PORTRAIT;
346 else
347 meOrientation = view::PaperOrientation_LANDSCAPE;
348 break;
349 }
350 default:
351 SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << sValue)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "unknown attribute " <<
SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) <<
"=" << sValue) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "351" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
sValue), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
sValue; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "351" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken
(aIter.getToken()) << "=" << sValue) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "351" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
sValue), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
sValue; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "351" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
352 }
353 }
354}
355
356SdXMLPageMasterStyleContext::~SdXMLPageMasterStyleContext()
357{
358}
359
360
361SdXMLPageMasterContext::SdXMLPageMasterContext(
362 SdXMLImport& rImport,
363 sal_Int32 /*nElement*/,
364 const uno::Reference< xml::sax::XFastAttributeList>& /*xAttrList*/)
365: SvXMLStyleContext(rImport, XmlStyleFamily::SD_PAGEMASTERCONTEXT_ID)
366{
367 // set family to something special at SvXMLStyleContext
368 // for differences in search-methods
369
370}
371
372css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLPageMasterContext::createFastChildContext(
373 sal_Int32 nElement,
374 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
375{
376 if(nElement == XML_ELEMENT(STYLE, XML_PAGE_LAYOUT_PROPERTIES)( NAMESPACE_TOKEN(XML_NAMESPACE_STYLE) | XML_PAGE_LAYOUT_PROPERTIES
)
)
377 {
378 DBG_ASSERT(!mxPageMasterStyle.is(), "PageMasterStyle is set, there seem to be two of them (!)")do { if (true && (!(!mxPageMasterStyle.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "378" ": "), "%s", "PageMasterStyle is set, there seem to be two of them (!)"
); } } while (false)
;
379 mxPageMasterStyle.set(new SdXMLPageMasterStyleContext(GetSdImport(), nElement, xAttrList));
380 return mxPageMasterStyle.get();
381 }
382 else
383 SAL_WARN("xmloff", "unknown element " << SvXMLImport::getPrefixAndNameFromToken(nElement))do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "unknown element " <<
SvXMLImport::getPrefixAndNameFromToken(nElement)) == 1) { ::
sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "383" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "unknown element " << SvXMLImport
::getPrefixAndNameFromToken(nElement)), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "unknown element "
<< SvXMLImport::getPrefixAndNameFromToken(nElement); ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), (
"/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "383" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "unknown element " << SvXMLImport::getPrefixAndNameFromToken
(nElement)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "383" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "unknown element " << SvXMLImport
::getPrefixAndNameFromToken(nElement)), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "unknown element "
<< SvXMLImport::getPrefixAndNameFromToken(nElement); ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), (
"/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "383" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
384
385 return nullptr;
386}
387
388SdXMLPresentationPageLayoutContext::SdXMLPresentationPageLayoutContext(
389 SdXMLImport& rImport,
390 sal_Int32 /*nElement*/,
391 const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/)
392: SvXMLStyleContext(rImport, XmlStyleFamily::SD_PRESENTATIONPAGELAYOUT_ID),
393 mnTypeId( AUTOLAYOUT_NONE )
394{
395 // set family to something special at SvXMLStyleContext
396 // for differences in search-methods
397}
398
399css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLPresentationPageLayoutContext::createFastChildContext(
400 sal_Int32 nElement,
401 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
402{
403 SvXMLImportContextRef xContext;
404
405 if(nElement == XML_ELEMENT(PRESENTATION, XML_PLACEHOLDER)( NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION) | XML_PLACEHOLDER
)
)
1
Assuming the condition is true
2
Taking true branch
406 {
407 const rtl::Reference< SdXMLPresentationPlaceholderContext > xLclContext{
408 new SdXMLPresentationPlaceholderContext(GetSdImport(), nElement, xAttrList)};
3
Memory is allocated
409 // presentation:placeholder inside style:presentation-page-layout context
410 xContext = xLclContext.get();
411
412 // remember SdXMLPresentationPlaceholderContext for later evaluation
413 maList.push_back(xLclContext);
414 }
4
Calling '~Reference'
11
Returning from '~Reference'
415 else
416 SAL_WARN("xmloff", "unknown element " << SvXMLImport::getPrefixAndNameFromToken(nElement))do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "unknown element " <<
SvXMLImport::getPrefixAndNameFromToken(nElement)) == 1) { ::
sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "416" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "unknown element " << SvXMLImport
::getPrefixAndNameFromToken(nElement)), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "unknown element "
<< SvXMLImport::getPrefixAndNameFromToken(nElement); ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), (
"/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "416" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "unknown element " << SvXMLImport::getPrefixAndNameFromToken
(nElement)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "416" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "unknown element " << SvXMLImport
::getPrefixAndNameFromToken(nElement)), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "unknown element "
<< SvXMLImport::getPrefixAndNameFromToken(nElement); ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), (
"/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "416" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
417
418 return xContext.get();
12
Calling 'Reference::get'
419}
420
421void SdXMLPresentationPageLayoutContext::endFastElement(sal_Int32 )
422{
423 // build presentation page layout type here
424 // calc mnTpeId due to content of maList
425 // at the moment only use number of types used there
426 if( maList.empty() )
427 return;
428
429 SdXMLPresentationPlaceholderContext* pObj0 = maList[ 0 ].get();
430 if( pObj0->GetName() == "handout" )
431 {
432 switch( maList.size() )
433 {
434 case 1:
435 mnTypeId = AUTOLAYOUT_HANDOUT1;
436 break;
437 case 2:
438 mnTypeId = AUTOLAYOUT_HANDOUT2;
439 break;
440 case 3:
441 mnTypeId = AUTOLAYOUT_HANDOUT3;
442 break;
443 case 4:
444 mnTypeId = AUTOLAYOUT_HANDOUT4;
445 break;
446 case 9:
447 mnTypeId = AUTOLAYOUT_HANDOUT9;
448 break;
449 default:
450 mnTypeId = AUTOLAYOUT_HANDOUT6;
451 }
452 }
453 else
454 {
455 switch( maList.size() )
456 {
457 case 1:
458 {
459 if( pObj0->GetName() == "title" )
460 {
461 mnTypeId = AUTOLAYOUT_TITLE_ONLY;
462 }
463 else
464 {
465 mnTypeId = AUTOLAYOUT_ONLY_TEXT;
466 }
467 break;
468 }
469 case 2:
470 {
471 SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get();
472
473 if( pObj1->GetName() == "subtitle" )
474 {
475 mnTypeId = AUTOLAYOUT_TITLE;
476 }
477 else if( pObj1->GetName() == "outline" )
478 {
479 mnTypeId = AUTOLAYOUT_TITLE_CONTENT;
480 }
481 else if( pObj1->GetName() == "chart" )
482 {
483 mnTypeId = AUTOLAYOUT_CHART;
484 }
485 else if( pObj1->GetName() == "table" )
486 {
487 mnTypeId = AUTOLAYOUT_TAB;
488 }
489 else if( pObj1->GetName() == "object" )
490 {
491 mnTypeId = AUTOLAYOUT_OBJ;
492 }
493 else if( pObj1->GetName() == "vertical_outline" )
494 {
495 if( pObj0->GetName() == "vertical_title" )
496 {
497 mnTypeId = AUTOLAYOUT_VTITLE_VCONTENT;
498 }
499 else
500 {
501 mnTypeId = AUTOLAYOUT_TITLE_VCONTENT;
502 }
503 }
504 else
505 {
506 mnTypeId = AUTOLAYOUT_NOTES;
507 }
508 break;
509 }
510 case 3:
511 {
512 SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get();
513 SdXMLPresentationPlaceholderContext* pObj2 = maList[ 2 ].get();
514
515 if( pObj1->GetName() == "outline" )
516 {
517 if( pObj2->GetName() == "outline" )
518 {
519 mnTypeId = AUTOLAYOUT_TITLE_2CONTENT;
520 }
521 else if( pObj2->GetName() == "chart" )
522 {
523 mnTypeId = AUTOLAYOUT_TEXTCHART;
524 }
525 else if( pObj2->GetName() == "graphic" )
526 {
527 mnTypeId = AUTOLAYOUT_TEXTCLIP;
528 }
529 else
530 {
531 if(pObj1->GetX() < pObj2->GetX())
532 {
533 mnTypeId = AUTOLAYOUT_TEXTOBJ; // outline left, object right
534 }
535 else
536 {
537 mnTypeId = AUTOLAYOUT_TEXTOVEROBJ; // outline top, object right
538 }
539 }
540 }
541 else if( pObj1->GetName() == "chart" )
542 {
543 mnTypeId = AUTOLAYOUT_CHARTTEXT;
544 }
545 else if( pObj1->GetName() == "graphic" )
546 {
547 if( pObj2->GetName() == "vertical_outline" )
548 {
549 mnTypeId = AUTOLAYOUT_TITLE_2VTEXT;
550 }
551 else
552 {
553 mnTypeId = AUTOLAYOUT_CLIPTEXT;
554 }
555 }
556 else if( pObj1->GetName() == "vertical_outline" )
557 {
558 mnTypeId = AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT;
559 }
560 else
561 {
562 if(pObj1->GetX() < pObj2->GetX())
563 {
564 mnTypeId = AUTOLAYOUT_OBJTEXT; // left, right
565 }
566 else
567 {
568 mnTypeId = AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT; // top, bottom
569 }
570 }
571 break;
572 }
573 case 4:
574 {
575 SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get();
576 SdXMLPresentationPlaceholderContext* pObj2 = maList[ 2 ].get();
577
578 if( pObj1->GetName() == "object" )
579 {
580 if(pObj1->GetX() < pObj2->GetX())
581 {
582 mnTypeId = AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT;
583 }
584 else
585 {
586 mnTypeId = AUTOLAYOUT_TITLE_2CONTENT_CONTENT;
587 }
588 }
589 else
590 {
591 mnTypeId = AUTOLAYOUT_TITLE_CONTENT_2CONTENT;
592 }
593 break;
594 }
595 case 5:
596 {
597 SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get();
598
599 if( pObj1->GetName() == "object" )
600 {
601 mnTypeId = AUTOLAYOUT_TITLE_4CONTENT;
602 }
603 else
604 {
605 mnTypeId = AUTOLAYOUT_4CLIPART;
606 }
607 break;
608
609 }
610 case 7:
611 {
612 mnTypeId = AUTOLAYOUT_4CLIPART; // FIXME: not AUTOLAYOUT_TITLE_6CONTENT?
613 break;
614 }
615 default:
616 {
617 mnTypeId = AUTOLAYOUT_NONE;
618 break;
619 }
620 }
621 }
622
623 // release remembered contexts, they are no longer needed
624 maList.clear();
625}
626
627SdXMLPresentationPlaceholderContext::SdXMLPresentationPlaceholderContext(
628 SdXMLImport& rImport,
629 sal_Int32 /*nElement*/,
630 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList)
631: SvXMLImportContext( rImport ),
632 mnX(0)
633{
634 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
635 {
636 OUString sValue = aIter.toString();
637 switch(aIter.getToken())
638 {
639 case XML_ELEMENT(PRESENTATION, XML_OBJECT)( NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION) | XML_OBJECT ):
640 {
641 msName = sValue;
642 break;
643 }
644 case XML_ELEMENT(SVG, XML_X)( NAMESPACE_TOKEN(XML_NAMESPACE_SVG) | XML_X ):
645 case XML_ELEMENT(SVG_COMPAT, XML_X)( NAMESPACE_TOKEN(XML_NAMESPACE_SVG_COMPAT) | XML_X ):
646 {
647 GetSdImport().GetMM100UnitConverter().convertMeasureToCore(
648 mnX, sValue);
649 break;
650 }
651 case XML_ELEMENT(SVG, XML_Y)( NAMESPACE_TOKEN(XML_NAMESPACE_SVG) | XML_Y ):
652 case XML_ELEMENT(SVG_COMPAT, XML_Y)( NAMESPACE_TOKEN(XML_NAMESPACE_SVG_COMPAT) | XML_Y ):
653 {
654 break;
655 }
656 case XML_ELEMENT(SVG, XML_WIDTH)( NAMESPACE_TOKEN(XML_NAMESPACE_SVG) | XML_WIDTH ):
657 case XML_ELEMENT(SVG_COMPAT, XML_WIDTH)( NAMESPACE_TOKEN(XML_NAMESPACE_SVG_COMPAT) | XML_WIDTH ):
658 {
659 break;
660 }
661 case XML_ELEMENT(SVG, XML_HEIGHT)( NAMESPACE_TOKEN(XML_NAMESPACE_SVG) | XML_HEIGHT ):
662 case XML_ELEMENT(SVG_COMPAT, XML_HEIGHT)( NAMESPACE_TOKEN(XML_NAMESPACE_SVG_COMPAT) | XML_HEIGHT ):
663 {
664 break;
665 }
666 default:
667 SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << sValue)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "unknown attribute " <<
SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) <<
"=" << sValue) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "667" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
sValue), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
sValue; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "667" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken
(aIter.getToken()) << "=" << sValue) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "667" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
sValue), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
sValue; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "667" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
668 }
669 }
670}
671
672SdXMLPresentationPlaceholderContext::~SdXMLPresentationPlaceholderContext()
673{
674}
675
676
677SdXMLMasterPageContext::SdXMLMasterPageContext(
678 SdXMLImport& rImport,
679 sal_Int32 nElement,
680 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList,
681 uno::Reference< drawing::XShapes > const & rShapes)
682: SdXMLGenericPageContext( rImport, xAttrList, rShapes )
683{
684 const bool bHandoutMaster = (nElement & TOKEN_MASK) == XML_HANDOUT_MASTER;
685 OUString sStyleName, sPageMasterName;
686
687 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
688 {
689 const OUString sValue = aIter.toString();
690 switch(aIter.getToken())
691 {
692 case XML_ELEMENT(STYLE, XML_NAME)( NAMESPACE_TOKEN(XML_NAMESPACE_STYLE) | XML_NAME ):
693 {
694 msName = sValue;
695 break;
696 }
697 case XML_ELEMENT(STYLE, XML_DISPLAY_NAME)( NAMESPACE_TOKEN(XML_NAMESPACE_STYLE) | XML_DISPLAY_NAME ):
698 {
699 msDisplayName = sValue;
700 break;
701 }
702 case XML_ELEMENT(STYLE, XML_PAGE_LAYOUT_NAME)( NAMESPACE_TOKEN(XML_NAMESPACE_STYLE) | XML_PAGE_LAYOUT_NAME
)
:
703 {
704 sPageMasterName = sValue;
705 break;
706 }
707 case XML_ELEMENT(DRAW, XML_STYLE_NAME)( NAMESPACE_TOKEN(XML_NAMESPACE_DRAW) | XML_STYLE_NAME ):
708 {
709 sStyleName = sValue;
710 break;
711 }
712 case XML_ELEMENT(PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME)( NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION) | XML_PRESENTATION_PAGE_LAYOUT_NAME
)
:
713 {
714 maPageLayoutName = sValue;
715 break;
716 }
717 case XML_ELEMENT(PRESENTATION, XML_USE_HEADER_NAME)( NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION) | XML_USE_HEADER_NAME
)
:
718 {
719 maUseHeaderDeclName = sValue;
720 break;
721 }
722 case XML_ELEMENT(PRESENTATION, XML_USE_FOOTER_NAME)( NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION) | XML_USE_FOOTER_NAME
)
:
723 {
724 maUseFooterDeclName = sValue;
725 break;
726 }
727 case XML_ELEMENT(PRESENTATION, XML_USE_DATE_TIME_NAME)( NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION) | XML_USE_DATE_TIME_NAME
)
:
728 {
729 maUseDateTimeDeclName = sValue;
730 break;
731 }
732 default:
733 SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << sValue)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "unknown attribute " <<
SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) <<
"=" << sValue) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "733" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
sValue), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
sValue; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "733" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken
(aIter.getToken()) << "=" << sValue) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "733" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
sValue), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
sValue; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "733" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
734 }
735 }
736
737 if( msDisplayName.isEmpty() )
738 msDisplayName = msName;
739 else if( msDisplayName != msName )
740 GetImport().AddStyleDisplayName( XmlStyleFamily::MASTER_PAGE, msName, msDisplayName );
741
742 GetImport().GetShapeImport()->startPage( GetLocalShapesContext() );
743
744 // set page name?
745 if(!bHandoutMaster && !msDisplayName.isEmpty() && GetLocalShapesContext().is())
746 {
747 uno::Reference < container::XNamed > xNamed(GetLocalShapesContext(), uno::UNO_QUERY);
748 if(xNamed.is())
749 xNamed->setName(msDisplayName);
750 }
751
752 // set page-master?
753 if(!sPageMasterName.isEmpty())
754 {
755 SetPageMaster( sPageMasterName );
756 }
757
758 SetStyle( sStyleName );
759
760 SetLayout();
761
762 DeleteAllShapes();
763}
764
765SdXMLMasterPageContext::~SdXMLMasterPageContext()
766{
767}
768
769void SdXMLMasterPageContext::endFastElement(sal_Int32 nElement)
770{
771 // set styles on master-page
772 if(!msName.isEmpty() && GetSdImport().GetShapeImport()->GetStylesContext())
773 {
774 SvXMLImportContext* pContext = GetSdImport().GetShapeImport()->GetStylesContext();
775 if (SdXMLStylesContext* pSdContext = dynamic_cast<SdXMLStylesContext*>(pContext))
776 pSdContext->SetMasterPageStyles(*this);
777 }
778
779 SdXMLGenericPageContext::endFastElement(nElement);
780 GetImport().GetShapeImport()->endPage(GetLocalShapesContext());
781}
782
783css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLMasterPageContext::createFastChildContext(
784 sal_Int32 nElement,
785 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
786{
787 switch (nElement)
788 {
789 // some special objects inside style:masterpage context
790 case XML_ELEMENT(STYLE, XML_STYLE)( NAMESPACE_TOKEN(XML_NAMESPACE_STYLE) | XML_STYLE ):
791 {
792 if(GetSdImport().GetShapeImport()->GetStylesContext())
793 {
794 // style:style inside master-page context -> presentation style
795 XMLShapeStyleContext* pNew = new XMLShapeStyleContext(
796 GetSdImport(),
797 *GetSdImport().GetShapeImport()->GetStylesContext(),
798 XmlStyleFamily::SD_PRESENTATION_ID);
799
800 // add this style to the outer StylesContext class for later processing
801 GetSdImport().GetShapeImport()->GetStylesContext()->AddStyle(*pNew);
802 return pNew;
803 }
804 break;
805 }
806 case XML_ELEMENT(PRESENTATION, XML_NOTES)( NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION) | XML_NOTES ):
807 {
808 if( GetSdImport().IsImpress() )
809 {
810 // get notes page
811 uno::Reference< presentation::XPresentationPage > xPresPage(GetLocalShapesContext(), uno::UNO_QUERY);
812 if(xPresPage.is())
813 {
814 uno::Reference< drawing::XDrawPage > xNotesDrawPage = xPresPage->getNotesPage();
815 if(xNotesDrawPage.is())
816 {
817 // presentation:notes inside master-page context
818 return new SdXMLNotesContext( GetSdImport(), xAttrList, xNotesDrawPage);
819 }
820 }
821 }
822 }
823 }
824 return SdXMLGenericPageContext::createFastChildContext(nElement, xAttrList);
825}
826
827SdXMLStylesContext::SdXMLStylesContext(
828 SdXMLImport& rImport,
829 bool bIsAutoStyle)
830: SvXMLStylesContext(rImport),
831 mbIsAutoStyle(bIsAutoStyle)
832{
833 Reference< uno::XComponentContext > xContext = rImport.GetComponentContext();
834 mpNumFormatter = std::make_unique<SvNumberFormatter>( xContext, LANGUAGE_SYSTEMLanguageType(0x0000) );
835 mpNumFmtHelper = std::make_unique<SvXMLNumFmtHelper>( mpNumFormatter.get(), xContext );
836}
837
838SvXMLStyleContext* SdXMLStylesContext::CreateStyleChildContext(
839 sal_Int32 nElement,
840 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList)
841{
842 switch (nElement)
843 {
844 case XML_ELEMENT(TABLE, XML_TABLE_TEMPLATE)( NAMESPACE_TOKEN(XML_NAMESPACE_TABLE) | XML_TABLE_TEMPLATE ):
845 {
846 auto pContext = GetImport().GetShapeImport()->GetShapeTableImport()->CreateTableTemplateContext(nElement, xAttrList );
847 if (pContext)
848 return pContext;
849 break;
850 }
851 case XML_ELEMENT(STYLE, XML_PAGE_LAYOUT)( NAMESPACE_TOKEN(XML_NAMESPACE_STYLE) | XML_PAGE_LAYOUT ):
852 // style:page-master inside office:styles context
853 return new SdXMLPageMasterContext(GetSdImport(), nElement, xAttrList);
854 case XML_ELEMENT(STYLE, XML_PRESENTATION_PAGE_LAYOUT)( NAMESPACE_TOKEN(XML_NAMESPACE_STYLE) | XML_PRESENTATION_PAGE_LAYOUT
)
:
855 // style:presentation-page-layout inside office:styles context
856 return new SdXMLPresentationPageLayoutContext(GetSdImport(), nElement, xAttrList);
857 case XML_ELEMENT(NUMBER, XML_DATE_STYLE)( NAMESPACE_TOKEN(XML_NAMESPACE_NUMBER) | XML_DATE_STYLE ):
858 // number:date-style or number:time-style
859 return new SdXMLNumberFormatImportContext( GetSdImport(), nElement, mpNumFmtHelper->getData(), SvXMLStylesTokens::DATE_STYLE, xAttrList, *this );
860 case XML_ELEMENT(NUMBER, XML_TIME_STYLE)( NAMESPACE_TOKEN(XML_NAMESPACE_NUMBER) | XML_TIME_STYLE ):
861 // number:date-style or number:time-style
862 return new SdXMLNumberFormatImportContext( GetSdImport(), nElement, mpNumFmtHelper->getData(), SvXMLStylesTokens::TIME_STYLE, xAttrList, *this );
863 case XML_ELEMENT(NUMBER, XML_NUMBER_STYLE)( NAMESPACE_TOKEN(XML_NAMESPACE_NUMBER) | XML_NUMBER_STYLE ):
864 return new SvXMLNumFormatContext( GetSdImport(), nElement,
865 mpNumFmtHelper->getData(), SvXMLStylesTokens::NUMBER_STYLE, xAttrList, *this );
866 case XML_ELEMENT(NUMBER, XML_CURRENCY_STYLE)( NAMESPACE_TOKEN(XML_NAMESPACE_NUMBER) | XML_CURRENCY_STYLE ):
867 return new SvXMLNumFormatContext( GetSdImport(), nElement,
868 mpNumFmtHelper->getData(), SvXMLStylesTokens::CURRENCY_STYLE, xAttrList, *this );
869 case XML_ELEMENT(NUMBER, XML_PERCENTAGE_STYLE)( NAMESPACE_TOKEN(XML_NAMESPACE_NUMBER) | XML_PERCENTAGE_STYLE
)
:
870 return new SvXMLNumFormatContext( GetSdImport(), nElement,
871 mpNumFmtHelper->getData(), SvXMLStylesTokens::PERCENTAGE_STYLE, xAttrList, *this );
872 case XML_ELEMENT(NUMBER, XML_BOOLEAN_STYLE)( NAMESPACE_TOKEN(XML_NAMESPACE_NUMBER) | XML_BOOLEAN_STYLE ):
873 return new SvXMLNumFormatContext( GetSdImport(), nElement,
874 mpNumFmtHelper->getData(), SvXMLStylesTokens::BOOLEAN_STYLE, xAttrList, *this );
875 case XML_ELEMENT(NUMBER, XML_TEXT_STYLE)( NAMESPACE_TOKEN(XML_NAMESPACE_NUMBER) | XML_TEXT_STYLE ):
876 return new SvXMLNumFormatContext( GetSdImport(), nElement,
877 mpNumFmtHelper->getData(), SvXMLStylesTokens::TEXT_STYLE, xAttrList, *this );
878 case XML_ELEMENT(PRESENTATION, XML_HEADER_DECL)( NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION) | XML_HEADER_DECL
)
:
879 case XML_ELEMENT(PRESENTATION, XML_FOOTER_DECL)( NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION) | XML_FOOTER_DECL
)
:
880 case XML_ELEMENT(PRESENTATION, XML_DATE_TIME_DECL)( NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION) | XML_DATE_TIME_DECL
)
:
881 return new SdXMLHeaderFooterDeclContext( GetImport(), xAttrList );
882 case XML_ELEMENT(STYLE, XML_STYLE)( NAMESPACE_TOKEN(XML_NAMESPACE_STYLE) | XML_STYLE ):
883 break; // ignore
884 default:
885 SAL_WARN("xmloff", "unknown element " << SvXMLImport::getPrefixAndNameFromToken(nElement))do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "unknown element " <<
SvXMLImport::getPrefixAndNameFromToken(nElement)) == 1) { ::
sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "885" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "unknown element " << SvXMLImport
::getPrefixAndNameFromToken(nElement)), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "unknown element "
<< SvXMLImport::getPrefixAndNameFromToken(nElement); ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), (
"/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "885" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "unknown element " << SvXMLImport::getPrefixAndNameFromToken
(nElement)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "885" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "unknown element " << SvXMLImport
::getPrefixAndNameFromToken(nElement)), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "unknown element "
<< SvXMLImport::getPrefixAndNameFromToken(nElement); ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), (
"/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "885" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
886 }
887
888 // call base class
889 return SvXMLStylesContext::CreateStyleChildContext(nElement, xAttrList);
890}
891
892SvXMLStyleContext* SdXMLStylesContext::CreateStyleStyleChildContext(
893 XmlStyleFamily nFamily,
894 sal_Int32 nElement,
895 const uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
896{
897 switch( nFamily )
898 {
899 case XmlStyleFamily::SD_DRAWINGPAGE_ID:
900 return new SdXMLDrawingPageStyleContext(GetSdImport(), *this );
901 break;
902 case XmlStyleFamily::TABLE_CELL:
903 case XmlStyleFamily::TABLE_COLUMN:
904 case XmlStyleFamily::TABLE_ROW:
905 return new XMLShapeStyleContext( GetSdImport(), *this, nFamily );
906 break;
907 default: break;
908 }
909
910 // call base class
911 return SvXMLStylesContext::CreateStyleStyleChildContext(nFamily, nElement, xAttrList);
912}
913
914SvXMLStyleContext* SdXMLStylesContext::CreateDefaultStyleStyleChildContext(
915 XmlStyleFamily nFamily,
916 sal_Int32 nElement,
917 const Reference< XFastAttributeList > & xAttrList )
918{
919 switch( nFamily )
920 {
921 case XmlStyleFamily::SD_GRAPHICS_ID:
922 return new XMLGraphicsDefaultStyle(GetSdImport(), *this );
923 break;
924 default: break;
925 }
926
927 // call base class
928 return SvXMLStylesContext::CreateDefaultStyleStyleChildContext(nFamily, nElement, xAttrList);
929}
930
931rtl::Reference< SvXMLImportPropertyMapper > SdXMLStylesContext::GetImportPropertyMapper(
932 XmlStyleFamily nFamily) const
933{
934 rtl::Reference < SvXMLImportPropertyMapper > xMapper;
935
936 switch( nFamily )
937 {
938 case XmlStyleFamily::SD_DRAWINGPAGE_ID:
939 {
940 if(!xPresImpPropMapper.is())
941 {
942 rtl::Reference< XMLShapeImportHelper > aImpHelper = const_cast<SvXMLImport&>(GetImport()).GetShapeImport();
943 const_cast<SdXMLStylesContext*>(this)->xPresImpPropMapper =
944 aImpHelper->GetPresPagePropsMapper();
945 }
946 xMapper = xPresImpPropMapper;
947 break;
948 }
949
950 case XmlStyleFamily::TABLE_COLUMN:
951 case XmlStyleFamily::TABLE_ROW:
952 case XmlStyleFamily::TABLE_CELL:
953 {
954 const rtl::Reference< XMLTableImport >& xTableImport( const_cast< SvXMLImport& >( GetImport() ).GetShapeImport()->GetShapeTableImport() );
955
956 switch( nFamily )
957 {
958 case XmlStyleFamily::TABLE_COLUMN: xMapper = xTableImport->GetColumnImportPropertySetMapper().get(); break;
959 case XmlStyleFamily::TABLE_ROW: xMapper = xTableImport->GetRowImportPropertySetMapper().get(); break;
960 case XmlStyleFamily::TABLE_CELL: xMapper = xTableImport->GetCellImportPropertySetMapper().get(); break;
961 default: break;
962 }
963 break;
964 }
965 default: break;
966 }
967
968 // call base class
969 if( !xMapper.is() )
970 xMapper = SvXMLStylesContext::GetImportPropertyMapper(nFamily);
971 return xMapper;
972}
973
974// Process all style and object info
975
976void SdXMLStylesContext::endFastElement(sal_Int32 )
977{
978 if(mbIsAutoStyle)
979 {
980 // AutoStyles for text import
981 GetImport().GetTextImport()->SetAutoStyles( this );
982
983 // AutoStyles for chart
984 GetImport().GetChartImport()->SetAutoStylesContext( this );
985
986 // AutoStyles for forms
987 GetImport().GetFormImport()->setAutoStyleContext( this );
988
989 // associate AutoStyles with styles in preparation to setting Styles on shapes
990 for(sal_uInt32 a(0); a < GetStyleCount(); a++)
991 {
992 const SvXMLStyleContext* pStyle = GetStyle(a);
993 if (const XMLShapeStyleContext* pDocStyle = dynamic_cast<const XMLShapeStyleContext*>(pStyle))
994 {
995 SvXMLStylesContext* pStylesContext = GetSdImport().GetShapeImport()->GetStylesContext();
996 if (pStylesContext)
997 {
998 pStyle = pStylesContext->FindStyleChildContext(pStyle->GetFamily(), pStyle->GetParentName());
999
1000 if (const XMLShapeStyleContext* pParentStyle = dynamic_cast<const XMLShapeStyleContext*>(pStyle))
1001 {
1002 if(pParentStyle->GetStyle().is())
1003 {
1004 const_cast<XMLShapeStyleContext*>(pDocStyle)->SetStyle(pParentStyle->GetStyle());
1005 }
1006 }
1007 }
1008 }
1009 }
1010
1011 FinishStyles( false );
1012 }
1013 else
1014 {
1015 // Process styles list
1016 ImpSetGraphicStyles();
1017 ImpSetCellStyles();
1018 GetImport().GetShapeImport()->GetShapeTableImport()->finishStyles();
1019
1020 // put style infos in the info set for other components ( content import f.e. )
1021 uno::Reference< beans::XPropertySet > xInfoSet( GetImport().getImportInfo() );
1022 if( xInfoSet.is() )
1023 {
1024 uno::Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() );
1025
1026 if( xInfoSetInfo->hasPropertyByName("PageLayouts") )
1027 xInfoSet->setPropertyValue("PageLayouts", uno::makeAny( getPageLayouts() ) );
1028 }
1029
1030 }
1031}
1032
1033// set master-page styles (all with family="presentation" and a special
1034// prefix) on given master-page.
1035
1036void SdXMLStylesContext::SetMasterPageStyles(SdXMLMasterPageContext const & rMaster) const
1037{
1038 const uno::Reference<container::XNameAccess>& rStyleFamilies =
1039 GetSdImport().GetLocalDocStyleFamilies();
1040
1041 if (!rStyleFamilies.is())
1042 return;
1043
1044 if (!rStyleFamilies->hasByName(rMaster.GetDisplayName()))
1045 return;
1046
1047 try
1048 {
1049 uno::Reference< container::XNameAccess > xMasterPageStyles( rStyleFamilies->getByName(rMaster.GetDisplayName()), UNO_QUERY_THROW );
1050 OUString sPrefix(rMaster.GetDisplayName() + "-");
1051 ImpSetGraphicStyles(xMasterPageStyles, XmlStyleFamily::SD_PRESENTATION_ID, sPrefix);
1052 }
1053 catch (const uno::Exception&)
1054 {
1055 TOOLS_WARN_EXCEPTION("xmloff.draw", "")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff.draw")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break;
case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1055" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1055" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "" << " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1055" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1055" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1056 }
1057}
1058
1059// Process styles list:
1060// set graphic styles (all with family="graphics"). Remember xStyle at list element.
1061
1062void SdXMLStylesContext::ImpSetGraphicStyles() const
1063{
1064 if(GetSdImport().GetLocalDocStyleFamilies().is()) try
1065 {
1066 uno::Reference< container::XNameAccess > xGraphicPageStyles( GetSdImport().GetLocalDocStyleFamilies()->getByName("graphics"), uno::UNO_QUERY_THROW );
1067
1068 ImpSetGraphicStyles(xGraphicPageStyles, XmlStyleFamily::SD_GRAPHICS_ID, OUString());
1069 }
1070 catch( uno::Exception& )
1071 {
1072 TOOLS_WARN_EXCEPTION("xmloff.draw", "")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff.draw")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break;
case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1072" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1072" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "" << " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1072" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1072" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1073 }
1074}
1075
1076void SdXMLStylesContext::ImpSetCellStyles() const
1077{
1078 if(GetSdImport().GetLocalDocStyleFamilies().is()) try
1079 {
1080 uno::Reference< container::XNameAccess > xGraphicPageStyles( GetSdImport().GetLocalDocStyleFamilies()->getByName("cell"), uno::UNO_QUERY_THROW );
1081
1082 ImpSetGraphicStyles(xGraphicPageStyles, XmlStyleFamily::TABLE_CELL, OUString());
1083 }
1084 catch( uno::Exception& )
1085 {
1086 TOOLS_WARN_EXCEPTION("xmloff.draw", "")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff.draw")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break;
case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1086" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1086" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "" << " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1086" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1086" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1087 }
1088}
1089
1090//Resolves: fdo#34987 if the style's auto height before and after is the same
1091//then don't reset it back to the underlying default of true for the small
1092//period before it's going to be reset to false again. Doing this avoids the
1093//master page shapes from resizing themselves due to autoheight becoming
1094//enabled before having autoheight turned off again and getting stuck on that
1095//autosized height
1096static bool canSkipReset(const OUString &rName, const XMLPropStyleContext* pPropStyle,
1097 const uno::Reference< beans::XPropertySet > &rPropSet, const rtl::Reference < XMLPropertySetMapper >& rPrMap)
1098{
1099 bool bCanSkipReset = false;
1100 if (pPropStyle && rName == "TextAutoGrowHeight")
1101 {
1102 bool bOldStyleTextAutoGrowHeight(false);
1103 rPropSet->getPropertyValue("TextAutoGrowHeight") >>= bOldStyleTextAutoGrowHeight;
1104
1105 sal_Int32 nIndexStyle = rPrMap->GetEntryIndex(XML_NAMESPACE_DRAW, "auto-grow-height", 0);
1106 if (nIndexStyle != -1)
1107 {
1108 const ::std::vector< XMLPropertyState > &rProperties = pPropStyle->GetProperties();
1109 auto property = std::find_if(rProperties.cbegin(), rProperties.cend(),
1110 [nIndexStyle](const XMLPropertyState& rProp) { return rProp.mnIndex == nIndexStyle; });
1111 if (property != rProperties.cend())
1112 {
1113 bool bNewStyleTextAutoGrowHeight(false);
1114 property->maValue >>= bNewStyleTextAutoGrowHeight;
1115 bCanSkipReset = (bNewStyleTextAutoGrowHeight == bOldStyleTextAutoGrowHeight);
1116 }
1117 }
1118 }
1119 return bCanSkipReset;
1120}
1121
1122// help function used by ImpSetGraphicStyles() and ImpSetMasterPageStyles()
1123
1124void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAccess > const & xPageStyles, XmlStyleFamily nFamily, const OUString& rPrefix) const
1125{
1126 sal_Int32 nPrefLen(rPrefix.getLength());
1127
1128 sal_uInt32 a;
1129
1130 // set defaults
1131 for( a = 0; a < GetStyleCount(); a++)
1132 {
1133 const SvXMLStyleContext* pStyle = GetStyle(a);
1134
1135 if(nFamily == pStyle->GetFamily() && pStyle->IsDefaultStyle())
1136 {
1137 const_cast<SvXMLStyleContext*>(pStyle)->SetDefaults();
1138 }
1139 }
1140
1141 // create all styles and set properties
1142 for( a = 0; a < GetStyleCount(); a++)
1143 {
1144 try
1145 {
1146 const SvXMLStyleContext* pStyle = GetStyle(a);
1147 if(nFamily == pStyle->GetFamily() && !pStyle->IsDefaultStyle())
1148 {
1149 OUString aStyleName(pStyle->GetDisplayName());
1150
1151 if( nPrefLen )
1152 {
1153 sal_Int32 nStylePrefLen = aStyleName.lastIndexOf( '-' ) + 1;
1154 if( (nPrefLen != nStylePrefLen) || !aStyleName.startsWith(rPrefix) )
1155 continue;
1156
1157 aStyleName = aStyleName.copy( nPrefLen );
1158 }
1159
1160 XMLPropStyleContext* pPropStyle = dynamic_cast< XMLPropStyleContext* >(const_cast< SvXMLStyleContext* >( pStyle ) );
1161
1162 uno::Reference< style::XStyle > xStyle;
1163 if(xPageStyles->hasByName(aStyleName))
1164 {
1165 xPageStyles->getByName(aStyleName) >>= xStyle;
1166
1167 // set properties of existing styles to default
1168 uno::Reference< beans::XPropertySet > xPropSet( xStyle, uno::UNO_QUERY );
1169 uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
1170 if( xPropSet.is() )
1171 xPropSetInfo = xPropSet->getPropertySetInfo();
1172
1173 uno::Reference< beans::XPropertyState > xPropState( xStyle, uno::UNO_QUERY );
1174
1175 if( xPropState.is() )
1176 {
1177 rtl::Reference < XMLPropertySetMapper > xPrMap;
1178 rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap = GetImportPropertyMapper( nFamily );
1179 SAL_WARN_IF( !xImpPrMap.is(), "xmloff", "There is the import prop mapper" )do { if (true && (!xImpPrMap.is())) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "xmloff")) { case SAL_DETAIL_LOG_ACTION_IGNORE
: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail
::getResult( ::sal::detail::StreamStart() << "There is the import prop mapper"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"
), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1179" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "There is the import prop mapper"), 0
); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "There is the import prop mapper"; ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1179" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "There is the import prop mapper") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1179" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "There is the import prop mapper"), 0
); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "There is the import prop mapper"; ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1179" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1180 if( xImpPrMap.is() )
1181 xPrMap = xImpPrMap->getPropertySetMapper();
1182 if( xPrMap.is() )
1183 {
1184 const sal_Int32 nCount = xPrMap->GetEntryCount();
1185 for( sal_Int32 i = 0; i < nCount; i++ )
1186 {
1187 const OUString& rName = xPrMap->GetEntryAPIName( i );
1188 if( xPropSetInfo->hasPropertyByName( rName ) && beans::PropertyState_DIRECT_VALUE == xPropState->getPropertyState( rName ) )
1189 {
1190 bool bCanSkipReset = canSkipReset(rName, pPropStyle, xPropSet, xPrMap);
1191 if (bCanSkipReset)
1192 continue;
1193 xPropState->setPropertyToDefault( rName );
1194 }
1195 }
1196 }
1197 }
1198 }
1199 else
1200 {
1201 // graphics style does not exist, create and add it
1202 uno::Reference< lang::XSingleServiceFactory > xServiceFact(xPageStyles, uno::UNO_QUERY);
1203 if(xServiceFact.is())
1204 {
1205 uno::Reference< style::XStyle > xNewStyle( xServiceFact->createInstance(), uno::UNO_QUERY);
1206
1207 if(xNewStyle.is())
1208 {
1209 // remember style
1210 xStyle = xNewStyle;
1211
1212 // add new style to graphics style pool
1213 uno::Reference< container::XNameContainer > xInsertContainer(xPageStyles, uno::UNO_QUERY);
1214 if(xInsertContainer.is())
1215 xInsertContainer->insertByName(aStyleName, uno::Any( xStyle ) );
1216 }
1217 }
1218 }
1219
1220 if(xStyle.is())
1221 {
1222 // set properties at style
1223 uno::Reference< beans::XPropertySet > xPropSet(xStyle, uno::UNO_QUERY);
1224 if(xPropSet.is() && pPropStyle)
1225 {
1226 pPropStyle->FillPropertySet(xPropSet);
1227 pPropStyle->SetStyle(xStyle);
1228 }
1229 }
1230 }
1231 }
1232 catch(const Exception& e)
1233 {
1234 uno::Sequence<OUString> aSeq(0);
1235 const_cast<SdXMLImport*>(&GetSdImport())->SetError( XMLERROR_FLAG_WARNING0x10000000 | XMLERROR_API( 0x00040000 | 0x00000004 ), aSeq, e.Message, nullptr );
1236 }
1237 }
1238
1239 // now set parents for all styles (when necessary)
1240 for(a = 0; a < GetStyleCount(); a++)
1241 {
1242 const SvXMLStyleContext* pStyle = GetStyle(a);
1243
1244 if(pStyle && !pStyle->GetDisplayName().isEmpty() && (nFamily == pStyle->GetFamily())) try
1245 {
1246 OUString aStyleName(pStyle->GetDisplayName());
1247 if( nPrefLen )
1248 {
1249 sal_Int32 nStylePrefLen = aStyleName.lastIndexOf( '-' ) + 1;
1250 if( (nPrefLen != nStylePrefLen) || !aStyleName.startsWith( rPrefix ) )
1251 continue;
1252
1253 aStyleName = aStyleName.copy( nPrefLen );
1254 }
1255
1256 uno::Reference< style::XStyle > xStyle( xPageStyles->getByName(aStyleName), UNO_QUERY );
1257 if(xStyle.is())
1258 {
1259 // set parent style name
1260 OUString sParentStyleDisplayName( GetImport().GetStyleDisplayName( pStyle->GetFamily(), pStyle->GetParentName() ) );
1261 if( nPrefLen )
1262 {
1263 sal_Int32 nStylePrefLen = sParentStyleDisplayName.lastIndexOf( '-' ) + 1;
1264 if( (nPrefLen != nStylePrefLen) || !sParentStyleDisplayName.startsWith( rPrefix ) )
1265 continue;
1266
1267 sParentStyleDisplayName = sParentStyleDisplayName.copy( nPrefLen );
1268 }
1269 xStyle->setParentStyle( sParentStyleDisplayName );
1270 }
1271 }
1272 catch( const Exception& e )
1273 {
1274 uno::Sequence<OUString> aSeq(0);
1275 const_cast<SdXMLImport*>(&GetSdImport())->SetError( XMLERROR_FLAG_WARNING0x10000000 | XMLERROR_API( 0x00040000 | 0x00000004 ), aSeq, e.Message, nullptr );
1276 }
1277 }
1278}
1279
1280// helper function to create the uno component that hold the mappings from
1281// xml auto layout name to internal autolayout id
1282
1283uno::Reference< container::XNameAccess > SdXMLStylesContext::getPageLayouts() const
1284{
1285 uno::Reference< container::XNameContainer > xLayouts( comphelper::NameContainer_createInstance( ::cppu::UnoType<sal_Int32>::get()) );
1286
1287 for(sal_uInt32 a(0); a < GetStyleCount(); a++)
1288 {
1289 const SvXMLStyleContext* pStyle = GetStyle(a);
1290 if (const SdXMLPresentationPageLayoutContext* pContext = dynamic_cast<const SdXMLPresentationPageLayoutContext*>(pStyle))
1291 {
1292 xLayouts->insertByName(pStyle->GetName(), uno::makeAny(static_cast<sal_Int32>(pContext->GetTypeId())));
1293 }
1294 }
1295
1296 return uno::Reference< container::XNameAccess >::query( xLayouts );
1297}
1298
1299
1300SdXMLMasterStylesContext::SdXMLMasterStylesContext(
1301 SdXMLImport& rImport)
1302: SvXMLImportContext( rImport )
1303{
1304}
1305
1306css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLMasterStylesContext::createFastChildContext(
1307 sal_Int32 nElement,
1308 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1309{
1310 if( nElement == XML_ELEMENT(STYLE, XML_MASTER_PAGE)( NAMESPACE_TOKEN(XML_NAMESPACE_STYLE) | XML_MASTER_PAGE ) )
1311 {
1312 // style:masterpage inside office:styles context
1313 uno::Reference< drawing::XDrawPage > xNewMasterPage;
1314 uno::Reference< drawing::XDrawPages > xMasterPages(GetSdImport().GetLocalMasterPages(), uno::UNO_QUERY);
1315
1316 if( xMasterPages.is() )
1317 {
1318 sal_Int32 nNewMasterPageCount = GetSdImport().GetNewMasterPageCount();
1319 sal_Int32 nMasterPageCount = xMasterPages->getCount();
1320 if (nNewMasterPageCount + 1 > nMasterPageCount)
1321 {
1322 // new page, create and insert
1323 xNewMasterPage = xMasterPages->insertNewByIndex(nMasterPageCount);
1324 }
1325 else
1326 {
1327 // existing page, use it
1328 xMasterPages->getByIndex(nNewMasterPageCount) >>= xNewMasterPage;
1329 }
1330
1331 // increment global import page counter
1332 GetSdImport().IncrementNewMasterPageCount();
1333
1334 if(xNewMasterPage.is())
1335 {
1336 if(GetSdImport().GetShapeImport()->GetStylesContext())
1337 {
1338 const rtl::Reference<SdXMLMasterPageContext> xLclContext{
1339 new SdXMLMasterPageContext(GetSdImport(),
1340 nElement, xAttrList, xNewMasterPage)};
1341 maMasterPageList.push_back(xLclContext);
1342 return xLclContext.get();
1343 }
1344 }
1345 }
1346 }
1347 else if( nElement == XML_ELEMENT(STYLE, XML_HANDOUT_MASTER)( NAMESPACE_TOKEN(XML_NAMESPACE_STYLE) | XML_HANDOUT_MASTER ) )
1348 {
1349 uno::Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetSdImport().GetModel(), uno::UNO_QUERY );
1350 if( xHandoutSupp.is() )
1351 {
1352 uno::Reference< drawing::XShapes > xHandoutPage = xHandoutSupp->getHandoutMasterPage();
1353 if(xHandoutPage.is() && GetSdImport().GetShapeImport()->GetStylesContext())
1354 {
1355 return new SdXMLMasterPageContext(GetSdImport(),
1356 nElement, xAttrList, xHandoutPage);
1357 }
1358 }
1359 }
1360 return nullptr;
1361}
1362
1363SvXMLImportContextRef SdXMLMasterStylesContext::CreateChildContext(
1364 sal_uInt16 nPrefix,
1365 const OUString& rLocalName,
1366 const uno::Reference< xml::sax::XAttributeList >& xAttrList)
1367{
1368 SvXMLImportContextRef xContext;
1369
1370 if( (nPrefix == XML_NAMESPACE_DRAW) && IsXMLToken( rLocalName, XML_LAYER_SET ) )
1371 {
1372 xContext = new SdXMLLayerSetContext( GetImport(), nPrefix, rLocalName, xAttrList );
1373 }
1374
1375 return xContext;
1376}
1377
1378SdXMLHeaderFooterDeclContext::SdXMLHeaderFooterDeclContext(SvXMLImport& rImport,
1379 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1380 : SvXMLStyleContext( rImport )
1381 , mbFixed(false)
1382{
1383 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
1384 {
1385 OUString sValue = aIter.toString();
1386 if( aIter.getToken() == XML_ELEMENT(PRESENTATION, XML_NAME)( NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION) | XML_NAME ) )
1387 {
1388 maStrName = sValue;
1389 }
1390 else if( aIter.getToken() == XML_ELEMENT(PRESENTATION, XML_SOURCE)( NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION) | XML_SOURCE ) )
1391 {
1392 mbFixed = IsXMLToken( sValue, XML_FIXED );
1393 }
1394 else if( aIter.getToken() == XML_ELEMENT(STYLE, XML_DATA_STYLE_NAME)( NAMESPACE_TOKEN(XML_NAMESPACE_STYLE) | XML_DATA_STYLE_NAME ) )
1395 {
1396 maStrDateTimeFormat = sValue;
1397 }
1398 else
1399 {
1400 SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << aIter.toString())do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "unknown attribute " <<
SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) <<
"=" << aIter.toString()) == 1) { ::sal_detail_log( (::
SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1400" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
aIter.toString()), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
aIter.toString(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1400" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken
(aIter.getToken()) << "=" << aIter.toString()) ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"
), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1400" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
aIter.toString()), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "unknown attribute " << SvXMLImport
::getPrefixAndNameFromToken(aIter.getToken()) << "=" <<
aIter.toString(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1400" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1401 }
1402 }
1403}
1404
1405bool SdXMLHeaderFooterDeclContext::IsTransient() const
1406{
1407 return true;
1408}
1409
1410void SdXMLHeaderFooterDeclContext::endFastElement(sal_Int32 nToken)
1411{
1412 SdXMLImport& rImport = dynamic_cast<SdXMLImport&>(GetImport());
1413 auto nElement = nToken & TOKEN_MASK;
1414 if( nElement == XML_HEADER_DECL )
1415 {
1416 rImport.AddHeaderDecl( maStrName, maStrText );
1417 }
1418 else if( nElement == XML_FOOTER_DECL )
1419 {
1420 rImport.AddFooterDecl( maStrName, maStrText );
1421 }
1422 else if( nElement == XML_DATE_TIME_DECL )
1423 {
1424 rImport.AddDateTimeDecl( maStrName, maStrText, mbFixed, maStrDateTimeFormat );
1425 }
1426 else
1427 {
1428 SAL_WARN("xmloff", "unknown element " << SvXMLImport::getPrefixAndNameFromToken(nToken))do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "unknown element " <<
SvXMLImport::getPrefixAndNameFromToken(nToken)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1428" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "unknown element " << SvXMLImport
::getPrefixAndNameFromToken(nToken)), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "unknown element "
<< SvXMLImport::getPrefixAndNameFromToken(nToken); ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1428" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "unknown element " << SvXMLImport::getPrefixAndNameFromToken
(nToken)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1428" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "unknown element " << SvXMLImport
::getPrefixAndNameFromToken(nToken)), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "unknown element "
<< SvXMLImport::getPrefixAndNameFromToken(nToken); ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/ximpstyl.cxx"
":" "1428" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1429 }
1430}
1431
1432void SdXMLHeaderFooterDeclContext::characters( const OUString& rChars )
1433{
1434 maStrText += rChars;
1435}
1436
1437/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/rtl/ref.hxx

1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_RTL_REF_HXX
21#define INCLUDED_RTL_REF_HXX
22
23#include "sal/config.h"
24
25#include <cassert>
26#include <cstddef>
27#include <functional>
28#ifdef LIBO_INTERNAL_ONLY1
29#include <type_traits>
30#endif
31
32#include "sal/types.h"
33
34namespace rtl
35{
36
37/** Template reference class for reference type.
38*/
39template <class reference_type>
40class Reference
41{
42 /** The <b>reference_type</b> body pointer.
43 */
44 reference_type * m_pBody;
45
46
47public:
48 /** Constructor...
49 */
50 Reference()
51 : m_pBody (NULL__null)
52 {}
53
54
55 /** Constructor...
56 */
57 Reference (reference_type * pBody, __sal_NoAcquire)
58 : m_pBody (pBody)
59 {
60 }
61
62 /** Constructor...
63 */
64 Reference (reference_type * pBody)
65 : m_pBody (pBody)
66 {
67 if (m_pBody)
68 m_pBody->acquire();
69 }
70
71 /** Copy constructor...
72 */
73 Reference (const Reference<reference_type> & handle)
74 : m_pBody (handle.m_pBody)
75 {
76 if (m_pBody)
77 m_pBody->acquire();
78 }
79
80#ifdef LIBO_INTERNAL_ONLY1
81 /** Move constructor...
82 */
83 Reference (Reference<reference_type> && handle) noexcept
84 : m_pBody (handle.m_pBody)
85 {
86 handle.m_pBody = nullptr;
87 }
88#endif
89
90#if defined LIBO_INTERNAL_ONLY1
91 /** Up-casting conversion constructor: Copies interface reference.
92
93 Does not work for up-casts to ambiguous bases.
94
95 @param rRef another reference
96 */
97 template< class derived_type >
98 inline Reference(
99 const Reference< derived_type > & rRef,
100 std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 )
101 : m_pBody (rRef.get())
102 {
103 if (m_pBody)
104 m_pBody->acquire();
105 }
106#endif
107
108 /** Destructor...
109 */
110 ~Reference() COVERITY_NOEXCEPT_FALSE
111 {
112 if (m_pBody
4.1
Field 'm_pBody' is non-null
4.1
Field 'm_pBody' is non-null
4.1
Field 'm_pBody' is non-null
)
5
Taking true branch
113 m_pBody->release();
6
Calling 'SvXMLImportContext::release'
10
Returning; memory was released
114 }
115
116 /** Set...
117 Similar to assignment.
118 */
119 Reference<reference_type> &
120 SAL_CALL set (reference_type * pBody)
121 {
122 if (pBody)
123 pBody->acquire();
124 reference_type * const pOld = m_pBody;
125 m_pBody = pBody;
126 if (pOld)
127 pOld->release();
128 return *this;
129 }
130
131 /** Assignment.
132 Unbinds this instance from its body (if bound) and
133 bind it to the body represented by the handle.
134 */
135 Reference<reference_type> &
136 SAL_CALL operator= (const Reference<reference_type> & handle)
137 {
138 return set( handle.m_pBody );
139 }
140
141#ifdef LIBO_INTERNAL_ONLY1
142 /** Assignment.
143 * Unbinds this instance from its body (if bound),
144 * bind it to the body represented by the handle, and
145 * set the body represented by the handle to nullptr.
146 */
147 Reference<reference_type> &
148 operator= (Reference<reference_type> && handle)
149 {
150 // self-movement guts ourself
151 if (m_pBody)
152 m_pBody->release();
153 m_pBody = handle.m_pBody;
154 handle.m_pBody = nullptr;
155 return *this;
156 }
157#endif
158
159 /** Assignment...
160 */
161 Reference<reference_type> &
162 SAL_CALL operator= (reference_type * pBody)
163 {
164 return set( pBody );
165 }
166
167 /** Unbind the body from this handle.
168 Note that for a handle representing a large body,
169 "handle.clear().set(new body());" _might_
170 perform a little bit better than "handle.set(new body());",
171 since in the second case two large objects exist in memory
172 (the old body and the new body).
173 */
174 Reference<reference_type> & SAL_CALL clear()
175 {
176 if (m_pBody)
177 {
178 reference_type * const pOld = m_pBody;
179 m_pBody = NULL__null;
180 pOld->release();
181 }
182 return *this;
183 }
184
185
186 /** Get the body. Can be used instead of operator->().
187 I.e. handle->someBodyOp() and handle.get()->someBodyOp()
188 are the same.
189 */
190 reference_type * SAL_CALL get() const
191 {
192 return m_pBody;
13
Use of memory after it is freed
193 }
194
195
196 /** Probably most common used: handle->someBodyOp().
197 */
198 reference_type * SAL_CALL operator->() const
199 {
200 assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail
("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx"
, 200, __extension__ __PRETTY_FUNCTION__))
;
201 return m_pBody;
202 }
203
204
205 /** Allows (*handle).someBodyOp().
206 */
207 reference_type & SAL_CALL operator*() const
208 {
209 assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail
("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx"
, 209, __extension__ __PRETTY_FUNCTION__))
;
210 return *m_pBody;
211 }
212
213
214 /** Returns True if the handle does point to a valid body.
215 */
216 bool SAL_CALL is() const
217 {
218 return (m_pBody != NULL__null);
219 }
220
221#if defined LIBO_INTERNAL_ONLY1
222 /** Returns True if the handle does point to a valid body.
223 */
224 explicit operator bool() const
225 {
226 return is();
227 }
228#endif
229
230 /** Returns True if this points to pBody.
231 */
232 bool SAL_CALL operator== (const reference_type * pBody) const
233 {
234 return (m_pBody == pBody);
235 }
236
237
238 /** Returns True if handle points to the same body.
239 */
240 bool
241 SAL_CALL operator== (const Reference<reference_type> & handle) const
242 {
243 return (m_pBody == handle.m_pBody);
244 }
245
246
247 /** Needed to place References into STL collection.
248 */
249 bool
250 SAL_CALL operator!= (const Reference<reference_type> & handle) const
251 {
252 return (m_pBody != handle.m_pBody);
253 }
254
255
256 /** Needed to place References into STL collection.
257 */
258 bool
259 SAL_CALL operator< (const Reference<reference_type> & handle) const
260 {
261 return (m_pBody < handle.m_pBody);
262 }
263
264
265 /** Needed to place References into STL collection.
266 */
267 bool
268 SAL_CALL operator> (const Reference<reference_type> & handle) const
269 {
270 return (m_pBody > handle.m_pBody);
271 }
272};
273
274} // namespace rtl
275
276#if defined LIBO_INTERNAL_ONLY1
277namespace std
278{
279
280/// @cond INTERNAL
281/**
282 Make rtl::Reference hashable by default for use in STL containers.
283
284 @since LibreOffice 6.3
285*/
286template<typename T>
287struct hash<::rtl::Reference<T>>
288{
289 std::size_t operator()(::rtl::Reference<T> const & s) const
290 { return std::size_t(s.get()); }
291};
292/// @endcond
293
294}
295
296#endif
297
298#endif /* ! INCLUDED_RTL_REF_HXX */
299
300/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/xmloff/xmlictxt.hxx

1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_XMLOFF_XMLICTXT_HXX
21#define INCLUDED_XMLOFF_XMLICTXT_HXX
22
23#include <sal/config.h>
24#include <xmloff/dllapi.h>
25#include <sal/types.h>
26#include <com/sun/star/xml/sax/XFastContextHandler.hpp>
27#include <com/sun/star/lang/XTypeProvider.hpp>
28#include <rtl/ustring.hxx>
29#include <xmloff/namespacemap.hxx>
30#include <memory>
31
32namespace com::sun::star::xml::sax { class XAttributeList; }
33
34class SvXMLImport;
35
36class SvXMLImportContext;
37
38typedef rtl::Reference<SvXMLImportContext> SvXMLImportContextRef;
39
40/**
41This class deliberately does not support XWeak, to improve performance when loading
42large documents.
43*/
44class XMLOFF_DLLPUBLIC__attribute__ ((visibility("default"))) SvXMLImportContext : public css::xml::sax::XFastContextHandler,
45 public css::lang::XTypeProvider
46
47{
48 friend class SvXMLImport;
49
50 SvXMLImport& mrImport;
51 OUString maLocalName;
52 std::unique_ptr<SvXMLNamespaceMap> m_pRewindMap;
53 oslInterlockedCount m_nRefCount;
54 sal_uInt16 mnPrefix;
55 bool mbPrefixAndLocalNameFilledIn;
56
57 SAL_DLLPRIVATE__attribute__ ((visibility("hidden"))) std::unique_ptr<SvXMLNamespaceMap> TakeRewindMap() { return std::move(m_pRewindMap); }
58 SAL_DLLPRIVATE__attribute__ ((visibility("hidden"))) void PutRewindMap(std::unique_ptr<SvXMLNamespaceMap> p) { m_pRewindMap = std::move(p); }
59
60protected:
61
62 SvXMLImport& GetImport() { return mrImport; }
63 const SvXMLImport& GetImport() const { return mrImport; }
64
65public:
66
67 bool IsPrefixFilledIn() const { return mnPrefix != 0; }
68 sal_uInt16 GetPrefix() const { assert(mbPrefixAndLocalNameFilledIn && "those fields not filled, probably fast-parser context")(static_cast <bool> (mbPrefixAndLocalNameFilledIn &&
"those fields not filled, probably fast-parser context") ? void
(0) : __assert_fail ("mbPrefixAndLocalNameFilledIn && \"those fields not filled, probably fast-parser context\""
, "/home/maarten/src/libreoffice/core/include/xmloff/xmlictxt.hxx"
, 68, __extension__ __PRETTY_FUNCTION__))
; return mnPrefix; }
69 const OUString& GetLocalName() const { assert(mbPrefixAndLocalNameFilledIn && "those fields not filled, probably fast-parser context")(static_cast <bool> (mbPrefixAndLocalNameFilledIn &&
"those fields not filled, probably fast-parser context") ? void
(0) : __assert_fail ("mbPrefixAndLocalNameFilledIn && \"those fields not filled, probably fast-parser context\""
, "/home/maarten/src/libreoffice/core/include/xmloff/xmlictxt.hxx"
, 69, __extension__ __PRETTY_FUNCTION__))
; return maLocalName; }
70
71 /** A contexts constructor does anything that is required if an element
72 * starts. Namespace processing has been done already.
73 * Note that virtual methods cannot be used inside constructors. Use
74 * StartElement instead if this is required. */
75 SvXMLImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
76 const OUString& rLName );
77
78 SvXMLImportContext( SvXMLImport& rImport );
79
80 /** A contexts destructor does anything that is required if an element
81 * ends. By default, nothing is done.
82 * Note that virtual methods cannot be used inside destructors. Use
83 * EndElement instead if this is required. */
84 virtual ~SvXMLImportContext();
85
86 /** Create a children element context. By default, the import's
87 * CreateContext method is called to create a new default context. */
88 virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
89 const OUString& rLocalName,
90 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList );
91
92 /** StartElement is called after a context has been constructed and
93 * before an elements context is parsed. It may be used for actions that
94 * require virtual methods. The default is to do nothing. */
95 virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList );
96
97 /** EndElement is called before a context will be destructed, but
98 * after an elements context has been parsed. It may be used for actions
99 * that require virtual methods. The default is to do nothing. */
100 virtual void EndElement();
101
102 /** This method is called for all characters that are contained in the
103 * current element. The default is to ignore them. */
104 virtual void Characters( const OUString& rChars );
105
106 // css::xml::sax::XFastContextHandler:
107 virtual void SAL_CALL startFastElement (sal_Int32 Element,
108 const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs) override;
109
110 virtual void SAL_CALL startUnknownElement(const OUString & Namespace, const OUString & Name,
111 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
112
113 virtual void SAL_CALL endFastElement(sal_Int32 Element) override;
114
115 virtual void SAL_CALL endUnknownElement(const OUString & Namespace, const OUString & Name) override;
116
117 virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element,
118 const css::uno::Reference<css::xml::sax::XFastAttributeList>& Attribs) override;
119
120 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext(
121 const OUString & Namespace, const OUString & Name,
122 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
123
124 virtual void SAL_CALL characters(const OUString & aChars) override;
125
126 // XInterface
127 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) final override;
128 virtual void SAL_CALL acquire() throw () final override
129 { osl_atomic_increment(&m_nRefCount)__sync_add_and_fetch((&m_nRefCount), 1); }
130 virtual void SAL_CALL release() throw () final override
131 { if (osl_atomic_decrement(&m_nRefCount)__sync_sub_and_fetch((&m_nRefCount), 1) == 0) delete this; }
7
Assuming the condition is true
8
Taking true branch
9
Memory is released
132
133 // XTypeProvider
134 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) final override;
135 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) final override;
136};
137
138#endif // INCLUDED_XMLOFF_XMLICTXT_HXX
139
140/* vim:set shiftwidth=4 softtabstop=4 expandtab: */