/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * 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 LokStarMathHelper::GetBoundingBox() const
{ if (mpIPClient)
{
tools::Rectangle r(mpIPClient->GetObjArea()); if (SfxObjectShell* pObjShell = const_cast<SfxViewShell*>(mpViewShell)->GetObjectShell())
{ const o3tl::Length unit = MapToO3tlLength(pObjShell->GetMapUnit()); if (unit != o3tl::Length::twip && unit != o3tl::Length::invalid)
r = o3tl::convert(r, unit, o3tl::Length::twip);
} return r;
} return {};
}
bool LokStarMathHelper::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier, double fPPTScaleX, double fPPTScaleY)
{ const tools::Rectangle rBBox = GetBoundingBox(); if (Point aMousePos(nX, nY); rBBox.Contains(aMousePos))
{ if (vcl::Window* pWindow = GetWidgetWindow())
{
aMousePos -= rBBox.TopLeft();
// In lok, Math does not convert coordinates (see SmGraphicWidget::SetDrawingArea, // which disables MapMode), and uses twips internally (see SmDocShell ctor and // SmMapUnit), but the conversion factor can depend on the client zoom. // 1. Remove the twip->pixel factor in the passed scales double fScaleX = o3tl::convert(fPPTScaleX, o3tl::Length::px, o3tl::Length::twip); double fScaleY = o3tl::convert(fPPTScaleY, o3tl::Length::px, o3tl::Length::twip); // 2. Adjust the position according to the scales
aMousePos
= Point(std::round(aMousePos.X() * fScaleX), std::round(aMousePos.Y() * fScaleY)); // 3. Take window own scaling into account (reverses the conversion done in // SmGraphicWidget::MouseButtonDown, albeit incompletely - it does not handle // GetFormulaDrawPos; hopefully, in lok/in-place case, it's always [ 0, 0 ]?)
aMousePos = pWindow->LogicToPixel(aMousePos);
vcl::Window* pWidgetWindow = GetWidgetWindow(); if (!pWidgetWindow) return;
Point aOffset(aMathRect.Left() - rTileRect.Left(), aMathRect.Top() - rTileRect.Top());
MapMode newMode = rDevice.GetMapMode();
newMode.SetOrigin(aOffset);
rDevice.SetMapMode(newMode); // Push/Pop is done in PaintAllInPlaceOnTile
pWidgetWindow->Paint(rDevice, {}); // SmGraphicWidget::Paint does not use the passed rectangle
}
void LokStarMathHelper::PaintAllInPlaceOnTile(VirtualDevice& rDevice, int nOutputWidth, int nOutputHeight, int nTilePosX, int nTilePosY,
tools::Long nTileWidth, tools::Long nTileHeight)
{ if (comphelper::LibreOfficeKit::isTiledAnnotations()) return;
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.