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

Generated by: LCOV version 1.10