LCOV - code coverage report
Current view: top level - xmloff/source/draw - ximpstyl.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 515 675 76.3 %
Date: 2014-04-11 Functions: 60 93 64.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10