diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2017-06-27 23:35:08 +0200 |
---|---|---|
committer | Marco Cecchetti <mrcekets@gmail.com> | 2017-08-03 10:58:59 +0200 |
commit | eba883c8a2ce045fc7bd3848d796ca10b7f4ba51 (patch) | |
tree | a6a5684a36725e67a24eab86fa984c38252cb2d9 /sc | |
parent | 166f13ef65b4a0eb9927eff2ffe5bac319785ee7 (diff) |
lok - add support for in place chart editing
This commit add a minimal support for editing chart embedded in a
spreadsheet or a text document or a presentation.
Graphic objects can be moved and resized, text objects can be edited.
Change-Id: I8e637dabf328a94bd6bb0e309a245302cff421d8
Reviewed-on: https://gerrit.libreoffice.org/39342
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index b6eeca6fc39a..8b70fa9f44e9 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -48,6 +48,7 @@ #include <unotools/charclass.hxx> #include <tools/multisel.hxx> #include <toolkit/awt/vclxdevice.hxx> +#include <toolkit/helper/vclunohelper.hxx> #include <unotools/saveopt.hxx> #include <float.h> @@ -75,6 +76,7 @@ #include <opencl/platforminfo.hxx> #endif #include <sfx2/lokhelper.hxx> +#include <sfx2/lokcharthelper.hxx> #include "cellsuno.hxx" #include <columnspanset.hxx> @@ -503,6 +505,9 @@ void ScModelObj::paintTile( VirtualDevice& rDevice, pGridWindow->PaintTile( rDevice, nOutputWidth, nOutputHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight ); + + LokChartHelper::PaintAllChartsOnTile(rDevice, nOutputWidth, nOutputHeight, + nTilePosX, nTilePosY, nTileWidth, nTileHeight); } void ScModelObj::setPart( int nPart ) @@ -570,20 +575,28 @@ void ScModelObj::postKeyEvent(int nType, int nCharCode, int nKeyCode) // There seems to be no clear way of getting the grid window for this // particular document, hence we need to hope we get the right window. ScViewData* pViewData = ScDocShell::GetViewData(); - ScGridWindow* pGridWindow = pViewData->GetActiveWin(); + vcl::Window* pWindow = pViewData->GetActiveWin(); - if (!pGridWindow) + if (!pWindow) return; KeyEvent aEvent(nCharCode, nKeyCode, 0); + ScTabViewShell * pTabViewShell = pViewData->GetViewShell(); + LokChartHelper aChartHelper(pTabViewShell); + vcl::Window* pChartWindow = aChartHelper.GetWindow(); + if (pChartWindow) + { + pWindow = pChartWindow; + } + switch (nType) { case LOK_KEYEVENT_KEYINPUT: - pGridWindow->KeyInput(aEvent); + pWindow->KeyInput(aEvent); break; case LOK_KEYEVENT_KEYUP: - pGridWindow->KeyUp(aEvent); + pWindow->KeyUp(aEvent); break; default: assert(false); @@ -607,6 +620,23 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButt pViewData->SetZoom(Fraction(mnTilePixelWidth * TWIPS_PER_PIXEL, mnTileTwipWidth), Fraction(mnTilePixelHeight * TWIPS_PER_PIXEL, mnTileTwipHeight), true); + // check if user hit a chart which is being edited by him + ScTabViewShell * pTabViewShell = pViewData->GetViewShell(); + LokChartHelper aChartHelper(pTabViewShell); + if (aChartHelper.postMouseEvent(nType, nX, nY, + nCount, nButtons, nModifier, + pViewData->GetPPTX(), pViewData->GetPPTY())) + return; + + // check if the user hit a chart which is being edited by someone else + // and, if so, skip current mouse event + if (nType != LOK_MOUSEEVENT_MOUSEMOVE) + { + if (LokChartHelper::HitAny(Point(nX, nY))) + return; + } + + // Calc operates in pixels... Point aPos(nX * pViewData->GetPPTX(), nY * pViewData->GetPPTY()); MouseEvent aEvent(aPos, nCount, @@ -645,9 +675,13 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButt void ScModelObj::setTextSelection(int nType, int nX, int nY) { SolarMutexGuard aGuard; - ScViewData* pViewData = ScDocShell::GetViewData(); ScTabViewShell* pViewShell = pViewData->GetViewShell(); + + LokChartHelper aChartHelper(pViewShell); + if (aChartHelper.setTextSelection(nType, nX, nY)) + return; + ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl(pViewShell); ScDrawView* pDrawView = pViewData->GetScDrawView(); @@ -822,9 +856,16 @@ void ScModelObj::setGraphicSelection(int nType, int nX, int nY) // update the aLogicMode in ScViewData to something predictable pViewData->SetZoom(Fraction(mnTilePixelWidth * TWIPS_PER_PIXEL, mnTileTwipWidth), Fraction(mnTilePixelHeight * TWIPS_PER_PIXEL, mnTileTwipHeight), true); + double fPPTX = pViewData->GetPPTX(); + double fPPTY = pViewData->GetPPTY(); + + ScTabViewShell* pViewShell = pViewData->GetViewShell(); + LokChartHelper aChartHelper(pViewShell); + if (aChartHelper.setGraphicSelection(nType, nX, nY, fPPTX, fPPTY)) + return; - int nPixelX = nX * pViewData->GetPPTX(); - int nPixelY = nY * pViewData->GetPPTY(); + int nPixelX = nX * fPPTX; + int nPixelY = nY * fPPTY; switch (nType) { |