xref: /trunk/main/sd/source/ui/view/outlnvsh.cxx (revision f120fe41)
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 "OutlineViewShell.hxx"
28 
29 #include "ViewShellImplementation.hxx"
30 #include <memory>
31 #include "helpids.h"
32 #include "app.hrc"
33 #include <svx/hyprlink.hxx>
34 #include <svx/hyperdlg.hxx>
35 #include <svx/zoomslideritem.hxx>
36 
37 #include <sfx2/objface.hxx>
38 #include <sot/exchange.hxx>
39 #include <svx/ruler.hxx>
40 #include <svx/zoomitem.hxx>
41 #include <editeng/eeitem.hxx>
42 #include <editeng/flditem.hxx>
43 #include <sfx2/shell.hxx>
44 #include <sfx2/templdlg.hxx>
45 #include <sfx2/viewfac.hxx>
46 #include <sfx2/request.hxx>
47 #include <svx/hlnkitem.hxx>
48 #include <svx/svdotext.hxx>
49 #include <sfx2/dispatch.hxx>
50 #include <vcl/scrbar.hxx>
51 #include <svl/whiter.hxx>
52 #include <editeng/editstat.hxx>
53 #include <svl/itempool.hxx>
54 #include <sfx2/tplpitem.hxx>
55 #include <sfx2/sidebar/SidebarChildWindow.hxx>
56 #include <sfx2/sidebar/EnumContext.hxx>
57 #include <svx/svdorect.hxx>
58 #include <sot/formats.hxx>
59 #include <com/sun/star/linguistic2/XThesaurus.hpp>
60 #include <com/sun/star/i18n/TransliterationModules.hpp>
61 #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
62 #include <editeng/unolingu.hxx>
63 #include <comphelper/processfactory.hxx>
64 #include <editeng/outlobj.hxx>
65 #include <svl/cjkoptions.hxx>
66 #include <svtools/cliplistener.hxx>
67 #include <svl/srchitem.hxx>
68 #include <editeng/editobj.hxx>
69 #include "fubullet.hxx"
70 #include "optsitem.hxx"
71 
72 #include "strings.hrc"
73 #include "glob.hrc"
74 #include "res_bmp.hrc"
75 #include "Outliner.hxx"
76 #include "Window.hxx"
77 #include "TextObjectBar.hxx"
78 #include "drawdoc.hxx"
79 #include "sdresid.hxx"
80 #include "sdpage.hxx"
81 #include "fuoltext.hxx"
82 #include "FrameView.hxx"
83 #include "zoomlist.hxx"
84 #include "stlsheet.hxx"
85 #include "slideshow.hxx"
86 #include "SdUnoOutlineView.hxx"
87 #include "SpellDialogChildWindow.hxx"
88 
89 #include "AccessibleOutlineView.hxx"
90 #include "ViewShellBase.hxx"
91 #include "ViewShellManager.hxx"
92 #include "DrawController.hxx"
93 #include "framework/FrameworkHelper.hxx"
94 
95 using ::rtl::OUString;
96 using namespace ::com::sun::star;
97 using namespace ::com::sun::star::uno;
98 using namespace ::com::sun::star::lang;
99 using namespace ::com::sun::star::linguistic2;
100 
101 using namespace sd;
102 #define OutlineViewShell
103 #include "sdslots.hxx"
104 
105 namespace sd {
106 
107 #define MIN_ZOOM	       10       // Minimaler Zoomfaktor
108 #define MAX_ZOOM	     1000	    // Maximaler Zoomfaktor
109 
110 /************************************************************************/
111 
112 
113 /*************************************************************************
114 |*
115 |* SFX-Slotmap und Standardinterface deklarieren
116 |*
117 \************************************************************************/
118 
119 
120 SFX_IMPL_INTERFACE(OutlineViewShell, SfxShell, SdResId(STR_OUTLINEVIEWSHELL))
121 {
122 	SFX_POPUPMENU_REGISTRATION( SdResId(RID_OUTLINE_POPUP) );
123 	SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS | SFX_VISIBILITY_STANDARD |
124 								SFX_VISIBILITY_FULLSCREEN | SFX_VISIBILITY_SERVER,
125 								SdResId(RID_OUTLINE_TOOLBOX) );
126     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_APPLICATION | SFX_VISIBILITY_DESKTOP | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_CLIENT | SFX_VISIBILITY_VIEWER | SFX_VISIBILITY_READONLYDOC,
127             					SdResId(RID_DRAW_VIEWER_TOOLBOX) );
128 	SFX_CHILDWINDOW_REGISTRATION( SfxTemplateDialogWrapper::GetChildWindowId() );
129 	SFX_CHILDWINDOW_REGISTRATION( SvxHyperlinkDlgWrapper::GetChildWindowId() );
130 	SFX_CHILDWINDOW_REGISTRATION( SvxHlinkDlgWrapper::GetChildWindowId() );
131 	SFX_CHILDWINDOW_REGISTRATION( ::sd::SpellDialogChildWindow::GetChildWindowId() );
132 	SFX_CHILDWINDOW_REGISTRATION( SID_SEARCH_DLG );
133 	SFX_CHILDWINDOW_REGISTRATION(::sfx2::sidebar::SidebarChildWindow::GetChildWindowId());
134 }
135 
136 
137 TYPEINIT1( OutlineViewShell, ViewShell );
138 
139 
140 /*************************************************************************
141 |*
142 |* gemeinsamer Initialiserungsanteil der beiden Konstruktoren
143 |*
144 \************************************************************************/
145 
146 void OutlineViewShell::Construct(DrawDocShell* )
147 {
148 	sal_Bool bModified = GetDoc()->IsChanged();
149 
150     meShellType = ST_OUTLINE;
151 	Size aSize(29700, 21000);
152 	Point aWinPos (0, 0);
153 	Point aViewOrigin(0, 0);
154 	GetActiveWindow()->SetMinZoomAutoCalc(sal_False);
155 	GetActiveWindow()->SetMinZoom( MIN_ZOOM );
156 	GetActiveWindow()->SetMaxZoom( MAX_ZOOM );
157 	InitWindows(aViewOrigin, aSize, aWinPos);
158 	pOlView = new OutlineView(GetDocSh(), GetActiveWindow(), this);
159 	mpView = pOlView;			 // Pointer der Basisklasse ViewShell
160 
161 	SetPool( &GetDoc()->GetPool() );
162 
163 	SetZoom(69);
164 
165 	// Einstellungen der FrameView uebernehmen
166 	ReadFrameViewData(mpFrameView);
167 
168 	::Outliner* pOutl = pOlView->GetOutliner();
169 	pOutl->SetUpdateMode(sal_True);
170 
171 	if (!bModified)
172 	{
173 		pOutl->ClearModifyFlag();
174 	}
175 
176 	pLastPage = GetActualPage();
177 
178 	String aName( RTL_CONSTASCII_USTRINGPARAM( "OutlineViewShell" ));
179 	SetName (aName);
180 
181 	SetHelpId( SD_IF_SDOUTLINEVIEWSHELL );
182 	GetActiveWindow()->SetHelpId( HID_SDOUTLINEVIEWSHELL );
183 	GetActiveWindow()->SetUniqueId( HID_SDOUTLINEVIEWSHELL );
184 }
185 
186 
187 
188 
189 Reference<drawing::XDrawSubController> OutlineViewShell::CreateSubController (void)
190 {
191     Reference<drawing::XDrawSubController> xSubController;
192 
193     if (IsMainViewShell())
194     {
195         // Create uno sub controller for the main view shell.
196         xSubController = Reference<drawing::XDrawSubController>(
197             new SdUnoOutlineView (
198                 GetViewShellBase().GetDrawController(),
199                 *this,
200                 *GetView()));
201     }
202 
203     return xSubController;
204 }
205 
206 
207 
208 
209 /*************************************************************************
210 |*
211 |* Standard-Konstruktor, Fenster duerfen nicht automatisch zentrieren
212 |*
213 \************************************************************************/
214 
215 OutlineViewShell::OutlineViewShell (
216     SfxViewFrame* pFrame,
217     ViewShellBase& rViewShellBase,
218     ::Window* pParentWindow,
219     FrameView* pFrameViewArgument)
220     : ViewShell(pFrame, pParentWindow, rViewShellBase),
221       pOlView(NULL),
222       pLastPage( NULL ),
223       pClipEvtLstnr(NULL),
224       bPastePossible(false),
225       mbInitialized(false)
226 
227 {
228 	if (pFrameViewArgument != NULL)
229 		mpFrameView = pFrameViewArgument;
230 	else
231         mpFrameView = new FrameView(GetDoc());
232 
233 	mpFrameView->Connect();
234 
235 	Construct(GetDocSh());
236 
237     SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_OutlineText));
238 }
239 
240 /*************************************************************************
241 |*
242 |* Destruktor
243 |*
244 \************************************************************************/
245 
246 OutlineViewShell::~OutlineViewShell()
247 {
248 	DisposeFunctions();
249 
250 	delete pOlView;
251 
252 	mpFrameView->Disconnect();
253 
254 	if ( pClipEvtLstnr )
255 	{
256 		pClipEvtLstnr->AddRemoveListener( GetActiveWindow(), sal_False );
257 		pClipEvtLstnr->ClearCallbackLink();		// #103849# prevent callback if another thread is waiting
258 		pClipEvtLstnr->release();
259 	}
260 }
261 
262 
263 
264 
265 void OutlineViewShell::Shutdown (void)
266 {
267     ViewShell::Shutdown();
268 
269     PrepareClose();
270 }
271 
272 
273 
274 
275 /*************************************************************************
276 |*
277 |* Paint-Methode: das Ereignis wird vom Fenster pWindow an
278 |* die Viewshell und die aktuelle Funktion weitergeleitet
279 |*
280 \************************************************************************/
281 
282 void OutlineViewShell::Paint(const Rectangle& rRect, ::sd::Window* pWin)
283 {
284 	if (pOlView)
285 	{
286 		pOlView->Paint(rRect, pWin);
287 	}
288 
289 	if(HasCurrentFunction())
290 	{
291 		GetCurrentFunction()->Paint(rRect, pWin);
292 	}
293 }
294 
295 void OutlineViewShell::ArrangeGUIElements ()
296 {
297     // Retrieve the current size (thickness) of the scroll bars.  That is
298     // the width of the vertical and the height of the horizontal scroll
299     // bar.
300     int nScrollBarSize =
301         GetParentWindow()->GetSettings().GetStyleSettings().GetScrollBarSize();
302 	maScrBarWH = Size (nScrollBarSize, nScrollBarSize);
303 
304 	ViewShell::ArrangeGUIElements ();
305 
306     ::sd::Window* pWindow = mpContentWindow.get();
307     if (pWindow != NULL)
308     {
309         pWindow->SetMinZoomAutoCalc(sal_False);
310 
311         // pWindow->SetPosSizePixel(rNewPos, Size(nSizeX, nSizeY));
312 
313         // OutputArea der OutlinerView aendern
314         OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow);
315 
316         Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel());
317 //		aWin.nLeft = pOlView->GetPageNumberWidthPixel();
318 
319         aWin = pWindow->PixelToLogic(aWin);
320         pOutlinerView->SetOutputArea(aWin);
321 
322         Rectangle aVis = pOutlinerView->GetVisArea();
323 
324         Rectangle aText = Rectangle(Point(0,0),
325             Size(pOlView->GetPaperWidth(),
326                 pOlView->GetOutliner()->GetTextHeight()));
327         aText.Bottom() += aWin.GetHeight();
328 
329         if (!aWin.IsEmpty())			// nicht beim Oeffnen
330         {
331             InitWindows(Point(0,0), aText.GetSize(), Point(aVis.TopLeft()));
332             UpdateScrollBars();
333         }
334     }
335 }
336 
337 /*************************************************************************
338 |*
339 |* SfxRequests fuer Controller bearbeiten
340 |*
341 \************************************************************************/
342 
343 void OutlineViewShell::ExecCtrl(SfxRequest &rReq)
344 {
345 	sal_uInt16 nSlot = rReq.GetSlot();
346 	switch ( nSlot )
347 	{
348 		case SID_MAIL_SCROLLBODY_PAGEDOWN:
349 		{
350             ExecReq( rReq );
351 			break;
352 		}
353 
354 		case SID_OPT_LOCALE_CHANGED:
355 		{
356 			pOlView->GetOutliner()->UpdateFields();
357 			UpdatePreview( GetActualPage() );
358 			rReq.Done();
359             break;
360 		}
361 
362 		default:
363 		break;
364 	}
365 }
366 
367 
368 
369 
370 void OutlineViewShell::AddWindow (::sd::Window* pWin)
371 {
372     pOlView->AddWindowToPaintView(pWin);
373 }
374 
375 
376 
377 
378 void OutlineViewShell::RemoveWindow (::sd::Window* pWin)
379 {
380     pOlView->DeleteWindowFromPaintView(pWin);
381 }
382 
383 
384 
385 
386 /*************************************************************************
387 |*
388 |* Activate(), beim ersten Aufruf erfolgt ein Update der Felder
389 |*
390 \************************************************************************/
391 void OutlineViewShell::Activate( sal_Bool bIsMDIActivate )
392 {
393     if ( ! mbInitialized)
394     {
395         mbInitialized = true;
396     	SfxRequest aRequest (SID_EDIT_OUTLINER, 0, GetDoc()->GetItemPool());
397         FuPermanent (aRequest);
398     }
399 
400     ViewShell::Activate( bIsMDIActivate );
401     pOlView->SetLinks();
402     pOlView->ConnectToApplication();
403 
404     if( bIsMDIActivate )
405     {
406         OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() );
407         ::Outliner* pOutl = pOutlinerView->GetOutliner();
408         pOutl->UpdateFields();
409     }
410 }
411 
412 /*************************************************************************
413 |*
414 |* Deactivate()
415 |*
416 \************************************************************************/
417 void OutlineViewShell::Deactivate( sal_Bool bIsMDIActivate )
418 {
419     pOlView->DisconnectFromApplication();
420 
421     // #96416# Links must be kept also on deactivated viewshell, to allow drag'n'drop
422     // to function properly
423     // pOlView->ResetLinks();
424 
425     ViewShell::Deactivate( bIsMDIActivate );
426 }
427 
428 /*************************************************************************
429 |*
430 |* Status von Controller-SfxSlots setzen
431 |*
432 \************************************************************************/
433 void OutlineViewShell::GetCtrlState(SfxItemSet &rSet)
434 {
435 	if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_HYPERLINK_GETLINK))
436 	{
437 		SvxHyperlinkItem aHLinkItem;
438 
439 		OutlinerView* pOLV = pOlView->GetViewByWindow(GetActiveWindow());
440 		if (pOLV)
441 		{
442 			const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
443 			if (pFieldItem)
444 			{
445                 ESelection aSel = pOLV->GetSelection();
446                 if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 )
447                 {
448 				    const SvxFieldData* pField = pFieldItem->GetField();
449 				    if ( pField->ISA(SvxURLField) )
450 				    {
451 					    aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation());
452 					    aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL());
453 					    aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame());
454 				    }
455                 }
456 			}
457 		}
458 		rSet.Put(aHLinkItem);
459 	}
460     rSet.Put( SfxBoolItem( SID_READONLY_MODE, GetDocSh()->IsReadOnly() ) );
461 
462 	if ( SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN) )
463 		rSet.Put( SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN, sal_True ) );
464 
465 	if ( SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_TRANSLITERATE_HALFWIDTH) ||
466 		 SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_TRANSLITERATE_FULLWIDTH) ||
467 		 SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_TRANSLITERATE_HIRAGANA) ||
468 		 SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_TRANSLITERATE_KATAGANA) )
469 	{
470         SvtCJKOptions aCJKOptions;
471 		if( !aCJKOptions.IsChangeCaseMapEnabled() )
472 		{
473             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_False );
474             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_False );
475             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_False );
476             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_False );
477 			rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH );
478 			rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH );
479 			rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA );
480 			rSet.DisableItem( SID_TRANSLITERATE_KATAGANA );
481 		}
482         else
483         {
484             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_True );
485             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_True );
486             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_True );
487             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_True );
488         }
489 	}
490 }
491 
492 /*************************************************************************
493 |*
494 |* SfxRequests fuer Support-Funktionen
495 |*
496 \************************************************************************/
497 
498 void OutlineViewShell::FuSupport(SfxRequest &rReq)
499 {
500 	if( rReq.GetSlot() == SID_STYLE_FAMILY && rReq.GetArgs())
501 		GetDocSh()->SetStyleFamily(((SfxUInt16Item&)rReq.GetArgs()->Get( SID_STYLE_FAMILY )).GetValue());
502 
503 	sal_Bool bPreviewState = sal_False;
504 	sal_uLong nSlot = rReq.GetSlot();
505 
506 	std::auto_ptr< OutlineViewModelChangeGuard > aGuard;
507 	if( pOlView && (
508         (nSlot == SID_TRANSLITERATE_SENTENCE_CASE) ||
509         (nSlot == SID_TRANSLITERATE_TITLE_CASE) ||
510         (nSlot == SID_TRANSLITERATE_TOGGLE_CASE) ||
511 		(nSlot == SID_TRANSLITERATE_UPPER) ||
512 		(nSlot == SID_TRANSLITERATE_LOWER) ||
513 		(nSlot == SID_TRANSLITERATE_HALFWIDTH) ||
514 		(nSlot == SID_TRANSLITERATE_FULLWIDTH) ||
515 		(nSlot == SID_TRANSLITERATE_HIRAGANA) ||
516 		(nSlot == SID_TRANSLITERATE_KATAGANA) ||
517 		(nSlot == SID_CUT) ||
518 //		(nSlot == SID_COPY) ||
519 		(nSlot == SID_PASTE) ||
520 		(nSlot == SID_DELETE)))
521 	{
522 		aGuard.reset( new OutlineViewModelChangeGuard( *pOlView ) );
523 	}
524 
525 	switch ( nSlot )
526 	{
527 		case SID_CUT:
528 		{
529 			if(HasCurrentFunction())
530 			{
531 				GetCurrentFunction()->DoCut();
532 			}
533 			else if (pOlView)
534 			{
535 				pOlView->DoCut();
536 			}
537 			rReq.Done();
538 			bPreviewState = sal_True;
539 		}
540 		break;
541 
542 		case SID_COPY:
543 		{
544 			if(HasCurrentFunction())
545 			{
546 				GetCurrentFunction()->DoCopy();
547 			}
548 			else if (pOlView)
549 			{
550 				pOlView->DoCopy();
551 			}
552 			rReq.Done();
553 			bPreviewState = sal_True;
554 		}
555 		break;
556 
557 		case SID_PASTE:
558 		{
559             OutlineViewPageChangesGuard aGuard2(pOlView);
560 
561 			if(HasCurrentFunction())
562 			{
563 				GetCurrentFunction()->DoPaste();
564 			}
565 			else if (pOlView)
566 			{
567 				pOlView->DoPaste();
568 			}
569 			rReq.Done();
570 			bPreviewState = sal_True;
571 		}
572 		break;
573 
574 		case SID_DELETE:
575 		{
576 			if( pOlView )
577 			{
578 				OutlinerView* pOutlView = pOlView->GetViewByWindow(GetActiveWindow());
579 				if (pOutlView)
580 				{
581 					OutlineViewPageChangesGuard aGuard2(pOlView);
582 
583 					KeyCode  aKCode(KEY_DELETE);
584 					KeyEvent aKEvt( 0, aKCode );
585 					pOutlView->PostKeyEvent(aKEvt);
586 
587 					FunctionReference xFunc( GetCurrentFunction() );
588 					FuOutlineText* pFuOutlineText = dynamic_cast< FuOutlineText* >( xFunc.get() );
589                     if( pFuOutlineText )
590                         pFuOutlineText->UpdateForKeyPress (aKEvt);
591 				}
592 			}
593 			rReq.Done();
594 			bPreviewState = sal_True;
595 		}
596 		break;
597 
598 		case SID_DRAWINGMODE:
599 		case SID_NOTESMODE:
600 		case SID_HANDOUTMODE:
601 		case SID_DIAMODE:
602 		case SID_OUTLINEMODE:
603             framework::FrameworkHelper::Instance(GetViewShellBase())->HandleModeChangeSlot(
604                 nSlot,
605                 rReq);
606 			rReq.Done();
607 			break;
608 
609 		case SID_RULER:
610 			SetRuler( !HasRuler() );
611 			Invalidate( SID_RULER );
612 			rReq.Done();
613 		break;
614 
615 		case SID_ZOOM_PREV:
616 		{
617 			if (mpZoomList->IsPreviousPossible())
618 			{
619 				// Vorheriges ZoomRect einstellen
620 				SetZoomRect(mpZoomList->GetPreviousZoomRect());
621 			}
622 			rReq.Done ();
623 		}
624 		break;
625 
626 		case SID_ZOOM_NEXT:
627 		{
628 			if (mpZoomList->IsNextPossible())
629 			{
630 				// Naechstes ZoomRect einstellen
631 				SetZoomRect(mpZoomList->GetNextZoomRect());
632 			}
633 			rReq.Done ();
634 		}
635 		break;
636 
637 		case SID_AUTOSPELL_CHECK:
638 		{
639 			GetDoc()->SetOnlineSpell(!GetDoc()->GetOnlineSpell());
640 			rReq.Done ();
641 		}
642 		break;
643 
644         case SID_TRANSLITERATE_SENTENCE_CASE:
645         case SID_TRANSLITERATE_TITLE_CASE:
646         case SID_TRANSLITERATE_TOGGLE_CASE:
647 		case SID_TRANSLITERATE_UPPER:
648 		case SID_TRANSLITERATE_LOWER:
649 		case SID_TRANSLITERATE_HALFWIDTH:
650 		case SID_TRANSLITERATE_FULLWIDTH:
651 		case SID_TRANSLITERATE_HIRAGANA:
652 		case SID_TRANSLITERATE_KATAGANA:
653 		{
654 			OutlinerView* pOLV = pOlView->GetViewByWindow( GetActiveWindow() );
655 			if( pOLV )
656 			{
657 				using namespace ::com::sun::star::i18n;
658 				sal_Int32 nType = 0;
659 
660 				switch( nSlot )
661 				{
662                     case SID_TRANSLITERATE_SENTENCE_CASE:
663                         nType = TransliterationModulesExtra::SENTENCE_CASE;
664                         break;
665                     case SID_TRANSLITERATE_TITLE_CASE:
666                         nType = TransliterationModulesExtra::TITLE_CASE;
667                         break;
668                     case SID_TRANSLITERATE_TOGGLE_CASE:
669                         nType = TransliterationModulesExtra::TOGGLE_CASE;
670                         break;
671                     case SID_TRANSLITERATE_UPPER:
672 						nType = TransliterationModules_LOWERCASE_UPPERCASE;
673 						break;
674 					case SID_TRANSLITERATE_LOWER:
675 						nType = TransliterationModules_UPPERCASE_LOWERCASE;
676 						break;
677 					case SID_TRANSLITERATE_HALFWIDTH:
678 						nType = TransliterationModules_FULLWIDTH_HALFWIDTH;
679 						break;
680 					case SID_TRANSLITERATE_FULLWIDTH:
681 						nType = TransliterationModules_HALFWIDTH_FULLWIDTH;
682 						break;
683 					case SID_TRANSLITERATE_HIRAGANA:
684 						nType = TransliterationModules_KATAKANA_HIRAGANA;
685 						break;
686 					case SID_TRANSLITERATE_KATAGANA:
687 						nType = TransliterationModules_HIRAGANA_KATAKANA;
688 						break;
689 				}
690 
691 				pOLV->TransliterateText( nType );
692 			}
693 
694 			rReq.Done();
695 			bPreviewState = sal_True;
696 		}
697 		break;
698 
699 		// #96090# added Undo/Redo handling
700 		case SID_UNDO :
701 		{
702 			OutlineViewPageChangesGuard aGuard2(pOlView);
703 			ImpSidUndo(sal_False, rReq);
704 		}
705 		break;
706 		case SID_REDO :
707 		{
708 			OutlineViewPageChangesGuard aGuard2(pOlView);
709 			ImpSidRedo(sal_False, rReq);
710 		}
711 		break;
712 
713 		default:
714 		break;
715 	}
716 
717 	if( bPreviewState )
718 		Invalidate( SID_PREVIEW_STATE );
719 
720 	Invalidate(SID_CUT);
721 	Invalidate(SID_COPY);
722 	Invalidate(SID_PASTE);
723 }
724 
725 /*************************************************************************
726 |*
727 |* SfxRequests fuer permanente Funktionen
728 |*
729 \************************************************************************/
730 
731 void OutlineViewShell::FuPermanent(SfxRequest &rReq)
732 {
733 	if(HasCurrentFunction())
734 	{
735 		DeactivateCurrentFunction(true);
736 	}
737 
738 	switch ( rReq.GetSlot() )
739 	{
740 		case SID_EDIT_OUTLINER:
741 		{
742 			::Outliner* pOutl = pOlView->GetOutliner();
743 			if( pOutl )
744 			{
745 				pOutl->GetUndoManager().Clear();
746 				pOutl->UpdateFields();
747 			}
748 
749 			SetCurrentFunction( FuOutlineText::Create(this,GetActiveWindow(),pOlView,GetDoc(),rReq) );
750 
751 			rReq.Done();
752 		}
753 		break;
754 
755 	  default:
756 	  break;
757 	}
758 
759 	if(HasOldFunction())
760 	{
761 		GetOldFunction()->Deactivate();
762 		SetOldFunction(0);
763 	}
764 
765 	if(HasCurrentFunction())
766 	{
767 		GetCurrentFunction()->Activate();
768 		SetOldFunction(GetCurrentFunction());
769 	}
770 }
771 
772 
773 IMPL_LINK( OutlineViewShell, ClipboardChanged, TransferableDataHelper*, pDataHelper )
774 {
775 	if ( pDataHelper )
776 	{
777 		bPastePossible = ( pDataHelper->GetFormatCount() != 0 &&
778 							( pDataHelper->HasFormat( FORMAT_STRING ) ||
779 							  pDataHelper->HasFormat( FORMAT_RTF ) ||
780 							  pDataHelper->HasFormat( SOT_FORMATSTR_ID_HTML ) ) );
781 
782 		SfxBindings& rBindings = GetViewFrame()->GetBindings();
783 		rBindings.Invalidate( SID_PASTE );
784         rBindings.Invalidate( SID_PASTE_SPECIAL );
785 		rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
786 	}
787 	return 0;
788 }
789 
790 /*************************************************************************
791 |*
792 |* Status (Enabled/Disabled) von Menue-SfxSlots setzen
793 |*
794 \************************************************************************/
795 
796 void OutlineViewShell::GetMenuState( SfxItemSet &rSet )
797 {
798 	ViewShell::GetMenuState(rSet);
799 
800 	// Vorlagenkatalog darf nicht aufgerufen werden
801 	rSet.DisableItem( SID_STYLE_CATALOG );
802 
803 	rSet.Put(SfxBoolItem(SID_DIAMODE, sal_False));
804 	rSet.Put(SfxBoolItem(SID_DRAWINGMODE, sal_False));
805 	rSet.Put(SfxBoolItem(SID_OUTLINEMODE, sal_True));
806 	rSet.Put(SfxBoolItem(SID_NOTESMODE, sal_False));
807 	rSet.Put(SfxBoolItem(SID_HANDOUTMODE, sal_False));
808 
809 	if (!mpZoomList->IsNextPossible())
810 	{
811 	   rSet.DisableItem(SID_ZOOM_NEXT);
812 	}
813 	if (!mpZoomList->IsPreviousPossible())
814 	{
815 	   rSet.DisableItem(SID_ZOOM_PREV);
816 	}
817 
818 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ZOOM_IN ) ||
819 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ZOOM_OUT ) )
820 	{
821 		if( GetActiveWindow()->GetZoom() <= GetActiveWindow()->GetMinZoom() || GetDocSh()->IsUIActive() )
822 			rSet.DisableItem( SID_ZOOM_IN );
823 		if( GetActiveWindow()->GetZoom() >= GetActiveWindow()->GetMaxZoom() || GetDocSh()->IsUIActive() )
824 			rSet.DisableItem( SID_ZOOM_OUT );
825 	}
826 
827 	::Outliner* pOutl = pOlView->GetOutliner();
828 	DBG_ASSERT(pOutl, "OutlineViewShell::GetMenuState(), no outliner? Fatality!");
829 	if( !pOutl )
830 		return;
831 
832 	// 'Alles auswaehlen' zulassen?
833 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_SELECTALL ) )
834 	{
835 		sal_uLong nParaCount = pOutl->GetParagraphCount();
836 		sal_Bool bDisable = nParaCount == 0;
837 		if (!bDisable && nParaCount == 1)
838 		{
839 			String aTest( pOutl->GetText( pOutl->GetParagraph( 0 ) ) );
840 			if (aTest.Len() == 0)
841 			{
842 				bDisable = sal_True;
843 			}
844 		}
845 		if (bDisable)
846 			rSet.DisableItem(SID_SELECTALL);
847 	}
848 
849 	// Status des Lineals setzen
850 	rSet.Put( SfxBoolItem( SID_RULER, HasRuler() ) );
851 
852 	// Formatierung ein oder aus?
853 	rSet.Put( SfxBoolItem( SID_OUTLINE_FORMAT, !pOutl->IsFlatMode() ) );
854 
855 	if( pOutl->IsFlatMode() )
856 		rSet.DisableItem( SID_COLORVIEW );
857 	else
858 	{
859 		// Farbansicht ein/aus
860 		sal_uLong nCntrl = pOutl->GetControlWord();
861 		sal_Bool bNoColor = sal_False;
862 		if (nCntrl & EE_CNTRL_NOCOLORS)
863 			bNoColor = sal_True;
864 
865 		rSet.Put( SfxBoolItem( SID_COLORVIEW, bNoColor ) );
866 	}
867 
868 	// Buttons der Werkzeugleiste
869 	// zunaechst selektionsabhaengige: COLLAPSE, EXPAND
870 	sal_Bool bDisableCollapse = sal_True;
871 	sal_Bool bDisableExpand   = sal_True;
872 	sal_Bool bUnique		  = sal_True;
873 	OutlinerView* pOutlinerView = pOlView->GetViewByWindow(GetActiveWindow());
874 	List* pList = pOutlinerView->CreateSelectionList();
875 	Paragraph* pPara = (Paragraph*)pList->First();
876 
877 	sal_Int16 nDepth;
878 	sal_Int16 nTmpDepth = pOutl->GetDepth( (sal_uInt16) pOutl->GetAbsPos( pPara ) );
879 	bool bPage = pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE );
880 	while (pPara)
881 	{
882 		nDepth = pOutl->GetDepth( (sal_uInt16) pOutl->GetAbsPos( pPara ) );
883 
884 		if( nDepth != nTmpDepth )
885 			bUnique = sal_False;
886 		if( bPage != pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
887 			bUnique = sal_False;
888 		if (!pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara))
889 			bDisableExpand = sal_False;
890 		if (pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara))
891 			bDisableCollapse = sal_False;
892 
893 		pPara = (Paragraph*)pList->Next();
894 	}
895 
896 	delete pList;
897 
898 	if (bDisableExpand)
899 		rSet.DisableItem(SID_OUTLINE_EXPAND);
900 	if (bDisableCollapse)
901 		rSet.DisableItem(SID_OUTLINE_COLLAPSE);
902 
903 	// ergibt die Selektion ein eindeutiges Praesentationslayout?
904 	// wenn nicht, duerfen die Vorlagen nicht bearbeitet werden
905 	SfxItemSet aSet(*rSet.GetPool(), SID_STATUS_LAYOUT, SID_STATUS_LAYOUT);
906 	GetStatusBarState(aSet);
907 	String aTest(((SfxStringItem&)aSet.Get(SID_STATUS_LAYOUT)).GetValue());
908 	if (aTest.Len() == 0)
909 	{
910 		bUnique = sal_False;
911 		rSet.DisableItem(SID_PRESENTATION_TEMPLATES);
912 	}
913 
914 	if (!bUnique)
915 		rSet.DisableItem( SID_PRESENTATIONOBJECT );
916 
917 	// jetzt die selektionsunabhaengigen: COLLAPSE_ALL, EXPAND_ALL
918 	sal_Bool bDisableCollapseAll = sal_True;
919 	sal_Bool bDisableExpandAll	 = sal_True;
920 
921 	// wenn schon die Selektion etwas kollabierbares/expandierbares enthaelt
922 	if (!bDisableCollapse)
923 		bDisableCollapseAll = sal_False;
924 	if (!bDisableExpand)
925 		bDisableExpandAll = sal_False;
926 
927 	// schade, so billig kommen wir nicht davon; alle Absaetze durchsuchen
928 	if (bDisableCollapseAll || bDisableExpandAll)
929 	{
930 		sal_uLong nParaPos = 0;
931 		pPara = pOutl->GetParagraph( nParaPos );
932 		while (pPara && (bDisableCollapseAll || bDisableExpandAll))
933 		{
934 			if (!pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara))
935 				bDisableExpandAll = sal_False;
936 
937 			if (pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara))
938 				bDisableCollapseAll = sal_False;
939 
940 			pPara = pOutl->GetParagraph( ++nParaPos );
941 		}
942 	}
943 
944 	if (bDisableExpandAll)
945 		rSet.DisableItem(SID_OUTLINE_EXPAND_ALL);
946 	if (bDisableCollapseAll)
947 		rSet.DisableItem(SID_OUTLINE_COLLAPSE_ALL);
948 
949 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PASTE ) )
950 	{
951 		if ( !pClipEvtLstnr )
952 		{
953 			// create listener
954 			pClipEvtLstnr = new TransferableClipboardListener( LINK( this, OutlineViewShell, ClipboardChanged ) );
955 			pClipEvtLstnr->acquire();
956 			pClipEvtLstnr->AddRemoveListener( GetActiveWindow(), sal_True );
957 
958 			// get initial state
959 			TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
960 			bPastePossible = ( aDataHelper.GetFormatCount() != 0 &&
961 								( aDataHelper.HasFormat( FORMAT_STRING ) ||
962 								  aDataHelper.HasFormat( FORMAT_RTF ) ||
963 								  aDataHelper.HasFormat( SOT_FORMATSTR_ID_HTML ) ) );
964 		}
965 
966 		if( !bPastePossible )
967 		{
968 			rSet.DisableItem( SID_PASTE );
969 		}
970 	}
971 
972 	if (!pOlView->GetViewByWindow(GetActiveWindow())->HasSelection())
973 	{
974 		rSet.DisableItem(SID_CUT);
975 		rSet.DisableItem(SID_COPY);
976 	}
977 
978 	if (pOlView->GetOutliner()->IsModified())
979 	{
980 		GetDoc()->SetChanged(sal_True);
981 	}
982 
983 	// Da �berladen, muss hier der Status gesetzt werden
984 	if( !GetDocSh()->IsModified() )
985 	{
986 		rSet.DisableItem( SID_SAVEDOC );
987 	}
988 
989 	if ( GetDocSh()->IsReadOnly() )
990 	{
991 		rSet.DisableItem( SID_AUTOSPELL_CHECK );
992 	}
993 	else
994 	{
995 		if (GetDoc()->GetOnlineSpell())
996 		{
997 			rSet.Put(SfxBoolItem(SID_AUTOSPELL_CHECK, sal_True));
998 		}
999 		else
1000 		{
1001 			rSet.Put(SfxBoolItem(SID_AUTOSPELL_CHECK, sal_False));
1002 		}
1003 	}
1004 
1005 	// Feldbefehle
1006 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_MODIFY_FIELD ) )
1007 	{
1008 		const SvxFieldItem* pFldItem = pOutlinerView->GetFieldAtSelection();
1009 
1010 		if( !( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
1011 							pFldItem->GetField()->ISA( SvxAuthorField ) ||
1012 							pFldItem->GetField()->ISA( SvxExtFileField ) ||
1013 							pFldItem->GetField()->ISA( SvxExtTimeField ) ) ) )
1014 		{
1015 			rSet.DisableItem( SID_MODIFY_FIELD );
1016 		}
1017 	}
1018 
1019 	if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_EXPAND_PAGE))
1020 	{
1021 		sal_Bool bDisable = sal_True;
1022 		sal_uInt16 i = 0;
1023 		sal_uInt16 nCount = GetDoc()->GetSdPageCount(PK_STANDARD);
1024 		pOlView->SetSelectedPages();
1025 
1026 		while (i < nCount && bDisable)
1027 		{
1028 			SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
1029 
1030 			if (pPage->IsSelected())
1031 			{
1032 				SdrObject* pObj = pPage->GetPresObj(PRESOBJ_OUTLINE);
1033 
1034                 if (pObj!=NULL )
1035 				{
1036 					if( !pObj->IsEmptyPresObj() )
1037 					{
1038 						bDisable = false;
1039 					}
1040 					else
1041 					{
1042 						// check if the object is in edit, than its temporarely not empty
1043 						SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
1044 						if( pTextObj )
1045 						{
1046 							OutlinerParaObject* pParaObj = pTextObj->GetEditOutlinerParaObject();
1047 							if( pParaObj )
1048 							{
1049 								delete pParaObj;
1050 								bDisable = false;
1051 							}
1052 						}
1053 					}
1054 				}
1055 			}
1056 
1057 			i++;
1058 		}
1059 
1060 		if (bDisable)
1061 		{
1062 			rSet.DisableItem(SID_EXPAND_PAGE);
1063 		}
1064 	}
1065 
1066 	if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_SUMMARY_PAGE))
1067 	{
1068 		sal_Bool bDisable = sal_True;
1069 		sal_uInt16 i = 0;
1070 		sal_uInt16 nCount = GetDoc()->GetSdPageCount(PK_STANDARD);
1071 		pOlView->SetSelectedPages();
1072 
1073 		while (i < nCount && bDisable)
1074 		{
1075 			SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
1076 
1077 			if (pPage->IsSelected())
1078 			{
1079 				SdrObject* pObj = pPage->GetPresObj(PRESOBJ_TITLE);
1080 
1081 				if (pObj && !pObj->IsEmptyPresObj())
1082 				{
1083 					bDisable = sal_False;
1084 				}
1085 			}
1086 
1087 			i++;
1088 		}
1089 
1090 		if (bDisable)
1091 		{
1092 			rSet.DisableItem(SID_SUMMARY_PAGE);
1093 		}
1094 	}
1095 
1096     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_THESAURUS ) )
1097 	{
1098 		if ( !pOlView->IsTextEdit() )
1099 		{
1100 			rSet.DisableItem( SID_THESAURUS );
1101 		}
1102 		else
1103 		{
1104 			LanguageType            eLang = GetDoc()->GetLanguage( EE_CHAR_LANGUAGE );
1105 	        Reference< XThesaurus > xThesaurus( LinguMgr::GetThesaurus() );
1106 			Locale                  aLocale;
1107 
1108 			SvxLanguageToLocale( aLocale, eLang );
1109 
1110             if (!xThesaurus.is() || eLang == LANGUAGE_NONE || !xThesaurus->hasLocale(aLocale))
1111 				rSet.DisableItem( SID_THESAURUS );
1112 		}
1113 	}
1114 
1115 	// Starten der Praesentation moeglich?
1116 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PRESENTATION ) )
1117 	{
1118 		sal_Bool bDisable = sal_True;
1119 		sal_uInt16 nCount = GetDoc()->GetSdPageCount( PK_STANDARD );
1120 
1121 		for( sal_uInt16 i = 0; i < nCount && bDisable; i++ )
1122 		{
1123 			SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
1124 
1125 			if( !pPage->IsExcluded() )
1126 				bDisable = sal_False;
1127 		}
1128 		if( bDisable || GetDocSh()->IsPreview())
1129 		{
1130 			rSet.DisableItem( SID_PRESENTATION );
1131 		}
1132 	}
1133 
1134 	FuBullet::GetSlotState( rSet, this, GetViewFrame() );
1135 
1136 	//rSet.DisableItem( SID_PRINTDOC );
1137 	//rSet.DisableItem( SID_PRINTDOCDIRECT );
1138 	//rSet.DisableItem( SID_SETUPPRINTER );
1139 }
1140 
1141 /*************************************************************************
1142 |*
1143 |* wird gerufen, wenn ScrollBar benutzt wird
1144 |*
1145 \************************************************************************/
1146 
1147 long OutlineViewShell::VirtHScrollHdl(ScrollBar* pHScroll)
1148 {
1149 	long   nThumb = pHScroll->GetThumbPos();
1150 	long   nRange = pHScroll->GetRange().Len();
1151 	double fX	  = (double) nThumb / nRange;
1152 
1153     Window* 	  pWin			= mpContentWindow.get();
1154     OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWin);
1155     long		  nViewWidth	= pWin->PixelToLogic(
1156         pWin->GetSizePixel()).Width();
1157     long		  nTextWidth	= pOlView->GetPaperWidth();
1158     nViewWidth					= Max(nViewWidth, nTextWidth);
1159     long		  nCurrentPos	= pOutlinerView->GetVisArea().Left();
1160     long		  nTargetPos	= (long)(fX * nViewWidth);
1161     long		  nDelta		= nTargetPos - nCurrentPos;
1162 
1163     pOutlinerView->HideCursor();
1164     pOutlinerView->Scroll(-nDelta, 0);
1165     pOutlinerView->ShowCursor(sal_False);
1166 
1167     pOlView->InvalidateSlideNumberArea();
1168 	return 0;
1169 }
1170 
1171 /*************************************************************************
1172 |*
1173 |* wird gerufen, wenn ScrollBar benutzt wird
1174 |*
1175 \************************************************************************/
1176 
1177 long OutlineViewShell::VirtVScrollHdl(ScrollBar* pVScroll)
1178 {
1179 	long nThumb = pVScroll->GetThumbPos();
1180 	long nRange = pVScroll->GetRange().Len();
1181 	double fY = (double) nThumb / nRange;
1182 
1183     Window* 	  pWin			= mpContentWindow.get();
1184     OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWin);
1185     long		  nViewHeight	= pWin->PixelToLogic(
1186         pWin->GetSizePixel()).Height();
1187     long		  nTextHeight	= pOlView->GetOutliner()->GetTextHeight();
1188     nViewHeight 			   += nTextHeight;
1189     long		  nCurrentPos	= pOutlinerView->GetVisArea().Top();
1190     long		  nTargetPos	= (long)(fY * nViewHeight);
1191     long		  nDelta		= nTargetPos - nCurrentPos;
1192 
1193     pOutlinerView->HideCursor();
1194     pOutlinerView->Scroll(0, -nDelta);
1195     pOutlinerView->ShowCursor(sal_False);
1196 
1197     pOlView->InvalidateSlideNumberArea();
1198 
1199 	return 0;
1200 }
1201 
1202 /*************************************************************************
1203 |*
1204 |* PrepareClose, wird gerufen, wenn die Shell zestoert werden soll,
1205 |* leitet den Aufruf an die View weiter
1206 |*
1207 \************************************************************************/
1208 
1209 sal_uInt16 OutlineViewShell::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing )
1210 {
1211 	if( ViewShell::PrepareClose(bUI, bForBrowsing) != sal_True )
1212 		return sal_False;
1213 
1214 	return pOlView == NULL || pOlView->PrepareClose(bUI);
1215 }
1216 
1217 
1218 /*************************************************************************
1219 |*
1220 |* Zoomen mit Zoomfaktor, OutlinerView informieren
1221 |*
1222 \************************************************************************/
1223 
1224 void OutlineViewShell::SetZoom(long nZoom)
1225 {
1226 	ViewShell::SetZoom(nZoom);
1227 
1228     ::sd::Window* pWindow = mpContentWindow.get();
1229     if (pWindow)
1230     {
1231         // OutputArea der OutlinerView aendern
1232         OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow);
1233         Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel());
1234         aWin = pWindow->PixelToLogic(aWin);
1235         pOutlinerView->SetOutputArea(aWin);
1236     }
1237 
1238 	// #106268#
1239 	GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
1240 	GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
1241 }
1242 
1243 /*************************************************************************
1244 |*
1245 |* Zoomen mit Zoomrechteck, OutlinerView informieren
1246 |*
1247 \************************************************************************/
1248 
1249 void OutlineViewShell::SetZoomRect(const Rectangle& rZoomRect)
1250 {
1251 	ViewShell::SetZoomRect(rZoomRect);
1252 
1253     ::sd::Window* pWindow = mpContentWindow.get();
1254     if (pWindow)
1255     {
1256         // OutputArea der OutlinerView aendern
1257         OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow);
1258         Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel());
1259         aWin = pWindow->PixelToLogic(aWin);
1260         pOutlinerView->SetOutputArea(aWin);
1261     }
1262 
1263 	// #106268#
1264 	GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
1265 	GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
1266 }
1267 
1268 /*************************************************************************
1269 |*
1270 |* Vorm Speichern das Model der Drawing Engine aktualisieren, dann den
1271 |* Call weiterleiten an die ObjectShell.
1272 |*
1273 \************************************************************************/
1274 
1275 void OutlineViewShell::Execute(SfxRequest& rReq)
1276 {
1277     bool bForwardCall = true;
1278 
1279 	switch(rReq.GetSlot())
1280 	{
1281 		case SID_SAVEDOC:
1282 		case SID_SAVEASDOC:
1283 			PrepareClose();
1284             break;
1285 
1286 		case SID_SEARCH_ITEM:
1287             // Forward this request to the the common (old) code of the
1288             // document shell.
1289             GetDocSh()->Execute (rReq);
1290             bForwardCall = false;
1291             break;
1292 
1293         case SID_SPELL_DIALOG:
1294         {
1295             SfxViewFrame* pViewFrame = GetViewFrame();
1296             if (rReq.GetArgs() != NULL)
1297                 pViewFrame->SetChildWindow (SID_SPELL_DIALOG,
1298                     ((const SfxBoolItem&) (rReq.GetArgs()->
1299                         Get(SID_SPELL_DIALOG))).GetValue());
1300             else
1301                 pViewFrame->ToggleChildWindow(SID_SPELL_DIALOG);
1302 
1303             pViewFrame->GetBindings().Invalidate(SID_SPELL_DIALOG);
1304             rReq.Done ();
1305 
1306             bForwardCall = false;
1307         }
1308         break;
1309 
1310 		default:
1311             OSL_TRACE ("OutlineViewShell::Execute(): can not handle slot %d", rReq.GetSlot());
1312             break;
1313 
1314 	}
1315 
1316     if (bForwardCall)
1317         ((DrawDocShell*)GetViewFrame()->GetObjectShell())->ExecuteSlot( rReq );
1318 }
1319 
1320 /*************************************************************************
1321 |*
1322 |* Read FrameViews data and set actual views data
1323 |*
1324 \************************************************************************/
1325 
1326 void OutlineViewShell::ReadFrameViewData(FrameView* pView)
1327 {
1328 	::Outliner* pOutl = pOlView->GetOutliner();
1329 
1330 	if ( pView->IsNoAttribs() )
1331 		pOutl->SetFlatMode( sal_True );   // Attribut-Darstellung ausschalten
1332 	else
1333 		pOutl->SetFlatMode( sal_False );  // Attribut-Darstellung einschalten
1334 
1335 	sal_uLong nCntrl = pOutl->GetControlWord();
1336 
1337 	if ( pView->IsNoColors() )
1338 		pOutl->SetControlWord(nCntrl | EE_CNTRL_NOCOLORS);   // Farbansicht ausschalten
1339 	else
1340 		pOutl->SetControlWord(nCntrl & ~EE_CNTRL_NOCOLORS);  // Farbansicht einschalten
1341 
1342 	sal_uInt16 nPage = mpFrameView->GetSelectedPage();
1343 	pLastPage = GetDoc()->GetSdPage( nPage, PK_STANDARD );
1344     pOlView->SetActualPage(pLastPage);
1345 }
1346 
1347 
1348 
1349 /*************************************************************************
1350 |*
1351 |* Write actual views data to FrameView
1352 |*
1353 \************************************************************************/
1354 
1355 void OutlineViewShell::WriteFrameViewData()
1356 {
1357 	::Outliner* pOutl = pOlView->GetOutliner();
1358 
1359 	sal_uLong nCntrl = pOutl->GetControlWord();
1360 	sal_Bool bNoColor = sal_False;
1361 	if (nCntrl & EE_CNTRL_NOCOLORS)
1362 		bNoColor = sal_True;
1363 	mpFrameView->SetNoColors(bNoColor);
1364 	mpFrameView->SetNoAttribs( pOutl->IsFlatMode() );
1365 	SdPage* pActualPage = pOlView->GetActualPage();
1366     DBG_ASSERT(pActualPage, "No current page");
1367 	if( pActualPage )
1368         mpFrameView->SetSelectedPage((pActualPage->GetPageNum() - 1) / 2);
1369 }
1370 
1371 
1372 /*************************************************************************
1373 |*
1374 |* SfxRequests fuer StatusBar bearbeiten
1375 |*
1376 \************************************************************************/
1377 
1378 void OutlineViewShell::ExecStatusBar(SfxRequest&)
1379 {
1380 }
1381 
1382 /*************************************************************************
1383 |*
1384 |* Statuswerte der Statusbar zurueckgeben
1385 |*
1386 \************************************************************************/
1387 
1388 void OutlineViewShell::GetStatusBarState(SfxItemSet& rSet)
1389 {
1390 	// Zoom-Item
1391 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOM ) )
1392 	{
1393 		SvxZoomItem* pZoomItem;
1394 		sal_uInt16 nZoom = (sal_uInt16) GetActiveWindow()->GetZoom();
1395 
1396 		pZoomItem = new SvxZoomItem( SVX_ZOOM_PERCENT, nZoom );
1397 
1398 		// Bereich einschraenken
1399 		sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL;
1400 		nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
1401 		nZoomValues &= ~SVX_ZOOM_ENABLE_WHOLEPAGE;
1402 		nZoomValues &= ~SVX_ZOOM_ENABLE_PAGEWIDTH;
1403 
1404 		pZoomItem->SetValueSet( nZoomValues );
1405 		rSet.Put( *pZoomItem );
1406 		delete pZoomItem;
1407 	}
1408 
1409 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOMSLIDER ) )
1410 	{
1411 		if (GetDocSh()->IsUIActive() || !GetActiveWindow() )
1412 		{
1413 			rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
1414 		}
1415 		else
1416 		{
1417 			sd::Window * pActiveWindow = GetActiveWindow();
1418 			SvxZoomSliderItem aZoomItem( (sal_uInt16) pActiveWindow->GetZoom(), (sal_uInt16)pActiveWindow->GetMinZoom(), (sal_uInt16)pActiveWindow->GetMaxZoom() ) ;
1419 			aZoomItem.AddSnappingPoint(100);
1420 			rSet.Put( aZoomItem );
1421 		}
1422 	}
1423 
1424 
1425 	// Seitenanzeige und Layout
1426 	/*
1427 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_PAGE ) ||
1428 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_LAYOUT ) )
1429 	*/
1430 	sal_uInt16	nPageCount = GetDoc()->GetSdPageCount( PK_STANDARD );
1431 	String	aPageStr, aLayoutStr;
1432 
1433 	::sd::Window*		pWin		= GetActiveWindow();
1434 	OutlinerView*	pActiveView = pOlView->GetViewByWindow( pWin );
1435 	::Outliner*     pOutliner   = pOlView->GetOutliner();
1436 	List*			pSelList	= (List*)pActiveView->CreateSelectionList();
1437 	Paragraph*		pFirstPara	= (Paragraph*)pSelList->First();
1438 	Paragraph*		pLastPara	= (Paragraph*)pSelList->Last();
1439 
1440 	if( !pOutliner->HasParaFlag(pFirstPara,PARAFLAG_ISPAGE) )
1441 		pFirstPara = pOlView->GetPrevTitle( pFirstPara );
1442 
1443 	if( !pOutliner->HasParaFlag(pLastPara, PARAFLAG_ISPAGE) )
1444 		pLastPara = pOlView->GetPrevTitle( pLastPara );
1445 
1446 	delete pSelList;				// die wurde extra fuer uns erzeugt
1447 
1448 	// nur eine Seite selektiert?
1449 	if( pFirstPara == pLastPara )
1450 	{
1451 		// wieviele Seiten sind vor der selektierten Seite?
1452 		sal_uLong nPos = 0L;
1453 		while( pFirstPara )
1454 		{
1455 			pFirstPara = pOlView->GetPrevTitle( pFirstPara );
1456 			if( pFirstPara )
1457 				nPos++;
1458 		}
1459 
1460 		if( nPos >= GetDoc()->GetSdPageCount( PK_STANDARD ) )
1461 			nPos = 0;
1462 
1463 		SdrPage* pPage = GetDoc()->GetSdPage( (sal_uInt16) nPos, PK_STANDARD );
1464 
1465 		aPageStr = String(SdResId( STR_SD_PAGE ));
1466 		aPageStr += sal_Unicode(' ');
1467 		aPageStr += String::CreateFromInt32( (sal_Int32)(nPos + 1) );	// sal_uLong -> sal_Int32
1468 		aPageStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " / " ));
1469 		aPageStr += String::CreateFromInt32( nPageCount );
1470 
1471 		aLayoutStr = pPage->GetLayoutName();
1472 		aLayoutStr.Erase( aLayoutStr.SearchAscii( SD_LT_SEPARATOR ) );
1473 	}
1474 	rSet.Put( SfxStringItem( SID_STATUS_PAGE, aPageStr ) );
1475 	rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aLayoutStr ) );
1476 }
1477 
1478 /*************************************************************************
1479 |*
1480 |* Command event
1481 |*
1482 \************************************************************************/
1483 
1484 void OutlineViewShell::Command( const CommandEvent& rCEvt, ::sd::Window* pWin )
1485 {
1486 	if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
1487 	{
1488 		GetActiveWindow()->ReleaseMouse();
1489 
1490 		OutlinerView* pOLV = pOlView->GetViewByWindow(GetActiveWindow());
1491 		Point aPos(rCEvt.GetMousePosPixel());
1492 
1493 		if (pOLV && pOLV->IsWrongSpelledWordAtPos(aPos))
1494 		{
1495 			// #91457# Popup for Online-Spelling now handled by DrawDocShell
1496 			// Link aLink = LINK(GetDoc(), SdDrawDocument, OnlineSpellCallback);
1497 			Link aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
1498 
1499 			pOLV->ExecuteSpellPopup(aPos, &aLink);
1500 		}
1501 		else
1502 		{
1503 		   GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(RID_OUTLINE_POPUP));
1504 		}
1505 	}
1506 	else
1507 	{
1508 		ViewShell::Command( rCEvt, pWin );
1509 
1510 		// ggfs. Preview den neuen Kontext mitteilen
1511 		Invalidate( SID_PREVIEW_STATE );
1512 
1513 	}
1514 }
1515 
1516 
1517 /*************************************************************************
1518 |*
1519 |* Keyboard event
1520 |*
1521 \************************************************************************/
1522 
1523 sal_Bool OutlineViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin)
1524 {
1525 	sal_Bool bReturn = sal_False;
1526 	OutlineViewPageChangesGuard aGuard(pOlView);
1527 
1528 	if (pWin == NULL && HasCurrentFunction())
1529 	{
1530 		bReturn = GetCurrentFunction()->KeyInput(rKEvt);
1531 	}
1532 
1533 	// nein, weiterleiten an Basisklasse
1534 	else
1535 	{
1536 		bReturn = ViewShell::KeyInput(rKEvt, pWin);
1537 	}
1538 
1539 	Invalidate(SID_STYLE_EDIT);
1540 	Invalidate(SID_STYLE_NEW);
1541 	Invalidate(SID_STYLE_DELETE);
1542 	Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE);
1543 	Invalidate(SID_STYLE_NEW_BY_EXAMPLE);
1544 	Invalidate(SID_STYLE_WATERCAN);
1545 	Invalidate(SID_STYLE_FAMILY5);
1546 
1547 	// Pruefen und Unterscheiden von CursorBewegungs- oder Eingabe-Keys
1548 	KeyCode aKeyGroup( rKEvt.GetKeyCode().GetGroup() );
1549 	if( (aKeyGroup != KEYGROUP_CURSOR && aKeyGroup != KEYGROUP_FKEYS) ||
1550 		(GetActualPage() != pLastPage) )
1551 	{
1552 		Invalidate( SID_PREVIEW_STATE );
1553 	}
1554 
1555 	return(bReturn);
1556 }
1557 
1558 
1559 /*************************************************************************
1560 |*
1561 |* Optimale Groesse zurueckgeben
1562 |*
1563 \************************************************************************/
1564 
1565 Size OutlineViewShell::GetOptimalSizePixel() const
1566 {
1567 	Size aResult(200, 200);
1568 	if (pOlView)
1569 	{
1570 		::Outliner* pOutliner = pOlView->GetOutliner();
1571 		if (pOutliner)
1572 		{
1573 			Size aTemp = pOutliner->CalcTextSize();
1574 			aTemp = GetActiveWindow()->LogicToPixel(aTemp);
1575 			aResult.Width() = Max(aResult.Width(), aTemp.Width());
1576 			aResult.Height() = Max(aResult.Height(), aTemp.Height());
1577 			if (4 * aResult.Height() > 3 * aResult.Width())
1578 			{
1579 				aResult.Height() = 3 * aResult.Width() / 4;
1580 			}
1581 		}
1582 	}
1583 
1584 	// und jetzt jetzt das Standardgelumpe draufaddieren
1585 	aResult.Width()  += mpVerticalScrollBar->GetSizePixel().Width();
1586 	aResult.Height() += mpHorizontalScrollBar->GetSizePixel().Height();
1587 		//!!! +	System::GetMenuBarHeightPixel();  // statt Titlebar
1588 	return aResult;
1589 }
1590 
1591 
1592 /*************************************************************************
1593 |*
1594 |* Text der Selektion zurueckgeben
1595 |*
1596 \************************************************************************/
1597 
1598 String OutlineViewShell::GetSelectionText(sal_Bool bCompleteWords)
1599 {
1600 	String aStrSelection;
1601 	::Outliner* pOl = pOlView->GetOutliner();
1602 	OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() );
1603 
1604 	if (pOl && pOlView)
1605 	{
1606 		if (bCompleteWords)
1607 		{
1608 			ESelection aSel = pOutlinerView->GetSelection();
1609 			String aStrCurrentDelimiters = pOl->GetWordDelimiters();
1610 
1611 			pOl->SetWordDelimiters( String( RTL_CONSTASCII_USTRINGPARAM( " .,;\"'" )));
1612 			aStrSelection = pOl->GetWord( aSel.nEndPara, aSel.nEndPos );
1613 			pOl->SetWordDelimiters( aStrCurrentDelimiters );
1614 		}
1615 		else
1616 		{
1617 			aStrSelection = pOutlinerView->GetSelected();
1618 		}
1619 	}
1620 
1621 	return (aStrSelection);
1622 }
1623 
1624 
1625 /*************************************************************************
1626 |*
1627 |* Ist etwas selektiert?
1628 |*
1629 \************************************************************************/
1630 
1631 sal_Bool OutlineViewShell::HasSelection(sal_Bool bText) const
1632 {
1633 	sal_Bool bReturn = sal_False;
1634 
1635 	if (bText)
1636 	{
1637 		OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() );
1638 
1639 		if (pOutlinerView && pOutlinerView->GetSelected().Len() != 0)
1640 		{
1641 			bReturn = sal_True;
1642 		}
1643 	}
1644 
1645 	return bReturn;
1646 }
1647 
1648 
1649 /*************************************************************************
1650 |*
1651 |* Status der Attribut-Items
1652 |*
1653 \************************************************************************/
1654 
1655 void OutlineViewShell::GetAttrState( SfxItemSet& rSet )
1656 {
1657 	SfxWhichIter  aIter( rSet );
1658 	sal_uInt16        nWhich = aIter.FirstWhich();
1659 	SfxAllItemSet aAllSet( *rSet.GetPool() );
1660 
1661 	while ( nWhich )
1662 	{
1663 		sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
1664 			? GetPool().GetSlotId(nWhich)
1665 			: nWhich;
1666 
1667 		switch ( nSlotId )
1668 		{
1669 			case SID_STYLE_FAMILY2:
1670 			case SID_STYLE_FAMILY3:
1671 			{
1672 				rSet.DisableItem( nWhich );
1673 			}
1674 			break;
1675 
1676 			case SID_STYLE_FAMILY5:
1677 			{
1678 				SfxStyleSheet* pStyleSheet = pOlView->GetViewByWindow(GetActiveWindow())->GetStyleSheet();
1679 
1680 				if( pStyleSheet )
1681 				{
1682 					pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet();
1683 
1684 					if (pStyleSheet)
1685 					{
1686 						SfxTemplateItem aItem( nWhich, pStyleSheet->GetName() );
1687 						aAllSet.Put( aItem, aItem.Which()  );
1688 					}
1689 				}
1690 
1691 				if( !pStyleSheet )
1692 				{
1693 					SfxTemplateItem aItem( nWhich, String() );
1694 					aAllSet.Put( aItem, aItem.Which() );
1695 					// rSet.DisableItem( nWhich );
1696 				}
1697 			}
1698 			break;
1699 
1700 			case SID_STYLE_EDIT:
1701 			{
1702 				ISfxTemplateCommon* pTmplCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
1703 
1704 				if (pTmplCommon && pTmplCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
1705 				{
1706 					SfxItemSet aSet(*rSet.GetPool(), SID_STATUS_LAYOUT, SID_STATUS_LAYOUT);
1707 					GetStatusBarState(aSet);
1708 					String aRealStyle(((SfxStringItem&) aSet.Get(SID_STATUS_LAYOUT)).GetValue());
1709 
1710 					if (!aRealStyle.Len())
1711 					{
1712 						// Kein eindeutiger Layoutname gefunden
1713 						rSet.DisableItem(nWhich);
1714 					}
1715 				}
1716 			}
1717 			break;
1718 
1719 			case SID_STYLE_UPDATE_BY_EXAMPLE:
1720 			{
1721 				::sd::Window*     pActWin = GetActiveWindow();
1722 				OutlinerView* pOV = pOlView->GetViewByWindow(pActWin);
1723 				ESelection aESel(pOV->GetSelection());
1724 
1725 				if (aESel.nStartPara != aESel.nEndPara ||
1726 					aESel.nStartPos  != aESel.nEndPos)
1727 					// aufgespannte Selektion, also StyleSheet und/oder
1728 					// Attributierung nicht zwingend eindeutig
1729 					rSet.DisableItem(nWhich);
1730 			}
1731 			break;
1732 
1733 			case SID_STYLE_NEW:
1734 			case SID_STYLE_DELETE:
1735 			case SID_STYLE_NEW_BY_EXAMPLE:
1736 			case SID_STYLE_WATERCAN:
1737 			{
1738 				rSet.DisableItem(nWhich);
1739 			}
1740 			break;
1741 		}
1742 
1743 		nWhich = aIter.NextWhich();
1744 	}
1745 
1746 	rSet.Put( aAllSet, sal_False );
1747 }
1748 
1749 
1750 
1751 /*************************************************************************
1752 |*
1753 |* MouseButtonUp event
1754 |*
1755 \************************************************************************/
1756 
1757 void OutlineViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
1758 {
1759 	// Zuerst die Basisklasse
1760 	ViewShell::MouseButtonUp(rMEvt, pWin);
1761 
1762 	Invalidate(SID_STYLE_EDIT);
1763 	Invalidate(SID_STYLE_NEW);
1764 	Invalidate(SID_STYLE_DELETE);
1765 	Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE);
1766 	Invalidate(SID_STYLE_NEW_BY_EXAMPLE);
1767 	Invalidate(SID_STYLE_WATERCAN);
1768 	Invalidate(SID_STYLE_FAMILY5);
1769 
1770 	// ggfs. Preview den neuen Kontext mitteilen
1771 	if( GetActualPage() != pLastPage )
1772 		Invalidate( SID_PREVIEW_STATE );
1773 }
1774 
1775 
1776 
1777 SdPage* OutlineViewShell::getCurrentPage() const
1778 {
1779 	// since there are no master pages in outline view, we can
1780 	// for now use the GetActualPage method
1781 	return const_cast<OutlineViewShell*>(this)->GetActualPage();
1782 }
1783 
1784 /*************************************************************************
1785 |*
1786 |* Liefert die erste selektierte Seite zurueck.
1787 |* Wenn nichts selektiert ist, wird die erste Seite zurueckgeliefert.
1788 |*
1789 \************************************************************************/
1790 SdPage* OutlineViewShell::GetActualPage()
1791 {
1792 	return pOlView->GetActualPage();
1793 }
1794 
1795 
1796 void OutlineViewShell::UpdatePreview( SdPage* pPage, sal_Bool )
1797 {
1798 	const bool bNewPage = pPage != pLastPage;
1799 	pLastPage = pPage;
1800 	if (bNewPage)
1801 	{
1802 		OutlineViewPageChangesGuard aGuard(pOlView);
1803         SetCurrentPage(pPage);
1804     }
1805 }
1806 
1807 /*************************************************************************
1808 |*
1809 |* Update Title
1810 |*
1811 \************************************************************************/
1812 
1813 bool OutlineViewShell::UpdateTitleObject( SdPage* pPage, Paragraph* pPara )
1814 {
1815 	DBG_ASSERT( pPage, "sd::OutlineViewShell::UpdateTitleObject(), pPage == 0?" );
1816 	DBG_ASSERT( pPara, "sd::OutlineViewShell::UpdateTitleObject(), pPara == 0?" );
1817 
1818 	if( !pPage || !pPara )
1819 		return false;
1820 
1821 	::Outliner* 			pOutliner = pOlView->GetOutliner();
1822 	SdrTextObj* 		pTO  = pOlView->GetTitleTextObject( pPage );
1823 	OutlinerParaObject* pOPO = NULL;
1824 
1825 	String	aTest( pOutliner->GetText( pPara ) );
1826 	bool 	bText = aTest.Len() > 0;
1827 	bool 	bNewObject = false;
1828 
1829 	if( bText )
1830 	{
1831 		// create a title object if we don't have one but have text
1832 		if( !pTO )
1833 		{
1834 			DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1835 			pTO = pOlView->CreateTitleTextObject(pPage);
1836 			bNewObject = sal_True;
1837 		}
1838 
1839 		// if we have a title object and a text, set the text
1840 		if( pTO )
1841 		{
1842 			pOPO = pOutliner->CreateParaObject( (sal_uInt16) pOutliner->GetAbsPos( pPara ), 1 );
1843 			pOPO->SetOutlinerMode( OUTLINERMODE_TITLEOBJECT );
1844 			pOPO->SetVertical( pTO->IsVerticalWriting() );
1845 			if( pTO->GetOutlinerParaObject() && (pOPO->GetTextObject() == pTO->GetOutlinerParaObject()->GetTextObject()) )
1846 			{
1847 				// do nothing, same text already set
1848 				delete pOPO;
1849 			}
1850 			else
1851 			{
1852 				DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1853 				if( !bNewObject && pOlView->isRecordingUndo() )
1854 					pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
1855 
1856 				pTO->SetOutlinerParaObject( pOPO );
1857 				pTO->SetEmptyPresObj( sal_False );
1858 				pTO->ActionChanged();
1859 			}
1860 		}
1861 	}
1862 	else if( pTO )
1863 	{
1864 		// no text but object available?
1865 		// outline object available, but we have no text
1866 		if(pPage->IsPresObj(pTO))
1867 		{
1868 			// if it is not already empty
1869 			if( !pTO->IsEmptyPresObj() )
1870 			{
1871 				DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1872 
1873 				// make it empty
1874 				if( pOlView->isRecordingUndo() )
1875 					pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
1876 				pPage->RestoreDefaultText( pTO );
1877 				pTO->SetEmptyPresObj(sal_True);
1878 				pTO->ActionChanged();
1879 			}
1880 		}
1881 		else
1882 		{
1883 			DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1884 			// outline object is not part of the layout, delete it
1885 			if( pOlView->isRecordingUndo() )
1886 				pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoRemoveObject(*pTO));
1887 			pPage->RemoveObject(pTO->GetOrdNum());
1888 		}
1889 	}
1890 
1891 	return bNewObject;
1892 }
1893 
1894 /*************************************************************************
1895 |*
1896 |* Update LayoutObject
1897 |*
1898 \************************************************************************/
1899 
1900 bool OutlineViewShell::UpdateOutlineObject( SdPage* pPage, Paragraph* pPara )
1901 {
1902 	DBG_ASSERT( pPage, "sd::OutlineViewShell::UpdateOutlineObject(), pPage == 0?" );
1903 	DBG_ASSERT( pPara, "sd::OutlineViewShell::UpdateOutlineObject(), pPara == 0?" );
1904 
1905 	if( !pPage || !pPara )
1906 		return false;
1907 
1908 	::Outliner* 		pOutliner = pOlView->GetOutliner();
1909 	OutlinerParaObject* pOPO = NULL;
1910 	SdrTextObj* 		pTO  = NULL;
1911 
1912 	sal_Bool bNewObject = sal_False;
1913 
1914 	sal_uInt16 eOutlinerMode = OUTLINERMODE_TITLEOBJECT;
1915 	pTO = (SdrTextObj*)pPage->GetPresObj( PRESOBJ_TEXT );
1916 	if( !pTO )
1917 	{
1918 		eOutlinerMode = OUTLINERMODE_OUTLINEOBJECT;
1919 		pTO = pOlView->GetOutlineTextObject( pPage );
1920 	}
1921 
1922 	// wieviele Absaetze in der Gliederung?
1923 	sal_uLong nTitlePara	 = pOutliner->GetAbsPos( pPara );
1924 	sal_uLong nPara          = nTitlePara + 1;
1925 	sal_uLong nParasInLayout = 0L;
1926 	pPara = pOutliner->GetParagraph( nPara );
1927 	while( pPara && !pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
1928 	{
1929 		nParasInLayout++;
1930 		pPara = pOutliner->GetParagraph( ++nPara );
1931 	}
1932 	if( nParasInLayout )
1933 	{
1934 		// ein OutlinerParaObject erzeugen
1935 		pPara = pOutliner->GetParagraph( nTitlePara + 1 );
1936 		pOPO  = pOutliner->CreateParaObject( (sal_uInt16) nTitlePara + 1, (sal_uInt16) nParasInLayout );
1937 	}
1938 
1939 	if( pOPO )
1940 	{
1941 		DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
1942 
1943 		// do we need an outline text object?
1944 		if( !pTO )
1945 		{
1946 			pTO = pOlView->CreateOutlineTextObject( pPage );
1947 			bNewObject = sal_True;
1948 		}
1949 
1950 		// Seitenobjekt, Gliederungstext im Outliner:
1951 		// Text uebernehmen
1952 		if( pTO )
1953 		{
1954 			pOPO->SetVertical( pTO->IsVerticalWriting() );
1955 			pOPO->SetOutlinerMode( eOutlinerMode );
1956 			if( pTO->GetOutlinerParaObject() && (pOPO->GetTextObject() == pTO->GetOutlinerParaObject()->GetTextObject()) )
1957 			{
1958 				// do nothing, same text already set
1959 				delete pOPO;
1960 			}
1961 			else
1962 			{
1963 				if( !bNewObject && pOlView->isRecordingUndo() )
1964 					pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
1965 
1966 				pTO->SetOutlinerParaObject( pOPO );
1967 				pTO->SetEmptyPresObj( sal_False );
1968 				pTO->ActionChanged();
1969 			}
1970 		}
1971 	}
1972 	else if( pTO )
1973 	{
1974 		// Seitenobjekt, aber kein Gliederungstext:
1975 		// wenn Objekt in Praesentationsliste der Seite ist -> Defaulttext,
1976 		// sonst Objekt loeschen
1977 		if( pPage->IsPresObj(pTO) )
1978 		{
1979 			if( !pTO->IsEmptyPresObj() )
1980 			{
1981 				DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
1982 
1983 				// loescht auch altes OutlinerParaObject
1984 				if( pOlView->isRecordingUndo() )
1985 					pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
1986 				pPage->RestoreDefaultText( pTO );
1987 				pTO->SetEmptyPresObj(sal_True);
1988 				pTO->ActionChanged();
1989 			}
1990 		}
1991 		else
1992 		{
1993 			DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
1994 			if( pOlView->isRecordingUndo() )
1995 				pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoRemoveObject(*pTO));
1996 			pPage->RemoveObject(pTO->GetOrdNum());
1997 		}
1998 	}
1999 
2000 	return bNewObject;
2001 }
2002 
2003 
2004 /*************************************************************************
2005 |*
2006 |* Outliner aus Stream fuellen
2007 |*
2008 \************************************************************************/
2009 
2010 sal_uLong OutlineViewShell::Read(SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat)
2011 {
2012 	sal_uLong bRet = 0;
2013 
2014 	::Outliner* pOutl = pOlView->GetOutliner();
2015 
2016 	{
2017 	OutlineViewPageChangesGuard aGuard( pOlView );
2018 	OutlineViewModelChangeGuard aGuard2( *pOlView );
2019 
2020     bRet = pOutl->Read( rInput, rBaseURL, eFormat, GetDocSh()->GetHeaderAttributes() );
2021 
2022 	SdPage* pPage = GetDoc()->GetSdPage( GetDoc()->GetSdPageCount(PK_STANDARD) - 1, PK_STANDARD );;
2023 	SfxStyleSheet* pTitleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE );
2024 	SfxStyleSheet* pOutlSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
2025 
2026 	sal_uInt16 nParaCount = (sal_uInt16)pOutl->GetParagraphCount();
2027 	if ( nParaCount > 0 )
2028 	{
2029 		for ( sal_uInt16 nPara = 0; nPara < nParaCount; nPara++ )
2030 		{
2031 			pOlView->UpdateParagraph( nPara );
2032 
2033 			sal_Int16 nDepth = pOutl->GetDepth( nPara );
2034 
2035 			if( (nDepth == 0) || !nPara )
2036 			{
2037 				Paragraph* pPara = pOutl->GetParagraph( nPara );
2038 				pOutl->SetDepth(pPara, -1);
2039 				pOutl->SetParaFlag(pPara, PARAFLAG_ISPAGE);
2040 
2041 				pOutl->SetStyleSheet( nPara, pTitleSheet );
2042 
2043 				if( nPara ) // first slide already exists
2044 					pOlView->InsertSlideForParagraph( pPara );
2045 			}
2046 			else
2047 			{
2048 				pOutl->SetDepth( pOutl->GetParagraph( nPara ), nDepth - 1 );
2049 				String aStyleSheetName( pOutlSheet->GetName() );
2050 				aStyleSheetName.Erase( aStyleSheetName.Len() - 1, 1 );
2051 				aStyleSheetName += String::CreateFromInt32( nDepth );
2052 				SfxStyleSheetBasePool* pStylePool = GetDoc()->GetStyleSheetPool();
2053 				SfxStyleSheet* pStyle = (SfxStyleSheet*) pStylePool->Find( aStyleSheetName, pOutlSheet->GetFamily() );
2054 				DBG_ASSERT( pStyle, "AutoStyleSheetName - Style not found!" );
2055 				if ( pStyle )
2056 					pOutl->SetStyleSheet( nPara, pStyle );
2057 			}
2058 		}
2059 	}
2060 	}
2061 
2062 	pOutl->GetUndoManager().Clear();
2063 
2064 	return( bRet );
2065 }
2066 
2067 void OutlineViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse )
2068 {
2069 	WriteFrameViewData();
2070 
2071 	ViewShell::WriteUserDataSequence( rSequence, bBrowse );
2072 }
2073 
2074 void OutlineViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse )
2075 {
2076 	WriteFrameViewData();
2077 
2078 	ViewShell::ReadUserDataSequence( rSequence, bBrowse );
2079 
2080 	ReadFrameViewData( mpFrameView );
2081 }
2082 
2083 void OutlineViewShell::VisAreaChanged(const Rectangle& rRect)
2084 {
2085 	ViewShell::VisAreaChanged( rRect );
2086 
2087 	GetViewShellBase().GetDrawController().FireVisAreaChanged(rRect);
2088 }
2089 
2090 /** If there is a valid controller then create a new instance of
2091     <type>AccessibleDrawDocumentView</type>.  Otherwise delegate this call
2092     to the base class to return a default object (probably an empty
2093     reference).
2094 */
2095 ::com::sun::star::uno::Reference<
2096     ::com::sun::star::accessibility::XAccessible>
2097     OutlineViewShell::CreateAccessibleDocumentView (::sd::Window* pWindow)
2098 {
2099     OSL_ASSERT (GetViewShell()!=NULL);
2100     if (GetViewShell()->GetController() != NULL)
2101     {
2102         ::accessibility::AccessibleOutlineView* pDocumentView =
2103             new ::accessibility::AccessibleOutlineView (
2104                 pWindow,
2105                 this,
2106                 GetViewShell()->GetController(),
2107                 pWindow->GetAccessibleParentWindow()->GetAccessible());
2108         pDocumentView->Init();
2109         return ::com::sun::star::uno::Reference<
2110             ::com::sun::star::accessibility::XAccessible>
2111             (static_cast< ::com::sun::star::uno::XWeak*>(pDocumentView),
2112                 ::com::sun::star::uno::UNO_QUERY);
2113     }
2114     else
2115     {
2116         OSL_TRACE ("OutlineViewShell::CreateAccessibleDocumentView: no controller");
2117         return ViewShell::CreateAccessibleDocumentView (pWindow);
2118     }
2119 }
2120 
2121 
2122 
2123 
2124 void OutlineViewShell::GetState (SfxItemSet& rSet)
2125 {
2126     // Iterate over all requested items in the set.
2127 	SfxWhichIter aIter( rSet );
2128 	sal_uInt16 nWhich = aIter.FirstWhich();
2129 	while (nWhich)
2130 	{
2131 		switch (nWhich)
2132 		{
2133 			case SID_SEARCH_ITEM:
2134 			case SID_SEARCH_OPTIONS:
2135                 // Call common (old) implementation in the document shell.
2136                 GetDocSh()->GetState (rSet);
2137                 break;
2138 			default:
2139                 OSL_TRACE ("OutlineViewShell::GetState(): can not handle which id %d", nWhich);
2140                 break;
2141         }
2142 		nWhich = aIter.NextWhich();
2143 	}
2144 }
2145 
2146 
2147 
2148 
2149 void OutlineViewShell::SetCurrentPage (SdPage* pPage)
2150 {
2151     // Adapt the selection of the model.
2152     for (sal_uInt16 i=0; i<GetDoc()->GetSdPageCount(PK_STANDARD); i++)
2153         GetDoc()->SetSelected(
2154             GetDoc()->GetSdPage(i, PK_STANDARD),
2155             sal_False);
2156     GetDoc()->SetSelected (pPage, sal_True);
2157 
2158     DrawController& rController(GetViewShellBase().GetDrawController());
2159     rController.FireSelectionChangeListener();
2160     rController.FireSwitchCurrentPage (pPage);
2161 
2162     pOlView->SetActualPage(pPage);
2163 }
2164 
2165 
2166 } // end of namespace sd
2167