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: fupoor.cxx,v $
10 * $Revision: 1.13.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 <svx/outliner.hxx>
35 #include <svx/svditer.hxx>
36 #include <svx/svdobj.hxx>
37 #include <svx/svdpagv.hxx>
40 #include "tabvwsh.hxx"
41 #include "drawview.hxx"
42 #include "detfunc.hxx"
43 #include "document.hxx"
44 #include <vcl/svapp.hxx>
45 #include <svx/sdrhittesthelper.hxx>
47 /*************************************************************************
51 \************************************************************************/
53 FuPoor::FuPoor(ScTabViewShell
* pViewSh
, Window
* pWin
, ScDrawView
* pViewP
,
54 SdrModel
* pDoc
, SfxRequest
& rReq
) :
62 // #95491# remember MouseButton state
65 aScrollTimer
.SetTimeoutHdl( LINK(this, FuPoor
, ScrollHdl
) );
66 aScrollTimer
.SetTimeout(SELENG_AUTOREPEAT_INTERVAL
);
68 aDragTimer
.SetTimeoutHdl( LINK(this, FuPoor
, DragTimerHdl
) );
69 aDragTimer
.SetTimeout(SELENG_DRAGDROP_TIMEOUT
);
72 /*************************************************************************
76 \************************************************************************/
87 /*************************************************************************
89 |* Function aktivieren
91 \************************************************************************/
93 void FuPoor::Activate()
101 /*************************************************************************
103 |* Function deaktivieren
105 \************************************************************************/
107 void FuPoor::Deactivate()
118 /*************************************************************************
120 |* Scrollen bei Erreichen des Fensterrandes; wird von
121 |* MouseMove aufgerufen
123 \************************************************************************/
125 void FuPoor::ForceScroll(const Point
& aPixPos
)
129 Size aSize
= pWindow
->GetSizePixel();
133 if ( aPixPos
.X() <= 0 ) dx
= -1;
134 if ( aPixPos
.X() >= aSize
.Width() ) dx
= 1;
135 if ( aPixPos
.Y() <= 0 ) dy
= -1;
136 if ( aPixPos
.Y() >= aSize
.Height() ) dy
= 1;
138 ScViewData
* pViewData
= pViewShell
->GetViewData();
139 if ( pViewData
->GetDocument()->IsNegativePage( pViewData
->GetTabNo() ) )
142 ScSplitPos eWhich
= pViewData
->GetActivePart();
143 if ( dx
> 0 && pViewData
->GetHSplitMode() == SC_SPLIT_FIX
&& WhichH(eWhich
) == SC_SPLIT_LEFT
)
145 pViewShell
->ActivatePart( ( eWhich
== SC_SPLIT_TOPLEFT
) ?
146 SC_SPLIT_TOPRIGHT
: SC_SPLIT_BOTTOMRIGHT
);
149 if ( dy
> 0 && pViewData
->GetVSplitMode() == SC_SPLIT_FIX
&& WhichV(eWhich
) == SC_SPLIT_TOP
)
151 pViewShell
->ActivatePart( ( eWhich
== SC_SPLIT_TOPLEFT
) ?
152 SC_SPLIT_BOTTOMLEFT
: SC_SPLIT_BOTTOMRIGHT
);
156 if ( dx
!= 0 || dy
!= 0 )
158 ScrollStart(); // Scrollaktion in abgeleiteter Klasse
159 pViewShell
->ScrollLines(2*dx
, 4*dy
);
161 aScrollTimer
.Start();
165 /*************************************************************************
167 |* Timer-Handler fuer Fensterscrolling
169 \************************************************************************/
171 IMPL_LINK_INLINE_START( FuPoor
, ScrollHdl
, Timer
*, EMPTYARG
)
173 Point aPosPixel
= pWindow
->GetPointerPosPixel();
175 // #95491# use remembered MouseButton state to create correct
176 // MouseEvents for this artifical MouseMove.
177 MouseMove(MouseEvent(aPosPixel
, 1, 0, GetMouseButtonCode()));
181 IMPL_LINK_INLINE_END( FuPoor
, ScrollHdl
, Timer
*, pTimer
)
183 // #95491# moved from inline to *.cxx
184 BOOL
FuPoor::MouseButtonUp(const MouseEvent
& rMEvt
)
186 // #95491# remember button state for creation of own MouseEvents
187 SetMouseButtonCode(rMEvt
.GetButtons());
192 // #95491# moved from inline to *.cxx
193 BOOL
FuPoor::MouseButtonDown(const MouseEvent
& rMEvt
)
195 // #95491# remember button state for creation of own MouseEvents
196 SetMouseButtonCode(rMEvt
.GetButtons());
201 /*************************************************************************
203 |* String in Applikations-Statuszeile ausgeben
205 \************************************************************************/
207 // WriteStatus gibt's nicht mehr
209 /*************************************************************************
211 |* Tastaturereignisse bearbeiten
213 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
216 \************************************************************************/
218 BOOL
FuPoor::KeyInput(const KeyEvent
& /* rKEvt */)
220 BOOL bReturn
= FALSE
;
225 BYTE
FuPoor::Command(const CommandEvent
& rCEvt
)
227 if ( COMMAND_STARTDRAG
== rCEvt
.GetCommand() )
229 //!!! sollte Joe eigentlich machen:
230 // nur, wenn im Outliner was selektiert ist, darf
231 // Command TRUE zurueckliefern:
233 OutlinerView
* pOutView
= pView
->GetTextEditOutlinerView();
236 return pOutView
->HasSelection() ? pView
->Command(rCEvt
,pWindow
) : SC_CMD_NONE
;
238 return pView
->Command(rCEvt
,pWindow
);
241 return pView
->Command(rCEvt
,pWindow
);
244 /*************************************************************************
246 |* Cut object to clipboard
248 \************************************************************************/
254 //! pView->DoCut(pWindow);
258 /*************************************************************************
260 |* Copy object to clipboard
262 \************************************************************************/
264 void FuPoor::DoCopy()
268 //! pView->DoCopy(pWindow);
272 /*************************************************************************
274 |* Paste object from clipboard
276 \************************************************************************/
278 void FuPoor::DoPaste()
282 //! pView->DoPaste(pWindow);
286 /*************************************************************************
288 |* Timer-Handler fuer Drag&Drop
290 \************************************************************************/
292 IMPL_LINK( FuPoor
, DragTimerHdl
, Timer
*, EMPTYARG
)
294 // ExecuteDrag (und das damit verbundene Reschedule) direkt aus dem Timer
295 // aufzurufen, bringt die VCL-Timer-Verwaltung durcheinander, wenn dabei
296 // (z.B. im Drop) wieder ein Timer gestartet wird (z.B. ComeBack-Timer der
297 // DrawView fuer Solid Handles / ModelHasChanged) - der neue Timer laeuft
298 // dann um die Dauer des Drag&Drop zu spaet ab.
299 // Darum Drag&Drop aus eigenem Event:
301 Application::PostUserEvent( LINK( this, FuPoor
, DragHdl
) );
305 IMPL_LINK( FuPoor
, DragHdl
, void *, EMPTYARG
)
307 SdrHdl
* pHdl
= pView
->PickHandle(aMDPos
);
309 if ( pHdl
==NULL
&& pView
->IsMarkedHit(aMDPos
) )
311 pWindow
->ReleaseMouse();
312 bIsInDragMode
= TRUE
;
314 // pView->BeginDrag(pWindow, aMDPos);
315 pViewShell
->GetScDrawView()->BeginDrag(pWindow
, aMDPos
);
322 BOOL
FuPoor::IsDetectiveHit( const Point
& rLogicPos
)
324 SdrPageView
* pPV
= pView
->GetSdrPageView();
329 SdrObjListIter
aIter( *pPV
->GetObjList(), IM_FLAT
);
330 SdrObject
* pObject
= aIter
.Next();
331 while (pObject
&& !bFound
)
333 if (ScDetectiveFunc::IsNonAlienArrow( pObject
))
335 USHORT nHitLog
= (USHORT
) pWindow
->PixelToLogic(
336 Size(pView
->GetHitTolerancePixel(),0)).Width();
337 if(SdrObjectPrimitiveHit(*pObject
, rLogicPos
, nHitLog
, *pPV
, 0, false))
343 pObject
= aIter
.Next();
348 void FuPoor::StopDragTimer()
350 if (aDragTimer
.IsActive() )
354 /*************************************************************************
356 |* #98185# Create default drawing objects via keyboard
358 \************************************************************************/
360 SdrObject
* FuPoor::CreateDefaultObject(const sal_uInt16
/* nID */, const Rectangle
& /* rRectangle */)
362 // empty base implementation
366 void FuPoor::ImpForceQuadratic(Rectangle
& rRect
)
368 if(rRect
.GetWidth() > rRect
.GetHeight())
371 Point(rRect
.Left() + ((rRect
.GetWidth() - rRect
.GetHeight()) / 2), rRect
.Top()),
372 Size(rRect
.GetHeight(), rRect
.GetHeight()));
377 Point(rRect
.Left(), rRect
.Top() + ((rRect
.GetHeight() - rRect
.GetWidth()) / 2)),
378 Size(rRect
.GetWidth(), rRect
.GetWidth()));
383 bool FuPoor::doConstructOrthogonal() const