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

Generated by: LCOV version 1.11