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