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

Generated by: LCOV version 1.11