LCOV - code coverage report
Current view: top level - sc/source/ui/view - tabvwshh.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 114 0.0 %
Date: 2014-04-14 Functions: 0 12 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 <svx/svdmark.hxx>
      21             : #include <svx/svdoole2.hxx>
      22             : #include <svx/svdview.hxx>
      23             : #include <sfx2/app.hxx>
      24             : #include <sfx2/objsh.hxx>
      25             : #include <sfx2/request.hxx>
      26             : #include <basic/sbxcore.hxx>
      27             : #include <svl/whiter.hxx>
      28             : #include <vcl/msgbox.hxx>
      29             : 
      30             : #include "tabvwsh.hxx"
      31             : #include "client.hxx"
      32             : #include "document.hxx"
      33             : #include "docsh.hxx"
      34             : #include "sc.hrc"
      35             : #include "drwlayer.hxx"
      36             : #include "retypepassdlg.hxx"
      37             : #include "tabprotection.hxx"
      38             : 
      39             : #include <boost/scoped_ptr.hpp>
      40             : 
      41             : using namespace com::sun::star;
      42             : 
      43           0 : void ScTabViewShell::ExecuteSbx( SfxRequest& /* rReq */ )
      44             : {
      45             :     //  SID_RANGE_OFFSET (Offset),
      46             :     //  SID_PIVOT_CREATE (DataPilotCreate) - removed (old Basic)
      47           0 : }
      48             : 
      49           0 : void ScTabViewShell::GetSbxState( SfxItemSet& /* rSet */ )
      50             : {
      51             :     //  SID_RANGE_REGION (CurrentRegion) - removed (old Basic)
      52           0 : }
      53             : 
      54           0 : void ScTabViewShell::ExecuteObject( SfxRequest& rReq )
      55             : {
      56           0 :     sal_uInt16 nSlotId = rReq.GetSlot();
      57           0 :     const SfxItemSet* pReqArgs = rReq.GetArgs();
      58             : 
      59             :         //  Objekte aktivieren/deaktivieren immer auf der sichtbaren View
      60             : 
      61           0 :     ScTabViewShell* pVisibleSh = this;
      62             :     if ( nSlotId == SID_OLE_SELECT || nSlotId == SID_OLE_ACTIVATE || nSlotId == SID_OLE_DEACTIVATE )
      63             :     {
      64             :         OSL_FAIL("old slot SID_OLE...");
      65             :     }
      66             : 
      67           0 :     switch (nSlotId)
      68             :     {
      69             :         case SID_OLE_SELECT:
      70             :         case SID_OLE_ACTIVATE:
      71             :             {
      72             :                 //  in beiden Faellen erstmal auf der sichtbaren View selektieren
      73             : 
      74           0 :                 OUString aName;
      75           0 :                 SdrView* pDrView = GetSdrView();
      76           0 :                 if (pDrView)
      77             :                 {
      78           0 :                     const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
      79           0 :                     if (rMarkList.GetMarkCount() == 1)
      80           0 :                         aName = ScDrawLayer::GetVisibleName( rMarkList.GetMark(0)->GetMarkedSdrObj() );
      81             :                 }
      82           0 :                 pVisibleSh->SelectObject( aName );
      83             : 
      84             :                 //  aktivieren
      85             : 
      86           0 :                 if ( nSlotId == SID_OLE_ACTIVATE )
      87           0 :                     pVisibleSh->DoVerb( 0 );
      88             :             }
      89           0 :             break;
      90             :         case SID_OLE_DEACTIVATE:
      91           0 :             pVisibleSh->DeactivateOle();
      92           0 :             break;
      93             : 
      94             :         case SID_OBJECT_LEFT:
      95             :         case SID_OBJECT_TOP:
      96             :         case SID_OBJECT_WIDTH:
      97             :         case SID_OBJECT_HEIGHT:
      98             :             {
      99           0 :                 bool bDone = false;
     100             :                 const SfxPoolItem* pItem;
     101           0 :                 if ( pReqArgs && pReqArgs->GetItemState( nSlotId, true, &pItem ) == SFX_ITEM_SET )
     102             :                 {
     103           0 :                     long nNewVal = ((const SfxInt32Item*)pItem)->GetValue();
     104           0 :                     if ( nNewVal < 0 )
     105           0 :                         nNewVal = 0;
     106             : 
     107             :                     //! von irgendwas in 1/100mm umrechnen ??????
     108             : 
     109           0 :                     SdrView* pDrView = GetSdrView();
     110           0 :                     if ( pDrView )
     111             :                     {
     112           0 :                         const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
     113           0 :                         if (rMarkList.GetMarkCount() == 1)
     114             :                         {
     115           0 :                             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     116           0 :                             Rectangle aRect = pObj->GetLogicRect();
     117             : 
     118           0 :                             if ( nSlotId == SID_OBJECT_LEFT )
     119           0 :                                 pDrView->MoveMarkedObj( Size( nNewVal - aRect.Left(), 0 ) );
     120           0 :                             else if ( nSlotId == SID_OBJECT_TOP )
     121           0 :                                 pDrView->MoveMarkedObj( Size( 0, nNewVal - aRect.Top() ) );
     122           0 :                             else if ( nSlotId == SID_OBJECT_WIDTH )
     123             :                                 pDrView->ResizeMarkedObj( aRect.TopLeft(),
     124             :                                                 Fraction( nNewVal, aRect.GetWidth() ),
     125           0 :                                                 Fraction( 1, 1 ) );
     126             :                             else // if ( nSlotId == SID_OBJECT_HEIGHT )
     127             :                                 pDrView->ResizeMarkedObj( aRect.TopLeft(),
     128             :                                                 Fraction( 1, 1 ),
     129           0 :                                                 Fraction( nNewVal, aRect.GetHeight() ) );
     130           0 :                             bDone = true;
     131             :                         }
     132             :                     }
     133             :                 }
     134             : #ifndef DISABLE_SCRIPTING
     135           0 :                 if (!bDone)
     136           0 :                     SbxBase::SetError( SbxERR_BAD_PARAMETER );  // Basic-Fehler
     137             : #endif
     138             :             }
     139           0 :             break;
     140             : 
     141             :     }
     142           0 : }
     143             : 
     144           0 : static uno::Reference < embed::XEmbeddedObject > lcl_GetSelectedObj( SdrView* pDrView )       //! Member von ScDrawView?
     145             : {
     146           0 :     uno::Reference < embed::XEmbeddedObject > xRet;
     147           0 :     if (pDrView)
     148             :     {
     149           0 :         const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
     150           0 :         if (rMarkList.GetMarkCount() == 1)
     151             :         {
     152           0 :             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     153           0 :             if (pObj->GetObjIdentifier() == OBJ_OLE2)
     154             :             {
     155           0 :                 SdrOle2Obj* pOle2Obj = (SdrOle2Obj*) pObj;
     156           0 :                 xRet = pOle2Obj->GetObjRef();
     157             :             }
     158             :         }
     159             :     }
     160             : 
     161           0 :     return xRet;
     162             : }
     163             : 
     164           0 : void ScTabViewShell::GetObjectState( SfxItemSet& rSet )
     165             : {
     166             :     //  SID_OLE_OBJECT - removed (old Basic)
     167             : 
     168           0 :     SfxWhichIter aIter(rSet);
     169           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     170           0 :     while ( nWhich )
     171             :     {
     172           0 :         switch (nWhich)
     173             :         {
     174             :             case SID_ACTIVE_OBJ_NAME:
     175             :                 {
     176           0 :                     OUString aName;
     177           0 :                     uno::Reference < embed::XEmbeddedObject > xOLE = lcl_GetSelectedObj( GetSdrView() );
     178           0 :                     if (xOLE.is())
     179             :                     {
     180           0 :                         aName = GetViewData()->GetSfxDocShell()->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xOLE );
     181             :                     }
     182           0 :                     rSet.Put( SfxStringItem( nWhich, aName ) );
     183             :                 }
     184           0 :                 break;
     185             :             case SID_OBJECT_LEFT:
     186             :             case SID_OBJECT_TOP:
     187             :             case SID_OBJECT_WIDTH:
     188             :             case SID_OBJECT_HEIGHT:
     189             :                 {
     190           0 :                     SdrView* pDrView = GetSdrView();
     191           0 :                     if ( pDrView )
     192             :                     {
     193           0 :                         const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
     194           0 :                         if (rMarkList.GetMarkCount() == 1)
     195             :                         {
     196           0 :                             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     197           0 :                             Rectangle aRect = pObj->GetLogicRect();
     198             : 
     199             :                             long nVal;
     200           0 :                             if ( nWhich == SID_OBJECT_LEFT )
     201           0 :                                 nVal = aRect.Left();
     202           0 :                             else if ( nWhich == SID_OBJECT_TOP )
     203           0 :                                 nVal = aRect.Top();
     204           0 :                             else if ( nWhich == SID_OBJECT_WIDTH )
     205           0 :                                 nVal = aRect.GetWidth();
     206             :                             else // if ( nWhich == SID_OBJECT_HEIGHT )
     207           0 :                                 nVal = aRect.GetHeight();
     208             : 
     209             :                             //! von 1/100mm in irgendwas umrechnen ??????
     210             : 
     211           0 :                             rSet.Put( SfxInt32Item( nWhich, nVal ) );
     212             :                         }
     213             :                     }
     214             :                 }
     215           0 :                 break;
     216             :         }
     217           0 :         nWhich = aIter.NextWhich();
     218           0 :     }
     219           0 : }
     220             : 
     221           0 : void ScTabViewShell::AddAccessibilityObject( SfxListener& rObject )
     222             : {
     223           0 :     if (!pAccessibilityBroadcaster)
     224           0 :         pAccessibilityBroadcaster = new SfxBroadcaster;
     225             : 
     226           0 :     rObject.StartListening( *pAccessibilityBroadcaster );
     227           0 :     ScDocument* pDoc = GetViewData()->GetDocument();
     228           0 :     if (pDoc)
     229           0 :         pDoc->AddUnoObject(rObject);
     230           0 : }
     231             : 
     232           0 : void ScTabViewShell::RemoveAccessibilityObject( SfxListener& rObject )
     233             : {
     234           0 :     if (pAccessibilityBroadcaster)
     235             :     {
     236           0 :         rObject.EndListening( *pAccessibilityBroadcaster );
     237           0 :         ScDocument* pDoc = GetViewData()->GetDocument();
     238           0 :         if (pDoc)
     239           0 :             pDoc->RemoveUnoObject(rObject);
     240             :     }
     241             :     else
     242             :     {
     243             :         OSL_FAIL("kein Accessibility-Broadcaster?");
     244             :     }
     245           0 : }
     246             : 
     247           0 : void ScTabViewShell::BroadcastAccessibility( const SfxHint &rHint )
     248             : {
     249           0 :     if (pAccessibilityBroadcaster)
     250           0 :         pAccessibilityBroadcaster->Broadcast( rHint );
     251           0 : }
     252             : 
     253           0 : bool ScTabViewShell::HasAccessibilityObjects()
     254             : {
     255           0 :     return pAccessibilityBroadcaster != NULL;
     256             : }
     257             : 
     258           0 : bool ScTabViewShell::ExecuteRetypePassDlg(ScPasswordHash eDesiredHash)
     259             : {
     260           0 :     ScDocument* pDoc = GetViewData()->GetDocument();
     261             : 
     262           0 :     boost::scoped_ptr<ScRetypePassDlg> pDlg(new ScRetypePassDlg(GetDialogParent()));
     263           0 :     pDlg->SetDataFromDocument(*pDoc);
     264           0 :     pDlg->SetDesiredHash(eDesiredHash);
     265           0 :     if (pDlg->Execute() != RET_OK)
     266           0 :         return false;
     267             : 
     268           0 :     pDlg->WriteNewDataToDocument(*pDoc);
     269           0 :     return true;
     270           0 : }
     271             : 
     272             : 
     273             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10