merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / func / fuconuno.cxx
blob8ffc4e50f303f69c31a65a81d743d20b542f2ef8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fuconuno.cxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "fuconuno.hxx"
35 #include <svtools/aeitem.hxx>
36 #include <sfx2/dispatch.hxx>
37 #include <sfx2/viewfrm.hxx>
38 #include <sfx2/request.hxx>
39 #include <svtools/intitem.hxx>
42 #include <svx/fmglob.hxx>
44 #include <svx/dialogs.hrc>
46 class SbModule;
49 #include "app.hrc"
50 #include "glob.hrc"
51 #include "ViewShell.hxx"
52 #include "View.hxx"
53 #ifndef SD_WINDOW_SHELL_HXX
54 #include "Window.hxx"
55 #endif
56 #include "ViewShellBase.hxx"
57 #include "ToolBarManager.hxx"
58 #include "drawdoc.hxx"
59 #include "sdresid.hxx"
60 #include "res_bmp.hrc"
62 namespace sd {
64 TYPEINIT1( FuConstructUnoControl, FuConstruct );
66 /*************************************************************************
68 |* Konstruktor
70 \************************************************************************/
72 FuConstructUnoControl::FuConstructUnoControl (
73 ViewShell* pViewSh,
74 ::sd::Window* pWin,
75 ::sd::View* pView,
76 SdDrawDocument* pDoc,
77 SfxRequest& rReq)
78 : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
82 FunctionReference FuConstructUnoControl::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
84 FuConstructUnoControl* pFunc;
85 FunctionReference xFunc( pFunc = new FuConstructUnoControl( pViewSh, pWin, pView, pDoc, rReq ) );
86 xFunc->DoExecute(rReq);
87 pFunc->SetPermanent(bPermanent);
88 return xFunc;
91 void FuConstructUnoControl::DoExecute( SfxRequest& rReq )
93 FuConstruct::DoExecute( rReq );
95 SFX_REQUEST_ARG( rReq, pInventorItem, SfxUInt32Item, SID_FM_CONTROL_INVENTOR, FALSE );
96 SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, FALSE );
97 if( pInventorItem )
98 nInventor = pInventorItem->GetValue();
99 if( pIdentifierItem )
100 nIdentifier = pIdentifierItem->GetValue();
102 mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
103 ToolBarManager::TBG_FUNCTION,
104 ToolBarManager::msDrawingObjectToolBar);
107 /*************************************************************************
109 |* MouseButtonDown-event
111 \************************************************************************/
112 BOOL FuConstructUnoControl::MouseButtonDown(const MouseEvent& rMEvt)
114 BOOL bReturn = FuConstruct::MouseButtonDown(rMEvt);
116 if ( rMEvt.IsLeft() && !mpView->IsAction() )
118 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
119 mpWindow->CaptureMouse();
120 USHORT nDrgLog = USHORT ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
121 mpView->BegCreateObj(aPnt, (OutputDevice*) NULL, nDrgLog);
122 bReturn = TRUE;
124 return bReturn;
127 /*************************************************************************
129 |* MouseMove-event
131 \************************************************************************/
132 BOOL FuConstructUnoControl::MouseMove(const MouseEvent& rMEvt)
134 return FuConstruct::MouseMove(rMEvt);
137 /*************************************************************************
139 |* MouseButtonUp-event
141 \************************************************************************/
142 BOOL FuConstructUnoControl::MouseButtonUp(const MouseEvent& rMEvt)
144 BOOL bReturn = FALSE;
146 if ( mpView->IsCreateObj() && rMEvt.IsLeft() )
148 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
149 mpView->EndCreateObj(SDRCREATE_FORCEEND);
150 bReturn = TRUE;
153 bReturn = (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
155 if (!bPermanent)
156 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
158 return (bReturn);
161 /*************************************************************************
163 |* Tastaturereignisse bearbeiten
165 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
166 |* FALSE.
168 \************************************************************************/
169 BOOL FuConstructUnoControl::KeyInput(const KeyEvent& rKEvt)
171 BOOL bReturn = FuConstruct::KeyInput(rKEvt);
172 return(bReturn);
175 /*************************************************************************
177 |* Function aktivieren
179 \************************************************************************/
180 void FuConstructUnoControl::Activate()
182 mpView->SetCurrentObj( nIdentifier, nInventor );
184 aNewPointer = Pointer(POINTER_DRAW_RECT);
185 aOldPointer = mpWindow->GetPointer();
186 mpWindow->SetPointer( aNewPointer );
188 aOldLayer = mpView->GetActiveLayer();
189 String aStr(SdResId(STR_LAYER_CONTROLS));
190 mpView->SetActiveLayer( aStr );
192 FuConstruct::Activate();
195 /*************************************************************************
197 |* Function deaktivieren
199 \************************************************************************/
200 void FuConstructUnoControl::Deactivate()
202 FuConstruct::Deactivate();
203 mpView->SetActiveLayer( aOldLayer );
204 mpWindow->SetPointer( aOldPointer );
207 // #97016#
208 SdrObject* FuConstructUnoControl::CreateDefaultObject(const sal_uInt16, const Rectangle& rRectangle)
210 // case SID_FM_CREATE_CONTROL:
212 SdrObject* pObj = SdrObjFactory::MakeNewObject(
213 mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
214 0L, mpDoc);
216 if(pObj)
218 pObj->SetLogicRect(rRectangle);
221 return pObj;
224 } // end of namespace sd