merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / drawfunc / fumark.cxx
blobb06f3cab199176445e9cd3ca191557d330c5c583
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fumark.cxx,v $
10 * $Revision: 1.9.128.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include <sfx2/dispatch.hxx>
35 #include <sfx2/viewfrm.hxx>
37 #include "fumark.hxx"
38 #include "sc.hrc"
39 #include "tabvwsh.hxx"
40 #include "scmod.hxx"
41 #include "reffact.hxx"
42 #include "document.hxx"
43 #include "scresid.hxx"
44 #include "drawview.hxx"
46 //------------------------------------------------------------------
48 /*************************************************************************
50 |* Funktion zum Aufziehen eines Rechtecks
52 \************************************************************************/
54 FuMarkRect::FuMarkRect(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
55 SdrModel* pDoc, SfxRequest& rReq) :
56 FuPoor(pViewSh, pWin, pViewP, pDoc, rReq),
57 bVisible(FALSE),
58 bStartDrag(FALSE)
62 /*************************************************************************
64 |* Destruktor
66 \************************************************************************/
68 FuMarkRect::~FuMarkRect()
72 /*************************************************************************
74 |* MouseButtonDown-event
76 \************************************************************************/
78 BOOL FuMarkRect::MouseButtonDown(const MouseEvent& rMEvt)
80 // #95491# remember button state for creation of own MouseEvents
81 SetMouseButtonCode(rMEvt.GetButtons());
83 pWindow->CaptureMouse();
84 pView->UnmarkAll(); // der Einheitlichkeit halber und wegen #50558#
85 bStartDrag = TRUE;
87 aBeginPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
88 aZoomRect = Rectangle( aBeginPos, Size() );
89 return TRUE;
92 /*************************************************************************
94 |* MouseMove-event
96 \************************************************************************/
98 BOOL FuMarkRect::MouseMove(const MouseEvent& rMEvt)
100 if ( bStartDrag )
102 if ( bVisible )
103 pViewShell->DrawMarkRect(aZoomRect);
104 Point aPixPos= rMEvt.GetPosPixel();
105 ForceScroll(aPixPos);
107 Point aEndPos = pWindow->PixelToLogic(aPixPos);
108 Rectangle aRect(aBeginPos, aEndPos);
109 aZoomRect = aRect;
110 aZoomRect.Justify();
111 pViewShell->DrawMarkRect(aZoomRect);
112 bVisible = TRUE;
115 ForcePointer(&rMEvt);
117 return bStartDrag;
120 /*************************************************************************
122 |* MouseButtonUp-event
124 \************************************************************************/
126 BOOL FuMarkRect::MouseButtonUp(const MouseEvent& rMEvt)
128 // #95491# remember button state for creation of own MouseEvents
129 SetMouseButtonCode(rMEvt.GetButtons());
131 if ( bVisible )
133 // Hide ZoomRect
134 pViewShell->DrawMarkRect(aZoomRect);
135 bVisible = FALSE;
138 Size aZoomSizePixel = pWindow->LogicToPixel(aZoomRect).GetSize();
140 USHORT nMinMove = pView->GetMinMoveDistancePixel();
141 if ( aZoomSizePixel.Width() < nMinMove || aZoomSizePixel.Height() < nMinMove )
143 // Klick auf der Stelle
145 aZoomRect.SetSize(Size()); // dann ganz leer
148 bStartDrag = FALSE;
149 pWindow->ReleaseMouse();
151 pViewShell->GetViewData()->GetDispatcher().
152 Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
154 // Daten an der View merken
156 pViewShell->SetChartArea( aSourceRange, aZoomRect );
158 // Chart-Dialog starten:
160 // USHORT nId = ScChartDlgWrapper::GetChildWindowId();
161 // SfxChildWindow* pWnd = pViewShell->GetViewFrame()->GetChildWindow( nId );
162 // SC_MOD()->SetRefDialog( nId, pWnd ? FALSE : TRUE );
164 return TRUE;
167 /*************************************************************************
169 |* Command-event
171 \************************************************************************/
173 BYTE FuMarkRect::Command(const CommandEvent& rCEvt)
175 if ( COMMAND_STARTDRAG == rCEvt.GetCommand() )
177 // #29877# nicht anfangen, auf der Tabelle rumzudraggen,
178 // aber Maus-Status nicht zuruecksetzen
179 return SC_CMD_IGNORE;
181 else
182 return FuPoor::Command(rCEvt);
185 /*************************************************************************
187 |* Tastaturereignisse bearbeiten
189 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
190 |* FALSE.
192 \************************************************************************/
194 BOOL FuMarkRect::KeyInput(const KeyEvent& rKEvt)
196 BOOL bReturn = FALSE;
198 switch ( rKEvt.GetKeyCode().GetCode() )
200 case KEY_ESCAPE:
201 // beenden
202 pViewShell->GetViewData()->GetDispatcher().
203 Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
204 bReturn = TRUE;
205 break;
208 if (!bReturn)
210 bReturn = FuPoor::KeyInput(rKEvt);
213 return (bReturn);
216 /*************************************************************************
218 |* Vor dem Scrollen Selektionsdarstellung ausblenden
220 \************************************************************************/
222 void FuMarkRect::ScrollStart()
226 /*************************************************************************
228 |* Nach dem Scrollen Selektionsdarstellung wieder anzeigen
230 \************************************************************************/
232 void FuMarkRect::ScrollEnd()
236 /*************************************************************************
238 |* Function aktivieren
240 \************************************************************************/
242 void FuMarkRect::Activate()
244 FuPoor::Activate();
246 // Markierung merken, bevor evtl. Tabelle umgeschaltet wird
248 ScViewData* pViewData = pViewShell->GetViewData();
249 ScMarkData& rMark = pViewData->GetMarkData();
251 if ( !rMark.IsMultiMarked() && !rMark.IsMarked() )
252 pViewShell->MarkDataArea( TRUE );
254 pViewData->GetMultiArea( aSourceRange ); // Mehrfachselektion erlaubt
256 // pViewShell->Unmark();
258 ForcePointer(NULL);
261 /*************************************************************************
263 |* Function deaktivieren
265 \************************************************************************/
267 void FuMarkRect::Deactivate()
269 FuPoor::Deactivate();
271 if (bVisible)
273 // Hide ZoomRect
274 pViewShell->DrawMarkRect(aZoomRect);
275 bVisible = FALSE;
276 bStartDrag = FALSE;
280 /*************************************************************************
282 |* Maus-Pointer umschalten
284 \************************************************************************/
286 void FuMarkRect::ForcePointer(const MouseEvent* /* pMEvt */)
288 pViewShell->SetActivePointer( Pointer( POINTER_CHART ) );