[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 2 commits - include/LibreOfficeKit libreofficekit/source sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Feb 6 03:13:56 PST 2015
include/LibreOfficeKit/LibreOfficeKit.h | 13 +++++++-
include/LibreOfficeKit/LibreOfficeKitGtk.h | 2 +
libreofficekit/source/gtk/lokdocview.c | 42 +++++++++++++++++++++++++++++
sw/source/core/crsr/viscrs.cxx | 14 +++++++++
sw/source/core/layout/trvlfrm.cxx | 6 +++-
5 files changed, 74 insertions(+), 3 deletions(-)
New commits:
commit a8e04b7cefebc8925f73639676b717db1832b33a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Feb 6 12:12:44 2015 +0100
lokdocview: implement selection overlay using LOK_CALLBACK_TEXT_SELECTION
Change-Id: I59cb870973ea4e2fda816b15ae7d9a53a4624e8d
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index fd57139..8c4bb56 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -51,6 +51,8 @@ struct _LOKDocView
guint32 m_nLastButtonPressTime;
/// Time of the last button release.
guint32 m_nLastButtonReleaseTime;
+ /// Rectangles of the current text selection.
+ GList* m_pTextSelectionRectangles;
};
struct _LOKDocViewClass
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index daaf89f..3e223fd 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -127,6 +127,7 @@ static void lok_docview_init( LOKDocView* pDocView )
pDocView->m_bCursorVisible = FALSE;
pDocView->m_nLastButtonPressTime = 0;
pDocView->m_nLastButtonReleaseTime = 0;
+ pDocView->m_pTextSelectionRectangles = NULL;
gtk_signal_connect( GTK_OBJECT(pDocView), "destroy",
GTK_SIGNAL_FUNC(lcl_onDestroy), NULL );
@@ -201,6 +202,20 @@ static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpoint
cairo_fill(pCairo);
}
+ if (pDocView->m_pTextSelectionRectangles)
+ {
+ GList* i;
+
+ for (i = pDocView->m_pTextSelectionRectangles; i != NULL; i = i->next)
+ {
+ GdkRectangle* pRectangle = i->data;
+ // Blue with 75% transparency.
+ cairo_set_source_rgba(pCairo, ((double)0x43)/255, ((double)0xac)/255, ((double)0xe8)/255, 0.25);
+ cairo_rectangle(pCairo, twipToPixel(pRectangle->x), twipToPixel(pRectangle->y), twipToPixel(pRectangle->width), twipToPixel(pRectangle->height));
+ cairo_fill(pCairo);
+ }
+ }
+
cairo_destroy(pCairo);
return FALSE;
}
@@ -346,6 +361,24 @@ static GdkRectangle lcl_payloadToRectangle(const char* pPayload)
return aRet;
}
+/// Returns the GdkRectangle list of a w,h,x,y;w2,h2,x2,y2;... string.
+static GList* lcl_payloadToRectangles(const char* pPayload)
+{
+ GList* pRet = NULL;
+ gchar** ppRectangles;
+ gchar** ppRectangle;
+
+ ppRectangles = g_strsplit(pPayload, "; ", 0);
+ for (ppRectangle = ppRectangles; *ppRectangle; ++ppRectangle)
+ {
+ GdkRectangle aRect = lcl_payloadToRectangle(*ppRectangle);
+ GdkRectangle* pRect = g_new0(GdkRectangle, 1);
+ *pRect = aRect;
+ pRet = g_list_prepend(pRet, pRect);
+ }
+ g_strfreev(ppRectangles);
+ return pRet;
+}
/// Invoked on the main thread if lok_docview_callback_worker() requests so.
static gboolean lok_docview_callback(gpointer pData)
{
@@ -371,6 +404,15 @@ static gboolean lok_docview_callback(gpointer pData)
gtk_widget_queue_draw(GTK_WIDGET(pCallback->m_pDocView->pEventBox));
}
break;
+ case LOK_CALLBACK_TEXT_SELECTION:
+ {
+ GList* pRectangles = lcl_payloadToRectangles(pCallback->m_pPayload);
+ if (pCallback->m_pDocView->m_pTextSelectionRectangles)
+ g_list_free_full(pCallback->m_pDocView->m_pTextSelectionRectangles, g_free);
+ pCallback->m_pDocView->m_pTextSelectionRectangles = pRectangles;
+ gtk_widget_queue_draw(GTK_WIDGET(pCallback->m_pDocView->pEventBox));
+ }
+ break;
default:
break;
}
commit 39ad66d928e322d90510e39bada1cce7db990d01
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Feb 6 12:12:02 2015 +0100
LOK: add LOK_CALLBACK_TEXT_SELECTION and implement it in sw
Change-Id: I31662cb06add0d1a1c517b5f5416703aeaae1e77
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index c76e56b..0187be0 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -57,7 +57,7 @@ typedef enum
* Any tiles which are over the rectangle described in the payload are no
* longer valid.
*
- * Rectangle format: "width,height,x,y", where all numbers are document
+ * Rectangle format: "width, height, x, y", where all numbers are document
* coordinates, in twips.
*/
LOK_CALLBACK_INVALIDATE_TILES,
@@ -66,7 +66,16 @@ typedef enum
*
* Rectangle format is the same as LOK_CALLBACK_INVALIDATE_TILES.
*/
- LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR
+ LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR,
+ /**
+ * The list of rectangles representing the current text selection changed.
+ *
+ * List format is "rectangle1[; rectangle2[; ...]]" (without quotes and
+ * brackets), where rectangleN has the same format as
+ * LOK_CALLBACK_INVALIDATE_TILES. When there is no selection, an empty
+ * string is provided.
+ */
+ LOK_CALLBACK_TEXT_SELECTION
}
LibreOfficeKitCallbackType;
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 247efcb..66bb2bc 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -314,6 +314,20 @@ void SwSelPaintRects::Show()
}
}
+ if (GetShell()->isTiledRendering())
+ {
+ std::stringstream ss;
+ for (size_type i = 0; i < size(); ++i)
+ {
+ const SwRect& rRect = (*this)[i];
+ if (i)
+ ss << "; ";
+ ss << rRect.Width() << ", " << rRect.Height() << ", " << rRect.Left() << ", " << rRect.Top();
+ }
+ OString sRect = ss.str().c_str();
+ GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
+ }
+
HighlightInputFld();
#else
const OutputDevice* pOut = GetShell()->GetWin();
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index b4820e0..dbdf72b 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -2007,8 +2007,12 @@ void SwRootFrm::CalcFrmRects(SwShellCrsr &rCrsr)
SwViewShell *pSh = GetCurrShell();
+ bool bIgnoreVisArea = false;
+ if (pSh)
+ bIgnoreVisArea = pSh->GetViewOptions()->IsPDFExport() || pSh->isTiledRendering();
+
// #i12836# enhanced pdf
- SwRegionRects aRegion( pSh && !pSh->GetViewOptions()->IsPDFExport() ?
+ SwRegionRects aRegion( !bIgnoreVisArea ?
pSh->VisArea() :
Frm() );
if( !pStartPos->nNode.GetNode().IsCntntNode() ||
More information about the Libreoffice-commits
mailing list