xref: /aoo41x/main/sd/source/ui/view/viewshel.cxx (revision 2a3f8a0e)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include "ViewShell.hxx"
28 #include "ViewShellImplementation.hxx"
29 
30 #ifndef _COM_SUN_STAR_EMBED_EMBEDSTATE_HPP_
31 #include <com/sun/star/embed/EmbedStates.hpp>
32 #endif
33 #include "ViewShellBase.hxx"
34 #include "ShellFactory.hxx"
35 #include "DrawController.hxx"
36 #include "LayerTabBar.hxx"
37 
38 #include <sfx2/viewfrm.hxx>
39 #include <sfx2/bindings.hxx>
40 #include <sfx2/dispatch.hxx>
41 #ifndef _SCRBAR_HXX //autogen
42 #include <vcl/scrbar.hxx>
43 #endif
44 #include <svl/eitem.hxx>
45 #include <svx/ruler.hxx>
46 #ifndef _SVXIDS_HXX
47 #include <svx/svxids.hrc>
48 #endif
49 #include <svx/fmshell.hxx>
50 #ifndef SD_WINDOW_UPDATER_HXX
51 #include "WindowUpdater.hxx"
52 #endif
53 #include "GraphicViewShell.hxx"
54 #include <sfx2/childwin.hxx>
55 #include <sdxfer.hxx>
56 #include "GraphicViewShell.hxx"
57 #include <sfx2/childwin.hxx>
58 
59 #include "app.hrc"
60 #include "helpids.h"
61 #include "strings.hrc"
62 #include "res_bmp.hrc"
63 #include "OutlineView.hxx"
64 #include "Client.hxx"
65 #include "sdresid.hxx"
66 #include "DrawDocShell.hxx"
67 #include "slideshow.hxx"
68 #include "drawdoc.hxx"
69 #include "sdpage.hxx"
70 #include "zoomlist.hxx"
71 #include "FrameView.hxx"
72 #include "optsitem.hxx"
73 #include "BezierObjectBar.hxx"
74 #include "TextObjectBar.hxx"
75 #include "GraphicObjectBar.hxx"
76 #include "MediaObjectBar.hxx"
77 #include "ViewShellManager.hxx"
78 #include "FormShellManager.hxx"
79 #include <svx/fmshell.hxx>
80 #include <svx/dialogs.hrc>
81 #include <svx/extrusionbar.hxx>
82 #include <svx/fontworkbar.hxx>
83 #include <svx/svdoutl.hxx>
84 #include <tools/diagnose_ex.h>
85 
86 // #96090#
87 #include <svl/slstitm.hxx>
88 #include <sfx2/request.hxx>
89 #include "SpellDialogChildWindow.hxx"
90 
91 #include "Window.hxx"
92 #include "fupoor.hxx"
93 
94 #include <editeng/numitem.hxx>
95 #include <editeng/eeitem.hxx>
96 #include <svl/poolitem.hxx>
97 #include <glob.hrc>
98 
99 #ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED
100 #define SO2_DECL_SVINPLACEOBJECT_DEFINED
101 SO2_DECL_REF(SvInPlaceObject)
102 #endif
103 
104 namespace sd { namespace ui { namespace table {
105 	extern SfxShell* CreateTableObjectBar( ViewShell& rShell, ::sd::View* pView );
106 } } }
107 
108 using namespace ::com::sun::star;
109 using namespace ::com::sun::star::uno;
110 using namespace ::com::sun::star::presentation;
111 
112 namespace {
113 
114 class ViewShellObjectBarFactory
115     : public ::sd::ShellFactory<SfxShell>
116 {
117 public:
118     ViewShellObjectBarFactory (::sd::ViewShell& rViewShell);
119     virtual ~ViewShellObjectBarFactory (void);
120     virtual SfxShell* CreateShell (
121         ::sd::ShellId nId,
122         ::Window* pParentWindow,
123         ::sd::FrameView* pFrameView);
124     virtual void ReleaseShell (SfxShell* pShell);
125 private:
126     ::sd::ViewShell& mrViewShell;
127     /** This cache holds the already created object bars.
128     */
129     typedef ::std::map< ::sd::ShellId,SfxShell*> ShellCache;
130     ShellCache maShellCache;
131 };
132 
133 
134 } // end of anonymous namespace
135 
136 
137 namespace sd {
138 
139 static const int DELTA_ZOOM = 10;
140 
141 sal_Bool ViewShell::IsPageFlipMode(void) const
142 {
143 	return this->ISA(DrawViewShell) && mpContentWindow.get() != NULL &&
144 		mpContentWindow->GetVisibleHeight() >= 1.0;
145 }
146 
147 SfxViewFrame* ViewShell::GetViewFrame (void) const
148 {
149     const SfxViewShell* pViewShell = GetViewShell();
150     if (pViewShell != NULL)
151     {
152         return pViewShell->GetViewFrame();
153     }
154     else
155     {
156         OSL_ASSERT (GetViewShell()!=NULL);
157         return NULL;
158     }
159 }
160 
161 
162 /*************************************************************************
163 |*
164 |* SFX-Slotmap und Standardinterface deklarieren
165 |*
166 \************************************************************************/
167 TYPEINIT1(ViewShell, SfxShell);
168 
169 
170 ViewShell::ViewShell( SfxViewFrame*, ::Window* pParentWindow, ViewShellBase& rViewShellBase, bool bAllowCenter)
171 :	SfxShell(&rViewShellBase)
172 ,	mbCenterAllowed(bAllowCenter)
173 ,	mpParentWindow(pParentWindow)
174 {
175 	construct();
176 }
177 
178 ViewShell::~ViewShell()
179 {
180     // Keep the content window from accessing in its destructor the
181     // WindowUpdater.
182     if (mpContentWindow)
183         mpContentWindow->SetViewShell(NULL);
184 
185 	delete mpZoomList;
186 
187     mpLayerTabBar.reset();
188 
189     if (mpImpl->mpSubShellFactory.get() != NULL)
190         GetViewShellBase().GetViewShellManager()->RemoveSubShellFactory(
191             this,mpImpl->mpSubShellFactory);
192 
193     if (mpContentWindow)
194     {
195         OSL_TRACE("destroying mpContentWindow at %x with parent %x", mpContentWindow.get(),
196             mpContentWindow->GetParent());
197         mpContentWindow.reset();
198     }
199 }
200 
201 
202 /*************************************************************************
203 |*
204 |* gemeinsamer Initialiserungsanteil der beiden Konstruktoren
205 |*
206 \************************************************************************/
207 
208 void ViewShell::construct(void)
209 {
210 	mbHasRulers = false;
211 	mpActiveWindow = 0;
212 	mpView = 0;
213 	mpFrameView = 0;
214 	mpZoomList = 0;
215 	mbStartShowWithDialog = sal_False;
216 	mnPrintedHandoutPageNum = 1;
217     mnPrintedHandoutPageCount = 0;
218 	mpWindowUpdater.reset( new ::sd::WindowUpdater() );
219 	mpImpl.reset(new Implementation(*this));
220 	meShellType = ST_NONE;
221 
222     OSL_ASSERT (GetViewShell()!=NULL);
223 
224     if (IsMainViewShell())
225         GetDocSh()->Connect (this);
226 
227 	mpZoomList = new ZoomList( this );
228 
229 	mpContentWindow.reset(new ::sd::Window(GetParentWindow()));
230     SetActiveWindow (mpContentWindow.get());
231 
232     GetParentWindow()->SetBackground (Wallpaper());
233     mpContentWindow->SetBackground (Wallpaper());
234 	mpContentWindow->SetCenterAllowed(mbCenterAllowed);
235 	mpContentWindow->SetViewShell(this);
236     mpContentWindow->SetPosSizePixel(
237         GetParentWindow()->GetPosPixel(),GetParentWindow()->GetSizePixel());
238     mpContentWindow->Show();
239     static_cast< ::Window*>(mpContentWindow.get())->Resize();
240     OSL_TRACE("content window has size %d %d",
241         mpContentWindow->GetSizePixel().Width(),
242         mpContentWindow->GetSizePixel().Height());
243 
244     if ( ! GetDocSh()->IsPreview())
245     {
246         // Create scroll bars and the filler between the scroll bars.
247         mpHorizontalScrollBar.reset (new ScrollBar(GetParentWindow(), WinBits(WB_HSCROLL | WB_DRAG)));
248         mpHorizontalScrollBar->EnableRTL (sal_False);
249         mpHorizontalScrollBar->SetRange(Range(0, 32000));
250         mpHorizontalScrollBar->SetScrollHdl(LINK(this, ViewShell, HScrollHdl));
251         mpHorizontalScrollBar->Show();
252 
253         mpVerticalScrollBar.reset (new ScrollBar(GetParentWindow(), WinBits(WB_VSCROLL | WB_DRAG)));
254         mpVerticalScrollBar->SetRange(Range(0, 32000));
255         mpVerticalScrollBar->SetScrollHdl(LINK(this, ViewShell, VScrollHdl));
256         mpVerticalScrollBar->Show();
257         maScrBarWH = Size(
258             mpVerticalScrollBar->GetSizePixel().Width(),
259             mpHorizontalScrollBar->GetSizePixel().Height());
260 
261         mpScrollBarBox.reset(new ScrollBarBox(GetParentWindow(), WB_SIZEABLE));
262         mpScrollBarBox->Show();
263     }
264 
265 	String aName( RTL_CONSTASCII_USTRINGPARAM( "ViewShell" ));
266 	SetName (aName);
267 
268 	GetDoc()->StartOnlineSpelling(sal_False);
269 
270     mpWindowUpdater->SetViewShell (*this);
271     mpWindowUpdater->SetDocument (GetDoc());
272 
273     // Re-initialize the spell dialog.
274     ::sd::SpellDialogChildWindow* pSpellDialog =
275           static_cast< ::sd::SpellDialogChildWindow*> (
276               GetViewFrame()->GetChildWindow (
277                   ::sd::SpellDialogChildWindow::GetChildWindowId()));
278     if (pSpellDialog != NULL)
279         pSpellDialog->InvalidateSpellDialog();
280 
281     // Register the sub shell factory.
282     mpImpl->mpSubShellFactory.reset(new ViewShellObjectBarFactory(*this));
283     GetViewShellBase().GetViewShellManager()->AddSubShellFactory(this,mpImpl->mpSubShellFactory);
284 
285     GetParentWindow()->Show();
286 }
287 
288 
289 
290 
291 void ViewShell::Init (bool bIsMainViewShell)
292 {
293     mpImpl->mbIsInitialized = true;
294     SetIsMainViewShell(bIsMainViewShell);
295     if (bIsMainViewShell)
296         SetActiveWindow (mpContentWindow.get());
297 }
298 
299 
300 
301 
302 void ViewShell::Exit (void)
303 {
304     sd::View* pView = GetView();
305     if (pView!=NULL && pView->IsTextEdit())
306     {
307         pView->SdrEndTextEdit();
308         pView->UnmarkAll();
309     }
310 
311     Deactivate (sal_True);
312 
313     if (IsMainViewShell())
314     {
315         GetDocSh()->Disconnect(this);
316     }
317 
318     SetIsMainViewShell(false);
319 }
320 
321 
322 
323 
324 /*************************************************************************
325 |*
326 |* Aktivierung: Arbeitsfenster den Fokus zuweisen
327 |*
328 \************************************************************************/
329 
330 void ViewShell::Activate(sal_Bool bIsMDIActivate)
331 {
332     // Do not forward to SfxShell::Activate()
333 
334 	// Laut MI darf keiner GrabFocus rufen, der nicht genau weiss von
335 	// welchem Window der Focus gegrabt wird. Da Activate() vom SFX teilweise
336 	// asynchron verschickt wird, kann es sein, dass ein falsches Window
337 	// den Focus hat (#29682#):
338 	//GetViewFrame()->GetWindow().GrabFocus();
339 
340     if (mpHorizontalRuler.get() != NULL)
341         mpHorizontalRuler->SetActive(sal_True);
342     if (mpVerticalRuler.get() != NULL)
343         mpVerticalRuler->SetActive(sal_True);
344 
345     if (bIsMDIActivate)
346     {
347         // Damit der Navigator auch einen aktuellen Status bekommt
348         SfxBoolItem aItem( SID_NAVIGATOR_INIT, sal_True );
349         if (GetDispatcher() != NULL)
350             GetDispatcher()->Execute(
351                 SID_NAVIGATOR_INIT,
352                 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
353                 &aItem,
354                 0L);
355 
356         SfxViewShell* pViewShell = GetViewShell();
357         OSL_ASSERT (pViewShell!=NULL);
358 		SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
359 		rBindings.Invalidate( SID_3D_STATE, sal_True, sal_False );
360 
361 		rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
362 		if(xSlideShow.is() && xSlideShow->isRunning() )
363 		{
364 			xSlideShow->activate(GetViewShellBase());
365 		}
366 		if(HasCurrentFunction())
367 		{
368 			GetCurrentFunction()->Activate();
369 		}
370 
371 		if(!GetDocSh()->IsUIActive())
372 			UpdatePreview( GetActualPage(), sal_True );
373 
374 		//HMH::sd::View* pView = GetView();
375 
376 		//HMHif (pView)
377 		//HMH{
378 		//HMH	pView->ShowMarkHdl();
379 		//HMH}
380 	}
381 
382 	ReadFrameViewData( mpFrameView );
383 
384     if (IsMainViewShell())
385         GetDocSh()->Connect(this);
386 }
387 
388 void ViewShell::UIActivating( SfxInPlaceClient*  )
389 {
390     OSL_ASSERT (GetViewShell()!=NULL);
391     GetViewShellBase().GetToolBarManager()->ToolBarsDestroyed();
392 }
393 
394 
395 
396 void ViewShell::UIDeactivated( SfxInPlaceClient*  )
397 {
398     OSL_ASSERT (GetViewShell()!=NULL);
399     GetViewShellBase().GetToolBarManager()->ToolBarsDestroyed();
400     if ( GetDrawView() )
401         GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this, *GetDrawView());
402 }
403 
404 /*************************************************************************
405 |*
406 |* Deaktivierung
407 |*
408 \************************************************************************/
409 
410 void ViewShell::Deactivate(sal_Bool bIsMDIActivate)
411 {
412 	// remove view from a still active drag'n'drop session
413 	SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag;
414 
415     if (IsMainViewShell())
416         GetDocSh()->Disconnect(this);
417 
418 	if( pDragTransferable )
419 		pDragTransferable->SetView( NULL );
420 
421     OSL_ASSERT (GetViewShell()!=NULL);
422 
423 	// View-Attribute an der FrameView merken
424 	WriteFrameViewData();
425 
426 	if (bIsMDIActivate)
427 	{
428 		rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
429 		if(xSlideShow.is() && xSlideShow->isRunning() )
430 		{
431 			xSlideShow->deactivate(GetViewShellBase());
432 		}
433 		if(HasCurrentFunction())
434 		{
435 			GetCurrentFunction()->Deactivate();
436 		}
437 	}
438 
439     if (mpHorizontalRuler.get() != NULL)
440         mpHorizontalRuler->SetActive(sal_False);
441     if (mpVerticalRuler.get() != NULL)
442         mpVerticalRuler->SetActive(sal_False);
443 
444 	SfxShell::Deactivate(bIsMDIActivate);
445 }
446 
447 
448 
449 
450 void ViewShell::Shutdown (void)
451 {
452     Exit ();
453 }
454 
455 
456 
457 
458 /*************************************************************************
459 |*
460 |* Keyboard event
461 |*
462 \************************************************************************/
463 
464 sal_Bool ViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin)
465 {
466 	sal_Bool bReturn(sal_False);
467 
468 	if(pWin)
469 	{
470 		SetActiveWindow(pWin);
471 	}
472 
473 	if(!bReturn)
474 	{
475 		// #76008#
476 		// give key input first to SfxViewShell to give CTRL+Key
477 		// (e.g. CTRL+SHIFT+'+', to front) priority.
478         OSL_ASSERT (GetViewShell()!=NULL);
479 		bReturn = (sal_Bool)GetViewShell()->KeyInput(rKEvt);
480 	}
481 
482 	if(!bReturn)
483 	{
484 		rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
485 		if(xSlideShow.is() && xSlideShow->isRunning())
486 		{
487 			bReturn = xSlideShow->keyInput(rKEvt);
488 		}
489 		else
490 		{
491 			bool bConsumed = false;
492 			if( GetView() )
493 				bConsumed = GetView()->getSmartTags().KeyInput(rKEvt);
494 
495 
496 			if( !bConsumed )
497 			{
498 				rtl::Reference< sdr::SelectionController > xSelectionController( GetView()->getSelectionController() );
499 				if( !xSelectionController.is() || !xSelectionController->onKeyInput( rKEvt, pWin ) )
500 				{
501 					if(HasCurrentFunction())
502 						bReturn = GetCurrentFunction()->KeyInput(rKEvt);
503 				}
504 				else
505 				{
506 					bReturn = sal_True;
507 				}
508 			}
509 		}
510 	}
511 
512 	if(!bReturn && GetActiveWindow())
513 	{
514 		KeyCode aKeyCode = rKEvt.GetKeyCode();
515 
516 		if (aKeyCode.IsMod1() && aKeyCode.IsShift()
517 			&& aKeyCode.GetCode() == KEY_R)
518 		{
519 			InvalidateWindows();
520 			bReturn = sal_True;
521 		}
522 	}
523 
524 	return(bReturn);
525 }
526 
527 /*************************************************************************
528 |*
529 |* MouseButtonDown event
530 |*
531 \************************************************************************/
532 
533 void ViewShell::MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin)
534 {
535     // We have to lock tool bar updates while the mouse button is pressed in
536     // order to prevent the shape under the mouse to be moved (this happens
537     // when the number of docked tool bars changes as result of a changed
538     // selection;  this changes the window size and thus the mouse position
539     // in model coordinates: with respect to model coordinates the mouse
540     // moves.)
541     OSL_ASSERT(mpImpl->mpUpdateLockForMouse.expired());
542     mpImpl->mpUpdateLockForMouse = ViewShell::Implementation::ToolBarManagerLock::Create(
543         GetViewShellBase().GetToolBarManager());
544 
545 	if ( pWin && !pWin->HasFocus() )
546 	{
547         pWin->GrabFocus();
548         SetActiveWindow(pWin);
549 //		  GetViewFrame()->GetWindow().GrabFocus();
550 	}
551 
552 	// MouseEvent in E3dView eintragen
553     if (GetView() != NULL)
554         GetView()->SetMouseEvent(rMEvt);
555 
556 	bool bConsumed = false;
557 	if( GetView() )
558 		bConsumed = GetView()->getSmartTags().MouseButtonDown( rMEvt );
559 
560 	if( !bConsumed )
561 	{
562 		rtl::Reference< sdr::SelectionController > xSelectionController( GetView()->getSelectionController() );
563 		if( !xSelectionController.is() || !xSelectionController->onMouseButtonDown( rMEvt, pWin ) )
564 		{
565 			if(HasCurrentFunction())
566 			{
567 				GetCurrentFunction()->MouseButtonDown(rMEvt);
568 			}
569 		}
570 	}
571 }
572 
573 /*************************************************************************
574 |*
575 |* MouseMove event
576 |*
577 \************************************************************************/
578 
579 void ViewShell::MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin)
580 {
581     if (rMEvt.IsLeaveWindow())
582     {
583         if ( ! mpImpl->mpUpdateLockForMouse.expired())
584         {
585             ::boost::shared_ptr<ViewShell::Implementation::ToolBarManagerLock> pLock(
586                 mpImpl->mpUpdateLockForMouse);
587             if (pLock.get() != NULL)
588                 pLock->Release();
589         }
590     }
591 
592 	if ( pWin )
593 	{
594 		SetActiveWindow(pWin);
595 	}
596 
597 	// MouseEvent in E3dView eintragen
598     if (GetView() != NULL)
599         GetView()->SetMouseEvent(rMEvt);
600 
601 	if(HasCurrentFunction())
602 	{
603 		rtl::Reference< sdr::SelectionController > xSelectionController( GetView()->getSelectionController() );
604 		if( !xSelectionController.is() || !xSelectionController->onMouseMove( rMEvt, pWin ) )
605 		{
606 			if(HasCurrentFunction())
607 				GetCurrentFunction()->MouseMove(rMEvt);
608 		}
609 	}
610 }
611 
612 /*************************************************************************
613 |*
614 |* MouseButtonUp event
615 |*
616 \************************************************************************/
617 
618 void ViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
619 {
620 	if ( pWin )
621 	{
622 		SetActiveWindow(pWin);
623 	}
624 
625 	// MouseEvent in E3dView eintragen
626     if (GetView() != NULL)
627         GetView()->SetMouseEvent(rMEvt);
628 
629 	if( HasCurrentFunction())
630 	{
631 		rtl::Reference< sdr::SelectionController > xSelectionController( GetView()->getSelectionController() );
632 		if( !xSelectionController.is() || !xSelectionController->onMouseButtonUp( rMEvt, pWin ) )
633 		{
634 			if(HasCurrentFunction())
635 				GetCurrentFunction()->MouseButtonUp(rMEvt);
636 		}
637 	}
638 
639     if ( ! mpImpl->mpUpdateLockForMouse.expired())
640     {
641         ::boost::shared_ptr<ViewShell::Implementation::ToolBarManagerLock> pLock(
642             mpImpl->mpUpdateLockForMouse);
643         if (pLock.get() != NULL)
644             pLock->Release();
645     }
646 }
647 
648 
649 /*************************************************************************
650 |*
651 |* Command event
652 |*
653 \************************************************************************/
654 
655 void ViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin)
656 {
657 	sal_Bool bDone = HandleScrollCommand (rCEvt, pWin);
658 
659 	if( !bDone )
660 	{
661 		if( rCEvt.GetCommand() == COMMAND_INPUTLANGUAGECHANGE )
662 		{
663             //#i42732# update state of fontname if input language changes
664             GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONT );
665             GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
666 		}
667 		else
668 		{
669 		    bool bConsumed = false;
670    			if( GetView() )
671    			{
672 				bConsumed = GetView()->getSmartTags().Command(rCEvt);
673 		    }
674 
675 			if( !bConsumed && HasCurrentFunction())
676 		    {
677 		        GetCurrentFunction()->Command(rCEvt);
678             }
679 		}
680 	}
681 }
682 
683 long ViewShell::Notify(NotifyEvent& rNEvt, ::sd::Window* pWin)
684 {
685     // handle scroll commands when they arrived at child windows
686     long nRet = sal_False;
687     if( rNEvt.GetType() == EVENT_COMMAND )
688     {
689         // note: dynamic_cast is not possible as GetData() returns a void*
690         CommandEvent* pCmdEvent = reinterpret_cast< CommandEvent* >(rNEvt.GetData());
691         nRet = HandleScrollCommand(*pCmdEvent, pWin);
692     }
693     return nRet;
694 }
695 
696 
697 bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWin)
698 {
699     bool bDone = false;
700 
701     switch( rCEvt.GetCommand() )
702     {
703         case COMMAND_WHEEL:
704 			{
705 				Reference< XSlideShowController > xSlideShowController( SlideShow::GetSlideShowController(GetViewShellBase() ) );
706 				if( xSlideShowController.is() )
707 				{
708 					// We ignore zooming with control+mouse wheel.
709 					const CommandWheelData* pData = rCEvt.GetWheelData();
710 					if( pData && !pData->GetModifier() && ( pData->GetMode() == COMMAND_WHEEL_SCROLL ) && !pData->IsHorz() )
711 					{
712 						long nDelta = pData->GetDelta();
713 						if( nDelta > 0 )
714 						{
715 							xSlideShowController->gotoPreviousSlide();
716 						}
717 						else if( nDelta < 0 )
718 						{
719 							xSlideShowController->gotoNextEffect();
720 						}
721 					}
722 					break;
723 				}
724 			}
725 			// fall through when not running slideshow
726         case COMMAND_STARTAUTOSCROLL:
727         case COMMAND_AUTOSCROLL:
728         {
729             const CommandWheelData* pData = rCEvt.GetWheelData();
730 
731             if (pData != NULL)
732             {
733                 if (pData->IsMod1())
734                 {
735                     if( !GetDocSh()->IsUIActive() )
736                     {
737                         const long  nOldZoom = GetActiveWindow()->GetZoom();
738                         long        nNewZoom;
739 
740                         if( pData->GetDelta() < 0L )
741                             nNewZoom = Max( (long) pWin->GetMinZoom(), (long)(nOldZoom - DELTA_ZOOM) );
742                         else
743                             nNewZoom = Min( (long) pWin->GetMaxZoom(), (long)(nOldZoom + DELTA_ZOOM) );
744 
745                         SetZoom( nNewZoom );
746                         Invalidate( SID_ATTR_ZOOM );
747 						Invalidate( SID_ATTR_ZOOMSLIDER );
748 
749                         bDone = true;
750                     }
751                 }
752                 else
753                 {
754                     if( mpContentWindow.get() == pWin )
755                     {
756                         sal_uLong nScrollLines = pData->GetScrollLines();
757                         if(IsPageFlipMode())
758                             nScrollLines = COMMAND_WHEEL_PAGESCROLL;
759                         CommandWheelData aWheelData( pData->GetDelta(),pData->GetNotchDelta(),
760                             nScrollLines,pData->GetMode(),pData->GetModifier(),pData->IsHorz() );
761                         CommandEvent aReWrite( rCEvt.GetMousePosPixel(),rCEvt.GetCommand(),
762                             rCEvt.IsMouseEvent(),(const void *) &aWheelData );
763                         bDone = pWin->HandleScrollCommand( aReWrite,
764                             mpHorizontalScrollBar.get(),
765                             mpVerticalScrollBar.get()) == sal_True;
766                     }
767                 }
768             }
769         }
770         break;
771 
772         default:
773         break;
774     }
775 
776     return bDone;
777 }
778 
779 
780 
781 void ViewShell::SetupRulers (void)
782 {
783 	if(mbHasRulers && (mpContentWindow.get() != NULL) && !SlideShow::IsRunning(GetViewShellBase()))
784 	{
785 		long nHRulerOfs = 0;
786 
787 		if ( mpVerticalRuler.get() == NULL )
788 		{
789 			mpVerticalRuler.reset(CreateVRuler(GetActiveWindow()));
790 			if ( mpVerticalRuler.get() != NULL )
791 			{
792 				nHRulerOfs = mpVerticalRuler->GetSizePixel().Width();
793 				mpVerticalRuler->SetActive(sal_True);
794 				mpVerticalRuler->Show();
795 			}
796 		}
797 		if ( mpHorizontalRuler.get() == NULL )
798 		{
799 			mpHorizontalRuler.reset(CreateHRuler(GetActiveWindow(), sal_True));
800 			if ( mpHorizontalRuler.get() != NULL )
801 			{
802 				mpHorizontalRuler->SetWinPos(nHRulerOfs);
803 				mpHorizontalRuler->SetActive(sal_True);
804 				mpHorizontalRuler->Show();
805 			}
806 		}
807 	}
808 }
809 
810 const SfxPoolItem* ViewShell::GetNumBulletItem(SfxItemSet& aNewAttr, sal_uInt16& nNumItemId)
811 {
812 	const SfxPoolItem* pTmpItem = NULL;
813 
814 	if(aNewAttr.GetItemState(nNumItemId, sal_False, &pTmpItem) == SFX_ITEM_SET)
815 	{
816 		return pTmpItem;
817 	}
818 	else
819 	{
820 		nNumItemId = aNewAttr.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
821 		SfxItemState eState = aNewAttr.GetItemState(nNumItemId, sal_False, &pTmpItem);
822 		if (eState == SFX_ITEM_SET)
823 			return pTmpItem;
824 		else
825 		{
826 			sal_Bool bOutliner = sal_False;
827 			sal_Bool bTitle = sal_False;
828 
829 			if( mpView )
830      			{
831 				const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
832 				const sal_uInt32 nCount = rMarkList.GetMarkCount();
833 
834 				for(sal_uInt32 nNum = 0; nNum < nCount; nNum++)
835 				{
836 					SdrObject* pObj = rMarkList.GetMark(nNum)->GetMarkedSdrObj();
837 					if( pObj->GetObjInventor() == SdrInventor )
838 					{
839 						switch(pObj->GetObjIdentifier())
840 						{
841 						case OBJ_TITLETEXT:
842 							bTitle = sal_True;
843 							break;
844 						case OBJ_OUTLINETEXT:
845 							bOutliner = sal_True;
846 							break;
847 						}
848 					}
849 				}
850 			}
851 
852 			const SvxNumBulletItem *pItem = NULL;
853 			if(bOutliner)
854 			{
855 				SfxStyleSheetBasePool* pSSPool = mpView->GetDocSh()->GetStyleSheetPool();
856 				String aStyleName((SdResId(STR_LAYOUT_OUTLINE)));
857 				aStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) );
858 				SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( aStyleName, SD_STYLE_FAMILY_PSEUDO);
859 				if( pFirstStyleSheet )
860 					pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, sal_False, (const SfxPoolItem**)&pItem);
861 			}
862 
863 			if( pItem == NULL )
864 				pItem = (SvxNumBulletItem*) aNewAttr.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET);
865 
866 			aNewAttr.Put(*pItem, EE_PARA_NUMBULLET);
867 
868 			if(bTitle && aNewAttr.GetItemState(EE_PARA_NUMBULLET,sal_True) == SFX_ITEM_ON )
869 			{
870 				SvxNumBulletItem* pItem = (SvxNumBulletItem*)aNewAttr.GetItem(EE_PARA_NUMBULLET,sal_True);
871 				SvxNumRule* pRule = pItem->GetNumRule();
872 				if(pRule)
873 				{
874 					SvxNumRule aNewRule( *pRule );
875 					aNewRule.SetFeatureFlag( NUM_NO_NUMBERS, sal_True );
876 
877 					SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET );
878 					aNewAttr.Put(aNewItem);
879 				}
880 			}
881 
882 			SfxItemState eState = aNewAttr.GetItemState(nNumItemId, sal_False, &pTmpItem);
883 			if (eState == SFX_ITEM_SET)
884 				return pTmpItem;
885 
886 		}
887 	}
888 	return pTmpItem;
889 }
890 
891 
892 sal_Bool ViewShell::HasRuler (void)
893 {
894     return mbHasRulers;
895 }
896 
897 
898 
899 
900 void ViewShell::Resize (void)
901 {
902 	SetupRulers ();
903 
904     if (mpParentWindow == NULL)
905         return;
906 
907     // Make sure that the new size is not degenerate.
908     const Size aSize (mpParentWindow->GetSizePixel());
909 	if (aSize.Width()==0 || aSize.Height()==0)
910 		return;
911 
912     // Remember the new position and size.
913 	maViewPos = Point(0,0); //mpParentWindow->GetPosPixel();
914 	maViewSize = aSize;
915 
916     // Rearrange the UI elements to take care of the new position and size.
917     ArrangeGUIElements ();
918     // end of included AdjustPosSizePixel.
919 
920     Size aS (GetParentWindow()->GetOutputSizePixel());
921 	Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
922 	Rectangle aVisArea = GetParentWindow()->PixelToLogic(
923         Rectangle( Point(0,0), aVisSizePixel));
924     Rectangle aCurrentVisArea (GetDocSh()->GetVisArea(ASPECT_CONTENT));
925     Rectangle aWindowRect = GetActiveWindow()->LogicToPixel(aCurrentVisArea);
926 	if (GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
927         && IsMainViewShell())
928 	{
929         //        GetDocSh()->SetVisArea(aVisArea);
930 	}
931 
932     //	VisAreaChanged(aVisArea);
933 
934 	::sd::View* pView = GetView();
935 
936 	if (pView)
937 	{
938 		pView->VisAreaChanged(GetActiveWindow());
939 	}
940 }
941 
942 SvBorder ViewShell::GetBorder (bool )
943 {
944     SvBorder aBorder;
945 
946 	// Horizontal scrollbar.
947     if (mpHorizontalScrollBar.get()!=NULL
948         && mpHorizontalScrollBar->IsVisible())
949     {
950         aBorder.Bottom() = maScrBarWH.Height();
951     }
952 
953 	// Vertical scrollbar.
954     if (mpVerticalScrollBar.get()!=NULL
955         && mpVerticalScrollBar->IsVisible())
956     {
957         aBorder.Right() = maScrBarWH.Width();
958     }
959 
960     // Place horizontal ruler below tab bar.
961     if (mbHasRulers && mpContentWindow.get() != NULL)
962     {
963         SetupRulers();
964         if (mpHorizontalRuler.get() != NULL)
965             aBorder.Top() = mpHorizontalRuler->GetSizePixel().Height();
966         if (mpVerticalRuler.get() != NULL)
967             aBorder.Left() = mpVerticalRuler->GetSizePixel().Width();
968     }
969 
970     return aBorder;
971 }
972 
973 
974 
975 
976 void ViewShell::ArrangeGUIElements (void)
977 {
978     if (mpImpl->mbArrangeActive)
979         return;
980     mpImpl->mbArrangeActive = true;
981 
982     // Calculate border for in-place editing.
983 	long nLeft = maViewPos.X();
984 	long nTop  = maViewPos.Y();
985 	long nRight = maViewPos.X() + maViewSize.Width();
986 	long nBottom = maViewPos.Y() + maViewSize.Height();
987 
988 	// Horizontal scrollbar.
989     if (mpHorizontalScrollBar.get()!=NULL
990         && mpHorizontalScrollBar->IsVisible())
991     {
992         int nLocalLeft = nLeft;
993         if (mpLayerTabBar.get()!=NULL && mpLayerTabBar->IsVisible())
994             nLocalLeft += mpLayerTabBar->GetSizePixel().Width();
995         nBottom -= maScrBarWH.Height();
996         mpHorizontalScrollBar->SetPosSizePixel (
997             Point(nLocalLeft,nBottom),
998             Size(nRight-nLocalLeft-maScrBarWH.Width(),maScrBarWH.Height()));
999     }
1000 
1001 	// Vertical scrollbar.
1002     if (mpVerticalScrollBar.get()!=NULL
1003         && mpVerticalScrollBar->IsVisible())
1004     {
1005         nRight -= maScrBarWH.Width();
1006         mpVerticalScrollBar->SetPosSizePixel (
1007             Point(nRight,nTop),
1008             Size (maScrBarWH.Width(),nBottom-nTop));
1009     }
1010 
1011     // Filler in the lower right corner.
1012     if (mpScrollBarBox.get() != NULL)
1013     {
1014         if (mpHorizontalScrollBar.get()!=NULL
1015             && mpHorizontalScrollBar->IsVisible()
1016             && mpVerticalScrollBar.get()!=NULL
1017             && mpVerticalScrollBar->IsVisible())
1018         {
1019             mpScrollBarBox->Show();
1020             mpScrollBarBox->SetPosSizePixel(Point(nRight, nBottom), maScrBarWH);
1021         }
1022         else
1023             mpScrollBarBox->Hide();
1024     }
1025 
1026     // Place horizontal ruler below tab bar.
1027     if (mbHasRulers && mpContentWindow.get() != NULL)
1028     {
1029         if (mpHorizontalRuler.get() != NULL)
1030         {
1031             Size aRulerSize = mpHorizontalRuler->GetSizePixel();
1032             aRulerSize.Width() = nRight - nLeft;
1033             mpHorizontalRuler->SetPosSizePixel (
1034                 Point(nLeft,nTop), aRulerSize);
1035             if (mpVerticalRuler.get() != NULL)
1036                 mpHorizontalRuler->SetBorderPos(
1037                     mpVerticalRuler->GetSizePixel().Width()-1);
1038             nTop += aRulerSize.Height();
1039         }
1040         if (mpVerticalRuler.get() != NULL)
1041         {
1042             Size aRulerSize = mpVerticalRuler->GetSizePixel();
1043             aRulerSize.Height() = nBottom  - nTop;
1044             mpVerticalRuler->SetPosSizePixel (
1045                 Point (nLeft,nTop), aRulerSize);
1046             nLeft += aRulerSize.Width();
1047         }
1048     }
1049 
1050 	rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
1051 
1052     // The size of the window of the center pane is set differently from
1053     // that of the windows in the docking windows.
1054     bool bSlideShowActive = (xSlideShow.is() && xSlideShow->isRunning()) && !xSlideShow->isFullScreen() && xSlideShow->getAnimationMode() == ANIMATIONMODE_SHOW;
1055     if ( !bSlideShowActive)
1056     {
1057         OSL_ASSERT (GetViewShell()!=NULL);
1058 
1059         if (mpContentWindow)
1060             mpContentWindow->SetPosSizePixel(
1061                 Point(nLeft,nTop),
1062                 Size(nRight-nLeft,nBottom-nTop));
1063     }
1064 
1065     // Windows in the center and rulers at the left and top side.
1066 	maAllWindowRectangle = Rectangle(
1067         maViewPos,
1068         Size(maViewSize.Width()-maScrBarWH.Width(),
1069             maViewSize.Height()-maScrBarWH.Height()));
1070 
1071     if (mpContentWindow.get() != NULL)
1072     {
1073         mpContentWindow->UpdateMapOrigin();
1074     }
1075 
1076     UpdateScrollBars();
1077 
1078     mpImpl->mbArrangeActive = false;
1079 }
1080 
1081 
1082 
1083 
1084 void ViewShell::SetUIUnit(FieldUnit eUnit)
1085 {
1086     // Set unit at horizontal and vertical rulers.
1087     if (mpHorizontalRuler.get() != NULL)
1088         mpHorizontalRuler->SetUnit(eUnit);
1089 
1090 
1091 	if (mpVerticalRuler.get() != NULL)
1092         mpVerticalRuler->SetUnit(eUnit);
1093 }
1094 
1095 /*************************************************************************
1096 |*
1097 |* DefTab an den horizontalen Linealen setzen
1098 |*
1099 \************************************************************************/
1100 void ViewShell::SetDefTabHRuler( sal_uInt16 nDefTab )
1101 {
1102     if (mpHorizontalRuler.get() != NULL)
1103         mpHorizontalRuler->SetDefTabDist( nDefTab );
1104 }
1105 
1106 
1107 
1108 
1109 /** Tell the FmFormShell that the view shell is closing.  Give it the
1110     oportunity to prevent that.
1111 */
1112 sal_uInt16 ViewShell::PrepareClose (sal_Bool bUI, sal_Bool bForBrowsing)
1113 {
1114     sal_uInt16 nResult = sal_True;
1115 
1116     FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
1117     if (pFormShell != NULL)
1118         nResult = pFormShell->PrepareClose (bUI, bForBrowsing);
1119 
1120 	return nResult;
1121 }
1122 
1123 
1124 
1125 
1126 void ViewShell::UpdatePreview (SdPage*, sal_Bool )
1127 {
1128     // Do nothing.  After the actual preview has been removed,
1129     // OutlineViewShell::UpdatePreview() is the place where something
1130     // usefull is still done.
1131 }
1132 
1133 ::svl::IUndoManager* ViewShell::ImpGetUndoManager (void) const
1134 {
1135 	const ViewShell* pMainViewShell = GetViewShellBase().GetMainViewShell().get();
1136 
1137 	if( pMainViewShell == 0 )
1138 		pMainViewShell = this;
1139 
1140 	::sd::View* pView = pMainViewShell->GetView();
1141 
1142 	// check for text edit our outline view
1143 	if( pView )
1144 	{
1145 		if( pMainViewShell->GetShellType() == ViewShell::ST_OUTLINE )
1146 		{
1147 			OutlineView* pOlView = dynamic_cast< OutlineView* >( pView );
1148 			if( pOlView )
1149 			{
1150 				::Outliner* pOutl = pOlView->GetOutliner();
1151 				if( pOutl )
1152 					return &pOutl->GetUndoManager();
1153 			}
1154 		}
1155 		else if( pView->IsTextEdit() )
1156 		{
1157 			SdrOutliner* pOL = pView->GetTextEditOutliner();
1158 			if( pOL )
1159 				return &pOL->GetUndoManager();
1160 		}
1161 	}
1162 
1163 	if( GetDocSh() )
1164 		return GetDocSh()->GetUndoManager();
1165 
1166 	return NULL;
1167 }
1168 
1169 
1170 
1171 
1172 void ViewShell::ImpGetUndoStrings(SfxItemSet &rSet) const
1173 {
1174 	::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
1175 	if(pUndoManager)
1176 	{
1177 		sal_uInt16 nCount(pUndoManager->GetUndoActionCount());
1178 		if(nCount)
1179 		{
1180 			// prepare list
1181 			List aStringList;
1182 			sal_uInt16 a;
1183 
1184 			for( a = 0; a < nCount; a++)
1185 			{
1186 				// generate one String in list per undo step
1187 				String* pInsertString = new String(pUndoManager->GetUndoActionComment(a));
1188 				aStringList.Insert(pInsertString, LIST_APPEND);
1189 			}
1190 
1191 			// set item
1192 			rSet.Put(SfxStringListItem(SID_GETUNDOSTRINGS, &aStringList));
1193 
1194 			// delete Strings again
1195 			for(a = 0; a < nCount; a++)
1196 				delete (String*)aStringList.GetObject(a);
1197 		}
1198 		else
1199 		{
1200 			rSet.DisableItem(SID_GETUNDOSTRINGS);
1201 		}
1202 	}
1203 }
1204 
1205 // -----------------------------------------------------------------------------
1206 
1207 void ViewShell::ImpGetRedoStrings(SfxItemSet &rSet) const
1208 {
1209 	::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
1210 	if(pUndoManager)
1211 	{
1212 		sal_uInt16 nCount(pUndoManager->GetRedoActionCount());
1213 		if(nCount)
1214 		{
1215 			// prepare list
1216 			List aStringList;
1217 			sal_uInt16 a;
1218 
1219 			for( a = 0; a < nCount; a++)
1220 			{
1221 				// generate one String in list per undo step
1222 				String* pInsertString = new String(pUndoManager->GetRedoActionComment(a));
1223 				aStringList.Insert(pInsertString, LIST_APPEND);
1224 			}
1225 
1226 			// set item
1227 			rSet.Put(SfxStringListItem(SID_GETREDOSTRINGS, &aStringList));
1228 
1229 			// delete Strings again
1230 			for(a = 0; a < nCount; a++)
1231 				delete (String*)aStringList.GetObject(a);
1232 		}
1233 		else
1234 		{
1235 			rSet.DisableItem(SID_GETREDOSTRINGS);
1236 		}
1237 	}
1238 }
1239 
1240 // -----------------------------------------------------------------------------
1241 
1242 void ViewShell::ImpSidUndo(sal_Bool, SfxRequest& rReq)
1243 {
1244 	::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
1245 	sal_uInt16 nNumber(1);
1246 	const SfxItemSet* pReqArgs = rReq.GetArgs();
1247 
1248 	if(pReqArgs)
1249 	{
1250 		SfxUInt16Item* pUIntItem = (SfxUInt16Item*)&pReqArgs->Get(SID_UNDO);
1251 		nNumber = pUIntItem->GetValue();
1252 	}
1253 
1254 	if(nNumber && pUndoManager)
1255 	{
1256 		sal_uInt16 nCount(pUndoManager->GetUndoActionCount());
1257 		if(nCount >= nNumber)
1258 		{
1259             try
1260             {
1261 			    // #94637# when UndoStack is cleared by ModifyPageUndoAction
1262 			    // the nCount may have changed, so test GetUndoActionCount()
1263 			    while(nNumber-- && pUndoManager->GetUndoActionCount())
1264 			    {
1265 				    pUndoManager->Undo();
1266 			    }
1267             }
1268             catch( const Exception& e )
1269             {
1270                 // no need to handle. By definition, the UndoManager handled this by clearing the
1271                 // Undo/Redo stacks
1272             }
1273 		}
1274 
1275 		// #91081# refresh rulers, maybe UNDO was move of TAB marker in ruler
1276 		if (mbHasRulers)
1277 		{
1278 			Invalidate(SID_ATTR_TABSTOP);
1279 		}
1280 	}
1281 
1282 	// This one is corresponding to the default handling
1283 	// of SID_UNDO in sfx2
1284 	GetViewFrame()->GetBindings().InvalidateAll(sal_False);
1285 
1286 	rReq.Done();
1287 }
1288 
1289 // -----------------------------------------------------------------------------
1290 
1291 void ViewShell::ImpSidRedo(sal_Bool, SfxRequest& rReq)
1292 {
1293 	::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
1294 	sal_uInt16 nNumber(1);
1295 	const SfxItemSet* pReqArgs = rReq.GetArgs();
1296 
1297 	if(pReqArgs)
1298 	{
1299 		SfxUInt16Item* pUIntItem = (SfxUInt16Item*)&pReqArgs->Get(SID_REDO);
1300 		nNumber = pUIntItem->GetValue();
1301 	}
1302 
1303 	if(nNumber && pUndoManager)
1304 	{
1305 		sal_uInt16 nCount(pUndoManager->GetRedoActionCount());
1306 		if(nCount >= nNumber)
1307 		{
1308             try
1309             {
1310 			    // #94637# when UndoStack is cleared by ModifyPageRedoAction
1311 			    // the nCount may have changed, so test GetRedoActionCount()
1312 			    while(nNumber-- && pUndoManager->GetRedoActionCount())
1313 			    {
1314 				    pUndoManager->Redo();
1315 			    }
1316             }
1317             catch( const Exception& e )
1318             {
1319                 // no need to handle. By definition, the UndoManager handled this by clearing the
1320                 // Undo/Redo stacks
1321             }
1322 		}
1323 
1324 		// #91081# refresh rulers, maybe REDO was move of TAB marker in ruler
1325 		if (mbHasRulers)
1326 		{
1327 			Invalidate(SID_ATTR_TABSTOP);
1328 		}
1329 	}
1330 
1331 	// This one is corresponding to the default handling
1332 	// of SID_UNDO in sfx2
1333 	GetViewFrame()->GetBindings().InvalidateAll(sal_False);
1334 
1335 	rReq.Done();
1336 }
1337 
1338 // -----------------------------------------------------------------------------
1339 
1340 void ViewShell::ExecReq( SfxRequest& rReq )
1341 {
1342     sal_uInt16 nSlot = rReq.GetSlot();
1343     switch( nSlot )
1344     {
1345 		case SID_MAIL_SCROLLBODY_PAGEDOWN:
1346 		{
1347 			FunctionReference xFunc( GetCurrentFunction() );
1348 			if( xFunc.is() )
1349 			{
1350 				xFunc->ScrollStart();
1351 				ScrollLines( 0, -1 );
1352 				xFunc->ScrollEnd();
1353 			}
1354 
1355             rReq.Done();
1356 		}
1357 		break;
1358 
1359 		case SID_OUTPUT_QUALITY_COLOR:
1360 		case SID_OUTPUT_QUALITY_GRAYSCALE:
1361 		case SID_OUTPUT_QUALITY_BLACKWHITE:
1362 		case SID_OUTPUT_QUALITY_CONTRAST:
1363 		{
1364 			sal_uLong nMode = OUTPUT_DRAWMODE_COLOR;
1365 
1366             switch( nSlot )
1367 			{
1368 			    case SID_OUTPUT_QUALITY_COLOR: nMode = OUTPUT_DRAWMODE_COLOR; break;
1369 			    case SID_OUTPUT_QUALITY_GRAYSCALE: nMode = OUTPUT_DRAWMODE_GRAYSCALE; break;
1370 			    case SID_OUTPUT_QUALITY_BLACKWHITE: nMode = OUTPUT_DRAWMODE_BLACKWHITE; break;
1371 			    case SID_OUTPUT_QUALITY_CONTRAST: nMode = OUTPUT_DRAWMODE_CONTRAST; break;
1372 			}
1373 
1374 			GetActiveWindow()->SetDrawMode( nMode );
1375             mpFrameView->SetDrawMode( nMode );
1376 // #110094#-7
1377 //            GetView()->ReleaseMasterPagePaintCache();
1378 			GetActiveWindow()->Invalidate();
1379 
1380 			Invalidate();
1381 			rReq.Done();
1382 			break;
1383 		}
1384     }
1385 }
1386 
1387 
1388 
1389 
1390 /** This default implemenation returns only an empty reference.  See derived
1391     classes for more interesting examples.
1392 */
1393 ::com::sun::star::uno::Reference<
1394     ::com::sun::star::accessibility::XAccessible>
1395 ViewShell::CreateAccessibleDocumentView (::sd::Window* )
1396 {
1397     return ::com::sun::star::uno::Reference<
1398         ::com::sun::star::accessibility::XAccessible> ();
1399 }
1400 
1401 
1402 
1403 ::sd::WindowUpdater* ViewShell::GetWindowUpdater (void) const
1404 {
1405     return mpWindowUpdater.get();
1406 }
1407 
1408 
1409 
1410 
1411 ViewShellBase& ViewShell::GetViewShellBase (void) const
1412 {
1413     return *static_cast<ViewShellBase*>(GetViewShell());
1414 }
1415 
1416 
1417 
1418 
1419 ViewShell::ShellType ViewShell::GetShellType (void) const
1420 {
1421     return meShellType;
1422 }
1423 
1424 
1425 
1426 
1427 DrawDocShell* ViewShell::GetDocSh (void) const
1428 {
1429     return GetViewShellBase().GetDocShell();
1430 }
1431 
1432 
1433 
1434 
1435 SdDrawDocument* ViewShell::GetDoc (void) const
1436 {
1437     return GetViewShellBase().GetDocument();
1438 }
1439 
1440 ErrCode ViewShell::DoVerb (long )
1441 {
1442     return ERRCODE_NONE;
1443 }
1444 
1445 void ViewShell::SetCurrentFunction( const FunctionReference& xFunction)
1446 {
1447 	if( mxCurrentFunction.is() && (mxOldFunction != mxCurrentFunction) )
1448 		mxCurrentFunction->Dispose();
1449 	FunctionReference xTemp( mxCurrentFunction );
1450     mxCurrentFunction = xFunction;
1451 }
1452 
1453 void ViewShell::SetOldFunction(const FunctionReference& xFunction)
1454 {
1455 	if( mxOldFunction.is() && (xFunction != mxOldFunction) && (mxCurrentFunction != mxOldFunction) )
1456 		mxOldFunction->Dispose();
1457 
1458 	FunctionReference xTemp( mxOldFunction );
1459     mxOldFunction = xFunction;
1460 }
1461 
1462 /** this method deactivates the current function. If an old function is
1463 	saved, this will become activated and current function.
1464 */
1465 void ViewShell::Cancel()
1466 {
1467 	if(mxCurrentFunction.is() && (mxCurrentFunction != mxOldFunction ))
1468 	{
1469 		FunctionReference xTemp( mxCurrentFunction );
1470 		mxCurrentFunction.clear();
1471 		xTemp->Deactivate();
1472 		xTemp->Dispose();
1473 	}
1474 
1475 	if(mxOldFunction.is())
1476 	{
1477 		mxCurrentFunction = mxOldFunction;
1478 		mxCurrentFunction->Activate();
1479 	}
1480 }
1481 
1482 void ViewShell::DeactivateCurrentFunction( bool bPermanent /* == false */ )
1483 {
1484 	if( mxCurrentFunction.is() )
1485 	{
1486 		if(bPermanent && (mxOldFunction == mxCurrentFunction))
1487 			mxOldFunction.clear();
1488 
1489 		mxCurrentFunction->Deactivate();
1490 		if( mxCurrentFunction != mxOldFunction )
1491 			mxCurrentFunction->Dispose();
1492 
1493 		FunctionReference xTemp( mxCurrentFunction );
1494 		mxCurrentFunction.clear();
1495 	}
1496 }
1497 
1498 void ViewShell::DisposeFunctions()
1499 {
1500 	if(mxCurrentFunction.is())
1501 	{
1502 		FunctionReference xTemp( mxCurrentFunction );
1503 		mxCurrentFunction.clear();
1504 		xTemp->Deactivate();
1505 		xTemp->Dispose();
1506 	}
1507 
1508 	if(mxOldFunction.is())
1509 	{
1510 		FunctionReference xTemp( mxOldFunction );
1511 		mxOldFunction->Dispose();
1512 		mxOldFunction.clear();
1513 	}
1514 }
1515 
1516 bool ViewShell::IsMainViewShell (void) const
1517 {
1518     return mpImpl->mbIsMainViewShell;
1519     //    return GetViewShellBase().GetMainViewShell() == this;
1520 }
1521 
1522 void ViewShell::SetIsMainViewShell (bool bIsMainViewShell)
1523 {
1524     if (bIsMainViewShell != mpImpl->mbIsMainViewShell)
1525     {
1526         mpImpl->mbIsMainViewShell = bIsMainViewShell;
1527         if (bIsMainViewShell)
1528         {
1529             GetDocSh()->Connect (this);
1530         }
1531         else
1532         {
1533             GetDocSh()->Disconnect (this);
1534         }
1535     }
1536 }
1537 
1538 
1539 
1540 
1541 ::sd::Window* ViewShell::GetActiveWindow (void) const
1542 {
1543     return mpActiveWindow;
1544 }
1545 
1546 
1547 
1548 
1549 void ViewShell::PrePaint()
1550 {
1551 }
1552 
1553 
1554 
1555 
1556 void ViewShell::Paint (const Rectangle&, ::sd::Window* )
1557 {
1558 }
1559 
1560 
1561 
1562 
1563 void ViewShell::Draw(OutputDevice &, const Region &)
1564 {
1565 }
1566 
1567 
1568 
1569 
1570 ZoomList* ViewShell::GetZoomList (void)
1571 {
1572     return mpZoomList;
1573 }
1574 
1575 
1576 
1577 
1578 void ViewShell::ShowUIControls (bool bVisible)
1579 {
1580     mpImpl->mbIsShowingUIControls = bVisible;
1581 
1582 	if (mbHasRulers)
1583 	{
1584 		if (mpHorizontalRuler.get() != NULL)
1585 			mpHorizontalRuler->Show( bVisible );
1586 
1587 		if (mpVerticalRuler.get() != NULL)
1588             mpVerticalRuler->Show( bVisible );
1589 	}
1590 
1591 	if (mpVerticalScrollBar.get() != NULL)
1592 		mpVerticalScrollBar->Show( bVisible );
1593 
1594 	if (mpHorizontalScrollBar.get() != NULL)
1595 		mpHorizontalScrollBar->Show( bVisible );
1596 
1597 	if (mpScrollBarBox.get() != NULL)
1598         mpScrollBarBox->Show(bVisible);
1599 
1600     if (mpContentWindow.get() != NULL)
1601         mpContentWindow->Show( bVisible );
1602 }
1603 
1604 
1605 
1606 
1607 
1608 bool ViewShell::RelocateToParentWindow (::Window* pParentWindow)
1609 {
1610     mpParentWindow = pParentWindow;
1611 
1612     mpParentWindow->SetBackground (Wallpaper());
1613 
1614     if (mpContentWindow.get() != NULL)
1615         mpContentWindow->SetParent(pParentWindow);
1616 
1617     if (mpHorizontalScrollBar.get() != NULL)
1618         mpHorizontalScrollBar->SetParent(mpParentWindow);
1619     if (mpVerticalScrollBar.get() != NULL)
1620         mpVerticalScrollBar->SetParent(mpParentWindow);
1621     if (mpScrollBarBox.get() != NULL)
1622         mpScrollBarBox->SetParent(mpParentWindow);
1623 
1624     return true;
1625 }
1626 
1627 
1628 
1629 } // end of namespace sd
1630 
1631 
1632 
1633 
1634 
1635 //===== ViewShellObjectBarFactory =============================================
1636 
1637 namespace {
1638 
1639 ViewShellObjectBarFactory::ViewShellObjectBarFactory (
1640     ::sd::ViewShell& rViewShell)
1641     : mrViewShell (rViewShell)
1642 {
1643 }
1644 
1645 
1646 
1647 
1648 ViewShellObjectBarFactory::~ViewShellObjectBarFactory (void)
1649 {
1650     for (ShellCache::iterator aI(maShellCache.begin());
1651          aI!=maShellCache.end();
1652          aI++)
1653     {
1654         delete aI->second;
1655     }
1656 }
1657 
1658 
1659 
1660 
1661 SfxShell* ViewShellObjectBarFactory::CreateShell (
1662     ::sd::ShellId nId,
1663     ::Window*,
1664     ::sd::FrameView* )
1665 {
1666     SfxShell* pShell = NULL;
1667 
1668     ShellCache::iterator aI (maShellCache.find(nId));
1669     if (aI == maShellCache.end() || aI->second==NULL)
1670     {
1671         ::sd::View* pView = mrViewShell.GetView();
1672         switch (nId)
1673         {
1674             case RID_BEZIER_TOOLBOX:
1675                 pShell = new ::sd::BezierObjectBar(&mrViewShell, pView);
1676                 break;
1677 
1678             case RID_DRAW_TEXT_TOOLBOX:
1679                 pShell = new ::sd::TextObjectBar(
1680                     &mrViewShell, mrViewShell.GetDoc()->GetPool(), pView);
1681                 break;
1682 
1683             case RID_DRAW_GRAF_TOOLBOX:
1684                 pShell = new ::sd::GraphicObjectBar(&mrViewShell, pView);
1685                 break;
1686 
1687             case RID_DRAW_MEDIA_TOOLBOX:
1688                 pShell = new ::sd::MediaObjectBar(&mrViewShell, pView);
1689                 break;
1690 
1691 			case RID_DRAW_TABLE_TOOLBOX:
1692 				pShell = ::sd::ui::table::CreateTableObjectBar( mrViewShell, pView );
1693 				break;
1694 
1695             case RID_SVX_EXTRUSION_BAR:
1696                 pShell = new ::svx::ExtrusionBar(
1697                     &mrViewShell.GetViewShellBase());
1698                 break;
1699 
1700             case RID_SVX_FONTWORK_BAR:
1701                 pShell = new ::svx::FontworkBar(
1702                     &mrViewShell.GetViewShellBase());
1703                 break;
1704 
1705             default:
1706                 pShell = NULL;
1707                 break;
1708         }
1709     }
1710     else
1711         pShell = aI->second;
1712 
1713     return pShell;
1714 }
1715 
1716 
1717 
1718 
1719 void ViewShellObjectBarFactory::ReleaseShell (SfxShell* pShell)
1720 {
1721     if (pShell != NULL)
1722         delete pShell;
1723 }
1724 
1725 } // end of anonymous namespace
1726