1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "fuconuno.hxx"
22 #include <svl/aeitem.hxx>
23 #include <sfx2/dispatch.hxx>
24 #include <sfx2/viewfrm.hxx>
25 #include <sfx2/request.hxx>
26 #include <svl/intitem.hxx>
29 #include <svx/fmglob.hxx>
31 #include <svx/dialogs.hrc>
35 #include "ViewShell.hxx"
38 #include "ViewShellBase.hxx"
39 #include "ToolBarManager.hxx"
40 #include "drawdoc.hxx"
41 #include "sdresid.hxx"
42 #include "res_bmp.hrc"
46 TYPEINIT1( FuConstructUnoControl
, FuConstruct
);
49 FuConstructUnoControl::FuConstructUnoControl (
55 : FuConstruct(pViewSh
, pWin
, pView
, pDoc
, rReq
)
59 FunctionReference
FuConstructUnoControl::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
, bool bPermanent
)
61 FuConstructUnoControl
* pFunc
;
62 FunctionReference
xFunc( pFunc
= new FuConstructUnoControl( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
63 xFunc
->DoExecute(rReq
);
64 pFunc
->SetPermanent(bPermanent
);
68 void FuConstructUnoControl::DoExecute( SfxRequest
& rReq
)
70 FuConstruct::DoExecute( rReq
);
72 SFX_REQUEST_ARG( rReq
, pInventorItem
, SfxUInt32Item
, SID_FM_CONTROL_INVENTOR
, sal_False
);
73 SFX_REQUEST_ARG( rReq
, pIdentifierItem
, SfxUInt16Item
, SID_FM_CONTROL_IDENTIFIER
, sal_False
);
75 nInventor
= pInventorItem
->GetValue();
77 nIdentifier
= pIdentifierItem
->GetValue();
79 mpViewShell
->GetViewShellBase().GetToolBarManager()->SetToolBar(
80 ToolBarManager::TBG_FUNCTION
,
81 ToolBarManager::msDrawingObjectToolBar
);
84 sal_Bool
FuConstructUnoControl::MouseButtonDown(const MouseEvent
& rMEvt
)
86 sal_Bool bReturn
= FuConstruct::MouseButtonDown(rMEvt
);
88 if ( rMEvt
.IsLeft() && !mpView
->IsAction() )
90 Point
aPnt( mpWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
91 mpWindow
->CaptureMouse();
92 sal_uInt16 nDrgLog
= sal_uInt16 ( mpWindow
->PixelToLogic(Size(DRGPIX
,0)).Width() );
93 mpView
->BegCreateObj(aPnt
, (OutputDevice
*) NULL
, nDrgLog
);
99 sal_Bool
FuConstructUnoControl::MouseMove(const MouseEvent
& rMEvt
)
101 return FuConstruct::MouseMove(rMEvt
);
104 sal_Bool
FuConstructUnoControl::MouseButtonUp(const MouseEvent
& rMEvt
)
106 sal_Bool bReturn
= sal_False
;
108 if ( mpView
->IsCreateObj() && rMEvt
.IsLeft() )
110 mpView
->EndCreateObj(SDRCREATE_FORCEEND
);
114 bReturn
= (FuConstruct::MouseButtonUp(rMEvt
) || bReturn
);
117 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SFX_CALLMODE_ASYNCHRON
);
123 * Process keyboard input
124 * @returns sal_True if a KeyEvent is being processed, sal_False otherwise
126 sal_Bool
FuConstructUnoControl::KeyInput(const KeyEvent
& rKEvt
)
128 sal_Bool bReturn
= FuConstruct::KeyInput(rKEvt
);
132 void FuConstructUnoControl::Activate()
134 mpView
->SetCurrentObj( nIdentifier
, nInventor
);
136 aNewPointer
= Pointer(POINTER_DRAW_RECT
);
137 aOldPointer
= mpWindow
->GetPointer();
138 mpWindow
->SetPointer( aNewPointer
);
140 aOldLayer
= mpView
->GetActiveLayer();
141 String
aStr(SdResId(STR_LAYER_CONTROLS
));
142 mpView
->SetActiveLayer( aStr
);
144 FuConstruct::Activate();
147 void FuConstructUnoControl::Deactivate()
149 FuConstruct::Deactivate();
150 mpView
->SetActiveLayer( aOldLayer
);
151 mpWindow
->SetPointer( aOldPointer
);
154 SdrObject
* FuConstructUnoControl::CreateDefaultObject(const sal_uInt16
, const Rectangle
& rRectangle
)
156 // case SID_FM_CREATE_CONTROL:
158 SdrObject
* pObj
= SdrObjFactory::MakeNewObject(
159 mpView
->GetCurrentObjInventor(), mpView
->GetCurrentObjIdentifier(),
164 pObj
->SetLogicRect(rRectangle
);
170 } // end of namespace sd
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */