bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / func / fuconuno.cxx
blobdf901883103d645a481a7c960cea2af0315065c0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include "fuconuno.hxx"
21 #include <svl/aeitem.hxx>
22 #include <sfx2/dispatch.hxx>
23 #include <sfx2/viewfrm.hxx>
24 #include <sfx2/request.hxx>
25 #include <svl/intitem.hxx>
27 #include <svx/fmglob.hxx>
29 #include <svx/dialogs.hrc>
31 #include "app.hrc"
32 #include "glob.hrc"
33 #include "ViewShell.hxx"
34 #include "View.hxx"
35 #include "Window.hxx"
36 #include "ViewShellBase.hxx"
37 #include "ToolBarManager.hxx"
38 #include "drawdoc.hxx"
39 #include "sdresid.hxx"
40 #include "res_bmp.hrc"
42 namespace sd {
44 TYPEINIT1( FuConstructUnoControl, FuConstruct );
46 FuConstructUnoControl::FuConstructUnoControl (
47 ViewShell* pViewSh,
48 ::sd::Window* pWin,
49 ::sd::View* pView,
50 SdDrawDocument* pDoc,
51 SfxRequest& rReq)
52 : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
53 , nInventor(0)
54 , nIdentifier(0)
58 rtl::Reference<FuPoor> FuConstructUnoControl::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
60 FuConstructUnoControl* pFunc;
61 rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructUnoControl( pViewSh, pWin, pView, pDoc, rReq ) );
62 xFunc->DoExecute(rReq);
63 pFunc->SetPermanent(bPermanent);
64 return xFunc;
67 void FuConstructUnoControl::DoExecute( SfxRequest& rReq )
69 FuConstruct::DoExecute( rReq );
71 SFX_REQUEST_ARG( rReq, pInventorItem, SfxUInt32Item, SID_FM_CONTROL_INVENTOR, false );
72 SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, false );
73 if( pInventorItem )
74 nInventor = pInventorItem->GetValue();
75 if( pIdentifierItem )
76 nIdentifier = pIdentifierItem->GetValue();
78 mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
79 ToolBarManager::TBG_FUNCTION,
80 ToolBarManager::msDrawingObjectToolBar);
83 bool FuConstructUnoControl::MouseButtonDown(const MouseEvent& rMEvt)
85 bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
87 if ( rMEvt.IsLeft() && !mpView->IsAction() )
89 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
90 mpWindow->CaptureMouse();
91 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
92 mpView->BegCreateObj(aPnt, (OutputDevice*) NULL, nDrgLog);
93 bReturn = true;
95 return bReturn;
98 bool FuConstructUnoControl::MouseMove(const MouseEvent& rMEvt)
100 return FuConstruct::MouseMove(rMEvt);
103 bool FuConstructUnoControl::MouseButtonUp(const MouseEvent& rMEvt)
105 bool bReturn = false;
107 if ( mpView->IsCreateObj() && rMEvt.IsLeft() )
109 mpView->EndCreateObj(SDRCREATE_FORCEEND);
110 bReturn = true;
113 bReturn = (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
115 if (!bPermanent)
116 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
118 return bReturn;
122 * Process keyboard input
123 * @returns sal_True if a KeyEvent is being processed, sal_False otherwise
125 bool FuConstructUnoControl::KeyInput(const KeyEvent& rKEvt)
127 return FuConstruct::KeyInput(rKEvt);
130 void FuConstructUnoControl::Activate()
132 mpView->SetCurrentObj( nIdentifier, nInventor );
134 aNewPointer = Pointer(PointerStyle::DrawRect);
135 aOldPointer = mpWindow->GetPointer();
136 mpWindow->SetPointer( aNewPointer );
138 aOldLayer = mpView->GetActiveLayer();
139 mpView->SetActiveLayer( SD_RESSTR(STR_LAYER_CONTROLS) );
141 FuConstruct::Activate();
144 void FuConstructUnoControl::Deactivate()
146 FuConstruct::Deactivate();
147 mpView->SetActiveLayer( aOldLayer );
148 mpWindow->SetPointer( aOldPointer );
151 SdrObject* FuConstructUnoControl::CreateDefaultObject(const sal_uInt16, const Rectangle& rRectangle)
153 // case SID_FM_CREATE_CONTROL:
155 SdrObject* pObj = SdrObjFactory::MakeNewObject(
156 mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
157 0L, mpDoc);
159 if(pObj)
161 pObj->SetLogicRect(rRectangle);
164 return pObj;
167 } // end of namespace sd
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */