/* -*- 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 .
*/
SdrPaintWindow* SdrPaintView::FindPaintWindow(const OutputDevice& rOut) const
{ // back to loop - there is more to test than a std::find_if and a lambda can do for(auto& candidate : maPaintWindows)
{ if(&(candidate->GetOutputDevice()) == &rOut)
{ return candidate.get();
}
// check for patched to allow finding in that state, too if(nullptr != candidate->getPatched() && &(candidate->getPatched()->GetOutputDevice()) == &rOut)
{ return candidate->getPatched();
}
}
for(a = 0; a < count; a++)
{ #endif// SVX_REPAINT_TIMER_TEST
// #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region // rReg may be made more granular (fine) with using it. Normally, rReg // does come from Window::Paint() anyways and thus is based on a single // rectangle which was derived from exactly that repaint region
vcl::Region aOptimizedRepaintRegion(rReg);
if(pPaintWindow)
{ // draw preprocessing, only for known devices // prepare PreRendering
pPaintWindow->PreparePreRenderDevice();
} else
{ // None of the known OutputDevices is the target of this paint, use // a temporary SdrPaintWindow for this Redraw.
pPaintWindow = new SdrPaintWindow(*this, *pOut);
pPaintWindow->setTemporaryTarget(true);
}
return pPaintWindow;
}
void SdrPaintView::DoCompleteRedraw(SdrPaintWindow& rPaintWindow, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector)
{ // redraw all PageViews with the target. This may expand the RedrawRegion // at the PaintWindow, plus taking care of FormLayer expansion if(mpPageView)
{
mpPageView->CompleteRedraw(rPaintWindow, rReg, pRedirector);
}
}
void SdrPaintView::EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer,
sdr::contact::ViewObjectContactRedirector* pRedirector)
{
std::unique_ptr<SdrPaintWindow> pPaintWindow; if (comphelper::LibreOfficeKit::isActive() && rPaintWindow.getTemporaryTarget())
{ // Tiled rendering, we must paint the TextEdit to the output device.
pPaintWindow.reset(&rPaintWindow);
pPaintWindow->setTemporaryTarget(false);
}
if(rPaintWindow.getTemporaryTarget())
{ // get rid of temp target again delete &rPaintWindow;
} else
{ // draw postprocessing, only for known devices // it is necessary to always paint FormLayer // In the LOK case control rendering is performed through LokControlHandler // except when the document is exported to PDF or printed, // so we use isTiledPainting() in place of the more generic isActive() if(!comphelper::LibreOfficeKit::isTiledPainting() && bPaintFormLayer)
{
ImpFormLayerDrawing(rPaintWindow, pRedirector);
}
// look for active TextEdit. As long as this cannot be painted to a VDev, // it cannot get part of buffering. In that case, output evtl. prerender // early and paint text edit to window.
SdrPageView* pPageView = GetSdrPageView(); if(IsTextEdit() && pPageView)
{ if (!comphelper::LibreOfficeKit::isActive() || mbPaintTextEdit) static_cast< SdrView* >(this)->TextEditDrawing(rPaintWindow);
}
if (comphelper::LibreOfficeKit::isActive() && pPageView)
{ // Look for active text edits in other views showing the same page, // and show them as well. Show only if Page/MasterPage mode is matching. bool bRequireMasterPage = pPageView->GetPage() ? pPageView->GetPage()->IsMasterPage() : false;
SdrViewIter::ForAllViews(pPageView->GetPage(),
[this, &bRequireMasterPage, &rPaintWindow] (SdrView* pView)
{
SdrPageView* pCurrentPageView = pView->GetSdrPageView(); bool bIsCurrentMasterPage = (pCurrentPageView && pCurrentPageView->GetPage()) ?
pCurrentPageView->GetPage()->IsMasterPage() : false;
if (pView == this || bRequireMasterPage != bIsCurrentMasterPage) returnfalse;
if (pView->IsTextEdit() && pView->GetSdrPageView())
{
pView->TextEditDrawing(rPaintWindow);
} returnfalse;
});
}
// draw Overlay, also to PreRender device if exists
rPaintWindow.DrawOverlay(rPaintWindow.GetRedrawRegion());
SdrPaintWindow* SdrPaintView::BeginDrawLayers(OutputDevice* pOut, const vcl::Region& rReg, bool bDisableIntersect)
{ // #i74769# use BeginCompleteRedraw() as common base
SdrPaintWindow* pPaintWindow = BeginCompleteRedraw(pOut);
assert(pPaintWindow && "SdrPaintView::BeginDrawLayers: No SdrPaintWindow (!)");
void SdrPaintView::EndDrawLayers(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer,
sdr::contact::ViewObjectContactRedirector* pRedirector)
{ // #i74769# use EndCompleteRedraw() as common base
EndCompleteRedraw(rPaintWindow, bPaintFormLayer, pRedirector);
vcl::Region SdrPaintView::OptimizeDrawLayersRegion(const OutputDevice* pOut, const vcl::Region& rReg, bool bDisableIntersect)
{ // #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region // rReg may be made more granular (fine) with using it. Normally, rReg // does come from Window::Paint() anyways and thus is based on a single // rectangle which was derived from exactly that repaint region
vcl::Region aOptimizedRepaintRegion(rReg);
// #i76114# Intersecting the region with the Window's paint region is disabled // for print preview in Calc, because the intersection can be empty (if the paint // region is outside of the table area of the page), and then no clip region // would be set. if(pOut && OUTDEV_WINDOW == pOut->GetOutDevType() && !bDisableIntersect)
{
vcl::Window* pWindow = pOut->GetOwnerWindow();
// BUFFERED use GetTargetOutputDevice() now, it may be targeted to VDevs, too // need to set PreparedPageWindow to make DrawLayer use the correct ObjectContact
mpPageView->setPreparedPageWindow(pKnownTarget);
mpPageView->DrawLayer(nControlLayerId, &rPaintWindow.GetTargetOutputDevice(),
pRedirector);
mpPageView->setPreparedPageWindow(nullptr);
}
}
void SdrPaintView::GlueInvalidate() const
{ // Do not invalidate GluePoints in Online // They are handled on front-end if (comphelper::LibreOfficeKit::isActive()) return;
Point aOrg(rOutDev.GetMapMode().GetOrigin());
aOrg.setX(-aOrg.X() ); aOrg.setY(-aOrg.Y() );
tools::Rectangle aOutRect(aOrg, rOutDev.GetOutputSize());
// In case of tiled rendering we want to get all invalidations, so visual area is not interesting. if (aRect.Overlaps(aOutRect) || comphelper::LibreOfficeKit::isActive())
{
InvalidateOneWin(rOutDev, aRect);
}
}
}
}
void SdrPaintView::InvalidateOneWin(OutputDevice& rDevice)
{ // do not erase background, that causes flicker (!) // tdf#160444 check device's owner window is a nullptr // Since commit 563f7077f1dbce31ff95ee8d2e8d17b629693db1, the // device's owner window gets deleted before this object is // deleted. if (rDevice.GetOwnerWindow())
rDevice.GetOwnerWindow()->Invalidate(InvalidateFlags::NoErase);
}
void SdrPaintView::InvalidateOneWin(OutputDevice& rDevice, const tools::Rectangle& rRect)
{ // do not erase background, that causes flicker (!)
rDevice.GetOwnerWindow()->Invalidate(rRect, InvalidateFlags::NoErase);
}
void SdrPaintView::SetNotPersistDefaultAttr(const SfxItemSet& rAttr)
{ // bReplaceAll has no effect here at all. bool bMeasure= dynamic_cast<const SdrView*>(this) != nullptr && static_cast<SdrView*>(this)->IsMeasureTool();
if (const SdrLayerIdItem *pPoolItem = rAttr.GetItemIfSet(SDRATTR_LAYERID))
{
SdrLayerID nLayerId = pPoolItem->GetValue(); const SdrLayer* pLayer = GetModel().GetLayerAdmin().GetLayerPerID(nLayerId); if (pLayer!=nullptr) { if (bMeasure) maMeasureLayer=pLayer->GetName(); else maActualLayer=pLayer->GetName();
}
} if (const SdrLayerNameItem *pPoolItem = rAttr.GetItemIfSet(SDRATTR_LAYERNAME))
{ if (bMeasure) maMeasureLayer = pPoolItem->GetValue(); else maActualLayer = pPoolItem->GetValue();
}
}
void SdrPaintView::MergeNotPersistDefaultAttr(SfxItemSet& rAttr) const
{ // bOnlyHardAttr has no effect here at all. bool bMeasure= dynamic_cast<const SdrView*>(this) != nullptr && static_cast<const SdrView*>(this)->IsMeasureTool(); const OUString& aNam = bMeasure ? maMeasureLayer : maActualLayer;
rAttr.Put(SdrLayerNameItem(aNam));
SdrLayerID nLayer = GetModel().GetLayerAdmin().GetLayerID(aNam); if (nLayer!=SDRLAYER_NOTFOUND) {
rAttr.Put(SdrLayerIdItem(nLayer));
}
}
if(bHasEEFeatureItems)
{
std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr,
VclMessageType::Info, VclButtonsType::Ok,
u"SdrPaintView::SetDefaultAttr(): Setting EE_FEATURE items at the SdrView does not make sense! It only leads to overhead and unreadable documents."_ustr));
xInfoBox->run();
}
} #endif if (bReplaceAll) maDefaultAttr.Set(rAttr); else maDefaultAttr.Put(rAttr,false); // if FALSE, regard InvalidItems as "holes," not as Default
SetNotPersistDefaultAttr(rAttr);
}
void SdrPaintView::SetDefaultStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr)
{ if (mpDefaultStyleSheet)
EndListening(*mpDefaultStyleSheet);
mpDefaultStyleSheet=pStyleSheet; if (mpDefaultStyleSheet)
StartListening(*mpDefaultStyleSheet);
if (pStyleSheet!=nullptr && !bDontRemoveHardAttr) {
SfxWhichIter aIter(pStyleSheet->GetItemSet());
sal_uInt16 nWhich=aIter.FirstWhich(); while (nWhich!=0) { if (aIter.GetItemState()==SfxItemState::SET) {
maDefaultAttr.ClearItem(nWhich);
}
nWhich=aIter.NextWhich();
}
}
}
void SdrPaintView::MakeVisible(const tools::Rectangle& rRect, vcl::Window& rWin)
{ // TODO: handle when the text cursor goes out of the chart area // However this hack avoids that the cursor gets misplaced wrt the text. if (comphelper::LibreOfficeKit::isActive() && rWin.IsChart())
{ return;
}
// Set background color for svx at SdrPageViews void SdrPaintView::SetApplicationBackgroundColor(Color aBackgroundColor)
{ if(mpPageView)
{
mpPageView->SetApplicationBackgroundColor(aBackgroundColor);
}
}
// Set document color for svx at SdrPageViews void SdrPaintView::SetApplicationDocumentColor(Color aDocumentColor)
{ if(mpPageView)
{
mpPageView->SetApplicationDocumentColor(aDocumentColor);
}
}
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.