fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / view / outlnvs2.cxx
blobc3aa7d728c094617fdbcc6439f3a726be96953fe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
27 #include "app.hrc"
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"
44 #include "Window.hxx"
45 #include "fubullet.hxx"
46 #include "fuolbull.hxx"
47 #include "FrameView.hxx"
48 #include "fuzoom.hxx"
49 #include "fuscale.hxx"
50 #include "fuchar.hxx"
51 #include "fuinsfil.hxx"
52 #include "fuprobjs.hxx"
53 #include "futhes.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"
61 #include "sdattr.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;
73 namespace sd {
76 /************************************************************************/
78 /**
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();
89 switch( nSId )
91 case SID_ATTR_ZOOM:
93 const SfxItemSet* pArgs = rReq.GetArgs();
95 if ( pArgs )
97 SvxZoomType eZT = ( ( const SvxZoomItem& ) pArgs->
98 Get( SID_ATTR_ZOOM ) ).GetType();
99 switch( eZT )
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 );
106 break;
107 default:
108 break;
110 rReq.Done();
112 else
114 // open the zoom dialog here
115 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
117 Cancel();
119 break;
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 );
141 Cancel();
142 rReq.Done ();
143 break;
146 case SID_ZOOM_OUT:
148 SetCurrentFunction( FuZoom::Create(this, GetActiveWindow(), pOlView, GetDoc(), rReq) );
149 // ends itself, no need for Cancel()!
150 rReq.Done();
152 break;
154 case SID_SIZE_REAL:
156 SetZoom( 100 );
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 );
162 Cancel();
163 rReq.Done();
165 break;
167 case SID_ZOOM_IN:
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 );
177 Cancel();
178 rReq.Done();
180 break;
182 case SID_OUTLINE_COLLAPSE_ALL:
184 pOutlinerView->CollapseAll();
185 Cancel();
186 rReq.Done();
188 break;
190 case SID_OUTLINE_COLLAPSE:
192 pOutlinerView->Collapse();
193 Cancel();
194 rReq.Done();
196 break;
198 case SID_OUTLINE_EXPAND_ALL:
200 pOutlinerView->ExpandAll();
201 Cancel();
202 rReq.Done();
204 break;
206 case SID_OUTLINE_EXPAND:
208 pOutlinerView->Expand();
209 Cancel();
210 rReq.Done();
212 break;
214 case SID_OUTLINE_FORMAT:
216 ::Outliner* pOutl = pOutlinerView->GetOutliner();
217 pOutl->SetFlatMode( !pOutl->IsFlatMode() );
218 Invalidate( SID_COLORVIEW );
219 Cancel();
220 rReq.Done();
222 break;
224 case SID_SELECTALL:
226 ::Outliner* pOutl = pOlView->GetOutliner();
227 sal_Int32 nParaCount = pOutl->GetParagraphCount();
228 if (nParaCount > 0)
230 pOutlinerView->SelectRange( 0, nParaCount );
232 Cancel();
234 break;
236 case SID_PRESENTATION:
237 case SID_PRESENTATION_CURRENT_SLIDE:
238 case SID_REHEARSE_TIMINGS:
240 pOlView->PrepareClose();
241 ShowSlideShow(rReq);
242 Cancel();
243 rReq.Done();
245 break;
247 case SID_COLORVIEW:
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);
257 else
259 // color view is disabled: enable
260 pOutl->SetControlWord(nCntrl & ~EE_CNTRL_NOCOLORS);
263 InvalidateWindows();
264 Invalidate( SID_COLORVIEW );
265 Cancel();
266 rReq.Done();
268 break;
270 case SID_STYLE_EDIT:
271 case SID_STYLE_UPDATE_BY_EXAMPLE:
273 if( rReq.GetArgs() )
275 SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
276 Cancel();
279 rReq.Ignore ();
281 break;
283 case SID_PRESENTATION_DLG:
285 SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
286 Cancel();
288 break;
290 case SID_CUSTOMSHOW_DLG:
292 SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
293 Cancel();
295 break;
297 case SID_PHOTOALBUM:
299 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
300 VclAbstractDialog* pDlg = pFact ? pFact->CreateSdPhotoAlbumDialog(
301 GetActiveWindow(),
302 GetDoc()) : 0;
304 if (pDlg)
306 pDlg->Execute();
307 delete pDlg;
309 Cancel();
310 rReq.Ignore ();
312 break;
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 );
331 Invalidate(SID_CUT);
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();
354 switch( nSId )
356 case SID_HYPERLINK_SETLINK:
358 const SfxItemSet* pReqArgs = rReq.GetArgs();
360 if (pReqArgs)
362 SvxHyperlinkItem* pHLItem =
363 (SvxHyperlinkItem*) &pReqArgs->Get(SID_HYPERLINK_SETLINK);
365 SvxFieldItem aURLItem(SvxURLField(pHLItem->GetURL(),
366 pHLItem->GetName(),
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;
372 else
373 aSel.nStartPos = aSel.nEndPos + 1;
374 pOutlinerView->SetSelection( aSel );
377 Cancel();
378 rReq.Ignore ();
380 break;
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:
389 case SID_CHARMAP:
391 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
392 Cancel();
394 break;
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 ) );
401 Cancel();
403 break;
405 case SID_THESAURUS:
407 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
408 Cancel();
409 rReq.Ignore ();
411 break;
413 case SID_CHAR_DLG_EFFECT:
414 case SID_CHAR_DLG:
416 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
417 Cancel();
419 break;
421 case SID_INSERTFILE:
423 SetCurrentFunction( FuInsertFile::Create(this, GetActiveWindow(), pOlView, GetDoc(), rReq) );
424 Cancel();
426 break;
428 case SID_PRESENTATIONOBJECT:
430 SetCurrentFunction( FuPresentationObjects::Create(this, GetActiveWindow(), pOlView, GetDoc(), rReq) );
431 Cancel();
433 break;
435 case SID_SET_DEFAULT:
437 pOutlinerView->RemoveAttribs(sal_True); // sal_True = also paragraph attributes
438 Cancel();
439 rReq.Done();
441 break;
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();
450 Cancel();
452 break;
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();
461 Cancel();
463 break;
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;
476 switch( nSId )
478 case SID_INSERT_FLD_DATE_FIX:
479 pFieldItem = new SvxFieldItem(
480 SvxDateField( Date( Date::SYSTEM ), SVXDATETYPE_FIX ), EE_FEATURE_FIELD );
481 break;
483 case SID_INSERT_FLD_DATE_VAR:
484 pFieldItem = new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD );
485 break;
487 case SID_INSERT_FLD_TIME_FIX:
488 pFieldItem = new SvxFieldItem(
489 SvxExtTimeField( Time( Time::SYSTEM ), SVXTIMETYPE_FIX ), EE_FEATURE_FIELD );
490 break;
492 case SID_INSERT_FLD_TIME_VAR:
493 pFieldItem = new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD );
494 break;
496 case SID_INSERT_FLD_AUTHOR:
498 SvtUserOptions aUserOptions;
499 pFieldItem = new SvxFieldItem(
500 SvxAuthorField(
501 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() )
502 , EE_FEATURE_FIELD );
504 break;
506 case SID_INSERT_FLD_PAGE:
507 pFieldItem = new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD );
508 break;
510 case SID_INSERT_FLD_PAGES:
511 pFieldItem = new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD );
512 break;
514 case SID_INSERT_FLD_FILE:
516 String aName;
517 if( GetDocSh()->HasName() )
518 aName = GetDocSh()->GetMedium()->GetName();
519 //else
520 // aName = GetDocSh()->GetName();
521 pFieldItem = new SvxFieldItem( SvxExtFileField( aName ), EE_FEATURE_FIELD );
523 break;
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 )
540 aSel.nEndPos++;
541 pOutlinerView->SetSelection( aSel );
544 if( pFieldItem )
545 pOutlinerView->InsertField( *pFieldItem );
547 delete pFieldItem;
549 Cancel();
550 rReq.Ignore ();
552 break;
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 ) ) )
563 // Dialog...
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();
569 if( pField )
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 )
578 bSel = sal_False;
579 aSel.nEndPos++;
581 pOutlinerView->SetSelection( aSel );
583 pOutlinerView->InsertField( aFieldItem );
585 // reset selection to original state
586 if( !bSel )
587 aSel.nEndPos--;
588 pOutlinerView->SetSelection( aSel );
590 delete pField;
593 SfxItemSet aSet( pDlg->GetItemSet() );
594 if( aSet.Count() )
596 pOutlinerView->SetAttribs( aSet );
598 ::Outliner* pOutliner = pOutlinerView->GetOutliner();
599 if( pOutliner )
600 pOutliner->UpdateFields();
603 delete pDlg;
606 Cancel();
607 rReq.Ignore ();
609 break;
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 );
628 Invalidate(SID_CUT);
629 Invalidate(SID_COPY);
630 Invalidate(SID_PASTE);
634 } // end of namespace sd
636 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */