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 .
20 #include "fuconuno.hxx"
21 #include "tabvwsh.hxx"
23 #include "drawview.hxx"
25 /*************************************************************************
29 \************************************************************************/
31 FuConstUnoControl::FuConstUnoControl(ScTabViewShell
* pViewSh
, vcl::Window
* pWin
, ScDrawView
* pViewP
,
32 SdrModel
* pDoc
, SfxRequest
& rReq
)
33 : FuConstruct(pViewSh
, pWin
, pViewP
, pDoc
, rReq
)
37 SFX_REQUEST_ARG( rReq
, pInventorItem
, SfxUInt32Item
, SID_FM_CONTROL_INVENTOR
, false );
38 SFX_REQUEST_ARG( rReq
, pIdentifierItem
, SfxUInt16Item
, SID_FM_CONTROL_IDENTIFIER
, false );
40 nInventor
= pInventorItem
->GetValue();
42 nIdentifier
= pIdentifierItem
->GetValue();
45 /*************************************************************************
49 \************************************************************************/
51 FuConstUnoControl::~FuConstUnoControl()
55 /*************************************************************************
57 |* MouseButtonDown-event
59 \************************************************************************/
61 bool FuConstUnoControl::MouseButtonDown(const MouseEvent
& rMEvt
)
63 // remember button state for creation of own MouseEvents
64 SetMouseButtonCode(rMEvt
.GetButtons());
66 bool bReturn
= FuConstruct::MouseButtonDown(rMEvt
);
68 if ( rMEvt
.IsLeft() && !pView
->IsAction() )
70 Point
aPnt( pWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
71 // Hack to align object to nearest grid position where object
72 // would be anchored ( if it were cell anchored )
73 // Get grid offset for current position ( note: aPnt is
75 Point aGridOff
= CurrentGridSyncOffsetAndPos( aPnt
);
77 pWindow
->CaptureMouse();
78 pView
->BegCreateObj(aPnt
);
79 pView
->GetCreateObj()->SetGridOffset( aGridOff
);
85 /*************************************************************************
89 \************************************************************************/
91 bool FuConstUnoControl::MouseMove(const MouseEvent
& rMEvt
)
93 return FuConstruct::MouseMove(rMEvt
);
96 /*************************************************************************
98 |* MouseButtonUp-event
100 \************************************************************************/
102 bool FuConstUnoControl::MouseButtonUp(const MouseEvent
& rMEvt
)
104 // remember button state for creation of own MouseEvents
105 SetMouseButtonCode(rMEvt
.GetButtons());
107 bool bReturn
= false;
109 if ( pView
->IsCreateObj() && rMEvt
.IsLeft() )
111 pView
->EndCreateObj(SDRCREATE_FORCEEND
);
114 return (FuConstruct::MouseButtonUp(rMEvt
) || bReturn
);
117 /*************************************************************************
119 |* Tastaturereignisse bearbeiten
121 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
124 \************************************************************************/
126 bool FuConstUnoControl::KeyInput(const KeyEvent
& rKEvt
)
128 return FuConstruct::KeyInput(rKEvt
);
131 /*************************************************************************
133 |* Function aktivieren
135 \************************************************************************/
137 void FuConstUnoControl::Activate()
139 pView
->SetCurrentObj( nIdentifier
, nInventor
);
141 aNewPointer
= Pointer( PointerStyle::DrawRect
);
142 aOldPointer
= pWindow
->GetPointer();
143 pViewShell
->SetActivePointer( aNewPointer
);
145 SdrLayer
* pLayer
= pView
->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_CONTROLS
);
147 pView
->SetActiveLayer( pLayer
->GetName() );
149 FuConstruct::Activate();
152 /*************************************************************************
154 |* Function deaktivieren
156 \************************************************************************/
158 void FuConstUnoControl::Deactivate()
160 FuConstruct::Deactivate();
162 SdrLayer
* pLayer
= pView
->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_FRONT
);
164 pView
->SetActiveLayer( pLayer
->GetName() );
166 pViewShell
->SetActivePointer( aOldPointer
);
169 // Create default drawing objects via keyboard
170 SdrObject
* FuConstUnoControl::CreateDefaultObject(const sal_uInt16
/* nID */, const Rectangle
& rRectangle
)
172 // case SID_FM_CREATE_CONTROL:
174 SdrObject
* pObj
= SdrObjFactory::MakeNewObject(
175 pView
->GetCurrentObjInventor(), pView
->GetCurrentObjIdentifier(),
180 pObj
->SetLogicRect(rRectangle
);
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */