Line data Source code
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/NoVisualAreaSizeException.hpp>
21 : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
22 :
23 : #include <com/sun/star/embed/EmbedMisc.hpp>
24 : #include <com/sun/star/embed/EmbedStates.hpp>
25 : #include <sfx2/app.hxx>
26 : #include <toolkit/helper/vclunohelper.hxx>
27 : #include <svx/svxdlg.hxx>
28 : #include <svx/dataaccessdescriptor.hxx>
29 : #include <svx/pfiledlg.hxx>
30 : #include <svx/svditer.hxx>
31 : #include <svx/svdmark.hxx>
32 : #include <svx/svdograf.hxx>
33 : #include <svx/svdogrp.hxx>
34 : #include <svx/svdoole2.hxx>
35 : #include <svx/svdouno.hxx>
36 : #include <svx/svdview.hxx>
37 : #include <sfx2/linkmgr.hxx>
38 : #include <svx/fontworkbar.hxx>
39 : #include <sfx2/bindings.hxx>
40 : #include <sfx2/dispatch.hxx>
41 : #include <sfx2/viewfrm.hxx>
42 : #include <svtools/soerr.hxx>
43 : #include <svl/rectitem.hxx>
44 : #include <svl/slstitm.hxx>
45 : #include <svl/whiter.hxx>
46 : #include <unotools/moduleoptions.hxx>
47 : #include <sot/exchange.hxx>
48 : #include <tools/diagnose_ex.h>
49 :
50 : #include "tabvwsh.hxx"
51 : #include "globstr.hrc"
52 : #include "scmod.hxx"
53 : #include "document.hxx"
54 : #include "sc.hrc"
55 : #include "client.hxx"
56 : #include "fuinsert.hxx"
57 : #include "docsh.hxx"
58 : #include "chartarr.hxx"
59 : #include "drawview.hxx"
60 : #include "ChartRangeSelectionListener.hxx"
61 :
62 : #include <tools/urlobj.hxx>
63 : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
64 :
65 : using namespace com::sun::star;
66 :
67 : // STATIC DATA -----------------------------------------------------------
68 :
69 0 : void ScTabViewShell::ConnectObject( SdrOle2Obj* pObj )
70 : {
71 : // wird aus dem Paint gerufen
72 :
73 0 : uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
74 0 : Window* pWin = GetActiveWin();
75 :
76 : // wenn schon connected ist, nicht nochmal SetObjArea/SetSizeScale
77 :
78 0 : SfxInPlaceClient* pClient = FindIPClient( xObj, pWin );
79 0 : if ( !pClient )
80 : {
81 0 : pClient = new ScClient( this, pWin, GetSdrView()->GetModel(), pObj );
82 0 : Rectangle aRect = pObj->GetLogicRect();
83 0 : Size aDrawSize = aRect.GetSize();
84 :
85 0 : Size aOleSize = pObj->GetOrigObjSize();
86 :
87 0 : Fraction aScaleWidth (aDrawSize.Width(), aOleSize.Width() );
88 0 : Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() );
89 0 : aScaleWidth.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj
90 0 : aScaleHeight.ReduceInaccurate(10);
91 0 : pClient->SetSizeScale(aScaleWidth,aScaleHeight);
92 :
93 : // sichtbarer Ausschnitt wird nur inplace veraendert!
94 : // the object area must be set after the scaling since it triggers the resizing
95 0 : aRect.SetSize( aOleSize );
96 0 : pClient->SetObjArea( aRect );
97 :
98 0 : ((ScClient*)pClient)->SetGrafEdit( NULL );
99 0 : }
100 0 : }
101 :
102 0 : bool ScTabViewShell::ActivateObject( SdrOle2Obj* pObj, long nVerb )
103 : {
104 : // Gueltigkeits-Hinweisfenster nicht ueber dem Objekt stehenlassen
105 0 : RemoveHintWindow();
106 :
107 0 : uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
108 0 : Window* pWin = GetActiveWin();
109 0 : ErrCode nErr = ERRCODE_NONE;
110 0 : bool bErrorShown = false;
111 :
112 : {
113 0 : SfxInPlaceClient* pClient = FindIPClient( xObj, pWin );
114 0 : if ( !pClient )
115 0 : pClient = new ScClient( this, pWin, GetSdrView()->GetModel(), pObj );
116 :
117 0 : if ( !(nErr & ERRCODE_ERROR_MASK) && xObj.is() )
118 : {
119 0 : Rectangle aRect = pObj->GetLogicRect();
120 :
121 : {
122 : // #i118485# center on BoundRect for activation,
123 : // OLE may be sheared/rotated now
124 0 : const Rectangle& rBoundRect = pObj->GetCurrentBoundRect();
125 0 : const Point aDelta(rBoundRect.Center() - aRect.Center());
126 0 : aRect.Move(aDelta.X(), aDelta.Y());
127 : }
128 :
129 0 : Size aDrawSize = aRect.GetSize();
130 :
131 0 : MapMode aMapMode( MAP_100TH_MM );
132 0 : Size aOleSize = pObj->GetOrigObjSize( &aMapMode );
133 :
134 0 : if ( pClient->GetAspect() != embed::Aspects::MSOLE_ICON
135 0 : && ( xObj->getStatus( pClient->GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
136 : {
137 : // scale must always be 1 - change VisArea if different from client size
138 :
139 0 : if ( aDrawSize != aOleSize )
140 : {
141 0 : MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( pClient->GetAspect() ) );
142 : aOleSize = OutputDevice::LogicToLogic( aDrawSize,
143 0 : MAP_100TH_MM, aUnit );
144 0 : awt::Size aSz( aOleSize.Width(), aOleSize.Height() );
145 0 : xObj->setVisualAreaSize( pClient->GetAspect(), aSz );
146 : }
147 0 : Fraction aOne( 1, 1 );
148 0 : pClient->SetSizeScale( aOne, aOne );
149 : }
150 : else
151 : {
152 : // calculate scale from client and VisArea size
153 :
154 0 : Fraction aScaleWidth (aDrawSize.Width(), aOleSize.Width() );
155 0 : Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() );
156 0 : aScaleWidth.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj
157 0 : aScaleHeight.ReduceInaccurate(10);
158 0 : pClient->SetSizeScale(aScaleWidth,aScaleHeight);
159 : }
160 :
161 : // sichtbarer Ausschnitt wird nur inplace veraendert!
162 : // the object area must be set after the scaling since it triggers the resizing
163 0 : aRect.SetSize( aOleSize );
164 0 : pClient->SetObjArea( aRect );
165 :
166 0 : ((ScClient*)pClient)->SetGrafEdit( NULL );
167 :
168 0 : nErr = pClient->DoVerb( nVerb );
169 0 : bErrorShown = true;
170 : // SfxViewShell::DoVerb zeigt seine Fehlermeldungen selber an
171 :
172 : // attach listener to selection changes in chart that affect cell
173 : // ranges, so those can be highlighted
174 : // note: do that after DoVerb, so that the chart controller exists
175 0 : if ( SvtModuleOptions().IsChart() )
176 : {
177 0 : SvGlobalName aObjClsId ( xObj->getClassID() );
178 0 : if (SotExchange::IsChart( aObjClsId ))
179 : {
180 : try
181 : {
182 0 : uno::Reference < embed::XComponentSupplier > xSup( xObj, uno::UNO_QUERY_THROW );
183 : uno::Reference< chart2::data::XDataReceiver > xDataReceiver(
184 0 : xSup->getComponent(), uno::UNO_QUERY_THROW );
185 : uno::Reference< chart2::data::XRangeHighlighter > xRangeHightlighter(
186 0 : xDataReceiver->getRangeHighlighter());
187 0 : if( xRangeHightlighter.is())
188 : {
189 : uno::Reference< view::XSelectionChangeListener > xListener(
190 0 : new ScChartRangeSelectionListener( this ));
191 0 : xRangeHightlighter->addSelectionChangeListener( xListener );
192 0 : }
193 : }
194 0 : catch( const uno::Exception & )
195 : {
196 : OSL_FAIL( "Exception caught while querying chart" );
197 : }
198 0 : }
199 0 : }
200 : }
201 : }
202 0 : if (nErr != ERRCODE_NONE && !bErrorShown)
203 0 : ErrorHandler::HandleError(nErr);
204 :
205 : // #i118524# refresh handles to suppress for activated OLE
206 0 : if(GetSdrView())
207 : {
208 0 : GetSdrView()->AdjustMarkHdl();
209 : }
210 : //! SetDocumentName sollte schon im Sfx passieren ???
211 : //TODO/LATER: how "SetDocumentName"?
212 : //xIPObj->SetDocumentName( GetViewData()->GetDocShell()->GetTitle() );
213 :
214 0 : return ( !(nErr & ERRCODE_ERROR_MASK) );
215 : }
216 :
217 0 : ErrCode ScTabViewShell::DoVerb(long nVerb)
218 : {
219 0 : SdrView* pView = GetSdrView();
220 0 : if (!pView)
221 0 : return ERRCODE_SO_NOTIMPL; // soll nicht sein
222 :
223 0 : SdrOle2Obj* pOle2Obj = NULL;
224 0 : ErrCode nErr = ERRCODE_NONE;
225 :
226 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
227 0 : if (rMarkList.GetMarkCount() == 1)
228 : {
229 0 : SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
230 0 : if (pObj->GetObjIdentifier() == OBJ_OLE2)
231 0 : pOle2Obj = (SdrOle2Obj*) pObj;
232 : }
233 :
234 0 : if (pOle2Obj)
235 : {
236 0 : ActivateObject( pOle2Obj, nVerb );
237 : }
238 : else
239 : {
240 : OSL_FAIL("kein Objekt fuer Verb gefunden");
241 : }
242 :
243 0 : return nErr;
244 : }
245 :
246 0 : void ScTabViewShell::DeactivateOle()
247 : {
248 : // deactivate inplace editing if currently active
249 :
250 0 : ScModule* pScMod = SC_MOD();
251 0 : bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
252 :
253 0 : ScClient* pClient = (ScClient*) GetIPClient();
254 0 : if ( pClient && pClient->IsObjectInPlaceActive() && !bUnoRefDialog )
255 0 : pClient->DeactivateObject();
256 0 : }
257 :
258 0 : void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
259 : {
260 0 : sal_uInt16 nSlot = rReq.GetSlot();
261 0 : if (nSlot != SID_OBJECTRESIZE )
262 : {
263 0 : SC_MOD()->InputEnterHandler();
264 0 : UpdateInputHandler();
265 : }
266 :
267 : // Rahmen fuer Chart einfuegen wird abgebrochen:
268 0 : FuPoor* pPoor = GetDrawFuncPtr();
269 0 : if ( pPoor && pPoor->GetSlotID() == SID_DRAW_CHART )
270 0 : GetViewData()->GetDispatcher().Execute(SID_DRAW_CHART, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
271 :
272 0 : MakeDrawLayer();
273 :
274 0 : SfxBindings& rBindings = GetViewFrame()->GetBindings();
275 0 : ScTabView* pTabView = GetViewData()->GetView();
276 0 : Window* pWin = pTabView->GetActiveWin();
277 0 : ScDrawView* pView = pTabView->GetScDrawView();
278 0 : ScDocShell* pDocSh = GetViewData()->GetDocShell();
279 0 : ScDocument* pDoc = pDocSh->GetDocument();
280 0 : SdrModel* pDrModel = pView->GetModel();
281 :
282 0 : switch ( nSlot )
283 : {
284 : case SID_INSERT_GRAPHIC:
285 0 : FuInsertGraphic(this, pWin, pView, pDrModel, rReq);
286 : // shell is set in MarkListHasChanged
287 0 : break;
288 :
289 : case SID_INSERT_AVMEDIA:
290 0 : FuInsertMedia(this, pWin, pView, pDrModel, rReq);
291 : // shell is set in MarkListHasChanged
292 0 : break;
293 :
294 : case SID_INSERT_DIAGRAM:
295 0 : FuInsertChart(this, pWin, pView, pDrModel, rReq);
296 0 : break;
297 :
298 : case SID_INSERT_OBJECT:
299 : case SID_INSERT_PLUGIN:
300 : case SID_INSERT_SOUND:
301 : case SID_INSERT_VIDEO:
302 : case SID_INSERT_SMATH:
303 : case SID_INSERT_FLOATINGFRAME:
304 0 : FuInsertOLE(this, pWin, pView, pDrModel, rReq);
305 0 : break;
306 :
307 : case SID_INSERT_DIAGRAM_FROM_FILE:
308 : {
309 : sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
310 0 : 0, OUString("com.sun.star.chart2.ChartDocument"));
311 0 : if(aDlg.Execute() == ERRCODE_NONE )
312 : {
313 0 : INetURLObject aURLObj( aDlg.GetPath() );
314 0 : OUString aURL = aURLObj.GetURLNoPass();
315 0 : FuInsertChartFromFile(this, pWin, pView, pDrModel, rReq, aURL);
316 0 : }
317 : }
318 0 : break;
319 :
320 : case SID_OBJECTRESIZE:
321 : {
322 : // Der Server moechte die Clientgrosse verandern
323 :
324 0 : SfxInPlaceClient* pClient = GetIPClient();
325 :
326 0 : if ( pClient && pClient->IsObjectInPlaceActive() )
327 : {
328 : const SfxRectangleItem& rRect =
329 0 : (SfxRectangleItem&)rReq.GetArgs()->Get(SID_OBJECTRESIZE);
330 0 : Rectangle aRect( pWin->PixelToLogic( rRect.GetValue() ) );
331 :
332 0 : if ( pView->AreObjectsMarked() )
333 : {
334 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
335 :
336 0 : if (rMarkList.GetMarkCount() == 1)
337 : {
338 0 : SdrMark* pMark = rMarkList.GetMark(0);
339 0 : SdrObject* pObj = pMark->GetMarkedSdrObj();
340 :
341 0 : sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
342 :
343 0 : if (nSdrObjKind == OBJ_OLE2)
344 : {
345 0 : if ( ( (SdrOle2Obj*) pObj)->GetObjRef().is() )
346 : {
347 0 : pObj->SetLogicRect(aRect);
348 : }
349 : }
350 : }
351 : }
352 : }
353 : }
354 0 : break;
355 :
356 : case SID_LINKS:
357 : {
358 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
359 0 : SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( pWin, pDoc->GetLinkManager() );
360 0 : if ( pDlg )
361 : {
362 0 : pDlg->Execute();
363 0 : rBindings.Invalidate( nSlot );
364 0 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator
365 0 : rReq.Done();
366 : }
367 : }
368 0 : break;
369 :
370 : // #98721#
371 : case SID_FM_CREATE_FIELDCONTROL:
372 : {
373 0 : SFX_REQUEST_ARG( rReq, pDescriptorItem, SfxUnoAnyItem, SID_FM_DATACCESS_DESCRIPTOR, false );
374 : OSL_ENSURE( pDescriptorItem, "SID_FM_CREATE_FIELDCONTROL: invalid request args!" );
375 :
376 0 : if(pDescriptorItem)
377 : {
378 : //! merge with ScViewFunc::PasteDataFormat (SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE)?
379 :
380 0 : ScDrawView* pDrView = GetScDrawView();
381 0 : SdrPageView* pPageView = pDrView ? pDrView->GetSdrPageView() : NULL;
382 0 : if(pPageView)
383 : {
384 0 : ::svx::ODataAccessDescriptor aDescriptor(pDescriptorItem->GetValue());
385 0 : SdrObject* pNewDBField = pDrView->CreateFieldControl(aDescriptor);
386 :
387 0 : if(pNewDBField)
388 : {
389 0 : Rectangle aVisArea = pWin->PixelToLogic(Rectangle(Point(0,0), pWin->GetOutputSizePixel()));
390 0 : Point aObjPos(aVisArea.Center());
391 0 : Size aObjSize(pNewDBField->GetLogicRect().GetSize());
392 0 : aObjPos.X() -= aObjSize.Width() / 2;
393 0 : aObjPos.Y() -= aObjSize.Height() / 2;
394 0 : Rectangle aNewObjectRectangle(aObjPos, aObjSize);
395 :
396 0 : pNewDBField->SetLogicRect(aNewObjectRectangle);
397 :
398 : // controls must be on control layer, groups on front layer
399 0 : if ( pNewDBField->ISA(SdrUnoObj) )
400 0 : pNewDBField->NbcSetLayer(SC_LAYER_CONTROLS);
401 : else
402 0 : pNewDBField->NbcSetLayer(SC_LAYER_FRONT);
403 0 : if (pNewDBField->ISA(SdrObjGroup))
404 : {
405 0 : SdrObjListIter aIter( *pNewDBField, IM_DEEPWITHGROUPS );
406 0 : SdrObject* pSubObj = aIter.Next();
407 0 : while (pSubObj)
408 : {
409 0 : if ( pSubObj->ISA(SdrUnoObj) )
410 0 : pSubObj->NbcSetLayer(SC_LAYER_CONTROLS);
411 : else
412 0 : pSubObj->NbcSetLayer(SC_LAYER_FRONT);
413 0 : pSubObj = aIter.Next();
414 0 : }
415 : }
416 :
417 0 : pView->InsertObjectAtView(pNewDBField, *pPageView);
418 0 : }
419 : }
420 : }
421 0 : rReq.Done();
422 : }
423 0 : break;
424 :
425 : case SID_FONTWORK_GALLERY_FLOATER:
426 0 : svx::FontworkBar::execute( pView, rReq, GetViewFrame()->GetBindings() );
427 0 : rReq.Ignore();
428 0 : break;
429 : }
430 0 : }
431 :
432 0 : void ScTabViewShell::GetDrawInsState(SfxItemSet &rSet)
433 : {
434 0 : bool bOle = GetViewFrame()->GetFrame().IsInPlace();
435 0 : bool bTabProt = GetViewData()->GetDocument()->IsTabProtected(GetViewData()->GetTabNo());
436 0 : ScDocShell* pDocShell = ( GetViewData() ? GetViewData()->GetDocShell() : NULL );
437 0 : bool bShared = ( pDocShell ? pDocShell->IsDocShared() : false );
438 :
439 0 : SfxWhichIter aIter(rSet);
440 0 : sal_uInt16 nWhich = aIter.FirstWhich();
441 0 : while ( nWhich )
442 : {
443 0 : switch ( nWhich )
444 : {
445 : case SID_INSERT_DIAGRAM:
446 0 : if ( bOle || bTabProt || !SvtModuleOptions().IsChart() || bShared )
447 0 : rSet.DisableItem( nWhich );
448 0 : break;
449 :
450 : case SID_INSERT_SMATH:
451 0 : if ( bOle || bTabProt || !SvtModuleOptions().IsMath() || bShared )
452 0 : rSet.DisableItem( nWhich );
453 0 : break;
454 :
455 : case SID_INSERT_OBJECT:
456 : case SID_INSERT_PLUGIN:
457 : case SID_INSERT_FLOATINGFRAME:
458 0 : if ( bOle || bTabProt || bShared )
459 0 : rSet.DisableItem( nWhich );
460 0 : break;
461 :
462 : case SID_INSERT_SOUND:
463 : case SID_INSERT_VIDEO:
464 : /* #i102735# discussed with NN: removed for performance reasons
465 : || !SvxPluginFileDlg::IsAvailable(nWhich)
466 : */
467 0 : if ( bOle || bTabProt || bShared )
468 0 : rSet.DisableItem( nWhich );
469 0 : break;
470 :
471 : case SID_INSERT_GRAPHIC:
472 : case SID_INSERT_AVMEDIA:
473 : case SID_FONTWORK_GALLERY_FLOATER:
474 0 : if ( bTabProt || bShared )
475 0 : rSet.DisableItem( nWhich );
476 0 : break;
477 :
478 : case SID_LINKS:
479 : {
480 0 : if (GetViewData()->GetDocument()->GetLinkManager()->GetLinks().empty())
481 0 : rSet.DisableItem( SID_LINKS );
482 : }
483 0 : break;
484 : }
485 0 : nWhich = aIter.NextWhich();
486 0 : }
487 0 : }
488 :
489 :
490 0 : void ScTabViewShell::ExecuteUndo(SfxRequest& rReq)
491 : {
492 0 : SfxShell* pSh = GetViewData()->GetDispatcher().GetShell(0);
493 0 : ::svl::IUndoManager* pUndoManager = pSh->GetUndoManager();
494 :
495 0 : const SfxItemSet* pReqArgs = rReq.GetArgs();
496 0 : ScDocShell* pDocSh = GetViewData()->GetDocShell();
497 :
498 0 : sal_uInt16 nSlot = rReq.GetSlot();
499 0 : switch ( nSlot )
500 : {
501 : case SID_UNDO:
502 : case SID_REDO:
503 0 : if ( pUndoManager )
504 : {
505 0 : bool bIsUndo = ( nSlot == SID_UNDO );
506 :
507 0 : sal_uInt16 nCount = 1;
508 : const SfxPoolItem* pItem;
509 0 : if ( pReqArgs && pReqArgs->GetItemState( nSlot, true, &pItem ) == SFX_ITEM_SET )
510 0 : nCount = ((const SfxUInt16Item*)pItem)->GetValue();
511 :
512 : // lock paint for more than one cell undo action (not for editing within a cell)
513 0 : bool bLockPaint = ( nCount > 1 && pUndoManager == GetUndoManager() );
514 0 : if ( bLockPaint )
515 0 : pDocSh->LockPaint();
516 :
517 : try
518 : {
519 0 : for (sal_uInt16 i=0; i<nCount; i++)
520 : {
521 0 : if ( bIsUndo )
522 0 : pUndoManager->Undo();
523 : else
524 0 : pUndoManager->Redo();
525 : }
526 : }
527 0 : catch ( const uno::Exception& )
528 : {
529 : // no need to handle. By definition, the UndoManager handled this by clearing the
530 : // Undo/Redo stacks
531 : }
532 :
533 0 : if ( bLockPaint )
534 0 : pDocSh->UnlockPaint();
535 :
536 0 : GetViewFrame()->GetBindings().InvalidateAll(false);
537 : }
538 0 : break;
539 : // default:
540 : // GetViewFrame()->ExecuteSlot( rReq );
541 : }
542 0 : }
543 :
544 0 : void ScTabViewShell::GetUndoState(SfxItemSet &rSet)
545 : {
546 0 : SfxShell* pSh = GetViewData()->GetDispatcher().GetShell(0);
547 0 : ::svl::IUndoManager* pUndoManager = pSh->GetUndoManager();
548 :
549 0 : SfxWhichIter aIter(rSet);
550 0 : sal_uInt16 nWhich = aIter.FirstWhich();
551 0 : while ( nWhich )
552 : {
553 0 : switch (nWhich)
554 : {
555 : case SID_GETUNDOSTRINGS:
556 : case SID_GETREDOSTRINGS:
557 : {
558 0 : SfxStringListItem aStrLst( nWhich );
559 0 : if ( pUndoManager )
560 : {
561 0 : std::vector<OUString> &aList = aStrLst.GetList();
562 0 : bool bIsUndo = ( nWhich == SID_GETUNDOSTRINGS );
563 0 : size_t nCount = bIsUndo ? pUndoManager->GetUndoActionCount() : pUndoManager->GetRedoActionCount();
564 0 : for (size_t i=0; i<nCount; ++i)
565 : {
566 0 : aList.push_back( bIsUndo ? pUndoManager->GetUndoActionComment(i) :
567 0 : pUndoManager->GetRedoActionComment(i) );
568 : }
569 : }
570 0 : rSet.Put( aStrLst );
571 : }
572 0 : break;
573 : default:
574 : // get state from sfx view frame
575 0 : GetViewFrame()->GetSlotState( nWhich, NULL, &rSet );
576 : }
577 :
578 0 : nWhich = aIter.NextWhich();
579 0 : }
580 0 : }
581 :
582 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|