1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fuconuno.cxx,v $
10 * $Revision: 1.10.128.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include "fuconuno.hxx"
35 #include "tabvwsh.hxx"
37 #include "drawview.hxx"
39 /*************************************************************************
43 \************************************************************************/
45 FuConstUnoControl::FuConstUnoControl(ScTabViewShell
* pViewSh
, Window
* pWin
, ScDrawView
* pViewP
,
46 SdrModel
* pDoc
, SfxRequest
& rReq
)
47 : FuConstruct(pViewSh
, pWin
, pViewP
, pDoc
, rReq
)
49 SFX_REQUEST_ARG( rReq
, pInventorItem
, SfxUInt32Item
, SID_FM_CONTROL_INVENTOR
, FALSE
);
50 SFX_REQUEST_ARG( rReq
, pIdentifierItem
, SfxUInt16Item
, SID_FM_CONTROL_IDENTIFIER
, FALSE
);
52 nInventor
= pInventorItem
->GetValue();
54 nIdentifier
= pIdentifierItem
->GetValue();
57 /*************************************************************************
61 \************************************************************************/
63 FuConstUnoControl::~FuConstUnoControl()
67 /*************************************************************************
69 |* MouseButtonDown-event
71 \************************************************************************/
73 BOOL __EXPORT
FuConstUnoControl::MouseButtonDown(const MouseEvent
& rMEvt
)
75 // #95491# remember button state for creation of own MouseEvents
76 SetMouseButtonCode(rMEvt
.GetButtons());
78 BOOL bReturn
= FuConstruct::MouseButtonDown(rMEvt
);
80 if ( rMEvt
.IsLeft() && !pView
->IsAction() )
82 Point
aPnt( pWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
83 pWindow
->CaptureMouse();
84 pView
->BegCreateObj(aPnt
);
90 /*************************************************************************
94 \************************************************************************/
96 BOOL __EXPORT
FuConstUnoControl::MouseMove(const MouseEvent
& rMEvt
)
98 return FuConstruct::MouseMove(rMEvt
);
101 /*************************************************************************
103 |* MouseButtonUp-event
105 \************************************************************************/
107 BOOL __EXPORT
FuConstUnoControl::MouseButtonUp(const MouseEvent
& rMEvt
)
109 // #95491# remember button state for creation of own MouseEvents
110 SetMouseButtonCode(rMEvt
.GetButtons());
112 BOOL bReturn
= FALSE
;
114 if ( pView
->IsCreateObj() && rMEvt
.IsLeft() )
116 Point
aPnt( pWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
117 pView
->EndCreateObj(SDRCREATE_FORCEEND
);
120 return (FuConstruct::MouseButtonUp(rMEvt
) || bReturn
);
123 /*************************************************************************
125 |* Tastaturereignisse bearbeiten
127 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
130 \************************************************************************/
132 BOOL __EXPORT
FuConstUnoControl::KeyInput(const KeyEvent
& rKEvt
)
134 BOOL bReturn
= FuConstruct::KeyInput(rKEvt
);
138 /*************************************************************************
140 |* Function aktivieren
142 \************************************************************************/
144 void FuConstUnoControl::Activate()
146 pView
->SetCurrentObj( nIdentifier
, nInventor
);
148 aNewPointer
= Pointer( POINTER_DRAW_RECT
);
149 aOldPointer
= pWindow
->GetPointer();
150 pViewShell
->SetActivePointer( aNewPointer
);
152 SdrLayer
* pLayer
= pView
->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_CONTROLS
);
154 pView
->SetActiveLayer( pLayer
->GetName() );
156 FuConstruct::Activate();
159 /*************************************************************************
161 |* Function deaktivieren
163 \************************************************************************/
165 void FuConstUnoControl::Deactivate()
167 FuConstruct::Deactivate();
169 SdrLayer
* pLayer
= pView
->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_FRONT
);
171 pView
->SetActiveLayer( pLayer
->GetName() );
173 pViewShell
->SetActivePointer( aOldPointer
);
176 // #98185# Create default drawing objects via keyboard
177 SdrObject
* FuConstUnoControl::CreateDefaultObject(const sal_uInt16
/* nID */, const Rectangle
& rRectangle
)
179 // case SID_FM_CREATE_CONTROL:
181 SdrObject
* pObj
= SdrObjFactory::MakeNewObject(
182 pView
->GetCurrentObjInventor(), pView
->GetCurrentObjIdentifier(),
187 pObj
->SetLogicRect(rRectangle
);