LCOV - code coverage report
Current view: top level - sw/source/filter/xml - xmltexte.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 375 0.0 %
Date: 2014-04-14 Functions: 0 12 0.0 %
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 <comphelper/classids.hxx>
      21             : #include <com/sun/star/embed/XEmbedObjectCreator.hpp>
      22             : #include <com/sun/star/embed/XEmbeddedObject.hpp>
      23             : #include <com/sun/star/embed/XLinkageSupport.hpp>
      24             : #include <com/sun/star/embed/EmbedStates.hpp>
      25             : #include <com/sun/star/embed/XClassifiedObject.hpp>
      26             : #include <com/sun/star/embed/Aspects.hpp>
      27             : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
      28             : #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
      29             : #include <xmloff/families.hxx>
      30             : #include <xmloff/xmlnmspe.hxx>
      31             : #include <xmloff/xmltoken.hxx>
      32             : #include <xmloff/txtprmap.hxx>
      33             : 
      34             : #include <svx/svdobj.hxx>
      35             : #include <doc.hxx>
      36             : #include <ndole.hxx>
      37             : #include <fmtcntnt.hxx>
      38             : #include <unostyle.hxx>
      39             : #include <unoframe.hxx>
      40             : #include <ndgrf.hxx>
      41             : #include "xmlexp.hxx"
      42             : #include "xmltexte.hxx"
      43             : #include <SwAppletImpl.hxx>
      44             : 
      45             : #include "svl/urihelper.hxx"
      46             : #include <sfx2/frmdescr.hxx>
      47             : #include <SwStyleNameMapper.hxx>
      48             : 
      49             : using namespace ::com::sun::star;
      50             : using namespace ::com::sun::star::uno;
      51             : using namespace ::com::sun::star::style;
      52             : using namespace ::com::sun::star::beans;
      53             : using namespace ::com::sun::star::lang;
      54             : using namespace ::com::sun::star::document;
      55             : using namespace ::com::sun::star::io;
      56             : using namespace ::xmloff::token;
      57             : 
      58             : enum SvEmbeddedObjectTypes
      59             : {
      60             :     SV_EMBEDDED_OWN,
      61             :     SV_EMBEDDED_OUTPLACE,
      62             :     SV_EMBEDDED_APPLET,
      63             :     SV_EMBEDDED_PLUGIN,
      64             :     SV_EMBEDDED_FRAME
      65             : };
      66             : 
      67           0 : SwNoTxtNode *SwXMLTextParagraphExport::GetNoTxtNode(
      68             :     const Reference < XPropertySet >& rPropSet ) const
      69             : {
      70           0 :     Reference<XUnoTunnel> xCrsrTunnel( rPropSet, UNO_QUERY );
      71             :     OSL_ENSURE( xCrsrTunnel.is(), "missing XUnoTunnel for embedded" );
      72             :     SwXFrame *pFrame = reinterpret_cast< SwXFrame * >(
      73           0 :                 sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( SwXFrame::getUnoTunnelId() )));
      74             :     OSL_ENSURE( pFrame, "SwXFrame missing" );
      75           0 :     SwFrmFmt *pFrmFmt = pFrame->GetFrmFmt();
      76           0 :     const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
      77           0 :     const SwNodeIndex *pNdIdx = rCntnt.GetCntntIdx();
      78           0 :     return  pNdIdx->GetNodes()[pNdIdx->GetIndex() + 1]->GetNoTxtNode();
      79             : }
      80             : 
      81           0 : void SwXMLTextParagraphExport::exportStyleContent(
      82             :         const Reference< XStyle > & rStyle )
      83             : {
      84             : 
      85           0 :     const SwXStyle* pStyle = 0;
      86           0 :     Reference<XUnoTunnel> xStyleTunnel( rStyle, UNO_QUERY);
      87           0 :     if( xStyleTunnel.is() )
      88             :     {
      89             :         pStyle = reinterpret_cast< SwXStyle * >(
      90           0 :                 sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId() )));
      91             :     }
      92           0 :     if( pStyle && SFX_STYLE_FAMILY_PARA == pStyle->GetFamily() )
      93             :     {
      94           0 :         const SwDoc *pDoc = pStyle->GetDoc();
      95             :         const SwTxtFmtColl *pColl =
      96           0 :             pDoc->FindTxtFmtCollByName( pStyle->GetStyleName() );
      97             :         OSL_ENSURE( pColl, "There is the text collection?" );
      98           0 :         if( pColl && RES_CONDTXTFMTCOLL == pColl->Which() )
      99             :         {
     100             :             const SwFmtCollConditions& rConditions =
     101           0 :                 ((const SwConditionTxtFmtColl *)pColl)->GetCondColls();
     102           0 :             for( sal_uInt16 i=0; i < rConditions.size(); i++ )
     103             :             {
     104           0 :                 const SwCollCondition& rCond = rConditions[i];
     105             : 
     106           0 :                 enum XMLTokenEnum eFunc = XML_TOKEN_INVALID;
     107           0 :                 OUStringBuffer sBuffer( 20 );
     108           0 :                 switch( rCond.GetCondition() )
     109             :                 {
     110             :                 case PARA_IN_LIST:
     111           0 :                     eFunc = XML_LIST_LEVEL;
     112           0 :                     sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
     113           0 :                     break;
     114             :                 case PARA_IN_OUTLINE:
     115           0 :                     eFunc = XML_OUTLINE_LEVEL;
     116           0 :                     sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
     117           0 :                     break;
     118             :                 case PARA_IN_FRAME:
     119           0 :                     eFunc = XML_TEXT_BOX;
     120           0 :                     break;
     121             :                 case PARA_IN_TABLEHEAD:
     122           0 :                     eFunc = XML_TABLE_HEADER;
     123           0 :                     break;
     124             :                 case PARA_IN_TABLEBODY:
     125           0 :                     eFunc = XML_TABLE;
     126           0 :                     break;
     127             :                 case PARA_IN_SECTION:
     128           0 :                     eFunc = XML_SECTION;
     129           0 :                     break;
     130             :                 case PARA_IN_FOOTENOTE:
     131           0 :                     eFunc = XML_FOOTNOTE;
     132           0 :                     break;
     133             :                 case PARA_IN_FOOTER:
     134           0 :                     eFunc = XML_FOOTER;
     135           0 :                     break;
     136             :                 case PARA_IN_HEADER:
     137           0 :                     eFunc = XML_HEADER;
     138           0 :                     break;
     139             :                 case PARA_IN_ENDNOTE:
     140           0 :                     eFunc = XML_ENDNOTE;
     141           0 :                     break;
     142             :                 }
     143           0 :                 OUString sVal( sBuffer.makeStringAndClear() );
     144             : 
     145             :                 OSL_ENSURE( eFunc != XML_TOKEN_INVALID,
     146             :                             "SwXMLExport::ExportFmt: unknown condition" );
     147           0 :                 if( eFunc != XML_TOKEN_INVALID )
     148             :                 {
     149           0 :                     sBuffer.append( GetXMLToken(eFunc) );
     150           0 :                     sBuffer.append( '(' );
     151           0 :                     sBuffer.append( ')' );
     152           0 :                     if( !sVal.isEmpty() )
     153             :                     {
     154           0 :                         sBuffer.append( '=' );
     155           0 :                         sBuffer.append( sVal );
     156             :                     }
     157             : 
     158           0 :                     GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     159             :                                 XML_CONDITION,
     160           0 :                                 sBuffer.makeStringAndClear() );
     161           0 :                     OUString aString;
     162             :                     SwStyleNameMapper::FillProgName(
     163           0 :                                     rCond.GetTxtFmtColl()->GetName(),
     164             :                                     aString,
     165             :                                     nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL,
     166           0 :                                     true);
     167           0 :                     aString = GetExport().EncodeStyleName( aString );
     168           0 :                     GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     169           0 :                                 XML_APPLY_STYLE_NAME, aString );
     170           0 :                     SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
     171           0 :                                               XML_MAP, true, true );
     172             :                 }
     173           0 :             }
     174             :         }
     175           0 :     }
     176           0 : }
     177             : 
     178           0 : SwXMLTextParagraphExport::SwXMLTextParagraphExport(
     179             :         SwXMLExport& rExp,
     180             :          SvXMLAutoStylePoolP& _rAutoStylePool ) :
     181             :     XMLTextParagraphExport( rExp, _rAutoStylePool ),
     182             :     sTextTable( "TextTable" ),
     183             :     sEmbeddedObjectProtocol( "vnd.sun.star.EmbeddedObject:" ),
     184             :     sGraphicObjectProtocol( "vnd.sun.star.GraphicObject:" ),
     185             :     aAppletClassId( SO3_APPLET_CLASSID ),
     186             :     aPluginClassId( SO3_PLUGIN_CLASSID ),
     187             :     aIFrameClassId( SO3_IFRAME_CLASSID ),
     188           0 :     aOutplaceClassId( SO3_OUT_CLASSID )
     189             : {
     190           0 : }
     191             : 
     192           0 : SwXMLTextParagraphExport::~SwXMLTextParagraphExport()
     193             : {
     194           0 : }
     195             : 
     196           0 : void SwXMLTextParagraphExport::setTextEmbeddedGraphicURL(
     197             :     const Reference < XPropertySet >& rPropSet,
     198             :     OUString& rURL) const
     199             : {
     200           0 :     if( rURL.isEmpty() )
     201           0 :         return;
     202             : 
     203           0 :     SwGrfNode *pGrfNd = GetNoTxtNode( rPropSet )->GetGrfNode();
     204           0 :     if (pGrfNd && !pGrfNd->IsGrfLink())
     205             :     {
     206             :         // #i15411# save-as will swap all graphics in; we need to swap
     207             :         // them out again, to prevent excessive memory use
     208           0 :         pGrfNd->SwapOut();
     209             :     }
     210             : }
     211             : 
     212           0 : static void lcl_addURL ( SvXMLExport &rExport, const OUString &rURL,
     213             :                          bool bToRel = true )
     214             : {
     215           0 :     OUString sRelURL;
     216             : 
     217           0 :     if( bToRel && !rURL.isEmpty() )
     218           0 :         sRelURL = URIHelper::simpleNormalizedMakeRelative(rExport.GetOrigFileName(),
     219           0 :               rURL);
     220             :     else
     221           0 :         sRelURL = rURL;
     222             : 
     223           0 :     if (!sRelURL.isEmpty())
     224             :     {
     225           0 :         rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, sRelURL );
     226           0 :         rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
     227           0 :         rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
     228           0 :         rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
     229           0 :     }
     230           0 : }
     231             : 
     232           0 : static void lcl_addAspect(
     233             :         const svt::EmbeddedObjectRef& rObj,
     234             :         const XMLPropertyState **pStates,
     235             :         const UniReference < XMLPropertySetMapper >& rMapper )
     236             : {
     237             :     {
     238           0 :         sal_Int64 nAspect = rObj.GetViewAspect();
     239             : 
     240           0 :         if ( nAspect )
     241             :         {
     242           0 :             *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_DRAW_ASPECT ), uno::makeAny( nAspect ) );
     243           0 :             pStates++;
     244             :         }
     245             :     }
     246           0 : }
     247             : 
     248           0 : static void lcl_addOutplaceProperties(
     249             :         const svt::EmbeddedObjectRef& rObj,
     250             :         const XMLPropertyState **pStates,
     251             :         const UniReference < XMLPropertySetMapper >& rMapper )
     252             : {
     253             :     {
     254           0 :         MapMode aMode( MAP_100TH_MM ); // the API expects this map mode for the embedded objects
     255           0 :         Size aSize = rObj.GetSize( &aMode ); // get the size in the requested map mode
     256             : 
     257           0 :         if( aSize.Width() && aSize.Height() )
     258             :         {
     259           0 :             Any aAny;
     260           0 :             aAny <<= 0L;
     261           0 :             *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_LEFT ), aAny );
     262           0 :             pStates++;
     263             : 
     264           0 :             aAny <<= 0L;
     265           0 :             *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_TOP ), aAny );
     266           0 :             pStates++;
     267             : 
     268           0 :             aAny <<= (sal_Int32)aSize.Width();
     269           0 :             *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_WIDTH ), aAny );
     270           0 :             pStates++;
     271             : 
     272           0 :             aAny <<= (sal_Int32)aSize.Height();
     273           0 :             *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_HEIGHT ), aAny );
     274           0 :             pStates++;
     275           0 :         }
     276             :     }
     277           0 : }
     278             : 
     279           0 : static void lcl_addFrameProperties(
     280             :         const uno::Reference < embed::XEmbeddedObject >& xObj,
     281             :         const XMLPropertyState **pStates,
     282             :         const UniReference < XMLPropertySetMapper >& rMapper )
     283             : {
     284           0 :     if ( !::svt::EmbeddedObjectRef::TryRunningState( xObj ) )
     285           0 :         return;
     286             : 
     287           0 :     uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
     288           0 :     if ( !xSet.is() )
     289           0 :         return;
     290             : 
     291           0 :     OUString aURL;
     292           0 :     Any aAny = xSet->getPropertyValue("FrameURL");
     293           0 :     aAny >>= aURL;
     294             : 
     295           0 :     OUString aName;
     296           0 :     aAny = xSet->getPropertyValue("FrameName");
     297           0 :     aAny >>= aName;
     298             : 
     299           0 :     sal_Bool bIsAutoScroll = sal_False, bIsScrollingMode;
     300           0 :     aAny = xSet->getPropertyValue("FrameIsAutoScroll");
     301           0 :     aAny >>= bIsAutoScroll;
     302           0 :     if ( !bIsAutoScroll )
     303             :     {
     304           0 :         aAny = xSet->getPropertyValue("FrameIsScrollingMode");
     305           0 :         aAny >>= bIsScrollingMode;
     306             :     }
     307             : 
     308           0 :     sal_Bool bIsBorderSet, bIsAutoBorder = sal_False;
     309           0 :     aAny = xSet->getPropertyValue("FrameIsAutoBorder");
     310           0 :     aAny >>= bIsAutoBorder;
     311           0 :     if ( !bIsAutoBorder )
     312             :     {
     313           0 :         aAny = xSet->getPropertyValue("FrameIsBorder");
     314           0 :         aAny >>= bIsBorderSet;
     315             :     }
     316             : 
     317             :     sal_Int32 nWidth, nHeight;
     318           0 :     aAny = xSet->getPropertyValue("FrameMarginWidth");
     319           0 :     aAny >>= nWidth;
     320           0 :     aAny = xSet->getPropertyValue("FrameMarginHeight");
     321           0 :     aAny >>= nHeight;
     322             : 
     323           0 :     if( !bIsAutoScroll )
     324             :     {
     325           0 :         Any aAny2( &bIsScrollingMode, ::getBooleanCppuType() );
     326           0 :         *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_DISPLAY_SCROLLBAR ), aAny2 );
     327           0 :         pStates++;
     328             :     }
     329           0 :     if( !bIsAutoBorder )
     330             :     {
     331           0 :         Any aAny2( &bIsBorderSet, ::getBooleanCppuType() );
     332           0 :         *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_DISPLAY_BORDER ), aAny2 );
     333           0 :         pStates++;
     334             :     }
     335           0 :     if( SIZE_NOT_SET != nWidth )
     336             :     {
     337           0 :         Any aAny2;
     338           0 :         aAny <<= nWidth;
     339           0 :         *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_MARGIN_HORI ), aAny2 );
     340           0 :         pStates++;
     341             :     }
     342           0 :     if( SIZE_NOT_SET != nHeight )
     343             :     {
     344           0 :         Any aAny2;
     345           0 :         aAny <<= nHeight;
     346           0 :         *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_MARGIN_VERT ), aAny2 );
     347           0 :         pStates++;
     348           0 :     }
     349             : }
     350             : 
     351           0 : void SwXMLTextParagraphExport::_collectTextEmbeddedAutoStyles(
     352             :         const Reference < XPropertySet > & rPropSet )
     353             : {
     354           0 :     SwOLENode *pOLENd = GetNoTxtNode( rPropSet )->GetOLENode();
     355           0 :     svt::EmbeddedObjectRef& rObjRef = pOLENd->GetOLEObj().GetObject();
     356           0 :     if( !rObjRef.is() )
     357           0 :         return;
     358             : 
     359           0 :     const XMLPropertyState *aStates[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
     360           0 :     SvGlobalName aClassId( rObjRef->getClassID() );
     361             : 
     362           0 :     if( aIFrameClassId == aClassId )
     363             :     {
     364           0 :         lcl_addFrameProperties( rObjRef.GetObject(), aStates,
     365           0 :                GetAutoFramePropMapper()->getPropertySetMapper() );
     366             :     }
     367           0 :     else if ( !SotExchange::IsInternal( aClassId ) )
     368             :     {
     369             :         lcl_addOutplaceProperties( rObjRef, aStates,
     370           0 :                GetAutoFramePropMapper()->getPropertySetMapper() );
     371             :     }
     372             : 
     373             :     lcl_addAspect( rObjRef, aStates,
     374           0 :            GetAutoFramePropMapper()->getPropertySetMapper() );
     375             : 
     376           0 :     Add( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, aStates );
     377             : 
     378           0 :     const XMLPropertyState **pStates = aStates;
     379           0 :     while( *pStates )
     380             :     {
     381           0 :         delete *pStates;
     382           0 :         pStates++;
     383           0 :     }
     384             : }
     385             : 
     386           0 : void SwXMLTextParagraphExport::_exportTextEmbedded(
     387             :         const Reference < XPropertySet > & rPropSet,
     388             :         const Reference < XPropertySetInfo > & rPropSetInfo )
     389             : {
     390           0 :     SwOLENode *pOLENd = GetNoTxtNode( rPropSet )->GetOLENode();
     391           0 :     SwOLEObj& rOLEObj = pOLENd->GetOLEObj();
     392           0 :     svt::EmbeddedObjectRef& rObjRef = rOLEObj.GetObject();
     393           0 :     if( !rObjRef.is() )
     394           0 :         return;
     395             : 
     396           0 :     SvGlobalName aClassId( rObjRef->getClassID() );
     397             : 
     398           0 :     SvEmbeddedObjectTypes nType = SV_EMBEDDED_OWN;
     399           0 :     if( aPluginClassId == aClassId )
     400             :     {
     401           0 :         nType = SV_EMBEDDED_PLUGIN;
     402             :     }
     403           0 :     else if( aAppletClassId == aClassId )
     404             :     {
     405           0 :         nType = SV_EMBEDDED_APPLET;
     406             :     }
     407           0 :     else if( aIFrameClassId == aClassId )
     408             :     {
     409           0 :         nType = SV_EMBEDDED_FRAME;
     410             :     }
     411           0 :     else if ( !SotExchange::IsInternal( aClassId ) )
     412             :     {
     413           0 :         nType = SV_EMBEDDED_OUTPLACE;
     414             :     }
     415             : 
     416           0 :     enum XMLTokenEnum eElementName = XML__UNKNOWN_;
     417           0 :     SvXMLExport &rXMLExport = GetExport();
     418             : 
     419             :     // First the stuff common to each of Applet/Plugin/Floating Frame
     420           0 :     OUString sStyle;
     421           0 :     Any aAny;
     422           0 :     if( rPropSetInfo->hasPropertyByName( sFrameStyleName ) )
     423             :     {
     424           0 :         aAny = rPropSet->getPropertyValue( sFrameStyleName );
     425           0 :         aAny >>= sStyle;
     426             :     }
     427             : 
     428           0 :     const XMLPropertyState *aStates[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
     429           0 :     switch( nType )
     430             :     {
     431             :     case SV_EMBEDDED_FRAME:
     432           0 :         lcl_addFrameProperties( rObjRef.GetObject(), aStates,
     433           0 :             GetAutoFramePropMapper()->getPropertySetMapper() );
     434           0 :         break;
     435             :     case SV_EMBEDDED_OUTPLACE:
     436             :         lcl_addOutplaceProperties( rObjRef, aStates,
     437           0 :             GetAutoFramePropMapper()->getPropertySetMapper() );
     438           0 :         break;
     439             :     default:
     440             :         ;
     441             :     }
     442             : 
     443             :     lcl_addAspect( rObjRef, aStates,
     444           0 :         GetAutoFramePropMapper()->getPropertySetMapper() );
     445             : 
     446           0 :     OUString sAutoStyle( sStyle );
     447           0 :     sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, sStyle,
     448           0 :                        aStates );
     449           0 :     const XMLPropertyState **pStates = aStates;
     450           0 :     while( *pStates )
     451             :     {
     452           0 :         delete *pStates;
     453           0 :         pStates++;
     454             :     }
     455             : 
     456           0 :     if( !sAutoStyle.isEmpty() )
     457           0 :         rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_STYLE_NAME, sAutoStyle );
     458           0 :     addTextFrameAttributes( rPropSet, false );
     459             : 
     460           0 :     SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW,
     461           0 :                               XML_FRAME, false, true );
     462             : 
     463           0 :     switch (nType)
     464             :     {
     465             :     case SV_EMBEDDED_OUTPLACE:
     466             :     case SV_EMBEDDED_OWN:
     467           0 :         if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) == 0 )
     468             :         {
     469           0 :             OUString sURL;
     470             : 
     471           0 :             bool bIsOwnLink = false;
     472           0 :             if( SV_EMBEDDED_OWN == nType )
     473             :             {
     474             :                 try
     475             :                 {
     476           0 :                     uno::Reference< embed::XLinkageSupport > xLinkage( rObjRef.GetObject(), uno::UNO_QUERY );
     477           0 :                     bIsOwnLink = xLinkage.is() && xLinkage->isLink();
     478           0 :                     if ( bIsOwnLink )
     479           0 :                         sURL = xLinkage->getLinkURL();
     480             :                 }
     481           0 :                 catch(const uno::Exception&)
     482             :                 {
     483             :                     // TODO/LATER: error handling
     484             :                     OSL_FAIL( "Link detection or retrieving of the URL of OOo link is failed!\n" );
     485             :                 }
     486             :             }
     487             : 
     488           0 :             if ( !bIsOwnLink )
     489             :             {
     490           0 :                 sURL = OUString( sEmbeddedObjectProtocol );
     491           0 :                 sURL += rOLEObj.GetCurrentPersistName();
     492             :             }
     493             : 
     494           0 :             sURL = GetExport().AddEmbeddedObject( sURL );
     495           0 :             lcl_addURL( rXMLExport, sURL, false );
     496             :         }
     497           0 :         if( SV_EMBEDDED_OWN == nType && !pOLENd->GetChartTblName().isEmpty() )
     498             :         {
     499           0 :             OUString sRange( pOLENd->GetChartTblName() );
     500           0 :             OUStringBuffer aBuffer( sRange.getLength() + 2 );
     501           0 :             for( sal_Int32 i=0; i < sRange.getLength(); i++ )
     502             :             {
     503           0 :                 sal_Unicode c = sRange[i];
     504           0 :                 switch( c  )
     505             :                 {
     506             :                     case ' ':
     507             :                     case '.':
     508             :                     case '\'':
     509             :                     case '\\':
     510           0 :                         if( aBuffer.isEmpty() )
     511             :                         {
     512           0 :                             aBuffer.append( '\'' );
     513           0 :                             aBuffer.append( sRange.copy( 0, i ) );
     514             :                         }
     515           0 :                         if( '\'' == c || '\\' == c )
     516           0 :                             aBuffer.append( '\\' );
     517             :                         // no break!
     518             :                     default:
     519           0 :                         if( !aBuffer.isEmpty() )
     520           0 :                             aBuffer.append( c );
     521             :                 }
     522             :             }
     523           0 :             if( !aBuffer.isEmpty() )
     524             :             {
     525           0 :                 aBuffer.append( '\'' );
     526           0 :                 sRange = aBuffer.makeStringAndClear();
     527             :             }
     528             : 
     529             :             rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES,
     530           0 :             sRange );
     531             :         }
     532             :         eElementName = SV_EMBEDDED_OUTPLACE==nType ? XML_OBJECT_OLE
     533           0 :                                                    : XML_OBJECT;
     534           0 :         break;
     535             :     case SV_EMBEDDED_APPLET:
     536             :         {
     537             :             // It's an applet!
     538           0 :             if( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
     539             :             {
     540           0 :                 uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
     541           0 :                 OUString aStr;
     542           0 :                 Any aAny2 = xSet->getPropertyValue("AppletCodeBase");
     543           0 :                 aAny2 >>= aStr;
     544           0 :                 if (!aStr.isEmpty() )
     545           0 :                     lcl_addURL(rXMLExport, aStr);
     546             : 
     547           0 :                 aAny2 = xSet->getPropertyValue("AppletName");
     548           0 :                 aAny2 >>= aStr;
     549           0 :                 if (!aStr.isEmpty())
     550           0 :                     rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_APPLET_NAME, aStr );
     551             : 
     552           0 :                 aAny2 = xSet->getPropertyValue("AppletCode");
     553           0 :                 aAny2 >>= aStr;
     554           0 :                 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CODE, aStr );
     555             : 
     556           0 :                 sal_Bool bScript = sal_False;
     557           0 :                 aAny2 = xSet->getPropertyValue("AppletIsScript");
     558           0 :                 aAny2 >>= bScript;
     559           0 :                 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MAY_SCRIPT, bScript ? XML_TRUE : XML_FALSE );
     560             : 
     561           0 :                 uno::Sequence < beans::PropertyValue > aProps;
     562           0 :                 aAny2 = xSet->getPropertyValue("AppletCommands");
     563           0 :                 aAny2 >>= aProps;
     564             : 
     565           0 :                 sal_Int32 i = aProps.getLength();
     566           0 :                 while ( i > 0 )
     567             :                 {
     568           0 :                     beans::PropertyValue& aProp = aProps[--i];
     569           0 :                     sal_uInt16 nType2 = SwApplet_Impl::GetOptionType( aProp.Name, sal_True );
     570           0 :                     if ( nType2 == SWHTML_OPTTYPE_TAG)
     571             :                     {
     572           0 :                         OUString aStr2;
     573           0 :                         aProp.Value >>= aStr2;
     574           0 :                         rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, aProp.Name, aStr2);
     575             :                     }
     576             :                 }
     577             : 
     578           0 :                 eElementName = XML_APPLET;
     579             :             }
     580             :         }
     581           0 :         break;
     582             :     case SV_EMBEDDED_PLUGIN:
     583             :         {
     584             :             // It's a plugin!
     585           0 :             if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
     586             :             {
     587           0 :                 uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
     588           0 :                 OUString aStr;
     589           0 :                 Any aAny2 = xSet->getPropertyValue("PluginURL");
     590           0 :                 aAny2 >>= aStr;
     591           0 :                 lcl_addURL( rXMLExport, aStr );
     592             : 
     593           0 :                 aAny2 = xSet->getPropertyValue("PluginMimeType");
     594           0 :                 aAny2 >>= aStr;
     595           0 :                 if (!aStr.isEmpty())
     596           0 :                     rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIME_TYPE, aStr );
     597           0 :                 eElementName = XML_PLUGIN;
     598             :             }
     599             :         }
     600           0 :         break;
     601             :     case SV_EMBEDDED_FRAME:
     602             :         {
     603             :             // It's a floating frame!
     604           0 :             if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
     605             :             {
     606           0 :                 uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
     607           0 :                 OUString aStr;
     608           0 :                 Any aAny2 = xSet->getPropertyValue("FrameURL");
     609           0 :                 aAny2 >>= aStr;
     610             : 
     611           0 :                 lcl_addURL( rXMLExport, aStr );
     612             : 
     613           0 :                 aAny2 = xSet->getPropertyValue("FrameName");
     614           0 :                 aAny2 >>= aStr;
     615             : 
     616           0 :                 if (!aStr.isEmpty())
     617           0 :                     rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_FRAME_NAME, aStr );
     618           0 :                 eElementName = XML_FLOATING_FRAME;
     619             :             }
     620             :         }
     621           0 :         break;
     622             :     default:
     623             :         OSL_ENSURE( !this, "unknown object type! Base class should have been called!" );
     624             :     }
     625             : 
     626             :     {
     627             :         SvXMLElementExport aElementExport( rXMLExport, XML_NAMESPACE_DRAW, eElementName,
     628           0 :                                       false, true );
     629           0 :         switch( nType )
     630             :         {
     631             :         case SV_EMBEDDED_OWN:
     632           0 :             if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) != 0 )
     633             :             {
     634           0 :                 Reference < XEmbeddedObjectSupplier > xEOS( rPropSet, UNO_QUERY );
     635             :                 OSL_ENSURE( xEOS.is(), "no embedded object supplier for own object" );
     636           0 :                 Reference < XComponent > xComp = xEOS->getEmbeddedObject();
     637           0 :                 rXMLExport.ExportEmbeddedOwnObject( xComp );
     638             :             }
     639           0 :             break;
     640             :         case SV_EMBEDDED_OUTPLACE:
     641           0 :             if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) != 0 )
     642             :             {
     643           0 :                 OUString sURL( sEmbeddedObjectProtocol );
     644           0 :                 sURL += rOLEObj.GetCurrentPersistName();
     645             : 
     646           0 :                 if ( ( rXMLExport.getExportFlags() & EXPORT_OASIS ) == 0 )
     647           0 :                     sURL += OUString( "?oasis=false" );
     648             : 
     649           0 :                 rXMLExport.AddEmbeddedObjectAsBase64( sURL );
     650             :             }
     651           0 :             break;
     652             :         case SV_EMBEDDED_APPLET:
     653             :             {
     654           0 :                 if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
     655             :                 {
     656           0 :                     uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
     657           0 :                     uno::Sequence < beans::PropertyValue > aProps;
     658           0 :                     aAny = xSet->getPropertyValue("AppletCommands");
     659           0 :                     aAny >>= aProps;
     660             : 
     661           0 :                     sal_Int32 i = aProps.getLength();
     662           0 :                     while ( i > 0 )
     663             :                     {
     664           0 :                         beans::PropertyValue& aProp = aProps[--i];
     665           0 :                         sal_uInt16 nType2 = SwApplet_Impl::GetOptionType( aProp.Name, sal_True );
     666           0 :                         if (SWHTML_OPTTYPE_PARAM == nType2 || SWHTML_OPTTYPE_SIZE == nType2 )
     667             :                         {
     668           0 :                             OUString aStr;
     669           0 :                             aProp.Value >>= aStr;
     670           0 :                             rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aProp.Name );
     671           0 :                             rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
     672           0 :                             SvXMLElementExport aElementExport2( rXMLExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true );
     673             :                         }
     674           0 :                     }
     675             :                 }
     676             :             }
     677           0 :             break;
     678             :         case SV_EMBEDDED_PLUGIN:
     679             :             {
     680           0 :                 if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
     681             :                 {
     682           0 :                     uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
     683           0 :                     uno::Sequence < beans::PropertyValue > aProps;
     684           0 :                     aAny = xSet->getPropertyValue("PluginCommands");
     685           0 :                     aAny >>= aProps;
     686             : 
     687           0 :                     sal_Int32 i = aProps.getLength();
     688           0 :                     while ( i > 0 )
     689             :                     {
     690           0 :                         beans::PropertyValue& aProp = aProps[--i];
     691           0 :                         sal_uInt16 nType2 = SwApplet_Impl::GetOptionType( aProp.Name, sal_False );
     692           0 :                         if ( nType2 == SWHTML_OPTTYPE_TAG)
     693             :                         {
     694           0 :                             OUString aStr;
     695           0 :                             aProp.Value >>= aStr;
     696           0 :                             rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aProp.Name );
     697           0 :                             rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
     698           0 :                             SvXMLElementExport aElementExport2( rXMLExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true );
     699             :                         }
     700           0 :                     }
     701             :                 }
     702             :             }
     703           0 :             break;
     704             :         default:
     705           0 :             break;
     706           0 :         }
     707             :     }
     708           0 :     if( SV_EMBEDDED_OUTPLACE==nType || SV_EMBEDDED_OWN==nType )
     709             :     {
     710           0 :         OUString sURL( sGraphicObjectProtocol );
     711           0 :         sURL += rOLEObj.GetCurrentPersistName();
     712           0 :         if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) == 0 )
     713             :         {
     714           0 :             sURL = GetExport().AddEmbeddedObject( sURL );
     715           0 :             lcl_addURL( rXMLExport, sURL, false );
     716             :         }
     717             : 
     718           0 :         SvXMLElementExport aElementExport( GetExport(), XML_NAMESPACE_DRAW,
     719           0 :                                   XML_IMAGE, false, true );
     720             : 
     721           0 :         if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) != 0 )
     722           0 :             GetExport().AddEmbeddedObjectAsBase64( sURL );
     723             :     }
     724             : 
     725             :     // Lastly the stuff common to each of Applet/Plugin/Floating Frame
     726           0 :     exportEvents( rPropSet );
     727           0 :     exportTitleAndDescription( rPropSet, rPropSetInfo );  // #i73249#
     728           0 :     exportContour( rPropSet, rPropSetInfo );
     729             : }
     730             : 
     731             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10