[Libreoffice-commits] core.git: 2 commits - android/Bootstrap android/source desktop/source include/LibreOfficeKit include/vcl libreofficekit/qa libreofficekit/source sc/inc sc/source
Mihai Varga
mihai.varga at collabora.com
Fri Nov 13 00:00:59 PST 2015
android/Bootstrap/src/org/libreoffice/kit/Document.java | 2
android/source/src/java/org/libreoffice/LOKitThread.java | 13 +-
android/source/src/java/org/libreoffice/LOKitTileProvider.java | 11 -
android/source/src/java/org/libreoffice/TileProvider.java | 4
android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java | 4
desktop/source/lib/init.cxx | 20 +++
desktop/source/lib/lokandroid.cxx | 8 +
include/LibreOfficeKit/LibreOfficeKit.h | 7 +
include/LibreOfficeKit/LibreOfficeKit.hxx | 17 ++
include/LibreOfficeKit/LibreOfficeKitEnums.h | 7 -
include/vcl/ITiledRenderable.hxx | 18 ++
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 24 +++
libreofficekit/source/gtk/lokdocview.cxx | 63 ++++++++++
libreofficekit/source/gtk/tilebuffer.hxx | 11 +
sc/inc/docuno.hxx | 3
sc/source/ui/app/inputhdl.cxx | 8 +
sc/source/ui/unoobj/docuno.cxx | 18 ++
17 files changed, 221 insertions(+), 17 deletions(-)
New commits:
commit 5b1e22e9ba941305a7f138adcef75a464161a145
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Nov 13 09:48:14 2015 +0200
LOK: calc formula callback + formula bar implementation in gtk
We need the callback to be able implement the formula bar
Change-Id: I1c78ab0b9ed9304c0465a9993a7101f8efb91052
Conflicts:
include/LibreOfficeKit/LibreOfficeKitEnums.h
libreofficekit/source/gtk/lokdocview.cxx
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 37837ea..7b23fcb 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -209,7 +209,12 @@ typedef enum
*
* Payload is a css mouse pointer style.
*/
- LOK_CALLBACK_MOUSE_POINTER
+ LOK_CALLBACK_MOUSE_POINTER,
+
+ /**
+ * The text content of the formula bar in Calc.
+ */
+ LOK_CALLBACK_CELL_FORMULA
}
LibreOfficeKitCallbackType;
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 5935b35..b751fec 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -101,6 +101,7 @@ public:
GtkToolItem* m_pCenterpara;
GtkToolItem* m_pRightpara;
GtkToolItem* m_pJustifypara;
+ GtkWidget* m_pFormulabarEntry;
GtkWidget* m_pScrolledWindow;
std::map<GtkToolItem*, std::string> m_aToolItemCommandNames;
std::map<std::string, GtkToolItem*> m_aCommandNameToolItems;
@@ -135,6 +136,7 @@ public:
m_pCenterpara(nullptr),
m_pRightpara(nullptr),
m_pJustifypara(nullptr),
+ m_pFormulabarEntry(nullptr),
m_pScrolledWindow(nullptr),
m_bToolItemBroadcast(true),
m_pVBox(nullptr),
@@ -632,6 +634,14 @@ static gboolean signalFindbar(GtkWidget* pWidget, GdkEventKey* pEvent, gpointer
return FALSE;
}
+/// Handles the key-press-event of the formula entry widget.
+static gboolean signalFormulabar(GtkWidget* /*pWidget*/, GdkEventKey* /*pEvent*/, gpointer /*pData*/)
+{
+ // for now it just displays the callback
+ // TODO - submit the edited formula
+ return TRUE;
+}
+
/// LOKDocView changed edit state -> inform the tool button.
static void signalEdit(LOKDocView* pLOKDocView, gboolean bWasEdit, gpointer /*pData*/)
{
@@ -768,6 +778,13 @@ static void cursorChanged(LOKDocView* pDocView, gint nX, gint nY,
gtk_adjustment_set_value(hadj, lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), x));
}
+/// LOKDocView the formula has changed
+static void formulaChanged(LOKDocView* pLOKDocView, char* pPayload, gpointer /*pData*/)
+{
+ TiledWindow& rWindow = lcl_getTiledWindow(GTK_WIDGET(pLOKDocView));
+ gtk_entry_set_text((GtkEntry*)rWindow.m_pFormulabarEntry, pPayload);
+}
+
static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/)
{
TiledWindow& rWindow = lcl_getTiledWindow(pWidget);
@@ -1076,6 +1093,12 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
gtk_toolbar_insert(GTK_TOOLBAR(pLowerToolbar), rWindow.m_pJustifypara, -1);
g_signal_connect(G_OBJECT(rWindow.m_pJustifypara), "toggled", G_CALLBACK(toggleToolItem), NULL);
lcl_registerToolItem(rWindow, rWindow.m_pJustifypara, ".uno:JustifyPara");
+ // Formula bar
+ GtkToolItem* pFormulaEntryContainer = gtk_tool_item_new();
+ rWindow.m_pFormulabarEntry = gtk_entry_new();
+ gtk_container_add(GTK_CONTAINER(pFormulaEntryContainer), rWindow.m_pFormulabarEntry);
+ g_signal_connect(rWindow.m_pFormulabarEntry, "key-press-event", G_CALLBACK(signalFormulabar), 0);
+ gtk_toolbar_insert(GTK_TOOLBAR(pLowerToolbar), pFormulaEntryContainer, -1);
gtk_box_pack_start(GTK_BOX(rWindow.m_pVBox), pLowerToolbar, FALSE, FALSE, 0 ); // Adds to top.
// Findbar
@@ -1189,6 +1212,7 @@ static void setupDocView(GtkWidget* pDocView)
g_signal_connect(pDocView, "size-changed", G_CALLBACK(signalSize), NULL);
g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), NULL);
g_signal_connect(pDocView, "cursor-changed", G_CALLBACK(cursorChanged), NULL);
+ g_signal_connect(pDocView, "formula-changed", G_CALLBACK(formulaChanged), NULL);
}
int main( int argc, char* argv[] )
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index f52ba61..0a7e8b8 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -184,6 +184,7 @@ enum
CURSOR_CHANGED,
SEARCH_RESULT_COUNT,
COMMAND_RESULT,
+ FORMULA_CHANGED,
LAST_SIGNAL
};
@@ -495,6 +496,11 @@ static void commandResult(LOKDocView* pDocView, const std::string& rString)
g_signal_emit(pDocView, doc_view_signals[COMMAND_RESULT], 0, rString.c_str());
}
+static void formulaChanged(LOKDocView* pDocView, const std::string& rString)
+{
+ g_signal_emit(pDocView, doc_view_signals[FORMULA_CHANGED], 0, rString.c_str());
+}
+
static void
setPart(LOKDocView* pDocView, const std::string& rString)
{
@@ -809,6 +815,11 @@ callback (gpointer pData)
commandResult(pDocView, pCallback->m_aPayload);
}
break;
+ case LOK_CALLBACK_CELL_FORMULA:
+ {
+ formulaChanged(pDocView, pCallback->m_aPayload);
+ }
+ break;
default:
g_assert(false);
break;
@@ -2248,6 +2259,20 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
G_TYPE_NONE, 1,
G_TYPE_STRING);
+ /**
+ * LOKDocView::formula-changed:
+ * @pDocView: the #LOKDocView on which the signal is emitted
+ * @aCommand: formula text content
+ */
+ doc_view_signals[FORMULA_CHANGED] =
+ g_signal_new("formula-changed",
+ G_TYPE_FROM_CLASS(pGObjectClass),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
}
SAL_DLLPUBLIC_EXPORT GtkWidget*
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 070c94a..4138bad 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -52,6 +52,7 @@
#include <tools/urlobj.hxx>
#include <comphelper/string.hxx>
#include <formula/formulahelper.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include "inputwin.hxx"
#include "tabvwsh.hxx"
@@ -2131,6 +2132,11 @@ void ScInputHandler::DataChanged( bool bFromTopNotify, bool bSetModified )
if ( pInputWin )
pInputWin->SetTextString( aText );
+
+ ScDocShell* pDocSh = pActiveViewSh->GetViewData().GetDocShell();
+ ScDocument& rDoc = pDocSh->GetDocument();
+ if ( rDoc.GetDrawLayer()->isTiledRendering() )
+ rDoc.GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_CELL_FORMULA, aText.toUtf8().getStr());
}
// If the cursor is before the end of a paragraph, parts are being pushed to
@@ -3466,6 +3472,8 @@ void ScInputHandler::NotifyChange( const ScInputHdlState* pState,
if ( pInputWin )
pInputWin->SetTextString(aString);
+ else if ( rDoc.GetDrawLayer()->isTiledRendering() )
+ rDoc.GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_CELL_FORMULA, aString.toUtf8().getStr());
}
if ( pInputWin ) // Named range input
commit 96cd2abd748ed24e5aba50cc4c300cf06e512db3
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Nov 6 14:34:28 2015 +0200
LOK: setClientZoom() - sets the client zoom level
We need to know the client's view level to correctly handle the mouse
events in calc. PaintTile() set a zoom level that corresponds to the
requested tiles and previously postMouseEvent would call SetZoom(1,1).
Now we can make use of knowing the client's view level and call
SetZoom() with the correct parameters
Change-Id: I34b5afcdcc06a671a8ac92c03e87404e42adf4cd
Conflicts:
sc/source/ui/unoobj/docuno.cxx
diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java
index 4cc4ba3..dcc315f 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/Document.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java
@@ -143,6 +143,8 @@ public class Document {
private native int getDocumentTypeNative();
+ public native void setClientZoom(int nTilePixelWidth, int nTilePixelHeight, int nTileTwipWidth, int nTileTwipHeight);
+
private native void saveAs(String url, String format, String options);
private native void paintTileNative(ByteBuffer buffer, int canvasWidth, int canvasHeight, int tilePositionX, int tilePositionY, int tileWidth, int tileHeight);
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index a8f4d30..978056d 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -299,17 +299,18 @@ public class LOKitThread extends Thread {
// to handle hyperlinks, enable single tap even in the Viewer
boolean editing = LOKitShell.isEditingEnabled();
+ float zoomFactor = mViewportMetrics.getZoomFactor();
if (touchType.equals("LongPress") && editing) {
mInvalidationHandler.changeStateTo(InvalidationHandler.OverlayState.TRANSITION);
- mTileProvider.mouseButtonDown(documentCoordinate, 1);
- mTileProvider.mouseButtonUp(documentCoordinate, 1);
- mTileProvider.mouseButtonDown(documentCoordinate, 2);
- mTileProvider.mouseButtonUp(documentCoordinate, 2);
+ mTileProvider.mouseButtonDown(documentCoordinate, 1, zoomFactor);
+ mTileProvider.mouseButtonUp(documentCoordinate, 1, zoomFactor);
+ mTileProvider.mouseButtonDown(documentCoordinate, 2, zoomFactor);
+ mTileProvider.mouseButtonUp(documentCoordinate, 2, zoomFactor);
} else if (touchType.equals("SingleTap")) {
mInvalidationHandler.changeStateTo(InvalidationHandler.OverlayState.TRANSITION);
- mTileProvider.mouseButtonDown(documentCoordinate, 1);
- mTileProvider.mouseButtonUp(documentCoordinate, 1);
+ mTileProvider.mouseButtonDown(documentCoordinate, 1, zoomFactor);
+ mTileProvider.mouseButtonUp(documentCoordinate, 1, zoomFactor);
} else if (touchType.equals("GraphicSelectionStart") && editing) {
mTileProvider.setGraphicSelectionStart(documentCoordinate);
} else if (touchType.equals("GraphicSelectionEnd") && editing) {
diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
index f859b7a..b70e852 100644
--- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
@@ -397,10 +397,11 @@ public class LOKitTileProvider implements TileProvider {
}
}
- private void mouseButton(int type, PointF inDocument, int numberOfClicks) {
+ private void mouseButton(int type, PointF inDocument, int numberOfClicks, float zoomFactor) {
int x = (int) pixelToTwip(inDocument.x, mDPI);
int y = (int) pixelToTwip(inDocument.y, mDPI);
+ mDocument.setClientZoom(TILE_SIZE, TILE_SIZE, (int) (mTileWidth / zoomFactor), (int) (mTileHeight / zoomFactor));
mDocument.postMouseEvent(type, x, y, numberOfClicks, Document.MOUSE_BUTTON_LEFT, Document.KEYBOARD_MODIFIER_NONE);
}
@@ -408,16 +409,16 @@ public class LOKitTileProvider implements TileProvider {
* @see TileProvider#mouseButtonDown(android.graphics.PointF, int)
*/
@Override
- public void mouseButtonDown(PointF documentCoordinate, int numberOfClicks) {
- mouseButton(Document.MOUSE_EVENT_BUTTON_DOWN, documentCoordinate, numberOfClicks);
+ public void mouseButtonDown(PointF documentCoordinate, int numberOfClicks, float zoomFactor) {
+ mouseButton(Document.MOUSE_EVENT_BUTTON_DOWN, documentCoordinate, numberOfClicks, zoomFactor);
}
/**
* @see TileProvider#mouseButtonUp(android.graphics.PointF, int)
*/
@Override
- public void mouseButtonUp(PointF documentCoordinate, int numberOfClicks) {
- mouseButton(Document.MOUSE_EVENT_BUTTON_UP, documentCoordinate, numberOfClicks);
+ public void mouseButtonUp(PointF documentCoordinate, int numberOfClicks, float zoomFactor) {
+ mouseButton(Document.MOUSE_EVENT_BUTTON_UP, documentCoordinate, numberOfClicks, zoomFactor);
}
@Override
diff --git a/android/source/src/java/org/libreoffice/TileProvider.java b/android/source/src/java/org/libreoffice/TileProvider.java
index 3104172..0ab5a1f 100644
--- a/android/source/src/java/org/libreoffice/TileProvider.java
+++ b/android/source/src/java/org/libreoffice/TileProvider.java
@@ -88,7 +88,7 @@ public interface TileProvider {
* @param documentCoordinate - coordinate relative to the document where the mouse button should be triggered
* @param numberOfClicks - number of clicks (1 - single click, 2 - double click)
*/
- void mouseButtonDown(PointF documentCoordinate, int numberOfClicks);
+ void mouseButtonDown(PointF documentCoordinate, int numberOfClicks, float zoomFactor);
/**
@@ -107,7 +107,7 @@ public interface TileProvider {
* @param documentCoordinate - coordinate relative to the document where the mouse button should be triggered
* @param numberOfClicks - number of clicks (1 - single click, 2 - double click)
*/
- void mouseButtonUp(PointF documentCoordinate, int numberOfClicks);
+ void mouseButtonUp(PointF documentCoordinate, int numberOfClicks, float zoomFactor);
/**
* Post a UNO command to LOK.
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java b/android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java
index 35b4175..f90580f 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java
@@ -106,6 +106,10 @@ public class ImmutableViewportMetrics {
return new RectF(cssPageRectLeft, cssPageRectTop, cssPageRectRight, cssPageRectBottom);
}
+ public float getZoomFactor() {
+ return zoomFactor;
+ }
+
/*
* Returns the viewport metrics that represent a linear transition between "this" and "to" at
* time "t", which is on the scale [0, 1). This function interpolates all values stored in
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e33544a..94b81e0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -318,7 +318,11 @@ static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis,
int nY);
static void doc_resetSelection (LibreOfficeKitDocument* pThis);
static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCommand);
-
+static void doc_setClientZoom(LibreOfficeKitDocument* pThis,
+ int nTilePixelWidth,
+ int nTilePixelHeight,
+ int nTileTwipWidth,
+ int nTileTwipHeight);
static int doc_createView(LibreOfficeKitDocument* pThis);
static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
@@ -358,6 +362,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->setGraphicSelection = doc_setGraphicSelection;
m_pDocumentClass->resetSelection = doc_resetSelection;
m_pDocumentClass->getCommandValues = doc_getCommandValues;
+ m_pDocumentClass->setClientZoom = doc_setClientZoom;
m_pDocumentClass->createView = doc_createView;
m_pDocumentClass->destroyView = doc_destroyView;
@@ -1470,6 +1475,19 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
}
}
+static void doc_setClientZoom(LibreOfficeKitDocument* pThis, int nTilePixelWidth, int nTilePixelHeight,
+ int nTileTwipWidth, int nTileTwipHeight)
+{
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return;
+ }
+
+ pDoc->setClientZoom(nTilePixelWidth, nTilePixelHeight, nTileTwipWidth, nTileTwipHeight);
+}
+
static int doc_createView(LibreOfficeKitDocument* /*pThis*/)
{
SolarMutexGuard aGuard;
diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx
index 017ab8a..0c360d3 100644
--- a/desktop/source/lib/lokandroid.cxx
+++ b/desktop/source/lib/lokandroid.cxx
@@ -358,4 +358,12 @@ extern "C" SAL_JNI_EXPORT jstring JNICALL Java_org_libreoffice_kit_Document_getC
return pEnv->NewStringUTF(pValue);
}
+
+extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_setClientZoom
+ (JNIEnv* pEnv, jobject aObject, jint nTilePixelWidth, jint nTilePixelHeight, jint nTileTwipWidth, jint nTileTwipHeight)
+{
+ LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
+ pDocument->pClass->setClientZoom(pDocument, nTilePixelWidth, nTilePixelHeight, nTileTwipWidth, nTileTwipHeight);
+
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index c887f5f..0321037 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -181,6 +181,13 @@ struct _LibreOfficeKitDocumentClass
/// @see lok::Document::getCommandValues().
char* (*getCommandValues) (LibreOfficeKitDocument* pThis, const char* pCommand);
+ /// @see lok::Document::setClientZoom().
+ void (*setClientZoom) (LibreOfficeKitDocument* pThis,
+ int nTilePixelWidth,
+ int nTilePixelHeight,
+ int nTileTwipWidth,
+ int nTileTwipHeight);
+
/// @see lok::Document::createView().
int (*createView) (LibreOfficeKitDocument* pThis);
/// @see lok::Document::destroyView().
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index fe8c4d1..d21abdd 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -294,6 +294,23 @@ public:
}
/**
+ * Save the client's view so that we can compute the right zoom level
+ * for the mouse events. This only affects CALC.
+ * @param nTilePixelWidth - tile width in pixels
+ * @param nTilePixelHeight - tile height in pixels
+ * @param nTileTwipWidth - tile width in twips
+ * @param nTileTwipHeight - tile height in twips
+ */
+ inline void setClientZoom(
+ int nTilePixelWidth,
+ int nTilePixelHeight,
+ int nTileTwipWidth,
+ int nTileTwipHeight)
+ {
+ mpDoc->pClass->setClientZoom(mpDoc, nTilePixelWidth, nTilePixelHeight, nTileTwipWidth, nTileTwipHeight);
+ }
+
+ /**
* Create a new view for an existing document.
* By default a loaded document has 1 view.
* @return the ID of the new view.
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 99c31b8..e1cdf83 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -23,6 +23,9 @@ namespace vcl
class VCL_DLLPUBLIC ITiledRenderable
{
+protected:
+ int nTilePixelWidth, nTilePixelHeight;
+ int nTileTwipWidth, nTileTwipHeight;
public:
virtual ~ITiledRenderable();
@@ -180,6 +183,21 @@ public:
/// If the current contents of the clipboard is something we can paste.
virtual bool isMimeTypeSupported() = 0;
+
+ /**
+ * Save the client's view so that we can compute the right zoom level
+ * for the mouse events.
+ * @param nTilePixelWidth - tile width in pixels
+ * @param nTilePixelHeight - tile height in pixels
+ * @param nTileTwipWidth - tile width in twips
+ * @param nTileTwipHeight - tile height in twips
+ */
+ virtual void setClientZoom(int /*nTilePixelWidth*/,
+ int /*nTilePixelHeight*/,
+ int /*nTileTwipWidth*/,
+ int /*nTileTwipHeight*/)
+ {
+ }
};
} // namespace vcl
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 550a922..f52ba61 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1506,6 +1506,23 @@ setGraphicSelectionInThread(gpointer data)
}
static void
+setClientZoomInThread(gpointer data)
+{
+ GTask* task = G_TASK(data);
+ LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
+ LOKDocViewPrivate& priv = getPrivate(pDocView);
+ LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
+
+ if (!priv->m_pDocument)
+ return;
+ priv->m_pDocument->pClass->setClientZoom(priv->m_pDocument,
+ pLOEvent->m_nTilePixelWidth,
+ pLOEvent->m_nTilePixelHeight,
+ pLOEvent->m_nTileTwipWidth,
+ pLOEvent->m_nTileTwipHeight);
+}
+
+static void
postMouseEventInThread(gpointer data)
{
GTask* task = G_TASK(data);
@@ -1721,6 +1738,9 @@ lokThreadFunc(gpointer data, gpointer /*user_data*/)
case LOK_SET_GRAPHIC_SELECTION:
setGraphicSelectionInThread(task);
break;
+ case LOK_SET_CLIENT_ZOOM:
+ setClientZoomInThread(task);
+ break;
}
g_object_unref(task);
@@ -2301,6 +2321,7 @@ SAL_DLLPUBLIC_EXPORT void
lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
{
LOKDocViewPrivate& priv = getPrivate(pDocView);
+ GError* error = NULL;
priv->m_fZoom = fZoom;
long nDocumentWidthPixels = twipToPixel(priv->m_nDocumentWidthTwips, fZoom);
@@ -2313,6 +2334,23 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
gtk_widget_set_size_request(GTK_WIDGET(pDocView),
nDocumentWidthPixels,
nDocumentHeightPixels);
+
+ // Update the client's view size
+ GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
+ LOEvent* pLOEvent = new LOEvent(LOK_SET_CLIENT_ZOOM);
+ pLOEvent->m_nTilePixelWidth = nTileSizePixels;
+ pLOEvent->m_nTilePixelHeight = nTileSizePixels;
+ pLOEvent->m_nTileTwipWidth = pixelToTwip(nTileSizePixels, fZoom);
+ pLOEvent->m_nTileTwipHeight = pixelToTwip(nTileSizePixels, fZoom);
+ g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
+
+ g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), &error);
+ if (error != NULL)
+ {
+ g_warning("Unable to call LOK_SET_CLIENT_ZOOM: %s", error->message);
+ g_clear_error(&error);
+ }
+ g_object_unref(task);
}
SAL_DLLPUBLIC_EXPORT float
diff --git a/libreofficekit/source/gtk/tilebuffer.hxx b/libreofficekit/source/gtk/tilebuffer.hxx
index 7d7160e..c8f401d 100644
--- a/libreofficekit/source/gtk/tilebuffer.hxx
+++ b/libreofficekit/source/gtk/tilebuffer.hxx
@@ -157,7 +157,8 @@ enum
LOK_POST_KEY,
LOK_PAINT_TILE,
LOK_POST_MOUSE_EVENT,
- LOK_SET_GRAPHIC_SELECTION
+ LOK_SET_GRAPHIC_SELECTION,
+ LOK_SET_CLIENT_ZOOM
};
enum
@@ -231,6 +232,14 @@ struct LOEvent
int m_nSetGraphicSelectionY;
///@}
+ /// @name setClientView parameters
+ ///@{
+ int m_nTilePixelWidth;
+ int m_nTilePixelHeight;
+ int m_nTileTwipWidth;
+ int m_nTileTwipHeight;
+ ///@}
+
/// Constructor to instantiate an object of type `type`.
LOEvent(int type)
: m_nType(type)
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index c208db3..4c79af8 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -405,6 +405,9 @@ public:
/// @see vcl::ITiledRenderable::isMimeTypeSupported().
virtual bool isMimeTypeSupported() override;
+ /// @see vcl::ITiledRenderable::setClientZoom().
+ virtual void setClientZoom(int nTilePixelWidth, int nTilePixelHeight, int nTileTwipWidth, int nTileTwipHeight) override;
+
/// @see vcl::ITiledRenderable::getRowColumnHeaders().
virtual OUString getRowColumnHeaders(const Rectangle& rRectangle) override;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index b3f80b2..01ca52d 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -604,7 +604,8 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButt
return;
// update the aLogicMode in ScViewData to something predictable
- pViewData->SetZoom(Fraction(1, 1), Fraction(1, 1), true);
+ pViewData->SetZoom(Fraction(nTilePixelWidth * TWIPS_PER_PIXEL, nTileTwipWidth),
+ Fraction(nTilePixelHeight * TWIPS_PER_PIXEL, nTileTwipHeight), true);
// Calc operates in pixels...
MouseEvent aEvent(Point(nX * pViewData->GetPPTX(), nY * pViewData->GetPPTY()), nCount,
@@ -872,6 +873,14 @@ bool ScModelObj::isMimeTypeSupported()
return EditEngine::HasValidData(aDataHelper.GetTransferable());
}
+void ScModelObj::setClientZoom(int nTilePixelWidth_, int nTilePixelHeight_, int nTileTwipWidth_, int nTileTwipHeight_)
+{
+ nTilePixelWidth = nTilePixelWidth_;
+ nTilePixelHeight = nTilePixelHeight_;
+ nTileTwipWidth = nTileTwipWidth_;
+ nTileTwipHeight = nTileTwipHeight_;
+}
+
OUString ScModelObj::getRowColumnHeaders(const Rectangle& rRectangle)
{
ScViewData* pViewData = ScDocShell::GetViewData();
@@ -930,6 +939,13 @@ void ScModelObj::initializeForTiledRendering()
// tdf#93154: in tiled rendering LO doesn't always detect changes
SvtMiscOptions aMiscOpt;
aMiscOpt.SetSaveAlwaysAllowed(true);
+
+ // default tile size in pixels
+ nTilePixelWidth = 256;
+ nTilePixelHeight = 256;
+ // the default zoom level will be 1
+ nTileTwipWidth = nTilePixelWidth * TWIPS_PER_PIXEL;
+ nTileTwipHeight = nTilePixelHeight * TWIPS_PER_PIXEL;
}
uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
More information about the Libreoffice-commits
mailing list