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 : :
30 : : #include "Ruler.hxx"
31 : : #include <svl/ptitem.hxx>
32 : : #include <svx/ruler.hxx>
33 : : #include <svx/svxids.hrc>
34 : : #include <sfx2/ctrlitem.hxx>
35 : : #include <sfx2/bindings.hxx>
36 : :
37 : :
38 : : #include "View.hxx"
39 : : #include "DrawViewShell.hxx"
40 : : #include "Window.hxx"
41 : :
42 : : #include "helpids.h"
43 : :
44 : : namespace sd {
45 : :
46 : : /*************************************************************************
47 : : |*
48 : : |* Controller-Item fuer Ruler
49 : : |*
50 : : \************************************************************************/
51 : :
52 [ - + ]: 416 : class RulerCtrlItem : public SfxControllerItem
53 : : {
54 : : Ruler &rRuler;
55 : :
56 : : protected:
57 : : virtual void StateChanged( sal_uInt16 nSId, SfxItemState eState,
58 : : const SfxPoolItem* pItem );
59 : :
60 : : public:
61 : : RulerCtrlItem(sal_uInt16 nId, Ruler& rRlr, SfxBindings& rBind);
62 : : };
63 : :
64 : 208 : RulerCtrlItem::RulerCtrlItem(sal_uInt16 _nId, Ruler& rRlr, SfxBindings& rBind)
65 : : : SfxControllerItem(_nId, rBind)
66 : 208 : , rRuler(rRlr)
67 : : {
68 : 208 : }
69 : :
70 : 114 : void RulerCtrlItem::StateChanged( sal_uInt16 nSId, SfxItemState, const SfxPoolItem* pState )
71 : : {
72 [ + - ]: 114 : switch( nSId )
73 : : {
74 : : case SID_RULER_NULL_OFFSET:
75 : : {
76 [ - + ]: 114 : const SfxPointItem* pItem = dynamic_cast< const SfxPointItem* >(pState);
77 : : DBG_ASSERT(pState ? pItem != NULL : sal_True, "SfxPointItem erwartet");
78 [ + - ]: 114 : if ( pItem )
79 : 114 : rRuler.SetNullOffset(pItem->GetValue());
80 : : }
81 : 114 : break;
82 : : }
83 : 114 : }
84 : :
85 : :
86 : : /*************************************************************************
87 : : |*
88 : : |* Konstruktor
89 : : |*
90 : : \************************************************************************/
91 : :
92 : 208 : Ruler::Ruler( DrawViewShell& rViewSh, ::Window* pParent, ::sd::Window* pWin, sal_uInt16 nRulerFlags, SfxBindings& rBindings, WinBits nWinStyle)
93 : : : SvxRuler(pParent, pWin, nRulerFlags, rBindings, nWinStyle)
94 : : , pSdWin(pWin)
95 : 208 : , pDrViewShell(&rViewSh)
96 : : {
97 [ + - ]: 208 : rBindings.EnterRegistrations();
98 [ + - ][ + - ]: 208 : pCtrlItem = new RulerCtrlItem(SID_RULER_NULL_OFFSET, *this, rBindings);
99 [ + - ]: 208 : rBindings.LeaveRegistrations();
100 : :
101 [ + + ]: 208 : if ( nWinStyle & WB_HSCROLL )
102 : : {
103 : 104 : bHorz = sal_True;
104 [ + - ]: 104 : SetHelpId( HID_SD_RULER_HORIZONTAL );
105 : : }
106 : : else
107 : : {
108 : 104 : bHorz = sal_False;
109 [ + - ]: 104 : SetHelpId( HID_SD_RULER_VERTICAL );
110 : : }
111 : 208 : }
112 : :
113 : : /*************************************************************************
114 : : |*
115 : : |* Destruktor
116 : : |*
117 : : \************************************************************************/
118 : :
119 : 208 : Ruler::~Ruler()
120 : : {
121 : 208 : SfxBindings& rBindings = pCtrlItem->GetBindings();
122 [ + - ]: 208 : rBindings.EnterRegistrations();
123 [ + - ][ + - ]: 208 : delete pCtrlItem;
124 [ + - ]: 208 : rBindings.LeaveRegistrations();
125 [ - + ]: 416 : }
126 : :
127 : : /*************************************************************************
128 : : |*
129 : : |* MouseButtonDown-Handler
130 : : |*
131 : : \************************************************************************/
132 : :
133 : 0 : void Ruler::MouseButtonDown(const MouseEvent& rMEvt)
134 : : {
135 : 0 : Point aMPos = rMEvt.GetPosPixel();
136 [ # # ]: 0 : RulerType eType = GetType(aMPos);
137 : :
138 [ # # ][ # # : 0 : if ( !pDrViewShell->GetView()->IsTextEdit() &&
# # # # ]
[ # # ][ # # ]
[ # # ]
139 : 0 : rMEvt.IsLeft() && rMEvt.GetClicks() == 1 &&
140 : : (eType == RULER_TYPE_DONTKNOW || eType == RULER_TYPE_OUTSIDE) )
141 : : {
142 [ # # ]: 0 : pDrViewShell->StartRulerDrag(*this, rMEvt);
143 : : }
144 : : else
145 [ # # ]: 0 : SvxRuler::MouseButtonDown(rMEvt);
146 : 0 : }
147 : :
148 : : /*************************************************************************
149 : : |*
150 : : |* MouseMove-Handler
151 : : |*
152 : : \************************************************************************/
153 : :
154 : 0 : void Ruler::MouseMove(const MouseEvent& rMEvt)
155 : : {
156 : 0 : SvxRuler::MouseMove(rMEvt);
157 : 0 : }
158 : :
159 : : /*************************************************************************
160 : : |*
161 : : |* MouseButtonUp-Handler
162 : : |*
163 : : \************************************************************************/
164 : :
165 : 0 : void Ruler::MouseButtonUp(const MouseEvent& rMEvt)
166 : : {
167 : 0 : SvxRuler::MouseButtonUp(rMEvt);
168 : 0 : }
169 : :
170 : : /*************************************************************************
171 : : |*
172 : : |* NullOffset setzen
173 : : |*
174 : : \************************************************************************/
175 : :
176 : 114 : void Ruler::SetNullOffset(const Point& rOffset)
177 : : {
178 : : long nOffset;
179 : :
180 [ + + ]: 114 : if ( bHorz ) nOffset = rOffset.X();
181 : 57 : else nOffset = rOffset.Y();
182 : :
183 : 114 : SetNullOffsetLogic(nOffset);
184 : 114 : }
185 : :
186 : : /*************************************************************************
187 : : |*
188 : : |* Command event
189 : : |*
190 : : \************************************************************************/
191 : :
192 : 0 : void Ruler::Command(const CommandEvent& rCEvt)
193 : : {
194 [ # # # # ]: 0 : if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU &&
[ # # ]
195 : 0 : !pDrViewShell->GetView()->IsTextEdit() )
196 : : {
197 : 0 : SvxRuler::Command( rCEvt );
198 : : }
199 : 0 : }
200 : :
201 : : /*************************************************************************
202 : : |*
203 : : |* ExtraDown
204 : : |*
205 : : \************************************************************************/
206 : :
207 : 0 : void Ruler::ExtraDown()
208 : : {
209 [ # # ]: 0 : if( !pDrViewShell->GetView()->IsTextEdit() )
210 : 0 : SvxRuler::ExtraDown();
211 : 0 : }
212 : :
213 : : } // end of namespace sd
214 : :
215 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|