LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLTextFrameContext.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 466 778 59.9 %
Date: 2014-04-11 Functions: 33 68 48.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10