fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / drawfunc / fupoor.cxx
blobb9e4eae8a67b8606fc24be5b8352e7660403230e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <editeng/outliner.hxx>
21 #include <svx/svditer.hxx>
22 #include <svx/svdobj.hxx>
23 #include <svx/svdpagv.hxx>
25 #include "fupoor.hxx"
26 #include "tabvwsh.hxx"
27 #include "drawview.hxx"
28 #include "detfunc.hxx"
29 #include "document.hxx"
30 #include <vcl/svapp.hxx>
31 #include <svx/sdrhittesthelper.hxx>
33 FuPoor::FuPoor(ScTabViewShell* pViewSh, vcl::Window* pWin, ScDrawView* pViewP,
34 SdrModel* pDoc, SfxRequest& rReq) :
35 pView(pViewP),
36 pViewShell(pViewSh),
37 pWindow(pWin),
38 pDrDoc(pDoc),
39 aSfxRequest(rReq),
40 pDialog(NULL),
41 bIsInDragMode(false),
42 // remember MouseButton state
43 mnCode(0)
45 aScrollTimer.SetTimeoutHdl( LINK(this, FuPoor, ScrollHdl) );
46 aScrollTimer.SetTimeout(SELENG_AUTOREPEAT_INTERVAL);
48 aDragTimer.SetTimeoutHdl( LINK(this, FuPoor, DragTimerHdl) );
49 aDragTimer.SetTimeout(SELENG_DRAGDROP_TIMEOUT);
52 FuPoor::~FuPoor()
54 aDragTimer.Stop();
55 aScrollTimer.Stop();
56 pDialog.disposeAndClear();
59 void FuPoor::Activate()
61 if (pDialog)
63 pDialog->Show();
67 void FuPoor::Deactivate()
69 aDragTimer.Stop();
70 aScrollTimer.Stop();
72 if (pDialog)
74 pDialog->Hide();
78 /*************************************************************************
80 |* Scrollen bei Erreichen des Fensterrandes; wird von
81 |* MouseMove aufgerufen
83 \************************************************************************/
85 void FuPoor::ForceScroll(const Point& aPixPos)
87 aScrollTimer.Stop();
89 Size aSize = pWindow->GetSizePixel();
90 SCsCOL dx = 0;
91 SCsROW dy = 0;
93 if ( aPixPos.X() <= 0 ) dx = -1;
94 if ( aPixPos.X() >= aSize.Width() ) dx = 1;
95 if ( aPixPos.Y() <= 0 ) dy = -1;
96 if ( aPixPos.Y() >= aSize.Height() ) dy = 1;
98 ScViewData& rViewData = pViewShell->GetViewData();
99 if ( rViewData.GetDocument()->IsNegativePage( rViewData.GetTabNo() ) )
100 dx = -dx;
102 ScSplitPos eWhich = rViewData.GetActivePart();
103 if ( dx > 0 && rViewData.GetHSplitMode() == SC_SPLIT_FIX && WhichH(eWhich) == SC_SPLIT_LEFT )
105 pViewShell->ActivatePart( ( eWhich == SC_SPLIT_TOPLEFT ) ?
106 SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT );
107 dx = 0;
109 if ( dy > 0 && rViewData.GetVSplitMode() == SC_SPLIT_FIX && WhichV(eWhich) == SC_SPLIT_TOP )
111 pViewShell->ActivatePart( ( eWhich == SC_SPLIT_TOPLEFT ) ?
112 SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT );
113 dy = 0;
116 if ( dx != 0 || dy != 0 )
118 pViewShell->ScrollLines(2*dx, 4*dy);
119 aScrollTimer.Start();
123 /*************************************************************************
125 |* Timer-Handler fuer Fensterscrolling
127 \************************************************************************/
129 IMPL_LINK_NOARG_TYPED(FuPoor, ScrollHdl, Timer *, void)
131 Point aPosPixel = pWindow->GetPointerPosPixel();
133 // use remembered MouseButton state to create correct
134 // MouseEvents for this artificial MouseMove.
135 MouseMove(MouseEvent(aPosPixel, 1, MouseEventModifiers::NONE, GetMouseButtonCode()));
138 // moved from inline to *.cxx
139 bool FuPoor::MouseButtonUp(const MouseEvent& rMEvt)
141 // remember button state for creation of own MouseEvents
142 SetMouseButtonCode(rMEvt.GetButtons());
144 return false;
147 // moved from inline to *.cxx
148 bool FuPoor::MouseButtonDown(const MouseEvent& rMEvt)
150 // remember button state for creation of own MouseEvents
151 SetMouseButtonCode(rMEvt.GetButtons());
153 return false;
156 /*************************************************************************
158 |* String in Applikations-Statuszeile ausgeben
160 \************************************************************************/
162 // WriteStatus gibt's nicht mehr
164 /*************************************************************************
166 |* Tastaturereignisse bearbeiten
168 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
169 |* FALSE.
171 \************************************************************************/
173 bool FuPoor::KeyInput(const KeyEvent& /* rKEvt */)
175 return false;
178 sal_uInt8 FuPoor::Command(const CommandEvent& rCEvt)
180 if ( CommandEventId::StartDrag == rCEvt.GetCommand() )
182 //!!! sollte Joe eigentlich machen:
183 // nur, wenn im Outliner was selektiert ist, darf
184 // Command sal_True zurueckliefern:
186 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
188 if ( pOutView )
189 return pOutView->HasSelection() ? (pView->Command(rCEvt,pWindow) ? 1 : 0) : SC_CMD_NONE;
190 else
191 return pView->Command(rCEvt,pWindow) ? 1 : 0;
193 else
194 return pView->Command(rCEvt,pWindow) ? 1 : 0;
197 /*************************************************************************
199 |* Timer-Handler fuer Drag&Drop
201 \************************************************************************/
202 IMPL_LINK_NOARG_TYPED(FuPoor, DragTimerHdl, Timer *, void)
204 // ExecuteDrag (und das damit verbundene Reschedule) direkt aus dem Timer
205 // aufzurufen, bringt die VCL-Timer-Verwaltung durcheinander, wenn dabei
206 // (z.B. im Drop) wieder ein Timer gestartet wird (z.B. ComeBack-Timer der
207 // DrawView fuer Solid Handles / ModelHasChanged) - der neue Timer laeuft
208 // dann um die Dauer des Drag&Drop zu spaet ab.
209 // Darum Drag&Drop aus eigenem Event:
211 Application::PostUserEvent( LINK( this, FuPoor, DragHdl ) );
214 IMPL_LINK_NOARG(FuPoor, DragHdl)
216 SdrHdl* pHdl = pView->PickHandle(aMDPos);
218 if ( pHdl==NULL && pView->IsMarkedHit(aMDPos) )
220 pWindow->ReleaseMouse();
221 bIsInDragMode = true;
222 pViewShell->GetScDrawView()->BeginDrag(pWindow, aMDPos);
224 return 0;
227 // Detektiv-Linie
229 bool FuPoor::IsDetectiveHit( const Point& rLogicPos )
231 SdrPageView* pPV = pView->GetSdrPageView();
232 if (!pPV)
233 return false;
235 bool bFound = false;
236 SdrObjListIter aIter( *pPV->GetObjList(), IM_FLAT );
237 SdrObject* pObject = aIter.Next();
238 while (pObject && !bFound)
240 if (ScDetectiveFunc::IsNonAlienArrow( pObject ))
242 sal_uInt16 nHitLog = (sal_uInt16) pWindow->PixelToLogic(
243 Size(pView->GetHitTolerancePixel(),0)).Width();
244 if(SdrObjectPrimitiveHit(*pObject, rLogicPos, nHitLog, *pPV, 0, false))
246 bFound = true;
250 pObject = aIter.Next();
252 return bFound;
255 void FuPoor::StopDragTimer()
257 if (aDragTimer.IsActive() )
258 aDragTimer.Stop();
261 /*************************************************************************
263 |* Create default drawing objects via keyboard
265 \************************************************************************/
267 SdrObject* FuPoor::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& /* rRectangle */)
269 // empty base implementation
270 return 0L;
273 void FuPoor::ImpForceQuadratic(Rectangle& rRect)
275 if(rRect.GetWidth() > rRect.GetHeight())
277 rRect = Rectangle(
278 Point(rRect.Left() + ((rRect.GetWidth() - rRect.GetHeight()) / 2), rRect.Top()),
279 Size(rRect.GetHeight(), rRect.GetHeight()));
281 else
283 rRect = Rectangle(
284 Point(rRect.Left(), rRect.Top() + ((rRect.GetHeight() - rRect.GetWidth()) / 2)),
285 Size(rRect.GetWidth(), rRect.GetWidth()));
289 // #i33136# fdo#88339
290 bool FuPoor::doConstructOrthogonal() const
292 // Detect whether we're moving an object or resizing.
293 bool bIsMoveMode = false;
294 if (pView->IsDragObj())
296 const SdrHdl* pHdl = pView->GetDragStat().GetHdl();
297 if (!pHdl || (!pHdl->IsCornerHdl() && !pHdl->IsVertexHdl()))
299 bIsMoveMode = true;
303 // Detect image and resize proportionally, but don't constrain movement by default
304 if (!bIsMoveMode && pView->AreObjectsMarked())
306 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
307 if (rMarkList.GetMarkCount() == 1)
309 if (rMarkList.GetMark(0)->GetMarkedSdrObj()->GetObjIdentifier() == OBJ_GRAF)
311 return true;
315 return false;
318 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */