diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2017-06-27 23:35:08 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-08-03 12:32:51 +0200 |
commit | 0d3a367b5623639e7fdc9ce1ccc277e2597694a0 (patch) | |
tree | bd69a33834b9d85fd738c550015461453da5f16f /sc | |
parent | 9a5c39ea56bbac48f30a1a4966caa68697d8b318 (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 object can be moved and resized, text object can be edited.
Change-Id: I8e637dabf328a94bd6bb0e309a245302cff421d8
Reviewed-on: https://gerrit.libreoffice.org/40681
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
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 917d03e15155..473a8dcb17ac 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -48,6 +48,7 @@ #include <tools/multisel.hxx> #include <tools/resary.hxx> #include <toolkit/awt/vclxdevice.hxx> +#include <toolkit/helper/vclunohelper.hxx> #include <unotools/saveopt.hxx> #include <ctype.h> @@ -74,6 +75,7 @@ #include <opencl/platforminfo.hxx> #endif #include <sfx2/lokhelper.hxx> +#include <sfx2/lokcharthelper.hxx> #include "cellsuno.hxx" #include <columnspanset.hxx> @@ -502,6 +504,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 ) @@ -581,20 +586,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); @@ -618,6 +631,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, @@ -656,9 +686,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(); @@ -835,9 +869,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) { |