/src/libreoffice/sd/source/ui/func/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 <rtl/ustring.hxx> |
22 | | #include <sfx2/dispatch.hxx> |
23 | | #include <sfx2/viewfrm.hxx> |
24 | | #include <sfx2/request.hxx> |
25 | | #include <svl/intitem.hxx> |
26 | | #include <svx/svxids.hrc> |
27 | | #include <vcl/ptrstyle.hxx> |
28 | | |
29 | | #include <ViewShell.hxx> |
30 | | #include <View.hxx> |
31 | | #include <Window.hxx> |
32 | | #include <ViewShellBase.hxx> |
33 | | #include <ToolBarManager.hxx> |
34 | | #include <unokywds.hxx> |
35 | | |
36 | | |
37 | | namespace sd { |
38 | | |
39 | | |
40 | | FuConstructUnoControl::FuConstructUnoControl ( |
41 | | ViewShell& rViewSh, |
42 | | ::sd::Window* pWin, |
43 | | ::sd::View* pView, |
44 | | SdDrawDocument& rDoc, |
45 | | SfxRequest& rReq) |
46 | 0 | : FuConstruct(rViewSh, pWin, pView, rDoc, rReq) |
47 | 0 | , nInventor(SdrInventor::Unknown) |
48 | 0 | , nIdentifier(SdrObjKind::NONE) |
49 | 0 | { |
50 | 0 | } |
51 | | |
52 | | rtl::Reference<FuPoor> FuConstructUnoControl::Create( ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq, bool bPermanent ) |
53 | 0 | { |
54 | 0 | FuConstructUnoControl* pFunc; |
55 | 0 | rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructUnoControl( rViewSh, pWin, pView, rDoc, rReq ) ); |
56 | 0 | xFunc->DoExecute(rReq); |
57 | 0 | pFunc->SetPermanent(bPermanent); |
58 | 0 | return xFunc; |
59 | 0 | } |
60 | | |
61 | | void FuConstructUnoControl::DoExecute( SfxRequest& rReq ) |
62 | 0 | { |
63 | 0 | FuConstruct::DoExecute( rReq ); |
64 | |
|
65 | 0 | const SfxUInt32Item* pInventorItem = rReq.GetArg(SID_FM_CONTROL_INVENTOR); |
66 | 0 | const SfxUInt16Item* pIdentifierItem = rReq.GetArg(SID_FM_CONTROL_IDENTIFIER); |
67 | 0 | if( pInventorItem ) |
68 | 0 | nInventor = static_cast<SdrInventor>(pInventorItem->GetValue()); |
69 | 0 | if( pIdentifierItem ) |
70 | 0 | nIdentifier = static_cast<SdrObjKind>(pIdentifierItem->GetValue()); |
71 | |
|
72 | 0 | mrViewShell.GetViewShellBase().GetToolBarManager()->SetToolBar( |
73 | 0 | ToolBarManager::ToolBarGroup::Function, |
74 | 0 | ToolBarManager::msDrawingObjectToolBar); |
75 | 0 | } |
76 | | |
77 | | bool FuConstructUnoControl::MouseButtonDown(const MouseEvent& rMEvt) |
78 | 0 | { |
79 | 0 | bool bReturn = FuConstruct::MouseButtonDown(rMEvt); |
80 | |
|
81 | 0 | if ( rMEvt.IsLeft() && !mpView->IsAction() ) |
82 | 0 | { |
83 | 0 | Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); |
84 | 0 | mpWindow->CaptureMouse(); |
85 | 0 | sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(mpView->GetDragThresholdPixels(),0)).Width() ); |
86 | 0 | mpView->BegCreateObj(aPnt, nullptr, nDrgLog); |
87 | 0 | bReturn = true; |
88 | 0 | } |
89 | 0 | return bReturn; |
90 | 0 | } |
91 | | |
92 | | bool FuConstructUnoControl::MouseButtonUp(const MouseEvent& rMEvt) |
93 | 0 | { |
94 | 0 | if (rMEvt.IsLeft() && IsIgnoreUnexpectedMouseButtonUp()) |
95 | 0 | return false; |
96 | | |
97 | 0 | bool bReturn = false; |
98 | |
|
99 | 0 | if ( mpView->IsCreateObj() && rMEvt.IsLeft() ) |
100 | 0 | { |
101 | 0 | mpView->EndCreateObj(SdrCreateCmd::ForceEnd); |
102 | 0 | bReturn = true; |
103 | 0 | } |
104 | |
|
105 | 0 | bReturn = (FuConstruct::MouseButtonUp(rMEvt) || bReturn); |
106 | |
|
107 | 0 | if (!bPermanent) |
108 | 0 | mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON); |
109 | |
|
110 | 0 | return bReturn; |
111 | 0 | } |
112 | | |
113 | | void FuConstructUnoControl::Activate() |
114 | 0 | { |
115 | 0 | mpView->SetCurrentObj( nIdentifier, nInventor ); |
116 | |
|
117 | 0 | aNewPointer = PointerStyle::DrawRect; |
118 | 0 | aOldPointer = mpWindow->GetPointer(); |
119 | 0 | mpWindow->SetPointer( aNewPointer ); |
120 | |
|
121 | 0 | aOldLayer = mpView->GetActiveLayer(); |
122 | 0 | mpView->SetActiveLayer(sUNO_LayerName_controls); |
123 | |
|
124 | 0 | FuConstruct::Activate(); |
125 | 0 | } |
126 | | |
127 | | void FuConstructUnoControl::Deactivate() |
128 | 0 | { |
129 | 0 | FuConstruct::Deactivate(); |
130 | 0 | mpView->SetActiveLayer( aOldLayer ); |
131 | 0 | mpWindow->SetPointer( aOldPointer ); |
132 | 0 | } |
133 | | |
134 | | rtl::Reference<SdrObject> FuConstructUnoControl::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& rRectangle) |
135 | 0 | { |
136 | | // case SID_FM_CREATE_CONTROL: |
137 | |
|
138 | 0 | rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject( |
139 | 0 | mpView->getSdrModelFromSdrView(), |
140 | 0 | mpView->GetCurrentObjInventor(), |
141 | 0 | mpView->GetCurrentObjIdentifier())); |
142 | |
|
143 | 0 | if(pObj) |
144 | 0 | { |
145 | 0 | pObj->SetLogicRect(rRectangle); |
146 | 0 | } |
147 | |
|
148 | 0 | return pObj; |
149 | 0 | } |
150 | | |
151 | | } // end of namespace sd |
152 | | |
153 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |