/* -*- 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 .
*/
class ViewShellObjectBarFactory
: public ::sd::ShellFactory<SfxShell>
{ public: explicit ViewShellObjectBarFactory (::sd::ViewShell& rViewShell); virtual SfxShell* CreateShell( ::sd::ShellId nId ) override; virtualvoid ReleaseShell (SfxShell* pShell) override; private:
::sd::ViewShell& mrViewShell;
};
} // end of anonymous namespace
namespace sd {
/// When true, scrolling to bottom of a page switches to the next page. bool ViewShell::CanPanAcrossPages() const
{ returndynamic_cast<const DrawViewShell*>(this) && mpContentWindow &&
mpContentWindow->GetVisibleHeight() < 1.0;
}
// Re-initialize the spell dialog.
::sd::SpellDialogChildWindow* pSpellDialog = static_cast< ::sd::SpellDialogChildWindow*> (
GetViewFrame()->GetChildWindow (
::sd::SpellDialogChildWindow::GetChildWindowId())); if (pSpellDialog != nullptr)
pSpellDialog->InvalidateSpellDialog();
// Register the sub shell factory.
mpImpl->mpSubShellFactory = std::make_shared<ViewShellObjectBarFactory>(*this);
GetViewShellBase().GetViewShellManager()->AddSubShellFactory(this,mpImpl->mpSubShellFactory);
}
ViewShell::~ViewShell()
{ // Keep the content window from accessing in its destructor the // WindowUpdater. if (mpContentWindow)
suppress_fun_call_w_exception(mpContentWindow->SetViewShell(nullptr));
mpZoomList.reset();
mpLayerTabBar.disposeAndClear();
if (mpImpl->mpSubShellFactory)
GetViewShellBase().GetViewShellManager()->RemoveSubShellFactory( this,mpImpl->mpSubShellFactory);
if (mpContentWindow)
{
SAL_INFO( "sd.view", "destroying mpContentWindow at " << mpContentWindow.get()
<< " with parent " << mpContentWindow->GetParent());
mpContentWindow.disposeAndClear();
}
if (IsMainViewShell())
GetDocSh()->Disconnect(this);
SetIsMainViewShell(false);
}
/** * set focus to working window
*/ void ViewShell::Activate(bool bIsMDIActivate)
{ // Do not forward to SfxShell::Activate()
/* According to MI, nobody is allowed to call GrabFocus, who does not exactly know from which window the focus is grabbed. Since Activate() is sent sometimes asynchronous, it can happen, that the wrong window
gets the focus. */
if (mpHorizontalRuler)
mpHorizontalRuler->SetActive(); if (mpVerticalRuler)
mpVerticalRuler->SetActive();
if (bIsMDIActivate)
{ // thus, the Navigator will also get a current status
SfxBoolItem aItem( SID_NAVIGATOR_INIT, true ); if (GetDispatcher() != nullptr)
{
SfxCallMode nCall = SfxCallMode::RECORD; if (comphelper::LibreOfficeKit::isActive())
{ // Make sure the LOK case doesn't dispatch async events while switching views, that // would lead to a loop, see SfxHintPoster::DoEvent_Impl().
nCall |= SfxCallMode::SYNCHRON;
} else
{
nCall |= SfxCallMode::ASYNCHRON;
}
GetDispatcher()->ExecuteList(
SID_NAVIGATOR_INIT,
nCall,
{ &aItem });
}
void ViewShell::Deactivate(bool bIsMDIActivate)
{ // remove view from a still active drag'n'drop session
SdTransferable* pDragTransferable = SdModule::get()->pTransferDrag;
if (IsMainViewShell())
GetDocSh()->Disconnect(this);
if (mpHorizontalRuler)
mpHorizontalRuler->SetActive(false); if (mpVerticalRuler)
mpVerticalRuler->SetActive(false);
SfxShell::Deactivate(bIsMDIActivate);
}
void ViewShell::BroadcastContextForActivation(constbool bIsActivated)
{ auto getFrameworkResourceIdForShell
= [&]() -> uno::Reference<drawing::framework::XResourceId> const
{
DrawController* pDrawController = GetViewShellBase().GetDrawController(); if (!pDrawController) return {};
Reference<::css::drawing::framework::XConfigurationController> xConfigurationController
= pDrawController->getConfigurationController(); if (!xConfigurationController.is()) return {};
Reference<::css::drawing::framework::XConfiguration> xConfiguration
= xConfigurationController->getCurrentConfiguration(); if (!xConfiguration.is()) return {};
auto aResIdsIndirect
= xConfiguration->getResources({}, "", drawing::framework::AnchorBindingMode_INDIRECT);
for (const uno::Reference<drawing::framework::XResourceId>& rResId : aResIdsIndirect)
{ auto pFrameworkHelper = framework::FrameworkHelper::Instance(GetViewShellBase());
uno::Reference<drawing::framework::XView> xView; if (rResId->getResourceURL().match(framework::FrameworkHelper::msViewURLPrefix))
{
xView.set(xConfigurationController->getResource(rResId), UNO_QUERY);
if (xView.is())
{ if (auto pViewShellWrapper = dynamic_cast<framework::ViewShellWrapper*>(xView.get()))
{ if (pViewShellWrapper->GetViewShell().get() == this)
{ return rResId;
}
}
}
}
} return {};
};
if (bIsActivated)
{
GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(
EventMultiplexerEventId::FocusShifted, nullptr, getFrameworkResourceIdForShell());
}
if (GetDispatcher())
SfxShell::BroadcastContextForActivation(bIsActivated);
}
void ViewShell::Shutdown()
{ Exit ();
}
// IASS: Check if commands should be used for SlideShow // This is the case when IASS is on, SlideShow is active // and the SlideShow Window has the focus bool ViewShell::useInputForSlideShow() const
{
rtl::Reference< SlideShow > xSlideShow(SlideShow::GetSlideShow(GetViewShellBase()));
if (!xSlideShow.is()) // no SlideShow, do not use returnfalse;
if (!xSlideShow->isRunning()) // SlideShow not running, do not use returnfalse;
if(!xSlideShow->IsInteractiveSlideshow()) // if IASS is deactivated, do what was done before when // SlideSHow is running: use for SlideShow returntrue;
// else, check if SlideShow Window has the focus
OutputDevice* pShOut(xSlideShow->getShowWindow());
vcl::Window* pShWin(pShOut ? pShOut->GetOwnerWindow() : nullptr);
// return true if we got the SlideShow Window and it has the focus return nullptr != pShWin && pShWin->HasFocus();
}
// give key input first to SfxViewShell to give CTRL+Key // (e.g. CTRL+SHIFT+'+', to front) priority.
OSL_ASSERT(GetViewShell() != nullptr);
bReturn = GetViewShell()->KeyInput(rKEvt);
void ViewShell::MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin)
{ // We have to lock tool bar updates while the mouse button is pressed in // order to prevent the shape under the mouse to be moved (this happens // when the number of docked tool bars changes as result of a changed // selection; this changes the window size and thus the mouse position // in model coordinates: with respect to model coordinates the mouse // moves.)
OSL_ASSERT(mpImpl->mpUpdateLockForMouse.expired());
mpImpl->mpUpdateLockForMouse = ViewShell::Implementation::ToolBarManagerLock::Create(
GetViewShellBase().GetToolBarManager());
if ( pWin && !pWin->HasFocus() )
{
pWin->GrabFocus();
SetActiveWindow(pWin);
}
::sd::View* pView = GetView(); if (!pView) return;
// insert MouseEvent into E3dView
pView->SetMouseEvent(rMEvt);
SetZoom( nNewZoom ); // Keep mouse at same doc point before zoom
Point aNewMousePos = GetActiveWindow()->PixelToLogic(rCEvt.GetMousePosPixel());
SetWinViewPos(GetWinViewPos() - (aNewMousePos - aOldMousePos));
// Keep mouse at same doc point before zoom
Point aNewMousePos = GetActiveWindow()->PixelToLogic(rCEvt.GetMousePosPixel());
SetWinViewPos(GetWinViewPos() - (aNewMousePos - aOldMousePos));
// Place horizontal ruler below tab bar. if (mbHasRulers && mpContentWindow)
{
SetupRulers(); if (mpHorizontalRuler)
aBorder.Top() = mpHorizontalRuler->GetSizePixel().Height(); if (mpVerticalRuler)
aBorder.Left() = mpVerticalRuler->GetSizePixel().Width();
}
return aBorder;
}
void ViewShell::ArrangeGUIElements()
{ if (mpImpl->mbArrangeActive) return; if (maViewSize.IsEmpty()) return;
mpImpl->mbArrangeActive = true;
// The size of the window of the center pane is set differently from // that of the windows in the docking windows. bool bSlideShowActive = (xSlideShow.is() && xSlideShow->isRunning()) //IASS
&& !xSlideShow->isFullScreen() && xSlideShow->getAnimationMode() == ANIMATIONMODE_SHOW; if ( !bSlideShowActive)
{
OSL_ASSERT (GetViewShell()!=nullptr);
if (mpContentWindow)
mpContentWindow->SetPosSizePixel(
Point(nLeft,nTop),
Size(nRight-nLeft,nBottom-nTop));
}
// Windows in the center and rulers at the left and top side.
maAllWindowRectangle = ::tools::Rectangle(
maViewPos,
Size(maViewSize.Width()-maScrBarWH.Width(),
maViewSize.Height()-maScrBarWH.Height()));
if (mpContentWindow)
mpContentWindow->UpdateMapOrigin();
UpdateScrollBars();
mpImpl->mbArrangeActive = false;
}
void ViewShell::SetUIUnit(FieldUnit eUnit)
{ // Set unit at horizontal and vertical rulers. if (mpHorizontalRuler)
mpHorizontalRuler->SetUnit(eUnit);
if (mpVerticalRuler)
mpVerticalRuler->SetUnit(eUnit);
}
/** * set DefTab at horizontal rulers
*/ void ViewShell::SetDefTabHRuler( sal_uInt16 nDefTab )
{ if (mpHorizontalRuler)
mpHorizontalRuler->SetDefTabDist( nDefTab );
}
/** Tell the FmFormShell that the view shell is closing. Give it the opportunity to prevent that.
*/ bool ViewShell::PrepareClose (bool bUI)
{ bool bResult = true;
void ViewShell::UpdatePreview (SdPage*)
{ // Do nothing. After the actual preview has been removed, // OutlineViewShell::UpdatePreview() is the place where something // useful is still done.
}
sal_uInt16 nCount(pUndoManager->GetUndoActionCount()); if(nCount)
{ // prepare list
std::vector<OUString> aStringList;
aStringList.reserve(nCount); for (sal_uInt16 a = 0; a < nCount; ++a)
{ // generate one String in list per undo step
aStringList.push_back( pUndoManager->GetUndoActionComment(a) );
}
sal_uInt16 nCount(pUndoManager->GetRedoActionCount()); if(nCount)
{ // prepare list
::std::vector< OUString > aStringList;
aStringList.reserve(nCount); for(sal_uInt16 a = 0; a < nCount; a++) // generate one String in list per undo step
aStringList.push_back( pUndoManager->GetRedoActionComment(a) );
// Repair mode: allow undo/redo of all undo actions, even if access would // be limited based on the view shell ID. if (const SfxBoolItem* pRepairItem = pReqArgs->GetItemIfSet(SID_REPAIRPACKAGE, false))
bRepair = pRepairItem->GetValue();
}
if(nNumber && pUndoManager)
{
sal_uInt16 nCount(pUndoManager->GetUndoActionCount()); if(nCount >= nNumber)
{ if (comphelper::LibreOfficeKit::isActive() && !bRepair)
{ // If another view created the first undo action, prevent redoing it from this view. const SfxUndoAction* pAction = pUndoManager->GetUndoAction(); if (pAction->GetViewShellId() != GetViewShellBase().GetViewShellId())
{
rReq.SetReturnValue(SfxUInt32Item(SID_UNDO, static_cast<sal_uInt32>(SID_REPAIRPACKAGE))); return;
}
}
try
{ // when UndoStack is cleared by ModifyPageUndoAction // the nCount may have changed, so test GetUndoActionCount() while (nNumber && pUndoManager->GetUndoActionCount())
{
pUndoManager->Undo();
--nNumber;
}
} catch( const Exception& )
{ // no need to handle. By definition, the UndoManager handled this by clearing the // Undo/Redo stacks
}
}
// refresh rulers, maybe UNDO was move of TAB marker in ruler if (mbHasRulers)
Invalidate(SID_ATTR_TABSTOP);
}
// This one is corresponding to the default handling // of SID_UNDO in sfx2
GetViewFrame()->GetBindings().InvalidateAll(false);
rReq.Done();
}
void ViewShell::ImpSidRedo(SfxRequest& rReq)
{ //The xWatcher keeps the SlideSorter selection in sync //with the page insertions/deletions that Undo may introduce
std::unique_ptr<KeepSlideSorterInSyncWithPageChanges, o3tl::default_delete<KeepSlideSorterInSyncWithPageChanges>> xWatcher;
slidesorter::SlideSorterViewShell* pSlideSorterViewShell
= slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase()); if (pSlideSorterViewShell)
xWatcher.reset(new KeepSlideSorterInSyncWithPageChanges(pSlideSorterViewShell->GetSlideSorter()));
if(pReqArgs)
{ const SfxUInt16Item* pUIntItem = static_cast<const SfxUInt16Item*>(&pReqArgs->Get(SID_REDO));
nNumber = pUIntItem->GetValue(); // Repair mode: allow undo/redo of all undo actions, even if access would // be limited based on the view shell ID. if (const SfxBoolItem* pRepairItem = pReqArgs->GetItemIfSet(SID_REPAIRPACKAGE, false))
bRepair = pRepairItem->GetValue();
}
if(nNumber && pUndoManager)
{
sal_uInt16 nCount(pUndoManager->GetRedoActionCount()); if(nCount >= nNumber)
{ if (comphelper::LibreOfficeKit::isActive() && !bRepair)
{ // If another view created the first undo action, prevent redoing it from this view. const SfxUndoAction* pAction = pUndoManager->GetRedoAction(); if (pAction->GetViewShellId() != GetViewShellBase().GetViewShellId())
{
rReq.SetReturnValue(SfxUInt32Item(SID_REDO, static_cast<sal_uInt32>(SID_REPAIRPACKAGE))); return;
}
}
try
{ // when UndoStack is cleared by ModifyPageRedoAction // the nCount may have changed, so test GetRedoActionCount() while (nNumber && pUndoManager->GetRedoActionCount())
{
pUndoManager->Redo();
--nNumber;
}
} catch( const Exception& )
{ // no need to handle. By definition, the UndoManager handled this by clearing the // Undo/Redo stacks
}
}
// refresh rulers, maybe REDO was move of TAB marker in ruler if (mbHasRulers)
{
Invalidate(SID_ATTR_TABSTOP);
}
}
// This one is corresponding to the default handling // of SID_UNDO in sfx2
GetViewFrame()->GetBindings().InvalidateAll(false);
case SID_OUTPUT_QUALITY_COLOR: case SID_OUTPUT_QUALITY_GRAYSCALE: case SID_OUTPUT_QUALITY_BLACKWHITE: case SID_OUTPUT_QUALITY_CONTRAST:
{
DrawModeFlags nMode = OUTPUT_DRAWMODE_COLOR;
switch( nSlot )
{ case SID_OUTPUT_QUALITY_COLOR: nMode = OUTPUT_DRAWMODE_COLOR; break; case SID_OUTPUT_QUALITY_GRAYSCALE: nMode = OUTPUT_DRAWMODE_GRAYSCALE; break; case SID_OUTPUT_QUALITY_BLACKWHITE: nMode = OUTPUT_DRAWMODE_BLACKWHITE; break; case SID_OUTPUT_QUALITY_CONTRAST: nMode = OUTPUT_DRAWMODE_CONTRAST; break;
}
/** This default implementation returns only an empty reference. See derived classes for more interesting examples.
*/
css::uno::Reference<css::accessibility::XAccessible>
ViewShell::CreateAccessibleDocumentView (::sd::Window* )
{
OSL_FAIL("ViewShell::CreateAccessibleDocumentView should not be called!, perhaps Meyers, 3rd edition, Item 9:");
/** this method deactivates the current function. If an old function is saved, this will become activated and current function.
*/ void ViewShell::Cancel()
{ if(mxCurrentFunction.is() && (mxCurrentFunction != mxOldFunction ))
{
rtl::Reference<FuPoor> xTemp( mxCurrentFunction );
mxCurrentFunction.clear();
xTemp->Deactivate();
xTemp->Dispose();
}
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.