1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: outlnvs2.cxx,v $
10 * $Revision: 1.31.36.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "OutlineViewShell.hxx"
36 #include <com/sun/star/presentation/XPresentation2.hpp>
39 #include <svx/hlnkitem.hxx>
40 #include <sfx2/docfile.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <sfx2/request.hxx>
43 #include <svtools/eitem.hxx>
44 #ifndef _ZOOMITEM_HXX //autogen
45 #include <svx/zoomitem.hxx>
47 #include <vcl/msgbox.hxx>
48 #include <svx/eeitem.hxx>
49 #include <svx/flditem.hxx>
50 #include <svx/editstat.hxx>
51 #include "optsitem.hxx"
52 #include <svtools/useroptions.hxx>
54 #include <sfx2/viewfrm.hxx>
55 #include "Outliner.hxx"
57 #include "OutlineViewShell.hxx"
58 #include "fubullet.hxx"
59 #include "fuolbull.hxx"
60 #include "FrameView.hxx"
62 #include "fuscale.hxx"
64 #include "fuinsfil.hxx"
65 #include "fuprobjs.hxx"
67 #include "futempl.hxx"
68 #include "fusldlg.hxx"
69 #include "zoomlist.hxx"
70 #include "fuexpand.hxx"
71 #include "fusumry.hxx"
72 #include "fucushow.hxx"
73 #include "drawdoc.hxx"
75 #include "ViewShellBase.hxx"
76 #include "sdabstdlg.hxx"
77 #include "framework/FrameworkHelper.hxx"
78 #include "DrawViewShell.hxx"
80 using namespace ::com::sun::star::uno
;
81 using namespace ::com::sun::star::presentation
;
86 /************************************************************************/
88 /*************************************************************************
90 |* SfxRequests fuer temporaere Funktionen
92 \************************************************************************/
94 void OutlineViewShell::FuTemporary(SfxRequest
&rReq
)
96 DeactivateCurrentFunction();
98 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow( GetActiveWindow() );
99 USHORT nSId
= rReq
.GetSlot();
105 const SfxItemSet
* pArgs
= rReq
.GetArgs();
109 SvxZoomType eZT
= ( ( const SvxZoomItem
& ) pArgs
->
110 Get( SID_ATTR_ZOOM
) ).GetType();
113 case SVX_ZOOM_PERCENT
:
114 SetZoom( (long) ( ( const SvxZoomItem
& ) pArgs
->
115 Get( SID_ATTR_ZOOM
) ).GetValue() );
116 Invalidate( SID_ATTR_ZOOM
);
117 Invalidate( SID_ATTR_ZOOMSLIDER
);
126 // hier den Zoom-Dialog oeffnen
127 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
133 case SID_ATTR_ZOOMSLIDER
:
135 const SfxItemSet
* pArgs
= rReq
.GetArgs();
137 if (pArgs
&& pArgs
->Count () == 1 )
139 SFX_REQUEST_ARG (rReq
, pScale
, SfxUInt16Item
, SID_ATTR_ZOOMSLIDER
, FALSE
);
140 if (CHECK_RANGE (5, pScale
->GetValue (), 3000))
142 SetZoom (pScale
->GetValue ());
144 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
145 rBindings
.Invalidate( SID_ATTR_ZOOM
);
146 rBindings
.Invalidate( SID_ZOOM_IN
);
147 rBindings
.Invalidate( SID_ZOOM_OUT
);
148 rBindings
.Invalidate( SID_ATTR_ZOOMSLIDER
);
160 SetCurrentFunction( FuZoom::Create(this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
161 // Beendet sich selbst, kein Cancel() notwendig!
169 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
170 GetActiveWindow()->GetOutputSizePixel()) );
171 mpZoomList
->InsertZoomRect(aVisAreaWin
);
172 Invalidate( SID_ATTR_ZOOM
);
173 Invalidate( SID_ATTR_ZOOMSLIDER
);
181 SetZoom( Max( (long) ( GetActiveWindow()->GetZoom() / 2 ), (long) GetActiveWindow()->GetMinZoom() ) );
182 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
183 GetActiveWindow()->GetOutputSizePixel()) );
184 mpZoomList
->InsertZoomRect(aVisAreaWin
);
185 Invalidate( SID_ATTR_ZOOM
);
186 Invalidate( SID_ZOOM_OUT
);
187 Invalidate( SID_ZOOM_IN
);
188 Invalidate( SID_ATTR_ZOOMSLIDER
);
194 case SID_OUTLINE_COLLAPSE_ALL
:
196 pOutlinerView
->CollapseAll();
202 case SID_OUTLINE_COLLAPSE
:
204 pOutlinerView
->Collapse();
210 case SID_OUTLINE_EXPAND_ALL
:
212 pOutlinerView
->ExpandAll();
218 case SID_OUTLINE_EXPAND
:
220 pOutlinerView
->Expand();
226 case SID_OUTLINE_FORMAT
:
228 ::Outliner
* pOutl
= pOutlinerView
->GetOutliner();
229 pOutl
->SetFlatMode( !pOutl
->IsFlatMode() );
230 Invalidate( SID_COLORVIEW
);
238 ::Outliner
* pOutl
= pOlView
->GetOutliner();
239 ULONG nParaCount
= pOutl
->GetParagraphCount();
242 pOutlinerView
->SelectRange( 0, (USHORT
) nParaCount
);
248 case SID_PRESENTATION
:
249 case SID_REHEARSE_TIMINGS
:
251 pOlView
->PrepareClose();
253 Reference
< XPresentation2
> xPresentation( GetDoc()->getPresentation() );
254 if( xPresentation
.is() )
256 if( ( SID_REHEARSE_TIMINGS
!= rReq
.GetSlot() ) )
257 xPresentation
->start();
259 xPresentation
->rehearseTimings();
267 ::Outliner
* pOutl
= pOutlinerView
->GetOutliner();
268 ULONG nCntrl
= pOutl
->GetControlWord();
270 if ( !(nCntrl
& EE_CNTRL_NOCOLORS
) )
272 // Farbansicht ist eingeschaltet: ausschalten
273 pOutl
->SetControlWord(nCntrl
| EE_CNTRL_NOCOLORS
);
277 // Farbansicht ist ausgeschaltet: einschalten
278 pOutl
->SetControlWord(nCntrl
& ~EE_CNTRL_NOCOLORS
);
282 Invalidate( SID_COLORVIEW
);
289 case SID_STYLE_UPDATE_BY_EXAMPLE
:
293 SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
301 case SID_PRESENTATION_DLG
:
303 SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
308 case SID_CUSTOMSHOW_DLG
:
310 SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
316 if(HasCurrentFunction())
317 GetCurrentFunction()->Activate();
319 Invalidate( SID_OUTLINE_COLLAPSE_ALL
);
320 Invalidate( SID_OUTLINE_COLLAPSE
);
321 Invalidate( SID_OUTLINE_EXPAND_ALL
);
322 Invalidate( SID_OUTLINE_EXPAND
);
324 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
325 rBindings
.Invalidate( SID_OUTLINE_LEFT
);
326 rBindings
.Invalidate( SID_OUTLINE_RIGHT
);
327 rBindings
.Invalidate( SID_OUTLINE_UP
);
328 rBindings
.Invalidate( SID_OUTLINE_DOWN
);
330 Invalidate( SID_OUTLINE_FORMAT
);
331 Invalidate( SID_COLORVIEW
);
333 Invalidate(SID_COPY
);
334 Invalidate(SID_PASTE
);
337 void OutlineViewShell::FuTemporaryModify(SfxRequest
&rReq
)
339 OutlineViewModelChangeGuard
aGuard( *pOlView
);
341 DeactivateCurrentFunction();
343 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow( GetActiveWindow() );
344 USHORT nSId
= rReq
.GetSlot();
348 case SID_HYPERLINK_SETLINK
:
350 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
354 SvxHyperlinkItem
* pHLItem
=
355 (SvxHyperlinkItem
*) &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
.nStartPos
<= aSel
.nEndPos
)
363 aSel
.nEndPos
= aSel
.nStartPos
+ 1;
365 aSel
.nStartPos
= aSel
.nEndPos
+ 1;
366 pOutlinerView
->SetSelection( aSel
);
374 case FN_INSERT_SOFT_HYPHEN
:
375 case FN_INSERT_HARDHYPHEN
:
376 case FN_INSERT_HARD_SPACE
:
377 case SID_INSERT_RLM
:
378 case SID_INSERT_LRM
:
379 case SID_INSERT_ZWNBSP
:
380 case SID_INSERT_ZWSP
:
383 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
388 case SID_OUTLINE_BULLET
:
390 SetCurrentFunction( FuOutlineBullet::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
397 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
405 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
412 SetCurrentFunction( FuInsertFile::Create(this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
417 case SID_PRESENTATIONOBJECT
:
419 SetCurrentFunction( FuPresentationObjects::Create(this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
424 case SID_SET_DEFAULT
:
426 // 1. Selektion merken (kriegt die eselige EditEngine nicht selbst
428 // 2. Update auf False (sonst flackert's noch staerker
429 // an allen selektierten Absaetzen:
430 // a. deren Vorlage nochmal setzen, um absatzweite harte Attribute
432 // b. harte Zeichenattribute loeschen
433 // 3. Update auf True und Selektion wieder setzen
435 ESelection aEsel= pOutlinerView->GetSelection();
436 Outliner* pOutl = pOutlinerView->GetOutliner();
437 pOutl->SetUpdateMode(FALSE);
438 List* pSelectedParas = pOutlinerView->CreateSelectionList();
439 Paragraph* pPara = (Paragraph*)pSelectedParas->First();
442 ULONG nParaPos = pOutl->GetAbsPos(pPara);
444 SfxStyleFamily aFamily;
445 pOutl->GetStyleSheet(nParaPos, aName, aFamily);
446 pOutl->SetStyleSheet(nParaPos, aName, aFamily);
447 pOutl->QuickRemoveCharAttribs(nParaPos);
448 pPara = (Paragraph*)pSelectedParas->Next();
450 delete pSelectedParas;
451 pOutl->SetUpdateMode(TRUE);
452 pOutlinerView->SetSelection(aEsel);
454 pOutlinerView
->RemoveAttribs(TRUE
); // TRUE = auch Absatzattribute
460 case SID_SUMMARY_PAGE
:
462 pOlView
->SetSelectedPages();
463 SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
464 pOlView
->GetOutliner()->Clear();
465 pOlView
->FillOutliner();
466 pOlView
->GetActualPage();
471 case SID_EXPAND_PAGE
:
473 pOlView
->SetSelectedPages();
474 SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), pOlView
, GetDoc(), rReq
) );
475 pOlView
->GetOutliner()->Clear();
476 pOlView
->FillOutliner();
477 pOlView
->GetActualPage();
482 case SID_INSERT_FLD_DATE_FIX
:
483 case SID_INSERT_FLD_DATE_VAR
:
484 case SID_INSERT_FLD_TIME_FIX
:
485 case SID_INSERT_FLD_TIME_VAR
:
486 case SID_INSERT_FLD_AUTHOR
:
487 case SID_INSERT_FLD_PAGE
:
488 case SID_INSERT_FLD_PAGES
:
489 case SID_INSERT_FLD_FILE
:
491 SvxFieldItem
* pFieldItem
= 0;
495 case SID_INSERT_FLD_DATE_FIX
:
496 pFieldItem
= new SvxFieldItem(
497 SvxDateField( Date(), SVXDATETYPE_FIX
), EE_FEATURE_FIELD
);
500 case SID_INSERT_FLD_DATE_VAR
:
501 pFieldItem
= new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD
);
504 case SID_INSERT_FLD_TIME_FIX
:
505 pFieldItem
= new SvxFieldItem(
506 SvxExtTimeField( Time(), SVXTIMETYPE_FIX
), EE_FEATURE_FIELD
);
509 case SID_INSERT_FLD_TIME_VAR
:
510 pFieldItem
= new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD
);
513 case SID_INSERT_FLD_AUTHOR
:
515 SvtUserOptions aUserOptions
;
516 pFieldItem
= new SvxFieldItem(
518 aUserOptions
.GetFirstName(), aUserOptions
.GetLastName(), aUserOptions
.GetID() )
519 , EE_FEATURE_FIELD
);
523 case SID_INSERT_FLD_PAGE
:
524 pFieldItem
= new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD
);
527 case SID_INSERT_FLD_PAGES
:
528 pFieldItem
= new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD
);
531 case SID_INSERT_FLD_FILE
:
534 if( GetDocSh()->HasName() )
535 aName
= GetDocSh()->GetMedium()->GetName();
537 // aName = GetDocSh()->GetName();
538 pFieldItem
= new SvxFieldItem( SvxExtFileField( aName
), EE_FEATURE_FIELD
);
543 const SvxFieldItem
* pOldFldItem
= pOutlinerView
->GetFieldAtSelection();
545 if( pOldFldItem
&& ( pOldFldItem
->GetField()->ISA( SvxURLField
) ||
546 pOldFldItem
->GetField()->ISA( SvxDateField
) ||
547 pOldFldItem
->GetField()->ISA( SvxTimeField
) ||
548 pOldFldItem
->GetField()->ISA( SvxExtTimeField
) ||
549 pOldFldItem
->GetField()->ISA( SvxExtFileField
) ||
550 pOldFldItem
->GetField()->ISA( SvxAuthorField
) ||
551 pOldFldItem
->GetField()->ISA( SvxPageField
) ||
552 pOldFldItem
->GetField()->ISA( SvxPagesField
)) )
554 // Feld selektieren, so dass es beim Insert geloescht wird
555 ESelection aSel
= pOutlinerView
->GetSelection();
556 if( aSel
.nStartPos
== aSel
.nEndPos
)
558 pOutlinerView
->SetSelection( aSel
);
562 pOutlinerView
->InsertField( *pFieldItem
);
571 case SID_MODIFY_FIELD
:
573 const SvxFieldItem
* pFldItem
= pOutlinerView
->GetFieldAtSelection();
575 if( pFldItem
&& (pFldItem
->GetField()->ISA( SvxDateField
) ||
576 pFldItem
->GetField()->ISA( SvxAuthorField
) ||
577 pFldItem
->GetField()->ISA( SvxExtFileField
) ||
578 pFldItem
->GetField()->ISA( SvxExtTimeField
) ) )
581 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
582 AbstractSdModifyFieldDlg
* pDlg
= pFact
? pFact
->CreateSdModifyFieldDlg(GetActiveWindow(), pFldItem
->GetField(), pOutlinerView
->GetAttribs() ) : 0;
583 if( pDlg
&& (pDlg
->Execute() == RET_OK
) )
585 SvxFieldData
* pField
= pDlg
->GetField();
588 SvxFieldItem
aFieldItem( *pField
, EE_FEATURE_FIELD
);
589 //pOLV->DeleteSelected(); <-- fehlt leider !
590 // Feld selektieren, so dass es beim Insert geloescht wird
591 ESelection aSel
= pOutlinerView
->GetSelection();
593 if( aSel
.nStartPos
== aSel
.nEndPos
)
598 pOutlinerView
->SetSelection( aSel
);
600 pOutlinerView
->InsertField( aFieldItem
);
602 // Selektion wird wieder in den Ursprungszustand gebracht
605 pOutlinerView
->SetSelection( aSel
);
610 SfxItemSet
aSet( pDlg
->GetItemSet() );
613 pOutlinerView
->SetAttribs( aSet
);
615 ::Outliner
* pOutliner
= pOutlinerView
->GetOutliner();
617 pOutliner
->UpdateFields();
629 if(HasCurrentFunction())
630 GetCurrentFunction()->Activate();
632 Invalidate( SID_OUTLINE_COLLAPSE_ALL
);
633 Invalidate( SID_OUTLINE_COLLAPSE
);
634 Invalidate( SID_OUTLINE_EXPAND_ALL
);
635 Invalidate( SID_OUTLINE_EXPAND
);
637 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
638 rBindings
.Invalidate( SID_OUTLINE_LEFT
);
639 rBindings
.Invalidate( SID_OUTLINE_RIGHT
);
640 rBindings
.Invalidate( SID_OUTLINE_UP
);
641 rBindings
.Invalidate( SID_OUTLINE_DOWN
);
643 Invalidate( SID_OUTLINE_FORMAT
);
644 Invalidate( SID_COLORVIEW
);
646 Invalidate(SID_COPY
);
647 Invalidate(SID_PASTE
);
651 } // end of namespace sd