summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2017-06-27 23:35:08 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-08-03 12:32:51 +0200
commit0d3a367b5623639e7fdc9ce1ccc277e2597694a0 (patch)
treebd69a33834b9d85fd738c550015461453da5f16f /sd
parent9a5c39ea56bbac48f30a1a4966caa68697d8b318 (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 'sd')
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx60
1 files changed, 51 insertions, 9 deletions
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 7791e4180123..6b852e2cb5bb 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -117,6 +117,10 @@
#include <drawinglayer/primitive2d/structuretagprimitive2d.hxx>
+#include <sfx2/lokcharthelper.hxx>
+
+#define TWIPS_PER_PIXEL 15
+
using namespace ::osl;
using namespace ::cppu;
using namespace ::com::sun::star;
@@ -2289,15 +2293,15 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice,
// 100th mm rather than TWIP. It makes most sense just to
// convert here and in getDocumentSize, and leave the tiled
// rendering API working in TWIPs.
- nTileWidth = convertTwipToMm100( nTileWidth );
- nTileHeight = convertTwipToMm100( nTileHeight );
- nTilePosX = convertTwipToMm100( nTilePosX );
- nTilePosY = convertTwipToMm100( nTilePosY );
+ long nTileWidthHMM = convertTwipToMm100( nTileWidth );
+ long nTileHeightHMM = convertTwipToMm100( nTileHeight );
+ int nTilePosXHMM = convertTwipToMm100( nTilePosX );
+ int nTilePosYHMM = convertTwipToMm100( nTilePosY );
MapMode aMapMode = rDevice.GetMapMode();
aMapMode.SetMapUnit( MapUnit::Map100thMM );
- aMapMode.SetOrigin( Point( -nTilePosX,
- -nTilePosY) );
+ aMapMode.SetOrigin( Point( -nTilePosXHMM,
+ -nTilePosYHMM) );
aMapMode.SetScaleX( scaleX );
aMapMode.SetScaleY( scaleY );
@@ -2305,11 +2309,14 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice,
rDevice.SetOutputSizePixel( Size(nOutputWidth, nOutputHeight) );
- Point aPoint(nTilePosX, nTilePosY);
- Size aSize(nTileWidth, nTileHeight);
+ Point aPoint(nTilePosXHMM, nTilePosYHMM);
+ Size aSize(nTileWidthHMM, nTileHeightHMM);
Rectangle aRect(aPoint, aSize);
pViewSh->GetView()->CompleteRedraw(&rDevice, vcl::Region(aRect));
+
+ LokChartHelper::PaintAllChartsOnTile(rDevice, nOutputWidth, nOutputHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight);
}
void SdXImpressDocument::setPart( int nPart )
@@ -2488,10 +2495,17 @@ void SdXImpressDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
if (!pViewShell)
return;
- sd::Window* pWindow = pViewShell->GetActiveWindow();
+ vcl::Window* pWindow = pViewShell->GetActiveWindow();
if (!pWindow)
return;
+ LokChartHelper aChartHelper(pViewShell->GetViewShell());
+ vcl::Window* pChartWindow = aChartHelper.GetWindow();
+ if (pChartWindow)
+ {
+ pWindow = pChartWindow;
+ }
+
KeyEvent aEvent(nCharCode, nKeyCode, 0);
switch (nType)
@@ -2515,6 +2529,24 @@ void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount, i
DrawViewShell* pViewShell = GetViewShell();
if (!pViewShell)
return;
+
+ double fScale = 1.0/TWIPS_PER_PIXEL;
+
+ // check if user hit a chart which is being edited by him
+ LokChartHelper aChartHelper(pViewShell->GetViewShell());
+ if (aChartHelper.postMouseEvent(nType, nX, nY,
+ nCount, nButtons, nModifier,
+ fScale, fScale))
+ 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;
+ }
+
Window* pWindow = pViewShell->GetActiveWindow();
Point aPos(Point(convertTwipToMm100(nX), convertTwipToMm100(nY)));
@@ -2552,6 +2584,10 @@ void SdXImpressDocument::setTextSelection(int nType, int nX, int nY)
if (!pViewShell)
return;
+ LokChartHelper aChartHelper(pViewShell->GetViewShell());
+ if (aChartHelper.setTextSelection(nType, nX, nY))
+ return;
+
Point aPoint(convertTwipToMm100(nX), convertTwipToMm100(nY));
switch (nType)
{
@@ -2589,6 +2625,12 @@ void SdXImpressDocument::setGraphicSelection(int nType, int nX, int nY)
if (!pViewShell)
return;
+ double fScale = 1.0/TWIPS_PER_PIXEL;
+
+ LokChartHelper aChartHelper(pViewShell->GetViewShell());
+ if (aChartHelper.setGraphicSelection(nType, nX, nY, fScale, fScale))
+ return;
+
Point aPoint(convertTwipToMm100(nX), convertTwipToMm100(nY));
switch (nType)
{