GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / sc / source / ui / view / tabvwshh.cxx
blob84e805bfba9bebd3d280fe56b562a95e1da21c04
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 <svx/svdmark.hxx>
21 #include <svx/svdoole2.hxx>
22 #include <svx/svdview.hxx>
23 #include <sfx2/app.hxx>
24 #include <sfx2/objsh.hxx>
25 #include <sfx2/request.hxx>
26 #include <basic/sbxcore.hxx>
27 #include <svl/whiter.hxx>
28 #include <vcl/msgbox.hxx>
30 #include "tabvwsh.hxx"
31 #include "client.hxx"
32 #include "document.hxx"
33 #include "docsh.hxx"
34 #include "sc.hrc"
35 #include "drwlayer.hxx"
36 #include "retypepassdlg.hxx"
37 #include "tabprotection.hxx"
39 #include <memory>
41 using namespace com::sun::star;
43 //------------------------------------------------------------------
45 void ScTabViewShell::ExecuteSbx( SfxRequest& /* rReq */ )
47 // SID_RANGE_OFFSET (Offset),
48 // SID_PIVOT_CREATE (DataPilotCreate) - removed (old Basic)
51 void ScTabViewShell::GetSbxState( SfxItemSet& /* rSet */ )
53 // SID_RANGE_REGION (CurrentRegion) - removed (old Basic)
56 //------------------------------------------------------------------
58 void ScTabViewShell::ExecuteObject( SfxRequest& rReq )
60 sal_uInt16 nSlotId = rReq.GetSlot();
61 const SfxItemSet* pReqArgs = rReq.GetArgs();
63 // Objekte aktivieren/deaktivieren immer auf der sichtbaren View
65 ScTabViewShell* pVisibleSh = this;
66 if ( nSlotId == SID_OLE_SELECT || nSlotId == SID_OLE_ACTIVATE || nSlotId == SID_OLE_DEACTIVATE )
68 OSL_FAIL("old slot SID_OLE...");
71 switch (nSlotId)
73 case SID_OLE_SELECT:
74 case SID_OLE_ACTIVATE:
76 // in beiden Faellen erstmal auf der sichtbaren View selektieren
78 OUString aName;
79 SdrView* pDrView = GetSdrView();
80 if (pDrView)
82 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
83 if (rMarkList.GetMarkCount() == 1)
84 aName = ScDrawLayer::GetVisibleName( rMarkList.GetMark(0)->GetMarkedSdrObj() );
86 pVisibleSh->SelectObject( aName );
88 // aktivieren
90 if ( nSlotId == SID_OLE_ACTIVATE )
91 pVisibleSh->DoVerb( 0 );
93 break;
94 case SID_OLE_DEACTIVATE:
95 pVisibleSh->DeactivateOle();
96 break;
98 case SID_OBJECT_LEFT:
99 case SID_OBJECT_TOP:
100 case SID_OBJECT_WIDTH:
101 case SID_OBJECT_HEIGHT:
103 sal_Bool bDone = false;
104 const SfxPoolItem* pItem;
105 if ( pReqArgs && pReqArgs->GetItemState( nSlotId, sal_True, &pItem ) == SFX_ITEM_SET )
107 long nNewVal = ((const SfxInt32Item*)pItem)->GetValue();
108 if ( nNewVal < 0 )
109 nNewVal = 0;
111 //! von irgendwas in 1/100mm umrechnen ??????
113 SdrView* pDrView = GetSdrView();
114 if ( pDrView )
116 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
117 if (rMarkList.GetMarkCount() == 1)
119 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
120 Rectangle aRect = pObj->GetLogicRect();
122 if ( nSlotId == SID_OBJECT_LEFT )
123 pDrView->MoveMarkedObj( Size( nNewVal - aRect.Left(), 0 ) );
124 else if ( nSlotId == SID_OBJECT_TOP )
125 pDrView->MoveMarkedObj( Size( 0, nNewVal - aRect.Top() ) );
126 else if ( nSlotId == SID_OBJECT_WIDTH )
127 pDrView->ResizeMarkedObj( aRect.TopLeft(),
128 Fraction( nNewVal, aRect.GetWidth() ),
129 Fraction( 1, 1 ) );
130 else // if ( nSlotId == SID_OBJECT_HEIGHT )
131 pDrView->ResizeMarkedObj( aRect.TopLeft(),
132 Fraction( 1, 1 ),
133 Fraction( nNewVal, aRect.GetHeight() ) );
134 bDone = sal_True;
138 #ifndef DISABLE_SCRIPTING
139 if (!bDone)
140 SbxBase::SetError( SbxERR_BAD_PARAMETER ); // Basic-Fehler
141 #endif
143 break;
148 static uno::Reference < embed::XEmbeddedObject > lcl_GetSelectedObj( SdrView* pDrView ) //! Member von ScDrawView?
150 uno::Reference < embed::XEmbeddedObject > xRet;
151 if (pDrView)
153 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
154 if (rMarkList.GetMarkCount() == 1)
156 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
157 if (pObj->GetObjIdentifier() == OBJ_OLE2)
159 SdrOle2Obj* pOle2Obj = (SdrOle2Obj*) pObj;
160 xRet = pOle2Obj->GetObjRef();
165 return xRet;
168 void ScTabViewShell::GetObjectState( SfxItemSet& rSet )
170 // SID_OLE_OBJECT - removed (old Basic)
172 SfxWhichIter aIter(rSet);
173 sal_uInt16 nWhich = aIter.FirstWhich();
174 while ( nWhich )
176 switch (nWhich)
178 case SID_ACTIVE_OBJ_NAME:
180 OUString aName;
181 uno::Reference < embed::XEmbeddedObject > xOLE = lcl_GetSelectedObj( GetSdrView() );
182 if (xOLE.is())
184 aName = GetViewData()->GetSfxDocShell()->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xOLE );
186 rSet.Put( SfxStringItem( nWhich, aName ) );
188 break;
189 case SID_OBJECT_LEFT:
190 case SID_OBJECT_TOP:
191 case SID_OBJECT_WIDTH:
192 case SID_OBJECT_HEIGHT:
194 SdrView* pDrView = GetSdrView();
195 if ( pDrView )
197 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
198 if (rMarkList.GetMarkCount() == 1)
200 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
201 Rectangle aRect = pObj->GetLogicRect();
203 long nVal;
204 if ( nWhich == SID_OBJECT_LEFT )
205 nVal = aRect.Left();
206 else if ( nWhich == SID_OBJECT_TOP )
207 nVal = aRect.Top();
208 else if ( nWhich == SID_OBJECT_WIDTH )
209 nVal = aRect.GetWidth();
210 else // if ( nWhich == SID_OBJECT_HEIGHT )
211 nVal = aRect.GetHeight();
213 //! von 1/100mm in irgendwas umrechnen ??????
215 rSet.Put( SfxInt32Item( nWhich, nVal ) );
219 break;
221 nWhich = aIter.NextWhich();
225 void ScTabViewShell::AddAccessibilityObject( SfxListener& rObject )
227 if (!pAccessibilityBroadcaster)
228 pAccessibilityBroadcaster = new SfxBroadcaster;
230 rObject.StartListening( *pAccessibilityBroadcaster );
231 ScDocument* pDoc = GetViewData()->GetDocument();
232 if (pDoc)
233 pDoc->AddUnoObject(rObject);
236 void ScTabViewShell::RemoveAccessibilityObject( SfxListener& rObject )
238 if (pAccessibilityBroadcaster)
240 rObject.EndListening( *pAccessibilityBroadcaster );
241 ScDocument* pDoc = GetViewData()->GetDocument();
242 if (pDoc)
243 pDoc->RemoveUnoObject(rObject);
245 else
247 OSL_FAIL("kein Accessibility-Broadcaster?");
251 void ScTabViewShell::BroadcastAccessibility( const SfxHint &rHint )
253 if (pAccessibilityBroadcaster)
254 pAccessibilityBroadcaster->Broadcast( rHint );
257 sal_Bool ScTabViewShell::HasAccessibilityObjects()
259 return pAccessibilityBroadcaster != NULL;
262 bool ScTabViewShell::ExecuteRetypePassDlg(ScPasswordHash eDesiredHash)
264 using ::std::auto_ptr;
266 ScDocument* pDoc = GetViewData()->GetDocument();
268 auto_ptr<ScRetypePassDlg> pDlg(new ScRetypePassDlg(GetDialogParent()));
269 pDlg->SetDataFromDocument(*pDoc);
270 pDlg->SetDesiredHash(eDesiredHash);
271 if (pDlg->Execute() != RET_OK)
272 return false;
274 pDlg->WriteNewDataToDocument(*pDoc);
275 return true;
281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */