/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
if ( mxClipEvtLstnr.is() )
{
mxClipEvtLstnr->RemoveListener( GetActiveWindow() );
mxClipEvtLstnr->ClearCallbackLink(); // prevent callback if another thread is waiting
}
}
/** * Paint method: the event gets forwarded from pWindow to the Viewshell * and the current function
*/ void OutlineViewShell::Paint(const ::tools::Rectangle& rRect, ::sd::Window* pWin)
{ if (pOlView)
{
pOlView->Paint(rRect, pWin);
}
}
void OutlineViewShell::ArrangeGUIElements ()
{ // Retrieve the current size (thickness) of the scroll bars. That is // the width of the vertical and the height of the horizontal scroll // bar. int nScrollBarSize =
GetParentWindow()->GetSettings().GetStyleSettings().GetScrollBarSize();
maScrBarWH = Size (nScrollBarSize, nScrollBarSize);
ViewShell::ArrangeGUIElements ();
::sd::Window* pWindow = mpContentWindow.get(); if (pWindow == nullptr) return;
pWindow->SetMinZoomAutoCalc(false);
// change OutputArea of the OutlinerView
OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow);
// Links must be kept also on deactivated viewshell, to allow drag'n'drop // to function properly
ViewShell::Deactivate( bIsMDIActivate );
}
/** * Set status of Controller-SfxSlots
*/ void OutlineViewShell::GetCtrlState(SfxItemSet &rSet)
{ if (SfxItemState::DEFAULT == rSet.GetItemState(SID_HYPERLINK_GETLINK))
{
SvxHyperlinkItem aHLinkItem;
case SID_DRAWINGMODE: case SID_SLIDE_MASTER_MODE: case SID_NOTES_MODE: case SID_NOTES_MASTER_MODE: case SID_HANDOUT_MASTER_MODE: case SID_SLIDE_SORTER_MODE: case SID_OUTLINE_MODE:
framework::FrameworkHelper::Instance(GetViewShellBase())->HandleModeChangeSlot(
nSlot,
rReq);
rReq.Done(); break;
case SID_RULER:
SetRuler( !HasRuler() );
Invalidate( SID_RULER );
rReq.Done(); break;
case SID_ZOOM_PREV:
{ if (mpZoomList->IsPreviousPossible())
{
SetZoomRect(mpZoomList->GetPreviousZoomRect());
}
rReq.Done ();
} break;
case SID_ZOOM_NEXT:
{ if (mpZoomList->IsNextPossible())
{
SetZoomRect(mpZoomList->GetNextZoomRect());
}
rReq.Done ();
} break;
case SID_AUTOSPELL_CHECK:
{
GetDoc()->SetOnlineSpell(!GetDoc()->GetOnlineSpell());
rReq.Done ();
} break;
case SID_TRANSLITERATE_SENTENCE_CASE: case SID_TRANSLITERATE_TITLE_CASE: case SID_TRANSLITERATE_TOGGLE_CASE: case SID_TRANSLITERATE_UPPER: case SID_TRANSLITERATE_LOWER: case SID_TRANSLITERATE_HALFWIDTH: case SID_TRANSLITERATE_FULLWIDTH: case SID_TRANSLITERATE_HIRAGANA: case SID_TRANSLITERATE_KATAKANA:
{
OutlinerView* pOLV = pOlView ? pOlView->GetViewByWindow( GetActiveWindow() ) : nullptr; if( pOLV )
{
TransliterationFlags nType = TransliterationFlags::NONE;
switch( nSlot )
{ case SID_TRANSLITERATE_SENTENCE_CASE:
nType = TransliterationFlags::SENTENCE_CASE; break; case SID_TRANSLITERATE_TITLE_CASE:
nType = TransliterationFlags::TITLE_CASE; break; case SID_TRANSLITERATE_TOGGLE_CASE:
nType = TransliterationFlags::TOGGLE_CASE; break; case SID_TRANSLITERATE_UPPER:
nType = TransliterationFlags::LOWERCASE_UPPERCASE; break; case SID_TRANSLITERATE_LOWER:
nType = TransliterationFlags::UPPERCASE_LOWERCASE; break; case SID_TRANSLITERATE_HALFWIDTH:
nType = TransliterationFlags::FULLWIDTH_HALFWIDTH; break; case SID_TRANSLITERATE_FULLWIDTH:
nType = TransliterationFlags::HALFWIDTH_FULLWIDTH; break; case SID_TRANSLITERATE_HIRAGANA:
nType = TransliterationFlags::KATAKANA_HIRAGANA; break; case SID_TRANSLITERATE_KATAKANA:
nType = TransliterationFlags::HIRAGANA_KATAKANA; break;
}
if (rOutl.HasChildren(pPara))
{ if (!rOutl.IsExpanded(pPara))
bDisableExpand = false; else
bDisableCollapse = false;
}
}
}
if (bDisableExpand)
rSet.DisableItem(SID_OUTLINE_EXPAND); if (bDisableCollapse)
rSet.DisableItem(SID_OUTLINE_COLLAPSE);
// does the selection provide a unique presentation layout? // if not, the templates must not be edited
SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<SID_STATUS_LAYOUT, SID_STATUS_LAYOUT>(*rSet.GetPool()));
GetStatusBarState(aSet);
OUString aTest = aSet.Get(SID_STATUS_LAYOUT).GetValue(); if (aTest.isEmpty())
{
bUnique = false;
}
if (!bUnique)
rSet.DisableItem( SID_PRESENTATIONOBJECT );
// now the selection independent ones: COLLAPSE_ALL, EXPAND_ALL bool bDisableCollapseAll = true; bool bDisableExpandAll = true;
// does the selection contain something collapsible/expandable? if (!bDisableCollapse)
bDisableCollapseAll = false; if (!bDisableExpand)
bDisableExpandAll = false;
// otherwise look through all paragraphs if (bDisableCollapseAll || bDisableExpandAll)
{
sal_Int32 nParaPos = 0;
Paragraph* pPara = rOutl.GetParagraph( nParaPos ); while (pPara && (bDisableCollapseAll || bDisableExpandAll))
{ if (!rOutl.IsExpanded(pPara) && rOutl.HasChildren(pPara))
bDisableExpandAll = false;
if (rOutl.IsExpanded(pPara) && rOutl.HasChildren(pPara))
bDisableCollapseAll = false;
pPara = rOutl.GetParagraph( ++nParaPos );
}
}
if (bDisableExpandAll)
rSet.DisableItem(SID_OUTLINE_EXPAND_ALL); if (bDisableCollapseAll)
rSet.DisableItem(SID_OUTLINE_COLLAPSE_ALL);
/** * PrepareClose, gets called when the Shell shall be destroyed. * Forwards the invocation to the View
*/ bool OutlineViewShell::PrepareClose( bool bUI )
{ if( !ViewShell::PrepareClose(bUI) ) returnfalse;
if (pOlView)
pOlView->PrepareClose(); returntrue;
}
/** * Before saving: Update Model of the Drawing Engine, then forward the * invocation to the ObjectShell.
*/ void OutlineViewShell::Execute(SfxRequest& rReq)
{ bool bForwardCall = true;
switch(rReq.GetSlot())
{ case SID_SAVEDOC: case SID_SAVEASDOC:
PrepareClose(); break;
case SID_SEARCH_ITEM: // Forward this request to the common (old) code of the // document shell.
GetDocSh()->Execute (rReq);
bForwardCall = false; break;
case SID_SPELL_DIALOG:
{
SfxViewFrame* pViewFrame = GetViewFrame(); if (rReq.GetArgs() != nullptr)
pViewFrame->SetChildWindow (SID_SPELL_DIALOG, static_cast<const SfxBoolItem&>(rReq.GetArgs()->
Get(SID_SPELL_DIALOG)).GetValue()); else
pViewFrame->ToggleChildWindow(SID_SPELL_DIALOG);
default:
SAL_WARN("sd", "OutlineViewShell::Execute(): can not handle slot " << rReq.GetSlot()); break;
}
if (bForwardCall) static_cast<DrawDocShell*>(GetViewFrame()->GetObjectShell())->ExecuteSlot( rReq );
}
/** * Read FrameViews data and set actual views data
*/ void OutlineViewShell::ReadFrameViewData(FrameView* pView)
{
::Outliner& rOutl = pOlView->GetOutliner();
// only one page selected? if( pFirstPara == pLastPara )
{ // how many pages are we before the selected page?
sal_uLong nPos = 0; while( pFirstPara )
{
pFirstPara = pOlView->GetPrevTitle( pFirstPara ); if( pFirstPara )
nPos++;
}
aLayoutStr = pPage->GetLayoutName();
sal_Int32 nIndex = aLayoutStr.indexOf(SD_LT_SEPARATOR); if (nIndex != -1)
aLayoutStr = aLayoutStr.copy(0, nIndex); //Now, CurrentPage property change is already sent for DrawView and OutlineView, so it is not necessary to send again here if(m_StrOldPageName!=aPageStr)
{
GetViewShellBase().GetDrawController()->fireSwitchCurrentPage(nPos);
m_StrOldPageName = aPageStr;
}
}
rSet.Put( SfxStringItem( SID_STATUS_PAGE, aPageStr ) );
rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aLayoutStr ) );
}
OutlinerView* pOLV = pOlView->GetViewByWindow(GetActiveWindow());
Point aPos(rCEvt.GetMousePosPixel());
if (pOLV && pOLV->IsWrongSpelledWordAtPos(aPos))
{ // Popup for Online-Spelling now handled by DrawDocShell
Link<SpellCallbackInfo&,void> aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
if (aESel.HasRange()) // spanned selection, i.e. StyleSheet and/or // attribution not necessarily unique
rSet.DisableItem(nWhich);
} break;
case SID_STYLE_NEW: case SID_STYLE_DELETE: case SID_STYLE_HIDE: case SID_STYLE_SHOW: case SID_STYLE_NEW_BY_EXAMPLE: case SID_STYLE_WATERCAN:
{
rSet.DisableItem(nWhich);
} break;
}
nWhich = aIter.NextWhich();
}
rSet.Put( aAllSet, false );
}
void OutlineViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
{ // first the base classes
ViewShell::MouseButtonUp(rMEvt, pWin);
// if necessary communicate the new context to the Preview if( GetActualPage() != pLastPage )
Invalidate( SID_PREVIEW_STATE );
}
SdPage* OutlineViewShell::getCurrentPage() const
{ // since there are no master pages in outline view, we can // for now use the GetActualPage method returnconst_cast<OutlineViewShell*>(this)->GetActualPage();
}
/** * Returns the first selected page. * If nothing is selected, the first page is returned.
*/
SdPage* OutlineViewShell::GetActualPage()
{ return pOlView->GetActualPage();
}
if( bText )
{ bool bNewObject = false; // create a title object if we don't have one but have text if( !pTO )
{
DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
pTO = OutlineView::CreateTitleTextObject(pPage);
bNewObject = true;
}
// if we have a title object and a text, set the text
std::optional<OutlinerParaObject> pOPO; if (pTO)
pOPO = rOutliner.CreateParaObject(rOutliner.GetAbsPos(pPara), 1); if (pOPO)
{
pOPO->SetOutlinerMode( OutlinerMode::TitleObject );
assert(pTO);
pOPO->SetVertical( pTO->IsVerticalWriting() ); if( pTO->GetOutlinerParaObject() && (pOPO->GetTextObject() == pTO->GetOutlinerParaObject()->GetTextObject()) )
{ // do nothing, same text already set
} else
{
DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" ); if( !bNewObject && pOlView->isRecordingUndo() )
pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
pTO->SetOutlinerParaObject( std::move(pOPO) );
pTO->SetEmptyPresObj( false );
pTO->ActionChanged();
}
}
} elseif( pTO )
{ // no text but object available? // outline object available, but we have no text if(pPage->IsPresObj(pTO))
{ // if it is not already empty if( !pTO->IsEmptyPresObj() )
{
DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
// make it empty if( pOlView->isRecordingUndo() )
pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
pPage->RestoreDefaultText( pTO );
pTO->SetEmptyPresObj(true);
pTO->ActionChanged();
}
} else
{
DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" ); // outline object is not part of the layout, delete it if( pOlView->isRecordingUndo() )
pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoRemoveObject(*pTO));
pPage->RemoveObject(pTO->GetOrdNum());
}
}
}
if( pOPO )
{
DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" ); bool bNewObject = false;
// do we need an outline text object? if( !pTO )
{
pTO = OutlineView::CreateOutlineTextObject( pPage );
bNewObject = true;
}
// page object, outline text in Outliner: // apply text if( pTO )
{
pOPO->SetVertical( pTO->IsVerticalWriting() );
pOPO->SetOutlinerMode( eOutlinerMode ); if( pTO->GetOutlinerParaObject() && (pOPO->GetTextObject() == pTO->GetOutlinerParaObject()->GetTextObject()) )
{ // do nothing, same text already set
} else
{ if( !bNewObject && pOlView->isRecordingUndo() )
pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
pTO->SetOutlinerParaObject( std::move(pOPO) );
pTO->SetEmptyPresObj( false );
pTO->ActionChanged();
}
}
} elseif( pTO )
{ // page object but no outline text: // if the object is in the outline of the page -> default text
// otherwise delete object if( pPage->IsPresObj(pTO) )
{ if( !pTO->IsEmptyPresObj() )
{
DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
// delete old OutlinerParaObject, too if( pOlView->isRecordingUndo() )
pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
pPage->RestoreDefaultText( pTO );
pTO->SetEmptyPresObj(true);
pTO->ActionChanged();
}
} else
{
DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" ); if( pOlView->isRecordingUndo() )
pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoRemoveObject(*pTO));
pPage->RemoveObject(pTO->GetOrdNum());
}
}
}
/** * Fill Outliner from Stream
*/
ErrCode OutlineViewShell::ReadRtf(SvStream& rInput)
{
ErrCode bRet = ERRCODE_NONE;
/** If there is a valid controller then create a new instance of <type>AccessibleDrawDocumentView</type>. Otherwise return an empty reference.
*/
css::uno::Reference<css::accessibility::XAccessible>
OutlineViewShell::CreateAccessibleDocumentView (::sd::Window* pWindow)
{
OSL_ASSERT (GetViewShell()!=nullptr); if (GetViewShell()->GetController() != nullptr)
{
rtl::Reference<::accessibility::AccessibleOutlineView> pDocumentView = new ::accessibility::AccessibleOutlineView (
pWindow, this,
GetViewShell()->GetController(),
pWindow->GetAccessibleParent());
pDocumentView->Init(); return pDocumentView;
}
SAL_WARN("sd", "OutlineViewShell::CreateAccessibleDocumentView: no controller"); return css::uno::Reference< css::accessibility::XAccessible >();
}
void OutlineViewShell::GetState (SfxItemSet& rSet)
{ // Iterate over all requested items in the set.
SfxWhichIter aIter( rSet );
sal_uInt16 nWhich = aIter.FirstWhich(); while (nWhich)
{ switch (nWhich)
{ case SID_SEARCH_ITEM: case SID_SEARCH_OPTIONS: // Call common (old) implementation in the document shell.
GetDocSh()->GetState (rSet); break; default:
SAL_WARN("sd", "OutlineViewShell::GetState(): can not handle which id " << nWhich); break;
}
nWhich = aIter.NextWhich();
}
}
void OutlineViewShell::SetCurrentPage (SdPage* pPage)
{ // Adapt the selection of the model. for (sal_uInt16 i=0; i<GetDoc()->GetSdPageCount(PageKind::Standard); i++)
GetDoc()->SetSelected(
GetDoc()->GetSdPage(i, PageKind::Standard), false);
GetDoc()->SetSelected (pPage, true);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.