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