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>
21 #include <Outliner.hxx>
24 #include <svx/hlnkitem.hxx>
25 #include <sfx2/bindings.hxx>
26 #include <sfx2/docfile.hxx>
27 #include <sfx2/request.hxx>
28 #include <sfx2/zoomitem.hxx>
29 #include <svx/svxids.hrc>
30 #include <svx/svdoutl.hxx>
31 #include <svx/zoomslideritem.hxx>
32 #include <editeng/eeitem.hxx>
33 #include <editeng/flditem.hxx>
34 #include <editeng/editstat.hxx>
35 #include <unotools/useroptions.hxx>
37 #include <sfx2/viewfrm.hxx>
39 #include <fubullet.hxx>
40 #include <fuolbull.hxx>
41 #include <fuscale.hxx>
43 #include <fuinsfil.hxx>
44 #include <fuprobjs.hxx>
46 #include <futempl.hxx>
47 #include <fusldlg.hxx>
48 #include <zoomlist.hxx>
49 #include <fuexpand.hxx>
50 #include <fusumry.hxx>
51 #include <fucushow.hxx>
52 #include <sdabstdlg.hxx>
53 #include <DrawDocShell.hxx>
54 #include <DrawViewShell.hxx>
55 #include <OutlineView.hxx>
56 #include <slideshow.hxx>
61 /************************************************************************/
64 * SfxRequests for temporary functions
67 void OutlineViewShell::FuTemporary(SfxRequest
&rReq
)
69 DeactivateCurrentFunction();
71 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow( GetActiveWindow() );
72 sal_uInt16 nSId
= rReq
.GetSlot();
78 const SfxItemSet
* pArgs
= rReq
.GetArgs();
82 SvxZoomType eZT
= pArgs
->Get( SID_ATTR_ZOOM
).GetType();
85 case SvxZoomType::PERCENT
:
86 SetZoom( static_cast<::tools::Long
>( pArgs
->Get( SID_ATTR_ZOOM
).GetValue()) );
87 Invalidate( SID_ATTR_ZOOM
);
88 Invalidate( SID_ATTR_ZOOMSLIDER
);
97 // open the zoom dialog here
98 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
104 case SID_ATTR_ZOOMSLIDER
:
106 const SfxItemSet
* pArgs
= rReq
.GetArgs();
108 const SfxUInt16Item
* pScale
= (pArgs
&& pArgs
->Count () == 1) ?
109 rReq
.GetArg(SID_ATTR_ZOOMSLIDER
) : nullptr;
110 if (pScale
&& CHECK_RANGE (5, pScale
->GetValue (), 3000))
112 SetZoom (pScale
->GetValue ());
114 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
115 rBindings
.Invalidate( SID_ATTR_ZOOM
);
116 rBindings
.Invalidate( SID_ZOOM_IN
);
117 rBindings
.Invalidate( SID_ZOOM_OUT
);
118 rBindings
.Invalidate( SID_ATTR_ZOOMSLIDER
);
129 SetZoom( std::min
<::tools::Long
>( GetActiveWindow()->GetZoom() * 2, GetActiveWindow()->GetMaxZoom() ) );
130 ::tools::Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
131 GetActiveWindow()->GetOutputSizePixel()) );
132 mpZoomList
->InsertZoomRect(aVisAreaWin
);
133 Invalidate( SID_ATTR_ZOOM
);
134 Invalidate( SID_ZOOM_IN
);
135 Invalidate(SID_ZOOM_OUT
);
136 Invalidate( SID_ATTR_ZOOMSLIDER
);
145 ::tools::Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
146 GetActiveWindow()->GetOutputSizePixel()) );
147 mpZoomList
->InsertZoomRect(aVisAreaWin
);
148 Invalidate( SID_ATTR_ZOOM
);
149 Invalidate( SID_ATTR_ZOOMSLIDER
);
157 SetZoom( std::max
<::tools::Long
>( GetActiveWindow()->GetZoom() / 2, GetActiveWindow()->GetMinZoom() ) );
158 ::tools::Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
159 GetActiveWindow()->GetOutputSizePixel()) );
160 mpZoomList
->InsertZoomRect(aVisAreaWin
);
161 Invalidate( SID_ATTR_ZOOM
);
162 Invalidate( SID_ZOOM_OUT
);
163 Invalidate( SID_ZOOM_IN
);
164 Invalidate( SID_ATTR_ZOOMSLIDER
);
170 case SID_OUTLINE_COLLAPSE_ALL
:
172 pOutlinerView
->CollapseAll();
178 case SID_OUTLINE_COLLAPSE
:
180 pOutlinerView
->Collapse();
186 case SID_OUTLINE_EXPAND_ALL
:
188 pOutlinerView
->ExpandAll();
194 case SID_OUTLINE_EXPAND
:
196 pOutlinerView
->Expand();
202 case SID_OUTLINE_FORMAT
:
204 ::Outliner
* pOutl
= pOutlinerView
->GetOutliner();
205 pOutl
->SetFlatMode( !pOutl
->IsFlatMode() );
206 Invalidate( SID_COLORVIEW
);
214 ::Outliner
& rOutl
= pOlView
->GetOutliner();
215 sal_Int32 nParaCount
= rOutl
.GetParagraphCount();
218 pOutlinerView
->SelectRange( 0, nParaCount
);
224 case SID_PRESENTATION
:
225 case SID_PRESENTATION_CURRENT_SLIDE
:
226 case SID_REHEARSE_TIMINGS
:
228 pOlView
->PrepareClose();
229 slideshowhelp::ShowSlideShow(rReq
, *GetDoc());
237 ::Outliner
* pOutl
= pOutlinerView
->GetOutliner();
238 EEControlBits nCntrl
= pOutl
->GetControlWord();
240 if ( !(nCntrl
& EEControlBits::NOCOLORS
) )
242 // color view is enabled: disable
243 pOutl
->SetControlWord(nCntrl
| EEControlBits::NOCOLORS
);
247 // color view is disabled: enable
248 pOutl
->SetControlWord(nCntrl
& ~EEControlBits::NOCOLORS
);
252 Invalidate( SID_COLORVIEW
);
259 case SID_STYLE_UPDATE_BY_EXAMPLE
:
263 SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
271 case SID_PRESENTATION_DLG
:
273 SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
280 #ifdef ENABLE_SDREMOTE
281 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
282 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateRemoteDialog(GetFrameWeld()));
288 case SID_CUSTOMSHOW_DLG
:
290 SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
297 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
298 vcl::Window
* pWin
= GetActiveWindow();
299 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateSdPhotoAlbumDialog(
300 pWin
? pWin
->GetFrameWeld() : nullptr,
311 if(HasCurrentFunction())
312 GetCurrentFunction()->Activate();
314 Invalidate( SID_OUTLINE_COLLAPSE_ALL
);
315 Invalidate( SID_OUTLINE_COLLAPSE
);
316 Invalidate( SID_OUTLINE_EXPAND_ALL
);
317 Invalidate( SID_OUTLINE_EXPAND
);
319 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
320 rBindings
.Invalidate( SID_OUTLINE_LEFT
);
321 rBindings
.Invalidate( SID_OUTLINE_RIGHT
);
322 rBindings
.Invalidate( SID_OUTLINE_UP
);
323 rBindings
.Invalidate( SID_OUTLINE_DOWN
);
325 Invalidate( SID_OUTLINE_FORMAT
);
326 Invalidate( SID_COLORVIEW
);
328 Invalidate(SID_COPY
);
329 Invalidate(SID_PASTE
);
330 Invalidate(SID_PASTE_UNFORMATTED
);
333 void OutlineViewShell::FuTemporaryModify(SfxRequest
&rReq
)
335 sal_uInt16 nSId
= rReq
.GetSlot();
336 std::unique_ptr
<OutlineViewModelChangeGuard
, o3tl::default_delete
<OutlineViewModelChangeGuard
>> aGuard
;
337 if (nSId
!= SID_OUTLINE_BULLET
&& nSId
!= FN_SVX_SET_BULLET
&& nSId
!= FN_SVX_SET_NUMBER
)
339 aGuard
.reset( new OutlineViewModelChangeGuard(*pOlView
) );
341 DeactivateCurrentFunction();
343 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow( GetActiveWindow() );
344 //sal_uInt16 nSId = rReq.GetSlot();
348 case SID_HYPERLINK_SETLINK
:
350 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
354 const SvxHyperlinkItem
* pHLItem
=
355 &pReqArgs
->Get(SID_HYPERLINK_SETLINK
);
357 SvxFieldItem
aURLItem(SvxURLField(pHLItem
->GetURL(),
359 SvxURLFormat::Repr
), EE_FEATURE_FIELD
);
360 ESelection
aSel( pOutlinerView
->GetSelection() );
361 pOutlinerView
->InsertField(aURLItem
);
362 if (aSel
.start
.nIndex
<= aSel
.end
.nIndex
)
363 aSel
.end
.nIndex
= aSel
.start
.nIndex
+ 1;
365 aSel
.start
.nIndex
= aSel
.end
.nIndex
+ 1;
366 pOutlinerView
->SetSelection( aSel
);
374 case FN_INSERT_SOFT_HYPHEN
:
375 case FN_INSERT_HARDHYPHEN
:
376 case FN_INSERT_HARD_SPACE
:
377 case FN_INSERT_NNBSP
:
378 case SID_INSERT_RLM
:
379 case SID_INSERT_LRM
:
381 case SID_INSERT_ZWSP
:
384 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
389 case SID_OUTLINE_BULLET
:
390 case FN_SVX_SET_BULLET
:
391 case FN_SVX_SET_NUMBER
:
393 SetCurrentFunction( FuBulletAndPosition::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
400 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
406 case SID_CHAR_DLG_EFFECT
:
409 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
416 SetCurrentFunction( FuInsertFile::Create(this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
421 case SID_PRESENTATIONOBJECT
:
423 SetCurrentFunction( FuPresentationObjects::Create(this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
428 case SID_SET_DEFAULT
:
430 pOutlinerView
->RemoveAttribs(true); // sal_True = also paragraph attributes
436 case SID_SUMMARY_PAGE
:
438 pOlView
->SetSelectedPages();
439 SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
440 pOlView
->GetOutliner().Clear();
441 pOlView
->FillOutliner();
442 pOlView
->GetActualPage();
447 case SID_EXPAND_PAGE
:
449 pOlView
->SetSelectedPages();
450 SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
451 pOlView
->GetOutliner().Clear();
452 pOlView
->FillOutliner();
453 pOlView
->GetActualPage();
458 case SID_INSERT_FLD_DATE_FIX
:
459 case SID_INSERT_FLD_DATE_VAR
:
460 case SID_INSERT_FLD_TIME_FIX
:
461 case SID_INSERT_FLD_TIME_VAR
:
462 case SID_INSERT_FLD_AUTHOR
:
463 case SID_INSERT_FLD_PAGE
:
464 case SID_INSERT_FLD_PAGE_TITLE
:
465 case SID_INSERT_FLD_PAGES
:
466 case SID_INSERT_FLD_FILE
:
468 std::unique_ptr
<SvxFieldItem
> pFieldItem
;
472 case SID_INSERT_FLD_DATE_FIX
:
473 pFieldItem
.reset(new SvxFieldItem(
474 SvxDateField( Date( Date::SYSTEM
), SvxDateType::Fix
), EE_FEATURE_FIELD
));
477 case SID_INSERT_FLD_DATE_VAR
:
478 pFieldItem
.reset(new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD
));
481 case SID_INSERT_FLD_TIME_FIX
:
482 pFieldItem
.reset(new SvxFieldItem(
483 SvxExtTimeField( ::tools::Time( ::tools::Time::SYSTEM
), SvxTimeType::Fix
), EE_FEATURE_FIELD
));
486 case SID_INSERT_FLD_TIME_VAR
:
487 pFieldItem
.reset(new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD
));
490 case SID_INSERT_FLD_AUTHOR
:
492 SvtUserOptions aUserOptions
;
493 pFieldItem
.reset(new SvxFieldItem(
495 aUserOptions
.GetFirstName(), aUserOptions
.GetLastName(), aUserOptions
.GetID() )
496 , EE_FEATURE_FIELD
));
500 case SID_INSERT_FLD_PAGE
:
501 pFieldItem
.reset(new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD
));
504 case SID_INSERT_FLD_PAGE_TITLE
:
505 pFieldItem
.reset(new SvxFieldItem( SvxPageTitleField(), EE_FEATURE_FIELD
));
508 case SID_INSERT_FLD_PAGES
:
509 pFieldItem
.reset(new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD
));
512 case SID_INSERT_FLD_FILE
:
515 if( GetDocSh()->HasName() )
516 aName
= GetDocSh()->GetMedium()->GetName();
518 // aName = GetDocSh()->GetName();
519 pFieldItem
.reset(new SvxFieldItem( SvxExtFileField( aName
), EE_FEATURE_FIELD
));
524 const SvxFieldItem
* pOldFldItem
= pOutlinerView
->GetFieldAtSelection();
526 if( pOldFldItem
&& ( nullptr != dynamic_cast< const SvxURLField
*>( pOldFldItem
->GetField() ) ||
527 nullptr != dynamic_cast< const SvxDateField
*>( pOldFldItem
->GetField() ) ||
528 nullptr != dynamic_cast< const SvxTimeField
*>( pOldFldItem
->GetField() ) ||
529 nullptr != dynamic_cast< const SvxExtTimeField
*>( pOldFldItem
->GetField() ) ||
530 nullptr != dynamic_cast< const SvxExtFileField
*>( pOldFldItem
->GetField() ) ||
531 nullptr != dynamic_cast< const SvxAuthorField
*>( pOldFldItem
->GetField() ) ||
532 nullptr != dynamic_cast< const SvxPageField
*>( pOldFldItem
->GetField() ) ||
533 nullptr != dynamic_cast< const SvxPagesField
*>( pOldFldItem
->GetField() )) )
535 // select field, so it gets deleted on Insert
536 ESelection aSel
= pOutlinerView
->GetSelection();
537 if (aSel
.start
.nIndex
== aSel
.end
.nIndex
)
539 pOutlinerView
->SetSelection( aSel
);
543 pOutlinerView
->InsertField( *pFieldItem
);
552 case SID_MODIFY_FIELD
:
554 const SvxFieldItem
* pFldItem
= pOutlinerView
->GetFieldAtSelection();
556 if( pFldItem
&& (nullptr != dynamic_cast< const SvxDateField
*>( pFldItem
->GetField() ) ||
557 nullptr != dynamic_cast< const SvxAuthorField
*>( pFldItem
->GetField() ) ||
558 nullptr != dynamic_cast< const SvxExtFileField
*>( pFldItem
->GetField() ) ||
559 nullptr != dynamic_cast< const SvxExtTimeField
*>( pFldItem
->GetField() ) ) )
562 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
563 vcl::Window
* pWin
= GetActiveWindow();
564 ScopedVclPtr
<AbstractSdModifyFieldDlg
> pDlg(pFact
->CreateSdModifyFieldDlg(pWin
? pWin
->GetFrameWeld() : nullptr, pFldItem
->GetField(), pOutlinerView
->GetAttribs() ));
565 if( pDlg
->Execute() == RET_OK
)
567 std::unique_ptr
<SvxFieldData
> pField(pDlg
->GetField());
570 SvxFieldItem
aFieldItem( *pField
, EE_FEATURE_FIELD
);
571 //pOLV->DeleteSelected(); <-- unfortunately missing!
572 // select field, so it gets deleted on Insert
573 ESelection aSel
= pOutlinerView
->GetSelection();
575 if (aSel
.start
.nIndex
== aSel
.end
.nIndex
)
580 pOutlinerView
->SetSelection( aSel
);
582 pOutlinerView
->InsertField( aFieldItem
);
584 // reset selection to original state
587 pOutlinerView
->SetSelection( aSel
);
592 SfxItemSet
aSet( pDlg
->GetItemSet() );
595 pOutlinerView
->SetAttribs( aSet
);
597 ::Outliner
* pOutliner
= pOutlinerView
->GetOutliner();
599 pOutliner
->UpdateFields();
610 if(HasCurrentFunction())
611 GetCurrentFunction()->Activate();
613 Invalidate( SID_OUTLINE_COLLAPSE_ALL
);
614 Invalidate( SID_OUTLINE_COLLAPSE
);
615 Invalidate( SID_OUTLINE_EXPAND_ALL
);
616 Invalidate( SID_OUTLINE_EXPAND
);
618 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
619 rBindings
.Invalidate( SID_OUTLINE_LEFT
);
620 rBindings
.Invalidate( SID_OUTLINE_RIGHT
);
621 rBindings
.Invalidate( SID_OUTLINE_UP
);
622 rBindings
.Invalidate( SID_OUTLINE_DOWN
);
624 Invalidate( SID_OUTLINE_FORMAT
);
625 Invalidate( SID_COLORVIEW
);
627 Invalidate(SID_COPY
);
628 Invalidate(SID_PASTE
);
629 Invalidate(SID_PASTE_UNFORMATTED
);
632 } // end of namespace sd
634 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */