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