LibreOffice Module xmloff (master)  1
xmlstyle.cxx
Go to the documentation of this file.
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 <sal/config.h>
21 
22 #include <com/sun/star/frame/XModel.hpp>
23 #include <com/sun/star/xml/sax/XAttributeList.hpp>
24 #include <com/sun/star/container/XNameContainer.hpp>
25 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
26 #include <com/sun/star/style/XAutoStylesSupplier.hpp>
27 #include <com/sun/star/style/XAutoStyleFamily.hpp>
28 #include <PageMasterPropMapper.hxx>
29 #include <sal/log.hxx>
30 #include <svl/style.hxx>
31 #include <xmloff/namespacemap.hxx>
32 #include <xmloff/xmlnamespace.hxx>
33 #include <xmloff/xmltoken.hxx>
34 
35 #include <xmloff/families.hxx>
36 #include <xmloff/xmlimp.hxx>
37 #include <xmloff/xmlnumi.hxx>
38 #include <xmloff/xmlimppr.hxx>
39 #include <xmloff/xmlstyle.hxx>
40 #include <xmloff/txtstyli.hxx>
41 #include <xmloff/xmlnumfi.hxx>
42 #include <XMLChartStyleContext.hxx>
45 #include "FillStyleContext.hxx"
51 
52 #include <memory>
53 #include <set>
54 #include <vector>
55 
56 using namespace ::com::sun::star;
57 using namespace ::com::sun::star::uno;
58 using namespace ::com::sun::star::container;
59 using namespace ::com::sun::star::style;
60 using namespace ::xmloff::token;
61 
62 constexpr OUStringLiteral gsParaStyleServiceName( u"com.sun.star.style.ParagraphStyle" );
63 constexpr OUStringLiteral gsTextStyleServiceName( u"com.sun.star.style.CharacterStyle" );
64 
65 void SvXMLStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
66  const OUString& rLocalName,
67  const OUString& rValue )
68 {
69  // TODO: use a map here
70  if( XML_NAMESPACE_STYLE == nPrefixKey )
71  {
72  if( IsXMLToken( rLocalName, XML_FAMILY ) )
73  {
74  if( IsXMLToken( rValue, XML_PARAGRAPH ) )
75  mnFamily = XmlStyleFamily(SfxStyleFamily::Para);
76  else if( IsXMLToken( rValue, XML_TEXT ) )
77  mnFamily = XmlStyleFamily(SfxStyleFamily::Char);
78  }
79  else if( IsXMLToken( rLocalName, XML_NAME ) )
80  {
81  maName = rValue;
82  }
83  else if( IsXMLToken( rLocalName, XML_DISPLAY_NAME ) )
84  {
86  }
87  else if( IsXMLToken( rLocalName, XML_PARENT_STYLE_NAME ) )
88  {
90  }
91  else if( IsXMLToken( rLocalName, XML_NEXT_STYLE_NAME ) )
92  {
93  maFollow = rValue;
94  }
95  else if( IsXMLToken( rLocalName, XML_HIDDEN ) )
96  {
97  mbHidden = rValue.toBoolean();
98  }
99  }
100  else if (XML_NAMESPACE_LO_EXT == nPrefixKey)
101  {
102  if (IsXMLToken(rLocalName, XML_HIDDEN))
103  {
104  mbHidden = rValue.toBoolean();
105  }
106  }
107 }
108 
109 
111  SvXMLImport& rImp,
112  XmlStyleFamily nFam, bool bDefault ) :
113  SvXMLImportContext( rImp ),
114  mbHidden( false ),
115  mnFamily( nFam ),
116  mbValid( true ),
117  mbNew( true ),
118  mbDefaultStyle( bDefault )
119 {
120 }
121 
123 {
124 }
125 
127  sal_Int32 /*nElement*/,
128  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
129 {
130  // Fall back from fastparser to slowparser code
131  for( auto &it : sax_fastparser::castToFastAttributeList( xAttrList ) )
132  {
133  sal_Int32 nToken = it.getToken();
134  const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken(nToken, &GetImport().GetNamespaceMap());
135  OUString sAttrName = SvXMLImport::getNameFromToken( nToken );
136  if ( !rAttrNamespacePrefix.isEmpty() )
137  sAttrName = rAttrNamespacePrefix + SvXMLImport::aNamespaceSeparator + sAttrName;
138  OUString aLocalName;
139  sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
140 
141  SetAttribute( nPrefix, aLocalName, it.toString() );
142  }
143 }
144 
146 {
147 }
148 
149 void SvXMLStyleContext::CreateAndInsert( bool /*bOverwrite*/ )
150 {
151 }
152 
153 void SvXMLStyleContext::CreateAndInsertLate( bool /*bOverwrite*/ )
154 {
155 }
156 
157 void SvXMLStyleContext::Finish( bool /*bOverwrite*/ )
158 {
159 }
160 
162 {
163  return false;
164 }
165 
166 namespace {
167 
168 class SvXMLStyleIndex_Impl
169 {
170  OUString sName;
171  XmlStyleFamily nFamily;
172  // we deliberately don't use a reference here, to avoid creating a ref-count-cycle
173  SvXMLStyleContext* mpStyle;
174 
175 public:
176 
177  SvXMLStyleIndex_Impl( XmlStyleFamily nFam, const OUString& rName ) :
178  sName( rName ),
179  nFamily( nFam ),
180  mpStyle(nullptr)
181  {
182  }
183 
184  SvXMLStyleIndex_Impl( const rtl::Reference<SvXMLStyleContext> &rStl ) :
185  sName( rStl->GetName() ),
186  nFamily( rStl->GetFamily() ),
187  mpStyle ( rStl.get() )
188  {
189  }
190 
191  const OUString& GetName() const { return sName; }
192  XmlStyleFamily GetFamily() const { return nFamily; }
193  const SvXMLStyleContext *GetStyle() const { return mpStyle; }
194 };
195 
196 struct SvXMLStyleIndexCmp_Impl
197 {
198  bool operator()(const SvXMLStyleIndex_Impl& r1, const SvXMLStyleIndex_Impl& r2) const
199  {
200  sal_Int32 nRet;
201 
202  if( r1.GetFamily() < r2.GetFamily() )
203  nRet = -1;
204  else if( r1.GetFamily() > r2.GetFamily() )
205  nRet = 1;
206  else
207  nRet = r1.GetName().compareTo( r2.GetName() );
208 
209  return nRet < 0;
210  }
211 };
212 
213 }
214 
216 {
217  typedef std::set<SvXMLStyleIndex_Impl, SvXMLStyleIndexCmp_Impl> IndicesType;
218 
219  std::vector<rtl::Reference<SvXMLStyleContext>> aStyles;
220  mutable std::unique_ptr<IndicesType> pIndices;
222 
223 #if OSL_DEBUG_LEVEL > 0
224  mutable sal_uInt32 m_nIndexCreated;
225 #endif
226 
227  void FlushIndex() { pIndices.reset(); }
228 
229 public:
230  explicit SvXMLStylesContext_Impl( bool bAuto );
231 
232  size_t GetStyleCount() const { return aStyles.size(); }
233 
235  {
236  return i < aStyles.size() ? aStyles[ i ].get() : nullptr;
237  }
238 
239  inline void AddStyle( SvXMLStyleContext *pStyle );
240  void dispose();
241 
243  const OUString& rName,
244  bool bCreateIndex ) const;
245  bool IsAutomaticStyle() const { return bAutomaticStyle; }
246 };
247 
249  bAutomaticStyle( bAuto )
250 #if OSL_DEBUG_LEVEL > 0
251  , m_nIndexCreated( 0 )
252 #endif
253 {}
254 
256 {
257 #if OSL_DEBUG_LEVEL > 0
258 // for (auto const & xStyle : aStyles)
259 // if (xStyle->GetFamily() == pStyle->GetFamily() && xStyle->GetName() == pStyle->GetName())
260 // assert(false && "duplicate style");
261 #endif
262  aStyles.emplace_back(pStyle );
263 
264  FlushIndex();
265 }
266 
268 {
269  FlushIndex();
270  aStyles.clear();
271 }
272 
274  const OUString& rName,
275  bool bCreateIndex ) const
276 {
277  const SvXMLStyleContext *pStyle = nullptr;
278 
279  if( !pIndices && bCreateIndex && !aStyles.empty() )
280  {
281  pIndices = std::make_unique<IndicesType>(aStyles.begin(), aStyles.end());
282  SAL_WARN_IF(pIndices->size() != aStyles.size(), "xmloff.style", "Here is a duplicate Style");
283 #if OSL_DEBUG_LEVEL > 0
284  SAL_WARN_IF(0 != m_nIndexCreated, "xmloff.style",
285  "Performance warning: sdbcx::Index created multiple times");
286  ++m_nIndexCreated;
287 #endif
288  }
289 
290  if( pIndices )
291  {
292  SvXMLStyleIndex_Impl aIndex( nFamily, rName );
293  IndicesType::iterator aFind = pIndices->find(aIndex);
294  if( aFind != pIndices->end() )
295  pStyle = aFind->GetStyle();
296  }
297  else
298  {
299  for( size_t i = 0; !pStyle && i < aStyles.size(); i++ )
300  {
301  const SvXMLStyleContext *pS = aStyles[ i ].get();
302  if( pS->GetFamily() == nFamily &&
303  pS->GetName() == rName )
304  pStyle = pS;
305  }
306  }
307  return pStyle;
308 }
309 
310 
312 {
313  return mpImpl->GetStyleCount();
314 }
315 
317 {
318  return mpImpl->GetStyle( i );
319 }
320 
322 {
323  return mpImpl->GetStyle( i );
324 }
325 
327 {
328  return mpImpl->IsAutomaticStyle();
329 }
330 
332  sal_Int32 nElement,
333  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
334 {
335  SvXMLStyleContext *pStyle = nullptr;
336 
337  if(GetImport().GetDataStylesImport())
338  {
339  pStyle = GetImport().GetDataStylesImport()->CreateChildContext(GetImport(), nElement,
340  xAttrList, *this);
341  if (pStyle)
342  return pStyle;
343  }
344 
345  switch (nElement)
346  {
347  case XML_ELEMENT(STYLE, XML_STYLE):
349  {
351  for( auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ) )
352  {
353  if( aIter.getToken() == XML_ELEMENT(STYLE, XML_FAMILY) )
354  {
355  nFamily = GetFamily( aIter.toString() );
356  break;
357  }
358  }
359  pStyle = XML_ELEMENT(STYLE, XML_STYLE)==nElement
360  ? CreateStyleStyleChildContext( nFamily, nElement, xAttrList )
361  : CreateDefaultStyleStyleChildContext( nFamily, nElement, xAttrList );
362  break;
363  }
366  break;
369  GetImport(), nElement, xAttrList);
370  break;
373  break;
376  {
377  //there is not page family in ODF now, so I specify one for it
378  bool bDefaultStyle = XML_ELEMENT(STYLE, XML_DEFAULT_PAGE_LAYOUT) == nElement;
379  pStyle = new PageStyleContext( GetImport(), *this, bDefaultStyle );
380  }
381  break;
383  pStyle = new SvxXMLListStyleContext( GetImport() );
384  break;
386  pStyle = new SvxXMLListStyleContext( GetImport(), true );
387  break;
388 
389  // FillStyles
390 
392  {
393  pStyle = new XMLGradientStyleContext( GetImport(), nElement, xAttrList );
394  break;
395  }
396  case XML_ELEMENT(DRAW, XML_HATCH):
397  {
398  pStyle = new XMLHatchStyleContext( GetImport(), nElement, xAttrList );
399  break;
400  }
402  {
403  pStyle = new XMLBitmapStyleContext( GetImport(), nElement, xAttrList );
404  break;
405  }
407  {
408  pStyle = new XMLTransGradientStyleContext( GetImport(), nElement, xAttrList );
409  break;
410  }
411  case XML_ELEMENT(DRAW, XML_MARKER):
412  {
413  pStyle = new XMLMarkerStyleContext( GetImport(), nElement, xAttrList );
414  break;
415  }
417  {
418  pStyle = new XMLDashStyleContext( GetImport(), nElement, xAttrList );
419  break;
420  }
421  }
422 
423  if (!pStyle)
424  SAL_WARN("xmloff", "Unknown element " << SvXMLImport::getPrefixAndNameFromToken(nElement));
425 
426  return pStyle;
427 }
428 
430  XmlStyleFamily nFamily, sal_Int32 /*nElement*/,
431  const uno::Reference< xml::sax::XFastAttributeList > & /*xAttrList*/ )
432 {
433  SvXMLStyleContext *pStyle = nullptr;
434 
435  switch( nFamily )
436  {
440  pStyle = new XMLTextStyleContext( GetImport(), *this, nFamily );
441  break;
442 
444  pStyle = new XMLPropStyleContext( GetImport(), *this, nFamily );
445  break;
447  pStyle = new XMLChartStyleContext( GetImport(), *this, nFamily );
448  break;
449 
453  pStyle = new XMLShapeStyleContext( GetImport(), *this, nFamily );
454  break;
455  default: break;
456  }
457 
458  return pStyle;
459 }
460 
462  XmlStyleFamily /*nFamily*/, sal_Int32 /*nElement*/,
463  const uno::Reference< xml::sax::XFastAttributeList > & )
464 {
465  return nullptr;
466 }
467 
469 {
470  return true;
471 }
472 
474 {
476  if( IsXMLToken( rValue, XML_PARAGRAPH ) )
477  {
479  }
480  else if( IsXMLToken( rValue, XML_TEXT ) )
481  {
482  nFamily = XmlStyleFamily::TEXT_TEXT;
483  }
484  else if( IsXMLToken( rValue, XML_DATA_STYLE ) )
485  {
486  nFamily = XmlStyleFamily::DATA_STYLE;
487  }
488  else if ( IsXMLToken( rValue, XML_SECTION ) )
489  {
491  }
492  else if( IsXMLToken( rValue, XML_TABLE ) )
493  {
494  nFamily = XmlStyleFamily::TABLE_TABLE;
495  }
496  else if( IsXMLToken( rValue, XML_TABLE_COLUMN ) )
498  else if( IsXMLToken( rValue, XML_TABLE_ROW ) )
499  nFamily = XmlStyleFamily::TABLE_ROW;
500  else if( IsXMLToken( rValue, XML_TABLE_CELL ) )
501  nFamily = XmlStyleFamily::TABLE_CELL;
502  else if ( rValue == XML_STYLE_FAMILY_SD_GRAPHICS_NAME )
503  {
505  }
506  else if ( rValue == XML_STYLE_FAMILY_SD_PRESENTATION_NAME )
507  {
509  }
510  else if ( rValue == XML_STYLE_FAMILY_SD_POOL_NAME )
511  {
512  nFamily = XmlStyleFamily::SD_POOL_ID;
513  }
514  else if ( rValue == XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME )
515  {
517  }
518  else if ( rValue == XML_STYLE_FAMILY_SCH_CHART_NAME )
519  {
521  }
522  else if ( IsXMLToken( rValue, XML_RUBY ) )
523  {
524  nFamily = XmlStyleFamily::TEXT_RUBY;
525  }
526 
527  return nFamily;
528 }
529 
531  XmlStyleFamily nFamily ) const
532 {
534 
535  switch( nFamily )
536  {
538  if( !mxParaImpPropMapper.is() )
539  {
540  SvXMLStylesContext * pThis = const_cast<SvXMLStylesContext *>(this);
541  pThis->mxParaImpPropMapper =
542  pThis->GetImport().GetTextImport()
543  ->GetParaImportPropertySetMapper();
544  }
545  xMapper = mxParaImpPropMapper;
546  break;
548  if( !mxTextImpPropMapper.is() )
549  {
550  SvXMLStylesContext * pThis = const_cast<SvXMLStylesContext *>(this);
551  pThis->mxTextImpPropMapper =
552  pThis->GetImport().GetTextImport()
553  ->GetTextImportPropertySetMapper();
554  }
555  xMapper = mxTextImpPropMapper;
556  break;
557 
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  GetSectionImportPropertySetMapper();
564  break;
565 
567  // don't cache section mapper, as it's rarely used
568  // *sigh*, cast to non-const, because this is a const method,
569  // but SvXMLImport::GetTextImport() isn't.
570  xMapper = const_cast<SvXMLStylesContext*>(this)->GetImport().GetTextImport()->
571  GetRubyImportPropertySetMapper();
572  break;
573 
577  if(!mxShapeImpPropMapper.is())
578  {
579  rtl::Reference< XMLShapeImportHelper > aImpHelper = const_cast<SvXMLImport&>(GetImport()).GetShapeImport();
580  const_cast<SvXMLStylesContext*>(this)->mxShapeImpPropMapper =
581  aImpHelper->GetPropertySetMapper();
582  }
583  xMapper = mxShapeImpPropMapper;
584  break;
586  if( ! mxChartImpPropMapper.is() )
587  {
588  XMLPropertySetMapper *const pPropMapper = new XMLChartPropertySetMapper(nullptr);
590  }
591  xMapper = mxChartImpPropMapper;
592  break;
594  if( ! mxPageImpPropMapper.is() )
595  {
596  XMLPropertySetMapper *pPropMapper =
599  new PageMasterImportPropertyMapper( pPropMapper,
600  const_cast<SvXMLStylesContext*>(this)->GetImport() );
601  }
602  xMapper = mxPageImpPropMapper;
603  break;
604  default: break;
605  }
606 
607  return xMapper;
608 }
609 
610 Reference < XAutoStyleFamily > SvXMLStylesContext::GetAutoStyles( XmlStyleFamily nFamily ) const
611 {
612  Reference < XAutoStyleFamily > xAutoStyles;
613  if( XmlStyleFamily::TEXT_TEXT == nFamily || XmlStyleFamily::TEXT_PARAGRAPH == nFamily)
614  {
615  bool bPara = XmlStyleFamily::TEXT_PARAGRAPH == nFamily;
616  if( !bPara && mxTextAutoStyles.is() )
617  xAutoStyles = mxTextAutoStyles;
618  else if( bPara && mxParaAutoStyles.is() )
619  xAutoStyles = mxParaAutoStyles;
620  else
621  {
622  OUStringLiteral sName = bPara ? OUStringLiteral( u"ParagraphStyles" ): OUStringLiteral( u"CharacterStyles" );
623  Reference< XAutoStylesSupplier > xAutoStylesSupp( GetImport().GetModel(), UNO_QUERY );
624  Reference< XAutoStyles > xAutoStyleFamilies = xAutoStylesSupp->getAutoStyles();
625  if (xAutoStyleFamilies->hasByName(sName))
626  {
627  Any aAny = xAutoStyleFamilies->getByName( sName );
628  aAny >>= xAutoStyles;
629  if( bPara )
630  const_cast<SvXMLStylesContext *>(this)->mxParaAutoStyles = xAutoStyles;
631  else
632  const_cast<SvXMLStylesContext *>(this)->mxTextAutoStyles = xAutoStyles;
633  }
634  }
635  }
636  return xAutoStyles;
637 }
638 
639 Reference < XNameContainer > SvXMLStylesContext::GetStylesContainer(
640  XmlStyleFamily nFamily ) const
641 {
642  Reference < XNameContainer > xStyles;
643  OUString sName;
644  switch( nFamily )
645  {
647  if( mxParaStyles.is() )
648  xStyles = mxParaStyles;
649  else
650  sName = "ParagraphStyles";
651  break;
652 
654  if( mxTextStyles.is() )
655  xStyles = mxTextStyles;
656  else
657  sName = "CharacterStyles";
658  break;
659  default: break;
660  }
661  if( !xStyles.is() && !sName.isEmpty() )
662  {
663  Reference< XStyleFamiliesSupplier > xFamiliesSupp(
664  GetImport().GetModel(), UNO_QUERY );
665  if ( xFamiliesSupp.is() )
666  {
667  Reference< XNameAccess > xFamilies = xFamiliesSupp->getStyleFamilies();
668  if (xFamilies->hasByName(sName))
669  {
670  xStyles.set(xFamilies->getByName( sName ),uno::UNO_QUERY);
671 
672  switch( nFamily )
673  {
675  const_cast<SvXMLStylesContext *>(this)->mxParaStyles = xStyles;
676  break;
677 
679  const_cast<SvXMLStylesContext *>(this)->mxTextStyles = xStyles;
680  break;
681  default: break;
682  }
683  }
684  }
685  }
686 
687  return xStyles;
688 }
689 
691 {
692  OUString sServiceName;
693  switch( nFamily )
694  {
696  sServiceName = gsParaStyleServiceName;
697  break;
699  sServiceName = gsTextStyleServiceName;
700  break;
701  default: break;
702  }
703 
704  return sServiceName;
705 }
706 
708  SvXMLImportContext( rImport ),
709  mpImpl( new SvXMLStylesContext_Impl( bAuto ) )
710 {
711 }
712 
714 {
715 }
716 
717 css::uno::Reference< css::xml::sax::XFastContextHandler > SvXMLStylesContext::createFastChildContext(
718  sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
719 {
720  SvXMLStyleContext *pStyle =
721  CreateStyleChildContext( nElement, xAttrList );
722  if( pStyle )
723  {
724  if( !pStyle->IsTransient() )
725  mpImpl->AddStyle( pStyle );
726  return pStyle;
727  }
728 
729  return nullptr;
730 }
731 
733 {
734  mpImpl->AddStyle( &rNew );
735 }
736 
738 {
739  mpImpl->dispose();
740 }
741 
743 {
744  sal_uInt32 nCount = GetStyleCount();
745  sal_uInt32 i;
746  for( i = 0; i < nCount; i++ )
747  {
748  SvXMLStyleContext *pStyle = GetStyle( i );
749  if( !pStyle || ( pStyle->GetFamily() != XmlStyleFamily::TEXT_TEXT &&
751  pStyle->GetFamily() != XmlStyleFamily::TABLE_CELL ) )
752  continue;
753  pStyle->CreateAndInsert( false );
754  }
755 }
756 
758  bool bFinish )
759 {
760  // pass 1: create text, paragraph and frame styles
761  sal_uInt32 nCount = GetStyleCount();
762  sal_uInt32 i;
763 
764  for( i = 0; i < nCount; i++ )
765  {
766  SvXMLStyleContext *pStyle = GetStyle( i );
767  if( !pStyle )
768  continue;
769 
770  if (pStyle->IsDefaultStyle())
771  {
772  if (bOverwrite) pStyle->SetDefaults();
773  }
774  else if( InsertStyleFamily( pStyle->GetFamily() ) )
775  pStyle->CreateAndInsert( bOverwrite );
776  }
777 
778  // pass 2: create list styles (they require char styles)
779  for( i=0; i<nCount; i++ )
780  {
781  SvXMLStyleContext *pStyle = GetStyle( i );
782  if( !pStyle || pStyle->IsDefaultStyle())
783  continue;
784 
785  if( InsertStyleFamily( pStyle->GetFamily() ) )
786  pStyle->CreateAndInsertLate( bOverwrite );
787  }
788 
789  // pass3: finish creation of styles
790  if( bFinish )
791  FinishStyles( bOverwrite );
792 }
793 
794 void SvXMLStylesContext::FinishStyles( bool bOverwrite )
795 {
796  sal_uInt32 nCount = GetStyleCount();
797  for( sal_uInt32 i=0; i<nCount; i++ )
798  {
799  SvXMLStyleContext *pStyle = GetStyle( i );
800  if( !pStyle || !pStyle->IsValid() || pStyle->IsDefaultStyle() )
801  continue;
802 
803  if( InsertStyleFamily( pStyle->GetFamily() ) )
804  pStyle->Finish( bOverwrite );
805  }
806 }
807 
809  XmlStyleFamily nFamily,
810  const OUString& rName,
811  bool bCreateIndex ) const
812 {
813  return mpImpl->FindStyleChildContext( nFamily, rName, bCreateIndex );
814 }
815 
816 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
css::uno::Reference< css::style::XAutoStyleFamily > mxTextAutoStyles
Definition: xmlstyle.hxx:134
virtual SvXMLStyleContext * CreateStyleChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Definition: xmlstyle.cxx:331
XmlStyleFamily GetFamily() const
Definition: xmlstyle.hxx:85
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3461
std::set< SvXMLStyleIndex_Impl, SvXMLStyleIndexCmp_Impl > IndicesType
Definition: xmlstyle.cxx:217
bool IsAutomaticStyle() const
Definition: xmlstyle.cxx:245
void CopyAutoStylesToDoc()
Definition: xmlstyle.cxx:742
OUString maParentName
Definition: xmlstyle.hxx:45
std::vector< rtl::Reference< SvXMLStyleContext > > aStyles
Definition: xmlstyle.cxx:219
rtl::Reference< SvXMLImportPropertyMapper > mxParaImpPropMapper
Definition: xmlstyle.hxx:136
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex) const
Definition: xmlstyle.cxx:273
size_t GetStyleCount() const
Definition: xmlstyle.cxx:232
css::uno::Reference< css::container::XNameContainer > mxParaStyles
Definition: xmlstyle.hxx:128
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:59
SvXMLStyleContext * GetStyle(sal_uInt32 i)
Definition: xmlstyle.cxx:316
css::uno::Reference< css::style::XAutoStyleFamily > GetAutoStyles(XmlStyleFamily nFamily) const
Definition: xmlstyle.cxx:610
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:393
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
bool IsDefaultStyle() const
Definition: xmlstyle.hxx:110
SvXMLNumFmtHelper * GetDataStylesImport()
Definition: xmlimp.hxx:649
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
SvXMLStyleContext * CreateChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, SvXMLStylesContext &rStyles)
Definition: xmlnumfi.cxx:2106
virtual ~SvXMLStyleContext() override
Definition: xmlstyle.cxx:122
void AddStyle(SvXMLStyleContext *pStyle)
Definition: xmlstyle.cxx:255
virtual ~SvXMLStylesContext() override
Definition: xmlstyle.cxx:713
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:597
#define XML_STYLE_FAMILY_SCH_CHART_NAME
Definition: families.hxx:43
virtual void Finish(bool bOverwrite)
Definition: xmlstyle.cxx:157
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
SvXMLStyleContext * GetStyle(size_t i)
Definition: xmlstyle.cxx:234
#define XML_STYLE_FAMILY_SD_PRESENTATION_NAME
Definition: families.hxx:38
bool IsAutomaticStyle() const
Definition: xmlstyle.cxx:326
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
XmlStyleFamily
Definition: families.hxx:47
static constexpr OUStringLiteral aNamespaceSeparator
Definition: xmlimp.hxx:530
sal_uInt32 m_nIndexCreated
Definition: xmlstyle.cxx:224
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: xmlstyle.cxx:717
DRAW
bool IsValid() const
Definition: xmlstyle.hxx:87
int nCount
static OUString getPrefixAndNameFromToken(sal_Int32 nToken)
Definition: xmlimp.cxx:1999
const char * sName
#define XML_STYLE_FAMILY_SD_GRAPHICS_NAME
Definition: families.hxx:36
const char * pS
OUString maDisplayName
Definition: xmlstyle.hxx:43
virtual rtl::Reference< SvXMLImportPropertyMapper > GetImportPropertyMapper(XmlStyleFamily nFamily) const
Definition: xmlstyle.cxx:530
#define XML_STYLE_FAMILY_SD_POOL_NAME
Definition: families.hxx:40
int i
SvXMLStylesContext_Impl(bool bAuto)
Definition: xmlstyle.cxx:248
void CopyStylesToDoc(bool bOverwrite, bool bFinish=true)
Definition: xmlstyle.cxx:757
std::unique_ptr< IndicesType > pIndices
Definition: xmlstyle.cxx:220
virtual SvXMLStyleContext * CreateDefaultStyleStyleChildContext(XmlStyleFamily nFamily, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Definition: xmlstyle.cxx:461
virtual bool IsTransient() const
if this method returns true, its parent styles context should not add it to its container.
Definition: xmlstyle.cxx:161
constexpr OUStringLiteral gsParaStyleServiceName(u"com.sun.star.style.ParagraphStyle")
rtl::Reference< SvXMLImportPropertyMapper > mxChartImpPropMapper
Definition: xmlstyle.hxx:139
float u
virtual void SetDefaults()
Definition: xmlstyle.cxx:145
constexpr OUStringLiteral gsTextStyleServiceName(u"com.sun.star.style.CharacterStyle")
static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap *pMap)
Definition: xmlimp.cxx:2009
std::unique_ptr< SvXMLStylesContext_Impl > mpImpl
Definition: xmlstyle.hxx:125
import footnote and endnote configuration elements
virtual bool InsertStyleFamily(XmlStyleFamily nFamily) const
Definition: xmlstyle.cxx:468
#define XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME
Definition: families.hxx:41
static const OUString & getNameFromToken(sal_Int32 nToken)
Definition: xmlimp.cxx:1994
virtual OUString GetServiceName(XmlStyleFamily nFamily) const
Definition: xmlstyle.cxx:690
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &) override
Definition: xmlstyle.cxx:126
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:45
SvXMLStyleContext(SvXMLImport &rImport, XmlStyleFamily nFamily=XmlStyleFamily::DATA_STYLE, bool bDefaultStyle=false)
Definition: xmlstyle.cxx:110
DefTokenId nToken
virtual void CreateAndInsert(bool bOverwrite)
Definition: xmlstyle.cxx:149
std::deque< AttacherIndex_Impl > aIndex
SvXMLStylesContext(SvXMLStylesContext const &)=delete
#define SAL_WARN_IF(condition, area, stream)
rtl::Reference< SvXMLImportPropertyMapper > mxTextImpPropMapper
Definition: xmlstyle.hxx:137
const OUString & GetName() const
Definition: xmlstyle.hxx:79
OUString maName
Definition: xmlstyle.hxx:42
Handling of tokens in XML:
XmlStyleFamily mnFamily
Definition: xmlstyle.hxx:49
OUString maFollow
Definition: xmlstyle.hxx:46
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:94
virtual SvXMLStyleContext * CreateStyleStyleChildContext(XmlStyleFamily nFamily, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Definition: xmlstyle.cxx:429
void AddStyle(SvXMLStyleContext &rNew)
Definition: xmlstyle.cxx:732
virtual void SetAttribute(sal_uInt16 nPrefixKey, const OUString &rLocalName, const OUString &rValue)
Definition: xmlstyle.cxx:65
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex=false) const
Definition: xmlstyle.cxx:808
css::uno::Reference< css::style::XAutoStyleFamily > mxParaAutoStyles
Definition: xmlstyle.hxx:132
#define SAL_WARN(area, stream)
static XmlStyleFamily GetFamily(const OUString &rFamily)
Definition: xmlstyle.cxx:473
const char sServiceName[]
if(!pCandidateA->getEnd().equal(pCandidateB->getStart()))
css::uno::Reference< css::container::XNameContainer > mxTextStyles
Definition: xmlstyle.hxx:130
virtual css::uno::Reference< css::container::XNameContainer > GetStylesContainer(XmlStyleFamily nFamily) const
Definition: xmlstyle.cxx:639
sal_uInt32 GetStyleCount() const
Definition: xmlstyle.cxx:311
rtl::Reference< SvXMLImportPropertyMapper > mxPageImpPropMapper
Definition: xmlstyle.hxx:140
rtl::Reference< SvXMLImportPropertyMapper > mxShapeImpPropMapper
Definition: xmlstyle.hxx:138
void FinishStyles(bool bOverwrite)
Definition: xmlstyle.cxx:794
TEXT
virtual void CreateAndInsertLate(bool bOverwrite)
Definition: xmlstyle.cxx:153
constexpr sal_uInt16 XML_NAMESPACE_STYLE
bool mbValid