1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "OutlineViewShell.hxx"
22 #include "ViewShellImplementation.hxx"
25 #include <svx/hyperdlg.hxx>
26 #include <svx/zoomslideritem.hxx>
28 #include <sfx2/infobar.hxx>
29 #include <sfx2/objface.hxx>
30 #include <sot/exchange.hxx>
31 #include <svx/ruler.hxx>
32 #include <sfx2/zoomitem.hxx>
33 #include <editeng/eeitem.hxx>
34 #include <editeng/flditem.hxx>
35 #include <sfx2/shell.hxx>
36 #include <sfx2/templdlg.hxx>
37 #include <sfx2/viewfac.hxx>
38 #include <sfx2/request.hxx>
39 #include <svx/hlnkitem.hxx>
40 #include <svx/svdotext.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <vcl/scrbar.hxx>
43 #include <vcl/settings.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"
66 #include "strings.hrc"
68 #include "res_bmp.hrc"
69 #include "Outliner.hxx"
71 #include "TextObjectBar.hxx"
72 #include "drawdoc.hxx"
73 #include "sdresid.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"
83 #include "AccessibleOutlineView.hxx"
84 #include "ViewShellBase.hxx"
85 #include "ViewShellManager.hxx"
86 #include "DrawController.hxx"
87 #include "framework/FrameworkHelper.hxx"
89 #include <boost/scoped_ptr.hpp>
91 using namespace ::com::sun::star
;
92 using namespace ::com::sun::star::uno
;
93 using namespace ::com::sun::star::lang
;
94 using namespace ::com::sun::star::linguistic2
;
98 #define OutlineViewShell
99 #include "sdslots.hxx"
103 #define MIN_ZOOM 10 // minimum zoom factor
104 #define MAX_ZOOM 1000 // maximum zoom factor
107 * Declare SFX-Slotmap and standard interface
109 SFX_IMPL_INTERFACE(OutlineViewShell
, SfxShell
)
111 void OutlineViewShell::InitInterface_Impl()
113 GetStaticInterface()->RegisterPopupMenu(SdResId(RID_OUTLINE_POPUP
));
115 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_TOOLS
| SFX_VISIBILITY_STANDARD
| SFX_VISIBILITY_FULLSCREEN
| SFX_VISIBILITY_SERVER
,
116 RID_OUTLINE_TOOLBOX
);
117 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_APPLICATION
| SFX_VISIBILITY_DESKTOP
| SFX_VISIBILITY_STANDARD
| SFX_VISIBILITY_CLIENT
| SFX_VISIBILITY_VIEWER
| SFX_VISIBILITY_READONLYDOC
,
118 RID_DRAW_VIEWER_TOOLBOX
);
120 GetStaticInterface()->RegisterChildWindow(SfxInfoBarContainerChild::GetChildWindowId());
121 GetStaticInterface()->RegisterChildWindow(SvxHlinkDlgWrapper::GetChildWindowId());
122 GetStaticInterface()->RegisterChildWindow(::sd::SpellDialogChildWindow::GetChildWindowId());
123 GetStaticInterface()->RegisterChildWindow(SID_SEARCH_DLG
);
124 GetStaticInterface()->RegisterChildWindow(::sfx2::sidebar::SidebarChildWindow::GetChildWindowId());
127 TYPEINIT1( OutlineViewShell
, ViewShell
);
130 * common initialization part of both constructors
132 void OutlineViewShell::Construct(DrawDocShell
* )
134 bool bModified
= GetDoc()->IsChanged();
136 meShellType
= ST_OUTLINE
;
137 Size
aSize(29700, 21000);
138 Point
aWinPos (0, 0);
139 Point
aViewOrigin(0, 0);
140 GetActiveWindow()->SetMinZoomAutoCalc(false);
141 GetActiveWindow()->SetMinZoom( MIN_ZOOM
);
142 GetActiveWindow()->SetMaxZoom( MAX_ZOOM
);
143 InitWindows(aViewOrigin
, aSize
, aWinPos
);
144 pOlView
= new OutlineView(*GetDocSh(), GetActiveWindow(), *this);
145 mpView
= pOlView
; // Pointer of base class ViewShell
147 SetPool( &GetDoc()->GetPool() );
151 // Apply settings of FrameView
152 ReadFrameViewData(mpFrameView
);
154 ::Outliner
& rOutl
= pOlView
->GetOutliner();
155 rOutl
.SetUpdateMode(true);
159 rOutl
.ClearModifyFlag();
162 pLastPage
= GetActualPage();
164 SetName( OUString( "OutlineViewShell" ) );
166 SetHelpId( SD_IF_SDOUTLINEVIEWSHELL
);
167 GetActiveWindow()->SetHelpId( HID_SDOUTLINEVIEWSHELL
);
168 GetActiveWindow()->SetUniqueId( HID_SDOUTLINEVIEWSHELL
);
171 Reference
<drawing::XDrawSubController
> OutlineViewShell::CreateSubController()
173 Reference
<drawing::XDrawSubController
> xSubController
;
175 if (IsMainViewShell())
177 // Create uno sub controller for the main view shell.
178 xSubController
= Reference
<drawing::XDrawSubController
>(
179 new SdUnoOutlineView (
183 return xSubController
;
187 * Default constructor, windows must not center themselves automatically
189 OutlineViewShell::OutlineViewShell (
190 SfxViewFrame
* pFrame
,
191 ViewShellBase
& rViewShellBase
,
192 vcl::Window
* pParentWindow
,
193 FrameView
* pFrameViewArgument
)
194 : ViewShell(pFrame
, pParentWindow
, rViewShellBase
),
198 bPastePossible(false),
202 if (pFrameViewArgument
!= NULL
)
203 mpFrameView
= pFrameViewArgument
;
205 mpFrameView
= new FrameView(GetDoc());
207 mpFrameView
->Connect();
209 Construct(GetDocSh());
211 SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_OutlineText
));
213 m_StrOldPageName
.clear();
218 OutlineViewShell::~OutlineViewShell()
224 mpFrameView
->Disconnect();
228 pClipEvtLstnr
->AddRemoveListener( GetActiveWindow(), false );
229 pClipEvtLstnr
->ClearCallbackLink(); // prevent callback if another thread is waiting
230 pClipEvtLstnr
->release();
234 void OutlineViewShell::Shutdown()
236 ViewShell::Shutdown();
242 * Paint method: the event gets forwarded from pWindow to the Viewshell
243 * and the current function
245 void OutlineViewShell::Paint(const Rectangle
& rRect
, ::sd::Window
* pWin
)
249 pOlView
->Paint(rRect
, pWin
);
253 void OutlineViewShell::ArrangeGUIElements ()
255 // Retrieve the current size (thickness) of the scroll bars. That is
256 // the width of the vertical and the height of the horizontal scroll
259 GetParentWindow()->GetSettings().GetStyleSettings().GetScrollBarSize();
260 maScrBarWH
= Size (nScrollBarSize
, nScrollBarSize
);
262 ViewShell::ArrangeGUIElements ();
264 ::sd::Window
* pWindow
= mpContentWindow
.get();
267 pWindow
->SetMinZoomAutoCalc(false);
269 // change OuputArea of the OutlinerView
270 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow(pWindow
);
272 Rectangle
aWin(Point(0,0), pWindow
->GetOutputSizePixel());
274 aWin
= pWindow
->PixelToLogic(aWin
);
275 pOutlinerView
->SetOutputArea(aWin
);
277 Rectangle aVis
= pOutlinerView
->GetVisArea();
279 Rectangle aText
= Rectangle(Point(0,0),
280 Size(pOlView
->GetPaperWidth(),
281 pOlView
->GetOutliner().GetTextHeight()));
282 if (aWin
.GetHeight() > aText
.Bottom())
283 aText
.Bottom() = aWin
.GetHeight();
285 if (!aWin
.IsEmpty()) // not when opening
287 InitWindows(Point(0,0), aText
.GetSize(), Point(aVis
.TopLeft()));
294 * Handle SfxRequest for the Controller
296 void OutlineViewShell::ExecCtrl(SfxRequest
&rReq
)
298 sal_uInt16 nSlot
= rReq
.GetSlot();
301 case SID_MAIL_SCROLLBODY_PAGEDOWN
:
307 case SID_OPT_LOCALE_CHANGED
:
309 pOlView
->GetOutliner().UpdateFields();
310 UpdatePreview( GetActualPage() );
321 * Activate(): during the first invocation the fields get updated
323 void OutlineViewShell::Activate( bool bIsMDIActivate
)
325 if ( ! mbInitialized
)
327 mbInitialized
= true;
328 SfxRequest
aRequest (SID_EDIT_OUTLINER
, SfxCallMode::SLOT
, GetDoc()->GetItemPool());
329 FuPermanent (aRequest
);
332 ViewShell::Activate( bIsMDIActivate
);
333 SfxShell::BroadcastContextForActivation(true);
336 pOlView
->ConnectToApplication();
340 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow( GetActiveWindow() );
341 ::Outliner
* pOutl
= pOutlinerView
->GetOutliner();
342 pOutl
->UpdateFields();
346 void OutlineViewShell::Deactivate( bool bIsMDIActivate
)
348 pOlView
->DisconnectFromApplication();
350 // Links must be kept also on deactivated viewshell, to allow drag'n'drop
351 // to function properly
352 ViewShell::Deactivate( bIsMDIActivate
);
356 * Set status of Controller-SfxSlots
358 void OutlineViewShell::GetCtrlState(SfxItemSet
&rSet
)
360 if (SfxItemState::DEFAULT
== rSet
.GetItemState(SID_HYPERLINK_GETLINK
))
362 SvxHyperlinkItem aHLinkItem
;
364 OutlinerView
* pOLV
= pOlView
->GetViewByWindow(GetActiveWindow());
367 const SvxFieldItem
* pFieldItem
= pOLV
->GetFieldAtSelection();
370 ESelection aSel
= pOLV
->GetSelection();
371 if ( abs( aSel
.nEndPos
- aSel
.nStartPos
) == 1 )
373 const SvxFieldData
* pField
= pFieldItem
->GetField();
374 if ( pField
->ISA(SvxURLField
) )
376 aHLinkItem
.SetName(static_cast<const SvxURLField
*>(pField
)->GetRepresentation());
377 aHLinkItem
.SetURL(static_cast<const SvxURLField
*>(pField
)->GetURL());
378 aHLinkItem
.SetTargetFrame(static_cast<const SvxURLField
*>(pField
)->GetTargetFrame());
383 rSet
.Put(aHLinkItem
);
385 rSet
.Put( SfxBoolItem( SID_READONLY_MODE
, GetDocSh()->IsReadOnly() ) );
387 if ( SfxItemState::DEFAULT
== rSet
.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN
) )
388 rSet
.Put( SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN
, true ) );
390 if ( SfxItemState::DEFAULT
== rSet
.GetItemState(SID_TRANSLITERATE_HALFWIDTH
) ||
391 SfxItemState::DEFAULT
== rSet
.GetItemState(SID_TRANSLITERATE_FULLWIDTH
) ||
392 SfxItemState::DEFAULT
== rSet
.GetItemState(SID_TRANSLITERATE_HIRAGANA
) ||
393 SfxItemState::DEFAULT
== rSet
.GetItemState(SID_TRANSLITERATE_KATAGANA
) )
395 SvtCJKOptions aCJKOptions
;
396 if( !aCJKOptions
.IsChangeCaseMapEnabled() )
398 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH
, false );
399 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH
, false );
400 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA
, false );
401 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA
, false );
402 rSet
.DisableItem( SID_TRANSLITERATE_HALFWIDTH
);
403 rSet
.DisableItem( SID_TRANSLITERATE_FULLWIDTH
);
404 rSet
.DisableItem( SID_TRANSLITERATE_HIRAGANA
);
405 rSet
.DisableItem( SID_TRANSLITERATE_KATAGANA
);
409 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH
, true );
410 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH
, true );
411 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA
, true );
412 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA
, true );
418 * SfxRequests for support functions
420 void OutlineViewShell::FuSupport(SfxRequest
&rReq
)
422 if( rReq
.GetSlot() == SID_STYLE_FAMILY
&& rReq
.GetArgs())
423 GetDocSh()->SetStyleFamily(static_cast<const SfxUInt16Item
&>(rReq
.GetArgs()->Get( SID_STYLE_FAMILY
)).GetValue());
425 bool bPreviewState
= false;
426 sal_uLong nSlot
= rReq
.GetSlot();
428 boost::scoped_ptr
< OutlineViewModelChangeGuard
> aGuard
;
430 (nSlot
== SID_TRANSLITERATE_SENTENCE_CASE
) ||
431 (nSlot
== SID_TRANSLITERATE_TITLE_CASE
) ||
432 (nSlot
== SID_TRANSLITERATE_TOGGLE_CASE
) ||
433 (nSlot
== SID_TRANSLITERATE_UPPER
) ||
434 (nSlot
== SID_TRANSLITERATE_LOWER
) ||
435 (nSlot
== SID_TRANSLITERATE_HALFWIDTH
) ||
436 (nSlot
== SID_TRANSLITERATE_FULLWIDTH
) ||
437 (nSlot
== SID_TRANSLITERATE_HIRAGANA
) ||
438 (nSlot
== SID_TRANSLITERATE_KATAGANA
) ||
439 (nSlot
== SID_CUT
) ||
440 (nSlot
== SID_PASTE
) ||
441 (nSlot
== SID_PASTE_UNFORMATTED
) ||
442 (nSlot
== SID_DELETE
)))
444 aGuard
.reset( new OutlineViewModelChangeGuard( *pOlView
) );
451 if(HasCurrentFunction())
453 GetCurrentFunction()->DoCut();
460 bPreviewState
= true;
466 if(HasCurrentFunction())
468 GetCurrentFunction()->DoCopy();
475 bPreviewState
= true;
481 OutlineViewPageChangesGuard
aGuard2(pOlView
);
483 if(HasCurrentFunction())
485 GetCurrentFunction()->DoPaste();
492 bPreviewState
= true;
496 case SID_PASTE_UNFORMATTED
:
498 OutlineViewPageChangesGuard
aGuard2(pOlView
);
500 if(HasCurrentFunction())
502 GetCurrentFunction()->DoPasteUnformatted();
506 sal_Int8 nAction
= DND_ACTION_COPY
;
507 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
508 if (aDataHelper
.GetTransferable().is())
510 pOlView
->InsertData( aDataHelper
,
511 GetActiveWindow()->PixelToLogic( Rectangle( Point(), GetActiveWindow()->GetOutputSizePixel() ).Center() ),
512 nAction
, false, SotClipboardFormatId::STRING
);
523 OutlinerView
* pOutlView
= pOlView
->GetViewByWindow(GetActiveWindow());
526 OutlineViewPageChangesGuard
aGuard2(pOlView
);
528 vcl::KeyCode
aKCode(KEY_DELETE
);
529 KeyEvent
aKEvt( 0, aKCode
);
530 pOutlView
->PostKeyEvent(aKEvt
);
532 rtl::Reference
<FuPoor
> xFunc( GetCurrentFunction() );
533 FuOutlineText
* pFuOutlineText
= dynamic_cast< FuOutlineText
* >( xFunc
.get() );
535 pFuOutlineText
->UpdateForKeyPress (aKEvt
);
539 bPreviewState
= true;
543 case SID_DRAWINGMODE
:
545 case SID_HANDOUTMODE
:
547 case SID_OUTLINEMODE
:
548 framework::FrameworkHelper::Instance(GetViewShellBase())->HandleModeChangeSlot(
555 SetRuler( !HasRuler() );
556 Invalidate( SID_RULER
);
562 if (mpZoomList
->IsPreviousPossible())
564 SetZoomRect(mpZoomList
->GetPreviousZoomRect());
572 if (mpZoomList
->IsNextPossible())
574 SetZoomRect(mpZoomList
->GetNextZoomRect());
580 case SID_AUTOSPELL_CHECK
:
582 GetDoc()->SetOnlineSpell(!GetDoc()->GetOnlineSpell());
587 case SID_TRANSLITERATE_SENTENCE_CASE
:
588 case SID_TRANSLITERATE_TITLE_CASE
:
589 case SID_TRANSLITERATE_TOGGLE_CASE
:
590 case SID_TRANSLITERATE_UPPER
:
591 case SID_TRANSLITERATE_LOWER
:
592 case SID_TRANSLITERATE_HALFWIDTH
:
593 case SID_TRANSLITERATE_FULLWIDTH
:
594 case SID_TRANSLITERATE_HIRAGANA
:
595 case SID_TRANSLITERATE_KATAGANA
:
597 OutlinerView
* pOLV
= pOlView
? pOlView
->GetViewByWindow( GetActiveWindow() ) : 0;
600 using namespace ::com::sun::star::i18n
;
605 case SID_TRANSLITERATE_SENTENCE_CASE
:
606 nType
= TransliterationModulesExtra::SENTENCE_CASE
;
608 case SID_TRANSLITERATE_TITLE_CASE
:
609 nType
= TransliterationModulesExtra::TITLE_CASE
;
611 case SID_TRANSLITERATE_TOGGLE_CASE
:
612 nType
= TransliterationModulesExtra::TOGGLE_CASE
;
614 case SID_TRANSLITERATE_UPPER
:
615 nType
= TransliterationModules_LOWERCASE_UPPERCASE
;
617 case SID_TRANSLITERATE_LOWER
:
618 nType
= TransliterationModules_UPPERCASE_LOWERCASE
;
620 case SID_TRANSLITERATE_HALFWIDTH
:
621 nType
= TransliterationModules_FULLWIDTH_HALFWIDTH
;
623 case SID_TRANSLITERATE_FULLWIDTH
:
624 nType
= TransliterationModules_HALFWIDTH_FULLWIDTH
;
626 case SID_TRANSLITERATE_HIRAGANA
:
627 nType
= TransliterationModules_KATAKANA_HIRAGANA
;
629 case SID_TRANSLITERATE_KATAGANA
:
630 nType
= TransliterationModules_HIRAGANA_KATAKANA
;
634 pOLV
->TransliterateText( nType
);
638 bPreviewState
= true;
642 // added Undo/Redo handling
645 OutlineViewPageChangesGuard
aGuard2(pOlView
);
646 ImpSidUndo(false, rReq
);
651 OutlineViewPageChangesGuard
aGuard2(pOlView
);
652 ImpSidRedo(false, rReq
);
661 Invalidate( SID_PREVIEW_STATE
);
664 Invalidate(SID_COPY
);
665 Invalidate(SID_PASTE
);
669 * SfxRequests for permanent functions
671 void OutlineViewShell::FuPermanent(SfxRequest
&rReq
)
673 if(HasCurrentFunction())
675 DeactivateCurrentFunction(true);
678 switch ( rReq
.GetSlot() )
680 case SID_EDIT_OUTLINER
:
682 ::Outliner
& rOutl
= pOlView
->GetOutliner();
683 rOutl
.GetUndoManager().Clear();
684 rOutl
.UpdateFields();
686 SetCurrentFunction( FuOutlineText::Create(this,GetActiveWindow(),pOlView
,GetDoc(),rReq
) );
698 GetOldFunction()->Deactivate();
702 if(HasCurrentFunction())
704 GetCurrentFunction()->Activate();
705 SetOldFunction(GetCurrentFunction());
709 IMPL_LINK( OutlineViewShell
, ClipboardChanged
, TransferableDataHelper
*, pDataHelper
)
713 bPastePossible
= ( pDataHelper
->GetFormatCount() != 0 &&
714 ( pDataHelper
->HasFormat( SotClipboardFormatId::STRING
) ||
715 pDataHelper
->HasFormat( SotClipboardFormatId::RTF
) ||
716 pDataHelper
->HasFormat( SotClipboardFormatId::HTML
) ) );
718 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
719 rBindings
.Invalidate( SID_PASTE
);
720 rBindings
.Invalidate( SID_PASTE_SPECIAL
);
721 rBindings
.Invalidate( SID_PASTE_UNFORMATTED
);
722 rBindings
.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS
);
728 * Set Status (Enabled/Disabled) of Menu-SfxSlots
730 void OutlineViewShell::GetMenuState( SfxItemSet
&rSet
)
732 ViewShell::GetMenuState(rSet
);
734 rSet
.Put(SfxBoolItem(SID_DIAMODE
, false));
735 rSet
.Put(SfxBoolItem(SID_DRAWINGMODE
, false));
736 rSet
.Put(SfxBoolItem(SID_OUTLINEMODE
, true));
737 rSet
.Put(SfxBoolItem(SID_NOTESMODE
, false));
738 rSet
.Put(SfxBoolItem(SID_HANDOUTMODE
, false));
740 if (!mpZoomList
->IsNextPossible())
742 rSet
.DisableItem(SID_ZOOM_NEXT
);
744 if (!mpZoomList
->IsPreviousPossible())
746 rSet
.DisableItem(SID_ZOOM_PREV
);
749 if( SfxItemState::DEFAULT
== rSet
.GetItemState( SID_ZOOM_IN
) ||
750 SfxItemState::DEFAULT
== rSet
.GetItemState( SID_ZOOM_OUT
) )
752 if( GetActiveWindow()->GetZoom() <= GetActiveWindow()->GetMinZoom() || GetDocSh()->IsUIActive() )
753 rSet
.DisableItem( SID_ZOOM_IN
);
754 if( GetActiveWindow()->GetZoom() >= GetActiveWindow()->GetMaxZoom() || GetDocSh()->IsUIActive() )
755 rSet
.DisableItem( SID_ZOOM_OUT
);
758 ::Outliner
& rOutl
= pOlView
->GetOutliner();
760 // allow 'Select All'?
761 if( SfxItemState::DEFAULT
== rSet
.GetItemState( SID_SELECTALL
) )
763 sal_Int32 nParaCount
= rOutl
.GetParagraphCount();
764 bool bDisable
= nParaCount
== 0;
765 if (!bDisable
&& nParaCount
== 1)
767 OUString aTest
= rOutl
.GetText(rOutl
.GetParagraph(0));
774 rSet
.DisableItem(SID_SELECTALL
);
777 // set status of Ruler
778 rSet
.Put( SfxBoolItem( SID_RULER
, HasRuler() ) );
780 // Enable formatting?
781 rSet
.Put( SfxBoolItem( SID_OUTLINE_FORMAT
, !rOutl
.IsFlatMode() ) );
783 if( rOutl
.IsFlatMode() )
784 rSet
.DisableItem( SID_COLORVIEW
);
787 // Enable color view?
788 EEControlBits nCntrl
= rOutl
.GetControlWord();
789 bool bNoColor
= false;
790 if (nCntrl
& EEControlBits::NOCOLORS
)
793 rSet
.Put( SfxBoolItem( SID_COLORVIEW
, bNoColor
) );
796 // Buttons of toolbar
797 // first the selection dependent ones: COLLAPSE, EXPAND
798 bool bDisableCollapse
= true;
799 bool bDisableExpand
= true;
801 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow(GetActiveWindow());
803 std::vector
<Paragraph
*> aSelList
;
804 pOutlinerView
->CreateSelectionList(aSelList
);
806 if (!aSelList
.empty())
808 std::vector
<Paragraph
*>::const_iterator iter
= aSelList
.begin();
809 Paragraph
* pPara
= *iter
;
812 sal_Int16 nTmpDepth
= rOutl
.GetDepth( rOutl
.GetAbsPos( pPara
) );
813 bool bPage
= ::Outliner::HasParaFlag( pPara
, ParaFlag::ISPAGE
);
815 while (iter
!= aSelList
.begin())
819 nDepth
= rOutl
.GetDepth( rOutl
.GetAbsPos( pPara
) );
821 if( nDepth
!= nTmpDepth
|| bPage
!= ::Outliner::HasParaFlag( pPara
, ParaFlag::ISPAGE
))
824 if (rOutl
.HasChildren(pPara
))
826 if (!rOutl
.IsExpanded(pPara
))
827 bDisableExpand
= false;
829 bDisableCollapse
= false;
837 rSet
.DisableItem(SID_OUTLINE_EXPAND
);
838 if (bDisableCollapse
)
839 rSet
.DisableItem(SID_OUTLINE_COLLAPSE
);
841 // does the selection provide a unique presentation layout?
842 // if not, the templates must not be edited
843 SfxItemSet
aSet(*rSet
.GetPool(), SID_STATUS_LAYOUT
, SID_STATUS_LAYOUT
);
844 GetStatusBarState(aSet
);
845 OUString aTest
= static_cast<const SfxStringItem
&>(aSet
.Get(SID_STATUS_LAYOUT
)).GetValue();
849 rSet
.DisableItem(SID_PRESENTATION_TEMPLATES
);
853 rSet
.DisableItem( SID_PRESENTATIONOBJECT
);
855 // now the selection independent ones: COLLAPSE_ALL, EXPAND_ALL
856 bool bDisableCollapseAll
= true;
857 bool bDisableExpandAll
= true;
859 // does the selection contain something collapsable/expandable?
860 if (!bDisableCollapse
)
861 bDisableCollapseAll
= false;
863 bDisableExpandAll
= false;
865 // otherwise look through all paragraphs
866 if (bDisableCollapseAll
|| bDisableExpandAll
)
868 sal_Int32 nParaPos
= 0;
869 Paragraph
* pPara
= rOutl
.GetParagraph( nParaPos
);
870 while (pPara
&& (bDisableCollapseAll
|| bDisableExpandAll
))
872 if (!rOutl
.IsExpanded(pPara
) && rOutl
.HasChildren(pPara
))
873 bDisableExpandAll
= false;
875 if (rOutl
.IsExpanded(pPara
) && rOutl
.HasChildren(pPara
))
876 bDisableCollapseAll
= false;
878 pPara
= rOutl
.GetParagraph( ++nParaPos
);
882 if (bDisableExpandAll
)
883 rSet
.DisableItem(SID_OUTLINE_EXPAND_ALL
);
884 if (bDisableCollapseAll
)
885 rSet
.DisableItem(SID_OUTLINE_COLLAPSE_ALL
);
887 if( SfxItemState::DEFAULT
== rSet
.GetItemState( SID_PASTE
) )
889 if ( !pClipEvtLstnr
)
892 pClipEvtLstnr
= new TransferableClipboardListener( LINK( this, OutlineViewShell
, ClipboardChanged
) );
893 pClipEvtLstnr
->acquire();
894 pClipEvtLstnr
->AddRemoveListener( GetActiveWindow(), true );
897 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
898 bPastePossible
= ( aDataHelper
.GetFormatCount() != 0 &&
899 ( aDataHelper
.HasFormat( SotClipboardFormatId::STRING
) ||
900 aDataHelper
.HasFormat( SotClipboardFormatId::RTF
) ||
901 aDataHelper
.HasFormat( SotClipboardFormatId::HTML
) ) );
904 if( !bPastePossible
)
906 rSet
.DisableItem( SID_PASTE
);
910 if (!pOlView
->GetViewByWindow(GetActiveWindow())->HasSelection())
912 rSet
.DisableItem(SID_CUT
);
913 rSet
.DisableItem(SID_COPY
);
916 if (pOlView
->GetOutliner().IsModified())
918 GetDoc()->SetChanged(true);
921 // the status has to be set here because of overriding
922 if( !GetDocSh()->IsModified() )
924 rSet
.DisableItem( SID_SAVEDOC
);
927 if ( GetDocSh()->IsReadOnly() )
929 rSet
.DisableItem( SID_AUTOSPELL_CHECK
);
933 if (GetDoc()->GetOnlineSpell())
935 rSet
.Put(SfxBoolItem(SID_AUTOSPELL_CHECK
, true));
939 rSet
.Put(SfxBoolItem(SID_AUTOSPELL_CHECK
, false));
944 if( SfxItemState::DEFAULT
== rSet
.GetItemState( SID_MODIFY_FIELD
) )
946 const SvxFieldItem
* pFldItem
= pOutlinerView
->GetFieldAtSelection();
948 if( !( pFldItem
&& (pFldItem
->GetField()->ISA( SvxDateField
) ||
949 pFldItem
->GetField()->ISA( SvxAuthorField
) ||
950 pFldItem
->GetField()->ISA( SvxExtFileField
) ||
951 pFldItem
->GetField()->ISA( SvxExtTimeField
) ) ) )
953 rSet
.DisableItem( SID_MODIFY_FIELD
);
957 if (SfxItemState::DEFAULT
== rSet
.GetItemState(SID_EXPAND_PAGE
))
959 bool bDisable
= true;
961 sal_uInt16 nCount
= GetDoc()->GetSdPageCount(PK_STANDARD
);
962 pOlView
->SetSelectedPages();
964 while (i
< nCount
&& bDisable
)
966 SdPage
* pPage
= GetDoc()->GetSdPage(i
, PK_STANDARD
);
968 if (pPage
->IsSelected())
970 SdrObject
* pObj
= pPage
->GetPresObj(PRESOBJ_OUTLINE
);
974 if( !pObj
->IsEmptyPresObj() )
980 // check if the object is in edit, than its temporarely not empty
981 SdrTextObj
* pTextObj
= dynamic_cast< SdrTextObj
* >( pObj
);
984 OutlinerParaObject
* pParaObj
= pTextObj
->GetEditOutlinerParaObject();
1000 rSet
.DisableItem(SID_EXPAND_PAGE
);
1004 if (SfxItemState::DEFAULT
== rSet
.GetItemState(SID_SUMMARY_PAGE
))
1006 bool bDisable
= true;
1008 sal_uInt16 nCount
= GetDoc()->GetSdPageCount(PK_STANDARD
);
1009 pOlView
->SetSelectedPages();
1011 while (i
< nCount
&& bDisable
)
1013 SdPage
* pPage
= GetDoc()->GetSdPage(i
, PK_STANDARD
);
1015 if (pPage
->IsSelected())
1017 SdrObject
* pObj
= pPage
->GetPresObj(PRESOBJ_TITLE
);
1019 if (pObj
&& !pObj
->IsEmptyPresObj())
1030 rSet
.DisableItem(SID_SUMMARY_PAGE
);
1034 if( SfxItemState::DEFAULT
== rSet
.GetItemState( SID_THESAURUS
) )
1036 if ( !pOlView
->IsTextEdit() )
1038 rSet
.DisableItem( SID_THESAURUS
);
1042 LanguageType eLang
= GetDoc()->GetLanguage( EE_CHAR_LANGUAGE
);
1043 Reference
< XThesaurus
> xThesaurus( LinguMgr::GetThesaurus() );
1045 if (!xThesaurus
.is() || eLang
== LANGUAGE_NONE
|| !xThesaurus
->hasLocale( LanguageTag::convertToLocale( eLang
)))
1046 rSet
.DisableItem( SID_THESAURUS
);
1050 // is starting the presentation possible?
1051 if( SfxItemState::DEFAULT
== rSet
.GetItemState( SID_PRESENTATION
) )
1053 bool bDisable
= true;
1054 sal_uInt16 nCount
= GetDoc()->GetSdPageCount( PK_STANDARD
);
1056 for( sal_uInt16 i
= 0; i
< nCount
&& bDisable
; i
++ )
1058 SdPage
* pPage
= GetDoc()->GetSdPage(i
, PK_STANDARD
);
1060 if( !pPage
->IsExcluded() )
1063 if( bDisable
|| GetDocSh()->IsPreview())
1065 rSet
.DisableItem( SID_PRESENTATION
);
1069 FuBullet::GetSlotState( rSet
, this, GetViewFrame() );
1074 * gets invoked when ScrollBar is used
1076 long OutlineViewShell::VirtHScrollHdl(ScrollBar
* pHScroll
)
1078 long nThumb
= pHScroll
->GetThumbPos();
1079 long nRange
= pHScroll
->GetRange().Len();
1080 double fX
= (double) nThumb
/ nRange
;
1082 Window
* pWin
= mpContentWindow
.get();
1083 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow(pWin
);
1084 long nViewWidth
= pWin
->PixelToLogic(
1085 pWin
->GetSizePixel()).Width();
1086 long nTextWidth
= pOlView
->GetPaperWidth();
1087 nViewWidth
= std::max(nViewWidth
, nTextWidth
);
1088 long nCurrentPos
= pOutlinerView
->GetVisArea().Left();
1089 long nTargetPos
= (long)(fX
* nViewWidth
);
1090 long nDelta
= nTargetPos
- nCurrentPos
;
1092 pOutlinerView
->HideCursor();
1093 pOutlinerView
->Scroll(-nDelta
, 0);
1094 pOutlinerView
->ShowCursor(false);
1099 long OutlineViewShell::VirtVScrollHdl(ScrollBar
* pVScroll
)
1101 long nThumb
= pVScroll
->GetThumbPos();
1102 long nRange
= pVScroll
->GetRange().Len();
1103 double fY
= (double) nThumb
/ nRange
;
1105 Window
* pWin
= mpContentWindow
.get();
1106 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow(pWin
);
1107 long nViewHeight
= pWin
->PixelToLogic(
1108 pWin
->GetSizePixel()).Height();
1109 long nTextHeight
= pOlView
->GetOutliner().GetTextHeight();
1110 nViewHeight
+= nTextHeight
;
1111 long nCurrentPos
= pOutlinerView
->GetVisArea().Top();
1112 long nTargetPos
= (long)(fY
* nViewHeight
);
1113 long nDelta
= nTargetPos
- nCurrentPos
;
1115 pOutlinerView
->HideCursor();
1116 pOutlinerView
->Scroll(0, -nDelta
);
1117 pOutlinerView
->ShowCursor(false);
1123 * PrepareClose, gets called when the Shell shall be destroyed.
1124 * Forwards the invocation to the View
1126 bool OutlineViewShell::PrepareClose( bool bUI
)
1128 if( !ViewShell::PrepareClose(bUI
) )
1131 return pOlView
== NULL
|| pOlView
->PrepareClose(bUI
);
1135 * Zoom with zoom factor. Inform OutlinerView
1137 void OutlineViewShell::SetZoom(long nZoom
)
1139 ViewShell::SetZoom(nZoom
);
1141 ::sd::Window
* pWindow
= mpContentWindow
.get();
1144 // change OutputArea of OutlinerView
1145 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow(pWindow
);
1146 Rectangle
aWin(Point(0,0), pWindow
->GetOutputSizePixel());
1147 aWin
= pWindow
->PixelToLogic(aWin
);
1148 pOutlinerView
->SetOutputArea(aWin
);
1151 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM
);
1152 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER
);
1156 * Zoom with zoom rectangle. Inform OutlinerView
1158 void OutlineViewShell::SetZoomRect(const Rectangle
& rZoomRect
)
1160 ViewShell::SetZoomRect(rZoomRect
);
1162 ::sd::Window
* pWindow
= mpContentWindow
.get();
1165 // change OutputArea of OutlinerView
1166 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow(pWindow
);
1167 Rectangle
aWin(Point(0,0), pWindow
->GetOutputSizePixel());
1168 aWin
= pWindow
->PixelToLogic(aWin
);
1169 pOutlinerView
->SetOutputArea(aWin
);
1172 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM
);
1173 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER
);
1177 * Before saving: Update Model of the Drawing Engine, then forward the
1178 * invocation to the ObjectShell.
1180 void OutlineViewShell::Execute(SfxRequest
& rReq
)
1182 bool bForwardCall
= true;
1184 switch(rReq
.GetSlot())
1191 case SID_SEARCH_ITEM
:
1192 // Forward this request to the common (old) code of the
1194 GetDocSh()->Execute (rReq
);
1195 bForwardCall
= false;
1198 case SID_SPELL_DIALOG
:
1200 SfxViewFrame
* pViewFrame
= GetViewFrame();
1201 if (rReq
.GetArgs() != NULL
)
1202 pViewFrame
->SetChildWindow (SID_SPELL_DIALOG
,
1203 static_cast<const SfxBoolItem
&>(rReq
.GetArgs()->
1204 Get(SID_SPELL_DIALOG
)).GetValue());
1206 pViewFrame
->ToggleChildWindow(SID_SPELL_DIALOG
);
1208 pViewFrame
->GetBindings().Invalidate(SID_SPELL_DIALOG
);
1211 bForwardCall
= false;
1216 OSL_TRACE ("OutlineViewShell::Execute(): can not handle slot %d", rReq
.GetSlot());
1222 static_cast<DrawDocShell
*>(GetViewFrame()->GetObjectShell())->ExecuteSlot( rReq
);
1226 * Read FrameViews data and set actual views data
1228 void OutlineViewShell::ReadFrameViewData(FrameView
* pView
)
1230 ::Outliner
& rOutl
= pOlView
->GetOutliner();
1232 rOutl
.SetFlatMode( pView
->IsNoAttribs() );
1234 EEControlBits nCntrl
= rOutl
.GetControlWord();
1236 if ( pView
->IsNoColors() )
1237 rOutl
.SetControlWord(nCntrl
| EEControlBits::NOCOLORS
);
1239 rOutl
.SetControlWord(nCntrl
& ~EEControlBits::NOCOLORS
);
1241 sal_uInt16 nPage
= mpFrameView
->GetSelectedPage();
1242 pLastPage
= GetDoc()->GetSdPage( nPage
, PK_STANDARD
);
1243 pOlView
->SetActualPage(pLastPage
);
1247 * Write actual views data to FrameView
1249 void OutlineViewShell::WriteFrameViewData()
1251 ::Outliner
& rOutl
= pOlView
->GetOutliner();
1253 EEControlBits nCntrl
= rOutl
.GetControlWord();
1254 bool bNoColor
= false;
1255 if (nCntrl
& EEControlBits::NOCOLORS
)
1257 mpFrameView
->SetNoColors(bNoColor
);
1258 mpFrameView
->SetNoAttribs( rOutl
.IsFlatMode() );
1259 SdPage
* pActualPage
= pOlView
->GetActualPage();
1260 DBG_ASSERT(pActualPage
, "No current page");
1262 mpFrameView
->SetSelectedPage((pActualPage
->GetPageNum() - 1) / 2);
1266 * Handle SfxRequests for the StatusBar
1268 void OutlineViewShell::ExecStatusBar(SfxRequest
&)
1272 void OutlineViewShell::GetStatusBarState(SfxItemSet
& rSet
)
1275 if( SfxItemState::DEFAULT
== rSet
.GetItemState( SID_ATTR_ZOOM
) )
1277 sal_uInt16 nZoom
= (sal_uInt16
) GetActiveWindow()->GetZoom();
1279 boost::scoped_ptr
<SvxZoomItem
> pZoomItem(new SvxZoomItem( SvxZoomType::PERCENT
, nZoom
));
1282 SvxZoomEnableFlags nZoomValues
= SvxZoomEnableFlags::ALL
;
1283 nZoomValues
&= ~SvxZoomEnableFlags::OPTIMAL
;
1284 nZoomValues
&= ~SvxZoomEnableFlags::WHOLEPAGE
;
1285 nZoomValues
&= ~SvxZoomEnableFlags::PAGEWIDTH
;
1287 pZoomItem
->SetValueSet( nZoomValues
);
1288 rSet
.Put( *pZoomItem
);
1291 if( SfxItemState::DEFAULT
== rSet
.GetItemState( SID_ATTR_ZOOMSLIDER
) )
1293 if (GetDocSh()->IsUIActive() || !GetActiveWindow() )
1295 rSet
.DisableItem( SID_ATTR_ZOOMSLIDER
);
1299 sd::Window
* pActiveWindow
= GetActiveWindow();
1300 SvxZoomSliderItem
aZoomItem( (sal_uInt16
) pActiveWindow
->GetZoom(), (sal_uInt16
)pActiveWindow
->GetMinZoom(), (sal_uInt16
)pActiveWindow
->GetMaxZoom() ) ;
1301 aZoomItem
.AddSnappingPoint(100);
1302 rSet
.Put( aZoomItem
);
1306 // page view and layout
1308 sal_uInt16 nPageCount
= GetDoc()->GetSdPageCount( PK_STANDARD
);
1309 OUString aPageStr
, aLayoutStr
;
1311 ::sd::Window
* pWin
= GetActiveWindow();
1312 OutlinerView
* pActiveView
= pOlView
->GetViewByWindow( pWin
);
1314 std::vector
<Paragraph
*> aSelList
;
1315 pActiveView
->CreateSelectionList(aSelList
);
1317 Paragraph
*pFirstPara
= NULL
;
1318 Paragraph
*pLastPara
= NULL
;
1320 if (!aSelList
.empty())
1322 pFirstPara
= *(aSelList
.begin());
1323 pLastPara
= *(aSelList
.rbegin());
1326 if( !::Outliner::HasParaFlag(pFirstPara
,ParaFlag::ISPAGE
) )
1327 pFirstPara
= pOlView
->GetPrevTitle( pFirstPara
);
1329 if( !::Outliner::HasParaFlag(pLastPara
, ParaFlag::ISPAGE
) )
1330 pLastPara
= pOlView
->GetPrevTitle( pLastPara
);
1332 // only one page selected?
1333 if( pFirstPara
== pLastPara
)
1335 // how many pages are we before the selected page?
1336 sal_uLong nPos
= 0L;
1339 pFirstPara
= pOlView
->GetPrevTitle( pFirstPara
);
1344 if( nPos
>= GetDoc()->GetSdPageCount( PK_STANDARD
) )
1347 SdrPage
* pPage
= GetDoc()->GetSdPage( (sal_uInt16
) nPos
, PK_STANDARD
);
1349 aPageStr
= SD_RESSTR(STR_SD_PAGE_COUNT
);
1351 aPageStr
= aPageStr
.replaceFirst("%1", OUString::number((sal_Int32
)(nPos
+ 1)));
1352 aPageStr
= aPageStr
.replaceFirst("%2", OUString::number(nPageCount
));
1354 aLayoutStr
= pPage
->GetLayoutName();
1355 sal_Int32 nIndex
= aLayoutStr
.indexOf(SD_LT_SEPARATOR
);
1357 aLayoutStr
= aLayoutStr
.copy(0, nIndex
);
1358 //Now, CurrentPage property change is already sent for DrawView and OutlineView, so it is not necessary to send again here
1359 if(m_StrOldPageName
!=aPageStr
)
1361 GetViewShellBase().GetDrawController().fireSwitchCurrentPage(nPos
);
1362 m_StrOldPageName
= aPageStr
;
1365 rSet
.Put( SfxStringItem( SID_STATUS_PAGE
, aPageStr
) );
1366 rSet
.Put( SfxStringItem( SID_STATUS_LAYOUT
, aLayoutStr
) );
1369 void OutlineViewShell::Command( const CommandEvent
& rCEvt
, ::sd::Window
* pWin
)
1371 if ( rCEvt
.GetCommand() == CommandEventId::ContextMenu
)
1373 GetActiveWindow()->ReleaseMouse();
1375 OutlinerView
* pOLV
= pOlView
->GetViewByWindow(GetActiveWindow());
1376 Point
aPos(rCEvt
.GetMousePosPixel());
1378 if (pOLV
&& pOLV
->IsWrongSpelledWordAtPos(aPos
))
1380 // Popup for Online-Spelling now handled by DrawDocShell
1381 Link
<> aLink
= LINK(GetDocSh(), DrawDocShell
, OnlineSpellCallback
);
1383 pOLV
->ExecuteSpellPopup(aPos
, &aLink
);
1387 GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(RID_OUTLINE_POPUP
));
1392 ViewShell::Command( rCEvt
, pWin
);
1394 // if necessary communicate the new context to the Preview
1395 Invalidate( SID_PREVIEW_STATE
);
1400 bool OutlineViewShell::KeyInput(const KeyEvent
& rKEvt
, ::sd::Window
* pWin
)
1402 bool bReturn
= false;
1403 OutlineViewPageChangesGuard
aGuard(pOlView
);
1405 if (pWin
== NULL
&& HasCurrentFunction())
1407 bReturn
= GetCurrentFunction()->KeyInput(rKEvt
);
1410 // no, forward to base class
1413 bReturn
= ViewShell::KeyInput(rKEvt
, pWin
);
1416 Invalidate(SID_STYLE_EDIT
);
1417 Invalidate(SID_STYLE_NEW
);
1418 Invalidate(SID_STYLE_DELETE
);
1419 Invalidate(SID_STYLE_HIDE
);
1420 Invalidate(SID_STYLE_SHOW
);
1421 Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE
);
1422 Invalidate(SID_STYLE_NEW_BY_EXAMPLE
);
1423 Invalidate(SID_STYLE_WATERCAN
);
1424 Invalidate(SID_STYLE_FAMILY5
);
1426 // check and distinguish cursor movements- or input-keys
1427 vcl::KeyCode
aKeyGroup( rKEvt
.GetKeyCode().GetGroup() );
1428 if( (aKeyGroup
!= KEYGROUP_CURSOR
&& aKeyGroup
!= KEYGROUP_FKEYS
) ||
1429 (GetActualPage() != pLastPage
) )
1431 Invalidate( SID_PREVIEW_STATE
);
1438 * Status of Attribute-Items
1440 void OutlineViewShell::GetAttrState( SfxItemSet
& rSet
)
1442 SfxWhichIter
aIter( rSet
);
1443 sal_uInt16 nWhich
= aIter
.FirstWhich();
1444 SfxAllItemSet
aAllSet( *rSet
.GetPool() );
1448 sal_uInt16 nSlotId
= SfxItemPool::IsWhich(nWhich
)
1449 ? GetPool().GetSlotId(nWhich
)
1454 case SID_STYLE_FAMILY2
:
1455 case SID_STYLE_FAMILY3
:
1457 rSet
.DisableItem( nWhich
);
1461 case SID_STYLE_FAMILY5
:
1463 SfxStyleSheet
* pStyleSheet
= pOlView
->GetViewByWindow(GetActiveWindow())->GetStyleSheet();
1467 pStyleSheet
= static_cast<SdStyleSheet
*>(pStyleSheet
)->GetPseudoStyleSheet();
1471 SfxTemplateItem
aItem( nWhich
, pStyleSheet
->GetName() );
1472 aAllSet
.Put( aItem
, aItem
.Which() );
1478 SfxTemplateItem
aItem( nWhich
, OUString() );
1479 aAllSet
.Put( aItem
, aItem
.Which() );
1480 // rSet.DisableItem( nWhich );
1485 case SID_STYLE_EDIT
:
1487 SfxPoolItem
* pItem
= NULL
;
1488 GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY
, pItem
);
1489 SfxUInt16Item
* pFamilyItem
= dynamic_cast<SfxUInt16Item
*>(pItem
);
1490 if (pFamilyItem
&& SfxTemplate::NIdToSfxFamilyId(pFamilyItem
->GetValue()) == SD_STYLE_FAMILY_PSEUDO
)
1492 SfxItemSet
aSet(*rSet
.GetPool(), SID_STATUS_LAYOUT
, SID_STATUS_LAYOUT
);
1493 GetStatusBarState(aSet
);
1494 OUString aRealStyle
= static_cast<const SfxStringItem
&>(aSet
.Get(SID_STATUS_LAYOUT
)).GetValue();
1495 if (aRealStyle
.isEmpty())
1497 // no unique layout name found
1498 rSet
.DisableItem(nWhich
);
1505 case SID_STYLE_UPDATE_BY_EXAMPLE
:
1507 ::sd::Window
* pActWin
= GetActiveWindow();
1508 OutlinerView
* pOV
= pOlView
->GetViewByWindow(pActWin
);
1509 ESelection
aESel(pOV
->GetSelection());
1511 if (aESel
.nStartPara
!= aESel
.nEndPara
||
1512 aESel
.nStartPos
!= aESel
.nEndPos
)
1513 // spanned selection, i.e. StyleSheet and/or
1514 // attribution not necessarily unqiue
1515 rSet
.DisableItem(nWhich
);
1520 case SID_STYLE_DELETE
:
1521 case SID_STYLE_HIDE
:
1522 case SID_STYLE_SHOW
:
1523 case SID_STYLE_NEW_BY_EXAMPLE
:
1524 case SID_STYLE_WATERCAN
:
1526 rSet
.DisableItem(nWhich
);
1531 nWhich
= aIter
.NextWhich();
1534 rSet
.Put( aAllSet
, false );
1537 void OutlineViewShell::MouseButtonUp(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
)
1539 // first the base classes
1540 ViewShell::MouseButtonUp(rMEvt
, pWin
);
1542 Invalidate(SID_STYLE_EDIT
);
1543 Invalidate(SID_STYLE_NEW
);
1544 Invalidate(SID_STYLE_DELETE
);
1545 Invalidate(SID_STYLE_HIDE
);
1546 Invalidate(SID_STYLE_SHOW
);
1547 Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE
);
1548 Invalidate(SID_STYLE_NEW_BY_EXAMPLE
);
1549 Invalidate(SID_STYLE_WATERCAN
);
1550 Invalidate(SID_STYLE_FAMILY5
);
1552 // if necessary communicate the new context to the Preview
1553 if( GetActualPage() != pLastPage
)
1554 Invalidate( SID_PREVIEW_STATE
);
1557 SdPage
* OutlineViewShell::getCurrentPage() const
1559 // since there are no master pages in outline view, we can
1560 // for now use the GetActualPage method
1561 return const_cast<OutlineViewShell
*>(this)->GetActualPage();
1565 * Returns the first selected page.
1566 * If nothing is selected, the first page is returned.
1568 SdPage
* OutlineViewShell::GetActualPage()
1570 return pOlView
->GetActualPage();
1573 void OutlineViewShell::UpdatePreview( SdPage
* pPage
, bool )
1575 const bool bNewPage
= pPage
!= pLastPage
;
1579 OutlineViewPageChangesGuard
aGuard(pOlView
);
1580 SetCurrentPage(pPage
);
1584 bool OutlineViewShell::UpdateTitleObject( SdPage
* pPage
, Paragraph
* pPara
)
1586 DBG_ASSERT( pPage
, "sd::OutlineViewShell::UpdateTitleObject(), pPage == 0?" );
1587 DBG_ASSERT( pPara
, "sd::OutlineViewShell::UpdateTitleObject(), pPara == 0?" );
1589 if( !pPage
|| !pPara
)
1592 ::Outliner
& rOutliner
= pOlView
->GetOutliner();
1593 SdrTextObj
* pTO
= OutlineView::GetTitleTextObject( pPage
);
1595 OUString aTest
= rOutliner
.GetText(pPara
);
1596 bool bText
= !aTest
.isEmpty();
1597 bool bNewObject
= false;
1601 // create a title object if we don't have one but have text
1604 DBG_ASSERT( pOlView
->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1605 pTO
= OutlineView::CreateTitleTextObject(pPage
);
1609 // if we have a title object and a text, set the text
1610 OutlinerParaObject
* pOPO
= pTO
? rOutliner
.CreateParaObject(rOutliner
.GetAbsPos(pPara
), 1) : NULL
;
1613 pOPO
->SetOutlinerMode( OUTLINERMODE_TITLEOBJECT
);
1614 pOPO
->SetVertical( pTO
->IsVerticalWriting() );
1615 if( pTO
->GetOutlinerParaObject() && (pOPO
->GetTextObject() == pTO
->GetOutlinerParaObject()->GetTextObject()) )
1617 // do nothing, same text already set
1622 DBG_ASSERT( pOlView
->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1623 if( !bNewObject
&& pOlView
->isRecordingUndo() )
1624 pOlView
->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO
,0));
1626 pTO
->SetOutlinerParaObject( pOPO
);
1627 pTO
->SetEmptyPresObj( false );
1628 pTO
->ActionChanged();
1634 // no text but object available?
1635 // outline object available, but we have no text
1636 if(pPage
->IsPresObj(pTO
))
1638 // if it is not already empty
1639 if( !pTO
->IsEmptyPresObj() )
1641 DBG_ASSERT( pOlView
->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1644 if( pOlView
->isRecordingUndo() )
1645 pOlView
->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO
,0));
1646 pPage
->RestoreDefaultText( pTO
);
1647 pTO
->SetEmptyPresObj(true);
1648 pTO
->ActionChanged();
1653 DBG_ASSERT( pOlView
->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1654 // outline object is not part of the layout, delete it
1655 if( pOlView
->isRecordingUndo() )
1656 pOlView
->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoRemoveObject(*pTO
));
1657 pPage
->RemoveObject(pTO
->GetOrdNum());
1664 bool OutlineViewShell::UpdateOutlineObject( SdPage
* pPage
, Paragraph
* pPara
)
1666 DBG_ASSERT( pPage
, "sd::OutlineViewShell::UpdateOutlineObject(), pPage == 0?" );
1667 DBG_ASSERT( pPara
, "sd::OutlineViewShell::UpdateOutlineObject(), pPara == 0?" );
1669 if( !pPage
|| !pPara
)
1672 ::Outliner
& rOutliner
= pOlView
->GetOutliner();
1673 OutlinerParaObject
* pOPO
= NULL
;
1674 SdrTextObj
* pTO
= NULL
;
1676 bool bNewObject
= false;
1678 sal_uInt16 eOutlinerMode
= OUTLINERMODE_TITLEOBJECT
;
1679 pTO
= static_cast<SdrTextObj
*>(pPage
->GetPresObj( PRESOBJ_TEXT
));
1682 eOutlinerMode
= OUTLINERMODE_OUTLINEOBJECT
;
1683 pTO
= OutlineView::GetOutlineTextObject( pPage
);
1686 // how many paragraphs in the outline?
1687 sal_Int32 nTitlePara
= rOutliner
.GetAbsPos( pPara
);
1688 sal_Int32 nPara
= nTitlePara
+ 1;
1689 sal_Int32 nParasInLayout
= 0L;
1690 pPara
= rOutliner
.GetParagraph( nPara
);
1691 while( pPara
&& !::Outliner::HasParaFlag(pPara
, ParaFlag::ISPAGE
) )
1694 pPara
= rOutliner
.GetParagraph( ++nPara
);
1696 if( nParasInLayout
)
1698 // create an OutlinerParaObject
1699 pOPO
= rOutliner
.CreateParaObject( nTitlePara
+ 1, nParasInLayout
);
1704 DBG_ASSERT( pOlView
->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
1706 // do we need an outline text object?
1709 pTO
= OutlineView::CreateOutlineTextObject( pPage
);
1713 // page object, outline text in Outliner:
1717 pOPO
->SetVertical( pTO
->IsVerticalWriting() );
1718 pOPO
->SetOutlinerMode( eOutlinerMode
);
1719 if( pTO
->GetOutlinerParaObject() && (pOPO
->GetTextObject() == pTO
->GetOutlinerParaObject()->GetTextObject()) )
1721 // do nothing, same text already set
1726 if( !bNewObject
&& pOlView
->isRecordingUndo() )
1727 pOlView
->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO
,0));
1729 pTO
->SetOutlinerParaObject( pOPO
);
1730 pTO
->SetEmptyPresObj( false );
1731 pTO
->ActionChanged();
1739 // page object but no outline text:
1740 // if the object is in the outline of the page -> default text
1742 // otherwise delete object
1743 if( pPage
->IsPresObj(pTO
) )
1745 if( !pTO
->IsEmptyPresObj() )
1747 DBG_ASSERT( pOlView
->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
1749 // delete old OutlinerParaObject, too
1750 if( pOlView
->isRecordingUndo() )
1751 pOlView
->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO
,0));
1752 pPage
->RestoreDefaultText( pTO
);
1753 pTO
->SetEmptyPresObj(true);
1754 pTO
->ActionChanged();
1759 DBG_ASSERT( pOlView
->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
1760 if( pOlView
->isRecordingUndo() )
1761 pOlView
->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoRemoveObject(*pTO
));
1762 pPage
->RemoveObject(pTO
->GetOrdNum());
1770 * Fill Outliner from Stream
1772 sal_uLong
OutlineViewShell::Read(SvStream
& rInput
, const OUString
& rBaseURL
, sal_uInt16 eFormat
)
1776 ::Outliner
& rOutl
= pOlView
->GetOutliner();
1778 OutlineViewPageChangesGuard
aGuard( pOlView
);
1779 OutlineViewModelChangeGuard
aGuard2( *pOlView
);
1781 bRet
= rOutl
.Read( rInput
, rBaseURL
, eFormat
, GetDocSh()->GetHeaderAttributes() );
1783 SdPage
* pPage
= GetDoc()->GetSdPage( GetDoc()->GetSdPageCount(PK_STANDARD
) - 1, PK_STANDARD
);;
1784 SfxStyleSheet
* pTitleSheet
= pPage
->GetStyleSheetForPresObj( PRESOBJ_TITLE
);
1785 SfxStyleSheet
* pOutlSheet
= pPage
->GetStyleSheetForPresObj( PRESOBJ_OUTLINE
);
1787 sal_Int32 nParaCount
= rOutl
.GetParagraphCount();
1788 if ( nParaCount
> 0 )
1790 for ( sal_Int32 nPara
= 0; nPara
< nParaCount
; nPara
++ )
1792 pOlView
->UpdateParagraph( nPara
);
1794 sal_Int16 nDepth
= rOutl
.GetDepth( nPara
);
1796 if( (nDepth
== 0) || !nPara
)
1798 Paragraph
* pPara
= rOutl
.GetParagraph( nPara
);
1799 rOutl
.SetDepth(pPara
, -1);
1800 rOutl
.SetParaFlag(pPara
, ParaFlag::ISPAGE
);
1802 rOutl
.SetStyleSheet( nPara
, pTitleSheet
);
1804 if( nPara
) // first slide already exists
1805 pOlView
->InsertSlideForParagraph( pPara
);
1809 rOutl
.SetDepth( rOutl
.GetParagraph( nPara
), nDepth
- 1 );
1810 OUString aStyleSheetName
= pOutlSheet
->GetName();
1811 if (!aStyleSheetName
.isEmpty())
1812 aStyleSheetName
= aStyleSheetName
.copy(0, aStyleSheetName
.getLength() - 1);
1813 aStyleSheetName
+= OUString::number( nDepth
);
1814 SfxStyleSheetBasePool
* pStylePool
= GetDoc()->GetStyleSheetPool();
1815 SfxStyleSheet
* pStyle
= static_cast<SfxStyleSheet
*>( pStylePool
->Find( aStyleSheetName
, pOutlSheet
->GetFamily() ) );
1816 DBG_ASSERT( pStyle
, "AutoStyleSheetName - Style not found!" );
1818 rOutl
.SetStyleSheet( nPara
, pStyle
);
1823 rOutl
.GetUndoManager().Clear();
1828 void OutlineViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rSequence
, bool bBrowse
)
1830 WriteFrameViewData();
1832 ViewShell::WriteUserDataSequence( rSequence
, bBrowse
);
1835 void OutlineViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rSequence
, bool bBrowse
)
1837 WriteFrameViewData();
1839 ViewShell::ReadUserDataSequence( rSequence
, bBrowse
);
1841 ReadFrameViewData( mpFrameView
);
1844 void OutlineViewShell::VisAreaChanged(const Rectangle
& rRect
)
1846 ViewShell::VisAreaChanged( rRect
);
1848 GetViewShellBase().GetDrawController().FireVisAreaChanged(rRect
);
1851 /** If there is a valid controller then create a new instance of
1852 <type>AccessibleDrawDocumentView</type>. Otherwise return an empty
1855 ::com::sun::star::uno::Reference
<
1856 ::com::sun::star::accessibility::XAccessible
>
1857 OutlineViewShell::CreateAccessibleDocumentView (::sd::Window
* pWindow
)
1859 OSL_ASSERT (GetViewShell()!=NULL
);
1860 if (GetViewShell()->GetController() != NULL
)
1862 ::accessibility::AccessibleOutlineView
* pDocumentView
=
1863 new ::accessibility::AccessibleOutlineView (
1866 GetViewShell()->GetController(),
1867 pWindow
->GetAccessibleParentWindow()->GetAccessible());
1868 pDocumentView
->Init();
1869 return ::com::sun::star::uno::Reference
<
1870 ::com::sun::star::accessibility::XAccessible
>
1871 (static_cast< ::com::sun::star::uno::XWeak
*>(pDocumentView
),
1872 ::com::sun::star::uno::UNO_QUERY
);
1875 OSL_TRACE ("OutlineViewShell::CreateAccessibleDocumentView: no controller");
1876 return ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>();
1879 void OutlineViewShell::GetState (SfxItemSet
& rSet
)
1881 // Iterate over all requested items in the set.
1882 SfxWhichIter
aIter( rSet
);
1883 sal_uInt16 nWhich
= aIter
.FirstWhich();
1888 case SID_SEARCH_ITEM
:
1889 case SID_SEARCH_OPTIONS
:
1890 // Call common (old) implementation in the document shell.
1891 GetDocSh()->GetState (rSet
);
1894 OSL_TRACE ("OutlineViewShell::GetState(): can not handle which id %d", nWhich
);
1897 nWhich
= aIter
.NextWhich();
1901 void OutlineViewShell::SetCurrentPage (SdPage
* pPage
)
1903 // Adapt the selection of the model.
1904 for (sal_uInt16 i
=0; i
<GetDoc()->GetSdPageCount(PK_STANDARD
); i
++)
1905 GetDoc()->SetSelected(
1906 GetDoc()->GetSdPage(i
, PK_STANDARD
),
1908 GetDoc()->SetSelected (pPage
, true);
1910 DrawController
& rController(GetViewShellBase().GetDrawController());
1911 rController
.FireSelectionChangeListener();
1912 rController
.FireSwitchCurrentPage (pPage
);
1914 pOlView
->SetActualPage(pPage
);
1917 } // end of namespace sd
1919 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */