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