1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 30*cdf0e10cSrcweir #include <tools/debug.hxx> 31*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/text/TextContentAnchorType.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/text/XTextFrame.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/text/SizeType.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/document/XEventsSupplier.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/text/HoriOrientation.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/text/VertOrientation.hpp> 43*cdf0e10cSrcweir #include <xmloff/xmlimp.hxx> 44*cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 45*cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 46*cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 47*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 48*cdf0e10cSrcweir #include "XMLAnchorTypePropHdl.hxx" 49*cdf0e10cSrcweir #include "XMLEmbeddedObjectImportContext.hxx" 50*cdf0e10cSrcweir #include <xmloff/XMLBase64ImportContext.hxx> 51*cdf0e10cSrcweir #include "XMLReplacementImageContext.hxx" 52*cdf0e10cSrcweir #include <xmloff/prstylei.hxx> 53*cdf0e10cSrcweir #include "xmloff/i18nmap.hxx" 54*cdf0e10cSrcweir #include "xexptran.hxx" 55*cdf0e10cSrcweir #include <xmloff/shapeimport.hxx> 56*cdf0e10cSrcweir #include <xmloff/XMLEventsImportContext.hxx> 57*cdf0e10cSrcweir #include "XMLImageMapContext.hxx" 58*cdf0e10cSrcweir #include "XMLTextFrameContext.hxx" 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir #include "XMLTextListBlockContext.hxx" 61*cdf0e10cSrcweir #include "XMLTextListItemContext.hxx" 62*cdf0e10cSrcweir #include <xmloff/attrlist.hxx> 63*cdf0e10cSrcweir #include <comphelper/stl_types.hxx> 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir #include <map> 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir using ::rtl::OUString; 69*cdf0e10cSrcweir using ::rtl::OUStringBuffer; 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir using namespace ::com::sun::star; 72*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 73*cdf0e10cSrcweir using namespace ::com::sun::star::text; 74*cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax; 75*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 76*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 77*cdf0e10cSrcweir using namespace ::com::sun::star::container; 78*cdf0e10cSrcweir using namespace ::com::sun::star::drawing; 79*cdf0e10cSrcweir using namespace ::com::sun::star::document; 80*cdf0e10cSrcweir using namespace ::xmloff::token; 81*cdf0e10cSrcweir using ::com::sun::star::document::XEventsSupplier; 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir #define XML_TEXT_FRAME_TEXTBOX 1 84*cdf0e10cSrcweir #define XML_TEXT_FRAME_GRAPHIC 2 85*cdf0e10cSrcweir #define XML_TEXT_FRAME_OBJECT 3 86*cdf0e10cSrcweir #define XML_TEXT_FRAME_OBJECT_OLE 4 87*cdf0e10cSrcweir #define XML_TEXT_FRAME_APPLET 5 88*cdf0e10cSrcweir #define XML_TEXT_FRAME_PLUGIN 6 89*cdf0e10cSrcweir #define XML_TEXT_FRAME_FLOATING_FRAME 7 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir typedef ::std::map < const ::rtl::OUString, ::rtl::OUString, ::comphelper::UStringLess> ParamMap; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir class XMLTextFrameContextHyperlink_Impl 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir OUString sHRef; 96*cdf0e10cSrcweir OUString sName; 97*cdf0e10cSrcweir OUString sTargetFrameName; 98*cdf0e10cSrcweir sal_Bool bMap; 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir public: 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir inline XMLTextFrameContextHyperlink_Impl( const OUString& rHRef, 103*cdf0e10cSrcweir const OUString& rName, 104*cdf0e10cSrcweir const OUString& rTargetFrameName, 105*cdf0e10cSrcweir sal_Bool bMap ); 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir const OUString& GetHRef() const { return sHRef; } 108*cdf0e10cSrcweir const OUString& GetName() const { return sName; } 109*cdf0e10cSrcweir const OUString& GetTargetFrameName() const { return sTargetFrameName; } 110*cdf0e10cSrcweir sal_Bool GetMap() const { return bMap; } 111*cdf0e10cSrcweir }; 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir inline XMLTextFrameContextHyperlink_Impl::XMLTextFrameContextHyperlink_Impl( 114*cdf0e10cSrcweir const OUString& rHRef, const OUString& rName, 115*cdf0e10cSrcweir const OUString& rTargetFrameName, sal_Bool bM ) : 116*cdf0e10cSrcweir sHRef( rHRef ), 117*cdf0e10cSrcweir sName( rName ), 118*cdf0e10cSrcweir sTargetFrameName( rTargetFrameName ), 119*cdf0e10cSrcweir bMap( bM ) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir // --> OD 2009-07-22 #i73249# 124*cdf0e10cSrcweir class XMLTextFrameTitleOrDescContext_Impl : public SvXMLImportContext 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir OUString& mrTitleOrDesc; 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir public: 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir TYPEINFO(); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir XMLTextFrameTitleOrDescContext_Impl( SvXMLImport& rImport, 133*cdf0e10cSrcweir sal_uInt16 nPrfx, 134*cdf0e10cSrcweir const ::rtl::OUString& rLName, 135*cdf0e10cSrcweir OUString& rTitleOrDesc ); 136*cdf0e10cSrcweir virtual ~XMLTextFrameTitleOrDescContext_Impl(); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir virtual void Characters( const OUString& rText ); 139*cdf0e10cSrcweir }; 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir TYPEINIT1( XMLTextFrameTitleOrDescContext_Impl, SvXMLImportContext ); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir XMLTextFrameTitleOrDescContext_Impl::XMLTextFrameTitleOrDescContext_Impl( 144*cdf0e10cSrcweir SvXMLImport& rImport, 145*cdf0e10cSrcweir sal_uInt16 nPrfx, 146*cdf0e10cSrcweir const OUString& rLName, 147*cdf0e10cSrcweir OUString& rTitleOrDesc ) 148*cdf0e10cSrcweir : SvXMLImportContext( rImport, nPrfx, rLName ) 149*cdf0e10cSrcweir , mrTitleOrDesc( rTitleOrDesc ) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir XMLTextFrameTitleOrDescContext_Impl::~XMLTextFrameTitleOrDescContext_Impl() 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir void XMLTextFrameTitleOrDescContext_Impl::Characters( const OUString& rText ) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir mrTitleOrDesc += rText; 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir // <-- 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir // ------------------------------------------------------------------------ 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir class XMLTextFrameParam_Impl : public SvXMLImportContext 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir public: 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir TYPEINFO(); 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir XMLTextFrameParam_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx, 172*cdf0e10cSrcweir const ::rtl::OUString& rLName, 173*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 174*cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > & xAttrList, 175*cdf0e10cSrcweir sal_uInt16 nType, 176*cdf0e10cSrcweir ParamMap &rParamMap); 177*cdf0e10cSrcweir virtual ~XMLTextFrameParam_Impl(); 178*cdf0e10cSrcweir }; 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir TYPEINIT1( XMLTextFrameParam_Impl, SvXMLImportContext ); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir XMLTextFrameParam_Impl::~XMLTextFrameParam_Impl() 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir XMLTextFrameParam_Impl::XMLTextFrameParam_Impl( 187*cdf0e10cSrcweir SvXMLImport& rImport, sal_uInt16 nPrfx, 188*cdf0e10cSrcweir const ::rtl::OUString& rLName, 189*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 190*cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > & xAttrList, 191*cdf0e10cSrcweir sal_uInt16 /*nType*/, 192*cdf0e10cSrcweir ParamMap &rParamMap): 193*cdf0e10cSrcweir SvXMLImportContext( rImport, nPrfx, rLName ) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir OUString sName, sValue; 196*cdf0e10cSrcweir sal_Bool bFoundValue = sal_False; // to allow empty values 197*cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 198*cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; i++ ) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir const OUString& rAttrName = xAttrList->getNameByIndex( i ); 201*cdf0e10cSrcweir const OUString& rValue = xAttrList->getValueByIndex( i ); 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir OUString aLocalName; 204*cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName ); 205*cdf0e10cSrcweir if ( XML_NAMESPACE_DRAW == nPrefix ) 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir if( IsXMLToken(aLocalName, XML_VALUE) ) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir sValue = rValue; 210*cdf0e10cSrcweir bFoundValue=sal_True; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir else if( IsXMLToken(aLocalName, XML_NAME) ) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir sName = rValue; 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir if (sName.getLength() && bFoundValue ) 219*cdf0e10cSrcweir rParamMap[sName] = sValue; 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir class XMLTextFrameContourContext_Impl : public SvXMLImportContext 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir Reference < XPropertySet > xPropSet; 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir public: 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir TYPEINFO(); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir XMLTextFrameContourContext_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx, 230*cdf0e10cSrcweir const ::rtl::OUString& rLName, 231*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 232*cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > & xAttrList, 233*cdf0e10cSrcweir const Reference < XPropertySet >& rPropSet, 234*cdf0e10cSrcweir sal_Bool bPath ); 235*cdf0e10cSrcweir virtual ~XMLTextFrameContourContext_Impl(); 236*cdf0e10cSrcweir }; 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir TYPEINIT1( XMLTextFrameContourContext_Impl, SvXMLImportContext ); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl( 241*cdf0e10cSrcweir SvXMLImport& rImport, 242*cdf0e10cSrcweir sal_uInt16 nPrfx, const OUString& rLName, 243*cdf0e10cSrcweir const Reference< XAttributeList > & xAttrList, 244*cdf0e10cSrcweir const Reference < XPropertySet >& rPropSet, 245*cdf0e10cSrcweir sal_Bool bPath ) : 246*cdf0e10cSrcweir SvXMLImportContext( rImport, nPrfx, rLName ), 247*cdf0e10cSrcweir xPropSet( rPropSet ) 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir OUString sD, sPoints, sViewBox; 250*cdf0e10cSrcweir sal_Bool bPixelWidth = sal_False, bPixelHeight = sal_False; 251*cdf0e10cSrcweir sal_Bool bAuto = sal_False; 252*cdf0e10cSrcweir sal_Int32 nWidth = 0; 253*cdf0e10cSrcweir sal_Int32 nHeight = 0; 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir const SvXMLTokenMap& rTokenMap = 256*cdf0e10cSrcweir GetImport().GetTextImport()->GetTextContourAttrTokenMap(); 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 259*cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; i++ ) 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir const OUString& rAttrName = xAttrList->getNameByIndex( i ); 262*cdf0e10cSrcweir const OUString& rValue = xAttrList->getValueByIndex( i ); 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir OUString aLocalName; 265*cdf0e10cSrcweir sal_uInt16 nPrefix = 266*cdf0e10cSrcweir GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, 267*cdf0e10cSrcweir &aLocalName ); 268*cdf0e10cSrcweir switch( rTokenMap.Get( nPrefix, aLocalName ) ) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir case XML_TOK_TEXT_CONTOUR_VIEWBOX: 271*cdf0e10cSrcweir sViewBox = rValue; 272*cdf0e10cSrcweir break; 273*cdf0e10cSrcweir case XML_TOK_TEXT_CONTOUR_D: 274*cdf0e10cSrcweir if( bPath ) 275*cdf0e10cSrcweir sD = rValue; 276*cdf0e10cSrcweir break; 277*cdf0e10cSrcweir case XML_TOK_TEXT_CONTOUR_POINTS: 278*cdf0e10cSrcweir if( !bPath ) 279*cdf0e10cSrcweir sPoints = rValue; 280*cdf0e10cSrcweir break; 281*cdf0e10cSrcweir case XML_TOK_TEXT_CONTOUR_WIDTH: 282*cdf0e10cSrcweir if( GetImport().GetMM100UnitConverter().convertMeasurePx( nWidth, 283*cdf0e10cSrcweir rValue) ) 284*cdf0e10cSrcweir bPixelWidth = sal_True; 285*cdf0e10cSrcweir else 286*cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertMeasure( nWidth, 287*cdf0e10cSrcweir rValue); 288*cdf0e10cSrcweir break; 289*cdf0e10cSrcweir case XML_TOK_TEXT_CONTOUR_HEIGHT: 290*cdf0e10cSrcweir if( GetImport().GetMM100UnitConverter().convertMeasurePx( nHeight, 291*cdf0e10cSrcweir rValue) ) 292*cdf0e10cSrcweir bPixelHeight = sal_True; 293*cdf0e10cSrcweir else 294*cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertMeasure( nHeight, 295*cdf0e10cSrcweir rValue); 296*cdf0e10cSrcweir break; 297*cdf0e10cSrcweir case XML_TOK_TEXT_CONTOUR_AUTO: 298*cdf0e10cSrcweir bAuto = IsXMLToken(rValue, XML_TRUE); 299*cdf0e10cSrcweir break; 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir OUString sContourPolyPolygon( 304*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("ContourPolyPolygon") ); 305*cdf0e10cSrcweir Reference < XPropertySetInfo > xPropSetInfo = 306*cdf0e10cSrcweir rPropSet->getPropertySetInfo(); 307*cdf0e10cSrcweir if( xPropSetInfo->hasPropertyByName( 308*cdf0e10cSrcweir sContourPolyPolygon ) && 309*cdf0e10cSrcweir nWidth > 0 && nHeight > 0 && bPixelWidth == bPixelHeight && 310*cdf0e10cSrcweir (bPath ? sD : sPoints).getLength() ) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir awt::Point aPoint( 0, 0 ); 313*cdf0e10cSrcweir awt::Size aSize( nWidth, nHeight ); 314*cdf0e10cSrcweir SdXMLImExViewBox aViewBox( sViewBox, 315*cdf0e10cSrcweir GetImport().GetMM100UnitConverter()); 316*cdf0e10cSrcweir Any aAny; 317*cdf0e10cSrcweir if( bPath ) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir SdXMLImExSvgDElement aPoints( sD, aViewBox, aPoint, aSize, 320*cdf0e10cSrcweir GetImport().GetMM100UnitConverter() ); 321*cdf0e10cSrcweir aAny <<= aPoints.GetPointSequenceSequence(); 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir else 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir SdXMLImExPointsElement aPoints( sPoints, aViewBox, aPoint, aSize, 326*cdf0e10cSrcweir GetImport().GetMM100UnitConverter() ); 327*cdf0e10cSrcweir aAny <<= aPoints.GetPointSequenceSequence(); 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir OUString sIsPixelContour( 331*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("IsPixelContour") ); 332*cdf0e10cSrcweir xPropSet->setPropertyValue( sContourPolyPolygon, aAny ); 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir if( xPropSetInfo->hasPropertyByName( sIsPixelContour ) ) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir aAny.setValue( &bPixelWidth, ::getBooleanCppuType() ); 337*cdf0e10cSrcweir xPropSet->setPropertyValue( sIsPixelContour, aAny ); 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir OUString sIsAutomaticContour( 341*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("IsAutomaticContour") ); 342*cdf0e10cSrcweir if( xPropSetInfo->hasPropertyByName( sIsAutomaticContour ) ) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir aAny.setValue( &bAuto, ::getBooleanCppuType() ); 345*cdf0e10cSrcweir xPropSet->setPropertyValue( sIsAutomaticContour, aAny ); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir XMLTextFrameContourContext_Impl::~XMLTextFrameContourContext_Impl() 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir // ------------------------------------------------------------------------ 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir class XMLTextFrameContext_Impl : public SvXMLImportContext 357*cdf0e10cSrcweir { 358*cdf0e10cSrcweir ::com::sun::star::uno::Reference < 359*cdf0e10cSrcweir ::com::sun::star::text::XTextCursor > xOldTextCursor; 360*cdf0e10cSrcweir ::com::sun::star::uno::Reference < 361*cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet > xPropSet; 362*cdf0e10cSrcweir ::com::sun::star::uno::Reference < 363*cdf0e10cSrcweir ::com::sun::star::io::XOutputStream > xBase64Stream; 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir /// old list item and block (#89891#) 366*cdf0e10cSrcweir bool mbListContextPushed; 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir const ::rtl::OUString sWidth; 369*cdf0e10cSrcweir const ::rtl::OUString sWidthType; 370*cdf0e10cSrcweir const ::rtl::OUString sRelativeWidth; 371*cdf0e10cSrcweir const ::rtl::OUString sHeight; 372*cdf0e10cSrcweir const ::rtl::OUString sRelativeHeight; 373*cdf0e10cSrcweir const ::rtl::OUString sSizeType; 374*cdf0e10cSrcweir const ::rtl::OUString sIsSyncWidthToHeight; 375*cdf0e10cSrcweir const ::rtl::OUString sIsSyncHeightToWidth; 376*cdf0e10cSrcweir const ::rtl::OUString sHoriOrient; 377*cdf0e10cSrcweir const ::rtl::OUString sHoriOrientPosition; 378*cdf0e10cSrcweir const ::rtl::OUString sVertOrient; 379*cdf0e10cSrcweir const ::rtl::OUString sVertOrientPosition; 380*cdf0e10cSrcweir const ::rtl::OUString sChainNextName; 381*cdf0e10cSrcweir const ::rtl::OUString sAnchorType; 382*cdf0e10cSrcweir const ::rtl::OUString sAnchorPageNo; 383*cdf0e10cSrcweir const ::rtl::OUString sGraphicURL; 384*cdf0e10cSrcweir const ::rtl::OUString sGraphicFilter; 385*cdf0e10cSrcweir // --> OD 2009-07-22 #i73249# 386*cdf0e10cSrcweir // const ::rtl::OUString sAlternativeText; 387*cdf0e10cSrcweir const ::rtl::OUString sTitle; 388*cdf0e10cSrcweir const ::rtl::OUString sDescription; 389*cdf0e10cSrcweir // <-- 390*cdf0e10cSrcweir const ::rtl::OUString sFrameStyleName; 391*cdf0e10cSrcweir const ::rtl::OUString sGraphicRotation; 392*cdf0e10cSrcweir const ::rtl::OUString sTextBoxServiceName; 393*cdf0e10cSrcweir const ::rtl::OUString sGraphicServiceName; 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir ::rtl::OUString sName; 396*cdf0e10cSrcweir ::rtl::OUString sStyleName; 397*cdf0e10cSrcweir ::rtl::OUString sNextName; 398*cdf0e10cSrcweir ::rtl::OUString sHRef; 399*cdf0e10cSrcweir ::rtl::OUString sFilterName; 400*cdf0e10cSrcweir ::rtl::OUString sCode; 401*cdf0e10cSrcweir ::rtl::OUString sObject; 402*cdf0e10cSrcweir ::rtl::OUString sArchive; 403*cdf0e10cSrcweir ::rtl::OUString sMimeType; 404*cdf0e10cSrcweir ::rtl::OUString sFrameName; 405*cdf0e10cSrcweir ::rtl::OUString sAppletName; 406*cdf0e10cSrcweir ::rtl::OUString sFilterService; 407*cdf0e10cSrcweir ::rtl::OUString sBase64CharsLeft; 408*cdf0e10cSrcweir ::rtl::OUString sTblName; 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir ParamMap aParamMap; 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir sal_Int32 nX; 413*cdf0e10cSrcweir sal_Int32 nY; 414*cdf0e10cSrcweir sal_Int32 nWidth; 415*cdf0e10cSrcweir sal_Int32 nHeight; 416*cdf0e10cSrcweir sal_Int32 nZIndex; 417*cdf0e10cSrcweir sal_Int16 nPage; 418*cdf0e10cSrcweir sal_Int16 nRotation; 419*cdf0e10cSrcweir sal_Int16 nRelWidth; 420*cdf0e10cSrcweir sal_Int16 nRelHeight; 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir sal_uInt16 nType; 423*cdf0e10cSrcweir ::com::sun::star::text::TextContentAnchorType eAnchorType; 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir sal_Bool bMayScript : 1; 426*cdf0e10cSrcweir sal_Bool bMinWidth : 1; 427*cdf0e10cSrcweir sal_Bool bMinHeight : 1; 428*cdf0e10cSrcweir sal_Bool bSyncWidth : 1; 429*cdf0e10cSrcweir sal_Bool bSyncHeight : 1; 430*cdf0e10cSrcweir sal_Bool bCreateFailed : 1; 431*cdf0e10cSrcweir sal_Bool bOwnBase64Stream : 1; 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir void Create( sal_Bool bHRefOrBase64 ); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir public: 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir TYPEINFO(); 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir sal_Bool CreateIfNotThere(); 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir XMLTextFrameContext_Impl( SvXMLImport& rImport, 442*cdf0e10cSrcweir sal_uInt16 nPrfx, 443*cdf0e10cSrcweir const ::rtl::OUString& rLName, 444*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 445*cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > & rAttrList, 446*cdf0e10cSrcweir ::com::sun::star::text::TextContentAnchorType eAnchorType, 447*cdf0e10cSrcweir sal_uInt16 nType, 448*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 449*cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > & rFrameAttrList ); 450*cdf0e10cSrcweir virtual ~XMLTextFrameContext_Impl(); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir virtual void EndElement(); 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir virtual void Characters( const ::rtl::OUString& rChars ); 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 457*cdf0e10cSrcweir const ::rtl::OUString& rLocalName, 458*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 459*cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir void SetHyperlink( const ::rtl::OUString& rHRef, 462*cdf0e10cSrcweir const ::rtl::OUString& rName, 463*cdf0e10cSrcweir const ::rtl::OUString& rTargetFrameName, 464*cdf0e10cSrcweir sal_Bool bMap ); 465*cdf0e10cSrcweir // --> OD 2009-07-22 #i73249# 466*cdf0e10cSrcweir void SetTitle( const ::rtl::OUString& rTitle ); 467*cdf0e10cSrcweir // <-- 468*cdf0e10cSrcweir void SetDesc( const ::rtl::OUString& rDesc ); 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir ::com::sun::star::text::TextContentAnchorType GetAnchorType() const { return eAnchorType; } 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir const ::com::sun::star::uno::Reference < 473*cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet >& GetPropSet() { return xPropSet; } 474*cdf0e10cSrcweir }; 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir TYPEINIT1( XMLTextFrameContext_Impl, SvXMLImportContext ); 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir void XMLTextFrameContext_Impl::Create( sal_Bool /*bHRefOrBase64*/ ) 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir UniReference < XMLTextImportHelper > xTextImportHelper = 481*cdf0e10cSrcweir GetImport().GetTextImport(); 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir switch ( nType) 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir case XML_TEXT_FRAME_OBJECT: 486*cdf0e10cSrcweir case XML_TEXT_FRAME_OBJECT_OLE: 487*cdf0e10cSrcweir if( xBase64Stream.is() ) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir OUString sURL( GetImport().ResolveEmbeddedObjectURLFromBase64() ); 490*cdf0e10cSrcweir if( sURL.getLength() ) 491*cdf0e10cSrcweir xPropSet = GetImport().GetTextImport() 492*cdf0e10cSrcweir ->createAndInsertOLEObject( GetImport(), sURL, 493*cdf0e10cSrcweir sStyleName, 494*cdf0e10cSrcweir sTblName, 495*cdf0e10cSrcweir nWidth, nHeight ); 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir else if( sHRef.getLength() ) 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir OUString sURL( GetImport().ResolveEmbeddedObjectURL( sHRef, 500*cdf0e10cSrcweir OUString() ) ); 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir if( GetImport().IsPackageURL( sHRef ) ) 503*cdf0e10cSrcweir { 504*cdf0e10cSrcweir xPropSet = GetImport().GetTextImport() 505*cdf0e10cSrcweir ->createAndInsertOLEObject( GetImport(), sURL, 506*cdf0e10cSrcweir sStyleName, 507*cdf0e10cSrcweir sTblName, 508*cdf0e10cSrcweir nWidth, nHeight ); 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir else 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir // it should be an own OOo link that has no storage persistance 513*cdf0e10cSrcweir xPropSet = GetImport().GetTextImport() 514*cdf0e10cSrcweir ->createAndInsertOOoLink( GetImport(), 515*cdf0e10cSrcweir sURL, 516*cdf0e10cSrcweir sStyleName, 517*cdf0e10cSrcweir sTblName, 518*cdf0e10cSrcweir nWidth, nHeight ); 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir else 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir OUString sURL( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.ServiceName:") ); 524*cdf0e10cSrcweir sURL += sFilterService; 525*cdf0e10cSrcweir xPropSet = GetImport().GetTextImport() 526*cdf0e10cSrcweir ->createAndInsertOLEObject( GetImport(), sURL, 527*cdf0e10cSrcweir sStyleName, 528*cdf0e10cSrcweir sTblName, 529*cdf0e10cSrcweir nWidth, nHeight ); 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir break; 533*cdf0e10cSrcweir case XML_TEXT_FRAME_APPLET: 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir xPropSet = GetImport().GetTextImport() 536*cdf0e10cSrcweir ->createAndInsertApplet( sAppletName, sCode, 537*cdf0e10cSrcweir bMayScript, sHRef, 538*cdf0e10cSrcweir nWidth, nHeight); 539*cdf0e10cSrcweir break; 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir case XML_TEXT_FRAME_PLUGIN: 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir if(sHRef.getLength()) 544*cdf0e10cSrcweir GetImport().GetAbsoluteReference(sHRef); 545*cdf0e10cSrcweir xPropSet = GetImport().GetTextImport() 546*cdf0e10cSrcweir ->createAndInsertPlugin( sMimeType, sHRef, 547*cdf0e10cSrcweir nWidth, nHeight); 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir break; 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir case XML_TEXT_FRAME_FLOATING_FRAME: 552*cdf0e10cSrcweir { 553*cdf0e10cSrcweir xPropSet = GetImport().GetTextImport() 554*cdf0e10cSrcweir ->createAndInsertFloatingFrame( sFrameName, sHRef, 555*cdf0e10cSrcweir sStyleName, 556*cdf0e10cSrcweir nWidth, nHeight); 557*cdf0e10cSrcweir break; 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir default: 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir Reference<XMultiServiceFactory> xFactory( GetImport().GetModel(), 562*cdf0e10cSrcweir UNO_QUERY ); 563*cdf0e10cSrcweir if( xFactory.is() ) 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir OUString sServiceName; 566*cdf0e10cSrcweir switch( nType ) 567*cdf0e10cSrcweir { 568*cdf0e10cSrcweir case XML_TEXT_FRAME_TEXTBOX: sServiceName = sTextBoxServiceName; break; 569*cdf0e10cSrcweir case XML_TEXT_FRAME_GRAPHIC: sServiceName = sGraphicServiceName; break; 570*cdf0e10cSrcweir } 571*cdf0e10cSrcweir Reference<XInterface> xIfc = xFactory->createInstance( sServiceName ); 572*cdf0e10cSrcweir DBG_ASSERT( xIfc.is(), "couldn't create frame" ); 573*cdf0e10cSrcweir if( xIfc.is() ) 574*cdf0e10cSrcweir xPropSet = Reference < XPropertySet >( xIfc, UNO_QUERY ); 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir } 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir if( !xPropSet.is() ) 580*cdf0e10cSrcweir { 581*cdf0e10cSrcweir bCreateFailed = sal_True; 582*cdf0e10cSrcweir return; 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir // set name 588*cdf0e10cSrcweir Reference < XNamed > xNamed( xPropSet, UNO_QUERY ); 589*cdf0e10cSrcweir if( xNamed.is() ) 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir OUString sOrigName( xNamed->getName() ); 592*cdf0e10cSrcweir if( !sOrigName.getLength() || 593*cdf0e10cSrcweir (sName.getLength() && sOrigName != sName) ) 594*cdf0e10cSrcweir { 595*cdf0e10cSrcweir OUString sOldName( sName ); 596*cdf0e10cSrcweir sal_Int32 i = 0; 597*cdf0e10cSrcweir while( xTextImportHelper->HasFrameByName( sName ) ) 598*cdf0e10cSrcweir { 599*cdf0e10cSrcweir sName = sOldName; 600*cdf0e10cSrcweir sName += OUString::valueOf( ++i ); 601*cdf0e10cSrcweir } 602*cdf0e10cSrcweir xNamed->setName( sName ); 603*cdf0e10cSrcweir if( sName != sOldName ) 604*cdf0e10cSrcweir xTextImportHelper->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_FRAME, 605*cdf0e10cSrcweir sOldName, sName ); 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir // frame style 610*cdf0e10cSrcweir XMLPropStyleContext *pStyle = 0; 611*cdf0e10cSrcweir if( sStyleName.getLength() ) 612*cdf0e10cSrcweir { 613*cdf0e10cSrcweir pStyle = xTextImportHelper->FindAutoFrameStyle( sStyleName ); 614*cdf0e10cSrcweir if( pStyle ) 615*cdf0e10cSrcweir sStyleName = pStyle->GetParentName(); 616*cdf0e10cSrcweir } 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir Any aAny; 619*cdf0e10cSrcweir if( sStyleName.getLength() ) 620*cdf0e10cSrcweir { 621*cdf0e10cSrcweir OUString sDisplayStyleName( GetImport().GetStyleDisplayName( 622*cdf0e10cSrcweir XML_STYLE_FAMILY_SD_GRAPHICS_ID, sStyleName ) ); 623*cdf0e10cSrcweir const Reference < XNameContainer > & rStyles = 624*cdf0e10cSrcweir xTextImportHelper->GetFrameStyles(); 625*cdf0e10cSrcweir if( rStyles.is() && 626*cdf0e10cSrcweir rStyles->hasByName( sDisplayStyleName ) ) 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir aAny <<= sDisplayStyleName; 629*cdf0e10cSrcweir xPropSet->setPropertyValue( sFrameStyleName, aAny ); 630*cdf0e10cSrcweir } 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir // anchor type (must be set before any other properties, because 634*cdf0e10cSrcweir // otherwise some orientations cannot be set or will be changed 635*cdf0e10cSrcweir // afterwards) 636*cdf0e10cSrcweir aAny <<= eAnchorType; 637*cdf0e10cSrcweir xPropSet->setPropertyValue( sAnchorType, aAny ); 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir // hard properties 640*cdf0e10cSrcweir if( pStyle ) 641*cdf0e10cSrcweir pStyle->FillPropertySet( xPropSet ); 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir // x and y 645*cdf0e10cSrcweir sal_Int16 nHoriOrient = HoriOrientation::NONE; 646*cdf0e10cSrcweir aAny = xPropSet->getPropertyValue( sHoriOrient ); 647*cdf0e10cSrcweir aAny >>= nHoriOrient; 648*cdf0e10cSrcweir if( HoriOrientation::NONE == nHoriOrient ) 649*cdf0e10cSrcweir { 650*cdf0e10cSrcweir aAny <<= nX; 651*cdf0e10cSrcweir xPropSet->setPropertyValue( sHoriOrientPosition, aAny ); 652*cdf0e10cSrcweir } 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir sal_Int16 nVertOrient = VertOrientation::NONE; 655*cdf0e10cSrcweir aAny = xPropSet->getPropertyValue( sVertOrient ); 656*cdf0e10cSrcweir aAny >>= nVertOrient; 657*cdf0e10cSrcweir if( VertOrientation::NONE == nVertOrient ) 658*cdf0e10cSrcweir { 659*cdf0e10cSrcweir aAny <<= nY; 660*cdf0e10cSrcweir xPropSet->setPropertyValue( sVertOrientPosition, aAny ); 661*cdf0e10cSrcweir } 662*cdf0e10cSrcweir 663*cdf0e10cSrcweir // width 664*cdf0e10cSrcweir if( nWidth > 0 ) 665*cdf0e10cSrcweir { 666*cdf0e10cSrcweir aAny <<= nWidth; 667*cdf0e10cSrcweir xPropSet->setPropertyValue( sWidth, aAny ); 668*cdf0e10cSrcweir } 669*cdf0e10cSrcweir if( nRelWidth > 0 || nWidth > 0 ) 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir aAny <<= nRelWidth; 672*cdf0e10cSrcweir xPropSet->setPropertyValue( sRelativeWidth, aAny ); 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir if( bSyncWidth || nWidth > 0 ) 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir sal_Bool bTmp = bSyncWidth; 677*cdf0e10cSrcweir aAny.setValue( &bTmp, ::getBooleanCppuType() ); 678*cdf0e10cSrcweir xPropSet->setPropertyValue( sIsSyncWidthToHeight, aAny ); 679*cdf0e10cSrcweir } 680*cdf0e10cSrcweir if( xPropSetInfo->hasPropertyByName( sWidthType ) && 681*cdf0e10cSrcweir (bMinWidth || nWidth > 0 || nRelWidth > 0 ) ) 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir sal_Int16 nSizeType = 684*cdf0e10cSrcweir (bMinWidth && XML_TEXT_FRAME_TEXTBOX == nType) ? SizeType::MIN 685*cdf0e10cSrcweir : SizeType::FIX; 686*cdf0e10cSrcweir aAny <<= nSizeType; 687*cdf0e10cSrcweir xPropSet->setPropertyValue( sWidthType, aAny ); 688*cdf0e10cSrcweir } 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir if( nHeight > 0 ) 691*cdf0e10cSrcweir { 692*cdf0e10cSrcweir aAny <<= nHeight; 693*cdf0e10cSrcweir xPropSet->setPropertyValue( sHeight, aAny ); 694*cdf0e10cSrcweir } 695*cdf0e10cSrcweir if( nRelHeight > 0 || nHeight > 0 ) 696*cdf0e10cSrcweir { 697*cdf0e10cSrcweir aAny <<= nRelHeight; 698*cdf0e10cSrcweir xPropSet->setPropertyValue( sRelativeHeight, aAny ); 699*cdf0e10cSrcweir } 700*cdf0e10cSrcweir if( bSyncHeight || nHeight > 0 ) 701*cdf0e10cSrcweir { 702*cdf0e10cSrcweir sal_Bool bTmp = bSyncHeight; 703*cdf0e10cSrcweir aAny.setValue( &bTmp, ::getBooleanCppuType() ); 704*cdf0e10cSrcweir xPropSet->setPropertyValue( sIsSyncHeightToWidth, aAny ); 705*cdf0e10cSrcweir } 706*cdf0e10cSrcweir if( xPropSetInfo->hasPropertyByName( sSizeType ) && 707*cdf0e10cSrcweir (bMinHeight || nHeight > 0 || nRelHeight > 0 ) ) 708*cdf0e10cSrcweir { 709*cdf0e10cSrcweir sal_Int16 nSizeType = 710*cdf0e10cSrcweir (bMinHeight && XML_TEXT_FRAME_TEXTBOX == nType) ? SizeType::MIN 711*cdf0e10cSrcweir : SizeType::FIX; 712*cdf0e10cSrcweir aAny <<= nSizeType; 713*cdf0e10cSrcweir xPropSet->setPropertyValue( sSizeType, aAny ); 714*cdf0e10cSrcweir } 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir if( XML_TEXT_FRAME_GRAPHIC == nType ) 717*cdf0e10cSrcweir { 718*cdf0e10cSrcweir // URL 719*cdf0e10cSrcweir OSL_ENSURE( sHRef.getLength() > 0 || xBase64Stream.is(), 720*cdf0e10cSrcweir "neither URL nor base64 image data given" ); 721*cdf0e10cSrcweir UniReference < XMLTextImportHelper > xTxtImport = 722*cdf0e10cSrcweir GetImport().GetTextImport(); 723*cdf0e10cSrcweir if( sHRef.getLength() ) 724*cdf0e10cSrcweir { 725*cdf0e10cSrcweir sal_Bool bForceLoad = xTxtImport->IsInsertMode() || 726*cdf0e10cSrcweir xTxtImport->IsBlockMode() || 727*cdf0e10cSrcweir xTxtImport->IsStylesOnlyMode() || 728*cdf0e10cSrcweir xTxtImport->IsOrganizerMode(); 729*cdf0e10cSrcweir sHRef = GetImport().ResolveGraphicObjectURL( sHRef, !bForceLoad ); 730*cdf0e10cSrcweir } 731*cdf0e10cSrcweir else if( xBase64Stream.is() ) 732*cdf0e10cSrcweir { 733*cdf0e10cSrcweir sHRef = GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream ); 734*cdf0e10cSrcweir xBase64Stream = 0; 735*cdf0e10cSrcweir } 736*cdf0e10cSrcweir aAny <<= sHRef; 737*cdf0e10cSrcweir xPropSet->setPropertyValue( sGraphicURL, aAny ); 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir // filter name 740*cdf0e10cSrcweir aAny <<=sFilterName; 741*cdf0e10cSrcweir xPropSet->setPropertyValue( sGraphicFilter, aAny ); 742*cdf0e10cSrcweir 743*cdf0e10cSrcweir // rotation 744*cdf0e10cSrcweir aAny <<= nRotation; 745*cdf0e10cSrcweir xPropSet->setPropertyValue( sGraphicRotation, aAny ); 746*cdf0e10cSrcweir } 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir // page number (must be set after the frame is inserted, because it 749*cdf0e10cSrcweir // will be overwritten then inserting the frame. 750*cdf0e10cSrcweir if( TextContentAnchorType_AT_PAGE == eAnchorType && nPage > 0 ) 751*cdf0e10cSrcweir { 752*cdf0e10cSrcweir aAny <<= nPage; 753*cdf0e10cSrcweir xPropSet->setPropertyValue( sAnchorPageNo, aAny ); 754*cdf0e10cSrcweir } 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir if( XML_TEXT_FRAME_OBJECT != nType && 757*cdf0e10cSrcweir XML_TEXT_FRAME_OBJECT_OLE != nType && 758*cdf0e10cSrcweir XML_TEXT_FRAME_APPLET != nType && 759*cdf0e10cSrcweir XML_TEXT_FRAME_PLUGIN!= nType && 760*cdf0e10cSrcweir XML_TEXT_FRAME_FLOATING_FRAME != nType) 761*cdf0e10cSrcweir { 762*cdf0e10cSrcweir Reference < XTextContent > xTxtCntnt( xPropSet, UNO_QUERY ); 763*cdf0e10cSrcweir xTextImportHelper->InsertTextContent( xTxtCntnt ); 764*cdf0e10cSrcweir } 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir Reference < XShape > xShape( xPropSet, UNO_QUERY ); 767*cdf0e10cSrcweir 768*cdf0e10cSrcweir // #107848# 769*cdf0e10cSrcweir // Make adding the shepe to Z-Ordering dependent from if we are 770*cdf0e10cSrcweir // inside a inside_deleted_section (redlining). That is necessary 771*cdf0e10cSrcweir // since the shape will be removed again later. It would lead to 772*cdf0e10cSrcweir // errors if it would stay inside the Z-Ordering. Thus, the 773*cdf0e10cSrcweir // easiest way to solve that conflict is to not add it here. 774*cdf0e10cSrcweir if(!GetImport().HasTextImport() 775*cdf0e10cSrcweir || !GetImport().GetTextImport()->IsInsideDeleteContext()) 776*cdf0e10cSrcweir { 777*cdf0e10cSrcweir GetImport().GetShapeImport()->shapeWithZIndexAdded( xShape, nZIndex ); 778*cdf0e10cSrcweir } 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir if( XML_TEXT_FRAME_TEXTBOX == nType ) 781*cdf0e10cSrcweir { 782*cdf0e10cSrcweir xTextImportHelper->ConnectFrameChains( sName, sNextName, xPropSet ); 783*cdf0e10cSrcweir Reference < XTextFrame > xTxtFrame( xPropSet, UNO_QUERY ); 784*cdf0e10cSrcweir Reference < XText > xTxt = xTxtFrame->getText(); 785*cdf0e10cSrcweir xOldTextCursor = xTextImportHelper->GetCursor(); 786*cdf0e10cSrcweir xTextImportHelper->SetCursor( xTxt->createTextCursor() ); 787*cdf0e10cSrcweir 788*cdf0e10cSrcweir // remember old list item and block (#89892#) and reset them 789*cdf0e10cSrcweir // for the text frame 790*cdf0e10cSrcweir xTextImportHelper->PushListContext(); 791*cdf0e10cSrcweir mbListContextPushed = true; 792*cdf0e10cSrcweir } 793*cdf0e10cSrcweir } 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir sal_Bool XMLTextFrameContext_Impl::CreateIfNotThere() 796*cdf0e10cSrcweir { 797*cdf0e10cSrcweir if( !xPropSet.is() && 798*cdf0e10cSrcweir ( XML_TEXT_FRAME_OBJECT_OLE == nType || 799*cdf0e10cSrcweir XML_TEXT_FRAME_GRAPHIC == nType ) && 800*cdf0e10cSrcweir xBase64Stream.is() && !bCreateFailed ) 801*cdf0e10cSrcweir { 802*cdf0e10cSrcweir if( bOwnBase64Stream ) 803*cdf0e10cSrcweir xBase64Stream->closeOutput(); 804*cdf0e10cSrcweir Create( sal_True ); 805*cdf0e10cSrcweir } 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir return xPropSet.is(); 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( 811*cdf0e10cSrcweir SvXMLImport& rImport, 812*cdf0e10cSrcweir sal_uInt16 nPrfx, const OUString& rLName, 813*cdf0e10cSrcweir const Reference< XAttributeList > & rAttrList, 814*cdf0e10cSrcweir TextContentAnchorType eATyp, 815*cdf0e10cSrcweir sal_uInt16 nNewType, 816*cdf0e10cSrcweir const Reference< XAttributeList > & rFrameAttrList ) 817*cdf0e10cSrcweir : SvXMLImportContext( rImport, nPrfx, rLName ) 818*cdf0e10cSrcweir , mbListContextPushed( false ) 819*cdf0e10cSrcweir , sWidth(RTL_CONSTASCII_USTRINGPARAM("Width")) 820*cdf0e10cSrcweir , sWidthType(RTL_CONSTASCII_USTRINGPARAM("WidthType")) 821*cdf0e10cSrcweir , sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth")) 822*cdf0e10cSrcweir , sHeight(RTL_CONSTASCII_USTRINGPARAM("Height")) 823*cdf0e10cSrcweir , sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight")) 824*cdf0e10cSrcweir , sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType")) 825*cdf0e10cSrcweir , sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight")) 826*cdf0e10cSrcweir , sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth")) 827*cdf0e10cSrcweir , sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")) 828*cdf0e10cSrcweir , sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")) 829*cdf0e10cSrcweir , sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient")) 830*cdf0e10cSrcweir , sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")) 831*cdf0e10cSrcweir , sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName")) 832*cdf0e10cSrcweir , sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType")) 833*cdf0e10cSrcweir , sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo")) 834*cdf0e10cSrcweir , sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")) 835*cdf0e10cSrcweir , sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter")) 836*cdf0e10cSrcweir // --> OD 2009-07-22 #i73249# 837*cdf0e10cSrcweir //, sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")) 838*cdf0e10cSrcweir , sTitle(RTL_CONSTASCII_USTRINGPARAM("Title")) 839*cdf0e10cSrcweir , sDescription(RTL_CONSTASCII_USTRINGPARAM("Description")) 840*cdf0e10cSrcweir // <-- 841*cdf0e10cSrcweir , sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName")) 842*cdf0e10cSrcweir , sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation")) 843*cdf0e10cSrcweir , sTextBoxServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame")) 844*cdf0e10cSrcweir , sGraphicServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GraphicObject")) 845*cdf0e10cSrcweir , nType( nNewType ) 846*cdf0e10cSrcweir , eAnchorType( eATyp ) 847*cdf0e10cSrcweir { 848*cdf0e10cSrcweir nX = 0; 849*cdf0e10cSrcweir nY = 0; 850*cdf0e10cSrcweir nWidth = 0; 851*cdf0e10cSrcweir nHeight = 0; 852*cdf0e10cSrcweir nZIndex = -1; 853*cdf0e10cSrcweir nPage = 0; 854*cdf0e10cSrcweir nRotation = 0; 855*cdf0e10cSrcweir nRelWidth = 0; 856*cdf0e10cSrcweir nRelHeight = 0; 857*cdf0e10cSrcweir bMayScript = sal_False; 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir bMinHeight = sal_False; 860*cdf0e10cSrcweir bMinWidth = sal_False; 861*cdf0e10cSrcweir bSyncWidth = sal_False; 862*cdf0e10cSrcweir bSyncHeight = sal_False; 863*cdf0e10cSrcweir bCreateFailed = sal_False; 864*cdf0e10cSrcweir bOwnBase64Stream = sal_False; 865*cdf0e10cSrcweir 866*cdf0e10cSrcweir UniReference < XMLTextImportHelper > xTxtImport = 867*cdf0e10cSrcweir GetImport().GetTextImport(); 868*cdf0e10cSrcweir const SvXMLTokenMap& rTokenMap = 869*cdf0e10cSrcweir xTxtImport->GetTextFrameAttrTokenMap(); 870*cdf0e10cSrcweir 871*cdf0e10cSrcweir sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0; 872*cdf0e10cSrcweir sal_Int16 nTotalAttrCount = nAttrCount + (rFrameAttrList.is() ? rFrameAttrList->getLength() : 0); 873*cdf0e10cSrcweir for( sal_Int16 i=0; i < nTotalAttrCount; i++ ) 874*cdf0e10cSrcweir { 875*cdf0e10cSrcweir const OUString& rAttrName = 876*cdf0e10cSrcweir i < nAttrCount ? rAttrList->getNameByIndex( i ) : rFrameAttrList->getNameByIndex( i-nAttrCount ); 877*cdf0e10cSrcweir const OUString& rValue = 878*cdf0e10cSrcweir i < nAttrCount ? rAttrList->getValueByIndex( i ): rFrameAttrList->getValueByIndex( i-nAttrCount ); 879*cdf0e10cSrcweir 880*cdf0e10cSrcweir OUString aLocalName; 881*cdf0e10cSrcweir sal_uInt16 nPrefix = 882*cdf0e10cSrcweir GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, 883*cdf0e10cSrcweir &aLocalName ); 884*cdf0e10cSrcweir switch( rTokenMap.Get( nPrefix, aLocalName ) ) 885*cdf0e10cSrcweir { 886*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_STYLE_NAME: 887*cdf0e10cSrcweir sStyleName = rValue; 888*cdf0e10cSrcweir break; 889*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_NAME: 890*cdf0e10cSrcweir sName = rValue; 891*cdf0e10cSrcweir break; 892*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_FRAME_NAME: 893*cdf0e10cSrcweir sFrameName = rValue; 894*cdf0e10cSrcweir break; 895*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_APPLET_NAME: 896*cdf0e10cSrcweir sAppletName = rValue; 897*cdf0e10cSrcweir break; 898*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_ANCHOR_TYPE: 899*cdf0e10cSrcweir if( TextContentAnchorType_AT_PARAGRAPH == eAnchorType || 900*cdf0e10cSrcweir TextContentAnchorType_AT_CHARACTER == eAnchorType || 901*cdf0e10cSrcweir TextContentAnchorType_AS_CHARACTER == eAnchorType ) 902*cdf0e10cSrcweir { 903*cdf0e10cSrcweir 904*cdf0e10cSrcweir TextContentAnchorType eNew; 905*cdf0e10cSrcweir if( XMLAnchorTypePropHdl::convert( rValue, eNew ) && 906*cdf0e10cSrcweir ( TextContentAnchorType_AT_PARAGRAPH == eNew || 907*cdf0e10cSrcweir TextContentAnchorType_AT_CHARACTER == eNew || 908*cdf0e10cSrcweir TextContentAnchorType_AS_CHARACTER == eNew || 909*cdf0e10cSrcweir TextContentAnchorType_AT_PAGE == eNew) ) 910*cdf0e10cSrcweir eAnchorType = eNew; 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir break; 913*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_ANCHOR_PAGE_NUMBER: 914*cdf0e10cSrcweir { 915*cdf0e10cSrcweir sal_Int32 nTmp; 916*cdf0e10cSrcweir if( GetImport().GetMM100UnitConverter(). 917*cdf0e10cSrcweir convertNumber( nTmp, rValue, 1, SHRT_MAX ) ) 918*cdf0e10cSrcweir nPage = (sal_Int16)nTmp; 919*cdf0e10cSrcweir } 920*cdf0e10cSrcweir break; 921*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_X: 922*cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertMeasure( nX, rValue ); 923*cdf0e10cSrcweir break; 924*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_Y: 925*cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertMeasure( nY, rValue ); 926*cdf0e10cSrcweir break; 927*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_WIDTH: 928*cdf0e10cSrcweir // relative widths are obsolete since SRC617. Remove them some day! 929*cdf0e10cSrcweir if( rValue.indexOf( '%' ) != -1 ) 930*cdf0e10cSrcweir { 931*cdf0e10cSrcweir sal_Int32 nTmp; 932*cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertPercent( nTmp, 933*cdf0e10cSrcweir rValue ); 934*cdf0e10cSrcweir nRelWidth = (sal_Int16)nTmp; 935*cdf0e10cSrcweir } 936*cdf0e10cSrcweir else 937*cdf0e10cSrcweir { 938*cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertMeasure( nWidth, 939*cdf0e10cSrcweir rValue, 0 ); 940*cdf0e10cSrcweir } 941*cdf0e10cSrcweir break; 942*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_REL_WIDTH: 943*cdf0e10cSrcweir if( IsXMLToken(rValue, XML_SCALE) ) 944*cdf0e10cSrcweir { 945*cdf0e10cSrcweir bSyncWidth = sal_True; 946*cdf0e10cSrcweir } 947*cdf0e10cSrcweir else 948*cdf0e10cSrcweir { 949*cdf0e10cSrcweir sal_Int32 nTmp; 950*cdf0e10cSrcweir if( GetImport().GetMM100UnitConverter(). 951*cdf0e10cSrcweir convertPercent( nTmp, rValue ) ) 952*cdf0e10cSrcweir nRelWidth = (sal_Int16)nTmp; 953*cdf0e10cSrcweir } 954*cdf0e10cSrcweir break; 955*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_MIN_WIDTH: 956*cdf0e10cSrcweir if( rValue.indexOf( '%' ) != -1 ) 957*cdf0e10cSrcweir { 958*cdf0e10cSrcweir sal_Int32 nTmp; 959*cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertPercent( nTmp, 960*cdf0e10cSrcweir rValue ); 961*cdf0e10cSrcweir nRelWidth = (sal_Int16)nTmp; 962*cdf0e10cSrcweir } 963*cdf0e10cSrcweir else 964*cdf0e10cSrcweir { 965*cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertMeasure( nWidth, 966*cdf0e10cSrcweir rValue, 0 ); 967*cdf0e10cSrcweir } 968*cdf0e10cSrcweir bMinWidth = sal_True; 969*cdf0e10cSrcweir break; 970*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_HEIGHT: 971*cdf0e10cSrcweir // relative heights are obsolete since SRC617. Remove them some day! 972*cdf0e10cSrcweir if( rValue.indexOf( '%' ) != -1 ) 973*cdf0e10cSrcweir { 974*cdf0e10cSrcweir sal_Int32 nTmp; 975*cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertPercent( nTmp, 976*cdf0e10cSrcweir rValue ); 977*cdf0e10cSrcweir nRelHeight = (sal_Int16)nTmp; 978*cdf0e10cSrcweir } 979*cdf0e10cSrcweir else 980*cdf0e10cSrcweir { 981*cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertMeasure( nHeight, 982*cdf0e10cSrcweir rValue, 0 ); 983*cdf0e10cSrcweir } 984*cdf0e10cSrcweir break; 985*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_REL_HEIGHT: 986*cdf0e10cSrcweir if( IsXMLToken( rValue, XML_SCALE ) ) 987*cdf0e10cSrcweir { 988*cdf0e10cSrcweir bSyncHeight = sal_True; 989*cdf0e10cSrcweir } 990*cdf0e10cSrcweir else if( IsXMLToken( rValue, XML_SCALE_MIN ) ) 991*cdf0e10cSrcweir { 992*cdf0e10cSrcweir bSyncHeight = sal_True; 993*cdf0e10cSrcweir bMinHeight = sal_True; 994*cdf0e10cSrcweir } 995*cdf0e10cSrcweir else 996*cdf0e10cSrcweir { 997*cdf0e10cSrcweir sal_Int32 nTmp; 998*cdf0e10cSrcweir if( GetImport().GetMM100UnitConverter(). 999*cdf0e10cSrcweir convertPercent( nTmp, rValue ) ) 1000*cdf0e10cSrcweir nRelHeight = (sal_Int16)nTmp; 1001*cdf0e10cSrcweir } 1002*cdf0e10cSrcweir break; 1003*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_MIN_HEIGHT: 1004*cdf0e10cSrcweir if( rValue.indexOf( '%' ) != -1 ) 1005*cdf0e10cSrcweir { 1006*cdf0e10cSrcweir sal_Int32 nTmp; 1007*cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertPercent( nTmp, 1008*cdf0e10cSrcweir rValue ); 1009*cdf0e10cSrcweir nRelHeight = (sal_Int16)nTmp; 1010*cdf0e10cSrcweir } 1011*cdf0e10cSrcweir else 1012*cdf0e10cSrcweir { 1013*cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertMeasure( nHeight, 1014*cdf0e10cSrcweir rValue, 0 ); 1015*cdf0e10cSrcweir } 1016*cdf0e10cSrcweir bMinHeight = sal_True; 1017*cdf0e10cSrcweir break; 1018*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_Z_INDEX: 1019*cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertNumber( nZIndex, rValue, -1 ); 1020*cdf0e10cSrcweir break; 1021*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_NEXT_CHAIN_NAME: 1022*cdf0e10cSrcweir sNextName = rValue; 1023*cdf0e10cSrcweir break; 1024*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_HREF: 1025*cdf0e10cSrcweir sHRef = rValue; 1026*cdf0e10cSrcweir break; 1027*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_FILTER_NAME: 1028*cdf0e10cSrcweir sFilterName = rValue; 1029*cdf0e10cSrcweir break; 1030*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_TRANSFORM: 1031*cdf0e10cSrcweir { 1032*cdf0e10cSrcweir OUString sValue( rValue ); 1033*cdf0e10cSrcweir sValue.trim(); 1034*cdf0e10cSrcweir const OUString aRotate(GetXMLToken(XML_ROTATE)); 1035*cdf0e10cSrcweir const sal_Int32 nRotateLen(aRotate.getLength()); 1036*cdf0e10cSrcweir sal_Int32 nLen = sValue.getLength(); 1037*cdf0e10cSrcweir if( nLen >= nRotateLen+3 && 1038*cdf0e10cSrcweir 0 == sValue.compareTo( aRotate, nRotateLen ) && 1039*cdf0e10cSrcweir '(' == sValue[nRotateLen] && 1040*cdf0e10cSrcweir ')' == sValue[nLen-1] ) 1041*cdf0e10cSrcweir { 1042*cdf0e10cSrcweir sValue = sValue.copy( nRotateLen+1, nLen-(nRotateLen+2) ); 1043*cdf0e10cSrcweir sValue.trim(); 1044*cdf0e10cSrcweir sal_Int32 nVal; 1045*cdf0e10cSrcweir if( GetImport().GetMM100UnitConverter().convertNumber( nVal, sValue ) ) 1046*cdf0e10cSrcweir nRotation = (sal_Int16)(nVal % 360 ); 1047*cdf0e10cSrcweir } 1048*cdf0e10cSrcweir } 1049*cdf0e10cSrcweir break; 1050*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_CODE: 1051*cdf0e10cSrcweir sCode = rValue; 1052*cdf0e10cSrcweir break; 1053*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_OBJECT: 1054*cdf0e10cSrcweir sObject = rValue; 1055*cdf0e10cSrcweir break; 1056*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_ARCHIVE: 1057*cdf0e10cSrcweir sArchive = rValue; 1058*cdf0e10cSrcweir break; 1059*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_MAY_SCRIPT: 1060*cdf0e10cSrcweir bMayScript = IsXMLToken( rValue, XML_TRUE ); 1061*cdf0e10cSrcweir break; 1062*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_MIME_TYPE: 1063*cdf0e10cSrcweir sMimeType = rValue; 1064*cdf0e10cSrcweir break; 1065*cdf0e10cSrcweir case XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE: 1066*cdf0e10cSrcweir sTblName = rValue; 1067*cdf0e10cSrcweir break; 1068*cdf0e10cSrcweir } 1069*cdf0e10cSrcweir } 1070*cdf0e10cSrcweir 1071*cdf0e10cSrcweir if( ( (XML_TEXT_FRAME_GRAPHIC == nType || 1072*cdf0e10cSrcweir XML_TEXT_FRAME_OBJECT == nType || 1073*cdf0e10cSrcweir XML_TEXT_FRAME_OBJECT_OLE == nType) && 1074*cdf0e10cSrcweir !sHRef.getLength() ) || 1075*cdf0e10cSrcweir ( XML_TEXT_FRAME_APPLET == nType && !sCode.getLength() ) || 1076*cdf0e10cSrcweir ( XML_TEXT_FRAME_PLUGIN == nType && 1077*cdf0e10cSrcweir sHRef.getLength() == 0 && sMimeType.getLength() == 0 ) ) 1078*cdf0e10cSrcweir return; // no URL: no image or OLE object 1079*cdf0e10cSrcweir 1080*cdf0e10cSrcweir Create( sal_True ); 1081*cdf0e10cSrcweir } 1082*cdf0e10cSrcweir 1083*cdf0e10cSrcweir XMLTextFrameContext_Impl::~XMLTextFrameContext_Impl() 1084*cdf0e10cSrcweir { 1085*cdf0e10cSrcweir } 1086*cdf0e10cSrcweir 1087*cdf0e10cSrcweir void XMLTextFrameContext_Impl::EndElement() 1088*cdf0e10cSrcweir { 1089*cdf0e10cSrcweir CreateIfNotThere(); 1090*cdf0e10cSrcweir 1091*cdf0e10cSrcweir if( xOldTextCursor.is() ) 1092*cdf0e10cSrcweir { 1093*cdf0e10cSrcweir GetImport().GetTextImport()->DeleteParagraph(); 1094*cdf0e10cSrcweir GetImport().GetTextImport()->SetCursor( xOldTextCursor ); 1095*cdf0e10cSrcweir } 1096*cdf0e10cSrcweir 1097*cdf0e10cSrcweir // reinstall old list item (if necessary) #89892# 1098*cdf0e10cSrcweir if (mbListContextPushed) { 1099*cdf0e10cSrcweir GetImport().GetTextImport()->PopListContext(); 1100*cdf0e10cSrcweir } 1101*cdf0e10cSrcweir 1102*cdf0e10cSrcweir if (( nType == XML_TEXT_FRAME_APPLET || nType == XML_TEXT_FRAME_PLUGIN ) && xPropSet.is()) 1103*cdf0e10cSrcweir GetImport().GetTextImport()->endAppletOrPlugin( xPropSet, aParamMap); 1104*cdf0e10cSrcweir } 1105*cdf0e10cSrcweir 1106*cdf0e10cSrcweir SvXMLImportContext *XMLTextFrameContext_Impl::CreateChildContext( 1107*cdf0e10cSrcweir sal_uInt16 nPrefix, 1108*cdf0e10cSrcweir const OUString& rLocalName, 1109*cdf0e10cSrcweir const Reference< XAttributeList > & xAttrList ) 1110*cdf0e10cSrcweir { 1111*cdf0e10cSrcweir SvXMLImportContext *pContext = 0; 1112*cdf0e10cSrcweir 1113*cdf0e10cSrcweir if( XML_NAMESPACE_DRAW == nPrefix ) 1114*cdf0e10cSrcweir { 1115*cdf0e10cSrcweir if ( (nType == XML_TEXT_FRAME_APPLET || nType == XML_TEXT_FRAME_PLUGIN) && 1116*cdf0e10cSrcweir IsXMLToken( rLocalName, XML_PARAM ) ) 1117*cdf0e10cSrcweir { 1118*cdf0e10cSrcweir pContext = new XMLTextFrameParam_Impl( GetImport(), 1119*cdf0e10cSrcweir nPrefix, rLocalName, 1120*cdf0e10cSrcweir xAttrList, nType, aParamMap ); 1121*cdf0e10cSrcweir } 1122*cdf0e10cSrcweir } 1123*cdf0e10cSrcweir else if( (XML_NAMESPACE_OFFICE == nPrefix) ) 1124*cdf0e10cSrcweir { 1125*cdf0e10cSrcweir if( IsXMLToken( rLocalName, XML_BINARY_DATA ) ) 1126*cdf0e10cSrcweir { 1127*cdf0e10cSrcweir if( !xPropSet.is() && !xBase64Stream.is() && !bCreateFailed ) 1128*cdf0e10cSrcweir { 1129*cdf0e10cSrcweir switch( nType ) 1130*cdf0e10cSrcweir { 1131*cdf0e10cSrcweir case XML_TEXT_FRAME_GRAPHIC: 1132*cdf0e10cSrcweir xBase64Stream = 1133*cdf0e10cSrcweir GetImport().GetStreamForGraphicObjectURLFromBase64(); 1134*cdf0e10cSrcweir break; 1135*cdf0e10cSrcweir case XML_TEXT_FRAME_OBJECT_OLE: 1136*cdf0e10cSrcweir xBase64Stream = 1137*cdf0e10cSrcweir GetImport().GetStreamForEmbeddedObjectURLFromBase64(); 1138*cdf0e10cSrcweir break; 1139*cdf0e10cSrcweir } 1140*cdf0e10cSrcweir if( xBase64Stream.is() ) 1141*cdf0e10cSrcweir pContext = new XMLBase64ImportContext( GetImport(), nPrefix, 1142*cdf0e10cSrcweir rLocalName, xAttrList, 1143*cdf0e10cSrcweir xBase64Stream ); 1144*cdf0e10cSrcweir } 1145*cdf0e10cSrcweir } 1146*cdf0e10cSrcweir } 1147*cdf0e10cSrcweir // --> OD 2009-08-17 #i100480# 1148*cdf0e10cSrcweir // correction of condition which also avoids warnings. 1149*cdf0e10cSrcweir if( !pContext && 1150*cdf0e10cSrcweir ( XML_TEXT_FRAME_OBJECT == nType && 1151*cdf0e10cSrcweir ( ( XML_NAMESPACE_OFFICE == nPrefix && 1152*cdf0e10cSrcweir IsXMLToken( rLocalName, XML_DOCUMENT ) ) || 1153*cdf0e10cSrcweir ( XML_NAMESPACE_MATH == nPrefix && 1154*cdf0e10cSrcweir IsXMLToken( rLocalName, XML_MATH ) ) ) ) ) 1155*cdf0e10cSrcweir // <-- 1156*cdf0e10cSrcweir { 1157*cdf0e10cSrcweir if( !xPropSet.is() && !bCreateFailed ) 1158*cdf0e10cSrcweir { 1159*cdf0e10cSrcweir XMLEmbeddedObjectImportContext *pEContext = 1160*cdf0e10cSrcweir new XMLEmbeddedObjectImportContext( GetImport(), nPrefix, 1161*cdf0e10cSrcweir rLocalName, xAttrList ); 1162*cdf0e10cSrcweir sFilterService = pEContext->GetFilterServiceName(); 1163*cdf0e10cSrcweir if( sFilterService.getLength() != 0 ) 1164*cdf0e10cSrcweir { 1165*cdf0e10cSrcweir Create( sal_False ); 1166*cdf0e10cSrcweir if( xPropSet.is() ) 1167*cdf0e10cSrcweir { 1168*cdf0e10cSrcweir Reference < XEmbeddedObjectSupplier > xEOS( xPropSet, 1169*cdf0e10cSrcweir UNO_QUERY ); 1170*cdf0e10cSrcweir OSL_ENSURE( xEOS.is(), 1171*cdf0e10cSrcweir "no embedded object supplier for own object" ); 1172*cdf0e10cSrcweir Reference<com::sun::star::lang::XComponent> aXComponent(xEOS->getEmbeddedObject()); 1173*cdf0e10cSrcweir pEContext->SetComponent( aXComponent ); 1174*cdf0e10cSrcweir } 1175*cdf0e10cSrcweir } 1176*cdf0e10cSrcweir pContext = pEContext; 1177*cdf0e10cSrcweir } 1178*cdf0e10cSrcweir } 1179*cdf0e10cSrcweir if( !pContext && xOldTextCursor.is() ) // text-box 1180*cdf0e10cSrcweir pContext = GetImport().GetTextImport()->CreateTextChildContext( 1181*cdf0e10cSrcweir GetImport(), nPrefix, rLocalName, xAttrList, 1182*cdf0e10cSrcweir XML_TEXT_TYPE_TEXTBOX ); 1183*cdf0e10cSrcweir 1184*cdf0e10cSrcweir if( !pContext ) 1185*cdf0e10cSrcweir pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); 1186*cdf0e10cSrcweir 1187*cdf0e10cSrcweir return pContext; 1188*cdf0e10cSrcweir } 1189*cdf0e10cSrcweir 1190*cdf0e10cSrcweir void XMLTextFrameContext_Impl::Characters( const OUString& rChars ) 1191*cdf0e10cSrcweir { 1192*cdf0e10cSrcweir if( ( XML_TEXT_FRAME_OBJECT_OLE == nType || 1193*cdf0e10cSrcweir XML_TEXT_FRAME_GRAPHIC == nType) && 1194*cdf0e10cSrcweir !xPropSet.is() && !bCreateFailed ) 1195*cdf0e10cSrcweir { 1196*cdf0e10cSrcweir OUString sTrimmedChars( rChars. trim() ); 1197*cdf0e10cSrcweir if( sTrimmedChars.getLength() ) 1198*cdf0e10cSrcweir { 1199*cdf0e10cSrcweir if( !xBase64Stream.is() ) 1200*cdf0e10cSrcweir { 1201*cdf0e10cSrcweir if( XML_TEXT_FRAME_GRAPHIC == nType ) 1202*cdf0e10cSrcweir { 1203*cdf0e10cSrcweir xBase64Stream = 1204*cdf0e10cSrcweir GetImport().GetStreamForGraphicObjectURLFromBase64(); 1205*cdf0e10cSrcweir } 1206*cdf0e10cSrcweir else 1207*cdf0e10cSrcweir { 1208*cdf0e10cSrcweir xBase64Stream = 1209*cdf0e10cSrcweir GetImport().GetStreamForEmbeddedObjectURLFromBase64(); 1210*cdf0e10cSrcweir } 1211*cdf0e10cSrcweir if( xBase64Stream.is() ) 1212*cdf0e10cSrcweir bOwnBase64Stream = sal_True; 1213*cdf0e10cSrcweir } 1214*cdf0e10cSrcweir if( bOwnBase64Stream && xBase64Stream.is() ) 1215*cdf0e10cSrcweir { 1216*cdf0e10cSrcweir OUString sChars; 1217*cdf0e10cSrcweir if( sBase64CharsLeft ) 1218*cdf0e10cSrcweir { 1219*cdf0e10cSrcweir sChars = sBase64CharsLeft; 1220*cdf0e10cSrcweir sChars += sTrimmedChars; 1221*cdf0e10cSrcweir sBase64CharsLeft = OUString(); 1222*cdf0e10cSrcweir } 1223*cdf0e10cSrcweir else 1224*cdf0e10cSrcweir { 1225*cdf0e10cSrcweir sChars = sTrimmedChars; 1226*cdf0e10cSrcweir } 1227*cdf0e10cSrcweir Sequence< sal_Int8 > aBuffer( (sChars.getLength() / 4) * 3 ); 1228*cdf0e10cSrcweir sal_Int32 nCharsDecoded = 1229*cdf0e10cSrcweir GetImport().GetMM100UnitConverter(). 1230*cdf0e10cSrcweir decodeBase64SomeChars( aBuffer, sChars ); 1231*cdf0e10cSrcweir xBase64Stream->writeBytes( aBuffer ); 1232*cdf0e10cSrcweir if( nCharsDecoded != sChars.getLength() ) 1233*cdf0e10cSrcweir sBase64CharsLeft = sChars.copy( nCharsDecoded ); 1234*cdf0e10cSrcweir } 1235*cdf0e10cSrcweir } 1236*cdf0e10cSrcweir } 1237*cdf0e10cSrcweir } 1238*cdf0e10cSrcweir 1239*cdf0e10cSrcweir void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef, 1240*cdf0e10cSrcweir const OUString& rName, 1241*cdf0e10cSrcweir const OUString& rTargetFrameName, 1242*cdf0e10cSrcweir sal_Bool bMap ) 1243*cdf0e10cSrcweir { 1244*cdf0e10cSrcweir static ::rtl::OUString s_HyperLinkURL( 1245*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL")); 1246*cdf0e10cSrcweir static ::rtl::OUString s_HyperLinkName( 1247*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("HyperLinkName")); 1248*cdf0e10cSrcweir static ::rtl::OUString s_HyperLinkTarget( 1249*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget")); 1250*cdf0e10cSrcweir static ::rtl::OUString s_ServerMap( 1251*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("ServerMap")); 1252*cdf0e10cSrcweir if( !xPropSet.is() ) 1253*cdf0e10cSrcweir return; 1254*cdf0e10cSrcweir 1255*cdf0e10cSrcweir UniReference< XMLTextImportHelper > xTxtImp = GetImport().GetTextImport(); 1256*cdf0e10cSrcweir Reference < XPropertySetInfo > xPropSetInfo = 1257*cdf0e10cSrcweir xPropSet->getPropertySetInfo(); 1258*cdf0e10cSrcweir if( !xPropSetInfo.is() || 1259*cdf0e10cSrcweir !xPropSetInfo->hasPropertyByName(s_HyperLinkURL)) 1260*cdf0e10cSrcweir return; 1261*cdf0e10cSrcweir 1262*cdf0e10cSrcweir Any aAny; 1263*cdf0e10cSrcweir aAny <<= rHRef; 1264*cdf0e10cSrcweir xPropSet->setPropertyValue( s_HyperLinkURL, aAny ); 1265*cdf0e10cSrcweir 1266*cdf0e10cSrcweir if (xPropSetInfo->hasPropertyByName(s_HyperLinkName)) 1267*cdf0e10cSrcweir { 1268*cdf0e10cSrcweir aAny <<= rName; 1269*cdf0e10cSrcweir xPropSet->setPropertyValue(s_HyperLinkName, aAny); 1270*cdf0e10cSrcweir } 1271*cdf0e10cSrcweir 1272*cdf0e10cSrcweir if (xPropSetInfo->hasPropertyByName(s_HyperLinkTarget)) 1273*cdf0e10cSrcweir { 1274*cdf0e10cSrcweir aAny <<= rTargetFrameName; 1275*cdf0e10cSrcweir xPropSet->setPropertyValue( s_HyperLinkTarget, aAny ); 1276*cdf0e10cSrcweir } 1277*cdf0e10cSrcweir 1278*cdf0e10cSrcweir if (xPropSetInfo->hasPropertyByName(s_ServerMap)) 1279*cdf0e10cSrcweir { 1280*cdf0e10cSrcweir aAny.setValue( &bMap, ::getBooleanCppuType() ); 1281*cdf0e10cSrcweir xPropSet->setPropertyValue(s_ServerMap, aAny); 1282*cdf0e10cSrcweir } 1283*cdf0e10cSrcweir } 1284*cdf0e10cSrcweir 1285*cdf0e10cSrcweir // --> OD 2009-07-22 #i73249# 1286*cdf0e10cSrcweir void XMLTextFrameContext_Impl::SetTitle( const OUString& rTitle ) 1287*cdf0e10cSrcweir { 1288*cdf0e10cSrcweir if ( xPropSet.is() ) 1289*cdf0e10cSrcweir { 1290*cdf0e10cSrcweir Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); 1291*cdf0e10cSrcweir if( xPropSetInfo->hasPropertyByName( sTitle ) ) 1292*cdf0e10cSrcweir { 1293*cdf0e10cSrcweir xPropSet->setPropertyValue( sTitle, makeAny( rTitle ) ); 1294*cdf0e10cSrcweir } 1295*cdf0e10cSrcweir } 1296*cdf0e10cSrcweir } 1297*cdf0e10cSrcweir 1298*cdf0e10cSrcweir void XMLTextFrameContext_Impl::SetDesc( const OUString& rDesc ) 1299*cdf0e10cSrcweir { 1300*cdf0e10cSrcweir if ( xPropSet.is() ) 1301*cdf0e10cSrcweir { 1302*cdf0e10cSrcweir Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); 1303*cdf0e10cSrcweir if( xPropSetInfo->hasPropertyByName( sDescription ) ) 1304*cdf0e10cSrcweir { 1305*cdf0e10cSrcweir xPropSet->setPropertyValue( sDescription, makeAny( rDesc ) ); 1306*cdf0e10cSrcweir } 1307*cdf0e10cSrcweir } 1308*cdf0e10cSrcweir } 1309*cdf0e10cSrcweir // <-- 1310*cdf0e10cSrcweir 1311*cdf0e10cSrcweir //----------------------------------------------------------------------------------------------------- 1312*cdf0e10cSrcweir 1313*cdf0e10cSrcweir TYPEINIT1( XMLTextFrameContext, SvXMLImportContext ); 1314*cdf0e10cSrcweir 1315*cdf0e10cSrcweir sal_Bool XMLTextFrameContext::CreateIfNotThere() 1316*cdf0e10cSrcweir { 1317*cdf0e10cSrcweir sal_Bool bRet = sal_False; 1318*cdf0e10cSrcweir SvXMLImportContext *pContext = &m_xImplContext; 1319*cdf0e10cSrcweir XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext ); 1320*cdf0e10cSrcweir if( pImpl ) 1321*cdf0e10cSrcweir bRet = pImpl->CreateIfNotThere(); 1322*cdf0e10cSrcweir 1323*cdf0e10cSrcweir return bRet; 1324*cdf0e10cSrcweir } 1325*cdf0e10cSrcweir 1326*cdf0e10cSrcweir sal_Bool XMLTextFrameContext::CreateIfNotThere( ::com::sun::star::uno::Reference < 1327*cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet >& rPropSet ) 1328*cdf0e10cSrcweir { 1329*cdf0e10cSrcweir SvXMLImportContext *pContext = &m_xImplContext; 1330*cdf0e10cSrcweir XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext ); 1331*cdf0e10cSrcweir if( pImpl ) 1332*cdf0e10cSrcweir { 1333*cdf0e10cSrcweir if( pImpl->CreateIfNotThere() ) 1334*cdf0e10cSrcweir rPropSet = pImpl->GetPropSet(); 1335*cdf0e10cSrcweir } 1336*cdf0e10cSrcweir 1337*cdf0e10cSrcweir return rPropSet.is(); 1338*cdf0e10cSrcweir } 1339*cdf0e10cSrcweir 1340*cdf0e10cSrcweir XMLTextFrameContext::XMLTextFrameContext( 1341*cdf0e10cSrcweir SvXMLImport& rImport, 1342*cdf0e10cSrcweir sal_uInt16 nPrfx, const OUString& rLName, 1343*cdf0e10cSrcweir const Reference< XAttributeList > & xAttrList, 1344*cdf0e10cSrcweir TextContentAnchorType eATyp ) 1345*cdf0e10cSrcweir : SvXMLImportContext( rImport, nPrfx, rLName ) 1346*cdf0e10cSrcweir , m_xAttrList( new SvXMLAttributeList( xAttrList ) ) 1347*cdf0e10cSrcweir , m_pHyperlink( 0 ) 1348*cdf0e10cSrcweir // --> OD 2009-07-22 #i73249# 1349*cdf0e10cSrcweir , m_sTitle() 1350*cdf0e10cSrcweir , m_sDesc() 1351*cdf0e10cSrcweir // <-- 1352*cdf0e10cSrcweir , m_eDefaultAnchorType( eATyp ) 1353*cdf0e10cSrcweir // --> OD 2006-03-10 #i51726# 1354*cdf0e10cSrcweir , m_HasAutomaticStyleWithoutParentStyle( sal_False ) 1355*cdf0e10cSrcweir // <-- 1356*cdf0e10cSrcweir , m_bSupportsReplacement( sal_False ) 1357*cdf0e10cSrcweir { 1358*cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 1359*cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; i++ ) 1360*cdf0e10cSrcweir { 1361*cdf0e10cSrcweir const OUString& rAttrName = xAttrList->getNameByIndex( i ); 1362*cdf0e10cSrcweir 1363*cdf0e10cSrcweir OUString aLocalName; 1364*cdf0e10cSrcweir sal_uInt16 nPrefix = 1365*cdf0e10cSrcweir GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName ); 1366*cdf0e10cSrcweir // --> OD 2006-03-10 #i51726# 1367*cdf0e10cSrcweir // New distinguish attribute between Writer objects and Draw objects is: 1368*cdf0e10cSrcweir // Draw objects have an automatic style without a parent style 1369*cdf0e10cSrcweir if ( XML_NAMESPACE_DRAW == nPrefix && 1370*cdf0e10cSrcweir IsXMLToken( aLocalName, XML_STYLE_NAME ) ) 1371*cdf0e10cSrcweir { 1372*cdf0e10cSrcweir OUString aStyleName = xAttrList->getValueByIndex( i ); 1373*cdf0e10cSrcweir if( aStyleName.getLength() ) 1374*cdf0e10cSrcweir { 1375*cdf0e10cSrcweir UniReference < XMLTextImportHelper > xTxtImport = 1376*cdf0e10cSrcweir GetImport().GetTextImport(); 1377*cdf0e10cSrcweir XMLPropStyleContext* pStyle( 0L ); 1378*cdf0e10cSrcweir pStyle = xTxtImport->FindAutoFrameStyle( aStyleName ); 1379*cdf0e10cSrcweir if ( pStyle && !pStyle->GetParentName().getLength() ) 1380*cdf0e10cSrcweir { 1381*cdf0e10cSrcweir m_HasAutomaticStyleWithoutParentStyle = sal_True; 1382*cdf0e10cSrcweir } 1383*cdf0e10cSrcweir } 1384*cdf0e10cSrcweir } 1385*cdf0e10cSrcweir // <-- 1386*cdf0e10cSrcweir else if ( XML_NAMESPACE_TEXT == nPrefix && 1387*cdf0e10cSrcweir IsXMLToken( aLocalName, XML_ANCHOR_TYPE ) ) 1388*cdf0e10cSrcweir { 1389*cdf0e10cSrcweir TextContentAnchorType eNew; 1390*cdf0e10cSrcweir if( XMLAnchorTypePropHdl::convert( xAttrList->getValueByIndex(i), 1391*cdf0e10cSrcweir eNew ) && 1392*cdf0e10cSrcweir ( TextContentAnchorType_AT_PARAGRAPH == eNew || 1393*cdf0e10cSrcweir TextContentAnchorType_AT_CHARACTER == eNew || 1394*cdf0e10cSrcweir TextContentAnchorType_AS_CHARACTER == eNew || 1395*cdf0e10cSrcweir TextContentAnchorType_AT_PAGE == eNew) ) 1396*cdf0e10cSrcweir m_eDefaultAnchorType = eNew; 1397*cdf0e10cSrcweir } 1398*cdf0e10cSrcweir } 1399*cdf0e10cSrcweir } 1400*cdf0e10cSrcweir 1401*cdf0e10cSrcweir XMLTextFrameContext::~XMLTextFrameContext() 1402*cdf0e10cSrcweir { 1403*cdf0e10cSrcweir delete m_pHyperlink; 1404*cdf0e10cSrcweir } 1405*cdf0e10cSrcweir 1406*cdf0e10cSrcweir void XMLTextFrameContext::EndElement() 1407*cdf0e10cSrcweir { 1408*cdf0e10cSrcweir SvXMLImportContext *pContext = &m_xImplContext; 1409*cdf0e10cSrcweir XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext ); 1410*cdf0e10cSrcweir if( pImpl ) 1411*cdf0e10cSrcweir { 1412*cdf0e10cSrcweir pImpl->CreateIfNotThere(); 1413*cdf0e10cSrcweir 1414*cdf0e10cSrcweir // --> OD 2009-07-22 #i73249# 1415*cdf0e10cSrcweir // // alternative text 1416*cdf0e10cSrcweir // if( m_sDesc.getLength() ) 1417*cdf0e10cSrcweir // pImpl->SetDesc( m_sDesc ); 1418*cdf0e10cSrcweir // svg:title 1419*cdf0e10cSrcweir if( m_sTitle.getLength() ) 1420*cdf0e10cSrcweir { 1421*cdf0e10cSrcweir pImpl->SetTitle( m_sTitle ); 1422*cdf0e10cSrcweir } 1423*cdf0e10cSrcweir if( m_sDesc.getLength() ) 1424*cdf0e10cSrcweir { 1425*cdf0e10cSrcweir pImpl->SetDesc( m_sDesc ); 1426*cdf0e10cSrcweir } 1427*cdf0e10cSrcweir // <-- 1428*cdf0e10cSrcweir 1429*cdf0e10cSrcweir if( m_pHyperlink ) 1430*cdf0e10cSrcweir { 1431*cdf0e10cSrcweir pImpl->SetHyperlink( m_pHyperlink->GetHRef(), m_pHyperlink->GetName(), 1432*cdf0e10cSrcweir m_pHyperlink->GetTargetFrameName(), m_pHyperlink->GetMap() ); 1433*cdf0e10cSrcweir delete m_pHyperlink; 1434*cdf0e10cSrcweir m_pHyperlink = 0; 1435*cdf0e10cSrcweir } 1436*cdf0e10cSrcweir 1437*cdf0e10cSrcweir } 1438*cdf0e10cSrcweir } 1439*cdf0e10cSrcweir 1440*cdf0e10cSrcweir SvXMLImportContext *XMLTextFrameContext::CreateChildContext( 1441*cdf0e10cSrcweir sal_uInt16 p_nPrefix, 1442*cdf0e10cSrcweir const OUString& rLocalName, 1443*cdf0e10cSrcweir const Reference< XAttributeList > & xAttrList ) 1444*cdf0e10cSrcweir { 1445*cdf0e10cSrcweir SvXMLImportContext *pContext = 0; 1446*cdf0e10cSrcweir 1447*cdf0e10cSrcweir if( !m_xImplContext.Is() ) 1448*cdf0e10cSrcweir { 1449*cdf0e10cSrcweir // no child exists 1450*cdf0e10cSrcweir if( XML_NAMESPACE_DRAW == p_nPrefix ) 1451*cdf0e10cSrcweir { 1452*cdf0e10cSrcweir sal_uInt16 nFrameType = USHRT_MAX; 1453*cdf0e10cSrcweir if( IsXMLToken( rLocalName, XML_TEXT_BOX ) ) 1454*cdf0e10cSrcweir nFrameType = XML_TEXT_FRAME_TEXTBOX; 1455*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_IMAGE ) ) 1456*cdf0e10cSrcweir nFrameType = XML_TEXT_FRAME_GRAPHIC; 1457*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_OBJECT ) ) 1458*cdf0e10cSrcweir nFrameType = XML_TEXT_FRAME_OBJECT; 1459*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_OBJECT_OLE ) ) 1460*cdf0e10cSrcweir nFrameType = XML_TEXT_FRAME_OBJECT_OLE; 1461*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_APPLET) ) 1462*cdf0e10cSrcweir nFrameType = XML_TEXT_FRAME_APPLET; 1463*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_PLUGIN ) ) 1464*cdf0e10cSrcweir nFrameType = XML_TEXT_FRAME_PLUGIN; 1465*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_FLOATING_FRAME ) ) 1466*cdf0e10cSrcweir nFrameType = XML_TEXT_FRAME_FLOATING_FRAME; 1467*cdf0e10cSrcweir 1468*cdf0e10cSrcweir if( USHRT_MAX != nFrameType ) 1469*cdf0e10cSrcweir { 1470*cdf0e10cSrcweir // --> OD 2006-03-10 #i51726# 1471*cdf0e10cSrcweir if ( ( XML_TEXT_FRAME_TEXTBOX == nFrameType || 1472*cdf0e10cSrcweir XML_TEXT_FRAME_GRAPHIC == nFrameType ) && 1473*cdf0e10cSrcweir m_HasAutomaticStyleWithoutParentStyle ) 1474*cdf0e10cSrcweir // <-- 1475*cdf0e10cSrcweir { 1476*cdf0e10cSrcweir Reference < XShapes > xShapes; 1477*cdf0e10cSrcweir pContext = GetImport().GetShapeImport()->CreateFrameChildContext( 1478*cdf0e10cSrcweir GetImport(), p_nPrefix, rLocalName, xAttrList, xShapes, m_xAttrList ); 1479*cdf0e10cSrcweir } 1480*cdf0e10cSrcweir else if( XML_TEXT_FRAME_PLUGIN == nFrameType ) 1481*cdf0e10cSrcweir { 1482*cdf0e10cSrcweir bool bMedia = false; 1483*cdf0e10cSrcweir 1484*cdf0e10cSrcweir // check, if we have a media object 1485*cdf0e10cSrcweir for( sal_Int16 n = 0, nAttrCount = ( xAttrList.is() ? xAttrList->getLength() : 0 ); n < nAttrCount; ++n ) 1486*cdf0e10cSrcweir { 1487*cdf0e10cSrcweir OUString aLocalName; 1488*cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( n ), &aLocalName ); 1489*cdf0e10cSrcweir 1490*cdf0e10cSrcweir if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( aLocalName, XML_MIME_TYPE ) ) 1491*cdf0e10cSrcweir { 1492*cdf0e10cSrcweir if( 0 == xAttrList->getValueByIndex( n ).compareToAscii( "application/vnd.sun.star.media" ) ) 1493*cdf0e10cSrcweir bMedia = true; 1494*cdf0e10cSrcweir 1495*cdf0e10cSrcweir // leave this loop 1496*cdf0e10cSrcweir n = nAttrCount - 1; 1497*cdf0e10cSrcweir } 1498*cdf0e10cSrcweir } 1499*cdf0e10cSrcweir 1500*cdf0e10cSrcweir if( bMedia ) 1501*cdf0e10cSrcweir { 1502*cdf0e10cSrcweir Reference < XShapes > xShapes; 1503*cdf0e10cSrcweir pContext = GetImport().GetShapeImport()->CreateFrameChildContext( 1504*cdf0e10cSrcweir GetImport(), p_nPrefix, rLocalName, xAttrList, xShapes, m_xAttrList ); 1505*cdf0e10cSrcweir } 1506*cdf0e10cSrcweir } 1507*cdf0e10cSrcweir else if( XML_TEXT_FRAME_OBJECT == nFrameType || 1508*cdf0e10cSrcweir XML_TEXT_FRAME_OBJECT_OLE == nFrameType ) 1509*cdf0e10cSrcweir { 1510*cdf0e10cSrcweir m_bSupportsReplacement = sal_True; 1511*cdf0e10cSrcweir } 1512*cdf0e10cSrcweir 1513*cdf0e10cSrcweir if( !pContext ) 1514*cdf0e10cSrcweir { 1515*cdf0e10cSrcweir 1516*cdf0e10cSrcweir pContext = new XMLTextFrameContext_Impl( GetImport(), p_nPrefix, 1517*cdf0e10cSrcweir rLocalName, xAttrList, 1518*cdf0e10cSrcweir m_eDefaultAnchorType, 1519*cdf0e10cSrcweir nFrameType, 1520*cdf0e10cSrcweir m_xAttrList ); 1521*cdf0e10cSrcweir } 1522*cdf0e10cSrcweir 1523*cdf0e10cSrcweir m_xImplContext = pContext; 1524*cdf0e10cSrcweir } 1525*cdf0e10cSrcweir } 1526*cdf0e10cSrcweir } 1527*cdf0e10cSrcweir else if( m_bSupportsReplacement && !m_xReplImplContext && 1528*cdf0e10cSrcweir XML_NAMESPACE_DRAW == p_nPrefix && 1529*cdf0e10cSrcweir IsXMLToken( rLocalName, XML_IMAGE ) ) 1530*cdf0e10cSrcweir { 1531*cdf0e10cSrcweir // read replacement image 1532*cdf0e10cSrcweir Reference < XPropertySet > xPropSet; 1533*cdf0e10cSrcweir if( CreateIfNotThere( xPropSet ) ) 1534*cdf0e10cSrcweir { 1535*cdf0e10cSrcweir pContext = new XMLReplacementImageContext( GetImport(), 1536*cdf0e10cSrcweir p_nPrefix, rLocalName, xAttrList, xPropSet ); 1537*cdf0e10cSrcweir m_xReplImplContext = pContext; 1538*cdf0e10cSrcweir } 1539*cdf0e10cSrcweir } 1540*cdf0e10cSrcweir else if( m_xImplContext->ISA( XMLTextFrameContext_Impl ) ) 1541*cdf0e10cSrcweir { 1542*cdf0e10cSrcweir // the child is a writer frame 1543*cdf0e10cSrcweir if( XML_NAMESPACE_SVG == p_nPrefix ) 1544*cdf0e10cSrcweir { 1545*cdf0e10cSrcweir // --> OD 2009-07-22 #i73249# 1546*cdf0e10cSrcweir // bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion(); 1547*cdf0e10cSrcweir // if( IsXMLToken( rLocalName, bOld ? XML_DESC : XML_TITLE ) ) 1548*cdf0e10cSrcweir // pContext = new XMLTextFrameDescContext_Impl( GetImport(), p_nPrefix, rLocalName, 1549*cdf0e10cSrcweir // xAttrList, m_sDesc ); 1550*cdf0e10cSrcweir const bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion(); 1551*cdf0e10cSrcweir if ( bOld ) 1552*cdf0e10cSrcweir { 1553*cdf0e10cSrcweir if ( IsXMLToken( rLocalName, XML_DESC ) ) 1554*cdf0e10cSrcweir { 1555*cdf0e10cSrcweir pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(), 1556*cdf0e10cSrcweir p_nPrefix, 1557*cdf0e10cSrcweir rLocalName, 1558*cdf0e10cSrcweir m_sTitle ); 1559*cdf0e10cSrcweir } 1560*cdf0e10cSrcweir } 1561*cdf0e10cSrcweir else 1562*cdf0e10cSrcweir { 1563*cdf0e10cSrcweir if( IsXMLToken( rLocalName, XML_TITLE ) ) 1564*cdf0e10cSrcweir { 1565*cdf0e10cSrcweir pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(), 1566*cdf0e10cSrcweir p_nPrefix, 1567*cdf0e10cSrcweir rLocalName, 1568*cdf0e10cSrcweir m_sTitle ); 1569*cdf0e10cSrcweir } 1570*cdf0e10cSrcweir else if ( IsXMLToken( rLocalName, XML_DESC ) ) 1571*cdf0e10cSrcweir { 1572*cdf0e10cSrcweir pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(), 1573*cdf0e10cSrcweir p_nPrefix, 1574*cdf0e10cSrcweir rLocalName, 1575*cdf0e10cSrcweir m_sDesc ); 1576*cdf0e10cSrcweir } 1577*cdf0e10cSrcweir } 1578*cdf0e10cSrcweir // <-- 1579*cdf0e10cSrcweir } 1580*cdf0e10cSrcweir else if( XML_NAMESPACE_DRAW == p_nPrefix ) 1581*cdf0e10cSrcweir { 1582*cdf0e10cSrcweir Reference < XPropertySet > xPropSet; 1583*cdf0e10cSrcweir if( IsXMLToken( rLocalName, XML_CONTOUR_POLYGON ) ) 1584*cdf0e10cSrcweir { 1585*cdf0e10cSrcweir if( CreateIfNotThere( xPropSet ) ) 1586*cdf0e10cSrcweir pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName, 1587*cdf0e10cSrcweir xAttrList, xPropSet, sal_False ); 1588*cdf0e10cSrcweir } 1589*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_CONTOUR_PATH ) ) 1590*cdf0e10cSrcweir { 1591*cdf0e10cSrcweir if( CreateIfNotThere( xPropSet ) ) 1592*cdf0e10cSrcweir pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName, 1593*cdf0e10cSrcweir xAttrList, xPropSet, sal_True ); 1594*cdf0e10cSrcweir } 1595*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_IMAGE_MAP ) ) 1596*cdf0e10cSrcweir { 1597*cdf0e10cSrcweir if( CreateIfNotThere( xPropSet ) ) 1598*cdf0e10cSrcweir pContext = new XMLImageMapContext( GetImport(), p_nPrefix, rLocalName, xPropSet ); 1599*cdf0e10cSrcweir } 1600*cdf0e10cSrcweir } 1601*cdf0e10cSrcweir else if( (XML_NAMESPACE_OFFICE == p_nPrefix) && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) 1602*cdf0e10cSrcweir { 1603*cdf0e10cSrcweir // do we still have the frame object? 1604*cdf0e10cSrcweir Reference < XPropertySet > xPropSet; 1605*cdf0e10cSrcweir if( CreateIfNotThere( xPropSet ) ) 1606*cdf0e10cSrcweir { 1607*cdf0e10cSrcweir // is it an event supplier? 1608*cdf0e10cSrcweir Reference<XEventsSupplier> xEventsSupplier(xPropSet, UNO_QUERY); 1609*cdf0e10cSrcweir if (xEventsSupplier.is()) 1610*cdf0e10cSrcweir { 1611*cdf0e10cSrcweir // OK, we have the events, so create the context 1612*cdf0e10cSrcweir pContext = new XMLEventsImportContext(GetImport(), p_nPrefix, 1613*cdf0e10cSrcweir rLocalName, xEventsSupplier); 1614*cdf0e10cSrcweir } 1615*cdf0e10cSrcweir } 1616*cdf0e10cSrcweir } 1617*cdf0e10cSrcweir } 1618*cdf0e10cSrcweir else if( p_nPrefix == XML_NAMESPACE_SVG && // #i68101# 1619*cdf0e10cSrcweir (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) 1620*cdf0e10cSrcweir { 1621*cdf0e10cSrcweir pContext = m_xImplContext->CreateChildContext( p_nPrefix, rLocalName, xAttrList ); 1622*cdf0e10cSrcweir } 1623*cdf0e10cSrcweir else 1624*cdf0e10cSrcweir { 1625*cdf0e10cSrcweir // the child is a drawing shape 1626*cdf0e10cSrcweir pContext = GetImport().GetShapeImport()->CreateFrameChildContext( 1627*cdf0e10cSrcweir &m_xImplContext, p_nPrefix, rLocalName, xAttrList ); 1628*cdf0e10cSrcweir } 1629*cdf0e10cSrcweir 1630*cdf0e10cSrcweir if( !pContext ) 1631*cdf0e10cSrcweir pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); 1632*cdf0e10cSrcweir 1633*cdf0e10cSrcweir return pContext; 1634*cdf0e10cSrcweir } 1635*cdf0e10cSrcweir 1636*cdf0e10cSrcweir void XMLTextFrameContext::SetHyperlink( const OUString& rHRef, 1637*cdf0e10cSrcweir const OUString& rName, 1638*cdf0e10cSrcweir const OUString& rTargetFrameName, 1639*cdf0e10cSrcweir sal_Bool bMap ) 1640*cdf0e10cSrcweir { 1641*cdf0e10cSrcweir OSL_ENSURE( !m_pHyperlink, "recursive SetHyperlink call" ); 1642*cdf0e10cSrcweir delete m_pHyperlink; 1643*cdf0e10cSrcweir m_pHyperlink = new XMLTextFrameContextHyperlink_Impl( 1644*cdf0e10cSrcweir rHRef, rName, rTargetFrameName, bMap ); 1645*cdf0e10cSrcweir } 1646*cdf0e10cSrcweir 1647*cdf0e10cSrcweir TextContentAnchorType XMLTextFrameContext::GetAnchorType() const 1648*cdf0e10cSrcweir { 1649*cdf0e10cSrcweir SvXMLImportContext *pContext = &m_xImplContext; 1650*cdf0e10cSrcweir XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext ); 1651*cdf0e10cSrcweir if( pImpl ) 1652*cdf0e10cSrcweir return pImpl->GetAnchorType(); 1653*cdf0e10cSrcweir else 1654*cdf0e10cSrcweir return m_eDefaultAnchorType; 1655*cdf0e10cSrcweir } 1656*cdf0e10cSrcweir 1657*cdf0e10cSrcweir Reference < XTextContent > XMLTextFrameContext::GetTextContent() const 1658*cdf0e10cSrcweir { 1659*cdf0e10cSrcweir Reference < XTextContent > xTxtCntnt; 1660*cdf0e10cSrcweir SvXMLImportContext *pContext = &m_xImplContext; 1661*cdf0e10cSrcweir XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext ); 1662*cdf0e10cSrcweir if( pImpl ) 1663*cdf0e10cSrcweir xTxtCntnt.set( pImpl->GetPropSet(), UNO_QUERY ); 1664*cdf0e10cSrcweir 1665*cdf0e10cSrcweir return xTxtCntnt; 1666*cdf0e10cSrcweir } 1667*cdf0e10cSrcweir 1668*cdf0e10cSrcweir // --> OD 2004-08-24 #33242# 1669*cdf0e10cSrcweir Reference < XShape > XMLTextFrameContext::GetShape() const 1670*cdf0e10cSrcweir { 1671*cdf0e10cSrcweir Reference < XShape > xShape; 1672*cdf0e10cSrcweir SvXMLImportContext* pContext = &m_xImplContext; 1673*cdf0e10cSrcweir SvXMLShapeContext* pImpl = PTR_CAST( SvXMLShapeContext, pContext ); 1674*cdf0e10cSrcweir if ( pImpl ) 1675*cdf0e10cSrcweir { 1676*cdf0e10cSrcweir xShape = pImpl->getShape(); 1677*cdf0e10cSrcweir } 1678*cdf0e10cSrcweir 1679*cdf0e10cSrcweir return xShape; 1680*cdf0e10cSrcweir } 1681*cdf0e10cSrcweir // <-- 1682