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