1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fuconuno.cxx,v $
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>
51 #include "ViewShell.hxx"
53 #ifndef SD_WINDOW_SHELL_HXX
56 #include "ViewShellBase.hxx"
57 #include "ToolBarManager.hxx"
58 #include "drawdoc.hxx"
59 #include "sdresid.hxx"
60 #include "res_bmp.hrc"
64 TYPEINIT1( FuConstructUnoControl
, FuConstruct
);
66 /*************************************************************************
70 \************************************************************************/
72 FuConstructUnoControl::FuConstructUnoControl (
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
);
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
);
98 nInventor
= pInventorItem
->GetValue();
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
);
127 /*************************************************************************
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
);
153 bReturn
= (FuConstruct::MouseButtonUp(rMEvt
) || bReturn
);
156 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SFX_CALLMODE_ASYNCHRON
);
161 /*************************************************************************
163 |* Tastaturereignisse bearbeiten
165 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
168 \************************************************************************/
169 BOOL
FuConstructUnoControl::KeyInput(const KeyEvent
& rKEvt
)
171 BOOL bReturn
= FuConstruct::KeyInput(rKEvt
);
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
);
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(),
218 pObj
->SetLogicRect(rRectangle
);
224 } // end of namespace sd