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