File: | home/maarten/src/libreoffice/core/sc/source/ui/drawfunc/drawsh2.cxx |
Warning: | line 433, column 26 Called C++ object pointer is null |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||
2 | /* | |||
3 | * This file is part of the LibreOffice project. | |||
4 | * | |||
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/. | |||
8 | * | |||
9 | * This file incorporates work covered by the following license notice: | |||
10 | * | |||
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 . | |||
18 | */ | |||
19 | ||||
20 | #include <com/sun/star/embed/EmbedMisc.hpp> | |||
21 | #include <com/sun/star/embed/XEmbeddedObject.hpp> | |||
22 | ||||
23 | #include <editeng/eeitem.hxx> | |||
24 | #include <editeng/sizeitem.hxx> | |||
25 | #include <svx/svdpagv.hxx> | |||
26 | #include <svx/xdef.hxx> | |||
27 | #include <sfx2/objsh.hxx> | |||
28 | #include <sfx2/viewfrm.hxx> | |||
29 | #include <svl/ptitem.hxx> | |||
30 | #include <svx/svdobj.hxx> | |||
31 | #include <svx/svdouno.hxx> | |||
32 | #include <svx/extrusionbar.hxx> | |||
33 | #include <svx/fontworkbar.hxx> | |||
34 | #include <svx/sidebar/SelectionChangeHandler.hxx> | |||
35 | #include <svx/sidebar/SelectionAnalyzer.hxx> | |||
36 | #include <svx/sidebar/ContextChangeEventMultiplexer.hxx> | |||
37 | ||||
38 | #include <drawsh.hxx> | |||
39 | #include <drawview.hxx> | |||
40 | #include <viewdata.hxx> | |||
41 | #include <sc.hrc> | |||
42 | #include <tabvwsh.hxx> | |||
43 | #include <document.hxx> | |||
44 | #include <drwlayer.hxx> | |||
45 | #include <userdat.hxx> | |||
46 | #include <drtxtob.hxx> | |||
47 | #include <gridwin.hxx> | |||
48 | #include <svx/svdoole2.hxx> | |||
49 | #include <svx/svdocapt.hxx> | |||
50 | #include <svx/xfillit0.hxx> | |||
51 | #include <svx/xflgrit.hxx> | |||
52 | #include <comphelper/lok.hxx> | |||
53 | #include <LibreOfficeKit/LibreOfficeKitEnums.h> | |||
54 | ||||
55 | #include <com/sun/star/drawing/FillStyle.hpp> | |||
56 | ||||
57 | using namespace com::sun::star::drawing; | |||
58 | using namespace com::sun::star; | |||
59 | ||||
60 | ||||
61 | ScDrawShell::ScDrawShell( ScViewData& rData ) : | |||
62 | SfxShell(rData.GetViewShell()), | |||
63 | rViewData( rData ), | |||
64 | mpSelectionChangeHandler(new svx::sidebar::SelectionChangeHandler( | |||
65 | [this] () { return this->GetSidebarContextName(); }, | |||
66 | GetFrame()->GetFrame().GetController(), | |||
67 | vcl::EnumContext::Context::Cell)) | |||
68 | { | |||
69 | SetPool( &rViewData.GetScDrawView()->GetModel()->GetItemPool() ); | |||
70 | SfxUndoManager* pMgr = rViewData.GetSfxDocShell()->GetUndoManager(); | |||
71 | SetUndoManager( pMgr ); | |||
72 | if ( !rViewData.GetDocument().IsUndoEnabled() ) | |||
73 | { | |||
74 | pMgr->SetMaxUndoActionCount( 0 ); | |||
75 | } | |||
76 | SetName("Drawing"); | |||
77 | ||||
78 | mpSelectionChangeHandler->Connect(); | |||
79 | } | |||
80 | ||||
81 | ScDrawShell::~ScDrawShell() | |||
82 | { | |||
83 | mpSelectionChangeHandler->Disconnect(); | |||
84 | } | |||
85 | ||||
86 | void ScDrawShell::GetState( SfxItemSet& rSet ) // Conditions / Toggles | |||
87 | { | |||
88 | ScDrawView* pView = rViewData.GetScDrawView(); | |||
89 | SdrDragMode eMode = pView->GetDragMode(); | |||
90 | ||||
91 | rSet.Put( SfxBoolItem( SID_OBJECT_ROTATETypedWhichId<SfxBoolItem>( 10000 + 129 ), eMode == SdrDragMode::Rotate ) ); | |||
92 | rSet.Put( SfxBoolItem( SID_OBJECT_MIRROR( 10000 + 1093 ), eMode == SdrDragMode::Mirror ) ); | |||
93 | rSet.Put( SfxBoolItem( SID_BEZIER_EDIT( 10000 + 126 ), !pView->IsFrameDragSingles() ) ); | |||
94 | ||||
95 | sal_uInt16 nFWId = ScGetFontWorkId(); | |||
96 | SfxViewFrame* pViewFrm = rViewData.GetViewShell()->GetViewFrame(); | |||
97 | rSet.Put(SfxBoolItem(SID_FONTWORK( 10000 + 256 ), pViewFrm->HasChildWindow(nFWId))); | |||
98 | ||||
99 | // Notes always default to Page anchor. | |||
100 | bool bDisableAnchor = false; | |||
101 | const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); | |||
102 | if ( rMarkList.GetMarkCount() == 1 ) | |||
103 | { | |||
104 | SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); | |||
105 | if( ScDrawLayer::IsNoteCaption( pObj ) ) | |||
106 | { | |||
107 | bDisableAnchor = true; | |||
108 | rSet.DisableItem( SID_ANCHOR_PAGE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+24) ); | |||
109 | rSet.DisableItem( SID_ANCHOR_CELL((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+25) ); | |||
110 | rSet.DisableItem( SID_ANCHOR_CELL_RESIZE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+26) ); | |||
111 | } | |||
112 | } | |||
113 | ||||
114 | if ( bDisableAnchor ) | |||
115 | return; | |||
116 | ||||
117 | switch( pView->GetAnchorType() ) | |||
118 | { | |||
119 | case SCA_PAGE: | |||
120 | rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+24), true ) ); | |||
121 | rSet.Put( SfxBoolItem( SID_ANCHOR_CELL((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+25), false ) ); | |||
122 | rSet.Put( SfxBoolItem( SID_ANCHOR_CELL_RESIZE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+26), false ) ); | |||
123 | break; | |||
124 | ||||
125 | case SCA_CELL: | |||
126 | rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+24), false ) ); | |||
127 | rSet.Put( SfxBoolItem( SID_ANCHOR_CELL((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+25), true ) ); | |||
128 | rSet.Put( SfxBoolItem( SID_ANCHOR_CELL_RESIZE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+26), false ) ); | |||
129 | break; | |||
130 | ||||
131 | case SCA_CELL_RESIZE: | |||
132 | rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+24), false ) ); | |||
133 | rSet.Put( SfxBoolItem( SID_ANCHOR_CELL((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+25), false ) ); | |||
134 | rSet.Put( SfxBoolItem( SID_ANCHOR_CELL_RESIZE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+26), true ) ); | |||
135 | break; | |||
136 | ||||
137 | default: | |||
138 | rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+24), false ) ); | |||
139 | rSet.Put( SfxBoolItem( SID_ANCHOR_CELL((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+25), false ) ); | |||
140 | rSet.Put( SfxBoolItem( SID_ANCHOR_CELL_RESIZE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+26), false ) ); | |||
141 | break; | |||
142 | } | |||
143 | } | |||
144 | ||||
145 | void ScDrawShell::GetDrawFuncState( SfxItemSet& rSet ) // disable functions | |||
146 | { | |||
147 | ScDrawView* pView = rViewData.GetScDrawView(); | |||
148 | ||||
149 | // call IsMirrorAllowed first to make sure ForcePossibilities (and thus CheckMarked) | |||
150 | // is called before GetMarkCount, so the nMarkCount value is valid for the rest of this method. | |||
151 | if (!pView->IsMirrorAllowed(true,true)) | |||
| ||||
152 | { | |||
153 | rSet.DisableItem( SID_MIRROR_HORIZONTAL((26000) + 66) ); | |||
154 | rSet.DisableItem( SID_MIRROR_VERTICAL((26000) + 65) ); | |||
155 | rSet.DisableItem( SID_FLIP_HORIZONTAL( 10000 + 1127 ) ); | |||
156 | rSet.DisableItem( SID_FLIP_VERTICAL( 10000 + 1128 ) ); | |||
157 | } | |||
158 | ||||
159 | ||||
160 | if (GetObjectShell()->isContentExtractionLocked()) | |||
161 | { | |||
162 | rSet.DisableItem(SID_COPY(5000 + 711)); | |||
163 | rSet.DisableItem(SID_CUT(5000 + 710)); | |||
164 | } | |||
165 | ||||
166 | const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); | |||
167 | const size_t nMarkCount = rMarkList.GetMarkCount(); | |||
168 | ||||
169 | if ( nMarkCount <= 1 || !pView->IsGroupPossible() ) | |||
170 | rSet.DisableItem( SID_GROUP( 10000 + 454 ) ); | |||
171 | if ( nMarkCount
| |||
172 | rSet.DisableItem( SID_UNGROUP( 10000 + 455 ) ); | |||
173 | if ( nMarkCount
| |||
174 | rSet.DisableItem( SID_ENTER_GROUP(27000 +96) ); | |||
175 | if ( !pView->IsGroupEntered() ) | |||
176 | rSet.DisableItem( SID_LEAVE_GROUP(27000 +97) ); | |||
177 | ||||
178 | if ( nMarkCount
| |||
179 | { | |||
180 | // alignment | |||
181 | rSet.DisableItem( SID_OBJECT_ALIGN_LEFT( 10000 + 131 ) ); // no alignment on the side | |||
182 | rSet.DisableItem( SID_OBJECT_ALIGN_CENTER( 10000 + 132 ) ); | |||
183 | rSet.DisableItem( SID_OBJECT_ALIGN_RIGHT( 10000 + 133 ) ); | |||
184 | rSet.DisableItem( SID_OBJECT_ALIGN_UP( 10000 + 134 ) ); | |||
185 | rSet.DisableItem( SID_OBJECT_ALIGN_MIDDLE( 10000 + 135 ) ); | |||
186 | rSet.DisableItem( SID_OBJECT_ALIGN_DOWN( 10000 + 136 ) ); | |||
187 | rSet.DisableItem( SID_OBJECT_ALIGN( 10000 + 130 ) ); | |||
188 | ||||
189 | // pseudo slots for Format menu | |||
190 | rSet.DisableItem( SID_ALIGN_ANY_LEFT( 10000 + 1002 ) ); | |||
191 | rSet.DisableItem( SID_ALIGN_ANY_HCENTER( 10000 + 1003 ) ); | |||
192 | rSet.DisableItem( SID_ALIGN_ANY_RIGHT( 10000 + 1004 ) ); | |||
193 | rSet.DisableItem( SID_ALIGN_ANY_TOP( 10000 + 1006 ) ); | |||
194 | rSet.DisableItem( SID_ALIGN_ANY_VCENTER( 10000 + 1007 ) ); | |||
195 | rSet.DisableItem( SID_ALIGN_ANY_BOTTOM( 10000 + 1008 ) ); | |||
196 | } | |||
197 | ||||
198 | // do not change layer of form controls | |||
199 | // #i83729# do not change layer of cell notes (on internal layer) | |||
200 | if ( !nMarkCount
| |||
201 | { | |||
202 | rSet.DisableItem( SID_OBJECT_HEAVEN( 10000 + 283 ) ); | |||
203 | rSet.DisableItem( SID_OBJECT_HELL( 10000 + 282 ) ); | |||
204 | } | |||
205 | else | |||
206 | { | |||
207 | if(AreAllObjectsOnLayer(SC_LAYER_FRONT,rMarkList)) | |||
208 | { | |||
209 | rSet.DisableItem( SID_OBJECT_HEAVEN( 10000 + 283 ) ); | |||
210 | } | |||
211 | else if(AreAllObjectsOnLayer(SC_LAYER_BACK,rMarkList)) | |||
212 | { | |||
213 | rSet.DisableItem( SID_OBJECT_HELL( 10000 + 282 ) ); | |||
214 | } | |||
215 | } | |||
216 | ||||
217 | bool bCanRename = false; | |||
218 | if ( nMarkCount > 1 ) | |||
219 | { | |||
220 | // no hypelink options for a selected group | |||
221 | rSet.DisableItem( SID_DRAW_HLINK_EDIT((26000) + 96) ); | |||
222 | rSet.DisableItem( SID_DRAW_HLINK_DELETE((26000) + 97) ); | |||
223 | rSet.DisableItem( SID_OPEN_HYPERLINK( 10000 + 955 ) ); | |||
224 | // Fit to cell only works with a single graphic | |||
225 | rSet.DisableItem( SID_FITCELLSIZE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+29) ); | |||
226 | } | |||
227 | else if ( nMarkCount == 1 ) | |||
228 | { | |||
229 | SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); | |||
230 | ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj ); | |||
231 | if ( !pInfo || pInfo->GetHlink().isEmpty() ) | |||
232 | { | |||
233 | rSet.DisableItem( SID_DRAW_HLINK_DELETE((26000) + 97) ); | |||
234 | rSet.DisableItem( SID_OPEN_HYPERLINK( 10000 + 955 ) ); | |||
235 | } | |||
236 | SdrLayerID nLayerID = pObj->GetLayer(); | |||
237 | if ( nLayerID != SC_LAYER_INTERN ) | |||
238 | bCanRename = true; // #i51351# anything except internal objects can be renamed | |||
239 | ||||
240 | // #91929#; don't show original size entry if not possible | |||
241 | sal_uInt16 nObjType = pObj->GetObjIdentifier(); | |||
242 | if ( nObjType == OBJ_OLE2 ) | |||
243 | { | |||
244 | SdrOle2Obj* pOleObj = static_cast<SdrOle2Obj*>(rMarkList.GetMark( 0 )->GetMarkedSdrObj()); | |||
245 | if (pOleObj->GetObjRef().is() && | |||
246 | (pOleObj->GetObjRef()->getStatus( pOleObj->GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) ) | |||
247 | //TODO/LATER: why different slots in Draw and Calc? | |||
248 | rSet.DisableItem(SID_ORIGINALSIZE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+28)); | |||
249 | } | |||
250 | else if ( nObjType == OBJ_CAPTION ) | |||
251 | { | |||
252 | if ( nLayerID == SC_LAYER_INTERN ) | |||
253 | { | |||
254 | // SdrCaptionObj() Notes cannot be cut/copy in isolation from | |||
255 | // their cells. | |||
256 | rSet.DisableItem( SID_CUT(5000 + 710) ); | |||
257 | rSet.DisableItem( SID_COPY(5000 + 711) ); | |||
258 | // Notes always default to Page anchor. | |||
259 | rSet.DisableItem( SID_ANCHOR_TOGGLE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+27) ); | |||
260 | rSet.DisableItem( SID_ANCHOR_MENU( 10000 + 1172 ) ); | |||
261 | } | |||
262 | } | |||
263 | ||||
264 | // Fit to cell is only available for cell anchored graphics obviously | |||
265 | if (pView->GetAnchorType() != SCA_CELL && | |||
266 | pView->GetAnchorType() != SCA_CELL_RESIZE) | |||
267 | rSet.DisableItem( SID_FITCELLSIZE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+29) ); | |||
268 | } | |||
269 | if ( !bCanRename ) | |||
270 | { | |||
271 | // #i68101# | |||
272 | rSet.DisableItem( SID_RENAME_OBJECT((26000) + 88) ); | |||
273 | rSet.DisableItem( SID_TITLE_DESCRIPTION_OBJECT((26000) + 94) ); | |||
274 | } | |||
275 | ||||
276 | if ( !nMarkCount ) // nothing selected | |||
277 | { | |||
278 | // Arrangement | |||
279 | rSet.DisableItem( SID_FRAME_UP( 10000 + 1118 ) ); | |||
280 | rSet.DisableItem( SID_FRAME_DOWN( 10000 + 1119 ) ); | |||
281 | rSet.DisableItem( SID_FRAME_TO_TOP( 10000 + 286 ) ); | |||
282 | rSet.DisableItem( SID_FRAME_TO_BOTTOM( 10000 + 287 ) ); | |||
283 | // Clipboard / delete | |||
284 | rSet.DisableItem( SID_DELETE(5000 + 713) ); | |||
285 | rSet.DisableItem( SID_DELETE_CONTENTS((26000 + 521) + 32) ); | |||
286 | rSet.DisableItem( SID_CUT(5000 + 710) ); | |||
287 | rSet.DisableItem( SID_COPY(5000 + 711) ); | |||
288 | // other | |||
289 | rSet.DisableItem( SID_ANCHOR_TOGGLE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+27) ); | |||
290 | rSet.DisableItem( SID_ANCHOR_MENU( 10000 + 1172 ) ); | |||
291 | rSet.DisableItem( SID_ORIGINALSIZE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+28) ); | |||
292 | rSet.DisableItem( SID_FITCELLSIZE((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25) ) + 22)) + 20)) + 29)) + 20))+20))+1))+29) ); | |||
293 | rSet.DisableItem( SID_ATTR_TRANSFORMTypedWhichId<SfxInt32Item>( 10000 + 87 ) ); | |||
294 | } | |||
295 | ||||
296 | if ( rSet.GetItemState( SID_ENABLE_HYPHENATION((26000) + 87) ) != SfxItemState::UNKNOWN ) | |||
297 | { | |||
298 | SfxItemSet aAttrs( pView->GetModel()->GetItemPool() ); | |||
299 | pView->GetAttributes( aAttrs ); | |||
300 | if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SfxItemState::DEFAULT ) | |||
301 | { | |||
302 | bool bValue = aAttrs.Get( EE_PARA_HYPHENATE ).GetValue(); | |||
303 | rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION((26000) + 87), bValue ) ); | |||
304 | } | |||
305 | } | |||
306 | ||||
307 | svx::ExtrusionBar::getState( pView, rSet ); | |||
308 | svx::FontworkBar::getState( pView, rSet ); | |||
309 | } | |||
310 | ||||
311 | // Attributes for Drawing-Objects | |||
312 | ||||
313 | void ScDrawShell::GetDrawAttrState( SfxItemSet& rSet ) | |||
314 | { | |||
315 | Point aMousePos = rViewData.GetMousePosPixel(); | |||
316 | vcl::Window* pWindow = rViewData.GetActiveWin(); | |||
317 | ScDrawView* pDrView = rViewData.GetScDrawView(); | |||
318 | Point aPos = pWindow->PixelToLogic(aMousePos); | |||
319 | bool bHasMarked = pDrView->AreObjectsMarked(); | |||
320 | ||||
321 | if( bHasMarked ) | |||
322 | { | |||
323 | rSet.Put( pDrView->GetAttrFromMarked(false), false ); | |||
324 | } | |||
325 | else | |||
326 | { | |||
327 | rSet.Put( pDrView->GetDefaultAttr() ); | |||
328 | } | |||
329 | ||||
330 | SdrPageView* pPV = pDrView->GetSdrPageView(); | |||
331 | if ( !pPV ) | |||
332 | return; | |||
333 | ||||
334 | // #i52073# when a sheet with an active OLE object is deleted, | |||
335 | // the slot state is queried without an active page view | |||
336 | ||||
337 | // Items for position and size (see ScGridWindow::UpdateStatusPosSize, #108137#) | |||
338 | ||||
339 | // #i34458# The SvxSizeItem in SID_TABLE_CELL is no longer needed by | |||
340 | // SvxPosSizeStatusBarControl, it's enough to have it in SID_ATTR_SIZE. | |||
341 | ||||
342 | bool bActionItem = false; | |||
343 | if ( pDrView->IsAction() ) // action rectangle | |||
344 | { | |||
345 | tools::Rectangle aRect; | |||
346 | pDrView->TakeActionRect( aRect ); | |||
347 | if ( !aRect.IsEmpty() ) | |||
348 | { | |||
349 | pPV->LogicToPagePos(aRect); | |||
350 | rSet.Put( SfxPointItem( SID_ATTR_POSITIONTypedWhichId<SfxPointItem>( 10000 + 223 ), aRect.TopLeft() ) ); | |||
351 | Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ); | |||
352 | rSet.Put( SvxSizeItem( SID_ATTR_SIZETypedWhichId<SvxSizeItem>( 10000 + 224 ), aSize ) ); | |||
353 | bActionItem = true; | |||
354 | } | |||
355 | } | |||
356 | if ( bActionItem ) | |||
357 | return; | |||
358 | ||||
359 | if ( pDrView->AreObjectsMarked() ) // selected objects | |||
360 | { | |||
361 | tools::Rectangle aRect = pDrView->GetAllMarkedRect(); | |||
362 | pPV->LogicToPagePos(aRect); | |||
363 | rSet.Put( SfxPointItem( SID_ATTR_POSITIONTypedWhichId<SfxPointItem>( 10000 + 223 ), aRect.TopLeft() ) ); | |||
364 | Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ); | |||
365 | rSet.Put( SvxSizeItem( SID_ATTR_SIZETypedWhichId<SvxSizeItem>( 10000 + 224 ), aSize ) ); | |||
366 | } | |||
367 | else // mouse position | |||
368 | { | |||
369 | // aPos is initialized above | |||
370 | pPV->LogicToPagePos(aPos); | |||
371 | rSet.Put( SfxPointItem( SID_ATTR_POSITIONTypedWhichId<SfxPointItem>( 10000 + 223 ), aPos ) ); | |||
372 | rSet.Put( SvxSizeItem( SID_ATTR_SIZETypedWhichId<SvxSizeItem>( 10000 + 224 ), Size( 0, 0 ) ) ); | |||
373 | } | |||
374 | } | |||
375 | ||||
376 | void ScDrawShell::GetAttrFuncState(SfxItemSet &rSet) | |||
377 | { | |||
378 | // Disable dialogs for Draw-attributes if necessary | |||
379 | ||||
380 | ScDrawView* pDrView = rViewData.GetScDrawView(); | |||
381 | SfxItemSet aViewSet = pDrView->GetAttrFromMarked(false); | |||
382 | const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); | |||
383 | const size_t nMarkCount = rMarkList.GetMarkCount(); | |||
384 | bool bShowArea = true, bShowMeasure = true; | |||
385 | ||||
386 | for ( size_t i = 0; i < nMarkCount && i < 50; ++i ) | |||
387 | { | |||
388 | SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); | |||
389 | sal_uInt16 nObjType = pObj->GetObjIdentifier(); | |||
390 | ||||
391 | if ( nObjType != OBJ_MEASURE ) | |||
392 | bShowMeasure = false; | |||
393 | ||||
394 | // If marked object is 2D, disable format area command. | |||
395 | if ( nObjType == OBJ_PLIN || | |||
396 | nObjType == OBJ_LINE || | |||
397 | nObjType == OBJ_PATHLINE || | |||
398 | nObjType == OBJ_FREELINE || | |||
399 | nObjType == OBJ_EDGE || | |||
400 | nObjType == OBJ_CARC || | |||
401 | bShowMeasure ) | |||
402 | bShowArea = false; | |||
403 | ||||
404 | if ( !bShowArea && !bShowMeasure ) | |||
405 | break; | |||
406 | } | |||
407 | ||||
408 | if ( !bShowArea ) | |||
409 | rSet.DisableItem( SID_ATTRIBUTES_AREA( 10000 + 142 ) ); | |||
410 | ||||
411 | if ( !bShowMeasure ) | |||
412 | rSet.DisableItem( SID_MEASURE_DLG( 10000 + 1176 ) ); | |||
413 | ||||
414 | if ( aViewSet.GetItemState( XATTR_LINESTYLE ) == SfxItemState::DEFAULT ) | |||
415 | { | |||
416 | rSet.DisableItem( SID_ATTRIBUTES_LINE( 10000 + 143 ) ); | |||
417 | rSet.DisableItem( SID_ATTR_LINEEND_STYLE( 10000 + 301 ) ); // Tbx-Controller | |||
418 | } | |||
419 | ||||
420 | if ( aViewSet.GetItemState( XATTR_FILLSTYLE ) == SfxItemState::DEFAULT ) | |||
421 | rSet.DisableItem( SID_ATTRIBUTES_AREA( 10000 + 142 ) ); | |||
422 | } | |||
423 | ||||
424 | bool ScDrawShell::AreAllObjectsOnLayer(SdrLayerID nLayerNo,const SdrMarkList& rMark) | |||
425 | { | |||
426 | bool bResult=true; | |||
427 | const size_t nCount = rMark.GetMarkCount(); | |||
428 | for (size_t i=0; i<nCount; ++i) | |||
429 | { | |||
430 | SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj(); | |||
431 | if ( dynamic_cast<const SdrUnoObj*>( pObj) == nullptr ) | |||
432 | { | |||
433 | if(nLayerNo!=pObj->GetLayer()) | |||
| ||||
434 | { | |||
435 | bResult=false; | |||
436 | break; | |||
437 | } | |||
438 | } | |||
439 | } | |||
440 | return bResult; | |||
441 | } | |||
442 | ||||
443 | void ScDrawShell::GetDrawAttrStateForIFBX( SfxItemSet& rSet ) | |||
444 | { | |||
445 | ScDrawView* pView = rViewData.GetScDrawView(); | |||
446 | const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); | |||
447 | ||||
448 | if( rMarkList.GetMark(0) != nullptr ) | |||
449 | { | |||
450 | SfxItemSet aNewAttr(pView->GetGeoAttrFromMarked()); | |||
451 | rSet.Put(aNewAttr, false); | |||
452 | } | |||
453 | } | |||
454 | ||||
455 | void ScDrawShell::Activate (const bool) | |||
456 | { | |||
457 | ContextChangeEventMultiplexer::NotifyContextChange( | |||
458 | GetFrame()->GetFrame().GetController(), | |||
459 | vcl::EnumContext::GetContextEnum( | |||
460 | GetSidebarContextName())); | |||
461 | } | |||
462 | ||||
463 | const OUString & ScDrawShell::GetSidebarContextName() | |||
464 | { | |||
465 | return vcl::EnumContext::GetContextName( | |||
466 | svx::sidebar::SelectionAnalyzer::GetContextForSelection_SC( | |||
467 | GetDrawView()->GetMarkedObjectList())); | |||
468 | } | |||
469 | ||||
470 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |