tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / drawfunc / fuconuno.cxx
blobe3c8f0b4d70e3efd73334d80d6145d0a29032803
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 <tabvwsh.hxx>
22 #include <drawview.hxx>
24 #include <svx/svxids.hrc>
26 FuConstUnoControl::FuConstUnoControl(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pViewP,
27 SdrModel* pDoc, const SfxRequest& rReq)
28 : FuConstruct(rViewSh, pWin, pViewP, pDoc, rReq)
29 , nInventor(SdrInventor::Unknown)
30 , nIdentifier(SdrObjKind::NONE)
32 const SfxUInt32Item* pInventorItem = rReq.GetArg<SfxUInt32Item>(SID_FM_CONTROL_INVENTOR);
33 const SfxUInt16Item* pIdentifierItem = rReq.GetArg<SfxUInt16Item>(SID_FM_CONTROL_IDENTIFIER);
34 if( pInventorItem )
35 nInventor = static_cast<SdrInventor>(pInventorItem->GetValue());
36 if( pIdentifierItem )
37 nIdentifier = static_cast<SdrObjKind>(pIdentifierItem->GetValue());
40 FuConstUnoControl::~FuConstUnoControl()
44 bool FuConstUnoControl::MouseButtonDown(const MouseEvent& rMEvt)
46 // remember button state for creation of own MouseEvents
47 SetMouseButtonCode(rMEvt.GetButtons());
49 bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
51 if ( rMEvt.IsLeft() && !pView->IsAction() )
53 Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
54 pWindow->CaptureMouse();
55 pView->BegCreateObj(aPnt);
56 bReturn = true;
58 return bReturn;
61 bool FuConstUnoControl::MouseButtonUp(const MouseEvent& rMEvt)
63 // remember button state for creation of own MouseEvents
64 SetMouseButtonCode(rMEvt.GetButtons());
66 bool bReturn = false;
68 if ( pView->IsCreateObj() && rMEvt.IsLeft() )
70 pView->EndCreateObj(SdrCreateCmd::ForceEnd);
71 bReturn = true;
73 return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
76 void FuConstUnoControl::Activate()
78 pView->SetCurrentObj( nIdentifier, nInventor );
80 aNewPointer = PointerStyle::DrawRect;
81 aOldPointer = pWindow->GetPointer();
82 rViewShell.SetActivePointer( aNewPointer );
84 SdrLayer* pLayer = pView->GetModel().GetLayerAdmin().GetLayerPerID(SC_LAYER_CONTROLS);
85 if (pLayer)
86 pView->SetActiveLayer( pLayer->GetName() );
88 FuConstruct::Activate();
91 void FuConstUnoControl::Deactivate()
93 FuConstruct::Deactivate();
95 SdrLayer* pLayer = pView->GetModel().GetLayerAdmin().GetLayerPerID(SC_LAYER_FRONT);
96 if (pLayer)
97 pView->SetActiveLayer( pLayer->GetName() );
99 rViewShell.SetActivePointer( aOldPointer );
102 // Create default drawing objects via keyboard
103 rtl::Reference<SdrObject> FuConstUnoControl::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& rRectangle)
105 // case SID_FM_CREATE_CONTROL:
107 rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject(
108 *pDrDoc,
109 pView->GetCurrentObjInventor(),
110 pView->GetCurrentObjIdentifier()));
112 if(pObj)
114 pObj->SetLogicRect(rRectangle);
115 // tdf#140252 Controls are always on layer "controls"
116 pObj->NbcSetLayer(SC_LAYER_CONTROLS);
119 return pObj;
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */