LCOV - code coverage report
Current view: top level - cui/source/dialogs - pastedlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 117 0.0 %
Date: 2012-08-25 Functions: 0 12 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 282 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <com/sun/star/embed/Aspects.hpp>
      30                 :            : 
      31                 :            : #include <pastedlg.hxx>
      32                 :            : #include <svtools/svmedit.hxx>
      33                 :            : #include <svtools/insdlg.hxx>
      34                 :            : #include <vcl/dialog.hxx>
      35                 :            : #include <vcl/button.hxx>
      36                 :            : #include <vcl/fixed.hxx>
      37                 :            : #include <vcl/group.hxx>
      38                 :            : #include <vcl/lstbox.hxx>
      39                 :            : #include <vcl/msgbox.hxx>
      40                 :            : #include "svuidlg.hrc"
      41                 :            : #include <sot/formats.hxx>
      42                 :            : #include <sot/stg.hxx>
      43                 :            : #include <svtools/sores.hxx>
      44                 :            : #include <vcl/svapp.hxx>
      45                 :            : 
      46                 :            : #include <dialmgr.hxx>
      47                 :            : 
      48                 :          0 : SvPasteObjectDialog::SvPasteObjectDialog( Window* pParent )
      49                 :            : 
      50                 :          0 :     : ModalDialog( pParent, CUI_RES( MD_PASTE_OBJECT ) ),
      51         [ #  # ]:          0 :     aFtSource( this, CUI_RES( FT_SOURCE ) ),
      52         [ #  # ]:          0 :     aFtObjectSource( this, CUI_RES( FT_OBJECT_SOURCE ) ),
      53         [ #  # ]:          0 :     aRbPaste( this, CUI_RES( RB_PASTE ) ),
      54         [ #  # ]:          0 :     aRbPasteLink( this, CUI_RES( RB_PASTE_LINK ) ),
      55         [ #  # ]:          0 :     aCbDisplayAsIcon( this, CUI_RES( CB_DISPLAY_AS_ICON ) ),
      56         [ #  # ]:          0 :     aPbChangeIcon( this, CUI_RES( PB_CHANGE_ICON ) ),
      57         [ #  # ]:          0 :     aFlChoice( this, CUI_RES( FL_CHOICE ) ),
      58         [ #  # ]:          0 :     aLbInsertList( this, CUI_RES( LB_INSERT_LIST ) ),
      59         [ #  # ]:          0 :     aOKButton1( this, CUI_RES( 1 ) ),
      60         [ #  # ]:          0 :     aCancelButton1( this, CUI_RES( 1 ) ),
      61 [ #  # ][ #  # ]:          0 :     aHelpButton1( this, CUI_RES( 1 ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      62                 :            : {
      63         [ #  # ]:          0 :     FreeResource();
      64         [ #  # ]:          0 :     SetHelpId( HID_PASTE_DLG );
      65         [ #  # ]:          0 :     SetUniqueId( HID_PASTE_DLG );
      66                 :            : 
      67         [ #  # ]:          0 :     Font aFont = aFtObjectSource.GetFont();
      68         [ #  # ]:          0 :     aFont.SetWeight( WEIGHT_LIGHT );
      69         [ #  # ]:          0 :     aFtObjectSource.SetFont( aFont );
      70         [ #  # ]:          0 :     aOKButton1.Disable();
      71                 :            : 
      72         [ #  # ]:          0 :     ObjectLB().SetSelectHdl( LINK( this, SvPasteObjectDialog, SelectHdl ) );
      73         [ #  # ]:          0 :     ObjectLB().SetDoubleClickHdl( LINK( this, SvPasteObjectDialog, DoubleClickHdl ) );
      74                 :          0 :     SetDefault();
      75                 :            : 
      76 [ #  # ][ #  # ]:          0 :     aLbInsertList.SetAccessibleName(aFlChoice.GetText());
         [ #  # ][ #  # ]
      77                 :          0 : }
      78                 :            : 
      79                 :          0 : void SvPasteObjectDialog::SelectObject()
      80                 :            : {
      81   [ #  #  #  #  :          0 :     if ( aLbInsertList.GetEntryCount() &&
           #  # ][ #  # ]
      82                 :          0 :          !aRbPaste.IsVisible() && !aRbPasteLink.IsVisible() )
      83                 :            :     {
      84                 :          0 :         aLbInsertList.SelectEntryPos(0);
      85                 :          0 :         SelectHdl( &aLbInsertList );
      86                 :            :     }
      87                 :          0 : }
      88                 :            : 
      89                 :          0 : IMPL_LINK( SvPasteObjectDialog, SelectHdl, ListBox *, pListBox )
      90                 :            : {
      91                 :            :     (void)pListBox;
      92                 :            : 
      93         [ #  # ]:          0 :     if ( !aOKButton1.IsEnabled() )
      94                 :          0 :         aOKButton1.Enable();
      95                 :          0 :     return 0;
      96                 :            : }
      97                 :            : 
      98                 :          0 : IMPL_LINK_INLINE_START( SvPasteObjectDialog, DoubleClickHdl, ListBox *, pListBox )
      99                 :            : {
     100                 :            :     (void)pListBox;
     101                 :            : 
     102                 :          0 :     EndDialog( RET_OK );
     103                 :          0 :     return 0;
     104                 :            : }
     105                 :          0 : IMPL_LINK_INLINE_END( SvPasteObjectDialog, DoubleClickHdl, ListBox *, pListBox )
     106                 :            : 
     107                 :          0 : void SvPasteObjectDialog::SetDefault()
     108                 :            : {
     109                 :          0 :     bLink   = sal_False;
     110                 :          0 :     nAspect = (sal_uInt16)::com::sun::star::embed::Aspects::MSOLE_CONTENT;
     111                 :          0 : }
     112                 :            : 
     113 [ #  # ][ #  # ]:          0 : SvPasteObjectDialog::~SvPasteObjectDialog()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     114                 :            : {
     115         [ #  # ]:          0 : }
     116                 :            : 
     117                 :            : /*************************************************************************
     118                 :            : |*    SvPasteObjectDialog::Insert()
     119                 :            : *************************************************************************/
     120                 :          0 : void SvPasteObjectDialog::Insert( SotFormatStringId nFormat, const String& rFormatName )
     121                 :            : {
     122         [ #  # ]:          0 :     aSupplementMap.insert( ::std::make_pair( nFormat, rFormatName ) );
     123                 :          0 : }
     124                 :            : 
     125                 :          0 : sal_uLong SvPasteObjectDialog::GetFormat( const TransferableDataHelper& rHelper,
     126                 :            :                                       const DataFlavorExVector* pFormats,
     127                 :            :                                       const TransferableObjectDescriptor* )
     128                 :            : {
     129                 :            :     //TODO/LATER: why is the Descriptor never used?!
     130         [ #  # ]:          0 :     TransferableObjectDescriptor aDesc;
     131 [ #  # ][ #  # ]:          0 :     if( rHelper.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) )
     132                 :            :         ((TransferableDataHelper&)rHelper).GetTransferableObjectDescriptor(
     133         [ #  # ]:          0 :                                 SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aDesc );
     134         [ #  # ]:          0 :     if ( !pFormats )
     135                 :          0 :         pFormats = &rHelper.GetDataFlavorExVector();
     136                 :            : 
     137                 :            :     // create and fill dialog box
     138 [ #  # ][ #  # ]:          0 :     String aSourceName, aTypeName;
     139                 :          0 :     sal_uLong nSelFormat = 0;
     140         [ #  # ]:          0 :     SvGlobalName aEmptyNm;
     141                 :            : 
     142         [ #  # ]:          0 :     ObjectLB().SetUpdateMode( sal_False );
     143                 :            : 
     144                 :          0 :     DataFlavorExVector::iterator aIter( ((DataFlavorExVector&)*pFormats).begin() ),
     145                 :          0 :                                  aEnd( ((DataFlavorExVector&)*pFormats).end() );
     146 [ #  # ][ #  # ]:          0 :     while( aIter != aEnd )
     147                 :            :     {
     148                 :          0 :         ::com::sun::star::datatransfer::DataFlavor aFlavor( *aIter );
     149         [ #  # ]:          0 :         SotFormatStringId nFormat = (*aIter++).mnSotId;
     150                 :            : 
     151                 :            :         ::std::map< SotFormatStringId, String >::iterator itName =
     152         [ #  # ]:          0 :             aSupplementMap.find( nFormat );
     153                 :            : 
     154                 :            :         // if there is an "Embed Source" or and "Embedded Object" on the
     155                 :            :         // Clipboard we read the Description and the Source of this object
     156                 :            :         // from an accompanied "Object Descriptor" format on the clipboard
     157                 :            :         // Remember: these formats mostly appear together on the clipboard
     158         [ #  # ]:          0 :         String aName;
     159                 :          0 :         const String* pName = NULL;
     160 [ #  # ][ #  # ]:          0 :         if ( itName == aSupplementMap.end() )
     161                 :            :         {
     162         [ #  # ]:          0 :             SvPasteObjectHelper::GetEmbeddedName(rHelper,aName,aSourceName,nFormat);
     163         [ #  # ]:          0 :             if ( aName.Len() )
     164                 :          0 :                 pName = &aName;
     165                 :            :         }
     166                 :            :         else
     167                 :            :         {
     168         [ #  # ]:          0 :             pName = &(itName->second);
     169                 :            :         }
     170                 :            : 
     171         [ #  # ]:          0 :         if( pName )
     172                 :            :         {
     173         [ #  # ]:          0 :             aName = *pName;
     174                 :            : 
     175         [ #  # ]:          0 :             if( SOT_FORMATSTR_ID_EMBED_SOURCE == nFormat )
     176                 :            :             {
     177 [ #  # ][ #  # ]:          0 :                 if( aDesc.maClassName != aEmptyNm )
     178                 :            :                 {
     179         [ #  # ]:          0 :                     aSourceName = aDesc.maDisplayName;
     180                 :            : 
     181 [ #  # ][ #  # ]:          0 :                     if( aDesc.maClassName == aObjClassName )
     182         [ #  # ]:          0 :                         aName = aObjName;
     183                 :            :                     else
     184 [ #  # ][ #  # ]:          0 :                         aName = aTypeName = aDesc.maTypeName;
     185                 :            :                 }
     186                 :            :             }
     187         [ #  # ]:          0 :             else if( SOT_FORMATSTR_ID_LINK_SOURCE == nFormat )
     188                 :            :             {
     189         [ #  # ]:          0 :                 PasteLink().Enable();
     190                 :          0 :                 continue;
     191                 :            :             }
     192         [ #  # ]:          0 :             else if( !aName.Len() )
     193 [ #  # ][ #  # ]:          0 :                 aName = SvPasteObjectHelper::GetSotFormatUIName( nFormat );
                 [ #  # ]
     194                 :            : 
     195 [ #  # ][ #  # ]:          0 :             if( LISTBOX_ENTRY_NOTFOUND == ObjectLB().GetEntryPos( aName ) )
     196                 :          0 :                 ObjectLB().SetEntryData(
     197   [ #  #  #  # ]:          0 :                     ObjectLB().InsertEntry( aName ), (void*) nFormat );
     198                 :            :         }
     199 [ #  # ][ #  # ]:          0 :     }
                 [ #  # ]
     200                 :            : 
     201 [ #  # ][ #  # ]:          0 :     if( !aTypeName.Len() && !aSourceName.Len() )
                 [ #  # ]
     202                 :            :     {
     203 [ #  # ][ #  # ]:          0 :         if( aDesc.maClassName != aEmptyNm )
     204                 :            :         {
     205         [ #  # ]:          0 :             aSourceName = aDesc.maDisplayName;
     206         [ #  # ]:          0 :             aTypeName = aDesc.maTypeName;
     207                 :            :         }
     208                 :            : 
     209 [ #  # ][ #  # ]:          0 :         if( !aTypeName.Len() && !aSourceName.Len() )
                 [ #  # ]
     210                 :            :         {
     211 [ #  # ][ #  # ]:          0 :             com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
     212         [ #  # ]:          0 :             ResMgr* pMgr = ResMgr::CreateResMgr( "svt", aLocale );
     213                 :            :             // global resource from svtools (former so3 resource)
     214         [ #  # ]:          0 :             if( pMgr )
     215 [ #  # ][ #  # ]:          0 :                 aSourceName = String( ResId( STR_UNKNOWN_SOURCE, *pMgr ) );
                 [ #  # ]
     216 [ #  # ][ #  # ]:          0 :             delete pMgr;
     217                 :            :         }
     218                 :            :     }
     219                 :            : 
     220         [ #  # ]:          0 :     ObjectLB().SetUpdateMode( sal_True );
     221         [ #  # ]:          0 :     SelectObject();
     222                 :            : 
     223         [ #  # ]:          0 :     if( aSourceName.Len() )
     224                 :            :     {
     225         [ #  # ]:          0 :         if( aTypeName.Len() )
     226         [ #  # ]:          0 :             aTypeName += '\n';
     227                 :            : 
     228         [ #  # ]:          0 :         aTypeName += aSourceName;
     229 [ #  # ][ #  # ]:          0 :         aTypeName = convertLineEnd(aTypeName, GetSystemLineEnd());
                 [ #  # ]
     230                 :            :     }
     231                 :            : 
     232         [ #  # ]:          0 :     ObjectSource().SetText( aTypeName );
     233                 :            : 
     234                 :          0 :     SetDefault();
     235                 :            : 
     236 [ #  # ][ #  # ]:          0 :     if( Dialog::Execute() == RET_OK )
     237                 :            :     {
     238                 :          0 :         bLink = PasteLink().IsChecked();
     239                 :            : 
     240 [ #  # ][ #  # ]:          0 :         if( AsIconBox().IsChecked() )
     241                 :          0 :             nAspect = (sal_uInt16)com::sun::star::embed::Aspects::MSOLE_ICON;
     242                 :            : 
     243 [ #  # ][ #  # ]:          0 :         nSelFormat  = (sal_uLong)ObjectLB().GetEntryData( ObjectLB().GetSelectEntryPos() );
     244                 :            :     }
     245                 :            : 
     246 [ #  # ][ #  # ]:          0 :     return nSelFormat;
         [ #  # ][ #  # ]
     247                 :            : }
     248                 :            : 
     249                 :          0 : void SvPasteObjectDialog::SetObjName( const SvGlobalName & rClass, const String & rObjName )
     250                 :            : {
     251                 :          0 :     aObjClassName = rClass;
     252                 :          0 :     aObjName = rObjName;
     253                 :          0 : }
     254                 :            : 
     255                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10