fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / view / tabvwshh.cxx
blob17dbaa8d2831f4f88a37a1ae40043dcdd3ee9f0b
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 <config_features.h>
22 #include <svx/svdmark.hxx>
23 #include <svx/svdoole2.hxx>
24 #include <svx/svdview.hxx>
25 #include <sfx2/app.hxx>
26 #include <sfx2/objsh.hxx>
27 #include <sfx2/request.hxx>
28 #include <basic/sbxcore.hxx>
29 #include <svl/whiter.hxx>
30 #include <vcl/msgbox.hxx>
32 #include "tabvwsh.hxx"
33 #include "client.hxx"
34 #include "document.hxx"
35 #include "docsh.hxx"
36 #include "sc.hrc"
37 #include "drwlayer.hxx"
38 #include "retypepassdlg.hxx"
39 #include "tabprotection.hxx"
41 #include <boost/scoped_ptr.hpp>
43 using namespace com::sun::star;
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 void ScTabViewShell::ExecuteObject( SfxRequest& rReq )
58 sal_uInt16 nSlotId = rReq.GetSlot();
59 const SfxItemSet* pReqArgs = rReq.GetArgs();
61 // Objekte aktivieren/deaktivieren immer auf der sichtbaren View
63 ScTabViewShell* pVisibleSh = this;
64 if ( nSlotId == SID_OLE_SELECT || nSlotId == SID_OLE_ACTIVATE || nSlotId == SID_OLE_DEACTIVATE )
66 OSL_FAIL("old slot SID_OLE...");
69 switch (nSlotId)
71 case SID_OLE_SELECT:
72 case SID_OLE_ACTIVATE:
74 // in beiden Faellen erstmal auf der sichtbaren View selektieren
76 OUString aName;
77 SdrView* pDrView = GetSdrView();
78 if (pDrView)
80 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
81 if (rMarkList.GetMarkCount() == 1)
82 aName = ScDrawLayer::GetVisibleName( rMarkList.GetMark(0)->GetMarkedSdrObj() );
84 pVisibleSh->SelectObject( aName );
86 // aktivieren
88 if ( nSlotId == SID_OLE_ACTIVATE )
89 pVisibleSh->DoVerb( 0 );
91 break;
92 case SID_OLE_DEACTIVATE:
93 pVisibleSh->DeactivateOle();
94 break;
96 case SID_OBJECT_LEFT:
97 case SID_OBJECT_TOP:
98 case SID_OBJECT_WIDTH:
99 case SID_OBJECT_HEIGHT:
101 bool bDone = false;
102 const SfxPoolItem* pItem;
103 if ( pReqArgs && pReqArgs->GetItemState( nSlotId, true, &pItem ) == SfxItemState::SET )
105 long nNewVal = static_cast<const SfxInt32Item*>(pItem)->GetValue();
106 if ( nNewVal < 0 )
107 nNewVal = 0;
109 //! von irgendwas in 1/100mm umrechnen ??????
111 SdrView* pDrView = GetSdrView();
112 if ( pDrView )
114 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
115 if (rMarkList.GetMarkCount() == 1)
117 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
118 Rectangle aRect = pObj->GetLogicRect();
120 if ( nSlotId == SID_OBJECT_LEFT )
121 pDrView->MoveMarkedObj( Size( nNewVal - aRect.Left(), 0 ) );
122 else if ( nSlotId == SID_OBJECT_TOP )
123 pDrView->MoveMarkedObj( Size( 0, nNewVal - aRect.Top() ) );
124 else if ( nSlotId == SID_OBJECT_WIDTH )
125 pDrView->ResizeMarkedObj( aRect.TopLeft(),
126 Fraction( nNewVal, aRect.GetWidth() ),
127 Fraction( 1, 1 ) );
128 else // if ( nSlotId == SID_OBJECT_HEIGHT )
129 pDrView->ResizeMarkedObj( aRect.TopLeft(),
130 Fraction( 1, 1 ),
131 Fraction( nNewVal, aRect.GetHeight() ) );
132 bDone = true;
136 #if HAVE_FEATURE_SCRIPTING
137 if (!bDone)
138 SbxBase::SetError( SbxERR_BAD_PARAMETER ); // Basic-Fehler
139 #endif
141 break;
146 static uno::Reference < embed::XEmbeddedObject > lcl_GetSelectedObj( SdrView* pDrView ) //! Member von ScDrawView?
148 uno::Reference < embed::XEmbeddedObject > xRet;
149 if (pDrView)
151 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
152 if (rMarkList.GetMarkCount() == 1)
154 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
155 if (pObj->GetObjIdentifier() == OBJ_OLE2)
157 SdrOle2Obj* pOle2Obj = static_cast<SdrOle2Obj*>(pObj);
158 xRet = pOle2Obj->GetObjRef();
163 return xRet;
166 void ScTabViewShell::GetObjectState( SfxItemSet& rSet )
168 // SID_OLE_OBJECT - removed (old Basic)
170 SfxWhichIter aIter(rSet);
171 sal_uInt16 nWhich = aIter.FirstWhich();
172 while ( nWhich )
174 switch (nWhich)
176 case SID_ACTIVE_OBJ_NAME:
178 OUString aName;
179 uno::Reference < embed::XEmbeddedObject > xOLE = lcl_GetSelectedObj( GetSdrView() );
180 if (xOLE.is())
182 aName = GetViewData().GetSfxDocShell()->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xOLE );
184 rSet.Put( SfxStringItem( nWhich, aName ) );
186 break;
187 case SID_OBJECT_LEFT:
188 case SID_OBJECT_TOP:
189 case SID_OBJECT_WIDTH:
190 case SID_OBJECT_HEIGHT:
192 SdrView* pDrView = GetSdrView();
193 if ( pDrView )
195 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
196 if (rMarkList.GetMarkCount() == 1)
198 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
199 Rectangle aRect = pObj->GetLogicRect();
201 long nVal;
202 if ( nWhich == SID_OBJECT_LEFT )
203 nVal = aRect.Left();
204 else if ( nWhich == SID_OBJECT_TOP )
205 nVal = aRect.Top();
206 else if ( nWhich == SID_OBJECT_WIDTH )
207 nVal = aRect.GetWidth();
208 else // if ( nWhich == SID_OBJECT_HEIGHT )
209 nVal = aRect.GetHeight();
211 //! von 1/100mm in irgendwas umrechnen ??????
213 rSet.Put( SfxInt32Item( nWhich, nVal ) );
217 break;
219 nWhich = aIter.NextWhich();
223 void ScTabViewShell::AddAccessibilityObject( SfxListener& rObject )
225 if (!pAccessibilityBroadcaster)
226 pAccessibilityBroadcaster = new SfxBroadcaster;
228 rObject.StartListening( *pAccessibilityBroadcaster );
229 ScDocument* pDoc = GetViewData().GetDocument();
230 if (pDoc)
231 pDoc->AddUnoObject(rObject);
234 void ScTabViewShell::RemoveAccessibilityObject( SfxListener& rObject )
236 SolarMutexGuard g;
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 bool ScTabViewShell::HasAccessibilityObjects()
259 return pAccessibilityBroadcaster != NULL;
262 bool ScTabViewShell::ExecuteRetypePassDlg(ScPasswordHash eDesiredHash)
264 ScDocument* pDoc = GetViewData().GetDocument();
266 VclPtrInstance< ScRetypePassDlg > pDlg(GetDialogParent());
267 pDlg->SetDataFromDocument(*pDoc);
268 pDlg->SetDesiredHash(eDesiredHash);
269 if (pDlg->Execute() != RET_OK)
270 return false;
272 pDlg->WriteNewDataToDocument(*pDoc);
273 return true;
276 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */