1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "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>
54 using namespace ::com::sun::star
;
55 using namespace ::com::sun::star::uno
;
56 using namespace ::com::sun::star::xml::sax
;
57 using namespace ::xmloff::token
;
61 class SdXMLDrawingPagePropertySetContext
: public SvXMLPropertySetContext
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
);
70 using SvXMLPropertySetContext::createFastChildContext
;
71 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> createFastChildContext(
73 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
,
74 ::std::vector
< XMLPropertyState
> &rProperties
,
75 const XMLPropertyState
& rProp
) override
;
80 SdXMLDrawingPagePropertySetContext::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
, rProps
, rMap
)
90 css::uno::Reference
< css::xml::sax::XFastContextHandler
> SdXMLDrawingPagePropertySetContext::createFastChildContext(
92 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
,
93 ::std::vector
< XMLPropertyState
> &rProperties
,
94 const XMLPropertyState
& rProp
)
96 switch( mxMapper
->getPropertySetMapper()->GetEntryContextId( rProp
.mnIndex
) )
98 case CTF_PAGE_SOUND_URL
:
100 for (auto &aIter
: sax_fastparser::castToFastAttributeList(xAttrList
))
102 if( aIter
.getToken() == XML_ELEMENT(XLINK
, XML_HREF
) )
104 uno::Any
aAny( GetImport().GetAbsoluteReference( aIter
.toString() ) );
105 XMLPropertyState
aPropState( rProp
.mnIndex
, aAny
);
106 rProperties
.push_back( aPropState
);
109 XMLOFF_WARN_UNKNOWN("xmloff", aIter
);
115 return SvXMLPropertySetContext::createFastChildContext( nElement
,
117 rProperties
, rProp
);
123 class SdXMLDrawingPageStyleContext
: public XMLDrawingPageStyleContext
127 SdXMLDrawingPageStyleContext(
128 SvXMLImport
& rImport
,
129 SvXMLStylesContext
& rStyles
);
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
;
134 virtual void Finish( bool bOverwrite
) override
;
137 const sal_uInt16 MAX_SPECIAL_DRAW_STYLES
= 7;
138 ContextID_Index_Pair
const g_ContextIDs
[MAX_SPECIAL_DRAW_STYLES
+1] =
140 { CTF_DASHNAME
, -1 },
141 { CTF_LINESTARTNAME
, -1 },
142 { CTF_LINEENDNAME
, -1 },
143 { CTF_FILLGRADIENTNAME
, -1 },
144 { CTF_FILLTRANSNAME
, -1 },
145 { CTF_FILLHATCHNAME
, -1 },
146 { CTF_FILLBITMAPNAME
, -1 },
149 XmlStyleFamily
const g_Families
[MAX_SPECIAL_DRAW_STYLES
] =
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
162 XMLDrawingPageStyleContext::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
)
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
));
176 SdXMLDrawingPageStyleContext::SdXMLDrawingPageStyleContext(
177 SvXMLImport
& rImport
,
178 SvXMLStylesContext
& rStyles
)
179 : XMLDrawingPageStyleContext(rImport
, rStyles
, g_ContextIDs
, g_Families
)
183 css::uno::Reference
< css::xml::sax::XFastContextHandler
> SdXMLDrawingPageStyleContext::createFastChildContext(
185 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
187 if( nElement
== XML_ELEMENT(STYLE
, XML_DRAWING_PAGE_PROPERTIES
) )
189 rtl::Reference
< SvXMLImportPropertyMapper
> xImpPrMap
=
190 GetStyles()->GetImportPropertyMapper( GetFamily() );
192 return new SdXMLDrawingPagePropertySetContext( GetImport(), nElement
,
198 return XMLPropStyleContext::createFastChildContext( nElement
, xAttrList
);
201 void SdXMLDrawingPageStyleContext::Finish( bool bOverwrite
)
203 XMLPropStyleContext::Finish( bOverwrite
);
205 ::std::vector
< XMLPropertyState
> &rProperties
= GetProperties();
207 const rtl::Reference
< XMLPropertySetMapper
>& rImpPrMap
= GetStyles()->GetImportPropertyMapper( GetFamily() )->getPropertySetMapper();
209 for(auto& property
: rProperties
)
211 if( property
.mnIndex
== -1 )
214 sal_Int16 nContextID
= rImpPrMap
->GetEntryContextId(property
.mnIndex
);
217 case CTF_DATE_TIME_FORMAT
:
220 property
.maValue
>>= sStyleName
;
222 sal_Int32 nStyle
= 0;
224 const SdXMLNumberFormatImportContext
* pSdNumStyle
=
225 dynamic_cast< const SdXMLNumberFormatImportContext
*> (
226 GetStyles()->FindStyleChildContext( XmlStyleFamily::DATA_STYLE
, sStyleName
, true ) );
229 nStyle
= pSdNumStyle
->GetDrawKey();
231 property
.maValue
<<= nStyle
;
241 void XMLDrawingPageStyleContext::FillPropertySet(
242 const Reference
< beans::XPropertySet
> & rPropSet
)
244 rtl::Reference
< SvXMLImportPropertyMapper
> xImpPrMap
=
245 GetStyles()->GetImportPropertyMapper( GetFamily() );
246 SAL_WARN_IF( !xImpPrMap
.is(), "xmloff", "There is the import prop mapper" );
248 xImpPrMap
->FillPropertySet(GetProperties(), rPropSet
, m_pContextIDs
.get());
250 Reference
< beans::XPropertySetInfo
> xInfo
;
251 for (size_t i
=0; m_pContextIDs
[i
].nContextID
!= -1; ++i
)
253 sal_Int32 nIndex
= m_pContextIDs
[i
].nIndex
;
256 struct XMLPropertyState
& rState
= GetProperties()[nIndex
];
258 rState
.maValue
>>= sStyleName
;
259 sStyleName
= GetImport().GetStyleDisplayName( m_pFamilies
[i
],
261 // get property set mapper
262 rtl::Reference
<XMLPropertySetMapper
> rPropMapper
=
263 xImpPrMap
->getPropertySetMapper();
266 const OUString
& rPropertyName
=
267 rPropMapper
->GetEntryAPIName(rState
.mnIndex
);
269 xInfo
= rPropSet
->getPropertySetInfo();
270 if ( xInfo
->hasPropertyByName( rPropertyName
) )
272 rPropSet
->setPropertyValue( rPropertyName
, Any( sStyleName
) );
279 SdXMLPageMasterStyleContext::SdXMLPageMasterStyleContext(
280 SdXMLImport
& rImport
,
281 sal_Int32
/*nElement*/,
282 const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
283 : SvXMLStyleContext(rImport
, XmlStyleFamily::SD_PAGEMASTERSTYLECONTEXT_ID
),
290 meOrientation(GetSdImport().IsDraw() ? view::PaperOrientation_PORTRAIT
: view::PaperOrientation_LANDSCAPE
)
292 // set family to something special at SvXMLStyleContext
293 // for differences in search-methods
295 for (auto &aIter
: sax_fastparser::castToFastAttributeList( xAttrList
))
297 OUString sValue
= aIter
.toString();
298 switch(aIter
.getToken())
300 case XML_ELEMENT(FO
, XML_MARGIN_TOP
):
301 case XML_ELEMENT(FO_COMPAT
, XML_MARGIN_TOP
):
303 GetSdImport().GetMM100UnitConverter().convertMeasureToCore(
304 mnBorderTop
, sValue
);
307 case XML_ELEMENT(FO
, XML_MARGIN_BOTTOM
):
308 case XML_ELEMENT(FO_COMPAT
, XML_MARGIN_BOTTOM
):
310 GetSdImport().GetMM100UnitConverter().convertMeasureToCore(
311 mnBorderBottom
, sValue
);
314 case XML_ELEMENT(FO
, XML_MARGIN_LEFT
):
315 case XML_ELEMENT(FO_COMPAT
, XML_MARGIN_LEFT
):
317 GetSdImport().GetMM100UnitConverter().convertMeasureToCore(
318 mnBorderLeft
, sValue
);
321 case XML_ELEMENT(FO
, XML_MARGIN_RIGHT
):
322 case XML_ELEMENT(FO_COMPAT
, XML_MARGIN_RIGHT
):
324 GetSdImport().GetMM100UnitConverter().convertMeasureToCore(
325 mnBorderRight
, sValue
);
328 case XML_ELEMENT(FO
, XML_PAGE_WIDTH
):
329 case XML_ELEMENT(FO_COMPAT
, XML_PAGE_WIDTH
):
331 GetSdImport().GetMM100UnitConverter().convertMeasureToCore(
335 case XML_ELEMENT(FO
, XML_PAGE_HEIGHT
):
336 case XML_ELEMENT(FO_COMPAT
, XML_PAGE_HEIGHT
):
338 GetSdImport().GetMM100UnitConverter().convertMeasureToCore(
342 case XML_ELEMENT(STYLE
, XML_PRINT_ORIENTATION
):
344 if( IsXMLToken( sValue
, XML_PORTRAIT
) )
345 meOrientation
= view::PaperOrientation_PORTRAIT
;
347 meOrientation
= view::PaperOrientation_LANDSCAPE
;
351 XMLOFF_WARN_UNKNOWN("xmloff", aIter
);
356 SdXMLPageMasterStyleContext::~SdXMLPageMasterStyleContext()
361 SdXMLPageMasterContext::SdXMLPageMasterContext(
362 SdXMLImport
& rImport
,
363 sal_Int32
/*nElement*/,
364 const uno::Reference
< xml::sax::XFastAttributeList
>& /*xAttrList*/)
365 : SvXMLStyleContext(rImport
, XmlStyleFamily::SD_PAGEMASTERCONTEXT_ID
)
367 // set family to something special at SvXMLStyleContext
368 // for differences in search-methods
372 css::uno::Reference
< css::xml::sax::XFastContextHandler
> SdXMLPageMasterContext::createFastChildContext(
374 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
376 if(nElement
== XML_ELEMENT(STYLE
, XML_PAGE_LAYOUT_PROPERTIES
))
378 DBG_ASSERT(!mxPageMasterStyle
.is(), "PageMasterStyle is set, there seem to be two of them (!)");
379 mxPageMasterStyle
.set(new SdXMLPageMasterStyleContext(GetSdImport(), nElement
, xAttrList
));
380 return mxPageMasterStyle
.get();
383 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement
);
388 SdXMLPresentationPageLayoutContext::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
)
395 // set family to something special at SvXMLStyleContext
396 // for differences in search-methods
399 css::uno::Reference
< css::xml::sax::XFastContextHandler
> SdXMLPresentationPageLayoutContext::createFastChildContext(
401 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
403 SvXMLImportContextRef xContext
;
405 if(nElement
== XML_ELEMENT(PRESENTATION
, XML_PLACEHOLDER
))
407 const rtl::Reference
< SdXMLPresentationPlaceholderContext
> xLclContext
{
408 new SdXMLPresentationPlaceholderContext(GetSdImport(), nElement
, xAttrList
)};
409 // presentation:placeholder inside style:presentation-page-layout context
410 xContext
= xLclContext
.get();
412 // remember SdXMLPresentationPlaceholderContext for later evaluation
413 maList
.push_back(xLclContext
);
416 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement
);
418 return xContext
.get();
421 void SdXMLPresentationPageLayoutContext::endFastElement(sal_Int32
)
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
429 SdXMLPresentationPlaceholderContext
* pObj0
= maList
[ 0 ].get();
430 if( pObj0
->GetName() == "handout" )
432 switch( maList
.size() )
435 mnTypeId
= AUTOLAYOUT_HANDOUT1
;
438 mnTypeId
= AUTOLAYOUT_HANDOUT2
;
441 mnTypeId
= AUTOLAYOUT_HANDOUT3
;
444 mnTypeId
= AUTOLAYOUT_HANDOUT4
;
447 mnTypeId
= AUTOLAYOUT_HANDOUT9
;
450 mnTypeId
= AUTOLAYOUT_HANDOUT6
;
455 switch( maList
.size() )
459 if( pObj0
->GetName() == "title" )
461 mnTypeId
= AUTOLAYOUT_TITLE_ONLY
;
465 mnTypeId
= AUTOLAYOUT_ONLY_TEXT
;
471 SdXMLPresentationPlaceholderContext
* pObj1
= maList
[ 1 ].get();
473 if( pObj1
->GetName() == "subtitle" )
475 mnTypeId
= AUTOLAYOUT_TITLE
;
477 else if( pObj1
->GetName() == "outline" )
479 mnTypeId
= AUTOLAYOUT_TITLE_CONTENT
;
481 else if( pObj1
->GetName() == "chart" )
483 mnTypeId
= AUTOLAYOUT_CHART
;
485 else if( pObj1
->GetName() == "table" )
487 mnTypeId
= AUTOLAYOUT_TAB
;
489 else if( pObj1
->GetName() == "object" )
491 mnTypeId
= AUTOLAYOUT_OBJ
;
493 else if( pObj1
->GetName() == "vertical_outline" )
495 if( pObj0
->GetName() == "vertical_title" )
497 mnTypeId
= AUTOLAYOUT_VTITLE_VCONTENT
;
501 mnTypeId
= AUTOLAYOUT_TITLE_VCONTENT
;
506 mnTypeId
= AUTOLAYOUT_NOTES
;
512 SdXMLPresentationPlaceholderContext
* pObj1
= maList
[ 1 ].get();
513 SdXMLPresentationPlaceholderContext
* pObj2
= maList
[ 2 ].get();
515 if( pObj1
->GetName() == "outline" )
517 if( pObj2
->GetName() == "outline" )
519 mnTypeId
= AUTOLAYOUT_TITLE_2CONTENT
;
521 else if( pObj2
->GetName() == "chart" )
523 mnTypeId
= AUTOLAYOUT_TEXTCHART
;
525 else if( pObj2
->GetName() == "graphic" )
527 mnTypeId
= AUTOLAYOUT_TEXTCLIP
;
531 if(pObj1
->GetX() < pObj2
->GetX())
533 mnTypeId
= AUTOLAYOUT_TEXTOBJ
; // outline left, object right
537 mnTypeId
= AUTOLAYOUT_TEXTOVEROBJ
; // outline top, object right
541 else if( pObj1
->GetName() == "chart" )
543 mnTypeId
= AUTOLAYOUT_CHARTTEXT
;
545 else if( pObj1
->GetName() == "graphic" )
547 if( pObj2
->GetName() == "vertical_outline" )
549 mnTypeId
= AUTOLAYOUT_TITLE_2VTEXT
;
553 mnTypeId
= AUTOLAYOUT_CLIPTEXT
;
556 else if( pObj1
->GetName() == "vertical_outline" )
558 mnTypeId
= AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT
;
562 if(pObj1
->GetX() < pObj2
->GetX())
564 mnTypeId
= AUTOLAYOUT_OBJTEXT
; // left, right
568 mnTypeId
= AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT
; // top, bottom
575 SdXMLPresentationPlaceholderContext
* pObj1
= maList
[ 1 ].get();
576 SdXMLPresentationPlaceholderContext
* pObj2
= maList
[ 2 ].get();
578 if( pObj1
->GetName() == "object" )
580 if(pObj1
->GetX() < pObj2
->GetX())
582 mnTypeId
= AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT
;
586 mnTypeId
= AUTOLAYOUT_TITLE_2CONTENT_CONTENT
;
591 mnTypeId
= AUTOLAYOUT_TITLE_CONTENT_2CONTENT
;
597 SdXMLPresentationPlaceholderContext
* pObj1
= maList
[ 1 ].get();
599 if( pObj1
->GetName() == "object" )
601 mnTypeId
= AUTOLAYOUT_TITLE_4CONTENT
;
605 mnTypeId
= AUTOLAYOUT_4CLIPART
;
612 mnTypeId
= AUTOLAYOUT_4CLIPART
; // FIXME: not AUTOLAYOUT_TITLE_6CONTENT?
617 mnTypeId
= AUTOLAYOUT_NONE
;
623 // release remembered contexts, they are no longer needed
627 SdXMLPresentationPlaceholderContext::SdXMLPresentationPlaceholderContext(
628 SdXMLImport
& rImport
,
629 sal_Int32
/*nElement*/,
630 const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
631 : SvXMLImportContext( rImport
),
634 for (auto &aIter
: sax_fastparser::castToFastAttributeList( xAttrList
))
636 OUString sValue
= aIter
.toString();
637 switch(aIter
.getToken())
639 case XML_ELEMENT(PRESENTATION
, XML_OBJECT
):
644 case XML_ELEMENT(SVG
, XML_X
):
645 case XML_ELEMENT(SVG_COMPAT
, XML_X
):
647 GetSdImport().GetMM100UnitConverter().convertMeasureToCore(
651 case XML_ELEMENT(SVG
, XML_Y
):
652 case XML_ELEMENT(SVG_COMPAT
, XML_Y
):
656 case XML_ELEMENT(SVG
, XML_WIDTH
):
657 case XML_ELEMENT(SVG_COMPAT
, XML_WIDTH
):
661 case XML_ELEMENT(SVG
, XML_HEIGHT
):
662 case XML_ELEMENT(SVG_COMPAT
, XML_HEIGHT
):
667 XMLOFF_WARN_UNKNOWN("xmloff", aIter
);
672 SdXMLPresentationPlaceholderContext::~SdXMLPresentationPlaceholderContext()
677 SdXMLMasterPageContext::SdXMLMasterPageContext(
678 SdXMLImport
& rImport
,
680 const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
,
681 uno::Reference
< drawing::XShapes
> const & rShapes
)
682 : SdXMLGenericPageContext( rImport
, xAttrList
, rShapes
)
684 const bool bHandoutMaster
= (nElement
& TOKEN_MASK
) == XML_HANDOUT_MASTER
;
685 OUString sStyleName
, sPageMasterName
;
687 for (auto &aIter
: sax_fastparser::castToFastAttributeList( xAttrList
))
689 const OUString sValue
= aIter
.toString();
690 switch(aIter
.getToken())
692 case XML_ELEMENT(STYLE
, XML_NAME
):
697 case XML_ELEMENT(STYLE
, XML_DISPLAY_NAME
):
699 msDisplayName
= sValue
;
702 case XML_ELEMENT(STYLE
, XML_PAGE_LAYOUT_NAME
):
704 sPageMasterName
= sValue
;
707 case XML_ELEMENT(DRAW
, XML_STYLE_NAME
):
712 case XML_ELEMENT(PRESENTATION
, XML_PRESENTATION_PAGE_LAYOUT_NAME
):
714 maPageLayoutName
= sValue
;
717 case XML_ELEMENT(PRESENTATION
, XML_USE_HEADER_NAME
):
719 maUseHeaderDeclName
= sValue
;
722 case XML_ELEMENT(PRESENTATION
, XML_USE_FOOTER_NAME
):
724 maUseFooterDeclName
= sValue
;
727 case XML_ELEMENT(PRESENTATION
, XML_USE_DATE_TIME_NAME
):
729 maUseDateTimeDeclName
= sValue
;
733 XMLOFF_WARN_UNKNOWN("xmloff", aIter
);
737 if( msDisplayName
.isEmpty() )
738 msDisplayName
= msName
;
739 else if( msDisplayName
!= msName
)
740 GetImport().AddStyleDisplayName( XmlStyleFamily::MASTER_PAGE
, msName
, msDisplayName
);
742 GetImport().GetShapeImport()->startPage( GetLocalShapesContext() );
745 if(!bHandoutMaster
&& !msDisplayName
.isEmpty() && GetLocalShapesContext().is())
747 uno::Reference
< container::XNamed
> xNamed(GetLocalShapesContext(), uno::UNO_QUERY
);
749 xNamed
->setName(msDisplayName
);
753 if(!sPageMasterName
.isEmpty())
755 SetPageMaster( sPageMasterName
);
758 SetStyle( sStyleName
);
765 SdXMLMasterPageContext::~SdXMLMasterPageContext()
769 void SdXMLMasterPageContext::endFastElement(sal_Int32 nElement
)
771 // set styles on master-page
772 if(!msName
.isEmpty() && GetSdImport().GetShapeImport()->GetStylesContext())
774 SvXMLImportContext
* pContext
= GetSdImport().GetShapeImport()->GetStylesContext();
775 if (SdXMLStylesContext
* pSdContext
= dynamic_cast<SdXMLStylesContext
*>(pContext
))
776 pSdContext
->SetMasterPageStyles(*this);
779 SdXMLGenericPageContext::endFastElement(nElement
);
780 GetImport().GetShapeImport()->endPage(GetLocalShapesContext());
783 css::uno::Reference
< css::xml::sax::XFastContextHandler
> SdXMLMasterPageContext::createFastChildContext(
785 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
789 // some special objects inside style:masterpage context
790 case XML_ELEMENT(STYLE
, XML_STYLE
):
792 if(GetSdImport().GetShapeImport()->GetStylesContext())
794 // style:style inside master-page context -> presentation style
795 XMLShapeStyleContext
* pNew
= new XMLShapeStyleContext(
797 *GetSdImport().GetShapeImport()->GetStylesContext(),
798 XmlStyleFamily::SD_PRESENTATION_ID
);
800 // add this style to the outer StylesContext class for later processing
801 GetSdImport().GetShapeImport()->GetStylesContext()->AddStyle(*pNew
);
806 case XML_ELEMENT(PRESENTATION
, XML_NOTES
):
808 if( GetSdImport().IsImpress() )
811 uno::Reference
< presentation::XPresentationPage
> xPresPage(GetLocalShapesContext(), uno::UNO_QUERY
);
814 uno::Reference
< drawing::XDrawPage
> xNotesDrawPage
= xPresPage
->getNotesPage();
815 if(xNotesDrawPage
.is())
817 // presentation:notes inside master-page context
818 return new SdXMLNotesContext( GetSdImport(), xAttrList
, xNotesDrawPage
);
824 return SdXMLGenericPageContext::createFastChildContext(nElement
, xAttrList
);
827 SdXMLStylesContext::SdXMLStylesContext(
828 SdXMLImport
& rImport
,
830 : SvXMLStylesContext(rImport
),
831 mbIsAutoStyle(bIsAutoStyle
)
833 Reference
< uno::XComponentContext
> xContext
= rImport
.GetComponentContext();
834 mpNumFormatter
= std::make_unique
<SvNumberFormatter
>( xContext
, LANGUAGE_SYSTEM
);
835 mpNumFmtHelper
= std::make_unique
<SvXMLNumFmtHelper
>( mpNumFormatter
.get(), xContext
);
838 SvXMLStyleContext
* SdXMLStylesContext::CreateStyleChildContext(
840 const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
844 case XML_ELEMENT(TABLE
, XML_TABLE_TEMPLATE
):
846 auto pContext
= GetImport().GetShapeImport()->GetShapeTableImport()->CreateTableTemplateContext(nElement
, xAttrList
);
851 case XML_ELEMENT(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
):
855 // style:presentation-page-layout inside office:styles context
856 return new SdXMLPresentationPageLayoutContext(GetSdImport(), nElement
, xAttrList
);
857 case XML_ELEMENT(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
):
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
):
864 return new SvXMLNumFormatContext( GetSdImport(), nElement
,
865 mpNumFmtHelper
->getData(), SvXMLStylesTokens::NUMBER_STYLE
, xAttrList
, *this );
866 case XML_ELEMENT(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
):
870 return new SvXMLNumFormatContext( GetSdImport(), nElement
,
871 mpNumFmtHelper
->getData(), SvXMLStylesTokens::PERCENTAGE_STYLE
, xAttrList
, *this );
872 case XML_ELEMENT(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
):
876 return new SvXMLNumFormatContext( GetSdImport(), nElement
,
877 mpNumFmtHelper
->getData(), SvXMLStylesTokens::TEXT_STYLE
, xAttrList
, *this );
878 case XML_ELEMENT(PRESENTATION
, XML_HEADER_DECL
):
879 case XML_ELEMENT(PRESENTATION
, XML_FOOTER_DECL
):
880 case XML_ELEMENT(PRESENTATION
, XML_DATE_TIME_DECL
):
881 return new SdXMLHeaderFooterDeclContext( GetImport(), xAttrList
);
882 case XML_ELEMENT(STYLE
, XML_STYLE
):
885 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement
);
889 return SvXMLStylesContext::CreateStyleChildContext(nElement
, xAttrList
);
892 SvXMLStyleContext
* SdXMLStylesContext::CreateStyleStyleChildContext(
893 XmlStyleFamily nFamily
,
895 const uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
899 case XmlStyleFamily::SD_DRAWINGPAGE_ID
:
900 return new SdXMLDrawingPageStyleContext(GetSdImport(), *this );
902 case XmlStyleFamily::TABLE_CELL
:
903 case XmlStyleFamily::TABLE_COLUMN
:
904 case XmlStyleFamily::TABLE_ROW
:
905 return new XMLShapeStyleContext( GetSdImport(), *this, nFamily
);
911 return SvXMLStylesContext::CreateStyleStyleChildContext(nFamily
, nElement
, xAttrList
);
914 SvXMLStyleContext
* SdXMLStylesContext::CreateDefaultStyleStyleChildContext(
915 XmlStyleFamily nFamily
,
917 const Reference
< XFastAttributeList
> & xAttrList
)
921 case XmlStyleFamily::SD_GRAPHICS_ID
:
922 return new XMLGraphicsDefaultStyle(GetSdImport(), *this );
928 return SvXMLStylesContext::CreateDefaultStyleStyleChildContext(nFamily
, nElement
, xAttrList
);
931 rtl::Reference
< SvXMLImportPropertyMapper
> SdXMLStylesContext::GetImportPropertyMapper(
932 XmlStyleFamily nFamily
) const
934 rtl::Reference
< SvXMLImportPropertyMapper
> xMapper
;
938 case XmlStyleFamily::SD_DRAWINGPAGE_ID
:
940 if(!xPresImpPropMapper
.is())
942 rtl::Reference
< XMLShapeImportHelper
> aImpHelper
= const_cast<SvXMLImport
&>(GetImport()).GetShapeImport();
943 const_cast<SdXMLStylesContext
*>(this)->xPresImpPropMapper
=
944 aImpHelper
->GetPresPagePropsMapper();
946 xMapper
= xPresImpPropMapper
;
950 case XmlStyleFamily::TABLE_COLUMN
:
951 case XmlStyleFamily::TABLE_ROW
:
952 case XmlStyleFamily::TABLE_CELL
:
954 const rtl::Reference
< XMLTableImport
>& xTableImport( const_cast< SvXMLImport
& >( GetImport() ).GetShapeImport()->GetShapeTableImport() );
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;
970 xMapper
= SvXMLStylesContext::GetImportPropertyMapper(nFamily
);
974 // Process all style and object info
976 void SdXMLStylesContext::endFastElement(sal_Int32
)
980 // AutoStyles for text import
981 GetImport().GetTextImport()->SetAutoStyles( this );
983 // AutoStyles for chart
984 GetImport().GetChartImport()->SetAutoStylesContext( this );
986 // AutoStyles for forms
987 GetImport().GetFormImport()->setAutoStyleContext( this );
989 // associate AutoStyles with styles in preparation to setting Styles on shapes
990 for(sal_uInt32
a(0); a
< GetStyleCount(); a
++)
992 const SvXMLStyleContext
* pStyle
= GetStyle(a
);
993 if (const XMLShapeStyleContext
* pDocStyle
= dynamic_cast<const XMLShapeStyleContext
*>(pStyle
))
995 SvXMLStylesContext
* pStylesContext
= GetSdImport().GetShapeImport()->GetStylesContext();
998 pStyle
= pStylesContext
->FindStyleChildContext(pStyle
->GetFamily(), pStyle
->GetParentName());
1000 if (const XMLShapeStyleContext
* pParentStyle
= dynamic_cast<const XMLShapeStyleContext
*>(pStyle
))
1002 if(pParentStyle
->GetStyle().is())
1004 const_cast<XMLShapeStyleContext
*>(pDocStyle
)->SetStyle(pParentStyle
->GetStyle());
1011 FinishStyles( false );
1015 // Process styles list
1016 ImpSetGraphicStyles();
1018 GetImport().GetShapeImport()->GetShapeTableImport()->finishStyles();
1020 // put style infos in the info set for other components ( content import f.e. )
1021 uno::Reference
< beans::XPropertySet
> xInfoSet( GetImport().getImportInfo() );
1024 uno::Reference
< beans::XPropertySetInfo
> xInfoSetInfo( xInfoSet
->getPropertySetInfo() );
1026 if( xInfoSetInfo
->hasPropertyByName("PageLayouts") )
1027 xInfoSet
->setPropertyValue("PageLayouts", uno::makeAny( getPageLayouts() ) );
1033 // set master-page styles (all with family="presentation" and a special
1034 // prefix) on given master-page.
1036 void SdXMLStylesContext::SetMasterPageStyles(SdXMLMasterPageContext
const & rMaster
) const
1038 const uno::Reference
<container::XNameAccess
>& rStyleFamilies
=
1039 GetSdImport().GetLocalDocStyleFamilies();
1041 if (!rStyleFamilies
.is())
1044 if (!rStyleFamilies
->hasByName(rMaster
.GetDisplayName()))
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
);
1053 catch (const uno::Exception
&)
1055 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1059 // Process styles list:
1060 // set graphic styles (all with family="graphics"). Remember xStyle at list element.
1062 void SdXMLStylesContext::ImpSetGraphicStyles() const
1064 if(GetSdImport().GetLocalDocStyleFamilies().is()) try
1066 uno::Reference
< container::XNameAccess
> xGraphicPageStyles( GetSdImport().GetLocalDocStyleFamilies()->getByName("graphics"), uno::UNO_QUERY_THROW
);
1068 ImpSetGraphicStyles(xGraphicPageStyles
, XmlStyleFamily::SD_GRAPHICS_ID
, OUString());
1070 catch( uno::Exception
& )
1072 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1076 void SdXMLStylesContext::ImpSetCellStyles() const
1078 if(GetSdImport().GetLocalDocStyleFamilies().is()) try
1080 uno::Reference
< container::XNameAccess
> xGraphicPageStyles( GetSdImport().GetLocalDocStyleFamilies()->getByName("cell"), uno::UNO_QUERY_THROW
);
1082 ImpSetGraphicStyles(xGraphicPageStyles
, XmlStyleFamily::TABLE_CELL
, OUString());
1084 catch( uno::Exception
& )
1086 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
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
1096 static bool canSkipReset(const OUString
&rName
, const XMLPropStyleContext
* pPropStyle
,
1097 const uno::Reference
< beans::XPropertySet
> &rPropSet
, const rtl::Reference
< XMLPropertySetMapper
>& rPrMap
)
1099 bool bCanSkipReset
= false;
1100 if (pPropStyle
&& rName
== "TextAutoGrowHeight")
1102 bool bOldStyleTextAutoGrowHeight(false);
1103 rPropSet
->getPropertyValue("TextAutoGrowHeight") >>= bOldStyleTextAutoGrowHeight
;
1105 sal_Int32 nIndexStyle
= rPrMap
->GetEntryIndex(XML_NAMESPACE_DRAW
, "auto-grow-height", 0);
1106 if (nIndexStyle
!= -1)
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())
1113 bool bNewStyleTextAutoGrowHeight(false);
1114 property
->maValue
>>= bNewStyleTextAutoGrowHeight
;
1115 bCanSkipReset
= (bNewStyleTextAutoGrowHeight
== bOldStyleTextAutoGrowHeight
);
1119 return bCanSkipReset
;
1122 // help function used by ImpSetGraphicStyles() and ImpSetMasterPageStyles()
1124 void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference
< container::XNameAccess
> const & xPageStyles
, XmlStyleFamily nFamily
, const OUString
& rPrefix
) const
1126 sal_Int32
nPrefLen(rPrefix
.getLength());
1131 for( a
= 0; a
< GetStyleCount(); a
++)
1133 const SvXMLStyleContext
* pStyle
= GetStyle(a
);
1135 if(nFamily
== pStyle
->GetFamily() && pStyle
->IsDefaultStyle())
1137 const_cast<SvXMLStyleContext
*>(pStyle
)->SetDefaults();
1141 // create all styles and set properties
1142 for( a
= 0; a
< GetStyleCount(); a
++)
1146 const SvXMLStyleContext
* pStyle
= GetStyle(a
);
1147 if(nFamily
== pStyle
->GetFamily() && !pStyle
->IsDefaultStyle())
1149 OUString
aStyleName(pStyle
->GetDisplayName());
1153 sal_Int32 nStylePrefLen
= aStyleName
.lastIndexOf( '-' ) + 1;
1154 if( (nPrefLen
!= nStylePrefLen
) || !aStyleName
.startsWith(rPrefix
) )
1157 aStyleName
= aStyleName
.copy( nPrefLen
);
1160 XMLPropStyleContext
* pPropStyle
= dynamic_cast< XMLPropStyleContext
* >(const_cast< SvXMLStyleContext
* >( pStyle
) );
1162 uno::Reference
< style::XStyle
> xStyle
;
1163 if(xPageStyles
->hasByName(aStyleName
))
1165 xPageStyles
->getByName(aStyleName
) >>= xStyle
;
1167 // set properties of existing styles to default
1168 uno::Reference
< beans::XPropertySet
> xPropSet( xStyle
, uno::UNO_QUERY
);
1169 uno::Reference
< beans::XPropertySetInfo
> xPropSetInfo
;
1171 xPropSetInfo
= xPropSet
->getPropertySetInfo();
1173 uno::Reference
< beans::XPropertyState
> xPropState( xStyle
, uno::UNO_QUERY
);
1175 if( xPropState
.is() )
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" );
1180 if( xImpPrMap
.is() )
1181 xPrMap
= xImpPrMap
->getPropertySetMapper();
1184 const sal_Int32 nCount
= xPrMap
->GetEntryCount();
1185 for( sal_Int32 i
= 0; i
< nCount
; i
++ )
1187 const OUString
& rName
= xPrMap
->GetEntryAPIName( i
);
1188 if( xPropSetInfo
->hasPropertyByName( rName
) && beans::PropertyState_DIRECT_VALUE
== xPropState
->getPropertyState( rName
) )
1190 bool bCanSkipReset
= canSkipReset(rName
, pPropStyle
, xPropSet
, xPrMap
);
1193 xPropState
->setPropertyToDefault( rName
);
1201 // graphics style does not exist, create and add it
1202 uno::Reference
< lang::XSingleServiceFactory
> xServiceFact(xPageStyles
, uno::UNO_QUERY
);
1203 if(xServiceFact
.is())
1205 uno::Reference
< style::XStyle
> xNewStyle( xServiceFact
->createInstance(), uno::UNO_QUERY
);
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
) );
1222 // set properties at style
1223 uno::Reference
< beans::XPropertySet
> xPropSet(xStyle
, uno::UNO_QUERY
);
1224 if(xPropSet
.is() && pPropStyle
)
1226 pPropStyle
->FillPropertySet(xPropSet
);
1227 pPropStyle
->SetStyle(xStyle
);
1232 catch(const Exception
& e
)
1234 uno::Sequence
<OUString
> aSeq(0);
1235 const_cast<SdXMLImport
*>(&GetSdImport())->SetError( XMLERROR_FLAG_WARNING
| XMLERROR_API
, aSeq
, e
.Message
, nullptr );
1239 // now set parents for all styles (when necessary)
1240 for(a
= 0; a
< GetStyleCount(); a
++)
1242 const SvXMLStyleContext
* pStyle
= GetStyle(a
);
1244 if(pStyle
&& !pStyle
->GetDisplayName().isEmpty() && (nFamily
== pStyle
->GetFamily())) try
1246 OUString
aStyleName(pStyle
->GetDisplayName());
1249 sal_Int32 nStylePrefLen
= aStyleName
.lastIndexOf( '-' ) + 1;
1250 if( (nPrefLen
!= nStylePrefLen
) || !aStyleName
.startsWith( rPrefix
) )
1253 aStyleName
= aStyleName
.copy( nPrefLen
);
1256 uno::Reference
< style::XStyle
> xStyle( xPageStyles
->getByName(aStyleName
), UNO_QUERY
);
1259 // set parent style name
1260 OUString
sParentStyleDisplayName( GetImport().GetStyleDisplayName( pStyle
->GetFamily(), pStyle
->GetParentName() ) );
1263 sal_Int32 nStylePrefLen
= sParentStyleDisplayName
.lastIndexOf( '-' ) + 1;
1264 if( (nPrefLen
!= nStylePrefLen
) || !sParentStyleDisplayName
.startsWith( rPrefix
) )
1267 sParentStyleDisplayName
= sParentStyleDisplayName
.copy( nPrefLen
);
1269 xStyle
->setParentStyle( sParentStyleDisplayName
);
1272 catch( const Exception
& e
)
1274 uno::Sequence
<OUString
> aSeq(0);
1275 const_cast<SdXMLImport
*>(&GetSdImport())->SetError( XMLERROR_FLAG_WARNING
| XMLERROR_API
, aSeq
, e
.Message
, nullptr );
1280 // helper function to create the uno component that hold the mappings from
1281 // xml auto layout name to internal autolayout id
1283 uno::Reference
< container::XNameAccess
> SdXMLStylesContext::getPageLayouts() const
1285 uno::Reference
< container::XNameContainer
> xLayouts( comphelper::NameContainer_createInstance( ::cppu::UnoType
<sal_Int32
>::get()) );
1287 for(sal_uInt32
a(0); a
< GetStyleCount(); a
++)
1289 const SvXMLStyleContext
* pStyle
= GetStyle(a
);
1290 if (const SdXMLPresentationPageLayoutContext
* pContext
= dynamic_cast<const SdXMLPresentationPageLayoutContext
*>(pStyle
))
1292 xLayouts
->insertByName(pStyle
->GetName(), uno::makeAny(static_cast<sal_Int32
>(pContext
->GetTypeId())));
1296 return uno::Reference
< container::XNameAccess
>::query( xLayouts
);
1300 SdXMLMasterStylesContext::SdXMLMasterStylesContext(
1301 SdXMLImport
& rImport
)
1302 : SvXMLImportContext( rImport
)
1306 css::uno::Reference
< css::xml::sax::XFastContextHandler
> SdXMLMasterStylesContext::createFastChildContext(
1308 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
1310 if( nElement
== XML_ELEMENT(STYLE
, XML_MASTER_PAGE
) )
1312 // style:masterpage inside office:styles context
1313 uno::Reference
< drawing::XDrawPage
> xNewMasterPage
;
1314 uno::Reference
< drawing::XDrawPages
> xMasterPages(GetSdImport().GetLocalMasterPages(), uno::UNO_QUERY
);
1316 if( xMasterPages
.is() )
1318 sal_Int32 nNewMasterPageCount
= GetSdImport().GetNewMasterPageCount();
1319 sal_Int32 nMasterPageCount
= xMasterPages
->getCount();
1320 if (nNewMasterPageCount
+ 1 > nMasterPageCount
)
1322 // new page, create and insert
1323 xNewMasterPage
= xMasterPages
->insertNewByIndex(nMasterPageCount
);
1327 // existing page, use it
1328 xMasterPages
->getByIndex(nNewMasterPageCount
) >>= xNewMasterPage
;
1331 // increment global import page counter
1332 GetSdImport().IncrementNewMasterPageCount();
1334 if(xNewMasterPage
.is())
1336 if(GetSdImport().GetShapeImport()->GetStylesContext())
1338 const rtl::Reference
<SdXMLMasterPageContext
> xLclContext
{
1339 new SdXMLMasterPageContext(GetSdImport(),
1340 nElement
, xAttrList
, xNewMasterPage
)};
1341 maMasterPageList
.push_back(xLclContext
);
1342 return xLclContext
.get();
1347 else if( nElement
== XML_ELEMENT(STYLE
, XML_HANDOUT_MASTER
) )
1349 uno::Reference
< presentation::XHandoutMasterSupplier
> xHandoutSupp( GetSdImport().GetModel(), uno::UNO_QUERY
);
1350 if( xHandoutSupp
.is() )
1352 uno::Reference
< drawing::XShapes
> xHandoutPage
= xHandoutSupp
->getHandoutMasterPage();
1353 if(xHandoutPage
.is() && GetSdImport().GetShapeImport()->GetStylesContext())
1355 return new SdXMLMasterPageContext(GetSdImport(),
1356 nElement
, xAttrList
, xHandoutPage
);
1363 SvXMLImportContextRef
SdXMLMasterStylesContext::CreateChildContext(
1365 const OUString
& rLocalName
,
1366 const uno::Reference
< xml::sax::XAttributeList
>& /*xAttrList*/)
1368 SvXMLImportContextRef xContext
;
1370 if( (nPrefix
== XML_NAMESPACE_DRAW
) && IsXMLToken( rLocalName
, XML_LAYER_SET
) )
1372 xContext
= new SdXMLLayerSetContext( GetImport() );
1378 SdXMLHeaderFooterDeclContext::SdXMLHeaderFooterDeclContext(SvXMLImport
& rImport
,
1379 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
1380 : SvXMLStyleContext( rImport
)
1383 for (auto &aIter
: sax_fastparser::castToFastAttributeList( xAttrList
))
1385 OUString sValue
= aIter
.toString();
1386 if( aIter
.getToken() == XML_ELEMENT(PRESENTATION
, XML_NAME
) )
1390 else if( aIter
.getToken() == XML_ELEMENT(PRESENTATION
, XML_SOURCE
) )
1392 mbFixed
= IsXMLToken( sValue
, XML_FIXED
);
1394 else if( aIter
.getToken() == XML_ELEMENT(STYLE
, XML_DATA_STYLE_NAME
) )
1396 maStrDateTimeFormat
= sValue
;
1400 XMLOFF_WARN_UNKNOWN("xmloff", aIter
);
1405 bool SdXMLHeaderFooterDeclContext::IsTransient() const
1410 void SdXMLHeaderFooterDeclContext::endFastElement(sal_Int32 nToken
)
1412 SdXMLImport
& rImport
= dynamic_cast<SdXMLImport
&>(GetImport());
1413 auto nElement
= nToken
& TOKEN_MASK
;
1414 if( nElement
== XML_HEADER_DECL
)
1416 rImport
.AddHeaderDecl( maStrName
, maStrText
);
1418 else if( nElement
== XML_FOOTER_DECL
)
1420 rImport
.AddFooterDecl( maStrName
, maStrText
);
1422 else if( nElement
== XML_DATE_TIME_DECL
)
1424 rImport
.AddDateTimeDecl( maStrName
, maStrText
, mbFixed
, maStrDateTimeFormat
);
1428 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nToken
);
1432 void SdXMLHeaderFooterDeclContext::characters( const OUString
& rChars
)
1434 maStrText
+= rChars
;
1437 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */