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 <config_wasm_strip.h>
22 #include <sal/config.h>
24 #include <com/sun/star/frame/XModel.hpp>
25 #include <com/sun/star/xml/sax/XAttributeList.hpp>
26 #include <com/sun/star/container/XNameContainer.hpp>
27 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
28 #include <com/sun/star/style/XAutoStylesSupplier.hpp>
29 #include <com/sun/star/style/XAutoStyleFamily.hpp>
30 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
31 #include <PageMasterPropMapper.hxx>
32 #include <sal/log.hxx>
33 #include <svl/style.hxx>
35 #include <xmloff/namespacemap.hxx>
36 #include <xmloff/xmlnamespace.hxx>
37 #include <xmloff/xmltoken.hxx>
39 #include <xmloff/families.hxx>
40 #include <xmloff/xmlimp.hxx>
41 #include <xmloff/xmlnumi.hxx>
42 #include <xmloff/xmlimppr.hxx>
43 #include <xmloff/xmlstyle.hxx>
44 #include <xmloff/txtstyli.hxx>
45 #include <xmloff/xmlnumfi.hxx>
46 #include <XMLChartStyleContext.hxx>
47 #include <XMLChartPropertySetMapper.hxx>
48 #include <XMLThemeContext.hxx>
49 #include <xmloff/XMLShapeStyleContext.hxx>
50 #include "FillStyleContext.hxx"
51 #include <XMLFootnoteConfigurationImportContext.hxx>
52 #include <XMLIndexBibliographyConfigurationContext.hxx>
53 #include <XMLLineNumberingImportContext.hxx>
54 #include <PageMasterImportContext.hxx>
55 #include "PageMasterImportPropMapper.hxx"
59 #include <string_view>
62 using namespace ::com::sun::star
;
63 using namespace ::com::sun::star::uno
;
64 using namespace ::com::sun::star::container
;
65 using namespace ::com::sun::star::style
;
66 using namespace ::xmloff::token
;
68 constexpr OUStringLiteral
gsParaStyleServiceName( u
"com.sun.star.style.ParagraphStyle" );
69 constexpr OUStringLiteral
gsTextStyleServiceName( u
"com.sun.star.style.CharacterStyle" );
70 constexpr OUStringLiteral
gsParagraphStyles(u
"ParagraphStyles");
71 constexpr OUStringLiteral
gsCharacterStyles(u
"CharacterStyles");
73 void SvXMLStyleContext::SetAttribute( sal_Int32 nElement
,
74 const OUString
& rValue
)
78 case XML_ELEMENT(STYLE
, XML_FAMILY
):
80 if( IsXMLToken( rValue
, XML_PARAGRAPH
) )
81 mnFamily
= XmlStyleFamily(SfxStyleFamily::Para
);
82 else if( IsXMLToken( rValue
, XML_TEXT
) )
83 mnFamily
= XmlStyleFamily(SfxStyleFamily::Char
);
86 case XML_ELEMENT(STYLE
, XML_NAME
):
89 case XML_ELEMENT(STYLE
, XML_DISPLAY_NAME
):
90 maDisplayName
= rValue
;
92 case XML_ELEMENT(STYLE
, XML_PARENT_STYLE_NAME
):
93 maParentName
= rValue
;
95 case XML_ELEMENT(STYLE
, XML_NEXT_STYLE_NAME
):
98 case XML_ELEMENT(LO_EXT
, XML_LINKED_STYLE_NAME
):
101 case XML_ELEMENT(STYLE
, XML_HIDDEN
):
102 mbHidden
= rValue
.toBoolean();
104 case XML_ELEMENT(LO_EXT
, XML_HIDDEN
):
105 mbHidden
= rValue
.toBoolean();
111 SvXMLStyleContext::SvXMLStyleContext(
113 XmlStyleFamily nFam
, bool bDefault
) :
114 SvXMLImportContext( rImp
),
119 mbDefaultStyle( bDefault
)
123 SvXMLStyleContext::~SvXMLStyleContext()
127 void SvXMLStyleContext::startFastElement(
128 sal_Int32
/*nElement*/,
129 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
131 for( auto &it
: sax_fastparser::castToFastAttributeList( xAttrList
) )
132 SetAttribute( it
.getToken(), it
.toString() );
135 void SvXMLStyleContext::SetDefaults()
139 void SvXMLStyleContext::CreateAndInsert( bool /*bOverwrite*/ )
143 void SvXMLStyleContext::CreateAndInsertLate( bool /*bOverwrite*/ )
147 void SvXMLStyleContext::Finish( bool /*bOverwrite*/ )
151 bool SvXMLStyleContext::IsTransient() const
158 class SvXMLStyleIndex_Impl
161 XmlStyleFamily nFamily
;
162 // we deliberately don't use a reference here, to avoid creating a ref-count-cycle
163 SvXMLStyleContext
* mpStyle
;
167 SvXMLStyleIndex_Impl( XmlStyleFamily nFam
, OUString aName
) :
168 sName(std::move( aName
)),
174 SvXMLStyleIndex_Impl( const rtl::Reference
<SvXMLStyleContext
> &rStl
) :
175 sName( rStl
->GetName() ),
176 nFamily( rStl
->GetFamily() ),
177 mpStyle ( rStl
.get() )
181 const OUString
& GetName() const { return sName
; }
182 XmlStyleFamily
GetFamily() const { return nFamily
; }
183 const SvXMLStyleContext
*GetStyle() const { return mpStyle
; }
186 struct SvXMLStyleIndexCmp_Impl
188 bool operator()(const SvXMLStyleIndex_Impl
& r1
, const SvXMLStyleIndex_Impl
& r2
) const
192 if( r1
.GetFamily() < r2
.GetFamily() )
194 else if( r1
.GetFamily() > r2
.GetFamily() )
197 nRet
= r1
.GetName().compareTo( r2
.GetName() );
205 class SvXMLStylesContext_Impl
207 typedef std::set
<SvXMLStyleIndex_Impl
, SvXMLStyleIndexCmp_Impl
> IndicesType
;
209 std::vector
<rtl::Reference
<SvXMLStyleContext
>> aStyles
;
210 mutable std::unique_ptr
<IndicesType
> pIndices
;
211 bool bAutomaticStyle
;
213 #if OSL_DEBUG_LEVEL > 0
214 mutable sal_uInt32 m_nIndexCreated
;
217 void FlushIndex() { pIndices
.reset(); }
220 explicit SvXMLStylesContext_Impl( bool bAuto
);
222 size_t GetStyleCount() const { return aStyles
.size(); }
224 SvXMLStyleContext
*GetStyle( size_t i
)
226 return i
< aStyles
.size() ? aStyles
[ i
].get() : nullptr;
229 inline void AddStyle( SvXMLStyleContext
*pStyle
);
232 const SvXMLStyleContext
*FindStyleChildContext( XmlStyleFamily nFamily
,
233 const OUString
& rName
,
234 bool bCreateIndex
) const;
235 bool IsAutomaticStyle() const { return bAutomaticStyle
; }
238 SvXMLStylesContext_Impl::SvXMLStylesContext_Impl( bool bAuto
) :
239 bAutomaticStyle( bAuto
)
240 #if OSL_DEBUG_LEVEL > 0
241 , m_nIndexCreated( 0 )
245 inline void SvXMLStylesContext_Impl::AddStyle( SvXMLStyleContext
*pStyle
)
247 #if OSL_DEBUG_LEVEL > 0
248 // for (auto const & xStyle : aStyles)
249 // if (xStyle->GetFamily() == pStyle->GetFamily() && xStyle->GetName() == pStyle->GetName())
250 // assert(false && "duplicate style");
252 aStyles
.emplace_back(pStyle
);
257 void SvXMLStylesContext_Impl::dispose()
263 const SvXMLStyleContext
*SvXMLStylesContext_Impl::FindStyleChildContext( XmlStyleFamily nFamily
,
264 const OUString
& rName
,
265 bool bCreateIndex
) const
267 const SvXMLStyleContext
*pStyle
= nullptr;
269 if( !pIndices
&& bCreateIndex
&& !aStyles
.empty() )
271 pIndices
= std::make_unique
<IndicesType
>(aStyles
.begin(), aStyles
.end());
272 SAL_WARN_IF(pIndices
->size() != aStyles
.size(), "xmloff.style", "Here is a duplicate Style");
273 #if OSL_DEBUG_LEVEL > 0
274 SAL_WARN_IF(0 != m_nIndexCreated
, "xmloff.style",
275 "Performance warning: sdbcx::Index created multiple times");
282 SvXMLStyleIndex_Impl
aIndex( nFamily
, rName
);
283 IndicesType::iterator aFind
= pIndices
->find(aIndex
);
284 if( aFind
!= pIndices
->end() )
285 pStyle
= aFind
->GetStyle();
289 for( size_t i
= 0; !pStyle
&& i
< aStyles
.size(); i
++ )
291 const SvXMLStyleContext
*pS
= aStyles
[ i
].get();
292 if( pS
->GetFamily() == nFamily
&&
293 pS
->GetName() == rName
)
301 sal_uInt32
SvXMLStylesContext::GetStyleCount() const
303 return mpImpl
->GetStyleCount();
306 SvXMLStyleContext
*SvXMLStylesContext::GetStyle( sal_uInt32 i
)
308 return mpImpl
->GetStyle( i
);
311 const SvXMLStyleContext
*SvXMLStylesContext::GetStyle( sal_uInt32 i
) const
313 return mpImpl
->GetStyle( i
);
316 bool SvXMLStylesContext::IsAutomaticStyle() const
318 return mpImpl
->IsAutomaticStyle();
321 SvXMLStyleContext
*SvXMLStylesContext::CreateStyleChildContext(
323 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
325 SvXMLStyleContext
*pStyle
= nullptr;
327 if(GetImport().GetDataStylesImport())
329 pStyle
= GetImport().GetDataStylesImport()->CreateChildContext(GetImport(), nElement
,
337 case XML_ELEMENT(STYLE
, XML_STYLE
):
338 case XML_ELEMENT(STYLE
, XML_DEFAULT_STYLE
):
340 XmlStyleFamily nFamily
= XmlStyleFamily::DATA_STYLE
;
341 for( auto &aIter
: sax_fastparser::castToFastAttributeList( xAttrList
) )
343 if( aIter
.getToken() == XML_ELEMENT(STYLE
, XML_FAMILY
) )
345 nFamily
= GetFamily( aIter
.toString() );
349 pStyle
= XML_ELEMENT(STYLE
, XML_STYLE
)==nElement
350 ? CreateStyleStyleChildContext( nFamily
, nElement
, xAttrList
)
351 : CreateDefaultStyleStyleChildContext( nFamily
, nElement
, xAttrList
);
354 case XML_ELEMENT(TEXT
, XML_BIBLIOGRAPHY_CONFIGURATION
):
355 pStyle
= new XMLIndexBibliographyConfigurationContext(GetImport());
357 case XML_ELEMENT(TEXT
, XML_NOTES_CONFIGURATION
):
358 pStyle
= new XMLFootnoteConfigurationImportContext(
359 GetImport(), nElement
, xAttrList
);
361 case XML_ELEMENT(TEXT
, XML_LINENUMBERING_CONFIGURATION
):
362 pStyle
= new XMLLineNumberingImportContext(GetImport());
364 case XML_ELEMENT(STYLE
, XML_PAGE_LAYOUT
):
365 case XML_ELEMENT(STYLE
, XML_DEFAULT_PAGE_LAYOUT
):
367 //there is not page family in ODF now, so I specify one for it
368 bool bDefaultStyle
= XML_ELEMENT(STYLE
, XML_DEFAULT_PAGE_LAYOUT
) == nElement
;
369 pStyle
= new PageStyleContext( GetImport(), *this, bDefaultStyle
);
372 case XML_ELEMENT(TEXT
, XML_LIST_STYLE
):
373 pStyle
= new SvxXMLListStyleContext( GetImport() );
375 case XML_ELEMENT(TEXT
, XML_OUTLINE_STYLE
):
376 pStyle
= new SvxXMLListStyleContext( GetImport(), true );
381 case XML_ELEMENT(DRAW
, XML_GRADIENT
):
383 pStyle
= new XMLGradientStyleContext( GetImport(), nElement
, xAttrList
);
386 case XML_ELEMENT(DRAW
, XML_HATCH
):
388 pStyle
= new XMLHatchStyleContext( GetImport(), nElement
, xAttrList
);
391 case XML_ELEMENT(DRAW
, XML_FILL_IMAGE
):
393 pStyle
= new XMLBitmapStyleContext( GetImport(), nElement
, xAttrList
);
396 case XML_ELEMENT(DRAW
, XML_OPACITY
):
398 pStyle
= new XMLTransGradientStyleContext( GetImport(), nElement
, xAttrList
);
401 case XML_ELEMENT(DRAW
, XML_MARKER
):
403 pStyle
= new XMLMarkerStyleContext( GetImport(), nElement
, xAttrList
);
406 case XML_ELEMENT(DRAW
, XML_STROKE_DASH
):
408 pStyle
= new XMLDashStyleContext( GetImport(), nElement
, xAttrList
);
414 SAL_WARN("xmloff", "Unknown element " << SvXMLImport::getPrefixAndNameFromToken(nElement
));
419 SvXMLStyleContext
*SvXMLStylesContext::CreateStyleStyleChildContext(
420 XmlStyleFamily nFamily
, sal_Int32
/*nElement*/,
421 const uno::Reference
< xml::sax::XFastAttributeList
> & /*xAttrList*/ )
423 SvXMLStyleContext
*pStyle
= nullptr;
427 case XmlStyleFamily::TEXT_PARAGRAPH
:
428 case XmlStyleFamily::TEXT_TEXT
:
429 case XmlStyleFamily::TEXT_SECTION
:
430 pStyle
= new XMLTextStyleContext( GetImport(), *this, nFamily
);
433 case XmlStyleFamily::TEXT_RUBY
:
434 pStyle
= new XMLPropStyleContext( GetImport(), *this, nFamily
);
436 #if !ENABLE_WASM_STRIP_CHART
438 case XmlStyleFamily::SCH_CHART_ID
:
439 pStyle
= new XMLChartStyleContext( GetImport(), *this, nFamily
);
442 case XmlStyleFamily::SD_GRAPHICS_ID
:
443 case XmlStyleFamily::SD_PRESENTATION_ID
:
444 case XmlStyleFamily::SD_POOL_ID
:
445 pStyle
= new XMLShapeStyleContext( GetImport(), *this, nFamily
);
453 SvXMLStyleContext
*SvXMLStylesContext::CreateDefaultStyleStyleChildContext(
454 XmlStyleFamily
/*nFamily*/, sal_Int32
/*nElement*/,
455 const uno::Reference
< xml::sax::XFastAttributeList
> & )
460 bool SvXMLStylesContext::InsertStyleFamily( XmlStyleFamily
) const
465 XmlStyleFamily
SvXMLStylesContext::GetFamily( std::u16string_view rValue
)
467 XmlStyleFamily nFamily
= XmlStyleFamily::DATA_STYLE
;
468 if( IsXMLToken( rValue
, XML_PARAGRAPH
) )
470 nFamily
= XmlStyleFamily::TEXT_PARAGRAPH
;
472 else if( IsXMLToken( rValue
, XML_TEXT
) )
474 nFamily
= XmlStyleFamily::TEXT_TEXT
;
476 else if( IsXMLToken( rValue
, XML_DATA_STYLE
) )
478 nFamily
= XmlStyleFamily::DATA_STYLE
;
480 else if ( IsXMLToken( rValue
, XML_SECTION
) )
482 nFamily
= XmlStyleFamily::TEXT_SECTION
;
484 else if( IsXMLToken( rValue
, XML_TABLE
) )
486 nFamily
= XmlStyleFamily::TABLE_TABLE
;
488 else if( IsXMLToken( rValue
, XML_TABLE_COLUMN
) )
489 nFamily
= XmlStyleFamily::TABLE_COLUMN
;
490 else if( IsXMLToken( rValue
, XML_TABLE_ROW
) )
491 nFamily
= XmlStyleFamily::TABLE_ROW
;
492 else if( IsXMLToken( rValue
, XML_TABLE_CELL
) )
493 nFamily
= XmlStyleFamily::TABLE_CELL
;
494 else if ( rValue
== XML_STYLE_FAMILY_SD_GRAPHICS_NAME
)
496 nFamily
= XmlStyleFamily::SD_GRAPHICS_ID
;
498 else if ( rValue
== XML_STYLE_FAMILY_SD_PRESENTATION_NAME
)
500 nFamily
= XmlStyleFamily::SD_PRESENTATION_ID
;
502 else if ( rValue
== XML_STYLE_FAMILY_SD_POOL_NAME
)
504 nFamily
= XmlStyleFamily::SD_POOL_ID
;
506 else if ( rValue
== XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME
)
508 nFamily
= XmlStyleFamily::SD_DRAWINGPAGE_ID
;
510 else if ( rValue
== XML_STYLE_FAMILY_SCH_CHART_NAME
)
512 nFamily
= XmlStyleFamily::SCH_CHART_ID
;
514 else if ( IsXMLToken( rValue
, XML_RUBY
) )
516 nFamily
= XmlStyleFamily::TEXT_RUBY
;
522 rtl::Reference
< SvXMLImportPropertyMapper
> SvXMLStylesContext::GetImportPropertyMapper(
523 XmlStyleFamily nFamily
) const
525 rtl::Reference
< SvXMLImportPropertyMapper
> xMapper
;
529 case XmlStyleFamily::TEXT_PARAGRAPH
:
530 if( !mxParaImpPropMapper
.is() )
532 SvXMLStylesContext
* pThis
= const_cast<SvXMLStylesContext
*>(this);
533 pThis
->mxParaImpPropMapper
=
534 pThis
->GetImport().GetTextImport()
535 ->GetParaImportPropertySetMapper();
537 xMapper
= mxParaImpPropMapper
;
539 case XmlStyleFamily::TEXT_TEXT
:
540 if( !mxTextImpPropMapper
.is() )
542 SvXMLStylesContext
* pThis
= const_cast<SvXMLStylesContext
*>(this);
543 pThis
->mxTextImpPropMapper
=
544 pThis
->GetImport().GetTextImport()
545 ->GetTextImportPropertySetMapper();
547 xMapper
= mxTextImpPropMapper
;
550 case XmlStyleFamily::TEXT_SECTION
:
551 // don't cache section mapper, as it's rarely used
552 // *sigh*, cast to non-const, because this is a const method,
553 // but SvXMLImport::GetTextImport() isn't.
554 xMapper
= const_cast<SvXMLStylesContext
*>(this)->GetImport().GetTextImport()->
555 GetSectionImportPropertySetMapper();
558 case XmlStyleFamily::TEXT_RUBY
:
559 // don't cache section mapper, as it's rarely used
560 // *sigh*, cast to non-const, because this is a const method,
561 // but SvXMLImport::GetTextImport() isn't.
562 xMapper
= const_cast<SvXMLStylesContext
*>(this)->GetImport().GetTextImport()->
563 GetRubyImportPropertySetMapper();
566 case XmlStyleFamily::SD_GRAPHICS_ID
:
567 case XmlStyleFamily::SD_PRESENTATION_ID
:
568 case XmlStyleFamily::SD_POOL_ID
:
569 if(!mxShapeImpPropMapper
.is())
571 rtl::Reference
< XMLShapeImportHelper
> aImpHelper
= const_cast<SvXMLImport
&>(GetImport()).GetShapeImport();
572 const_cast<SvXMLStylesContext
*>(this)->mxShapeImpPropMapper
=
573 aImpHelper
->GetPropertySetMapper();
575 xMapper
= mxShapeImpPropMapper
;
577 #if !ENABLE_WASM_STRIP_CHART
579 case XmlStyleFamily::SCH_CHART_ID
:
580 if( ! mxChartImpPropMapper
.is() )
582 XMLPropertySetMapper
*const pPropMapper
= new XMLChartPropertySetMapper(nullptr);
583 mxChartImpPropMapper
= new XMLChartImportPropertyMapper( pPropMapper
, GetImport() );
585 xMapper
= mxChartImpPropMapper
;
588 case XmlStyleFamily::PAGE_MASTER
:
589 if( ! mxPageImpPropMapper
.is() )
591 XMLPropertySetMapper
*pPropMapper
=
592 new XMLPageMasterPropSetMapper();
593 mxPageImpPropMapper
=
594 new PageMasterImportPropertyMapper( pPropMapper
,
595 const_cast<SvXMLStylesContext
*>(this)->GetImport() );
597 xMapper
= mxPageImpPropMapper
;
605 Reference
< XAutoStyleFamily
> SvXMLStylesContext::GetAutoStyles( XmlStyleFamily nFamily
) const
607 Reference
< XAutoStyleFamily
> xAutoStyles
;
608 if( XmlStyleFamily::TEXT_TEXT
== nFamily
|| XmlStyleFamily::TEXT_PARAGRAPH
== nFamily
)
610 bool bPara
= XmlStyleFamily::TEXT_PARAGRAPH
== nFamily
;
611 const Reference
<XAutoStyleFamily
>& rxAutoStyles
= bPara
? mxParaAutoStyles
: mxTextAutoStyles
;
614 OUString
sName(bPara
? gsParagraphStyles
: gsCharacterStyles
);
615 Reference
< XAutoStylesSupplier
> xAutoStylesSupp( GetImport().GetModel(), UNO_QUERY
);
616 Reference
< XAutoStyles
> xAutoStyleFamilies
= xAutoStylesSupp
->getAutoStyles();
617 if (xAutoStyleFamilies
->hasByName(sName
))
619 Any aAny
= xAutoStyleFamilies
->getByName( sName
);
620 aAny
>>= const_cast<Reference
<XAutoStyleFamily
>&>(rxAutoStyles
);
623 xAutoStyles
= rxAutoStyles
;
628 Reference
< XNameContainer
> SvXMLStylesContext::GetStylesContainer(
629 XmlStyleFamily nFamily
) const
631 Reference
< XNameContainer
> xStyles
;
632 if (XmlStyleFamily::TEXT_TEXT
== nFamily
|| XmlStyleFamily::TEXT_PARAGRAPH
== nFamily
)
634 bool bPara
= XmlStyleFamily::TEXT_PARAGRAPH
== nFamily
;
635 const Reference
<XNameContainer
>& rxStyles
= bPara
? mxParaStyles
: mxTextStyles
;
638 OUString
sName(bPara
? gsParagraphStyles
: gsCharacterStyles
);
639 Reference
<XStyleFamiliesSupplier
> xFamiliesSupp(GetImport().GetModel(), UNO_QUERY
);
640 if (xFamiliesSupp
.is())
642 Reference
<XNameAccess
> xFamilies
= xFamiliesSupp
->getStyleFamilies();
643 if (xFamilies
->hasByName(sName
))
645 Any aAny
= xFamilies
->getByName(sName
);
646 aAny
>>= const_cast<Reference
<XNameContainer
>&>(rxStyles
);
656 OUString
SvXMLStylesContext::GetServiceName( XmlStyleFamily nFamily
) const
658 OUString sServiceName
;
661 case XmlStyleFamily::TEXT_PARAGRAPH
:
662 sServiceName
= gsParaStyleServiceName
;
664 case XmlStyleFamily::TEXT_TEXT
:
665 sServiceName
= gsTextStyleServiceName
;
673 SvXMLStylesContext::SvXMLStylesContext( SvXMLImport
& rImport
, bool bAuto
) :
674 SvXMLImportContext( rImport
),
675 mpImpl( new SvXMLStylesContext_Impl( bAuto
) )
679 SvXMLStylesContext::~SvXMLStylesContext()
683 css::uno::Reference
< css::xml::sax::XFastContextHandler
> SvXMLStylesContext::createFastChildContext(
684 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
686 SvXMLStyleContext
* pStyle
= CreateStyleChildContext( nElement
, xAttrList
);
689 if (!pStyle
->IsTransient())
690 mpImpl
->AddStyle(pStyle
);
693 else if (nElement
== XML_ELEMENT(LO_EXT
, XML_THEME
))
695 uno::Reference
<drawing::XDrawPageSupplier
> const xDrawPageSupplier(GetImport().GetModel(), uno::UNO_QUERY
);
696 if (xDrawPageSupplier
.is())
698 uno::Reference
<drawing::XDrawPage
> xPage
= xDrawPageSupplier
->getDrawPage();
700 return new XMLThemeContext(GetImport(), xAttrList
, xPage
);
707 void SvXMLStylesContext::AddStyle(SvXMLStyleContext
& rNew
)
709 mpImpl
->AddStyle( &rNew
);
712 void SvXMLStylesContext::dispose()
717 void SvXMLStylesContext::CopyAutoStylesToDoc()
719 sal_uInt32 nCount
= GetStyleCount();
721 for( i
= 0; i
< nCount
; i
++ )
723 SvXMLStyleContext
*pStyle
= GetStyle( i
);
724 if( !pStyle
|| ( pStyle
->GetFamily() != XmlStyleFamily::TEXT_TEXT
&&
725 pStyle
->GetFamily() != XmlStyleFamily::TEXT_PARAGRAPH
&&
726 pStyle
->GetFamily() != XmlStyleFamily::TABLE_CELL
) )
728 pStyle
->CreateAndInsert( false );
732 void SvXMLStylesContext::CopyStylesToDoc( bool bOverwrite
,
735 // pass 1: create text, paragraph and frame styles
736 sal_uInt32 nCount
= GetStyleCount();
739 for( i
= 0; i
< nCount
; i
++ )
741 SvXMLStyleContext
*pStyle
= GetStyle( i
);
745 if (pStyle
->IsDefaultStyle())
747 if (bOverwrite
) pStyle
->SetDefaults();
749 else if( InsertStyleFamily( pStyle
->GetFamily() ) )
750 pStyle
->CreateAndInsert( bOverwrite
);
753 // pass 2: create list styles (they require char styles)
754 for( i
=0; i
<nCount
; i
++ )
756 SvXMLStyleContext
*pStyle
= GetStyle( i
);
757 if( !pStyle
|| pStyle
->IsDefaultStyle())
760 if( InsertStyleFamily( pStyle
->GetFamily() ) )
761 pStyle
->CreateAndInsertLate( bOverwrite
);
764 // pass3: finish creation of styles
766 FinishStyles( bOverwrite
);
769 void SvXMLStylesContext::FinishStyles( bool bOverwrite
)
771 sal_uInt32 nCount
= GetStyleCount();
772 for( sal_uInt32 i
=0; i
<nCount
; i
++ )
774 SvXMLStyleContext
*pStyle
= GetStyle( i
);
775 if( !pStyle
|| !pStyle
->IsValid() || pStyle
->IsDefaultStyle() )
778 if( InsertStyleFamily( pStyle
->GetFamily() ) )
779 pStyle
->Finish( bOverwrite
);
783 const SvXMLStyleContext
*SvXMLStylesContext::FindStyleChildContext(
784 XmlStyleFamily nFamily
,
785 const OUString
& rName
,
786 bool bCreateIndex
) const
788 return mpImpl
->FindStyleChildContext( nFamily
, rName
, bCreateIndex
);
791 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */