xref: /trunk/main/sc/source/ui/drawfunc/drawsh2.cxx (revision f120fe4110718eecb5f5933a421104aa4582f505)
1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b3f79822SAndrew Rist  * distributed with this work for additional information
6b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17b3f79822SAndrew Rist  * specific language governing permissions and limitations
18b3f79822SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20b3f79822SAndrew Rist  *************************************************************/
21b3f79822SAndrew Rist 
22b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //------------------------------------------------------------------
28cdf0e10cSrcweir #include <com/sun/star/embed/EmbedMisc.hpp>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "scitems.hxx"
31cdf0e10cSrcweir #include <editeng/eeitem.hxx>
32cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
33cdf0e10cSrcweir #include <svx/svdpagv.hxx>
34cdf0e10cSrcweir #include <svx/xdef.hxx>
35cdf0e10cSrcweir #include <sfx2/app.hxx>
36cdf0e10cSrcweir #include <sfx2/objsh.hxx>
37cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
38cdf0e10cSrcweir #include <svl/ptitem.hxx>
39cdf0e10cSrcweir #include <svl/whiter.hxx>
40cdf0e10cSrcweir #include <svx/svdobj.hxx>
41cdf0e10cSrcweir #include <svx/svdouno.hxx>
42cdf0e10cSrcweir #include <svx/extrusionbar.hxx>
43cdf0e10cSrcweir #include <svx/fontworkbar.hxx>
44*f120fe41SAndre Fischer #include <svx/sidebar/SelectionChangeHandler.hxx>
45*f120fe41SAndre Fischer #include <svx/sidebar/SelectionAnalyzer.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include "drawsh.hxx"
48cdf0e10cSrcweir #include "drawview.hxx"
49cdf0e10cSrcweir #include "viewdata.hxx"
50cdf0e10cSrcweir #include "sc.hrc"
51cdf0e10cSrcweir #include "tabvwsh.hxx"
52cdf0e10cSrcweir #include "document.hxx"
53cdf0e10cSrcweir #include "drwlayer.hxx"
54cdf0e10cSrcweir #include "userdat.hxx"
55cdf0e10cSrcweir #include <svx/svdoole2.hxx>
56cdf0e10cSrcweir #include <svx/svdocapt.hxx>
57cdf0e10cSrcweir 
58*f120fe41SAndre Fischer #include <boost/bind.hpp>
59*f120fe41SAndre Fischer 
60*f120fe41SAndre Fischer 
61cdf0e10cSrcweir sal_uInt16 ScGetFontWorkId();       // in drtxtob
62cdf0e10cSrcweir 
63cdf0e10cSrcweir using namespace com::sun::star;
64cdf0e10cSrcweir 
65*f120fe41SAndre Fischer 
66cdf0e10cSrcweir //------------------------------------------------------------------
67cdf0e10cSrcweir 
68cdf0e10cSrcweir ScDrawShell::ScDrawShell( ScViewData* pData ) :
69cdf0e10cSrcweir     SfxShell(pData->GetViewShell()),
70*f120fe41SAndre Fischer     pViewData( pData ),
71*f120fe41SAndre Fischer     mpSelectionChangeHandler(new svx::sidebar::SelectionChangeHandler(
72*f120fe41SAndre Fischer             ::boost::bind(&ScDrawShell::GetContextForSelection, this),
73*f120fe41SAndre Fischer             GetFrame()->GetFrame().GetController(),
74*f120fe41SAndre Fischer             sfx2::sidebar::EnumContext::Context_Cell))
75cdf0e10cSrcweir {
76cdf0e10cSrcweir     SetPool( &pViewData->GetScDrawView()->GetModel()->GetItemPool() );
77cdf0e10cSrcweir     ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
78cdf0e10cSrcweir     SetUndoManager( pMgr );
79cdf0e10cSrcweir     if ( !pViewData->GetDocument()->IsUndoEnabled() )
80cdf0e10cSrcweir     {
81cdf0e10cSrcweir         pMgr->SetMaxUndoActionCount( 0 );
82cdf0e10cSrcweir     }
83cdf0e10cSrcweir     SetHelpId( HID_SCSHELL_DRAWSH );
84cdf0e10cSrcweir     SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Drawing")));
85*f120fe41SAndre Fischer 
86*f120fe41SAndre Fischer     mpSelectionChangeHandler->Connect();
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir ScDrawShell::~ScDrawShell()
90cdf0e10cSrcweir {
91*f120fe41SAndre Fischer     mpSelectionChangeHandler->Disconnect();
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir void ScDrawShell::GetState( SfxItemSet& rSet )          // Zustaende / Toggles
95cdf0e10cSrcweir {
96cdf0e10cSrcweir     ScDrawView* pView    = pViewData->GetScDrawView();
97cdf0e10cSrcweir     SdrDragMode eMode    = pView->GetDragMode();
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     rSet.Put( SfxBoolItem( SID_OBJECT_ROTATE, eMode == SDRDRAG_ROTATE ) );
100cdf0e10cSrcweir     rSet.Put( SfxBoolItem( SID_OBJECT_MIRROR, eMode == SDRDRAG_MIRROR ) );
101cdf0e10cSrcweir     rSet.Put( SfxBoolItem( SID_BEZIER_EDIT, !pView->IsFrameDragSingles() ) );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     sal_uInt16 nFWId = ScGetFontWorkId();
104cdf0e10cSrcweir     SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
105cdf0e10cSrcweir     rSet.Put(SfxBoolItem(SID_FONTWORK, pViewFrm->HasChildWindow(nFWId)));
106cdf0e10cSrcweir 
107cdf0e10cSrcweir         // Notes always default to Page anchor.
108cdf0e10cSrcweir     bool bDisableAnchor = false;
109cdf0e10cSrcweir     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
110cdf0e10cSrcweir     sal_uLong nMarkCount = rMarkList.GetMarkCount();
111cdf0e10cSrcweir     if ( nMarkCount == 1 )
112cdf0e10cSrcweir     {
113cdf0e10cSrcweir         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
114cdf0e10cSrcweir         if( ScDrawLayer::IsNoteCaption( pObj ) )
115cdf0e10cSrcweir         {
116cdf0e10cSrcweir             bDisableAnchor = true;
117cdf0e10cSrcweir             rSet.DisableItem( SID_ANCHOR_PAGE );
118cdf0e10cSrcweir             rSet.DisableItem( SID_ANCHOR_CELL );
119cdf0e10cSrcweir         }
120cdf0e10cSrcweir     }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     if ( !bDisableAnchor )
123cdf0e10cSrcweir     {
124cdf0e10cSrcweir         switch( pView->GetAnchor() )
125cdf0e10cSrcweir         {
126cdf0e10cSrcweir         case SCA_PAGE:
127cdf0e10cSrcweir             rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, sal_True ) );
128cdf0e10cSrcweir             rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, sal_False ) );
129cdf0e10cSrcweir         break;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir         case SCA_CELL:
132cdf0e10cSrcweir         rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, sal_False ) );
133cdf0e10cSrcweir         rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, sal_True ) );
134cdf0e10cSrcweir         break;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir         default:
137cdf0e10cSrcweir         rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, sal_False ) );
138cdf0e10cSrcweir         rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, sal_False ) );
139cdf0e10cSrcweir         break;
140cdf0e10cSrcweir         }
141cdf0e10cSrcweir     }
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir void ScDrawShell::GetDrawFuncState( SfxItemSet& rSet )      // Funktionen disablen
145cdf0e10cSrcweir {
146cdf0e10cSrcweir     ScDrawView* pView = pViewData->GetScDrawView();
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     //  #111711# call IsMirrorAllowed first to make sure ForcePossibilities (and thus CheckMarked)
149cdf0e10cSrcweir     //  is called before GetMarkCount, so the nMarkCount value is valid for the rest of this method.
150cdf0e10cSrcweir     if (!pView->IsMirrorAllowed(sal_True,sal_True))
151cdf0e10cSrcweir     {
152cdf0e10cSrcweir         rSet.DisableItem( SID_MIRROR_HORIZONTAL );
153cdf0e10cSrcweir         rSet.DisableItem( SID_MIRROR_VERTICAL );
154ee093554SAndre Fischer         rSet.DisableItem( SID_FLIP_HORIZONTAL );
155ee093554SAndre Fischer         rSet.DisableItem( SID_FLIP_VERTICAL );
156cdf0e10cSrcweir     }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
159cdf0e10cSrcweir     sal_uLong nMarkCount = rMarkList.GetMarkCount();
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     if ( nMarkCount <= 1 || !pView->IsGroupPossible() )
162cdf0e10cSrcweir         rSet.DisableItem( SID_GROUP );
163cdf0e10cSrcweir     if ( nMarkCount == 0 || !pView->IsUnGroupPossible() )
164cdf0e10cSrcweir         rSet.DisableItem( SID_UNGROUP );
165cdf0e10cSrcweir     if ( nMarkCount != 1 || !pView->IsGroupEnterPossible() )
166cdf0e10cSrcweir         rSet.DisableItem( SID_ENTER_GROUP );
167cdf0e10cSrcweir     if ( !pView->IsGroupEntered() )
168cdf0e10cSrcweir         rSet.DisableItem( SID_LEAVE_GROUP );
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     if ( nMarkCount <= 1 )                      // nichts oder nur ein Objekt selektiert
171cdf0e10cSrcweir     {
172cdf0e10cSrcweir             //  Ausrichtung
173cdf0e10cSrcweir         rSet.DisableItem( SID_OBJECT_ALIGN_LEFT );      // keine Ausrichtung an der Seite
174cdf0e10cSrcweir         rSet.DisableItem( SID_OBJECT_ALIGN_CENTER );
175cdf0e10cSrcweir         rSet.DisableItem( SID_OBJECT_ALIGN_RIGHT );
176cdf0e10cSrcweir         rSet.DisableItem( SID_OBJECT_ALIGN_UP );
177cdf0e10cSrcweir         rSet.DisableItem( SID_OBJECT_ALIGN_MIDDLE );
178cdf0e10cSrcweir         rSet.DisableItem( SID_OBJECT_ALIGN_DOWN );
179cdf0e10cSrcweir 
180cdf0e10cSrcweir         // pseudo slots for Format menu
181cdf0e10cSrcweir         rSet.DisableItem( SID_ALIGN_ANY_LEFT );
182cdf0e10cSrcweir         rSet.DisableItem( SID_ALIGN_ANY_HCENTER );
183cdf0e10cSrcweir         rSet.DisableItem( SID_ALIGN_ANY_RIGHT );
184cdf0e10cSrcweir         rSet.DisableItem( SID_ALIGN_ANY_TOP );
185cdf0e10cSrcweir         rSet.DisableItem( SID_ALIGN_ANY_VCENTER );
186cdf0e10cSrcweir         rSet.DisableItem( SID_ALIGN_ANY_BOTTOM );
187cdf0e10cSrcweir     }
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     // do not change layer of form controls
190cdf0e10cSrcweir     // #158385# #i83729# do not change layer of cell notes (on internal layer)
191cdf0e10cSrcweir     if ( !nMarkCount || pView->HasMarkedControl() || pView->HasMarkedInternal() )
192cdf0e10cSrcweir     {
193cdf0e10cSrcweir         rSet.DisableItem( SID_OBJECT_HEAVEN );
194cdf0e10cSrcweir         rSet.DisableItem( SID_OBJECT_HELL );
195cdf0e10cSrcweir     }
196cdf0e10cSrcweir     else
197cdf0e10cSrcweir     {
198cdf0e10cSrcweir         if(AreAllObjectsOnLayer(SC_LAYER_FRONT,rMarkList))
199cdf0e10cSrcweir         {
200cdf0e10cSrcweir             rSet.DisableItem( SID_OBJECT_HEAVEN );
201cdf0e10cSrcweir         }
202cdf0e10cSrcweir         else if(AreAllObjectsOnLayer(SC_LAYER_BACK,rMarkList))
203cdf0e10cSrcweir         {
204cdf0e10cSrcweir             rSet.DisableItem( SID_OBJECT_HELL );
205cdf0e10cSrcweir         }
206cdf0e10cSrcweir     }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir     sal_Bool bCanRename = sal_False;
209cdf0e10cSrcweir     if ( nMarkCount > 1 )
210cdf0e10cSrcweir     {
211cdf0e10cSrcweir #ifdef ISSUE66550_HLINK_FOR_SHAPES
212cdf0e10cSrcweir         // no hypelink options for a selected group
213cdf0e10cSrcweir         rSet.DisableItem( SID_DRAW_HLINK_EDIT );
214cdf0e10cSrcweir         rSet.DisableItem( SID_DRAW_HLINK_DELETE );
215cdf0e10cSrcweir         rSet.DisableItem( SID_OPEN_HYPERLINK );
216cdf0e10cSrcweir #endif
217cdf0e10cSrcweir     }
218cdf0e10cSrcweir     else if ( nMarkCount == 1 )
219cdf0e10cSrcweir     {
220cdf0e10cSrcweir         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
221cdf0e10cSrcweir #ifdef ISSUE66550_HLINK_FOR_SHAPES
222cdf0e10cSrcweir         ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj );
223cdf0e10cSrcweir         if ( !pInfo || (pInfo->GetHlink().getLength() == 0) )
224cdf0e10cSrcweir         {
225cdf0e10cSrcweir             rSet.DisableItem( SID_DRAW_HLINK_DELETE );
226cdf0e10cSrcweir             rSet.DisableItem( SID_OPEN_HYPERLINK );
227cdf0e10cSrcweir         }
228cdf0e10cSrcweir #endif
229cdf0e10cSrcweir         SdrLayerID nLayerID = pObj->GetLayer();
230cdf0e10cSrcweir         if ( nLayerID != SC_LAYER_INTERN )
231cdf0e10cSrcweir             bCanRename = sal_True;                          // #i51351# anything except internal objects can be renamed
232cdf0e10cSrcweir 
233cdf0e10cSrcweir         // #91929#; don't show original size entry if not possible
234cdf0e10cSrcweir         sal_uInt16 nObjType = pObj->GetObjIdentifier();
235cdf0e10cSrcweir         if ( nObjType == OBJ_OLE2 )
236cdf0e10cSrcweir         {
237cdf0e10cSrcweir             SdrOle2Obj* pOleObj = static_cast<SdrOle2Obj*>(rMarkList.GetMark( 0 )->GetMarkedSdrObj());
238cdf0e10cSrcweir             if (pOleObj->GetObjRef().is() &&
239cdf0e10cSrcweir                 ((pOleObj->GetObjRef()->getStatus( pOleObj->GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) ) )
240cdf0e10cSrcweir                 //TODO/LATER: why different slots in Draw and Calc?
241cdf0e10cSrcweir                 rSet.DisableItem(SID_ORIGINALSIZE);
242cdf0e10cSrcweir         }
243cdf0e10cSrcweir         else if ( nObjType == OBJ_CAPTION )
244cdf0e10cSrcweir         {
245cdf0e10cSrcweir             if ( nLayerID == SC_LAYER_INTERN )
246cdf0e10cSrcweir             {
247cdf0e10cSrcweir                 // SdrCaptionObj() Notes cannot be cut/copy in isolation from
248cdf0e10cSrcweir                 // their cells.
249cdf0e10cSrcweir                 rSet.DisableItem( SID_CUT );
250cdf0e10cSrcweir                 rSet.DisableItem( SID_COPY );
251cdf0e10cSrcweir                 // Notes always default to Page anchor.
252cdf0e10cSrcweir                 rSet.DisableItem( SID_ANCHOR_TOGGLE );
253cdf0e10cSrcweir             }
254cdf0e10cSrcweir         }
255cdf0e10cSrcweir     }
256cdf0e10cSrcweir     if ( !bCanRename )
257cdf0e10cSrcweir     {
258cdf0e10cSrcweir         // #i68101#
259cdf0e10cSrcweir         rSet.DisableItem( SID_RENAME_OBJECT );
260cdf0e10cSrcweir         rSet.DisableItem( SID_TITLE_DESCRIPTION_OBJECT );
261cdf0e10cSrcweir     }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir     if ( !nMarkCount )                          // nichts selektiert
264cdf0e10cSrcweir     {
265cdf0e10cSrcweir             //  Anordnung
266cdf0e10cSrcweir         rSet.DisableItem( SID_FRAME_UP );
267cdf0e10cSrcweir         rSet.DisableItem( SID_FRAME_DOWN );
268cdf0e10cSrcweir         rSet.DisableItem( SID_FRAME_TO_TOP );
269cdf0e10cSrcweir         rSet.DisableItem( SID_FRAME_TO_BOTTOM );
270cdf0e10cSrcweir             //  Clipboard / loeschen
271cdf0e10cSrcweir         rSet.DisableItem( SID_DELETE );
272cdf0e10cSrcweir         rSet.DisableItem( SID_DELETE_CONTENTS );
273cdf0e10cSrcweir         rSet.DisableItem( SID_CUT );
274cdf0e10cSrcweir         rSet.DisableItem( SID_COPY );
275cdf0e10cSrcweir             //  sonstiges
276cdf0e10cSrcweir         rSet.DisableItem( SID_ANCHOR_TOGGLE );
277cdf0e10cSrcweir         rSet.DisableItem( SID_ORIGINALSIZE );
278cdf0e10cSrcweir         rSet.DisableItem( SID_ATTR_TRANSFORM );
279cdf0e10cSrcweir     }
280cdf0e10cSrcweir 
281cdf0e10cSrcweir     if ( rSet.GetItemState( SID_ENABLE_HYPHENATION ) != SFX_ITEM_UNKNOWN )
282cdf0e10cSrcweir     {
283cdf0e10cSrcweir         SfxItemSet aAttrs( pView->GetModel()->GetItemPool() );
284cdf0e10cSrcweir         pView->GetAttributes( aAttrs );
285cdf0e10cSrcweir         if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
286cdf0e10cSrcweir         {
287cdf0e10cSrcweir             sal_Bool bValue = ( (const SfxBoolItem&) aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue();
288cdf0e10cSrcweir             rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) );
289cdf0e10cSrcweir         }
290cdf0e10cSrcweir     }
291cdf0e10cSrcweir 
292cdf0e10cSrcweir     svx::ExtrusionBar::getState( pView, rSet );
293cdf0e10cSrcweir     svx::FontworkBar::getState( pView, rSet );
294cdf0e10cSrcweir }
295cdf0e10cSrcweir 
296cdf0e10cSrcweir //
297cdf0e10cSrcweir //          Attribute fuer Drawing-Objekte
298cdf0e10cSrcweir //
299cdf0e10cSrcweir 
300cdf0e10cSrcweir void ScDrawShell::GetDrawAttrState( SfxItemSet& rSet )
301cdf0e10cSrcweir {
302cdf0e10cSrcweir     Point       aMousePos   = pViewData->GetMousePosPixel();
303cdf0e10cSrcweir     Window*     pWindow     = pViewData->GetActiveWin();
304cdf0e10cSrcweir     ScDrawView* pDrView     = pViewData->GetScDrawView();
305cdf0e10cSrcweir     Point       aPos        = pWindow->PixelToLogic(aMousePos);
306cdf0e10cSrcweir     sal_Bool        bHasMarked  = pDrView->AreObjectsMarked();
307cdf0e10cSrcweir 
308cdf0e10cSrcweir     if( bHasMarked )
309cdf0e10cSrcweir     {
310cdf0e10cSrcweir         rSet.Put( pDrView->GetAttrFromMarked(sal_False) );
311cdf0e10cSrcweir 
312cdf0e10cSrcweir         // Wenn die View selektierte Objekte besitzt, muessen entspr. Items
313cdf0e10cSrcweir         // von SFX_ITEM_DEFAULT (_ON) auf SFX_ITEM_DISABLED geaendert werden
314cdf0e10cSrcweir 
315cdf0e10cSrcweir         SfxWhichIter aIter( rSet, XATTR_LINE_FIRST, XATTR_FILL_LAST );
316cdf0e10cSrcweir         sal_uInt16 nWhich = aIter.FirstWhich();
317cdf0e10cSrcweir         while( nWhich )
318cdf0e10cSrcweir         {
319cdf0e10cSrcweir             if( SFX_ITEM_DEFAULT == rSet.GetItemState( nWhich ) )
320cdf0e10cSrcweir                 rSet.DisableItem( nWhich );
321cdf0e10cSrcweir 
322cdf0e10cSrcweir             nWhich = aIter.NextWhich();
323cdf0e10cSrcweir         }
324cdf0e10cSrcweir     }
325cdf0e10cSrcweir     else
326cdf0e10cSrcweir         rSet.Put( pDrView->GetDefaultAttr() );
327cdf0e10cSrcweir 
328cdf0e10cSrcweir     SdrPageView* pPV = pDrView->GetSdrPageView();
329cdf0e10cSrcweir     if ( pPV )
330cdf0e10cSrcweir     {
331cdf0e10cSrcweir         // #i52073# when a sheet with an active OLE object is deleted,
332cdf0e10cSrcweir         // the slot state is queried without an active page view
333cdf0e10cSrcweir 
334cdf0e10cSrcweir         //  Items for position and size (see ScGridWindow::UpdateStatusPosSize, #108137#)
335cdf0e10cSrcweir 
336cdf0e10cSrcweir         // #i34458# The SvxSizeItem in SID_TABLE_CELL is no longer needed by
337cdf0e10cSrcweir         // SvxPosSizeStatusBarControl, it's enough to have it in SID_ATTR_SIZE.
338cdf0e10cSrcweir 
339cdf0e10cSrcweir         sal_Bool bActionItem = sal_False;
340cdf0e10cSrcweir         if ( pDrView->IsAction() )              // action rectangle
341cdf0e10cSrcweir         {
342cdf0e10cSrcweir             Rectangle aRect;
343cdf0e10cSrcweir             pDrView->TakeActionRect( aRect );
344cdf0e10cSrcweir             if ( !aRect.IsEmpty() )
345cdf0e10cSrcweir             {
346cdf0e10cSrcweir                 pPV->LogicToPagePos(aRect);
347cdf0e10cSrcweir                 rSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) );
348cdf0e10cSrcweir                 Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
349cdf0e10cSrcweir                 rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize ) );
350cdf0e10cSrcweir                 bActionItem = sal_True;
351cdf0e10cSrcweir             }
352cdf0e10cSrcweir         }
353cdf0e10cSrcweir         if ( !bActionItem )
354cdf0e10cSrcweir         {
355cdf0e10cSrcweir             if ( pDrView->AreObjectsMarked() )      // selected objects
356cdf0e10cSrcweir             {
357cdf0e10cSrcweir                 Rectangle aRect = pDrView->GetAllMarkedRect();
358cdf0e10cSrcweir                 pPV->LogicToPagePos(aRect);
359cdf0e10cSrcweir                 rSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) );
360cdf0e10cSrcweir                 Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
361cdf0e10cSrcweir                 rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize ) );
362cdf0e10cSrcweir             }
363cdf0e10cSrcweir             else                                // mouse position
364cdf0e10cSrcweir             {
365cdf0e10cSrcweir                 // aPos is initialized above
366cdf0e10cSrcweir                 pPV->LogicToPagePos(aPos);
367cdf0e10cSrcweir                 rSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos ) );
368cdf0e10cSrcweir                 rSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) );
369cdf0e10cSrcweir             }
370cdf0e10cSrcweir         }
371cdf0e10cSrcweir     }
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
374cdf0e10cSrcweir void ScDrawShell::GetAttrFuncState(SfxItemSet &rSet)
375cdf0e10cSrcweir {
376cdf0e10cSrcweir     //  Dialoge fuer Draw-Attribute disablen, wenn noetig
377cdf0e10cSrcweir 
378cdf0e10cSrcweir     ScDrawView* pDrView = pViewData->GetScDrawView();
379cdf0e10cSrcweir     SfxItemSet aViewSet = pDrView->GetAttrFromMarked(sal_False);
380cdf0e10cSrcweir 
381cdf0e10cSrcweir     if ( aViewSet.GetItemState( XATTR_LINESTYLE ) == SFX_ITEM_DEFAULT )
382cdf0e10cSrcweir     {
383cdf0e10cSrcweir         rSet.DisableItem( SID_ATTRIBUTES_LINE );
384cdf0e10cSrcweir         rSet.DisableItem( SID_ATTR_LINEEND_STYLE );     // Tbx-Controller
385cdf0e10cSrcweir     }
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     if ( aViewSet.GetItemState( XATTR_FILLSTYLE ) == SFX_ITEM_DEFAULT )
388cdf0e10cSrcweir         rSet.DisableItem( SID_ATTRIBUTES_AREA );
389cdf0e10cSrcweir }
390cdf0e10cSrcweir 
391cdf0e10cSrcweir sal_Bool ScDrawShell::AreAllObjectsOnLayer(sal_uInt16 nLayerNo,const SdrMarkList& rMark)
392cdf0e10cSrcweir {
393cdf0e10cSrcweir     sal_Bool bResult=sal_True;
394cdf0e10cSrcweir     sal_uLong nCount = rMark.GetMarkCount();
395cdf0e10cSrcweir     for (sal_uLong i=0; i<nCount; i++)
396cdf0e10cSrcweir     {
397cdf0e10cSrcweir         SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
398cdf0e10cSrcweir         if ( !pObj->ISA(SdrUnoObj) )
399cdf0e10cSrcweir         {
400cdf0e10cSrcweir             if(nLayerNo!=pObj->GetLayer())
401cdf0e10cSrcweir             {
402cdf0e10cSrcweir                 bResult=sal_False;
403cdf0e10cSrcweir                 break;
404cdf0e10cSrcweir             }
405cdf0e10cSrcweir         }
406cdf0e10cSrcweir     }
407cdf0e10cSrcweir     return bResult;
408cdf0e10cSrcweir }
409cdf0e10cSrcweir 
410ee093554SAndre Fischer void ScDrawShell::GetDrawAttrStateForIFBX( SfxItemSet& rSet )
411ee093554SAndre Fischer {
412ee093554SAndre Fischer     ScDrawView* pView = pViewData->GetScDrawView();
413ee093554SAndre Fischer     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
414cdf0e10cSrcweir 
415ee093554SAndre Fischer     if( rMarkList.GetMark(0) != 0 )
416ee093554SAndre Fischer     {
417ee093554SAndre Fischer         SfxItemSet aNewAttr(pView->GetGeoAttrFromMarked());
418ee093554SAndre Fischer         rSet.Put(aNewAttr, sal_False);
419ee093554SAndre Fischer     }
420ee093554SAndre Fischer }
421*f120fe41SAndre Fischer 
422*f120fe41SAndre Fischer sfx2::sidebar::EnumContext::Context ScDrawShell::GetContextForSelection (void)
423*f120fe41SAndre Fischer {
424*f120fe41SAndre Fischer     return ::svx::sidebar::SelectionAnalyzer::GetContextForSelection_SC(
425*f120fe41SAndre Fischer         GetDrawView()->GetMarkedObjectList());
426*f120fe41SAndre Fischer }
427