xref: /AOO41X/main/xmloff/source/draw/ximpstyl.cxx (revision 24c56ab9f1bd1305754aa2f564704f38ff57627e)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 
27 
28 #include "ximpstyl.hxx"
29 #include <xmloff/XMLShapeStyleContext.hxx>
30 #include "xmloff/xmlnmspe.hxx"
31 #include <xmloff/xmltoken.hxx>
32 #include <xmloff/xmluconv.hxx>
33 #include "ximpnote.hxx"
34 #include <tools/debug.hxx>
35 
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
38 #include <com/sun/star/presentation/XPresentationPage.hpp>
39 #include <com/sun/star/drawing/XDrawPages.hpp>
40 #include <com/sun/star/container/XNamed.hpp>
41 #include <com/sun/star/beans/XPropertySet.hpp>
42 #include <com/sun/star/beans/XPropertyState.hpp>
43 #include <com/sun/star/presentation/XHandoutMasterSupplier.hpp>
44 #include <comphelper/namecontainer.hxx>
45 #include <xmloff/xmlprcon.hxx>
46 #include <xmloff/families.hxx>
47 #include <com/sun/star/container/XNameContainer.hpp>
48 #include <svl/zforlist.hxx>
49 #include "PropertySetMerger.hxx"
50 #include "sdpropls.hxx"
51 #include "layerimp.hxx"
52 #include <xmloff/XMLGraphicsDefaultStyle.hxx>
53 #include "XMLNumberStylesImport.hxx"
54 #include "xmloff/xmlerror.hxx"
55 
56 using ::rtl::OUString;
57 using ::rtl::OUStringBuffer;
58 
59 using namespace ::com::sun::star;
60 using namespace ::com::sun::star::uno;
61 using namespace ::com::sun::star::xml::sax;
62 using namespace ::xmloff::token;
63 
64 //////////////////////////////////////////////////////////////////////////////
65 
66 class SdXMLDrawingPagePropertySetContext : public SvXMLPropertySetContext
67 {
68 public:
69 
70     TYPEINFO();
71 
72     SdXMLDrawingPagePropertySetContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
73                 const ::rtl::OUString& rLName,
74                  const ::com::sun::star::uno::Reference<
75                         ::com::sun::star::xml::sax::XAttributeList >& xAttrList,
76                  ::std::vector< XMLPropertyState > &rProps,
77                  const UniReference < SvXMLImportPropertyMapper > &rMap );
78 
79     virtual ~SdXMLDrawingPagePropertySetContext();
80 
81     using SvXMLPropertySetContext::CreateChildContext;
82     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
83                                    const ::rtl::OUString& rLocalName,
84                                    const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList,
85                                    ::std::vector< XMLPropertyState > &rProperties,
86                                    const XMLPropertyState& rProp);
87 };
88 
89 TYPEINIT1( SdXMLDrawingPagePropertySetContext, SvXMLPropertySetContext );
90 
SdXMLDrawingPagePropertySetContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const uno::Reference<xml::sax::XAttributeList> & xAttrList,::std::vector<XMLPropertyState> & rProps,const UniReference<SvXMLImportPropertyMapper> & rMap)91 SdXMLDrawingPagePropertySetContext::SdXMLDrawingPagePropertySetContext(
92                  SvXMLImport& rImport, sal_uInt16 nPrfx,
93                  const OUString& rLName,
94                  const uno::Reference< xml::sax::XAttributeList > & xAttrList,
95                  ::std::vector< XMLPropertyState > &rProps,
96                  const UniReference < SvXMLImportPropertyMapper > &rMap ) :
97     SvXMLPropertySetContext( rImport, nPrfx, rLName, xAttrList,
98                              XML_TYPE_PROP_DRAWING_PAGE, rProps, rMap )
99 {
100 }
101 
~SdXMLDrawingPagePropertySetContext()102 SdXMLDrawingPagePropertySetContext::~SdXMLDrawingPagePropertySetContext()
103 {
104 }
105 
CreateChildContext(sal_uInt16 p_nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList,::std::vector<XMLPropertyState> & rProperties,const XMLPropertyState & rProp)106 SvXMLImportContext *SdXMLDrawingPagePropertySetContext::CreateChildContext(
107                    sal_uInt16 p_nPrefix,
108                    const OUString& rLocalName,
109                    const uno::Reference< xml::sax::XAttributeList > & xAttrList,
110                    ::std::vector< XMLPropertyState > &rProperties,
111                    const XMLPropertyState& rProp )
112 {
113     SvXMLImportContext *pContext = 0;
114 
115     switch( mxMapper->getPropertySetMapper()->GetEntryContextId( rProp.mnIndex ) )
116     {
117     case CTF_PAGE_SOUND_URL:
118     {
119         const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
120         for(sal_Int16 i=0; i < nAttrCount; i++)
121         {
122             OUString aLocalName;
123             sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(xAttrList->getNameByIndex(i), &aLocalName);
124 
125             if( (nPrefix == XML_NAMESPACE_XLINK) && IsXMLToken( aLocalName, XML_HREF ) )
126             {
127                 uno::Any aAny( GetImport().GetAbsoluteReference( xAttrList->getValueByIndex(i) ) );
128                 XMLPropertyState aPropState( rProp.mnIndex, aAny );
129                 rProperties.push_back( aPropState );
130             }
131         }
132         break;
133     }
134     }
135 
136     if( !pContext )
137         pContext = SvXMLPropertySetContext::CreateChildContext( p_nPrefix, rLocalName,
138                                                             xAttrList,
139                                                             rProperties, rProp );
140 
141     return pContext;
142 }
143 
144 //////////////////////////////////////////////////////////////////////////////
145 
146 class SdXMLDrawingPageStyleContext : public XMLPropStyleContext
147 {
148 public:
149     TYPEINFO();
150 
151     SdXMLDrawingPageStyleContext(
152         SvXMLImport& rImport,
153         sal_uInt16 nPrfx,
154         const rtl::OUString& rLName,
155         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList,
156         SvXMLStylesContext& rStyles,
157         sal_uInt16 nFamily = XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID);
158     virtual ~SdXMLDrawingPageStyleContext();
159 
160     SvXMLImportContext * CreateChildContext(
161         sal_uInt16 nPrefix,
162         const ::rtl::OUString& rLocalName,
163         const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
164 
165     virtual void Finish( sal_Bool bOverwrite );
166 
167     // #i35918#
168     virtual void FillPropertySet(
169             const ::com::sun::star::uno::Reference<
170                 ::com::sun::star::beans::XPropertySet > & rPropSet );
171 };
172 
173 TYPEINIT1( SdXMLDrawingPageStyleContext, XMLPropStyleContext );
174 
SdXMLDrawingPageStyleContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const uno::Reference<xml::sax::XAttributeList> & xAttrList,SvXMLStylesContext & rStyles,sal_uInt16 nFamily)175 SdXMLDrawingPageStyleContext::SdXMLDrawingPageStyleContext(
176     SvXMLImport& rImport,
177     sal_uInt16 nPrfx,
178     const OUString& rLName,
179     const uno::Reference< xml::sax::XAttributeList >& xAttrList,
180     SvXMLStylesContext& rStyles,
181     sal_uInt16 nFamily)
182 :   XMLPropStyleContext(rImport, nPrfx, rLName, xAttrList, rStyles, nFamily )
183 {
184 }
185 
~SdXMLDrawingPageStyleContext()186 SdXMLDrawingPageStyleContext::~SdXMLDrawingPageStyleContext()
187 {
188 }
189 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)190 SvXMLImportContext *SdXMLDrawingPageStyleContext::CreateChildContext(
191         sal_uInt16 nPrefix,
192         const OUString& rLocalName,
193         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
194 {
195     SvXMLImportContext *pContext = 0;
196 
197     if( XML_NAMESPACE_STYLE == nPrefix &&
198         IsXMLToken( rLocalName, XML_DRAWING_PAGE_PROPERTIES ) )
199     {
200         UniReference < SvXMLImportPropertyMapper > xImpPrMap =
201             GetStyles()->GetImportPropertyMapper( GetFamily() );
202         if( xImpPrMap.is() )
203             pContext = new SdXMLDrawingPagePropertySetContext( GetImport(), nPrefix,
204                                                     rLocalName, xAttrList,
205                                                     GetProperties(),
206                                                     xImpPrMap );
207     }
208 
209     if( !pContext )
210         pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName,
211                                                           xAttrList );
212 
213     return pContext;
214 }
215 
Finish(sal_Bool bOverwrite)216 void SdXMLDrawingPageStyleContext::Finish( sal_Bool bOverwrite )
217 {
218     XMLPropStyleContext::Finish( bOverwrite );
219 
220     ::std::vector< XMLPropertyState > &rProperties = GetProperties();
221 
222     const UniReference< XMLPropertySetMapper >& rImpPrMap = GetStyles()->GetImportPropertyMapper( GetFamily() )->getPropertySetMapper();
223 
224     ::std::vector< XMLPropertyState >::iterator property = rProperties.begin();
225     for(; property != rProperties.end(); property++)
226     {
227         if( property->mnIndex == -1 )
228             continue;
229 
230         sal_Int16 nContextID = rImpPrMap->GetEntryContextId(property->mnIndex);
231         switch( nContextID )
232         {
233             case CTF_DATE_TIME_FORMAT:
234             {
235                 OUString sStyleName;
236                 (*property).maValue >>= sStyleName;
237 
238                 sal_Int32 nStyle = 0;
239 
240                 SdXMLNumberFormatImportContext* pSdNumStyle =
241                     PTR_CAST( SdXMLNumberFormatImportContext,
242                         GetStyles()->FindStyleChildContext( XML_STYLE_FAMILY_DATA_STYLE, sStyleName, sal_True ) );
243 
244                 if( pSdNumStyle )
245                     nStyle = pSdNumStyle->GetDrawKey();
246 
247                 (*property).maValue <<= nStyle;
248             }
249             break;
250         }
251     }
252 
253 }
254 
255 // #i35918#
FillPropertySet(const Reference<beans::XPropertySet> & rPropSet)256 void SdXMLDrawingPageStyleContext::FillPropertySet(
257     const Reference< beans::XPropertySet > & rPropSet )
258 {
259     const sal_uInt16 MAX_SPECIAL_DRAW_STYLES = 7;
260     struct _ContextID_Index_Pair aContextIDs[MAX_SPECIAL_DRAW_STYLES+1] =
261     {
262         { CTF_DASHNAME , -1 },
263         { CTF_LINESTARTNAME , -1 },
264         { CTF_LINEENDNAME , -1 },
265         { CTF_FILLGRADIENTNAME, -1 },
266         { CTF_FILLTRANSNAME , -1 },
267         { CTF_FILLHATCHNAME , -1 },
268         { CTF_FILLBITMAPNAME , -1 },
269         { -1, -1 }
270     };
271     static sal_uInt16 aFamilies[MAX_SPECIAL_DRAW_STYLES] =
272     {
273         XML_STYLE_FAMILY_SD_STROKE_DASH_ID,
274         XML_STYLE_FAMILY_SD_MARKER_ID,
275         XML_STYLE_FAMILY_SD_MARKER_ID,
276         XML_STYLE_FAMILY_SD_GRADIENT_ID,
277         XML_STYLE_FAMILY_SD_GRADIENT_ID,
278         XML_STYLE_FAMILY_SD_HATCH_ID,
279         XML_STYLE_FAMILY_SD_FILL_IMAGE_ID
280     };
281 
282     UniReference < SvXMLImportPropertyMapper > xImpPrMap =
283         GetStyles()->GetImportPropertyMapper( GetFamily() );
284     DBG_ASSERT( xImpPrMap.is(), "There is the import prop mapper" );
285     if( xImpPrMap.is() )
286         xImpPrMap->FillPropertySet( GetProperties(), rPropSet, aContextIDs );
287 
288     Reference< beans::XPropertySetInfo > xInfo;
289     for( sal_uInt16 i=0; i<MAX_SPECIAL_DRAW_STYLES; i++ )
290     {
291         sal_Int32 nIndex = aContextIDs[i].nIndex;
292         if( nIndex != -1 )
293         {
294             struct XMLPropertyState& rState = GetProperties()[nIndex];
295             OUString sStyleName;
296             rState.maValue >>= sStyleName;
297             sStyleName = GetImport().GetStyleDisplayName( aFamilies[i],
298                                                           sStyleName );
299             // get property set mapper
300             UniReference<XMLPropertySetMapper> rPropMapper =
301                                         xImpPrMap->getPropertySetMapper();
302 
303             // set property
304             const OUString& rPropertyName =
305                     rPropMapper->GetEntryAPIName(rState.mnIndex);
306             if( !xInfo.is() )
307                 xInfo = rPropSet->getPropertySetInfo();
308             if ( xInfo->hasPropertyByName( rPropertyName ) )
309             {
310                 rPropSet->setPropertyValue( rPropertyName, Any( sStyleName ) );
311             }
312         }
313     }
314 }
315 
316 //////////////////////////////////////////////////////////////////////////////
317 
318 TYPEINIT1( SdXMLPageMasterStyleContext, SvXMLStyleContext );
319 
SdXMLPageMasterStyleContext(SdXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)320 SdXMLPageMasterStyleContext::SdXMLPageMasterStyleContext(
321     SdXMLImport& rImport,
322     sal_uInt16 nPrfx,
323     const OUString& rLName,
324     const uno::Reference< xml::sax::XAttributeList>& xAttrList)
325 :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList, XML_STYLE_FAMILY_SD_PAGEMASTERSTYLECONEXT_ID),
326     mnBorderBottom( 0L ),
327     mnBorderLeft( 0L ),
328     mnBorderRight( 0L ),
329     mnBorderTop( 0L ),
330     mnWidth( 0L ),
331     mnHeight( 0L ),
332     meOrientation(GetSdImport().IsDraw() ? view::PaperOrientation_PORTRAIT : view::PaperOrientation_LANDSCAPE)
333 {
334     // set family to something special at SvXMLStyleContext
335     // for differences in search-methods
336 
337     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
338     for(sal_Int16 i=0; i < nAttrCount; i++)
339     {
340         OUString sAttrName = xAttrList->getNameByIndex(i);
341         OUString aLocalName;
342         sal_uInt16 nPrefix = GetSdImport().GetNamespaceMap().GetKeyByAttrName(sAttrName, &aLocalName);
343         OUString sValue = xAttrList->getValueByIndex(i);
344         const SvXMLTokenMap& rAttrTokenMap = GetSdImport().GetPageMasterStyleAttrTokenMap();
345 
346         switch(rAttrTokenMap.Get(nPrefix, aLocalName))
347         {
348             case XML_TOK_PAGEMASTERSTYLE_MARGIN_TOP:
349             {
350                 GetSdImport().GetMM100UnitConverter().convertMeasure(mnBorderTop, sValue);
351                 break;
352             }
353             case XML_TOK_PAGEMASTERSTYLE_MARGIN_BOTTOM:
354             {
355                 GetSdImport().GetMM100UnitConverter().convertMeasure(mnBorderBottom, sValue);
356                 break;
357             }
358             case XML_TOK_PAGEMASTERSTYLE_MARGIN_LEFT:
359             {
360                 GetSdImport().GetMM100UnitConverter().convertMeasure(mnBorderLeft, sValue);
361                 break;
362             }
363             case XML_TOK_PAGEMASTERSTYLE_MARGIN_RIGHT:
364             {
365                 GetSdImport().GetMM100UnitConverter().convertMeasure(mnBorderRight, sValue);
366                 break;
367             }
368             case XML_TOK_PAGEMASTERSTYLE_PAGE_WIDTH:
369             {
370                 GetSdImport().GetMM100UnitConverter().convertMeasure(mnWidth, sValue);
371                 break;
372             }
373             case XML_TOK_PAGEMASTERSTYLE_PAGE_HEIGHT:
374             {
375                 GetSdImport().GetMM100UnitConverter().convertMeasure(mnHeight, sValue);
376                 break;
377             }
378             case XML_TOK_PAGEMASTERSTYLE_PAGE_ORIENTATION:
379             {
380                 if( IsXMLToken( sValue, XML_PORTRAIT ) )
381                     meOrientation = view::PaperOrientation_PORTRAIT;
382                 else
383                     meOrientation = view::PaperOrientation_LANDSCAPE;
384                 break;
385             }
386         }
387     }
388 }
389 
390 //////////////////////////////////////////////////////////////////////////////
391 
~SdXMLPageMasterStyleContext()392 SdXMLPageMasterStyleContext::~SdXMLPageMasterStyleContext()
393 {
394 }
395 
396 //////////////////////////////////////////////////////////////////////////////
397 //////////////////////////////////////////////////////////////////////////////
398 
399 TYPEINIT1( SdXMLPageMasterContext, SvXMLStyleContext );
400 
SdXMLPageMasterContext(SdXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)401 SdXMLPageMasterContext::SdXMLPageMasterContext(
402     SdXMLImport& rImport,
403     sal_uInt16 nPrfx,
404     const OUString& rLName,
405     const uno::Reference< xml::sax::XAttributeList>& xAttrList)
406 :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList, XML_STYLE_FAMILY_SD_PAGEMASTERCONEXT_ID),
407     mpPageMasterStyle( 0L )
408 {
409     // set family to something special at SvXMLStyleContext
410     // for differences in search-methods
411 
412     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
413     for(sal_Int16 i=0; i < nAttrCount; i++)
414     {
415         OUString sAttrName = xAttrList->getNameByIndex(i);
416         OUString aLocalName;
417         sal_uInt16 nPrefix = GetSdImport().GetNamespaceMap().GetKeyByAttrName(sAttrName, &aLocalName);
418         OUString sValue = xAttrList->getValueByIndex(i);
419         const SvXMLTokenMap& rAttrTokenMap = GetSdImport().GetPageMasterAttrTokenMap();
420 
421         switch(rAttrTokenMap.Get(nPrefix, aLocalName))
422         {
423             case XML_TOK_PAGEMASTER_NAME:
424             {
425                 msName = sValue;
426                 break;
427             }
428         }
429     }
430 }
431 
432 //////////////////////////////////////////////////////////////////////////////
433 
~SdXMLPageMasterContext()434 SdXMLPageMasterContext::~SdXMLPageMasterContext()
435 {
436     // release remembered contexts, they are no longer needed
437     if(mpPageMasterStyle)
438     {
439         mpPageMasterStyle->ReleaseRef();
440         mpPageMasterStyle = 0L;
441     }
442 }
443 
444 //////////////////////////////////////////////////////////////////////////////
445 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)446 SvXMLImportContext *SdXMLPageMasterContext::CreateChildContext(
447     sal_uInt16 nPrefix,
448     const OUString& rLocalName,
449     const uno::Reference< xml::sax::XAttributeList >& xAttrList )
450 {
451     SvXMLImportContext* pContext = 0;
452 
453     if(nPrefix == XML_NAMESPACE_STYLE && IsXMLToken( rLocalName, XML_PAGE_LAYOUT_PROPERTIES) )
454     {
455         pContext = new SdXMLPageMasterStyleContext(GetSdImport(), nPrefix, rLocalName, xAttrList);
456 
457         // remember SdXMLPresentationPlaceholderContext for later evaluation
458         if(pContext)
459         {
460             pContext->AddRef();
461             DBG_ASSERT(!mpPageMasterStyle, "PageMasterStyle is set, there seem to be two of them (!)");
462             mpPageMasterStyle = (SdXMLPageMasterStyleContext*)pContext;
463         }
464     }
465 
466     // call base class
467     if(!pContext)
468         pContext = SvXMLStyleContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
469 
470     return pContext;
471 }
472 
473 //////////////////////////////////////////////////////////////////////////////
474 //////////////////////////////////////////////////////////////////////////////
475 
476 TYPEINIT1( SdXMLPresentationPageLayoutContext, SvXMLStyleContext );
477 
SdXMLPresentationPageLayoutContext(SdXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)478 SdXMLPresentationPageLayoutContext::SdXMLPresentationPageLayoutContext(
479     SdXMLImport& rImport,
480     sal_uInt16 nPrfx,
481     const OUString& rLName,
482     const uno::Reference< xml::sax::XAttributeList >& xAttrList)
483 :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList, XML_STYLE_FAMILY_SD_PRESENTATIONPAGELAYOUT_ID),
484     mnTypeId( 20 ) // AUTOLAYOUT_NONE
485 {
486     // set family to somethiong special at SvXMLStyleContext
487     // for differences in search-methods
488 
489     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
490     for( sal_Int16 i=0; i < nAttrCount; i++ )
491     {
492         const OUString& rAttrName = xAttrList->getNameByIndex( i );
493         OUString aLocalName;
494         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName );
495 
496         if(nPrefix == XML_NAMESPACE_STYLE && IsXMLToken( aLocalName, XML_NAME ) )
497         {
498             msName = xAttrList->getValueByIndex( i );
499         }
500     }
501 }
502 
~SdXMLPresentationPageLayoutContext()503 SdXMLPresentationPageLayoutContext::~SdXMLPresentationPageLayoutContext()
504 {
505 }
506 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)507 SvXMLImportContext *SdXMLPresentationPageLayoutContext::CreateChildContext(
508     sal_uInt16 nPrefix,
509     const OUString& rLocalName,
510     const uno::Reference< xml::sax::XAttributeList >& xAttrList )
511 {
512     SvXMLImportContext* pContext = 0;
513 
514     if(nPrefix == XML_NAMESPACE_PRESENTATION && IsXMLToken( rLocalName, XML_PLACEHOLDER ) )
515     {
516         // presentation:placeholder inside style:presentation-page-layout context
517         pContext = new SdXMLPresentationPlaceholderContext(
518             GetSdImport(), nPrefix, rLocalName, xAttrList);
519 
520         // remember SdXMLPresentationPlaceholderContext for later evaluation
521         if(pContext)
522         {
523             pContext->AddRef();
524             maList.Insert((SdXMLPresentationPlaceholderContext*)pContext, LIST_APPEND);
525         }
526     }
527 
528     // call base class
529     if(!pContext)
530         pContext = SvXMLStyleContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
531 
532     return pContext;
533 }
534 
EndElement()535 void SdXMLPresentationPageLayoutContext::EndElement()
536 {
537     // build presentation page layout type here
538     // calc mnTpeId due to content of maList
539     // at the moment only use number of types used there
540     if(maList.Count())
541     {
542         SdXMLPresentationPlaceholderContext* pObj0 = maList.GetObject(0);
543         if(pObj0->GetName().equals(OUString(RTL_CONSTASCII_USTRINGPARAM("handout"))))
544         {
545             switch( maList.Count() )
546             {
547             case 1:
548                 mnTypeId = 22; // AUTOLAYOUT_HANDOUT1
549                 break;
550             case 2:
551                 mnTypeId = 23; // AUTOLAYOUT_HANDOUT2
552                 break;
553             case 3:
554                 mnTypeId = 24; // AUTOLAYOUT_HANDOUT3
555                 break;
556             case 4:
557                 mnTypeId = 25; // AUTOLAYOUT_HANDOUT4
558                 break;
559             case 9:
560                 mnTypeId = 31; // AUTOLAYOUT_HANDOUT9
561                 break;
562             default:
563                 mnTypeId = 26; // AUTOLAYOUT_HANDOUT6
564             }
565         }
566         else
567         {
568             switch(maList.Count())
569             {
570                 case 1:
571                 {
572                     if(pObj0->GetName().equals(OUString(RTL_CONSTASCII_USTRINGPARAM("title"))))
573                     {
574                         mnTypeId = 19; // AUTOLAYOUT_ONLY_TITLE
575                     }
576                     else
577                     {
578                         mnTypeId = 32; // AUTOLAYOUT_ONLY_TEXT
579                     }
580                     break;
581                 }
582                 case 2:
583                 {
584                     SdXMLPresentationPlaceholderContext* pObj1 = maList.GetObject(1);
585 
586                     if(pObj1->GetName().equals(
587                         OUString(RTL_CONSTASCII_USTRINGPARAM("subtitle"))))
588                     {
589                         mnTypeId = 0; // AUTOLAYOUT_TITLE
590                     }
591                     else if(pObj1->GetName().equals(
592                         OUString(RTL_CONSTASCII_USTRINGPARAM("outline"))))
593                     {
594                         mnTypeId = 1; // AUTOLAYOUT_ENUM
595                     }
596                     else if(pObj1->GetName().equals(
597                         OUString(RTL_CONSTASCII_USTRINGPARAM("chart"))))
598                     {
599                         mnTypeId = 2; // AUTOLAYOUT_CHART
600                     }
601                     else if(pObj1->GetName().equals(
602                         OUString(RTL_CONSTASCII_USTRINGPARAM("table"))))
603                     {
604                         mnTypeId = 8; // AUTOLAYOUT_TAB
605                     }
606                     else if(pObj1->GetName().equals(
607                         OUString(RTL_CONSTASCII_USTRINGPARAM("object"))))
608                     {
609                         mnTypeId = 11; // AUTOLAYOUT_OBJ
610                     }
611                     else if(pObj1->GetName().equals(
612                         OUString(RTL_CONSTASCII_USTRINGPARAM("vertical_outline"))))
613                     {
614                         if(pObj0->GetName().equals(OUString(RTL_CONSTASCII_USTRINGPARAM("vertical_title"))))
615                         {
616                             // AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE
617                             mnTypeId = 28;
618                         }
619                         else
620                         {
621                             // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE
622                             mnTypeId = 29;
623                         }
624                     }
625                     else
626                     {
627                         mnTypeId = 21; // AUTOLAYOUT_NOTES
628                     }
629                     break;
630                 }
631                 case 3:
632                 {
633                     SdXMLPresentationPlaceholderContext* pObj1 = maList.GetObject(1);
634                     SdXMLPresentationPlaceholderContext* pObj2 = maList.GetObject(2);
635 
636                     if(pObj1->GetName().equals(
637                         OUString(RTL_CONSTASCII_USTRINGPARAM("outline"))))
638                     {
639                         if(pObj2->GetName().equals(
640                             OUString(RTL_CONSTASCII_USTRINGPARAM("outline"))))
641                         {
642                             mnTypeId = 3; // AUTOLAYOUT_2TEXT
643                         }
644                         else if(pObj2->GetName().equals(
645                             OUString(RTL_CONSTASCII_USTRINGPARAM("chart"))))
646                         {
647                             mnTypeId = 4; // AUTOLAYOUT_TEXTCHART
648                         }
649                         else if(pObj2->GetName().equals(
650                             OUString(RTL_CONSTASCII_USTRINGPARAM("graphic"))))
651                         {
652                             mnTypeId = 6; // AUTOLAYOUT_TEXTCLIP
653                         }
654                         else
655                         {
656                             if(pObj1->GetX() < pObj2->GetX())
657                             {
658                                 mnTypeId = 10; // AUTOLAYOUT_TEXTOBJ -> outline left, object right
659                             }
660                             else
661                             {
662                                 mnTypeId = 17; // AUTOLAYOUT_TEXTOVEROBJ -> outline top, object right
663                             }
664                         }
665                     }
666                     else if(pObj1->GetName().equals(
667                         OUString(RTL_CONSTASCII_USTRINGPARAM("chart"))))
668                     {
669                         mnTypeId = 7; // AUTOLAYOUT_CHARTTEXT
670                     }
671                     else if(pObj1->GetName().equals(
672                         OUString(RTL_CONSTASCII_USTRINGPARAM("graphic"))))
673                     {
674                         if(pObj2->GetName().equals(OUString(RTL_CONSTASCII_USTRINGPARAM("vertical_outline"))))
675                         {
676                             // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART
677                             mnTypeId = 30;
678                         }
679                         else
680                         {
681                             mnTypeId = 9; // AUTOLAYOUT_CLIPTEXT
682                         }
683                     }
684                     else if(pObj1->GetName().equals(
685                         OUString(RTL_CONSTASCII_USTRINGPARAM("vertical_outline"))))
686                     {
687                         // AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART
688                         mnTypeId = 27;
689                     }
690                     else
691                     {
692                         if(pObj1->GetX() < pObj2->GetX())
693                         {
694                             mnTypeId = 13; // AUTOLAYOUT_OBJTEXT -> left, right
695                         }
696                         else
697                         {
698                             mnTypeId = 14; // AUTOLAYOUT_OBJOVERTEXT -> top, bottom
699                         }
700                     }
701                     break;
702                 }
703                 case 4:
704                 {
705                     SdXMLPresentationPlaceholderContext* pObj1 = maList.GetObject(1);
706                     SdXMLPresentationPlaceholderContext* pObj2 = maList.GetObject(2);
707 
708                     if(pObj1->GetName().equals(
709                         OUString(RTL_CONSTASCII_USTRINGPARAM("object"))))
710                     {
711                         if(pObj1->GetX() < pObj2->GetX())
712                         {
713                             mnTypeId = 16; // AUTOLAYOUT_2OBJOVERTEXT
714                         }
715                         else
716                         {
717                             mnTypeId = 15; // AUTOLAYOUT_2OBJTEXT
718                         }
719                     }
720                     else
721                     {
722                         mnTypeId = 12; // AUTOLAYOUT_TEXT2OBJ
723                     }
724                     break;
725                 }
726                 case 5:
727                 {
728                     SdXMLPresentationPlaceholderContext* pObj1 = maList.GetObject(1);
729 
730                     if(pObj1->GetName().equals(
731                         OUString(RTL_CONSTASCII_USTRINGPARAM("object"))))
732                     {
733                         mnTypeId = 18; // AUTOLAYOUT_4OBJ
734                     }
735                     else
736                     {
737                         mnTypeId = 33; // AUTOLAYOUT_4CLIPART
738                     }
739                     break;
740 
741                 }
742                 case 7:
743                 {
744                     mnTypeId = 33; // AUTOLAYOUT_6CLIPART
745                     break;
746                 }
747                 default:
748                 {
749                     mnTypeId = 20; // AUTOLAYOUT_NONE
750                     break;
751                 }
752             }
753         }
754 
755         // release remembered contexts, they are no longer needed
756         while(maList.Count())
757             maList.Remove(maList.Count() - 1)->ReleaseRef();
758     }
759 }
760 
761 //////////////////////////////////////////////////////////////////////////////
762 //////////////////////////////////////////////////////////////////////////////
763 
SdXMLPresentationPlaceholderContext(SdXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)764 SdXMLPresentationPlaceholderContext::SdXMLPresentationPlaceholderContext(
765     SdXMLImport& rImport,
766     sal_uInt16 nPrfx, const
767     OUString& rLName,
768     const uno::Reference< xml::sax::XAttributeList>& xAttrList)
769 :   SvXMLImportContext( rImport, nPrfx, rLName),
770     mnX(0L),
771     mnY(0L),
772     mnWidth(1L),
773     mnHeight(1L)
774 {
775     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
776     for(sal_Int16 i=0; i < nAttrCount; i++)
777     {
778         OUString sAttrName = xAttrList->getNameByIndex(i);
779         OUString aLocalName;
780         sal_uInt16 nPrefix = GetSdImport().GetNamespaceMap().GetKeyByAttrName(sAttrName, &aLocalName);
781         OUString sValue = xAttrList->getValueByIndex(i);
782         const SvXMLTokenMap& rAttrTokenMap = GetSdImport().GetPresentationPlaceholderAttrTokenMap();
783 
784         switch(rAttrTokenMap.Get(nPrefix, aLocalName))
785         {
786             case XML_TOK_PRESENTATIONPLACEHOLDER_OBJECTNAME:
787             {
788                 msName = sValue;
789                 break;
790             }
791             case XML_TOK_PRESENTATIONPLACEHOLDER_X:
792             {
793                 GetSdImport().GetMM100UnitConverter().convertMeasure(mnX, sValue);
794                 break;
795             }
796             case XML_TOK_PRESENTATIONPLACEHOLDER_Y:
797             {
798                 GetSdImport().GetMM100UnitConverter().convertMeasure(mnY, sValue);
799                 break;
800             }
801             case XML_TOK_PRESENTATIONPLACEHOLDER_WIDTH:
802             {
803                 GetSdImport().GetMM100UnitConverter().convertMeasure(mnWidth, sValue);
804                 break;
805             }
806             case XML_TOK_PRESENTATIONPLACEHOLDER_HEIGHT:
807             {
808                 GetSdImport().GetMM100UnitConverter().convertMeasure(mnHeight, sValue);
809                 break;
810             }
811         }
812     }
813 }
814 
815 //////////////////////////////////////////////////////////////////////////////
816 
~SdXMLPresentationPlaceholderContext()817 SdXMLPresentationPlaceholderContext::~SdXMLPresentationPlaceholderContext()
818 {
819 }
820 
821 //////////////////////////////////////////////////////////////////////////////
822 //////////////////////////////////////////////////////////////////////////////
823 
824 TYPEINIT1( SdXMLMasterPageContext, SdXMLGenericPageContext );
825 
SdXMLMasterPageContext(SdXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const uno::Reference<xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes)826 SdXMLMasterPageContext::SdXMLMasterPageContext(
827     SdXMLImport& rImport,
828     sal_uInt16 nPrfx,
829     const OUString& rLName,
830     const uno::Reference< xml::sax::XAttributeList>& xAttrList,
831     uno::Reference< drawing::XShapes >& rShapes)
832 :   SdXMLGenericPageContext( rImport, nPrfx, rLName, xAttrList, rShapes )
833 {
834     const sal_Bool bHandoutMaster = IsXMLToken( rLName, XML_HANDOUT_MASTER );
835 
836     const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
837     for(sal_Int16 i=0; i < nAttrCount; i++)
838     {
839         OUString sAttrName = xAttrList->getNameByIndex( i );
840         OUString aLocalName;
841         sal_uInt16 nPrefix = GetSdImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
842         OUString sValue = xAttrList->getValueByIndex( i );
843         const SvXMLTokenMap& rAttrTokenMap = GetSdImport().GetMasterPageAttrTokenMap();
844 
845         switch(rAttrTokenMap.Get(nPrefix, aLocalName))
846         {
847             case XML_TOK_MASTERPAGE_NAME:
848             {
849                 msName = sValue;
850                 break;
851             }
852             case XML_TOK_MASTERPAGE_DISPLAY_NAME:
853             {
854                 msDisplayName = sValue;
855                 break;
856             }
857             case XML_TOK_MASTERPAGE_PAGE_MASTER_NAME:
858             {
859                 msPageMasterName = sValue;
860                 break;
861             }
862             case XML_TOK_MASTERPAGE_STYLE_NAME:
863             {
864                 msStyleName = sValue;
865                 break;
866             }
867             case XML_TOK_MASTERPAGE_PAGE_LAYOUT_NAME:
868             {
869                 maPageLayoutName = sValue;
870                 break;
871             }
872             case XML_TOK_MASTERPAGE_USE_HEADER_NAME:
873             {
874                 maUseHeaderDeclName =  sValue;
875                 break;
876             }
877             case XML_TOK_MASTERPAGE_USE_FOOTER_NAME:
878             {
879                 maUseFooterDeclName =  sValue;
880                 break;
881             }
882             case XML_TOK_MASTERPAGE_USE_DATE_TIME_NAME:
883             {
884                 maUseDateTimeDeclName =  sValue;
885                 break;
886             }
887         }
888     }
889 
890     if( !msDisplayName.getLength() )
891         msDisplayName = msName;
892     else if( msDisplayName != msName )
893         GetImport().AddStyleDisplayName( XML_STYLE_FAMILY_MASTER_PAGE, msName, msDisplayName );
894 
895     GetImport().GetShapeImport()->startPage( GetLocalShapesContext() );
896 
897     // set page name?
898     if(!bHandoutMaster && msDisplayName.getLength() && GetLocalShapesContext().is())
899     {
900         uno::Reference < container::XNamed > xNamed(GetLocalShapesContext(), uno::UNO_QUERY);
901         if(xNamed.is())
902             xNamed->setName(msDisplayName);
903     }
904 
905     // set page-master?
906     if(msPageMasterName.getLength())
907     {
908         SetPageMaster( msPageMasterName );
909     }
910 
911     SetStyle( msStyleName );
912 
913     SetLayout();
914 
915     DeleteAllShapes();
916 }
917 
918 //////////////////////////////////////////////////////////////////////////////
919 
~SdXMLMasterPageContext()920 SdXMLMasterPageContext::~SdXMLMasterPageContext()
921 {
922 }
923 
924 //////////////////////////////////////////////////////////////////////////////
925 
EndElement()926 void SdXMLMasterPageContext::EndElement()
927 {
928     // set styles on master-page
929     if(msName.getLength() && GetSdImport().GetShapeImport()->GetStylesContext())
930     {
931         SvXMLImportContext* pContext = GetSdImport().GetShapeImport()->GetStylesContext();
932         if( pContext && pContext->ISA( SvXMLStyleContext ) )
933             ((SdXMLStylesContext*)pContext)->SetMasterPageStyles(*this);
934     }
935 
936     SdXMLGenericPageContext::EndElement();
937     GetImport().GetShapeImport()->endPage(GetLocalShapesContext());
938 }
939 
940 //////////////////////////////////////////////////////////////////////////////
941 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)942 SvXMLImportContext* SdXMLMasterPageContext::CreateChildContext(
943     sal_uInt16 nPrefix,
944     const OUString& rLocalName,
945     const uno::Reference< xml::sax::XAttributeList>& xAttrList )
946 {
947     SvXMLImportContext* pContext = 0;
948     const SvXMLTokenMap& rTokenMap = GetSdImport().GetMasterPageElemTokenMap();
949 
950     // some special objects inside style:masterpage context
951     switch(rTokenMap.Get(nPrefix, rLocalName))
952     {
953         case XML_TOK_MASTERPAGE_STYLE:
954         {
955             if(GetSdImport().GetShapeImport()->GetStylesContext())
956             {
957                 // style:style inside master-page context -> presentation style
958                 XMLShapeStyleContext* pNew = new XMLShapeStyleContext(
959                     GetSdImport(), nPrefix, rLocalName, xAttrList,
960                     *GetSdImport().GetShapeImport()->GetStylesContext(),
961                     XML_STYLE_FAMILY_SD_PRESENTATION_ID);
962 
963                 // add this style to the outer StylesContext class for later processing
964                 if(pNew)
965                 {
966                     pContext = pNew;
967                     GetSdImport().GetShapeImport()->GetStylesContext()->AddStyle(*pNew);
968                 }
969             }
970             break;
971         }
972         case XML_TOK_MASTERPAGE_NOTES:
973         {
974             if( GetSdImport().IsImpress() )
975             {
976                 // get notes page
977                 uno::Reference< presentation::XPresentationPage > xPresPage(GetLocalShapesContext(), uno::UNO_QUERY);
978                 if(xPresPage.is())
979                 {
980                     uno::Reference< drawing::XDrawPage > xNotesDrawPage(xPresPage->getNotesPage(), uno::UNO_QUERY);
981                     if(xNotesDrawPage.is())
982                     {
983                         uno::Reference< drawing::XShapes > xNewShapes(xNotesDrawPage, uno::UNO_QUERY);
984                         if(xNewShapes.is())
985                         {
986                             // presentation:notes inside master-page context
987                             pContext = new SdXMLNotesContext( GetSdImport(), nPrefix, rLocalName, xAttrList, xNewShapes);
988                         }
989                     }
990                 }
991             }
992         }
993     }
994 
995     // call base class
996     if(!pContext)
997         pContext = SdXMLGenericPageContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
998 
999     return pContext;
1000 }
1001 
1002 //////////////////////////////////////////////////////////////////////////////
1003 //////////////////////////////////////////////////////////////////////////////
1004 
1005 TYPEINIT1( SdXMLStylesContext, SvXMLStyleContext );
1006 
SdXMLStylesContext(SdXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const uno::Reference<xml::sax::XAttributeList> & xAttrList,sal_Bool bIsAutoStyle)1007 SdXMLStylesContext::SdXMLStylesContext(
1008     SdXMLImport& rImport,
1009     sal_uInt16 nPrfx,
1010     const OUString& rLName,
1011     const uno::Reference< xml::sax::XAttributeList >& xAttrList,
1012     sal_Bool bIsAutoStyle)
1013 :   SvXMLStylesContext(rImport, nPrfx, rLName, xAttrList),
1014     mbIsAutoStyle(bIsAutoStyle)
1015 {
1016     // #110680#
1017     // Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
1018     Reference< lang::XMultiServiceFactory > xMSF = rImport.getServiceFactory();
1019 
1020     mpNumFormatter = new SvNumberFormatter( xMSF, LANGUAGE_SYSTEM );
1021 
1022     // #110680#
1023     // mpNumFmtHelper = new SvXMLNumFmtHelper( mpNumFormatter );
1024     mpNumFmtHelper = new SvXMLNumFmtHelper( mpNumFormatter, xMSF );
1025 }
1026 
1027 //////////////////////////////////////////////////////////////////////////////
1028 
~SdXMLStylesContext()1029 SdXMLStylesContext::~SdXMLStylesContext()
1030 {
1031     delete mpNumFmtHelper;
1032     delete mpNumFormatter;
1033 }
1034 
1035 //////////////////////////////////////////////////////////////////////////////
1036 
CreateStyleChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)1037 SvXMLStyleContext* SdXMLStylesContext::CreateStyleChildContext(
1038     sal_uInt16 nPrefix,
1039     const OUString& rLocalName,
1040     const uno::Reference< xml::sax::XAttributeList >& xAttrList)
1041 {
1042     SvXMLStyleContext* pContext = 0;
1043     const SvXMLTokenMap& rStyleTokenMap = GetSdImport().GetStylesElemTokenMap();
1044 
1045     switch(rStyleTokenMap.Get(nPrefix, rLocalName))
1046     {
1047         case XML_TOK_STYLES_PAGE_MASTER:
1048         {
1049             // style:page-master inside office:styles context
1050             pContext = new SdXMLPageMasterContext(GetSdImport(), nPrefix, rLocalName, xAttrList);
1051             break;
1052         }
1053         case XML_TOK_STYLES_PRESENTATION_PAGE_LAYOUT:
1054         {
1055             // style:presentation-page-layout inside office:styles context
1056             pContext = new SdXMLPresentationPageLayoutContext(GetSdImport(), nPrefix, rLocalName, xAttrList);
1057             break;
1058         }
1059     }
1060 
1061     if(!pContext)
1062     {
1063         const SvXMLTokenMap& rTokenMap = mpNumFmtHelper->GetStylesElemTokenMap();
1064         sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
1065         switch (nToken)
1066         {
1067             case XML_TOK_STYLES_DATE_STYLE:
1068             case XML_TOK_STYLES_TIME_STYLE:
1069                 // number:date-style or number:time-style
1070                 pContext = new SdXMLNumberFormatImportContext( GetSdImport(), nPrefix, rLocalName, mpNumFmtHelper->getData(), nToken, xAttrList, *this );
1071                 break;
1072 
1073             case XML_TOK_STYLES_NUMBER_STYLE:
1074             case XML_TOK_STYLES_CURRENCY_STYLE:
1075             case XML_TOK_STYLES_PERCENTAGE_STYLE:
1076             case XML_TOK_STYLES_BOOLEAN_STYLE:
1077             case XML_TOK_STYLES_TEXT_STYLE:
1078                 pContext = new SvXMLNumFormatContext( GetSdImport(), nPrefix, rLocalName,
1079                                                         mpNumFmtHelper->getData(), nToken, xAttrList, *this );
1080                 break;
1081         }
1082     }
1083 
1084     if(!pContext && nPrefix == XML_NAMESPACE_PRESENTATION )
1085     {
1086         if( IsXMLToken( rLocalName, XML_HEADER_DECL ) ||
1087             IsXMLToken( rLocalName, XML_FOOTER_DECL ) ||
1088             IsXMLToken( rLocalName, XML_DATE_TIME_DECL ) )
1089         {
1090             pContext = new SdXMLHeaderFooterDeclContext( GetImport(), nPrefix, rLocalName, xAttrList );
1091         }
1092     }
1093 
1094     if(!pContext && (nPrefix == XML_NAMESPACE_TABLE) && IsXMLToken( rLocalName, XML_TABLE_TEMPLATE ) )
1095     {
1096         pContext = GetImport().GetShapeImport()->GetShapeTableImport()->CreateTableTemplateContext(nPrefix, rLocalName, xAttrList );
1097     }
1098 
1099     // call base class
1100     if(!pContext)
1101         pContext = SvXMLStylesContext::CreateStyleChildContext(nPrefix, rLocalName, xAttrList);
1102 
1103     return pContext;
1104 }
1105 
1106 //////////////////////////////////////////////////////////////////////////////
1107 
CreateStyleStyleChildContext(sal_uInt16 nFamily,sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList)1108 SvXMLStyleContext* SdXMLStylesContext::CreateStyleStyleChildContext(
1109     sal_uInt16 nFamily,
1110     sal_uInt16 nPrefix,
1111     const OUString& rLocalName,
1112     const uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList)
1113 {
1114     SvXMLStyleContext* pContext = 0;
1115 
1116     switch( nFamily )
1117     {
1118     case XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID:
1119         pContext = new SdXMLDrawingPageStyleContext(GetSdImport(), nPrefix, rLocalName, xAttrList, *this );
1120         break;
1121     case XML_STYLE_FAMILY_TABLE_CELL:
1122     case XML_STYLE_FAMILY_TABLE_COLUMN:
1123     case XML_STYLE_FAMILY_TABLE_ROW:
1124         pContext = new XMLShapeStyleContext( GetSdImport(), nPrefix, rLocalName, xAttrList, *this, nFamily );
1125         break;
1126     }
1127 
1128     // call base class
1129     if(!pContext)
1130         pContext = SvXMLStylesContext::CreateStyleStyleChildContext(nFamily, nPrefix, rLocalName, xAttrList);
1131 
1132     return pContext;
1133 }
1134 
1135 //////////////////////////////////////////////////////////////////////////////
1136 
CreateDefaultStyleStyleChildContext(sal_uInt16 nFamily,sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<XAttributeList> & xAttrList)1137 SvXMLStyleContext* SdXMLStylesContext::CreateDefaultStyleStyleChildContext(
1138     sal_uInt16 nFamily,
1139     sal_uInt16 nPrefix,
1140     const OUString& rLocalName,
1141     const Reference< XAttributeList > & xAttrList )
1142 {
1143     SvXMLStyleContext* pContext = 0;
1144 
1145     switch( nFamily )
1146     {
1147     case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
1148         pContext = new XMLGraphicsDefaultStyle(GetSdImport(), nPrefix, rLocalName, xAttrList, *this );
1149         break;
1150     }
1151 
1152     // call base class
1153     if(!pContext)
1154         pContext = SvXMLStylesContext::CreateDefaultStyleStyleChildContext(nFamily, nPrefix, rLocalName, xAttrList);
1155 
1156     return pContext;
1157 }
1158 
1159 //////////////////////////////////////////////////////////////////////////////
1160 
GetFamily(const OUString & rFamily) const1161 sal_uInt16 SdXMLStylesContext::GetFamily( const OUString& rFamily ) const
1162 {
1163 //  if(rFamily.getLength())
1164 //  {
1165 //      if(rFamily.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME))))
1166 //          return XML_STYLE_FAMILY_SD_GRAPHICS_ID;
1167 //
1168 //      if(rFamily.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_PRESENTATION_NAME))))
1169 //          return XML_STYLE_FAMILY_SD_PRESENTATION_ID;
1170 //
1171 //      if(rFamily.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_POOL_NAME))))
1172 //          return XML_STYLE_FAMILY_SD_POOL_ID;
1173 //
1174 //      if(rFamily.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME))))
1175 //          return XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID;
1176 //  }
1177 
1178     // call base class
1179     return SvXMLStylesContext::GetFamily(rFamily);
1180 }
1181 
1182 //////////////////////////////////////////////////////////////////////////////
1183 
GetImportPropertyMapper(sal_uInt16 nFamily) const1184 UniReference< SvXMLImportPropertyMapper > SdXMLStylesContext::GetImportPropertyMapper(
1185     sal_uInt16 nFamily) const
1186 {
1187     UniReference < SvXMLImportPropertyMapper > xMapper;
1188 
1189 //  if(XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily
1190 //      || XML_STYLE_FAMILY_SD_PRESENTATION_ID == nFamily
1191 //      || XML_STYLE_FAMILY_SD_POOL_ID == nFamily)
1192 //  {
1193 //      if(!xPropImpPropMapper.is())
1194 //      {
1195 //          UniReference< XMLShapeImportHelper > aImpHelper = ((SvXMLImport&)GetImport()).GetShapeImport();
1196 //          ((SdXMLStylesContext*)this)->xPropImpPropMapper =
1197 //              new SvXMLImportPropertyMapper(aImpHelper->GetPropertySetMapper());
1198 //      }
1199 //      xMapper = xPropImpPropMapper;
1200 //      return xMapper;
1201 //  }
1202 
1203     switch( nFamily )
1204     {
1205     case XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID:
1206     {
1207         if(!xPresImpPropMapper.is())
1208         {
1209             UniReference< XMLShapeImportHelper > aImpHelper = ((SvXMLImport&)GetImport()).GetShapeImport();
1210             ((SdXMLStylesContext*)this)->xPresImpPropMapper =
1211                 aImpHelper->GetPresPagePropsMapper();
1212         }
1213         xMapper = xPresImpPropMapper;
1214         break;
1215     }
1216 
1217     case XML_STYLE_FAMILY_TABLE_COLUMN:
1218     case XML_STYLE_FAMILY_TABLE_ROW:
1219     case XML_STYLE_FAMILY_TABLE_CELL:
1220     {
1221         const rtl::Reference< XMLTableImport >& xTableImport( const_cast< SvXMLImport& >( GetImport() ).GetShapeImport()->GetShapeTableImport() );
1222 
1223         switch( nFamily )
1224         {
1225         case XML_STYLE_FAMILY_TABLE_COLUMN: xMapper = xTableImport->GetColumnImportPropertySetMapper().get(); break;
1226         case XML_STYLE_FAMILY_TABLE_ROW: xMapper = xTableImport->GetRowImportPropertySetMapper().get(); break;
1227         case XML_STYLE_FAMILY_TABLE_CELL: xMapper = xTableImport->GetCellImportPropertySetMapper().get(); break;
1228         }
1229         break;
1230     }
1231     }
1232 
1233     // call base class
1234     if( !xMapper.is() )
1235         xMapper = SvXMLStylesContext::GetImportPropertyMapper(nFamily);
1236     return xMapper;
1237 }
1238 
1239 //////////////////////////////////////////////////////////////////////////////
1240 // Process all style and object info
1241 //
EndElement()1242 void SdXMLStylesContext::EndElement()
1243 {
1244     if(mbIsAutoStyle)
1245     {
1246         // AutoStyles for text import
1247         GetImport().GetTextImport()->SetAutoStyles( this );
1248 
1249         // AutoStyles for chart
1250         GetImport().GetChartImport()->SetAutoStylesContext( this );
1251 
1252         // AutoStyles for forms
1253         GetImport().GetFormImport()->setAutoStyleContext( this );
1254 
1255         // associate AutoStyles with styles in preparation to setting Styles on shapes
1256         for(sal_uInt32 a(0L); a < GetStyleCount(); a++)
1257         {
1258             const SvXMLStyleContext* pStyle = GetStyle(a);
1259             if(pStyle && pStyle->ISA(XMLShapeStyleContext))
1260             {
1261                 XMLShapeStyleContext* pDocStyle = (XMLShapeStyleContext*)pStyle;
1262 //              pDocStyle->Filter();
1263 
1264                 SvXMLStylesContext* pStylesContext = GetSdImport().GetShapeImport()->GetStylesContext();
1265                 if( pStylesContext )
1266                 {
1267                     pStyle = pStylesContext->FindStyleChildContext(pStyle->GetFamily(), pStyle->GetParentName());
1268 
1269                     if(pStyle && pStyle->ISA(XMLShapeStyleContext))
1270                     {
1271                         XMLShapeStyleContext* pParentStyle = (XMLShapeStyleContext*)pStyle;
1272                         if(pParentStyle->GetStyle().is())
1273                         {
1274                             pDocStyle->SetStyle(pParentStyle->GetStyle());
1275                         }
1276                     }
1277                 }
1278             }
1279         }
1280 
1281         FinishStyles( false );
1282     }
1283     else
1284     {
1285         // Process styles list
1286         ImpSetGraphicStyles();
1287         ImpSetCellStyles();
1288         GetImport().GetShapeImport()->GetShapeTableImport()->finishStyles();
1289 
1290         // put style infos in the info set for other components ( content import f.e. )
1291         uno::Reference< beans::XPropertySet > xInfoSet( GetImport().getImportInfo() );
1292         if( xInfoSet.is() )
1293         {
1294             uno::Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() );
1295 
1296             if( xInfoSetInfo->hasPropertyByName( OUString( RTL_CONSTASCII_USTRINGPARAM( "PageLayouts" ) ) ) )
1297                 xInfoSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PageLayouts" ) ), uno::makeAny( getPageLayouts() ) );
1298         }
1299 
1300     }
1301 }
1302 
1303 //////////////////////////////////////////////////////////////////////////////
1304 // set master-page styles (all with family="presentation" and a special
1305 // prefix) on given master-page.
1306 //
SetMasterPageStyles(SdXMLMasterPageContext & rMaster) const1307 void SdXMLStylesContext::SetMasterPageStyles(SdXMLMasterPageContext& rMaster) const
1308 {
1309     UniString sPrefix( rMaster.GetDisplayName());
1310     sPrefix += sal_Unicode('-');
1311 
1312     if(GetSdImport().GetLocalDocStyleFamilies().is() && GetSdImport().GetLocalDocStyleFamilies()->hasByName(rMaster.GetDisplayName())) try
1313     {
1314         uno::Reference< container::XNameAccess > xMasterPageStyles( GetSdImport().GetLocalDocStyleFamilies()->getByName(rMaster.GetDisplayName()), UNO_QUERY_THROW );
1315         ImpSetGraphicStyles(xMasterPageStyles, XML_STYLE_FAMILY_SD_PRESENTATION_ID, sPrefix);
1316     }
1317     catch( uno::Exception& )
1318     {
1319         DBG_ERROR( "xmloff::SdXMLStylesContext::SetMasterPageStyles(), exception caught!" );
1320     }
1321 }
1322 
1323 //////////////////////////////////////////////////////////////////////////////
1324 // Process styles list:
1325 // set graphic styles (all with family="graphics"). Remember xStyle at list element.
1326 //
ImpSetGraphicStyles() const1327 void SdXMLStylesContext::ImpSetGraphicStyles() const
1328 {
1329     if(GetSdImport().GetLocalDocStyleFamilies().is()) try
1330     {
1331         const OUString sGraphicStyleName(OUString(RTL_CONSTASCII_USTRINGPARAM("graphics")));
1332         uno::Reference< container::XNameAccess > xGraphicPageStyles( GetSdImport().GetLocalDocStyleFamilies()->getByName(sGraphicStyleName), uno::UNO_QUERY_THROW );
1333 
1334         UniString aPrefix;
1335         ImpSetGraphicStyles(xGraphicPageStyles, XML_STYLE_FAMILY_SD_GRAPHICS_ID, aPrefix);
1336     }
1337     catch( uno::Exception& )
1338     {
1339         DBG_ERROR( "xmloff::SdXMLStylesContext::ImpSetGraphicStyles(), exception caught!" );
1340     }
1341 }
1342 
ImpSetCellStyles() const1343 void SdXMLStylesContext::ImpSetCellStyles() const
1344 {
1345     if(GetSdImport().GetLocalDocStyleFamilies().is()) try
1346     {
1347         const OUString sCellStyleName(OUString(RTL_CONSTASCII_USTRINGPARAM("cell")));
1348         uno::Reference< container::XNameAccess > xGraphicPageStyles( GetSdImport().GetLocalDocStyleFamilies()->getByName(sCellStyleName), uno::UNO_QUERY_THROW );
1349 
1350         UniString aPrefix;
1351         ImpSetGraphicStyles(xGraphicPageStyles, XML_STYLE_FAMILY_TABLE_CELL, aPrefix);
1352     }
1353     catch( uno::Exception& )
1354     {
1355         DBG_ERROR( "xmloff::SdXMLStylesContext::ImpSetCellStyles(), exception caught!" );
1356     }
1357 }
1358 
1359 //////////////////////////////////////////////////////////////////////////////
1360 // help function used by ImpSetGraphicStyles() and ImpSetMasterPageStyles()
1361 //
ImpSetGraphicStyles(uno::Reference<container::XNameAccess> & xPageStyles,sal_uInt16 nFamily,const UniString & rPrefix) const1362 void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAccess >& xPageStyles,  sal_uInt16 nFamily,  const UniString& rPrefix) const
1363 {
1364     xub_StrLen nPrefLen(rPrefix.Len());
1365 
1366     sal_uInt32 a;
1367 
1368     // set defaults
1369     for( a = 0; a < GetStyleCount(); a++)
1370     {
1371         const SvXMLStyleContext* pStyle = GetStyle(a);
1372 
1373         if(nFamily == pStyle->GetFamily() && pStyle->IsDefaultStyle())
1374         {
1375             ((SvXMLStyleContext*)pStyle)->SetDefaults();
1376         }
1377     }
1378 
1379     // create all styles and set properties
1380     for( a = 0; a < GetStyleCount(); a++)
1381     {
1382         try
1383         {
1384             const SvXMLStyleContext* pStyle = GetStyle(a);
1385             if(nFamily == pStyle->GetFamily() && !pStyle->IsDefaultStyle())
1386             {
1387                 OUString aStyleName(pStyle->GetDisplayName());
1388                 if( nPrefLen )
1389                 {
1390                     sal_Int32 nStylePrefLen = aStyleName.lastIndexOf( sal_Unicode('-') ) + 1;
1391                     if( (nPrefLen != nStylePrefLen) ||  (aStyleName.compareTo( rPrefix, nPrefLen ) != 0) )
1392                         continue;
1393 
1394                     aStyleName = aStyleName.copy( nPrefLen );
1395                 }
1396 
1397                 uno::Reference< style::XStyle > xStyle;
1398                 if(xPageStyles->hasByName(aStyleName))
1399                 {
1400                     xPageStyles->getByName(aStyleName) >>= xStyle;
1401 
1402                     // set properties of existing styles to default
1403                     uno::Reference< beans::XPropertySet > xPropSet( xStyle, uno::UNO_QUERY );
1404                     uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
1405                     if( xPropSet.is() )
1406                         xPropSetInfo = xPropSet->getPropertySetInfo();
1407 
1408                     uno::Reference< beans::XPropertyState > xPropState( xStyle, uno::UNO_QUERY );
1409 
1410                     if( xPropState.is() )
1411                     {
1412                         UniReference < XMLPropertySetMapper > xPrMap;
1413                         UniReference < SvXMLImportPropertyMapper > xImpPrMap = GetImportPropertyMapper( nFamily );
1414                         DBG_ASSERT( xImpPrMap.is(), "There is the import prop mapper" );
1415                         if( xImpPrMap.is() )
1416                             xPrMap = xImpPrMap->getPropertySetMapper();
1417                         if( xPrMap.is() )
1418                         {
1419                             const sal_Int32 nCount = xPrMap->GetEntryCount();
1420                             for( sal_Int32 i = 0; i < nCount; i++ )
1421                             {
1422                                 const OUString& rName = xPrMap->GetEntryAPIName( i );
1423                                 if( xPropSetInfo->hasPropertyByName( rName ) && beans::PropertyState_DIRECT_VALUE == xPropState->getPropertyState( rName ) )
1424                                 {
1425                                     xPropState->setPropertyToDefault( rName );
1426                                 }
1427                             }
1428                         }
1429                     }
1430                 }
1431                 else
1432                 {
1433                     // graphics style does not exist, create and add it
1434                     uno::Reference< lang::XSingleServiceFactory > xServiceFact(xPageStyles, uno::UNO_QUERY);
1435                     if(xServiceFact.is())
1436                     {
1437                         uno::Reference< style::XStyle > xNewStyle( xServiceFact->createInstance(), uno::UNO_QUERY);
1438 
1439                         if(xNewStyle.is())
1440                         {
1441                             // remember style
1442                             xStyle = xNewStyle;
1443 
1444                             // add new style to graphics style pool
1445                             uno::Reference< container::XNameContainer > xInsertContainer(xPageStyles, uno::UNO_QUERY);
1446                             if(xInsertContainer.is())
1447                                 xInsertContainer->insertByName(aStyleName, uno::Any( xStyle ) );
1448                         }
1449                     }
1450                 }
1451 
1452                 if(xStyle.is())
1453                 {
1454                     // set properties at style
1455                     XMLPropStyleContext* pPropStyle = dynamic_cast< XMLPropStyleContext* >( const_cast< SvXMLStyleContext* >( pStyle ) );
1456                     uno::Reference< beans::XPropertySet > xPropSet(xStyle, uno::UNO_QUERY);
1457 
1458                     if(xPropSet.is() && pPropStyle)
1459                     {
1460                         pPropStyle->FillPropertySet(xPropSet);
1461                         pPropStyle->SetStyle(xStyle);
1462                     }
1463                 }
1464             }
1465         }
1466         catch( Exception& e)
1467         {
1468             uno::Sequence<OUString> aSeq(0);
1469             const_cast<SdXMLImport*>(&GetSdImport())->SetError( XMLERROR_FLAG_WARNING | XMLERROR_API, aSeq, e.Message, NULL );
1470         }
1471     }
1472 
1473     // now set parents for all styles (when necessary)
1474     for(a = 0L; a < GetStyleCount(); a++)
1475     {
1476         const SvXMLStyleContext* pStyle = GetStyle(a);
1477 
1478         if(pStyle && pStyle->GetName().getLength() && (nFamily == pStyle->GetFamily())) try
1479         {
1480             OUString aStyleName(pStyle->GetDisplayName());
1481             if( nPrefLen )
1482             {
1483                 sal_Int32 nStylePrefLen = aStyleName.lastIndexOf( sal_Unicode('-') ) + 1;
1484                 if( (nPrefLen != nStylePrefLen) ||  (aStyleName.compareTo( rPrefix, nPrefLen ) != 0) )
1485                     continue;
1486 
1487                 aStyleName = aStyleName.copy( nPrefLen );
1488             }
1489 
1490             uno::Reference< style::XStyle > xStyle( xPageStyles->getByName(aStyleName), UNO_QUERY );
1491             if(xStyle.is())
1492             {
1493                 // set parent style name
1494                 ::rtl::OUString sParentStyleDisplayName( const_cast< SvXMLImport& >( GetImport() ).GetStyleDisplayName( pStyle->GetFamily(), pStyle->GetParentName() ) );
1495                 if( nPrefLen )
1496                 {
1497                     sal_Int32 nStylePrefLen = sParentStyleDisplayName.lastIndexOf( sal_Unicode('-') ) + 1;
1498                     if( (nPrefLen != nStylePrefLen) || (sParentStyleDisplayName.compareTo( rPrefix, nPrefLen ) != 0) )
1499                         continue;
1500 
1501                     sParentStyleDisplayName = sParentStyleDisplayName.copy( nPrefLen );
1502                 }
1503                 xStyle->setParentStyle( sParentStyleDisplayName );
1504             }
1505         }
1506         catch( Exception& e )
1507         {
1508             uno::Sequence<OUString> aSeq(0);
1509             const_cast<SdXMLImport*>(&GetSdImport())->SetError( XMLERROR_FLAG_WARNING | XMLERROR_API, aSeq, e.Message, NULL );
1510         }
1511     }
1512 }
1513 
1514 ////////////////////////////////////////////////////////////////////////////////
1515 // helper function to create the uno component that hold the mappings from
1516 // xml auto layout name to internal autolayout id
1517 
getPageLayouts() const1518 uno::Reference< container::XNameAccess > SdXMLStylesContext::getPageLayouts() const
1519 {
1520     uno::Reference< container::XNameContainer > xLayouts( comphelper::NameContainer_createInstance( ::getCppuType((const sal_Int32*)0)) );
1521 
1522     for(sal_uInt32 a(0L); a < GetStyleCount(); a++)
1523     {
1524         const SvXMLStyleContext* pStyle = GetStyle(a);
1525         if(pStyle && pStyle->ISA(SdXMLPresentationPageLayoutContext))
1526         {
1527             xLayouts->insertByName( pStyle->GetName(), uno::makeAny(
1528             (sal_Int32)((SdXMLPresentationPageLayoutContext*)pStyle)->GetTypeId() ) );
1529         }
1530     }
1531 
1532     return uno::Reference< container::XNameAccess >::query( xLayouts );
1533 }
1534 
1535 ////////////////////////////////////////////////////////////////////////////////
1536 ////////////////////////////////////////////////////////////////////////////////
1537 //
1538 TYPEINIT1( SdXMLMasterStylesContext, SvXMLImportContext );
1539 
SdXMLMasterStylesContext(SdXMLImport & rImport,sal_uInt16 nPrfx,const rtl::OUString & rLName)1540 SdXMLMasterStylesContext::SdXMLMasterStylesContext(
1541     SdXMLImport& rImport,
1542     sal_uInt16 nPrfx,
1543     const rtl::OUString& rLName)
1544 :   SvXMLImportContext( rImport, nPrfx, rLName)
1545 {
1546 }
1547 
~SdXMLMasterStylesContext()1548 SdXMLMasterStylesContext::~SdXMLMasterStylesContext()
1549 {
1550     while(maMasterPageList.Count())
1551         maMasterPageList.Remove(maMasterPageList.Count() - 1)->ReleaseRef();
1552 }
1553 
CreateChildContext(sal_uInt16 nPrefix,const rtl::OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)1554 SvXMLImportContext* SdXMLMasterStylesContext::CreateChildContext(
1555     sal_uInt16 nPrefix,
1556     const rtl::OUString& rLocalName,
1557     const uno::Reference< xml::sax::XAttributeList >& xAttrList)
1558 {
1559     SvXMLImportContext* pContext = 0;
1560 
1561     if(nPrefix == XML_NAMESPACE_STYLE
1562        && IsXMLToken( rLocalName, XML_MASTER_PAGE ) )
1563     {
1564         // style:masterpage inside office:styles context
1565         uno::Reference< drawing::XDrawPage > xNewMasterPage;
1566         uno::Reference< drawing::XDrawPages > xMasterPages(GetSdImport().GetLocalMasterPages(), uno::UNO_QUERY);
1567 
1568         if( xMasterPages.is() )
1569         {
1570             if(GetSdImport().GetNewMasterPageCount() + 1 > xMasterPages->getCount())
1571             {
1572                 // new page, create and insert
1573                 xNewMasterPage = xMasterPages->insertNewByIndex(xMasterPages->getCount());
1574             }
1575             else
1576             {
1577                 // existing page, use it
1578                 xMasterPages->getByIndex(GetSdImport().GetNewMasterPageCount()) >>= xNewMasterPage;
1579             }
1580 
1581             // increment global import page counter
1582             GetSdImport().IncrementNewMasterPageCount();
1583 
1584             if(xNewMasterPage.is())
1585             {
1586                 uno::Reference< drawing::XShapes > xNewShapes(xNewMasterPage, uno::UNO_QUERY);
1587                 if(xNewShapes.is() && GetSdImport().GetShapeImport()->GetStylesContext())
1588                 {
1589                     pContext = new SdXMLMasterPageContext(GetSdImport(),
1590                         nPrefix, rLocalName, xAttrList, xNewShapes);
1591 
1592                     if(pContext)
1593                     {
1594                         pContext->AddRef();
1595                         maMasterPageList.Insert((SdXMLMasterPageContext*)pContext, LIST_APPEND);
1596                     }
1597                 }
1598             }
1599         }
1600     }
1601     else    if(nPrefix == XML_NAMESPACE_STYLE
1602         && IsXMLToken( rLocalName, XML_HANDOUT_MASTER ) )
1603     {
1604         uno::Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetSdImport().GetModel(), uno::UNO_QUERY );
1605         if( xHandoutSupp.is() )
1606         {
1607             uno::Reference< drawing::XShapes > xHandoutPage( xHandoutSupp->getHandoutMasterPage(), uno::UNO_QUERY );
1608             if(xHandoutPage.is() && GetSdImport().GetShapeImport()->GetStylesContext())
1609             {
1610                 pContext = new SdXMLMasterPageContext(GetSdImport(),
1611                     nPrefix, rLocalName, xAttrList, xHandoutPage);
1612             }
1613         }
1614     }
1615     else if( (nPrefix == XML_NAMESPACE_DRAW )&& IsXMLToken( rLocalName, XML_LAYER_SET ) )
1616     {
1617         pContext = new SdXMLLayerSetContext( GetImport(), nPrefix, rLocalName, xAttrList );
1618     }
1619 
1620     // call base class
1621     if(!pContext)
1622         pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
1623 
1624     return pContext;
1625 }
1626 
1627 ///////////////////////////////////////////////////////////////////////
1628 
SdXMLHeaderFooterDeclContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const::rtl::OUString & rLName,const::com::sun::star::uno::Reference<::com::sun::star::xml::sax::XAttributeList> & xAttrList)1629 SdXMLHeaderFooterDeclContext::SdXMLHeaderFooterDeclContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
1630         const ::rtl::OUString& rLName,
1631         const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList )
1632 : SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList )
1633 {
1634     const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1635     for(sal_Int16 i=0; i < nAttrCount; i++)
1636     {
1637         OUString aLocalName;
1638         const OUString aValue( xAttrList->getValueByIndex(i) );
1639         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(xAttrList->getNameByIndex(i), &aLocalName);
1640 
1641         if( nPrefix == XML_NAMESPACE_PRESENTATION )
1642         {
1643             if( IsXMLToken( aLocalName, XML_NAME ) )
1644             {
1645                 maStrName = aValue;
1646             }
1647             else if( IsXMLToken( aLocalName, XML_SOURCE ) )
1648             {
1649                 mbFixed = IsXMLToken( aValue, XML_FIXED );
1650             }
1651         }
1652         else if( nPrefix == XML_NAMESPACE_STYLE )
1653         {
1654             if( IsXMLToken( aLocalName, XML_DATA_STYLE_NAME ) )
1655             {
1656                 maStrDateTimeFormat = aValue;
1657             }
1658         }
1659     }
1660 }
1661 
IsTransient() const1662 sal_Bool SdXMLHeaderFooterDeclContext::IsTransient() const
1663 {
1664     return sal_True;
1665 }
1666 
EndElement()1667 void SdXMLHeaderFooterDeclContext::EndElement()
1668 {
1669     SdXMLImport& rImport = *dynamic_cast< SdXMLImport* >( &GetImport() );
1670     if( IsXMLToken( GetLocalName(), XML_HEADER_DECL ) )
1671     {
1672         rImport.AddHeaderDecl( maStrName, maStrText );
1673     }
1674     else if( IsXMLToken( GetLocalName(), XML_FOOTER_DECL ) )
1675     {
1676         rImport.AddFooterDecl( maStrName, maStrText );
1677     }
1678     else if( IsXMLToken( GetLocalName(), XML_DATE_TIME_DECL ) )
1679     {
1680         rImport.AddDateTimeDecl( maStrName, maStrText, mbFixed, maStrDateTimeFormat );
1681     }
1682 }
1683 
Characters(const::rtl::OUString & rChars)1684 void SdXMLHeaderFooterDeclContext::Characters( const ::rtl::OUString& rChars )
1685 {
1686     maStrText += rChars;
1687 }
1688 
1689