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