/* -*- 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 .
*/
SdrPageView::SdrPageView(SdrPage* pPage1, SdrView& rNewView)
: mrView(rNewView), // col_auto color lets the view takes the default SvxColorConfig entry
maDocumentColor( COL_AUTO ),
maBackgroundColor( COL_AUTO ), // #i48367# also react on autocolor
mpPreparedPageWindow(nullptr) // #i72752#
{
mpPage = pPage1;
if(mpPage)
{
maPageOrigin.setX(mpPage->GetLeftBorder() );
maPageOrigin.setY(mpPage->GetUpperBorder() );
} // For example, in the case of charts, there is a LayerAdmin, but it has no valid values. Therefore // a solution like pLayerAdmin->getVisibleLayersODF(aLayerVisi) is not possible. So use the // generic SetAll() for now.
m_aLayerVisi.SetAll();
m_aLayerPrn.SetAll();
if(pKnownTarget)
{ // paint known target
pKnownTarget->RedrawLayer(&nID, pRedirector, pPageFrame);
} else
{ // #i72752# DrawLayer() uses an OutputDevice different from BeginDrawLayer. This happens // e.g. when SW paints a single text line in text edit mode. Try to use it
SdrPageWindow* pPreparedTarget = mpPreparedPageWindow;
if(pPreparedTarget)
{ // if we have a prepared target, do not use a new SdrPageWindow since this // works but is expensive. Just use a temporary PaintWindow
SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
// Copy existing paint region to use the same as prepared in BeginDrawLayer
SdrPaintWindow& rExistingPaintWindow = pPreparedTarget->GetPaintWindow(); const vcl::Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion(); bool bUseRect(false); if (!rRect.IsEmpty())
{
vcl::Region r(rExistingRegion);
r.Intersect(rRect); // fdo#74435: FIXME: visibility check broken if empty if (!r.IsEmpty())
bUseRect = true;
} if (!bUseRect)
aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion); else
aTemporaryPaintWindow.SetRedrawRegion(vcl::Region(rRect));
// patch the ExistingPageWindow auto pPreviousWindow = pPreparedTarget->patchPaintWindow(aTemporaryPaintWindow); // unpatch window when leaving the scope const ::comphelper::ScopeGuard aGuard(
[&pPreviousWindow, &pPreparedTarget]() { pPreparedTarget->unpatchPaintWindow(pPreviousWindow); } ); // redraw the layer
pPreparedTarget->RedrawLayer(&nID, pRedirector, pPageFrame);
} else
{
OSL_FAIL("SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), this should never be needed (!)");
// None of the known OutputDevices is the target of this paint, use // a temporary SdrPageWindow for this Redraw.
SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
SdrPageWindow aTemporaryPageWindow(*this, aTemporaryPaintWindow);
// #i72752# // Copy existing paint region if other PageWindows exist, this was created by // PrepareRedraw() from BeginDrawLayer(). Needs to be used e.g. when suddenly SW // paints into an unknown device other than the view was created for (e.g. VirtualDevice) if(PageWindowCount())
{
SdrPageWindow* pExistingPageWindow = GetPageWindow(0);
SdrPaintWindow& rExistingPaintWindow = pExistingPageWindow->GetPaintWindow(); const vcl::Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
}
aTemporaryPageWindow.RedrawLayer(&nID, pRedirector, nullptr);
}
}
} else
{ // paint in all known windows for(sal_uInt32 a(0); a < PageWindowCount(); a++)
{
SdrPageWindow* pTarget = GetPageWindow(a);
pTarget->RedrawLayer(&nID, pRedirector, nullptr);
}
}
}
void SdrPageView::SetDesignMode( bool _bDesignMode ) const
{ for ( sal_uInt32 i = 0; i < PageWindowCount(); ++i )
{ const SdrPageWindow& rPageViewWindow = *GetPageWindow(i);
rPageViewWindow.SetDesignMode( _bDesignMode );
}
}
void SdrPageView::DrawPageViewGrid(OutputDevice& rOut, const tools::Rectangle& rRect, Color aColor)
{ if (GetPage()==nullptr) return;
if (nx1==0) nx1=nx2; if (nx2==0) nx2=nx1; if (ny1==0) ny1=ny2; if (ny2==0) ny2=ny1; if (nx1==0) { nx1=ny1; nx2=ny2; } if (ny1==0) { ny1=nx1; ny2=nx2; } if (nx1<0) nx1=-nx1; if (nx2<0) nx2=-nx2; if (ny1<0) ny1=-ny1; if (ny2<0) ny2=-ny2;
if (nx1==0) return;
// no more global output size, use window size instead to decide grid sizes
tools::Long nScreenWdt = rOut.GetOutputSizePixel().Width();
sal_uInt16 nGridPaintCnt=1; if (pFrames!=nullptr) nGridPaintCnt=pFrames->GetCount(); for (sal_uInt16 nGridPaintNum=0; nGridPaintNum<nGridPaintCnt; nGridPaintNum++) { if (pFrames!=nullptr) { const SdrPageGridFrame& rGF=(*pFrames)[nGridPaintNum];
nWrX=rGF.GetPaperRect().Left();
nWrY=rGF.GetPaperRect().Top();
x1=rGF.GetUserArea().Left();
x2=rGF.GetUserArea().Right();
y1=rGF.GetUserArea().Top();
y2=rGF.GetUserArea().Bottom();
aOrg=rGF.GetUserArea().TopLeft();
aOrg-=rGF.GetPaperRect().TopLeft();
} if (!rRect.IsEmpty()) {
Size a1PixSiz(rOut.PixelToLogic(Size(1,1)));
tools::Long nX1Pix=a1PixSiz.Width(); // add 1 pixel of tolerance
tools::Long nY1Pix=a1PixSiz.Height(); if (x1<rRect.Left() -nX1Pix) x1=rRect.Left() -nX1Pix; if (x2>rRect.Right() +nX1Pix) x2=rRect.Right() +nX1Pix; if (y1<rRect.Top() -nY1Pix) y1=rRect.Top() -nY1Pix; if (y2>rRect.Bottom()+nY1Pix) y2=rRect.Bottom()+nY1Pix;
}
tools::Long xBigOrg=aOrg.X()+nWrX; while (xBigOrg>=x1) xBigOrg-=nx1; while (xBigOrg<x1) xBigOrg+=nx1;
tools::Long xFinOrg=xBigOrg; while (xFinOrg>=x1) xFinOrg-=nx2; while (xFinOrg<x1) xFinOrg+=nx2;
tools::Long yBigOrg=aOrg.Y()+nWrY; while (yBigOrg>=y1) yBigOrg-=ny1; while (yBigOrg<y1) yBigOrg+=ny1;
tools::Long yFinOrg=yBigOrg; while (yFinOrg>=y1) yFinOrg-=ny2; while (yFinOrg<y1) yFinOrg+=ny2;
bool SdrPageView::IsObjMarkable(SdrObject const * pObj) const
{ if (!pObj) returnfalse; if (pObj->IsMarkProtect()) returnfalse; // excluded from selection? if (!pObj->IsVisible()) returnfalse; // only visible are selectable if (!pObj->IsInserted()) returnfalse; // Obj deleted? if (auto pObjGroup = dynamic_cast<const SdrObjGroup*>(pObj))
{ // If object is a Group object, visibility may depend on // multiple layers. If one object is markable, Group is markable.
SdrObjList* pObjList = pObjGroup->GetSubList();
if (pObjList && pObjList->GetObjCount())
{ for (const rtl::Reference<SdrObject>& pCandidate : *pObjList)
{ // call recursively if (IsObjMarkable(pCandidate.get())) returntrue;
} returnfalse;
} else
{ // #i43302# // Allow empty groups to be selected to be able to delete them returntrue;
}
} if (!pObj->Is3DObj() && pObj->getSdrPageFromSdrObject() != GetPage())
{ // Obj suddenly in different Page returnfalse;
}
// the layer has to be visible and must not be locked
SdrLayerID nL = pObj->GetLayer(); if (!m_aLayerVisi.IsSet(nL)) returnfalse; if (m_aLayerLock.IsSet(nL)) returnfalse; returntrue;
}
void SdrPageView::SetPageOrigin(const Point& rOrg)
{ if (rOrg != maPageOrigin)
{
maPageOrigin = rOrg; if (GetView().IsGridVisible())
{
InvalidateAllWin();
}
}
}
void SdrPageView::ImpInvalidateHelpLineArea(sal_uInt16 nNum) const
{ if (!(GetView().IsHlplVisible() && nNum<m_aHelpLines.GetCount())) return;
if (bGlueInvalidate)
{
GetView().GlueInvalidate();
}
// deselect all
GetView().UnmarkAll();
// set current group and list
SdrObjList* pNewObjList = pObj->GetSubList();
SetCurrentGroupAndList(pObj, pNewObjList);
// select contained object if only one object is contained, // else select nothing and let the user decide what to do next if(pNewObjList && pNewObjList->GetObjCount() == 1)
{
SdrObject* pFirstObject = pNewObjList->GetObj(0);
// Set background color for svx at SdrPageViews void SdrPageView::SetApplicationBackgroundColor(Color aBackgroundColor)
{
maBackgroundColor = aBackgroundColor;
}
// Set document color for svx at SdrPageViews void SdrPageView::SetApplicationDocumentColor(Color aDocumentColor)
{
maDocumentColor = aDocumentColor;
}
void SdrPageView::resetGridOffsetsOfAllPageWindows() const
{ for (auto& pPageWindow : maPageWindows)
{
assert(pPageWindow && "SdrView::SetMasterPagePaintCaching: Corrupt SdrPageWindow list (!)");
if (pPageWindow)
{
sdr::contact::ObjectContact& rObjectContact(pPageWindow->GetObjectContact());
if (rObjectContact.supportsGridOffsets())
{
rObjectContact.resetAllGridOffsets();
}
}
}
}
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.