[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 3 commits - desktop/source include/LibreOfficeKit include/vcl libreofficekit/source sw/inc sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Jan 21 09:02:41 PST 2015
desktop/source/lib/init.cxx | 42 ++++++++++++------------------
include/LibreOfficeKit/LibreOfficeKit.h | 10 ++++---
include/LibreOfficeKit/LibreOfficeKit.hxx | 24 ++++++++---------
include/vcl/ITiledRenderable.hxx | 7 +++++
libreofficekit/source/gtk/lokdocview.c | 4 +-
sw/inc/unotxdoc.hxx | 2 +
sw/source/uibase/docvw/edtwin.cxx | 38 +++++++++++++++++++++------
sw/source/uibase/inc/edtwin.hxx | 6 ++++
sw/source/uibase/uno/unotxdoc.cxx | 20 ++++++++++++++
9 files changed, 103 insertions(+), 50 deletions(-)
New commits:
commit 879250d6be11c523ef584e70cadd7e14e1abed1a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Jan 21 17:57:05 2015 +0100
Initial SwEditWin::LogicMouseButtonDown/Up
This makes single left mouse button clicks work while editing. The idea
is that when we do tiled rendering, we get the click position in
document coordinates (twips) and SwEditWin::MouseButtonDown() can check
if we're doing tiled rendering. For now, make sure that the position is
not passed to any other methods in the tiled rendering case, those may
interpret them as pixels, which is not true.
Change-Id: Icbd16411596393ed983a87fd3a59a08e4fda3696
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index d04e3d7..61e99cf 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -2816,6 +2816,7 @@ void SwEditWin::MoveCursor( SwWrtShell &rSh, const Point aDocPos,
void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
{
SwWrtShell &rSh = m_rView.GetWrtShell();
+ bool bTiledRendering = rSh.isTiledRendering();
const SwField *pCrsrFld = rSh.CrsrInsideInputFld() ? rSh.GetCurFld( true ) : NULL;
// We have to check if a context menu is shown and we have an UI
@@ -2832,7 +2833,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
MouseEvent rMEvt(_rMEvt);
- if (m_rView.GetPostItMgr()->IsHit(rMEvt.GetPosPixel()))
+ if (!bTiledRendering && m_rView.GetPostItMgr()->IsHit(rMEvt.GetPosPixel()))
return;
m_rView.GetPostItMgr()->SetActiveSidebarWin(0);
@@ -2851,7 +2852,11 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
m_bWasShdwCrsr = 0 != m_pShadCrsr;
delete m_pShadCrsr, m_pShadCrsr = 0;
- const Point aDocPos( PixelToLogic( rMEvt.GetPosPixel() ) );
+ Point aDocPos;
+ if (bTiledRendering)
+ aDocPos = rMEvt.GetPosPixel();
+ else
+ aDocPos = PixelToLogic( rMEvt.GetPosPixel() );
// How many clicks do we need to select a fly frame?
FrameControlType eControl;
@@ -2973,7 +2978,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
SET_CURR_SHELL( &rSh );
SdrView *pSdrView = rSh.GetDrawView();
- if ( pSdrView )
+ if ( pSdrView && !bTiledRendering)
{
if (pSdrView->MouseButtonDown( rMEvt, this ) )
{
@@ -3022,7 +3027,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
m_rView.InvalidateRulerPos();
SfxBindings& rBind = m_rView.GetViewFrame()->GetBindings();
rBind.Update();
- if ( RulerColumnDrag( rMEvt,
+ if ( !bTiledRendering && RulerColumnDrag( rMEvt,
(SwTab::COL_VERT == nMouseTabCol || SwTab::ROW_HORI == nMouseTabCol)) )
{
m_rView.SetTabColFromDoc( false );
@@ -3046,7 +3051,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
SfxBindings& rBind = m_rView.GetViewFrame()->GetBindings();
rBind.Update();
- if ( RulerMarginDrag( rMEvt,
+ if ( !bTiledRendering && RulerMarginDrag( rMEvt,
rSh.IsVerticalModeAtNdAndPos( *pNodeAtPos, aDocPos ) ) )
{
m_rView.SetNumRuleNodeFromDoc( NULL );
@@ -3101,7 +3106,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
return;
}
}
- if ( EnterDrawMode( rMEvt, aDocPos ) )
+ if ( !bTiledRendering && EnterDrawMode( rMEvt, aDocPos ) )
{
bNoInterrupt = false;
return;
@@ -3176,7 +3181,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
SwEditWin::m_nDDStartPosX = aDocPos.X();
// hit an URL in DrawText object?
- if (bExecHyperlinks && pSdrView)
+ if (bExecHyperlinks && pSdrView && !bTiledRendering)
{
SdrViewEvent aVEvt;
pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
@@ -3743,7 +3748,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
}
}
- if (bCallBase)
+ if (bCallBase && !bTiledRendering)
Window::MouseButtonDown(rMEvt);
}
@@ -6254,12 +6259,17 @@ void SwEditWin::LogicMouseMove(const MouseEvent& /*rMouseEvent*/)
{
}
-void SwEditWin::LogicMouseButtonDown(const MouseEvent& /*rMouseEvent*/)
+void SwEditWin::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
{
+ // When we're not doing tiled rendering, then positions must be passed as pixels.
+ assert(m_rView.GetWrtShell().isTiledRendering());
+ MouseButtonDown(rMouseEvent);
}
-void SwEditWin::LogicMouseButtonUp(const MouseEvent& /*rMouseEvent*/)
+void SwEditWin::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
{
+ assert(m_rView.GetWrtShell().isTiledRendering());
+ MouseButtonUp(rMouseEvent);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 2db5e39ae1784727ab92c6b8dfb4e9bdc8139919
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Jan 21 12:52:30 2015 +0100
Add SwXTextDocument::postMouseEvent()
Change-Id: Ic2e6343288e87e23026b2f0c17338ecf5f1bed99
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index a837c76..2d5161e 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -413,6 +413,8 @@ public:
* @param pData is private data of the client that will be sent back when the callback is invoked
*/
virtual void registerCallback(LibreOfficeKitCallback pCallback, void* pData) SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::postMouseEvent().
+ virtual void postMouseEvent(int nType, int nX, int nY) SAL_OVERRIDE;
void Invalidate();
void Reactivate(SwDocShell* pNewDocShell);
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index fef9d4d..d04e3d7 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -6250,15 +6250,15 @@ void SwEditWin::LogicInvalidate(const vcl::Region* pRegion)
m_rView.GetWrtShell().libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
}
-void SwEditWin::LogicMouseMove(const MouseEvent& rMouseEvent)
+void SwEditWin::LogicMouseMove(const MouseEvent& /*rMouseEvent*/)
{
}
-void SwEditWin::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
+void SwEditWin::LogicMouseButtonDown(const MouseEvent& /*rMouseEvent*/)
{
}
-void SwEditWin::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
+void SwEditWin::LogicMouseButtonUp(const MouseEvent& /*rMouseEvent*/)
{
}
diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
index d56783a..5372c7b 100644
--- a/sw/source/uibase/inc/edtwin.hxx
+++ b/sw/source/uibase/inc/edtwin.hxx
@@ -302,8 +302,11 @@ public:
* @param pRegion If 0, that means the whole area, otherwise the area in logic coordinates.
*/
void LogicInvalidate(const vcl::Region* pRegion) SAL_OVERRIDE;
+ /// Same as MouseMove(), but coordinates are in logic unit.
void LogicMouseMove(const MouseEvent& rMouseEvent);
+ /// Same as MouseButtonDown(), but coordinates are in logic unit.
void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
+ /// Same as MouseButtonUp(), but coordinates are in logic unit.
void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
};
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index e3d57dd..95233e1 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -129,6 +129,7 @@
#include <swatrset.hxx>
#include <view.hxx>
#include <srcview.hxx>
+#include <edtwin.hxx>
#include <svtools/langtab.hxx>
#include <map>
@@ -3172,6 +3173,25 @@ void SwXTextDocument::registerCallback(LibreOfficeKitCallback pCallback, void* p
pViewShell->registerLibreOfficeKitCallback(pCallback, pData);
}
+void SwXTextDocument::postMouseEvent(int nType, int nX, int nY)
+{
+ SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
+ MouseEvent aEvent(Point(nX, nY), 1, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
+
+ switch (nType)
+ {
+ case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
+ rEditWin.LogicMouseButtonDown(aEvent);
+ break;
+ case LOK_MOUSEEVENT_MOUSEBUTTONUP:
+ rEditWin.LogicMouseButtonUp(aEvent);
+ break;
+ default:
+ assert(false);
+ break;
+ }
+}
+
void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
{
return SwXTextDocumentBaseClass::operator new(t);
commit 185bb706b367d326dabd4903da9ce74208576df7
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Jan 21 12:42:08 2015 +0100
LOK: move postMouseEvent to Document
Change-Id: I5d2d2d05fc0f55d98a1e7a1591b4d66fd93ad353
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e8f98aa..154a8f5a 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -203,6 +203,10 @@ static void doc_initializeForRendering(LibreOfficeKitDocument* pThis);
static void doc_registerCallback(LibreOfficeKitDocument* pThis,
LibreOfficeKitCallback pCallback,
void* pData);
+static void doc_postMouseEvent (LibreOfficeKitDocument* pThis,
+ int nType,
+ int nX,
+ int nY);
struct LibLODocument_Impl : public _LibreOfficeKitDocument
{
@@ -230,6 +234,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
m_pDocumentClass->getDocumentSize = doc_getDocumentSize;
m_pDocumentClass->initializeForRendering = doc_initializeForRendering;
m_pDocumentClass->registerCallback = doc_registerCallback;
+ m_pDocumentClass->postMouseEvent = doc_postMouseEvent;
gDocumentClass = m_pDocumentClass;
}
@@ -253,7 +258,6 @@ static int lo_initialize (LibreOfficeKit* pThis, const ch
static LibreOfficeKitDocument* lo_documentLoad (LibreOfficeKit* pThis, const char* pURL);
static char * lo_getError (LibreOfficeKit* pThis);
static void lo_postKeyEvent (LibreOfficeKit* pThis, int nType, int nCode);
-static void lo_postMouseEvent (LibreOfficeKit* pThis, int nType, int nX, int nY);
struct LibLibreOffice_Impl : public _LibreOfficeKit
@@ -273,7 +277,6 @@ struct LibLibreOffice_Impl : public _LibreOfficeKit
m_pOfficeClass->documentLoad = lo_documentLoad;
m_pOfficeClass->getError = lo_getError;
m_pOfficeClass->postKeyEvent = lo_postKeyEvent;
- m_pOfficeClass->postMouseEvent = lo_postMouseEvent;
gOfficeClass = m_pOfficeClass;
}
@@ -644,6 +647,19 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
pDoc->registerCallback(pCallback, pData);
}
+static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
+{
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return;
+ }
+
+ pDoc->postMouseEvent(nType, nX, nY);
+}
+
+
static char* lo_getError (LibreOfficeKit *pThis)
{
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
@@ -672,28 +688,6 @@ static void lo_postKeyEvent(LibreOfficeKit* /*pThis*/, int nType, int nCode)
#endif
}
-static void lo_postMouseEvent(LibreOfficeKit* /*pThis*/, int nType, int nX, int nY)
-{
-#if defined(UNX) && !defined(MACOSX) && !defined(ENABLE_HEADLESS)
- if (SalFrame *pFocus = SvpSalFrame::GetFocusFrame())
- {
- MouseEvent aEvent = MouseEvent(Point(nX, nY), 1, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
- switch (nType)
- {
- case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
- Application::PostMouseEvent(VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pFocus->GetWindow(), &aEvent);
- break;
- case LOK_MOUSEEVENT_MOUSEBUTTONUP:
- Application::PostMouseEvent(VCLEVENT_WINDOW_MOUSEBUTTONUP, pFocus->GetWindow(), &aEvent);
- break;
- default:
- assert(false);
- break;
- }
- }
-#endif
-}
-
static void force_c_locale(void)
{
// force locale (and resource files loaded) to en-US
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 397d435..991fae4 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -100,7 +100,6 @@ struct _LibreOfficeKitClass
LibreOfficeKitDocument* (*documentLoad) (LibreOfficeKit* pThis, const char* pURL);
char* (*getError) (LibreOfficeKit* pThis);
void (*postKeyEvent) (LibreOfficeKit* pThis, int nType, int nCode);
- void (*postMouseEvent)(LibreOfficeKit* pThis, int nType, int nX, int nY);
};
#define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize)
@@ -165,9 +164,12 @@ struct _LibreOfficeKitDocumentClass
void (*registerCallback) (LibreOfficeKitDocument* pThis,
LibreOfficeKitCallback pCallback,
void* pData);
- void (*postKeyEvent) (LibreOfficeKitDocument* pThis,
- int nType,
- int nCode);
+
+ /// @see lok::Document::postMouseEvent
+ void (*postMouseEvent)(LibreOfficeKitDocument* pThis,
+ int nType,
+ int nX,
+ int nY);
#endif // LOK_USE_UNSTABLE_API
};
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index bd3ce55..f3b3e88 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -104,6 +104,18 @@ public:
{
mpDoc->pClass->registerCallback(mpDoc, pCallback, pData);
}
+
+ /**
+ * Posts a mouse event to the document.
+ *
+ * @param nType Event type, like down, move or up.
+ * @param nX horizontal position in document coordinates
+ * @param nY vertical position in document coordinates
+ */
+ inline void postMouseEvent(int nType, int nX, int nY)
+ {
+ mpDoc->pClass->postMouseEvent(mpDoc, nType, nX, nY);
+ }
#endif // LOK_USE_UNSTABLE_API
};
@@ -146,18 +158,6 @@ public:
{
mpThis->pClass->postKeyEvent(mpThis, nType, nCode);
}
-
- /**
- * Posts a mouse event to the focused frame.
- *
- * @param nType Event type, like down, move or up.
- * @param nX horizontal position
- * @param nY vertical position
- */
- inline void postMouseEvent(int nType, int nX, int nY)
- {
- mpThis->pClass->postMouseEvent(mpThis, nType, nX, nY);
- }
};
inline Office* lok_cpp_init(const char* pInstallPath)
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 15630c1..8711611 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -96,6 +96,13 @@ public:
* @param pData is private data of the client that will be sent back when the callback is invoked
*/
virtual void registerCallback(LibreOfficeKitCallback /*pCallback*/, void* /*pData*/) { }
+
+ /**
+ * Posts a mouse event on the document.
+ *
+ * @see lok::Document::postMouseEvent().
+ */
+ virtual void postMouseEvent(int /*nType*/, int /*nX*/, int /*nY*/) { }
};
} // namespace vcl
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 972acab..bb2444c 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -45,10 +45,10 @@ void lcl_signalButton(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocView*
switch (pEvent->type)
{
case GDK_BUTTON_PRESS:
- pDocView->pOffice->pClass->postMouseEvent(pDocView->pOffice, LOK_MOUSEEVENT_MOUSEBUTTONDOWN, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
+ pDocView->pDocument->pClass->postMouseEvent(pDocView->pDocument, LOK_MOUSEEVENT_MOUSEBUTTONDOWN, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
break;
case GDK_BUTTON_RELEASE:
- pDocView->pOffice->pClass->postMouseEvent(pDocView->pOffice, LOK_MOUSEEVENT_MOUSEBUTTONUP, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
+ pDocView->pDocument->pClass->postMouseEvent(pDocView->pDocument, LOK_MOUSEEVENT_MOUSEBUTTONUP, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
break;
default:
break;
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 7001bf0..fef9d4d 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -6250,4 +6250,16 @@ void SwEditWin::LogicInvalidate(const vcl::Region* pRegion)
m_rView.GetWrtShell().libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
}
+void SwEditWin::LogicMouseMove(const MouseEvent& rMouseEvent)
+{
+}
+
+void SwEditWin::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
+{
+}
+
+void SwEditWin::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
+{
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
index ff04909..d56783a 100644
--- a/sw/source/uibase/inc/edtwin.hxx
+++ b/sw/source/uibase/inc/edtwin.hxx
@@ -302,6 +302,9 @@ public:
* @param pRegion If 0, that means the whole area, otherwise the area in logic coordinates.
*/
void LogicInvalidate(const vcl::Region* pRegion) SAL_OVERRIDE;
+ void LogicMouseMove(const MouseEvent& rMouseEvent);
+ void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
+ void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
};
#endif
More information about the Libreoffice-commits
mailing list