summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2017-06-27 23:35:08 +0200
committerMarco Cecchetti <mrcekets@gmail.com>2017-08-03 10:58:59 +0200
commiteba883c8a2ce045fc7bd3848d796ca10b7f4ba51 (patch)
treea6a5684a36725e67a24eab86fa984c38252cb2d9 /sd
parent166f13ef65b4a0eb9927eff2ffe5bac319785ee7 (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 '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 352994d067da..a7c4d0663734 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -119,6 +119,10 @@
#include <drawinglayer/primitive2d/structuretagprimitive2d.hxx>
+#include <sfx2/lokcharthelper.hxx>
+
+#define TWIPS_PER_PIXEL 15
+
using namespace ::cppu;
using namespace ::com::sun::star;
using namespace ::sd;
@@ -2250,15 +2254,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 );
@@ -2266,11 +2270,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);
::tools::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 )
@@ -2449,10 +2456,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)
@@ -2476,6 +2490,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)));
@@ -2513,6 +2545,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)
{
@@ -2550,6 +2586,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)
{