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 10cdf0e10cSrcweir * 11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 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 #include <tools/debug.hxx> 27cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 28cdf0e10cSrcweir #include <xmloff/xmltkmap.hxx> 29cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 30cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 31cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 32cdf0e10cSrcweir #include <xmloff/xmlimp.hxx> 33cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 34cdf0e10cSrcweir #include <xmloff/XMLBase64ImportContext.hxx> 35cdf0e10cSrcweir #include "XMLBackgroundImageContext.hxx" 36cdf0e10cSrcweir 37cdf0e10cSrcweir using ::rtl::OUString; 38cdf0e10cSrcweir using ::rtl::OUStringBuffer; 39cdf0e10cSrcweir 40cdf0e10cSrcweir using namespace ::com::sun::star; 41cdf0e10cSrcweir using namespace ::com::sun::star::uno; 42cdf0e10cSrcweir using namespace ::com::sun::star::style; 43cdf0e10cSrcweir using namespace ::com::sun::star::io; 44cdf0e10cSrcweir using namespace ::xmloff::token; 45cdf0e10cSrcweir 46cdf0e10cSrcweir enum SvXMLTokenMapAttrs 47cdf0e10cSrcweir { 48cdf0e10cSrcweir XML_TOK_BGIMG_HREF, 49cdf0e10cSrcweir XML_TOK_BGIMG_TYPE, 50cdf0e10cSrcweir XML_TOK_BGIMG_ACTUATE, 51cdf0e10cSrcweir XML_TOK_BGIMG_SHOW, 52cdf0e10cSrcweir XML_TOK_BGIMG_POSITION, 53cdf0e10cSrcweir XML_TOK_BGIMG_REPEAT, 54cdf0e10cSrcweir XML_TOK_BGIMG_FILTER, 55cdf0e10cSrcweir XML_TOK_BGIMG_OPACITY, 56cdf0e10cSrcweir XML_TOK_NGIMG_END=XML_TOK_UNKNOWN 57cdf0e10cSrcweir }; 58cdf0e10cSrcweir const SvXMLTokenMapEntry* lcl_getBGImgAttributesAttrTokenMap() 59cdf0e10cSrcweir { 60cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aBGImgAttributesAttrTokenMap[] = 61cdf0e10cSrcweir { 62cdf0e10cSrcweir { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_BGIMG_HREF }, 63cdf0e10cSrcweir { XML_NAMESPACE_XLINK, XML_TYPE, XML_TOK_BGIMG_TYPE }, 64cdf0e10cSrcweir { XML_NAMESPACE_XLINK, XML_ACTUATE, XML_TOK_BGIMG_ACTUATE }, 65cdf0e10cSrcweir { XML_NAMESPACE_XLINK, XML_SHOW, XML_TOK_BGIMG_SHOW }, 66cdf0e10cSrcweir { XML_NAMESPACE_STYLE, XML_POSITION, XML_TOK_BGIMG_POSITION }, 67cdf0e10cSrcweir { XML_NAMESPACE_STYLE, XML_REPEAT, XML_TOK_BGIMG_REPEAT }, 68cdf0e10cSrcweir { XML_NAMESPACE_STYLE, XML_FILTER_NAME, XML_TOK_BGIMG_FILTER }, 69cdf0e10cSrcweir { XML_NAMESPACE_DRAW, XML_OPACITY, XML_TOK_BGIMG_OPACITY }, 70cdf0e10cSrcweir XML_TOKEN_MAP_END 71cdf0e10cSrcweir }; 72cdf0e10cSrcweir return aBGImgAttributesAttrTokenMap; 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 75cdf0e10cSrcweir 76cdf0e10cSrcweir 77cdf0e10cSrcweir SvXMLEnumMapEntry psXML_BrushHoriPos[] = 78cdf0e10cSrcweir { 79cdf0e10cSrcweir { XML_LEFT, GraphicLocation_LEFT_MIDDLE }, 80cdf0e10cSrcweir { XML_RIGHT, GraphicLocation_RIGHT_MIDDLE }, 81cdf0e10cSrcweir { XML_TOKEN_INVALID, 0 } 82cdf0e10cSrcweir }; 83cdf0e10cSrcweir 84cdf0e10cSrcweir SvXMLEnumMapEntry psXML_BrushVertPos[] = 85cdf0e10cSrcweir { 86cdf0e10cSrcweir { XML_TOP, GraphicLocation_MIDDLE_TOP }, 87cdf0e10cSrcweir { XML_BOTTOM, GraphicLocation_MIDDLE_BOTTOM }, 88cdf0e10cSrcweir { XML_TOKEN_INVALID, 0 } 89cdf0e10cSrcweir }; 90cdf0e10cSrcweir 91cdf0e10cSrcweir void lcl_xmlbic_MergeHoriPos( GraphicLocation& ePos, 92cdf0e10cSrcweir GraphicLocation eHori ) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir DBG_ASSERT( GraphicLocation_LEFT_MIDDLE==eHori || 95cdf0e10cSrcweir GraphicLocation_MIDDLE_MIDDLE==eHori || 96cdf0e10cSrcweir GraphicLocation_RIGHT_MIDDLE==eHori, 97cdf0e10cSrcweir "lcl_xmlbic_MergeHoriPos: vertical pos must be middle" ); 98cdf0e10cSrcweir 99cdf0e10cSrcweir switch( ePos ) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir case GraphicLocation_LEFT_TOP: 102cdf0e10cSrcweir case GraphicLocation_MIDDLE_TOP: 103cdf0e10cSrcweir case GraphicLocation_RIGHT_TOP: 104cdf0e10cSrcweir ePos = GraphicLocation_LEFT_MIDDLE==eHori 105cdf0e10cSrcweir ? GraphicLocation_LEFT_TOP 106cdf0e10cSrcweir : (GraphicLocation_MIDDLE_MIDDLE==eHori 107cdf0e10cSrcweir ? GraphicLocation_MIDDLE_TOP 108cdf0e10cSrcweir : GraphicLocation_RIGHT_TOP); 109cdf0e10cSrcweir break; 110cdf0e10cSrcweir 111cdf0e10cSrcweir case GraphicLocation_LEFT_MIDDLE: 112cdf0e10cSrcweir case GraphicLocation_MIDDLE_MIDDLE: 113cdf0e10cSrcweir case GraphicLocation_RIGHT_MIDDLE: 114cdf0e10cSrcweir ePos = eHori; 115cdf0e10cSrcweir break; 116cdf0e10cSrcweir 117cdf0e10cSrcweir case GraphicLocation_LEFT_BOTTOM: 118cdf0e10cSrcweir case GraphicLocation_MIDDLE_BOTTOM: 119cdf0e10cSrcweir case GraphicLocation_RIGHT_BOTTOM: 120cdf0e10cSrcweir ePos = GraphicLocation_LEFT_MIDDLE==eHori 121cdf0e10cSrcweir ? GraphicLocation_LEFT_BOTTOM 122cdf0e10cSrcweir : (GraphicLocation_MIDDLE_MIDDLE==eHori 123cdf0e10cSrcweir ? GraphicLocation_MIDDLE_BOTTOM 124cdf0e10cSrcweir : GraphicLocation_RIGHT_BOTTOM); 125cdf0e10cSrcweir break; 126cdf0e10cSrcweir default: 127cdf0e10cSrcweir break; 128cdf0e10cSrcweir } 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir void lcl_xmlbic_MergeVertPos( GraphicLocation& ePos, 132cdf0e10cSrcweir GraphicLocation eVert ) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir DBG_ASSERT( GraphicLocation_MIDDLE_TOP==eVert || 135cdf0e10cSrcweir GraphicLocation_MIDDLE_MIDDLE==eVert || 136cdf0e10cSrcweir GraphicLocation_MIDDLE_BOTTOM==eVert, 137cdf0e10cSrcweir "lcl_xmlbic_MergeVertPos: horizontal pos must be middle" ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir switch( ePos ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir case GraphicLocation_LEFT_TOP: 142cdf0e10cSrcweir case GraphicLocation_LEFT_MIDDLE: 143cdf0e10cSrcweir case GraphicLocation_LEFT_BOTTOM: 144cdf0e10cSrcweir ePos = GraphicLocation_MIDDLE_TOP==eVert 145cdf0e10cSrcweir ? GraphicLocation_LEFT_TOP 146cdf0e10cSrcweir : (GraphicLocation_MIDDLE_MIDDLE==eVert 147cdf0e10cSrcweir ? GraphicLocation_LEFT_MIDDLE 148cdf0e10cSrcweir : GraphicLocation_LEFT_BOTTOM); 149cdf0e10cSrcweir ePos = eVert; 150cdf0e10cSrcweir break; 151cdf0e10cSrcweir 152cdf0e10cSrcweir case GraphicLocation_MIDDLE_TOP: 153cdf0e10cSrcweir case GraphicLocation_MIDDLE_MIDDLE: 154cdf0e10cSrcweir case GraphicLocation_MIDDLE_BOTTOM: 155cdf0e10cSrcweir ePos = eVert; 156cdf0e10cSrcweir break; 157cdf0e10cSrcweir 158cdf0e10cSrcweir case GraphicLocation_RIGHT_TOP: 159cdf0e10cSrcweir case GraphicLocation_RIGHT_MIDDLE: 160cdf0e10cSrcweir case GraphicLocation_RIGHT_BOTTOM: 161cdf0e10cSrcweir ePos = GraphicLocation_MIDDLE_TOP==eVert 162cdf0e10cSrcweir ? GraphicLocation_RIGHT_TOP 163cdf0e10cSrcweir : (GraphicLocation_MIDDLE_MIDDLE==eVert 164cdf0e10cSrcweir ? GraphicLocation_RIGHT_MIDDLE 165cdf0e10cSrcweir : GraphicLocation_RIGHT_BOTTOM); 166cdf0e10cSrcweir break; 167cdf0e10cSrcweir default: 168cdf0e10cSrcweir break; 169cdf0e10cSrcweir } 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir TYPEINIT1( XMLBackgroundImageContext, XMLElementPropertyContext ); 173cdf0e10cSrcweir 174cdf0e10cSrcweir void XMLBackgroundImageContext::ProcessAttrs( 175cdf0e10cSrcweir const Reference< xml::sax::XAttributeList >& xAttrList ) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir SvXMLTokenMap aTokenMap( lcl_getBGImgAttributesAttrTokenMap() ); 178cdf0e10cSrcweir 179cdf0e10cSrcweir ePos = GraphicLocation_NONE; 180cdf0e10cSrcweir 181cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 182cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; i++ ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir const OUString& rAttrName = xAttrList->getNameByIndex( i ); 185cdf0e10cSrcweir OUString aLocalName; 186cdf0e10cSrcweir sal_uInt16 nPrefix = 187cdf0e10cSrcweir GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, 188cdf0e10cSrcweir &aLocalName ); 189cdf0e10cSrcweir const OUString& rValue = xAttrList->getValueByIndex( i ); 190cdf0e10cSrcweir 191cdf0e10cSrcweir switch( aTokenMap.Get( nPrefix, aLocalName ) ) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir case XML_TOK_BGIMG_HREF: 194cdf0e10cSrcweir sURL = rValue; 195cdf0e10cSrcweir if( GraphicLocation_NONE == ePos ) 196cdf0e10cSrcweir ePos = GraphicLocation_TILED; 197cdf0e10cSrcweir break; 198cdf0e10cSrcweir case XML_TOK_BGIMG_TYPE: 199cdf0e10cSrcweir case XML_TOK_BGIMG_ACTUATE: 200cdf0e10cSrcweir case XML_TOK_BGIMG_SHOW: 201cdf0e10cSrcweir break; 202cdf0e10cSrcweir case XML_TOK_BGIMG_POSITION: 203cdf0e10cSrcweir { 204cdf0e10cSrcweir GraphicLocation eNewPos = GraphicLocation_NONE, eTmp; 205cdf0e10cSrcweir sal_uInt16 nTmp; 206cdf0e10cSrcweir SvXMLTokenEnumerator aTokenEnum( rValue ); 207cdf0e10cSrcweir OUString aToken; 208cdf0e10cSrcweir sal_Bool bHori = sal_False, bVert = sal_False; 209cdf0e10cSrcweir sal_Bool bOK = sal_True; 210cdf0e10cSrcweir while( bOK && aTokenEnum.getNextToken( aToken ) ) 211cdf0e10cSrcweir { 212cdf0e10cSrcweir if( bHori && bVert ) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir bOK = sal_False; 215cdf0e10cSrcweir } 216cdf0e10cSrcweir else if( -1 != aToken.indexOf( sal_Unicode('%') ) ) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir sal_Int32 nPrc = 50; 219cdf0e10cSrcweir if( SvXMLUnitConverter::convertPercent( nPrc, aToken ) ) 220cdf0e10cSrcweir { 221cdf0e10cSrcweir if( !bHori ) 222cdf0e10cSrcweir { 223cdf0e10cSrcweir eNewPos = nPrc < 25 224cdf0e10cSrcweir ? GraphicLocation_LEFT_TOP 225cdf0e10cSrcweir : (nPrc < 75 ? GraphicLocation_MIDDLE_MIDDLE 226cdf0e10cSrcweir : GraphicLocation_RIGHT_BOTTOM); 227cdf0e10cSrcweir bHori = sal_True; 228cdf0e10cSrcweir } 229cdf0e10cSrcweir else 230cdf0e10cSrcweir { 231cdf0e10cSrcweir eTmp = nPrc < 25 232cdf0e10cSrcweir ? GraphicLocation_LEFT_TOP 233cdf0e10cSrcweir : (nPrc < 75 ? GraphicLocation_LEFT_MIDDLE 234cdf0e10cSrcweir : GraphicLocation_LEFT_BOTTOM); 235cdf0e10cSrcweir lcl_xmlbic_MergeVertPos( eNewPos, eTmp ); 236cdf0e10cSrcweir bVert = sal_True; 237cdf0e10cSrcweir } 238cdf0e10cSrcweir } 239cdf0e10cSrcweir else 240cdf0e10cSrcweir { 241cdf0e10cSrcweir // wrong percentage 242cdf0e10cSrcweir bOK = sal_False; 243cdf0e10cSrcweir } 244cdf0e10cSrcweir } 245cdf0e10cSrcweir else if( IsXMLToken( aToken, XML_CENTER ) ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir if( bHori ) 248cdf0e10cSrcweir lcl_xmlbic_MergeVertPos( eNewPos, 249cdf0e10cSrcweir GraphicLocation_MIDDLE_MIDDLE ); 250cdf0e10cSrcweir else if ( bVert ) 251cdf0e10cSrcweir lcl_xmlbic_MergeHoriPos( eNewPos, 252cdf0e10cSrcweir GraphicLocation_MIDDLE_MIDDLE ); 253cdf0e10cSrcweir else 254cdf0e10cSrcweir eNewPos = GraphicLocation_MIDDLE_MIDDLE; 255cdf0e10cSrcweir } 256cdf0e10cSrcweir else if( SvXMLUnitConverter::convertEnum( nTmp, aToken, 257cdf0e10cSrcweir psXML_BrushHoriPos ) ) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir if( bVert ) 260cdf0e10cSrcweir lcl_xmlbic_MergeHoriPos( eNewPos, 261cdf0e10cSrcweir (GraphicLocation)nTmp ); 262cdf0e10cSrcweir else if( !bHori ) 263cdf0e10cSrcweir eNewPos = (GraphicLocation)nTmp; 264cdf0e10cSrcweir else 265cdf0e10cSrcweir bOK = sal_False; 266cdf0e10cSrcweir bHori = sal_True; 267cdf0e10cSrcweir } 268cdf0e10cSrcweir else if( SvXMLUnitConverter::convertEnum( nTmp, aToken, 269cdf0e10cSrcweir psXML_BrushVertPos ) ) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir if( bHori ) 272cdf0e10cSrcweir lcl_xmlbic_MergeVertPos( eNewPos, 273cdf0e10cSrcweir (GraphicLocation)nTmp ); 274cdf0e10cSrcweir else if( !bVert ) 275cdf0e10cSrcweir eNewPos = (GraphicLocation)nTmp; 276cdf0e10cSrcweir else 277cdf0e10cSrcweir bOK = sal_False; 278cdf0e10cSrcweir bVert = sal_True; 279cdf0e10cSrcweir } 280cdf0e10cSrcweir else 281cdf0e10cSrcweir { 282cdf0e10cSrcweir bOK = sal_False; 283cdf0e10cSrcweir } 284cdf0e10cSrcweir } 285cdf0e10cSrcweir 286cdf0e10cSrcweir bOK &= GraphicLocation_NONE != eNewPos; 287cdf0e10cSrcweir if( bOK ) 288cdf0e10cSrcweir ePos = eNewPos; 289cdf0e10cSrcweir } 290cdf0e10cSrcweir break; 291cdf0e10cSrcweir case XML_TOK_BGIMG_REPEAT: 292cdf0e10cSrcweir { 293cdf0e10cSrcweir sal_uInt16 nPos = GraphicLocation_NONE; 294cdf0e10cSrcweir static SvXMLEnumMapEntry psXML_BrushRepeat[] = 295cdf0e10cSrcweir { 296cdf0e10cSrcweir { XML_BACKGROUND_REPEAT, GraphicLocation_TILED }, 297cdf0e10cSrcweir { XML_BACKGROUND_NO_REPEAT, GraphicLocation_MIDDLE_MIDDLE }, 298cdf0e10cSrcweir { XML_BACKGROUND_STRETCH, GraphicLocation_AREA }, 299cdf0e10cSrcweir { XML_TOKEN_INVALID, 0 } 300cdf0e10cSrcweir }; 301cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nPos, rValue, 302cdf0e10cSrcweir psXML_BrushRepeat ) ) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir if( GraphicLocation_MIDDLE_MIDDLE != nPos || 305cdf0e10cSrcweir GraphicLocation_NONE == ePos || 306cdf0e10cSrcweir GraphicLocation_AREA == ePos || 307cdf0e10cSrcweir GraphicLocation_TILED == ePos ) 308cdf0e10cSrcweir ePos = (GraphicLocation)nPos; 309cdf0e10cSrcweir } 310cdf0e10cSrcweir } 311cdf0e10cSrcweir break; 312cdf0e10cSrcweir case XML_TOK_BGIMG_FILTER: 313cdf0e10cSrcweir sFilter = rValue; 314cdf0e10cSrcweir break; 315cdf0e10cSrcweir case XML_TOK_BGIMG_OPACITY: 316cdf0e10cSrcweir { 317cdf0e10cSrcweir sal_Int32 nTmp; 318cdf0e10cSrcweir // convert from percent and clip 319cdf0e10cSrcweir if( SvXMLUnitConverter::convertPercent( nTmp, rValue ) ) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir if( (nTmp >= 0) && (nTmp <= 100) ) 322cdf0e10cSrcweir nTransparency = static_cast<sal_Int8>( 100-nTmp ); 323cdf0e10cSrcweir } 324cdf0e10cSrcweir } 325cdf0e10cSrcweir break; 326cdf0e10cSrcweir } 327cdf0e10cSrcweir } 328cdf0e10cSrcweir 329cdf0e10cSrcweir } 330cdf0e10cSrcweir 331cdf0e10cSrcweir XMLBackgroundImageContext::XMLBackgroundImageContext( 332cdf0e10cSrcweir SvXMLImport& rImport, sal_uInt16 nPrfx, 333cdf0e10cSrcweir const OUString& rLName, 334cdf0e10cSrcweir const Reference< xml::sax::XAttributeList > & xAttrList, 335cdf0e10cSrcweir const XMLPropertyState& rProp, 336cdf0e10cSrcweir sal_Int32 nPosIdx, 337cdf0e10cSrcweir sal_Int32 nFilterIdx, 338cdf0e10cSrcweir sal_Int32 nTransparencyIdx, 339cdf0e10cSrcweir ::std::vector< XMLPropertyState > &rProps ) : 340cdf0e10cSrcweir XMLElementPropertyContext( rImport, nPrfx, rLName, rProp, rProps ), 341cdf0e10cSrcweir aPosProp( nPosIdx ), 342cdf0e10cSrcweir aFilterProp( nFilterIdx ), 343cdf0e10cSrcweir aTransparencyProp( nTransparencyIdx ), 344cdf0e10cSrcweir nTransparency( 0 ) 345cdf0e10cSrcweir { 346cdf0e10cSrcweir ProcessAttrs( xAttrList ); 347cdf0e10cSrcweir } 348cdf0e10cSrcweir 349cdf0e10cSrcweir XMLBackgroundImageContext::~XMLBackgroundImageContext() 350cdf0e10cSrcweir { 351cdf0e10cSrcweir } 352cdf0e10cSrcweir 353cdf0e10cSrcweir SvXMLImportContext *XMLBackgroundImageContext::CreateChildContext( 354cdf0e10cSrcweir sal_uInt16 nPrefix, const OUString& rLocalName, 355cdf0e10cSrcweir const Reference< xml::sax::XAttributeList > & xAttrList ) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir SvXMLImportContext *pContext = NULL; 358cdf0e10cSrcweir if( (XML_NAMESPACE_OFFICE == nPrefix) && 359cdf0e10cSrcweir xmloff::token::IsXMLToken( rLocalName, 360cdf0e10cSrcweir xmloff::token::XML_BINARY_DATA ) ) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir if( !sURL.getLength() && !xBase64Stream.is() ) 363cdf0e10cSrcweir { 364cdf0e10cSrcweir xBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64(); 365cdf0e10cSrcweir if( xBase64Stream.is() ) 366cdf0e10cSrcweir pContext = new XMLBase64ImportContext( GetImport(), nPrefix, 367cdf0e10cSrcweir rLocalName, xAttrList, 368cdf0e10cSrcweir xBase64Stream ); 369cdf0e10cSrcweir } 370cdf0e10cSrcweir } 371cdf0e10cSrcweir if( !pContext ) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); 374cdf0e10cSrcweir } 375cdf0e10cSrcweir 376cdf0e10cSrcweir return pContext; 377cdf0e10cSrcweir } 378cdf0e10cSrcweir 379cdf0e10cSrcweir void XMLBackgroundImageContext::EndElement() 380cdf0e10cSrcweir { 381cdf0e10cSrcweir if( sURL.getLength() ) 382cdf0e10cSrcweir { 383cdf0e10cSrcweir sURL = GetImport().ResolveGraphicObjectURL( sURL, sal_False ); 384cdf0e10cSrcweir } 385cdf0e10cSrcweir else if( xBase64Stream.is() ) 386cdf0e10cSrcweir { 387cdf0e10cSrcweir sURL = GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream ); 388cdf0e10cSrcweir xBase64Stream = 0; 389cdf0e10cSrcweir } 390cdf0e10cSrcweir 391cdf0e10cSrcweir if( !sURL.getLength() ) 392cdf0e10cSrcweir ePos = GraphicLocation_NONE; 393cdf0e10cSrcweir else if( GraphicLocation_NONE == ePos ) 394cdf0e10cSrcweir ePos = GraphicLocation_TILED; 395cdf0e10cSrcweir 396cdf0e10cSrcweir aProp.maValue <<= sURL; 397cdf0e10cSrcweir aPosProp.maValue <<= ePos; 398cdf0e10cSrcweir aFilterProp.maValue <<= sFilter; 399cdf0e10cSrcweir aTransparencyProp.maValue <<= nTransparency; 400cdf0e10cSrcweir 401cdf0e10cSrcweir SetInsert( sal_True ); 402cdf0e10cSrcweir XMLElementPropertyContext::EndElement(); 403cdf0e10cSrcweir 404cdf0e10cSrcweir if( -1 != aPosProp.mnIndex ) 405cdf0e10cSrcweir rProperties.push_back( aPosProp ); 406cdf0e10cSrcweir if( -1 != aFilterProp.mnIndex ) 407cdf0e10cSrcweir rProperties.push_back( aFilterProp ); 408cdf0e10cSrcweir if( -1 != aTransparencyProp.mnIndex ) 409cdf0e10cSrcweir rProperties.push_back( aTransparencyProp ); 410cdf0e10cSrcweir } 411