1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <sfx2/dispatch.hxx>
22 #include <sfx2/viewfrm.hxx>
26 #include "tabvwsh.hxx"
28 #include "reffact.hxx"
29 #include "document.hxx"
30 #include "scresid.hxx"
31 #include "drawview.hxx"
32 #include "markdata.hxx"
34 //------------------------------------------------------------------
36 /*************************************************************************
38 |* Funktion zum Aufziehen eines Rechtecks
40 \************************************************************************/
42 FuMarkRect::FuMarkRect(ScTabViewShell
* pViewSh
, Window
* pWin
, ScDrawView
* pViewP
,
43 SdrModel
* pDoc
, SfxRequest
& rReq
) :
44 FuPoor(pViewSh
, pWin
, pViewP
, pDoc
, rReq
),
50 /*************************************************************************
54 \************************************************************************/
56 FuMarkRect::~FuMarkRect()
60 /*************************************************************************
62 |* MouseButtonDown-event
64 \************************************************************************/
66 sal_Bool
FuMarkRect::MouseButtonDown(const MouseEvent
& rMEvt
)
68 // remember button state for creation of own MouseEvents
69 SetMouseButtonCode(rMEvt
.GetButtons());
71 pWindow
->CaptureMouse();
72 pView
->UnmarkAll(); // der Einheitlichkeit halber und wegen #50558#
73 bStartDrag
= sal_True
;
75 aBeginPos
= pWindow
->PixelToLogic( rMEvt
.GetPosPixel() );
76 aZoomRect
= Rectangle( aBeginPos
, Size() );
80 /*************************************************************************
84 \************************************************************************/
86 sal_Bool
FuMarkRect::MouseMove(const MouseEvent
& rMEvt
)
91 pViewShell
->DrawMarkRect(aZoomRect
);
92 Point aPixPos
= rMEvt
.GetPosPixel();
95 Point aEndPos
= pWindow
->PixelToLogic(aPixPos
);
96 Rectangle
aRect(aBeginPos
, aEndPos
);
99 pViewShell
->DrawMarkRect(aZoomRect
);
103 ForcePointer(&rMEvt
);
108 /*************************************************************************
110 |* MouseButtonUp-event
112 \************************************************************************/
114 sal_Bool
FuMarkRect::MouseButtonUp(const MouseEvent
& rMEvt
)
116 // remember button state for creation of own MouseEvents
117 SetMouseButtonCode(rMEvt
.GetButtons());
122 pViewShell
->DrawMarkRect(aZoomRect
);
126 Size aZoomSizePixel
= pWindow
->LogicToPixel(aZoomRect
).GetSize();
128 sal_uInt16 nMinMove
= pView
->GetMinMoveDistancePixel();
129 if ( aZoomSizePixel
.Width() < nMinMove
|| aZoomSizePixel
.Height() < nMinMove
)
131 // Klick auf der Stelle
133 aZoomRect
.SetSize(Size()); // dann ganz leer
137 pWindow
->ReleaseMouse();
139 pViewShell
->GetViewData()->GetDispatcher().
140 Execute(aSfxRequest
.GetSlot(), SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
);
142 // Daten an der View merken
144 pViewShell
->SetChartArea( aSourceRange
, aZoomRect
);
146 // Chart-Dialog starten:
148 // sal_uInt16 nId = ScChartDlgWrapper::GetChildWindowId();
149 // SfxChildWindow* pWnd = pViewShell->GetViewFrame()->GetChildWindow( nId );
150 // SC_MOD()->SetRefDialog( nId, pWnd ? sal_False : sal_True );
155 /*************************************************************************
159 \************************************************************************/
161 sal_uInt8
FuMarkRect::Command(const CommandEvent
& rCEvt
)
163 if ( COMMAND_STARTDRAG
== rCEvt
.GetCommand() )
165 // nicht anfangen, auf der Tabelle rumzudraggen,
166 // aber Maus-Status nicht zuruecksetzen
167 return SC_CMD_IGNORE
;
170 return FuPoor::Command(rCEvt
);
173 /*************************************************************************
175 |* Tastaturereignisse bearbeiten
177 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
180 \************************************************************************/
182 sal_Bool
FuMarkRect::KeyInput(const KeyEvent
& rKEvt
)
184 sal_Bool bReturn
= false;
186 switch ( rKEvt
.GetKeyCode().GetCode() )
190 pViewShell
->GetViewData()->GetDispatcher().
191 Execute(aSfxRequest
.GetSlot(), SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
198 bReturn
= FuPoor::KeyInput(rKEvt
);
204 /*************************************************************************
206 |* Function aktivieren
208 \************************************************************************/
210 void FuMarkRect::Activate()
214 // Markierung merken, bevor evtl. Tabelle umgeschaltet wird
216 ScViewData
* pViewData
= pViewShell
->GetViewData();
217 ScMarkData
& rMark
= pViewData
->GetMarkData();
219 if ( !rMark
.IsMultiMarked() && !rMark
.IsMarked() )
220 pViewShell
->MarkDataArea( sal_True
);
222 pViewData
->GetMultiArea( aSourceRange
); // Mehrfachselektion erlaubt
224 // pViewShell->Unmark();
229 /*************************************************************************
231 |* Function deaktivieren
233 \************************************************************************/
235 void FuMarkRect::Deactivate()
237 FuPoor::Deactivate();
242 pViewShell
->DrawMarkRect(aZoomRect
);
248 /*************************************************************************
250 |* Maus-Pointer umschalten
252 \************************************************************************/
254 void FuMarkRect::ForcePointer(const MouseEvent
* /* pMEvt */)
256 pViewShell
->SetActivePointer( Pointer( POINTER_CHART
) );
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */