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 <PageMasterPropMapper.hxx>
31 #include <sal/log.hxx>
32 #include <svl/style.hxx>
34 #include <xmloff/namespacemap.hxx>
35 #include <xmloff/xmlnamespace.hxx>
36 #include <xmloff/xmltoken.hxx>
38 #include <xmloff/families.hxx>
39 #include <xmloff/xmlimp.hxx>
40 #include <xmloff/xmlnumi.hxx>
41 #include <xmloff/xmlimppr.hxx>
42 #include <xmloff/xmlstyle.hxx>
43 #include <xmloff/txtstyli.hxx>
44 #include <xmloff/xmlnumfi.hxx>
45 #include <XMLChartStyleContext.hxx>
46 #include <XMLChartPropertySetMapper.hxx>
47 #include <xmloff/XMLShapeStyleContext.hxx>
48 #include "FillStyleContext.hxx"
49 #include <XMLFootnoteConfigurationImportContext.hxx>
50 #include <XMLIndexBibliographyConfigurationContext.hxx>
51 #include <XMLLineNumberingImportContext.hxx>
52 #include <PageMasterImportContext.hxx>
53 #include "PageMasterImportPropMapper.hxx"
57 #include <string_view>
60 using namespace ::com::sun::star
;
61 using namespace ::com::sun::star::uno
;
62 using namespace ::com::sun::star::container
;
63 using namespace ::com::sun::star::style
;
64 using namespace ::xmloff::token
;
66 constexpr OUStringLiteral
gsParaStyleServiceName( u
"com.sun.star.style.ParagraphStyle" );
67 constexpr OUStringLiteral
gsTextStyleServiceName( u
"com.sun.star.style.CharacterStyle" );
69 void SvXMLStyleContext::SetAttribute( sal_Int32 nElement
,
70 const OUString
& rValue
)
74 case XML_ELEMENT(STYLE
, XML_FAMILY
):
76 if( IsXMLToken( rValue
, XML_PARAGRAPH
) )
77 mnFamily
= XmlStyleFamily(SfxStyleFamily::Para
);
78 else if( IsXMLToken( rValue
, XML_TEXT
) )
79 mnFamily
= XmlStyleFamily(SfxStyleFamily::Char
);
82 case XML_ELEMENT(STYLE
, XML_NAME
):
85 case XML_ELEMENT(STYLE
, XML_DISPLAY_NAME
):
86 maDisplayName
= rValue
;
88 case XML_ELEMENT(STYLE
, XML_PARENT_STYLE_NAME
):
89 maParentName
= rValue
;
91 case XML_ELEMENT(STYLE
, XML_NEXT_STYLE_NAME
):
94 case XML_ELEMENT(LO_EXT
, XML_LINKED_STYLE_NAME
):
97 case XML_ELEMENT(STYLE
, XML_HIDDEN
):
98 mbHidden
= rValue
.toBoolean();
100 case XML_ELEMENT(LO_EXT
, XML_HIDDEN
):
101 mbHidden
= rValue
.toBoolean();
107 SvXMLStyleContext::SvXMLStyleContext(
109 XmlStyleFamily nFam
, bool bDefault
) :
110 SvXMLImportContext( rImp
),
115 mbDefaultStyle( bDefault
)
119 SvXMLStyleContext::~SvXMLStyleContext()
123 void SvXMLStyleContext::startFastElement(
124 sal_Int32
/*nElement*/,
125 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
127 for( auto &it
: sax_fastparser::castToFastAttributeList( xAttrList
) )
128 SetAttribute( it
.getToken(), it
.toString() );
131 void SvXMLStyleContext::SetDefaults()
135 void SvXMLStyleContext::CreateAndInsert( bool /*bOverwrite*/ )
139 void SvXMLStyleContext::CreateAndInsertLate( bool /*bOverwrite*/ )
143 void SvXMLStyleContext::Finish( bool /*bOverwrite*/ )
147 bool SvXMLStyleContext::IsTransient() const
154 class SvXMLStyleIndex_Impl
157 XmlStyleFamily nFamily
;
158 // we deliberately don't use a reference here, to avoid creating a ref-count-cycle
159 SvXMLStyleContext
* mpStyle
;
163 SvXMLStyleIndex_Impl( XmlStyleFamily nFam
, OUString aName
) :
164 sName(std::move( aName
)),
170 SvXMLStyleIndex_Impl( const rtl::Reference
<SvXMLStyleContext
> &rStl
) :
171 sName( rStl
->GetName() ),
172 nFamily( rStl
->GetFamily() ),
173 mpStyle ( rStl
.get() )
177 const OUString
& GetName() const { return sName
; }
178 XmlStyleFamily
GetFamily() const { return nFamily
; }
179 const SvXMLStyleContext
*GetStyle() const { return mpStyle
; }
182 struct SvXMLStyleIndexCmp_Impl
184 bool operator()(const SvXMLStyleIndex_Impl
& r1
, const SvXMLStyleIndex_Impl
& r2
) const
188 if( r1
.GetFamily() < r2
.GetFamily() )
190 else if( r1
.GetFamily() > r2
.GetFamily() )
193 nRet
= r1
.GetName().compareTo( r2
.GetName() );
201 class SvXMLStylesContext_Impl
203 typedef std::set
<SvXMLStyleIndex_Impl
, SvXMLStyleIndexCmp_Impl
> IndicesType
;
205 std::vector
<rtl::Reference
<SvXMLStyleContext
>> aStyles
;
206 mutable std::unique_ptr
<IndicesType
> pIndices
;
207 bool bAutomaticStyle
;
209 #if OSL_DEBUG_LEVEL > 0
210 mutable sal_uInt32 m_nIndexCreated
;
213 void FlushIndex() { pIndices
.reset(); }
216 explicit SvXMLStylesContext_Impl( bool bAuto
);
218 size_t GetStyleCount() const { return aStyles
.size(); }
220 SvXMLStyleContext
*GetStyle( size_t i
)
222 return i
< aStyles
.size() ? aStyles
[ i
].get() : nullptr;
225 inline void AddStyle( SvXMLStyleContext
*pStyle
);
228 const SvXMLStyleContext
*FindStyleChildContext( XmlStyleFamily nFamily
,
229 const OUString
& rName
,
230 bool bCreateIndex
) const;
231 bool IsAutomaticStyle() const { return bAutomaticStyle
; }
234 SvXMLStylesContext_Impl::SvXMLStylesContext_Impl( bool bAuto
) :
235 bAutomaticStyle( bAuto
)
236 #if OSL_DEBUG_LEVEL > 0
237 , m_nIndexCreated( 0 )
241 inline void SvXMLStylesContext_Impl::AddStyle( SvXMLStyleContext
*pStyle
)
243 #if OSL_DEBUG_LEVEL > 0
244 // for (auto const & xStyle : aStyles)
245 // if (xStyle->GetFamily() == pStyle->GetFamily() && xStyle->GetName() == pStyle->GetName())
246 // assert(false && "duplicate style");
248 aStyles
.emplace_back(pStyle
);
253 void SvXMLStylesContext_Impl::dispose()
259 const SvXMLStyleContext
*SvXMLStylesContext_Impl::FindStyleChildContext( XmlStyleFamily nFamily
,
260 const OUString
& rName
,
261 bool bCreateIndex
) const
263 const SvXMLStyleContext
*pStyle
= nullptr;
265 if( !pIndices
&& bCreateIndex
&& !aStyles
.empty() )
267 pIndices
= std::make_unique
<IndicesType
>(aStyles
.begin(), aStyles
.end());
268 SAL_WARN_IF(pIndices
->size() != aStyles
.size(), "xmloff.style", "Here is a duplicate Style");
269 #if OSL_DEBUG_LEVEL > 0
270 SAL_WARN_IF(0 != m_nIndexCreated
, "xmloff.style",
271 "Performance warning: sdbcx::Index created multiple times");
278 SvXMLStyleIndex_Impl
aIndex( nFamily
, rName
);
279 IndicesType::iterator aFind
= pIndices
->find(aIndex
);
280 if( aFind
!= pIndices
->end() )
281 pStyle
= aFind
->GetStyle();
285 for( size_t i
= 0; !pStyle
&& i
< aStyles
.size(); i
++ )
287 const SvXMLStyleContext
*pS
= aStyles
[ i
].get();
288 if( pS
->GetFamily() == nFamily
&&
289 pS
->GetName() == rName
)
297 sal_uInt32
SvXMLStylesContext::GetStyleCount() const
299 return mpImpl
->GetStyleCount();
302 SvXMLStyleContext
*SvXMLStylesContext::GetStyle( sal_uInt32 i
)
304 return mpImpl
->GetStyle( i
);
307 const SvXMLStyleContext
*SvXMLStylesContext::GetStyle( sal_uInt32 i
) const
309 return mpImpl
->GetStyle( i
);
312 bool SvXMLStylesContext::IsAutomaticStyle() const
314 return mpImpl
->IsAutomaticStyle();
317 SvXMLStyleContext
*SvXMLStylesContext::CreateStyleChildContext(
319 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
321 SvXMLStyleContext
*pStyle
= nullptr;
323 if(GetImport().GetDataStylesImport())
325 pStyle
= GetImport().GetDataStylesImport()->CreateChildContext(GetImport(), nElement
,
333 case XML_ELEMENT(STYLE
, XML_STYLE
):
334 case XML_ELEMENT(STYLE
, XML_DEFAULT_STYLE
):
336 XmlStyleFamily nFamily
= XmlStyleFamily::DATA_STYLE
;
337 for( auto &aIter
: sax_fastparser::castToFastAttributeList( xAttrList
) )
339 if( aIter
.getToken() == XML_ELEMENT(STYLE
, XML_FAMILY
) )
341 nFamily
= GetFamily( aIter
.toString() );
345 pStyle
= XML_ELEMENT(STYLE
, XML_STYLE
)==nElement
346 ? CreateStyleStyleChildContext( nFamily
, nElement
, xAttrList
)
347 : CreateDefaultStyleStyleChildContext( nFamily
, nElement
, xAttrList
);
350 case XML_ELEMENT(TEXT
, XML_BIBLIOGRAPHY_CONFIGURATION
):
351 pStyle
= new XMLIndexBibliographyConfigurationContext(GetImport());
353 case XML_ELEMENT(TEXT
, XML_NOTES_CONFIGURATION
):
354 pStyle
= new XMLFootnoteConfigurationImportContext(
355 GetImport(), nElement
, xAttrList
);
357 case XML_ELEMENT(TEXT
, XML_LINENUMBERING_CONFIGURATION
):
358 pStyle
= new XMLLineNumberingImportContext(GetImport());
360 case XML_ELEMENT(STYLE
, XML_PAGE_LAYOUT
):
361 case XML_ELEMENT(STYLE
, XML_DEFAULT_PAGE_LAYOUT
):
363 //there is not page family in ODF now, so I specify one for it
364 bool bDefaultStyle
= XML_ELEMENT(STYLE
, XML_DEFAULT_PAGE_LAYOUT
) == nElement
;
365 pStyle
= new PageStyleContext( GetImport(), *this, bDefaultStyle
);
368 case XML_ELEMENT(TEXT
, XML_LIST_STYLE
):
369 pStyle
= new SvxXMLListStyleContext( GetImport() );
371 case XML_ELEMENT(TEXT
, XML_OUTLINE_STYLE
):
372 pStyle
= new SvxXMLListStyleContext( GetImport(), true );
377 case XML_ELEMENT(DRAW
, XML_GRADIENT
):
379 pStyle
= new XMLGradientStyleContext( GetImport(), nElement
, xAttrList
);
382 case XML_ELEMENT(DRAW
, XML_HATCH
):
384 pStyle
= new XMLHatchStyleContext( GetImport(), nElement
, xAttrList
);
387 case XML_ELEMENT(DRAW
, XML_FILL_IMAGE
):
389 pStyle
= new XMLBitmapStyleContext( GetImport(), nElement
, xAttrList
);
392 case XML_ELEMENT(DRAW
, XML_OPACITY
):
394 pStyle
= new XMLTransGradientStyleContext( GetImport(), nElement
, xAttrList
);
397 case XML_ELEMENT(DRAW
, XML_MARKER
):
399 pStyle
= new XMLMarkerStyleContext( GetImport(), nElement
, xAttrList
);
402 case XML_ELEMENT(DRAW
, XML_STROKE_DASH
):
404 pStyle
= new XMLDashStyleContext( GetImport(), nElement
, xAttrList
);
410 SAL_WARN("xmloff", "Unknown element " << SvXMLImport::getPrefixAndNameFromToken(nElement
));
415 SvXMLStyleContext
*SvXMLStylesContext::CreateStyleStyleChildContext(
416 XmlStyleFamily nFamily
, sal_Int32
/*nElement*/,
417 const uno::Reference
< xml::sax::XFastAttributeList
> & /*xAttrList*/ )
419 SvXMLStyleContext
*pStyle
= nullptr;
423 case XmlStyleFamily::TEXT_PARAGRAPH
:
424 case XmlStyleFamily::TEXT_TEXT
:
425 case XmlStyleFamily::TEXT_SECTION
:
426 pStyle
= new XMLTextStyleContext( GetImport(), *this, nFamily
);
429 case XmlStyleFamily::TEXT_RUBY
:
430 pStyle
= new XMLPropStyleContext( GetImport(), *this, nFamily
);
432 #if !ENABLE_WASM_STRIP_CHART
434 case XmlStyleFamily::SCH_CHART_ID
:
435 pStyle
= new XMLChartStyleContext( GetImport(), *this, nFamily
);
438 case XmlStyleFamily::SD_GRAPHICS_ID
:
439 case XmlStyleFamily::SD_PRESENTATION_ID
:
440 case XmlStyleFamily::SD_POOL_ID
:
441 pStyle
= new XMLShapeStyleContext( GetImport(), *this, nFamily
);
449 SvXMLStyleContext
*SvXMLStylesContext::CreateDefaultStyleStyleChildContext(
450 XmlStyleFamily
/*nFamily*/, sal_Int32
/*nElement*/,
451 const uno::Reference
< xml::sax::XFastAttributeList
> & )
456 bool SvXMLStylesContext::InsertStyleFamily( XmlStyleFamily
) const
461 XmlStyleFamily
SvXMLStylesContext::GetFamily( std::u16string_view rValue
)
463 XmlStyleFamily nFamily
= XmlStyleFamily::DATA_STYLE
;
464 if( IsXMLToken( rValue
, XML_PARAGRAPH
) )
466 nFamily
= XmlStyleFamily::TEXT_PARAGRAPH
;
468 else if( IsXMLToken( rValue
, XML_TEXT
) )
470 nFamily
= XmlStyleFamily::TEXT_TEXT
;
472 else if( IsXMLToken( rValue
, XML_DATA_STYLE
) )
474 nFamily
= XmlStyleFamily::DATA_STYLE
;
476 else if ( IsXMLToken( rValue
, XML_SECTION
) )
478 nFamily
= XmlStyleFamily::TEXT_SECTION
;
480 else if( IsXMLToken( rValue
, XML_TABLE
) )
482 nFamily
= XmlStyleFamily::TABLE_TABLE
;
484 else if( IsXMLToken( rValue
, XML_TABLE_COLUMN
) )
485 nFamily
= XmlStyleFamily::TABLE_COLUMN
;
486 else if( IsXMLToken( rValue
, XML_TABLE_ROW
) )
487 nFamily
= XmlStyleFamily::TABLE_ROW
;
488 else if( IsXMLToken( rValue
, XML_TABLE_CELL
) )
489 nFamily
= XmlStyleFamily::TABLE_CELL
;
490 else if ( rValue
== XML_STYLE_FAMILY_SD_GRAPHICS_NAME
)
492 nFamily
= XmlStyleFamily::SD_GRAPHICS_ID
;
494 else if ( rValue
== XML_STYLE_FAMILY_SD_PRESENTATION_NAME
)
496 nFamily
= XmlStyleFamily::SD_PRESENTATION_ID
;
498 else if ( rValue
== XML_STYLE_FAMILY_SD_POOL_NAME
)
500 nFamily
= XmlStyleFamily::SD_POOL_ID
;
502 else if ( rValue
== XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME
)
504 nFamily
= XmlStyleFamily::SD_DRAWINGPAGE_ID
;
506 else if ( rValue
== XML_STYLE_FAMILY_SCH_CHART_NAME
)
508 nFamily
= XmlStyleFamily::SCH_CHART_ID
;
510 else if ( IsXMLToken( rValue
, XML_RUBY
) )
512 nFamily
= XmlStyleFamily::TEXT_RUBY
;
518 rtl::Reference
< SvXMLImportPropertyMapper
> SvXMLStylesContext::GetImportPropertyMapper(
519 XmlStyleFamily nFamily
) const
521 rtl::Reference
< SvXMLImportPropertyMapper
> xMapper
;
525 case XmlStyleFamily::TEXT_PARAGRAPH
:
526 if( !mxParaImpPropMapper
.is() )
528 SvXMLStylesContext
* pThis
= const_cast<SvXMLStylesContext
*>(this);
529 pThis
->mxParaImpPropMapper
=
530 pThis
->GetImport().GetTextImport()
531 ->GetParaImportPropertySetMapper();
533 xMapper
= mxParaImpPropMapper
;
535 case XmlStyleFamily::TEXT_TEXT
:
536 if( !mxTextImpPropMapper
.is() )
538 SvXMLStylesContext
* pThis
= const_cast<SvXMLStylesContext
*>(this);
539 pThis
->mxTextImpPropMapper
=
540 pThis
->GetImport().GetTextImport()
541 ->GetTextImportPropertySetMapper();
543 xMapper
= mxTextImpPropMapper
;
546 case XmlStyleFamily::TEXT_SECTION
:
547 // don't cache section mapper, as it's rarely used
548 // *sigh*, cast to non-const, because this is a const method,
549 // but SvXMLImport::GetTextImport() isn't.
550 xMapper
= const_cast<SvXMLStylesContext
*>(this)->GetImport().GetTextImport()->
551 GetSectionImportPropertySetMapper();
554 case XmlStyleFamily::TEXT_RUBY
:
555 // don't cache section mapper, as it's rarely used
556 // *sigh*, cast to non-const, because this is a const method,
557 // but SvXMLImport::GetTextImport() isn't.
558 xMapper
= const_cast<SvXMLStylesContext
*>(this)->GetImport().GetTextImport()->
559 GetRubyImportPropertySetMapper();
562 case XmlStyleFamily::SD_GRAPHICS_ID
:
563 case XmlStyleFamily::SD_PRESENTATION_ID
:
564 case XmlStyleFamily::SD_POOL_ID
:
565 if(!mxShapeImpPropMapper
.is())
567 rtl::Reference
< XMLShapeImportHelper
> aImpHelper
= const_cast<SvXMLImport
&>(GetImport()).GetShapeImport();
568 const_cast<SvXMLStylesContext
*>(this)->mxShapeImpPropMapper
=
569 aImpHelper
->GetPropertySetMapper();
571 xMapper
= mxShapeImpPropMapper
;
573 #if !ENABLE_WASM_STRIP_CHART
575 case XmlStyleFamily::SCH_CHART_ID
:
576 if( ! mxChartImpPropMapper
.is() )
578 XMLPropertySetMapper
*const pPropMapper
= new XMLChartPropertySetMapper(nullptr);
579 mxChartImpPropMapper
= new XMLChartImportPropertyMapper( pPropMapper
, GetImport() );
581 xMapper
= mxChartImpPropMapper
;
584 case XmlStyleFamily::PAGE_MASTER
:
585 if( ! mxPageImpPropMapper
.is() )
587 XMLPropertySetMapper
*pPropMapper
=
588 new XMLPageMasterPropSetMapper();
589 mxPageImpPropMapper
=
590 new PageMasterImportPropertyMapper( pPropMapper
,
591 const_cast<SvXMLStylesContext
*>(this)->GetImport() );
593 xMapper
= mxPageImpPropMapper
;
601 Reference
< XAutoStyleFamily
> SvXMLStylesContext::GetAutoStyles( XmlStyleFamily nFamily
) const
603 Reference
< XAutoStyleFamily
> xAutoStyles
;
604 if( XmlStyleFamily::TEXT_TEXT
== nFamily
|| XmlStyleFamily::TEXT_PARAGRAPH
== nFamily
)
606 bool bPara
= XmlStyleFamily::TEXT_PARAGRAPH
== nFamily
;
607 if( !bPara
&& mxTextAutoStyles
.is() )
608 xAutoStyles
= mxTextAutoStyles
;
609 else if( bPara
&& mxParaAutoStyles
.is() )
610 xAutoStyles
= mxParaAutoStyles
;
613 OUString
sName(bPara
? std::u16string_view( u
"ParagraphStyles" ): std::u16string_view( u
"CharacterStyles" ));
614 Reference
< XAutoStylesSupplier
> xAutoStylesSupp( GetImport().GetModel(), UNO_QUERY
);
615 Reference
< XAutoStyles
> xAutoStyleFamilies
= xAutoStylesSupp
->getAutoStyles();
616 if (xAutoStyleFamilies
->hasByName(sName
))
618 Any aAny
= xAutoStyleFamilies
->getByName( sName
);
619 aAny
>>= xAutoStyles
;
621 const_cast<SvXMLStylesContext
*>(this)->mxParaAutoStyles
= xAutoStyles
;
623 const_cast<SvXMLStylesContext
*>(this)->mxTextAutoStyles
= xAutoStyles
;
630 Reference
< XNameContainer
> SvXMLStylesContext::GetStylesContainer(
631 XmlStyleFamily nFamily
) const
633 Reference
< XNameContainer
> xStyles
;
637 case XmlStyleFamily::TEXT_PARAGRAPH
:
638 if( mxParaStyles
.is() )
639 xStyles
= mxParaStyles
;
641 sName
= "ParagraphStyles";
644 case XmlStyleFamily::TEXT_TEXT
:
645 if( mxTextStyles
.is() )
646 xStyles
= mxTextStyles
;
648 sName
= "CharacterStyles";
652 if( !xStyles
.is() && !sName
.isEmpty() )
654 Reference
< XStyleFamiliesSupplier
> xFamiliesSupp(
655 GetImport().GetModel(), UNO_QUERY
);
656 if ( xFamiliesSupp
.is() )
658 Reference
< XNameAccess
> xFamilies
= xFamiliesSupp
->getStyleFamilies();
659 if (xFamilies
->hasByName(sName
))
661 xStyles
.set(xFamilies
->getByName( sName
),uno::UNO_QUERY
);
665 case XmlStyleFamily::TEXT_PARAGRAPH
:
666 const_cast<SvXMLStylesContext
*>(this)->mxParaStyles
= xStyles
;
669 case XmlStyleFamily::TEXT_TEXT
:
670 const_cast<SvXMLStylesContext
*>(this)->mxTextStyles
= xStyles
;
681 OUString
SvXMLStylesContext::GetServiceName( XmlStyleFamily nFamily
) const
683 OUString sServiceName
;
686 case XmlStyleFamily::TEXT_PARAGRAPH
:
687 sServiceName
= gsParaStyleServiceName
;
689 case XmlStyleFamily::TEXT_TEXT
:
690 sServiceName
= gsTextStyleServiceName
;
698 SvXMLStylesContext::SvXMLStylesContext( SvXMLImport
& rImport
, bool bAuto
) :
699 SvXMLImportContext( rImport
),
700 mpImpl( new SvXMLStylesContext_Impl( bAuto
) )
704 SvXMLStylesContext::~SvXMLStylesContext()
708 css::uno::Reference
< css::xml::sax::XFastContextHandler
> SvXMLStylesContext::createFastChildContext(
709 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
711 SvXMLStyleContext
*pStyle
=
712 CreateStyleChildContext( nElement
, xAttrList
);
715 if( !pStyle
->IsTransient() )
716 mpImpl
->AddStyle( pStyle
);
723 void SvXMLStylesContext::AddStyle(SvXMLStyleContext
& rNew
)
725 mpImpl
->AddStyle( &rNew
);
728 void SvXMLStylesContext::dispose()
733 void SvXMLStylesContext::CopyAutoStylesToDoc()
735 sal_uInt32 nCount
= GetStyleCount();
737 for( i
= 0; i
< nCount
; i
++ )
739 SvXMLStyleContext
*pStyle
= GetStyle( i
);
740 if( !pStyle
|| ( pStyle
->GetFamily() != XmlStyleFamily::TEXT_TEXT
&&
741 pStyle
->GetFamily() != XmlStyleFamily::TEXT_PARAGRAPH
&&
742 pStyle
->GetFamily() != XmlStyleFamily::TABLE_CELL
) )
744 pStyle
->CreateAndInsert( false );
748 void SvXMLStylesContext::CopyStylesToDoc( bool bOverwrite
,
751 // pass 1: create text, paragraph and frame styles
752 sal_uInt32 nCount
= GetStyleCount();
755 for( i
= 0; i
< nCount
; i
++ )
757 SvXMLStyleContext
*pStyle
= GetStyle( i
);
761 if (pStyle
->IsDefaultStyle())
763 if (bOverwrite
) pStyle
->SetDefaults();
765 else if( InsertStyleFamily( pStyle
->GetFamily() ) )
766 pStyle
->CreateAndInsert( bOverwrite
);
769 // pass 2: create list styles (they require char styles)
770 for( i
=0; i
<nCount
; i
++ )
772 SvXMLStyleContext
*pStyle
= GetStyle( i
);
773 if( !pStyle
|| pStyle
->IsDefaultStyle())
776 if( InsertStyleFamily( pStyle
->GetFamily() ) )
777 pStyle
->CreateAndInsertLate( bOverwrite
);
780 // pass3: finish creation of styles
782 FinishStyles( bOverwrite
);
785 void SvXMLStylesContext::FinishStyles( bool bOverwrite
)
787 sal_uInt32 nCount
= GetStyleCount();
788 for( sal_uInt32 i
=0; i
<nCount
; i
++ )
790 SvXMLStyleContext
*pStyle
= GetStyle( i
);
791 if( !pStyle
|| !pStyle
->IsValid() || pStyle
->IsDefaultStyle() )
794 if( InsertStyleFamily( pStyle
->GetFamily() ) )
795 pStyle
->Finish( bOverwrite
);
799 const SvXMLStyleContext
*SvXMLStylesContext::FindStyleChildContext(
800 XmlStyleFamily nFamily
,
801 const OUString
& rName
,
802 bool bCreateIndex
) const
804 return mpImpl
->FindStyleChildContext( nFamily
, rName
, bCreateIndex
);
807 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */