chart2/source/controller/main/ChartController_Window.cxx |   14 ++++++++++++++
 vcl/source/window/floatwin.cxx                           |   14 +++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

New commits:
commit 3cfeb9b063fd8f1f46fe0e60581bc9b37baefbd1
Author: Marco Cecchetti <marco.cecche...@collabora.com>
Date:   Wed Apr 18 18:31:00 2018 +0200

    lok: charts context menu was misplaced + wrong LogicToLogic conversion
    
    Chart context menu was misplaced since the context menu expects a
    position related to the document window not to the chart window.
    Moreover map mode is not enabled for chart window, that leads to use
    the LogicToLogic routine which unfortunately provides a wrong pixel to
    twips conversion. In fact we gets a 20 twips per pixel conversion
    since LogicToLogic uses a fixed 72 dpi value, instead of a correctly
    computed output device real dpi or at least the most commonly used 96
    dpi value.
    
    Change-Id: Idb4220d03fddd4b6d643c1c0fb52754bafed7e36
    Reviewed-on: https://gerrit.libreoffice.org/53118
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>
    Tested-by: Jan Holesovsky <ke...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/54649

diff --git a/chart2/source/controller/main/ChartController_Window.cxx 
b/chart2/source/controller/main/ChartController_Window.cxx
index ed3ef2bce8e2..0b0053e479a9 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -66,6 +66,7 @@
 #include <toolkit/awt/vclxmenu.hxx>
 
 #include <sfx2/viewsh.hxx>
+#include <sfx2/ipclient.hxx>
 #include <svx/svxids.hrc>
 #include <svx/ActionDescriptionProvider.hxx>
 #include <svx/obj3d.hxx>
@@ -1258,6 +1259,19 @@ void ChartController::execute_Command( const 
CommandEvent& rCEvt )
         {
             PopupMenu* pPopupMenu = 
static_cast<PopupMenu*>(VCLXMenu::GetImplementation(xPopupMenu)->GetMenu());
             pPopupMenu->SetLOKNotifier(SfxViewShell::Current());
+
+            // the context menu expects a position related to the document 
window,
+            // not to the chart window
+            SfxInPlaceClient* pIPClient = 
SfxViewShell::Current()->GetIPClient();
+            if (pIPClient)
+            {
+                vcl::Window* pRootWin = pIPClient->GetEditWin();
+                if (pRootWin)
+                {
+                    Point aOffset = 
pChartWindow->GetOffsetPixelFrom(*pRootWin);
+                    aPos += aOffset;
+                }
+            }
         }
 
         xPopupController->setPopupMenu( xPopupMenu );
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index e39f1dc1f121..84105f7ff865 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -442,10 +442,22 @@ Point FloatingWindow::ImplCalcPos(vcl::Window* pWindow,
 
     if (bLOKActive && pLOKTwipsPos)
     {
-        if (pW->IsMapModeEnabled())
+        if (pW->IsMapModeEnabled() || pW->GetMapMode().GetMapUnit() == 
MapUnit::MapPixel)
+        {
+            // if we use pW->LogicToLogic(aPos, pW->GetMapMode(), 
MapMode(MapUnit::MapTwip)),
+            // for pixel conversions when map mode is not enabled, we gets
+            // a 20 twips per pixel conversion since LogicToLogic uses
+            // a fixed 72 dpi value, instead of a correctly computed output
+            // device dpi or at least the most commonly used 96 dpi value;
+            // and anyway the following is what we already do in
+            // ScGridWindow::LogicInvalidate when map mode is not enabled.
+
             *pLOKTwipsPos = pW->PixelToLogic(aPos, MapMode(MapUnit::MapTwip));
+        }
         else
+        {
             *pLOKTwipsPos = pW->LogicToLogic(aPos, pW->GetMapMode(), 
MapMode(MapUnit::MapTwip));
+        }
     }
 
     // caller expects coordinates relative to top-level win
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to