LCOV - code coverage report
Current view: top level - sd/source/ui/view - zoomlist.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 20 37 54.1 %
Date: 2015-06-13 12:38:46 Functions: 6 8 75.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 "zoomlist.hxx"
      21             : 
      22             : #include <svx/svxids.hrc>
      23             : #include <sfx2/bindings.hxx>
      24             : #include <sfx2/viewfrm.hxx>
      25             : #include <sfx2/viewsh.hxx>
      26             : 
      27             : #include "ViewShell.hxx"
      28             : 
      29             : namespace sd {
      30             : 
      31             : #define MAX_ENTRYS  10
      32             : 
      33         197 : ZoomList::ZoomList(ViewShell* pViewShell)
      34             : : mpViewShell (pViewShell)
      35         197 : , mnCurPos(0)
      36             : {
      37         197 : }
      38             : 
      39         427 : void ZoomList::InsertZoomRect(const Rectangle& rRect)
      40             : {
      41         427 :     size_t nRectCount = maRectangles.size();
      42             : 
      43         427 :     if (nRectCount >= MAX_ENTRYS)
      44           0 :         maRectangles.erase(maRectangles.begin());
      45         427 :     else if (nRectCount == 0)
      46         133 :         mnCurPos = 0;
      47             :     else
      48         294 :         mnCurPos++;
      49             : 
      50         427 :     maRectangles.insert(maRectangles.begin()+mnCurPos,rRect);
      51             : 
      52         427 :     SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
      53         427 :     rBindings.Invalidate( SID_ZOOM_NEXT );
      54         427 :     rBindings.Invalidate( SID_ZOOM_PREV );
      55         427 : }
      56             : 
      57           0 : Rectangle ZoomList::GetNextZoomRect()
      58             : {
      59           0 :     mnCurPos++;
      60           0 :     size_t nRectCount = maRectangles.size();
      61             : 
      62           0 :     if (nRectCount > 0 && mnCurPos > nRectCount - 1)
      63           0 :         mnCurPos = nRectCount - 1;
      64             : 
      65           0 :     SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
      66           0 :     rBindings.Invalidate( SID_ZOOM_NEXT );
      67           0 :     rBindings.Invalidate( SID_ZOOM_PREV );
      68             : 
      69           0 :     return maRectangles[mnCurPos];
      70             : }
      71             : 
      72           0 : Rectangle ZoomList::GetPreviousZoomRect()
      73             : {
      74           0 :     if (mnCurPos > 0)
      75           0 :         mnCurPos--;
      76             : 
      77           0 :     SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
      78           0 :     rBindings.Invalidate( SID_ZOOM_NEXT );
      79           0 :     rBindings.Invalidate( SID_ZOOM_PREV );
      80             : 
      81           0 :     return maRectangles[mnCurPos];
      82             : }
      83             : 
      84        4175 : bool ZoomList::IsNextPossible() const
      85             : {
      86        4175 :     size_t nRectCount = maRectangles.size();
      87             : 
      88        4175 :     return nRectCount > 0 && mnCurPos < nRectCount - 1;
      89             : }
      90             : 
      91        4175 : bool ZoomList::IsPreviousPossible() const
      92             : {
      93        4175 :     return mnCurPos > 0;
      94             : }
      95             : 
      96          66 : } // end of namespace sd
      97             : 
      98             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11