1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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>
39 #include "tabvwsh.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
),
62 /*************************************************************************
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#
87 aBeginPos
= pWindow
->PixelToLogic( rMEvt
.GetPosPixel() );
88 aZoomRect
= Rectangle( aBeginPos
, Size() );
92 /*************************************************************************
96 \************************************************************************/
98 BOOL
FuMarkRect::MouseMove(const MouseEvent
& rMEvt
)
103 pViewShell
->DrawMarkRect(aZoomRect
);
104 Point aPixPos
= rMEvt
.GetPosPixel();
105 ForceScroll(aPixPos
);
107 Point aEndPos
= pWindow
->PixelToLogic(aPixPos
);
108 Rectangle
aRect(aBeginPos
, aEndPos
);
111 pViewShell
->DrawMarkRect(aZoomRect
);
115 ForcePointer(&rMEvt
);
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());
134 pViewShell
->DrawMarkRect(aZoomRect
);
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
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 );
167 /*************************************************************************
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
;
182 return FuPoor::Command(rCEvt
);
185 /*************************************************************************
187 |* Tastaturereignisse bearbeiten
189 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
192 \************************************************************************/
194 BOOL
FuMarkRect::KeyInput(const KeyEvent
& rKEvt
)
196 BOOL bReturn
= FALSE
;
198 switch ( rKEvt
.GetKeyCode().GetCode() )
202 pViewShell
->GetViewData()->GetDispatcher().
203 Execute(aSfxRequest
.GetSlot(), SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
210 bReturn
= FuPoor::KeyInput(rKEvt
);
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()
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();
261 /*************************************************************************
263 |* Function deaktivieren
265 \************************************************************************/
267 void FuMarkRect::Deactivate()
269 FuPoor::Deactivate();
274 pViewShell
->DrawMarkRect(aZoomRect
);
280 /*************************************************************************
282 |* Maus-Pointer umschalten
284 \************************************************************************/
286 void FuMarkRect::ForcePointer(const MouseEvent
* /* pMEvt */)
288 pViewShell
->SetActivePointer( Pointer( POINTER_CHART
) );