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

Generated by: LCOV version 1.10