summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/source/lib/init.cxx46
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h17
-rw-r--r--include/vcl/IDialogRenderable.hxx8
-rw-r--r--include/vcl/dialog.hxx5
-rw-r--r--libreofficekit/Executable_gtktiledviewer.mk4
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx116
-rw-r--r--sw/inc/unotxdoc.hxx8
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx41
-rw-r--r--vcl/source/window/dialog.cxx40
9 files changed, 272 insertions, 13 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7abb8359b9f5..8246894e22dc 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -544,6 +544,11 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis,
int nType,
int nCharCode,
int nKeyCode);
+static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis,
+ const char* pDialogId,
+ int nType,
+ int nCharCode,
+ int nKeyCode);
static void doc_postMouseEvent (LibreOfficeKitDocument* pThis,
int nType,
int nX,
@@ -551,6 +556,14 @@ static void doc_postMouseEvent (LibreOfficeKitDocument* pThis,
int nCount,
int nButtons,
int nModifier);
+static void doc_postDialogMouseEvent (LibreOfficeKitDocument* pThis,
+ const char* pDialogId,
+ int nType,
+ int nX,
+ int nY,
+ int nCount,
+ int nButtons,
+ int nModifier);
static void doc_postUnoCommand(LibreOfficeKitDocument* pThis,
const char* pCommand,
const char* pArguments,
@@ -618,7 +631,9 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->initializeForRendering = doc_initializeForRendering;
m_pDocumentClass->registerCallback = doc_registerCallback;
m_pDocumentClass->postKeyEvent = doc_postKeyEvent;
+ m_pDocumentClass->postDialogKeyEvent = doc_postDialogKeyEvent;
m_pDocumentClass->postMouseEvent = doc_postMouseEvent;
+ m_pDocumentClass->postDialogMouseEvent = doc_postDialogMouseEvent;
m_pDocumentClass->postUnoCommand = doc_postUnoCommand;
m_pDocumentClass->setTextSelection = doc_setTextSelection;
m_pDocumentClass->getTextSelection = doc_getTextSelection;
@@ -2121,10 +2136,24 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nChar
gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
return;
}
-
pDoc->postKeyEvent(nType, nCharCode, nKeyCode);
}
+static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis, const char* pDialogId, int nType, int nCharCode, int nKeyCode)
+{
+ SolarMutexGuard aGuard;
+
+ IDialogRenderable* pDoc = getDialogRenderable(pThis);
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering";
+ return;
+ }
+
+ vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
+ pDoc->postDialogKeyEvent(aDialogID, nType, nCharCode, nKeyCode);
+}
+
/** Class to react on finishing of a dispatched command.
This will call a LOK_COMMAND_FINISHED callback when postUnoCommand was
@@ -2276,6 +2305,21 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
}
}
+static void doc_postDialogMouseEvent(LibreOfficeKitDocument* pThis, const char* pDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+{
+ SolarMutexGuard aGuard;
+
+ IDialogRenderable* pDoc = getDialogRenderable(pThis);
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering";
+ return;
+ }
+
+ vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
+ pDoc->postDialogMouseEvent(aDialogID, nType, nX, nY, nCount, nButtons, nModifier);
+}
+
static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
{
SolarMutexGuard aGuard;
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 46ecb6c83372..5a099f7c7f67 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -269,6 +269,23 @@ struct _LibreOfficeKitDocumentClass
/// WIP
void (*paintDialog) (LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
+ /// WIP
+ void (*postDialogKeyEvent) (LibreOfficeKitDocument* pThis,
+ const char* pDialogId,
+ int nType,
+ int nCharCode,
+ int nKeyCode);
+
+ /// WIP
+ void (*postDialogMouseEvent) (LibreOfficeKitDocument* pThis,
+ const char* pDialogId,
+ int nType,
+ int nX,
+ int nY,
+ int nCount,
+ int nButtons,
+ int nModifier);
+
#endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
};
diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx
index 2621ec03947a..cf9d41e54cde 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -33,11 +33,11 @@ public:
virtual void paintDialog(const DialogID& rDialogID, VirtualDevice &rDevice,
int& nOutputWidth, int& nOutputHeight) = 0;
- virtual void postDialogMouseEvent(const DialogID& rDialogID, int nType,
- int nCharCode, int nKeyCode) = 0;
+ virtual void postDialogKeyEvent(const DialogID& rDialogID, int nType,
+ int nCharCode, int nKeyCode) = 0;
- virtual void postDialogKeyEvent(const DialogID& rDialogID, int nType, int nX, int nY,
- int nCount, int nButtons, int nModifier) = 0;
+ virtual void postDialogMouseEvent(const DialogID& rDialogID, int nType, int nX, int nY,
+ int nCount, int nButtons, int nModifier) = 0;
};
} // namespace vcl
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 7a3aa4c0c1c0..092533c9143d 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -78,8 +78,11 @@ public:
SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; }
virtual void doDeferredInit(WinBits nBits) override;
virtual void LogicInvalidate(const tools::Rectangle* pRectangle) override { (void)pRectangle; }
- // Paints the current dialog to the given virtual device
+ /// Paints the current dialog to the given virtual device
void paintDialog(VirtualDevice& rDevice);
+ void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
+ void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
+ void LogicMouseButtonMove(const MouseEvent& rMouseEvent);
protected:
explicit Dialog( WindowType nType );
diff --git a/libreofficekit/Executable_gtktiledviewer.mk b/libreofficekit/Executable_gtktiledviewer.mk
index 55434cef376e..5dd89e6065f6 100644
--- a/libreofficekit/Executable_gtktiledviewer.mk
+++ b/libreofficekit/Executable_gtktiledviewer.mk
@@ -9,10 +9,14 @@
$(eval $(call gb_Executable_Executable,gtktiledviewer))
+$(eval $(call gb_Library_use_sdk_api,gtktiledviewer))
+
$(eval $(call gb_Executable_set_include,gtktiledviewer,\
$$(INCLUDE) \
-I$(SRCDIR)/desktop/inc \
-I$(SRCDIR)/libreofficekit/qa/gtktiledviewer/ \
+ -I$(WORKDIR)/UnoApiHeadersTarget/offapi/normal/ \
+ -I$(WORKDIR)/UnoApiHeadersTarget/udkapi/normal/ \
))
$(eval $(call gb_Executable_use_externals,gtktiledviewer,\
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index a073198e5db3..24773ebfc9a0 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -12,11 +12,17 @@
#include <cmath>
#include <iostream>
+#include <LibreOfficeKit/LibreOfficeKitGtk.h>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+
#include <gtv-application-window.hxx>
#include <gtv-signal-handlers.hxx>
#include <gtv-helpers.hxx>
#include <gtv-lok-dialog.hxx>
+#include <com/sun/star/awt/Key.hpp>
+#include <vcl/event.hxx>
+
#include <map>
#include <boost/property_tree/json_parser.hpp>
@@ -24,6 +30,11 @@ struct GtvLokDialogPrivate
{
LOKDocView* lokdocview;
GtkWidget* pDialogDrawingArea;
+
+ guint32 m_nLastButtonPressTime;
+ guint32 m_nLastButtonReleaseTime;
+ guint32 m_nKeyModifier;
+
gchar* dialogid;
};
@@ -45,6 +56,18 @@ getPrivate(GtvLokDialog* dialog)
return static_cast<GtvLokDialogPrivate*>(gtv_lok_dialog_get_instance_private(dialog));
}
+static float
+pixelToTwip(float fInput)
+{
+ return (fInput / 96 / 1.0 /* zoom */) * 1440.0f;
+}
+
+static float
+twipToPixel(float fInput)
+{
+ return fInput / 1440.0f * 96 * 1.0 /* zoom */;
+}
+
static void
gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer)
{
@@ -66,6 +89,89 @@ gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer)
cairo_paint(pCairo);
}
+static gboolean
+gtv_lok_dialog_signal_button(GtkWidget* pDialogDrawingArea, GdkEventButton* pEvent)
+{
+ GtvLokDialog* pDialog = GTV_LOK_DIALOG(gtk_widget_get_toplevel(pDialogDrawingArea));
+ GtvLokDialogPrivate* priv = getPrivate(pDialog);
+
+ GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_window_get_transient_for(GTK_WINDOW(pDialog)));
+ LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(window->lokdocview));
+
+ g_info("lok_dialog_signal_button: %d, %d (in twips: %d, %d)",
+ (int)pEvent->x, (int)pEvent->y,
+ (int)pixelToTwip(pEvent->x),
+ (int)pixelToTwip(pEvent->y));
+ gtk_widget_grab_focus(GTK_WIDGET(pDialog));
+
+ switch (pEvent->type)
+ {
+ case GDK_BUTTON_PRESS:
+ {
+ int nCount = 1;
+ if ((pEvent->time - priv->m_nLastButtonPressTime) < 250)
+ nCount++;
+ priv->m_nLastButtonPressTime = pEvent->time;
+ int nEventButton = 0;
+ switch (pEvent->button)
+ {
+ case 1:
+ nEventButton = MOUSE_LEFT;
+ break;
+ case 2:
+ nEventButton = MOUSE_MIDDLE;
+ break;
+ case 3:
+ nEventButton = MOUSE_RIGHT;
+ break;
+ }
+ pDocument->pClass->postDialogMouseEvent(pDocument,
+ priv->dialogid,
+ LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+ pixelToTwip(pEvent->x),
+ pixelToTwip(pEvent->y),
+ nCount,
+ nEventButton,
+ 0/* Modifier */);
+
+ break;
+ }
+ case GDK_BUTTON_RELEASE:
+ {
+ int nCount = 1;
+ if ((pEvent->time - priv->m_nLastButtonReleaseTime) < 250)
+ nCount++;
+ priv->m_nLastButtonReleaseTime = pEvent->time;
+ int nEventButton = 0;
+ switch (pEvent->button)
+ {
+ case 1:
+ nEventButton = MOUSE_LEFT;
+ break;
+ case 2:
+ nEventButton = MOUSE_MIDDLE;
+ break;
+ case 3:
+ nEventButton = MOUSE_RIGHT;
+ break;
+ }
+
+ pDocument->pClass->postDialogMouseEvent(pDocument,
+ priv->dialogid,
+ LOK_MOUSEEVENT_MOUSEBUTTONUP,
+ pixelToTwip(pEvent->x),
+ pixelToTwip(pEvent->y),
+ nCount,
+ nEventButton,
+ 0/* Modifier */);
+ break;
+ }
+ default:
+ break;
+ }
+ return FALSE;
+}
+
static void
gtv_lok_dialog_init(GtvLokDialog* dialog)
{
@@ -74,7 +180,17 @@ gtv_lok_dialog_init(GtvLokDialog* dialog)
GtkWidget* pContentArea = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
priv->pDialogDrawingArea = gtk_drawing_area_new();
+ priv->m_nLastButtonPressTime = 0;
+ priv->m_nLastButtonReleaseTime = 0;
+ priv->m_nKeyModifier = 0;
+
+ gtk_widget_add_events(GTK_WIDGET(priv->pDialogDrawingArea),
+ GDK_BUTTON_PRESS_MASK
+ |GDK_BUTTON_RELEASE_MASK);
+
g_signal_connect(G_OBJECT(priv->pDialogDrawingArea), "draw", G_CALLBACK(gtv_lok_dialog_draw), nullptr);
+ g_signal_connect(G_OBJECT(priv->pDialogDrawingArea), "button-press-event", G_CALLBACK(gtv_lok_dialog_signal_button), dialog);
+ g_signal_connect(G_OBJECT(priv->pDialogDrawingArea), "button-release-event", G_CALLBACK(gtv_lok_dialog_signal_button), dialog);
gtk_container_add(GTK_CONTAINER(pContentArea), priv->pDialogDrawingArea);
}
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 0f8bc11d4da5..3df958033c5e 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -432,11 +432,11 @@ public:
OUString getPostIts() override;
void paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, int& nWidth, int& nHeight) override;
- void postDialogMouseEvent(const vcl::DialogID& rDialogID, int nType,
- int nCharCode, int nKeyCode) override;
+ void postDialogKeyEvent(const vcl::DialogID& rDialogID, int nType,
+ int nCharCode, int nKeyCode) override;
- void postDialogKeyEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY,
- int nCount, int nButtons, int nModifier) override;
+ void postDialogMouseEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY,
+ int nCount, int nButtons, int nModifier) override;
// css::tiledrendering::XTiledRenderable
virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) override;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index b00047a54fbe..73bdc7e7ace1 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3667,13 +3667,48 @@ void SwXTextDocument::paintDialog(const vcl::DialogID& rDialogID, VirtualDevice&
nHeight = aSize.getHeight();
}
-void SwXTextDocument::postDialogMouseEvent(const vcl::DialogID& /*rDialogID*/, int /*nType*/, int /*nCharCode*/, int /*nKeyCode*/)
+void SwXTextDocument::postDialogKeyEvent(const vcl::DialogID& /*rDialogID*/, int /*nType*/, int /*nCharCode*/, int /*nKeyCode*/)
{
+
}
-void SwXTextDocument::postDialogKeyEvent(const vcl::DialogID& /*rDialogID*/, int /*nType*/, int /*nX*/, int /*nY*/,
- int /*nCount*/, int /*nButtons*/, int /*nModifier*/)
+void SwXTextDocument::postDialogMouseEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY,
+ int nCount, int nButtons, int nModifier)
{
+ SolarMutexGuard aGuard;
+
+ // check if dialog is already open
+ SfxViewFrame* pViewFrame = pDocShell->GetView()->GetViewFrame();
+ SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
+ const SfxSlot* pSlot = pSlotPool->GetUnoSlot(rDialogID);
+ if (!pSlot)
+ {
+ SAL_WARN("lok.dialog", "No slot found for " << rDialogID);
+ return;
+ }
+ SfxChildWindow* pChild = pViewFrame->GetChildWindow(pSlot->GetSlotId());
+ if (pChild)
+ {
+ Dialog* pDialog = static_cast<Dialog*>(pChild->GetWindow());
+ Point aPos(nX , nY);
+ MouseEvent aEvent(aPos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
+
+ switch (nType)
+ {
+ case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
+ pDialog->LogicMouseButtonDown(aEvent);
+ break;
+ case LOK_MOUSEEVENT_MOUSEBUTTONUP:
+ pDialog->LogicMouseButtonUp(aEvent);
+ break;
+ case LOK_MOUSEEVENT_MOUSEMOVE:
+ //pDialog->LogicMouseMove(aEvent);
+ break;
+ default:
+ assert(false);
+ break;
+ }
+ }
}
void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index b4e5b6a667fb..cf078750e4cc 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/util/thePathSettings.hpp>
#include <com/sun/star/frame/theGlobalEventBroadcaster.hpp>
+#include <comphelper/lok.hxx>
#include <comphelper/processfactory.hxx>
#include <osl/file.hxx>
@@ -871,6 +872,45 @@ void Dialog::paintDialog(VirtualDevice& rDevice)
PaintToDevice(&rDevice, Point(0, 0), Size());
}
+void Dialog::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
+{
+ // When we're not doing tiled rendering, then positions must be passed as pixels.
+ assert(comphelper::LibreOfficeKit::isActive());
+
+ Point aPoint = GetPointerPosPixel();
+ SetLastMousePos(rMouseEvent.GetPosPixel());
+
+ MouseButtonDown(rMouseEvent);
+
+ SetPointerPosPixel(aPoint);
+}
+
+void Dialog::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
+{
+ // When we're not doing tiled rendering, then positions must be passed as pixels.
+ assert(comphelper::LibreOfficeKit::isActive());
+
+ Point aPoint = GetPointerPosPixel();
+ SetLastMousePos(rMouseEvent.GetPosPixel());
+
+ MouseButtonUp(rMouseEvent);
+
+ SetPointerPosPixel(aPoint);
+}
+
+void Dialog::LogicMouseButtonMove(const MouseEvent& rMouseEvent)
+{
+ // When we're not doing tiled rendering, then positions must be passed as pixels.
+ assert(comphelper::LibreOfficeKit::isActive());
+
+ Point aPoint = GetPointerPosPixel();
+ SetLastMousePos(rMouseEvent.GetPosPixel());
+
+ MouseMove(rMouseEvent);
+
+ SetPointerPosPixel(aPoint);
+}
+
void Dialog::ensureRepaint()
{
// ensure repaint