[Libreoffice-commits] core.git: libreofficekit/source

2022-11-15 Thread Mike Kaganski (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 32aa6697c0b9f0ef490f42165a6b777c2b800da4
Author: Mike Kaganski 
AuthorDate: Tue Nov 15 11:04:18 2022 +0300
Commit: Mike Kaganski 
CommitDate: Tue Nov 15 10:11:06 2022 +0100

gtktiledviewer: Don't call updateClientZoom until zoom is initialized

Avoids some console noise

Change-Id: I521e430eeabe8fcf5012834dc7be7af8c0ce418b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142724
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 451a373d416b..4fc6fe0452c1 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2840,6 +2840,8 @@ static gboolean spin_lok_loop(void *pData)
 static void updateClientZoom(LOKDocView *pDocView)
 {
 LOKDocViewPrivate& priv = getPrivate(pDocView);
+if (!priv->m_fZoom)
+return; // Not initialized yet?
 gint nScaleFactor = gtk_widget_get_scale_factor(GTK_WIDGET(pDocView));
 gint nTileSizePixelsScaled = nTileSizePixels * nScaleFactor;
 GError* error = nullptr;


[Libreoffice-commits] core.git: libreofficekit/source vcl/source

2022-10-28 Thread Mike Kaganski (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |   16 ++--
 vcl/source/app/svapp.cxx |2 ++
 2 files changed, 8 insertions(+), 10 deletions(-)

New commits:
commit 616e95c7044e8ea4fe3396dfa22c4ef7e9d4cd32
Author: Mike Kaganski 
AuthorDate: Fri Oct 28 13:04:00 2022 +0300
Commit: Mike Kaganski 
CommitDate: Fri Oct 28 13:59:36 2022 +0200

lok: You can't assume that destroyView would only destroy one view

In case you have some in-place clients (e.g., Math in-place editing
is active), destroying the parent view would also destroy children,
and then both numberOfViewsChanged (called from doc_destroyView)
must tolerate 0 as a valid input, and lok_doc_view_destroy must
make sure to destroy the document after the last views had gone.

Change-Id: I32370fea49da0969e1fbbf971a397c4d657ec8f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141963
Reviewed-by: Michael Meeks 
Tested-by: Jenkins

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index f52330bcbd56..451a373d416b 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2771,17 +2771,13 @@ static void lok_doc_view_destroy (GtkWidget* widget)
 
 if (priv->m_pDocument)
 {
-if (priv->m_pDocument->pClass->getViewsCount(priv->m_pDocument) > 1)
+// This call may drop several views - e.g., embedded OLE in-place 
clients
+priv->m_pDocument->pClass->destroyView(priv->m_pDocument, 
priv->m_nViewId);
+if (priv->m_pDocument->pClass->getViewsCount(priv->m_pDocument) == 0)
 {
-priv->m_pDocument->pClass->destroyView(priv->m_pDocument, 
priv->m_nViewId);
-}
-else
-{
-if (priv->m_pDocument)
-{
-priv->m_pDocument->pClass->destroy (priv->m_pDocument);
-priv->m_pDocument = nullptr;
-}
+// Last view(s) gone
+priv->m_pDocument->pClass->destroy (priv->m_pDocument);
+priv->m_pDocument = nullptr;
 if (priv->m_pOffice)
 {
 priv->m_pOffice->pClass->destroy (priv->m_pOffice);
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 6fb299f82a0f..6dfa35c61551 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1830,6 +1830,8 @@ bool isUnipoll()
 
 void numberOfViewsChanged(int count)
 {
+if (count == 0)
+return;
 ImplSVData * pSVData = ImplGetSVData();
 auto& rCache = pSVData->maGDIData.maScaleCache;
 // Normally the cache size is set to 10, scale according to the number of 
users.


[Libreoffice-commits] core.git: libreofficekit/source sw/source

2022-10-25 Thread Mike Kaganski (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |   79 +--
 sw/source/uibase/uno/unotxdoc.cxx|5 -
 2 files changed, 25 insertions(+), 59 deletions(-)

New commits:
commit 2e34b2f32586947ca1e93dee9ab482372d604d10
Author: Mike Kaganski 
AuthorDate: Tue Oct 25 11:49:55 2022 +0200
Commit: Mike Kaganski 
CommitDate: Tue Oct 25 16:31:01 2022 +0200

Consistently set document view also for zoom event

And extract this code to a dedicated function.

The problem was, that creating a new view sets the document's current
view shell (in SwViewGlueDocShell); upon destruction, document's view
shell is set to nullptr. In desktop case, document view shell is then
reset to another active shell e.g. inside "grab focus" event, which
makes all following operations safe. But in gtktiledviewer case, the
"grab focus" event is not handled, so setClientZoomInThread resulted
in eventual nullptr dereference.

It was workarounded in commit 25de85bc3ce2d2f9b7736f65492f42579048da27
  Date   Fri Oct 21 21:14:04 2022 +0200
nullptr check

but that was not the proper fix.

Possibly it could also be reasonable to start handling "focus-in-event"
[1] in gtktiledviewer; but since just setting the view consistently in
setClientZoomInThread solves the problem, it looks excessive.

This reverts commit 25de85bc3ce2d2f9b7736f65492f42579048da27.

[1] https://docs.gtk.org/gtk3/signal.Widget.focus-in-event.html

Change-Id: Iac4ff4e9b043aec0e0af6ed811c0e7f018378271
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141753
Tested-by: Mike Kaganski 
Reviewed-by: Mike Kaganski 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 0486d16e9213..fba48d9293ef 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -258,6 +258,15 @@ struct LOKDocViewPrivateImpl
 }
 };
 
+// Must be run with g_aLOKMutex locked
+void setDocumentView(LibreOfficeKitDocument* pDoc, int viewId)
+{
+assert(pDoc);
+std::stringstream ss;
+ss << "lok::Document::setView(" << viewId << ")";
+g_info("%s", ss.str().c_str());
+pDoc->pClass->setView(pDoc, viewId);
+}
 }
 
 /// Wrapper around LOKDocViewPrivateImpl, managed by malloc/memset/free.
@@ -596,10 +605,8 @@ postKeyEventInThread(gpointer data)
 gint nTileSizePixelsScaled = nTileSizePixels * nScaleFactor;
 
 std::scoped_lock aGuard(g_aLOKMutex);
+setDocumentView(priv->m_pDocument, priv->m_nViewId);
 std::stringstream ss;
-ss << "lok::Document::setView(" << priv->m_nViewId << ")";
-g_info("%s", ss.str().c_str());
-priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
 
 if (priv->m_nTileSizeTwips)
 {
@@ -2172,10 +2179,7 @@ lok_doc_view_signal_motion (GtkWidget* pWidget, 
GdkEventMotion* pEvent)
 GError* error = nullptr;
 
 std::unique_lock aGuard(g_aLOKMutex);
-std::stringstream ss;
-ss << "lok::Document::setView(" << priv->m_nViewId << ")";
-g_info("%s", ss.str().c_str());
-priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
+setDocumentView(priv->m_pDocument, priv->m_nViewId);
 if (priv->m_bInDragMiddleHandle)
 {
 g_info("lcl_signalMotion: dragging the middle handle");
@@ -2273,11 +2277,8 @@ setGraphicSelectionInThread(gpointer data)
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
 std::scoped_lock aGuard(g_aLOKMutex);
+setDocumentView(priv->m_pDocument, priv->m_nViewId);
 std::stringstream ss;
-ss << "lok::Document::setView(" << priv->m_nViewId << ")";
-g_info("%s", ss.str().c_str());
-priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
-ss.str(std::string());
 ss << "lok::Document::setGraphicSelection(" << 
pLOEvent->m_nSetGraphicSelectionType;
 ss << ", " << pLOEvent->m_nSetGraphicSelectionX;
 ss << ", " << pLOEvent->m_nSetGraphicSelectionY << ")";
@@ -2297,6 +2298,7 @@ setClientZoomInThread(gpointer data)
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
 std::scoped_lock aGuard(g_aLOKMutex);
+setDocumentView(priv->m_pDocument, priv->m_nViewId);
 priv->m_pDocument->pClass->setClientZoom(priv->m_pDocument,
  pLOEvent->m_nTilePixelWidth,
  pLOEvent->m_nTilePixelHeight,
@@ -2313,11 +2315,8 @@ postMouseEventInThread(gpointer data)
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
 std::scoped_lock aGuard(g_aLOKMutex);
+setDocumentView(priv->m_pDocument, priv->m_nViewId);
 std::stringstream ss;
-ss << "lok::Document::setView(" << priv->m_nViewId << ")";
-g_info("%s", ss.str().c_str());
-priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
-ss.str(std::string());
 ss << 

[Libreoffice-commits] core.git: libreofficekit/source vcl/headless vcl/inc vcl/README.scheduler.md

2021-11-30 Thread Jan-Marek Glogowski (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |9 +
 vcl/README.scheduler.md  |7 +
 vcl/headless/svpinst.cxx |  148 ---
 vcl/inc/headless/svpinst.hxx |1 
 4 files changed, 89 insertions(+), 76 deletions(-)

New commits:
commit 5fbc7ab55a119504fc484cef28de52b6d5cf8b12
Author: Jan-Marek Glogowski 
AuthorDate: Fri Jun 25 09:55:20 2021 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Tue Nov 30 20:39:33 2021 +0100

svp: normalize DoYield

I somehow missed / forgot, that SvpInstance::DoYield was now also
yielding on the main thread and doesn't try to do "funky" multi-
threaded event processing anymore (because it's no GUI), since
commit 0efd06de8fca4036c4132b2745a11273b1755df2 ("vcl: fix hangs
in SvpSalInstance"),

So this just moves the main thread part into ImplYield and
implements DoYield like on all other architectures, as described
in README.scheduler.

I've tried to fix the LOK poll to be more sensible.

Change-Id: I4323685aa250e9d62a2f448cef358a7aa8ae862c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117899
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 015995016a36..2d7852f3781e 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2729,16 +2729,17 @@ static gboolean timeout_wakeup(void *)
 // integrate our mainloop with LOK's
 static int lok_poll_callback(void*, int timeoutUs)
 {
-if (timeoutUs)
+bool bWasEvent(false);
+if (timeoutUs > 0)
 {
 guint timeout = g_timeout_add(timeoutUs / 1000, timeout_wakeup, 
nullptr);
-g_main_context_iteration(nullptr, true);
+bWasEvent = g_main_context_iteration(nullptr, true);
 g_source_remove(timeout);
 }
 else
-g_main_context_iteration(nullptr, FALSE);
+bWasEvent = g_main_context_iteration(nullptr, timeoutUs < 0);
 
-return 0;
+return bWasEvent ? 1 : 0;
 }
 
 // thread-safe wakeup of our mainloop
diff --git a/vcl/README.scheduler.md b/vcl/README.scheduler.md
index ae62f10d04a3..bfaf53e017d0 100644
--- a/vcl/README.scheduler.md
+++ b/vcl/README.scheduler.md
@@ -130,11 +130,16 @@ There are three types of events, with different priority:
 They should be processed according to the following code:
 
 ```
-bool DoYield( bool bWait, bool bAllCurrent )
+bool ImplYield(bool bWait, bool bAllCurrent)
 {
+DBG_TESTSOLARMUTEX();
+assert(IsMainThread());
+
 bool bWasEvent = ProcessUserEvents( bAllCurrent );
 if ( !bAllCurrent && bWasEvent )
 return true;
+
+SolarMutexReleaser();
 bWasEvent = ProcessSystemEvents( bAllCurrent,  ) || 
bWasEvent;
 if ( !bWasSchedulerEvent && IsSchedulerEvent() )
 {
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index b573f756f411..a42b788a8249 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -56,6 +56,7 @@
 // FIXME: remove when we re-work the svp mainloop
 #include 
 #include 
+#include 
 
 SvpSalInstance* SvpSalInstance::s_pDefaultInstance = nullptr;
 
@@ -404,7 +405,7 @@ sal_uInt32 SvpSalYieldMutex::doRelease(bool const 
bUnlockAll)
 if (vcl::lok::isUnipoll())
 {
 if (pInst)
-pInst->Wakeup(SvpRequest::NONE);
+pInst->Wakeup();
 }
 else
 {
@@ -420,13 +421,9 @@ sal_uInt32 SvpSalYieldMutex::doRelease(bool const 
bUnlockAll)
 bool SvpSalYieldMutex::IsCurrentThread() const
 {
 if (GetSalData()->m_pInstance->IsMainThread() && m_bNoYieldLock)
-{
 return true;
-}
 else
-{
 return SalYieldMutex::IsCurrentThread();
-}
 }
 
 bool SvpSalInstance::IsMainThread() const
@@ -443,94 +440,103 @@ void SvpSalInstance::updateMainThread()
 }
 }
 
-bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents)
+bool SvpSalInstance::ImplYield(bool bWait, bool bHandleAllCurrentEvents)
 {
 DBG_TESTSVPYIELDMUTEX();
+DBG_TESTSOLARMUTEX();
+assert(IsMainThread());
 
-// first, process current user events
-bool bEvent = DispatchUserEvents(bHandleAllCurrentEvents);
-if (!bHandleAllCurrentEvents && bEvent)
+bool bWasEvent = DispatchUserEvents(bHandleAllCurrentEvents);
+if (!bHandleAllCurrentEvents && bWasEvent)
 return true;
 
-ImplSVData* pSVData = ImplGetSVData();
+bWasEvent = CheckTimeout() || bWasEvent;
+const bool bMustSleep = bWait && !bWasEvent;
 
-bool bTimeout = CheckTimeout();
-bool bSkipPoll = bEvent;
-if (pSVData->mpPollCallback == nullptr)
-bSkipPoll = bEvent || bTimeout;
-// else - give the poll-callback visibility into waiting timeouts too.
+// This is wrong and must be removed!
+// We always want to drop the SolarMutex on yield; that is the 

[Libreoffice-commits] core.git: libreofficekit/source

2021-11-08 Thread Miklos Vajna (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 4a9ccc24b65070729720bc121cdc281fff96c302
Author: Miklos Vajna 
AuthorDate: Mon Nov 8 14:54:54 2021 +0100
Commit: Miklos Vajna 
CommitDate: Mon Nov 8 15:46:29 2021 +0100

libreofficekit: fix lokdocview crash on startup

Regression from commit 1597cc5b3e07dd24cb4cb10b35b1e93545e4b929
(convert #defines to OUStringLiteral, 2021-07-29), the problem is that
this the new path was

instdir/programhandle_image_middle.png

instead of the old:

instdir/program/../share/libreofficekit/handle_image_middle.png

This is external code, just revert back to the old code.

Change-Id: I816e67091a2cd6bf07138a5166363803022bab8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124869
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index b0fffd490219..41b8f0cc320a 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -35,7 +35,7 @@
 #endif
 
 // Cursor bitmaps from the installation set.
-constexpr OUStringLiteral CURSOR_HANDLE_DIR = u"/../share/libreofficekit/";
+#define CURSOR_HANDLE_DIR "/../share/libreofficekit/"
 // Number of handles around a graphic selection.
 #define GRAPHIC_HANDLE_COUNT 8
 // Maximum Zoom allowed


[Libreoffice-commits] core.git: libreofficekit/source

2021-03-21 Thread Caolán McNamara (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 9456a764a98daa2915f6fefac336d8bb5cff531a
Author: Caolán McNamara 
AuthorDate: Sun Mar 21 14:38:36 2021 +
Commit: Caolán McNamara 
CommitDate: Sun Mar 21 20:44:59 2021 +0100

cid#1474127 Unchecked return value from library

Change-Id: I6dac6f24d33ce4557ab94ff08357e597819510d5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112839
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 832d799b1b7a..156224b57351 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2788,10 +2788,10 @@ static gboolean lok_doc_view_initable_init (GInitable 
*initable, GCancellable* /
 return true;
 
 if (priv->m_bUnipoll)
-g_setenv("SAL_LOK_OPTIONS", "unipoll", FALSE);
+(void)g_setenv("SAL_LOK_OPTIONS", "unipoll", FALSE);
 
 static const char testingLangs[] = "de_DE en_GB en_US es_ES fr_FR it nl 
pt_BR pt_PT ru";
-g_setenv("LOK_ALLOWLIST_LANGUAGES", testingLangs, FALSE);
+(void)g_setenv("LOK_ALLOWLIST_LANGUAGES", testingLangs, FALSE);
 
 priv->m_pOffice = lok_init_2(priv->m_aLOPath.c_str(), 
priv->m_aUserProfileURL.empty() ? nullptr : priv->m_aUserProfileURL.c_str());
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2021-03-21 Thread Caolán McNamara (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |   14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

New commits:
commit da86cd492c5a04c42086985e17ae84d63bdedd0b
Author: Caolán McNamara 
AuthorDate: Sat Mar 20 20:14:43 2021 +
Commit: Caolán McNamara 
CommitDate: Sun Mar 21 15:32:55 2021 +0100

cid#1478187 Resource leak

Change-Id: Ib63d25e358f81c428fcbbb502650c37d016b6b44
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112821
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 2a4b90cc8de5..832d799b1b7a 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -991,19 +991,28 @@ payloadToRectangle (LOKDocView* pDocView, const char* 
pPayload)
 aRet.width = aRet.height = aRet.x = aRet.y = 0;
 
 if (!*ppCoordinate)
+{
+g_strfreev(ppCoordinates);
 return aRet;
+}
 aRet.x = atoi(*ppCoordinate);
 if (aRet.x < 0)
 aRet.x = 0;
 ++ppCoordinate;
 if (!*ppCoordinate)
+{
+g_strfreev(ppCoordinates);
 return aRet;
+}
 aRet.y = atoi(*ppCoordinate);
 if (aRet.y < 0)
 aRet.y = 0;
 ++ppCoordinate;
 if (!*ppCoordinate)
+{
+g_strfreev(ppCoordinates);
 return aRet;
+}
 long l = atol(*ppCoordinate);
 if (l > std::numeric_limits::max())
 aRet.width = std::numeric_limits::max();
@@ -1013,7 +1022,10 @@ payloadToRectangle (LOKDocView* pDocView, const char* 
pPayload)
 aRet.width = priv->m_nDocumentWidthTwips - aRet.x;
 ++ppCoordinate;
 if (!*ppCoordinate)
+{
+g_strfreev(ppCoordinates);
 return aRet;
+}
 l = atol(*ppCoordinate);
 if (l > std::numeric_limits::max())
 aRet.height = std::numeric_limits::max();
@@ -1021,8 +1033,8 @@ payloadToRectangle (LOKDocView* pDocView, const char* 
pPayload)
 aRet.height = l;
 if (aRet.y + aRet.height > priv->m_nDocumentHeightTwips)
 aRet.height = priv->m_nDocumentHeightTwips - aRet.y;
-g_strfreev(ppCoordinates);
 
+g_strfreev(ppCoordinates);
 return aRet;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2020-10-26 Thread Michael Meeks (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 6bcdbb97b99369b20f6f1d2bdbc6eca1ff1f1150
Author: Michael Meeks 
AuthorDate: Thu Oct 22 22:09:33 2020 +0100
Commit: Noel Grandin 
CommitDate: Mon Oct 26 08:51:07 2020 +0100

Allow some spelling dictionaries for gtktiledviewer.

Change-Id: Ie3e646321aff2705d908b25e4beff0768a5936fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104703
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 6af262bb8df2..466a1cc85b0e 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2779,6 +2779,9 @@ static gboolean lok_doc_view_initable_init (GInitable 
*initable, GCancellable* /
 if (priv->m_bUnipoll)
 g_setenv("SAL_LOK_OPTIONS", "unipoll", FALSE);
 
+static const char testingLangs[] = "de_DE en_GB en_US es_ES fr_FR it nl 
pt_BR pt_PT ru";
+g_setenv("LOK_ALLOWLIST_LANGUAGES", testingLangs, FALSE);
+
 priv->m_pOffice = lok_init_2(priv->m_aLOPath.c_str(), 
priv->m_aUserProfileURL.empty() ? nullptr : priv->m_aUserProfileURL.c_str());
 
 if (priv->m_pOffice == nullptr)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2020-06-04 Thread Tor Lillqvist (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 716f3e6ff560893febc95f55fc39bc46151afd7f
Author: Tor Lillqvist 
AuthorDate: Thu Jun 4 15:46:54 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Thu Jun 4 15:49:25 2020 +0300

Change FIXME to plain comment, there apparently is nothing to do about it 
here

Change-Id: I81e50e7e604e8ef17ba0d369e8987f4c840f8361

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 8bcbd1aeb904..ae2c00bcaa08 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -891,8 +891,9 @@ static gboolean postDocumentLoad(gpointer pData)
 
 std::unique_lock aGuard(g_aLOKMutex);
 priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, 
priv->m_aRenderingArguments.c_str());
-// FIXME: This returns the view id of the "current" view, but sadly if you 
load multiple
-// documents that is apparently not a view showing the most recently 
loaded document.
+// This returns the view id of the "current" view, but sadly if you load 
multiple documents that
+// is apparently not a view showing the most recently loaded document. Not 
much we can do here,
+// though. If that is fixed, this comment becomes incorrect.
 priv->m_nViewId = priv->m_pDocument->pClass->getView(priv->m_pDocument);
 g_aAuthorViews[getAuthorRenderingArgument(priv)] = priv->m_nViewId;
 priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, 
callbackWorker, pLOKDocView);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2020-06-04 Thread Tor Lillqvist (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |2 --
 1 file changed, 2 deletions(-)

New commits:
commit 8d41357570ad2671b0053c462e33b1d78626dca0
Author: Tor Lillqvist 
AuthorDate: Thu Jun 4 14:45:21 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Thu Jun 4 14:14:33 2020 +0200

Bin two leftover spurious writes to std::cerr

Change-Id: I89601e3682a5f8eca81b45af62e5aa50c481bc84
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95502
Tested-by: Tor Lillqvist 
Reviewed-by: Tor Lillqvist 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index ac5edc633ee0..8bcbd1aeb904 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1113,8 +1113,6 @@ callback (gpointer pData)
 
 priv->m_aVisibleCursor = payloadToRectangle(pDocView, 
rRectangle.c_str());
 priv->m_bCursorOverlayVisible = true;
-std::cerr << nViewId;
-std::cerr << priv->m_nViewId;
 if(nViewId == priv->m_nViewId)
 {
 g_signal_emit(pDocView, doc_view_signals[CURSOR_CHANGED], 0,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2020-06-04 Thread Tor Lillqvist (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 79c933916861d085ab844c50d7f07ba9c2d5e570
Author: Tor Lillqvist 
AuthorDate: Thu Jun 4 15:06:24 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Thu Jun 4 14:13:46 2020 +0200

tdf#128502: Add a FIXME comment

The view id concept is badly broken. Way too many wild assumptions
that the "current" view is the one we expect here and there. For
instance here.

Change-Id: Icf36808b2c09f0b3fd8070deecf175ba7f52b5f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95508
Tested-by: Tor Lillqvist 
Reviewed-by: Tor Lillqvist 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 75deee7a38a0..ac5edc633ee0 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1,4 +1,4 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
 /*
  * This file is part of the LibreOffice project.
  *
@@ -891,6 +891,8 @@ static gboolean postDocumentLoad(gpointer pData)
 
 std::unique_lock aGuard(g_aLOKMutex);
 priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, 
priv->m_aRenderingArguments.c_str());
+// FIXME: This returns the view id of the "current" view, but sadly if you 
load multiple
+// documents that is apparently not a view showing the most recently 
loaded document.
 priv->m_nViewId = priv->m_pDocument->pClass->getView(priv->m_pDocument);
 g_aAuthorViews[getAuthorRenderingArgument(priv)] = priv->m_nViewId;
 priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, 
callbackWorker, pLOKDocView);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2019-11-29 Thread Corentin Noël (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 63acb8cfa4d66baf48a0fe5cdc9ababb6f981666
Author: Corentin Noël 
AuthorDate: Mon Nov 11 22:33:26 2019 +0100
Commit: Jan Holesovsky 
CommitDate: Fri Nov 29 10:07:12 2019 +0100

lokdocview: Add notify_property when the document is initialized

The property "is-initialized" was updated under the hood but no 
notification was sent to the user preventing to use features like 
g_object_bind_property

Change-Id: If5fab557fbd2b3ae2b2531799548907404d79a33
Reviewed-on: https://gerrit.libreoffice.org/82472
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 9e15e4173719..0d7ad9b9e7a6 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -906,6 +906,7 @@ static gboolean postDocumentLoad(gpointer pData)
 
 // we are completely loaded
 priv->m_bInit = true;
+g_object_notify_by_pspec(G_OBJECT(pLOKDocView), 
properties[PROP_IS_INITIALIZED]);
 
 return G_SOURCE_REMOVE;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: libreofficekit/source

2019-11-29 Thread Corentin Noël (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |  159 +++
 libreofficekit/source/gtk/tilebuffer.hxx |4 
 2 files changed, 100 insertions(+), 63 deletions(-)

New commits:
commit d687bbe1f4df068786ee6535854f0760e9447bea
Author: Corentin Noël 
AuthorDate: Thu Nov 14 15:44:39 2019 +0100
Commit: Jan Holesovsky 
CommitDate: Fri Nov 29 10:05:23 2019 +0100

lokdocview: Add support for HiDPI rendering

Change-Id: I3c6b8c958dec78de1457d06ceb81e56b9ae36ce9
Reviewed-on: https://gerrit.libreoffice.org/82714
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index d5c9b919e0a9..9e15e4173719 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -322,6 +322,7 @@ static GParamSpec *properties[PROP_LAST] = { nullptr };
 
 static void lok_doc_view_initable_iface_init (GInitableIface *iface);
 static void callbackWorker (int nType, const char* pPayload, void* pData);
+static void updateClientZoom (LOKDocView *pDocView);
 
 SAL_DLLPUBLIC_EXPORT GType lok_doc_view_get_type();
 #ifdef __GNUC__
@@ -588,6 +589,8 @@ postKeyEventInThread(gpointer data)
 LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
+gint nScaleFactor = gtk_widget_get_scale_factor(GTK_WIDGET(pDocView));
+gint nTileSizePixelsScaled = nTileSizePixels * nScaleFactor;
 
 std::scoped_lock aGuard(g_aLOKMutex);
 std::stringstream ss;
@@ -598,11 +601,11 @@ postKeyEventInThread(gpointer data)
 if (priv->m_nTileSizeTwips)
 {
 ss.str(std::string());
-ss << "lok::Document::setClientZoom(" << nTileSizePixels << ", " << 
nTileSizePixels << ", " << priv->m_nTileSizeTwips << ", " << 
priv->m_nTileSizeTwips << ")";
+ss << "lok::Document::setClientZoom(" << nTileSizePixelsScaled << ", " 
<< nTileSizePixelsScaled << ", " << priv->m_nTileSizeTwips << ", " << 
priv->m_nTileSizeTwips << ")";
 g_info("%s", ss.str().c_str());
 priv->m_pDocument->pClass->setClientZoom(priv->m_pDocument,
- nTileSizePixels,
- nTileSizePixels,
+ nTileSizePixelsScaled,
+ nTileSizePixelsScaled,
  priv->m_nTileSizeTwips,
  priv->m_nTileSizeTwips);
 priv->m_nTileSizeTwips = 0;
@@ -865,14 +868,16 @@ static void refreshSize(LOKDocView* pDocView)
 
 priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, 
>m_nDocumentWidthTwips, >m_nDocumentHeightTwips);
 float zoom = priv->m_fZoom;
+gint nScaleFactor = gtk_widget_get_scale_factor(GTK_WIDGET(pDocView));
+gint nTileSizePixelsScaled = nTileSizePixels * nScaleFactor;
 long nDocumentWidthTwips = priv->m_nDocumentWidthTwips;
 long nDocumentHeightTwips = priv->m_nDocumentHeightTwips;
 long nDocumentWidthPixels = twipToPixel(nDocumentWidthTwips, zoom);
 long nDocumentHeightPixels = twipToPixel(nDocumentHeightTwips, zoom);
 
 // Total number of columns in this document.
-guint nColumns = ceil(static_cast(nDocumentWidthPixels) / 
nTileSizePixels);
-priv->m_pTileBuffer = std::make_unique(nColumns);
+guint nColumns = ceil(static_cast(nDocumentWidthPixels) / 
nTileSizePixelsScaled);
+priv->m_pTileBuffer = std::make_unique(nColumns, nScaleFactor);
 gtk_widget_set_size_request(GTK_WIDGET(pDocView),
 nDocumentWidthPixels,
 nDocumentHeightPixels);
@@ -1041,16 +1046,18 @@ setTilesInvalid (LOKDocView* pDocView, const 
GdkRectangle& rRectangle)
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 GdkRectangle aRectanglePixels;
 GdkPoint aStart, aEnd;
-
-aRectanglePixels.x = twipToPixel(rRectangle.x, priv->m_fZoom);
-aRectanglePixels.y = twipToPixel(rRectangle.y, priv->m_fZoom);
-aRectanglePixels.width = twipToPixel(rRectangle.width, priv->m_fZoom);
-aRectanglePixels.height = twipToPixel(rRectangle.height, priv->m_fZoom);
-
-aStart.x = aRectanglePixels.y / nTileSizePixels;
-aStart.y = aRectanglePixels.x / nTileSizePixels;
-aEnd.x = (aRectanglePixels.y + aRectanglePixels.height + nTileSizePixels) 
/ nTileSizePixels;
-aEnd.y = (aRectanglePixels.x + aRectanglePixels.width + nTileSizePixels) / 
nTileSizePixels;
+gint nScaleFactor = gtk_widget_get_scale_factor(GTK_WIDGET(pDocView));
+gint nTileSizePixelsScaled = nTileSizePixels * nScaleFactor;
+
+aRectanglePixels.x = twipToPixel(rRectangle.x, priv->m_fZoom) * 
nScaleFactor;
+aRectanglePixels.y = twipToPixel(rRectangle.y, priv->m_fZoom) * 
nScaleFactor;
+

[Libreoffice-commits] core.git: libreofficekit/source

2019-11-13 Thread Michael Meeks (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |   58 +++
 1 file changed, 21 insertions(+), 37 deletions(-)

New commits:
commit 1da4f8048fb478a60b8ccd05bace17ce540a0c9a
Author: Michael Meeks 
AuthorDate: Tue Nov 12 21:19:25 2019 +
Commit: Michael Meeks 
CommitDate: Wed Nov 13 13:58:30 2019 +0100

lokdocview: refresh tile buffer on resize to avoid UI breakage.

Otherwise we get tiles in the wrong locations based on incorrrect
widths.

Change-Id: I1c76bc6eaabd8af4c283e421bf8901e7d64b4efa
Reviewed-on: https://gerrit.libreoffice.org/82574
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 2c2951637f01..5dd0457479af 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -356,22 +356,6 @@ struct CallbackData
 };
 
 static void
-payloadToSize(const char* pPayload, long& rWidth, long& rHeight)
-{
-rWidth = rHeight = 0;
-gchar** ppCoordinates = g_strsplit(pPayload, ", ", 2);
-gchar** ppCoordinate = ppCoordinates;
-if (!*ppCoordinate)
-return;
-rWidth = atoi(*ppCoordinate);
-++ppCoordinate;
-if (!*ppCoordinate)
-return;
-rHeight = atoi(*ppCoordinate);
-g_strfreev(ppCoordinates);
-}
-
-static void
 LOKPostCommand (LOKDocView* pDocView,
 const gchar* pCommand,
 const gchar* pArguments,
@@ -867,6 +851,25 @@ static std::string 
getAuthorRenderingArgument(LOKDocViewPrivate& priv)
 /// Author string <-> View ID map
 static std::map g_aAuthorViews;
 
+static void refreshSize(LOKDocView* pDocView)
+{
+LOKDocViewPrivate& priv = getPrivate(pDocView);
+
+priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, 
>m_nDocumentWidthTwips, >m_nDocumentHeightTwips);
+float zoom = priv->m_fZoom;
+long nDocumentWidthTwips = priv->m_nDocumentWidthTwips;
+long nDocumentHeightTwips = priv->m_nDocumentHeightTwips;
+long nDocumentWidthPixels = twipToPixel(nDocumentWidthTwips, zoom);
+long nDocumentHeightPixels = twipToPixel(nDocumentHeightTwips, zoom);
+
+// Total number of columns in this document.
+guint nColumns = ceil(static_cast(nDocumentWidthPixels) / 
nTileSizePixels);
+priv->m_pTileBuffer = std::make_unique(nColumns);
+gtk_widget_set_size_request(GTK_WIDGET(pDocView),
+nDocumentWidthPixels,
+nDocumentHeightPixels);
+}
+
 /// Set up LOKDocView after the document is loaded, invoked on the main thread 
by openDocumentInThread() running in a thread.
 static gboolean postDocumentLoad(gpointer pData)
 {
@@ -878,23 +881,12 @@ static gboolean postDocumentLoad(gpointer pData)
 priv->m_nViewId = priv->m_pDocument->pClass->getView(priv->m_pDocument);
 g_aAuthorViews[getAuthorRenderingArgument(priv)] = priv->m_nViewId;
 priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, 
callbackWorker, pLOKDocView);
-priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, 
>m_nDocumentWidthTwips, >m_nDocumentHeightTwips);
 priv->m_nParts = priv->m_pDocument->pClass->getParts(priv->m_pDocument);
 aGuard.unlock();
 priv->m_nTimeoutId = g_timeout_add(600, handleTimeout, pLOKDocView);
 
-float zoom = priv->m_fZoom;
-long nDocumentWidthTwips = priv->m_nDocumentWidthTwips;
-long nDocumentHeightTwips = priv->m_nDocumentHeightTwips;
-long nDocumentWidthPixels = twipToPixel(nDocumentWidthTwips, zoom);
-long nDocumentHeightPixels = twipToPixel(nDocumentHeightTwips, zoom);
-// Total number of columns in this document.
-guint nColumns = ceil(static_cast(nDocumentWidthPixels) / 
nTileSizePixels);
+refreshSize(pLOKDocView);
 
-priv->m_pTileBuffer = std::make_unique(nColumns);
-gtk_widget_set_size_request(GTK_WIDGET(pLOKDocView),
-nDocumentWidthPixels,
-nDocumentHeightPixels);
 gtk_widget_set_can_focus(GTK_WIDGET(pLOKDocView), TRUE);
 gtk_widget_grab_focus(GTK_WIDGET(pLOKDocView));
 lok_doc_view_set_zoom(pLOKDocView, 1.0);
@@ -1220,15 +1212,7 @@ callback (gpointer pData)
 break;
 case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
 {
-if (!pCallback->m_aPayload.empty())
-payloadToSize(pCallback->m_aPayload.c_str(), 
priv->m_nDocumentWidthTwips, priv->m_nDocumentHeightTwips);
-else
-priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, 
>m_nDocumentWidthTwips, >m_nDocumentHeightTwips);
-
-gtk_widget_set_size_request(GTK_WIDGET(pDocView),
-twipToPixel(priv->m_nDocumentWidthTwips, 
priv->m_fZoom),
-twipToPixel(priv->m_nDocumentHeightTwips, 
priv->m_fZoom));
-
+refreshSize(pDocView);
 g_signal_emit(pDocView, doc_view_signals[SIZE_CHANGED], 0, nullptr);
 }
 

[Libreoffice-commits] core.git: libreofficekit/source

2019-11-13 Thread Michael Meeks (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |9 ++---
 libreofficekit/source/gtk/tilebuffer.cxx |   15 +++
 libreofficekit/source/gtk/tilebuffer.hxx |   10 ++
 3 files changed, 27 insertions(+), 7 deletions(-)

New commits:
commit 1654152b5ed110b8bec491fd300257f09ed77504
Author: Michael Meeks 
AuthorDate: Tue Nov 12 21:18:16 2019 +
Commit: Michael Meeks 
CommitDate: Wed Nov 13 11:23:59 2019 +0100

lokdocview: encapsulate tile buffer properly.

Change-Id: I59d690fbde67f4985246f13b992e962d11b7b07f
Reviewed-on: https://gerrit.libreoffice.org/82573
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 0e710d5faf27..2c2951637f01 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1538,7 +1538,6 @@ paintTileCallback(GObject* sourceObject, GAsyncResult* 
res, gpointer userData)
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(userData);
 std::unique_ptr& buffer = priv->m_pTileBuffer;
-int index = pLOEvent->m_nPaintTileX * buffer->m_nWidth + 
pLOEvent->m_nPaintTileY;
 GError* error;
 
 error = nullptr;
@@ -1555,8 +1554,7 @@ paintTileCallback(GObject* sourceObject, GAsyncResult* 
res, gpointer userData)
 return;
 }
 
-buffer->m_mTiles[index].setSurface(pSurface);
-buffer->m_mTiles[index].valid = true;
+buffer->setTile(pLOEvent->m_nPaintTileX, pLOEvent->m_nPaintTileY, 
pSurface);
 gdk_threads_add_idle(queueDraw, GTK_WIDGET(pDocView));
 
 cairo_surface_destroy(pSurface);
@@ -2343,9 +2341,7 @@ paintTileInThread (gpointer data)
 return;
 }
 std::unique_ptr& buffer = priv->m_pTileBuffer;
-int index = pLOEvent->m_nPaintTileX * buffer->m_nWidth + 
pLOEvent->m_nPaintTileY;
-if (buffer->m_mTiles.find(index) != buffer->m_mTiles.end() &&
-buffer->m_mTiles[index].valid)
+if (buffer->hasValidTile(pLOEvent->m_nPaintTileX, pLOEvent->m_nPaintTileY))
 return;
 
 cairo_surface_t *pSurface = 
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, nTileSizePixels, 
nTileSizePixels);
@@ -3516,7 +3512,6 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
 long nDocumentHeightPixels = twipToPixel(priv->m_nDocumentHeightTwips, 
fZoom);
 // Total number of columns in this document.
 guint nColumns = ceil(static_cast(nDocumentWidthPixels) / 
nTileSizePixels);
-
 priv->m_pTileBuffer = std::make_unique(nColumns);
 gtk_widget_set_size_request(GTK_WIDGET(pDocView),
 nDocumentWidthPixels,
diff --git a/libreofficekit/source/gtk/tilebuffer.cxx 
b/libreofficekit/source/gtk/tilebuffer.cxx
index 9085ba06ac2c..82f0253d9e82 100644
--- a/libreofficekit/source/gtk/tilebuffer.cxx
+++ b/libreofficekit/source/gtk/tilebuffer.cxx
@@ -109,6 +109,21 @@ Tile& TileBuffer::getTile(int x, int y, GTask* task,
 return m_mTiles[index];
 }
 
+void TileBuffer::setTile(int x, int y, cairo_surface_t *surface)
+{
+int index = x * m_nWidth + y;
+
+m_mTiles[index].setSurface(surface);
+m_mTiles[index].valid = true;
+}
+
+bool TileBuffer::hasValidTile(int x, int y)
+{
+int index = x * m_nWidth + y;
+auto it = m_mTiles.find(index);
+return (it != m_mTiles.end()) && it->second.valid;
+}
+
 void LOEvent::destroy(void* pMemory)
 {
 LOEvent* pLOEvent = static_cast(pMemory);
diff --git a/libreofficekit/source/gtk/tilebuffer.hxx 
b/libreofficekit/source/gtk/tilebuffer.hxx
index 88961cc1f44d..fccc6211acc3 100644
--- a/libreofficekit/source/gtk/tilebuffer.hxx
+++ b/libreofficekit/source/gtk/tilebuffer.hxx
@@ -116,6 +116,15 @@ class TileBuffer
@return the tile at the mentioned position (x, y)
  */
 Tile& getTile(int x, int y, GTask* task, GThreadPool* pool);
+
+/*
+  Takes ownership of the surface and sets it on a tile at a given location
+*/
+void  setTile(int x, int y, cairo_surface_t *surface);
+
+/// Returns true if a valid tile exists at this location
+bool hasValidTile(int x, int y);
+
 /// Destroys all the tiles in the tile buffer; also frees the memory 
allocated
 /// for all the Tile objects.
 void resetAllTiles();
@@ -133,6 +142,7 @@ class TileBuffer
  */
 void setInvalid(int x, int y, float zoom, GTask* task, GThreadPool*);
 
+private:
 /// Stores all the tiles cached by this tile buffer.
 std::map m_mTiles;
 /// Width of the current tile buffer (number of columns)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: libreofficekit/source

2019-10-30 Thread Ashod Nakashian (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 369eac81d4a5aa629762d04f1a9b9696ffec8f1f
Author: Ashod Nakashian 
AuthorDate: Mon Jul 29 09:21:27 2019 -0400
Commit: Michael Meeks 
CommitDate: Wed Oct 30 22:50:46 2019 +0100

gtktiledviewer: always load with en-US language

This is the default for Online, so makes sense
to have the same in the gtktiledviewer as well.

Change-Id: I8c4729aa301069e246554b06671ad86bbe50c441
Reviewed-on: https://gerrit.libreoffice.org/81778
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 122c6dcc4149..0e710d5faf27 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2227,7 +2227,7 @@ openDocumentInThread (gpointer data)
 }
 
 priv->m_pOffice->pClass->registerCallback(priv->m_pOffice, 
globalCallbackWorker, pDocView);
-priv->m_pDocument = priv->m_pOffice->pClass->documentLoad( 
priv->m_pOffice, priv->m_aDocPath.c_str() );
+priv->m_pDocument = priv->m_pOffice->pClass->documentLoadWithOptions( 
priv->m_pOffice, priv->m_aDocPath.c_str(), "en-US" );
 if ( !priv->m_pDocument )
 {
 char *pError = priv->m_pOffice->pClass->getError( priv->m_pOffice );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: libreofficekit/source

2019-09-26 Thread Jan Holesovsky (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |   33 +--
 1 file changed, 19 insertions(+), 14 deletions(-)

New commits:
commit dfaf6ebc1ebadd1ea4bb334b1adf4172e3aa205c
Author: Jan Holesovsky 
AuthorDate: Tue Sep 24 17:00:41 2019 +0200
Commit: Jan Holesovsky 
CommitDate: Thu Sep 26 09:32:43 2019 +0200

gtktiledviewer: Turn an annoying assert into a compile-time check.

So that people don't forget adding the enum values here...

Change-Id: I0342e2ecca4d7d14641e44ca562b121182e8
Reviewed-on: https://gerrit.libreoffice.org/79554
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 2e304a07ee49..97a37b8557b8 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1072,7 +1072,7 @@ callback (gpointer pData)
 return G_SOURCE_REMOVE;
 }
 
-switch (pCallback->m_nType)
+switch (static_cast(pCallback->m_nType))
 {
 case LOK_CALLBACK_INVALIDATE_TILES:
 {
@@ -1261,11 +1261,6 @@ callback (gpointer pData)
 reportError(pDocView, pCallback->m_aPayload);
 }
 break;
-case LOK_CALLBACK_CONTEXT_MENU:
-{
-// TODO: Implement me
-break;
-}
 case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
 {
 std::stringstream aStream(pCallback->m_aPayload);
@@ -1360,12 +1355,6 @@ callback (gpointer pData)
 case LOK_CALLBACK_INVALIDATE_HEADER:
 g_signal_emit(pCallback->m_pDocView, 
doc_view_signals[INVALIDATE_HEADER], 0, pCallback->m_aPayload.c_str());
 break;
-case LOK_CALLBACK_CLIPBOARD_CHANGED:
-case LOK_CALLBACK_CONTEXT_CHANGED:
-case LOK_CALLBACK_CELL_SELECTION_AREA:
-case LOK_CALLBACK_CELL_AUTO_FILL_AREA:
-case LOK_CALLBACK_TABLE_SELECTED:
-break; // TODO
 case LOK_CALLBACK_REFERENCE_MARKS:
 {
 std::stringstream aStream(pCallback->m_aPayload);
@@ -1387,10 +1376,26 @@ callback (gpointer pData)
 gtk_widget_queue_draw(GTK_WIDGET(pDocView));
 break;
 }
-default:
-g_assert(false);
+
+case LOK_CALLBACK_STATUS_INDICATOR_START:
+case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
+case LOK_CALLBACK_STATUS_INDICATOR_FINISH:
+case LOK_CALLBACK_DOCUMENT_PASSWORD:
+case LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY:
+case LOK_CALLBACK_VALIDITY_LIST_BUTTON:
+case LOK_CALLBACK_SIGNATURE_STATUS:
+case LOK_CALLBACK_CONTEXT_MENU:
+case LOK_CALLBACK_PROFILE_FRAME:
+case LOK_CALLBACK_CLIPBOARD_CHANGED:
+case LOK_CALLBACK_CONTEXT_CHANGED:
+case LOK_CALLBACK_CELL_SELECTION_AREA:
+case LOK_CALLBACK_CELL_AUTO_FILL_AREA:
+case LOK_CALLBACK_TABLE_SELECTED:
+{
+// TODO: Implement me
 break;
 }
+}
 delete pCallback;
 
 return G_SOURCE_REMOVE;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: libreofficekit/source

2019-09-06 Thread Aron Budea (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 29bda20c915287bbd1cd0fc6c56574cfa74b5ce3
Author: Aron Budea 
AuthorDate: Sat Sep 7 05:17:41 2019 +0200
Commit: Aron Budea 
CommitDate: Sat Sep 7 06:12:44 2019 +0200

lokdocview: Add missing callback cases

To prevent gtktiledviewer from crashing.

Change-Id: Ia23504c20eac185f3302e8d694672ebf6d853585
Reviewed-on: https://gerrit.libreoffice.org/78737
Tested-by: Jenkins
Reviewed-by: Aron Budea 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 51e1e8e1e801..4fa07b9c60c1 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1359,6 +1359,9 @@ callback (gpointer pData)
 break;
 case LOK_CALLBACK_CLIPBOARD_CHANGED:
 case LOK_CALLBACK_CONTEXT_CHANGED:
+case LOK_CALLBACK_CELL_SELECTION_AREA:
+case LOK_CALLBACK_CELL_AUTO_FILL_AREA:
+case LOK_CALLBACK_TABLE_SELECTED:
 break; // TODO
 default:
 g_assert(false);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: libreofficekit/source vcl/source vcl/unx

2019-06-19 Thread Stephan Bergmann (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx   |   14 +++---
 vcl/source/graphic/Manager.cxx |   14 +++---
 vcl/source/uitest/uno/uiobject_uno.cxx |4 ++--
 vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.hxx |2 +-
 4 files changed, 17 insertions(+), 17 deletions(-)

New commits:
commit 9376f65a26240441bf9dd6ae1f69886dc9fa60fa
Author: Stephan Bergmann 
AuthorDate: Wed Jun 19 22:28:20 2019 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Jun 20 07:50:19 2019 +0200

Consolidate on C++17 std::scoped_lock instead of std::lock_guard

...where scoped_lock was originally meant as a transparent generalization of
lock_guard, but eventually had to supersede it under a new name, for 
backwards-
compatibility reasons, see
 
"Variadic
lock_guard (Rev. 5)" and
 "WG21
Working Paper, NB Comments, ISO/IEC CD 14882".

Change-Id: Ie58909f63beec5939601183d6bcda3bc638d5747
Reviewed-on: https://gerrit.libreoffice.org/74382
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index b55ca470e253..3f43a1487502 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2186,7 +2186,7 @@ setGraphicSelectionInThread(gpointer data)
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
-std::lock_guard aGuard(g_aLOKMutex);
+std::scoped_lock aGuard(g_aLOKMutex);
 std::stringstream ss;
 ss << "lok::Document::setView(" << priv->m_nViewId << ")";
 g_info("%s", ss.str().c_str());
@@ -2210,7 +2210,7 @@ setClientZoomInThread(gpointer data)
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
-std::lock_guard aGuard(g_aLOKMutex);
+std::scoped_lock aGuard(g_aLOKMutex);
 priv->m_pDocument->pClass->setClientZoom(priv->m_pDocument,
  pLOEvent->m_nTilePixelWidth,
  pLOEvent->m_nTilePixelHeight,
@@ -2226,7 +2226,7 @@ postMouseEventInThread(gpointer data)
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
-std::lock_guard aGuard(g_aLOKMutex);
+std::scoped_lock aGuard(g_aLOKMutex);
 std::stringstream ss;
 ss << "lok::Document::setView(" << priv->m_nViewId << ")";
 g_info("%s", ss.str().c_str());
@@ -2255,7 +2255,7 @@ openDocumentInThread (gpointer data)
 LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 
-std::lock_guard aGuard(g_aLOKMutex);
+std::scoped_lock aGuard(g_aLOKMutex);
 if ( priv->m_pDocument )
 {
 priv->m_pDocument->pClass->destroy( priv->m_pDocument );
@@ -2306,7 +2306,7 @@ setPartmodeInThread(gpointer data)
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 int nPartMode = pLOEvent->m_nPartMode;
 
-std::lock_guard aGuard(g_aLOKMutex);
+std::scoped_lock aGuard(g_aLOKMutex);
 std::stringstream ss;
 ss << "lok::Document::setView(" << priv->m_nViewId << ")";
 g_info("%s", ss.str().c_str());
@@ -2329,7 +2329,7 @@ setEditInThread(gpointer data)
 else if (priv->m_bEdit && !bEdit)
 {
 g_info("lok_doc_view_set_edit: leaving edit mode");
-std::lock_guard aGuard(g_aLOKMutex);
+std::scoped_lock aGuard(g_aLOKMutex);
 std::stringstream ss;
 ss << "lok::Document::setView(" << priv->m_nViewId << ")";
 g_info("%s", ss.str().c_str());
@@ -2349,7 +2349,7 @@ postCommandInThread (gpointer data)
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 
-std::lock_guard aGuard(g_aLOKMutex);
+std::scoped_lock aGuard(g_aLOKMutex);
 std::stringstream ss;
 ss << "lok::Document::setView(" << priv->m_nViewId << ")";
 g_info("%s", ss.str().c_str());
diff --git a/vcl/source/graphic/Manager.cxx b/vcl/source/graphic/Manager.cxx
index 7a03f85468dd..3ddec0ae280b 100644
--- a/vcl/source/graphic/Manager.cxx
+++ b/vcl/source/graphic/Manager.cxx
@@ -76,7 +76,7 @@ Manager::Manager()
 
 void Manager::reduceGraphicMemory()
 {
-std::lock_guard aGuard(maMutex);
+std::scoped_lock aGuard(maMutex);
 
 for (ImpGraphic* pEachImpGraphic : m_pImpGraphicList)
 {
@@ -108,7 +108,7 @@ sal_Int64 Manager::getGraphicSizeBytes(const ImpGraphic* 
pImpGraphic)
 
 IMPL_LINK(Manager, SwapOutTimerHandler, Timer*, pTimer, void)
 {
-std::lock_guard aGuard(maMutex);
+std::scoped_lock aGuard(maMutex);
 
 pTimer->Stop();
 reduceGraphicMemory();
@@ -118,7 +118,7 @@ 

[Libreoffice-commits] core.git: libreofficekit/source

2019-05-25 Thread Michael Meeks (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 20dbfaedc0147e6276f4b41cf9b4fb6af2ee71f0
Author: Michael Meeks 
AuthorDate: Sat May 25 15:50:13 2019 +0100
Commit: Michael Meeks 
CommitDate: Sat May 25 22:23:01 2019 +0200

gtktiledviewer: Fix crash on copy.

Change-Id: I1afc6278f6853d5e45a305b4f731cb6af0e00cc1
Reviewed-on: https://gerrit.libreoffice.org/72955
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 54c63de3674a..b55ca470e253 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1452,6 +1452,7 @@ callback (gpointer pData)
 case LOK_CALLBACK_INVALIDATE_HEADER:
 g_signal_emit(pCallback->m_pDocView, 
doc_view_signals[INVALIDATE_HEADER], 0, pCallback->m_aPayload.c_str());
 break;
+case LOK_CALLBACK_CLIPBOARD_CHANGED:
 case LOK_CALLBACK_CONTEXT_CHANGED:
 break; // TODO
 default:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: libreofficekit/source

2019-04-27 Thread Michael Meeks (via logerrit)
 libreofficekit/source/gtk/lokdocview.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 85dc12a99b455126e8deae5637bf63c48ce8938e
Author: Michael Meeks 
AuthorDate: Fri Apr 26 21:40:05 2019 +0100
Commit: Michael Meeks 
CommitDate: Sat Apr 27 21:05:33 2019 +0200

lok: handle missing callback.

Change-Id: I13a200c9c9d8b0a8fde6dd15a71fe1a665d04e8d
Reviewed-on: https://gerrit.libreoffice.org/71432
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 36601e385173..3187daed6a41 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1449,6 +1449,8 @@ callback (gpointer pData)
 case LOK_CALLBACK_INVALIDATE_HEADER:
 g_signal_emit(pCallback->m_pDocView, 
doc_view_signals[INVALIDATE_HEADER], 0, pCallback->m_aPayload.c_str());
 break;
+case LOK_CALLBACK_CONTEXT_CHANGED:
+break; // TODO
 default:
 g_assert(false);
 break;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: libreofficekit/source

2018-11-15 Thread Libreoffice Gerrit user
 libreofficekit/source/gtk/lokdocview.cxx |5 +
 1 file changed, 5 insertions(+)

New commits:
commit 350a9ddc264ae414e72e6e780a71077d2ce65cdb
Author: Jan Holesovsky 
AuthorDate: Wed Nov 14 15:36:30 2018 +0100
Commit: Jan Holesovsky 
CommitDate: Thu Nov 15 10:11:16 2018 +0100

gtktiledviewer: Handle LOK_CALLBACK_SIGNATURE_STATUS to avoid an assert.

Change-Id: Iae56708d94a229911a5d008d519120ac59069cf3
Reviewed-on: https://gerrit.libreoffice.org/63391
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index e2d58a632f8f..7d288a449651 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1029,6 +1029,11 @@ globalCallback (gpointer pData)
 reportError(pCallback->m_pDocView, pCallback->m_aPayload);
 }
 break;
+case LOK_CALLBACK_SIGNATURE_STATUS:
+{
+// TODO
+}
+break;
 default:
 g_assert(false);
 break;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2018-11-15 Thread Libreoffice Gerrit user
 libreofficekit/source/gtk/lokdocview.cxx |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

New commits:
commit bde2eeddf27483dc598cdf02ff2d23ec0cbc53d8
Author: Jan Holesovsky 
AuthorDate: Wed Nov 14 15:21:46 2018 +0100
Commit: Jan Holesovsky 
CommitDate: Thu Nov 15 10:11:02 2018 +0100

gtktiledviewer: Compile-time check instead of an annoying assert.

Change-Id: Iece75f6f40bf7d7dfcde372cf9b4606adb9e34b2
Reviewed-on: https://gerrit.libreoffice.org/63390
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index a1bf0d7d70d8..e2d58a632f8f 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -364,7 +364,7 @@ payloadToSize(const char* pPayload, long& rWidth, long& 
rHeight)
 static const char*
 callbackTypeToString (int nType)
 {
-switch (nType)
+switch (static_cast(nType))
 {
 case LOK_CALLBACK_INVALIDATE_TILES:
 return "LOK_CALLBACK_INVALIDATE_TILES";
@@ -440,6 +440,14 @@ callbackTypeToString (int nType)
 return "LOK_CALLBACK_RULER_UPDATE";
 case LOK_CALLBACK_WINDOW:
 return "LOK_CALLBACK_WINDOW";
+case LOK_CALLBACK_VALIDITY_LIST_BUTTON:
+return "LOK_CALLBACK_VALIDITY_LIST_BUTTON";
+case LOK_CALLBACK_CLIPBOARD_CHANGED:
+return "LOK_CALLBACK_CLIPBOARD_CHANGED";
+case LOK_CALLBACK_CONTEXT_CHANGED:
+return "LOK_CALLBACK_CONTEXT_CHANGED";
+case LOK_CALLBACK_SIGNATURE_STATUS:
+return "LOK_CALLBACK_SIGNATURE_STATUS";
 }
 g_assert(false);
 return nullptr;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2018-01-09 Thread Andrea Gelmini
 libreofficekit/source/gtk/lokdocview.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 0cc38c926eeafab2f8ddb21c2121d3d6aa7b90ae
Author: Andrea Gelmini 
Date:   Mon Jan 8 21:30:28 2018 +0100

Fix typo

Change-Id: I2261578d54e4b986871eab9c309884eb903aa3c6
Reviewed-on: https://gerrit.libreoffice.org/47614
Tested-by: Jenkins 
Reviewed-by: Jens Carl 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index a4bf0c64f3b5..5002e7b0c4e7 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -3207,7 +3207,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
 /**
  * LOKDocView::ruler:
  * @pDocView: the #LOKDocView on which the signal is emitted
- * @pPayload: the JSON string contaning the information about ruler 
properties
+ * @pPayload: the JSON string containing the information about ruler 
properties
  *
  * The payload format is:
  *
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2017-12-22 Thread Caolán McNamara
 libreofficekit/source/gtk/lokdocview.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 1c70d20fcb3a0e8a0e9752b0e3ee45532da8f72a
Author: Caolán McNamara 
Date:   Thu Dec 21 16:19:42 2017 +

rhbz#1527945 segv on failed open of password protected doc in 
gnome-documents

Change-Id: I1bec502ae20d03214c673d8911792c89669c0fe9
Reviewed-on: https://gerrit.libreoffice.org/46921
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index ea9047fb3101..ca4e2433c43a 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2225,7 +2225,6 @@ openDocumentInThread (gpointer data)
 
 priv->m_pOffice->pClass->registerCallback(priv->m_pOffice, 
globalCallbackWorker, pDocView);
 priv->m_pDocument = priv->m_pOffice->pClass->documentLoad( 
priv->m_pOffice, priv->m_aDocPath.c_str() );
-priv->m_eDocumentType = 
static_cast(priv->m_pDocument->pClass->getDocumentType(priv->m_pDocument));
 if ( !priv->m_pDocument )
 {
 char *pError = priv->m_pOffice->pClass->getError( priv->m_pOffice );
@@ -2233,6 +2232,7 @@ openDocumentInThread (gpointer data)
 }
 else
 {
+priv->m_eDocumentType = 
static_cast(priv->m_pDocument->pClass->getDocumentType(priv->m_pDocument));
 gdk_threads_add_idle(postDocumentLoad, pDocView);
 g_task_return_boolean (task, true);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2017-10-24 Thread David Tardon
 libreofficekit/source/gtk/lokdocview.cxx |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

New commits:
commit db6673bb32bb131b6446dc976fe09b1f8df72d49
Author: David Tardon 
Date:   Tue Oct 24 17:07:24 2017 +0200

fix build error

Change-Id: I1e65f075a0519db86836b3aa09848178796a020b

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index d2bfefcc089e..607a8624ecc3 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -177,10 +177,8 @@ struct LOKDocViewPrivateImpl
 /// Cached document type, returned by getDocumentType().
 LibreOfficeKitDocumentType m_eDocumentType;
 
-/**
- * Contains a freshly set zoom level: logic size of a tile.
- * It gets reset back to 0 when LOK was informed about this zoom change.
-*/
+/// Contains a freshly set zoom level: logic size of a tile.
+/// It gets reset back to 0 when LOK was informed about this zoom change.
 int m_nTileSizeTwips;
 
 GdkRectangle m_aVisibleArea;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2017-06-16 Thread Caolán McNamara
 libreofficekit/source/gtk/lokdocview.cxx |   15 +++
 1 file changed, 15 insertions(+)

New commits:
commit 805adaae918d91cbde510aef6d7422cb345c41d4
Author: Caolán McNamara 
Date:   Fri Jun 16 15:30:10 2017 +0100

Resolves: rhbz#1454693 segv if tiled rendering is interrupted

Change-Id: I1131f246c43806adb8a83f6eeafca2b734851a0e
Reviewed-on: https://gerrit.libreoffice.org/3
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index ceda8160c9dd..0a81d3679b69 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1148,6 +1148,14 @@ callback (gpointer pData)
 LOKDocView* pDocView = LOK_DOC_VIEW (pCallback->m_pDocView);
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 
+//callback registered before the widget was destroyed.
+//Use existance of lokThreadPool as flag it was torn down
+if (!priv->lokThreadPool)
+{
+delete pCallback;
+return G_SOURCE_REMOVE;
+}
+
 switch (pCallback->m_nType)
 {
 case LOK_CALLBACK_INVALIDATE_TILES:
@@ -2627,6 +2635,13 @@ static void lok_doc_view_destroy (GtkWidget* widget)
 priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
 priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, 
nullptr, nullptr);
 }
+
+if (priv->lokThreadPool)
+{
+g_thread_pool_free(priv->lokThreadPool, true, true);
+priv->lokThreadPool = nullptr;
+}
+
 aGuard.unlock();
 
 if (priv->m_pDocument)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2017-06-15 Thread Caolán McNamara
 libreofficekit/source/gtk/lokdocview.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit e567ede54e85200f9e412dfa94a0f7b05c27d32f
Author: Caolán McNamara 
Date:   Wed Jun 14 21:18:22 2017 +0100

Related: rhbz#137 check if m_nTimeoutId is valid

Change-Id: I80d850d23ab0e95bb4b105efa5a1ae1e59933a95

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index a59d72bcc374..ceda8160c9dd 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -246,7 +246,8 @@ struct LOKDocViewPrivateImpl
 
 ~LOKDocViewPrivateImpl()
 {
-g_source_remove(m_nTimeoutId);
+if (m_nTimeoutId)
+g_source_remove(m_nTimeoutId);
 }
 };
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2017-05-09 Thread Caolán McNamara
 libreofficekit/source/gtk/lokdocview.cxx |   17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

New commits:
commit c45660df336a640f0f9d4290b881548d25c9db9d
Author: Caolán McNamara 
Date:   Fri May 5 14:34:51 2017 +0100

rhbz#137 gnome-documents finalize may not occur immediately

when LOK Widget is destroyed, it may instead happen during GC of javascript,
like in the in gnome-documents case, but "destroy" will be called promptly. 
So
close documents and office in destroy, not finalize

Change-Id: I1dd7b828839894cb2d87f5c087194fe458ca22f0
Reviewed-on: https://gerrit.libreoffice.org/37398
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 1effc335aed4..65c5a64111f6 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2595,9 +2595,12 @@ static gboolean lok_doc_view_draw (GtkWidget* pWidget, 
cairo_t* pCairo)
 return FALSE;
 }
 
-static void lok_doc_view_finalize (GObject* object)
+//rhbz#137 finalize may not occur immediately when this widget is destroyed
+//it may happen during GC of javascript, e.g. in gnome-documents but "destroy"
+//will be called promptly, so close documents in destroy, not finalize
+static void lok_doc_view_destroy (GtkWidget* widget)
 {
-LOKDocView* pDocView = LOK_DOC_VIEW (object);
+LOKDocView* pDocView = LOK_DOC_VIEW (widget);
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 
 // Ignore notifications sent to this view on shutdown.
@@ -2620,6 +2623,15 @@ static void lok_doc_view_finalize (GObject* object)
 if (priv->m_pOffice)
 priv->m_pOffice->pClass->destroy (priv->m_pOffice);
 }
+
+GTK_WIDGET_CLASS (lok_doc_view_parent_class)->destroy (widget);
+}
+
+static void lok_doc_view_finalize (GObject* object)
+{
+LOKDocView* pDocView = LOK_DOC_VIEW (object);
+LOKDocViewPrivate& priv = getPrivate(pDocView);
+
 delete priv.m_pImpl;
 priv.m_pImpl = nullptr;
 
@@ -2670,6 +2682,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
 pWidgetClass->key_press_event = signalKey;
 pWidgetClass->key_release_event = signalKey;
 pWidgetClass->motion_notify_event = lok_doc_view_signal_motion;
+pWidgetClass->destroy = lok_doc_view_destroy;
 
 /**
  * LOKDocView:lopath:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2017-01-27 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 0f0164d647e01c2e7d2a42a0dd9d58d5e7b765d4
Author: Pranav Kant 
Date:   Wed Jan 18 16:18:21 2017 +0530

lokdocview: Turn off annotations rendering here

Change-Id: Ia1ee4f54a05ab3daca62a78fe335e731e4cfc02d
Reviewed-on: https://gerrit.libreoffice.org/33465
Reviewed-by: pranavk 
Tested-by: pranavk 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 19080fd..c9c32af 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2628,6 +2628,7 @@ static gboolean lok_doc_view_initable_init (GInitable 
*initable, GCancellable* /
 return FALSE;
 }
 priv->m_nLOKFeatures |= LOK_FEATURE_PART_IN_INVALIDATION_CALLBACK;
+priv->m_nLOKFeatures |= LOK_FEATURE_NO_TILED_ANNOTATIONS;
 priv->m_pOffice->pClass->setOptionalFeatures(priv->m_pOffice, 
priv->m_nLOKFeatures);
 
 return TRUE;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2017-01-22 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 5128e503ba8f602d1fda47c89e5b6ee4be6b7029
Author: Pranav Kant 
Date:   Thu Jan 19 14:13:54 2017 +0530

lokdocview: Handle keypad enter

Change-Id: Ia892c346d4a3c0a5439c7977963cc502d287e6f7
Reviewed-on: https://gerrit.libreoffice.org/33445
Reviewed-by: pranavk 
Tested-by: pranavk 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 0b8fa7d..19080fd 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -723,6 +723,7 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
 nKeyCode = com::sun::star::awt::Key::DELETE;
 break;
 case GDK_KEY_Return:
+case GDK_KEY_KP_Enter:
 nKeyCode = com::sun::star::awt::Key::RETURN;
 break;
 case GDK_KEY_Escape:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2017-01-06 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit de6e3d1e87d0e620bcef115605404a76800600a9
Author: Pranav Kant 
Date:   Fri Jan 6 14:33:36 2017 +0530

lokdocview: Handle insert key

Change-Id: Idb5ad17a3a94b9a6fba1113a759207c59acfb7bd

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index cb88bb1..0721080 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -749,6 +749,9 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
 case GDK_KEY_Page_Up:
 nKeyCode = com::sun::star::awt::Key::PAGEUP;
 break;
+case GDK_KEY_Insert:
+nKeyCode = com::sun::star::awt::Key::INSERT;
+break;
 case GDK_KEY_Shift_L:
 case GDK_KEY_Shift_R:
 if (pEvent->type == GDK_KEY_PRESS)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-09-20 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 28447258fb6d9b8246f2a96d1a86945ef255d110
Author: Miklos Vajna 
Date:   Tue Sep 20 17:04:50 2016 +0200

lokdocview: guard against int overflow

If a too large rectangle is parsed, the width or the height may be
larger than std::numeric_limits::max(), in that case just set
width/height to that max value, instead of allowing an overflow.

Change-Id: Ic01319b01a3f9286501c346ea765868be57466a1

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 195335c..d8f2074 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1035,13 +1035,21 @@ payloadToRectangle (LOKDocView* pDocView, const char* 
pPayload)
 ++ppCoordinate;
 if (!*ppCoordinate)
 return aRet;
-aRet.width = atoi(*ppCoordinate);
+long l = atol(*ppCoordinate);
+if (l > std::numeric_limits::max())
+aRet.width = std::numeric_limits::max();
+else
+aRet.width = l;
 if (aRet.x + aRet.width > priv->m_nDocumentWidthTwips)
 aRet.width = priv->m_nDocumentWidthTwips - aRet.x;
 ++ppCoordinate;
 if (!*ppCoordinate)
 return aRet;
-aRet.height = atoi(*ppCoordinate);
+l = atol(*ppCoordinate);
+if (l > std::numeric_limits::max())
+aRet.height = std::numeric_limits::max();
+else
+aRet.height = l;
 if (aRet.y + aRet.height > priv->m_nDocumentHeightTwips)
 aRet.height = priv->m_nDocumentHeightTwips - aRet.y;
 g_strfreev(ppCoordinates);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-09-12 Thread Marco Cecchetti
 libreofficekit/source/gtk/lokdocview.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit b7b62d4a59bb274dffed93489068ceb3342f717e
Author: Marco Cecchetti 
Date:   Mon Sep 12 10:49:28 2016 +0200

gtktiledviewer - Calc fix: selection handlers were not removed

Change-Id: I2b4ad4dbf281458d0994eff176a2f62e20fb603b

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 0699322..e2ea5ca 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1054,6 +1054,9 @@ payloadToRectangles(LOKDocView* pDocView, const char* 
pPayload)
 {
 std::vector aRet;
 
+if (g_strcmp0(pPayload, "EMPTY") == 0)
+   return aRet;
+
 gchar** ppRectangles = g_strsplit(pPayload, "; ", 0);
 for (gchar** ppRectangle = ppRectangles; *ppRectangle; ++ppRectangle)
 aRet.push_back(payloadToRectangle(pDocView, *ppRectangle));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-08-31 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 127a34ef2cf9fe0ac13a273c12c6d45ef57eaf49
Author: Miklos Vajna 
Date:   Wed Aug 31 11:38:41 2016 +0200

lokdocview: handle empty LOK_CALLBACK_DOCUMENT_SIZE_CHANGED payload

Calc omits the document size in the payload in several cases, and
online.git handles that, so handle it in lokdocview as well for now,
instead of fixing up all the sc code to always emit the doc size in the
payload.

Change-Id: Ib2cca1770d2a160e32540e3a3158eb00bf13207b

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index fc8d3637..0699322 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1228,7 +1228,11 @@ callback (gpointer pData)
 break;
 case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
 {
-payloadToSize(pCallback->m_aPayload.c_str(), 
priv->m_nDocumentWidthTwips, priv->m_nDocumentHeightTwips);
+if (!pCallback->m_aPayload.empty())
+payloadToSize(pCallback->m_aPayload.c_str(), 
priv->m_nDocumentWidthTwips, priv->m_nDocumentHeightTwips);
+else
+priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, 
>m_nDocumentWidthTwips, >m_nDocumentHeightTwips);
+
 gtk_widget_set_size_request(GTK_WIDGET(pDocView),
 twipToPixel(priv->m_nDocumentWidthTwips, 
priv->m_fZoom),
 twipToPixel(priv->m_nDocumentHeightTwips, 
priv->m_fZoom));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-07-25 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |   26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

New commits:
commit 57c8915376dbb580760486071cac6533e05427bf
Author: Miklos Vajna 
Date:   Mon Jul 25 08:52:40 2016 +0200

lokdocview: draw a lock inside the lock indicator

Hopefully less confusing, the crossed out rectangle is also used inside
the tiles for deleted comments, and the two are independent.

Change-Id: Id06fbf6ec1b21dfbab1c126c3c432f91cf51430c
Reviewed-on: https://gerrit.libreoffice.org/27503
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index f604b58..3201ad3 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1789,19 +1789,19 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
 cairo_set_line_width(pCairo, 2.0);
 cairo_stroke(pCairo);
 
-// Cross it.
-cairo_move_to(pCairo,
-  twipToPixel(rRectangle.m_aRectangle.x, priv->m_fZoom),
-  twipToPixel(rRectangle.m_aRectangle.y, priv->m_fZoom));
-cairo_line_to(pCairo,
-  twipToPixel(rRectangle.m_aRectangle.x + 
rRectangle.m_aRectangle.width, priv->m_fZoom),
-  twipToPixel(rRectangle.m_aRectangle.y + 
rRectangle.m_aRectangle.height, priv->m_fZoom));
-cairo_move_to(pCairo,
-  twipToPixel(rRectangle.m_aRectangle.x, priv->m_fZoom),
-  twipToPixel(rRectangle.m_aRectangle.y + 
rRectangle.m_aRectangle.height, priv->m_fZoom));
-cairo_line_to(pCairo,
-  twipToPixel(rRectangle.m_aRectangle.x + 
rRectangle.m_aRectangle.width, priv->m_fZoom),
-  twipToPixel(rRectangle.m_aRectangle.y, priv->m_fZoom));
+// And a lock.
+cairo_rectangle(pCairo,
+twipToPixel(rRectangle.m_aRectangle.x + 
rRectangle.m_aRectangle.width, priv->m_fZoom) - 25,
+twipToPixel(rRectangle.m_aRectangle.y + 
rRectangle.m_aRectangle.height, priv->m_fZoom) - 15,
+20,
+10);
+cairo_fill(pCairo);
+cairo_arc(pCairo,
+  twipToPixel(rRectangle.m_aRectangle.x + 
rRectangle.m_aRectangle.width, priv->m_fZoom) - 15,
+  twipToPixel(rRectangle.m_aRectangle.y + 
rRectangle.m_aRectangle.height, priv->m_fZoom) - 15,
+  5,
+  180.0 * (M_PI/180.0),
+  360.0 * (M_PI/180.0));
 cairo_stroke(pCairo);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-07-19 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |   14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

New commits:
commit 3c425926d48e513937ad727a56ab7744ca379e63
Author: Miklos Vajna 
Date:   Tue Jul 19 15:57:29 2016 +0200

lokdocview: still allow view selections/cursors from other Writer views

Writer pages are exposed as parts, but it still makes sense showing
selections/cursors from other parts in that case.

Change-Id: Ic76d93291bde2d959c149cf2ef5eba7ed33a45e8
Reviewed-on: https://gerrit.libreoffice.org/27321
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 1e32785..d5a1dd3 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -172,9 +172,12 @@ struct LOKDocViewPrivateImpl
 /// View ID, returned by createView() or 0 by default.
 int m_nViewId;
 
-/// Part ID, returned by getPart().
+/// Cached part ID, returned by getPart().
 int m_nPartId;
 
+/// Cached document type, returned by getDocumentType().
+LibreOfficeKitDocumentType m_eDocumentType;
+
 /**
  * Contains a freshly set zoom level: logic size of a tile.
  * It gets reset back to 0 when LOK was informed about this zoom change.
@@ -1601,7 +1604,8 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
 if (itVisibility != priv->m_aViewCursorVisibilities.end() && 
!itVisibility->second)
 continue;
 
-if (rPair.second.m_nPart != priv->m_nPartId)
+// Show view cursors when in Writer or when the part matches.
+if (rPair.second.m_nPart != priv->m_nPartId && 
priv->m_eDocumentType != LOK_DOCTYPE_TEXT)
 continue;
 
 GdkRectangle& rCursor = rPair.second.m_aRectangle;
@@ -1677,7 +1681,7 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
 // Selections of other views.
 for (auto& rPair : priv->m_aTextViewSelectionRectangles)
 {
-if (rPair.second.m_nPart != priv->m_nPartId)
+if (rPair.second.m_nPart != priv->m_nPartId && priv->m_eDocumentType 
!= LOK_DOCTYPE_TEXT)
 continue;
 
 for (GdkRectangle& rRectangle : rPair.second.m_aRectangles)
@@ -1704,7 +1708,7 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
 for (auto& rPair : priv->m_aGraphicViewSelections)
 {
 const ViewRectangle& rRectangle = rPair.second;
-if (rRectangle.m_nPart != priv->m_nPartId)
+if (rRectangle.m_nPart != priv->m_nPartId && priv->m_eDocumentType != 
LOK_DOCTYPE_TEXT)
 continue;
 
 const GdkRGBA& rDark = getDarkColor(rPair.first);
@@ -2061,6 +2065,7 @@ openDocumentInThread (gpointer data)
 
 priv->m_pOffice->pClass->registerCallback(priv->m_pOffice, 
globalCallbackWorker, pDocView);
 priv->m_pDocument = priv->m_pOffice->pClass->documentLoad( 
priv->m_pOffice, priv->m_aDocPath );
+priv->m_eDocumentType = 
static_cast(priv->m_pDocument->pClass->getDocumentType(priv->m_pDocument));
 if ( !priv->m_pDocument )
 {
 char *pError = priv->m_pOffice->pClass->getError( priv->m_pOffice );
@@ -2334,6 +2339,7 @@ static void lok_doc_view_set_property (GObject* object, 
guint propId, const GVal
 break;
 case PROP_DOC_POINTER:
 priv->m_pDocument = 
static_cast(g_value_get_pointer(value));
+priv->m_eDocumentType = 
static_cast(priv->m_pDocument->pClass->getDocumentType(priv->m_pDocument));
 break;
 case PROP_EDITABLE:
 lok_doc_view_set_edit (pDocView, g_value_get_boolean (value));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-07-19 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |   91 +++
 1 file changed, 68 insertions(+), 23 deletions(-)

New commits:
commit 1ba00c2173938ed2ea2f25074e866ea51370d727
Author: Miklos Vajna 
Date:   Tue Jul 19 11:14:52 2016 +0200

lokdocview: handle part number in view selections/cursors

This way we show view selections/cursors from other views only in case
the part number matches. Anything else looks buggy in Calc/Impress.

Change-Id: If3ecbfc4b05350606730319b1a570afc15fd9d0a
Reviewed-on: https://gerrit.libreoffice.org/27315
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 198dfd8..1e32785 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -48,6 +48,32 @@
 /// This is expected to be locked during setView(), doSomethingElse() LOK 
calls.
 std::mutex g_aLOKMutex;
 
+/// Same as a GdkRectangle, but also tracks in which part the rectangle is.
+struct ViewRectangle
+{
+int m_nPart;
+GdkRectangle m_aRectangle;
+
+ViewRectangle(int nPart = 0, const GdkRectangle& rRectangle = 
GdkRectangle())
+: m_nPart(nPart),
+m_aRectangle(rRectangle)
+{
+}
+};
+
+/// Same as a list of GdkRectangles, but also tracks in which part the 
rectangle is.
+struct ViewRectangles
+{
+int m_nPart;
+std::vector m_aRectangles;
+
+ViewRectangles(int nPart = 0, const std::vector& rRectangles 
= std::vector())
+: m_nPart(nPart),
+m_aRectangles(rRectangles)
+{
+}
+};
+
 /// Private struct used by this GObject type
 struct LOKDocViewPrivateImpl
 {
@@ -78,7 +104,7 @@ struct LOKDocViewPrivateImpl
 GdkRectangle m_aVisibleCursor;
 /// Position and size of the view cursors. The current view can only see
 /// them, can't modify them. Key is the view id.
-std::map m_aViewCursors;
+std::map m_aViewCursors;
 /// Cursor overlay is visible or hidden (for blinking).
 gboolean m_bCursorOverlayVisible;
 /// Cursor is visible or hidden (e.g. for graphic selection).
@@ -98,7 +124,7 @@ struct LOKDocViewPrivateImpl
 std::vector m_aTextSelectionRectangles;
 /// Rectangles of view selections. The current view can only see
 /// them, can't modify them. Key is the view id.
-std::map m_aTextViewSelectionRectangles;
+std::map m_aTextViewSelectionRectangles;
 /// Position and size of the selection start (as if there would be a 
cursor caret there).
 GdkRectangle m_aTextSelectionStart;
 /// Position and size of the selection end.
@@ -106,11 +132,11 @@ struct LOKDocViewPrivateImpl
 GdkRectangle m_aGraphicSelection;
 /// Position and size of the graphic view selections. The current view can 
only
 /// see them, can't modify them. Key is the view id.
-std::map m_aGraphicViewSelections;
+std::map m_aGraphicViewSelections;
 GdkRectangle m_aCellCursor;
 /// Position and size of the cell view cursors. The current view can only
 /// see them, can't modify them. Key is the view id.
-std::map m_aCellViewCursors;
+std::map m_aCellViewCursors;
 gboolean m_bInDragGraphicSelection;
 
 /// @name Start/middle/end handle.
@@ -146,6 +172,9 @@ struct LOKDocViewPrivateImpl
 /// View ID, returned by createView() or 0 by default.
 int m_nViewId;
 
+/// Part ID, returned by getPart().
+int m_nPartId;
+
 /**
  * Contains a freshly set zoom level: logic size of a tile.
  * It gets reset back to 0 when LOK was informed about this zoom change.
@@ -197,6 +226,7 @@ struct LOKDocViewPrivateImpl
 m_aHandleEndRect({0, 0, 0, 0}),
 m_bInDragEndHandle(false),
 m_nViewId(0),
+m_nPartId(0),
 m_nTileSizeTwips(0),
 m_aVisibleArea({0, 0, 0, 0}),
 m_bVisibleAreaSet(false),
@@ -850,7 +880,9 @@ static void reportError(LOKDocView* /*pDocView*/, const 
std::string& rString)
 static void
 setPart(LOKDocView* pDocView, const std::string& rString)
 {
-g_signal_emit(pDocView, doc_view_signals[PART_CHANGED], 0, 
std::stoi(rString));
+LOKDocViewPrivate& priv = getPrivate(pDocView);
+priv->m_nPartId = std::stoi(rString);
+g_signal_emit(pDocView, doc_view_signals[PART_CHANGED], 0, 
priv->m_nPartId);
 }
 
 static void
@@ -1142,9 +1174,10 @@ callback (gpointer pData)
 boost::property_tree::ptree aTree;
 boost::property_tree::read_json(aStream, aTree);
 int nViewId = aTree.get("viewId");
+int nPart = aTree.get("part");
 const std::string& rRectangle = aTree.get("selection");
 if (rRectangle != "EMPTY")
-priv->m_aGraphicViewSelections[nViewId] = 

[Libreoffice-commits] core.git: libreofficekit/source

2016-07-13 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |5 +
 1 file changed, 5 insertions(+)

New commits:
commit a54d466edc456be5dfd5c695c6b99f570e228916
Author: Pranav Kant 
Date:   Wed Jul 13 12:18:04 2016 +0530

lokdocview: This can be fired even without document

... so handle it and avoid the assert

Change-Id: Ib244746fabeaf41b5ca927d94fc4c3bda19bef26

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 34c2cae..613a909 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -932,6 +932,11 @@ globalCallback (gpointer pData)
 g_signal_emit (pCallback->m_pDocView, 
doc_view_signals[PASSWORD_REQUIRED], 0, pURL, bModify);
 }
 break;
+case LOK_CALLBACK_ERROR:
+{
+reportError(pCallback->m_pDocView, pCallback->m_aPayload);
+}
+break;
 default:
 g_assert(false);
 break;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-07-13 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |4 
 1 file changed, 4 insertions(+)

New commits:
commit 5ff1e6bdf7f5b9db3b72d62537047fc45b7d104b
Author: Pranav Kant 
Date:   Wed Jul 13 12:02:43 2016 +0530

lokdocview: Add missing callbacks

Change-Id: I2fd32bb210f1b5f0a090c29af707cb6ca6e8dd77

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index f65bfcd..34c2cae 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -369,6 +369,10 @@ callbackTypeToString (int nType)
 return "LOK_CALLBACK_CELL_VIEW_CURSOR";
 case LOK_CALLBACK_CELL_FORMULA:
 return "LOK_CALLBACK_CELL_FORMULA";
+case LOK_CALLBACK_UNO_COMMAND_RESULT:
+return "LOK_CALLBACK_UNO_COMMAND_RESULT";
+case LOK_CALLBACK_ERROR:
+return "LOK_CALLBACK_ERROR";
 }
 g_assert(false);
 return nullptr;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-07-12 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 29089b562ea6d0137cf054d9710b7238e327aa4f
Author: Miklos Vajna 
Date:   Tue Jul 12 11:29:52 2016 +0200

lokdocview: log the view id of the callback messages

So that e.g. it's possible to see which invalidation affects which view.

Change-Id: I6b6db2fa07eaecd1315ce8160c3b3b86e9e5a348
Reviewed-on: https://gerrit.libreoffice.org/27138
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 667b4d4..f65bfcd 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1271,7 +1271,10 @@ static void callbackWorker (int nType, const char* 
pPayload, void* pData)
 LOKDocView* pDocView = LOK_DOC_VIEW (pData);
 
 CallbackData* pCallback = new CallbackData(nType, pPayload ? pPayload : 
"(nil)", pDocView);
-g_info("callbackWorker: %s, '%s'", callbackTypeToString(nType), pPayload);
+LOKDocViewPrivate& priv = getPrivate(pDocView);
+std::stringstream ss;
+ss << "callbackWorker, view #" << priv->m_nViewId << ": " << 
callbackTypeToString(nType) << ", '" << pPayload << "'";
+g_info("%s", ss.str().c_str());
 gdk_threads_add_idle(callback, pCallback);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-06-30 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |4 
 1 file changed, 4 deletions(-)

New commits:
commit bfd4234fd863ee75f4f07d9bded061063bbde3d4
Author: Miklos Vajna 
Date:   Thu Jun 30 09:13:52 2016 +0200

lokdocview: avoid pointless setView() before getView()

This fixes the following use-case:

1) Start gtktiledviewer, click New View
2) Click Edit in the first view
3) Click somewhere in the document in the first view -> nothing happens

Change-Id: I79d63538607f03b78851a639adf158d918745276
Reviewed-on: https://gerrit.libreoffice.org/26789
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index c27a1f9..8e2d278 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -848,10 +848,6 @@ static gboolean postDocumentLoad(gpointer pData)
 LOKDocViewPrivate& priv = getPrivate(pLOKDocView);
 
 std::unique_lock aGuard(g_aLOKMutex);
-std::stringstream ss;
-ss << "lok::Document::setView(" << priv->m_nViewId << ")";
-g_info("%s", ss.str().c_str());
-priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
 priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, 
priv->m_aRenderingArguments.c_str());
 priv->m_nViewId = priv->m_pDocument->pClass->getView(priv->m_pDocument);
 priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, 
callbackWorker, pLOKDocView);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-06-22 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |   23 +++
 1 file changed, 23 insertions(+)

New commits:
commit 380a646b957052f96b3f9440d20dc63fc72e1d46
Author: Miklos Vajna 
Date:   Wed Jun 22 08:02:46 2016 +0200

lokdocview: ensure setView() + doSomethingElse is atomic

Otherwise it's possible that a keystroke is sent in for a different view,
when that other view reacts to an invalidation (invoking paintTile())
caused by a previous keystroke.

I.e. open two views, place the cursor at different positions, type fast,
and some of the characters appeared at the incorrect view.

Change-Id: Ie5e471f1b9c2d69adaa87111fba74d4abe184ef8
Reviewed-on: https://gerrit.libreoffice.org/26562
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 1d629b9..5510cde 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -44,6 +45,9 @@
 // Minimum Zoom allowed
 #define MIN_ZOOM 0.25f
 
+/// This is expected to be locked during setView(), doSomethingElse() LOK 
calls.
+std::mutex g_aLOKMutex;
+
 /// Private struct used by this GObject type
 struct LOKDocViewPrivateImpl
 {
@@ -581,6 +585,7 @@ postKeyEventInThread(gpointer data)
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
+std::unique_lock aGuard(g_aLOKMutex);
 std::stringstream ss;
 ss << "lok::Document::setView(" << priv->m_nViewId << ")";
 g_info("%s", ss.str().c_str());
@@ -842,6 +847,7 @@ static gboolean postDocumentLoad(gpointer pData)
 LOKDocView* pLOKDocView = static_cast(pData);
 LOKDocViewPrivate& priv = getPrivate(pLOKDocView);
 
+std::unique_lock aGuard(g_aLOKMutex);
 std::stringstream ss;
 ss << "lok::Document::setView(" << priv->m_nViewId << ")";
 g_info("%s", ss.str().c_str());
@@ -851,6 +857,7 @@ static gboolean postDocumentLoad(gpointer pData)
 priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, 
callbackWorker, pLOKDocView);
 priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, 
>m_nDocumentWidthTwips, >m_nDocumentHeightTwips);
 priv->m_nParts = priv->m_pDocument->pClass->getParts(priv->m_pDocument);
+aGuard.unlock();
 g_timeout_add(600, handleTimeout, pLOKDocView);
 
 float zoom = priv->m_fZoom;
@@ -1733,6 +1740,7 @@ lok_doc_view_signal_motion (GtkWidget* pWidget, 
GdkEventMotion* pEvent)
 GdkPoint aPoint;
 GError* error = nullptr;
 
+std::unique_lock aGuard(g_aLOKMutex);
 std::stringstream ss;
 ss << "lok::Document::setView(" << priv->m_nViewId << ")";
 g_info("%s", ss.str().c_str());
@@ -1758,6 +1766,7 @@ lok_doc_view_signal_motion (GtkWidget* pWidget, 
GdkEventMotion* pEvent)
 priv->m_pDocument->pClass->setTextSelection(priv->m_pDocument, 
LOK_SETTEXTSELECTION_END, pixelToTwip(aPoint.x, priv->m_fZoom), 
pixelToTwip(aPoint.y, priv->m_fZoom));
 return FALSE;
 }
+aGuard.unlock();
 for (int i = 0; i < GRAPHIC_HANDLE_COUNT; ++i)
 {
 if (priv->m_bInDragGraphicHandles[i])
@@ -1832,6 +1841,7 @@ setGraphicSelectionInThread(gpointer data)
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
+std::lock_guard aGuard(g_aLOKMutex);
 std::stringstream ss;
 ss << "lok::Document::setView(" << priv->m_nViewId << ")";
 g_info("%s", ss.str().c_str());
@@ -1855,6 +1865,7 @@ setClientZoomInThread(gpointer data)
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
+std::lock_guard aGuard(g_aLOKMutex);
 priv->m_pDocument->pClass->setClientZoom(priv->m_pDocument,
  pLOEvent->m_nTilePixelWidth,
  pLOEvent->m_nTilePixelHeight,
@@ -1870,6 +1881,7 @@ postMouseEventInThread(gpointer data)
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
+std::lock_guard aGuard(g_aLOKMutex);
 std::stringstream ss;
 ss << "lok::Document::setView(" << priv->m_nViewId << ")";
 g_info("%s", ss.str().c_str());
@@ -1898,6 +1910,7 @@ openDocumentInThread (gpointer data)
 LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 
+std::lock_guard aGuard(g_aLOKMutex);
 if ( priv->m_pDocument )
 {
 priv->m_pDocument->pClass->destroy( priv->m_pDocument );
@@ -1927,11 +1940,13 @@ setPartInThread(gpointer data)
 LOEvent* pLOEvent = 

[Libreoffice-commits] core.git: libreofficekit/source sw/qa

2016-06-21 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx   |1 
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   41 +++--
 2 files changed, 38 insertions(+), 4 deletions(-)

New commits:
commit 45182f36ef263d6fd94cc79bb242fbfb5a471c22
Author: Miklos Vajna 
Date:   Tue Jun 21 14:28:08 2016 +0200

sw: add LOK_CALLBACK_TEXT_VIEW_SELECTION testcase

Fails with 9f66db9c474f71f43d7a3667230241fd4fa4183f (sw lok: add
LOK_CALLBACK_TEXT_VIEW_SELECTION, 2016-06-21) reverted.

Change-Id: Ide21167ce2dc4287b1860b5f03a6975dc9edd4c6
Reviewed-on: https://gerrit.libreoffice.org/26550
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 802be93..1d629b9 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1039,7 +1039,6 @@ callback (gpointer pData)
   priv->m_aVisibleCursor.y,
   priv->m_aVisibleCursor.width,
   priv->m_aVisibleCursor.height);
-std::cerr << "debug, LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: i am " << 
priv->m_nViewId << ", i got " << pCallback->m_aPayload << " for myself" << 
std::endl;
 gtk_widget_queue_draw(GTK_WIDGET(pDocView));
 }
 break;
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index a24042f..240a27c 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -225,7 +225,7 @@ void SwTiledRenderingTest::testSetTextSelection()
 SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
 // Move the cursor into the second word.
 pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 5, 
/*bBasicCall=*/false);
-// Create a selection by on the word.
+// Create a selection on the word.
 pWrtShell->SelWrd();
 SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
 // Did we indeed manage to select the second word?
@@ -548,10 +548,14 @@ class ViewCallback
 public:
 bool m_bOwnCursorInvalidated;
 bool m_bViewCursorInvalidated;
+bool m_bOwnSelectionSet;
+bool m_bViewSelectionSet;
 
 ViewCallback()
 : m_bOwnCursorInvalidated(false),
-  m_bViewCursorInvalidated(false)
+  m_bViewCursorInvalidated(false),
+  m_bOwnSelectionSet(false),
+  m_bViewSelectionSet(false)
 {
 }
 
@@ -574,6 +578,16 @@ public:
 m_bViewCursorInvalidated = true;
 }
 break;
+case LOK_CALLBACK_TEXT_SELECTION:
+{
+m_bOwnSelectionSet = true;
+}
+break;
+case LOK_CALLBACK_TEXT_VIEW_SELECTION:
+{
+m_bViewSelectionSet = true;
+}
+break;
 }
 }
 };
@@ -582,7 +596,7 @@ void SwTiledRenderingTest::testViewCursors()
 {
 comphelper::LibreOfficeKit::setActive();
 
-createDoc("dummy.fodt");
+SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
 ViewCallback aView1;
 
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(::callback,
 );
 SfxLokHelper::createView();
@@ -595,6 +609,27 @@ void SwTiledRenderingTest::testViewCursors()
 // it changed.
 CPPUNIT_ASSERT(aView2.m_bViewCursorInvalidated);
 
+// Make sure that aView1 gets a view-only selection notification, while
+// aView2 gets a real selection notification.
+aView1.m_bOwnSelectionSet = false;
+aView1.m_bViewSelectionSet = false;
+aView2.m_bOwnSelectionSet = false;
+aView2.m_bViewSelectionSet = false;
+SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+// Move the cursor into the second word.
+pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 5, 
/*bBasicCall=*/false);
+// Create a selection on the word.
+pWrtShell->SelWrd();
+SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
+// Did we indeed manage to select the second word?
+CPPUNIT_ASSERT_EQUAL(OUString("bbb"), pShellCursor->GetText());
+CPPUNIT_ASSERT(!aView1.m_bOwnSelectionSet);
+// This failed, aView1 did not get notification about selection changes in
+// aView2.
+CPPUNIT_ASSERT(aView1.m_bViewSelectionSet);
+CPPUNIT_ASSERT(aView2.m_bOwnSelectionSet);
+CPPUNIT_ASSERT(!aView2.m_bViewSelectionSet);
+
 comphelper::LibreOfficeKit::setActive(false);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-06-21 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |   30 --
 1 file changed, 28 insertions(+), 2 deletions(-)

New commits:
commit 6b9053d371fc8b8543faf7add5fb6d61aab26605
Author: Miklos Vajna 
Date:   Tue Jun 21 11:30:04 2016 +0200

lokdocview: handle LOK_CALLBACK_TEXT_VIEW_SELECTION

It's similar to the normal selection, but it's colored and has no
handles.

Change-Id: Ibd9594b4834ff4f9b1cfd85912ed5cee3c8b8c71
Reviewed-on: https://gerrit.libreoffice.org/26543
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 39676f3..802be93 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -89,6 +89,9 @@ struct LOKDocViewPrivateImpl
 guint32 m_nKeyModifier;
 /// Rectangles of the current text selection.
 std::vector m_aTextSelectionRectangles;
+/// Rectangles of view selections. The current view can only see
+/// them, can't modify them. Key is the view id.
+std::map 
m_aTextViewSelectionRectangles;
 /// Position and size of the selection start (as if there would be a 
cursor caret there).
 GdkRectangle m_aTextSelectionStart;
 /// Position and size of the selection end.
@@ -1179,7 +1182,13 @@ callback (gpointer pData)
 }
 case LOK_CALLBACK_TEXT_VIEW_SELECTION:
 {
-// TODO: Implement me
+std::stringstream aStream(pCallback->m_aPayload);
+boost::property_tree::ptree aTree;
+boost::property_tree::read_json(aStream, aTree);
+std::uintptr_t nViewId = aTree.get("viewId");
+const std::string& rSelection = aTree.get("selection");
+priv->m_aTextViewSelectionRectangles[nViewId] = 
payloadToRectangles(pDocView, rSelection.c_str());
+gtk_widget_queue_draw(GTK_WIDGET(pDocView));
 break;
 }
 default:
@@ -1475,7 +1484,7 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
 // Set a minimal width if it would be 0.
 rCursor.width = 30;
 
-const GdkRGBA& rDark = getDarkColor(priv->m_nViewId);
+const GdkRGBA& rDark = getDarkColor(rPair.first);
 cairo_set_source_rgb(pCairo, rDark.red, rDark.green, rDark.blue);
 cairo_rectangle(pCairo,
 twipToPixel(rCursor.x, priv->m_fZoom),
@@ -1540,6 +1549,23 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
 }
 }
 
+// Selections of other views.
+for (std::pair>& rPair : 
priv->m_aTextViewSelectionRectangles)
+{
+for (GdkRectangle& rRectangle : rPair.second)
+{
+const GdkRGBA& rDark = getDarkColor(rPair.first);
+// 75% transparency.
+cairo_set_source_rgba(pCairo, rDark.red, rDark.green, rDark.blue, 
0.25);
+cairo_rectangle(pCairo,
+twipToPixel(rRectangle.x, priv->m_fZoom),
+twipToPixel(rRectangle.y, priv->m_fZoom),
+twipToPixel(rRectangle.width, priv->m_fZoom),
+twipToPixel(rRectangle.height, priv->m_fZoom));
+cairo_fill(pCairo);
+}
+}
+
 if (!isEmptyRectangle(priv->m_aGraphicSelection))
 {
 gchar* handleGraphicPath = g_strconcat (priv->m_aLOPath, 
CURSOR_HANDLE_DIR, "handle_graphic.png", nullptr);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-06-20 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |   59 ++-
 1 file changed, 58 insertions(+), 1 deletion(-)

New commits:
commit ada901d2c412f8a1b1ae668e883114ccb9c69277
Author: Miklos Vajna 
Date:   Mon Jun 20 17:14:30 2016 +0200

lokdocview: handle LOK_CALLBACK_INVALIDATE_VIEW_CURSOR

It's similar to the normal cursor, but it's colored and does not blink.

Change-Id: I6a869a98f46979946f320905426e016fe011cbc6
Reviewed-on: https://gerrit.libreoffice.org/26522
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index d4ca4a9..90f01d9 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -72,6 +72,9 @@ struct LOKDocViewPrivateImpl
 gint m_nParts;
 /// Position and size of the visible cursor.
 GdkRectangle m_aVisibleCursor;
+/// Position and size of the view cursors. The current view can only see
+/// them, can't modify them. Key is the view id.
+std::map m_aViewCursors;
 /// Cursor overlay is visible or hidden (for blinking).
 gboolean m_bCursorOverlayVisible;
 /// Cursor is visible or hidden (e.g. for graphic selection).
@@ -1031,6 +1034,7 @@ callback (gpointer pData)
   priv->m_aVisibleCursor.y,
   priv->m_aVisibleCursor.width,
   priv->m_aVisibleCursor.height);
+std::cerr << "debug, LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: i am " << 
priv->m_nViewId << ", i got " << pCallback->m_aPayload << " for myself" << 
std::endl;
 gtk_widget_queue_draw(GTK_WIDGET(pDocView));
 }
 break;
@@ -1162,7 +1166,13 @@ callback (gpointer pData)
 }
 case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
 {
-// TODO: Implement me
+std::stringstream aStream(pCallback->m_aPayload);
+boost::property_tree::ptree aTree;
+boost::property_tree::read_json(aStream, aTree);
+std::uintptr_t nViewId = aTree.get("viewId");
+const std::string& rRectangle = aTree.get("rectangle");
+priv->m_aViewCursors[nViewId] = payloadToRectangle(pDocView, 
rRectangle.c_str());
+gtk_widget_queue_draw(GTK_WIDGET(pDocView));
 break;
 }
 default:
@@ -1402,6 +1412,32 @@ renderDocument(LOKDocView* pDocView, cairo_t* pCairo)
 return FALSE;
 }
 
+static const GdkRGBA& getDarkColor(std::uintptr_t nViewId)
+{
+static std::map aColorMap;
+auto it = aColorMap.find(nViewId);
+if (it != aColorMap.end())
+return it->second;
+
+// Based on tools/colordata.hxx, COL_AUTHOR1_DARK..COL_AUTHOR9_DARK.
+static std::vector aColors =
+{
+{((double)198)/255, ((double)146)/255, ((double)0)/255, 0},
+{((double)6)/255, ((double)70)/255, ((double)162)/255, 0},
+{((double)87)/255, ((double)157)/255, ((double)28)/255, 0},
+{((double)105)/255, ((double)43)/255, ((double)157)/255, 0},
+{((double)197)/255, ((double)0)/255, ((double)11)/255, 0},
+{((double)0)/255, ((double)128)/255, ((double)128)/255, 0},
+{((double)140)/255, ((double)132)/255, ((double)0)/255, 0},
+{((double)43)/255, ((double)85)/255, ((double)107)/255, 0},
+{((double)209)/255, ((double)118)/255, ((double)0)/255, 0},
+};
+static int nColorCounter = 0;
+GdkRGBA aColor = aColors[nColorCounter++ % aColors.size()];
+aColorMap[nViewId] = aColor;
+return aColorMap[nViewId];
+}
+
 static gboolean
 renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
 {
@@ -1422,6 +1458,27 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
 cairo_fill(pCairo);
 }
 
+// View cursors: they do not blink and are colored.
+if (priv->m_bEdit && !priv->m_aViewCursors.empty())
+{
+for (auto& rPair : priv->m_aViewCursors)
+{
+GdkRectangle& rCursor = rPair.second;
+if (rCursor.width < 30)
+// Set a minimal width if it would be 0.
+rCursor.width = 30;
+
+const GdkRGBA& rDark = getDarkColor(priv->m_nViewId);
+cairo_set_source_rgb(pCairo, rDark.red, rDark.green, rDark.blue);
+cairo_rectangle(pCairo,
+twipToPixel(rCursor.x, priv->m_fZoom),
+twipToPixel(rCursor.y, priv->m_fZoom),
+twipToPixel(rCursor.width, priv->m_fZoom),
+twipToPixel(rCursor.height, priv->m_fZoom));
+cairo_fill(pCairo);
+}
+}
+
 if (priv->m_bEdit && priv->m_bCursorVisible && 
!isEmptyRectangle(priv->m_aVisibleCursor) && 
priv->m_aTextSelectionRectangles.empty())
 {
 // Have a cursor, but no selection: we need the middle handle.

[Libreoffice-commits] core.git: libreofficekit/source

2016-06-14 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |   55 +--
 1 file changed, 46 insertions(+), 9 deletions(-)

New commits:
commit 60e57960f25202f7b23bf4dbbda46780fb6032a9
Author: Miklos Vajna 
Date:   Tue Jun 14 11:41:24 2016 +0200

lok_doc_view_reset_view: don't touch the view id

Otherwise the following can happen:

- view #0 is created
- view #1 is created
- view #1 changes part, so lok_doc_view_reset_view() gets called
- view #1 calls postMouseEvent(), but claims it happened on view #0

Also log all setView() calls in the widget.

Change-Id: Iefcf82d9396b2af75586e79dde59998320f41d60
Reviewed-on: https://gerrit.libreoffice.org/26245
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 38b1a6d..dc986da 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -571,11 +571,14 @@ postKeyEventInThread(gpointer data)
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
+std::stringstream ss;
+ss << "lok::Document::setView(" << priv->m_nViewId << ")";
+g_info("%s", ss.str().c_str());
 priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
 
 if (priv->m_nTileSizeTwips)
 {
-std::stringstream ss;
+ss.str(std::string());
 ss << "lok::Document::setClientZoom(" << nTileSizePixels << ", " << 
nTileSizePixels << ", " << priv->m_nTileSizeTwips << ", " << 
priv->m_nTileSizeTwips << ")";
 g_info("%s", ss.str().c_str());
 priv->m_pDocument->pClass->setClientZoom(priv->m_pDocument,
@@ -587,7 +590,7 @@ postKeyEventInThread(gpointer data)
 }
 if (priv->m_bVisibleAreaSet)
 {
-std::stringstream ss;
+ss.str(std::string());
 ss << "lok::Document::setClientVisibleArea(" << priv->m_aVisibleArea.x 
<< ", " << priv->m_aVisibleArea.y << ", ";
 ss << priv->m_aVisibleArea.width << ", " << 
priv->m_aVisibleArea.height << ")";
 g_info("%s", ss.str().c_str());
@@ -599,7 +602,7 @@ postKeyEventInThread(gpointer data)
 priv->m_bVisibleAreaSet = false;
 }
 
-std::stringstream ss;
+ss.str(std::string());
 ss << "lok::Document::postKeyEvent(" << pLOEvent->m_nKeyEvent << ", " << 
pLOEvent->m_nCharCode << ", " << pLOEvent->m_nKeyCode << ")";
 g_info("%s", ss.str().c_str());
 priv->m_pDocument->pClass->postKeyEvent(priv->m_pDocument,
@@ -829,6 +832,9 @@ static gboolean postDocumentLoad(gpointer pData)
 LOKDocView* pLOKDocView = static_cast(pData);
 LOKDocViewPrivate& priv = getPrivate(pLOKDocView);
 
+std::stringstream ss;
+ss << "lok::Document::setView(" << priv->m_nViewId << ")";
+g_info("%s", ss.str().c_str());
 priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
 priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, 
priv->m_aRenderingArguments.c_str());
 priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, 
callbackWorker, pLOKDocView);
@@ -1630,6 +1636,9 @@ lok_doc_view_signal_motion (GtkWidget* pWidget, 
GdkEventMotion* pEvent)
 GdkPoint aPoint;
 GError* error = nullptr;
 
+std::stringstream ss;
+ss << "lok::Document::setView(" << priv->m_nViewId << ")";
+g_info("%s", ss.str().c_str());
 priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
 if (priv->m_bInDragMiddleHandle)
 {
@@ -1726,8 +1735,11 @@ setGraphicSelectionInThread(gpointer data)
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
-priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
 std::stringstream ss;
+ss << "lok::Document::setView(" << priv->m_nViewId << ")";
+g_info("%s", ss.str().c_str());
+priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
+ss.str(std::string());
 ss << "lok::Document::setGraphicSelection(" << 
pLOEvent->m_nSetGraphicSelectionType;
 ss << ", " << pLOEvent->m_nSetGraphicSelectionX;
 ss << ", " << pLOEvent->m_nSetGraphicSelectionY << ")";
@@ -1761,8 +1773,11 @@ postMouseEventInThread(gpointer data)
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
-priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
 std::stringstream ss;
+ss << "lok::Document::setView(" << priv->m_nViewId << ")";
+g_info("%s", ss.str().c_str());
+priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
+ss.str(std::string());
 ss << "lok::Document::postMouseEvent(" << pLOEvent->m_nPostMouseEventType;
 ss << ", " << 

[Libreoffice-commits] core.git: libreofficekit/source

2016-04-27 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |8 
 1 file changed, 8 insertions(+)

New commits:
commit 99ea437f7570ab59f186583f368398919db67c3a
Author: Miklos Vajna 
Date:   Wed Apr 27 15:09:35 2016 +0200

lokdocview: log postMouseEvent() arguments

Change-Id: Idd4db9259448d3dcf4e0820b8845a1ab395f0bff
Reviewed-on: https://gerrit.libreoffice.org/24427
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index d10eee8..9d5f656 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1762,6 +1762,14 @@ postMouseEventInThread(gpointer data)
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
 priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
+std::stringstream ss;
+ss << "lok::Document::postMouseEvent(" << pLOEvent->m_nPostMouseEventType;
+ss << ", " << pLOEvent->m_nPostMouseEventX;
+ss << ", " << pLOEvent->m_nPostMouseEventY;
+ss << ", " << pLOEvent->m_nPostMouseEventCount;
+ss << ", " << pLOEvent->m_nPostMouseEventButton;
+ss << ", " << pLOEvent->m_nPostMouseEventModifier << ")";
+g_info("%s", ss.str().c_str());
 priv->m_pDocument->pClass->postMouseEvent(priv->m_pDocument,
   pLOEvent->m_nPostMouseEventType,
   pLOEvent->m_nPostMouseEventX,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-04-26 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |5 +
 1 file changed, 5 insertions(+)

New commits:
commit f9ade68d8d432a5e771e9674284f454c0f4c250d
Author: Miklos Vajna 
Date:   Tue Apr 26 11:38:41 2016 +0200

lokdocview: log setGraphicSelection() arguments

Change-Id: I36af712274e1a3f9dacd5d62ab42032ca9e9acdd
Reviewed-on: https://gerrit.libreoffice.org/24390
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index fdb07fe..d10eee8 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1727,6 +1727,11 @@ setGraphicSelectionInThread(gpointer data)
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
 priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
+std::stringstream ss;
+ss << "lok::Document::setGraphicSelection(" << 
pLOEvent->m_nSetGraphicSelectionType;
+ss << ", " << pLOEvent->m_nSetGraphicSelectionX;
+ss << ", " << pLOEvent->m_nSetGraphicSelectionY << ")";
+g_info("%s", ss.str().c_str());
 priv->m_pDocument->pClass->setGraphicSelection(priv->m_pDocument,

pLOEvent->m_nSetGraphicSelectionType,

pLOEvent->m_nSetGraphicSelectionX,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-02-25 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 73e6b95ed249cf7cb1d46c1f40c0a537e757b1eb
Author: Miklos Vajna 
Date:   Thu Feb 25 21:21:08 2016 +0100

cid#1354270 fix uninitialized members

Change-Id: I35fda96885375996a1b0b05ecc04a0ac35104b88

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 3ecf52c..155174f 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -152,6 +152,7 @@ struct LOKDocViewPrivateImpl
 m_nDocumentHeightTwips(0),
 m_bEdit(FALSE),
 m_nLOKFeatures(0),
+m_nParts(0),
 m_aVisibleCursor({0, 0, 0, 0}),
 m_bCursorOverlayVisible(false),
 m_bCursorVisible(true),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-02-14 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 58ec66da422e5ac6aec5cbd28403039cded7c7ed
Author: Pranav Kant 
Date:   Sun Feb 14 20:44:00 2016 +0530

lokdocview: Center the widget vertically inside the allocation

Change-Id: I891519d54212ecd99273a54aca2a44e2d54c1933

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 742946d..baa4f6e 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2574,6 +2574,7 @@ lok_doc_view_new (const gchar* pPath, GCancellable 
*cancellable, GError **error)
 return GTK_WIDGET (g_initable_new (LOK_TYPE_DOC_VIEW, cancellable, error,
"lopath", pPath == nullptr ? LOK_PATH : 
pPath,
"halign", GTK_ALIGN_CENTER,
+   "valign", GTK_ALIGN_CENTER,
nullptr));
 }
 
@@ -2585,6 +2586,7 @@ SAL_DLLPUBLIC_EXPORT GtkWidget* 
lok_doc_view_new_from_widget(LOKDocView* pOldLOK
"lopointer", 
pOldPriv->m_pOffice,
"docpointer", 
pOldPriv->m_pDocument,
"halign", 
GTK_ALIGN_CENTER,
+   "valign", 
GTK_ALIGN_CENTER,
nullptr));
 
 // No documentLoad(), just a createView().
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-02-13 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit f01bac5cc2b54b6df731b45c46187fec12515b46
Author: Pranav Kant 
Date:   Sun Feb 14 02:53:16 2016 +0530

tdf#97301: Return silently when no document is loaded

Change-Id: Id6cf77ee7597fb992a306649c2f2a3639bf6dad8

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index c7dceaa..742946d 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2663,6 +2663,9 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 GError* error = nullptr;
 
+if (!priv->m_pDocument)
+return;
+
 // Clamp the input value in [MIN_ZOOM, MAX_ZOOM]
 fZoom = fZoom < MIN_ZOOM ? MIN_ZOOM : fZoom;
 fZoom = fZoom > MAX_ZOOM ? MAX_ZOOM : fZoom;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-02-05 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 12c59662f79a72ecf2c8faf6a9bf54b8acd4885a
Author: Miklos Vajna 
Date:   Fri Feb 5 21:03:07 2016 +0100

cid#1351879 missing break

Change-Id: I3e86b57b6384370666f023115ae7d4671f1eaca1

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index afaf71b..c7dceaa 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -877,6 +877,7 @@ globalCallback (gpointer pData)
 break;
 case LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY:
 bModify = true;
+// fallthrough
 case LOK_CALLBACK_DOCUMENT_PASSWORD:
 {
 char const*const pURL(pCallback->m_aPayload.c_str());
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-01-20 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

New commits:
commit 070bfedb7c0bc01ada0c0b95622543472ccb4a1c
Author: Pranav Kant 
Date:   Wed Jan 20 14:49:29 2016 +0530

lokdocview: Center the widget inside the allocation

Change-Id: I8d7f8ffb1c5ddd07ccf7d56bdf0ccc866c927401
Reviewed-on: https://gerrit.libreoffice.org/21624
Tested-by: Jenkins 
Reviewed-by: Pranav Kant 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index f70b15f..f63e9d6 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2405,14 +2405,21 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
 SAL_DLLPUBLIC_EXPORT GtkWidget*
 lok_doc_view_new (const gchar* pPath, GCancellable *cancellable, GError 
**error)
 {
-return GTK_WIDGET (g_initable_new (LOK_TYPE_DOC_VIEW, cancellable, error, 
"lopath", pPath == nullptr ? LOK_PATH : pPath, nullptr));
+return GTK_WIDGET (g_initable_new (LOK_TYPE_DOC_VIEW, cancellable, error,
+   "lopath", pPath == nullptr ? LOK_PATH : 
pPath,
+   "halign", GTK_ALIGN_CENTER,
+   nullptr));
 }
 
 SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new_from_widget(LOKDocView* 
pOldLOKDocView)
 {
 LOKDocViewPrivate& pOldPriv = getPrivate(pOldLOKDocView);
 GtkWidget* pNewDocView = GTK_WIDGET(g_initable_new(LOK_TYPE_DOC_VIEW, 
/*cancellable=*/nullptr, /*error=*/nullptr,
-   "lopath", 
pOldPriv->m_aLOPath, "lopointer", pOldPriv->m_pOffice, "docpointer", 
pOldPriv->m_pDocument, nullptr));
+   "lopath", 
pOldPriv->m_aLOPath,
+   "lopointer", 
pOldPriv->m_pOffice,
+   "docpointer", 
pOldPriv->m_pDocument,
+   "halign", 
GTK_ALIGN_CENTER,
+   nullptr));
 
 // No documentLoad(), just a createView().
 LibreOfficeKitDocument* pDocument = 
lok_doc_view_get_document(LOK_DOC_VIEW(pNewDocView));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-01-15 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |5 +
 1 file changed, 5 insertions(+)

New commits:
commit 42cf5fe3047f3f29db7194705deb9ab6d118478b
Author: Miklos Vajna 
Date:   Fri Jan 15 14:14:32 2016 +0100

libreofficekit: log document paste arguments

Change-Id: I0e7783cf73d2d4bfcd4f0c75ca3ad82336048b27

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 140479b..bca54bd 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2766,7 +2766,12 @@ lok_doc_view_paste (LOKDocView* pDocView,
 }
 
 if (pData)
+{
+std::stringstream ss;
+ss << "lok::Document::paste('" << pMimeType << "', '" << 
std::string(pData, nSize) << ", "<pClass->paste(pDocument, pMimeType, pData, nSize);
+}
 
 return ret;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-01-11 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 02b49890d51ec463d32846f1108344159664a9eb
Author: Pranav Kant 
Date:   Sun Jan 10 22:50:46 2016 +0530

lokdocview: Use shared_ptr to fix a possible memory leak

Possible because boost::property_tree can throw an exception.

Change-Id: I68394ce3b30d448d40d8e22555bafdff1ffa6092
Reviewed-on: https://gerrit.libreoffice.org/21309
Reviewed-by: David Tardon 
Tested-by: David Tardon 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 168338d..5df7746 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -343,13 +344,12 @@ doSearch(LOKDocView* pDocView, const char* pText, bool 
bBackwards, bool highligh
 boost::property_tree::ptree aTree;
 GtkWidget* drawingWidget = GTK_WIDGET(pDocView);
 GdkWindow* drawingWindow = gtk_widget_get_window(drawingWidget);
-cairo_region_t* cairoVisRegion = 
gdk_window_get_visible_region(drawingWindow);
+std::shared_ptr cairoVisRegion( 
gdk_window_get_visible_region(drawingWindow),
+cairo_region_destroy);
 cairo_rectangle_int_t cairoVisRect;
-int x, y;
-
-cairo_region_get_rectangle(cairoVisRegion, 0, );
-x = pixelToTwip (cairoVisRect.x, priv->m_fZoom);
-y = pixelToTwip (cairoVisRect.y, priv->m_fZoom);
+cairo_region_get_rectangle(cairoVisRegion.get(), 0, );
+int x = pixelToTwip (cairoVisRect.x, priv->m_fZoom);
+int y = pixelToTwip (cairoVisRect.y, priv->m_fZoom);
 
 
aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchString/type",
 '/'), "string");
 
aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchString/value",
 '/'), pText);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-01-11 Thread David Tardon
 libreofficekit/source/gtk/lokdocview.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 080a9c3a5107347a74bb17bad185d418561d9d77
Author: David Tardon 
Date:   Mon Jan 11 12:15:38 2016 +0100

iostream is not needed

Change-Id: I481b402e0d3b42de5b486a159acb8a25e345b8b8

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 5df7746..fcc170b 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -13,7 +13,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #include 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-01-11 Thread Stephan Bergmann
 libreofficekit/source/gtk/lokdocview.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit ac1f0b59043a02e4d430cade3cc5b8b069feed87
Author: Stephan Bergmann 
Date:   Mon Jan 11 13:24:33 2016 +0100

Silence loplugin:implicitboolconversion between bool and gboolean

Change-Id: I83ce360622eea0fb805833650c0d2126bcd5d8db

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 383f35f..87b6ca0 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2503,12 +2503,12 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float 
fZoom)
 // set properties to indicate if view can be further zoomed in/out
 bool bCanZoomIn  = priv->m_fZoom < MAX_ZOOM;
 bool bCanZoomOut = priv->m_fZoom > MIN_ZOOM;
-if (bCanZoomIn != priv->m_bCanZoomIn)
+if (bCanZoomIn != bool(priv->m_bCanZoomIn))
 {
 priv->m_bCanZoomIn = bCanZoomIn;
 g_object_notify_by_pspec(G_OBJECT(pDocView), 
properties[PROP_CAN_ZOOM_IN]);
 }
-if (bCanZoomOut != priv->m_bCanZoomOut)
+if (bCanZoomOut != bool(priv->m_bCanZoomOut))
 {
 priv->m_bCanZoomOut = bCanZoomOut;
 g_object_notify_by_pspec(G_OBJECT(pDocView), 
properties[PROP_CAN_ZOOM_OUT]);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-01-11 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 4200a678fb54f0fa5d2f0c26c655252f9267a527
Author: Pranav Kant 
Date:   Fri Dec 18 22:42:53 2015 +0530

tdf#96421: Return if no window is realized

Change-Id: I13de7e6eae4e73932e8441ba2e2ad3e4ff888f41
Reviewed-on: https://gerrit.libreoffice.org/20799
Tested-by: Jenkins 
Reviewed-by: David Tardon 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index fcc170b..c1f550a 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -344,6 +344,8 @@ doSearch(LOKDocView* pDocView, const char* pText, bool 
bBackwards, bool highligh
 boost::property_tree::ptree aTree;
 GtkWidget* drawingWidget = GTK_WIDGET(pDocView);
 GdkWindow* drawingWindow = gtk_widget_get_window(drawingWidget);
+if (!drawingWindow)
+return;
 std::shared_ptr cairoVisRegion( 
gdk_window_get_visible_region(drawingWindow),
 cairo_region_destroy);
 cairo_rectangle_int_t cairoVisRect;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2016-01-11 Thread Debarshi Ray
 libreofficekit/source/gtk/lokdocview.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 3ba1b60c97b342c13593d37ccf2b97a919808dfc
Author: Debarshi Ray 
Date:   Fri Jan 8 18:06:18 2016 +0100

lokdocview: Fix WARNING when creating an error

A GError needs a valid GQuark as the domain. Passing 0 leads to:
  GLib-WARNING **: (gerror.c:408):g_error_new_valist: runtime check
failed: (domain != 0)

Change-Id: I2f252eaa83a1519b5d16c7ba22c8f593732807ca
Reviewed-on: https://gerrit.libreoffice.org/21261
Tested-by: Jenkins 
Reviewed-by: Pranav Kant 
Reviewed-by: jan iversen 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 87b6ca0..140479b 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1684,7 +1684,7 @@ openDocumentInThread (gpointer data)
 if ( !priv->m_pDocument )
 {
 char *pError = priv->m_pOffice->pClass->getError( priv->m_pOffice );
-g_task_return_new_error(task, 0, 0, "%s", pError);
+g_task_return_new_error(task, g_quark_from_static_string ("LOK 
error"), 0, "%s", pError);
 }
 else
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-12-30 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |  187 ++-
 1 file changed, 90 insertions(+), 97 deletions(-)

New commits:
commit 81f31f5151b54899ac5461c9c7c4021cdf31a9a6
Author: Pranav Kant 
Date:   Fri Dec 18 21:51:23 2015 +0530

lokdocview: Use an array to install properties

This way we can directly reference any property by pointers to
GParamSpec stored in a static array, rather than looking for
property using property name. The former is a faster approach.

This will come in handy for functions, such as, g_object_notify
which needs to access properties to notify the object of any
property change in a faster way.

Change-Id: Ic4087bff3bdb63a3e8853d158c7af688e5e67811
Reviewed-on: https://gerrit.libreoffice.org/20797
Tested-by: Jenkins 
Reviewed-by: David Tardon 
Tested-by: David Tardon 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 55c7f78..1915c5f 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -205,10 +205,13 @@ enum
 PROP_DOC_WIDTH,
 PROP_DOC_HEIGHT,
 PROP_CAN_ZOOM_IN,
-PROP_CAN_ZOOM_OUT
+PROP_CAN_ZOOM_OUT,
+
+PROP_LAST
 };
 
 static guint doc_view_signals[LAST_SIGNAL] = { 0 };
+static GParamSpec *properties[PROP_LAST] = { nullptr };
 
 static void lok_doc_view_initable_iface_init (GInitableIface *iface);
 static void callbackWorker (int nType, const char* pPayload, void* pData);
@@ -2047,15 +2050,14 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
  *
  * The absolute path of the LibreOffice install.
  */
-g_object_class_install_property (pGObjectClass,
-  PROP_LO_PATH,
-  g_param_spec_string("lopath",
-  "LO Path",
-  "LibreOffice Install Path",
-  nullptr,
-  static_cast(G_PARAM_READWRITE |
-   G_PARAM_CONSTRUCT_ONLY |
-   
G_PARAM_STATIC_STRINGS)));
+properties[PROP_LO_PATH] =
+g_param_spec_string("lopath",
+"LO Path",
+"LibreOffice Install Path",
+nullptr,
+static_cast(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
 
 /**
  * LOKDocView:lopointer:
@@ -2063,28 +2065,26 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
  * A LibreOfficeKit* in case lok_init() is already called
  * previously.
  */
-g_object_class_install_property (pGObjectClass,
-  PROP_LO_POINTER,
-  g_param_spec_pointer("lopointer",
-   "LO Pointer",
-   "A LibreOfficeKit* from lok_init()",
-   static_cast(G_PARAM_READWRITE |
-G_PARAM_CONSTRUCT_ONLY 
|
-
G_PARAM_STATIC_STRINGS)));
+properties[PROP_LO_POINTER] =
+g_param_spec_pointer("lopointer",
+ "LO Pointer",
+ "A LibreOfficeKit* from lok_init()",
+ static_cast(G_PARAM_READWRITE |
+  G_PARAM_CONSTRUCT_ONLY |
+  G_PARAM_STATIC_STRINGS));
 
 /**
  * LOKDocView:docpath:
  *
  * The path of the document that is currently being viewed.
  */
-g_object_class_install_property (pGObjectClass,
-  PROP_DOC_PATH,
-  g_param_spec_string("docpath",
-  "Document Path",
-  "The URI of the document to open",
-  nullptr,
-  static_cast(G_PARAM_READWRITE |
-   
G_PARAM_STATIC_STRINGS)));
+properties[PROP_DOC_PATH] =
+g_param_spec_string("docpath",
+"Document Path",
+"The URI of the document to open",
+nullptr,
+static_cast(G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
 
 /**
  * LOKDocView:docpointer:
@@ -2092,27 +2092,25 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
  * A LibreOfficeKitDocument* in case documentLoad() is already called
  * previously.
  */
-g_object_class_install_property (pGObjectClass,
-  

[Libreoffice-commits] core.git: libreofficekit/source

2015-12-30 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 398ef76d5dc3ec1ed22fa1d9fd9151b61cce54e2
Author: Pranav Kant 
Date:   Fri Dec 18 21:58:26 2015 +0530

tdf#96514: Emits a 'notify' signal when zoom changes

Change-Id: I5f55e4cce26096afcae3ad3711efa37757aada39
Reviewed-on: https://gerrit.libreoffice.org/20798
Reviewed-by: David Tardon 
Tested-by: David Tardon 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 1915c5f..168338d 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2485,6 +2485,8 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
 nDocumentWidthPixels,
 nDocumentHeightPixels);
 
+g_object_notify_by_pspec(G_OBJECT(pDocView), properties[PROP_ZOOM]);
+
 // Update the client's view size
 GTask* task = g_task_new(pDocView, nullptr, nullptr, nullptr);
 LOEvent* pLOEvent = new LOEvent(LOK_SET_CLIENT_ZOOM);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-12-17 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 244aad533b0fd714136f4f62b5a07fc136c740f0
Author: Pranav Kant 
Date:   Sun Dec 13 10:48:45 2015 +0530

lokdocview: Remove an easy FIXME

Change-Id: I8305f3eb45330f457089ca0524a0df004410f59c
Reviewed-on: https://gerrit.libreoffice.org/20774
Reviewed-by: David Tardon 
Tested-by: David Tardon 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 85aa1be..f1375dd 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2430,8 +2430,7 @@ lok_doc_view_open_document_finish (LOKDocView* pDocView, 
GAsyncResult* res, GErr
 GTask* task = G_TASK(res);
 
 g_return_val_if_fail(g_task_is_valid(res, pDocView), false);
-//FIXME: make source_tag work
-//g_return_val_if_fail(g_task_get_source_tag(task) == 
lok_doc_view_open_document, NULL);
+g_return_val_if_fail(g_task_get_source_tag(task) == 
lok_doc_view_open_document, false);
 g_return_val_if_fail(error == nullptr || *error == nullptr, false);
 
 return g_task_propagate_boolean(task, error);
@@ -2456,6 +2455,7 @@ lok_doc_view_open_document (LOKDocView* pDocView,
 if (pRenderingArguments)
 priv->m_aRenderingArguments = pRenderingArguments;
 g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
+g_task_set_source_tag(task, 
reinterpret_cast(lok_doc_view_open_document));
 
 g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), );
 if (error != nullptr)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-12-17 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit a2682e4b081a9a8c6814db768e4ee9e5390907ae
Author: Pranav Kant 
Date:   Tue Dec 15 00:23:46 2015 +0530

lokdocview: Superfluous *_set_zoom() call on widget initialization

G_PARAM_CONSTRUCT implies that parameter will be set upon widget
initialization which means calling lok_doc_view_set_zoom() while
document still points to null.

Change-Id: Ib576ac3b32c2349be2b2df6067ae79a056a03028
Reviewed-on: https://gerrit.libreoffice.org/20775
Reviewed-by: David Tardon 
Tested-by: David Tardon 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index f1375dd..c78d008 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -759,6 +759,7 @@ static gboolean postDocumentLoad(gpointer pData)
 nDocumentHeightPixels);
 gtk_widget_set_can_focus(GTK_WIDGET(pLOKDocView), TRUE);
 gtk_widget_grab_focus(GTK_WIDGET(pLOKDocView));
+lok_doc_view_set_zoom(pLOKDocView, 1.0);
 
 return G_SOURCE_REMOVE;
 }
@@ -2142,7 +2143,6 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
  "The current zoom level of the content",
  0, 5.0, 1.0,
  static_cast(G_PARAM_READWRITE |
-  G_PARAM_CONSTRUCT |
   
G_PARAM_STATIC_STRINGS)));
 
 /**
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-12-16 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 032e34d0014d2154feaf97105d2dbe69b290b8c5
Author: Miklos Vajna 
Date:   Wed Dec 16 20:04:01 2015 +0100

tdf#96250 LOK: guard against 0 pRenderingArguments

Change-Id: Ifa3995ce92c31c891ffc1b9b1a297b00

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 9c3b5c7..85aa1be 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2453,7 +2453,8 @@ lok_doc_view_open_document (LOKDocView* pDocView,
 pLOEvent->m_pPath = pPath;
 
 priv->m_aDocPath = pPath;
-priv->m_aRenderingArguments = pRenderingArguments;
+if (pRenderingArguments)
+priv->m_aRenderingArguments = pRenderingArguments;
 g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
 
 g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-12-11 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |   21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

New commits:
commit ea5c99428f56e1d3a3e782505aa2f56f905038a4
Author: Pranav Kant 
Date:   Thu Dec 10 21:10:16 2015 +0530

tdf#96384: Add a new signal 'text-selection' to lokdocview

To help client know when the user has selected a non-null text.

Change-Id: Ie939612fc5f38e2e50e9ad9792e04e89ae918886
Reviewed-on: https://gerrit.libreoffice.org/20621
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 5903320..9c3b5c7 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -185,6 +185,7 @@ enum
 SEARCH_RESULT_COUNT,
 COMMAND_RESULT,
 FORMULA_CHANGED,
+TEXT_SELECTION,
 
 LAST_SIGNAL
 };
@@ -924,8 +925,9 @@ callback (gpointer pData)
 case LOK_CALLBACK_TEXT_SELECTION:
 {
 priv->m_aTextSelectionRectangles = payloadToRectangles(pDocView, 
pCallback->m_aPayload.c_str());
+gboolean bIsTextSelected = !priv->m_aTextSelectionRectangles.empty();
 // In case the selection is empty, then we get no 
LOK_CALLBACK_TEXT_SELECTION_START/END events.
-if (priv->m_aTextSelectionRectangles.empty())
+if (!bIsTextSelected)
 {
 memset(>m_aTextSelectionStart, 0, 
sizeof(priv->m_aTextSelectionStart));
 memset(>m_aHandleStartRect, 0, 
sizeof(priv->m_aHandleStartRect));
@@ -934,6 +936,8 @@ callback (gpointer pData)
 }
 else
 memset(>m_aHandleMiddleRect, 0, 
sizeof(priv->m_aHandleMiddleRect));
+
+g_signal_emit(pDocView, doc_view_signals[TEXT_SELECTION], 0, 
bIsTextSelected);
 gtk_widget_queue_draw(GTK_WIDGET(pDocView));
 }
 break;
@@ -2381,6 +2385,21 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
  g_cclosure_marshal_VOID__STRING,
  G_TYPE_NONE, 1,
  G_TYPE_STRING);
+
+/**
+ * LOKDocView::text-selection:
+ * @pDocView: the #LOKDocView on which the signal is emitted
+ * @bIsTextSelected: whether text selected is non-null
+ */
+doc_view_signals[TEXT_SELECTION] =
+g_signal_new("text-selection",
+ G_TYPE_FROM_CLASS(pGObjectClass),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ nullptr, nullptr,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1,
+ G_TYPE_BOOLEAN);
 }
 
 SAL_DLLPUBLIC_EXPORT GtkWidget*
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-12-10 Thread Ashod Nakashian
 libreofficekit/source/gtk/lokdocview.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit deb9203741dcea5dd3f2260f90203c07fb79e9de
Author: Ashod Nakashian 
Date:   Sat Dec 5 22:11:33 2015 -0500

Crash fix in gtktiledviewer when creating new view

Change-Id: I85bb71e775f300214e05e75636bbee200d35ffaa
Reviewed-on: https://gerrit.libreoffice.org/20418
Tested-by: Jenkins 
Reviewed-by: David Tardon 
Tested-by: David Tardon 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index e0654b1..5903320 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2399,6 +2399,7 @@ SAL_DLLPUBLIC_EXPORT GtkWidget* 
lok_doc_view_new_from_widget(LOKDocView* pOldLOK
 LibreOfficeKitDocument* pDocument = 
lok_doc_view_get_document(LOK_DOC_VIEW(pNewDocView));
 LOKDocViewPrivate& pNewPriv = getPrivate(LOK_DOC_VIEW(pNewDocView));
 pNewPriv->m_nViewId = pDocument->pClass->createView(pDocument);
+pNewPriv->m_aRenderingArguments = pOldPriv->m_aRenderingArguments;
 
 postDocumentLoad(pNewDocView);
 return pNewDocView;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-12-09 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |  312 +--
 1 file changed, 180 insertions(+), 132 deletions(-)

New commits:
commit b3bfc26d0863b074bb990725718f2ab23d05425d
Author: Pranav Kant 
Date:   Wed Dec 9 01:03:02 2015 +0530

tdf#96316: Decouple view-only/editable modes

- Move text selection and graphic selection tasks into functions
- Merge GDK_BUTTON_PRESS, GDK_BUTTON_RELEASE conditional code
- Do not change to 'move' cursor in view-only mode
- Ignore LOK_POST_COMMAND, LOK_SET_GRAPHIC_SELECTION in view-only

As a consequence this commit also allows dragging handles during text
selection in view-only mode which was earlier not possible.

Change-Id: Iffb668d5447dd646a1e40237dee8d8d3fa3314b6
Reviewed-on: https://gerrit.libreoffice.org/20487
Reviewed-by: David Tardon 
Tested-by: David Tardon 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 0a4543b..97a5e73 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -311,6 +311,153 @@ isEmptyRectangle(const GdkRectangle& rRectangle)
 return rRectangle.x == 0 && rRectangle.y == 0 && rRectangle.width == 0 && 
rRectangle.height == 0;
 }
 
+/// if handled, returns TRUE else FALSE
+static bool
+handleTextSelectionOnButtonPress(GdkRectangle& aClick, LOKDocView* pDocView) {
+LOKDocViewPrivate& priv = getPrivate(pDocView);
+
+if (gdk_rectangle_intersect(, >m_aHandleStartRect, nullptr))
+{
+g_info("LOKDocView_Impl::signalButton: start of drag start handle");
+priv->m_bInDragStartHandle = true;
+return TRUE;
+}
+else if (gdk_rectangle_intersect(, >m_aHandleMiddleRect, 
nullptr))
+{
+g_info("LOKDocView_Impl::signalButton: start of drag middle handle");
+priv->m_bInDragMiddleHandle = true;
+return TRUE;
+}
+else if (gdk_rectangle_intersect(, >m_aHandleEndRect, 
nullptr))
+{
+g_info("LOKDocView_Impl::signalButton: start of drag end handle");
+priv->m_bInDragEndHandle = true;
+return TRUE;
+}
+
+return FALSE;
+}
+
+/// if handled, returns TRUE else FALSE
+static bool
+handleGraphicSelectionOnButtonPress(GdkRectangle& aClick, LOKDocView* 
pDocView) {
+LOKDocViewPrivate& priv = getPrivate(pDocView);
+GError* error = nullptr;
+
+for (int i = 0; i < GRAPHIC_HANDLE_COUNT; ++i)
+{
+if (gdk_rectangle_intersect(, >m_aGraphicHandleRects[i], 
nullptr))
+{
+g_info("LOKDocView_Impl::signalButton: start of drag graphic 
handle #%d", i);
+priv->m_bInDragGraphicHandles[i] = true;
+
+GTask* task = g_task_new(pDocView, nullptr, nullptr, nullptr);
+LOEvent* pLOEvent = new LOEvent(LOK_SET_GRAPHIC_SELECTION);
+pLOEvent->m_nSetGraphicSelectionType = 
LOK_SETGRAPHICSELECTION_START;
+pLOEvent->m_nSetGraphicSelectionX = 
pixelToTwip(priv->m_aGraphicHandleRects[i].x + 
priv->m_aGraphicHandleRects[i].width / 2, priv->m_fZoom);
+pLOEvent->m_nSetGraphicSelectionY = 
pixelToTwip(priv->m_aGraphicHandleRects[i].y + 
priv->m_aGraphicHandleRects[i].height / 2, priv->m_fZoom);
+g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
+
+g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), 
);
+if (error != nullptr)
+{
+g_warning("Unable to call LOK_SET_GRAPHIC_SELECTION: %s", 
error->message);
+g_clear_error();
+}
+g_object_unref(task);
+
+return TRUE;
+}
+}
+
+return FALSE;
+}
+
+/// if handled, returns TRUE else FALSE
+static bool
+handleTextSelectionOnButtonRelease(LOKDocView* pDocView) {
+LOKDocViewPrivate& priv = getPrivate(pDocView);
+
+if (priv->m_bInDragStartHandle)
+{
+g_info("LOKDocView_Impl::signalButton: end of drag start handle");
+priv->m_bInDragStartHandle = false;
+return TRUE;
+}
+else if (priv->m_bInDragMiddleHandle)
+{
+g_info("LOKDocView_Impl::signalButton: end of drag middle handle");
+priv->m_bInDragMiddleHandle = false;
+return TRUE;
+}
+else if (priv->m_bInDragEndHandle)
+{
+g_info("LOKDocView_Impl::signalButton: end of drag end handle");
+priv->m_bInDragEndHandle = false;
+return TRUE;
+}
+
+return FALSE;
+}
+
+/// if handled, returns TRUE else FALSE
+static bool
+handleGraphicSelectionOnButtonRelease(LOKDocView* pDocView, GdkEventButton* 
pEvent) {
+LOKDocViewPrivate& priv = getPrivate(pDocView);
+GError* error = nullptr;
+
+for (int i = 0; i < GRAPHIC_HANDLE_COUNT; ++i)
+{
+if (priv->m_bInDragGraphicHandles[i])
+{
+g_info("LOKDocView_Impl::signalButton: end of drag graphic handle 
#%d", i);
+

[Libreoffice-commits] core.git: libreofficekit/source

2015-12-09 Thread Stephan Bergmann
 libreofficekit/source/gtk/lokdocview.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit ab5d730b2a4276d261c1ef11f94b16d0936acf5c
Author: Stephan Bergmann 
Date:   Wed Dec 9 17:25:18 2015 +0100

loplugin:nullptr

Change-Id: Id249baebf047bae083e36ad6e23d5bb8989f9a98

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index ce21d6e..3bf4d44 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2386,7 +2386,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
 SAL_DLLPUBLIC_EXPORT GtkWidget*
 lok_doc_view_new (const gchar* pPath, GCancellable *cancellable, GError 
**error)
 {
-return GTK_WIDGET (g_initable_new (LOK_TYPE_DOC_VIEW, cancellable, error, 
"lopath", pPath == NULL ? LOK_PATH : pPath, NULL));
+return GTK_WIDGET (g_initable_new (LOK_TYPE_DOC_VIEW, cancellable, error, 
"lopath", pPath == nullptr ? LOK_PATH : pPath, NULL));
 }
 
 SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new_from_widget(LOKDocView* 
pOldLOKDocView)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-11-23 Thread Stephan Bergmann
 libreofficekit/source/gtk/lokdocview.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 086bd3c57405ae4993be2e9100a9a7a8b85e76b2
Author: Stephan Bergmann 
Date:   Mon Nov 23 15:58:19 2015 +0100

loplugin:cstylecast

Change-Id: I4a02309c3ef4cb8c88edd538012ed2a8c43da307

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index fe1a12c..c808752 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1713,7 +1713,7 @@ paintTileInThread (gpointer data)
 return;
 }
 
-g_task_return_pointer(task, pSurface, 
(GDestroyNotify)cairo_surface_destroy);
+g_task_return_pointer(task, pSurface, 
reinterpret_cast(cairo_surface_destroy));
 }
 
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-11-13 Thread Stephan Bergmann
 libreofficekit/source/gtk/lokdocview.cxx |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit c6c8af5ef46e2178e4b9abcd95f76c8df2db2732
Author: Stephan Bergmann 
Date:   Fri Nov 13 10:41:32 2015 +0100

loplugin:nullptr

Change-Id: Iaf779157b97e4d3a3a449cc7f17e4d5c533955f0

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 0a7e8b8..5c5336d 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2269,7 +2269,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
  G_TYPE_FROM_CLASS(pGObjectClass),
  G_SIGNAL_RUN_FIRST,
  0,
- NULL, NULL,
+ nullptr, nullptr,
  g_cclosure_marshal_VOID__STRING,
  G_TYPE_NONE, 1,
  G_TYPE_STRING);
@@ -2346,7 +2346,7 @@ SAL_DLLPUBLIC_EXPORT void
 lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
 {
 LOKDocViewPrivate& priv = getPrivate(pDocView);
-GError* error = NULL;
+GError* error = nullptr;
 
 priv->m_fZoom = fZoom;
 long nDocumentWidthPixels = twipToPixel(priv->m_nDocumentWidthTwips, 
fZoom);
@@ -2361,7 +2361,7 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
 nDocumentHeightPixels);
 
 // Update the client's view size
-GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
+GTask* task = g_task_new(pDocView, nullptr, nullptr, nullptr);
 LOEvent* pLOEvent = new LOEvent(LOK_SET_CLIENT_ZOOM);
 pLOEvent->m_nTilePixelWidth = nTileSizePixels;
 pLOEvent->m_nTilePixelHeight = nTileSizePixels;
@@ -2370,7 +2370,7 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
 g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
 
 g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), );
-if (error != NULL)
+if (error != nullptr)
 {
 g_warning("Unable to call LOK_SET_CLIENT_ZOOM: %s", error->message);
 g_clear_error();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-11-11 Thread Andrzej Hunt
 libreofficekit/source/gtk/lokdocview.cxx |   11 +++
 1 file changed, 11 insertions(+)

New commits:
commit cc920bc27a0c37233d65ee1b20712e3ac6896c9a
Author: Andrzej Hunt 
Date:   Tue Nov 10 11:40:41 2015 +0100

lokdocview: support LOK_CALLBACK_MOUSE_POINTER

Change-Id: I2052e39fa2e25988a40f293389d5a183a625acd4
Reviewed-on: https://gerrit.libreoffice.org/19903
Reviewed-by: Andrzej Hunt 
Tested-by: Andrzej Hunt 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index cff7889..550a922 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -282,6 +282,8 @@ callbackTypeToString (int nType)
 return "LOK_CALLBACK_CELL_CURSOR";
 case LOK_CALLBACK_HYPERLINK_CLICKED:
 return "LOK_CALLBACK_HYPERLINK_CLICKED";
+case LOK_CALLBACK_MOUSE_POINTER:
+return "LOK_CALLBACK_MOUSE_POINTER";
 case LOK_CALLBACK_STATE_CHANGED:
 return "LOK_CALLBACK_STATE_CHANGED";
 case LOK_CALLBACK_STATUS_INDICATOR_START:
@@ -736,6 +738,15 @@ callback (gpointer pData)
 priv->m_bCursorVisible = pCallback->m_aPayload == "true";
 }
 break;
+case LOK_CALLBACK_MOUSE_POINTER:
+{
+// The gtk docs claim that most css cursors should be supported, 
however
+// on my system at least this is not true and many cursors are 
unsupported.
+// In this case pCursor = null, which results in the default cursor 
being set.
+GdkCursor* pCursor = 
gdk_cursor_new_from_name(gtk_widget_get_display(GTK_WIDGET(pDocView)), 
pCallback->m_aPayload.c_str());
+gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(pDocView)), 
pCursor);
+}
+break;
 case LOK_CALLBACK_GRAPHIC_SELECTION:
 {
 if (pCallback->m_aPayload != "EMPTY")
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-11-04 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |   38 +--
 libreofficekit/source/gtk/tilebuffer.cxx |6 
 libreofficekit/source/gtk/tilebuffer.hxx |   15 
 3 files changed, 57 insertions(+), 2 deletions(-)

New commits:
commit 93f98e98e42d75914a3e1d8f85bd3c6328d2e111
Author: Pranav Kant 
Date:   Sun Nov 1 17:11:09 2015 +0530

lokdocview: Don't render tiles while tile buffer has changed

This is common when widget gets a zoom request, resulting in a
new tile buffer, and the tiles from the old tile buffer are still
waiting to be processed in the LOK thread, for old tile buffer. If
we allow these useless operations to execute successfully, they
would end up writing in new tile buffer giving false results.

Lets tag every paint tile operations with their respective tile
buffer during `task` creation, and then check whether the tile
buffer has changed or not before writing to the tile buffer.

Change-Id: If784341a67ad430bc3415b765137badaad6b97f6
Reviewed-on: https://gerrit.libreoffice.org/19726
Reviewed-by: Miklos Vajna 
Tested-by: Miklos Vajna 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 82d119c..dcf6d5f 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -912,7 +912,12 @@ paintTileCallback(GObject* sourceObject, GAsyncResult* 
res, gpointer userData)
 GdkPixbuf* pPixBuf = static_cast(paintTileFinish(pDocView, 
res, ));
 if (error != NULL)
 {
-g_warning("Unable to get painted GdkPixbuf: %s", error->message);
+if (error->domain == LOK_TILEBUFFER_ERROR &&
+error->code == LOK_TILEBUFFER_CHANGED)
+g_info("Skipping paint tile request because corresponding"
+   "tile buffer has been destroyed");
+else
+g_warning("Unable to get painted GdkPixbuf: %s", error->message);
 g_error_free(error);
 return;
 }
@@ -977,6 +982,7 @@ renderDocument(LOKDocView* pDocView, cairo_t* pCairo)
 pLOEvent->m_nPaintTileX = nRow;
 pLOEvent->m_nPaintTileY = nColumn;
 pLOEvent->m_fPaintTileZoom = priv->m_fZoom;
+pLOEvent->m_pTileBuffer = &*priv->m_pTileBuffer;
 GTask* task = g_task_new(pDocView, NULL, paintTileCallback, 
pLOEvent);
 g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
 
@@ -1541,6 +1547,17 @@ paintTileInThread (gpointer data)
 LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
+
+// check if "source" tile buffer is different from "current" tile buffer
+if (pLOEvent->m_pTileBuffer != &*priv->m_pTileBuffer)
+{
+pLOEvent->m_pTileBuffer = nullptr;
+g_task_return_new_error(task,
+LOK_TILEBUFFER_ERROR,
+LOK_TILEBUFFER_CHANGED,
+"TileBuffer has changed");
+return;
+}
 std::unique_ptr& buffer = priv->m_pTileBuffer;
 int index = pLOEvent->m_nPaintTileX * buffer->m_nWidth + 
pLOEvent->m_nPaintTileY;
 if (buffer->m_mTiles.find(index) != buffer->m_mTiles.end() &&
@@ -1550,7 +1567,10 @@ paintTileInThread (gpointer data)
 GdkPixbuf* pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 
nTileSizePixels, nTileSizePixels);
 if (!pPixBuf)
 {
-g_info ("Error allocating memory to pixbuf");
+g_task_return_new_error(task,
+LOK_TILEBUFFER_ERROR,
+LOK_TILEBUFFER_MEMORY,
+"Error allocating memory to GdkPixbuf");
 return;
 }
 
@@ -1574,6 +1594,20 @@ paintTileInThread (gpointer data)
  pixelToTwip(nTileSizePixels, 
pLOEvent->m_fPaintTileZoom),
  pixelToTwip(nTileSizePixels, 
pLOEvent->m_fPaintTileZoom));
 
+// Its likely that while the tilebuffer has changed, one of the paint tile
+// requests has passed the previous check at start of this function, and 
has
+// rendered the tile already. We want to stop such rendered tiles from 
being
+// stored in new tile buffer.
+if (pLOEvent->m_pTileBuffer != &*priv->m_pTileBuffer)
+{
+pLOEvent->m_pTileBuffer = nullptr;
+g_task_return_new_error(task,
+LOK_TILEBUFFER_ERROR,
+LOK_TILEBUFFER_CHANGED,
+"TileBuffer has changed");
+return;
+}
+
 g_task_return_pointer(task, pPixBuf, g_object_unref);
 }
 
diff --git a/libreofficekit/source/gtk/tilebuffer.cxx 

[Libreoffice-commits] core.git: libreofficekit/source

2015-11-03 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |   56 +++
 libreofficekit/source/gtk/tilebuffer.cxx |   10 -
 2 files changed, 49 insertions(+), 17 deletions(-)

New commits:
commit de0c7e1783edc6a36037f2657f823dc9812c0804
Author: Pranav Kant 
Date:   Sun Nov 1 13:22:25 2015 +0530

lokdocview: Separate "painting" and "saving" of tiles

Lets separate the task of painting the tile, and saving the tile
in tile buffer using GAsyncReadyCallback. This will provide us
with better control over tiles -- cancelling the painting operation,
and filtering tiles that should not be saved in the tile buffer.

Change-Id: I6aae928d8cc0c906034570ed0e9a054763d493a3
Reviewed-on: https://gerrit.libreoffice.org/19725
Reviewed-by: Miklos Vajna 
Tested-by: Miklos Vajna 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 431e745..66ab461 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -873,6 +873,47 @@ renderGraphicHandle(LOKDocView* pDocView,
 }
 }
 
+/// Finishes the paint tile operation and returns the result, if any
+static gpointer
+paintTileFinish(LOKDocView* pDocView, GAsyncResult* res, GError **error)
+{
+GTask* task = G_TASK(res);
+
+g_return_val_if_fail(LOK_IS_DOC_VIEW(pDocView), NULL);
+g_return_val_if_fail(g_task_is_valid(res, pDocView), NULL);
+g_return_val_if_fail(error == NULL || *error == NULL, NULL);
+
+return g_task_propagate_pointer(task, error);
+}
+
+/// Callback called in the main UI thread when paintTileInThread in LOK thread 
has finished
+static void
+paintTileCallback(GObject* sourceObject, GAsyncResult* res, gpointer userData)
+{
+LOKDocView* pDocView = LOK_DOC_VIEW(sourceObject);
+LOKDocViewPrivate& priv = getPrivate(pDocView);
+LOEvent* pLOEvent = static_cast(userData);
+std::unique_ptr& buffer = priv->m_pTileBuffer;
+int index = pLOEvent->m_nPaintTileX * buffer->m_nWidth + 
pLOEvent->m_nPaintTileY;
+GError* error;
+
+error = NULL;
+GdkPixbuf* pPixBuf = static_cast(paintTileFinish(pDocView, 
res, ));
+if (error != NULL)
+{
+g_warning("Unable to get painted GdkPixbuf: %s", error->message);
+g_error_free(error);
+return;
+}
+
+buffer->m_mTiles[index].setPixbuf(pPixBuf);
+buffer->m_mTiles[index].valid = true;
+gdk_threads_add_idle(queueDraw, GTK_WIDGET(pDocView));
+
+g_object_unref(pPixBuf);
+}
+
+
 static gboolean
 renderDocument(LOKDocView* pDocView, cairo_t* pCairo)
 {
@@ -921,7 +962,13 @@ renderDocument(LOKDocView* pDocView, cairo_t* pCairo)
 
 if (bPaint)
 {
-GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
+LOEvent* pLOEvent = new LOEvent(LOK_PAINT_TILE);
+pLOEvent->m_nPaintTileX = nRow;
+pLOEvent->m_nPaintTileY = nColumn;
+pLOEvent->m_fPaintTileZoom = priv->m_fZoom;
+GTask* task = g_task_new(pDocView, NULL, paintTileCallback, 
pLOEvent);
+g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
+
 Tile& currentTile = priv->m_pTileBuffer->getTile(nRow, 
nColumn, priv->m_fZoom, task, priv->lokThreadPool);
 GdkPixbuf* pPixBuf = currentTile.getBuffer();
 gdk_cairo_set_source_pixbuf (pCairo, pPixBuf,
@@ -1516,12 +1563,7 @@ paintTileInThread (gpointer data)
  pixelToTwip(nTileSizePixels, 
pLOEvent->m_fPaintTileZoom),
  pixelToTwip(nTileSizePixels, 
pLOEvent->m_fPaintTileZoom));
 
-//create a mapping for it
-buffer->m_mTiles[index].setPixbuf(pPixBuf);
-buffer->m_mTiles[index].valid = true;
-gdk_threads_add_idle(queueDraw, GTK_WIDGET(pDocView));
-
-g_object_unref(pPixBuf);
+g_task_return_pointer(task, pPixBuf, g_object_unref);
 }
 
 
diff --git a/libreofficekit/source/gtk/tilebuffer.cxx 
b/libreofficekit/source/gtk/tilebuffer.cxx
index 1560641..a139082 100644
--- a/libreofficekit/source/gtk/tilebuffer.cxx
+++ b/libreofficekit/source/gtk/tilebuffer.cxx
@@ -87,11 +87,6 @@ Tile& TileBuffer::getTile(int x, int y, float fZoom, GTask* 
task,
 
 if (m_mTiles.find(index) != m_mTiles.end() && !m_mTiles[index].valid)
 {
-LOEvent* pLOEvent = new LOEvent(LOK_PAINT_TILE);
-pLOEvent->m_nPaintTileX = x;
-pLOEvent->m_nPaintTileY = y;
-pLOEvent->m_fPaintTileZoom = fZoom;
-g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
 g_thread_pool_push(lokThreadPool, g_object_ref(task), );
 if (error != NULL)
 {
@@ -102,11 +97,6 @@ Tile& TileBuffer::getTile(int x, int y, float fZoom, GTask* 
task,
 }
 else if(m_mTiles.find(index) == m_mTiles.end())
 {
-LOEvent* pLOEvent = 

[Libreoffice-commits] core.git: libreofficekit/source

2015-11-03 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |2 +-
 libreofficekit/source/gtk/tilebuffer.cxx |2 +-
 libreofficekit/source/gtk/tilebuffer.hxx |3 +--
 3 files changed, 3 insertions(+), 4 deletions(-)

New commits:
commit 602c1b4e2922c6a0ce425f398983ef64e595b606
Author: Miklos Vajna 
Date:   Tue Nov 3 11:19:03 2015 +0100

libreofficekit: -Werror=unused-parameter

Change-Id: I89c4d9752ef650d516bed8fcdc5873de8ae87e18

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 66ab461..f980e7f 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -969,7 +969,7 @@ renderDocument(LOKDocView* pDocView, cairo_t* pCairo)
 GTask* task = g_task_new(pDocView, NULL, paintTileCallback, 
pLOEvent);
 g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
 
-Tile& currentTile = priv->m_pTileBuffer->getTile(nRow, 
nColumn, priv->m_fZoom, task, priv->lokThreadPool);
+Tile& currentTile = priv->m_pTileBuffer->getTile(nRow, 
nColumn, task, priv->lokThreadPool);
 GdkPixbuf* pPixBuf = currentTile.getBuffer();
 gdk_cairo_set_source_pixbuf (pCairo, pPixBuf,
  
twipToPixel(aTileRectangleTwips.x, priv->m_fZoom),
diff --git a/libreofficekit/source/gtk/tilebuffer.cxx 
b/libreofficekit/source/gtk/tilebuffer.cxx
index a139082..6d447a8d 100644
--- a/libreofficekit/source/gtk/tilebuffer.cxx
+++ b/libreofficekit/source/gtk/tilebuffer.cxx
@@ -79,7 +79,7 @@ void TileBuffer::setInvalid(int x, int y, float fZoom, GTask* 
task,
 }
 }
 
-Tile& TileBuffer::getTile(int x, int y, float fZoom, GTask* task,
+Tile& TileBuffer::getTile(int x, int y, GTask* task,
   GThreadPool* lokThreadPool)
 {
 int index = x * m_nWidth + y;
diff --git a/libreofficekit/source/gtk/tilebuffer.hxx 
b/libreofficekit/source/gtk/tilebuffer.hxx
index 27fbdf6..f74cae7 100644
--- a/libreofficekit/source/gtk/tilebuffer.hxx
+++ b/libreofficekit/source/gtk/tilebuffer.hxx
@@ -105,7 +105,6 @@ class TileBuffer
 
@param x the tile along the x-axis of the buffer
@param y the tile along the y-axis of the buffer
-   @param aZoom current zoom factor of the document
@param task GTask object containing the necessary data
@param pool GThreadPool managed by the widget instance used for all the
LOK calls made by widget. It is needed here because getTile invokes one
@@ -113,7 +112,7 @@ class TileBuffer
 
@return the tile at the mentioned position (x, y)
  */
-Tile& getTile(int x, int y, float aZoom, GTask* task, GThreadPool* pool);
+Tile& getTile(int x, int y, GTask* task, GThreadPool* pool);
 /// Destroys all the tiles in the tile buffer; also frees the memory 
allocated
 /// for all the Tile objects.
 void resetAllTiles();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-11-03 Thread Stephan Bergmann
 libreofficekit/source/gtk/lokdocview.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 02b39996fa8447305900adad509250646c0a3b80
Author: Stephan Bergmann 
Date:   Tue Nov 3 22:20:45 2015 +0100

-Werror,-Wformat-security

Change-Id: I23f4b906456fdba84f2772a4ed15ac6c141a094d

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 6a0adfa..82d119c 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1530,7 +1530,7 @@ postCommandInThread (gpointer data)
 priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
 std::stringstream ss;
 ss << "lok::Document::postUnoCommand(" << pLOEvent->m_pCommand << ", " << 
pLOEvent->m_pArguments << ")";
-g_info(ss.str().c_str());
+g_info("%s", ss.str().c_str());
 priv->m_pDocument->pClass->postUnoCommand(priv->m_pDocument, 
pLOEvent->m_pCommand, pLOEvent->m_pArguments, pLOEvent->m_bNotifyWhenFinished);
 }
 
@@ -1566,7 +1566,7 @@ paintTileInThread (gpointer data)
 << aTileRectangle.x << ", " << aTileRectangle.y << ", "
 << pixelToTwip(nTileSizePixels, pLOEvent->m_fPaintTileZoom) << ", "
 << pixelToTwip(nTileSizePixels, pLOEvent->m_fPaintTileZoom) << ")";
-g_info(ss.str().c_str());
+g_info("%s", ss.str().c_str());
 priv->m_pDocument->pClass->paintTile(priv->m_pDocument,
  pBuffer,
  nTileSizePixels, nTileSizePixels,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-10-31 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |   33 +++
 libreofficekit/source/gtk/tilebuffer.cxx |5 
 libreofficekit/source/gtk/tilebuffer.hxx |8 +--
 3 files changed, 28 insertions(+), 18 deletions(-)

New commits:
commit cfbc36e2eade42e471056d3c32fc962cd3149c17
Author: Pranav Kant 
Date:   Sun Oct 25 19:22:46 2015 +0530

lokdocview: Fix memory leaks

Change-Id: I5107e4fa1828145a709e1edffe02831f4faae3c8
Reviewed-on: https://gerrit.libreoffice.org/19676
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index e22816b..431e745 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -50,7 +50,7 @@ struct LOKDocViewPrivateImpl
 LibreOfficeKit* m_pOffice;
 LibreOfficeKitDocument* m_pDocument;
 
-TileBuffer m_aTileBuffer;
+std::unique_ptr m_pTileBuffer;
 GThreadPool* lokThreadPool;
 
 gfloat m_fZoom;
@@ -503,9 +503,8 @@ static gboolean postDocumentLoad(gpointer pData)
 // Total number of columns in this document.
 guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
 
-
-priv->m_aTileBuffer = TileBuffer(priv->m_pDocument,
- nColumns);
+priv->m_pTileBuffer = std::unique_ptr(new 
TileBuffer(priv->m_pDocument,
+ 
nColumns));
 gtk_widget_set_size_request(GTK_WIDGET(pLOKDocView),
 nDocumentWidthPixels,
 nDocumentHeightPixels);
@@ -634,7 +633,7 @@ setTilesInvalid (LOKDocView* pDocView, const GdkRectangle& 
rRectangle)
 for (int j = aStart.y; j < aEnd.y; j++)
 {
 GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
-priv->m_aTileBuffer.setInvalid(i, j, priv->m_fZoom, task, 
priv->lokThreadPool);
+priv->m_pTileBuffer->setInvalid(i, j, priv->m_fZoom, task, 
priv->lokThreadPool);
 g_object_unref(task);
 }
 }
@@ -657,7 +656,7 @@ callback (gpointer pData)
 setTilesInvalid(pDocView, aRectangle);
 }
 else
-priv->m_aTileBuffer.resetAllTiles();
+priv->m_pTileBuffer->resetAllTiles();
 
 gtk_widget_queue_draw(GTK_WIDGET(pDocView));
 }
@@ -923,7 +922,7 @@ renderDocument(LOKDocView* pDocView, cairo_t* pCairo)
 if (bPaint)
 {
 GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
-Tile& currentTile = priv->m_aTileBuffer.getTile(nRow, nColumn, 
priv->m_fZoom, task, priv->lokThreadPool);
+Tile& currentTile = priv->m_pTileBuffer->getTile(nRow, 
nColumn, priv->m_fZoom, task, priv->lokThreadPool);
 GdkPixbuf* pPixBuf = currentTile.getBuffer();
 gdk_cairo_set_source_pixbuf (pCairo, pPixBuf,
  
twipToPixel(aTileRectangleTwips.x, priv->m_fZoom),
@@ -1484,10 +1483,10 @@ paintTileInThread (gpointer data)
 LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
 LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
-TileBuffer& buffer = priv->m_aTileBuffer;
-int index = pLOEvent->m_nPaintTileX * buffer.m_nWidth + 
pLOEvent->m_nPaintTileY;
-if (buffer.m_mTiles.find(index) != buffer.m_mTiles.end() &&
-buffer.m_mTiles[index].valid)
+std::unique_ptr& buffer = priv->m_pTileBuffer;
+int index = pLOEvent->m_nPaintTileX * buffer->m_nWidth + 
pLOEvent->m_nPaintTileY;
+if (buffer->m_mTiles.find(index) != buffer->m_mTiles.end() &&
+buffer->m_mTiles[index].valid)
 return;
 
 GdkPixbuf* pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 
nTileSizePixels, nTileSizePixels);
@@ -1518,9 +1517,11 @@ paintTileInThread (gpointer data)
  pixelToTwip(nTileSizePixels, 
pLOEvent->m_fPaintTileZoom));
 
 //create a mapping for it
-buffer.m_mTiles[index].setPixbuf(pPixBuf);
-buffer.m_mTiles[index].valid = true;
+buffer->m_mTiles[index].setPixbuf(pPixBuf);
+buffer->m_mTiles[index].valid = true;
 gdk_threads_add_idle(queueDraw, GTK_WIDGET(pDocView));
+
+g_object_unref(pPixBuf);
 }
 
 
@@ -2129,8 +2130,8 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
 // Total number of columns in this document.
 guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
 
-priv->m_aTileBuffer = TileBuffer(priv->m_pDocument,
- nColumns);
+priv->m_pTileBuffer = std::unique_ptr(new 
TileBuffer(priv->m_pDocument,
+ 
nColumns));
 

[Libreoffice-commits] core.git: libreofficekit/source

2015-10-30 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |  152 +--
 libreofficekit/source/gtk/tilebuffer.hxx |4 
 2 files changed, 108 insertions(+), 48 deletions(-)

New commits:
commit bd0ec1e68dcbc344cbaa50e35608bab95925fcaf
Author: Miklos Vajna 
Date:   Fri Oct 30 08:31:43 2015 +0100

lokdocview: ensure private structure is allocated with operator new

It's undesirable to malloc a struct that has a TileBuffer member, while
TileBuffer doesn't have a default ctor.

Change-Id: I72dfacc0088f238ee101d84838bd7eea51ced82a

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 75032b7..e22816b 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -39,7 +39,7 @@
 #define GRAPHIC_HANDLE_COUNT 8
 
 /// Private struct used by this GObject type
-struct _LOKDocViewPrivate
+struct LOKDocViewPrivateImpl
 {
 const gchar* m_aLOPath;
 const gchar* m_aDocPath;
@@ -115,6 +115,58 @@ struct _LOKDocViewPrivate
 
 /// View ID, returned by createView() or 0 by default.
 int m_nViewId;
+
+LOKDocViewPrivateImpl()
+: m_aLOPath(0),
+m_aDocPath(0),
+m_nLoadProgress(0),
+m_bIsLoading(false),
+m_bCanZoomIn(false),
+m_bCanZoomOut(false),
+m_pOffice(0),
+m_pDocument(0),
+lokThreadPool(0),
+m_fZoom(0),
+m_nDocumentWidthTwips(0),
+m_nDocumentHeightTwips(0),
+m_bEdit(FALSE),
+m_aVisibleCursor({0, 0, 0, 0}),
+m_bCursorOverlayVisible(false),
+m_bCursorVisible(true),
+m_nLastButtonPressTime(0),
+m_nLastButtonReleaseTime(0),
+m_nLastButtonPressed(0),
+m_nKeyModifier(0),
+m_aTextSelectionStart({0, 0, 0, 0}),
+m_aTextSelectionEnd({0, 0, 0, 0}),
+m_aGraphicSelection({0, 0, 0, 0}),
+m_bInDragGraphicSelection(false),
+m_pHandleStart(0),
+m_aHandleStartRect({0, 0, 0, 0}),
+m_bInDragStartHandle(0),
+m_pHandleMiddle(0),
+m_aHandleMiddleRect({0, 0, 0, 0}),
+m_bInDragMiddleHandle(false),
+m_pHandleEnd(0),
+m_aHandleEndRect({0, 0, 0, 0}),
+m_bInDragEndHandle(false),
+m_pGraphicHandle(0),
+m_nViewId(0)
+{
+memset(_aGraphicHandleRects, 0, sizeof(m_aGraphicHandleRects));
+memset(_bInDragGraphicHandles, 0, sizeof(m_bInDragGraphicHandles));
+}
+};
+
+/// Wrapper around LOKDocViewPrivateImpl, managed by malloc/memset/free.
+struct _LOKDocViewPrivate
+{
+LOKDocViewPrivateImpl* m_pImpl;
+
+LOKDocViewPrivateImpl* operator->()
+{
+return m_pImpl;
+}
 };
 
 enum
@@ -167,6 +219,12 @@ G_DEFINE_TYPE_WITH_CODE (LOKDocView, lok_doc_view, 
GTK_TYPE_DRAWING_AREA,
 #pragma GCC diagnostic pop
 #endif
 
+static LOKDocViewPrivate& getPrivate(LOKDocView* pDocView)
+{
+LOKDocViewPrivate* priv = 
static_cast(lok_doc_view_get_instance_private(pDocView));
+return *priv;
+}
+
 /// Helper struct used to pass the data from soffice thread -> main thread.
 struct CallbackData
 {
@@ -249,7 +307,7 @@ postKeyEventInThread(gpointer data)
 {
 GTask* task = G_TASK(data);
 LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
-LOKDocViewPrivate *priv = 
static_cast(lok_doc_view_get_instance_private (pDocView));
+LOKDocViewPrivate& priv = getPrivate(pDocView);
 LOEvent* pLOEvent = static_cast(g_task_get_task_data(task));
 
 priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
@@ -263,7 +321,7 @@ static gboolean
 signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
 {
 LOKDocView* pDocView = LOK_DOC_VIEW(pWidget);
-LOKDocViewPrivate* priv = 
static_cast(lok_doc_view_get_instance_private (pDocView));
+LOKDocViewPrivate& priv = getPrivate(pDocView);
 int nCharCode = 0;
 int nKeyCode = 0;
 GError* error = NULL;
@@ -372,7 +430,7 @@ static gboolean
 handleTimeout (gpointer pData)
 {
 LOKDocView* pDocView = LOK_DOC_VIEW (pData);
-LOKDocViewPrivate* priv = 
static_cast(lok_doc_view_get_instance_private (pDocView));
+LOKDocViewPrivate& priv = getPrivate(pDocView);
 
 if (priv->m_bEdit)
 {
@@ -429,7 +487,7 @@ static gboolean queueDraw(gpointer pData)
 static gboolean postDocumentLoad(gpointer pData)
 {
 LOKDocView* pLOKDocView = static_cast(pData);
-LOKDocViewPrivate* priv = 
static_cast(lok_doc_view_get_instance_private(pLOKDocView));
+LOKDocViewPrivate& priv = getPrivate(pLOKDocView);
 
 priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
 priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument);
@@ -462,7 +520,7 @@ static gboolean
 globalCallback (gpointer pData)
 {
 CallbackData* pCallback = 

[Libreoffice-commits] core.git: libreofficekit/source

2015-10-21 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |  106 ++-
 libreofficekit/source/gtk/tilebuffer.cxx |   23 +-
 2 files changed, 112 insertions(+), 17 deletions(-)

New commits:
commit 54409159b8a12ca3d387e2ff2a2e1ff9dad1a2a3
Author: Pranav Kant 
Date:   Tue Oct 20 01:02:56 2015 +0530

lokdocview: Emit a warning after error

Change-Id: Id8e20e6561239096438d420c65d0da6dcc7f5e2e
Reviewed-on: https://gerrit.libreoffice.org/19474
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 30c5951..75032b7 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -266,6 +266,7 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
 LOKDocViewPrivate* priv = 
static_cast(lok_doc_view_get_instance_private (pDocView));
 int nCharCode = 0;
 int nKeyCode = 0;
+GError* error = NULL;
 
 if (!priv->m_bEdit)
 {
@@ -339,7 +340,12 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
 pLOEvent->m_nCharCode = nCharCode;
 pLOEvent->m_nKeyCode  = nKeyCode;
 g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
-g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), NULL);
+g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), );
+if (error != NULL)
+{
+g_warning("Unable to call LOK_POST_KEY: %s", error->message);
+g_clear_error();
+}
 g_object_unref(task);
 }
 else
@@ -350,7 +356,12 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
 pLOEvent->m_nCharCode = nCharCode;
 pLOEvent->m_nKeyCode  = nKeyCode;
 g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
-g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), NULL);
+g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), );
+if (error != NULL)
+{
+g_warning("Unable to call LOK_POST_KEY: %s", error->message);
+g_clear_error();
+}
 g_object_unref(task);
 }
 
@@ -950,6 +961,7 @@ lok_doc_view_signal_button(GtkWidget* pWidget, 
GdkEventButton* pEvent)
 {
 LOKDocView* pDocView = LOK_DOC_VIEW (pWidget);
 LOKDocViewPrivate *priv = 
static_cast(lok_doc_view_get_instance_private (pDocView));
+GError* error = NULL;
 
 g_info("LOKDocView_Impl::signalButton: %d, %d (in twips: %d, %d)",
(int)pEvent->x, (int)pEvent->y,
@@ -992,7 +1004,12 @@ lok_doc_view_signal_button(GtkWidget* pWidget, 
GdkEventButton* pEvent)
 pLOEvent->m_nSetGraphicSelectionY = pixelToTwip(pEvent->y, 
priv->m_fZoom);
 g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
 
-g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), 
NULL);
+g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), 
);
+if (error != NULL)
+{
+g_warning("Unable to call LOK_SET_GRAPHIC_SELECTION: %s", 
error->message);
+g_clear_error();
+}
 g_object_unref(task);
 
 return FALSE;
@@ -1011,7 +1028,12 @@ lok_doc_view_signal_button(GtkWidget* pWidget, 
GdkEventButton* pEvent)
 pLOEvent->m_nSetGraphicSelectionY = pixelToTwip(pEvent->y, 
priv->m_fZoom);
 g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
 
-g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), NULL);
+g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), 
);
+if (error != NULL)
+{
+g_warning("Unable to call LOK_SET_GRAPHIC_SELECTION: %s", 
error->message);
+g_clear_error();
+}
 g_object_unref(task);
 
 return FALSE;
@@ -1060,7 +1082,12 @@ lok_doc_view_signal_button(GtkWidget* pWidget, 
GdkEventButton* pEvent)
 pLOEvent->m_nSetGraphicSelectionY = 
pixelToTwip(priv->m_aGraphicHandleRects[i].y + 
priv->m_aGraphicHandleRects[i].height / 2, priv->m_fZoom);
 g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
 
-g_thread_pool_push(priv->lokThreadPool, 
g_object_ref(task), NULL);
+g_thread_pool_push(priv->lokThreadPool, 
g_object_ref(task), );
+if (error != NULL)
+{
+g_warning("Unable to call LOK_SET_GRAPHIC_SELECTION: 
%s", error->message);
+g_clear_error();
+}
 g_object_unref(task);
 
 return FALSE;
@@ -1102,7 +1129,12 @@ lok_doc_view_signal_button(GtkWidget* pWidget, 
GdkEventButton* pEvent)
 priv->m_nLastButtonPressed = 

[Libreoffice-commits] core.git: libreofficekit/source

2015-10-20 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |   42 +++
 1 file changed, 26 insertions(+), 16 deletions(-)

New commits:
commit d2d5a00e0e3972c0021e2e664301a32da6e54c1a
Author: Pranav Kant 
Date:   Mon Oct 19 22:36:12 2015 +0530

lokdocview: Use G_PARAM_STATIC_STRINGS

... as `name`, `nick`, and `blurb` are guaranteed to remain valid
and unmodified for the lifetime of the parameters.

Change-Id: Ic6463b470546669d5a815842daedb170df85d161
Reviewed-on: https://gerrit.libreoffice.org/19472
Reviewed-by: Miklos Vajna 
Tested-by: Miklos Vajna 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index fd6d769..30c5951 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1638,8 +1638,9 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
   "LO Path",
   "LibreOffice Install Path",
   0,
-  static_cast(G_PARAM_READWRITE
-   | 
G_PARAM_CONSTRUCT_ONLY)));
+  static_cast(G_PARAM_READWRITE |
+   G_PARAM_CONSTRUCT_ONLY |
+   
G_PARAM_STATIC_STRINGS)));
 
 /**
  * LOKDocView:lopointer:
@@ -1650,10 +1651,11 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
 g_object_class_install_property (pGObjectClass,
   PROP_LO_POINTER,
   g_param_spec_pointer("lopointer",
-  "LO Pointer",
-  "A LibreOfficeKit* from lok_init()",
-  static_cast(G_PARAM_READWRITE
-   | 
G_PARAM_CONSTRUCT_ONLY)));
+   "LO Pointer",
+   "A LibreOfficeKit* from lok_init()",
+   static_cast(G_PARAM_READWRITE |
+G_PARAM_CONSTRUCT_ONLY 
|
+
G_PARAM_STATIC_STRINGS)));
 
 /**
  * LOKDocView:docpath:
@@ -1666,7 +1668,8 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
   "Document Path",
   "The URI of the document to open",
   0,
-  static_cast(G_PARAM_READWRITE)));
+  static_cast(G_PARAM_READWRITE |
+   
G_PARAM_STATIC_STRINGS)));
 
 /**
  * LOKDocView:docpointer:
@@ -1677,9 +1680,10 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
 g_object_class_install_property (pGObjectClass,
   PROP_DOC_POINTER,
   g_param_spec_pointer("docpointer",
-  "Document Pointer",
-  "A LibreOfficeKitDocument* from documentLoad()",
-  static_cast(G_PARAM_READWRITE)));
+   "Document Pointer",
+   "A LibreOfficeKitDocument* from documentLoad()",
+   static_cast(G_PARAM_READWRITE |
+
G_PARAM_STATIC_STRINGS)));
 
 /**
  * LOKDocView:editable:
@@ -1692,7 +1696,8 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
"Editable",
"Whether the content is in edit mode or not",
FALSE,
-   static_cast(G_PARAM_READWRITE)));
+   static_cast(G_PARAM_READWRITE |
+
G_PARAM_STATIC_STRINGS)));
 
 /**
  * LOKDocView:load-progress:
@@ -1708,7 +1713,8 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
   "Estimated Load Progress",
   "Shows the progress of the document load 
operation",
   0.0, 1.0, 0.0,
-  G_PARAM_READABLE));
+  static_cast(G_PARAM_READABLE |
+   
G_PARAM_STATIC_STRINGS)));
 
 /**
  * LOKDocView:zoom-level:
@@ -1723,7 +1729,8 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
  "The current zoom level of the content",
  0, 5.0, 1.0,
  static_cast(G_PARAM_READWRITE |
-  G_PARAM_CONSTRUCT)));
+   

[Libreoffice-commits] core.git: libreofficekit/source

2015-10-06 Thread Michael Stahl
 libreofficekit/source/gtk/tilebuffer.cxx |3 ---
 1 file changed, 3 deletions(-)

New commits:
commit 0ca6d934b318bda1c91e4166acc2f2216a0d2b2a
Author: Michael Stahl 
Date:   Tue Oct 6 14:23:38 2015 +0200

libreofficekit: -Werror=unused-macros

Change-Id: I154bd2c101819669d43ab475144ae400454df4d0

diff --git a/libreofficekit/source/gtk/tilebuffer.cxx 
b/libreofficekit/source/gtk/tilebuffer.cxx
index e0ca2d2..70d12fe 100644
--- a/libreofficekit/source/gtk/tilebuffer.cxx
+++ b/libreofficekit/source/gtk/tilebuffer.cxx
@@ -9,9 +9,6 @@
 
 #include "tilebuffer.hxx"
 
-#if !GLIB_CHECK_VERSION(2,40,0)
-#define g_info(...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, __VA_ARGS__)
-#endif
 
 /* --
Utility functions
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-10-05 Thread Mihai Varga
 libreofficekit/source/gtk/lokdocview.cxx |   11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

New commits:
commit a6ef5718475ba35b52d9de474741b640316502eb
Author: Mihai Varga 
Date:   Mon Oct 5 18:07:28 2015 +0300

LOK: fixed duplicated switch case values

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 2aa1916..d5eab90 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -661,11 +661,7 @@ callback (gpointer pData)
 case LOK_CALLBACK_SEARCH_RESULT_COUNT:
 {
 size_t nPos = pCallback->m_aPayload.find_first_of(";");
-int nSearchResultCount = std::stoi(pCallback->m_aPayload.substr(0, 
nPos));
-if (nSearchResultCount == 0)
-{
-searchNotFound(pDocView, pCallback->m_aPayload.substr(nPos + 1));
-}
+searchResultCount(pDocView, pCallback->m_aPayload.substr(0, nPos));
 }
 break;
 case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
@@ -683,11 +679,6 @@ callback (gpointer pData)
 setPart(pDocView, pCallback->m_aPayload);
 }
 break;
-case LOK_CALLBACK_SEARCH_RESULT_COUNT:
-{
-searchResultCount(pDocView, pCallback->m_aPayload);
-}
-break;
 default:
 g_assert(false);
 break;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-09-29 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |   37 +++
 1 file changed, 37 insertions(+)

New commits:
commit c3ce35f0a12af2887b10987f76675174563487d7
Author: Pranav Kant 
Date:   Thu Sep 24 18:47:01 2015 +0200

lokdocview: Reset view completely

Resetting tiles only is not enough. We need to empty stale
selection rectangles, handle bars, cursor positions etc., so that
they do not interfere with next view to be opened using same
widget instance.

We are not destroying the document here, so the widget would
still point to the same document unless it is made to point to
another document by subsequent lok_doc_view_open_document calls.

Change-Id: I3c7cc789c8c7393b3793b4edf6aa96d54bc0b1a3
Reviewed-on: https://gerrit.libreoffice.org/18866
Reviewed-by: Miklos Vajna 
Tested-by: Miklos Vajna 

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 8d218f4..8b85c45 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1986,6 +1986,43 @@ lok_doc_view_reset_view(LOKDocView* pDocView)
 {
 LOKDocViewPrivate *priv = 
static_cast(lok_doc_view_get_instance_private (pDocView));
 priv->m_aTileBuffer.resetAllTiles();
+priv->m_nLoadProgress = 0.0;
+
+memset(>m_aVisibleCursor, 0, sizeof(priv->m_aVisibleCursor));
+priv->m_bCursorOverlayVisible = false;
+priv->m_bCursorVisible = false;
+
+priv->m_nLastButtonPressTime = 0;
+priv->m_nLastButtonReleaseTime = 0;
+priv->m_aTextSelectionRectangles.clear();
+
+memset(>m_aTextSelectionStart, 0, 
sizeof(priv->m_aTextSelectionStart));
+memset(>m_aTextSelectionEnd, 0, sizeof(priv->m_aTextSelectionEnd));
+memset(>m_aGraphicSelection, 0, sizeof(priv->m_aGraphicSelection));
+priv->m_bInDragGraphicSelection = false;
+
+cairo_surface_destroy(priv->m_pHandleStart);
+priv->m_pHandleStart = 0;
+memset(>m_aHandleStartRect, 0, sizeof(priv->m_aHandleStartRect));
+priv->m_bInDragStartHandle = false;
+
+cairo_surface_destroy(priv->m_pHandleMiddle);
+priv->m_pHandleMiddle = 0;
+memset(>m_aHandleMiddleRect, 0, sizeof(priv->m_aHandleMiddleRect));
+priv->m_bInDragMiddleHandle = false;
+
+cairo_surface_destroy(priv->m_pHandleEnd);
+priv->m_pHandleEnd = 0;
+memset(>m_aHandleEndRect, 0, sizeof(priv->m_aHandleEndRect));
+priv->m_bInDragEndHandle = false;
+
+cairo_surface_destroy(priv->m_pGraphicHandle);
+priv->m_pGraphicHandle = 0;
+memset(>m_aGraphicHandleRects, 0, 
sizeof(priv->m_aGraphicHandleRects));
+memset(>m_bInDragGraphicHandles, 0, 
sizeof(priv->m_bInDragGraphicHandles));
+
+priv->m_nViewId = 0;
+
 gtk_widget_queue_draw(GTK_WIDGET(pDocView));
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-09-11 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |   14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

New commits:
commit 88b6dd3ea77ca9f6d5fac2965cea6ff0634e6ba5
Author: Miklos Vajna 
Date:   Fri Sep 11 11:27:08 2015 +0200

lokdocview: GTK+ calls should be made from the main thread

Change-Id: Ia76ef70700ef507550222ca917986d4fe00e

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 41ec8f0..4448026 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -368,6 +368,16 @@ hyperlinkClicked(LOKDocView* pDocView, const std::string& 
rString)
 g_signal_emit(pDocView, doc_view_signals[HYPERLINK_CLICKED], 0, 
rString.c_str());
 }
 
+/// Trigger a redraw, invoked on the main thread by other functions running in 
a thread.
+static gboolean queueDraw(gpointer pData)
+{
+GtkWidget* pWidget = static_cast(pData);
+
+gtk_widget_queue_draw(pWidget);
+
+return G_SOURCE_REMOVE;
+}
+
 /// Implementation of the global callback handler, invoked by globalCallback();
 static gboolean
 globalCallback (gpointer pData)
@@ -1249,7 +1259,7 @@ setEditInThread(gpointer data)
 }
 priv->m_bEdit = bEdit;
 g_signal_emit(pDocView, doc_view_signals[EDIT_CHANGED], 0, bWasEdit);
-gtk_widget_queue_draw(GTK_WIDGET(pDocView));
+gdk_threads_add_idle(queueDraw, GTK_WIDGET(pDocView));
 }
 
 static void
@@ -1305,7 +1315,7 @@ paintTileInThread (gpointer data)
 //create a mapping for it
 buffer.m_mTiles[index].setPixbuf(pPixBuf);
 buffer.m_mTiles[index].valid = true;
-gtk_widget_queue_draw(GTK_WIDGET(pDocView));
+gdk_threads_add_idle(queueDraw, GTK_WIDGET(pDocView));
 }
 
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-08-19 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 520053459aa6a34b6d9ad52d97704399e5138d3d
Author: Pranav Kant pran...@gnome.org
Date:   Sun Aug 16 15:17:15 2015 +0530

Fix incomplete g-i annotations

Change-Id: I2665a12251921523045f4071df88ca69ecd5a5c0

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 7f2dc73..41ec8f0 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1810,7 +1810,10 @@ lok_doc_view_open_document_finish (LOKDocView* pDocView, 
GAsyncResult* res, GErr
 /**
  * lok_doc_view_open_document:
  * @pDocView: The #LOKDocView instance
- * @pPath: The path of the document that #LOKDocView widget should try to open
+ * @pPath: (transfer full): The path of the document that #LOKDocView widget 
should try to open
+ * @cancellable:
+ * @callback:
+ * @userdata:
  *
  * Returns: %TRUE if the document is loaded succesfully, %FALSE otherwise
  */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-08-04 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |   53 ---
 libreofficekit/source/gtk/tilebuffer.cxx |8 ++--
 libreofficekit/source/gtk/tilebuffer.hxx |   15 +++-
 3 files changed, 44 insertions(+), 32 deletions(-)

New commits:
commit 4df957f7255cf2ddce47a088dd30f945db6975be
Author: Pranav Kant pran...@gnome.org
Date:   Wed Jul 29 21:41:56 2015 +0530

lokdocview: Don't use extern variable: lokThreadPool

Change-Id: Ia208e3309bb64baf71ceb97cdf1b3b57b6120353

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index b864d6f..8a2e4a2 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -49,6 +49,7 @@ struct _LOKDocViewPrivate
 LibreOfficeKitDocument* m_pDocument;
 
 TileBuffer m_aTileBuffer;
+GThreadPool* lokThreadPool;
 
 gfloat m_fZoom;
 glong m_nDocumentWidthTwips;
@@ -152,8 +153,6 @@ G_DEFINE_TYPE_WITH_CODE (LOKDocView, lok_doc_view, 
GTK_TYPE_DRAWING_AREA,
 #pragma GCC diagnostic pop
 #endif
 
-GThreadPool* lokThreadPool;
-
 /// Helper struct used to pass the data from soffice thread - main thread.
 struct CallbackData
 {
@@ -308,7 +307,7 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
 pLOEvent-m_nCharCode = nCharCode;
 pLOEvent-m_nKeyCode  = nKeyCode;
 g_task_set_task_data(task, pLOEvent, g_free);
-g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
+g_thread_pool_push(priv-lokThreadPool, g_object_ref(task), NULL);
 g_object_unref(task);
 }
 else
@@ -319,7 +318,7 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
 pLOEvent-m_nCharCode = nCharCode;
 pLOEvent-m_nKeyCode  = nKeyCode;
 g_task_set_task_data(task, pLOEvent, g_free);
-g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
+g_thread_pool_push(priv-lokThreadPool, g_object_ref(task), NULL);
 g_object_unref(task);
 }
 
@@ -487,7 +486,7 @@ setTilesInvalid (LOKDocView* pDocView, const GdkRectangle 
rRectangle)
 for (int j = aStart.y; j  aEnd.y; j++)
 {
 GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
-priv-m_aTileBuffer.setInvalid(i, j, priv-m_fZoom, task);
+priv-m_aTileBuffer.setInvalid(i, j, priv-m_fZoom, task, 
priv-lokThreadPool);
 g_object_unref(task);
 }
 }
@@ -762,7 +761,7 @@ renderDocument(LOKDocView* pDocView, cairo_t* pCairo)
 if (bPaint)
 {
 GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
-Tile currentTile = priv-m_aTileBuffer.getTile(nRow, nColumn, 
priv-m_fZoom, task);
+Tile currentTile = priv-m_aTileBuffer.getTile(nRow, nColumn, 
priv-m_fZoom, task, priv-lokThreadPool);
 GdkPixbuf* pPixBuf = currentTile.getBuffer();
 gdk_cairo_set_source_pixbuf (pCairo, pPixBuf,
  
twipToPixel(aTileRectangleTwips.x, priv-m_fZoom),
@@ -900,7 +899,7 @@ lok_doc_view_signal_button(GtkWidget* pWidget, 
GdkEventButton* pEvent)
 pLOEvent-m_nSetGraphicSelectionY = pixelToTwip(pEvent-y, 
priv-m_fZoom);
 g_task_set_task_data(task, pLOEvent, g_free);
 
-g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
+g_thread_pool_push(priv-lokThreadPool, g_object_ref(task), 
NULL);
 g_object_unref(task);
 
 return FALSE;
@@ -919,7 +918,7 @@ lok_doc_view_signal_button(GtkWidget* pWidget, 
GdkEventButton* pEvent)
 pLOEvent-m_nSetGraphicSelectionY = pixelToTwip(pEvent-y, 
priv-m_fZoom);
 g_task_set_task_data(task, pLOEvent, g_free);
 
-g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
+g_thread_pool_push(priv-lokThreadPool, g_object_ref(task), NULL);
 g_object_unref(task);
 
 return FALSE;
@@ -968,7 +967,7 @@ lok_doc_view_signal_button(GtkWidget* pWidget, 
GdkEventButton* pEvent)
 pLOEvent-m_nSetGraphicSelectionY = 
pixelToTwip(priv-m_aGraphicHandleRects[i].y + 
priv-m_aGraphicHandleRects[i].height / 2, priv-m_fZoom);
 g_task_set_task_data(task, pLOEvent, g_free);
 
-g_thread_pool_push(lokThreadPool, g_object_ref(task), 
NULL);
+g_thread_pool_push(priv-lokThreadPool, 
g_object_ref(task), NULL);
 g_object_unref(task);
 
 return FALSE;
@@ -996,7 +995,7 @@ lok_doc_view_signal_button(GtkWidget* pWidget, 
GdkEventButton* pEvent)
 pLOEvent-m_nPostMouseEventCount = nCount;
 g_task_set_task_data(task, pLOEvent, g_free);
 
-g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
+g_thread_pool_push(priv-lokThreadPool, g_object_ref(task), NULL);
 g_object_unref(task);
 break;
 }
@@ -1014,7 +1013,7 @@ 

[Libreoffice-commits] core.git: libreofficekit/source

2015-07-28 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit b120adb290cee480516b14683f314318573c9d7e
Author: Miklos Vajna vmik...@collabora.co.uk
Date:   Tue Jul 28 16:35:02 2015 +0200

libreofficekit: -Werror,-Wformat-security

Change-Id: I177ea091fb1061d9fa71f7fb1a84629128afd6a0

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 7ce2764..d13fb9b 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1169,7 +1169,7 @@ openDocumentInThread (gpointer data)
 // FIXME: should have a GError parameter and populate it.
 char *pError = priv-m_pOffice-pClass-getError( priv-m_pOffice );
 fprintf( stderr, Error opening document '%s'\n, pError );
-g_task_return_new_error(task, 0, 0, pError);
+g_task_return_new_error(task, 0, 0, %s, pError);
 }
 else
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-07-07 Thread Pranav Kant
 libreofficekit/source/gtk/lokdocview.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit a625cd702700ae1773966a3133d27027d1c4d083
Author: Pranav Kant pran...@gnome.org
Date:   Thu Jul 2 23:47:33 2015 +0530

lokdocview: Grab focus on mouse 'button-press-event'

Change-Id: I65187bbd2cc32d9278d8b3890a82b390858a

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 62f1e61..bf12ca0 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -812,6 +812,7 @@ lok_doc_view_signal_button(GtkWidget* pWidget, 
GdkEventButton* pEvent)
(int)pEvent-x, (int)pEvent-y,
(int)pixelToTwip(pEvent-x, priv-m_fZoom),
(int)pixelToTwip(pEvent-y, priv-m_fZoom));
+gtk_widget_grab_focus(GTK_WIDGET(pDocView));
 
 if (pEvent-type == GDK_BUTTON_RELEASE)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-06-16 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |   13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

New commits:
commit 9dcd2d119ab67bde9de588c42db3805525d5f06a
Author: Miklos Vajna vmik...@collabora.co.uk
Date:   Tue Jun 16 11:34:36 2015 +0200

lokdocview: couple for missing static_castGParamFlags()

Change-Id: I038c05c0d081f52e4ac90688f73397565413632d

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index f4e1b77..9e8cabb 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -519,10 +519,7 @@ callback (gpointer pData)
 break;
 case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
 {
-g_info (%d %d, priv-m_nDocumentWidthTwips, 
priv-m_nDocumentHeightTwips);
-g_info (startin);
 payloadToSize(pCallback-m_aPayload.c_str(), 
priv-m_nDocumentWidthTwips, priv-m_nDocumentHeightTwips);
-g_info (%d %d, priv-m_nDocumentWidthTwips, 
priv-m_nDocumentHeightTwips);
 gtk_widget_set_size_request(GTK_WIDGET(pDocView),
 twipToPixel(priv-m_nDocumentWidthTwips, 
priv-m_fZoom),
 twipToPixel(priv-m_nDocumentHeightTwips, 
priv-m_fZoom));
@@ -1156,7 +1153,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
   Document Path,
   The URI of the document to open,
   0,
-  G_PARAM_READWRITE));
+  static_castGParamFlags(G_PARAM_READWRITE)));
 
 /**
  * LOKDocView:editable:
@@ -1169,7 +1166,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
Editable,
Whether the content is in edit mode or not,
FALSE,
-   G_PARAM_READWRITE));
+   static_castGParamFlags(G_PARAM_READWRITE)));
 
 /**
  * LOKDocView:load-progress:
@@ -1214,7 +1211,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
Is Loading,
Whether the view is loading a document,
FALSE,
-   G_PARAM_READABLE));
+   static_castGParamFlags(G_PARAM_READABLE)));
 
 /**
  * LOKDocView:doc-width:
@@ -1227,7 +1224,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
 Document Width,
 Width of the document in twips,
 0, G_MAXLONG, 0,
-G_PARAM_READWRITE));
+static_castGParamFlags(G_PARAM_READWRITE)));
 
 /**
  * LOKDocView:doc-height:
@@ -1240,7 +1237,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* 
pClass)
 Document Height,
 Height of the document in twips,
 0, G_MAXLONG, 0,
-G_PARAM_READWRITE));
+static_castGParamFlags(G_PARAM_READWRITE)));
 
 /**
  * LOKDocView:can-zoom-in:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-06-14 Thread Julien Nabet
 libreofficekit/source/gtk/tilebuffer.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 01a189abcd9a4ca472a74b3b2c000c9338fc2c91
Author: Julien Nabet serval2...@yahoo.fr
Date:   Sun Jun 14 09:09:52 2015 +0200

cppcheck: postfixOperator

Change-Id: Ia17bdf6e8f871d64add358822ea383236ecd6405

diff --git a/libreofficekit/source/gtk/tilebuffer.cxx 
b/libreofficekit/source/gtk/tilebuffer.cxx
index 2c0ee90..3f22f98 100644
--- a/libreofficekit/source/gtk/tilebuffer.cxx
+++ b/libreofficekit/source/gtk/tilebuffer.cxx
@@ -54,7 +54,7 @@ void Tile::setPixbuf(GdkPixbuf *buffer)
 void TileBuffer::resetAllTiles()
 {
 std::mapint, Tile::iterator it = m_mTiles.begin();
-for (; it != m_mTiles.end(); it++)
+for (; it != m_mTiles.end(); ++it)
 {
 it-second.release();
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-05-27 Thread Andrzej Hunt
 libreofficekit/source/gtk/lokdocview.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 176c27f1946ae889910dd154742f2416b481569d
Author: Andrzej Hunt andr...@ahunt.org
Date:   Wed May 27 19:30:07 2015 +0100

loplugin:staticmethods

Change-Id: I8a6a6dcac8355796b984f6b37b791596fe9dca02

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index ebb09e7..b6ec892 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -171,7 +171,7 @@ struct LOKDocView_Impl
  */
 void renderDocument(GdkRectangle* pPartial);
 /// Sets rWidth and rHeight from a width, height string.
-void payloadToSize(const char* pPayload, long rWidth, long rHeight);
+static void payloadToSize(const char* pPayload, long rWidth, long 
rHeight);
 /// Returns the GdkRectangle of a width,height,x,y string.
 static GdkRectangle payloadToRectangle(const char* pPayload);
 /// Returns the GdkRectangles of a w,h,x,y;w2,h2,x2,y2;... string.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-05-27 Thread Stephan Bergmann
 libreofficekit/source/gtk/lokdocview.cxx |   39 ---
 1 file changed, 21 insertions(+), 18 deletions(-)

New commits:
commit 5af7ca55a3d06ab23df715346c9b24d1333907be
Author: Stephan Bergmann sberg...@redhat.com
Date:   Wed May 27 20:51:09 2015 +0200

loplugin:staticmethods

Change-Id: Idb1072ecedd9ab0315d67e296da6d306c098b183

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index b6ec892..e3c03db 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -38,6 +38,26 @@
 // We know that VirtualDevices use a DPI of 96.
 static const int DPI = 96;
 
+namespace {
+
+/// Sets rWidth and rHeight from a width, height string.
+void payloadToSize(const char* pPayload, long rWidth, long rHeight)
+{
+rWidth = rHeight = 0;
+gchar** ppCoordinates = g_strsplit(pPayload, , , 2);
+gchar** ppCoordinate = ppCoordinates;
+if (!*ppCoordinate)
+return;
+rWidth = atoi(*ppCoordinate);
+++ppCoordinate;
+if (!*ppCoordinate)
+return;
+rHeight = atoi(*ppCoordinate);
+g_strfreev(ppCoordinates);
+}
+
+}
+
 /// Holds data used by LOKDocView only.
 struct LOKDocView_Impl
 {
@@ -170,8 +190,6 @@ struct LOKDocView_Impl
  * the tiles that intersect with pPartial.
  */
 void renderDocument(GdkRectangle* pPartial);
-/// Sets rWidth and rHeight from a width, height string.
-static void payloadToSize(const char* pPayload, long rWidth, long 
rHeight);
 /// Returns the GdkRectangle of a width,height,x,y string.
 static GdkRectangle payloadToRectangle(const char* pPayload);
 /// Returns the GdkRectangles of a w,h,x,y;w2,h2,x2,y2;... string.
@@ -846,21 +864,6 @@ void LOKDocView_Impl::renderDocument(GdkRectangle* 
pPartial)
 }
 }
 
-void LOKDocView_Impl::payloadToSize(const char* pPayload, long rWidth, long 
rHeight)
-{
-rWidth = rHeight = 0;
-gchar** ppCoordinates = g_strsplit(pPayload, , , 2);
-gchar** ppCoordinate = ppCoordinates;
-if (!*ppCoordinate)
-return;
-rWidth = atoi(*ppCoordinate);
-++ppCoordinate;
-if (!*ppCoordinate)
-return;
-rHeight = atoi(*ppCoordinate);
-g_strfreev(ppCoordinates);
-}
-
 GdkRectangle LOKDocView_Impl::payloadToRectangle(const char* pPayload)
 {
 GdkRectangle aRet;
@@ -1033,7 +1036,7 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* 
pCallback)
 break;
 case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
 {
-LOKDocView_Impl::payloadToSize(pCallback-m_aPayload.c_str(), 
m_nDocumentWidthTwips, m_nDocumentHeightTwips);
+payloadToSize(pCallback-m_aPayload.c_str(), m_nDocumentWidthTwips, 
m_nDocumentHeightTwips);
 }
 break;
 case LOK_CALLBACK_SET_PART:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-05-18 Thread Stephan Bergmann
 libreofficekit/source/gtk/lokdocview.cxx |   59 ---
 1 file changed, 31 insertions(+), 28 deletions(-)

New commits:
commit 626b1e9177eed280a71ca9a009bc76a4c3476364
Author: Stephan Bergmann sberg...@redhat.com
Date:   Mon May 18 09:33:53 2015 +0200

loplugin:staticmethods

Change-Id: I660d68b9b596be531d595c35666a33fb02d6fd6a

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 4fffaf3..f7f040a 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -183,8 +183,6 @@ struct LOKDocView_Impl
 static gboolean globalCallback(gpointer pData);
 /// Implementation of the callback handler, invoked by callback();
 gboolean callbackImpl(CallbackData* pCallbackData);
-/// Implementation of the global callback handler, invoked by 
globalCallback();
-gboolean globalCallbackImpl(CallbackData* pCallbackData);
 /// Our LOK callback, runs on the LO thread.
 static void callbackWorker(int nType, const char* pPayload, void* pData);
 /// Implementation of the callback worder handler, invoked by 
callbackWorker().
@@ -197,6 +195,36 @@ struct LOKDocView_Impl
 void commandChanged(const std::string rPayload);
 };
 
+namespace {
+
+/// Implementation of the global callback handler, invoked by globalCallback();
+gboolean globalCallbackImpl(LOKDocView_Impl::CallbackData* pCallback)
+{
+switch (pCallback-m_nType)
+{
+case LOK_CALLBACK_STATUS_INDICATOR_START:
+{
+}
+break;
+case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
+{
+}
+break;
+case LOK_CALLBACK_STATUS_INDICATOR_FINISH:
+{
+}
+break;
+default:
+g_assert(false);
+break;
+}
+delete pCallback;
+
+return G_SOURCE_REMOVE;
+}
+
+}
+
 LOKDocView_Impl::CallbackData::CallbackData(int nType, const std::string 
rPayload, LOKDocView* pDocView)
 : m_nType(nType),
 m_aPayload(rPayload),
@@ -899,7 +927,7 @@ gboolean LOKDocView_Impl::callback(gpointer pData)
 gboolean LOKDocView_Impl::globalCallback(gpointer pData)
 {
 LOKDocView_Impl::CallbackData* pCallback = 
static_castLOKDocView_Impl::CallbackData*(pData);
-return pCallback-m_pDocView-m_pImpl-globalCallbackImpl(pCallback);
+return globalCallbackImpl(pCallback);
 }
 
 gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback)
@@ -987,31 +1015,6 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* 
pCallback)
 return G_SOURCE_REMOVE;
 }
 
-gboolean LOKDocView_Impl::globalCallbackImpl(CallbackData* pCallback)
-{
-switch (pCallback-m_nType)
-{
-case LOK_CALLBACK_STATUS_INDICATOR_START:
-{
-}
-break;
-case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
-{
-}
-break;
-case LOK_CALLBACK_STATUS_INDICATOR_FINISH:
-{
-}
-break;
-default:
-g_assert(false);
-break;
-}
-delete pCallback;
-
-return G_SOURCE_REMOVE;
-}
-
 void LOKDocView_Impl::callbackWorker(int nType, const char* pPayload, void* 
pData)
 {
 LOKDocView* pDocView = static_castLOKDocView*(pData);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-04-13 Thread Tor Lillqvist
 libreofficekit/source/gtk/lokdocview.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c10f132aa823dc1129ab863c97083a03c7859e8c
Author: Tor Lillqvist t...@collabora.com
Date:   Mon Apr 13 18:36:11 2015 +0300

WaE: format string is not a string literal

Change-Id: I0346c98ec1e075009ac6b563119ee44178e9c773

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index ac94f15..2e2313a 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -941,7 +941,7 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* 
pCallback)
 }
 case LOK_CALLBACK_STATE_CHANGED:
 {
-g_info(pCallback-m_aPayload.c_str());
+g_info(%s, pCallback-m_aPayload.c_str());
 }
 break;
 default:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-04-07 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit c3699a4c482bb5151d8fff7502332e3554caa314
Author: Miklos Vajna vmik...@collabora.co.uk
Date:   Tue Apr 7 09:21:04 2015 +0200

lokdocview: gtk_show_uri() requires Gtk 2.14

Change-Id: I54454fec250b74238a1c064cc2136889e1a28972

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index b71355e..7430511 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -933,7 +933,9 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* 
pCallback)
 case LOK_CALLBACK_HYPERLINK_CLICKED:
 {
 GError* pError = NULL;
+#if GTK_CHECK_VERSION(2,14,0)
 gtk_show_uri(NULL, pCallback-m_aPayload.c_str(), GDK_CURRENT_TIME, 
pError);
+#endif
 }
 break;
 default:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-03-16 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 81f0c285deb50fcec729168c8736729590c07fa7
Author: Miklos Vajna vmik...@collabora.co.uk
Date:   Mon Mar 16 12:45:21 2015 +0100

lok_docview_init: ignore the second, not the first param

Fixes the crash on startup.

Change-Id: I991537644dfb6a5335d08d3d03c3d25491a0c335

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index c0f2130..668d6de 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -337,9 +337,9 @@ static void lok_docview_class_init( gpointer ptr )
  G_TYPE_BOOLEAN);
 }
 
-static void lok_docview_init( GTypeInstance *, gpointer ptr )
+static void lok_docview_init( GTypeInstance* pInstance, gpointer )
 {
-LOKDocView* pDocView = static_castLOKDocView *(ptr);
+LOKDocView* pDocView = reinterpret_castLOKDocView *(pInstance);
 // Gtk ScrolledWindow is apparently not fully initialised yet, we 
specifically
 // have to set the [hv]adjustment to prevent GTK assertions from firing, 
see
 // https://bugzilla.gnome.org/show_bug.cgi?id=438114 for more info.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source svx/source sw/source

2015-03-08 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.c |2 +-
 svx/source/svdraw/svdhdl.cxx   |2 +-
 sw/source/core/view/viewsh.cxx |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit bb0cae0f967eed386b546dd7367c2cc1b274f555
Author: Miklos Vajna vmik...@collabora.co.uk
Date:   Sun Mar 8 11:23:03 2015 +0100

libreofficekit, svx, sw: fix typos

Change-Id: I883c0b95d91ae9cb7e59b8f68ae0c8a3ebcb9f88
Reviewed-on: https://gerrit.libreoffice.org/14796
Reviewed-by: Miklos Vajna vmik...@collabora.co.uk
Tested-by: Jenkins c...@libreoffice.org

diff --git a/libreofficekit/source/gtk/lokdocview.c 
b/libreofficekit/source/gtk/lokdocview.c
index 525bf84..672270f 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -277,7 +277,7 @@ SAL_DLLPUBLIC_EXPORT GtkWidget* lok_docview_new( 
LibreOfficeKit* pOffice )
 return GTK_WIDGET( pDocView );
 }
 
-// We know that VirtualDevises use a DPI of 96.
+// We know that VirtualDevices use a DPI of 96.
 static const int g_nDPI = 96;
 
 /// Converts from document coordinates to screen pixels.
diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx
index 66e3bc1..08afe88 100644
--- a/svx/source/svdraw/svdhdl.cxx
+++ b/svx/source/svdraw/svdhdl.cxx
@@ -372,7 +372,7 @@ void SdrHdl::SetHdlList(SdrHdlList* pList)
 {
 if(pHdlList != pList)
 {
-// rememver list
+// remember list
 pHdlList = pList;
 
 // now its possible to create graphic representation
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index e74f326..da36228 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -1790,7 +1790,7 @@ void SwViewShell::PaintTile(VirtualDevice rDevice, int 
contextWidth, int contex
 aMapMode.SetOrigin(Point(-tilePosX, -tilePosY));
 
 // Scaling. Must convert from pixels to twips. We know
-// that VirtualDevises use a DPI of 96.
+// that VirtualDevices use a DPI of 96.
 Fraction scaleX = Fraction(contextWidth, 96) * Fraction(1440L) / 
Fraction(tileWidth);
 Fraction scaleY = Fraction(contextHeight, 96) * Fraction(1440L) / 
Fraction(tileHeight);
 aMapMode.SetScaleX(scaleX);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-02-23 Thread Michael Meeks
 libreofficekit/source/gtk/lokdocview.c |   58 +++--
 1 file changed, 41 insertions(+), 17 deletions(-)

New commits:
commit 74a9840a51d734568e4f7ba13f1b4a819215acba
Author: Michael Meeks michael.me...@collabora.com
Date:   Mon Feb 23 10:04:38 2015 +

lokdocview: scale selection rendering / cursor handling with zoom.

Change-Id: I2e3b86fd7f9eb2da0bcd36afd5a735a2815d70cd

diff --git a/libreofficekit/source/gtk/lokdocview.c 
b/libreofficekit/source/gtk/lokdocview.c
index 31d9430..ce81eb8 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -74,19 +74,25 @@ gboolean lcl_signalMotion(GtkWidget* pEventBox, 
GdkEventButton* pEvent, LOKDocVi
 {
 g_info(lcl_signalMotion: dragging the middle handle);
 lcl_getDragPoint(pDocView-m_aHandleMiddleRect, pEvent, aPoint);
-pDocView-pDocument-pClass-setTextSelection(pDocView-pDocument, 
LOK_SETTEXTSELECTION_RESET, pixelToTwip(aPoint.x), pixelToTwip(aPoint.y));
+pDocView-pDocument-pClass-setTextSelection(
+pDocView-pDocument, LOK_SETTEXTSELECTION_RESET,
+pixelToTwip(aPoint.x) / pDocView-fZoom, pixelToTwip(aPoint.y) 
/ pDocView-fZoom);
 }
 else if (pDocView-m_bInDragStartHandle)
 {
 g_info(lcl_signalMotion: dragging the start handle);
 lcl_getDragPoint(pDocView-m_aHandleStartRect, pEvent, aPoint);
-pDocView-pDocument-pClass-setTextSelection(pDocView-pDocument, 
LOK_SETTEXTSELECTION_START, pixelToTwip(aPoint.x), pixelToTwip(aPoint.y));
+pDocView-pDocument-pClass-setTextSelection(
+pDocView-pDocument, LOK_SETTEXTSELECTION_START,
+pixelToTwip(aPoint.x) / pDocView-fZoom, pixelToTwip(aPoint.y) 
/ pDocView-fZoom);
 }
 else if (pDocView-m_bInDragEndHandle)
 {
 g_info(lcl_signalMotion: dragging the end handle);
 lcl_getDragPoint(pDocView-m_aHandleEndRect, pEvent, aPoint);
-pDocView-pDocument-pClass-setTextSelection(pDocView-pDocument, 
LOK_SETTEXTSELECTION_END, pixelToTwip(aPoint.x), pixelToTwip(aPoint.y));
+pDocView-pDocument-pClass-setTextSelection(
+pDocView-pDocument, LOK_SETTEXTSELECTION_END,
+pixelToTwip(aPoint.x) / pDocView-fZoom, pixelToTwip(aPoint.y) 
/ pDocView-fZoom);
 }
 return FALSE;
 }
@@ -159,7 +165,10 @@ gboolean lcl_signalButton(GtkWidget* pEventBox, 
GdkEventButton* pEvent, LOKDocVi
 if ((pEvent-time - pDocView-m_nLastButtonPressTime)  250)
 nCount++;
 pDocView-m_nLastButtonPressTime = pEvent-time;
-pDocView-pDocument-pClass-postMouseEvent(pDocView-pDocument, 
LOK_MOUSEEVENT_MOUSEBUTTONDOWN, pixelToTwip(pEvent-x), pixelToTwip(pEvent-y), 
nCount);
+pDocView-pDocument-pClass-postMouseEvent(
+pDocView-pDocument, LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+pixelToTwip(pEvent-x) / pDocView-fZoom,
+pixelToTwip(pEvent-y) / pDocView-fZoom, nCount);
 break;
 }
 case GDK_BUTTON_RELEASE:
@@ -168,7 +177,10 @@ gboolean lcl_signalButton(GtkWidget* pEventBox, 
GdkEventButton* pEvent, LOKDocVi
 if ((pEvent-time - pDocView-m_nLastButtonReleaseTime)  250)
 nCount++;
 pDocView-m_nLastButtonReleaseTime = pEvent-time;
-pDocView-pDocument-pClass-postMouseEvent(pDocView-pDocument, 
LOK_MOUSEEVENT_MOUSEBUTTONUP, pixelToTwip(pEvent-x), pixelToTwip(pEvent-y), 
nCount);
+pDocView-pDocument-pClass-postMouseEvent(
+pDocView-pDocument, LOK_MOUSEEVENT_MOUSEBUTTONUP,
+pixelToTwip(pEvent-x) / pDocView-fZoom,
+pixelToTwip(pEvent-y) / pDocView-fZoom, nCount);
 break;
 }
 default:
@@ -303,7 +315,8 @@ static gboolean lcl_handleTimeout(gpointer pData)
 }
 
 /// Renders pHandle below a pCursor rectangle on pCairo.
-static void lcl_renderHandle(cairo_t* pCairo, GdkRectangle* pCursor, 
cairo_surface_t* pHandle, GdkRectangle* pRectangle)
+static void lcl_renderHandle(cairo_t* pCairo, GdkRectangle* pCursor, 
cairo_surface_t* pHandle,
+ GdkRectangle* pRectangle, float fZoom)
 {
 GdkPoint aCursorBottom;
 int nHandleWidth, nHandleHeight;
@@ -312,10 +325,10 @@ static void lcl_renderHandle(cairo_t* pCairo, 
GdkRectangle* pCursor, cairo_surfa
 nHandleWidth = cairo_image_surface_get_width(pHandle);
 nHandleHeight = cairo_image_surface_get_height(pHandle);
 // We want to scale down the handle, so that its height is the same as the 
cursor caret.
-fHandleScale = twipToPixel(pCursor-height) / nHandleHeight;
+fHandleScale = twipToPixel(pCursor-height) * fZoom / nHandleHeight;
 // We want the top center of the handle bitmap to be at the bottom center 
of the cursor rectangle.
-aCursorBottom.x = twipToPixel(pCursor-x) + twipToPixel(pCursor-width) / 
2 - (nHandleWidth * fHandleScale) / 2;
-aCursorBottom.y = twipToPixel(pCursor-y) + 

[Libreoffice-commits] core.git: libreofficekit/source

2015-01-30 Thread Caolán McNamara
 libreofficekit/source/gtk/lokdocview.c |1 +
 1 file changed, 1 insertion(+)

New commits:
commit cc5af14e67f75a2d42bce2b6a2d996cf8f7aee87
Author: Caolán McNamara caol...@redhat.com
Date:   Fri Jan 30 20:56:07 2015 +

coverity#1267697 Uninitialized scalar variable

Change-Id: I0703df58dd3d798ff0928f317b8d61e13ec2f0ce

diff --git a/libreofficekit/source/gtk/lokdocview.c 
b/libreofficekit/source/gtk/lokdocview.c
index 372fa9d..8f80d20 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -262,6 +262,7 @@ static GdkRectangle lcl_payloadToRectangle(const char* 
pPayload)
 GdkRectangle aRet;
 gchar** ppCoordinates;
 
+aRet.width = aRet.height = aRet.x = aRet.y = 0;
 ppCoordinates = g_strsplit(pPayload, , , 4);
 if (!*ppCoordinates)
 return aRet;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: libreofficekit/source

2015-01-26 Thread Miklos Vajna
 libreofficekit/source/gtk/lokdocview.c |4 
 1 file changed, 4 insertions(+)

New commits:
commit 64235bc9896911b4abfca47089ac1e71056afea7
Author: Miklos Vajna vmik...@collabora.co.uk
Date:   Mon Jan 26 14:08:45 2015 +0100

lokdocview: fix for missing gtk_table_get_size()

Change-Id: Ib3f9849c2f28375a7e8bcd6575a6c3da0860d4fb

diff --git a/libreofficekit/source/gtk/lokdocview.c 
b/libreofficekit/source/gtk/lokdocview.c
index 7264563..372fa9d 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -163,10 +163,14 @@ void renderDocument(LOKDocView* pDocView, GdkRectangle* 
pPartial)
 // Same as nRows / nColumns, but from the previous renderDocument() 
call.
 guint nOldRows, nOldColumns;
 
+#if GTK_CHECK_VERSION(2,22,0)
 gtk_table_get_size(GTK_TABLE(pDocView-pTable), nOldRows, 
nOldColumns);
 if (nOldRows != nRows || nOldColumns != nColumns)
 // Can't do partial rendering, document size changed.
 pPartial = NULL;
+#else
+pPartial = NULL;
+#endif
 }
 if (!pPartial)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


  1   2   >