1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sd.hxx" 26 27 28 29 #include "fudspord.hxx" 30 31 #include <svx/svxids.hrc> 32 #include <vcl/pointr.hxx> 33 34 #include "app.hrc" 35 #include "fupoor.hxx" 36 #include "ViewShell.hxx" 37 #include "View.hxx" 38 #ifndef SD_WINDOW_SHELL_HXX 39 #include "Window.hxx" 40 #endif 41 #include "drawdoc.hxx" 42 43 namespace sd { 44 45 TYPEINIT1( FuDisplayOrder, FuPoor ); 46 47 /************************************************************************* 48 |* 49 |* Konstruktor 50 |* 51 \************************************************************************/ 52 53 FuDisplayOrder::FuDisplayOrder( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq) 54 : FuPoor(pViewSh, pWin, pView, pDoc, rReq) 55 , mpRefObj(NULL) 56 , mpOverlay(0L) 57 { 58 } 59 60 /************************************************************************* 61 |* 62 |* Destruktor 63 |* 64 \************************************************************************/ 65 66 FuDisplayOrder::~FuDisplayOrder() 67 { 68 implClearOverlay(); 69 } 70 71 void FuDisplayOrder::implClearOverlay() 72 { 73 if(mpOverlay) 74 { 75 delete mpOverlay; 76 mpOverlay = 0L; 77 } 78 } 79 80 FunctionReference FuDisplayOrder::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ) 81 { 82 FunctionReference xFunc( new FuDisplayOrder( pViewSh, pWin, pView, pDoc, rReq ) ); 83 return xFunc; 84 } 85 86 /************************************************************************* 87 |* 88 |* MouseButtonDown-event 89 |* 90 \************************************************************************/ 91 92 sal_Bool FuDisplayOrder::MouseButtonDown(const MouseEvent& rMEvt) 93 { 94 // #95491# remember button state for creation of own MouseEvents 95 SetMouseButtonCode(rMEvt.GetButtons()); 96 97 return sal_True; 98 } 99 100 /************************************************************************* 101 |* 102 |* MouseMove-event 103 |* 104 \************************************************************************/ 105 106 sal_Bool FuDisplayOrder::MouseMove(const MouseEvent& rMEvt) 107 { 108 SdrObject* pPickObj; 109 SdrPageView* pPV; 110 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); 111 112 if ( mpView->PickObj(aPnt, mpView->getHitTolLog(), pPickObj, pPV) ) 113 { 114 if (mpRefObj != pPickObj) 115 { 116 // delete current overlay 117 implClearOverlay(); 118 119 // create new one 120 mpOverlay = new SdrDropMarkerOverlay(*mpView, *pPickObj); 121 122 // remember referenced object 123 mpRefObj = pPickObj; 124 } 125 } 126 else 127 { 128 mpRefObj = NULL; 129 implClearOverlay(); 130 } 131 132 return sal_True; 133 } 134 135 /************************************************************************* 136 |* 137 |* MouseButtonUp-event 138 |* 139 \************************************************************************/ 140 141 sal_Bool FuDisplayOrder::MouseButtonUp(const MouseEvent& rMEvt) 142 { 143 // #95491# remember button state for creation of own MouseEvents 144 SetMouseButtonCode(rMEvt.GetButtons()); 145 146 SdrPageView* pPV = NULL; 147 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); 148 149 if ( mpView->PickObj(aPnt, mpView->getHitTolLog(), mpRefObj, pPV) ) 150 { 151 if (nSlotId == SID_BEFORE_OBJ) 152 { 153 mpView->PutMarkedInFrontOfObj(mpRefObj); 154 } 155 else 156 { 157 mpView->PutMarkedBehindObj(mpRefObj); 158 } 159 } 160 161 mpViewShell->Cancel(); 162 163 return sal_True; 164 } 165 166 /************************************************************************* 167 |* 168 |* Function aktivieren 169 |* 170 \************************************************************************/ 171 172 void FuDisplayOrder::Activate() 173 { 174 maPtr = mpWindow->GetPointer(); 175 mpWindow->SetPointer( Pointer( POINTER_REFHAND ) ); 176 } 177 178 /************************************************************************* 179 |* 180 |* Function deaktivieren 181 |* 182 \************************************************************************/ 183 184 void FuDisplayOrder::Deactivate() 185 { 186 mpWindow->SetPointer( maPtr ); 187 } 188 189 190 } // end of namespace sd 191