android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / view / outlnvs2.cxx
blob2a890cec1b415fd487e962375792db82e3d8381b
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 <app.hrc>
23 #include <svx/hlnkitem.hxx>
24 #include <sfx2/bindings.hxx>
25 #include <sfx2/docfile.hxx>
26 #include <sfx2/request.hxx>
27 #include <sfx2/zoomitem.hxx>
28 #include <svx/svxids.hrc>
29 #include <svx/svdoutl.hxx>
30 #include <svx/zoomslideritem.hxx>
31 #include <editeng/eeitem.hxx>
32 #include <editeng/flditem.hxx>
33 #include <editeng/editstat.hxx>
34 #include <unotools/useroptions.hxx>
36 #include <sfx2/viewfrm.hxx>
37 #include <Window.hxx>
38 #include <fubullet.hxx>
39 #include <fuolbull.hxx>
40 #include <fuscale.hxx>
41 #include <fuchar.hxx>
42 #include <fuinsfil.hxx>
43 #include <fuprobjs.hxx>
44 #include <futhes.hxx>
45 #include <futempl.hxx>
46 #include <fusldlg.hxx>
47 #include <zoomlist.hxx>
48 #include <fuexpand.hxx>
49 #include <fusumry.hxx>
50 #include <fucushow.hxx>
51 #include <sdabstdlg.hxx>
52 #include <DrawDocShell.hxx>
53 #include <DrawViewShell.hxx>
54 #include <OutlineView.hxx>
55 #include <slideshow.hxx>
56 #include <memory>
58 using namespace ::com::sun::star::uno;
59 using namespace ::com::sun::star::beans;
61 namespace sd {
63 /************************************************************************/
65 /**
66 * SfxRequests for temporary functions
69 void OutlineViewShell::FuTemporary(SfxRequest &rReq)
71 DeactivateCurrentFunction();
73 OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() );
74 sal_uInt16 nSId = rReq.GetSlot();
76 switch( nSId )
78 case SID_ATTR_ZOOM:
80 const SfxItemSet* pArgs = rReq.GetArgs();
82 if ( pArgs )
84 SvxZoomType eZT = pArgs->Get( SID_ATTR_ZOOM ).GetType();
85 switch( eZT )
87 case SvxZoomType::PERCENT:
88 SetZoom( static_cast<::tools::Long>( pArgs->Get( SID_ATTR_ZOOM ).GetValue()) );
89 Invalidate( SID_ATTR_ZOOM );
90 Invalidate( SID_ATTR_ZOOMSLIDER );
91 break;
92 default:
93 break;
95 rReq.Done();
97 else
99 // open the zoom dialog here
100 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
102 Cancel();
104 break;
106 case SID_ATTR_ZOOMSLIDER:
108 const SfxItemSet* pArgs = rReq.GetArgs();
110 const SfxUInt16Item* pScale = (pArgs && pArgs->Count () == 1) ?
111 rReq.GetArg(SID_ATTR_ZOOMSLIDER) : nullptr;
112 if (pScale && CHECK_RANGE (5, pScale->GetValue (), 3000))
114 SetZoom (pScale->GetValue ());
116 SfxBindings& rBindings = GetViewFrame()->GetBindings();
117 rBindings.Invalidate( SID_ATTR_ZOOM );
118 rBindings.Invalidate( SID_ZOOM_IN );
119 rBindings.Invalidate( SID_ZOOM_OUT );
120 rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
124 Cancel();
125 rReq.Done ();
126 break;
129 case SID_ZOOM_IN:
131 SetZoom( std::min<::tools::Long>( GetActiveWindow()->GetZoom() * 2, GetActiveWindow()->GetMaxZoom() ) );
132 ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
133 GetActiveWindow()->GetOutputSizePixel()) );
134 mpZoomList->InsertZoomRect(aVisAreaWin);
135 Invalidate( SID_ATTR_ZOOM );
136 Invalidate( SID_ZOOM_IN );
137 Invalidate(SID_ZOOM_OUT);
138 Invalidate( SID_ATTR_ZOOMSLIDER );
139 Cancel();
140 rReq.Done();
142 break;
144 case SID_SIZE_REAL:
146 SetZoom( 100 );
147 ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
148 GetActiveWindow()->GetOutputSizePixel()) );
149 mpZoomList->InsertZoomRect(aVisAreaWin);
150 Invalidate( SID_ATTR_ZOOM );
151 Invalidate( SID_ATTR_ZOOMSLIDER );
152 Cancel();
153 rReq.Done();
155 break;
157 case SID_ZOOM_OUT:
159 SetZoom( std::max<::tools::Long>( GetActiveWindow()->GetZoom() / 2, GetActiveWindow()->GetMinZoom() ) );
160 ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
161 GetActiveWindow()->GetOutputSizePixel()) );
162 mpZoomList->InsertZoomRect(aVisAreaWin);
163 Invalidate( SID_ATTR_ZOOM );
164 Invalidate( SID_ZOOM_OUT);
165 Invalidate( SID_ZOOM_IN );
166 Invalidate( SID_ATTR_ZOOMSLIDER );
167 Cancel();
168 rReq.Done();
170 break;
172 case SID_OUTLINE_COLLAPSE_ALL:
174 pOutlinerView->CollapseAll();
175 Cancel();
176 rReq.Done();
178 break;
180 case SID_OUTLINE_COLLAPSE:
182 pOutlinerView->Collapse();
183 Cancel();
184 rReq.Done();
186 break;
188 case SID_OUTLINE_EXPAND_ALL:
190 pOutlinerView->ExpandAll();
191 Cancel();
192 rReq.Done();
194 break;
196 case SID_OUTLINE_EXPAND:
198 pOutlinerView->Expand();
199 Cancel();
200 rReq.Done();
202 break;
204 case SID_OUTLINE_FORMAT:
206 ::Outliner* pOutl = pOutlinerView->GetOutliner();
207 pOutl->SetFlatMode( !pOutl->IsFlatMode() );
208 Invalidate( SID_COLORVIEW );
209 Cancel();
210 rReq.Done();
212 break;
214 case SID_SELECTALL:
216 ::Outliner& rOutl = pOlView->GetOutliner();
217 sal_Int32 nParaCount = rOutl.GetParagraphCount();
218 if (nParaCount > 0)
220 pOutlinerView->SelectRange( 0, nParaCount );
222 Cancel();
224 break;
226 case SID_PRESENTATION:
227 case SID_PRESENTATION_CURRENT_SLIDE:
228 case SID_REHEARSE_TIMINGS:
230 pOlView->PrepareClose();
231 slideshowhelp::ShowSlideShow(rReq, *GetDoc());
232 Cancel();
233 rReq.Done();
235 break;
237 case SID_COLORVIEW:
239 ::Outliner* pOutl = pOutlinerView->GetOutliner();
240 EEControlBits nCntrl = pOutl->GetControlWord();
242 if ( !(nCntrl & EEControlBits::NOCOLORS) )
244 // color view is enabled: disable
245 pOutl->SetControlWord(nCntrl | EEControlBits::NOCOLORS);
247 else
249 // color view is disabled: enable
250 pOutl->SetControlWord(nCntrl & ~EEControlBits::NOCOLORS);
253 InvalidateWindows();
254 Invalidate( SID_COLORVIEW );
255 Cancel();
256 rReq.Done();
258 break;
260 case SID_STYLE_EDIT:
261 case SID_STYLE_UPDATE_BY_EXAMPLE:
263 if( rReq.GetArgs() )
265 SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
266 Cancel();
269 rReq.Ignore ();
271 break;
273 case SID_PRESENTATION_DLG:
275 SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
276 Cancel();
278 break;
280 case SID_REMOTE_DLG:
282 #ifdef ENABLE_SDREMOTE
283 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
284 ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateRemoteDialog(GetFrameWeld()));
285 pDlg->Execute();
286 #endif
288 break;
290 case SID_CUSTOMSHOW_DLG:
292 SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
293 Cancel();
295 break;
297 case SID_PHOTOALBUM:
299 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
300 vcl::Window* pWin = GetActiveWindow();
301 ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSdPhotoAlbumDialog(
302 pWin ? pWin->GetFrameWeld() : nullptr,
303 GetDoc()));
305 pDlg->Execute();
307 Cancel();
308 rReq.Ignore ();
310 break;
313 if(HasCurrentFunction())
314 GetCurrentFunction()->Activate();
316 Invalidate( SID_OUTLINE_COLLAPSE_ALL );
317 Invalidate( SID_OUTLINE_COLLAPSE );
318 Invalidate( SID_OUTLINE_EXPAND_ALL );
319 Invalidate( SID_OUTLINE_EXPAND );
321 SfxBindings& rBindings = GetViewFrame()->GetBindings();
322 rBindings.Invalidate( SID_OUTLINE_LEFT );
323 rBindings.Invalidate( SID_OUTLINE_RIGHT );
324 rBindings.Invalidate( SID_OUTLINE_UP );
325 rBindings.Invalidate( SID_OUTLINE_DOWN );
327 Invalidate( SID_OUTLINE_FORMAT );
328 Invalidate( SID_COLORVIEW );
329 Invalidate(SID_CUT);
330 Invalidate(SID_COPY);
331 Invalidate(SID_PASTE);
332 Invalidate(SID_PASTE_UNFORMATTED);
335 void OutlineViewShell::FuTemporaryModify(SfxRequest &rReq)
337 sal_uInt16 nSId = rReq.GetSlot();
338 std::unique_ptr<OutlineViewModelChangeGuard, o3tl::default_delete<OutlineViewModelChangeGuard>> aGuard;
339 if (nSId != SID_OUTLINE_BULLET && nSId != FN_SVX_SET_BULLET && nSId != FN_SVX_SET_NUMBER)
341 aGuard.reset( new OutlineViewModelChangeGuard(*pOlView) );
343 DeactivateCurrentFunction();
345 OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() );
346 //sal_uInt16 nSId = rReq.GetSlot();
348 switch( nSId )
350 case SID_HYPERLINK_SETLINK:
352 const SfxItemSet* pReqArgs = rReq.GetArgs();
354 if (pReqArgs)
356 const SvxHyperlinkItem* pHLItem =
357 &pReqArgs->Get(SID_HYPERLINK_SETLINK);
359 SvxFieldItem aURLItem(SvxURLField(pHLItem->GetURL(),
360 pHLItem->GetName(),
361 SvxURLFormat::Repr), EE_FEATURE_FIELD);
362 ESelection aSel( pOutlinerView->GetSelection() );
363 pOutlinerView->InsertField(aURLItem);
364 if ( aSel.nStartPos <= aSel.nEndPos )
365 aSel.nEndPos = aSel.nStartPos + 1;
366 else
367 aSel.nStartPos = aSel.nEndPos + 1;
368 pOutlinerView->SetSelection( aSel );
371 Cancel();
372 rReq.Ignore ();
374 break;
376 case FN_INSERT_SOFT_HYPHEN:
377 case FN_INSERT_HARDHYPHEN:
378 case FN_INSERT_HARD_SPACE:
379 case FN_INSERT_NNBSP:
380 case SID_INSERT_RLM :
381 case SID_INSERT_LRM :
382 case SID_INSERT_WJ :
383 case SID_INSERT_ZWSP:
384 case SID_CHARMAP:
386 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
387 Cancel();
389 break;
391 case SID_OUTLINE_BULLET:
392 case FN_SVX_SET_BULLET:
393 case FN_SVX_SET_NUMBER:
395 SetCurrentFunction( FuBulletAndPosition::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
396 Cancel();
398 break;
400 case SID_THESAURUS:
402 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
403 Cancel();
404 rReq.Ignore ();
406 break;
408 case SID_CHAR_DLG_EFFECT:
409 case SID_CHAR_DLG:
411 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
412 Cancel();
414 break;
416 case SID_INSERTFILE:
418 SetCurrentFunction( FuInsertFile::Create(this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq) );
419 Cancel();
421 break;
423 case SID_PRESENTATIONOBJECT:
425 SetCurrentFunction( FuPresentationObjects::Create(this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq) );
426 Cancel();
428 break;
430 case SID_SET_DEFAULT:
432 pOutlinerView->RemoveAttribs(true); // sal_True = also paragraph attributes
433 Cancel();
434 rReq.Done();
436 break;
438 case SID_SUMMARY_PAGE:
440 pOlView->SetSelectedPages();
441 SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
442 pOlView->GetOutliner().Clear();
443 pOlView->FillOutliner();
444 pOlView->GetActualPage();
445 Cancel();
447 break;
449 case SID_EXPAND_PAGE:
451 pOlView->SetSelectedPages();
452 SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), pOlView.get(), GetDoc(), rReq ) );
453 pOlView->GetOutliner().Clear();
454 pOlView->FillOutliner();
455 pOlView->GetActualPage();
456 Cancel();
458 break;
460 case SID_INSERT_FLD_DATE_FIX:
461 case SID_INSERT_FLD_DATE_VAR:
462 case SID_INSERT_FLD_TIME_FIX:
463 case SID_INSERT_FLD_TIME_VAR:
464 case SID_INSERT_FLD_AUTHOR:
465 case SID_INSERT_FLD_PAGE:
466 case SID_INSERT_FLD_PAGE_TITLE:
467 case SID_INSERT_FLD_PAGES:
468 case SID_INSERT_FLD_FILE:
470 std::unique_ptr<SvxFieldItem> pFieldItem;
472 switch( nSId )
474 case SID_INSERT_FLD_DATE_FIX:
475 pFieldItem.reset(new SvxFieldItem(
476 SvxDateField( Date( Date::SYSTEM ), SvxDateType::Fix ), EE_FEATURE_FIELD ));
477 break;
479 case SID_INSERT_FLD_DATE_VAR:
480 pFieldItem.reset(new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD ));
481 break;
483 case SID_INSERT_FLD_TIME_FIX:
484 pFieldItem.reset(new SvxFieldItem(
485 SvxExtTimeField( ::tools::Time( ::tools::Time::SYSTEM ), SvxTimeType::Fix ), EE_FEATURE_FIELD ));
486 break;
488 case SID_INSERT_FLD_TIME_VAR:
489 pFieldItem.reset(new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD ));
490 break;
492 case SID_INSERT_FLD_AUTHOR:
494 SvtUserOptions aUserOptions;
495 pFieldItem.reset(new SvxFieldItem(
496 SvxAuthorField(
497 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() )
498 , EE_FEATURE_FIELD ));
500 break;
502 case SID_INSERT_FLD_PAGE:
503 pFieldItem.reset(new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD ));
504 break;
506 case SID_INSERT_FLD_PAGE_TITLE:
507 pFieldItem.reset(new SvxFieldItem( SvxPageTitleField(), EE_FEATURE_FIELD));
508 break;
510 case SID_INSERT_FLD_PAGES:
511 pFieldItem.reset(new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD ));
512 break;
514 case SID_INSERT_FLD_FILE:
516 OUString aName;
517 if( GetDocSh()->HasName() )
518 aName = GetDocSh()->GetMedium()->GetName();
519 //else
520 // aName = GetDocSh()->GetName();
521 pFieldItem.reset(new SvxFieldItem( SvxExtFileField( aName ), EE_FEATURE_FIELD ));
523 break;
526 const SvxFieldItem* pOldFldItem = pOutlinerView->GetFieldAtSelection();
528 if( pOldFldItem && ( nullptr != dynamic_cast< const SvxURLField *>( pOldFldItem->GetField() ) ||
529 nullptr != dynamic_cast< const SvxDateField *>( pOldFldItem->GetField() ) ||
530 nullptr != dynamic_cast< const SvxTimeField *>( pOldFldItem->GetField() ) ||
531 nullptr != dynamic_cast< const SvxExtTimeField *>( pOldFldItem->GetField() ) ||
532 nullptr != dynamic_cast< const SvxExtFileField *>( pOldFldItem->GetField() ) ||
533 nullptr != dynamic_cast< const SvxAuthorField *>( pOldFldItem->GetField() ) ||
534 nullptr != dynamic_cast< const SvxPageField *>( pOldFldItem->GetField() ) ||
535 nullptr != dynamic_cast< const SvxPagesField *>( pOldFldItem->GetField() )) )
537 // select field, so it gets deleted on Insert
538 ESelection aSel = pOutlinerView->GetSelection();
539 if( aSel.nStartPos == aSel.nEndPos )
540 aSel.nEndPos++;
541 pOutlinerView->SetSelection( aSel );
544 if( pFieldItem )
545 pOutlinerView->InsertField( *pFieldItem );
547 pFieldItem.reset();
549 Cancel();
550 rReq.Ignore ();
552 break;
554 case SID_MODIFY_FIELD:
556 const SvxFieldItem* pFldItem = pOutlinerView->GetFieldAtSelection();
558 if( pFldItem && (nullptr != dynamic_cast< const SvxDateField *>( pFldItem->GetField() ) ||
559 nullptr != dynamic_cast< const SvxAuthorField *>( pFldItem->GetField() ) ||
560 nullptr != dynamic_cast< const SvxExtFileField *>( pFldItem->GetField() ) ||
561 nullptr != dynamic_cast< const SvxExtTimeField *>( pFldItem->GetField() ) ) )
563 // Dialog...
564 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
565 vcl::Window* pWin = GetActiveWindow();
566 ScopedVclPtr<AbstractSdModifyFieldDlg> pDlg(pFact->CreateSdModifyFieldDlg(pWin ? pWin->GetFrameWeld() : nullptr, pFldItem->GetField(), pOutlinerView->GetAttribs() ));
567 if( pDlg->Execute() == RET_OK )
569 std::unique_ptr<SvxFieldData> pField(pDlg->GetField());
570 if( pField )
572 SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
573 //pOLV->DeleteSelected(); <-- unfortunately missing!
574 // select field, so it gets deleted on Insert
575 ESelection aSel = pOutlinerView->GetSelection();
576 bool bSel = true;
577 if( aSel.nStartPos == aSel.nEndPos )
579 bSel = false;
580 aSel.nEndPos++;
582 pOutlinerView->SetSelection( aSel );
584 pOutlinerView->InsertField( aFieldItem );
586 // reset selection to original state
587 if( !bSel )
588 aSel.nEndPos--;
589 pOutlinerView->SetSelection( aSel );
591 pField.reset();
594 SfxItemSet aSet( pDlg->GetItemSet() );
595 if( aSet.Count() )
597 pOutlinerView->SetAttribs( aSet );
599 ::Outliner* pOutliner = pOutlinerView->GetOutliner();
600 if( pOutliner )
601 pOutliner->UpdateFields();
606 Cancel();
607 rReq.Ignore ();
609 break;
612 if(HasCurrentFunction())
613 GetCurrentFunction()->Activate();
615 Invalidate( SID_OUTLINE_COLLAPSE_ALL );
616 Invalidate( SID_OUTLINE_COLLAPSE );
617 Invalidate( SID_OUTLINE_EXPAND_ALL );
618 Invalidate( SID_OUTLINE_EXPAND );
620 SfxBindings& rBindings = GetViewFrame()->GetBindings();
621 rBindings.Invalidate( SID_OUTLINE_LEFT );
622 rBindings.Invalidate( SID_OUTLINE_RIGHT );
623 rBindings.Invalidate( SID_OUTLINE_UP );
624 rBindings.Invalidate( SID_OUTLINE_DOWN );
626 Invalidate( SID_OUTLINE_FORMAT );
627 Invalidate( SID_COLORVIEW );
628 Invalidate(SID_CUT);
629 Invalidate(SID_COPY);
630 Invalidate(SID_PASTE);
631 Invalidate(SID_PASTE_UNFORMATTED);
634 } // end of namespace sd
636 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */