LCOV - code coverage report
Current view: top level - sc/source/ui/view - tabvwshh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 21 113 18.6 %
Date: 2012-08-25 Functions: 4 10 40.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 195 3.6 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <svx/svdmark.hxx>
      30                 :            : #include <svx/svdoole2.hxx>
      31                 :            : #include <svx/svdview.hxx>
      32                 :            : #include <sfx2/app.hxx>
      33                 :            : #include <sfx2/objsh.hxx>
      34                 :            : #include <sfx2/request.hxx>
      35                 :            : #include <basic/sbxcore.hxx>
      36                 :            : #include <svl/whiter.hxx>
      37                 :            : #include <vcl/msgbox.hxx>
      38                 :            : 
      39                 :            : #include "tabvwsh.hxx"
      40                 :            : #include "client.hxx"
      41                 :            : #include "document.hxx"
      42                 :            : #include "docsh.hxx"
      43                 :            : #include "sc.hrc"
      44                 :            : #include "drwlayer.hxx"     // GetVisibleName
      45                 :            : #include "retypepassdlg.hxx"
      46                 :            : #include "tabprotection.hxx"
      47                 :            : 
      48                 :            : #include <memory>
      49                 :            : 
      50                 :            : using namespace com::sun::star;
      51                 :            : 
      52                 :            : //------------------------------------------------------------------
      53                 :            : 
      54                 :          0 : void ScTabViewShell::ExecuteSbx( SfxRequest& /* rReq */ )
      55                 :            : {
      56                 :            :     //  SID_RANGE_OFFSET (Offset),
      57                 :            :     //  SID_PIVOT_CREATE (DataPilotCreate) - removed (old Basic)
      58                 :          0 : }
      59                 :            : 
      60                 :          0 : void ScTabViewShell::GetSbxState( SfxItemSet& /* rSet */ )
      61                 :            : {
      62                 :            :     //  SID_RANGE_REGION (CurrentRegion) - removed (old Basic)
      63                 :          0 : }
      64                 :            : 
      65                 :            : //------------------------------------------------------------------
      66                 :            : 
      67                 :          0 : void ScTabViewShell::ExecuteObject( SfxRequest& rReq )
      68                 :            : {
      69                 :          0 :     sal_uInt16 nSlotId = rReq.GetSlot();
      70                 :          0 :     const SfxItemSet* pReqArgs = rReq.GetArgs();
      71                 :            : 
      72                 :            :         //  Objekte aktivieren/deaktivieren immer auf der sichtbaren View
      73                 :            : 
      74                 :          0 :     ScTabViewShell* pVisibleSh = this;
      75                 :            :     if ( nSlotId == SID_OLE_SELECT || nSlotId == SID_OLE_ACTIVATE || nSlotId == SID_OLE_DEACTIVATE )
      76                 :            :     {
      77                 :            :         OSL_FAIL("old slot SID_OLE...");
      78                 :            :     }
      79                 :            : 
      80   [ #  #  #  # ]:          0 :     switch (nSlotId)
      81                 :            :     {
      82                 :            :         case SID_OLE_SELECT:
      83                 :            :         case SID_OLE_ACTIVATE:
      84                 :            :             {
      85                 :            :                 //  in beiden Faellen erstmal auf der sichtbaren View selektieren
      86                 :            : 
      87         [ #  # ]:          0 :                 String aName;
      88         [ #  # ]:          0 :                 SdrView* pDrView = GetSdrView();
      89         [ #  # ]:          0 :                 if (pDrView)
      90                 :            :                 {
      91                 :          0 :                     const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
      92         [ #  # ]:          0 :                     if (rMarkList.GetMarkCount() == 1)
      93 [ #  # ][ #  # ]:          0 :                         aName = ScDrawLayer::GetVisibleName( rMarkList.GetMark(0)->GetMarkedSdrObj() );
         [ #  # ][ #  # ]
                 [ #  # ]
      94                 :            :                 }
      95         [ #  # ]:          0 :                 pVisibleSh->SelectObject( aName );
      96                 :            : 
      97                 :            :                 //  aktivieren
      98                 :            : 
      99         [ #  # ]:          0 :                 if ( nSlotId == SID_OLE_ACTIVATE )
     100 [ #  # ][ #  # ]:          0 :                     pVisibleSh->DoVerb( 0 );
     101                 :            :             }
     102                 :          0 :             break;
     103                 :            :         case SID_OLE_DEACTIVATE:
     104                 :          0 :             pVisibleSh->DeactivateOle();
     105                 :          0 :             break;
     106                 :            : 
     107                 :            :         case SID_OBJECT_LEFT:
     108                 :            :         case SID_OBJECT_TOP:
     109                 :            :         case SID_OBJECT_WIDTH:
     110                 :            :         case SID_OBJECT_HEIGHT:
     111                 :            :             {
     112                 :          0 :                 sal_Bool bDone = false;
     113                 :            :                 const SfxPoolItem* pItem;
     114 [ #  # ][ #  # ]:          0 :                 if ( pReqArgs && pReqArgs->GetItemState( nSlotId, sal_True, &pItem ) == SFX_ITEM_SET )
         [ #  # ][ #  # ]
     115                 :            :                 {
     116                 :          0 :                     long nNewVal = ((const SfxInt32Item*)pItem)->GetValue();
     117         [ #  # ]:          0 :                     if ( nNewVal < 0 )
     118                 :          0 :                         nNewVal = 0;
     119                 :            : 
     120                 :            :                     //! von irgendwas in 1/100mm umrechnen ??????
     121                 :            : 
     122         [ #  # ]:          0 :                     SdrView* pDrView = GetSdrView();
     123         [ #  # ]:          0 :                     if ( pDrView )
     124                 :            :                     {
     125                 :          0 :                         const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
     126         [ #  # ]:          0 :                         if (rMarkList.GetMarkCount() == 1)
     127                 :            :                         {
     128 [ #  # ][ #  # ]:          0 :                             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     129         [ #  # ]:          0 :                             Rectangle aRect = pObj->GetLogicRect();
     130                 :            : 
     131         [ #  # ]:          0 :                             if ( nSlotId == SID_OBJECT_LEFT )
     132         [ #  # ]:          0 :                                 pDrView->MoveMarkedObj( Size( nNewVal - aRect.Left(), 0 ) );
     133         [ #  # ]:          0 :                             else if ( nSlotId == SID_OBJECT_TOP )
     134         [ #  # ]:          0 :                                 pDrView->MoveMarkedObj( Size( 0, nNewVal - aRect.Top() ) );
     135         [ #  # ]:          0 :                             else if ( nSlotId == SID_OBJECT_WIDTH )
     136                 :            :                                 pDrView->ResizeMarkedObj( aRect.TopLeft(),
     137                 :            :                                                 Fraction( nNewVal, aRect.GetWidth() ),
     138 [ #  # ][ #  # ]:          0 :                                                 Fraction( 1, 1 ) );
         [ #  # ][ #  # ]
     139                 :            :                             else // if ( nSlotId == SID_OBJECT_HEIGHT )
     140                 :            :                                 pDrView->ResizeMarkedObj( aRect.TopLeft(),
     141                 :            :                                                 Fraction( 1, 1 ),
     142 [ #  # ][ #  # ]:          0 :                                                 Fraction( nNewVal, aRect.GetHeight() ) );
         [ #  # ][ #  # ]
     143                 :          0 :                             bDone = sal_True;
     144                 :            :                         }
     145                 :            :                     }
     146                 :            :                 }
     147                 :            : #ifndef DISABLE_SCRIPTING
     148         [ #  # ]:          0 :                 if (!bDone)
     149         [ #  # ]:          0 :                     SbxBase::SetError( SbxERR_BAD_PARAMETER );  // Basic-Fehler
     150                 :            : #endif
     151                 :            :             }
     152                 :          0 :             break;
     153                 :            : 
     154                 :            :     }
     155                 :          0 : }
     156                 :            : 
     157                 :          0 : uno::Reference < embed::XEmbeddedObject > lcl_GetSelectedObj( SdrView* pDrView )       //! Member von ScDrawView?
     158                 :            : {
     159                 :          0 :     uno::Reference < embed::XEmbeddedObject > xRet;
     160         [ #  # ]:          0 :     if (pDrView)
     161                 :            :     {
     162                 :          0 :         const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
     163         [ #  # ]:          0 :         if (rMarkList.GetMarkCount() == 1)
     164                 :            :         {
     165 [ #  # ][ #  # ]:          0 :             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     166 [ #  # ][ #  # ]:          0 :             if (pObj->GetObjIdentifier() == OBJ_OLE2)
     167                 :            :             {
     168                 :          0 :                 SdrOle2Obj* pOle2Obj = (SdrOle2Obj*) pObj;
     169 [ #  # ][ #  # ]:          0 :                 xRet = pOle2Obj->GetObjRef();
     170                 :            :             }
     171                 :            :         }
     172                 :            :     }
     173                 :            : 
     174                 :          0 :     return xRet;
     175                 :            : }
     176                 :            : 
     177                 :          0 : void ScTabViewShell::GetObjectState( SfxItemSet& rSet )
     178                 :            : {
     179                 :            :     //  SID_OLE_OBJECT - removed (old Basic)
     180                 :            : 
     181         [ #  # ]:          0 :     SfxWhichIter aIter(rSet);
     182         [ #  # ]:          0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     183         [ #  # ]:          0 :     while ( nWhich )
     184                 :            :     {
     185      [ #  #  # ]:          0 :         switch (nWhich)
     186                 :            :         {
     187                 :            :             case SID_ACTIVE_OBJ_NAME:
     188                 :            :                 {
     189         [ #  # ]:          0 :                     String aName;
     190 [ #  # ][ #  # ]:          0 :                     uno::Reference < embed::XEmbeddedObject > xOLE = lcl_GetSelectedObj( GetSdrView() );
     191         [ #  # ]:          0 :                     if (xOLE.is())
     192                 :            :                     {
     193 [ #  # ][ #  # ]:          0 :                         aName = GetViewData()->GetSfxDocShell()->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xOLE );
         [ #  # ][ #  # ]
     194                 :            :                     }
     195 [ #  # ][ #  # ]:          0 :                     rSet.Put( SfxStringItem( nWhich, aName ) );
         [ #  # ][ #  # ]
     196                 :            :                 }
     197                 :          0 :                 break;
     198                 :            :             case SID_OBJECT_LEFT:
     199                 :            :             case SID_OBJECT_TOP:
     200                 :            :             case SID_OBJECT_WIDTH:
     201                 :            :             case SID_OBJECT_HEIGHT:
     202                 :            :                 {
     203         [ #  # ]:          0 :                     SdrView* pDrView = GetSdrView();
     204         [ #  # ]:          0 :                     if ( pDrView )
     205                 :            :                     {
     206                 :          0 :                         const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
     207         [ #  # ]:          0 :                         if (rMarkList.GetMarkCount() == 1)
     208                 :            :                         {
     209 [ #  # ][ #  # ]:          0 :                             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     210         [ #  # ]:          0 :                             Rectangle aRect = pObj->GetLogicRect();
     211                 :            : 
     212                 :            :                             long nVal;
     213         [ #  # ]:          0 :                             if ( nWhich == SID_OBJECT_LEFT )
     214                 :          0 :                                 nVal = aRect.Left();
     215         [ #  # ]:          0 :                             else if ( nWhich == SID_OBJECT_TOP )
     216                 :          0 :                                 nVal = aRect.Top();
     217         [ #  # ]:          0 :                             else if ( nWhich == SID_OBJECT_WIDTH )
     218         [ #  # ]:          0 :                                 nVal = aRect.GetWidth();
     219                 :            :                             else // if ( nWhich == SID_OBJECT_HEIGHT )
     220         [ #  # ]:          0 :                                 nVal = aRect.GetHeight();
     221                 :            : 
     222                 :            :                             //! von 1/100mm in irgendwas umrechnen ??????
     223                 :            : 
     224 [ #  # ][ #  # ]:          0 :                             rSet.Put( SfxInt32Item( nWhich, nVal ) );
                 [ #  # ]
     225                 :            :                         }
     226                 :            :                     }
     227                 :            :                 }
     228                 :          0 :                 break;
     229                 :            :         }
     230         [ #  # ]:          0 :         nWhich = aIter.NextWhich();
     231         [ #  # ]:          0 :     }
     232                 :          0 : }
     233                 :            : 
     234                 :         21 : void ScTabViewShell::AddAccessibilityObject( SfxListener& rObject )
     235                 :            : {
     236         [ +  + ]:         21 :     if (!pAccessibilityBroadcaster)
     237         [ +  - ]:          5 :         pAccessibilityBroadcaster = new SfxBroadcaster;
     238                 :            : 
     239                 :         21 :     rObject.StartListening( *pAccessibilityBroadcaster );
     240                 :         21 :     ScDocument* pDoc = GetViewData()->GetDocument();
     241         [ +  - ]:         21 :     if (pDoc)
     242                 :         21 :         pDoc->AddUnoObject(rObject);
     243                 :         21 : }
     244                 :            : 
     245                 :         21 : void ScTabViewShell::RemoveAccessibilityObject( SfxListener& rObject )
     246                 :            : {
     247         [ +  - ]:         21 :     if (pAccessibilityBroadcaster)
     248                 :            :     {
     249                 :         21 :         rObject.EndListening( *pAccessibilityBroadcaster );
     250                 :         21 :         ScDocument* pDoc = GetViewData()->GetDocument();
     251         [ +  - ]:         21 :         if (pDoc)
     252                 :         21 :             pDoc->RemoveUnoObject(rObject);
     253                 :            :     }
     254                 :            :     else
     255                 :            :     {
     256                 :            :         OSL_FAIL("kein Accessibility-Broadcaster?");
     257                 :            :     }
     258                 :         21 : }
     259                 :            : 
     260                 :         11 : void ScTabViewShell::BroadcastAccessibility( const SfxHint &rHint )
     261                 :            : {
     262         [ +  - ]:         11 :     if (pAccessibilityBroadcaster)
     263                 :         11 :         pAccessibilityBroadcaster->Broadcast( rHint );
     264                 :         11 : }
     265                 :            : 
     266                 :       3071 : sal_Bool ScTabViewShell::HasAccessibilityObjects()
     267                 :            : {
     268                 :       3071 :     return pAccessibilityBroadcaster != NULL;
     269                 :            : }
     270                 :            : 
     271                 :          0 : bool ScTabViewShell::ExecuteRetypePassDlg(ScPasswordHash eDesiredHash)
     272                 :            : {
     273                 :            :     using ::std::auto_ptr;
     274                 :            : 
     275         [ #  # ]:          0 :     ScDocument* pDoc = GetViewData()->GetDocument();
     276                 :            : 
     277 [ #  # ][ #  # ]:          0 :     auto_ptr<ScRetypePassDlg> pDlg(new ScRetypePassDlg(GetDialogParent()));
                 [ #  # ]
     278         [ #  # ]:          0 :     pDlg->SetDataFromDocument(*pDoc);
     279         [ #  # ]:          0 :     pDlg->SetDesiredHash(eDesiredHash);
     280 [ #  # ][ #  # ]:          0 :     if (pDlg->Execute() != RET_OK)
     281                 :          0 :         return false;
     282                 :            : 
     283         [ #  # ]:          0 :     pDlg->WriteNewDataToDocument(*pDoc);
     284         [ #  # ]:          0 :     return true;
     285                 :            : }
     286                 :            : 
     287                 :            : 
     288                 :            : 
     289                 :            : 
     290                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10