/* -*- 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 .
*/
namespace
{ inlinedouble getViewToScrollScalarForPanAcrossPages(sal_uInt16 nTotalPages, double fVisibleHeight,
::tools::Long nScrollRangeMax)
{ // fTotalScrollableRange is (1 - fVisibleHeight) for all of the // pages except the last one. Because switch to the next page // happens when the view reaches bottom. double fTotalScrollableRange = (nTotalPages - 1) * (1 - fVisibleHeight) + 1.0; return nScrollRangeMax / fTotalScrollableRange;
}
}
/** * Scroll a specific number of lines. Is used in the automatic scrolling * (character/drag).
*/ void ViewShell::ScrollLines(::tools::Long nLinesX, ::tools::Long nLinesY)
{ if ( nLinesX )
{
nLinesX *= mpHorizontalScrollBar->GetLineSize();
} if ( nLinesY )
{
nLinesY *= mpVerticalScrollBar->GetLineSize();
}
::sd::View* pView = GetView(); if (pView)
{
pView->VisAreaChanged(GetActiveWindow()->GetOutDev());
}
if (mbHasRulers)
{
UpdateHRuler();
UpdateVRuler();
}
}
/** * Set zoom factor for all split windows.
*/ void ViewShell::SetZoom(::tools::Long nZoom)
{
Fraction aUIScale(nZoom, 100);
aUIScale *= GetDoc()->GetUIScale();
if (mpHorizontalRuler)
mpHorizontalRuler->SetZoom(aUIScale);
if (mpVerticalRuler)
mpVerticalRuler->SetZoom(aUIScale);
if (mpContentWindow)
{
mpContentWindow->SetZoomIntegral(nZoom);
// #i74769# Here is a 2nd way (besides Window::Scroll) to set the visible prt // of the window. It needs - like Scroll(ScrollFlags::Children) does - also to move // the child windows. I am trying InvalidateFlags::Children here which makes things better, // but does not solve the problem completely. Need to ask PL.
mpContentWindow->Invalidate(InvalidateFlags::Children);
}
::sd::View* pView = GetView(); if (pView)
{
pView->VisAreaChanged(GetActiveWindow()->GetOutDev());
}
UpdateScrollBars();
}
::tools::Long ViewShell::GetZoom() const
{ if (mpContentWindow)
{ return mpContentWindow->GetZoom();
}
return 0;
}
/** * Set zoom rectangle for active window. Sets all split windows to the same zoom * factor.
*/ void ViewShell::SetZoomRect(const ::tools::Rectangle& rZoomRect)
{
::tools::Long nZoom = GetActiveWindow()->SetZoomRect(rZoomRect);
Fraction aUIScale(nZoom, 100);
aUIScale *= GetDoc()->GetUIScale();
Point aPos = GetActiveWindow()->GetWinViewPos();
if (mpHorizontalRuler)
mpHorizontalRuler->SetZoom(aUIScale);
if (mpVerticalRuler)
mpVerticalRuler->SetZoom(aUIScale);
if (mpContentWindow)
{
Point aNewPos = mpContentWindow->GetWinViewPos();
aNewPos.setX( aPos.X() );
aNewPos.setY( aPos.Y() );
mpContentWindow->SetZoomIntegral(nZoom);
mpContentWindow->SetWinViewPos(aNewPos);
mpContentWindow->UpdateMapOrigin();
// When tiled rendering, UpdateMapOrigin() doesn't touch the map mode. if (!comphelper::LibreOfficeKit::isActive()) // #i74769# see above
mpContentWindow->Invalidate(InvalidateFlags::Children);
}
::sd::View* pView = GetView(); if (pView)
{
pView->VisAreaChanged(GetActiveWindow()->GetOutDev());
}
}
/** * Invalidate all split windows below the ?provided rectangle.
*/ void ViewShell::InvalidateWindows()
{ if (mpContentWindow)
mpContentWindow->Invalidate();
}
/** * Draw a selection rectangle with the ?provided pen on all split windows.
*/ void ViewShell::DrawMarkRect(const ::tools::Rectangle& rRect) const
{ if (mpContentWindow)
{
mpContentWindow->InvertTracking(rRect, ShowTrackFlags::Object | ShowTrackFlags::TrackWindow);
}
}
// use Model-based method at SdDrawDocument
GetDoc()->AdaptPageSizeForAllPages(
rNewSize,
ePageKind,
pUndoGroup.get(),
nLeft,
nRight,
nUpper,
nLower,
bScaleAll,
eOrientation,
nPaperBin,
bBackgroundFullSize);
// adjust handout page to new format of the standard page if(0 != nPageCnt && ((ePageKind == PageKind::Standard) || (ePageKind == PageKind::Handout)))
{
GetDoc()->GetSdPage(0, PageKind::Handout)->CreateTitleAndLayout(true);
}
// handed over undo group to undo manager if (pViewShell)
{
pViewShell->GetViewFrame().GetObjectShell()->GetUndoManager()->AddUndoAction(std::move(pUndoGroup));
}
if (pViewShell->GetWindow() != pWin)
{ // #i31551# was wrong, it may have been a problem with the repaint at that time. // For transparent form controls, it is necessary to have that flag set, all apps // do set it. Enabling again. if (pWin)
{
pWin->EnableChildTransparentMode();
}
}
if (mpActiveWindow.get() != pWin)
mpActiveWindow = pWin;
// The rest of this function is not guarded anymore against calling this // method with an already active window because the functions may still // point to the old window when the new one has already been assigned to // pWindow elsewhere.
::sd::View* pView = GetView(); if (pView)
{
pView->SetActualWin(pWin->GetOutDev());
} if(HasCurrentFunction())
{
GetCurrentFunction()->SetWindow(pWin);
}
}
/************************************************************************* |* |* Read FrameViews data and set actual views data |*
\************************************************************************/
void ViewShell::ReadFrameViewData(FrameView*)
{
}
/************************************************************************* |* |* Write actual views data to FrameView |*
\************************************************************************/
if ( xObj.is() )
{ // OLE object is no longer empty
pObj->SetEmptyPresObj(false);
pObj->SetOutlinerParaObject(std::nullopt);
pObj->ClearGraphic();
// the empty OLE object gets a new IPObj if (!aName.isEmpty())
{
pObj->SetObjRef(xObj);
pObj->SetName(aObjName);
pObj->SetPersistName(aObjName);
} else
{ // insertion was done by the dialog
pObj->SetObjRef(xObj);
}
if ( !pSdClient )
{
pSdClient = new Client(pObj, *this, GetActiveWindow());
}
::tools::Rectangle aRect = pObj->GetLogicRect();
{ // #i118485# center on BoundRect for activation, // OLE may be sheared/rotated now const ::tools::Rectangle& rBoundRect = pObj->GetCurrentBoundRect(); const Point aDelta(rBoundRect.Center() - aRect.Center());
aRect.Move(aDelta.X(), aDelta.Y());
}
Size aDrawSize = aRect.GetSize();
MapMode aMapMode( GetDoc()->GetScaleUnit() );
Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode ); if( pObj->IsChart() ) //charts never should be stretched see #i84323# for example
aObjAreaSize = aDrawSize;
Fraction aScaleWidth (aDrawSize.Width(), aObjAreaSize.Width() );
Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() );
aScaleWidth.ReduceInaccurate(10); // compatible to the SdrOle2Obj
aScaleHeight.ReduceInaccurate(10);
pSdClient->SetSizeScale(aScaleWidth, aScaleHeight);
// visible section is only changed in-place!
aRect.SetSize(aObjAreaSize); // the object area size must be set after scaling, since it triggers the resizing
pSdClient->SetObjArea(aRect);
pSdClient->DoVerb(nVerb); // if necessary, ErrCode is outputted by Sfx
pViewShell->GetViewFrame().GetBindings().Invalidate(
SID_NAVIGATOR_STATE, true);
}
GetDocSh()->SetWaitCursor( false );
if (aErrCode != ERRCODE_NONE && !bAbort)
{
ErrorHandler::HandleError(ErrCodeMsg(aErrCode));
}
return aErrCode == ERRCODE_NONE;
}
/** * @returns enclosing rectangle of all (split-) windows.
*/ const ::tools::Rectangle& ViewShell::GetAllWindowRect()
{
maAllWindowRectangle.SetPos(
mpContentWindow->OutputToScreenPixel(Point(0,0))); return maAllWindowRectangle;
}
OSL_ASSERT (GetViewShell()!=nullptr); // Get the view id from the view shell in the center pane. This will // usually be the called view shell, but to be on the safe side we call // the main view shell explicitly.
SfxInterfaceId nViewID (IMPRESS_FACTORY_ID); if (auto pViewShell = GetViewShellBase().GetMainViewShell().get())
nViewID = pViewShell->mpImpl->GetViewId();
pSequence[nIndex].Name = sUNO_View_ViewId;
pSequence[nIndex].Value <<= "view" + OUString::number( static_cast<sal_uInt16>(nViewID));
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.