LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/dialogs - insdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 92 0.0 %
Date: 2012-12-27 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 <sot/clsids.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 String & 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             : /* [Beschreibung]
      97             : 
      98             :     Die Liste wird mit allen Typen gef"ullt, die im Insert-Dialog
      99             :     ausgew"ahlt werden k"onnen.
     100             : */
     101             : {
     102             :     try{
     103           0 :         uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
     104             : 
     105             :         uno::Reference< lang::XMultiServiceFactory > sProviderMSFactory =
     106           0 :             configuration::theDefaultProvider::get(xContext);
     107             : 
     108           0 :         ::rtl::OUString sReaderService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" ));
     109           0 :         uno::Sequence< uno::Any > aArguments( 1 );
     110           0 :         beans::PropertyValue aPathProp;
     111           0 :         aPathProp.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ));
     112           0 :         aPathProp.Value <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Embedding/ObjectNames" ));
     113           0 :         aArguments[0] <<= aPathProp;
     114             : 
     115             :         uno::Reference< container::XNameAccess > xNameAccess(
     116           0 :             sProviderMSFactory->createInstanceWithArguments( sReaderService,aArguments ),
     117           0 :             uno::UNO_QUERY );
     118             : 
     119           0 :         if( xNameAccess.is())
     120             :         {
     121           0 :             uno::Sequence< ::rtl::OUString > seqNames= xNameAccess->getElementNames();
     122             :             sal_Int32 nInd;
     123             : 
     124           0 :             ::rtl::OUString aStringProductName( RTL_CONSTASCII_USTRINGPARAM( "%PRODUCTNAME" ) );
     125           0 :             sal_Int32 nStringProductNameLength = aStringProductName.getLength();
     126             : 
     127           0 :             ::rtl::OUString aStringProductVersion( RTL_CONSTASCII_USTRINGPARAM( "%PRODUCTVERSION" ) );
     128           0 :             sal_Int32 nStringProductVersionLength = aStringProductVersion.getLength();
     129             : 
     130           0 :             for( nInd = 0; nInd < seqNames.getLength(); nInd++ )
     131             :             {
     132           0 :                 uno::Reference< container::XNameAccess > xEntry ;
     133           0 :                 xNameAccess->getByName( seqNames[nInd] ) >>= xEntry;
     134           0 :                 if ( xEntry.is() )
     135             :                 {
     136           0 :                     ::rtl::OUString aUIName;
     137           0 :                     ::rtl::OUString aClassID;
     138           0 :                     xEntry->getByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ObjectUIName" )) ) >>= aUIName;
     139           0 :                     xEntry->getByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ClassID" )) ) >>= aClassID;
     140             : 
     141           0 :                     if ( !aUIName.isEmpty() )
     142             :                     {
     143             :                         // replace %PRODUCTNAME
     144           0 :                         sal_Int32 nIndex = aUIName.indexOf( aStringProductName );
     145           0 :                         while( nIndex != -1 )
     146             :                         {
     147             :                             aUIName = aUIName.replaceAt(
     148             :                                 nIndex, nStringProductNameLength,
     149           0 :                                 utl::ConfigManager::getProductName() );
     150           0 :                             nIndex = aUIName.indexOf( aStringProductName );
     151             :                         }
     152             : 
     153             :                         // replace %PRODUCTVERSION
     154           0 :                         nIndex = aUIName.indexOf( aStringProductVersion );
     155           0 :                         while( nIndex != -1 )
     156             :                         {
     157             :                             aUIName = aUIName.replaceAt(
     158             :                                 nIndex, nStringProductVersionLength,
     159           0 :                                 utl::ConfigManager::getProductVersion() );
     160           0 :                             nIndex = aUIName.indexOf( aStringProductVersion );
     161             :                         }
     162             :                     }
     163             : 
     164           0 :                     SvGlobalName aClassName;
     165           0 :                     if( aClassName.MakeId( String( aClassID )))
     166             :                     {
     167           0 :                         if( !Get( aClassName ) )
     168             :                             // noch nicht eingetragen
     169           0 :                             aObjectServerList.push_back( SvObjectServer( aClassName, aUIName ) );
     170           0 :                     }
     171             :                 }
     172           0 :             }
     173           0 :         }
     174             : 
     175             : 
     176             : #ifdef WNT
     177             :         SvGlobalName aOleFact( SO3_OUT_CLASSID );
     178             :         String aOleObj( SVT_RESSTR( STR_FURTHER_OBJECT ) );
     179             :         aObjectServerList.push_back( SvObjectServer( aOleFact, aOleObj ) );
     180             : #endif
     181             : 
     182           0 :     }catch(const container::NoSuchElementException&)
     183             :     {
     184           0 :     }catch(const uno::Exception&)
     185             :     {
     186             :     }
     187           0 :     catch(...)
     188             :     {
     189             :     }
     190           0 : }
     191             : 
     192           0 : String SvPasteObjectHelper::GetSotFormatUIName( SotFormatStringId nId )
     193             : {
     194             :     struct SotResourcePair
     195             :     {
     196             :         SotFormatStringId   mnSotId;
     197             :         sal_uInt16              mnResId;
     198             :     };
     199             : 
     200             :     static const SotResourcePair aSotResourcePairs[] =
     201             :     {
     202             :         { SOT_FORMAT_STRING,                    STR_FORMAT_STRING },
     203             :         { SOT_FORMAT_BITMAP,                    STR_FORMAT_BITMAP },
     204             :         { SOT_FORMAT_GDIMETAFILE,               STR_FORMAT_GDIMETAFILE },
     205             :         { SOT_FORMAT_RTF,                       STR_FORMAT_RTF },
     206             :         { SOT_FORMATSTR_ID_DRAWING,             STR_FORMAT_ID_DRAWING },
     207             :         { SOT_FORMATSTR_ID_SVXB,                STR_FORMAT_ID_SVXB },
     208             :         { SOT_FORMATSTR_ID_INTERNALLINK_STATE,  STR_FORMAT_ID_INTERNALLINK_STATE },
     209             :         { SOT_FORMATSTR_ID_SOLK,                STR_FORMAT_ID_SOLK },
     210             :         { SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK,   STR_FORMAT_ID_NETSCAPE_BOOKMARK },
     211             :         { SOT_FORMATSTR_ID_STARSERVER,          STR_FORMAT_ID_STARSERVER },
     212             :         { SOT_FORMATSTR_ID_STAROBJECT,          STR_FORMAT_ID_STAROBJECT },
     213             :         { SOT_FORMATSTR_ID_APPLETOBJECT,        STR_FORMAT_ID_APPLETOBJECT },
     214             :         { SOT_FORMATSTR_ID_PLUGIN_OBJECT,       STR_FORMAT_ID_PLUGIN_OBJECT },
     215             :         { SOT_FORMATSTR_ID_STARWRITER_30,       STR_FORMAT_ID_STARWRITER_30 },
     216             :         { SOT_FORMATSTR_ID_STARWRITER_40,       STR_FORMAT_ID_STARWRITER_40 },
     217             :         { SOT_FORMATSTR_ID_STARWRITER_50,       STR_FORMAT_ID_STARWRITER_50 },
     218             :         { SOT_FORMATSTR_ID_STARWRITERWEB_40,    STR_FORMAT_ID_STARWRITERWEB_40 },
     219             :         { SOT_FORMATSTR_ID_STARWRITERWEB_50,    STR_FORMAT_ID_STARWRITERWEB_50 },
     220             :         { SOT_FORMATSTR_ID_STARWRITERGLOB_40,   STR_FORMAT_ID_STARWRITERGLOB_40 },
     221             :         { SOT_FORMATSTR_ID_STARWRITERGLOB_50,   STR_FORMAT_ID_STARWRITERGLOB_50 },
     222             :         { SOT_FORMATSTR_ID_STARDRAW,            STR_FORMAT_ID_STARDRAW },
     223             :         { SOT_FORMATSTR_ID_STARDRAW_40,         STR_FORMAT_ID_STARDRAW_40 },
     224             :         { SOT_FORMATSTR_ID_STARIMPRESS_50,      STR_FORMAT_ID_STARIMPRESS_50 },
     225             :         { SOT_FORMATSTR_ID_STARDRAW_50,         STR_FORMAT_ID_STARDRAW_50 },
     226             :         { SOT_FORMATSTR_ID_STARCALC,            STR_FORMAT_ID_STARCALC },
     227             :         { SOT_FORMATSTR_ID_STARCALC_40,         STR_FORMAT_ID_STARCALC_40 },
     228             :         { SOT_FORMATSTR_ID_STARCALC_50,         STR_FORMAT_ID_STARCALC_50 },
     229             :         { SOT_FORMATSTR_ID_STARCHART,           STR_FORMAT_ID_STARCHART },
     230             :         { SOT_FORMATSTR_ID_STARCHART_40,        STR_FORMAT_ID_STARCHART_40 },
     231             :         { SOT_FORMATSTR_ID_STARCHART_50,        STR_FORMAT_ID_STARCHART_50 },
     232             :         { SOT_FORMATSTR_ID_STARIMAGE,           STR_FORMAT_ID_STARIMAGE },
     233             :         { SOT_FORMATSTR_ID_STARIMAGE_40,        STR_FORMAT_ID_STARIMAGE_40 },
     234             :         { SOT_FORMATSTR_ID_STARIMAGE_50,        STR_FORMAT_ID_STARIMAGE_50 },
     235             :         { SOT_FORMATSTR_ID_STARMATH,            STR_FORMAT_ID_STARMATH },
     236             :         { SOT_FORMATSTR_ID_STARMATH_40,         STR_FORMAT_ID_STARMATH_40 },
     237             :         { SOT_FORMATSTR_ID_STARMATH_50,         STR_FORMAT_ID_STARMATH_50 },
     238             :         { SOT_FORMATSTR_ID_STAROBJECT_PAINTDOC, STR_FORMAT_ID_STAROBJECT_PAINTDOC },
     239             :         { SOT_FORMATSTR_ID_HTML,                STR_FORMAT_ID_HTML },
     240             :         { SOT_FORMATSTR_ID_HTML_SIMPLE,         STR_FORMAT_ID_HTML_SIMPLE },
     241             :         { SOT_FORMATSTR_ID_BIFF_5,              STR_FORMAT_ID_BIFF_5 },
     242             :         { SOT_FORMATSTR_ID_BIFF_8,              STR_FORMAT_ID_BIFF_8 },
     243             :         { SOT_FORMATSTR_ID_SYLK,                STR_FORMAT_ID_SYLK },
     244             :         { SOT_FORMATSTR_ID_LINK,                STR_FORMAT_ID_LINK },
     245             :         { SOT_FORMATSTR_ID_DIF,                 STR_FORMAT_ID_DIF },
     246             :         { SOT_FORMATSTR_ID_MSWORD_DOC,          STR_FORMAT_ID_MSWORD_DOC },
     247             :         { SOT_FORMATSTR_ID_STAR_FRAMESET_DOC,   STR_FORMAT_ID_STAR_FRAMESET_DOC },
     248             :         { SOT_FORMATSTR_ID_OFFICE_DOC,          STR_FORMAT_ID_OFFICE_DOC },
     249             :         { SOT_FORMATSTR_ID_NOTES_DOCINFO,       STR_FORMAT_ID_NOTES_DOCINFO },
     250             :         { SOT_FORMATSTR_ID_SFX_DOC,             STR_FORMAT_ID_SFX_DOC },
     251             :         { SOT_FORMATSTR_ID_STARCHARTDOCUMENT_50,STR_FORMAT_ID_STARCHARTDOCUMENT_50 },
     252             :         { SOT_FORMATSTR_ID_GRAPHOBJ,            STR_FORMAT_ID_GRAPHOBJ },
     253             :         { SOT_FORMATSTR_ID_STARWRITER_60,       STR_FORMAT_ID_STARWRITER_60 },
     254             :         { SOT_FORMATSTR_ID_STARWRITERWEB_60,    STR_FORMAT_ID_STARWRITERWEB_60 },
     255             :         { SOT_FORMATSTR_ID_STARWRITERGLOB_60,   STR_FORMAT_ID_STARWRITERGLOB_60 },
     256             :         { SOT_FORMATSTR_ID_STARDRAW_60,         STR_FORMAT_ID_STARDRAW_60 },
     257             :         { SOT_FORMATSTR_ID_STARIMPRESS_60,      STR_FORMAT_ID_STARIMPRESS_60 },
     258             :         { SOT_FORMATSTR_ID_STARCALC_60,         STR_FORMAT_ID_STARCALC_60 },
     259             :         { SOT_FORMATSTR_ID_STARCHART_60,        STR_FORMAT_ID_STARCHART_60 },
     260             :         { SOT_FORMATSTR_ID_STARMATH_60,         STR_FORMAT_ID_STARMATH_60 },
     261             :         { SOT_FORMATSTR_ID_WMF,                 STR_FORMAT_ID_WMF },
     262             :         { SOT_FORMATSTR_ID_DBACCESS_QUERY,      STR_FORMAT_ID_DBACCESS_QUERY },
     263             :         { SOT_FORMATSTR_ID_DBACCESS_TABLE,      STR_FORMAT_ID_DBACCESS_TABLE },
     264             :         { SOT_FORMATSTR_ID_DBACCESS_COMMAND,    STR_FORMAT_ID_DBACCESS_COMMAND },
     265             :         { SOT_FORMATSTR_ID_DIALOG_60,           STR_FORMAT_ID_DIALOG_60 },
     266             :         { SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR,   STR_FORMAT_ID_FILEGRPDESCRIPTOR },
     267             :         { SOT_FORMATSTR_ID_HTML_NO_COMMENT,     STR_FORMAT_ID_HTML_NO_COMMENT }
     268             :     };
     269             : 
     270           0 :     String aUIName;
     271           0 :     sal_uInt16 nResId = 0;
     272             : 
     273           0 :     for( sal_uInt32 i = 0, nCount = SAL_N_ELEMENTS( aSotResourcePairs ); ( i < nCount ) && !nResId; i++ )
     274             :     {
     275           0 :         if( aSotResourcePairs[ i ].mnSotId == nId )
     276           0 :             nResId = aSotResourcePairs[ i ].mnResId;
     277             :     }
     278             : 
     279           0 :     if( nResId )
     280           0 :         aUIName = SVT_RESSTR( nResId );
     281             :     else
     282           0 :         aUIName = SotExchange::GetFormatName( nId );
     283             : 
     284           0 :     return aUIName;
     285             : }
     286             : // -----------------------------------------------------------------------------
     287           0 : sal_Bool SvPasteObjectHelper::GetEmbeddedName(const TransferableDataHelper& rData,String& _rName,String& _rSource,SotFormatStringId& _nFormat)
     288             : {
     289           0 :     sal_Bool bRet = sal_False;
     290           0 :     if( _nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE_OLE || _nFormat == SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE )
     291             :     {
     292           0 :         datatransfer::DataFlavor aFlavor;
     293           0 :         SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE, aFlavor );
     294             : 
     295           0 :         uno::Any aAny;
     296           0 :         if( rData.HasFormat( aFlavor ) &&
     297           0 :             ( aAny = rData.GetAny( aFlavor ) ).hasValue() )
     298             :         {
     299           0 :             uno::Sequence< sal_Int8 > anySequence;
     300           0 :             aAny >>= anySequence;
     301             : 
     302             :             OleObjectDescriptor* pOleObjDescr =
     303           0 :                 reinterpret_cast< OleObjectDescriptor* >( anySequence.getArray( ) );
     304             : 
     305             :             // determine the user friendly description of the embedded object
     306           0 :             if ( pOleObjDescr->dwFullUserTypeName )
     307             :             {
     308             :                 // we set the pointer to the start of user friendly description
     309             :                 // string. it starts  at &OleObjectDescriptor + dwFullUserTypeName.
     310             :                 // dwFullUserTypeName is the offset in bytes.
     311             :                 // the user friendly description string is '\0' terminated.
     312             :                 const sal_Unicode* pUserTypeName =
     313             :                     reinterpret_cast< sal_Unicode* >(
     314             :                         reinterpret_cast< sal_Char* >( pOleObjDescr ) +
     315           0 :                             pOleObjDescr->dwFullUserTypeName );
     316             : 
     317           0 :                 _rName.Append( pUserTypeName );
     318             :                 // the following statement was here for historical reasons, it is commented out since it causes bug i49460
     319             :                 // _nFormat = SOT_FORMATSTR_ID_EMBED_SOURCE_OLE;
     320             :             }
     321             : 
     322             :             // determine the source of the embedded object
     323           0 :             if ( pOleObjDescr->dwSrcOfCopy )
     324             :             {
     325             :                 // we set the pointer to the start of source string
     326             :                 // it starts  at &OleObjectDescriptor + dwSrcOfCopy.
     327             :                 // dwSrcOfCopy is the offset in bytes.
     328             :                 // the source string is '\0' terminated.
     329             :                 const sal_Unicode* pSrcOfCopy =
     330             :                     reinterpret_cast< sal_Unicode* >(
     331             :                         reinterpret_cast< sal_Char* >( pOleObjDescr ) +
     332           0 :                             pOleObjDescr->dwSrcOfCopy );
     333             : 
     334           0 :                 _rSource.Append( pSrcOfCopy );
     335             :             }
     336             :             else
     337           0 :                 _rSource = SVT_RESSTR(STR_UNKNOWN_SOURCE);
     338             :         }
     339           0 :         bRet = sal_True;
     340             :     }
     341           0 :     return bRet;
     342             : }
     343             : // -----------------------------------------------------------------------------
     344             : 
     345             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10