1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*b3f79822SAndrew Rist * distributed with this work for additional information
6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the
17*b3f79822SAndrew Rist * specific language governing permissions and limitations
18*b3f79822SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*b3f79822SAndrew Rist *************************************************************/
21*b3f79822SAndrew Rist
22*b3f79822SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <editeng/outliner.hxx>
28cdf0e10cSrcweir #include <svx/svditer.hxx>
29cdf0e10cSrcweir #include <svx/svdobj.hxx>
30cdf0e10cSrcweir #include <svx/svdpagv.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include "fupoor.hxx"
33cdf0e10cSrcweir #include "tabvwsh.hxx"
34cdf0e10cSrcweir #include "drawview.hxx"
35cdf0e10cSrcweir #include "detfunc.hxx"
36cdf0e10cSrcweir #include "document.hxx"
37cdf0e10cSrcweir #include <vcl/svapp.hxx>
38cdf0e10cSrcweir #include <svx/sdrhittesthelper.hxx>
39cdf0e10cSrcweir
40cdf0e10cSrcweir /*************************************************************************
41cdf0e10cSrcweir |*
42cdf0e10cSrcweir |* Konstruktor
43cdf0e10cSrcweir |*
44cdf0e10cSrcweir \************************************************************************/
45cdf0e10cSrcweir
FuPoor(ScTabViewShell * pViewSh,Window * pWin,ScDrawView * pViewP,SdrModel * pDoc,SfxRequest & rReq)46cdf0e10cSrcweir FuPoor::FuPoor(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
47cdf0e10cSrcweir SdrModel* pDoc, SfxRequest& rReq) :
48cdf0e10cSrcweir pView(pViewP),
49cdf0e10cSrcweir pViewShell(pViewSh),
50cdf0e10cSrcweir pWindow(pWin),
51cdf0e10cSrcweir pDrDoc(pDoc),
52cdf0e10cSrcweir aSfxRequest(rReq),
53cdf0e10cSrcweir pDialog(NULL),
54cdf0e10cSrcweir bIsInDragMode(sal_False),
55cdf0e10cSrcweir // #95491# remember MouseButton state
56cdf0e10cSrcweir mnCode(0)
57cdf0e10cSrcweir {
58cdf0e10cSrcweir aScrollTimer.SetTimeoutHdl( LINK(this, FuPoor, ScrollHdl) );
59cdf0e10cSrcweir aScrollTimer.SetTimeout(SELENG_AUTOREPEAT_INTERVAL);
60cdf0e10cSrcweir
61cdf0e10cSrcweir aDragTimer.SetTimeoutHdl( LINK(this, FuPoor, DragTimerHdl) );
62cdf0e10cSrcweir aDragTimer.SetTimeout(SELENG_DRAGDROP_TIMEOUT);
63cdf0e10cSrcweir }
64cdf0e10cSrcweir
65cdf0e10cSrcweir /*************************************************************************
66cdf0e10cSrcweir |*
67cdf0e10cSrcweir |* Destruktor
68cdf0e10cSrcweir |*
69cdf0e10cSrcweir \************************************************************************/
70cdf0e10cSrcweir
~FuPoor()71cdf0e10cSrcweir FuPoor::~FuPoor()
72cdf0e10cSrcweir {
73cdf0e10cSrcweir aDragTimer.Stop();
74cdf0e10cSrcweir aScrollTimer.Stop();
75cdf0e10cSrcweir
76cdf0e10cSrcweir if (pDialog)
77cdf0e10cSrcweir delete pDialog;
78cdf0e10cSrcweir }
79cdf0e10cSrcweir
80cdf0e10cSrcweir /*************************************************************************
81cdf0e10cSrcweir |*
82cdf0e10cSrcweir |* Function aktivieren
83cdf0e10cSrcweir |*
84cdf0e10cSrcweir \************************************************************************/
85cdf0e10cSrcweir
Activate()86cdf0e10cSrcweir void FuPoor::Activate()
87cdf0e10cSrcweir {
88cdf0e10cSrcweir if (pDialog)
89cdf0e10cSrcweir {
90cdf0e10cSrcweir pDialog->Show();
91cdf0e10cSrcweir }
92cdf0e10cSrcweir }
93cdf0e10cSrcweir
94cdf0e10cSrcweir /*************************************************************************
95cdf0e10cSrcweir |*
96cdf0e10cSrcweir |* Function deaktivieren
97cdf0e10cSrcweir |*
98cdf0e10cSrcweir \************************************************************************/
99cdf0e10cSrcweir
Deactivate()100cdf0e10cSrcweir void FuPoor::Deactivate()
101cdf0e10cSrcweir {
102cdf0e10cSrcweir aDragTimer.Stop();
103cdf0e10cSrcweir aScrollTimer.Stop();
104cdf0e10cSrcweir
105cdf0e10cSrcweir if (pDialog)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir pDialog->Hide();
108cdf0e10cSrcweir }
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
111cdf0e10cSrcweir /*************************************************************************
112cdf0e10cSrcweir |*
113cdf0e10cSrcweir |* Scrollen bei Erreichen des Fensterrandes; wird von
114cdf0e10cSrcweir |* MouseMove aufgerufen
115cdf0e10cSrcweir |*
116cdf0e10cSrcweir \************************************************************************/
117cdf0e10cSrcweir
ForceScroll(const Point & aPixPos)118cdf0e10cSrcweir void FuPoor::ForceScroll(const Point& aPixPos)
119cdf0e10cSrcweir {
120cdf0e10cSrcweir aScrollTimer.Stop();
121cdf0e10cSrcweir
122cdf0e10cSrcweir Size aSize = pWindow->GetSizePixel();
123cdf0e10cSrcweir SCsCOL dx = 0;
124cdf0e10cSrcweir SCsROW dy = 0;
125cdf0e10cSrcweir
126cdf0e10cSrcweir if ( aPixPos.X() <= 0 ) dx = -1;
127cdf0e10cSrcweir if ( aPixPos.X() >= aSize.Width() ) dx = 1;
128cdf0e10cSrcweir if ( aPixPos.Y() <= 0 ) dy = -1;
129cdf0e10cSrcweir if ( aPixPos.Y() >= aSize.Height() ) dy = 1;
130cdf0e10cSrcweir
131cdf0e10cSrcweir ScViewData* pViewData = pViewShell->GetViewData();
132cdf0e10cSrcweir if ( pViewData->GetDocument()->IsNegativePage( pViewData->GetTabNo() ) )
133cdf0e10cSrcweir dx = -dx;
134cdf0e10cSrcweir
135cdf0e10cSrcweir ScSplitPos eWhich = pViewData->GetActivePart();
136cdf0e10cSrcweir if ( dx > 0 && pViewData->GetHSplitMode() == SC_SPLIT_FIX && WhichH(eWhich) == SC_SPLIT_LEFT )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir pViewShell->ActivatePart( ( eWhich == SC_SPLIT_TOPLEFT ) ?
139cdf0e10cSrcweir SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT );
140cdf0e10cSrcweir dx = 0;
141cdf0e10cSrcweir }
142cdf0e10cSrcweir if ( dy > 0 && pViewData->GetVSplitMode() == SC_SPLIT_FIX && WhichV(eWhich) == SC_SPLIT_TOP )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir pViewShell->ActivatePart( ( eWhich == SC_SPLIT_TOPLEFT ) ?
145cdf0e10cSrcweir SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT );
146cdf0e10cSrcweir dy = 0;
147cdf0e10cSrcweir }
148cdf0e10cSrcweir
149cdf0e10cSrcweir if ( dx != 0 || dy != 0 )
150cdf0e10cSrcweir {
151cdf0e10cSrcweir ScrollStart(); // Scrollaktion in abgeleiteter Klasse
152cdf0e10cSrcweir pViewShell->ScrollLines(2*dx, 4*dy);
153cdf0e10cSrcweir ScrollEnd();
154cdf0e10cSrcweir aScrollTimer.Start();
155cdf0e10cSrcweir }
156cdf0e10cSrcweir }
157cdf0e10cSrcweir
158cdf0e10cSrcweir /*************************************************************************
159cdf0e10cSrcweir |*
160cdf0e10cSrcweir |* Timer-Handler fuer Fensterscrolling
161cdf0e10cSrcweir |*
162cdf0e10cSrcweir \************************************************************************/
163cdf0e10cSrcweir
IMPL_LINK_INLINE_START(FuPoor,ScrollHdl,Timer *,EMPTYARG)164cdf0e10cSrcweir IMPL_LINK_INLINE_START( FuPoor, ScrollHdl, Timer *, EMPTYARG )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir Point aPosPixel = pWindow->GetPointerPosPixel();
167cdf0e10cSrcweir
168cdf0e10cSrcweir // #95491# use remembered MouseButton state to create correct
169cdf0e10cSrcweir // MouseEvents for this artifical MouseMove.
170cdf0e10cSrcweir MouseMove(MouseEvent(aPosPixel, 1, 0, GetMouseButtonCode()));
171cdf0e10cSrcweir
172cdf0e10cSrcweir return 0;
173cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(FuPoor,ScrollHdl,Timer *,pTimer)174cdf0e10cSrcweir IMPL_LINK_INLINE_END( FuPoor, ScrollHdl, Timer *, pTimer )
175cdf0e10cSrcweir
176cdf0e10cSrcweir // #95491# moved from inline to *.cxx
177cdf0e10cSrcweir sal_Bool FuPoor::MouseButtonUp(const MouseEvent& rMEvt)
178cdf0e10cSrcweir {
179cdf0e10cSrcweir // #95491# remember button state for creation of own MouseEvents
180cdf0e10cSrcweir SetMouseButtonCode(rMEvt.GetButtons());
181cdf0e10cSrcweir
182cdf0e10cSrcweir return sal_False;
183cdf0e10cSrcweir }
184cdf0e10cSrcweir
185cdf0e10cSrcweir // #95491# moved from inline to *.cxx
MouseButtonDown(const MouseEvent & rMEvt)186cdf0e10cSrcweir sal_Bool FuPoor::MouseButtonDown(const MouseEvent& rMEvt)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir // #95491# remember button state for creation of own MouseEvents
189cdf0e10cSrcweir SetMouseButtonCode(rMEvt.GetButtons());
190cdf0e10cSrcweir
191cdf0e10cSrcweir return sal_False;
192cdf0e10cSrcweir }
193cdf0e10cSrcweir
194cdf0e10cSrcweir /*************************************************************************
195cdf0e10cSrcweir |*
196cdf0e10cSrcweir |* String in Applikations-Statuszeile ausgeben
197cdf0e10cSrcweir |*
198cdf0e10cSrcweir \************************************************************************/
199cdf0e10cSrcweir
200cdf0e10cSrcweir // WriteStatus gibt's nicht mehr
201cdf0e10cSrcweir
202cdf0e10cSrcweir /*************************************************************************
203cdf0e10cSrcweir |*
204cdf0e10cSrcweir |* Tastaturereignisse bearbeiten
205cdf0e10cSrcweir |*
206cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
207cdf0e10cSrcweir |* FALSE.
208cdf0e10cSrcweir |*
209cdf0e10cSrcweir \************************************************************************/
210cdf0e10cSrcweir
KeyInput(const KeyEvent &)211cdf0e10cSrcweir sal_Bool FuPoor::KeyInput(const KeyEvent& /* rKEvt */)
212cdf0e10cSrcweir {
213cdf0e10cSrcweir sal_Bool bReturn = sal_False;
214cdf0e10cSrcweir
215cdf0e10cSrcweir return(bReturn);
216cdf0e10cSrcweir }
217cdf0e10cSrcweir
Command(const CommandEvent & rCEvt)218cdf0e10cSrcweir sal_uInt8 FuPoor::Command(const CommandEvent& rCEvt)
219cdf0e10cSrcweir {
220cdf0e10cSrcweir if ( COMMAND_STARTDRAG == rCEvt.GetCommand() )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir //!!! sollte Joe eigentlich machen:
223cdf0e10cSrcweir // nur, wenn im Outliner was selektiert ist, darf
224cdf0e10cSrcweir // Command sal_True zurueckliefern:
225cdf0e10cSrcweir
226cdf0e10cSrcweir OutlinerView* pOutView = pView->GetTextEditOutlinerView();
227cdf0e10cSrcweir
228cdf0e10cSrcweir if ( pOutView )
229cdf0e10cSrcweir return pOutView->HasSelection() ? pView->Command(rCEvt,pWindow) : SC_CMD_NONE;
230cdf0e10cSrcweir else
231cdf0e10cSrcweir return pView->Command(rCEvt,pWindow);
232cdf0e10cSrcweir }
233cdf0e10cSrcweir else
234cdf0e10cSrcweir return pView->Command(rCEvt,pWindow);
235cdf0e10cSrcweir }
236cdf0e10cSrcweir
237cdf0e10cSrcweir /*************************************************************************
238cdf0e10cSrcweir |*
239cdf0e10cSrcweir |* Cut object to clipboard
240cdf0e10cSrcweir |*
241cdf0e10cSrcweir \************************************************************************/
242cdf0e10cSrcweir
DoCut()243cdf0e10cSrcweir void FuPoor::DoCut()
244cdf0e10cSrcweir {
245cdf0e10cSrcweir if (pView)
246cdf0e10cSrcweir {
247cdf0e10cSrcweir //! pView->DoCut(pWindow);
248cdf0e10cSrcweir }
249cdf0e10cSrcweir }
250cdf0e10cSrcweir
251cdf0e10cSrcweir /*************************************************************************
252cdf0e10cSrcweir |*
253cdf0e10cSrcweir |* Copy object to clipboard
254cdf0e10cSrcweir |*
255cdf0e10cSrcweir \************************************************************************/
256cdf0e10cSrcweir
DoCopy()257cdf0e10cSrcweir void FuPoor::DoCopy()
258cdf0e10cSrcweir {
259cdf0e10cSrcweir if (pView)
260cdf0e10cSrcweir {
261cdf0e10cSrcweir //! pView->DoCopy(pWindow);
262cdf0e10cSrcweir }
263cdf0e10cSrcweir }
264cdf0e10cSrcweir
265cdf0e10cSrcweir /*************************************************************************
266cdf0e10cSrcweir |*
267cdf0e10cSrcweir |* Paste object from clipboard
268cdf0e10cSrcweir |*
269cdf0e10cSrcweir \************************************************************************/
270cdf0e10cSrcweir
DoPaste()271cdf0e10cSrcweir void FuPoor::DoPaste()
272cdf0e10cSrcweir {
273cdf0e10cSrcweir if (pView)
274cdf0e10cSrcweir {
275cdf0e10cSrcweir //! pView->DoPaste(pWindow);
276cdf0e10cSrcweir }
277cdf0e10cSrcweir }
278cdf0e10cSrcweir
279cdf0e10cSrcweir /*************************************************************************
280cdf0e10cSrcweir |*
281cdf0e10cSrcweir |* Timer-Handler fuer Drag&Drop
282cdf0e10cSrcweir |*
283cdf0e10cSrcweir \************************************************************************/
284cdf0e10cSrcweir
IMPL_LINK(FuPoor,DragTimerHdl,Timer *,EMPTYARG)285cdf0e10cSrcweir IMPL_LINK( FuPoor, DragTimerHdl, Timer *, EMPTYARG )
286cdf0e10cSrcweir {
287cdf0e10cSrcweir // ExecuteDrag (und das damit verbundene Reschedule) direkt aus dem Timer
288cdf0e10cSrcweir // aufzurufen, bringt die VCL-Timer-Verwaltung durcheinander, wenn dabei
289cdf0e10cSrcweir // (z.B. im Drop) wieder ein Timer gestartet wird (z.B. ComeBack-Timer der
290cdf0e10cSrcweir // DrawView fuer Solid Handles / ModelHasChanged) - der neue Timer laeuft
291cdf0e10cSrcweir // dann um die Dauer des Drag&Drop zu spaet ab.
292cdf0e10cSrcweir // Darum Drag&Drop aus eigenem Event:
293cdf0e10cSrcweir
294cdf0e10cSrcweir Application::PostUserEvent( LINK( this, FuPoor, DragHdl ) );
295cdf0e10cSrcweir return 0;
296cdf0e10cSrcweir }
297cdf0e10cSrcweir
IMPL_LINK(FuPoor,DragHdl,void *,EMPTYARG)298cdf0e10cSrcweir IMPL_LINK( FuPoor, DragHdl, void *, EMPTYARG )
299cdf0e10cSrcweir {
300cdf0e10cSrcweir SdrHdl* pHdl = pView->PickHandle(aMDPos);
301cdf0e10cSrcweir
302cdf0e10cSrcweir if ( pHdl==NULL && pView->IsMarkedHit(aMDPos) )
303cdf0e10cSrcweir {
304cdf0e10cSrcweir pWindow->ReleaseMouse();
305cdf0e10cSrcweir bIsInDragMode = sal_True;
306cdf0e10cSrcweir
307cdf0e10cSrcweir // pView->BeginDrag(pWindow, aMDPos);
308cdf0e10cSrcweir pViewShell->GetScDrawView()->BeginDrag(pWindow, aMDPos);
309cdf0e10cSrcweir }
310cdf0e10cSrcweir return 0;
311cdf0e10cSrcweir }
312cdf0e10cSrcweir
313cdf0e10cSrcweir // Detektiv-Linie
314cdf0e10cSrcweir
IsDetectiveHit(const Point & rLogicPos)315cdf0e10cSrcweir sal_Bool FuPoor::IsDetectiveHit( const Point& rLogicPos )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir SdrPageView* pPV = pView->GetSdrPageView();
318cdf0e10cSrcweir if (!pPV)
319cdf0e10cSrcweir return sal_False;
320cdf0e10cSrcweir
321cdf0e10cSrcweir sal_Bool bFound = sal_False;
322cdf0e10cSrcweir SdrObjListIter aIter( *pPV->GetObjList(), IM_FLAT );
323cdf0e10cSrcweir SdrObject* pObject = aIter.Next();
324cdf0e10cSrcweir while (pObject && !bFound)
325cdf0e10cSrcweir {
326cdf0e10cSrcweir if (ScDetectiveFunc::IsNonAlienArrow( pObject ))
327cdf0e10cSrcweir {
328cdf0e10cSrcweir sal_uInt16 nHitLog = (sal_uInt16) pWindow->PixelToLogic(
329cdf0e10cSrcweir Size(pView->GetHitTolerancePixel(),0)).Width();
330cdf0e10cSrcweir if(SdrObjectPrimitiveHit(*pObject, rLogicPos, nHitLog, *pPV, 0, false))
331cdf0e10cSrcweir {
332cdf0e10cSrcweir bFound = sal_True;
333cdf0e10cSrcweir }
334cdf0e10cSrcweir }
335cdf0e10cSrcweir
336cdf0e10cSrcweir pObject = aIter.Next();
337cdf0e10cSrcweir }
338cdf0e10cSrcweir return bFound;
339cdf0e10cSrcweir }
340cdf0e10cSrcweir
StopDragTimer()341cdf0e10cSrcweir void FuPoor::StopDragTimer()
342cdf0e10cSrcweir {
343cdf0e10cSrcweir if (aDragTimer.IsActive() )
344cdf0e10cSrcweir aDragTimer.Stop();
345cdf0e10cSrcweir }
346cdf0e10cSrcweir
347cdf0e10cSrcweir /*************************************************************************
348cdf0e10cSrcweir |*
349cdf0e10cSrcweir |* #98185# Create default drawing objects via keyboard
350cdf0e10cSrcweir |*
351cdf0e10cSrcweir \************************************************************************/
352cdf0e10cSrcweir
CreateDefaultObject(const sal_uInt16,const Rectangle &)353cdf0e10cSrcweir SdrObject* FuPoor::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& /* rRectangle */)
354cdf0e10cSrcweir {
355cdf0e10cSrcweir // empty base implementation
356cdf0e10cSrcweir return 0L;
357cdf0e10cSrcweir }
358cdf0e10cSrcweir
ImpForceQuadratic(Rectangle & rRect)359cdf0e10cSrcweir void FuPoor::ImpForceQuadratic(Rectangle& rRect)
360cdf0e10cSrcweir {
361cdf0e10cSrcweir if(rRect.GetWidth() > rRect.GetHeight())
362cdf0e10cSrcweir {
363cdf0e10cSrcweir rRect = Rectangle(
364cdf0e10cSrcweir Point(rRect.Left() + ((rRect.GetWidth() - rRect.GetHeight()) / 2), rRect.Top()),
365cdf0e10cSrcweir Size(rRect.GetHeight(), rRect.GetHeight()));
366cdf0e10cSrcweir }
367cdf0e10cSrcweir else
368cdf0e10cSrcweir {
369cdf0e10cSrcweir rRect = Rectangle(
370cdf0e10cSrcweir Point(rRect.Left(), rRect.Top() + ((rRect.GetHeight() - rRect.GetWidth()) / 2)),
371cdf0e10cSrcweir Size(rRect.GetWidth(), rRect.GetWidth()));
372cdf0e10cSrcweir }
373cdf0e10cSrcweir }
374cdf0e10cSrcweir
375cdf0e10cSrcweir // #i33136#
doConstructOrthogonal() const376cdf0e10cSrcweir bool FuPoor::doConstructOrthogonal() const
377cdf0e10cSrcweir {
378cdf0e10cSrcweir return false;
379cdf0e10cSrcweir }
380cdf0e10cSrcweir
381cdf0e10cSrcweir // eof
382