fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / drawfunc / fuconuno.cxx
blob3c9828d4bba6cf3e3be53bb84aeae14a7ae6820a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
22 #include "sc.hrc"
23 #include "drawview.hxx"
25 /*************************************************************************
27 |* Konstruktor
29 \************************************************************************/
31 FuConstUnoControl::FuConstUnoControl(ScTabViewShell* pViewSh, vcl::Window* pWin, ScDrawView* pViewP,
32 SdrModel* pDoc, SfxRequest& rReq)
33 : FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq)
34 , nInventor(0)
35 , nIdentifier(0)
37 SFX_REQUEST_ARG( rReq, pInventorItem, SfxUInt32Item, SID_FM_CONTROL_INVENTOR, false );
38 SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, false );
39 if( pInventorItem )
40 nInventor = pInventorItem->GetValue();
41 if( pIdentifierItem )
42 nIdentifier = pIdentifierItem->GetValue();
45 /*************************************************************************
47 |* Destruktor
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
74 // also adjusted )
75 Point aGridOff = CurrentGridSyncOffsetAndPos( aPnt );
77 pWindow->CaptureMouse();
78 pView->BegCreateObj(aPnt);
79 pView->GetCreateObj()->SetGridOffset( aGridOff );
80 bReturn = true;
82 return bReturn;
85 /*************************************************************************
87 |* MouseMove-event
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);
112 bReturn = true;
114 return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
117 /*************************************************************************
119 |* Tastaturereignisse bearbeiten
121 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
122 |* FALSE.
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);
146 if (pLayer)
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);
163 if (pLayer)
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(),
176 0L, pDrDoc);
178 if(pObj)
180 pObj->SetLogicRect(rRectangle);
183 return pObj;
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */