Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "fudspord.hxx"
21 :
22 : #include <svx/svxids.hrc>
23 : #include <vcl/pointr.hxx>
24 :
25 : #include "app.hrc"
26 : #include "fupoor.hxx"
27 : #include "ViewShell.hxx"
28 : #include "View.hxx"
29 : #include "Window.hxx"
30 : #include "drawdoc.hxx"
31 :
32 : namespace sd {
33 :
34 0 : TYPEINIT1( FuDisplayOrder, FuPoor );
35 :
36 0 : FuDisplayOrder::FuDisplayOrder( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq)
37 : : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
38 : , mpRefObj(NULL)
39 0 : , mpOverlay(0L)
40 : {
41 0 : }
42 :
43 0 : FuDisplayOrder::~FuDisplayOrder()
44 : {
45 0 : implClearOverlay();
46 0 : }
47 :
48 0 : void FuDisplayOrder::implClearOverlay()
49 : {
50 0 : if(mpOverlay)
51 : {
52 0 : delete mpOverlay;
53 0 : mpOverlay = 0L;
54 : }
55 0 : }
56 :
57 0 : rtl::Reference<FuPoor> FuDisplayOrder::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
58 : {
59 0 : rtl::Reference<FuPoor> xFunc( new FuDisplayOrder( pViewSh, pWin, pView, pDoc, rReq ) );
60 0 : return xFunc;
61 : }
62 :
63 0 : bool FuDisplayOrder::MouseButtonDown(const MouseEvent& rMEvt)
64 : {
65 : // remember button state for creation of own MouseEvents
66 0 : SetMouseButtonCode(rMEvt.GetButtons());
67 :
68 0 : return true;
69 : }
70 :
71 0 : bool FuDisplayOrder::MouseMove(const MouseEvent& rMEvt)
72 : {
73 : SdrObject* pPickObj;
74 : SdrPageView* pPV;
75 0 : Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
76 :
77 0 : if ( mpView->PickObj(aPnt, mpView->getHitTolLog(), pPickObj, pPV) )
78 : {
79 0 : if (mpRefObj != pPickObj)
80 : {
81 : // delete current overlay
82 0 : implClearOverlay();
83 :
84 : // create new one
85 0 : mpOverlay = new SdrDropMarkerOverlay(*mpView, *pPickObj);
86 :
87 : // remember referenced object
88 0 : mpRefObj = pPickObj;
89 : }
90 : }
91 : else
92 : {
93 0 : mpRefObj = NULL;
94 0 : implClearOverlay();
95 : }
96 :
97 0 : return true;
98 : }
99 :
100 0 : bool FuDisplayOrder::MouseButtonUp(const MouseEvent& rMEvt)
101 : {
102 : // remember button state for creation of own MouseEvents
103 0 : SetMouseButtonCode(rMEvt.GetButtons());
104 :
105 0 : SdrPageView* pPV = NULL;
106 0 : Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
107 :
108 0 : if ( mpView->PickObj(aPnt, mpView->getHitTolLog(), mpRefObj, pPV) )
109 : {
110 0 : if (nSlotId == SID_BEFORE_OBJ)
111 : {
112 0 : mpView->PutMarkedInFrontOfObj(mpRefObj);
113 : }
114 : else
115 : {
116 0 : mpView->PutMarkedBehindObj(mpRefObj);
117 : }
118 : }
119 :
120 0 : mpViewShell->Cancel();
121 :
122 0 : return true;
123 : }
124 :
125 0 : void FuDisplayOrder::Activate()
126 : {
127 0 : maPtr = mpWindow->GetPointer();
128 0 : mpWindow->SetPointer( Pointer( PointerStyle::RefHand ) );
129 0 : }
130 :
131 0 : void FuDisplayOrder::Deactivate()
132 : {
133 0 : mpWindow->SetPointer( maPtr );
134 0 : }
135 :
136 66 : } // end of namespace sd
137 :
138 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|