LibreOffice Module sc (master) 1
fuconstr.cxx
Go to the documentation of this file.
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 <editeng/outlobj.hxx>
21#include <svx/svdotext.hxx>
22#include <svx/svdouno.hxx>
23#include <svx/svxids.hrc>
24#include <sfx2/dispatch.hxx>
25
26#include <fuconstr.hxx>
27#include <fudraw.hxx>
28#include <tabvwsh.hxx>
29#include <futext.hxx>
30#include <drawview.hxx>
31
32// maximal permitted mouse movement to start Drag&Drop
34#define SC_MAXDRAGMOVE 3
35
37 SdrModel* pDoc, const SfxRequest& rReq)
38 : FuDraw(rViewSh, pWin, pViewP, pDoc, rReq)
39{
40}
41
43{
44}
45
47{
48 // remember button state for creation of own MouseEvents
50
51 bool bReturn = FuDraw::MouseButtonDown(rMEvt);
52
53 if ( pView->IsAction() )
54 {
55 if ( rMEvt.IsRight() )
57 return true;
58 }
59
61
62 aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
63
64 if ( rMEvt.IsLeft() )
65 {
66 pWindow->CaptureMouse();
67
68 SdrHdl* pHdl = pView->PickHandle(aMDPos);
69
70 if ( pHdl != nullptr || pView->IsMarkedHit(aMDPos) )
71 {
72 pView->BegDragObj(aMDPos, nullptr, pHdl, 1);
73 bReturn = true;
74 }
75 else if ( pView->AreObjectsMarked() )
76 {
78 bReturn = true;
79 }
80 }
81
82 bIsInDragMode = false;
83
84 return bReturn;
85}
86
88{
89 FuDraw::MouseMove(rMEvt);
90
91 if (aDragTimer.IsActive() )
92 {
93 Point aOldPixel = pWindow->LogicToPixel( aMDPos );
94 Point aNewPixel = rMEvt.GetPosPixel();
95 if ( std::abs( aOldPixel.X() - aNewPixel.X() ) > SC_MAXDRAGMOVE ||
96 std::abs( aOldPixel.Y() - aNewPixel.Y() ) > SC_MAXDRAGMOVE )
98 }
99
100 Point aPix(rMEvt.GetPosPixel());
101 Point aPnt( pWindow->PixelToLogic(aPix) );
102
103 if ( pView->IsAction() )
104 {
105 ForceScroll(aPix);
106 pView->MovAction(aPnt);
107 }
108 else
109 {
110 SdrHdl* pHdl=pView->PickHandle(aPnt);
111
112 if ( pHdl != nullptr )
113 {
115 }
116 else if ( pView->IsMarkedHit(aPnt) )
117 {
118 rViewShell.SetActivePointer(PointerStyle::Move);
119 }
120 else
121 {
123 }
124 }
125 return true;
126}
127
129{
130 // remember button state for creation of own MouseEvents
132
133 bool bReturn = SimpleMouseButtonUp( rMEvt );
134
135 // Double-click on text object? (->fusel)
136
137 sal_uInt16 nClicks = rMEvt.GetClicks();
138 if ( nClicks == 2 && rMEvt.IsLeft() )
139 {
140 if ( pView->AreObjectsMarked() )
141 {
142 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
143 if (rMarkList.GetMarkCount() == 1)
144 {
145 SdrMark* pMark = rMarkList.GetMark(0);
146 SdrObject* pObj = pMark->GetMarkedSdrObj();
147
148 // if Uno-Controls no text mode
149 if ( DynCastSdrTextObj( pObj) != nullptr && dynamic_cast<const SdrUnoObj*>( pObj) == nullptr )
150 {
152 bool bVertical = ( pOPO && pOPO->IsEffectivelyVertical() );
153 sal_uInt16 nTextSlotId = bVertical ? SID_DRAW_TEXT_VERTICAL : SID_DRAW_TEXT;
154
156 Execute(nTextSlotId, SfxCallMode::SLOT | SfxCallMode::RECORD);
157
158 // Get the created FuText now and change into EditMode
160 if ( pPoor && pPoor->GetSlotID() == nTextSlotId ) // has no RTTI
161 {
162 FuText* pText = static_cast<FuText*>(pPoor);
163 Point aMousePixel = rMEvt.GetPosPixel();
164 pText->SetInEditMode( pObj, &aMousePixel );
165 }
166 bReturn = true;
167 }
168 }
169 }
170 }
171
173
174 return bReturn;
175}
176
177// SimpleMouseButtonUp - no test on double-click
178
180{
181 bool bReturn = true;
182
183 if (aDragTimer.IsActive() )
184 {
186 }
187
188 Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
189
190 if ( pView->IsDragObj() )
191 pView->EndDragObj( rMEvt.IsMod1() );
192
193 else if ( pView->IsMarkObj() )
194 pView->EndMarkObj();
195
196 else bReturn = false;
197
198 if ( !pView->IsAction() )
199 {
200 pWindow->ReleaseMouse();
201
202 if ( !pView->AreObjectsMarked() && rMEvt.GetClicks() < 2 )
203 {
204 pView->MarkObj(aPnt, -2, false, rMEvt.IsMod1());
205
207 if ( pView->AreObjectsMarked() )
208 rDisp.Execute(SID_OBJECT_SELECT, SfxCallMode::SLOT | SfxCallMode::RECORD);
209 else
210 rDisp.Execute(aSfxRequest.GetSlot(), SfxCallMode::SLOT | SfxCallMode::RECORD);
211 }
212 }
213
214 return bReturn;
215}
216
217// If we handle a KeyEvent, then the return value is sal_True else FALSE.
219{
220 bool bReturn = false;
221
222 switch ( rKEvt.GetKeyCode().GetCode() )
223 {
224 case KEY_ESCAPE:
225 if ( pView->IsAction() )
226 {
227 pView->BrkAction();
228 pWindow->ReleaseMouse();
229 bReturn = true;
230 }
231 else // end drawing mode
232 {
234 Execute(aSfxRequest.GetSlot(), SfxCallMode::SLOT | SfxCallMode::RECORD);
235 }
236 break;
237
238 case KEY_DELETE:
240 bReturn = true;
241 break;
242 }
243
244 if ( !bReturn )
245 {
246 bReturn = FuDraw::KeyInput(rKEvt);
247 }
248
249 return bReturn;
250}
251
252/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool BegDragObj(const Point &rPnt, OutputDevice *pOut, SdrHdl *pHdl, short nMinMov=-3, SdrDragMethod *pForcedMeth=nullptr) override
virtual void MovAction(const Point &rPnt) override
bool SimpleMouseButtonUp(const MouseEvent &rMEvt)
Definition: fuconstr.cxx:179
virtual SC_DLLPUBLIC bool MouseMove(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:87
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:128
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:46
FuConstruct(ScTabViewShell &rViewSh, vcl::Window *pWin, ScDrawView *pView, SdrModel *pDoc, const SfxRequest &rReq)
Definition: fuconstr.cxx:36
virtual bool KeyInput(const KeyEvent &rKEvt) override
Definition: fuconstr.cxx:218
virtual ~FuConstruct() override
Definition: fuconstr.cxx:42
Base class for all Drawmodule specific functions.
Definition: fudraw.hxx:28
virtual bool KeyInput(const KeyEvent &rKEvt) override
Definition: fudraw.cxx:190
PointerStyle aNewPointer
Definition: fudraw.hxx:30
virtual bool MouseMove(const MouseEvent &rMEvt) override
Definition: fudraw.cxx:137
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: fudraw.cxx:147
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: fudraw.cxx:128
Base class for all functions.
Definition: fupoor.hxx:40
Point aMDPos
Definition: fupoor.hxx:57
ScDrawView * pView
Definition: fupoor.hxx:42
bool bIsInDragMode
Definition: fupoor.hxx:56
sal_uInt16 GetSlotID() const
Definition: fupoor.hxx:90
void SetMouseButtonCode(sal_uInt16 nNew)
Definition: fupoor.hxx:70
SfxRequest aSfxRequest
Definition: fupoor.hxx:47
void ForceScroll(const Point &aPixPos)
Definition: fupoor.cxx:72
ScTabViewShell & rViewShell
Definition: fupoor.hxx:43
Timer aDragTimer
Definition: fupoor.hxx:53
VclPtr< vcl::Window > pWindow
Definition: fupoor.hxx:44
Base class for Text functions.
Definition: futext.hxx:28
void SetInEditMode(SdrObject *pObj=nullptr, const Point *pMousePixel=nullptr, bool bCursorToEnd=false, const KeyEvent *pInitialKey=nullptr)
Definition: futext.cxx:533
const vcl::KeyCode & GetKeyCode() const
bool IsMod1() const
sal_uInt16 GetClicks() const
bool IsRight() const
sal_uInt16 GetButtons() const
const Point & GetPosPixel() const
bool IsLeft() const
bool IsEffectivelyVertical() const
virtual void DeleteMarked() override
Definition: drawview.cxx:858
FuPoor * GetDrawFuncPtr()
Definition: tabview.hxx:323
ScViewData & GetViewData()
Definition: tabview.hxx:335
void SetActivePointer(PointerStyle nPointer)
Definition: tabview.cxx:884
SfxDispatcher & GetDispatcher()
Definition: viewdata.cxx:3135
ScDBFunc * GetView() const
Definition: viewdata.cxx:863
virtual void BrkAction() override
virtual bool IsAction() const override
virtual void BckAction() override
bool EndDragObj(bool bCopy=false)
bool IsDragObj() const
virtual PointerStyle GetPointer() const
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
SdrHdl * PickHandle(const Point &rPnt) const
const SdrMarkList & GetMarkedObjectList() const
bool AreObjectsMarked() const
bool IsMarkObj() const
bool IsMarkedHit(const Point &rPnt, short nTol=-2) const
bool EndMarkObj()
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
SdrObject * GetMarkedSdrObj() const
virtual OutlinerParaObject * GetOutlinerParaObject() const
void UnmarkAll()
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
sal_uInt16 GetSlot() const
bool IsActive() const
void Stop()
virtual void Start(bool bStartTimer=true) override
sal_uInt16 GetCode() const
#define SC_MAXDRAGMOVE
fusel,fuconstr,futext - combine them!
Definition: fuconstr.cxx:34
constexpr sal_uInt16 KEY_ESCAPE
constexpr sal_uInt16 KEY_DELETE
const ::avmedia::MediaItem * Execute(const SdrMarkView *pSdrView, SfxRequest const &rReq)
SVXCORE_DLLPUBLIC SdrTextObj * DynCastSdrTextObj(SdrObject *)