LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/func - fuscale.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 65 1.5 %
Date: 2013-07-09 Functions: 2 10 20.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 "fuscale.hxx"
      21             : 
      22             : #include <svx/dialogs.hrc>
      23             : 
      24             : #include "app.hrc"
      25             : #include "View.hxx"
      26             : #include "Window.hxx"
      27             : #include "OutlineViewShell.hxx"
      28             : #include "drawview.hxx"
      29             : #include "drawdoc.hxx"
      30             : #include "DrawViewShell.hxx"
      31             : #include "ViewShell.hxx"
      32             : #include "fuzoom.hxx" // because of SidArrayZoom[]
      33             : 
      34             : #include <vcl/msgbox.hxx>
      35             : #include <svx/svdpagv.hxx>
      36             : #include <sfx2/viewfrm.hxx>
      37             : #include <sfx2/dispatch.hxx>
      38             : #include <svx/zoom_def.hxx>
      39             : #include <sfx2/zoomitem.hxx>
      40             : #include <sfx2/request.hxx>
      41             : #include <svx/svxdlg.hxx>
      42             : 
      43             : namespace sd {
      44             : 
      45           0 : TYPEINIT1( FuScale, FuPoor );
      46             : 
      47           0 : FuScale::FuScale (
      48             :     ViewShell* pViewSh,
      49             :     ::sd::Window* pWin,
      50             :     ::sd::View* pView,
      51             :     SdDrawDocument* pDoc,
      52             :     SfxRequest& rReq)
      53           0 :     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
      54             : {
      55           0 : }
      56             : 
      57           0 : FunctionReference FuScale::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      58             : {
      59           0 :     FunctionReference xFunc( new FuScale( pViewSh, pWin, pView, pDoc, rReq ) );
      60           0 :     xFunc->DoExecute(rReq);
      61           0 :     return xFunc;
      62             : }
      63             : 
      64           0 : void FuScale::DoExecute( SfxRequest& rReq )
      65             : {
      66             :     sal_Int16 nValue;
      67             : 
      68           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
      69             : 
      70           0 :     if( !pArgs )
      71             :     {
      72           0 :         SfxItemSet aNewAttr( mpDoc->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM );
      73             :         SvxZoomItem* pZoomItem;
      74           0 :         sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL;
      75             : 
      76           0 :         nValue = (sal_Int16) mpWindow->GetZoom();
      77             : 
      78             :         // zoom on page size?
      79           0 :         if( mpViewShell && mpViewShell->ISA( DrawViewShell ) &&
      80           0 :             static_cast<DrawViewShell*>(mpViewShell)->IsZoomOnPage() )
      81             :         {
      82           0 :             pZoomItem = new SvxZoomItem( SVX_ZOOM_WHOLEPAGE, nValue );
      83             :         }
      84             :         else
      85             :         {
      86           0 :             pZoomItem = new SvxZoomItem( SVX_ZOOM_PERCENT, nValue );
      87             :         }
      88             : 
      89             :         // limit range
      90           0 :         if( mpViewShell )
      91             :         {
      92           0 :             if( mpViewShell->ISA( DrawViewShell ) )
      93             :             {
      94           0 :                 SdrPageView* pPageView = mpView->GetSdrPageView();
      95           0 :                 if( ( pPageView && pPageView->GetObjList()->GetObjCount() == 0 ) )
      96             :                     // || ( mpView->GetMarkedObjectList().GetMarkCount() == 0 ) )
      97             :                 {
      98           0 :                     nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
      99             :                 }
     100             :             }
     101           0 :             else if( mpViewShell->ISA( OutlineViewShell ) )
     102             :             {
     103           0 :                 nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
     104           0 :                 nZoomValues &= ~SVX_ZOOM_ENABLE_WHOLEPAGE;
     105           0 :                 nZoomValues &= ~SVX_ZOOM_ENABLE_PAGEWIDTH;
     106             :             }
     107             :         }
     108             : 
     109           0 :         pZoomItem->SetValueSet( nZoomValues );
     110           0 :         aNewAttr.Put( *pZoomItem );
     111             : 
     112           0 :         AbstractSvxZoomDialog* pDlg=NULL;
     113           0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     114           0 :         if(pFact)
     115             :         {
     116           0 :             pDlg = pFact->CreateSvxZoomDialog(NULL, aNewAttr);
     117             :         }
     118             : 
     119           0 :         if( pDlg )
     120             :         {
     121           0 :             pDlg->SetLimits( (sal_uInt16)mpWindow->GetMinZoom(), (sal_uInt16)mpWindow->GetMaxZoom() );
     122           0 :             sal_uInt16 nResult = pDlg->Execute();
     123           0 :             switch( nResult )
     124             :             {
     125             :                 case RET_CANCEL:
     126             :                 {
     127           0 :                     delete pDlg;
     128           0 :                     delete pZoomItem;
     129           0 :                     rReq.Ignore ();
     130           0 :                     return; // Cancel
     131             :                 }
     132             :                 default:
     133             :                 {
     134           0 :                     rReq.Ignore ();
     135             :         /*
     136             :                         rReq.Done( *( pDlg->GetOutputItemSet() ) );
     137             :                         pArgs = rReq.GetArgs();*/
     138             :                 }
     139           0 :                 break;
     140             :             }
     141             : 
     142           0 :             const SfxItemSet aArgs (*(pDlg->GetOutputItemSet ()));
     143             : 
     144           0 :             delete pDlg;
     145             : 
     146           0 :             switch (((const SvxZoomItem &) aArgs.Get (SID_ATTR_ZOOM)).GetType ())
     147             :             {
     148             :                 case SVX_ZOOM_PERCENT:
     149             :                 {
     150           0 :                     nValue = ((const SvxZoomItem &) aArgs.Get (SID_ATTR_ZOOM)).GetValue ();
     151             : 
     152           0 :                     mpViewShell->SetZoom( nValue );
     153             : 
     154           0 :                     mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom );
     155             :                 }
     156           0 :                 break;
     157             : 
     158             :                 case SVX_ZOOM_OPTIMAL:
     159             :                 {
     160           0 :                     if( mpViewShell->ISA( DrawViewShell ) )
     161             :                     {
     162             :                         // name confusion: SID_SIZE_ALL -> zoom onto all objects
     163             :                         // --> the program offers it as optimal
     164           0 :                         mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_ALL, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
     165             :                     }
     166             :                 }
     167           0 :                 break;
     168             : 
     169             :                 case SVX_ZOOM_PAGEWIDTH:
     170           0 :                     mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE_WIDTH, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
     171           0 :                     break;
     172             : 
     173             :                 case SVX_ZOOM_WHOLEPAGE:
     174           0 :                     mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
     175           0 :                     break;
     176             :                 default:
     177           0 :                     break;
     178           0 :             }
     179             :         }
     180             : 
     181           0 :         delete pZoomItem;
     182             :     }
     183           0 :     else if(mpViewShell && (pArgs->Count () == 1))
     184             :     {
     185           0 :         SFX_REQUEST_ARG (rReq, pScale, SfxUInt32Item, ID_VAL_ZOOM, sal_False);
     186           0 :         mpViewShell->SetZoom (pScale->GetValue ());
     187             : 
     188           0 :         mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom );
     189             :     }
     190             : 
     191             : }
     192             : 
     193          33 : } // end of namespace sd
     194             : 
     195             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10