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 338 : ZoomList::ZoomList(ViewShell* pViewShell)
34 : : mpViewShell (pViewShell)
35 338 : , mnCurPos(0)
36 : {
37 338 : }
38 :
39 726 : void ZoomList::InsertZoomRect(const Rectangle& rRect)
40 : {
41 726 : size_t nRectCount = maRectangles.size();
42 :
43 726 : if (nRectCount >= MAX_ENTRYS)
44 0 : maRectangles.erase(maRectangles.begin());
45 726 : else if (nRectCount == 0)
46 212 : mnCurPos = 0;
47 : else
48 514 : mnCurPos++;
49 :
50 726 : maRectangles.insert(maRectangles.begin()+mnCurPos,rRect);
51 :
52 726 : SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
53 726 : rBindings.Invalidate( SID_ZOOM_NEXT );
54 726 : rBindings.Invalidate( SID_ZOOM_PREV );
55 726 : }
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 4221 : bool ZoomList::IsNextPossible() const
85 : {
86 4221 : size_t nRectCount = maRectangles.size();
87 :
88 4221 : return nRectCount > 0 && mnCurPos < nRectCount - 1;
89 : }
90 :
91 4221 : bool ZoomList::IsPreviousPossible() const
92 : {
93 4221 : return mnCurPos > 0;
94 : }
95 :
96 114 : } // end of namespace sd
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|