bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / func / fuconuno.cxx
blob6edfaaa769c9a36b8ceb064d6629591eec531219
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 <rtl/ustring.hxx>
22 #include <sfx2/dispatch.hxx>
23 #include <sfx2/viewfrm.hxx>
24 #include <sfx2/request.hxx>
25 #include <svl/intitem.hxx>
26 #include <svx/svxids.hrc>
27 #include <vcl/ptrstyle.hxx>
29 #include <ViewShell.hxx>
30 #include <View.hxx>
31 #include <Window.hxx>
32 #include <ViewShellBase.hxx>
33 #include <ToolBarManager.hxx>
34 #include <unokywds.hxx>
37 namespace sd {
40 FuConstructUnoControl::FuConstructUnoControl (
41 ViewShell* pViewSh,
42 ::sd::Window* pWin,
43 ::sd::View* pView,
44 SdDrawDocument* pDoc,
45 SfxRequest& rReq)
46 : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
47 , nInventor(SdrInventor::Unknown)
48 , nIdentifier(0)
52 rtl::Reference<FuPoor> FuConstructUnoControl::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
54 FuConstructUnoControl* pFunc;
55 rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructUnoControl( pViewSh, pWin, pView, pDoc, rReq ) );
56 xFunc->DoExecute(rReq);
57 pFunc->SetPermanent(bPermanent);
58 return xFunc;
61 void FuConstructUnoControl::DoExecute( SfxRequest& rReq )
63 FuConstruct::DoExecute( rReq );
65 const SfxUInt32Item* pInventorItem = rReq.GetArg<SfxUInt32Item>(SID_FM_CONTROL_INVENTOR);
66 const SfxUInt16Item* pIdentifierItem = rReq.GetArg<SfxUInt16Item>(SID_FM_CONTROL_IDENTIFIER);
67 if( pInventorItem )
68 nInventor = static_cast<SdrInventor>(pInventorItem->GetValue());
69 if( pIdentifierItem )
70 nIdentifier = pIdentifierItem->GetValue();
72 mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
73 ToolBarManager::ToolBarGroup::Function,
74 ToolBarManager::msDrawingObjectToolBar);
77 bool FuConstructUnoControl::MouseButtonDown(const MouseEvent& rMEvt)
79 bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
81 if ( rMEvt.IsLeft() && !mpView->IsAction() )
83 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
84 mpWindow->CaptureMouse();
85 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
86 mpView->BegCreateObj(aPnt, nullptr, nDrgLog);
87 bReturn = true;
89 return bReturn;
92 bool FuConstructUnoControl::MouseButtonUp(const MouseEvent& rMEvt)
94 bool bReturn = false;
96 if ( mpView->IsCreateObj() && rMEvt.IsLeft() )
98 mpView->EndCreateObj(SdrCreateCmd::ForceEnd);
99 bReturn = true;
102 bReturn = (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
104 if (!bPermanent)
105 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
107 return bReturn;
110 void FuConstructUnoControl::Activate()
112 mpView->SetCurrentObj( nIdentifier, nInventor );
114 aNewPointer = PointerStyle::DrawRect;
115 aOldPointer = mpWindow->GetPointer();
116 mpWindow->SetPointer( aNewPointer );
118 aOldLayer = mpView->GetActiveLayer();
119 mpView->SetActiveLayer(sUNO_LayerName_controls);
121 FuConstruct::Activate();
124 void FuConstructUnoControl::Deactivate()
126 FuConstruct::Deactivate();
127 mpView->SetActiveLayer( aOldLayer );
128 mpWindow->SetPointer( aOldPointer );
131 SdrObjectUniquePtr FuConstructUnoControl::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& rRectangle)
133 // case SID_FM_CREATE_CONTROL:
135 SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
136 mpView->getSdrModelFromSdrView(),
137 mpView->GetCurrentObjInventor(),
138 mpView->GetCurrentObjIdentifier()));
140 if(pObj)
142 pObj->SetLogicRect(rRectangle);
145 return pObj;
148 } // end of namespace sd
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */