Line data Source code
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 <svl/aeitem.hxx>
22 : #include <sfx2/dispatch.hxx>
23 : #include <sfx2/viewfrm.hxx>
24 : #include <sfx2/request.hxx>
25 : #include <svl/intitem.hxx>
26 :
27 : #include <svx/fmglob.hxx>
28 :
29 : #include <svx/dialogs.hrc>
30 :
31 : #include "app.hrc"
32 : #include "glob.hrc"
33 : #include "ViewShell.hxx"
34 : #include "View.hxx"
35 : #include "Window.hxx"
36 : #include "ViewShellBase.hxx"
37 : #include "ToolBarManager.hxx"
38 : #include "drawdoc.hxx"
39 : #include "sdresid.hxx"
40 : #include "res_bmp.hrc"
41 :
42 : namespace sd {
43 :
44 0 : TYPEINIT1( FuConstructUnoControl, FuConstruct );
45 :
46 0 : FuConstructUnoControl::FuConstructUnoControl (
47 : ViewShell* pViewSh,
48 : ::sd::Window* pWin,
49 : ::sd::View* pView,
50 : SdDrawDocument* pDoc,
51 : SfxRequest& rReq)
52 : : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
53 : , nInventor(0)
54 0 : , nIdentifier(0)
55 : {
56 0 : }
57 :
58 0 : rtl::Reference<FuPoor> FuConstructUnoControl::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
59 : {
60 : FuConstructUnoControl* pFunc;
61 0 : rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructUnoControl( pViewSh, pWin, pView, pDoc, rReq ) );
62 0 : xFunc->DoExecute(rReq);
63 0 : pFunc->SetPermanent(bPermanent);
64 0 : return xFunc;
65 : }
66 :
67 0 : void FuConstructUnoControl::DoExecute( SfxRequest& rReq )
68 : {
69 0 : FuConstruct::DoExecute( rReq );
70 :
71 0 : SFX_REQUEST_ARG( rReq, pInventorItem, SfxUInt32Item, SID_FM_CONTROL_INVENTOR, false );
72 0 : SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, false );
73 0 : if( pInventorItem )
74 0 : nInventor = pInventorItem->GetValue();
75 0 : if( pIdentifierItem )
76 0 : nIdentifier = pIdentifierItem->GetValue();
77 :
78 0 : mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
79 : ToolBarManager::TBG_FUNCTION,
80 0 : ToolBarManager::msDrawingObjectToolBar);
81 0 : }
82 :
83 0 : bool FuConstructUnoControl::MouseButtonDown(const MouseEvent& rMEvt)
84 : {
85 0 : bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
86 :
87 0 : if ( rMEvt.IsLeft() && !mpView->IsAction() )
88 : {
89 0 : Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
90 0 : mpWindow->CaptureMouse();
91 0 : sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
92 0 : mpView->BegCreateObj(aPnt, nullptr, nDrgLog);
93 0 : bReturn = true;
94 : }
95 0 : return bReturn;
96 : }
97 :
98 0 : bool FuConstructUnoControl::MouseMove(const MouseEvent& rMEvt)
99 : {
100 0 : return FuConstruct::MouseMove(rMEvt);
101 : }
102 :
103 0 : bool FuConstructUnoControl::MouseButtonUp(const MouseEvent& rMEvt)
104 : {
105 0 : bool bReturn = false;
106 :
107 0 : if ( mpView->IsCreateObj() && rMEvt.IsLeft() )
108 : {
109 0 : mpView->EndCreateObj(SDRCREATE_FORCEEND);
110 0 : bReturn = true;
111 : }
112 :
113 0 : bReturn = (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
114 :
115 0 : if (!bPermanent)
116 0 : mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
117 :
118 0 : return bReturn;
119 : }
120 :
121 : /**
122 : * Process keyboard input
123 : * @returns sal_True if a KeyEvent is being processed, sal_False otherwise
124 : */
125 0 : bool FuConstructUnoControl::KeyInput(const KeyEvent& rKEvt)
126 : {
127 0 : return FuConstruct::KeyInput(rKEvt);
128 : }
129 :
130 0 : void FuConstructUnoControl::Activate()
131 : {
132 0 : mpView->SetCurrentObj( nIdentifier, nInventor );
133 :
134 0 : aNewPointer = Pointer(PointerStyle::DrawRect);
135 0 : aOldPointer = mpWindow->GetPointer();
136 0 : mpWindow->SetPointer( aNewPointer );
137 :
138 0 : aOldLayer = mpView->GetActiveLayer();
139 0 : mpView->SetActiveLayer( SD_RESSTR(STR_LAYER_CONTROLS) );
140 :
141 0 : FuConstruct::Activate();
142 0 : }
143 :
144 0 : void FuConstructUnoControl::Deactivate()
145 : {
146 0 : FuConstruct::Deactivate();
147 0 : mpView->SetActiveLayer( aOldLayer );
148 0 : mpWindow->SetPointer( aOldPointer );
149 0 : }
150 :
151 0 : SdrObject* FuConstructUnoControl::CreateDefaultObject(const sal_uInt16, const Rectangle& rRectangle)
152 : {
153 : // case SID_FM_CREATE_CONTROL:
154 :
155 : SdrObject* pObj = SdrObjFactory::MakeNewObject(
156 0 : mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
157 0 : 0L, mpDoc);
158 :
159 0 : if(pObj)
160 : {
161 0 : pObj->SetLogicRect(rRectangle);
162 : }
163 :
164 0 : return pObj;
165 : }
166 :
167 66 : } // end of namespace sd
168 :
169 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|