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 .
21 #include "OutlineViewShell.hxx"
23 #include <com/sun/star/presentation/XPresentation2.hpp>
24 #include <com/sun/star/beans/PropertyValue.hpp>
25 #include <com/sun/star/uno/Any.hxx>
28 #include <svx/hlnkitem.hxx>
29 #include <sfx2/docfile.hxx>
30 #include <sfx2/dispatch.hxx>
31 #include <sfx2/request.hxx>
32 #include <svl/eitem.hxx>
33 #include <sfx2/zoomitem.hxx>
34 #include <svx/svxids.hrc>
35 #include <vcl/msgbox.hxx>
36 #include <editeng/eeitem.hxx>
37 #include <editeng/flditem.hxx>
38 #include <editeng/editstat.hxx>
39 #include "optsitem.hxx"
40 #include <unotools/useroptions.hxx>
42 #include <sfx2/viewfrm.hxx>
43 #include "Outliner.hxx"
45 #include "fubullet.hxx"
46 #include "fuolbull.hxx"
47 #include "FrameView.hxx"
49 #include "fuscale.hxx"
51 #include "fuinsfil.hxx"
52 #include "fuprobjs.hxx"
54 #include "futempl.hxx"
55 #include "fusldlg.hxx"
56 #include "zoomlist.hxx"
57 #include "fuexpand.hxx"
58 #include "fusumry.hxx"
59 #include "fucushow.hxx"
60 #include "drawdoc.hxx"
62 #include "ViewShellBase.hxx"
63 #include "sdabstdlg.hxx"
64 #include "framework/FrameworkHelper.hxx"
65 #include "DrawViewShell.hxx"
66 #include "slideshow.hxx"
67 #include <boost/scoped_ptr.hpp>
69 using namespace ::com::sun::star::uno
;
70 using namespace ::com::sun::star::presentation
;
71 using namespace ::com::sun::star::beans
;
76 /************************************************************************/
79 * SfxRequests for temporary functions
82 void OutlineViewShell::FuTemporary(SfxRequest
&rReq
)
84 DeactivateCurrentFunction();
86 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow( GetActiveWindow() );
87 sal_uInt16 nSId
= rReq
.GetSlot();
93 const SfxItemSet
* pArgs
= rReq
.GetArgs();
97 SvxZoomType eZT
= ( ( const SvxZoomItem
& ) pArgs
->
98 Get( SID_ATTR_ZOOM
) ).GetType();
101 case SVX_ZOOM_PERCENT
:
102 SetZoom( (long) ( ( const SvxZoomItem
& ) pArgs
->
103 Get( SID_ATTR_ZOOM
) ).GetValue() );
104 Invalidate( SID_ATTR_ZOOM
);
105 Invalidate( SID_ATTR_ZOOMSLIDER
);
114 // open the zoom dialog here
115 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
121 case SID_ATTR_ZOOMSLIDER
:
123 const SfxItemSet
* pArgs
= rReq
.GetArgs();
125 if (pArgs
&& pArgs
->Count () == 1 )
127 SFX_REQUEST_ARG (rReq
, pScale
, SfxUInt16Item
, SID_ATTR_ZOOMSLIDER
, sal_False
);
128 if (CHECK_RANGE (5, pScale
->GetValue (), 3000))
130 SetZoom (pScale
->GetValue ());
132 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
133 rBindings
.Invalidate( SID_ATTR_ZOOM
);
134 rBindings
.Invalidate( SID_ZOOM_IN
);
135 rBindings
.Invalidate( SID_ZOOM_OUT
);
136 rBindings
.Invalidate( SID_ATTR_ZOOMSLIDER
);
148 SetCurrentFunction( FuZoom::Create(this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
149 // ends itself, no need for Cancel()!
157 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
158 GetActiveWindow()->GetOutputSizePixel()) );
159 mpZoomList
->InsertZoomRect(aVisAreaWin
);
160 Invalidate( SID_ATTR_ZOOM
);
161 Invalidate( SID_ATTR_ZOOMSLIDER
);
169 SetZoom( std::max( (long) ( GetActiveWindow()->GetZoom() / 2 ), (long) GetActiveWindow()->GetMinZoom() ) );
170 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
171 GetActiveWindow()->GetOutputSizePixel()) );
172 mpZoomList
->InsertZoomRect(aVisAreaWin
);
173 Invalidate( SID_ATTR_ZOOM
);
174 Invalidate( SID_ZOOM_OUT
);
175 Invalidate( SID_ZOOM_IN
);
176 Invalidate( SID_ATTR_ZOOMSLIDER
);
182 case SID_OUTLINE_COLLAPSE_ALL
:
184 pOutlinerView
->CollapseAll();
190 case SID_OUTLINE_COLLAPSE
:
192 pOutlinerView
->Collapse();
198 case SID_OUTLINE_EXPAND_ALL
:
200 pOutlinerView
->ExpandAll();
206 case SID_OUTLINE_EXPAND
:
208 pOutlinerView
->Expand();
214 case SID_OUTLINE_FORMAT
:
216 ::Outliner
* pOutl
= pOutlinerView
->GetOutliner();
217 pOutl
->SetFlatMode( !pOutl
->IsFlatMode() );
218 Invalidate( SID_COLORVIEW
);
226 ::Outliner
* pOutl
= pOlView
->GetOutliner();
227 sal_Int32 nParaCount
= pOutl
->GetParagraphCount();
230 pOutlinerView
->SelectRange( 0, nParaCount
);
236 case SID_PRESENTATION
:
237 case SID_PRESENTATION_CURRENT_SLIDE
:
238 case SID_REHEARSE_TIMINGS
:
240 pOlView
->PrepareClose();
249 ::Outliner
* pOutl
= pOutlinerView
->GetOutliner();
250 sal_uLong nCntrl
= pOutl
->GetControlWord();
252 if ( !(nCntrl
& EE_CNTRL_NOCOLORS
) )
254 // color view is enabled: disable
255 pOutl
->SetControlWord(nCntrl
| EE_CNTRL_NOCOLORS
);
259 // color view is disabled: enable
260 pOutl
->SetControlWord(nCntrl
& ~EE_CNTRL_NOCOLORS
);
264 Invalidate( SID_COLORVIEW
);
271 case SID_STYLE_UPDATE_BY_EXAMPLE
:
275 SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
283 case SID_PRESENTATION_DLG
:
285 SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
290 case SID_CUSTOMSHOW_DLG
:
292 SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
299 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
300 VclAbstractDialog
* pDlg
= pFact
? pFact
->CreateSdPhotoAlbumDialog(
315 if(HasCurrentFunction())
316 GetCurrentFunction()->Activate();
318 Invalidate( SID_OUTLINE_COLLAPSE_ALL
);
319 Invalidate( SID_OUTLINE_COLLAPSE
);
320 Invalidate( SID_OUTLINE_EXPAND_ALL
);
321 Invalidate( SID_OUTLINE_EXPAND
);
323 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
324 rBindings
.Invalidate( SID_OUTLINE_LEFT
);
325 rBindings
.Invalidate( SID_OUTLINE_RIGHT
);
326 rBindings
.Invalidate( SID_OUTLINE_UP
);
327 rBindings
.Invalidate( SID_OUTLINE_DOWN
);
329 Invalidate( SID_OUTLINE_FORMAT
);
330 Invalidate( SID_COLORVIEW
);
332 Invalidate(SID_COPY
);
333 Invalidate(SID_PASTE
);
336 void OutlineViewShell::ShowSlideShow(SfxRequest
& rReq
)
338 slideshowhelp::ShowSlideShow(rReq
, *GetDoc());
341 void OutlineViewShell::FuTemporaryModify(SfxRequest
&rReq
)
343 sal_uInt16 nSId
= rReq
.GetSlot();
344 boost::scoped_ptr
< OutlineViewModelChangeGuard
> aGuard
;
345 if (nSId
!= SID_OUTLINE_BULLET
&& nSId
!= FN_SVX_SET_BULLET
&& nSId
!= FN_SVX_SET_NUMBER
)
347 aGuard
.reset( new OutlineViewModelChangeGuard(*pOlView
) );
349 DeactivateCurrentFunction();
351 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow( GetActiveWindow() );
352 //sal_uInt16 nSId = rReq.GetSlot();
356 case SID_HYPERLINK_SETLINK
:
358 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
362 SvxHyperlinkItem
* pHLItem
=
363 (SvxHyperlinkItem
*) &pReqArgs
->Get(SID_HYPERLINK_SETLINK
);
365 SvxFieldItem
aURLItem(SvxURLField(pHLItem
->GetURL(),
367 SVXURLFORMAT_REPR
), EE_FEATURE_FIELD
);
368 ESelection
aSel( pOutlinerView
->GetSelection() );
369 pOutlinerView
->InsertField(aURLItem
);
370 if ( aSel
.nStartPos
<= aSel
.nEndPos
)
371 aSel
.nEndPos
= aSel
.nStartPos
+ 1;
373 aSel
.nStartPos
= aSel
.nEndPos
+ 1;
374 pOutlinerView
->SetSelection( aSel
);
382 case FN_INSERT_SOFT_HYPHEN
:
383 case FN_INSERT_HARDHYPHEN
:
384 case FN_INSERT_HARD_SPACE
:
385 case SID_INSERT_RLM
:
386 case SID_INSERT_LRM
:
387 case SID_INSERT_ZWNBSP
:
388 case SID_INSERT_ZWSP
:
391 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
396 case SID_OUTLINE_BULLET
:
397 case FN_SVX_SET_BULLET
:
398 case FN_SVX_SET_NUMBER
:
400 SetCurrentFunction( FuOutlineBullet::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
407 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
413 case SID_CHAR_DLG_EFFECT
:
416 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
423 SetCurrentFunction( FuInsertFile::Create(this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
428 case SID_PRESENTATIONOBJECT
:
430 SetCurrentFunction( FuPresentationObjects::Create(this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
435 case SID_SET_DEFAULT
:
437 pOutlinerView
->RemoveAttribs(sal_True
); // sal_True = also paragraph attributes
443 case SID_SUMMARY_PAGE
:
445 pOlView
->SetSelectedPages();
446 SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
447 pOlView
->GetOutliner()->Clear();
448 pOlView
->FillOutliner();
449 pOlView
->GetActualPage();
454 case SID_EXPAND_PAGE
:
456 pOlView
->SetSelectedPages();
457 SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
458 pOlView
->GetOutliner()->Clear();
459 pOlView
->FillOutliner();
460 pOlView
->GetActualPage();
465 case SID_INSERT_FLD_DATE_FIX
:
466 case SID_INSERT_FLD_DATE_VAR
:
467 case SID_INSERT_FLD_TIME_FIX
:
468 case SID_INSERT_FLD_TIME_VAR
:
469 case SID_INSERT_FLD_AUTHOR
:
470 case SID_INSERT_FLD_PAGE
:
471 case SID_INSERT_FLD_PAGES
:
472 case SID_INSERT_FLD_FILE
:
474 SvxFieldItem
* pFieldItem
= 0;
478 case SID_INSERT_FLD_DATE_FIX
:
479 pFieldItem
= new SvxFieldItem(
480 SvxDateField( Date( Date::SYSTEM
), SVXDATETYPE_FIX
), EE_FEATURE_FIELD
);
483 case SID_INSERT_FLD_DATE_VAR
:
484 pFieldItem
= new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD
);
487 case SID_INSERT_FLD_TIME_FIX
:
488 pFieldItem
= new SvxFieldItem(
489 SvxExtTimeField( Time( Time::SYSTEM
), SVXTIMETYPE_FIX
), EE_FEATURE_FIELD
);
492 case SID_INSERT_FLD_TIME_VAR
:
493 pFieldItem
= new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD
);
496 case SID_INSERT_FLD_AUTHOR
:
498 SvtUserOptions aUserOptions
;
499 pFieldItem
= new SvxFieldItem(
501 aUserOptions
.GetFirstName(), aUserOptions
.GetLastName(), aUserOptions
.GetID() )
502 , EE_FEATURE_FIELD
);
506 case SID_INSERT_FLD_PAGE
:
507 pFieldItem
= new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD
);
510 case SID_INSERT_FLD_PAGES
:
511 pFieldItem
= 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
= new SvxFieldItem( SvxExtFileField( aName
), EE_FEATURE_FIELD
);
526 const SvxFieldItem
* pOldFldItem
= pOutlinerView
->GetFieldAtSelection();
528 if( pOldFldItem
&& ( pOldFldItem
->GetField()->ISA( SvxURLField
) ||
529 pOldFldItem
->GetField()->ISA( SvxDateField
) ||
530 pOldFldItem
->GetField()->ISA( SvxTimeField
) ||
531 pOldFldItem
->GetField()->ISA( SvxExtTimeField
) ||
532 pOldFldItem
->GetField()->ISA( SvxExtFileField
) ||
533 pOldFldItem
->GetField()->ISA( SvxAuthorField
) ||
534 pOldFldItem
->GetField()->ISA( SvxPageField
) ||
535 pOldFldItem
->GetField()->ISA( SvxPagesField
)) )
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
&& (pFldItem
->GetField()->ISA( SvxDateField
) ||
559 pFldItem
->GetField()->ISA( SvxAuthorField
) ||
560 pFldItem
->GetField()->ISA( SvxExtFileField
) ||
561 pFldItem
->GetField()->ISA( SvxExtTimeField
) ) )
564 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
565 AbstractSdModifyFieldDlg
* pDlg
= pFact
? pFact
->CreateSdModifyFieldDlg(GetActiveWindow(), pFldItem
->GetField(), pOutlinerView
->GetAttribs() ) : 0;
566 if( pDlg
&& (pDlg
->Execute() == RET_OK
) )
568 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();
575 sal_Bool bSel
= sal_True
;
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();
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
);
634 } // end of namespace sd
636 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */