1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sd.hxx" 30 31 #include "fuconuno.hxx" 32 #include <svl/aeitem.hxx> 33 #include <sfx2/dispatch.hxx> 34 #include <sfx2/viewfrm.hxx> 35 #include <sfx2/request.hxx> 36 #include <svl/intitem.hxx> 37 38 39 #include <svx/fmglob.hxx> 40 41 #include <svx/dialogs.hrc> 42 43 class SbModule; 44 45 46 #include "app.hrc" 47 #include "glob.hrc" 48 #include "ViewShell.hxx" 49 #include "View.hxx" 50 #ifndef SD_WINDOW_SHELL_HXX 51 #include "Window.hxx" 52 #endif 53 #include "ViewShellBase.hxx" 54 #include "ToolBarManager.hxx" 55 #include "drawdoc.hxx" 56 #include "sdresid.hxx" 57 #include "res_bmp.hrc" 58 59 namespace sd { 60 61 TYPEINIT1( FuConstructUnoControl, FuConstruct ); 62 63 /************************************************************************* 64 |* 65 |* Konstruktor 66 |* 67 \************************************************************************/ 68 69 FuConstructUnoControl::FuConstructUnoControl ( 70 ViewShell* pViewSh, 71 ::sd::Window* pWin, 72 ::sd::View* pView, 73 SdDrawDocument* pDoc, 74 SfxRequest& rReq) 75 : FuConstruct(pViewSh, pWin, pView, pDoc, rReq) 76 { 77 } 78 79 FunctionReference FuConstructUnoControl::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent ) 80 { 81 FuConstructUnoControl* pFunc; 82 FunctionReference xFunc( pFunc = new FuConstructUnoControl( pViewSh, pWin, pView, pDoc, rReq ) ); 83 xFunc->DoExecute(rReq); 84 pFunc->SetPermanent(bPermanent); 85 return xFunc; 86 } 87 88 void FuConstructUnoControl::DoExecute( SfxRequest& rReq ) 89 { 90 FuConstruct::DoExecute( rReq ); 91 92 SFX_REQUEST_ARG( rReq, pInventorItem, SfxUInt32Item, SID_FM_CONTROL_INVENTOR, sal_False ); 93 SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, sal_False ); 94 if( pInventorItem ) 95 nInventor = pInventorItem->GetValue(); 96 if( pIdentifierItem ) 97 nIdentifier = pIdentifierItem->GetValue(); 98 99 mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar( 100 ToolBarManager::TBG_FUNCTION, 101 ToolBarManager::msDrawingObjectToolBar); 102 } 103 104 /************************************************************************* 105 |* 106 |* MouseButtonDown-event 107 |* 108 \************************************************************************/ 109 sal_Bool FuConstructUnoControl::MouseButtonDown(const MouseEvent& rMEvt) 110 { 111 sal_Bool bReturn = FuConstruct::MouseButtonDown(rMEvt); 112 113 if ( rMEvt.IsLeft() && !mpView->IsAction() ) 114 { 115 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); 116 mpWindow->CaptureMouse(); 117 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() ); 118 mpView->BegCreateObj(aPnt, (OutputDevice*) NULL, nDrgLog); 119 bReturn = sal_True; 120 } 121 return bReturn; 122 } 123 124 /************************************************************************* 125 |* 126 |* MouseMove-event 127 |* 128 \************************************************************************/ 129 sal_Bool FuConstructUnoControl::MouseMove(const MouseEvent& rMEvt) 130 { 131 return FuConstruct::MouseMove(rMEvt); 132 } 133 134 /************************************************************************* 135 |* 136 |* MouseButtonUp-event 137 |* 138 \************************************************************************/ 139 sal_Bool FuConstructUnoControl::MouseButtonUp(const MouseEvent& rMEvt) 140 { 141 sal_Bool bReturn = sal_False; 142 143 if ( mpView->IsCreateObj() && rMEvt.IsLeft() ) 144 { 145 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); 146 mpView->EndCreateObj(SDRCREATE_FORCEEND); 147 bReturn = sal_True; 148 } 149 150 bReturn = (FuConstruct::MouseButtonUp(rMEvt) || bReturn); 151 152 if (!bPermanent) 153 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON); 154 155 return (bReturn); 156 } 157 158 /************************************************************************* 159 |* 160 |* Tastaturereignisse bearbeiten 161 |* 162 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls 163 |* sal_False. 164 |* 165 \************************************************************************/ 166 sal_Bool FuConstructUnoControl::KeyInput(const KeyEvent& rKEvt) 167 { 168 sal_Bool bReturn = FuConstruct::KeyInput(rKEvt); 169 return(bReturn); 170 } 171 172 /************************************************************************* 173 |* 174 |* Function aktivieren 175 |* 176 \************************************************************************/ 177 void FuConstructUnoControl::Activate() 178 { 179 mpView->SetCurrentObj( nIdentifier, nInventor ); 180 181 aNewPointer = Pointer(POINTER_DRAW_RECT); 182 aOldPointer = mpWindow->GetPointer(); 183 mpWindow->SetPointer( aNewPointer ); 184 185 aOldLayer = mpView->GetActiveLayer(); 186 String aStr(SdResId(STR_LAYER_CONTROLS)); 187 mpView->SetActiveLayer( aStr ); 188 189 FuConstruct::Activate(); 190 } 191 192 /************************************************************************* 193 |* 194 |* Function deaktivieren 195 |* 196 \************************************************************************/ 197 void FuConstructUnoControl::Deactivate() 198 { 199 FuConstruct::Deactivate(); 200 mpView->SetActiveLayer( aOldLayer ); 201 mpWindow->SetPointer( aOldPointer ); 202 } 203 204 // #97016# 205 SdrObject* FuConstructUnoControl::CreateDefaultObject(const sal_uInt16, const Rectangle& rRectangle) 206 { 207 // case SID_FM_CREATE_CONTROL: 208 209 SdrObject* pObj = SdrObjFactory::MakeNewObject( 210 mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(), 211 0L, mpDoc); 212 213 if(pObj) 214 { 215 pObj->SetLogicRect(rRectangle); 216 } 217 218 return pObj; 219 } 220 221 } // end of namespace sd 222