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