summaryrefslogtreecommitdiff
path: root/chart2
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 /chart2
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 'chart2')
-rw-r--r--chart2/source/controller/inc/ChartController.hxx2
-rw-r--r--chart2/source/controller/inc/ChartWindow.hxx9
-rw-r--r--chart2/source/controller/main/ChartController.cxx15
-rw-r--r--chart2/source/controller/main/ChartController_Tools.cxx35
-rw-r--r--chart2/source/controller/main/ChartController_Window.cxx5
-rw-r--r--chart2/source/controller/main/ChartWindow.cxx110
6 files changed, 174 insertions, 2 deletions
diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx
index 29f74ad358e2..145939f1b947 100644
--- a/chart2/source/controller/inc/ChartController.hxx
+++ b/chart2/source/controller/inc/ChartController.hxx
@@ -488,6 +488,8 @@ private:
void executeDispatch_ToggleGridHorizontal();
void executeDispatch_ToggleGridVertical();
+ void executeDispatch_LOKSetTextSelection(int nType, int nX, int nY);
+
void sendPopupRequest(OUString const & rCID, tools::Rectangle aRectangle);
void impl_ShapeControllerDispatch( const css::util::URL& rURL,
diff --git a/chart2/source/controller/inc/ChartWindow.hxx b/chart2/source/controller/inc/ChartWindow.hxx
index 95a029698e9c..db9044970247 100644
--- a/chart2/source/controller/inc/ChartWindow.hxx
+++ b/chart2/source/controller/inc/ChartWindow.hxx
@@ -58,6 +58,7 @@ public:
virtual void Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE ) override;
virtual void Invalidate( const tools::Rectangle& rRect, InvalidateFlags nFlags = InvalidateFlags::NONE ) override;
virtual void Invalidate( const vcl::Region& rRegion, InvalidateFlags nFlags = InvalidateFlags::NONE ) override;
+ virtual void LogicInvalidate( const tools::Rectangle* pRectangle ) override;
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
@@ -65,9 +66,17 @@ public:
ChartController* GetController();
+ virtual bool IsChart() const override { return true; }
+ vcl::Window* GetParentEditWin();
+
+private:
+ // returns the chart bounding box in twips
+ tools::Rectangle GetBoundingBox();
+
private:
ChartController* m_pWindowController;
bool m_bInPaint;
+ VclPtr<vcl::Window> m_pViewShellWindow;
VclPtr<vcl::Window> m_pOpenGLWindow;
void adjustHighContrastMode();
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index 2e822ceea120..e660dfb24be7 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -1091,7 +1091,20 @@ void SAL_CALL ChartController::dispatch(
{
OUString aCommand = rURL.Path;
- if(aCommand == "Paste")
+ if(aCommand == "LOKSetTextSelection")
+ {
+ if (rArgs.getLength() == 3)
+ {
+ sal_Int32 nType = -1;
+ rArgs[0].Value >>= nType;
+ sal_Int32 nX = 0;
+ rArgs[1].Value >>= nX;
+ sal_Int32 nY = 0;
+ rArgs[2].Value >>= nY;
+ executeDispatch_LOKSetTextSelection(nType, nX, nY);
+ }
+ }
+ else if(aCommand == "Paste")
this->executeDispatch_Paste();
else if(aCommand == "Copy" )
this->executeDispatch_Copy();
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index 36c6a569985e..61144839e995 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -52,6 +52,8 @@
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
+#include <editeng/editview.hxx>
+#include <editeng/outliner.hxx>
#include <svx/ActionDescriptionProvider.hxx>
#include <svtools/transfer.hxx>
#include <sot/storage.hxx>
@@ -70,6 +72,8 @@
#include <svx/unoapi.hxx>
#include <svx/unopage.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+
#include <memory>
using namespace ::com::sun::star;
@@ -923,6 +927,37 @@ void ChartController::executeDispatch_ToggleGridVertical()
}
}
+void ChartController::executeDispatch_LOKSetTextSelection(int nType, int nX, int nY)
+{
+ if (m_pDrawViewWrapper)
+ {
+ if (m_pDrawViewWrapper->IsTextEdit())
+ {
+ OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView();
+ if (pOutlinerView)
+ {
+ EditView& rEditView = pOutlinerView->GetEditView();
+ Point aPoint(convertTwipToMm100(nX), convertTwipToMm100(nY));
+ switch (nType)
+ {
+ case LOK_SETTEXTSELECTION_START:
+ rEditView.SetCursorLogicPosition(aPoint, /*bPoint=*/false, /*bClearMark=*/false);
+ break;
+ case LOK_SETTEXTSELECTION_END:
+ rEditView.SetCursorLogicPosition(aPoint, /*bPoint=*/true, /*bClearMark=*/false);
+ break;
+ case LOK_SETTEXTSELECTION_RESET:
+ rEditView.SetCursorLogicPosition(aPoint, /*bPoint=*/true, /*bClearMark=*/true);
+ break;
+ default:
+ assert(false);
+ break;
+ }
+ }
+ }
+ }
+}
+
void ChartController::impl_ShapeControllerDispatch( const util::URL& rURL, const Sequence< beans::PropertyValue >& rArgs )
{
Reference< frame::XDispatch > xDispatch( m_aDispatchContainer.getShapeController() );
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index c05c56af059d..f5d31525cc24 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -888,7 +888,10 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
else
m_aSelection.resetPossibleSelectionAfterSingleClickWasEnsured();
}
- else if( isDoubleClick(rMEvt) && !bMouseUpWithoutMouseDown /*#i106966#*/ )
+ // In tiled rendering drag mode could be not yet over on the call
+ // that should handle the double-click, so better to perform this check
+ // always.
+ if( isDoubleClick(rMEvt) && !bMouseUpWithoutMouseDown /*#i106966#*/ )
{
Point aMousePixel = rMEvt.GetPosPixel();
execute_DoubleClick( &aMousePixel );
diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx
index b03f10164b17..717704fcda27 100644
--- a/chart2/source/controller/main/ChartWindow.cxx
+++ b/chart2/source/controller/main/ChartWindow.cxx
@@ -28,6 +28,13 @@
#include <config_features.h>
#include <com/sun/star/chart2/X3DChartWindowProvider.hpp>
+#include <sfx2/ipclient.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/lokhelper.hxx>
+#include <comphelper/lok.hxx>
+
+#define TWIPS_PER_PIXEL 15
+
using namespace ::com::sun::star;
namespace
@@ -50,6 +57,7 @@ ChartWindow::ChartWindow( ChartController* pController, vcl::Window* pParent, Wi
: Window(pParent, nStyle)
, m_pWindowController( pController )
, m_bInPaint(false)
+ , m_pViewShellWindow( nullptr )
#if HAVE_FEATURE_OPENGL
, m_pOpenGLWindow(VclPtr<OpenGLWindow>::Create(this, false))
#else
@@ -94,6 +102,7 @@ void ChartWindow::dispose()
xUpdatable->update();
}
m_pOpenGLWindow.disposeAndClear();
+ m_pViewShellWindow.clear();
vcl::Window::dispose();
}
@@ -108,6 +117,10 @@ void ChartWindow::PrePaint(vcl::RenderContext& )
void ChartWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
{
+ if (comphelper::LibreOfficeKit::isActive()
+ && rRenderContext.GetOutDevType() != OutDevType::OUTDEV_VIRDEV)
+ return;
+
m_bInPaint = true;
if (m_pOpenGLWindow && m_pOpenGLWindow->IsVisible())
{
@@ -301,6 +314,56 @@ void ChartWindow::Invalidate( const vcl::Region& rRegion, InvalidateFlags nFlags
}
}
+void ChartWindow::LogicInvalidate(const tools::Rectangle* pRectangle)
+{
+ OString sRectangle;
+ if (!pRectangle)
+ {
+ // we have to invalidate the whole chart area not the whole document
+ sRectangle = GetBoundingBox().toString();
+ }
+ else
+ {
+ tools::Rectangle aRectangle(*pRectangle);
+ // When dragging shapes the map mode is disabled.
+ if (IsMapModeEnabled())
+ {
+ if (GetMapMode().GetMapUnit() == MapUnit::Map100thMM)
+ aRectangle = OutputDevice::LogicToLogic(aRectangle, MapUnit::Map100thMM, MapUnit::MapTwip);
+ }
+ else
+ {
+ aRectangle = PixelToLogic(aRectangle, MapMode(MapUnit::MapTwip));
+ }
+
+ vcl::Window* pEditWin = GetParentEditWin();
+ if (pEditWin)
+ {
+ MapMode aCWMapMode = GetMapMode();
+ double fXScale = aCWMapMode.GetScaleX();
+ double fYScale = aCWMapMode.GetScaleY();
+
+ if (!IsMapModeEnabled())
+ {
+ aRectangle.Left() /= fXScale;
+ aRectangle.Right() /= fXScale;
+ aRectangle.Top() /= fYScale;
+ aRectangle.Bottom() /= fYScale;
+ }
+
+ Point aOffset = this->GetOffsetPixelFrom(*pEditWin);
+ aOffset.X() *= (TWIPS_PER_PIXEL / fXScale);
+ aOffset.Y() *= (TWIPS_PER_PIXEL / fYScale);
+
+ aRectangle = tools::Rectangle(aRectangle.TopLeft() + aOffset, aRectangle.GetSize());
+ }
+
+ sRectangle = aRectangle.toString();
+ }
+ SfxViewShell* pCurrentShell = SfxViewShell::Current();
+ SfxLokHelper::notifyInvalidation(pCurrentShell, sRectangle);
+}
+
FactoryFunction ChartWindow::GetUITestFactory() const
{
return ChartWindowUIObject::create;
@@ -311,6 +374,53 @@ ChartController* ChartWindow::GetController()
return m_pWindowController;
}
+vcl::Window* ChartWindow::GetParentEditWin()
+{
+ if (m_pViewShellWindow)
+ return m_pViewShellWindow.get();
+
+ // So, you are thinking, why do not invoke pCurrentShell->GetWindow() ?
+ // Because in Impress the parent edit win is not view shell window.
+ SfxViewShell* pCurrentShell = SfxViewShell::Current();
+ if( pCurrentShell )
+ {
+ SfxInPlaceClient* pIPClient = pCurrentShell->GetIPClient();
+ if (pIPClient)
+ {
+ vcl::Window* pRootWin = pIPClient->GetEditWin();
+ if(pRootWin && pRootWin->IsAncestorOf(*this))
+ {
+ m_pViewShellWindow = pRootWin;
+ return m_pViewShellWindow.get();
+ }
+ }
+ }
+ return nullptr;
+}
+
+tools::Rectangle ChartWindow::GetBoundingBox()
+{
+ tools::Rectangle aBBox;
+
+ vcl::Window* pRootWin = GetParentEditWin();
+ if (pRootWin)
+ {
+ // In all cases, the following code fragment
+ // returns the chart bounding box in twips.
+ MapMode aCWMapMode = GetMapMode();
+ double fXScale = aCWMapMode.GetScaleX();
+ double fYScale = aCWMapMode.GetScaleY();
+ Point aOffset = GetOffsetPixelFrom(*pRootWin);
+ aOffset.X() *= (TWIPS_PER_PIXEL / fXScale);
+ aOffset.Y() *= (TWIPS_PER_PIXEL / fYScale);
+ Size aSize = GetSizePixel();
+ aSize.Width() *= (TWIPS_PER_PIXEL / fXScale);
+ aSize.Height() *= (TWIPS_PER_PIXEL / fYScale);
+ aBBox = tools::Rectangle(aOffset, aSize);
+ }
+ return aBBox;
+}
+
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */