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 <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"
32 #include "document.hxx"
35 #include "drwlayer.hxx"
36 #include "retypepassdlg.hxx"
37 #include "tabprotection.hxx"
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...");
74 case SID_OLE_ACTIVATE
:
76 // in beiden Faellen erstmal auf der sichtbaren View selektieren
79 SdrView
* pDrView
= GetSdrView();
82 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
83 if (rMarkList
.GetMarkCount() == 1)
84 aName
= ScDrawLayer::GetVisibleName( rMarkList
.GetMark(0)->GetMarkedSdrObj() );
86 pVisibleSh
->SelectObject( aName
);
90 if ( nSlotId
== SID_OLE_ACTIVATE
)
91 pVisibleSh
->DoVerb( 0 );
94 case SID_OLE_DEACTIVATE
:
95 pVisibleSh
->DeactivateOle();
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();
111 //! von irgendwas in 1/100mm umrechnen ??????
113 SdrView
* pDrView
= GetSdrView();
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() ),
130 else // if ( nSlotId == SID_OBJECT_HEIGHT )
131 pDrView
->ResizeMarkedObj( aRect
.TopLeft(),
133 Fraction( nNewVal
, aRect
.GetHeight() ) );
138 #ifndef DISABLE_SCRIPTING
140 SbxBase::SetError( SbxERR_BAD_PARAMETER
); // Basic-Fehler
148 static uno::Reference
< embed::XEmbeddedObject
> lcl_GetSelectedObj( SdrView
* pDrView
) //! Member von ScDrawView?
150 uno::Reference
< embed::XEmbeddedObject
> xRet
;
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();
168 void ScTabViewShell::GetObjectState( SfxItemSet
& rSet
)
170 // SID_OLE_OBJECT - removed (old Basic)
172 SfxWhichIter
aIter(rSet
);
173 sal_uInt16 nWhich
= aIter
.FirstWhich();
178 case SID_ACTIVE_OBJ_NAME
:
181 uno::Reference
< embed::XEmbeddedObject
> xOLE
= lcl_GetSelectedObj( GetSdrView() );
184 aName
= GetViewData()->GetSfxDocShell()->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xOLE
);
186 rSet
.Put( SfxStringItem( nWhich
, aName
) );
189 case SID_OBJECT_LEFT
:
191 case SID_OBJECT_WIDTH
:
192 case SID_OBJECT_HEIGHT
:
194 SdrView
* pDrView
= GetSdrView();
197 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
198 if (rMarkList
.GetMarkCount() == 1)
200 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
201 Rectangle aRect
= pObj
->GetLogicRect();
204 if ( nWhich
== SID_OBJECT_LEFT
)
206 else if ( nWhich
== SID_OBJECT_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
) );
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();
233 pDoc
->AddUnoObject(rObject
);
236 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 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
)
274 pDlg
->WriteNewDataToDocument(*pDoc
);
281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */