LCOV - code coverage report
Current view: top level - sd/source/ui/func - fuscale.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 66 1.5 %
Date: 2015-06-13 12:38:46 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"
      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             : #include <boost/scoped_ptr.hpp>
      43             : 
      44             : namespace sd {
      45             : 
      46           0 : TYPEINIT1( FuScale, FuPoor );
      47             : 
      48           0 : FuScale::FuScale (
      49             :     ViewShell* pViewSh,
      50             :     ::sd::Window* pWin,
      51             :     ::sd::View* pView,
      52             :     SdDrawDocument* pDoc,
      53             :     SfxRequest& rReq)
      54           0 :     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
      55             : {
      56           0 : }
      57             : 
      58           0 : rtl::Reference<FuPoor> FuScale::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      59             : {
      60           0 :     rtl::Reference<FuPoor> xFunc( new FuScale( pViewSh, pWin, pView, pDoc, rReq ) );
      61           0 :     xFunc->DoExecute(rReq);
      62           0 :     return xFunc;
      63             : }
      64             : 
      65           0 : void FuScale::DoExecute( SfxRequest& rReq )
      66             : {
      67             :     sal_Int16 nValue;
      68             : 
      69           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
      70             : 
      71           0 :     if( !pArgs )
      72             :     {
      73           0 :         SfxItemSet aNewAttr( mpDoc->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM );
      74           0 :         boost::scoped_ptr<SvxZoomItem> pZoomItem;
      75           0 :         SvxZoomEnableFlags nZoomValues = SvxZoomEnableFlags::ALL;
      76             : 
      77           0 :         nValue = (sal_Int16) mpWindow->GetZoom();
      78             : 
      79             :         // zoom on page size?
      80           0 :         if( mpViewShell && mpViewShell->ISA( DrawViewShell ) &&
      81           0 :             static_cast<DrawViewShell*>(mpViewShell)->IsZoomOnPage() )
      82             :         {
      83           0 :             pZoomItem.reset(new SvxZoomItem( SvxZoomType::WHOLEPAGE, nValue ));
      84             :         }
      85             :         else
      86             :         {
      87           0 :             pZoomItem.reset(new SvxZoomItem( SvxZoomType::PERCENT, nValue ));
      88             :         }
      89             : 
      90             :         // limit range
      91           0 :         if( mpViewShell )
      92             :         {
      93           0 :             if( mpViewShell->ISA( DrawViewShell ) )
      94             :             {
      95           0 :                 SdrPageView* pPageView = mpView->GetSdrPageView();
      96           0 :                 if( ( pPageView && pPageView->GetObjList()->GetObjCount() == 0 ) )
      97             :                     // || ( mpView->GetMarkedObjectList().GetMarkCount() == 0 ) )
      98             :                 {
      99           0 :                     nZoomValues &= ~SvxZoomEnableFlags::OPTIMAL;
     100             :                 }
     101             :             }
     102           0 :             else if( mpViewShell->ISA( OutlineViewShell ) )
     103             :             {
     104           0 :                 nZoomValues &= ~SvxZoomEnableFlags::OPTIMAL;
     105           0 :                 nZoomValues &= ~SvxZoomEnableFlags::WHOLEPAGE;
     106           0 :                 nZoomValues &= ~SvxZoomEnableFlags::PAGEWIDTH;
     107             :             }
     108             :         }
     109             : 
     110           0 :         pZoomItem->SetValueSet( nZoomValues );
     111           0 :         aNewAttr.Put( *pZoomItem );
     112             : 
     113           0 :         boost::scoped_ptr<AbstractSvxZoomDialog> pDlg;
     114           0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     115           0 :         if(pFact)
     116             :         {
     117           0 :             pDlg.reset(pFact->CreateSvxZoomDialog(NULL, aNewAttr));
     118             :         }
     119             : 
     120           0 :         if( pDlg )
     121             :         {
     122           0 :             pDlg->SetLimits( (sal_uInt16)mpWindow->GetMinZoom(), (sal_uInt16)mpWindow->GetMaxZoom() );
     123           0 :             sal_uInt16 nResult = pDlg->Execute();
     124           0 :             switch( nResult )
     125             :             {
     126             :                 case RET_CANCEL:
     127             :                 {
     128           0 :                     rReq.Ignore ();
     129           0 :                     return; // Cancel
     130             :                 }
     131             :                 default:
     132             :                 {
     133           0 :                     rReq.Ignore ();
     134             :                 }
     135           0 :                 break;
     136             :             }
     137             : 
     138           0 :             const SfxItemSet aArgs (*(pDlg->GetOutputItemSet ()));
     139             : 
     140           0 :             pDlg.reset();
     141             : 
     142           0 :             if (!mpViewShell)
     143           0 :                 return;
     144             : 
     145           0 :             switch (static_cast<const SvxZoomItem &>( aArgs.Get (SID_ATTR_ZOOM)).GetType ())
     146             :             {
     147             :                 case SvxZoomType::PERCENT:
     148             :                 {
     149           0 :                     nValue = static_cast<const SvxZoomItem &>( aArgs.Get (SID_ATTR_ZOOM)).GetValue ();
     150             : 
     151           0 :                     mpViewShell->SetZoom( nValue );
     152             : 
     153           0 :                     mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom );
     154             :                 }
     155           0 :                 break;
     156             : 
     157             :                 case SvxZoomType::OPTIMAL:
     158             :                 {
     159           0 :                     if( mpViewShell->ISA( DrawViewShell ) )
     160             :                     {
     161             :                         // name confusion: SID_SIZE_ALL -> zoom onto all objects
     162             :                         // --> the program offers it as optimal
     163           0 :                         mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_ALL, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
     164             :                     }
     165             :                 }
     166           0 :                 break;
     167             : 
     168             :                 case SvxZoomType::PAGEWIDTH:
     169           0 :                     mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE_WIDTH, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
     170           0 :                     break;
     171             : 
     172             :                 case SvxZoomType::WHOLEPAGE:
     173           0 :                     mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
     174           0 :                     break;
     175             :                 default:
     176           0 :                     break;
     177           0 :             }
     178           0 :         }
     179             :     }
     180           0 :     else if(mpViewShell && (pArgs->Count () == 1))
     181             :     {
     182           0 :         SFX_REQUEST_ARG (rReq, pScale, SfxUInt32Item, ID_VAL_ZOOM, false);
     183           0 :         mpViewShell->SetZoom (pScale->GetValue ());
     184             : 
     185           0 :         mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArrayZoom );
     186             :     }
     187             : 
     188             : }
     189             : 
     190          66 : } // end of namespace sd
     191             : 
     192             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11