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 <editeng/outliner.hxx>
22 #include <svx/svditer.hxx>
23 #include <svx/svdobj.hxx>
24 #include <svx/svdpagv.hxx>
27 #include "tabvwsh.hxx"
28 #include "drawview.hxx"
29 #include "detfunc.hxx"
30 #include "document.hxx"
31 #include <vcl/svapp.hxx>
32 #include <svx/sdrhittesthelper.hxx>
34 FuPoor::FuPoor(ScTabViewShell
* pViewSh
, Window
* pWin
, ScDrawView
* pViewP
,
35 SdrModel
* pDoc
, SfxRequest
& rReq
) :
43 // remember MouseButton state
46 aScrollTimer
.SetTimeoutHdl( LINK(this, FuPoor
, ScrollHdl
) );
47 aScrollTimer
.SetTimeout(SELENG_AUTOREPEAT_INTERVAL
);
49 aDragTimer
.SetTimeoutHdl( LINK(this, FuPoor
, DragTimerHdl
) );
50 aDragTimer
.SetTimeout(SELENG_DRAGDROP_TIMEOUT
);
61 void FuPoor::Activate()
69 void FuPoor::Deactivate()
80 /*************************************************************************
82 |* Scrollen bei Erreichen des Fensterrandes; wird von
83 |* MouseMove aufgerufen
85 \************************************************************************/
87 void FuPoor::ForceScroll(const Point
& aPixPos
)
91 Size aSize
= pWindow
->GetSizePixel();
95 if ( aPixPos
.X() <= 0 ) dx
= -1;
96 if ( aPixPos
.X() >= aSize
.Width() ) dx
= 1;
97 if ( aPixPos
.Y() <= 0 ) dy
= -1;
98 if ( aPixPos
.Y() >= aSize
.Height() ) dy
= 1;
100 ScViewData
* pViewData
= pViewShell
->GetViewData();
101 if ( pViewData
->GetDocument()->IsNegativePage( pViewData
->GetTabNo() ) )
104 ScSplitPos eWhich
= pViewData
->GetActivePart();
105 if ( dx
> 0 && pViewData
->GetHSplitMode() == SC_SPLIT_FIX
&& WhichH(eWhich
) == SC_SPLIT_LEFT
)
107 pViewShell
->ActivatePart( ( eWhich
== SC_SPLIT_TOPLEFT
) ?
108 SC_SPLIT_TOPRIGHT
: SC_SPLIT_BOTTOMRIGHT
);
111 if ( dy
> 0 && pViewData
->GetVSplitMode() == SC_SPLIT_FIX
&& WhichV(eWhich
) == SC_SPLIT_TOP
)
113 pViewShell
->ActivatePart( ( eWhich
== SC_SPLIT_TOPLEFT
) ?
114 SC_SPLIT_BOTTOMLEFT
: SC_SPLIT_BOTTOMRIGHT
);
118 if ( dx
!= 0 || dy
!= 0 )
120 pViewShell
->ScrollLines(2*dx
, 4*dy
);
121 aScrollTimer
.Start();
125 /*************************************************************************
127 |* Timer-Handler fuer Fensterscrolling
129 \************************************************************************/
131 IMPL_LINK_NOARG_INLINE_START(FuPoor
, ScrollHdl
)
133 Point aPosPixel
= pWindow
->GetPointerPosPixel();
135 // use remembered MouseButton state to create correct
136 // MouseEvents for this artifical MouseMove.
137 MouseMove(MouseEvent(aPosPixel
, 1, 0, GetMouseButtonCode()));
141 IMPL_LINK_INLINE_END( FuPoor
, ScrollHdl
, Timer
*, pTimer
)
143 // moved from inline to *.cxx
144 sal_Bool
FuPoor::MouseButtonUp(const MouseEvent
& rMEvt
)
146 // remember button state for creation of own MouseEvents
147 SetMouseButtonCode(rMEvt
.GetButtons());
152 // moved from inline to *.cxx
153 sal_Bool
FuPoor::MouseButtonDown(const MouseEvent
& rMEvt
)
155 // remember button state for creation of own MouseEvents
156 SetMouseButtonCode(rMEvt
.GetButtons());
161 /*************************************************************************
163 |* String in Applikations-Statuszeile ausgeben
165 \************************************************************************/
167 // WriteStatus gibt's nicht mehr
169 /*************************************************************************
171 |* Tastaturereignisse bearbeiten
173 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
176 \************************************************************************/
178 sal_Bool
FuPoor::KeyInput(const KeyEvent
& /* rKEvt */)
180 sal_Bool bReturn
= false;
185 sal_uInt8
FuPoor::Command(const CommandEvent
& rCEvt
)
187 if ( COMMAND_STARTDRAG
== rCEvt
.GetCommand() )
189 //!!! sollte Joe eigentlich machen:
190 // nur, wenn im Outliner was selektiert ist, darf
191 // Command sal_True zurueckliefern:
193 OutlinerView
* pOutView
= pView
->GetTextEditOutlinerView();
196 return pOutView
->HasSelection() ? pView
->Command(rCEvt
,pWindow
) : SC_CMD_NONE
;
198 return pView
->Command(rCEvt
,pWindow
);
201 return pView
->Command(rCEvt
,pWindow
);
208 //! pView->DoCut(pWindow);
212 /*************************************************************************
214 |* Copy object to clipboard
216 \************************************************************************/
218 void FuPoor::DoCopy()
222 //! pView->DoCopy(pWindow);
226 void FuPoor::DoPaste()
230 //! pView->DoPaste(pWindow);
234 /*************************************************************************
236 |* Timer-Handler fuer Drag&Drop
238 \************************************************************************/
240 IMPL_LINK_NOARG(FuPoor
, DragTimerHdl
)
242 // ExecuteDrag (und das damit verbundene Reschedule) direkt aus dem Timer
243 // aufzurufen, bringt die VCL-Timer-Verwaltung durcheinander, wenn dabei
244 // (z.B. im Drop) wieder ein Timer gestartet wird (z.B. ComeBack-Timer der
245 // DrawView fuer Solid Handles / ModelHasChanged) - der neue Timer laeuft
246 // dann um die Dauer des Drag&Drop zu spaet ab.
247 // Darum Drag&Drop aus eigenem Event:
249 Application::PostUserEvent( LINK( this, FuPoor
, DragHdl
) );
253 IMPL_LINK_NOARG(FuPoor
, DragHdl
)
255 SdrHdl
* pHdl
= pView
->PickHandle(aMDPos
);
257 if ( pHdl
==NULL
&& pView
->IsMarkedHit(aMDPos
) )
259 pWindow
->ReleaseMouse();
260 bIsInDragMode
= sal_True
;
262 // pView->BeginDrag(pWindow, aMDPos);
263 pViewShell
->GetScDrawView()->BeginDrag(pWindow
, aMDPos
);
270 sal_Bool
FuPoor::IsDetectiveHit( const Point
& rLogicPos
)
272 SdrPageView
* pPV
= pView
->GetSdrPageView();
276 sal_Bool bFound
= false;
277 SdrObjListIter
aIter( *pPV
->GetObjList(), IM_FLAT
);
278 SdrObject
* pObject
= aIter
.Next();
279 while (pObject
&& !bFound
)
281 if (ScDetectiveFunc::IsNonAlienArrow( pObject
))
283 sal_uInt16 nHitLog
= (sal_uInt16
) pWindow
->PixelToLogic(
284 Size(pView
->GetHitTolerancePixel(),0)).Width();
285 if(SdrObjectPrimitiveHit(*pObject
, rLogicPos
, nHitLog
, *pPV
, 0, false))
291 pObject
= aIter
.Next();
296 void FuPoor::StopDragTimer()
298 if (aDragTimer
.IsActive() )
302 /*************************************************************************
304 |* Create default drawing objects via keyboard
306 \************************************************************************/
308 SdrObject
* FuPoor::CreateDefaultObject(const sal_uInt16
/* nID */, const Rectangle
& /* rRectangle */)
310 // empty base implementation
314 void FuPoor::ImpForceQuadratic(Rectangle
& rRect
)
316 if(rRect
.GetWidth() > rRect
.GetHeight())
319 Point(rRect
.Left() + ((rRect
.GetWidth() - rRect
.GetHeight()) / 2), rRect
.Top()),
320 Size(rRect
.GetHeight(), rRect
.GetHeight()));
325 Point(rRect
.Left(), rRect
.Top() + ((rRect
.GetHeight() - rRect
.GetWidth()) / 2)),
326 Size(rRect
.GetWidth(), rRect
.GetWidth()));
331 bool FuPoor::doConstructOrthogonal() const
336 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */