Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <editeng/eeitem.hxx>
30 : :
31 : : #include <sfx2/viewfrm.hxx>
32 : : #include <sfx2/request.hxx>
33 : : #include <sfx2/bindings.hxx>
34 : : #include <tools/urlobj.hxx>
35 : : #include <svx/svxdlg.hxx>
36 : : #include <svx/dialogs.hrc>
37 : : #include <svx/fmglob.hxx>
38 : : #include <svx/hlnkitem.hxx>
39 : : #include <svx/fontwork.hxx>
40 : : #include <svx/svdocapt.hxx>
41 : : #include <svx/svdoole2.hxx>
42 : : #include <svx/svdouno.hxx>
43 : : #include <svx/svdpage.hxx>
44 : : #include <svx/svdundo.hxx>
45 : : #include <svx/xdef.hxx>
46 : : #include <svx/xftsfit.hxx>
47 : : #include <vcl/msgbox.hxx>
48 : : #include <svx/extrusionbar.hxx>
49 : : #include <svx/fontworkbar.hxx>
50 : : #include <sfx2/docfile.hxx>
51 : :
52 : : #include <com/sun/star/form/FormButtonType.hpp>
53 : : #include <com/sun/star/beans/XPropertySet.hpp>
54 : : #include <com/sun/star/beans/XPropertySetInfo.hpp>
55 : : #include <com/sun/star/awt/XControlModel.hpp>
56 : :
57 : : #include "drawsh.hxx"
58 : : #include "drawview.hxx"
59 : : #include "viewdata.hxx"
60 : : #include "tabvwsh.hxx"
61 : : #include "docsh.hxx"
62 : : #include "scresid.hxx"
63 : : #include "undotab.hxx"
64 : : #include "drwlayer.hxx"
65 : : #include "userdat.hxx"
66 : : #include "postit.hxx"
67 : :
68 : : #include "sc.hrc"
69 : :
70 : : using namespace com::sun::star;
71 : :
72 : : //------------------------------------------------------------------
73 : :
74 : 0 : void ScDrawShell::GetHLinkState( SfxItemSet& rSet ) // Hyperlink
75 : : {
76 [ # # ]: 0 : ScDrawView* pView = pViewData->GetScDrawView();
77 : 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
78 : 0 : sal_uLong nMarkCount = rMarkList.GetMarkCount();
79 : :
80 : : // Hyperlink
81 : :
82 [ # # ]: 0 : SvxHyperlinkItem aHLinkItem;
83 : :
84 [ # # ]: 0 : if ( nMarkCount == 1 ) // URL-Button markiert ?
85 : : {
86 [ # # ][ # # ]: 0 : SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
87 [ # # ]: 0 : ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj );
88 [ # # ][ # # ]: 0 : if ( pInfo && !pInfo->GetHlink().isEmpty() )
[ # # ]
89 : : {
90 [ # # ][ # # ]: 0 : aHLinkItem.SetURL( pInfo->GetHlink() );
[ # # ]
91 : 0 : aHLinkItem.SetInsertMode(HLINK_FIELD);
92 : : }
93 [ # # ][ # # ]: 0 : SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObj);
[ # # ][ # # ]
94 [ # # ][ # # ]: 0 : if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
[ # # ][ # # ]
95 : : {
96 [ # # ]: 0 : uno::Reference<awt::XControlModel> xControlModel = pUnoCtrl->GetUnoControlModel();
97 : : OSL_ENSURE( xControlModel.is(), "UNO-Control ohne Model" );
98 [ # # ]: 0 : if( !xControlModel.is() )
99 : 0 : return;
100 : :
101 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
102 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
103 : :
104 [ # # ]: 0 : rtl::OUString sPropButtonType(RTL_CONSTASCII_USTRINGPARAM( "ButtonType" ));
105 [ # # ]: 0 : rtl::OUString sPropTargetURL(RTL_CONSTASCII_USTRINGPARAM( "TargetURL" ));
106 [ # # ]: 0 : rtl::OUString sPropTargetFrame(RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" ));
107 [ # # ]: 0 : rtl::OUString sPropLabel(RTL_CONSTASCII_USTRINGPARAM( "Label" ));
108 : :
109 [ # # ][ # # ]: 0 : if(xInfo->hasPropertyByName( sPropButtonType ))
[ # # ]
110 : : {
111 [ # # ][ # # ]: 0 : uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType );
112 : : form::FormButtonType eTmp;
113 [ # # ][ # # ]: 0 : if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL )
[ # # ][ # # ]
114 : : {
115 : 0 : rtl::OUString sTmp;
116 : : // Label
117 [ # # ][ # # ]: 0 : if(xInfo->hasPropertyByName( sPropLabel ))
[ # # ]
118 : : {
119 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue( sPropLabel );
120 [ # # ][ # # ]: 0 : if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
[ # # ]
121 : : {
122 [ # # ][ # # ]: 0 : aHLinkItem.SetName(sTmp);
[ # # ]
123 : : }
124 : : }
125 : : // URL
126 [ # # ][ # # ]: 0 : if(xInfo->hasPropertyByName( sPropTargetURL ))
[ # # ]
127 : : {
128 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue( sPropTargetURL );
129 [ # # ][ # # ]: 0 : if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
[ # # ]
130 : : {
131 [ # # ][ # # ]: 0 : aHLinkItem.SetURL(sTmp);
[ # # ]
132 : : }
133 : : }
134 : : // Target
135 [ # # ][ # # ]: 0 : if(xInfo->hasPropertyByName( sPropTargetFrame ))
[ # # ]
136 : : {
137 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue( sPropTargetFrame );
138 [ # # ][ # # ]: 0 : if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
[ # # ]
139 : : {
140 [ # # ][ # # ]: 0 : aHLinkItem.SetTargetFrame(sTmp);
[ # # ]
141 : : }
142 : : }
143 : 0 : aHLinkItem.SetInsertMode(HLINK_BUTTON);
144 : 0 : }
145 [ # # ]: 0 : }
146 : : }
147 : : }
148 : :
149 [ # # ][ # # ]: 0 : rSet.Put(aHLinkItem);
[ # # ]
150 : : }
151 : :
152 : 0 : void ScDrawShell::ExecuteHLink( SfxRequest& rReq )
153 : : {
154 : 0 : const SfxItemSet* pReqArgs = rReq.GetArgs();
155 : :
156 : 0 : sal_uInt16 nSlot = rReq.GetSlot();
157 [ # # ]: 0 : switch ( nSlot )
158 : : {
159 : : case SID_HYPERLINK_SETLINK:
160 [ # # ]: 0 : if( pReqArgs )
161 : : {
162 : : const SfxPoolItem* pItem;
163 [ # # ][ # # ]: 0 : if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, sal_True, &pItem ) == SFX_ITEM_SET )
164 : : {
165 : 0 : const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
166 : 0 : const String& rName = pHyper->GetName();
167 : 0 : const String& rURL = pHyper->GetURL();
168 : 0 : const String& rTarget = pHyper->GetTargetFrame();
169 : 0 : SvxLinkInsertMode eMode = pHyper->GetInsertMode();
170 : :
171 : 0 : sal_Bool bDone = false;
172 [ # # ][ # # ]: 0 : if ( eMode == HLINK_FIELD || eMode == HLINK_BUTTON )
173 : : {
174 [ # # ]: 0 : ScDrawView* pView = pViewData->GetScDrawView();
175 : 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
176 [ # # ]: 0 : if ( rMarkList.GetMarkCount() == 1 )
177 : : {
178 [ # # ][ # # ]: 0 : SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
179 [ # # ][ # # ]: 0 : SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObj );
[ # # ][ # # ]
180 [ # # ][ # # ]: 0 : if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
[ # # ][ # # ]
181 : : {
182 : : uno::Reference<awt::XControlModel> xControlModel =
183 [ # # ]: 0 : pUnoCtrl->GetUnoControlModel();
184 : : OSL_ENSURE( xControlModel.is(), "UNO-Control ohne Model" );
185 [ # # ]: 0 : if( !xControlModel.is() )
186 : 0 : return;
187 : :
188 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
189 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
190 : :
191 [ # # ]: 0 : rtl::OUString sPropTargetURL(RTL_CONSTASCII_USTRINGPARAM( "TargetURL" ));
192 : :
193 : : // Darf man eine URL an dem Objekt setzen?
194 [ # # ][ # # ]: 0 : if (xInfo->hasPropertyByName( sPropTargetURL ))
[ # # ]
195 : : {
196 : : // Ja!
197 : :
198 [ # # ]: 0 : rtl::OUString sPropButtonType(RTL_CONSTASCII_USTRINGPARAM( "ButtonType") );
199 [ # # ]: 0 : rtl::OUString sPropTargetFrame(RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" ));
200 [ # # ]: 0 : rtl::OUString sPropLabel(RTL_CONSTASCII_USTRINGPARAM( "Label" ));
201 : :
202 : 0 : uno::Any aAny;
203 [ # # ][ # # ]: 0 : if ( xInfo->hasPropertyByName( sPropLabel ) )
[ # # ]
204 : : {
205 [ # # ][ # # ]: 0 : aAny <<= rtl::OUString(rName);
206 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue( sPropLabel, aAny );
207 : : }
208 : :
209 [ # # ][ # # ]: 0 : ::rtl::OUString aTmp = INetURLObject::GetAbsURL( pViewData->GetDocShell()->GetMedium()->GetBaseURL(), rURL );
[ # # ]
210 [ # # ]: 0 : aAny <<= aTmp;
211 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue( sPropTargetURL, aAny );
212 : :
213 [ # # ][ # # ]: 0 : if( rTarget.Len() && xInfo->hasPropertyByName( sPropTargetFrame ) )
[ # # ][ # # ]
[ # # ]
214 : : {
215 [ # # ][ # # ]: 0 : aAny <<= rtl::OUString(rTarget);
216 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue( sPropTargetFrame, aAny );
217 : : }
218 : :
219 [ # # ][ # # ]: 0 : if ( xInfo->hasPropertyByName( sPropButtonType ) )
[ # # ]
220 : : {
221 : 0 : form::FormButtonType eButtonType = form::FormButtonType_URL;
222 [ # # ]: 0 : aAny <<= eButtonType;
223 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue( sPropButtonType, aAny );
224 : : }
225 : :
226 : : //! Undo ???
227 [ # # ]: 0 : pViewData->GetDocShell()->SetDocumentModified();
228 : 0 : bDone = sal_True;
229 [ # # ]: 0 : }
230 : : }
231 : : else
232 : : {
233 [ # # ][ # # ]: 0 : SetHlinkForObject( pObj, rURL );
234 : 0 : bDone = sal_True;
235 : : }
236 : : }
237 : : }
238 : :
239 [ # # ]: 0 : if (!bDone)
240 : : pViewData->GetViewShell()->
241 [ # # ]: 0 : InsertURL( rName, rURL, rTarget, (sal_uInt16) eMode );
242 : :
243 : : // InsertURL an der ViewShell schaltet bei "Text" die DrawShell ab !!!
244 : : }
245 : : }
246 : 0 : break;
247 : : default:
248 : : OSL_FAIL("falscher Slot");
249 : : }
250 : : }
251 : :
252 : : sal_uInt16 ScGetFontWorkId(); // wegen CLOOKs - in drtxtob2
253 : :
254 : : //------------------------------------------------------------------
255 : :
256 : : //
257 : : // Funktionen auf Drawing-Objekten
258 : : //
259 : :
260 : 0 : void ScDrawShell::ExecDrawFunc( SfxRequest& rReq )
261 : : {
262 : 0 : SfxBindings& rBindings = pViewData->GetBindings();
263 [ # # ]: 0 : ScTabView* pTabView = pViewData->GetView();
264 : 0 : ScDrawView* pView = pTabView->GetScDrawView();
265 : 0 : const SfxItemSet *pArgs = rReq.GetArgs();
266 : 0 : sal_uInt16 nSlotId = rReq.GetSlot();
267 : :
268 : : //!!!
269 : : // wer weiss, wie lange das funktioniert? (->vom Abreisscontrol funktioniert es)
270 : : //
271 [ # # ][ # # ]: 0 : if (nSlotId == SID_OBJECT_ALIGN && pArgs)
272 : 0 : nSlotId = SID_OBJECT_ALIGN + ((SfxEnumItem&)pArgs->Get(SID_OBJECT_ALIGN)).GetValue() + 1;
273 : :
274 [ # # # # : 0 : switch (nSlotId)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
275 : : {
276 : : case SID_OBJECT_HEAVEN:
277 : 0 : pView->SetMarkedToLayer( SC_LAYER_FRONT );
278 : 0 : rBindings.Invalidate(SID_OBJECT_HEAVEN);
279 : 0 : rBindings.Invalidate(SID_OBJECT_HELL);
280 : 0 : break;
281 : : case SID_OBJECT_HELL:
282 : 0 : pView->SetMarkedToLayer( SC_LAYER_BACK );
283 : 0 : rBindings.Invalidate(SID_OBJECT_HEAVEN);
284 : 0 : rBindings.Invalidate(SID_OBJECT_HELL);
285 : : // leave draw shell if nothing selected (layer may be locked)
286 : 0 : pViewData->GetViewShell()->UpdateDrawShell();
287 : 0 : break;
288 : :
289 : : case SID_FRAME_TO_TOP:
290 : 0 : pView->PutMarkedToTop();
291 : 0 : break;
292 : : case SID_FRAME_TO_BOTTOM:
293 : 0 : pView->PutMarkedToBtm();
294 : 0 : break;
295 : : case SID_FRAME_UP:
296 : 0 : pView->MovMarkedToTop();
297 : 0 : break;
298 : : case SID_FRAME_DOWN:
299 : 0 : pView->MovMarkedToBtm();
300 : 0 : break;
301 : :
302 : : case SID_GROUP:
303 : 0 : pView->GroupMarked();
304 : 0 : break;
305 : : case SID_UNGROUP:
306 : 0 : pView->UnGroupMarked();
307 : 0 : break;
308 : : case SID_ENTER_GROUP:
309 : 0 : pView->EnterMarkedGroup();
310 : 0 : break;
311 : : case SID_LEAVE_GROUP:
312 : 0 : pView->LeaveOneGroup();
313 : 0 : break;
314 : :
315 : : case SID_MIRROR_HORIZONTAL:
316 : 0 : pView->MirrorAllMarkedHorizontal();
317 : 0 : break;
318 : : case SID_MIRROR_VERTICAL:
319 : 0 : pView->MirrorAllMarkedVertical();
320 : 0 : break;
321 : :
322 : : case SID_OBJECT_ALIGN_LEFT:
323 : : case SID_ALIGN_ANY_LEFT:
324 [ # # ]: 0 : if (pView->IsAlignPossible())
325 : 0 : pView->AlignMarkedObjects(SDRHALIGN_LEFT, SDRVALIGN_NONE);
326 : 0 : break;
327 : : case SID_OBJECT_ALIGN_CENTER:
328 : : case SID_ALIGN_ANY_HCENTER:
329 [ # # ]: 0 : if (pView->IsAlignPossible())
330 : 0 : pView->AlignMarkedObjects(SDRHALIGN_CENTER, SDRVALIGN_NONE);
331 : 0 : break;
332 : : case SID_OBJECT_ALIGN_RIGHT:
333 : : case SID_ALIGN_ANY_RIGHT:
334 [ # # ]: 0 : if (pView->IsAlignPossible())
335 : 0 : pView->AlignMarkedObjects(SDRHALIGN_RIGHT, SDRVALIGN_NONE);
336 : 0 : break;
337 : : case SID_OBJECT_ALIGN_UP:
338 : : case SID_ALIGN_ANY_TOP:
339 [ # # ]: 0 : if (pView->IsAlignPossible())
340 : 0 : pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_TOP);
341 : 0 : break;
342 : : case SID_OBJECT_ALIGN_MIDDLE:
343 : : case SID_ALIGN_ANY_VCENTER:
344 [ # # ]: 0 : if (pView->IsAlignPossible())
345 : 0 : pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_CENTER);
346 : 0 : break;
347 : : case SID_OBJECT_ALIGN_DOWN:
348 : : case SID_ALIGN_ANY_BOTTOM:
349 [ # # ]: 0 : if (pView->IsAlignPossible())
350 : 0 : pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_BOTTOM);
351 : 0 : break;
352 : :
353 : : case SID_DELETE:
354 : : case SID_DELETE_CONTENTS:
355 : 0 : pView->DeleteMarked();
356 : 0 : pViewData->GetViewShell()->UpdateDrawShell();
357 : 0 : break;
358 : :
359 : : case SID_CUT:
360 : 0 : pView->DoCut();
361 : 0 : pViewData->GetViewShell()->UpdateDrawShell();
362 : 0 : break;
363 : :
364 : : case SID_COPY:
365 : 0 : pView->DoCopy();
366 : 0 : break;
367 : :
368 : : case SID_PASTE:
369 : : OSL_FAIL( "SdrView::PasteClipboard not supported anymore" );
370 : 0 : break;
371 : :
372 : : case SID_SELECTALL:
373 : 0 : pView->MarkAll();
374 : 0 : break;
375 : :
376 : : case SID_ANCHOR_PAGE:
377 : 0 : pView->SetPageAnchored();
378 : 0 : rBindings.Invalidate( SID_ANCHOR_PAGE );
379 : 0 : rBindings.Invalidate( SID_ANCHOR_CELL );
380 : 0 : break;
381 : :
382 : : case SID_ANCHOR_CELL:
383 : 0 : pView->SetCellAnchored();
384 : 0 : rBindings.Invalidate( SID_ANCHOR_PAGE );
385 : 0 : rBindings.Invalidate( SID_ANCHOR_CELL );
386 : 0 : break;
387 : :
388 : : case SID_ANCHOR_TOGGLE:
389 : : {
390 [ # # ]: 0 : switch( pView->GetAnchorType() )
391 : : {
392 : : case SCA_CELL:
393 : 0 : pView->SetPageAnchored();
394 : 0 : break;
395 : : default:
396 : 0 : pView->SetCellAnchored();
397 : 0 : break;
398 : : }
399 : : }
400 : 0 : rBindings.Invalidate( SID_ANCHOR_PAGE );
401 : 0 : rBindings.Invalidate( SID_ANCHOR_CELL );
402 : 0 : break;
403 : :
404 : : case SID_OBJECT_ROTATE:
405 : : {
406 : : SdrDragMode eMode;
407 [ # # ]: 0 : if (pView->GetDragMode() == SDRDRAG_ROTATE)
408 : 0 : eMode = SDRDRAG_MOVE;
409 : : else
410 : 0 : eMode = SDRDRAG_ROTATE;
411 : 0 : pView->SetDragMode( eMode );
412 : 0 : rBindings.Invalidate( SID_OBJECT_ROTATE );
413 : 0 : rBindings.Invalidate( SID_OBJECT_MIRROR );
414 [ # # ][ # # ]: 0 : if (eMode == SDRDRAG_ROTATE && !pView->IsFrameDragSingles())
[ # # ]
415 : : {
416 : 0 : pView->SetFrameDragSingles( sal_True );
417 : 0 : rBindings.Invalidate( SID_BEZIER_EDIT );
418 : : }
419 : : }
420 : 0 : break;
421 : : case SID_OBJECT_MIRROR:
422 : : {
423 : : SdrDragMode eMode;
424 [ # # ]: 0 : if (pView->GetDragMode() == SDRDRAG_MIRROR)
425 : 0 : eMode = SDRDRAG_MOVE;
426 : : else
427 : 0 : eMode = SDRDRAG_MIRROR;
428 : 0 : pView->SetDragMode( eMode );
429 : 0 : rBindings.Invalidate( SID_OBJECT_ROTATE );
430 : 0 : rBindings.Invalidate( SID_OBJECT_MIRROR );
431 [ # # ][ # # ]: 0 : if (eMode == SDRDRAG_MIRROR && !pView->IsFrameDragSingles())
[ # # ]
432 : : {
433 : 0 : pView->SetFrameDragSingles( sal_True );
434 : 0 : rBindings.Invalidate( SID_BEZIER_EDIT );
435 : : }
436 : : }
437 : 0 : break;
438 : : case SID_BEZIER_EDIT:
439 : : {
440 : 0 : sal_Bool bOld = pView->IsFrameDragSingles();
441 : 0 : pView->SetFrameDragSingles( !bOld );
442 : 0 : rBindings.Invalidate( SID_BEZIER_EDIT );
443 [ # # ][ # # ]: 0 : if (bOld && pView->GetDragMode() != SDRDRAG_MOVE)
[ # # ]
444 : : {
445 : 0 : pView->SetDragMode( SDRDRAG_MOVE );
446 : 0 : rBindings.Invalidate( SID_OBJECT_ROTATE );
447 : 0 : rBindings.Invalidate( SID_OBJECT_MIRROR );
448 : : }
449 : : }
450 : 0 : break;
451 : :
452 : : case SID_FONTWORK:
453 : : {
454 : 0 : sal_uInt16 nId = ScGetFontWorkId();
455 : 0 : SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
456 : :
457 [ # # ]: 0 : if ( rReq.GetArgs() )
458 : : pViewFrm->SetChildWindow( nId,
459 : : ((const SfxBoolItem&)
460 : 0 : (rReq.GetArgs()->Get(SID_FONTWORK))).
461 : 0 : GetValue() );
462 : : else
463 : 0 : pViewFrm->ToggleChildWindow( nId );
464 : :
465 : 0 : rBindings.Invalidate( SID_FONTWORK );
466 : 0 : rReq.Done();
467 : : }
468 : 0 : break;
469 : :
470 : : case SID_ORIGINALSIZE:
471 : 0 : pView->SetMarkedOriginalSize();
472 : 0 : break;
473 : :
474 : : case SID_ENABLE_HYPHENATION:
475 : : {
476 : 0 : SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_ENABLE_HYPHENATION, false);
477 [ # # ]: 0 : if( pItem )
478 : : {
479 [ # # ]: 0 : SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
480 : 0 : sal_Bool bValue = ( (const SfxBoolItem*) pItem)->GetValue();
481 [ # # ][ # # ]: 0 : aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
[ # # ]
482 [ # # ][ # # ]: 0 : pView->SetAttributes( aSet );
483 : : }
484 : 0 : rReq.Done();
485 : : }
486 : 0 : break;
487 : :
488 : : case SID_RENAME_OBJECT:
489 : : {
490 [ # # ]: 0 : if(1L == pView->GetMarkedObjectCount())
491 : : {
492 : : // #i68101#
493 : 0 : SdrObject* pSelected = pView->GetMarkedObjectByIndex(0L);
494 : : OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
495 : :
496 [ # # ]: 0 : if(SC_LAYER_INTERN != pSelected->GetLayer())
497 : : {
498 [ # # ]: 0 : rtl::OUString aName = pSelected->GetName();
499 : :
500 [ # # ]: 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
501 : : OSL_ENSURE(pFact, "Dialogdiet fail!");
502 [ # # ][ # # ]: 0 : AbstractSvxObjectNameDialog* pDlg = pFact->CreateSvxObjectNameDialog(NULL, aName);
[ # # ]
503 : : OSL_ENSURE(pDlg, "Dialogdiet fail!");
504 : :
505 [ # # ][ # # ]: 0 : pDlg->SetCheckNameHdl(LINK(this, ScDrawShell, NameObjectHdl));
506 : :
507 [ # # ][ # # ]: 0 : if(RET_OK == pDlg->Execute())
508 : : {
509 : 0 : ScDocShell* pDocSh = pViewData->GetDocShell();
510 [ # # ]: 0 : String aTmp;
511 [ # # ]: 0 : pDlg->GetName(aTmp);
512 [ # # ]: 0 : aName = aTmp;
513 : :
514 [ # # ][ # # ]: 0 : if (!aName.equals(pSelected->GetName()))
515 : : {
516 : : // handle name change
517 [ # # ]: 0 : const sal_uInt16 nObjType(pSelected->GetObjIdentifier());
518 : :
519 [ # # ][ # # ]: 0 : if (OBJ_GRAF == nObjType && aName.isEmpty())
[ # # ]
520 : : {
521 : : // graphics objects must have names
522 : : // (all graphics are supposed to be in the navigator)
523 [ # # ][ # # ]: 0 : ScDrawLayer* pModel = pViewData->GetDocument()->GetDrawLayer();
524 : :
525 [ # # ]: 0 : if(pModel)
526 : : {
527 [ # # ][ # # ]: 0 : aName = pModel->GetNewGraphicName();
[ # # ]
528 : : }
529 : : }
530 : :
531 : : // An undo action for renaming is missing in svdraw (99363).
532 : : // For OLE objects (which can be identified using the persist name),
533 : : // ScUndoRenameObject can be used until there is a common action for all objects.
534 [ # # ]: 0 : if(OBJ_OLE2 == nObjType)
535 : : {
536 [ # # ]: 0 : const String aPersistName = static_cast<SdrOle2Obj*>(pSelected)->GetPersistName();
537 : :
538 [ # # ]: 0 : if(aPersistName.Len())
539 : : {
540 [ # # ]: 0 : pDocSh->GetUndoManager()->AddUndoAction(
541 [ # # ][ # # ]: 0 : new ScUndoRenameObject(pDocSh, aPersistName, pSelected->GetName(), aName));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
542 [ # # ]: 0 : }
543 : : }
544 : :
545 : : // set new name
546 [ # # ]: 0 : pSelected->SetName(aName);
547 : : }
548 : :
549 : : // ChartListenerCollectionNeedsUpdate is needed for Navigator update
550 : 0 : pDocSh->GetDocument()->SetChartListenerCollectionNeedsUpdate( sal_True );
551 [ # # ][ # # ]: 0 : pDocSh->SetDrawModified();
552 : : }
553 : :
554 [ # # ][ # # ]: 0 : delete pDlg;
555 : : }
556 : : }
557 : 0 : break;
558 : : }
559 : :
560 : : // #i68101#
561 : : case SID_TITLE_DESCRIPTION_OBJECT:
562 : : {
563 [ # # ]: 0 : if(1L == pView->GetMarkedObjectCount())
564 : : {
565 : 0 : SdrObject* pSelected = pView->GetMarkedObjectByIndex(0L);
566 : : OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
567 : :
568 [ # # ]: 0 : if(SC_LAYER_INTERN != pSelected->GetLayer())
569 : : {
570 [ # # ][ # # ]: 0 : String aTitle(pSelected->GetTitle());
571 [ # # ][ # # ]: 0 : String aDescription(pSelected->GetDescription());
572 : :
573 [ # # ]: 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
574 : : OSL_ENSURE(pFact, "Dialogdiet fail!");
575 [ # # ]: 0 : AbstractSvxObjectTitleDescDialog* pDlg = pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription);
576 : : OSL_ENSURE(pDlg, "Dialogdiet fail!");
577 : :
578 [ # # ][ # # ]: 0 : if(RET_OK == pDlg->Execute())
579 : : {
580 : 0 : ScDocShell* pDocSh = pViewData->GetDocShell();
581 : :
582 : : // handle Title and Description
583 [ # # ]: 0 : pDlg->GetTitle(aTitle);
584 [ # # ]: 0 : pDlg->GetDescription(aDescription);
585 [ # # ][ # # ]: 0 : pSelected->SetTitle(aTitle);
586 [ # # ][ # # ]: 0 : pSelected->SetDescription(aDescription);
587 : :
588 : : // ChartListenerCollectionNeedsUpdate is needed for Navigator update
589 : 0 : pDocSh->GetDocument()->SetChartListenerCollectionNeedsUpdate( sal_True );
590 [ # # ]: 0 : pDocSh->SetDrawModified();
591 : : }
592 : :
593 [ # # ][ # # ]: 0 : delete pDlg;
[ # # ][ # # ]
594 : : }
595 : : }
596 : 0 : break;
597 : : }
598 : :
599 : : case SID_EXTRUSION_TOOGLE:
600 : : case SID_EXTRUSION_TILT_DOWN:
601 : : case SID_EXTRUSION_TILT_UP:
602 : : case SID_EXTRUSION_TILT_LEFT:
603 : : case SID_EXTRUSION_TILT_RIGHT:
604 : : case SID_EXTRUSION_3D_COLOR:
605 : : case SID_EXTRUSION_DEPTH:
606 : : case SID_EXTRUSION_DIRECTION:
607 : : case SID_EXTRUSION_PROJECTION:
608 : : case SID_EXTRUSION_LIGHTING_DIRECTION:
609 : : case SID_EXTRUSION_LIGHTING_INTENSITY:
610 : : case SID_EXTRUSION_SURFACE:
611 : : case SID_EXTRUSION_DEPTH_FLOATER:
612 : : case SID_EXTRUSION_DIRECTION_FLOATER:
613 : : case SID_EXTRUSION_LIGHTING_FLOATER:
614 : : case SID_EXTRUSION_SURFACE_FLOATER:
615 : : case SID_EXTRUSION_DEPTH_DIALOG:
616 : 0 : svx::ExtrusionBar::execute( pView, rReq, rBindings );
617 : 0 : rReq.Ignore ();
618 : 0 : break;
619 : :
620 : : case SID_FONTWORK_SHAPE:
621 : : case SID_FONTWORK_SHAPE_TYPE:
622 : : case SID_FONTWORK_ALIGNMENT:
623 : : case SID_FONTWORK_SAME_LETTER_HEIGHTS:
624 : : case SID_FONTWORK_CHARACTER_SPACING:
625 : : case SID_FONTWORK_KERN_CHARACTER_PAIRS:
626 : : case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
627 : : case SID_FONTWORK_ALIGNMENT_FLOATER:
628 : : case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
629 : 0 : svx::FontworkBar::execute( pView, rReq, rBindings );
630 : 0 : rReq.Ignore ();
631 : 0 : break;
632 : :
633 : : default:
634 : 0 : break;
635 : : }
636 : 0 : }
637 : :
638 : 0 : IMPL_LINK( ScDrawShell, NameObjectHdl, AbstractSvxNameDialog*, pDialog )
639 : : {
640 [ # # ]: 0 : String aName;
641 : :
642 [ # # ]: 0 : if( pDialog )
643 [ # # ]: 0 : pDialog->GetName( aName );
644 : :
645 [ # # ][ # # ]: 0 : ScDrawLayer* pModel = pViewData->GetDocument()->GetDrawLayer();
646 [ # # ][ # # ]: 0 : if ( aName.Len() && pModel )
[ # # ]
647 : : {
648 : : SCTAB nDummyTab;
649 [ # # ][ # # ]: 0 : if ( pModel->GetNamedObject( aName, 0, nDummyTab ) )
650 : : {
651 : : // existing object found -> name invalid
652 : 0 : return 0;
653 : : }
654 : : }
655 : :
656 [ # # ]: 0 : return 1; // name is valid
657 : : }
658 : :
659 : : //------------------------------------------------------------------
660 : :
661 : 0 : void ScDrawShell::ExecFormText(SfxRequest& rReq)
662 : : {
663 : 0 : ScDrawView* pDrView = pViewData->GetScDrawView();
664 : 0 : const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
665 : :
666 [ # # ][ # # ]: 0 : if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
[ # # ]
667 : : {
668 : 0 : const SfxItemSet& rSet = *rReq.GetArgs();
669 : : const SfxPoolItem* pItem;
670 : :
671 [ # # ][ # # ]: 0 : if ( pDrView->IsTextEdit() )
672 [ # # ]: 0 : pDrView->ScEndTextEdit();
673 : :
674 [ # # # # ]: 0 : if ( SFX_ITEM_SET ==
[ # # ]
675 [ # # ]: 0 : rSet.GetItemState(XATTR_FORMTXTSTDFORM, sal_True, &pItem)
676 : : && XFTFORM_NONE !=
677 : 0 : ((const XFormTextStdFormItem*) pItem)->GetValue() )
678 : : {
679 : :
680 [ # # ]: 0 : sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
681 : 0 : SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
682 : : SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*)
683 : : (pViewFrm->
684 [ # # ]: 0 : GetChildWindow(nId)->GetWindow());
685 : :
686 : 0 : pDlg->CreateStdFormObj(*pDrView, *pDrView->GetSdrPageView(),
687 [ # # ][ # # ]: 0 : rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(),
688 : : ((const XFormTextStdFormItem*) pItem)->
689 [ # # ]: 0 : GetValue());
690 : : }
691 : : else
692 [ # # ]: 0 : pDrView->SetAttributes(rSet);
693 : : }
694 : 0 : }
695 : :
696 : : //------------------------------------------------------------------
697 : :
698 : 0 : void ScDrawShell::ExecFormatPaintbrush( SfxRequest& rReq )
699 : : {
700 [ # # ]: 0 : ScViewFunc* pView = pViewData->GetView();
701 [ # # ]: 0 : if ( pView->HasPaintBrush() )
702 : : {
703 : : // cancel paintbrush mode
704 : 0 : pView->ResetBrushDocument();
705 : : }
706 : : else
707 : : {
708 : 0 : sal_Bool bLock = false;
709 : 0 : const SfxItemSet *pArgs = rReq.GetArgs();
710 [ # # ][ # # ]: 0 : if( pArgs && pArgs->Count() >= 1 )
[ # # ]
711 : 0 : bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue();
712 : :
713 : 0 : ScDrawView* pDrawView = pViewData->GetScDrawView();
714 [ # # ][ # # ]: 0 : if ( pDrawView && pDrawView->AreObjectsMarked() )
[ # # ]
715 : : {
716 : 0 : sal_Bool bOnlyHardAttr = sal_True;
717 [ # # ]: 0 : SfxItemSet* pItemSet = new SfxItemSet( pDrawView->GetAttrFromMarked(bOnlyHardAttr) );
718 : 0 : pView->SetDrawBrushSet( pItemSet, bLock );
719 : : }
720 : : }
721 : 0 : }
722 : :
723 : 0 : void ScDrawShell::StateFormatPaintbrush( SfxItemSet& rSet )
724 : : {
725 : 0 : ScDrawView* pDrawView = pViewData->GetScDrawView();
726 [ # # ][ # # ]: 0 : sal_Bool bSelection = pDrawView && pDrawView->AreObjectsMarked();
727 : 0 : sal_Bool bHasPaintBrush = pViewData->GetView()->HasPaintBrush();
728 : :
729 [ # # ][ # # ]: 0 : if ( !bHasPaintBrush && !bSelection )
730 : 0 : rSet.DisableItem( SID_FORMATPAINTBRUSH );
731 : : else
732 [ # # ]: 0 : rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, bHasPaintBrush ) );
733 : 0 : }
734 : :
735 : 0 : ScDrawView* ScDrawShell::GetDrawView()
736 : : {
737 : 0 : return pViewData->GetView()->GetScDrawView();
738 : : }
739 : :
740 : :
741 : :
742 : :
743 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|