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