/* -*- 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 (mxParentWindow.is())
{
mxParentWindow->addWindowListener(this);
mxParentWindow->addPaintListener(this);
mxParentWindow->addMouseListener(this);
mxParentWindow->addFocusListener(this);
// We paint our own background, make that of the parent window transparent.
Reference<awt::XWindowPeer> xPeer (mxParentWindow, UNO_QUERY); if (xPeer.is())
xPeer->setBackground(util::Color(0xff000000));
}
}
void PresenterWindowManager::PaintChildren (const awt::PaintEvent& rEvent) const
{ // Call windowPaint on all children that lie in or touch the // update rectangle. for (constauto& rxPane : mpPaneContainer->maPanes)
{ try
{ // Make sure that the pane shall and can be painted. if ( ! rxPane->mbIsActive) continue; if (rxPane->mbIsSprite) continue; if ( ! rxPane->mxPane.is()) continue; if ( ! rxPane->mxBorderWindow.is()) continue;
Reference<awt::XWindow> xBorderWindow (rxPane->mxBorderWindow); if ( ! xBorderWindow.is()) continue;
// Get the area in which the border of the pane has to be painted. const awt::Rectangle aBorderBox (xBorderWindow->getPosSize()); const awt::Rectangle aBorderUpdateBox(
PresenterGeometryHelper::Intersection(
rEvent.UpdateRect,
aBorderBox)); if (aBorderUpdateBox.Width<=0 || aBorderUpdateBox.Height<=0) continue;
// Invalidate the area of the content window.
mpPresenterController->GetPaintManager()->Invalidate(
xBorderWindow,
aLocalBorderUpdateBox,
sal_Int16(awt::InvalidateStyle::CHILDREN
| awt::InvalidateStyle::NOTRANSPARENT));
} catch (RuntimeException&)
{
OSL_FAIL("paint children failed!");
}
}
}
void PresenterWindowManager::RemoveLayoutListener ( const Reference<document::XEventListener>& rxListener)
{ // Assume that there are no multiple entries. auto iListener = std::find(maLayoutListeners.begin(), maLayoutListeners.end(), rxListener); if (iListener != maLayoutListeners.end())
maLayoutListeners.erase(iListener);
}
void PresenterWindowManager::Layout()
{ if (!mxParentWindow.is() || mbIsLayouting) return;
// For the current slide view calculate the outer height from the outer // width. This takes into account the slide aspect ratio and thus has to // go over the inner pane size.
PresenterPaneContainer::SharedPaneDescriptor pPane (
mpPaneContainer->FindPaneURL(PresenterPaneFactory::msCurrentSlidePreviewPaneURL)); if (pPane)
{ const awt::Size aCurrentSlideOuterBox(CalculatePaneSize(
nHorizontalSlideDivide - 1.5*nGap,
PresenterPaneFactory::msCurrentSlidePreviewPaneURL));
nSlidePreviewTop = (aBox.Height - aCurrentSlideOuterBox.Height) / 2; double Temp=nGap; /// check whether RTL interface or not if(AllSettings::GetLayoutRTL())
Temp=aBox.Width - aCurrentSlideOuterBox.Width - nGap;
SetPanePosSizeAbsolute (
PresenterPaneFactory::msCurrentSlidePreviewPaneURL,
Temp,
nSlidePreviewTop,
aCurrentSlideOuterBox.Width,
aCurrentSlideOuterBox.Height);
}
// For the next slide view calculate the outer height from the outer // width. This takes into account the slide aspect ratio and thus has to // go over the inner pane size.
pPane = mpPaneContainer->FindPaneURL(PresenterPaneFactory::msNextSlidePreviewPaneURL); if (pPane)
{ const awt::Size aNextSlideOuterBox (CalculatePaneSize(
aBox.Width - nHorizontalSlideDivide - 1.5*nGap,
PresenterPaneFactory::msNextSlidePreviewPaneURL)); double Temp=aBox.Width - aNextSlideOuterBox.Width - nGap; /// check whether RTL interface or not if(AllSettings::GetLayoutRTL())
Temp=nGap;
SetPanePosSizeAbsolute (
PresenterPaneFactory::msNextSlidePreviewPaneURL,
Temp,
nSlidePreviewTop,
aNextSlideOuterBox.Width,
aNextSlideOuterBox.Height);
}
// For the current slide view calculate the outer height from the outer // width. This takes into account the slide aspect ratio and thus has to // go over the inner pane size.
pPane = mpPaneContainer->FindPaneURL(PresenterPaneFactory::msCurrentSlidePreviewPaneURL); if (pPane)
{ const awt::Size aCurrentSlideOuterBox(CalculatePaneSize(
nSecondaryWidth - 1.5*nGap,
PresenterPaneFactory::msCurrentSlidePreviewPaneURL)); /// check whether RTL interface or not double Temp=nGap; if(AllSettings::GetLayoutRTL())
Temp=aBox.Width - aCurrentSlideOuterBox.Width - nGap;
SetPanePosSizeAbsolute (
PresenterPaneFactory::msCurrentSlidePreviewPaneURL,
Temp,
nSlidePreviewTop,
aCurrentSlideOuterBox.Width,
aCurrentSlideOuterBox.Height);
}
// For the next slide view calculate the outer height from the outer // width. This takes into account the slide aspect ratio and thus has to // go over the inner pane size.
pPane = mpPaneContainer->FindPaneURL(PresenterPaneFactory::msNextSlidePreviewPaneURL); if (!pPane) return;
// Get access to the tool bar.
PresenterPaneContainer::SharedPaneDescriptor pDescriptor(
mpPaneContainer->FindPaneURL(PresenterPaneFactory::msToolBarPaneURL)); if (pDescriptor)
{
PresenterToolBarView* pToolBarView
= dynamic_cast<PresenterToolBarView*>(pDescriptor->mxView.get()); if (pToolBarView != nullptr && pToolBarView->GetPresenterToolBar().is())
{
geometry::RealSize2D aSize (pToolBarView->GetPresenterToolBar()->GetMinimalSize());
awt::Size PresenterWindowManager::CalculatePaneSize ( constdouble nOuterWidth, const OUString& rsPaneURL)
{ // Calculate the inner width by removing the pane border.
awt::Rectangle aInnerBox (mpPaneBorderPainter->RemoveBorder (
rsPaneURL,
awt::Rectangle(0,0,
sal_Int32(nOuterWidth+0.5),sal_Int32(nOuterWidth)),
drawing::framework::BorderType_TOTAL_BORDER));
// Calculate the inner height with the help of the slide aspect ratio. constdouble nCurrentSlideInnerHeight (
aInnerBox.Width / mpPresenterController->GetSlideAspectRatio());
// Add the pane border to get the outer box.
awt::Rectangle aOuterBox (mpPaneBorderPainter->AddBorder (
rsPaneURL,
awt::Rectangle(0,0,
aInnerBox.Width,sal_Int32(nCurrentSlideInnerHeight+0.5)),
drawing::framework::BorderType_TOTAL_BORDER));
Reference<rendering::XGraphicDevice> xDevice (mxParentCanvas->getDevice()); if ( ! xDevice.is()) return;
// Create a polygon for the background and for clipping.
Reference<rendering::XPolyPolygon2D> xBackgroundPolygon (
PresenterGeometryHelper::CreatePolygon(mxParentWindow->getPosSize(), xDevice)); if ( ! mxClipPolygon.is())
mxClipPolygon = CreateClipPolyPolygon();
Reference<rendering::XPolyPolygon2D> PresenterWindowManager::CreateClipPolyPolygon() const
{ // Create a clip polygon that includes the whole update area but has the // content windows as holes. const sal_Int32 nPaneCount (mpPaneContainer->maPanes.size());
::std::vector<awt::Rectangle> aRectangles;
aRectangles.reserve(1+nPaneCount);
aRectangles.push_back(mxParentWindow->getPosSize()); for (constauto& pDescriptor : mpPaneContainer->maPanes)
{ if ( ! pDescriptor->mbIsActive) continue; if ( ! pDescriptor->mbIsOpaque) continue; if ( ! pDescriptor->mxBorderWindow.is() || ! pDescriptor->mxContentWindow.is()) continue;
Reference<awt::XWindow2> xWindow (pDescriptor->mxBorderWindow, UNO_QUERY); if (xWindow.is() && ! xWindow->isVisible()) continue;
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.