LCOV - code coverage report
Current view: top level - svtools/source/dialogs - insdlg.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 94 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <svtools/insdlg.hxx>
      21             : #include <svtools/sores.hxx>
      22             : #include <svtools/svtresid.hxx>
      23             : 
      24             : #include <unotools/configmgr.hxx>
      25             : #include <comphelper/classids.hxx>
      26             : #include <sot/stg.hxx>
      27             : #include <sal/macros.h>
      28             : 
      29             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      30             : #include <com/sun/star/beans/PropertyValue.hpp>
      31             : #include <com/sun/star/configuration/theDefaultProvider.hpp>
      32             : #include <comphelper/processfactory.hxx>
      33             : #include <com/sun/star/container/XNameAccess.hpp>
      34             : 
      35             : using namespace ::com::sun::star;
      36             : 
      37             : 
      38             : // this struct conforms to the Microsoft
      39             : // OBJECTDESCRIPTOR -> see oleidl.h
      40             : // (MS platform sdk)
      41             : 
      42             : 
      43             : struct OleObjectDescriptor
      44             : {
      45             :     sal_uInt32  cbSize;
      46             :     ClsId       clsid;
      47             :     sal_uInt32  dwDrawAspect;
      48             :     Size        sizel;
      49             :     Point       pointl;
      50             :     sal_uInt32  dwStatus;
      51             :     sal_uInt32  dwFullUserTypeName;
      52             :     sal_uInt32  dwSrcOfCopy;
      53             : };
      54             : 
      55             : /********************** SvObjectServerList ********************************
      56             : **************************************************************************/
      57             : 
      58           0 : const SvObjectServer * SvObjectServerList::Get( const OUString & rHumanName ) const
      59             : {
      60           0 :     for( size_t i = 0; i < aObjectServerList.size(); i++ )
      61             :     {
      62           0 :         if( rHumanName == aObjectServerList[ i ].GetHumanName() )
      63           0 :             return &aObjectServerList[ i ];
      64             :     }
      65           0 :     return NULL;
      66             : }
      67             : 
      68           0 : const SvObjectServer * SvObjectServerList::Get( const SvGlobalName & rName ) const
      69             : {
      70           0 :     for( size_t i = 0; i < aObjectServerList.size(); i++ )
      71             :     {
      72           0 :         if( rName == aObjectServerList[ i ].GetClassName() )
      73           0 :             return &aObjectServerList[ i ];
      74             :     }
      75           0 :     return NULL;
      76             : }
      77             : 
      78           0 : void SvObjectServerList::Remove( const SvGlobalName & rName )
      79             : {
      80           0 :     for( size_t i = 0; i < aObjectServerList.size(); )
      81             :     {
      82           0 :         if( aObjectServerList[ i ].GetClassName() == rName )
      83             :         {
      84           0 :             SvObjectServerList_impl::iterator it = aObjectServerList.begin() + i;
      85           0 :             aObjectServerList.erase( it );
      86             :         }
      87             :         else
      88             :         {
      89           0 :             ++i;
      90             :         }
      91             :     }
      92           0 : }
      93             : 
      94             : 
      95           0 : void SvObjectServerList::FillInsertObjects()
      96             : /* [Description]
      97             : 
      98             :     The list is filled with all types which can be selected in the insert-dialog.
      99             : */
     100             : {
     101             :     try{
     102           0 :         uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
     103             : 
     104             :         uno::Reference< lang::XMultiServiceFactory > sProviderMSFactory =
     105           0 :             configuration::theDefaultProvider::get(xContext);
     106             : 
     107           0 :         OUString sReaderService( "com.sun.star.configuration.ConfigurationAccess" );
     108           0 :         uno::Sequence< uno::Any > aArguments( 1 );
     109           0 :         beans::PropertyValue aPathProp;
     110           0 :         aPathProp.Name = "nodepath";
     111           0 :         aPathProp.Value <<= OUString( "/org.openoffice.Office.Embedding/ObjectNames" );
     112           0 :         aArguments[0] <<= aPathProp;
     113             : 
     114             :         uno::Reference< container::XNameAccess > xNameAccess(
     115           0 :             sProviderMSFactory->createInstanceWithArguments( sReaderService,aArguments ),
     116           0 :             uno::UNO_QUERY );
     117             : 
     118           0 :         if( xNameAccess.is())
     119             :         {
     120           0 :             uno::Sequence< OUString > seqNames= xNameAccess->getElementNames();
     121             :             sal_Int32 nInd;
     122             : 
     123           0 :             OUString aStringProductName( "%PRODUCTNAME" );
     124           0 :             sal_Int32 nStringProductNameLength = aStringProductName.getLength();
     125             : 
     126           0 :             OUString aStringProductVersion( "%PRODUCTVERSION" );
     127           0 :             sal_Int32 nStringProductVersionLength = aStringProductVersion.getLength();
     128             : 
     129           0 :             for( nInd = 0; nInd < seqNames.getLength(); nInd++ )
     130             :             {
     131           0 :                 uno::Reference< container::XNameAccess > xEntry ;
     132           0 :                 xNameAccess->getByName( seqNames[nInd] ) >>= xEntry;
     133           0 :                 if ( xEntry.is() )
     134             :                 {
     135           0 :                     OUString aUIName;
     136           0 :                     OUString aClassID;
     137           0 :                     xEntry->getByName("ObjectUIName") >>= aUIName;
     138           0 :                     xEntry->getByName("ClassID") >>= aClassID;
     139             : 
     140           0 :                     if ( !aUIName.isEmpty() )
     141             :                     {
     142             :                         // replace %PRODUCTNAME
     143           0 :                         sal_Int32 nIndex = aUIName.indexOf( aStringProductName );
     144           0 :                         while( nIndex != -1 )
     145             :                         {
     146           0 :                             aUIName = aUIName.replaceAt(
     147             :                                 nIndex, nStringProductNameLength,
     148           0 :                                 utl::ConfigManager::getProductName() );
     149           0 :                             nIndex = aUIName.indexOf( aStringProductName );
     150             :                         }
     151             : 
     152             :                         // replace %PRODUCTVERSION
     153           0 :                         nIndex = aUIName.indexOf( aStringProductVersion );
     154           0 :                         while( nIndex != -1 )
     155             :                         {
     156           0 :                             aUIName = aUIName.replaceAt(
     157             :                                 nIndex, nStringProductVersionLength,
     158           0 :                                 utl::ConfigManager::getProductVersion() );
     159           0 :                             nIndex = aUIName.indexOf( aStringProductVersion );
     160             :                         }
     161             :                     }
     162             : 
     163           0 :                     SvGlobalName aClassName;
     164           0 :                     if( aClassName.MakeId( aClassID) )
     165             :                     {
     166           0 :                         if( !Get( aClassName ) )
     167             :                             // noch nicht eingetragen
     168           0 :                             aObjectServerList.push_back( SvObjectServer( aClassName, aUIName ) );
     169           0 :                     }
     170             :                 }
     171           0 :             }
     172           0 :         }
     173             : 
     174             : 
     175             : #ifdef WNT
     176             :         SvGlobalName aOleFact( SO3_OUT_CLASSID );
     177             :         OUString aOleObj( SVT_RESSTR( STR_FURTHER_OBJECT ) );
     178             :         aObjectServerList.push_back( SvObjectServer( aOleFact, aOleObj ) );
     179             : #endif
     180             : 
     181           0 :     }catch(const container::NoSuchElementException&)
     182             :     {
     183           0 :     }catch(const uno::Exception&)
     184             :     {
     185             :     }
     186           0 :     catch(...)
     187             :     {
     188             :     }
     189           0 : }
     190             : 
     191           0 : OUString SvPasteObjectHelper::GetSotFormatUIName( SotClipboardFormatId nId )
     192             : {
     193             :     struct SotResourcePair
     194             :     {
     195             :         SotClipboardFormatId   mnSotId;
     196             :         sal_uInt16              mnResId;
     197             :     };
     198             : 
     199             :     static const SotResourcePair aSotResourcePairs[] =
     200             :     {
     201             :         { SotClipboardFormatId::STRING,                    STR_FORMAT_STRING },
     202             :         { SotClipboardFormatId::BITMAP,                    STR_FORMAT_BITMAP },
     203             :         { SotClipboardFormatId::GDIMETAFILE,               STR_FORMAT_GDIMETAFILE },
     204             :         { SotClipboardFormatId::RTF,                       STR_FORMAT_RTF },
     205             :         { SotClipboardFormatId::DRAWING,             STR_FORMAT_ID_DRAWING },
     206             :         { SotClipboardFormatId::SVXB,                STR_FORMAT_ID_SVXB },
     207             :         { SotClipboardFormatId::INTERNALLINK_STATE,  STR_FORMAT_ID_INTERNALLINK_STATE },
     208             :         { SotClipboardFormatId::SOLK,                STR_FORMAT_ID_SOLK },
     209             :         { SotClipboardFormatId::NETSCAPE_BOOKMARK,   STR_FORMAT_ID_NETSCAPE_BOOKMARK },
     210             :         { SotClipboardFormatId::STARSERVER,          STR_FORMAT_ID_STARSERVER },
     211             :         { SotClipboardFormatId::STAROBJECT,          STR_FORMAT_ID_STAROBJECT },
     212             :         { SotClipboardFormatId::APPLETOBJECT,        STR_FORMAT_ID_APPLETOBJECT },
     213             :         { SotClipboardFormatId::PLUGIN_OBJECT,       STR_FORMAT_ID_PLUGIN_OBJECT },
     214             :         { SotClipboardFormatId::STARWRITER_30,       STR_FORMAT_ID_STARWRITER_30 },
     215             :         { SotClipboardFormatId::STARWRITER_40,       STR_FORMAT_ID_STARWRITER_40 },
     216             :         { SotClipboardFormatId::STARWRITER_50,       STR_FORMAT_ID_STARWRITER_50 },
     217             :         { SotClipboardFormatId::STARWRITERWEB_40,    STR_FORMAT_ID_STARWRITERWEB_40 },
     218             :         { SotClipboardFormatId::STARWRITERWEB_50,    STR_FORMAT_ID_STARWRITERWEB_50 },
     219             :         { SotClipboardFormatId::STARWRITERGLOB_40,   STR_FORMAT_ID_STARWRITERGLOB_40 },
     220             :         { SotClipboardFormatId::STARWRITERGLOB_50,   STR_FORMAT_ID_STARWRITERGLOB_50 },
     221             :         { SotClipboardFormatId::STARDRAW,            STR_FORMAT_ID_STARDRAW },
     222             :         { SotClipboardFormatId::STARDRAW_40,         STR_FORMAT_ID_STARDRAW_40 },
     223             :         { SotClipboardFormatId::STARIMPRESS_50,      STR_FORMAT_ID_STARIMPRESS_50 },
     224             :         { SotClipboardFormatId::STARDRAW_50,         STR_FORMAT_ID_STARDRAW_50 },
     225             :         { SotClipboardFormatId::STARCALC,            STR_FORMAT_ID_STARCALC },
     226             :         { SotClipboardFormatId::STARCALC_40,         STR_FORMAT_ID_STARCALC_40 },
     227             :         { SotClipboardFormatId::STARCALC_50,         STR_FORMAT_ID_STARCALC_50 },
     228             :         { SotClipboardFormatId::STARCHART,           STR_FORMAT_ID_STARCHART },
     229             :         { SotClipboardFormatId::STARCHART_40,        STR_FORMAT_ID_STARCHART_40 },
     230             :         { SotClipboardFormatId::STARCHART_50,        STR_FORMAT_ID_STARCHART_50 },
     231             :         { SotClipboardFormatId::STARIMAGE,           STR_FORMAT_ID_STARIMAGE },
     232             :         { SotClipboardFormatId::STARIMAGE_40,        STR_FORMAT_ID_STARIMAGE_40 },
     233             :         { SotClipboardFormatId::STARIMAGE_50,        STR_FORMAT_ID_STARIMAGE_50 },
     234             :         { SotClipboardFormatId::STARMATH,            STR_FORMAT_ID_STARMATH },
     235             :         { SotClipboardFormatId::STARMATH_40,         STR_FORMAT_ID_STARMATH_40 },
     236             :         { SotClipboardFormatId::STARMATH_50,         STR_FORMAT_ID_STARMATH_50 },
     237             :         { SotClipboardFormatId::STAROBJECT_PAINTDOC, STR_FORMAT_ID_STAROBJECT_PAINTDOC },
     238             :         { SotClipboardFormatId::HTML,                STR_FORMAT_ID_HTML },
     239             :         { SotClipboardFormatId::HTML_SIMPLE,         STR_FORMAT_ID_HTML_SIMPLE },
     240             :         { SotClipboardFormatId::BIFF_5,              STR_FORMAT_ID_BIFF_5 },
     241             :         { SotClipboardFormatId::BIFF_8,              STR_FORMAT_ID_BIFF_8 },
     242             :         { SotClipboardFormatId::SYLK,                STR_FORMAT_ID_SYLK },
     243             :         { SotClipboardFormatId::LINK,                STR_FORMAT_ID_LINK },
     244             :         { SotClipboardFormatId::DIF,                 STR_FORMAT_ID_DIF },
     245             :         { SotClipboardFormatId::MSWORD_DOC,          STR_FORMAT_ID_MSWORD_DOC },
     246             :         { SotClipboardFormatId::STAR_FRAMESET_DOC,   STR_FORMAT_ID_STAR_FRAMESET_DOC },
     247             :         { SotClipboardFormatId::OFFICE_DOC,          STR_FORMAT_ID_OFFICE_DOC },
     248             :         { SotClipboardFormatId::NOTES_DOCINFO,       STR_FORMAT_ID_NOTES_DOCINFO },
     249             :         { SotClipboardFormatId::SFX_DOC,             STR_FORMAT_ID_SFX_DOC },
     250             :         { SotClipboardFormatId::STARCHARTDOCUMENT_50,STR_FORMAT_ID_STARCHARTDOCUMENT_50 },
     251             :         { SotClipboardFormatId::GRAPHOBJ,            STR_FORMAT_ID_GRAPHOBJ },
     252             :         { SotClipboardFormatId::STARWRITER_60,       STR_FORMAT_ID_STARWRITER_60 },
     253             :         { SotClipboardFormatId::STARWRITERWEB_60,    STR_FORMAT_ID_STARWRITERWEB_60 },
     254             :         { SotClipboardFormatId::STARWRITERGLOB_60,   STR_FORMAT_ID_STARWRITERGLOB_60 },
     255             :         { SotClipboardFormatId::STARDRAW_60,         STR_FORMAT_ID_STARDRAW_60 },
     256             :         { SotClipboardFormatId::STARIMPRESS_60,      STR_FORMAT_ID_STARIMPRESS_60 },
     257             :         { SotClipboardFormatId::STARCALC_60,         STR_FORMAT_ID_STARCALC_60 },
     258             :         { SotClipboardFormatId::STARCHART_60,        STR_FORMAT_ID_STARCHART_60 },
     259             :         { SotClipboardFormatId::STARMATH_60,         STR_FORMAT_ID_STARMATH_60 },
     260             :         { SotClipboardFormatId::WMF,                 STR_FORMAT_ID_WMF },
     261             :         { SotClipboardFormatId::DBACCESS_QUERY,      STR_FORMAT_ID_DBACCESS_QUERY },
     262             :         { SotClipboardFormatId::DBACCESS_TABLE,      STR_FORMAT_ID_DBACCESS_TABLE },
     263             :         { SotClipboardFormatId::DBACCESS_COMMAND,    STR_FORMAT_ID_DBACCESS_COMMAND },
     264             :         { SotClipboardFormatId::DIALOG_60,           STR_FORMAT_ID_DIALOG_60 },
     265             :         { SotClipboardFormatId::FILEGRPDESCRIPTOR,   STR_FORMAT_ID_FILEGRPDESCRIPTOR },
     266             :         { SotClipboardFormatId::HTML_NO_COMMENT,     STR_FORMAT_ID_HTML_NO_COMMENT }
     267             :     };
     268             : 
     269           0 :     OUString aUIName;
     270           0 :     sal_uInt16 nResId = 0;
     271             : 
     272           0 :     for( sal_uInt32 i = 0, nCount = SAL_N_ELEMENTS( aSotResourcePairs ); ( i < nCount ) && !nResId; i++ )
     273             :     {
     274           0 :         if( aSotResourcePairs[ i ].mnSotId == nId )
     275           0 :             nResId = aSotResourcePairs[ i ].mnResId;
     276             :     }
     277             : 
     278           0 :     if( nResId )
     279           0 :         aUIName = SVT_RESSTR( nResId );
     280             :     else
     281           0 :         aUIName = SotExchange::GetFormatName( nId );
     282             : 
     283           0 :     return aUIName;
     284             : }
     285             : 
     286           0 : bool SvPasteObjectHelper::GetEmbeddedName(const TransferableDataHelper& rData, OUString& _rName, OUString& _rSource, SotClipboardFormatId& _nFormat)
     287             : {
     288           0 :     bool bRet = false;
     289           0 :     if( _nFormat == SotClipboardFormatId::EMBED_SOURCE_OLE || _nFormat == SotClipboardFormatId::EMBEDDED_OBJ_OLE )
     290             :     {
     291           0 :         datatransfer::DataFlavor aFlavor;
     292           0 :         SotExchange::GetFormatDataFlavor( SotClipboardFormatId::OBJECTDESCRIPTOR_OLE, aFlavor );
     293             : 
     294           0 :         uno::Any aAny;
     295           0 :         if( rData.HasFormat( aFlavor ) &&
     296           0 :             ( aAny = rData.GetAny(aFlavor, OUString()) ).hasValue() )
     297             :         {
     298           0 :             uno::Sequence< sal_Int8 > anySequence;
     299           0 :             aAny >>= anySequence;
     300             : 
     301             :             OleObjectDescriptor* pOleObjDescr =
     302           0 :                 reinterpret_cast< OleObjectDescriptor* >( anySequence.getArray( ) );
     303             : 
     304             :             // determine the user friendly description of the embedded object
     305           0 :             if ( pOleObjDescr->dwFullUserTypeName )
     306             :             {
     307             :                 // we set the pointer to the start of user friendly description
     308             :                 // string. it starts  at &OleObjectDescriptor + dwFullUserTypeName.
     309             :                 // dwFullUserTypeName is the offset in bytes.
     310             :                 // the user friendly description string is '\0' terminated.
     311             :                 const sal_Unicode* pUserTypeName =
     312             :                     reinterpret_cast< sal_Unicode* >(
     313             :                         reinterpret_cast< sal_Char* >( pOleObjDescr ) +
     314           0 :                             pOleObjDescr->dwFullUserTypeName );
     315             : 
     316           0 :                 _rName += pUserTypeName;
     317             :                 // the following statement was here for historical reasons, it is commented out since it causes bug i49460
     318             :                 // _nFormat = SotClipboardFormatId::EMBED_SOURCE_OLE;
     319             :             }
     320             : 
     321             :             // determine the source of the embedded object
     322           0 :             if ( pOleObjDescr->dwSrcOfCopy )
     323             :             {
     324             :                 // we set the pointer to the start of source string
     325             :                 // it starts  at &OleObjectDescriptor + dwSrcOfCopy.
     326             :                 // dwSrcOfCopy is the offset in bytes.
     327             :                 // the source string is '\0' terminated.
     328             :                 const sal_Unicode* pSrcOfCopy =
     329             :                     reinterpret_cast< sal_Unicode* >(
     330             :                         reinterpret_cast< sal_Char* >( pOleObjDescr ) +
     331           0 :                             pOleObjDescr->dwSrcOfCopy );
     332             : 
     333           0 :                 _rSource += pSrcOfCopy;
     334             :             }
     335             :             else
     336           0 :                 _rSource = SVT_RESSTR(STR_UNKNOWN_SOURCE);
     337             :         }
     338           0 :         bRet = true;
     339             :     }
     340           0 :     return bRet;
     341             : }
     342             : 
     343             : 
     344             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11