/src/libreoffice/sc/source/ui/drawfunc/fuconuno.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <fuconuno.hxx> |
21 | | #include <tabvwsh.hxx> |
22 | | #include <drawview.hxx> |
23 | | |
24 | | #include <svx/svxids.hrc> |
25 | | #include <vcl/ptrstyle.hxx> |
26 | | |
27 | | FuConstUnoControl::FuConstUnoControl(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pViewP, |
28 | | SdrModel& rDoc, const SfxRequest& rReq) |
29 | 0 | : FuConstruct(rViewSh, pWin, pViewP, rDoc, rReq) |
30 | 0 | , nInventor(SdrInventor::Unknown) |
31 | 0 | , nIdentifier(SdrObjKind::NONE) |
32 | 0 | { |
33 | 0 | const SfxUInt32Item* pInventorItem = rReq.GetArg(SID_FM_CONTROL_INVENTOR); |
34 | 0 | const SfxUInt16Item* pIdentifierItem = rReq.GetArg(SID_FM_CONTROL_IDENTIFIER); |
35 | 0 | if( pInventorItem ) |
36 | 0 | nInventor = static_cast<SdrInventor>(pInventorItem->GetValue()); |
37 | 0 | if( pIdentifierItem ) |
38 | 0 | nIdentifier = static_cast<SdrObjKind>(pIdentifierItem->GetValue()); |
39 | 0 | } |
40 | | |
41 | | FuConstUnoControl::~FuConstUnoControl() |
42 | 0 | { |
43 | 0 | } |
44 | | |
45 | | bool FuConstUnoControl::MouseButtonDown(const MouseEvent& rMEvt) |
46 | 0 | { |
47 | | // remember button state for creation of own MouseEvents |
48 | 0 | SetMouseButtonCode(rMEvt.GetButtons()); |
49 | |
|
50 | 0 | bool bReturn = FuConstruct::MouseButtonDown(rMEvt); |
51 | |
|
52 | 0 | if ( rMEvt.IsLeft() && !pView->IsAction() ) |
53 | 0 | { |
54 | 0 | Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); |
55 | 0 | pWindow->CaptureMouse(); |
56 | 0 | pView->BegCreateObj(aPnt); |
57 | 0 | bReturn = true; |
58 | 0 | } |
59 | 0 | return bReturn; |
60 | 0 | } |
61 | | |
62 | | bool FuConstUnoControl::MouseButtonUp(const MouseEvent& rMEvt) |
63 | 0 | { |
64 | | // remember button state for creation of own MouseEvents |
65 | 0 | SetMouseButtonCode(rMEvt.GetButtons()); |
66 | |
|
67 | 0 | bool bReturn = false; |
68 | |
|
69 | 0 | if ( pView->IsCreateObj() && rMEvt.IsLeft() ) |
70 | 0 | { |
71 | 0 | pView->EndCreateObj(SdrCreateCmd::ForceEnd); |
72 | 0 | bReturn = true; |
73 | 0 | } |
74 | 0 | return (FuConstruct::MouseButtonUp(rMEvt) || bReturn); |
75 | 0 | } |
76 | | |
77 | | void FuConstUnoControl::Activate() |
78 | 0 | { |
79 | 0 | pView->SetCurrentObj( nIdentifier, nInventor ); |
80 | |
|
81 | 0 | aNewPointer = PointerStyle::DrawRect; |
82 | 0 | aOldPointer = pWindow->GetPointer(); |
83 | 0 | rViewShell.SetActivePointer( aNewPointer ); |
84 | |
|
85 | 0 | SdrLayer* pLayer = pView->GetModel().GetLayerAdmin().GetLayerPerID(SC_LAYER_CONTROLS); |
86 | 0 | if (pLayer) |
87 | 0 | pView->SetActiveLayer( pLayer->GetName() ); |
88 | |
|
89 | 0 | FuConstruct::Activate(); |
90 | 0 | } |
91 | | |
92 | | void FuConstUnoControl::Deactivate() |
93 | 0 | { |
94 | 0 | FuConstruct::Deactivate(); |
95 | |
|
96 | 0 | SdrLayer* pLayer = pView->GetModel().GetLayerAdmin().GetLayerPerID(SC_LAYER_FRONT); |
97 | 0 | if (pLayer) |
98 | 0 | pView->SetActiveLayer( pLayer->GetName() ); |
99 | |
|
100 | 0 | rViewShell.SetActivePointer( aOldPointer ); |
101 | 0 | } |
102 | | |
103 | | // Create default drawing objects via keyboard |
104 | | rtl::Reference<SdrObject> FuConstUnoControl::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& rRectangle) |
105 | 0 | { |
106 | | // case SID_FM_CREATE_CONTROL: |
107 | |
|
108 | 0 | rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject( |
109 | 0 | rDrDoc, |
110 | 0 | pView->GetCurrentObjInventor(), |
111 | 0 | pView->GetCurrentObjIdentifier())); |
112 | |
|
113 | 0 | if(pObj) |
114 | 0 | { |
115 | 0 | pObj->SetLogicRect(rRectangle); |
116 | | // tdf#140252 Controls are always on layer "controls" |
117 | 0 | pObj->NbcSetLayer(SC_LAYER_CONTROLS); |
118 | 0 | } |
119 | |
|
120 | 0 | return pObj; |
121 | 0 | } |
122 | | |
123 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |