LCOV - code coverage report
Current view: top level - sw/source/filter/xml - xmltexti.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 184 463 39.7 %
Date: 2014-11-03 Functions: 18 23 78.3 %
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/storagehelper.hxx>
      21             : #include <comphelper/processfactory.hxx>
      22             : #include <com/sun/star/embed/EmbedStates.hpp>
      23             : #include <com/sun/star/embed/EmbeddedObjectCreator.hpp>
      24             : #include <com/sun/star/embed/OOoEmbeddedObjectFactory.hpp>
      25             : #include <com/sun/star/embed/XLinkCreator.hpp>
      26             : #include <com/sun/star/embed/XEmbeddedObject.hpp>
      27             : #include <com/sun/star/embed/XVisualObject.hpp>
      28             : #include <com/sun/star/embed/Aspects.hpp>
      29             : #include <com/sun/star/task/XInteractionHandler.hpp>
      30             : #include <rtl/ustrbuf.hxx>
      31             : #include <comphelper/classids.hxx>
      32             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      33             : #include <xmloff/prstylei.hxx>
      34             : #include <xmloff/maptype.hxx>
      35             : #include <xmloff/xmlprmap.hxx>
      36             : #include <xmloff/txtprmap.hxx>
      37             : #include <xmloff/i18nmap.hxx>
      38             : #include "unocrsr.hxx"
      39             : #include "TextCursorHelper.hxx"
      40             : #include "unoframe.hxx"
      41             : #include "doc.hxx"
      42             : #include <IDocumentDrawModelAccess.hxx>
      43             : #include <IDocumentContentOperations.hxx>
      44             : #include "unocoll.hxx"
      45             : #include <fmtfsize.hxx>
      46             : #include <fmtanchr.hxx>
      47             : #include <fmtcntnt.hxx>
      48             : #include "xmlimp.hxx"
      49             : #include "xmltbli.hxx"
      50             : #include "xmltexti.hxx"
      51             : #include "XMLRedlineImportHelper.hxx"
      52             : #include <xmloff/XMLFilterServiceNames.h>
      53             : #include <SwAppletImpl.hxx>
      54             : #include <ndole.hxx>
      55             : #include <docsh.hxx>
      56             : #include <sfx2/docfile.hxx>
      57             : #include <switerator.hxx>
      58             : #include <vcl/svapp.hxx>
      59             : #include <osl/mutex.hxx>
      60             : #include <toolkit/helper/vclunohelper.hxx>
      61             : #include <svtools/embedhlp.hxx>
      62             : #include <svl/urihelper.hxx>
      63             : 
      64             : using namespace ::com::sun::star;
      65             : using namespace ::com::sun::star::uno;
      66             : using namespace ::com::sun::star::lang;
      67             : using namespace ::com::sun::star::text;
      68             : using namespace ::com::sun::star::frame;
      69             : using namespace ::com::sun::star::beans;
      70             : using namespace xml::sax;
      71             : 
      72             : struct XMLServiceMapEntry_Impl
      73             : {
      74             :     const sal_Char *sFilterService;
      75             :     sal_Int32      nFilterServiceLen;
      76             : 
      77             :     sal_uInt32  n1;
      78             :     sal_uInt16  n2, n3;
      79             :     sal_uInt8   n4, n5, n6, n7, n8, n9, n10, n11;
      80             : };
      81             : 
      82             : #define SERVICE_MAP_ENTRY( app, s ) \
      83             :     { XML_IMPORT_FILTER_##app, sizeof(XML_IMPORT_FILTER_##app)-1, \
      84             :       SO3_##s##_CLASSID }
      85             : 
      86             : const XMLServiceMapEntry_Impl aServiceMap[] =
      87             : {
      88             :     SERVICE_MAP_ENTRY( WRITER, SW ),
      89             :     SERVICE_MAP_ENTRY( CALC, SC ),
      90             :     SERVICE_MAP_ENTRY( DRAW, SDRAW ),
      91             :     SERVICE_MAP_ENTRY( IMPRESS, SIMPRESS ),
      92             :     SERVICE_MAP_ENTRY( CHART, SCH ),
      93             :     SERVICE_MAP_ENTRY( MATH, SM ),
      94             :     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
      95             : };
      96          30 : static void lcl_putHeightAndWidth ( SfxItemSet &rItemSet,
      97             :         sal_Int32 nHeight, sal_Int32 nWidth,
      98             :         long *pTwipHeight=0, long *pTwipWidth=0 )
      99             : {
     100          30 :     if( nWidth > 0 && nHeight > 0 )
     101             :     {
     102          30 :         nWidth = convertMm100ToTwip( nWidth );
     103          30 :         if( nWidth < MINFLY )
     104           0 :             nWidth = MINFLY;
     105          30 :         nHeight = convertMm100ToTwip( nHeight );
     106          30 :         if( nHeight < MINFLY )
     107           0 :             nHeight = MINFLY;
     108          30 :         rItemSet.Put( SwFmtFrmSize( ATT_FIX_SIZE, nWidth, nHeight ) );
     109             :     }
     110             : 
     111          30 :     SwFmtAnchor aAnchor( FLY_AT_CHAR );
     112          30 :     rItemSet.Put( aAnchor );
     113             : 
     114          30 :     if( pTwipWidth )
     115          30 :         *pTwipWidth = nWidth;
     116          30 :     if( pTwipHeight )
     117          30 :         *pTwipHeight = nHeight;
     118          30 : }
     119             : 
     120          16 : static void lcl_setObjectVisualArea( const uno::Reference< embed::XEmbeddedObject >& xObj,
     121             :                                     sal_Int64 nAspect,
     122             :                                     const Size& aVisSize,
     123             :                                     const MapUnit& aUnit )
     124             : {
     125          16 :     if( xObj.is() && nAspect != embed::Aspects::MSOLE_ICON )
     126             :     {
     127             :         // convert the visual area to the objects units
     128          16 :         MapUnit aObjUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
     129          16 :         Size aObjVisSize = OutputDevice::LogicToLogic( aVisSize, aUnit, aObjUnit );
     130          16 :         awt::Size aSz;
     131          16 :         aSz.Width = aObjVisSize.Width();
     132          16 :         aSz.Height = aObjVisSize.Height();
     133             : 
     134             :         try
     135             :         {
     136          16 :             xObj->setVisualAreaSize( nAspect, aSz );
     137             :         }
     138           0 :         catch( uno::Exception& )
     139             :         {
     140             :             OSL_FAIL( "Couldn't set visual area of the object!\n" );
     141             :         }
     142             :     }
     143          16 : }
     144             : 
     145        1358 : SwXMLTextImportHelper::SwXMLTextImportHelper(
     146             :         const uno::Reference < XModel>& rModel,
     147             :         SvXMLImport& rImport,
     148             :         const uno::Reference<XPropertySet> & rInfoSet,
     149             :         bool bInsertM, bool bStylesOnlyM, bool _bProgress,
     150             :         bool bBlockM, bool bOrganizerM,
     151             :         bool /*bPreserveRedlineMode*/ ) :
     152             :     XMLTextImportHelper( rModel, rImport, bInsertM, bStylesOnlyM, _bProgress,
     153             :                          bBlockM, bOrganizerM ),
     154        1358 :     pRedlineHelper( NULL )
     155             : {
     156        1358 :     uno::Reference<XPropertySet> xDocPropSet( rModel, UNO_QUERY );
     157             :     pRedlineHelper = new XMLRedlineImportHelper(
     158        1358 :         bInsertM || bBlockM, xDocPropSet, rInfoSet );
     159        1358 : }
     160             : 
     161        4074 : SwXMLTextImportHelper::~SwXMLTextImportHelper()
     162             : {
     163             :     // the redline helper destructor sets properties on the document
     164             :     // and may through an exception while doing so... catch this
     165             :     try
     166             :     {
     167        1358 :         delete pRedlineHelper;
     168             :     }
     169             :     catch ( const RuntimeException& )
     170             :     {
     171             :         // ignore
     172             :     }
     173        2716 : }
     174             : 
     175         102 : SvXMLImportContext *SwXMLTextImportHelper::CreateTableChildContext(
     176             :                 SvXMLImport& rImport,
     177             :                 sal_uInt16 nPrefix, const OUString& rLocalName,
     178             :                 const uno::Reference< XAttributeList > & xAttrList )
     179             : {
     180             :     return new SwXMLTableContext(
     181         102 :                 (SwXMLImport&)rImport, nPrefix, rLocalName, xAttrList );
     182             : }
     183             : 
     184         104 : bool SwXMLTextImportHelper::IsInHeaderFooter() const
     185             : {
     186             :     uno::Reference<XUnoTunnel> xCrsrTunnel(
     187         104 :             ((SwXMLTextImportHelper *)this)->GetCursor(), UNO_QUERY );
     188             :     OSL_ENSURE( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" );
     189             :     OTextCursorHelper *pTxtCrsr = reinterpret_cast< OTextCursorHelper * >(
     190         104 :                 sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
     191             :     OSL_ENSURE( pTxtCrsr, "SwXTextCursor missing" );
     192         104 :     SwDoc *pDoc = pTxtCrsr ? pTxtCrsr->GetDoc() : NULL;
     193             : 
     194         104 :     return pDoc && pDoc->IsInHeaderFooter( pTxtCrsr->GetPaM()->GetPoint()->nNode );
     195             : }
     196             : 
     197          30 : static SwOLENode *lcl_GetOLENode( const SwFrmFmt *pFrmFmt )
     198             : {
     199          30 :     SwOLENode *pOLENd = 0;
     200          30 :     if( pFrmFmt )
     201             :     {
     202          30 :         const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
     203          30 :         const SwNodeIndex *pNdIdx = rCntnt.GetCntntIdx();
     204          30 :         pOLENd = pNdIdx->GetNodes()[pNdIdx->GetIndex() + 1]->GetOLENode();
     205             :     }
     206             :     OSL_ENSURE( pOLENd, "Where is the OLE node" );
     207          30 :     return pOLENd;
     208             : }
     209             : 
     210          30 : uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject(
     211             :         SvXMLImport& rImport,
     212             :         const OUString& rHRef,
     213             :         const OUString& rStyleName,
     214             :         const OUString& rTblName,
     215             :         sal_Int32 nWidth, sal_Int32 nHeight )
     216             : {
     217             :     // this method will modify the document directly -> lock SolarMutex
     218          30 :     SolarMutexGuard aGuard;
     219             : 
     220          30 :     uno::Reference < XPropertySet > xPropSet;
     221             : 
     222          30 :     sal_Int32 nPos = rHRef.indexOf( ':' );
     223          30 :     if( -1 == nPos )
     224           0 :         return xPropSet;
     225             : 
     226          60 :     OUString aObjName( rHRef.copy( nPos+1) );
     227             : 
     228          30 :     if( aObjName.isEmpty() )
     229           0 :         return xPropSet;
     230             : 
     231          60 :     uno::Reference<XUnoTunnel> xCrsrTunnel( GetCursor(), UNO_QUERY );
     232             :     OSL_ENSURE( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" );
     233             :     OTextCursorHelper *pTxtCrsr = reinterpret_cast< OTextCursorHelper * >(
     234          30 :                 sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
     235             :     OSL_ENSURE( pTxtCrsr, "SwXTextCursor missing" );
     236          30 :     SwDoc *pDoc = SwImport::GetDocFromXMLImport( rImport );
     237             : 
     238          30 :     SfxItemSet aItemSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
     239          60 :                          RES_FRMATR_END );
     240          30 :     Size aTwipSize( 0, 0 );
     241          30 :     Rectangle aVisArea( 0, 0, nWidth, nHeight );
     242             :     lcl_putHeightAndWidth( aItemSet, nHeight, nWidth,
     243          30 :                            &aTwipSize.Height(), &aTwipSize.Width() );
     244             : 
     245          30 :     SwFrmFmt *pFrmFmt = 0;
     246          30 :     SwOLENode *pOLENd = 0;
     247          30 :     if( rHRef.copy( 0, nPos ) == "vnd.sun.star.ServiceName" )
     248             :     {
     249          10 :         bool bInsert = false;
     250          10 :         SvGlobalName aClassName;
     251          10 :         const XMLServiceMapEntry_Impl *pEntry = aServiceMap;
     252          40 :         while( pEntry->sFilterService )
     253             :         {
     254          30 :             if( aObjName.equalsAsciiL( pEntry->sFilterService,
     255          30 :                                      pEntry->nFilterServiceLen ) )
     256             :             {
     257          20 :                 aClassName = SvGlobalName( pEntry->n1, pEntry->n2,
     258             :                                            pEntry->n3, pEntry->n4,
     259             :                                            pEntry->n5, pEntry->n6,
     260             :                                            pEntry->n7, pEntry->n8,
     261             :                                            pEntry->n9, pEntry->n10,
     262          10 :                                            pEntry->n11  );
     263          10 :                 bInsert = true;
     264          10 :                 break;
     265             :             }
     266          20 :             pEntry++;
     267             :         }
     268             : 
     269          10 :         if( bInsert )
     270             :         {
     271          10 :             uno::Reference < embed::XStorage > xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
     272             :             try
     273             :             {
     274             :                 // create object with desired ClassId
     275          10 :                 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
     276          10 :                 OUString aName("DummyName");
     277          20 :                 uno::Sequence < sal_Int8 > aClass( aClassName.GetByteSequence() );
     278          20 :                 uno::Reference < embed::XEmbeddedObjectCreator > xFactory = embed::EmbeddedObjectCreator::create( ::comphelper::getProcessComponentContext() );
     279             :                 uno::Reference < embed::XEmbeddedObject > xObj =
     280          10 :                     uno::Reference < embed::XEmbeddedObject >( xFactory->createInstanceInitNew(
     281             :                     aClass, OUString(), xStorage, aName,
     282          20 :                     uno::Sequence < beans::PropertyValue >() ), uno::UNO_QUERY );
     283          10 :                 if ( xObj.is() )
     284             :                 {
     285             :                     //TODO/LATER: is it enough to only set the VisAreaSize?
     286          10 :                     lcl_setObjectVisualArea( xObj, nAspect, aTwipSize, MAP_TWIP );
     287             :                 }
     288             : 
     289          20 :                 pFrmFmt = pDoc->getIDocumentContentOperations().Insert( *pTxtCrsr->GetPaM(),
     290             :                                         ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ),
     291             :                                         &aItemSet,
     292             :                                         NULL,
     293          20 :                                         NULL );
     294          10 :                 pOLENd = lcl_GetOLENode( pFrmFmt );
     295          10 :                 if( pOLENd )
     296          20 :                     aObjName = pOLENd->GetOLEObj().GetCurrentPersistName();
     297             :             }
     298           0 :             catch ( uno::Exception& )
     299             :             {
     300          10 :             }
     301          10 :         }
     302             :     }
     303             :     else
     304             :     {
     305             :         // check whether an object with this name already exists in the document
     306          20 :         OUString aName;
     307          40 :         SwIterator<SwCntntNode,SwFmtColl> aIter( *pDoc->GetDfltGrfFmtColl() );
     308          34 :         for( SwCntntNode* pNd = aIter.First(); pNd; pNd = aIter.Next() )
     309             :         {
     310          14 :             SwOLENode* pExistingOLENd = pNd->GetOLENode();
     311          14 :             if( pExistingOLENd )
     312             :             {
     313          12 :                 OUString aExistingName = pExistingOLENd->GetOLEObj().GetCurrentPersistName();
     314          12 :                 if ( aExistingName.equals( aObjName ) )
     315             :                 {
     316             :                     OSL_FAIL( "The document contains duplicate object references, means it is partially broken, please let developers know how this document was generated!\n" );
     317             : 
     318           0 :                     OUString aTmpName = pDoc->GetPersist()->GetEmbeddedObjectContainer().CreateUniqueObjectName();
     319             :                     try
     320             :                     {
     321           0 :                         pDoc->GetPersist()->GetStorage()->copyElementTo( aObjName,
     322             :                                                                          pDoc->GetPersist()->GetStorage(),
     323           0 :                                                                          aTmpName );
     324           0 :                         aName = aTmpName;
     325             :                     }
     326           0 :                     catch ( uno::Exception& )
     327             :                     {
     328             :                         OSL_FAIL( "Couldn't create a copy of the object!\n" );
     329             :                     }
     330             : 
     331           0 :                     break;
     332          12 :                 }
     333             :             }
     334             :         }
     335             : 
     336          20 :         if ( aName.isEmpty() )
     337          20 :             aName = aObjName;
     338             : 
     339             :         // the correct aspect will be set later
     340             :         // TODO/LATER: Actually it should be set here
     341          20 :         if( pTxtCrsr )
     342             :         {
     343          20 :             pFrmFmt = pDoc->getIDocumentContentOperations().InsertOLE( *pTxtCrsr->GetPaM(), aName, embed::Aspects::MSOLE_CONTENT, &aItemSet, NULL, NULL );
     344          20 :             pOLENd = lcl_GetOLENode( pFrmFmt );
     345             :         }
     346          40 :         aObjName = aName;
     347             :     }
     348             : 
     349          30 :     if( !pFrmFmt )
     350           0 :         return xPropSet;
     351             : 
     352          30 :     if( IsInsertMode() )
     353             :     {
     354          10 :         if( !pOLENd )
     355           0 :             pOLENd = lcl_GetOLENode( pFrmFmt );
     356          10 :         if( pOLENd )
     357          10 :             pOLENd->SetOLESizeInvalid( true );
     358             :     }
     359             : 
     360             :     xPropSet.set(SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
     361          30 :                 *pDoc, pFrmFmt), uno::UNO_QUERY);
     362          30 :     if( pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
     363             :     {
     364             :         // req for z-order
     365          30 :         SwXFrame::GetOrCreateSdrObject(*static_cast<SwFlyFrmFmt*>(pFrmFmt));
     366             :     }
     367          30 :     if( !rTblName.isEmpty() )
     368             :     {
     369           0 :         const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
     370           0 :         const SwNodeIndex *pNdIdx = rCntnt.GetCntntIdx();
     371           0 :         SwOLENode *pOLENode = pNdIdx->GetNodes()[pNdIdx->GetIndex() + 1]->GetOLENode();
     372             :         OSL_ENSURE( pOLENode, "Where is the OLE node" );
     373             : 
     374           0 :         OUStringBuffer aBuffer( rTblName.getLength() );
     375           0 :         bool bQuoted = false;
     376           0 :         bool bEscape = false;
     377           0 :         bool bError = false;
     378           0 :         for( sal_Int32 i=0; i < rTblName.getLength(); i++ )
     379             :         {
     380           0 :             bool bEndOfNameFound = false;
     381           0 :             sal_Unicode c = rTblName[i];
     382           0 :             switch( c )
     383             :             {
     384             :             case '\'':
     385           0 :                 if( bEscape )
     386             :                 {
     387           0 :                     aBuffer.append( c );
     388           0 :                     bEscape = false;
     389             :                 }
     390           0 :                 else if( bQuoted )
     391             :                 {
     392           0 :                     bEndOfNameFound = true;
     393             :                 }
     394           0 :                 else if( 0 == i )
     395             :                 {
     396           0 :                     bQuoted = true;
     397             :                 }
     398             :                 else
     399             :                 {
     400           0 :                     bError = true;
     401             :                 }
     402           0 :                 break;
     403             :             case '\\':
     404           0 :                 if( bEscape )
     405             :                 {
     406           0 :                     aBuffer.append( c );
     407           0 :                     bEscape = false;
     408             :                 }
     409             :                 else
     410             :                 {
     411           0 :                     bEscape = true;
     412             :                 }
     413           0 :                 break;
     414             :             case ' ':
     415             :             case '.':
     416           0 :                 if( !bQuoted )
     417             :                 {
     418           0 :                     bEndOfNameFound = true;
     419             :                 }
     420             :                 else
     421             :                 {
     422           0 :                     aBuffer.append( c );
     423           0 :                     bEscape = false;
     424             :                 }
     425           0 :                 break;
     426             :             default:
     427             :                 {
     428           0 :                     aBuffer.append( c );
     429           0 :                     bEscape = false;
     430             :                 }
     431           0 :                 break;
     432             :             }
     433           0 :             if( bError || bEndOfNameFound )
     434             :                 break;
     435             :         }
     436           0 :         if( !bError )
     437             :         {
     438           0 :             OUString sTblName( aBuffer.makeStringAndClear() );
     439           0 :             pOLENode->SetChartTblName( GetRenameMap().Get( XML_TEXT_RENAME_TYPE_TABLE, sTblName ) );
     440           0 :         }
     441             :     }
     442             : 
     443          30 :     sal_Int64 nDrawAspect = 0;
     444          30 :     const XMLPropStyleContext *pStyle = 0;
     445          30 :     bool bHasSizeProps = false;
     446          30 :     if( !rStyleName.isEmpty() )
     447             :     {
     448          30 :         pStyle = FindAutoFrameStyle( rStyleName );
     449          30 :         if( pStyle )
     450             :         {
     451             :             rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap =
     452          30 :                 pStyle->GetStyles()
     453          30 :                       ->GetImportPropertyMapper(pStyle->GetFamily());
     454             :             OSL_ENSURE( xImpPrMap.is(), "Where is the import prop mapper?" );
     455          30 :             if( xImpPrMap.is() )
     456             :             {
     457             :                 rtl::Reference<XMLPropertySetMapper> rPropMapper =
     458          30 :                 xImpPrMap->getPropertySetMapper();
     459             : 
     460          30 :                 sal_Int32 nCount = pStyle->GetProperties().size();
     461         278 :                 for( sal_Int32 i=0; i < nCount; i++ )
     462             :                 {
     463         248 :                     const XMLPropertyState& rProp = pStyle->GetProperties()[i];
     464         248 :                     sal_Int32 nIdx = rProp.mnIndex;
     465         248 :                     if( -1 == nIdx )
     466          32 :                         continue;
     467             : 
     468         216 :                     switch( rPropMapper->GetEntryContextId(nIdx) )
     469             :                     {
     470             :                     case CTF_OLE_VIS_AREA_LEFT:
     471             :                         {
     472           0 :                             sal_Int32 nVal = 0;
     473           0 :                             rProp.maValue >>= nVal;
     474           0 :                             aVisArea.setX( nVal );
     475             :                         }
     476           0 :                         break;
     477             :                     case CTF_OLE_VIS_AREA_TOP:
     478             :                         {
     479           0 :                             sal_Int32 nVal = 0;
     480           0 :                             rProp.maValue >>= nVal;
     481           0 :                             aVisArea.setY( nVal );
     482             :                         }
     483           0 :                         break;
     484             :                     case CTF_OLE_VIS_AREA_WIDTH:
     485             :                         {
     486           6 :                             sal_Int32 nVal = 0;
     487           6 :                             rProp.maValue >>= nVal;
     488           6 :                             aVisArea.setWidth( nVal );
     489           6 :                             bHasSizeProps = true;
     490             :                         }
     491           6 :                         break;
     492             :                     case CTF_OLE_VIS_AREA_HEIGHT:
     493             :                         {
     494           6 :                             sal_Int32 nVal = 0;
     495           6 :                             rProp.maValue >>= nVal;
     496           6 :                             aVisArea.setHeight( nVal );
     497           6 :                             bHasSizeProps = true;
     498             :                         }
     499           6 :                         break;
     500             :                     case CTF_OLE_DRAW_ASPECT:
     501             :                         {
     502          30 :                             rProp.maValue >>= nDrawAspect;
     503             : 
     504          30 :                             if ( !nDrawAspect )
     505           0 :                                 nDrawAspect = embed::Aspects::MSOLE_CONTENT;
     506             : 
     507          30 :                             if ( pOLENd )
     508          30 :                                 pOLENd->GetOLEObj().GetObject().SetViewAspect( nDrawAspect );
     509             :                         }
     510          30 :                         break;
     511             :                     }
     512          30 :                 }
     513          30 :             }
     514             :         }
     515             :     }
     516             : 
     517          30 :     if ( bHasSizeProps )
     518             :     {
     519             :         uno::Reference < embed::XEmbeddedObject > xObj =
     520           6 :                     pDoc->GetPersist()->GetEmbeddedObjectContainer().GetEmbeddedObject( aObjName );
     521           6 :         if( xObj.is() )
     522             :             lcl_setObjectVisualArea( xObj, ( nDrawAspect ? nDrawAspect : embed::Aspects::MSOLE_CONTENT ),
     523           6 :                                      aVisArea.GetSize(), MAP_100TH_MM );
     524             :     }
     525             : 
     526          60 :     return xPropSet;
     527             : }
     528             : 
     529           0 : uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOOoLink(
     530             :         SvXMLImport& rImport,
     531             :         const OUString& rHRef,
     532             :         const OUString& /*rStyleName*/,
     533             :         const OUString& /*rTblName*/,
     534             :         sal_Int32 nWidth, sal_Int32 nHeight )
     535             : {
     536             :     // this method will modify the document directly -> lock SolarMutex
     537           0 :     SolarMutexGuard aGuard;
     538             : 
     539           0 :     uno::Reference < XPropertySet > xPropSet;
     540             : 
     541           0 :     uno::Reference<XUnoTunnel> xCrsrTunnel( GetCursor(), UNO_QUERY );
     542             :     OSL_ENSURE( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" );
     543             :     OTextCursorHelper *pTxtCrsr = reinterpret_cast< OTextCursorHelper * >(
     544           0 :                 sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
     545             :     OSL_ENSURE( pTxtCrsr, "SwXTextCursor missing" );
     546           0 :     SwDoc *pDoc = SwImport::GetDocFromXMLImport( rImport );
     547             : 
     548           0 :     SfxItemSet aItemSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
     549           0 :                          RES_FRMATR_END );
     550           0 :     Size aTwipSize( 0, 0 );
     551             :     lcl_putHeightAndWidth( aItemSet, nHeight, nWidth,
     552           0 :                            &aTwipSize.Height(), &aTwipSize.Width() );
     553             : 
     554             :     // We'll need a (valid) URL. If we don't have do not insert the link and return early.
     555             :     // Copy URL into URL oject on the way.
     556           0 :        INetURLObject aURLObj;
     557           0 :     bool bValidURL = !rHRef.isEmpty() &&
     558             :                      aURLObj.SetURL( URIHelper::SmartRel2Abs(
     559           0 :                                 INetURLObject( GetXMLImport().GetBaseURL() ), rHRef ) );
     560           0 :     if( !bValidURL )
     561           0 :         return xPropSet;
     562             : 
     563           0 :     uno::Reference < embed::XStorage > xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
     564             :     try
     565             :     {
     566             :         // create object with desired ClassId
     567           0 :         OUString aName("DummyName");
     568             :         uno::Reference < embed::XEmbeddedObjectCreator > xFactory =
     569           0 :                 embed::OOoEmbeddedObjectFactory::create(::comphelper::getProcessComponentContext());
     570             : 
     571           0 :         uno::Sequence< beans::PropertyValue > aMediaDescriptor( 1 );
     572           0 :         aMediaDescriptor[0].Name = "URL";
     573           0 :         aMediaDescriptor[0].Value <<= OUString( aURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
     574           0 :         if ( pDoc->GetDocShell() && pDoc->GetDocShell()->GetMedium() )
     575             :         {
     576             :             uno::Reference< task::XInteractionHandler > xInteraction =
     577           0 :                                         pDoc->GetDocShell()->GetMedium()->GetInteractionHandler();
     578           0 :             if ( xInteraction.is() )
     579             :             {
     580           0 :                 aMediaDescriptor.realloc( 2 );
     581           0 :                 aMediaDescriptor[1].Name = "InteractionHandler";
     582           0 :                 aMediaDescriptor[1].Value <<= xInteraction;
     583           0 :             }
     584             :         }
     585             : 
     586             :         uno::Reference < embed::XEmbeddedObject > xObj(
     587           0 :             xFactory->createInstanceLink(
     588           0 :                 xStorage, aName, aMediaDescriptor, uno::Sequence< beans::PropertyValue >() ),
     589           0 :             uno::UNO_QUERY_THROW );
     590             : 
     591             :         {
     592           0 :             SwFrmFmt *pFrmFmt = pDoc->getIDocumentContentOperations().Insert( *pTxtCrsr->GetPaM(),
     593             :                                             ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ),
     594             :                                             &aItemSet,
     595             :                                             NULL,
     596           0 :                                             NULL );
     597             : 
     598             :             // TODO/LATER: in future may need a way to set replacement image url to the link ( may be even to the object ), needs oasis cws???
     599             : 
     600             :             xPropSet.set(SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
     601           0 :                             *pDoc, pFrmFmt), uno::UNO_QUERY);
     602           0 :             if( pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
     603             :             {
     604             :                 SwXFrame::GetOrCreateSdrObject(*
     605           0 :                         static_cast<SwFlyFrmFmt*>(pFrmFmt)); // req for z-order
     606             :             }
     607           0 :         }
     608             :     }
     609           0 :     catch ( uno::Exception& )
     610             :     {
     611             :     }
     612             : 
     613             :     // TODO/LATER: should the rStyleName and rTblName be handled as for usual embedded object?
     614             : 
     615           0 :     return xPropSet;
     616             : }
     617             : 
     618           0 : uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertApplet(
     619             :         const OUString &rName,
     620             :         const OUString &rCode,
     621             :         bool bMayScript,
     622             :         const OUString& rHRef,
     623             :         sal_Int32 nWidth, sal_Int32 nHeight )
     624             : {
     625             :     // this method will modify the document directly -> lock SolarMutex
     626           0 :     SolarMutexGuard aGuard;
     627             : 
     628           0 :     uno::Reference < XPropertySet > xPropSet;
     629           0 :     uno::Reference<XUnoTunnel> xCrsrTunnel( GetCursor(), UNO_QUERY );
     630             :     OSL_ENSURE( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" );
     631             :     OTextCursorHelper *pTxtCrsr = reinterpret_cast< OTextCursorHelper * >(
     632           0 :                 sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
     633             :     OSL_ENSURE( pTxtCrsr, "SwXTextCursor missing" );
     634           0 :     SwDoc *pDoc = pTxtCrsr->GetDoc();
     635             : 
     636           0 :     SfxItemSet aItemSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
     637           0 :                          RES_FRMATR_END );
     638           0 :     lcl_putHeightAndWidth( aItemSet, nHeight, nWidth);
     639             : 
     640           0 :     SwApplet_Impl aAppletImpl ( aItemSet );
     641             : 
     642           0 :     OUString sCodeBase;
     643           0 :     if( !rHRef.isEmpty() )
     644           0 :         sCodeBase = GetXMLImport().GetAbsoluteReference( rHRef );
     645             : 
     646           0 :     aAppletImpl.CreateApplet ( rCode, rName, bMayScript, sCodeBase, GetXMLImport().GetDocumentBase() );
     647             : 
     648             :     // set the size of the applet
     649             :     lcl_setObjectVisualArea( aAppletImpl.GetApplet(),
     650             :                             embed::Aspects::MSOLE_CONTENT,
     651             :                             Size( nWidth, nHeight ),
     652           0 :                             MAP_100TH_MM );
     653             : 
     654           0 :     SwFrmFmt *pFrmFmt = pDoc->getIDocumentContentOperations().Insert( *pTxtCrsr->GetPaM(),
     655             :                                        ::svt::EmbeddedObjectRef( aAppletImpl.GetApplet(), embed::Aspects::MSOLE_CONTENT ),
     656           0 :                                        &aAppletImpl.GetItemSet(),
     657             :                                        NULL,
     658           0 :                                        NULL);
     659             :     xPropSet.set(SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
     660           0 :                 *pDoc, pFrmFmt), uno::UNO_QUERY);
     661           0 :     if( pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
     662             :     {
     663             :         // req for z-order
     664           0 :         SwXFrame::GetOrCreateSdrObject(*static_cast<SwFlyFrmFmt*>(pFrmFmt));
     665             :     }
     666             : 
     667           0 :     return xPropSet;
     668             : }
     669             : 
     670           0 : uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertPlugin(
     671             :         const OUString &rMimeType,
     672             :         const OUString& rHRef,
     673             :         sal_Int32 nWidth, sal_Int32 nHeight )
     674             : {
     675           0 :     uno::Reference < XPropertySet > xPropSet;
     676           0 :     uno::Reference<XUnoTunnel> xCrsrTunnel( GetCursor(), UNO_QUERY );
     677             :     OSL_ENSURE( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" );
     678             :     OTextCursorHelper *pTxtCrsr = reinterpret_cast< OTextCursorHelper * >(
     679           0 :             sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
     680             :     OSL_ENSURE( pTxtCrsr, "SwXTextCursor missing" );
     681           0 :     SwDoc *pDoc = pTxtCrsr->GetDoc();
     682             : 
     683           0 :     SfxItemSet aItemSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
     684           0 :                          RES_FRMATR_END );
     685           0 :     lcl_putHeightAndWidth( aItemSet, nHeight, nWidth);
     686             : 
     687             :     // We'll need a (valid) URL, or we need a MIME type. If we don't have
     688             :     // either, do not insert plugin and return early. Copy URL into URL oject
     689             :     // on the way.
     690           0 :        INetURLObject aURLObj;
     691             : 
     692           0 :     bool bValidURL = !rHRef.isEmpty() &&
     693           0 :                      aURLObj.SetURL( URIHelper::SmartRel2Abs( INetURLObject( GetXMLImport().GetBaseURL() ), rHRef ) );
     694           0 :     bool bValidMimeType = !rMimeType.isEmpty();
     695           0 :     if( !bValidURL && !bValidMimeType )
     696           0 :         return xPropSet;
     697             : 
     698           0 :     uno::Reference < embed::XStorage > xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
     699             :     try
     700             :     {
     701             :         // create object with desired ClassId
     702           0 :         OUString aName("DummyName");
     703           0 :         uno::Sequence < sal_Int8 > aClass( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence() );
     704           0 :         uno::Reference < embed::XEmbeddedObjectCreator > xFactory =  embed::EmbeddedObjectCreator::create( ::comphelper::getProcessComponentContext() );
     705             :         uno::Reference < embed::XEmbeddedObject > xObj =
     706           0 :             uno::Reference < embed::XEmbeddedObject >( xFactory->createInstanceInitNew(
     707             :             aClass, OUString(), xStorage, aName,
     708           0 :             uno::Sequence < beans::PropertyValue >() ), uno::UNO_QUERY );
     709             : 
     710             :         // set size to the object
     711             :         lcl_setObjectVisualArea( xObj,
     712             :                                 embed::Aspects::MSOLE_CONTENT,
     713             :                                 Size( nWidth, nHeight ),
     714           0 :                                 MAP_100TH_MM );
     715             : 
     716           0 :         if ( svt::EmbeddedObjectRef::TryRunningState( xObj ) )
     717             :         {
     718           0 :             uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
     719           0 :             if ( xSet.is() )
     720             :             {
     721           0 :                 if( bValidURL )
     722           0 :                     xSet->setPropertyValue("PluginURL",
     723           0 :                         makeAny( OUString( aURLObj.GetMainURL( INetURLObject::NO_DECODE ) ) ) );
     724           0 :                 if( bValidMimeType )
     725           0 :                     xSet->setPropertyValue("PluginMimeType",
     726           0 :                         makeAny( OUString( rMimeType ) ) );
     727             :             }
     728             : 
     729           0 :             SwFrmFmt *pFrmFmt = pDoc->getIDocumentContentOperations().Insert( *pTxtCrsr->GetPaM(),
     730             :                                             ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ),
     731             :                                             &aItemSet,
     732             :                                             NULL,
     733           0 :                                             NULL);
     734             :             xPropSet.set(SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
     735           0 :                             *pDoc, pFrmFmt), uno::UNO_QUERY);
     736           0 :             if( pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
     737             :             {
     738             :                 SwXFrame::GetOrCreateSdrObject(*
     739           0 :                         static_cast<SwFlyFrmFmt*>(pFrmFmt)); // req for z-order
     740           0 :             }
     741           0 :         }
     742             :     }
     743           0 :     catch ( uno::Exception& )
     744             :     {
     745             :     }
     746             : 
     747           0 :     return xPropSet;
     748             : }
     749           0 : uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFrame(
     750             :         const OUString& rName,
     751             :         const OUString& rHRef,
     752             :         const OUString& rStyleName,
     753             :         sal_Int32 nWidth, sal_Int32 nHeight )
     754             : {
     755             :     // this method will modify the document directly -> lock SolarMutex
     756           0 :     SolarMutexGuard aGuard;
     757             : 
     758           0 :     uno::Reference < XPropertySet > xPropSet;
     759           0 :     uno::Reference<XUnoTunnel> xCrsrTunnel( GetCursor(), UNO_QUERY );
     760             :     OSL_ENSURE( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" );
     761             :     OTextCursorHelper *pTxtCrsr = reinterpret_cast< OTextCursorHelper * >(
     762           0 :                 sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
     763             :     OSL_ENSURE( pTxtCrsr, "SwXTextCursor missing" );
     764           0 :     SwDoc *pDoc = pTxtCrsr->GetDoc();
     765             : 
     766           0 :     SfxItemSet aItemSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
     767           0 :                          RES_FRMATR_END );
     768           0 :     lcl_putHeightAndWidth( aItemSet, nHeight, nWidth);
     769             : 
     770           0 :     ScrollingMode eScrollMode = ScrollingAuto;
     771           0 :     bool bHasBorder = false;
     772           0 :     bool bIsBorderSet = false;
     773           0 :     Size aMargin( SIZE_NOT_SET, SIZE_NOT_SET );
     774           0 :     const XMLPropStyleContext *pStyle = 0;
     775           0 :     if( !rStyleName.isEmpty() )
     776             :     {
     777           0 :         pStyle = FindAutoFrameStyle( rStyleName );
     778           0 :         if( pStyle )
     779             :         {
     780             :             rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap =
     781           0 :                 pStyle->GetStyles()
     782           0 :                       ->GetImportPropertyMapper(pStyle->GetFamily());
     783             :             OSL_ENSURE( xImpPrMap.is(), "Where is the import prop mapper?" );
     784           0 :             if( xImpPrMap.is() )
     785             :             {
     786             :                 rtl::Reference<XMLPropertySetMapper> rPropMapper =
     787           0 :                 xImpPrMap->getPropertySetMapper();
     788             : 
     789           0 :                 sal_Int32 nCount = pStyle->GetProperties().size();
     790           0 :                 for( sal_Int32 i=0; i < nCount; i++ )
     791             :                 {
     792           0 :                     const XMLPropertyState& rProp = pStyle->GetProperties()[i];
     793           0 :                     sal_Int32 nIdx = rProp.mnIndex;
     794           0 :                     if( -1 == nIdx )
     795           0 :                         continue;
     796             : 
     797           0 :                     switch( rPropMapper->GetEntryContextId(nIdx) )
     798             :                     {
     799             :                     case CTF_FRAME_DISPLAY_SCROLLBAR:
     800             :                         {
     801           0 :                             bool bYes = *(sal_Bool *)rProp.maValue.getValue();
     802           0 :                             eScrollMode = bYes ? ScrollingYes : ScrollingNo;
     803             :                         }
     804           0 :                         break;
     805             :                     case CTF_FRAME_DISPLAY_BORDER:
     806             :                         {
     807           0 :                             bHasBorder = *(sal_Bool *)rProp.maValue.getValue();
     808           0 :                             bIsBorderSet = true;
     809             :                         }
     810           0 :                         break;
     811             :                     case CTF_FRAME_MARGIN_HORI:
     812             :                         {
     813           0 :                             sal_Int32 nVal = SIZE_NOT_SET;
     814           0 :                             rProp.maValue >>= nVal;
     815           0 :                             aMargin.Width() = nVal;
     816             :                         }
     817           0 :                         break;
     818             :                     case CTF_FRAME_MARGIN_VERT:
     819             :                         {
     820           0 :                             sal_Int32 nVal = SIZE_NOT_SET;
     821           0 :                             rProp.maValue >>= nVal;
     822           0 :                             aMargin.Height() = nVal;
     823             :                         }
     824           0 :                         break;
     825             :                     }
     826           0 :                 }
     827           0 :             }
     828             :         }
     829             :     }
     830             : 
     831           0 :     uno::Reference < embed::XStorage > xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
     832             :     try
     833             :     {
     834             :         // create object with desired ClassId
     835           0 :         OUString aName("DummyName");
     836           0 :         uno::Sequence < sal_Int8 > aClass( SvGlobalName( SO3_IFRAME_CLASSID ).GetByteSequence() );
     837           0 :         uno::Reference < embed::XEmbeddedObjectCreator > xFactory = embed::EmbeddedObjectCreator::create( ::comphelper::getProcessComponentContext() );
     838             :         uno::Reference < embed::XEmbeddedObject > xObj =
     839           0 :             uno::Reference < embed::XEmbeddedObject >( xFactory->createInstanceInitNew(
     840             :             aClass, OUString(), xStorage, aName,
     841           0 :             uno::Sequence < beans::PropertyValue >() ), uno::UNO_QUERY );
     842             : 
     843             :         // set size to the object
     844             :         lcl_setObjectVisualArea( xObj,
     845             :                                 embed::Aspects::MSOLE_CONTENT,
     846             :                                 Size( nWidth, nHeight ),
     847           0 :                                 MAP_100TH_MM );
     848             : 
     849           0 :         if ( svt::EmbeddedObjectRef::TryRunningState( xObj ) )
     850             :         {
     851           0 :             uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
     852           0 :             if ( xSet.is() )
     853             :             {
     854           0 :                 xSet->setPropertyValue("FrameURL",
     855             :                     makeAny( OUString( URIHelper::SmartRel2Abs(
     856           0 :                             INetURLObject( GetXMLImport().GetBaseURL() ), rHRef ) ) ) );
     857             : 
     858           0 :                 xSet->setPropertyValue("FrameName",
     859           0 :                     makeAny( OUString( rName ) ) );
     860             : 
     861           0 :                 if ( eScrollMode == ScrollingAuto )
     862           0 :                     xSet->setPropertyValue("FrameIsAutoScroll",
     863           0 :                         makeAny( true ) );
     864             :                 else
     865           0 :                     xSet->setPropertyValue("FrameIsScrollingMode",
     866           0 :                         makeAny( eScrollMode == ScrollingYes ) );
     867             : 
     868           0 :                 if ( bIsBorderSet )
     869           0 :                     xSet->setPropertyValue("FrameIsBorder",
     870           0 :                         makeAny( bHasBorder ) );
     871             :                 else
     872           0 :                     xSet->setPropertyValue("FrameIsAutoBorder",
     873           0 :                         makeAny( true ) );
     874             : 
     875           0 :                 xSet->setPropertyValue("FrameMarginWidth",
     876           0 :                     makeAny( sal_Int32( aMargin.Width() ) ) );
     877             : 
     878           0 :                 xSet->setPropertyValue("FrameMarginHeight",
     879           0 :                     makeAny( sal_Int32( aMargin.Height() ) ) );
     880             :             }
     881             : 
     882           0 :             SwFrmFmt *pFrmFmt = pDoc->getIDocumentContentOperations().Insert( *pTxtCrsr->GetPaM(),
     883             :                                             ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ),
     884             :                                             &aItemSet,
     885             :                                             NULL,
     886           0 :                                             NULL);
     887             :             xPropSet.set(SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
     888           0 :                             *pDoc, pFrmFmt), uno::UNO_QUERY);
     889           0 :             if( pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
     890             :             {
     891             :                 // req for z-order
     892             :                 SwXFrame::GetOrCreateSdrObject(*
     893           0 :                         static_cast<SwFlyFrmFmt*>(pFrmFmt));
     894           0 :             }
     895           0 :         }
     896             :     }
     897           0 :     catch ( uno::Exception& )
     898             :     {
     899             :     }
     900             : 
     901           0 :     return xPropSet;
     902             : }
     903             : 
     904           0 : void SwXMLTextImportHelper::endAppletOrPlugin(
     905             :         const uno::Reference < XPropertySet > &rPropSet,
     906             :         ::std::map < const OUString, OUString > &rParamMap)
     907             : {
     908             :     // this method will modify the document directly -> lock SolarMutex
     909           0 :     SolarMutexGuard aGuard;
     910             : 
     911           0 :     uno::Reference<XUnoTunnel> xCrsrTunnel( rPropSet, UNO_QUERY );
     912             :     OSL_ENSURE( xCrsrTunnel.is(), "missing XUnoTunnel for embedded" );
     913             :     SwXFrame *pFrame = reinterpret_cast< SwXFrame * >(
     914           0 :                 sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( SwXFrame::getUnoTunnelId() )));
     915             :     OSL_ENSURE( pFrame, "SwXFrame missing" );
     916           0 :     SwFrmFmt *pFrmFmt = pFrame->GetFrmFmt();
     917           0 :     const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
     918           0 :     const SwNodeIndex *pNdIdx = rCntnt.GetCntntIdx();
     919           0 :     SwOLENode *pOLENd = pNdIdx->GetNodes()[pNdIdx->GetIndex() + 1]->GetNoTxtNode()->GetOLENode();
     920           0 :     SwOLEObj& rOLEObj = pOLENd->GetOLEObj();
     921             : 
     922           0 :     uno::Reference < embed::XEmbeddedObject > xEmbObj( rOLEObj.GetOleRef() );
     923           0 :     if ( svt::EmbeddedObjectRef::TryRunningState( xEmbObj ) )
     924             :     {
     925           0 :         uno::Reference < beans::XPropertySet > xSet( xEmbObj->getComponent(), uno::UNO_QUERY );
     926           0 :         if ( xSet.is() )
     927             :         {
     928           0 :             const sal_Int32 nCount = rParamMap.size();
     929           0 :             uno::Sequence< beans::PropertyValue > aCommandSequence( nCount );
     930             : 
     931           0 :             ::std::map < const OUString, OUString > ::iterator aIter = rParamMap.begin();
     932           0 :             ::std::map < const OUString, OUString > ::iterator aEnd = rParamMap.end();
     933           0 :             sal_Int32 nIndex=0;
     934           0 :             while (aIter != aEnd )
     935             :             {
     936           0 :                 aCommandSequence[nIndex].Name = (*aIter).first;
     937           0 :                 aCommandSequence[nIndex].Handle = -1;
     938           0 :                 aCommandSequence[nIndex].Value = makeAny( OUString((*aIter).second) );
     939           0 :                 aCommandSequence[nIndex].State = beans::PropertyState_DIRECT_VALUE;
     940           0 :                 ++aIter, ++nIndex;
     941             :             }
     942             : 
     943             :             // unfortunately the names of the properties are depending on the object
     944           0 :             OUString aParaName("AppletCommands");
     945             :             try
     946             :             {
     947           0 :                 xSet->setPropertyValue( aParaName, makeAny( aCommandSequence ) );
     948             :             }
     949           0 :             catch ( uno::Exception& )
     950             :             {
     951           0 :                 aParaName = "PluginCommands";
     952             :                 try
     953             :                 {
     954           0 :                     xSet->setPropertyValue( aParaName, makeAny( aCommandSequence ) );
     955             :                 }
     956           0 :                 catch ( uno::Exception& )
     957             :                 {
     958             :                 }
     959           0 :             }
     960           0 :         }
     961           0 :     }
     962           0 : }
     963             : 
     964             : // redlining helper methods
     965             : // (override to provide the real implementation)
     966          20 : void SwXMLTextImportHelper::RedlineAdd(
     967             :     const OUString& rType,
     968             :     const OUString& rId,
     969             :     const OUString& rAuthor,
     970             :     const OUString& rComment,
     971             :     const util::DateTime& rDateTime,
     972             :     bool bMergeLastPara)
     973             : {
     974             :     // create redline helper on demand
     975             :     OSL_ENSURE(NULL != pRedlineHelper, "helper should have been created in constructor");
     976          20 :     if (NULL != pRedlineHelper)
     977             :         pRedlineHelper->Add(rType, rId, rAuthor, rComment, rDateTime,
     978          20 :                             bMergeLastPara);
     979          20 : }
     980             : 
     981          12 : uno::Reference<XTextCursor> SwXMLTextImportHelper::RedlineCreateText(
     982             :     uno::Reference<XTextCursor> & rOldCursor,
     983             :     const OUString& rId)
     984             : {
     985          12 :     uno::Reference<XTextCursor> xRet;
     986             : 
     987          12 :     if (NULL != pRedlineHelper)
     988             :     {
     989          12 :         xRet = pRedlineHelper->CreateRedlineTextSection(rOldCursor, rId);
     990             :     }
     991             : 
     992          12 :     return xRet;
     993             : }
     994             : 
     995          40 : void SwXMLTextImportHelper::RedlineSetCursor(
     996             :     const OUString& rId,
     997             :     bool bStart,
     998             :     bool bIsOutsideOfParagraph)
     999             : {
    1000          40 :     if (NULL != pRedlineHelper) {
    1001          40 :         uno::Reference<XTextRange> xTextRange( GetCursor()->getStart() );
    1002             :         pRedlineHelper->SetCursor(rId, bStart, xTextRange,
    1003          40 :                                   bIsOutsideOfParagraph);
    1004             :     }
    1005             :     // else: ignore redline (wasn't added before, else we'd have a helper)
    1006          40 : }
    1007             : 
    1008        1822 : void SwXMLTextImportHelper::RedlineAdjustStartNodeCursor(
    1009             :     bool bStart)
    1010             : {
    1011        1822 :     OUString rId = GetOpenRedlineId();
    1012        1822 :     if ((NULL != pRedlineHelper) && !rId.isEmpty())
    1013             :     {
    1014           0 :         uno::Reference<XTextRange> xTextRange( GetCursor()->getStart() );
    1015           0 :         pRedlineHelper->AdjustStartNodeCursor(rId, bStart, xTextRange );
    1016           0 :         ResetOpenRedlineId();
    1017        1822 :     }
    1018             :     // else: ignore redline (wasn't added before, or no open redline ID
    1019        1822 : }
    1020             : 
    1021         308 : void SwXMLTextImportHelper::SetShowChanges( bool bShowChanges )
    1022             : {
    1023         308 :     if ( NULL != pRedlineHelper )
    1024         308 :         pRedlineHelper->SetShowChanges( bShowChanges );
    1025         308 : }
    1026             : 
    1027          12 : void SwXMLTextImportHelper::SetRecordChanges( bool bRecordChanges )
    1028             : {
    1029          12 :     if ( NULL != pRedlineHelper )
    1030          12 :         pRedlineHelper->SetRecordChanges( bRecordChanges );
    1031          12 : }
    1032             : 
    1033         308 : void SwXMLTextImportHelper::SetChangesProtectionKey(
    1034             :     const Sequence<sal_Int8> & rKey )
    1035             : {
    1036         308 :     if ( NULL != pRedlineHelper )
    1037         308 :         pRedlineHelper->SetProtectionKey( rKey );
    1038         578 : }
    1039             : 
    1040             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10