LCOV - code coverage report
Current view: top level - sw/source/core/uibase/uiview - uivwimp.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 136 0.0 %
Date: 2014-04-14 Functions: 0 21 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 <cmdid.h>
      21             : #include "globals.hrc"
      22             : 
      23             : #include <tools/shl.hxx>
      24             : #include <com/sun/star/scanner/XScannerManager2.hpp>
      25             : #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
      26             : #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
      27             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      28             : #include <comphelper/processfactory.hxx>
      29             : #include <osl/mutex.hxx>
      30             : #include <vcl/svapp.hxx>
      31             : #include <vcl/wrkwin.hxx>
      32             : #include <vcl/msgbox.hxx>
      33             : #include <sfx2/viewfrm.hxx>
      34             : #include <sfx2/bindings.hxx>
      35             : 
      36             : #include <sfx2/docinsert.hxx>
      37             : #include <sfx2/request.hxx>
      38             : #include <uivwimp.hxx>
      39             : #include <wview.hxx>
      40             : #include <unotxvw.hxx>
      41             : #include <unodispatch.hxx>
      42             : #include <swmodule.hxx>
      43             : #include <swdtflvr.hxx>
      44             : #include <edtwin.hxx>
      45             : #include <mmconfigitem.hxx>
      46             : 
      47             : #include <view.hrc>
      48             : 
      49             : using namespace ::com::sun::star;
      50             : using namespace ::com::sun::star::uno;
      51             : using namespace ::com::sun::star::scanner;
      52             : using namespace ::com::sun::star::lang;
      53             : using namespace ::com::sun::star::datatransfer::clipboard;
      54             : 
      55           0 : SwView_Impl::SwView_Impl(SwView* pShell)
      56           0 :     : pxXTextView(new uno::Reference<view::XSelectionSupplier>)
      57             :     , pView(pShell)
      58             :     , pScanEvtLstnr(0)
      59             :     , pClipEvtLstnr(0)
      60             :     , eShellMode(SHELL_MODE_TEXT)
      61             :     , pConfigItem(0)
      62             :     , nMailMergeRestartPage(0)
      63             :     , bMailMergeSourceView(sal_True)
      64             :     , m_pDocInserter(NULL)
      65             :     , m_pRequest(NULL)
      66             :     , m_nParam(0)
      67             :     , m_bSelectObject(false)
      68           0 :     , m_bEditingPositionSet(false)
      69             : {
      70           0 :     *pxXTextView = new SwXTextView(pView);
      71           0 :     xDisProvInterceptor = new SwXDispatchProviderInterceptor(*pView);
      72           0 : }
      73             : 
      74           0 : SwView_Impl::~SwView_Impl()
      75             : {
      76           0 :     Reference<XUnoTunnel> xDispTunnel(xDisProvInterceptor, UNO_QUERY);
      77           0 :     SwXDispatchProviderInterceptor* pInterceptor = 0;
      78           0 :     if(xDispTunnel.is() &&
      79             :         0 != (pInterceptor = reinterpret_cast< SwXDispatchProviderInterceptor * >(
      80             :                     sal::static_int_cast< sal_IntPtr >(
      81           0 :                     xDispTunnel->getSomething(SwXDispatchProviderInterceptor::getUnoTunnelId())))))
      82             :     {
      83           0 :         pInterceptor->Invalidate();
      84             :     }
      85           0 :     view::XSelectionSupplier* pTextView = pxXTextView->get();
      86           0 :     ((SwXTextView*)pTextView)->Invalidate();
      87           0 :     delete pxXTextView;
      88           0 :     if( xScanEvtLstnr.is() )
      89           0 :            pScanEvtLstnr->ViewDestroyed();
      90           0 :     if( xClipEvtLstnr.is() )
      91             :     {
      92           0 :         pClipEvtLstnr->AddRemoveListener( sal_False );
      93           0 :         pClipEvtLstnr->ViewDestroyed();
      94             :     }
      95           0 :     delete pConfigItem;
      96             : 
      97           0 :     delete m_pDocInserter;
      98           0 :     delete m_pRequest;
      99           0 : }
     100             : 
     101           0 : void SwView_Impl::SetShellMode(ShellModes eSet)
     102             : {
     103           0 :     eShellMode = eSet;
     104           0 : }
     105             : 
     106           0 : view::XSelectionSupplier*   SwView_Impl::GetUNOObject()
     107             : {
     108           0 :     return pxXTextView->get();
     109             : }
     110             : 
     111           0 : SwXTextView*    SwView_Impl::GetUNOObject_Impl()
     112             : {
     113           0 :         view::XSelectionSupplier* pTextView = pxXTextView->get();
     114           0 :         return ((SwXTextView*)pTextView);
     115             : }
     116             : 
     117           0 : void SwView_Impl::ExecuteScan( SfxRequest& rReq )
     118             : {
     119           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     120           0 :     switch(nSlot)
     121             :     {
     122             :         case SID_TWAIN_SELECT:
     123             :         {
     124           0 :             sal_Bool bDone = sal_False;
     125           0 :             Reference< XScannerManager2 > xScanMgr = SW_MOD()->GetScannerManager();
     126             : 
     127           0 :             if( xScanMgr.is() )
     128             :             {
     129             :                 try
     130             :                 {
     131           0 :                     SwScannerEventListener& rListener = GetScannerEventListener();
     132             :                     const Sequence< ScannerContext >
     133           0 :                         aContexts( xScanMgr->getAvailableScanners() );
     134             : 
     135           0 :                     if( aContexts.getLength() )
     136             :                     {
     137           0 :                         Reference< XEventListener > xLstner = &rListener;
     138           0 :                         ScannerContext aContext( aContexts.getConstArray()[ 0 ] );
     139           0 :                         bDone = xScanMgr->configureScannerAndScan( aContext, xLstner );
     140           0 :                     }
     141             :                 }
     142           0 :                 catch(...)
     143             :                 {
     144             :                 }
     145             : 
     146             :             }
     147           0 :             if( bDone )
     148           0 :                 rReq.Done();
     149             :             else
     150             :             {
     151           0 :                 rReq.Ignore();
     152           0 :             }
     153             :         }
     154           0 :         break;
     155             : 
     156             :         case SID_TWAIN_TRANSFER:
     157             :         {
     158           0 :             bool bDone = false;
     159             : 
     160           0 :             Reference< XScannerManager2 > xScanMgr = SW_MOD()->GetScannerManager();
     161           0 :             if( xScanMgr.is() )
     162             :             {
     163           0 :                 SwScannerEventListener& rListener = GetScannerEventListener();
     164             :                 try
     165             :                 {
     166           0 :                     const Sequence< scanner::ScannerContext >aContexts( xScanMgr->getAvailableScanners() );
     167           0 :                     if( aContexts.getLength() )
     168             :                     {
     169           0 :                         Reference< XEventListener > xLstner = &rListener;
     170           0 :                         xScanMgr->startScan( aContexts.getConstArray()[ 0 ], xLstner );
     171           0 :                         bDone = true;
     172           0 :                     }
     173             :                 }
     174           0 :                 catch(...)
     175             :                 {
     176             :                 }
     177             :             }
     178             : 
     179           0 :             if( !bDone )
     180             :             {
     181           0 :                 InfoBox( 0, SW_RES(MSG_SCAN_NOSOURCE) ).Execute();
     182           0 :                 rReq.Ignore();
     183             :             }
     184             :             else
     185             :             {
     186           0 :                 rReq.Done();
     187           0 :                 SfxBindings& rBind = pView->GetViewFrame()->GetBindings();
     188           0 :                 rBind.Invalidate( SID_TWAIN_SELECT );
     189           0 :                 rBind.Invalidate( SID_TWAIN_TRANSFER );
     190           0 :             }
     191             :         }
     192           0 :         break;
     193             :     }
     194           0 : }
     195             : 
     196           0 : SwScannerEventListener& SwView_Impl::GetScannerEventListener()
     197             : {
     198           0 :     if(!xScanEvtLstnr.is())
     199           0 :         xScanEvtLstnr = pScanEvtLstnr = new SwScannerEventListener(*pView);
     200           0 :     return *pScanEvtLstnr;
     201             : }
     202             : 
     203           0 : void SwView_Impl::AddClipboardListener()
     204             : {
     205           0 :     if(!xClipEvtLstnr.is())
     206             :     {
     207           0 :         xClipEvtLstnr = pClipEvtLstnr = new SwClipboardChangeListener( *pView );
     208           0 :         pClipEvtLstnr->AddRemoveListener( sal_True );
     209             :     }
     210           0 : }
     211             : 
     212           0 : void SwView_Impl::Invalidate()
     213             : {
     214           0 :     GetUNOObject_Impl()->Invalidate();
     215           0 :     Reference< XUnoTunnel > xTunnel(xTransferable.get(), UNO_QUERY);
     216           0 :     if(xTunnel.is())
     217             : 
     218             :     {
     219             :         SwTransferable* pTransferable = reinterpret_cast< SwTransferable * >(
     220             :                 sal::static_int_cast< sal_IntPtr >(
     221           0 :                 xTunnel->getSomething(SwTransferable::getUnoTunnelId())));
     222           0 :         if(pTransferable)
     223           0 :             pTransferable->Invalidate();
     224           0 :     }
     225           0 : }
     226             : 
     227           0 : void SwView_Impl::AddTransferable(SwTransferable& rTransferable)
     228             : {
     229             :     //prevent removing of the non-referenced SwTransferable
     230           0 :     rTransferable.m_refCount++;
     231             :     {
     232           0 :         xTransferable = Reference<XUnoTunnel> (&rTransferable);
     233             :     }
     234           0 :     rTransferable.m_refCount--;
     235           0 : }
     236             : 
     237           0 : void SwView_Impl::StartDocumentInserter( const OUString& rFactory, const Link& rEndDialogHdl )
     238             : {
     239           0 :     delete m_pDocInserter;
     240           0 :     m_pDocInserter = new ::sfx2::DocumentInserter( rFactory );
     241           0 :     m_pDocInserter->StartExecuteModal( rEndDialogHdl );
     242           0 : }
     243             : 
     244           0 : SfxMedium* SwView_Impl::CreateMedium()
     245             : {
     246           0 :     return m_pDocInserter->CreateMedium();
     247             : }
     248             : 
     249           0 : void SwView_Impl::InitRequest( const SfxRequest& rRequest )
     250             : {
     251           0 :     delete m_pRequest;
     252           0 :     m_pRequest = new SfxRequest( rRequest );
     253           0 : }
     254             : 
     255           0 : SwScannerEventListener::~SwScannerEventListener()
     256             : {
     257           0 : }
     258             : 
     259           0 : void SAL_CALL SwScannerEventListener::disposing( const EventObject& rEventObject) throw(uno::RuntimeException, std::exception)
     260             : {
     261             : #if defined WNT || defined UNX
     262           0 :     SolarMutexGuard aGuard;
     263           0 :     if( pView )
     264           0 :         pView->ScannerEventHdl( rEventObject );
     265             : #endif
     266           0 : }
     267             : 
     268           0 : SwClipboardChangeListener::~SwClipboardChangeListener()
     269             : {
     270           0 : }
     271             : 
     272           0 : void SAL_CALL SwClipboardChangeListener::disposing( const EventObject& /*rEventObject*/ )
     273             :     throw ( RuntimeException, std::exception )
     274             : {
     275           0 : }
     276             : 
     277           0 : void SAL_CALL SwClipboardChangeListener::changedContents( const ::com::sun::star::datatransfer::clipboard::ClipboardEvent& rEventObject )
     278             :     throw (RuntimeException, std::exception)
     279             : 
     280             : {
     281           0 :     const SolarMutexGuard aGuard;
     282           0 :     if( pView )
     283             :     {
     284             :         {
     285           0 :             TransferableDataHelper aDataHelper( rEventObject.Contents );
     286           0 :             SwWrtShell& rSh = pView->GetWrtShell();
     287             : 
     288           0 :             pView->m_nLastPasteDestination = SwTransferable::GetSotDestination( rSh );
     289           0 :             pView->m_bPasteState = aDataHelper.GetXTransferable().is() &&
     290           0 :                             SwTransferable::IsPaste( rSh, aDataHelper );
     291             : 
     292           0 :             pView->m_bPasteSpecialState = aDataHelper.GetXTransferable().is() &&
     293           0 :                         SwTransferable::IsPasteSpecial( rSh, aDataHelper );
     294             :         }
     295             : 
     296           0 :         SfxBindings& rBind = pView->GetViewFrame()->GetBindings();
     297           0 :         rBind.Invalidate( SID_PASTE );
     298           0 :         rBind.Invalidate( SID_PASTE_SPECIAL );
     299           0 :         rBind.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
     300           0 :     }
     301           0 : }
     302             : 
     303           0 : void SwClipboardChangeListener::AddRemoveListener( sal_Bool bAdd )
     304             : {
     305           0 :     pView->AddRemoveClipboardListener( Reference< XClipboardListener >( this ), bAdd );
     306           0 : }
     307             : 
     308             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10