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