tdf#120905 Remove old FuOutlineBullet dialog code.
[LibreOffice.git] / sd / source / ui / view / outlnvs2.cxx
blob9935e2eecd5d6ce8836c34924adef49b168ada6f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <OutlineViewShell.hxx>
22 #include <com/sun/star/beans/PropertyValue.hpp>
24 #include <app.hrc>
25 #include <svx/hlnkitem.hxx>
26 #include <sfx2/docfile.hxx>
27 #include <sfx2/dispatch.hxx>
28 #include <sfx2/request.hxx>
29 #include <svl/eitem.hxx>
30 #include <sfx2/zoomitem.hxx>
31 #include <svx/svxids.hrc>
32 #include <editeng/eeitem.hxx>
33 #include <editeng/flditem.hxx>
34 #include <editeng/editstat.hxx>
35 #include <optsitem.hxx>
36 #include <unotools/useroptions.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include <Outliner.hxx>
40 #include <Window.hxx>
41 #include <fubullet.hxx>
42 #include <fuolbull.hxx>
43 #include <FrameView.hxx>
44 #include <fuzoom.hxx>
45 #include <fuscale.hxx>
46 #include <fuchar.hxx>
47 #include <fuinsfil.hxx>
48 #include <fuprobjs.hxx>
49 #include <futhes.hxx>
50 #include <futempl.hxx>
51 #include <fusldlg.hxx>
52 #include <zoomlist.hxx>
53 #include <fuexpand.hxx>
54 #include <fusumry.hxx>
55 #include <fucushow.hxx>
56 #include <drawdoc.hxx>
57 #include <sdattr.hxx>
58 #include <ViewShellBase.hxx>
59 #include <sdabstdlg.hxx>
60 #include <framework/FrameworkHelper.hxx>
61 #include <DrawDocShell.hxx>
62 #include <DrawViewShell.hxx>
63 #include <OutlineView.hxx>
64 #include <slideshow.hxx>
65 #include <memory>
67 using namespace ::com::sun::star::uno;
68 using namespace ::com::sun::star::beans;
70 namespace sd {
72 /************************************************************************/
74 /**
75 * SfxRequests for temporary functions
78 void OutlineViewShell::FuTemporary(SfxRequest &rReq)
80 DeactivateCurrentFunction();
82 OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() );
83 sal_uInt16 nSId = rReq.GetSlot();
85 switch( nSId )
87 case SID_ATTR_ZOOM:
89 const SfxItemSet* pArgs = rReq.GetArgs();
91 if ( pArgs )
93 SvxZoomType eZT = pArgs->Get( SID_ATTR_ZOOM ).GetType();
94 switch( eZT )
96 case SvxZoomType::PERCENT:
97 SetZoom( static_cast<long>( pArgs->Get( SID_ATTR_ZOOM ).GetValue()) );
98 Invalidate( SID_ATTR_ZOOM );
99 Invalidate( SID_ATTR_ZOOMSLIDER );
100 break;
101 default:
102 break;
104 rReq.Done();
106 else
108 // open the zoom dialog here
109 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
111 Cancel();
113 break;
115 case SID_ATTR_ZOOMSLIDER:
117 const SfxItemSet* pArgs = rReq.GetArgs();
119 const SfxUInt16Item* pScale = (pArgs && pArgs->Count () == 1) ?
120 rReq.GetArg<SfxUInt16Item>(SID_ATTR_ZOOMSLIDER) : nullptr;
121 if (pScale && CHECK_RANGE (5, pScale->GetValue (), 3000))
123 SetZoom (pScale->GetValue ());
125 SfxBindings& rBindings = GetViewFrame()->GetBindings();
126 rBindings.Invalidate( SID_ATTR_ZOOM );
127 rBindings.Invalidate( SID_ZOOM_IN );
128 rBindings.Invalidate( SID_ZOOM_OUT );
129 rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
133 Cancel();
134 rReq.Done ();
135 break;
138 case SID_ZOOM_OUT:
140 SetZoom( std::min<long>( GetActiveWindow()->GetZoom() * 2, GetActiveWindow()->GetMaxZoom() ) );
141 ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
142 GetActiveWindow()->GetOutputSizePixel()) );
143 mpZoomList->InsertZoomRect(aVisAreaWin);
144 Invalidate( SID_ATTR_ZOOM );
145 Invalidate( SID_ZOOM_IN );
146 Invalidate( SID_ATTR_ZOOMSLIDER );
147 Cancel();
148 rReq.Done();
150 break;
152 case SID_SIZE_REAL:
154 SetZoom( 100 );
155 ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
156 GetActiveWindow()->GetOutputSizePixel()) );
157 mpZoomList->InsertZoomRect(aVisAreaWin);
158 Invalidate( SID_ATTR_ZOOM );
159 Invalidate( SID_ATTR_ZOOMSLIDER );
160 Cancel();
161 rReq.Done();
163 break;
165 case SID_ZOOM_IN:
167 SetZoom( std::max<long>( GetActiveWindow()->GetZoom() / 2, GetActiveWindow()->GetMinZoom() ) );
168 ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
169 GetActiveWindow()->GetOutputSizePixel()) );
170 mpZoomList->InsertZoomRect(aVisAreaWin);
171 Invalidate( SID_ATTR_ZOOM );
172 Invalidate( SID_ZOOM_OUT);
173 Invalidate( SID_ZOOM_IN );
174 Invalidate( SID_ATTR_ZOOMSLIDER );
175 Cancel();
176 rReq.Done();
178 break;
180 case SID_OUTLINE_COLLAPSE_ALL:
182 pOutlinerView->CollapseAll();
183 Cancel();
184 rReq.Done();
186 break;
188 case SID_OUTLINE_COLLAPSE:
190 pOutlinerView->Collapse();
191 Cancel();
192 rReq.Done();
194 break;
196 case SID_OUTLINE_EXPAND_ALL:
198 pOutlinerView->ExpandAll();
199 Cancel();
200 rReq.Done();
202 break;
204 case SID_OUTLINE_EXPAND:
206 pOutlinerView->Expand();
207 Cancel();
208 rReq.Done();
210 break;
212 case SID_OUTLINE_FORMAT:
214 ::Outliner* pOutl = pOutlinerView->GetOutliner();
215 pOutl->SetFlatMode( !pOutl->IsFlatMode() );
216 Invalidate( SID_COLORVIEW );
217 Cancel();
218 rReq.Done();
220 break;
222 case SID_SELECTALL:
224 ::Outliner& rOutl = pOlView->GetOutliner();
225 sal_Int32 nParaCount = rOutl.GetParagraphCount();
226 if (nParaCount > 0)
228 pOutlinerView->SelectRange( 0, nParaCount );
230 Cancel();
232 break;
234 case SID_PRESENTATION:
235 case SID_PRESENTATION_CURRENT_SLIDE:
236 case SID_REHEARSE_TIMINGS:
238 pOlView->PrepareClose();
239 slideshowhelp::ShowSlideShow(rReq, *GetDoc());
240 Cancel();
241 rReq.Done();
243 break;
245 case SID_COLORVIEW:
247 ::Outliner* pOutl = pOutlinerView->GetOutliner();
248 EEControlBits nCntrl = pOutl->GetControlWord();
250 if ( !(nCntrl & EEControlBits::NOCOLORS) )
252 // color view is enabled: disable
253 pOutl->SetControlWord(nCntrl | EEControlBits::NOCOLORS);
255 else
257 // color view is disabled: enable
258 pOutl->SetControlWord(nCntrl & ~EEControlBits::NOCOLORS);
261 InvalidateWindows();
262 Invalidate( SID_COLORVIEW );
263 Cancel();
264 rReq.Done();
266 break;
268 case SID_STYLE_EDIT:
269 case SID_STYLE_UPDATE_BY_EXAMPLE:
271 if( rReq.GetArgs() )
273 SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
274 Cancel();
277 rReq.Ignore ();
279 break;
281 case SID_PRESENTATION_DLG:
283 SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
284 Cancel();
286 break;
288 case SID_REMOTE_DLG:
290 #ifdef ENABLE_SDREMOTE
291 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
292 ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateRemoteDialog(GetActiveWindow()));
293 pDlg->Execute();
294 #endif
296 break;
298 case SID_CUSTOMSHOW_DLG:
300 SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
301 Cancel();
303 break;
305 case SID_PHOTOALBUM:
307 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
308 vcl::Window* pWin = GetActiveWindow();
309 ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSdPhotoAlbumDialog(
310 pWin ? pWin->GetFrameWeld() : nullptr,
311 GetDoc()));
313 pDlg->Execute();
315 Cancel();
316 rReq.Ignore ();
318 break;
321 if(HasCurrentFunction())
322 GetCurrentFunction()->Activate();
324 Invalidate( SID_OUTLINE_COLLAPSE_ALL );
325 Invalidate( SID_OUTLINE_COLLAPSE );
326 Invalidate( SID_OUTLINE_EXPAND_ALL );
327 Invalidate( SID_OUTLINE_EXPAND );
329 SfxBindings& rBindings = GetViewFrame()->GetBindings();
330 rBindings.Invalidate( SID_OUTLINE_LEFT );
331 rBindings.Invalidate( SID_OUTLINE_RIGHT );
332 rBindings.Invalidate( SID_OUTLINE_UP );
333 rBindings.Invalidate( SID_OUTLINE_DOWN );
335 Invalidate( SID_OUTLINE_FORMAT );
336 Invalidate( SID_COLORVIEW );
337 Invalidate(SID_CUT);
338 Invalidate(SID_COPY);
339 Invalidate(SID_PASTE);
340 Invalidate(SID_PASTE_UNFORMATTED);
343 void OutlineViewShell::FuTemporaryModify(SfxRequest &rReq)
345 sal_uInt16 nSId = rReq.GetSlot();
346 std::unique_ptr<OutlineViewModelChangeGuard, o3tl::default_delete<OutlineViewModelChangeGuard>> aGuard;
347 if (nSId != SID_OUTLINE_BULLET && nSId != FN_SVX_SET_BULLET && nSId != FN_SVX_SET_NUMBER)
349 aGuard.reset( new OutlineViewModelChangeGuard(*pOlView) );
351 DeactivateCurrentFunction();
353 OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() );
354 //sal_uInt16 nSId = rReq.GetSlot();
356 switch( nSId )
358 case SID_HYPERLINK_SETLINK:
360 const SfxItemSet* pReqArgs = rReq.GetArgs();
362 if (pReqArgs)
364 const SvxHyperlinkItem* pHLItem =
365 &pReqArgs->Get(SID_HYPERLINK_SETLINK);
367 SvxFieldItem aURLItem(SvxURLField(pHLItem->GetURL(),
368 pHLItem->GetName(),
369 SvxURLFormat::Repr), EE_FEATURE_FIELD);
370 ESelection aSel( pOutlinerView->GetSelection() );
371 pOutlinerView->InsertField(aURLItem);
372 if ( aSel.nStartPos <= aSel.nEndPos )
373 aSel.nEndPos = aSel.nStartPos + 1;
374 else
375 aSel.nStartPos = aSel.nEndPos + 1;
376 pOutlinerView->SetSelection( aSel );
379 Cancel();
380 rReq.Ignore ();
382 break;
384 case FN_INSERT_SOFT_HYPHEN:
385 case FN_INSERT_HARDHYPHEN:
386 case FN_INSERT_HARD_SPACE:
387 case FN_INSERT_NNBSP:
388 case SID_INSERT_RLM :
389 case SID_INSERT_LRM :
390 case SID_INSERT_ZWNBSP :
391 case SID_INSERT_ZWSP:
392 case SID_CHARMAP:
394 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
395 Cancel();
397 break;
399 case SID_OUTLINE_BULLET:
400 case FN_SVX_SET_BULLET:
401 case FN_SVX_SET_NUMBER:
403 SetCurrentFunction( FuBulletAndPosition::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
404 Cancel();
406 break;
408 case SID_THESAURUS:
410 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
411 Cancel();
412 rReq.Ignore ();
414 break;
416 case SID_CHAR_DLG_EFFECT:
417 case SID_CHAR_DLG:
419 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
420 Cancel();
422 break;
424 case SID_INSERTFILE:
426 SetCurrentFunction( FuInsertFile::Create(this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq) );
427 Cancel();
429 break;
431 case SID_PRESENTATIONOBJECT:
433 SetCurrentFunction( FuPresentationObjects::Create(this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq) );
434 Cancel();
436 break;
438 case SID_SET_DEFAULT:
440 pOutlinerView->RemoveAttribs(true); // sal_True = also paragraph attributes
441 Cancel();
442 rReq.Done();
444 break;
446 case SID_SUMMARY_PAGE:
448 pOlView->SetSelectedPages();
449 SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
450 pOlView->GetOutliner().Clear();
451 pOlView->FillOutliner();
452 pOlView->GetActualPage();
453 Cancel();
455 break;
457 case SID_EXPAND_PAGE:
459 pOlView->SetSelectedPages();
460 SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
461 pOlView->GetOutliner().Clear();
462 pOlView->FillOutliner();
463 pOlView->GetActualPage();
464 Cancel();
466 break;
468 case SID_INSERT_FLD_DATE_FIX:
469 case SID_INSERT_FLD_DATE_VAR:
470 case SID_INSERT_FLD_TIME_FIX:
471 case SID_INSERT_FLD_TIME_VAR:
472 case SID_INSERT_FLD_AUTHOR:
473 case SID_INSERT_FLD_PAGE:
474 case SID_INSERT_FLD_PAGE_TITLE:
475 case SID_INSERT_FLD_PAGES:
476 case SID_INSERT_FLD_FILE:
478 std::unique_ptr<SvxFieldItem> pFieldItem;
480 switch( nSId )
482 case SID_INSERT_FLD_DATE_FIX:
483 pFieldItem.reset(new SvxFieldItem(
484 SvxDateField( Date( Date::SYSTEM ), SvxDateType::Fix ), EE_FEATURE_FIELD ));
485 break;
487 case SID_INSERT_FLD_DATE_VAR:
488 pFieldItem.reset(new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD ));
489 break;
491 case SID_INSERT_FLD_TIME_FIX:
492 pFieldItem.reset(new SvxFieldItem(
493 SvxExtTimeField( ::tools::Time( ::tools::Time::SYSTEM ), SvxTimeType::Fix ), EE_FEATURE_FIELD ));
494 break;
496 case SID_INSERT_FLD_TIME_VAR:
497 pFieldItem.reset(new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD ));
498 break;
500 case SID_INSERT_FLD_AUTHOR:
502 SvtUserOptions aUserOptions;
503 pFieldItem.reset(new SvxFieldItem(
504 SvxAuthorField(
505 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() )
506 , EE_FEATURE_FIELD ));
508 break;
510 case SID_INSERT_FLD_PAGE:
511 pFieldItem.reset(new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD ));
512 break;
514 case SID_INSERT_FLD_PAGE_TITLE:
515 pFieldItem.reset(new SvxFieldItem( SvxPageTitleField(), EE_FEATURE_FIELD));
516 break;
518 case SID_INSERT_FLD_PAGES:
519 pFieldItem.reset(new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD ));
520 break;
522 case SID_INSERT_FLD_FILE:
524 OUString aName;
525 if( GetDocSh()->HasName() )
526 aName = GetDocSh()->GetMedium()->GetName();
527 //else
528 // aName = GetDocSh()->GetName();
529 pFieldItem.reset(new SvxFieldItem( SvxExtFileField( aName ), EE_FEATURE_FIELD ));
531 break;
534 const SvxFieldItem* pOldFldItem = pOutlinerView->GetFieldAtSelection();
536 if( pOldFldItem && ( nullptr != dynamic_cast< const SvxURLField *>( pOldFldItem->GetField() ) ||
537 nullptr != dynamic_cast< const SvxDateField *>( pOldFldItem->GetField() ) ||
538 nullptr != dynamic_cast< const SvxTimeField *>( pOldFldItem->GetField() ) ||
539 nullptr != dynamic_cast< const SvxExtTimeField *>( pOldFldItem->GetField() ) ||
540 nullptr != dynamic_cast< const SvxExtFileField *>( pOldFldItem->GetField() ) ||
541 nullptr != dynamic_cast< const SvxAuthorField *>( pOldFldItem->GetField() ) ||
542 nullptr != dynamic_cast< const SvxPageField *>( pOldFldItem->GetField() ) ||
543 nullptr != dynamic_cast< const SvxPagesField *>( pOldFldItem->GetField() )) )
545 // select field, so it gets deleted on Insert
546 ESelection aSel = pOutlinerView->GetSelection();
547 if( aSel.nStartPos == aSel.nEndPos )
548 aSel.nEndPos++;
549 pOutlinerView->SetSelection( aSel );
552 if( pFieldItem )
553 pOutlinerView->InsertField( *pFieldItem );
555 pFieldItem.reset();
557 Cancel();
558 rReq.Ignore ();
560 break;
562 case SID_MODIFY_FIELD:
564 const SvxFieldItem* pFldItem = pOutlinerView->GetFieldAtSelection();
566 if( pFldItem && (nullptr != dynamic_cast< const SvxDateField *>( pFldItem->GetField() ) ||
567 nullptr != dynamic_cast< const SvxAuthorField *>( pFldItem->GetField() ) ||
568 nullptr != dynamic_cast< const SvxExtFileField *>( pFldItem->GetField() ) ||
569 nullptr != dynamic_cast< const SvxExtTimeField *>( pFldItem->GetField() ) ) )
571 // Dialog...
572 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
573 vcl::Window* pWin = GetActiveWindow();
574 ScopedVclPtr<AbstractSdModifyFieldDlg> pDlg(pFact->CreateSdModifyFieldDlg(pWin ? pWin->GetFrameWeld() : nullptr, pFldItem->GetField(), pOutlinerView->GetAttribs() ));
575 if( pDlg->Execute() == RET_OK )
577 std::unique_ptr<SvxFieldData> pField(pDlg->GetField());
578 if( pField )
580 SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
581 //pOLV->DeleteSelected(); <-- unfortunately missing!
582 // select field, so it gets deleted on Insert
583 ESelection aSel = pOutlinerView->GetSelection();
584 bool bSel = true;
585 if( aSel.nStartPos == aSel.nEndPos )
587 bSel = false;
588 aSel.nEndPos++;
590 pOutlinerView->SetSelection( aSel );
592 pOutlinerView->InsertField( aFieldItem );
594 // reset selection to original state
595 if( !bSel )
596 aSel.nEndPos--;
597 pOutlinerView->SetSelection( aSel );
599 pField.reset();
602 SfxItemSet aSet( pDlg->GetItemSet() );
603 if( aSet.Count() )
605 pOutlinerView->SetAttribs( aSet );
607 ::Outliner* pOutliner = pOutlinerView->GetOutliner();
608 if( pOutliner )
609 pOutliner->UpdateFields();
614 Cancel();
615 rReq.Ignore ();
617 break;
620 if(HasCurrentFunction())
621 GetCurrentFunction()->Activate();
623 Invalidate( SID_OUTLINE_COLLAPSE_ALL );
624 Invalidate( SID_OUTLINE_COLLAPSE );
625 Invalidate( SID_OUTLINE_EXPAND_ALL );
626 Invalidate( SID_OUTLINE_EXPAND );
628 SfxBindings& rBindings = GetViewFrame()->GetBindings();
629 rBindings.Invalidate( SID_OUTLINE_LEFT );
630 rBindings.Invalidate( SID_OUTLINE_RIGHT );
631 rBindings.Invalidate( SID_OUTLINE_UP );
632 rBindings.Invalidate( SID_OUTLINE_DOWN );
634 Invalidate( SID_OUTLINE_FORMAT );
635 Invalidate( SID_COLORVIEW );
636 Invalidate(SID_CUT);
637 Invalidate(SID_COPY);
638 Invalidate(SID_PASTE);
639 Invalidate(SID_PASTE_UNFORMATTED);
642 } // end of namespace sd
644 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */