Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sd / source / ui / func / fudspord.cxx
blobe867c2fe6ed4a731e0410ca86f3146a78cd1657b
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 <fudspord.hxx>
22 #include <svx/svxids.hrc>
23 #include <vcl/pointr.hxx>
25 #include <app.hrc>
26 #include <fupoor.hxx>
27 #include <ViewShell.hxx>
28 #include <View.hxx>
29 #include <Window.hxx>
30 #include <drawdoc.hxx>
32 namespace sd {
35 FuDisplayOrder::FuDisplayOrder( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq)
36 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
37 , mpRefObj(nullptr)
38 , mpOverlay(nullptr)
42 FuDisplayOrder::~FuDisplayOrder()
44 implClearOverlay();
47 void FuDisplayOrder::implClearOverlay()
49 if(mpOverlay)
51 delete mpOverlay;
52 mpOverlay = nullptr;
56 rtl::Reference<FuPoor> FuDisplayOrder::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
58 rtl::Reference<FuPoor> xFunc( new FuDisplayOrder( pViewSh, pWin, pView, pDoc, rReq ) );
59 return xFunc;
62 bool FuDisplayOrder::MouseButtonDown(const MouseEvent& rMEvt)
64 // remember button state for creation of own MouseEvents
65 SetMouseButtonCode(rMEvt.GetButtons());
67 return true;
70 bool FuDisplayOrder::MouseMove(const MouseEvent& rMEvt)
72 SdrPageView* pPV;
73 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
75 SdrObject* pPickObj = mpView->PickObj(aPnt, mpView->getHitTolLog(), pPV);
76 if (pPickObj)
78 if (mpRefObj != pPickObj)
80 // delete current overlay
81 implClearOverlay();
83 // create new one
84 mpOverlay = new SdrDropMarkerOverlay(*mpView, *pPickObj);
86 // remember referenced object
87 mpRefObj = pPickObj;
90 else
92 mpRefObj = nullptr;
93 implClearOverlay();
96 return true;
99 bool FuDisplayOrder::MouseButtonUp(const MouseEvent& rMEvt)
101 // remember button state for creation of own MouseEvents
102 SetMouseButtonCode(rMEvt.GetButtons());
104 SdrPageView* pPV = nullptr;
105 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
107 mpRefObj = mpView->PickObj(aPnt, mpView->getHitTolLog(), pPV);
108 if (mpRefObj)
110 if (nSlotId == SID_BEFORE_OBJ)
112 mpView->PutMarkedInFrontOfObj(mpRefObj);
114 else
116 mpView->PutMarkedBehindObj(mpRefObj);
120 mpViewShell->Cancel();
122 return true;
125 void FuDisplayOrder::Activate()
127 maPtr = mpWindow->GetPointer();
128 mpWindow->SetPointer( Pointer( PointerStyle::RefHand ) );
131 void FuDisplayOrder::Deactivate()
133 mpWindow->SetPointer( maPtr );
136 } // end of namespace sd
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */