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 "ViewShell.hxx"
22 #include "ViewShellImplementation.hxx"
24 #include <com/sun/star/embed/EmbedStates.hpp>
25 #include "ViewShellBase.hxx"
26 #include "ShellFactory.hxx"
27 #include "DrawController.hxx"
28 #include "LayerTabBar.hxx"
30 #include <sfx2/viewfrm.hxx>
31 #include <sfx2/bindings.hxx>
32 #include <sfx2/dispatch.hxx>
33 #include <vcl/scrbar.hxx>
34 #include <svl/eitem.hxx>
35 #include <svx/ruler.hxx>
36 #include <svx/svxids.hrc>
37 #include <svx/fmshell.hxx>
38 #include "WindowUpdater.hxx"
39 #include "GraphicViewShell.hxx"
40 #include <sfx2/childwin.hxx>
45 #include "strings.hrc"
46 #include "res_bmp.hrc"
47 #include "OutlineView.hxx"
49 #include "sdresid.hxx"
50 #include "DrawDocShell.hxx"
51 #include "slideshow.hxx"
52 #include "drawdoc.hxx"
54 #include "zoomlist.hxx"
55 #include "FrameView.hxx"
56 #include "optsitem.hxx"
57 #include "BezierObjectBar.hxx"
58 #include "TextObjectBar.hxx"
59 #include "GraphicObjectBar.hxx"
60 #include "MediaObjectBar.hxx"
61 #include "ViewShellManager.hxx"
62 #include "FormShellManager.hxx"
63 #include <svx/dialogs.hrc>
64 #include <svx/extrusionbar.hxx>
65 #include <svx/fontworkbar.hxx>
66 #include <svx/svdoutl.hxx>
67 #include <tools/diagnose_ex.h>
69 #include <svl/slstitm.hxx>
70 #include <sfx2/request.hxx>
71 #include "SpellDialogChildWindow.hxx"
73 #include <basegfx/tools/zoomtools.hxx>
78 #include <editeng/numitem.hxx>
79 #include <editeng/eeitem.hxx>
80 #include <svl/poolitem.hxx>
83 namespace sd
{ namespace ui
{ namespace table
{
84 extern SfxShell
* CreateTableObjectBar( ViewShell
& rShell
, ::sd::View
* pView
);
87 using namespace ::com::sun::star
;
88 using namespace ::com::sun::star::uno
;
89 using namespace ::com::sun::star::presentation
;
93 class ViewShellObjectBarFactory
94 : public ::sd::ShellFactory
<SfxShell
>
97 ViewShellObjectBarFactory (::sd::ViewShell
& rViewShell
);
98 virtual ~ViewShellObjectBarFactory (void);
99 virtual SfxShell
* CreateShell (
101 ::Window
* pParentWindow
,
102 ::sd::FrameView
* pFrameView
);
103 virtual void ReleaseShell (SfxShell
* pShell
);
105 ::sd::ViewShell
& mrViewShell
;
106 /** This cache holds the already created object bars.
108 typedef ::std::map
< ::sd::ShellId
,SfxShell
*> ShellCache
;
109 ShellCache maShellCache
;
113 } // end of anonymous namespace
118 sal_Bool
ViewShell::IsPageFlipMode(void) const
120 return this->ISA(DrawViewShell
) && mpContentWindow
.get() != NULL
&&
121 mpContentWindow
->GetVisibleHeight() >= 1.0;
124 SfxViewFrame
* ViewShell::GetViewFrame (void) const
126 const SfxViewShell
* pViewShell
= GetViewShell();
127 if (pViewShell
!= NULL
)
129 return pViewShell
->GetViewFrame();
133 OSL_ASSERT (GetViewShell()!=NULL
);
139 /// declare SFX-Slotmap and standard interface
140 TYPEINIT1(ViewShell
, SfxShell
);
143 ViewShell::ViewShell( SfxViewFrame
*, ::Window
* pParentWindow
, ViewShellBase
& rViewShellBase
, bool bAllowCenter
)
144 : SfxShell(&rViewShellBase
)
145 , mbCenterAllowed(bAllowCenter
)
146 , mpParentWindow(pParentWindow
)
151 ViewShell::~ViewShell()
153 // Keep the content window from accessing in its destructor the
156 mpContentWindow
->SetViewShell(NULL
);
160 mpLayerTabBar
.reset();
162 if (mpImpl
->mpSubShellFactory
.get() != NULL
)
163 GetViewShellBase().GetViewShellManager()->RemoveSubShellFactory(
164 this,mpImpl
->mpSubShellFactory
);
168 OSL_TRACE("destroying mpContentWindow at %x with parent %x", mpContentWindow
.get(),
169 mpContentWindow
->GetParent());
170 mpContentWindow
.reset();
176 * common initialization part of both constructors
178 void ViewShell::construct(void)
185 mbStartShowWithDialog
= sal_False
;
186 mnPrintedHandoutPageNum
= 1;
187 mnPrintedHandoutPageCount
= 0;
188 mpWindowUpdater
.reset( new ::sd::WindowUpdater() );
189 mpImpl
.reset(new Implementation(*this));
190 meShellType
= ST_NONE
;
192 OSL_ASSERT (GetViewShell()!=NULL
);
194 if (IsMainViewShell())
195 GetDocSh()->Connect (this);
197 mpZoomList
= new ZoomList( this );
199 mpContentWindow
.reset(new ::sd::Window(GetParentWindow()));
200 SetActiveWindow (mpContentWindow
.get());
202 GetParentWindow()->SetBackground (Wallpaper());
203 mpContentWindow
->SetBackground (Wallpaper());
204 mpContentWindow
->SetCenterAllowed(mbCenterAllowed
);
205 mpContentWindow
->SetViewShell(this);
206 mpContentWindow
->SetPosSizePixel(
207 GetParentWindow()->GetPosPixel(),GetParentWindow()->GetSizePixel());
209 if ( ! GetDocSh()->IsPreview())
211 // Create scroll bars and the filler between the scroll bars.
212 mpHorizontalScrollBar
.reset (new ScrollBar(GetParentWindow(), WinBits(WB_HSCROLL
| WB_DRAG
)));
213 mpHorizontalScrollBar
->EnableRTL (sal_False
);
214 mpHorizontalScrollBar
->SetRange(Range(0, 32000));
215 mpHorizontalScrollBar
->SetScrollHdl(LINK(this, ViewShell
, HScrollHdl
));
217 mpVerticalScrollBar
.reset (new ScrollBar(GetParentWindow(), WinBits(WB_VSCROLL
| WB_DRAG
)));
218 mpVerticalScrollBar
->SetRange(Range(0, 32000));
219 mpVerticalScrollBar
->SetScrollHdl(LINK(this, ViewShell
, VScrollHdl
));
221 mpScrollBarBox
.reset(new ScrollBarBox(GetParentWindow(), WB_SIZEABLE
));
224 OUString
aName( "ViewShell" );
227 GetDoc()->StartOnlineSpelling(sal_False
);
229 mpWindowUpdater
->SetViewShell (*this);
230 mpWindowUpdater
->SetDocument (GetDoc());
232 // Re-initialize the spell dialog.
233 ::sd::SpellDialogChildWindow
* pSpellDialog
=
234 static_cast< ::sd::SpellDialogChildWindow
*> (
235 GetViewFrame()->GetChildWindow (
236 ::sd::SpellDialogChildWindow::GetChildWindowId()));
237 if (pSpellDialog
!= NULL
)
238 pSpellDialog
->InvalidateSpellDialog();
240 // Register the sub shell factory.
241 mpImpl
->mpSubShellFactory
.reset(new ViewShellObjectBarFactory(*this));
242 GetViewShellBase().GetViewShellManager()->AddSubShellFactory(this,mpImpl
->mpSubShellFactory
);
245 void ViewShell::doShow(void)
247 mpContentWindow
->Show();
248 static_cast< ::Window
*>(mpContentWindow
.get())->Resize();
249 OSL_TRACE("content window has size %d %d",
250 mpContentWindow
->GetSizePixel().Width(),
251 mpContentWindow
->GetSizePixel().Height());
253 if ( ! GetDocSh()->IsPreview())
256 mpHorizontalScrollBar
->Show();
258 mpVerticalScrollBar
->Show();
260 mpVerticalScrollBar
->GetSizePixel().Width(),
261 mpHorizontalScrollBar
->GetSizePixel().Height());
263 mpScrollBarBox
->Show();
266 GetParentWindow()->Show();
269 void ViewShell::Init (bool bIsMainViewShell
)
271 mpImpl
->mbIsInitialized
= true;
272 SetIsMainViewShell(bIsMainViewShell
);
273 if (bIsMainViewShell
)
274 SetActiveWindow (mpContentWindow
.get());
280 void ViewShell::Exit (void)
282 sd::View
* pView
= GetView();
283 if (pView
!=NULL
&& pView
->IsTextEdit())
285 pView
->SdrEndTextEdit();
289 Deactivate (sal_True
);
291 if (IsMainViewShell())
293 GetDocSh()->Disconnect(this);
296 SetIsMainViewShell(false);
303 * set focus to working window
305 void ViewShell::Activate(sal_Bool bIsMDIActivate
)
307 // Do not forward to SfxShell::Activate()
309 /* According to MI, nobody is allowed to call GrabFocus, who does not
310 exactly know from which window the focus is grabbed. Since Activate()
311 is sent sometimes asynchronous, it can happen, that the wrong window
314 if (mpHorizontalRuler
.get() != NULL
)
315 mpHorizontalRuler
->SetActive(sal_True
);
316 if (mpVerticalRuler
.get() != NULL
)
317 mpVerticalRuler
->SetActive(sal_True
);
321 // thus, the Navigator will also get a current status
322 SfxBoolItem
aItem( SID_NAVIGATOR_INIT
, sal_True
);
323 if (GetDispatcher() != NULL
)
324 GetDispatcher()->Execute(
326 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
,
330 SfxViewShell
* pViewShell
= GetViewShell();
331 OSL_ASSERT (pViewShell
!=NULL
);
332 SfxBindings
& rBindings
= pViewShell
->GetViewFrame()->GetBindings();
333 rBindings
.Invalidate( SID_3D_STATE
, sal_True
, sal_False
);
335 rtl::Reference
< SlideShow
> xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
336 if(xSlideShow
.is() && xSlideShow
->isRunning() )
338 xSlideShow
->activate(GetViewShellBase());
340 if(HasCurrentFunction())
342 GetCurrentFunction()->Activate();
345 if(!GetDocSh()->IsUIActive())
346 UpdatePreview( GetActualPage(), sal_True
);
350 ReadFrameViewData( mpFrameView
);
352 if (IsMainViewShell())
353 GetDocSh()->Connect(this);
356 void ViewShell::UIActivating( SfxInPlaceClient
* )
358 OSL_ASSERT (GetViewShell()!=NULL
);
359 GetViewShellBase().GetToolBarManager()->ToolBarsDestroyed();
364 void ViewShell::UIDeactivated( SfxInPlaceClient
* )
366 OSL_ASSERT (GetViewShell()!=NULL
);
367 GetViewShellBase().GetToolBarManager()->ToolBarsDestroyed();
369 GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this, *GetDrawView());
373 void ViewShell::Deactivate(sal_Bool bIsMDIActivate
)
375 // remove view from a still active drag'n'drop session
376 SdTransferable
* pDragTransferable
= SD_MOD()->pTransferDrag
;
378 if (IsMainViewShell())
379 GetDocSh()->Disconnect(this);
381 if( pDragTransferable
)
382 pDragTransferable
->SetView( NULL
);
384 OSL_ASSERT (GetViewShell()!=NULL
);
386 // remember view attributes of FrameView
387 WriteFrameViewData();
391 rtl::Reference
< SlideShow
> xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
392 if(xSlideShow
.is() && xSlideShow
->isRunning() )
394 xSlideShow
->deactivate(GetViewShellBase());
396 if(HasCurrentFunction())
398 GetCurrentFunction()->Deactivate();
402 if (mpHorizontalRuler
.get() != NULL
)
403 mpHorizontalRuler
->SetActive(sal_False
);
404 if (mpVerticalRuler
.get() != NULL
)
405 mpVerticalRuler
->SetActive(sal_False
);
406 // Do not forward to SfxShell::Deactivate()
412 void ViewShell::Shutdown (void)
420 sal_Bool
ViewShell::KeyInput(const KeyEvent
& rKEvt
, ::sd::Window
* pWin
)
422 sal_Bool
bReturn(sal_False
);
426 SetActiveWindow(pWin
);
431 // give key input first to SfxViewShell to give CTRL+Key
432 // (e.g. CTRL+SHIFT+'+', to front) priority.
433 OSL_ASSERT (GetViewShell()!=NULL
);
434 bReturn
= (sal_Bool
)GetViewShell()->KeyInput(rKEvt
);
439 rtl::Reference
< SlideShow
> xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
440 if(xSlideShow
.is() && xSlideShow
->isRunning())
442 bReturn
= xSlideShow
->keyInput(rKEvt
);
446 bool bConsumed
= false;
448 bConsumed
= GetView()->getSmartTags().KeyInput(rKEvt
);
453 rtl::Reference
< sdr::SelectionController
> xSelectionController( GetView()->getSelectionController() );
454 if( !xSelectionController
.is() || !xSelectionController
->onKeyInput( rKEvt
, pWin
) )
456 if(HasCurrentFunction())
457 bReturn
= GetCurrentFunction()->KeyInput(rKEvt
);
467 if(!bReturn
&& GetActiveWindow())
469 KeyCode aKeyCode
= rKEvt
.GetKeyCode();
471 if (aKeyCode
.IsMod1() && aKeyCode
.IsShift()
472 && aKeyCode
.GetCode() == KEY_R
)
483 void ViewShell::MouseButtonDown(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
)
485 // We have to lock tool bar updates while the mouse button is pressed in
486 // order to prevent the shape under the mouse to be moved (this happens
487 // when the number of docked tool bars changes as result of a changed
488 // selection; this changes the window size and thus the mouse position
489 // in model coordinates: with respect to model coordinates the mouse
491 OSL_ASSERT(mpImpl
->mpUpdateLockForMouse
.expired());
492 mpImpl
->mpUpdateLockForMouse
= ViewShell::Implementation::ToolBarManagerLock::Create(
493 GetViewShellBase().GetToolBarManager());
495 if ( pWin
&& !pWin
->HasFocus() )
498 SetActiveWindow(pWin
);
501 // insert MouseEvent into E3dView
502 if (GetView() != NULL
)
503 GetView()->SetMouseEvent(rMEvt
);
505 bool bConsumed
= false;
507 bConsumed
= GetView()->getSmartTags().MouseButtonDown( rMEvt
);
511 rtl::Reference
< sdr::SelectionController
> xSelectionController( GetView()->getSelectionController() );
512 if( !xSelectionController
.is() || !xSelectionController
->onMouseButtonDown( rMEvt
, pWin
) )
514 if(HasCurrentFunction())
516 GetCurrentFunction()->MouseButtonDown(rMEvt
);
523 void ViewShell::MouseMove(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
)
525 if (rMEvt
.IsLeaveWindow())
527 if ( ! mpImpl
->mpUpdateLockForMouse
.expired())
529 ::boost::shared_ptr
<ViewShell::Implementation::ToolBarManagerLock
> pLock(
530 mpImpl
->mpUpdateLockForMouse
);
531 if (pLock
.get() != NULL
)
538 SetActiveWindow(pWin
);
541 // insert MouseEvent into E3dView
542 if (GetView() != NULL
)
543 GetView()->SetMouseEvent(rMEvt
);
545 if(HasCurrentFunction())
547 rtl::Reference
< sdr::SelectionController
> xSelectionController( GetView()->getSelectionController() );
548 if( !xSelectionController
.is() || !xSelectionController
->onMouseMove( rMEvt
, pWin
) )
550 if(HasCurrentFunction())
551 GetCurrentFunction()->MouseMove(rMEvt
);
557 void ViewShell::MouseButtonUp(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
)
561 SetActiveWindow(pWin
);
564 // insert MouseEvent into E3dView
565 if (GetView() != NULL
)
566 GetView()->SetMouseEvent(rMEvt
);
568 if( HasCurrentFunction())
570 rtl::Reference
< sdr::SelectionController
> xSelectionController( GetView()->getSelectionController() );
571 if( !xSelectionController
.is() || !xSelectionController
->onMouseButtonUp( rMEvt
, pWin
) )
573 if(HasCurrentFunction())
574 GetCurrentFunction()->MouseButtonUp(rMEvt
);
578 if ( ! mpImpl
->mpUpdateLockForMouse
.expired())
580 ::boost::shared_ptr
<ViewShell::Implementation::ToolBarManagerLock
> pLock(
581 mpImpl
->mpUpdateLockForMouse
);
582 if (pLock
.get() != NULL
)
589 void ViewShell::Command(const CommandEvent
& rCEvt
, ::sd::Window
* pWin
)
591 sal_Bool bDone
= HandleScrollCommand (rCEvt
, pWin
);
595 if( rCEvt
.GetCommand() == COMMAND_INPUTLANGUAGECHANGE
)
597 //#i42732# update state of fontname if input language changes
598 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONT
);
599 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT
);
603 bool bConsumed
= false;
606 bConsumed
= GetView()->getSmartTags().Command(rCEvt
);
609 if( !bConsumed
&& HasCurrentFunction())
611 GetCurrentFunction()->Command(rCEvt
);
617 long ViewShell::Notify(NotifyEvent
& rNEvt
, ::sd::Window
* pWin
)
619 // handle scroll commands when they arrived at child windows
620 long nRet
= sal_False
;
621 if( rNEvt
.GetType() == EVENT_COMMAND
)
623 // note: dynamic_cast is not possible as GetData() returns a void*
624 CommandEvent
* pCmdEvent
= reinterpret_cast< CommandEvent
* >(rNEvt
.GetData());
625 nRet
= HandleScrollCommand(*pCmdEvent
, pWin
);
631 bool ViewShell::HandleScrollCommand(const CommandEvent
& rCEvt
, ::sd::Window
* pWin
)
635 switch( rCEvt
.GetCommand() )
639 Reference
< XSlideShowController
> xSlideShowController( SlideShow::GetSlideShowController(GetViewShellBase() ) );
640 if( xSlideShowController
.is() )
642 // We ignore zooming with control+mouse wheel.
643 const CommandWheelData
* pData
= rCEvt
.GetWheelData();
644 if( pData
&& !pData
->GetModifier() && ( pData
->GetMode() == COMMAND_WHEEL_SCROLL
) && !pData
->IsHorz() )
646 long nDelta
= pData
->GetDelta();
649 xSlideShowController
->gotoPreviousSlide();
651 else if( nDelta
< 0 )
653 xSlideShowController
->gotoNextEffect();
659 // fall through when not running slideshow
660 case COMMAND_STARTAUTOSCROLL
:
661 case COMMAND_AUTOSCROLL
:
663 const CommandWheelData
* pData
= rCEvt
.GetWheelData();
669 if( !GetDocSh()->IsUIActive() )
671 const long nOldZoom
= GetActiveWindow()->GetZoom();
674 if( pData
->GetDelta() < 0L )
675 nNewZoom
= std::max( (long) pWin
->GetMinZoom(), basegfx::zoomtools::zoomOut( nOldZoom
));
677 nNewZoom
= std::min( (long) pWin
->GetMaxZoom(), basegfx::zoomtools::zoomIn( nOldZoom
));
680 Invalidate( SID_ATTR_ZOOM
);
681 Invalidate( SID_ATTR_ZOOMSLIDER
);
688 if( mpContentWindow
.get() == pWin
)
690 sal_uLong nScrollLines
= pData
->GetScrollLines();
692 nScrollLines
= COMMAND_WHEEL_PAGESCROLL
;
693 CommandWheelData
aWheelData( pData
->GetDelta(),pData
->GetNotchDelta(),
694 nScrollLines
,pData
->GetMode(),pData
->GetModifier(),pData
->IsHorz() );
695 CommandEvent
aReWrite( rCEvt
.GetMousePosPixel(),rCEvt
.GetCommand(),
696 rCEvt
.IsMouseEvent(),(const void *) &aWheelData
);
697 bDone
= pWin
->HandleScrollCommand( aReWrite
,
698 mpHorizontalScrollBar
.get(),
699 mpVerticalScrollBar
.get()) == sal_True
;
715 void ViewShell::SetupRulers (void)
717 if(mbHasRulers
&& (mpContentWindow
.get() != NULL
) && !SlideShow::IsRunning(GetViewShellBase()))
721 if ( mpVerticalRuler
.get() == NULL
)
723 mpVerticalRuler
.reset(CreateVRuler(GetActiveWindow()));
724 if ( mpVerticalRuler
.get() != NULL
)
726 nHRulerOfs
= mpVerticalRuler
->GetSizePixel().Width();
727 mpVerticalRuler
->SetActive(sal_True
);
728 mpVerticalRuler
->Show();
731 if ( mpHorizontalRuler
.get() == NULL
)
733 mpHorizontalRuler
.reset(CreateHRuler(GetActiveWindow(), sal_True
));
734 if ( mpHorizontalRuler
.get() != NULL
)
736 mpHorizontalRuler
->SetWinPos(nHRulerOfs
);
737 mpHorizontalRuler
->SetActive(sal_True
);
738 mpHorizontalRuler
->Show();
744 const SfxPoolItem
* ViewShell::GetNumBulletItem(SfxItemSet
& aNewAttr
, sal_uInt16
& nNumItemId
)
746 const SfxPoolItem
* pTmpItem
= NULL
;
748 if(aNewAttr
.GetItemState(nNumItemId
, sal_False
, &pTmpItem
) == SFX_ITEM_SET
)
754 nNumItemId
= aNewAttr
.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
);
755 SfxItemState eState
= aNewAttr
.GetItemState(nNumItemId
, sal_False
, &pTmpItem
);
756 if (eState
== SFX_ITEM_SET
)
760 sal_Bool bOutliner
= sal_False
;
761 sal_Bool bTitle
= sal_False
;
765 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
766 const sal_uInt32 nCount
= rMarkList
.GetMarkCount();
768 for(sal_uInt32 nNum
= 0; nNum
< nCount
; nNum
++)
770 SdrObject
* pObj
= rMarkList
.GetMark(nNum
)->GetMarkedSdrObj();
771 if( pObj
->GetObjInventor() == SdrInventor
)
773 switch(pObj
->GetObjIdentifier())
778 case OBJ_OUTLINETEXT
:
779 bOutliner
= sal_True
;
786 const SvxNumBulletItem
*pItem
= NULL
;
789 SfxStyleSheetBasePool
* pSSPool
= mpView
->GetDocSh()->GetStyleSheetPool();
790 String
aStyleName((SdResId(STR_LAYOUT_OUTLINE
)));
791 aStyleName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) );
792 SfxStyleSheetBase
* pFirstStyleSheet
= pSSPool
->Find( aStyleName
, SD_STYLE_FAMILY_PSEUDO
);
793 if( pFirstStyleSheet
)
794 pFirstStyleSheet
->GetItemSet().GetItemState(EE_PARA_NUMBULLET
, sal_False
, (const SfxPoolItem
**)&pItem
);
798 pItem
= (SvxNumBulletItem
*) aNewAttr
.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET
);
800 aNewAttr
.Put(*pItem
, EE_PARA_NUMBULLET
);
802 if(bTitle
&& aNewAttr
.GetItemState(EE_PARA_NUMBULLET
,sal_True
) == SFX_ITEM_ON
)
804 SvxNumBulletItem
* pBulletItem
= (SvxNumBulletItem
*)aNewAttr
.GetItem(EE_PARA_NUMBULLET
,sal_True
);
805 SvxNumRule
* pRule
= pBulletItem
->GetNumRule();
808 SvxNumRule
aNewRule( *pRule
);
809 aNewRule
.SetFeatureFlag( NUM_NO_NUMBERS
, sal_True
);
811 SvxNumBulletItem
aNewItem( aNewRule
, EE_PARA_NUMBULLET
);
812 aNewAttr
.Put(aNewItem
);
816 SfxItemState eNumState
= aNewAttr
.GetItemState(nNumItemId
, sal_False
, &pTmpItem
);
817 if (eNumState
== SFX_ITEM_SET
)
826 sal_Bool
ViewShell::HasRuler (void)
834 void ViewShell::Resize (void)
838 if (mpParentWindow
== NULL
)
841 // Make sure that the new size is not degenerate.
842 const Size
aSize (mpParentWindow
->GetSizePixel());
843 if (aSize
.Width()==0 || aSize
.Height()==0)
846 // Remember the new position and size.
847 maViewPos
= Point(0,0);
850 // Rearrange the UI elements to take care of the new position and size.
851 ArrangeGUIElements ();
852 // end of included AdjustPosSizePixel.
854 ::sd::View
* pView
= GetView();
858 pView
->VisAreaChanged(GetActiveWindow());
862 SvBorder
ViewShell::GetBorder (bool )
866 // Horizontal scrollbar.
867 if (mpHorizontalScrollBar
.get()!=NULL
868 && mpHorizontalScrollBar
->IsVisible())
870 aBorder
.Bottom() = maScrBarWH
.Height();
873 // Vertical scrollbar.
874 if (mpVerticalScrollBar
.get()!=NULL
875 && mpVerticalScrollBar
->IsVisible())
877 aBorder
.Right() = maScrBarWH
.Width();
880 // Place horizontal ruler below tab bar.
881 if (mbHasRulers
&& mpContentWindow
.get() != NULL
)
884 if (mpHorizontalRuler
.get() != NULL
)
885 aBorder
.Top() = mpHorizontalRuler
->GetSizePixel().Height();
886 if (mpVerticalRuler
.get() != NULL
)
887 aBorder
.Left() = mpVerticalRuler
->GetSizePixel().Width();
896 void ViewShell::ArrangeGUIElements (void)
898 if (mpImpl
->mbArrangeActive
)
900 mpImpl
->mbArrangeActive
= true;
902 // Calculate border for in-place editing.
903 long nLeft
= maViewPos
.X();
904 long nTop
= maViewPos
.Y();
905 long nRight
= maViewPos
.X() + maViewSize
.Width();
906 long nBottom
= maViewPos
.Y() + maViewSize
.Height();
908 // Horizontal scrollbar.
909 if (mpHorizontalScrollBar
.get()!=NULL
910 && mpHorizontalScrollBar
->IsVisible())
912 int nLocalLeft
= nLeft
;
913 if (mpLayerTabBar
.get()!=NULL
&& mpLayerTabBar
->IsVisible())
914 nLocalLeft
+= mpLayerTabBar
->GetSizePixel().Width();
915 nBottom
-= maScrBarWH
.Height();
916 mpHorizontalScrollBar
->SetPosSizePixel (
917 Point(nLocalLeft
,nBottom
),
918 Size(nRight
-nLocalLeft
-maScrBarWH
.Width(),maScrBarWH
.Height()));
921 // Vertical scrollbar.
922 if (mpVerticalScrollBar
.get()!=NULL
923 && mpVerticalScrollBar
->IsVisible())
925 nRight
-= maScrBarWH
.Width();
926 mpVerticalScrollBar
->SetPosSizePixel (
928 Size (maScrBarWH
.Width(),nBottom
-nTop
));
931 // Filler in the lower right corner.
932 if (mpScrollBarBox
.get() != NULL
)
934 if (mpHorizontalScrollBar
.get()!=NULL
935 && mpHorizontalScrollBar
->IsVisible()
936 && mpVerticalScrollBar
.get()!=NULL
937 && mpVerticalScrollBar
->IsVisible())
939 mpScrollBarBox
->Show();
940 mpScrollBarBox
->SetPosSizePixel(Point(nRight
, nBottom
), maScrBarWH
);
943 mpScrollBarBox
->Hide();
946 // Place horizontal ruler below tab bar.
947 if (mbHasRulers
&& mpContentWindow
.get() != NULL
)
949 if (mpHorizontalRuler
.get() != NULL
)
951 Size aRulerSize
= mpHorizontalRuler
->GetSizePixel();
952 aRulerSize
.Width() = nRight
- nLeft
;
953 mpHorizontalRuler
->SetPosSizePixel (
954 Point(nLeft
,nTop
), aRulerSize
);
955 if (mpVerticalRuler
.get() != NULL
)
956 mpHorizontalRuler
->SetBorderPos(
957 mpVerticalRuler
->GetSizePixel().Width()-1);
958 nTop
+= aRulerSize
.Height();
960 if (mpVerticalRuler
.get() != NULL
)
962 Size aRulerSize
= mpVerticalRuler
->GetSizePixel();
963 aRulerSize
.Height() = nBottom
- nTop
;
964 mpVerticalRuler
->SetPosSizePixel (
965 Point (nLeft
,nTop
), aRulerSize
);
966 nLeft
+= aRulerSize
.Width();
970 rtl::Reference
< SlideShow
> xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
972 // The size of the window of the center pane is set differently from
973 // that of the windows in the docking windows.
974 bool bSlideShowActive
= (xSlideShow
.is() && xSlideShow
->isRunning()) && !xSlideShow
->isFullScreen() && xSlideShow
->getAnimationMode() == ANIMATIONMODE_SHOW
;
975 if ( !bSlideShowActive
)
977 OSL_ASSERT (GetViewShell()!=NULL
);
980 mpContentWindow
->SetPosSizePixel(
982 Size(nRight
-nLeft
,nBottom
-nTop
));
985 // Windows in the center and rulers at the left and top side.
986 maAllWindowRectangle
= Rectangle(
988 Size(maViewSize
.Width()-maScrBarWH
.Width(),
989 maViewSize
.Height()-maScrBarWH
.Height()));
991 if (mpContentWindow
.get() != NULL
)
993 mpContentWindow
->UpdateMapOrigin();
998 mpImpl
->mbArrangeActive
= false;
1004 void ViewShell::SetUIUnit(FieldUnit eUnit
)
1006 // Set unit at horizontal and vertical rulers.
1007 if (mpHorizontalRuler
.get() != NULL
)
1008 mpHorizontalRuler
->SetUnit(eUnit
);
1011 if (mpVerticalRuler
.get() != NULL
)
1012 mpVerticalRuler
->SetUnit(eUnit
);
1016 * set DefTab at horizontal rulers
1018 void ViewShell::SetDefTabHRuler( sal_uInt16 nDefTab
)
1020 if (mpHorizontalRuler
.get() != NULL
)
1021 mpHorizontalRuler
->SetDefTabDist( nDefTab
);
1027 /** Tell the FmFormShell that the view shell is closing. Give it the
1028 oportunity to prevent that.
1030 sal_uInt16
ViewShell::PrepareClose (sal_Bool bUI
, sal_Bool bForBrowsing
)
1032 sal_uInt16 nResult
= sal_True
;
1034 FmFormShell
* pFormShell
= GetViewShellBase().GetFormShellManager()->GetFormShell();
1035 if (pFormShell
!= NULL
)
1036 nResult
= pFormShell
->PrepareClose (bUI
, bForBrowsing
);
1044 void ViewShell::UpdatePreview (SdPage
*, sal_Bool
)
1046 // Do nothing. After the actual preview has been removed,
1047 // OutlineViewShell::UpdatePreview() is the place where something
1048 // useful is still done.
1051 ::svl::IUndoManager
* ViewShell::ImpGetUndoManager (void) const
1053 const ViewShell
* pMainViewShell
= GetViewShellBase().GetMainViewShell().get();
1055 if( pMainViewShell
== 0 )
1056 pMainViewShell
= this;
1058 ::sd::View
* pView
= pMainViewShell
->GetView();
1060 // check for text edit our outline view
1063 if( pMainViewShell
->GetShellType() == ViewShell::ST_OUTLINE
)
1065 OutlineView
* pOlView
= dynamic_cast< OutlineView
* >( pView
);
1068 ::Outliner
* pOutl
= pOlView
->GetOutliner();
1070 return &pOutl
->GetUndoManager();
1073 else if( pView
->IsTextEdit() )
1075 SdrOutliner
* pOL
= pView
->GetTextEditOutliner();
1077 return &pOL
->GetUndoManager();
1082 return GetDocSh()->GetUndoManager();
1090 void ViewShell::ImpGetUndoStrings(SfxItemSet
&rSet
) const
1092 ::svl::IUndoManager
* pUndoManager
= ImpGetUndoManager();
1095 sal_uInt16
nCount(pUndoManager
->GetUndoActionCount());
1099 ::std::vector
< String
> aStringList
;
1101 for (sal_uInt16 a
= 0; a
< nCount
; ++a
)
1103 // generate one String in list per undo step
1104 aStringList
.push_back( String(pUndoManager
->GetUndoActionComment(a
)) );
1108 rSet
.Put(SfxStringListItem(SID_GETUNDOSTRINGS
, &aStringList
));
1112 rSet
.DisableItem(SID_GETUNDOSTRINGS
);
1117 // -----------------------------------------------------------------------------
1119 void ViewShell::ImpGetRedoStrings(SfxItemSet
&rSet
) const
1121 ::svl::IUndoManager
* pUndoManager
= ImpGetUndoManager();
1124 sal_uInt16
nCount(pUndoManager
->GetRedoActionCount());
1128 ::std::vector
< String
> aStringList
;
1131 for( a
= 0; a
< nCount
; a
++)
1133 // generate one String in list per undo step
1134 aStringList
.push_back( String(pUndoManager
->GetRedoActionComment(a
)) );
1138 rSet
.Put(SfxStringListItem(SID_GETREDOSTRINGS
, &aStringList
));
1142 rSet
.DisableItem(SID_GETREDOSTRINGS
);
1147 // -----------------------------------------------------------------------------
1149 void ViewShell::ImpSidUndo(sal_Bool
, SfxRequest
& rReq
)
1151 ::svl::IUndoManager
* pUndoManager
= ImpGetUndoManager();
1152 sal_uInt16
nNumber(1);
1153 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
1157 SfxUInt16Item
* pUIntItem
= (SfxUInt16Item
*)&pReqArgs
->Get(SID_UNDO
);
1158 nNumber
= pUIntItem
->GetValue();
1161 if(nNumber
&& pUndoManager
)
1163 sal_uInt16
nCount(pUndoManager
->GetUndoActionCount());
1164 if(nCount
>= nNumber
)
1168 // when UndoStack is cleared by ModifyPageUndoAction
1169 // the nCount may have changed, so test GetUndoActionCount()
1170 while(nNumber
-- && pUndoManager
->GetUndoActionCount())
1172 pUndoManager
->Undo();
1175 catch( const Exception
& )
1177 // no need to handle. By definition, the UndoManager handled this by clearing the
1182 // refresh rulers, maybe UNDO was move of TAB marker in ruler
1185 Invalidate(SID_ATTR_TABSTOP
);
1189 // This one is corresponding to the default handling
1190 // of SID_UNDO in sfx2
1191 GetViewFrame()->GetBindings().InvalidateAll(sal_False
);
1196 // -----------------------------------------------------------------------------
1198 void ViewShell::ImpSidRedo(sal_Bool
, SfxRequest
& rReq
)
1200 ::svl::IUndoManager
* pUndoManager
= ImpGetUndoManager();
1201 sal_uInt16
nNumber(1);
1202 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
1206 SfxUInt16Item
* pUIntItem
= (SfxUInt16Item
*)&pReqArgs
->Get(SID_REDO
);
1207 nNumber
= pUIntItem
->GetValue();
1210 if(nNumber
&& pUndoManager
)
1212 sal_uInt16
nCount(pUndoManager
->GetRedoActionCount());
1213 if(nCount
>= nNumber
)
1217 // when UndoStack is cleared by ModifyPageRedoAction
1218 // the nCount may have changed, so test GetRedoActionCount()
1219 while(nNumber
-- && pUndoManager
->GetRedoActionCount())
1221 pUndoManager
->Redo();
1224 catch( const Exception
& )
1226 // no need to handle. By definition, the UndoManager handled this by clearing the
1231 // refresh rulers, maybe REDO was move of TAB marker in ruler
1234 Invalidate(SID_ATTR_TABSTOP
);
1238 // This one is corresponding to the default handling
1239 // of SID_UNDO in sfx2
1240 GetViewFrame()->GetBindings().InvalidateAll(sal_False
);
1245 // -----------------------------------------------------------------------------
1247 void ViewShell::ExecReq( SfxRequest
& rReq
)
1249 sal_uInt16 nSlot
= rReq
.GetSlot();
1252 case SID_MAIL_SCROLLBODY_PAGEDOWN
:
1254 FunctionReference
xFunc( GetCurrentFunction() );
1256 ScrollLines( 0, -1 );
1262 case SID_OUTPUT_QUALITY_COLOR
:
1263 case SID_OUTPUT_QUALITY_GRAYSCALE
:
1264 case SID_OUTPUT_QUALITY_BLACKWHITE
:
1265 case SID_OUTPUT_QUALITY_CONTRAST
:
1267 sal_uLong nMode
= OUTPUT_DRAWMODE_COLOR
;
1271 case SID_OUTPUT_QUALITY_COLOR
: nMode
= OUTPUT_DRAWMODE_COLOR
; break;
1272 case SID_OUTPUT_QUALITY_GRAYSCALE
: nMode
= OUTPUT_DRAWMODE_GRAYSCALE
; break;
1273 case SID_OUTPUT_QUALITY_BLACKWHITE
: nMode
= OUTPUT_DRAWMODE_BLACKWHITE
; break;
1274 case SID_OUTPUT_QUALITY_CONTRAST
: nMode
= OUTPUT_DRAWMODE_CONTRAST
; break;
1277 GetActiveWindow()->SetDrawMode( nMode
);
1278 mpFrameView
->SetDrawMode( nMode
);
1280 GetActiveWindow()->Invalidate();
1292 /** This default implemenation returns only an empty reference. See derived
1293 classes for more interesting examples.
1295 ::com::sun::star::uno::Reference
<
1296 ::com::sun::star::accessibility::XAccessible
>
1297 ViewShell::CreateAccessibleDocumentView (::sd::Window
* )
1299 OSL_FAIL("ViewShell::CreateAccessibleDocumentView should not be called!, perhaps Meyers, 3rd edition, Item 9:\n");
1301 return ::com::sun::star::uno::Reference
<
1302 ::com::sun::star::accessibility::XAccessible
> ();
1307 ::sd::WindowUpdater
* ViewShell::GetWindowUpdater (void) const
1309 return mpWindowUpdater
.get();
1315 ViewShellBase
& ViewShell::GetViewShellBase (void) const
1317 return *static_cast<ViewShellBase
*>(GetViewShell());
1323 ViewShell::ShellType
ViewShell::GetShellType (void) const
1331 DrawDocShell
* ViewShell::GetDocSh (void) const
1333 return GetViewShellBase().GetDocShell();
1339 SdDrawDocument
* ViewShell::GetDoc (void) const
1341 return GetViewShellBase().GetDocument();
1344 ErrCode
ViewShell::DoVerb (long )
1346 return ERRCODE_NONE
;
1349 void ViewShell::SetCurrentFunction( const FunctionReference
& xFunction
)
1351 if( mxCurrentFunction
.is() && (mxOldFunction
!= mxCurrentFunction
) )
1352 mxCurrentFunction
->Dispose();
1353 FunctionReference
xTemp( mxCurrentFunction
);
1354 mxCurrentFunction
= xFunction
;
1357 void ViewShell::SetOldFunction(const FunctionReference
& xFunction
)
1359 if( mxOldFunction
.is() && (xFunction
!= mxOldFunction
) && (mxCurrentFunction
!= mxOldFunction
) )
1360 mxOldFunction
->Dispose();
1362 FunctionReference
xTemp( mxOldFunction
);
1363 mxOldFunction
= xFunction
;
1366 /** this method deactivates the current function. If an old function is
1367 saved, this will become activated and current function.
1369 void ViewShell::Cancel()
1371 if(mxCurrentFunction
.is() && (mxCurrentFunction
!= mxOldFunction
))
1373 FunctionReference
xTemp( mxCurrentFunction
);
1374 mxCurrentFunction
.clear();
1375 xTemp
->Deactivate();
1379 if(mxOldFunction
.is())
1381 mxCurrentFunction
= mxOldFunction
;
1382 mxCurrentFunction
->Activate();
1386 void ViewShell::DeactivateCurrentFunction( bool bPermanent
/* == false */ )
1388 if( mxCurrentFunction
.is() )
1390 if(bPermanent
&& (mxOldFunction
== mxCurrentFunction
))
1391 mxOldFunction
.clear();
1393 mxCurrentFunction
->Deactivate();
1394 if( mxCurrentFunction
!= mxOldFunction
)
1395 mxCurrentFunction
->Dispose();
1397 FunctionReference
xTemp( mxCurrentFunction
);
1398 mxCurrentFunction
.clear();
1402 void ViewShell::DisposeFunctions()
1404 if(mxCurrentFunction
.is())
1406 FunctionReference
xTemp( mxCurrentFunction
);
1407 mxCurrentFunction
.clear();
1408 xTemp
->Deactivate();
1412 if(mxOldFunction
.is())
1414 FunctionReference
xTemp( mxOldFunction
);
1415 mxOldFunction
->Dispose();
1416 mxOldFunction
.clear();
1420 bool ViewShell::IsMainViewShell (void) const
1422 return mpImpl
->mbIsMainViewShell
;
1425 void ViewShell::SetIsMainViewShell (bool bIsMainViewShell
)
1427 if (bIsMainViewShell
!= mpImpl
->mbIsMainViewShell
)
1429 mpImpl
->mbIsMainViewShell
= bIsMainViewShell
;
1430 if (bIsMainViewShell
)
1432 GetDocSh()->Connect (this);
1436 GetDocSh()->Disconnect (this);
1444 ::sd::Window
* ViewShell::GetActiveWindow (void) const
1446 return mpActiveWindow
;
1452 void ViewShell::PrePaint()
1459 void ViewShell::Paint (const Rectangle
&, ::sd::Window
* )
1466 void ViewShell::Draw(OutputDevice
&, const Region
&)
1473 ZoomList
* ViewShell::GetZoomList (void)
1481 void ViewShell::ShowUIControls (bool bVisible
)
1483 mpImpl
->mbIsShowingUIControls
= bVisible
;
1487 if (mpHorizontalRuler
.get() != NULL
)
1488 mpHorizontalRuler
->Show( bVisible
);
1490 if (mpVerticalRuler
.get() != NULL
)
1491 mpVerticalRuler
->Show( bVisible
);
1494 if (mpVerticalScrollBar
.get() != NULL
)
1495 mpVerticalScrollBar
->Show( bVisible
);
1497 if (mpHorizontalScrollBar
.get() != NULL
)
1498 mpHorizontalScrollBar
->Show( bVisible
);
1500 if (mpScrollBarBox
.get() != NULL
)
1501 mpScrollBarBox
->Show(bVisible
);
1503 if (mpContentWindow
.get() != NULL
)
1504 mpContentWindow
->Show( bVisible
);
1511 bool ViewShell::RelocateToParentWindow (::Window
* pParentWindow
)
1513 mpParentWindow
= pParentWindow
;
1515 mpParentWindow
->SetBackground (Wallpaper());
1517 if (mpContentWindow
.get() != NULL
)
1518 mpContentWindow
->SetParent(pParentWindow
);
1520 if (mpHorizontalScrollBar
.get() != NULL
)
1521 mpHorizontalScrollBar
->SetParent(mpParentWindow
);
1522 if (mpVerticalScrollBar
.get() != NULL
)
1523 mpVerticalScrollBar
->SetParent(mpParentWindow
);
1524 if (mpScrollBarBox
.get() != NULL
)
1525 mpScrollBarBox
->SetParent(mpParentWindow
);
1532 } // end of namespace sd
1538 //===== ViewShellObjectBarFactory =============================================
1542 ViewShellObjectBarFactory::ViewShellObjectBarFactory (
1543 ::sd::ViewShell
& rViewShell
)
1544 : mrViewShell (rViewShell
)
1551 ViewShellObjectBarFactory::~ViewShellObjectBarFactory (void)
1553 for (ShellCache::iterator
aI(maShellCache
.begin());
1554 aI
!=maShellCache
.end();
1564 SfxShell
* ViewShellObjectBarFactory::CreateShell (
1569 SfxShell
* pShell
= NULL
;
1571 ShellCache::iterator
aI (maShellCache
.find(nId
));
1572 if (aI
== maShellCache
.end() || aI
->second
==NULL
)
1574 ::sd::View
* pView
= mrViewShell
.GetView();
1577 case RID_BEZIER_TOOLBOX
:
1578 pShell
= new ::sd::BezierObjectBar(&mrViewShell
, pView
);
1581 case RID_DRAW_TEXT_TOOLBOX
:
1582 pShell
= new ::sd::TextObjectBar(
1583 &mrViewShell
, mrViewShell
.GetDoc()->GetPool(), pView
);
1586 case RID_DRAW_GRAF_TOOLBOX
:
1587 pShell
= new ::sd::GraphicObjectBar(&mrViewShell
, pView
);
1590 case RID_DRAW_MEDIA_TOOLBOX
:
1591 pShell
= new ::sd::MediaObjectBar(&mrViewShell
, pView
);
1594 case RID_DRAW_TABLE_TOOLBOX
:
1595 pShell
= ::sd::ui::table::CreateTableObjectBar( mrViewShell
, pView
);
1598 case RID_SVX_EXTRUSION_BAR
:
1599 pShell
= new ::svx::ExtrusionBar(
1600 &mrViewShell
.GetViewShellBase());
1603 case RID_SVX_FONTWORK_BAR
:
1604 pShell
= new ::svx::FontworkBar(
1605 &mrViewShell
.GetViewShellBase());
1614 pShell
= aI
->second
;
1622 void ViewShellObjectBarFactory::ReleaseShell (SfxShell
* pShell
)
1628 } // end of anonymous namespace
1630 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */