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