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/presentation/XPresentation2.hpp>
23 #include <com/sun/star/beans/PropertyValue.hpp>
24 #include <com/sun/star/uno/Any.hxx>
27 #include <svx/hlnkitem.hxx>
28 #include <sfx2/docfile.hxx>
29 #include <sfx2/dispatch.hxx>
30 #include <sfx2/request.hxx>
31 #include <svl/eitem.hxx>
32 #include <sfx2/zoomitem.hxx>
33 #include <svx/svxids.hrc>
34 #include <vcl/msgbox.hxx>
35 #include <editeng/eeitem.hxx>
36 #include <editeng/flditem.hxx>
37 #include <editeng/editstat.hxx>
38 #include "optsitem.hxx"
39 #include <unotools/useroptions.hxx>
41 #include <sfx2/viewfrm.hxx>
42 #include "Outliner.hxx"
44 #include "fubullet.hxx"
45 #include "fuolbull.hxx"
46 #include "FrameView.hxx"
48 #include "fuscale.hxx"
50 #include "fuinsfil.hxx"
51 #include "fuprobjs.hxx"
53 #include "futempl.hxx"
54 #include "fusldlg.hxx"
55 #include "zoomlist.hxx"
56 #include "fuexpand.hxx"
57 #include "fusumry.hxx"
58 #include "fucushow.hxx"
59 #include "drawdoc.hxx"
61 #include "ViewShellBase.hxx"
62 #include "sdabstdlg.hxx"
63 #include "framework/FrameworkHelper.hxx"
64 #include "DrawViewShell.hxx"
65 #include "slideshow.hxx"
66 #include <boost/scoped_ptr.hpp>
68 using namespace ::com::sun::star::uno
;
69 using namespace ::com::sun::star::presentation
;
70 using namespace ::com::sun::star::beans
;
74 /************************************************************************/
77 * SfxRequests for temporary functions
80 void OutlineViewShell::FuTemporary(SfxRequest
&rReq
)
82 DeactivateCurrentFunction();
84 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow( GetActiveWindow() );
85 sal_uInt16 nSId
= rReq
.GetSlot();
91 const SfxItemSet
* pArgs
= rReq
.GetArgs();
95 SvxZoomType eZT
= static_cast<const SvxZoomItem
&>( pArgs
->
96 Get( SID_ATTR_ZOOM
) ).GetType();
99 case SvxZoomType::PERCENT
:
100 SetZoom( (long) static_cast<const SvxZoomItem
&>( pArgs
->
101 Get( SID_ATTR_ZOOM
) ).GetValue() );
102 Invalidate( SID_ATTR_ZOOM
);
103 Invalidate( SID_ATTR_ZOOMSLIDER
);
112 // open the zoom dialog here
113 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
119 case SID_ATTR_ZOOMSLIDER
:
121 const SfxItemSet
* pArgs
= rReq
.GetArgs();
123 if (pArgs
&& pArgs
->Count () == 1 )
125 SFX_REQUEST_ARG (rReq
, pScale
, SfxUInt16Item
, SID_ATTR_ZOOMSLIDER
, false);
126 if (CHECK_RANGE (5, pScale
->GetValue (), 3000))
128 SetZoom (pScale
->GetValue ());
130 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
131 rBindings
.Invalidate( SID_ATTR_ZOOM
);
132 rBindings
.Invalidate( SID_ZOOM_IN
);
133 rBindings
.Invalidate( SID_ZOOM_OUT
);
134 rBindings
.Invalidate( SID_ATTR_ZOOMSLIDER
);
146 SetZoom( std::min( (long) ( GetActiveWindow()->GetZoom() * 2 ), (long) GetActiveWindow()->GetMaxZoom() ) );
147 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
148 GetActiveWindow()->GetOutputSizePixel()) );
149 mpZoomList
->InsertZoomRect(aVisAreaWin
);
150 Invalidate( SID_ATTR_ZOOM
);
151 Invalidate( SID_ZOOM_IN
);
152 Invalidate( SID_ATTR_ZOOMSLIDER
);
161 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
162 GetActiveWindow()->GetOutputSizePixel()) );
163 mpZoomList
->InsertZoomRect(aVisAreaWin
);
164 Invalidate( SID_ATTR_ZOOM
);
165 Invalidate( SID_ATTR_ZOOMSLIDER
);
173 SetZoom( std::max( (long) ( GetActiveWindow()->GetZoom() / 2 ), (long) GetActiveWindow()->GetMinZoom() ) );
174 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
175 GetActiveWindow()->GetOutputSizePixel()) );
176 mpZoomList
->InsertZoomRect(aVisAreaWin
);
177 Invalidate( SID_ATTR_ZOOM
);
178 Invalidate( SID_ZOOM_OUT
);
179 Invalidate( SID_ZOOM_IN
);
180 Invalidate( SID_ATTR_ZOOMSLIDER
);
186 case SID_OUTLINE_COLLAPSE_ALL
:
188 pOutlinerView
->CollapseAll();
194 case SID_OUTLINE_COLLAPSE
:
196 pOutlinerView
->Collapse();
202 case SID_OUTLINE_EXPAND_ALL
:
204 pOutlinerView
->ExpandAll();
210 case SID_OUTLINE_EXPAND
:
212 pOutlinerView
->Expand();
218 case SID_OUTLINE_FORMAT
:
220 ::Outliner
* pOutl
= pOutlinerView
->GetOutliner();
221 pOutl
->SetFlatMode( !pOutl
->IsFlatMode() );
222 Invalidate( SID_COLORVIEW
);
230 ::Outliner
& rOutl
= pOlView
->GetOutliner();
231 sal_Int32 nParaCount
= rOutl
.GetParagraphCount();
234 pOutlinerView
->SelectRange( 0, nParaCount
);
240 case SID_PRESENTATION
:
241 case SID_PRESENTATION_CURRENT_SLIDE
:
242 case SID_REHEARSE_TIMINGS
:
244 pOlView
->PrepareClose();
253 ::Outliner
* pOutl
= pOutlinerView
->GetOutliner();
254 EEControlBits nCntrl
= pOutl
->GetControlWord();
256 if ( !(nCntrl
& EEControlBits::NOCOLORS
) )
258 // color view is enabled: disable
259 pOutl
->SetControlWord(nCntrl
| EEControlBits::NOCOLORS
);
263 // color view is disabled: enable
264 pOutl
->SetControlWord(nCntrl
& ~EEControlBits::NOCOLORS
);
268 Invalidate( SID_COLORVIEW
);
275 case SID_STYLE_UPDATE_BY_EXAMPLE
:
279 SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
287 case SID_PRESENTATION_DLG
:
289 SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
296 #ifdef ENABLE_SDREMOTE
297 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
298 VclAbstractDialog
* pDlg
= pFact
? pFact
->CreateRemoteDialog(GetActiveWindow()) : 0;
305 case SID_CUSTOMSHOW_DLG
:
307 SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
314 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
315 boost::scoped_ptr
<VclAbstractDialog
> pDlg(pFact
? pFact
->CreateSdPhotoAlbumDialog(
330 if(HasCurrentFunction())
331 GetCurrentFunction()->Activate();
333 Invalidate( SID_OUTLINE_COLLAPSE_ALL
);
334 Invalidate( SID_OUTLINE_COLLAPSE
);
335 Invalidate( SID_OUTLINE_EXPAND_ALL
);
336 Invalidate( SID_OUTLINE_EXPAND
);
338 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
339 rBindings
.Invalidate( SID_OUTLINE_LEFT
);
340 rBindings
.Invalidate( SID_OUTLINE_RIGHT
);
341 rBindings
.Invalidate( SID_OUTLINE_UP
);
342 rBindings
.Invalidate( SID_OUTLINE_DOWN
);
344 Invalidate( SID_OUTLINE_FORMAT
);
345 Invalidate( SID_COLORVIEW
);
347 Invalidate(SID_COPY
);
348 Invalidate(SID_PASTE
);
349 Invalidate(SID_PASTE_UNFORMATTED
);
352 void OutlineViewShell::ShowSlideShow(SfxRequest
& rReq
)
354 slideshowhelp::ShowSlideShow(rReq
, *GetDoc());
357 void OutlineViewShell::FuTemporaryModify(SfxRequest
&rReq
)
359 sal_uInt16 nSId
= rReq
.GetSlot();
360 boost::scoped_ptr
< OutlineViewModelChangeGuard
> aGuard
;
361 if (nSId
!= SID_OUTLINE_BULLET
&& nSId
!= FN_SVX_SET_BULLET
&& nSId
!= FN_SVX_SET_NUMBER
)
363 aGuard
.reset( new OutlineViewModelChangeGuard(*pOlView
) );
365 DeactivateCurrentFunction();
367 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow( GetActiveWindow() );
368 //sal_uInt16 nSId = rReq.GetSlot();
372 case SID_HYPERLINK_SETLINK
:
374 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
378 const SvxHyperlinkItem
* pHLItem
=
379 static_cast<const SvxHyperlinkItem
*>( &pReqArgs
->Get(SID_HYPERLINK_SETLINK
) );
381 SvxFieldItem
aURLItem(SvxURLField(pHLItem
->GetURL(),
383 SVXURLFORMAT_REPR
), EE_FEATURE_FIELD
);
384 ESelection
aSel( pOutlinerView
->GetSelection() );
385 pOutlinerView
->InsertField(aURLItem
);
386 if ( aSel
.nStartPos
<= aSel
.nEndPos
)
387 aSel
.nEndPos
= aSel
.nStartPos
+ 1;
389 aSel
.nStartPos
= aSel
.nEndPos
+ 1;
390 pOutlinerView
->SetSelection( aSel
);
398 case FN_INSERT_SOFT_HYPHEN
:
399 case FN_INSERT_HARDHYPHEN
:
400 case FN_INSERT_HARD_SPACE
:
401 case SID_INSERT_RLM
:
402 case SID_INSERT_LRM
:
403 case SID_INSERT_ZWNBSP
:
404 case SID_INSERT_ZWSP
:
407 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
412 case SID_OUTLINE_BULLET
:
413 case FN_SVX_SET_BULLET
:
414 case FN_SVX_SET_NUMBER
:
416 SetCurrentFunction( FuOutlineBullet::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
423 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
429 case SID_CHAR_DLG_EFFECT
:
432 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
439 SetCurrentFunction( FuInsertFile::Create(this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
444 case SID_PRESENTATIONOBJECT
:
446 SetCurrentFunction( FuPresentationObjects::Create(this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
451 case SID_SET_DEFAULT
:
453 pOutlinerView
->RemoveAttribs(true); // sal_True = also paragraph attributes
459 case SID_SUMMARY_PAGE
:
461 pOlView
->SetSelectedPages();
462 SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
463 pOlView
->GetOutliner().Clear();
464 pOlView
->FillOutliner();
465 pOlView
->GetActualPage();
470 case SID_EXPAND_PAGE
:
472 pOlView
->SetSelectedPages();
473 SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
474 pOlView
->GetOutliner().Clear();
475 pOlView
->FillOutliner();
476 pOlView
->GetActualPage();
481 case SID_INSERT_FLD_DATE_FIX
:
482 case SID_INSERT_FLD_DATE_VAR
:
483 case SID_INSERT_FLD_TIME_FIX
:
484 case SID_INSERT_FLD_TIME_VAR
:
485 case SID_INSERT_FLD_AUTHOR
:
486 case SID_INSERT_FLD_PAGE
:
487 case SID_INSERT_FLD_PAGE_TITLE
:
488 case SID_INSERT_FLD_PAGES
:
489 case SID_INSERT_FLD_FILE
:
491 boost::scoped_ptr
<SvxFieldItem
> pFieldItem
;
495 case SID_INSERT_FLD_DATE_FIX
:
496 pFieldItem
.reset(new SvxFieldItem(
497 SvxDateField( Date( Date::SYSTEM
), SVXDATETYPE_FIX
), EE_FEATURE_FIELD
));
500 case SID_INSERT_FLD_DATE_VAR
:
501 pFieldItem
.reset(new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD
));
504 case SID_INSERT_FLD_TIME_FIX
:
505 pFieldItem
.reset(new SvxFieldItem(
506 SvxExtTimeField( ::tools::Time( ::tools::Time::SYSTEM
), SVXTIMETYPE_FIX
), EE_FEATURE_FIELD
));
509 case SID_INSERT_FLD_TIME_VAR
:
510 pFieldItem
.reset(new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD
));
513 case SID_INSERT_FLD_AUTHOR
:
515 SvtUserOptions aUserOptions
;
516 pFieldItem
.reset(new SvxFieldItem(
518 aUserOptions
.GetFirstName(), aUserOptions
.GetLastName(), aUserOptions
.GetID() )
519 , EE_FEATURE_FIELD
));
523 case SID_INSERT_FLD_PAGE
:
524 pFieldItem
.reset(new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD
));
527 case SID_INSERT_FLD_PAGE_TITLE
:
528 pFieldItem
.reset(new SvxFieldItem( SvxPageTitleField(), EE_FEATURE_FIELD
));
531 case SID_INSERT_FLD_PAGES
:
532 pFieldItem
.reset(new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD
));
535 case SID_INSERT_FLD_FILE
:
538 if( GetDocSh()->HasName() )
539 aName
= GetDocSh()->GetMedium()->GetName();
541 // aName = GetDocSh()->GetName();
542 pFieldItem
.reset(new SvxFieldItem( SvxExtFileField( aName
), EE_FEATURE_FIELD
));
547 const SvxFieldItem
* pOldFldItem
= pOutlinerView
->GetFieldAtSelection();
549 if( pOldFldItem
&& ( pOldFldItem
->GetField()->ISA( SvxURLField
) ||
550 pOldFldItem
->GetField()->ISA( SvxDateField
) ||
551 pOldFldItem
->GetField()->ISA( SvxTimeField
) ||
552 pOldFldItem
->GetField()->ISA( SvxExtTimeField
) ||
553 pOldFldItem
->GetField()->ISA( SvxExtFileField
) ||
554 pOldFldItem
->GetField()->ISA( SvxAuthorField
) ||
555 pOldFldItem
->GetField()->ISA( SvxPageField
) ||
556 pOldFldItem
->GetField()->ISA( SvxPagesField
)) )
558 // select field, so it gets deleted on Insert
559 ESelection aSel
= pOutlinerView
->GetSelection();
560 if( aSel
.nStartPos
== aSel
.nEndPos
)
562 pOutlinerView
->SetSelection( aSel
);
566 pOutlinerView
->InsertField( *pFieldItem
);
575 case SID_MODIFY_FIELD
:
577 const SvxFieldItem
* pFldItem
= pOutlinerView
->GetFieldAtSelection();
579 if( pFldItem
&& (pFldItem
->GetField()->ISA( SvxDateField
) ||
580 pFldItem
->GetField()->ISA( SvxAuthorField
) ||
581 pFldItem
->GetField()->ISA( SvxExtFileField
) ||
582 pFldItem
->GetField()->ISA( SvxExtTimeField
) ) )
585 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
586 boost::scoped_ptr
<AbstractSdModifyFieldDlg
> pDlg(pFact
? pFact
->CreateSdModifyFieldDlg(GetActiveWindow(), pFldItem
->GetField(), pOutlinerView
->GetAttribs() ) : 0);
587 if( pDlg
&& (pDlg
->Execute() == RET_OK
) )
589 boost::scoped_ptr
<SvxFieldData
> pField(pDlg
->GetField());
592 SvxFieldItem
aFieldItem( *pField
, EE_FEATURE_FIELD
);
593 //pOLV->DeleteSelected(); <-- unfortunately missing!
594 // select field, so it gets deleted on Insert
595 ESelection aSel
= pOutlinerView
->GetSelection();
597 if( aSel
.nStartPos
== aSel
.nEndPos
)
602 pOutlinerView
->SetSelection( aSel
);
604 pOutlinerView
->InsertField( aFieldItem
);
606 // reset selection to original state
609 pOutlinerView
->SetSelection( aSel
);
614 SfxItemSet
aSet( pDlg
->GetItemSet() );
617 pOutlinerView
->SetAttribs( aSet
);
619 ::Outliner
* pOutliner
= pOutlinerView
->GetOutliner();
621 pOutliner
->UpdateFields();
632 if(HasCurrentFunction())
633 GetCurrentFunction()->Activate();
635 Invalidate( SID_OUTLINE_COLLAPSE_ALL
);
636 Invalidate( SID_OUTLINE_COLLAPSE
);
637 Invalidate( SID_OUTLINE_EXPAND_ALL
);
638 Invalidate( SID_OUTLINE_EXPAND
);
640 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
641 rBindings
.Invalidate( SID_OUTLINE_LEFT
);
642 rBindings
.Invalidate( SID_OUTLINE_RIGHT
);
643 rBindings
.Invalidate( SID_OUTLINE_UP
);
644 rBindings
.Invalidate( SID_OUTLINE_DOWN
);
646 Invalidate( SID_OUTLINE_FORMAT
);
647 Invalidate( SID_COLORVIEW
);
649 Invalidate(SID_COPY
);
650 Invalidate(SID_PASTE
);
651 Invalidate(SID_PASTE_UNFORMATTED
);
654 } // end of namespace sd
656 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */