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 <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>
38 #include <fubullet.hxx>
39 #include <fuolbull.hxx>
40 #include <fuscale.hxx>
42 #include <fuinsfil.hxx>
43 #include <fuprobjs.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>
58 using namespace ::com::sun::star::uno
;
59 using namespace ::com::sun::star::beans
;
63 /************************************************************************/
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();
80 const SfxItemSet
* pArgs
= rReq
.GetArgs();
84 SvxZoomType eZT
= pArgs
->Get( SID_ATTR_ZOOM
).GetType();
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
);
99 // open the zoom dialog here
100 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
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
);
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
);
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
);
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
);
172 case SID_OUTLINE_COLLAPSE_ALL
:
174 pOutlinerView
->CollapseAll();
180 case SID_OUTLINE_COLLAPSE
:
182 pOutlinerView
->Collapse();
188 case SID_OUTLINE_EXPAND_ALL
:
190 pOutlinerView
->ExpandAll();
196 case SID_OUTLINE_EXPAND
:
198 pOutlinerView
->Expand();
204 case SID_OUTLINE_FORMAT
:
206 ::Outliner
* pOutl
= pOutlinerView
->GetOutliner();
207 pOutl
->SetFlatMode( !pOutl
->IsFlatMode() );
208 Invalidate( SID_COLORVIEW
);
216 ::Outliner
& rOutl
= pOlView
->GetOutliner();
217 sal_Int32 nParaCount
= rOutl
.GetParagraphCount();
220 pOutlinerView
->SelectRange( 0, nParaCount
);
226 case SID_PRESENTATION
:
227 case SID_PRESENTATION_CURRENT_SLIDE
:
228 case SID_REHEARSE_TIMINGS
:
230 pOlView
->PrepareClose();
231 slideshowhelp::ShowSlideShow(rReq
, *GetDoc());
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
);
249 // color view is disabled: enable
250 pOutl
->SetControlWord(nCntrl
& ~EEControlBits::NOCOLORS
);
254 Invalidate( SID_COLORVIEW
);
261 case SID_STYLE_UPDATE_BY_EXAMPLE
:
265 SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
273 case SID_PRESENTATION_DLG
:
275 SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
282 #ifdef ENABLE_SDREMOTE
283 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
284 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateRemoteDialog(GetFrameWeld()));
290 case SID_CUSTOMSHOW_DLG
:
292 SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
299 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
300 vcl::Window
* pWin
= GetActiveWindow();
301 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateSdPhotoAlbumDialog(
302 pWin
? pWin
->GetFrameWeld() : nullptr,
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
);
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();
350 case SID_HYPERLINK_SETLINK
:
352 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
356 const SvxHyperlinkItem
* pHLItem
=
357 &pReqArgs
->Get(SID_HYPERLINK_SETLINK
);
359 SvxFieldItem
aURLItem(SvxURLField(pHLItem
->GetURL(),
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;
367 aSel
.nStartPos
= aSel
.nEndPos
+ 1;
368 pOutlinerView
->SetSelection( aSel
);
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
:
383 case SID_INSERT_ZWSP
:
386 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
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
) );
402 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
408 case SID_CHAR_DLG_EFFECT
:
411 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
418 SetCurrentFunction( FuInsertFile::Create(this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
423 case SID_PRESENTATIONOBJECT
:
425 SetCurrentFunction( FuPresentationObjects::Create(this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
430 case SID_SET_DEFAULT
:
432 pOutlinerView
->RemoveAttribs(true); // sal_True = also paragraph attributes
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();
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();
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
;
474 case SID_INSERT_FLD_DATE_FIX
:
475 pFieldItem
.reset(new SvxFieldItem(
476 SvxDateField( Date( Date::SYSTEM
), SvxDateType::Fix
), EE_FEATURE_FIELD
));
479 case SID_INSERT_FLD_DATE_VAR
:
480 pFieldItem
.reset(new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD
));
483 case SID_INSERT_FLD_TIME_FIX
:
484 pFieldItem
.reset(new SvxFieldItem(
485 SvxExtTimeField( ::tools::Time( ::tools::Time::SYSTEM
), SvxTimeType::Fix
), EE_FEATURE_FIELD
));
488 case SID_INSERT_FLD_TIME_VAR
:
489 pFieldItem
.reset(new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD
));
492 case SID_INSERT_FLD_AUTHOR
:
494 SvtUserOptions aUserOptions
;
495 pFieldItem
.reset(new SvxFieldItem(
497 aUserOptions
.GetFirstName(), aUserOptions
.GetLastName(), aUserOptions
.GetID() )
498 , EE_FEATURE_FIELD
));
502 case SID_INSERT_FLD_PAGE
:
503 pFieldItem
.reset(new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD
));
506 case SID_INSERT_FLD_PAGE_TITLE
:
507 pFieldItem
.reset(new SvxFieldItem( SvxPageTitleField(), EE_FEATURE_FIELD
));
510 case SID_INSERT_FLD_PAGES
:
511 pFieldItem
.reset(new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD
));
514 case SID_INSERT_FLD_FILE
:
517 if( GetDocSh()->HasName() )
518 aName
= GetDocSh()->GetMedium()->GetName();
520 // aName = GetDocSh()->GetName();
521 pFieldItem
.reset(new SvxFieldItem( SvxExtFileField( aName
), EE_FEATURE_FIELD
));
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
)
541 pOutlinerView
->SetSelection( aSel
);
545 pOutlinerView
->InsertField( *pFieldItem
);
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() ) ) )
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());
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();
577 if( aSel
.nStartPos
== aSel
.nEndPos
)
582 pOutlinerView
->SetSelection( aSel
);
584 pOutlinerView
->InsertField( aFieldItem
);
586 // reset selection to original state
589 pOutlinerView
->SetSelection( aSel
);
594 SfxItemSet
aSet( pDlg
->GetItemSet() );
597 pOutlinerView
->SetAttribs( aSet
);
599 ::Outliner
* pOutliner
= pOutlinerView
->GetOutliner();
601 pOutliner
->UpdateFields();
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
);
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: */