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