LCOV - code coverage report
Current view: top level - cui/source/dialogs - pastedlg.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 92 0.0 %
Date: 2014-04-11 Functions: 0 11 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 <com/sun/star/embed/Aspects.hpp>
      21             : 
      22             : #include <pastedlg.hxx>
      23             : #include <svtools/svmedit.hxx>
      24             : #include <svtools/insdlg.hxx>
      25             : #include <vcl/dialog.hxx>
      26             : #include <vcl/button.hxx>
      27             : #include <vcl/fixed.hxx>
      28             : #include <vcl/group.hxx>
      29             : #include <vcl/lstbox.hxx>
      30             : #include <vcl/msgbox.hxx>
      31             : #include <sot/formats.hxx>
      32             : #include <sot/stg.hxx>
      33             : #include <svtools/sores.hxx>
      34             : #include <vcl/svapp.hxx>
      35             : #include <vcl/settings.hxx>
      36             : 
      37             : #include <dialmgr.hxx>
      38             : 
      39           0 : SvPasteObjectDialog::SvPasteObjectDialog( Window* pParent )
      40           0 :     : ModalDialog(pParent, "PasteSpecialDialog", "cui/ui/pastespecial.ui")
      41             : {
      42           0 :     get(m_pFtObjectSource, "source");
      43           0 :     get(m_pLbInsertList, "list");
      44           0 :     get(m_pOKButton, "ok");
      45             : 
      46           0 :     m_pLbInsertList->SetDropDownLineCount(8);
      47           0 :     m_pLbInsertList->set_width_request(m_pLbInsertList->approximate_char_width() * 32);
      48           0 :     m_pOKButton->Disable();
      49             : 
      50           0 :     ObjectLB().SetSelectHdl( LINK( this, SvPasteObjectDialog, SelectHdl ) );
      51           0 :     ObjectLB().SetDoubleClickHdl( LINK( this, SvPasteObjectDialog, DoubleClickHdl ) );
      52           0 : }
      53             : 
      54           0 : void SvPasteObjectDialog::SelectObject()
      55             : {
      56           0 :     if (m_pLbInsertList->GetEntryCount())
      57             :     {
      58           0 :         m_pLbInsertList->SelectEntryPos(0);
      59           0 :         SelectHdl(m_pLbInsertList);
      60             :     }
      61           0 : }
      62             : 
      63           0 : IMPL_LINK( SvPasteObjectDialog, SelectHdl, ListBox *, pListBox )
      64             : {
      65             :     (void)pListBox;
      66             : 
      67           0 :     if ( !m_pOKButton->IsEnabled() )
      68           0 :         m_pOKButton->Enable();
      69           0 :     return 0;
      70             : }
      71             : 
      72           0 : IMPL_LINK_INLINE_START( SvPasteObjectDialog, DoubleClickHdl, ListBox *, pListBox )
      73             : {
      74             :     (void)pListBox;
      75             : 
      76           0 :     EndDialog( RET_OK );
      77           0 :     return 0;
      78             : }
      79           0 : IMPL_LINK_INLINE_END( SvPasteObjectDialog, DoubleClickHdl, ListBox *, pListBox )
      80             : 
      81           0 : SvPasteObjectDialog::~SvPasteObjectDialog()
      82             : {
      83           0 : }
      84             : 
      85             : /*************************************************************************
      86             : |*    SvPasteObjectDialog::Insert()
      87             : *************************************************************************/
      88           0 : void SvPasteObjectDialog::Insert( SotFormatStringId nFormat, const OUString& rFormatName )
      89             : {
      90           0 :     aSupplementMap.insert( ::std::make_pair( nFormat, rFormatName ) );
      91           0 : }
      92             : 
      93           0 : sal_uLong SvPasteObjectDialog::GetFormat( const TransferableDataHelper& rHelper,
      94             :                                       const DataFlavorExVector* pFormats,
      95             :                                       const TransferableObjectDescriptor* )
      96             : {
      97             :     //TODO/LATER: why is the Descriptor never used?!
      98           0 :     TransferableObjectDescriptor aDesc;
      99           0 :     if( rHelper.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) )
     100             :         ((TransferableDataHelper&)rHelper).GetTransferableObjectDescriptor(
     101           0 :                                 SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aDesc );
     102           0 :     if ( !pFormats )
     103           0 :         pFormats = &rHelper.GetDataFlavorExVector();
     104             : 
     105             :     // create and fill dialog box
     106           0 :     OUString aSourceName, aTypeName;
     107           0 :     sal_uLong nSelFormat = 0;
     108           0 :     SvGlobalName aEmptyNm;
     109             : 
     110           0 :     ObjectLB().SetUpdateMode( false );
     111             : 
     112           0 :     DataFlavorExVector::iterator aIter( ((DataFlavorExVector&)*pFormats).begin() ),
     113           0 :                                  aEnd( ((DataFlavorExVector&)*pFormats).end() );
     114           0 :     while( aIter != aEnd )
     115             :     {
     116           0 :         ::com::sun::star::datatransfer::DataFlavor aFlavor( *aIter );
     117           0 :         SotFormatStringId nFormat = (*aIter++).mnSotId;
     118             : 
     119             :         ::std::map< SotFormatStringId, OUString >::iterator itName =
     120           0 :             aSupplementMap.find( nFormat );
     121             : 
     122             :         // if there is an "Embed Source" or and "Embedded Object" on the
     123             :         // Clipboard we read the Description and the Source of this object
     124             :         // from an accompanied "Object Descriptor" format on the clipboard
     125             :         // Remember: these formats mostly appear together on the clipboard
     126           0 :         OUString aName;
     127           0 :         const OUString* pName = NULL;
     128           0 :         if ( itName == aSupplementMap.end() )
     129             :         {
     130           0 :             SvPasteObjectHelper::GetEmbeddedName(rHelper,aName,aSourceName,nFormat);
     131           0 :             if ( !aName.isEmpty() )
     132           0 :                 pName = &aName;
     133             :         }
     134             :         else
     135             :         {
     136           0 :             pName = &(itName->second);
     137             :         }
     138             : 
     139           0 :         if( pName )
     140             :         {
     141           0 :             aName = *pName;
     142             : 
     143           0 :             if( SOT_FORMATSTR_ID_EMBED_SOURCE == nFormat )
     144             :             {
     145           0 :                 if( aDesc.maClassName != aEmptyNm )
     146             :                 {
     147           0 :                     aSourceName = aDesc.maDisplayName;
     148             : 
     149           0 :                     if( aDesc.maClassName == aObjClassName )
     150           0 :                         aName = aObjName;
     151             :                     else
     152           0 :                         aName = aTypeName = aDesc.maTypeName;
     153             :                 }
     154             :             }
     155           0 :             else if( SOT_FORMATSTR_ID_LINK_SOURCE == nFormat )
     156             :             {
     157           0 :                 continue;
     158             :             }
     159           0 :             else if( aName.isEmpty() )
     160           0 :                 aName = SvPasteObjectHelper::GetSotFormatUIName( nFormat );
     161             : 
     162           0 :             if( LISTBOX_ENTRY_NOTFOUND == ObjectLB().GetEntryPos( aName ) )
     163           0 :                 ObjectLB().SetEntryData(
     164           0 :                     ObjectLB().InsertEntry( aName ), (void*) nFormat );
     165             :         }
     166           0 :     }
     167             : 
     168           0 :     if( aTypeName.isEmpty() && aSourceName.isEmpty() )
     169             :     {
     170           0 :         if( aDesc.maClassName != aEmptyNm )
     171             :         {
     172           0 :             aSourceName = aDesc.maDisplayName;
     173           0 :             aTypeName = aDesc.maTypeName;
     174             :         }
     175             : 
     176           0 :         if( aTypeName.isEmpty() && aSourceName.isEmpty() )
     177             :         {
     178           0 :             ResMgr* pMgr = ResMgr::CreateResMgr( "svt", Application::GetSettings().GetUILanguageTag() );
     179             :             // global resource from svtools (former so3 resource)
     180           0 :             if( pMgr )
     181           0 :                 aSourceName = OUString( ResId( STR_UNKNOWN_SOURCE, *pMgr ) );
     182           0 :             delete pMgr;
     183             :         }
     184             :     }
     185             : 
     186           0 :     ObjectLB().SetUpdateMode( true );
     187           0 :     SelectObject();
     188             : 
     189           0 :     if( !aSourceName.isEmpty() )
     190             :     {
     191           0 :         if( !aTypeName.isEmpty() )
     192           0 :             aTypeName += "\n";
     193             : 
     194           0 :         aTypeName += aSourceName;
     195           0 :         aTypeName = convertLineEnd(aTypeName, GetSystemLineEnd());
     196             :     }
     197             : 
     198           0 :     ObjectSource().SetText( aTypeName );
     199             : 
     200           0 :     if( Dialog::Execute() == RET_OK )
     201             :     {
     202           0 :         nSelFormat  = (sal_uLong)ObjectLB().GetEntryData( ObjectLB().GetSelectEntryPos() );
     203             :     }
     204             : 
     205           0 :     return nSelFormat;
     206             : }
     207             : 
     208           0 : void SvPasteObjectDialog::SetObjName( const SvGlobalName & rClass, const OUString & rObjName )
     209             : {
     210           0 :     aObjClassName = rClass;
     211           0 :     aObjName = rObjName;
     212           0 : }
     213             : 
     214             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10