1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
34 #include "document.hxx"
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...");
72 case SID_OLE_ACTIVATE
:
74 // in beiden Faellen erstmal auf der sichtbaren View selektieren
77 SdrView
* pDrView
= GetSdrView();
80 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
81 if (rMarkList
.GetMarkCount() == 1)
82 aName
= ScDrawLayer::GetVisibleName( rMarkList
.GetMark(0)->GetMarkedSdrObj() );
84 pVisibleSh
->SelectObject( aName
);
88 if ( nSlotId
== SID_OLE_ACTIVATE
)
89 pVisibleSh
->DoVerb( 0 );
92 case SID_OLE_DEACTIVATE
:
93 pVisibleSh
->DeactivateOle();
98 case SID_OBJECT_WIDTH
:
99 case SID_OBJECT_HEIGHT
:
102 const SfxPoolItem
* pItem
;
103 if ( pReqArgs
&& pReqArgs
->GetItemState( nSlotId
, true, &pItem
) == SfxItemState::SET
)
105 long nNewVal
= static_cast<const SfxInt32Item
*>(pItem
)->GetValue();
109 //! von irgendwas in 1/100mm umrechnen ??????
111 SdrView
* pDrView
= GetSdrView();
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() ),
128 else // if ( nSlotId == SID_OBJECT_HEIGHT )
129 pDrView
->ResizeMarkedObj( aRect
.TopLeft(),
131 Fraction( nNewVal
, aRect
.GetHeight() ) );
136 #if HAVE_FEATURE_SCRIPTING
138 SbxBase::SetError( SbxERR_BAD_PARAMETER
); // Basic-Fehler
146 static uno::Reference
< embed::XEmbeddedObject
> lcl_GetSelectedObj( SdrView
* pDrView
) //! Member von ScDrawView?
148 uno::Reference
< embed::XEmbeddedObject
> xRet
;
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();
166 void ScTabViewShell::GetObjectState( SfxItemSet
& rSet
)
168 // SID_OLE_OBJECT - removed (old Basic)
170 SfxWhichIter
aIter(rSet
);
171 sal_uInt16 nWhich
= aIter
.FirstWhich();
176 case SID_ACTIVE_OBJ_NAME
:
179 uno::Reference
< embed::XEmbeddedObject
> xOLE
= lcl_GetSelectedObj( GetSdrView() );
182 aName
= GetViewData().GetSfxDocShell()->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xOLE
);
184 rSet
.Put( SfxStringItem( nWhich
, aName
) );
187 case SID_OBJECT_LEFT
:
189 case SID_OBJECT_WIDTH
:
190 case SID_OBJECT_HEIGHT
:
192 SdrView
* pDrView
= GetSdrView();
195 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
196 if (rMarkList
.GetMarkCount() == 1)
198 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
199 Rectangle aRect
= pObj
->GetLogicRect();
202 if ( nWhich
== SID_OBJECT_LEFT
)
204 else if ( nWhich
== SID_OBJECT_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
) );
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();
231 pDoc
->AddUnoObject(rObject
);
234 void ScTabViewShell::RemoveAccessibilityObject( SfxListener
& rObject
)
238 if (pAccessibilityBroadcaster
)
240 rObject
.EndListening( *pAccessibilityBroadcaster
);
241 ScDocument
* pDoc
= GetViewData().GetDocument();
243 pDoc
->RemoveUnoObject(rObject
);
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
)
272 pDlg
->WriteNewDataToDocument(*pDoc
);
276 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */