1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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 <editeng/eeitem.hxx>
31 #include <editeng/flditem.hxx>
32 #include <editeng/editstat.hxx>
33 #include <unotools/useroptions.hxx>
35 #include <sfx2/viewfrm.hxx>
37 #include <fubullet.hxx>
38 #include <fuolbull.hxx>
39 #include <fuscale.hxx>
41 #include <fuinsfil.hxx>
42 #include <fuprobjs.hxx>
44 #include <futempl.hxx>
45 #include <fusldlg.hxx>
46 #include <zoomlist.hxx>
47 #include <fuexpand.hxx>
48 #include <fusumry.hxx>
49 #include <fucushow.hxx>
50 #include <sdabstdlg.hxx>
51 #include <DrawDocShell.hxx>
52 #include <DrawViewShell.hxx>
53 #include <OutlineView.hxx>
54 #include <slideshow.hxx>
57 using namespace ::com::sun::star::uno
;
58 using namespace ::com::sun::star::beans
;
62 /************************************************************************/
65 * SfxRequests for temporary functions
68 void OutlineViewShell::FuTemporary(SfxRequest
&rReq
)
70 DeactivateCurrentFunction();
72 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow( GetActiveWindow() );
73 sal_uInt16 nSId
= rReq
.GetSlot();
79 const SfxItemSet
* pArgs
= rReq
.GetArgs();
83 SvxZoomType eZT
= pArgs
->Get( SID_ATTR_ZOOM
).GetType();
86 case SvxZoomType::PERCENT
:
87 SetZoom( static_cast<::tools::Long
>( pArgs
->Get( SID_ATTR_ZOOM
).GetValue()) );
88 Invalidate( SID_ATTR_ZOOM
);
89 Invalidate( SID_ATTR_ZOOMSLIDER
);
98 // open the zoom dialog here
99 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
105 case SID_ATTR_ZOOMSLIDER
:
107 const SfxItemSet
* pArgs
= rReq
.GetArgs();
109 const SfxUInt16Item
* pScale
= (pArgs
&& pArgs
->Count () == 1) ?
110 rReq
.GetArg
<SfxUInt16Item
>(SID_ATTR_ZOOMSLIDER
) : nullptr;
111 if (pScale
&& CHECK_RANGE (5, pScale
->GetValue (), 3000))
113 SetZoom (pScale
->GetValue ());
115 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
116 rBindings
.Invalidate( SID_ATTR_ZOOM
);
117 rBindings
.Invalidate( SID_ZOOM_IN
);
118 rBindings
.Invalidate( SID_ZOOM_OUT
);
119 rBindings
.Invalidate( SID_ATTR_ZOOMSLIDER
);
130 SetZoom( std::min
<::tools::Long
>( GetActiveWindow()->GetZoom() * 2, GetActiveWindow()->GetMaxZoom() ) );
131 ::tools::Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
132 GetActiveWindow()->GetOutputSizePixel()) );
133 mpZoomList
->InsertZoomRect(aVisAreaWin
);
134 Invalidate( SID_ATTR_ZOOM
);
135 Invalidate( SID_ZOOM_IN
);
136 Invalidate(SID_ZOOM_OUT
);
137 Invalidate( SID_ATTR_ZOOMSLIDER
);
146 ::tools::Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
147 GetActiveWindow()->GetOutputSizePixel()) );
148 mpZoomList
->InsertZoomRect(aVisAreaWin
);
149 Invalidate( SID_ATTR_ZOOM
);
150 Invalidate( SID_ATTR_ZOOMSLIDER
);
158 SetZoom( std::max
<::tools::Long
>( GetActiveWindow()->GetZoom() / 2, GetActiveWindow()->GetMinZoom() ) );
159 ::tools::Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
160 GetActiveWindow()->GetOutputSizePixel()) );
161 mpZoomList
->InsertZoomRect(aVisAreaWin
);
162 Invalidate( SID_ATTR_ZOOM
);
163 Invalidate( SID_ZOOM_OUT
);
164 Invalidate( SID_ZOOM_IN
);
165 Invalidate( SID_ATTR_ZOOMSLIDER
);
171 case SID_OUTLINE_COLLAPSE_ALL
:
173 pOutlinerView
->CollapseAll();
179 case SID_OUTLINE_COLLAPSE
:
181 pOutlinerView
->Collapse();
187 case SID_OUTLINE_EXPAND_ALL
:
189 pOutlinerView
->ExpandAll();
195 case SID_OUTLINE_EXPAND
:
197 pOutlinerView
->Expand();
203 case SID_OUTLINE_FORMAT
:
205 ::Outliner
* pOutl
= pOutlinerView
->GetOutliner();
206 pOutl
->SetFlatMode( !pOutl
->IsFlatMode() );
207 Invalidate( SID_COLORVIEW
);
215 ::Outliner
& rOutl
= pOlView
->GetOutliner();
216 sal_Int32 nParaCount
= rOutl
.GetParagraphCount();
219 pOutlinerView
->SelectRange( 0, nParaCount
);
225 case SID_PRESENTATION
:
226 case SID_PRESENTATION_CURRENT_SLIDE
:
227 case SID_REHEARSE_TIMINGS
:
229 pOlView
->PrepareClose();
230 slideshowhelp::ShowSlideShow(rReq
, *GetDoc());
238 ::Outliner
* pOutl
= pOutlinerView
->GetOutliner();
239 EEControlBits nCntrl
= pOutl
->GetControlWord();
241 if ( !(nCntrl
& EEControlBits::NOCOLORS
) )
243 // color view is enabled: disable
244 pOutl
->SetControlWord(nCntrl
| EEControlBits::NOCOLORS
);
248 // color view is disabled: enable
249 pOutl
->SetControlWord(nCntrl
& ~EEControlBits::NOCOLORS
);
253 Invalidate( SID_COLORVIEW
);
260 case SID_STYLE_UPDATE_BY_EXAMPLE
:
264 SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
272 case SID_PRESENTATION_DLG
:
274 SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
281 #ifdef ENABLE_SDREMOTE
282 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
283 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateRemoteDialog(GetFrameWeld()));
289 case SID_CUSTOMSHOW_DLG
:
291 SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
298 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
299 vcl::Window
* pWin
= GetActiveWindow();
300 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateSdPhotoAlbumDialog(
301 pWin
? pWin
->GetFrameWeld() : nullptr,
312 if(HasCurrentFunction())
313 GetCurrentFunction()->Activate();
315 Invalidate( SID_OUTLINE_COLLAPSE_ALL
);
316 Invalidate( SID_OUTLINE_COLLAPSE
);
317 Invalidate( SID_OUTLINE_EXPAND_ALL
);
318 Invalidate( SID_OUTLINE_EXPAND
);
320 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
321 rBindings
.Invalidate( SID_OUTLINE_LEFT
);
322 rBindings
.Invalidate( SID_OUTLINE_RIGHT
);
323 rBindings
.Invalidate( SID_OUTLINE_UP
);
324 rBindings
.Invalidate( SID_OUTLINE_DOWN
);
326 Invalidate( SID_OUTLINE_FORMAT
);
327 Invalidate( SID_COLORVIEW
);
329 Invalidate(SID_COPY
);
330 Invalidate(SID_PASTE
);
331 Invalidate(SID_PASTE_UNFORMATTED
);
334 void OutlineViewShell::FuTemporaryModify(SfxRequest
&rReq
)
336 sal_uInt16 nSId
= rReq
.GetSlot();
337 std::unique_ptr
<OutlineViewModelChangeGuard
, o3tl::default_delete
<OutlineViewModelChangeGuard
>> aGuard
;
338 if (nSId
!= SID_OUTLINE_BULLET
&& nSId
!= FN_SVX_SET_BULLET
&& nSId
!= FN_SVX_SET_NUMBER
)
340 aGuard
.reset( new OutlineViewModelChangeGuard(*pOlView
) );
342 DeactivateCurrentFunction();
344 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow( GetActiveWindow() );
345 //sal_uInt16 nSId = rReq.GetSlot();
349 case SID_HYPERLINK_SETLINK
:
351 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
355 const SvxHyperlinkItem
* pHLItem
=
356 &pReqArgs
->Get(SID_HYPERLINK_SETLINK
);
358 SvxFieldItem
aURLItem(SvxURLField(pHLItem
->GetURL(),
360 SvxURLFormat::Repr
), EE_FEATURE_FIELD
);
361 ESelection
aSel( pOutlinerView
->GetSelection() );
362 pOutlinerView
->InsertField(aURLItem
);
363 if ( aSel
.nStartPos
<= aSel
.nEndPos
)
364 aSel
.nEndPos
= aSel
.nStartPos
+ 1;
366 aSel
.nStartPos
= aSel
.nEndPos
+ 1;
367 pOutlinerView
->SetSelection( aSel
);
375 case FN_INSERT_SOFT_HYPHEN
:
376 case FN_INSERT_HARDHYPHEN
:
377 case FN_INSERT_HARD_SPACE
:
378 case FN_INSERT_NNBSP
:
379 case SID_INSERT_RLM
:
380 case SID_INSERT_LRM
:
381 case SID_INSERT_ZWNBSP
:
382 case SID_INSERT_ZWSP
:
385 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
390 case SID_OUTLINE_BULLET
:
391 case FN_SVX_SET_BULLET
:
392 case FN_SVX_SET_NUMBER
:
394 SetCurrentFunction( FuBulletAndPosition::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
401 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
407 case SID_CHAR_DLG_EFFECT
:
410 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
417 SetCurrentFunction( FuInsertFile::Create(this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
422 case SID_PRESENTATIONOBJECT
:
424 SetCurrentFunction( FuPresentationObjects::Create(this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
429 case SID_SET_DEFAULT
:
431 pOutlinerView
->RemoveAttribs(true); // sal_True = also paragraph attributes
437 case SID_SUMMARY_PAGE
:
439 pOlView
->SetSelectedPages();
440 SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
441 pOlView
->GetOutliner().Clear();
442 pOlView
->FillOutliner();
443 pOlView
->GetActualPage();
448 case SID_EXPAND_PAGE
:
450 pOlView
->SetSelectedPages();
451 SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
452 pOlView
->GetOutliner().Clear();
453 pOlView
->FillOutliner();
454 pOlView
->GetActualPage();
459 case SID_INSERT_FLD_DATE_FIX
:
460 case SID_INSERT_FLD_DATE_VAR
:
461 case SID_INSERT_FLD_TIME_FIX
:
462 case SID_INSERT_FLD_TIME_VAR
:
463 case SID_INSERT_FLD_AUTHOR
:
464 case SID_INSERT_FLD_PAGE
:
465 case SID_INSERT_FLD_PAGE_TITLE
:
466 case SID_INSERT_FLD_PAGES
:
467 case SID_INSERT_FLD_FILE
:
469 std::unique_ptr
<SvxFieldItem
> pFieldItem
;
473 case SID_INSERT_FLD_DATE_FIX
:
474 pFieldItem
.reset(new SvxFieldItem(
475 SvxDateField( Date( Date::SYSTEM
), SvxDateType::Fix
), EE_FEATURE_FIELD
));
478 case SID_INSERT_FLD_DATE_VAR
:
479 pFieldItem
.reset(new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD
));
482 case SID_INSERT_FLD_TIME_FIX
:
483 pFieldItem
.reset(new SvxFieldItem(
484 SvxExtTimeField( ::tools::Time( ::tools::Time::SYSTEM
), SvxTimeType::Fix
), EE_FEATURE_FIELD
));
487 case SID_INSERT_FLD_TIME_VAR
:
488 pFieldItem
.reset(new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD
));
491 case SID_INSERT_FLD_AUTHOR
:
493 SvtUserOptions aUserOptions
;
494 pFieldItem
.reset(new SvxFieldItem(
496 aUserOptions
.GetFirstName(), aUserOptions
.GetLastName(), aUserOptions
.GetID() )
497 , EE_FEATURE_FIELD
));
501 case SID_INSERT_FLD_PAGE
:
502 pFieldItem
.reset(new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD
));
505 case SID_INSERT_FLD_PAGE_TITLE
:
506 pFieldItem
.reset(new SvxFieldItem( SvxPageTitleField(), EE_FEATURE_FIELD
));
509 case SID_INSERT_FLD_PAGES
:
510 pFieldItem
.reset(new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD
));
513 case SID_INSERT_FLD_FILE
:
516 if( GetDocSh()->HasName() )
517 aName
= GetDocSh()->GetMedium()->GetName();
519 // aName = GetDocSh()->GetName();
520 pFieldItem
.reset(new SvxFieldItem( SvxExtFileField( aName
), EE_FEATURE_FIELD
));
525 const SvxFieldItem
* pOldFldItem
= pOutlinerView
->GetFieldAtSelection();
527 if( pOldFldItem
&& ( nullptr != dynamic_cast< const SvxURLField
*>( pOldFldItem
->GetField() ) ||
528 nullptr != dynamic_cast< const SvxDateField
*>( pOldFldItem
->GetField() ) ||
529 nullptr != dynamic_cast< const SvxTimeField
*>( pOldFldItem
->GetField() ) ||
530 nullptr != dynamic_cast< const SvxExtTimeField
*>( pOldFldItem
->GetField() ) ||
531 nullptr != dynamic_cast< const SvxExtFileField
*>( pOldFldItem
->GetField() ) ||
532 nullptr != dynamic_cast< const SvxAuthorField
*>( pOldFldItem
->GetField() ) ||
533 nullptr != dynamic_cast< const SvxPageField
*>( pOldFldItem
->GetField() ) ||
534 nullptr != dynamic_cast< const SvxPagesField
*>( pOldFldItem
->GetField() )) )
536 // select field, so it gets deleted on Insert
537 ESelection aSel
= pOutlinerView
->GetSelection();
538 if( aSel
.nStartPos
== aSel
.nEndPos
)
540 pOutlinerView
->SetSelection( aSel
);
544 pOutlinerView
->InsertField( *pFieldItem
);
553 case SID_MODIFY_FIELD
:
555 const SvxFieldItem
* pFldItem
= pOutlinerView
->GetFieldAtSelection();
557 if( pFldItem
&& (nullptr != dynamic_cast< const SvxDateField
*>( pFldItem
->GetField() ) ||
558 nullptr != dynamic_cast< const SvxAuthorField
*>( pFldItem
->GetField() ) ||
559 nullptr != dynamic_cast< const SvxExtFileField
*>( pFldItem
->GetField() ) ||
560 nullptr != dynamic_cast< const SvxExtTimeField
*>( pFldItem
->GetField() ) ) )
563 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
564 vcl::Window
* pWin
= GetActiveWindow();
565 ScopedVclPtr
<AbstractSdModifyFieldDlg
> pDlg(pFact
->CreateSdModifyFieldDlg(pWin
? pWin
->GetFrameWeld() : nullptr, pFldItem
->GetField(), pOutlinerView
->GetAttribs() ));
566 if( pDlg
->Execute() == RET_OK
)
568 std::unique_ptr
<SvxFieldData
> pField(pDlg
->GetField());
571 SvxFieldItem
aFieldItem( *pField
, EE_FEATURE_FIELD
);
572 //pOLV->DeleteSelected(); <-- unfortunately missing!
573 // select field, so it gets deleted on Insert
574 ESelection aSel
= pOutlinerView
->GetSelection();
576 if( aSel
.nStartPos
== aSel
.nEndPos
)
581 pOutlinerView
->SetSelection( aSel
);
583 pOutlinerView
->InsertField( aFieldItem
);
585 // reset selection to original state
588 pOutlinerView
->SetSelection( aSel
);
593 SfxItemSet
aSet( pDlg
->GetItemSet() );
596 pOutlinerView
->SetAttribs( aSet
);
598 ::Outliner
* pOutliner
= pOutlinerView
->GetOutliner();
600 pOutliner
->UpdateFields();
611 if(HasCurrentFunction())
612 GetCurrentFunction()->Activate();
614 Invalidate( SID_OUTLINE_COLLAPSE_ALL
);
615 Invalidate( SID_OUTLINE_COLLAPSE
);
616 Invalidate( SID_OUTLINE_EXPAND_ALL
);
617 Invalidate( SID_OUTLINE_EXPAND
);
619 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
620 rBindings
.Invalidate( SID_OUTLINE_LEFT
);
621 rBindings
.Invalidate( SID_OUTLINE_RIGHT
);
622 rBindings
.Invalidate( SID_OUTLINE_UP
);
623 rBindings
.Invalidate( SID_OUTLINE_DOWN
);
625 Invalidate( SID_OUTLINE_FORMAT
);
626 Invalidate( SID_COLORVIEW
);
628 Invalidate(SID_COPY
);
629 Invalidate(SID_PASTE
);
630 Invalidate(SID_PASTE_UNFORMATTED
);
633 } // end of namespace sd
635 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */