LibreOffice Module sc (master)  1
fuconuno.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <fuconuno.hxx>
21 #include <tabvwsh.hxx>
22 #include <drawview.hxx>
23 
24 #include <svx/svxids.hrc>
25 
27  SdrModel* pDoc, const SfxRequest& rReq)
28  : FuConstruct(rViewSh, pWin, pViewP, pDoc, rReq)
29  , nInventor(SdrInventor::Unknown)
30  , nIdentifier(OBJ_NONE)
31 {
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());
38 }
39 
41 {
42 }
43 
45 {
46  // remember button state for creation of own MouseEvents
48 
49  bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
50 
51  if ( rMEvt.IsLeft() && !pView->IsAction() )
52  {
53  Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
55  pView->BegCreateObj(aPnt);
56  bReturn = true;
57  }
58  return bReturn;
59 }
60 
62 {
63  // remember button state for creation of own MouseEvents
65 
66  bool bReturn = false;
67 
68  if ( pView->IsCreateObj() && rMEvt.IsLeft() )
69  {
70  pView->EndCreateObj(SdrCreateCmd::ForceEnd);
71  bReturn = true;
72  }
73  return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
74 }
75 
77 {
79 
80  aNewPointer = PointerStyle::DrawRect;
83 
85  if (pLayer)
86  pView->SetActiveLayer( pLayer->GetName() );
87 
89 }
90 
92 {
94 
96  if (pLayer)
97  pView->SetActiveLayer( pLayer->GetName() );
98 
100 }
101 
102 // Create default drawing objects via keyboard
103 SdrObjectUniquePtr FuConstUnoControl::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& rRectangle)
104 {
105  // case SID_FM_CREATE_CONTROL:
106 
108  *pDrDoc,
111 
112  if(pObj)
113  {
114  pObj->SetLogicRect(rRectangle);
115  }
116 
117  return pObj;
118 }
119 
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void CaptureMouse()
bool EndCreateObj(SdrCreateCmd eCmd)
PointerStyle aOldPointer
Definition: fudraw.hxx:32
bool BegCreateObj(const Point &rPnt, OutputDevice *pOut=nullptr, short nMinMov=-3)
static SdrObject * MakeNewObject(SdrModel &rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier, const tools::Rectangle *pSnapRect=nullptr)
SdrInventor
SdrModel * pDrDoc
Definition: fupoor.hxx:46
Draw rectangle.
Definition: fuconstr.hxx:26
SdrObjKind
Unknown
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:128
sal_uInt16 GetButtons() const
void SetMouseButtonCode(sal_uInt16 nNew)
Definition: fupoor.hxx:71
ScTabViewShell & rViewShell
Definition: fupoor.hxx:44
virtual void Activate() override
Definition: fuconuno.cxx:76
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:46
PointerStyle GetPointer() const
virtual void Deactivate() override
Definition: fuconuno.cxx:91
void SetActivePointer(PointerStyle nPointer)
Definition: tabview.cxx:893
const T * GetArg(sal_uInt16 nSlotId) const
const OUString & GetName() const
SdrInventor nInventor
Definition: fuconuno.hxx:30
void SetCurrentObj(SdrObjKind nIdent, SdrInventor nInvent=SdrInventor::Default)
SdrLayer * GetLayerPerID(SdrLayerID nID)
bool IsCreateObj() const
Point PixelToLogic(const Point &rDevicePt) const
virtual bool IsAction() const override
SdrObjKind nIdentifier
Definition: fuconuno.hxx:31
constexpr SdrLayerID SC_LAYER_FRONT(0)
bool IsLeft() const
ScDrawView * pView
Definition: fupoor.hxx:43
virtual ~FuConstUnoControl() override
Definition: fuconuno.cxx:40
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
const Point & GetPosPixel() const
virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle &rRectangle) override
Definition: fuconuno.cxx:103
void SetActiveLayer(const OUString &rName)
PointerStyle aNewPointer
Definition: fudraw.hxx:31
sal_uInt32 GetValue() const
FuConstUnoControl(ScTabViewShell &rViewSh, vcl::Window *pWin, ScDrawView *pView, SdrModel *pDoc, const SfxRequest &rReq)
Definition: fuconuno.cxx:26
SdrObjKind GetCurrentObjIdentifier() const
const SdrLayerAdmin & GetLayerAdmin() const
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: fuconuno.cxx:61
OBJ_NONE
SdrModel * GetModel() const
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: fuconuno.cxx:44
constexpr SdrLayerID SC_LAYER_CONTROLS(3)
virtual void Activate()
Definition: fupoor.cxx:59
VclPtr< vcl::Window > pWindow
Definition: fupoor.hxx:45
SdrInventor GetCurrentObjInventor() const
virtual void Deactivate()
Definition: fupoor.cxx:63