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>
22 #include <com/sun/star/beans/PropertyValue.hpp>
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>
41 #include <fubullet.hxx>
42 #include <fuolbull.hxx>
43 #include <FrameView.hxx>
45 #include <fuscale.hxx>
47 #include <fuinsfil.hxx>
48 #include <fuprobjs.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>
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>
67 using namespace ::com::sun::star::uno
;
68 using namespace ::com::sun::star::beans
;
72 /************************************************************************/
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();
89 const SfxItemSet
* pArgs
= rReq
.GetArgs();
93 SvxZoomType eZT
= pArgs
->Get( SID_ATTR_ZOOM
).GetType();
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
);
108 // open the zoom dialog here
109 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
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
);
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
);
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
);
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
);
180 case SID_OUTLINE_COLLAPSE_ALL
:
182 pOutlinerView
->CollapseAll();
188 case SID_OUTLINE_COLLAPSE
:
190 pOutlinerView
->Collapse();
196 case SID_OUTLINE_EXPAND_ALL
:
198 pOutlinerView
->ExpandAll();
204 case SID_OUTLINE_EXPAND
:
206 pOutlinerView
->Expand();
212 case SID_OUTLINE_FORMAT
:
214 ::Outliner
* pOutl
= pOutlinerView
->GetOutliner();
215 pOutl
->SetFlatMode( !pOutl
->IsFlatMode() );
216 Invalidate( SID_COLORVIEW
);
224 ::Outliner
& rOutl
= pOlView
->GetOutliner();
225 sal_Int32 nParaCount
= rOutl
.GetParagraphCount();
228 pOutlinerView
->SelectRange( 0, nParaCount
);
234 case SID_PRESENTATION
:
235 case SID_PRESENTATION_CURRENT_SLIDE
:
236 case SID_REHEARSE_TIMINGS
:
238 pOlView
->PrepareClose();
239 slideshowhelp::ShowSlideShow(rReq
, *GetDoc());
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
);
257 // color view is disabled: enable
258 pOutl
->SetControlWord(nCntrl
& ~EEControlBits::NOCOLORS
);
262 Invalidate( SID_COLORVIEW
);
269 case SID_STYLE_UPDATE_BY_EXAMPLE
:
273 SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
281 case SID_PRESENTATION_DLG
:
283 SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
290 #ifdef ENABLE_SDREMOTE
291 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
292 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateRemoteDialog(GetActiveWindow()));
298 case SID_CUSTOMSHOW_DLG
:
300 SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
307 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
308 vcl::Window
* pWin
= GetActiveWindow();
309 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateSdPhotoAlbumDialog(
310 pWin
? pWin
->GetFrameWeld() : nullptr,
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
);
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();
358 case SID_HYPERLINK_SETLINK
:
360 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
364 const SvxHyperlinkItem
* pHLItem
=
365 &pReqArgs
->Get(SID_HYPERLINK_SETLINK
);
367 SvxFieldItem
aURLItem(SvxURLField(pHLItem
->GetURL(),
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;
375 aSel
.nStartPos
= aSel
.nEndPos
+ 1;
376 pOutlinerView
->SetSelection( aSel
);
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
:
394 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
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
) );
410 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
416 case SID_CHAR_DLG_EFFECT
:
419 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
426 SetCurrentFunction( FuInsertFile::Create(this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
431 case SID_PRESENTATIONOBJECT
:
433 SetCurrentFunction( FuPresentationObjects::Create(this, GetActiveWindow(), pOlView
.get(), GetDoc(), rReq
) );
438 case SID_SET_DEFAULT
:
440 pOutlinerView
->RemoveAttribs(true); // sal_True = also paragraph attributes
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();
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();
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
;
482 case SID_INSERT_FLD_DATE_FIX
:
483 pFieldItem
.reset(new SvxFieldItem(
484 SvxDateField( Date( Date::SYSTEM
), SvxDateType::Fix
), EE_FEATURE_FIELD
));
487 case SID_INSERT_FLD_DATE_VAR
:
488 pFieldItem
.reset(new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD
));
491 case SID_INSERT_FLD_TIME_FIX
:
492 pFieldItem
.reset(new SvxFieldItem(
493 SvxExtTimeField( ::tools::Time( ::tools::Time::SYSTEM
), SvxTimeType::Fix
), EE_FEATURE_FIELD
));
496 case SID_INSERT_FLD_TIME_VAR
:
497 pFieldItem
.reset(new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD
));
500 case SID_INSERT_FLD_AUTHOR
:
502 SvtUserOptions aUserOptions
;
503 pFieldItem
.reset(new SvxFieldItem(
505 aUserOptions
.GetFirstName(), aUserOptions
.GetLastName(), aUserOptions
.GetID() )
506 , EE_FEATURE_FIELD
));
510 case SID_INSERT_FLD_PAGE
:
511 pFieldItem
.reset(new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD
));
514 case SID_INSERT_FLD_PAGE_TITLE
:
515 pFieldItem
.reset(new SvxFieldItem( SvxPageTitleField(), EE_FEATURE_FIELD
));
518 case SID_INSERT_FLD_PAGES
:
519 pFieldItem
.reset(new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD
));
522 case SID_INSERT_FLD_FILE
:
525 if( GetDocSh()->HasName() )
526 aName
= GetDocSh()->GetMedium()->GetName();
528 // aName = GetDocSh()->GetName();
529 pFieldItem
.reset(new SvxFieldItem( SvxExtFileField( aName
), EE_FEATURE_FIELD
));
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
)
549 pOutlinerView
->SetSelection( aSel
);
553 pOutlinerView
->InsertField( *pFieldItem
);
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() ) ) )
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());
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();
585 if( aSel
.nStartPos
== aSel
.nEndPos
)
590 pOutlinerView
->SetSelection( aSel
);
592 pOutlinerView
->InsertField( aFieldItem
);
594 // reset selection to original state
597 pOutlinerView
->SetSelection( aSel
);
602 SfxItemSet
aSet( pDlg
->GetItemSet() );
605 pOutlinerView
->SetAttribs( aSet
);
607 ::Outliner
* pOutliner
= pOutlinerView
->GetOutliner();
609 pOutliner
->UpdateFields();
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
);
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: */