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 .
21 #include "fuconuno.hxx"
22 #include "tabvwsh.hxx"
24 #include "drawview.hxx"
26 /*************************************************************************
30 \************************************************************************/
32 FuConstUnoControl::FuConstUnoControl(ScTabViewShell
* pViewSh
, Window
* pWin
, ScDrawView
* pViewP
,
33 SdrModel
* pDoc
, SfxRequest
& rReq
)
34 : FuConstruct(pViewSh
, pWin
, pViewP
, pDoc
, rReq
)
36 SFX_REQUEST_ARG( rReq
, pInventorItem
, SfxUInt32Item
, SID_FM_CONTROL_INVENTOR
, false );
37 SFX_REQUEST_ARG( rReq
, pIdentifierItem
, SfxUInt16Item
, SID_FM_CONTROL_IDENTIFIER
, false );
39 nInventor
= pInventorItem
->GetValue();
41 nIdentifier
= pIdentifierItem
->GetValue();
44 /*************************************************************************
48 \************************************************************************/
50 FuConstUnoControl::~FuConstUnoControl()
54 /*************************************************************************
56 |* MouseButtonDown-event
58 \************************************************************************/
60 sal_Bool
FuConstUnoControl::MouseButtonDown(const MouseEvent
& rMEvt
)
62 // remember button state for creation of own MouseEvents
63 SetMouseButtonCode(rMEvt
.GetButtons());
65 sal_Bool bReturn
= FuConstruct::MouseButtonDown(rMEvt
);
67 if ( rMEvt
.IsLeft() && !pView
->IsAction() )
69 Point
aPnt( pWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
70 // Hack to align object to nearest grid position where object
71 // would be anchored ( if it were cell anchored )
72 // Get grid offset for current position ( note: aPnt is
74 Point aGridOff
= CurrentGridSyncOffsetAndPos( aPnt
);
76 pWindow
->CaptureMouse();
77 pView
->BegCreateObj(aPnt
);
78 pView
->GetCreateObj()->SetGridOffset( aGridOff
);
84 /*************************************************************************
88 \************************************************************************/
90 sal_Bool
FuConstUnoControl::MouseMove(const MouseEvent
& rMEvt
)
92 return FuConstruct::MouseMove(rMEvt
);
95 /*************************************************************************
97 |* MouseButtonUp-event
99 \************************************************************************/
101 sal_Bool
FuConstUnoControl::MouseButtonUp(const MouseEvent
& rMEvt
)
103 // remember button state for creation of own MouseEvents
104 SetMouseButtonCode(rMEvt
.GetButtons());
106 sal_Bool bReturn
= false;
108 if ( pView
->IsCreateObj() && rMEvt
.IsLeft() )
110 pView
->EndCreateObj(SDRCREATE_FORCEEND
);
113 return (FuConstruct::MouseButtonUp(rMEvt
) || bReturn
);
116 /*************************************************************************
118 |* Tastaturereignisse bearbeiten
120 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
123 \************************************************************************/
125 sal_Bool
FuConstUnoControl::KeyInput(const KeyEvent
& rKEvt
)
127 sal_Bool bReturn
= FuConstruct::KeyInput(rKEvt
);
131 /*************************************************************************
133 |* Function aktivieren
135 \************************************************************************/
137 void FuConstUnoControl::Activate()
139 pView
->SetCurrentObj( nIdentifier
, nInventor
);
141 aNewPointer
= Pointer( POINTER_DRAW_RECT
);
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
);
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */