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

Generated by: LCOV version 1.10