From 7b8f630db30ee0066a9f4b6e540368d2fcad7fa8 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sun, 14 Nov 2021 00:09:43 +0300 Subject: Use o3tl::convert Change-Id: I78db3001d602ec1a0847785b3c127b9d345f5af7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125173 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- .../qa/gtktiledviewer/gtv-lok-dialog.cxx | 28 +++++++--------------- libreofficekit/source/gtk/tilebuffer.cxx | 7 ++++-- libreofficekit/source/gtk/tilebuffer.hxx | 2 -- 3 files changed, 13 insertions(+), 24 deletions(-) (limited to 'libreofficekit') diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx index a67d3427eae5..4d889645b2fc 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx @@ -20,6 +20,8 @@ #include "gtv-lok-dialog.hxx" #include + +#include #include namespace { @@ -83,20 +85,6 @@ getPrivate(GtvLokDialog* dialog) return static_cast(gtv_lok_dialog_get_instance_private(dialog)); } -static float -pixelToTwip(float fInput) -{ - return (fInput / 96 / 1.0 /* zoom */) * 1440.0f; -} - -#if 0 -static float -twipToPixel(float fInput) -{ - return fInput / 1440.0f * 96 * 1.0 /* zoom */; -} -#endif - static void gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer) { @@ -235,8 +223,8 @@ gtv_lok_dialog_signal_motion(GtkWidget* pDialogDrawingArea, GdkEventButton* pEve g_info("lok_dialog_signal_motion: %d, %d (in twips: %d, %d)", static_cast(pEvent->x), static_cast(pEvent->y), - static_cast(pixelToTwip(pEvent->x)), - static_cast(pixelToTwip(pEvent->y))); + static_cast(o3tl::toTwips(pEvent->x, o3tl::Length::px)), + static_cast(o3tl::toTwips(pEvent->y, o3tl::Length::px))); pDocument->pClass->postWindowMouseEvent(pDocument, priv->dialogid, @@ -531,8 +519,8 @@ gtv_lok_dialog_floating_win_signal_button(GtkWidget* /*pDialogChildDrawingArea*/ g_info("lok_dialog_floating_win_signal_button (type: %s): %d, %d (in twips: %d, %d)", aEventType.c_str(), static_cast(pEvent->x), static_cast(pEvent->y), - static_cast(pixelToTwip(pEvent->x)), - static_cast(pixelToTwip(pEvent->y))); + static_cast(o3tl::toTwips(pEvent->x, o3tl::Length::px)), + static_cast(o3tl::toTwips(pEvent->y, o3tl::Length::px))); switch (pEvent->type) { @@ -614,8 +602,8 @@ gtv_lok_dialog_floating_win_signal_motion(GtkWidget* /*pDialogDrawingArea*/, Gdk g_info("lok_dialog_floating_win_signal_motion: %d, %d (in twips: %d, %d)", static_cast(pEvent->x), static_cast(pEvent->y), - static_cast(pixelToTwip(pEvent->x)), - static_cast(pixelToTwip(pEvent->y))); + static_cast(o3tl::toTwips(pEvent->x, o3tl::Length::px)), + static_cast(o3tl::toTwips(pEvent->y, o3tl::Length::px))); pDocument->pClass->postWindowMouseEvent(pDocument, priv->m_nChildId, diff --git a/libreofficekit/source/gtk/tilebuffer.cxx b/libreofficekit/source/gtk/tilebuffer.cxx index 6836031661bc..3c73c9dddf83 100644 --- a/libreofficekit/source/gtk/tilebuffer.cxx +++ b/libreofficekit/source/gtk/tilebuffer.cxx @@ -9,19 +9,22 @@ #include "tilebuffer.hxx" +#include + /* ------------------ Utility functions ------------------ */ +// We know that VirtualDevices use a DPI of 96. float pixelToTwip(float fInput, float zoom) { - return (fInput / DPI / zoom) * 1440.0f; + return o3tl::toTwips(fInput / zoom, o3tl::Length::px); } float twipToPixel(float fInput, float zoom) { - return fInput / 1440.0f * DPI * zoom; + return o3tl::convert(fInput * zoom, o3tl::Length::twip, o3tl::Length::px); } /* ---------------------------- diff --git a/libreofficekit/source/gtk/tilebuffer.hxx b/libreofficekit/source/gtk/tilebuffer.hxx index 79fa48c555db..239482e34625 100644 --- a/libreofficekit/source/gtk/tilebuffer.hxx +++ b/libreofficekit/source/gtk/tilebuffer.hxx @@ -18,8 +18,6 @@ #define LOK_TILEBUFFER_ERROR (LOKTileBufferErrorQuark()) -// We know that VirtualDevices use a DPI of 96. -const int DPI = 96; // Lets use a square of side 256 pixels for each tile. const int nTileSizePixels = 256; -- cgit ov-5.1 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2019-11-03loplugin:stringaddNoel Grandin
2019-10-31Fix StringAdd::isCompileTimeConstantStephan Bergmann
2019-03-11tdf#42949 Fix IWYU warnings in sc/source/ui/[f-o]*/*cxxGabor Kelemen
2018-11-06tdf#42949 Fix IWYU warnings in sc/source/ui/inc/[m-z]*Gabor Kelemen
2018-06-12simplify calls to *DialogFactory::Create methodsNoel Grandin
2018-06-09remove cargo cult OSL_ENSURE(pFact, "ScAbstractFactory create fail!"(Noel Grandin
2018-04-16weld SvxPostItDialogCaolán McNamara
2018-03-20drop unnecessary includesCaolán McNamara
2017-10-23loplugin:includeform: scStephan Bergmann
2016-10-27make the AbstractDialog stuff extend from VclReferenceBaseNoel Grandin
2016-10-05Remove _TYPED suffix from tools/link.hxx macrosStephan Bergmann
2016-01-15loplugin:unusedmethods unused return value in scNoel Grandin
2015-11-10loplugin:nullptr (automatic rewrite)Stephan Bergmann
2015-09-25convert Link<> to typedNoel Grandin
2015-08-14loplugin: defaultparamsNoel Grandin
2014-09-23fdo#82577: Handle WindowNoel Grandin
2014-06-25remove whitespaceMarkus Mohrhard
2014-06-24new compilerplugin returnbyrefNoel Grandin
2014-06-13loplugin:staticcallStephan Bergmann
2014-04-23sc: sal_Bool->boolNoel Grandin
2014-02-27coverity#1187869 Uninitialized pointer fieldCaolán McNamara
2014-02-23Remove unneccessary commentsAlexander Wilms
2014-02-19sal_Bool->boolNoel Grandin
2013-10-08convert sc/source/ui/miscdlgs/*.cxx from String to OUStringNoel Grandin