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
)
38 SFX_REQUEST_ARG( rReq
, pInventorItem
, SfxUInt32Item
, SID_FM_CONTROL_INVENTOR
, false );
39 SFX_REQUEST_ARG( rReq
, pIdentifierItem
, SfxUInt16Item
, SID_FM_CONTROL_IDENTIFIER
, false );
41 nInventor
= pInventorItem
->GetValue();
43 nIdentifier
= pIdentifierItem
->GetValue();
46 /*************************************************************************
50 \************************************************************************/
52 FuConstUnoControl::~FuConstUnoControl()
56 /*************************************************************************
58 |* MouseButtonDown-event
60 \************************************************************************/
62 bool FuConstUnoControl::MouseButtonDown(const MouseEvent
& rMEvt
)
64 // remember button state for creation of own MouseEvents
65 SetMouseButtonCode(rMEvt
.GetButtons());
67 bool bReturn
= FuConstruct::MouseButtonDown(rMEvt
);
69 if ( rMEvt
.IsLeft() && !pView
->IsAction() )
71 Point
aPnt( pWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
72 // Hack to align object to nearest grid position where object
73 // would be anchored ( if it were cell anchored )
74 // Get grid offset for current position ( note: aPnt is
76 Point aGridOff
= CurrentGridSyncOffsetAndPos( aPnt
);
78 pWindow
->CaptureMouse();
79 pView
->BegCreateObj(aPnt
);
80 pView
->GetCreateObj()->SetGridOffset( aGridOff
);
86 /*************************************************************************
90 \************************************************************************/
92 bool FuConstUnoControl::MouseMove(const MouseEvent
& rMEvt
)
94 return FuConstruct::MouseMove(rMEvt
);
97 /*************************************************************************
99 |* MouseButtonUp-event
101 \************************************************************************/
103 bool FuConstUnoControl::MouseButtonUp(const MouseEvent
& rMEvt
)
105 // remember button state for creation of own MouseEvents
106 SetMouseButtonCode(rMEvt
.GetButtons());
108 bool bReturn
= false;
110 if ( pView
->IsCreateObj() && rMEvt
.IsLeft() )
112 pView
->EndCreateObj(SDRCREATE_FORCEEND
);
115 return (FuConstruct::MouseButtonUp(rMEvt
) || bReturn
);
118 /*************************************************************************
120 |* Tastaturereignisse bearbeiten
122 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
125 \************************************************************************/
127 bool FuConstUnoControl::KeyInput(const KeyEvent
& rKEvt
)
129 return FuConstruct::KeyInput(rKEvt
);
132 /*************************************************************************
134 |* Function aktivieren
136 \************************************************************************/
138 void FuConstUnoControl::Activate()
140 pView
->SetCurrentObj( nIdentifier
, nInventor
);
142 aNewPointer
= Pointer( POINTER_DRAW_RECT
);
143 aOldPointer
= pWindow
->GetPointer();
144 pViewShell
->SetActivePointer( aNewPointer
);
146 SdrLayer
* pLayer
= pView
->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_CONTROLS
);
148 pView
->SetActiveLayer( pLayer
->GetName() );
150 FuConstruct::Activate();
153 /*************************************************************************
155 |* Function deaktivieren
157 \************************************************************************/
159 void FuConstUnoControl::Deactivate()
161 FuConstruct::Deactivate();
163 SdrLayer
* pLayer
= pView
->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_FRONT
);
165 pView
->SetActiveLayer( pLayer
->GetName() );
167 pViewShell
->SetActivePointer( aOldPointer
);
170 // Create default drawing objects via keyboard
171 SdrObject
* FuConstUnoControl::CreateDefaultObject(const sal_uInt16
/* nID */, const Rectangle
& rRectangle
)
173 // case SID_FM_CREATE_CONTROL:
175 SdrObject
* pObj
= SdrObjFactory::MakeNewObject(
176 pView
->GetCurrentObjInventor(), pView
->GetCurrentObjIdentifier(),
181 pObj
->SetLogicRect(rRectangle
);
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */