/* -*- 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/.
*/
tools::Rectangle LokChartHelper::GetChartBoundingBox()
{
tools::Rectangle aBBox; if (mpViewShell)
{
SfxInPlaceClient* pIPClient = mpViewShell->GetIPClient(); if (pIPClient)
{
vcl::Window* pRootWin = pIPClient->GetEditWin(); if (pRootWin)
{
vcl::Window* pWindow = GetWindow(); if (pWindow)
{ // In all cases, the following code fragment // returns the chart bounding box in twips. const MapMode& aCWMapMode = pWindow->GetMapMode();
constexpr auto p = o3tl::getConversionMulDiv(o3tl::Length::px, o3tl::Length::twip); constauto& scaleX = aCWMapMode.GetScaleX(); constauto& scaleY = aCWMapMode.GetScaleY(); constauto nXNum = p.first * scaleX.GetDenominator(); constauto nXDen = p.second * scaleX.GetNumerator(); constauto nYNum = p.first * scaleY.GetDenominator(); constauto nYDen = p.second * scaleY.GetNumerator();
Point aOffset = pWindow->GetOffsetPixelFrom(*pRootWin); if (mbNegativeX && AllSettings::GetLayoutRTL())
{ // If global RTL flag is set, vcl-window X offset of chart window is // mirrored w.r.t parent window rectangle. This needs to be reverted.
aOffset.setX(pRootWin->GetOutOffXPixel() + pRootWin->GetSizePixel().Width()
- pWindow->GetOutOffXPixel() - pWindow->GetSizePixel().Width());
if (bRenderContextEnableMapMode)
rRenderContext.EnableMapMode(false); if (bEnableMapMode)
pChartWindow->EnableMapMode(false);
}
void LokChartHelper::PaintAllChartsOnTile(VirtualDevice& rDevice, int nOutputWidth, int nOutputHeight, int nTilePosX, int nTilePosY,
tools::Long nTileWidth, tools::Long nTileHeight, bool bNegativeX)
{ if (comphelper::LibreOfficeKit::isTiledAnnotations()) return;
// Resizes the virtual device so to contain the entries context
rDevice.SetOutputSizePixel(Size(nOutputWidth, nOutputHeight), /*bErase*/false);
bool LokChartHelper::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier, double fScaleX, double fScaleY)
{
Point aMousePos(nX, nY);
vcl::Window* pChartWindow = GetWindow(); if (pChartWindow)
{
tools::Rectangle rChartBBox = GetChartBoundingBox(); if (rChartBBox.Contains(aMousePos))
{ int nChartWinX = nX - rChartBBox.Left(); int nChartWinY = nY - rChartBBox.Top();
// chart window expects pixels, but the conversion factor // can depend on the client zoom
Point aPos(nChartWinX * fScaleX, nChartWinY * fScaleY);
bool LokChartHelper::setTextSelection(int nType, int nX, int nY)
{
tools::Rectangle rChartBBox = GetChartBoundingBox(); if (rChartBBox.Contains(Point(nX, nY)))
{
css::uno::Reference<css::frame::XDispatch> xDispatcher = GetXDispatcher(); if (xDispatcher.is())
{ int nChartWinX = nX - rChartBBox.Left(); int nChartWinY = nY - rChartBBox.Top();
// no scale here the chart controller expects twips // that are converted to hmm
util::URL aURL;
aURL.Path = "LOKSetTextSelection";
uno::Sequence< beans::PropertyValue > aArgs{
comphelper::makePropertyValue({}, static_cast<sal_Int32>(nType)), // Why no name?
comphelper::makePropertyValue({}, static_cast<sal_Int32>(nChartWinX)),
comphelper::makePropertyValue({}, static_cast<sal_Int32>(nChartWinY))
};
xDispatcher->dispatch(aURL, aArgs);
} returntrue;
} returnfalse;
}
bool LokChartHelper::setGraphicSelection(int nType, int nX, int nY, double fScaleX, double fScaleY)
{
tools::Rectangle rChartBBox = GetChartBoundingBox(); if (rChartBBox.Contains(Point(nX, nY)))
{ int nChartWinX = nX - rChartBBox.Left(); int nChartWinY = nY - rChartBBox.Top();
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.