Kaydet (Commit) 27309441 authored tarafından Miklos Vajna's avatar Miklos Vajna

lokdocview: add lok_docview_get_document()

And move private data out of LibreOfficeKitGtk.h, so that clients are
forced to use the getter/setter functions.

Change-Id: I6565312b5ec5a8e882c3763164ff5aa81ed9720c
üst a20167ba
...@@ -30,68 +30,8 @@ typedef struct _LOKDocViewClass LOKDocViewClass; ...@@ -30,68 +30,8 @@ typedef struct _LOKDocViewClass LOKDocViewClass;
struct _LOKDocView struct _LOKDocView
{ {
GtkScrolledWindow scrollWindow; GtkScrolledWindow aScrollWindow;
struct LOKDocView_Impl* m_pImpl;
GtkWidget* pEventBox;
GtkWidget* pTable;
GtkWidget** pCanvas;
float fZoom;
LibreOfficeKit* pOffice;
LibreOfficeKitDocument* pDocument;
/// View or edit mode.
gboolean m_bEdit;
/// Position and size of the visible cursor.
GdkRectangle m_aVisibleCursor;
/// Cursor overlay is visible or hidden (for blinking).
gboolean m_bCursorOverlayVisible;
/// Cursor is visible or hidden (e.g. for graphic selection).
gboolean m_bCursorVisible;
/// Time of the last button press.
guint32 m_nLastButtonPressTime;
/// Time of the last button release.
guint32 m_nLastButtonReleaseTime;
/// Rectangles of the current text selection.
GList* m_pTextSelectionRectangles;
/// 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.
GdkRectangle m_aTextSelectionEnd;
GdkRectangle m_aGraphicSelection;
gboolean m_bInDragGraphicSelection;
/// @name Start/middle/end handle.
///@{
/// Bitmap of the text selection start handle.
cairo_surface_t* m_pHandleStart;
/// Rectangle of the text selection start handle, to know if the user clicked on it or not
GdkRectangle m_aHandleStartRect;
/// If we are in the middle of a drag of the text selection end handle.
gboolean m_bInDragStartHandle;
/// Bitmap of the text selection middle handle.
cairo_surface_t* m_pHandleMiddle;
/// Rectangle of the text selection middle handle, to know if the user clicked on it or not
GdkRectangle m_aHandleMiddleRect;
/// If we are in the middle of a drag of the text selection middle handle.
gboolean m_bInDragMiddleHandle;
/// Bitmap of the text selection end handle.
cairo_surface_t* m_pHandleEnd;
/// Rectangle of the text selection end handle, to know if the user clicked on it or not
GdkRectangle m_aHandleEndRect;
/// If we are in the middle of a drag of the text selection end handle.
gboolean m_bInDragEndHandle;
///@}
/// @name Graphic handles.
///@{
/// Bitmap of a graphic selection handle.
cairo_surface_t* m_pGraphicHandle;
/// Rectangle of a graphic selection handle, to know if the user clicked on it or not.
GdkRectangle m_aGraphicHandleRects[8];
/// If we are in the middle of a drag of a graphic selection handle.
gboolean m_bInDragGraphicHandles[8];
///@}
}; };
struct _LOKDocViewClass struct _LOKDocViewClass
...@@ -104,6 +44,10 @@ guint lok_docview_get_type (void); ...@@ -104,6 +44,10 @@ guint lok_docview_get_type (void);
GtkWidget* lok_docview_new ( LibreOfficeKit* pOffice ); GtkWidget* lok_docview_new ( LibreOfficeKit* pOffice );
gboolean lok_docview_open_document (LOKDocView* pDocView, gboolean lok_docview_open_document (LOKDocView* pDocView,
char* pPath); char* pPath);
/// Gets the document the viewer displays.
LibreOfficeKitDocument* lok_docview_get_document(LOKDocView* pDocView);
void lok_docview_set_zoom (LOKDocView* pDocView, void lok_docview_set_zoom (LOKDocView* pDocView,
float fZoom); float fZoom);
float lok_docview_get_zoom (LOKDocView* pDocView); float lok_docview_get_zoom (LOKDocView* pDocView);
......
...@@ -126,7 +126,7 @@ static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pD ...@@ -126,7 +126,7 @@ static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pD
int nCharCode = 0; int nCharCode = 0;
int nKeyCode = 0; int nKeyCode = 0;
if (!pLOKDocView->m_bEdit) if (!lok_docview_get_edit(pLOKDocView))
{ {
g_info("signalKey: not in edit mode, ignore"); g_info("signalKey: not in edit mode, ignore");
return; return;
...@@ -171,10 +171,11 @@ static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pD ...@@ -171,10 +171,11 @@ static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pD
if (pEvent->state & GDK_SHIFT_MASK) if (pEvent->state & GDK_SHIFT_MASK)
nKeyCode |= KEY_SHIFT; nKeyCode |= KEY_SHIFT;
LibreOfficeKitDocument* pDocument = lok_docview_get_document(pLOKDocView);
if (pEvent->type == GDK_KEY_RELEASE) if (pEvent->type == GDK_KEY_RELEASE)
pLOKDocView->pDocument->pClass->postKeyEvent(pLOKDocView->pDocument, LOK_KEYEVENT_KEYUP, nCharCode, nKeyCode); pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, nCharCode, nKeyCode);
else else
pLOKDocView->pDocument->pClass->postKeyEvent(pLOKDocView->pDocument, LOK_KEYEVENT_KEYINPUT, nCharCode, nKeyCode); pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, nCharCode, nKeyCode);
} }
// GtkComboBox requires gtk 2.24 or later // GtkComboBox requires gtk 2.24 or later
...@@ -340,7 +341,7 @@ int main( int argc, char* argv[] ) ...@@ -340,7 +341,7 @@ int main( int argc, char* argv[] )
int bOpened = lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] ); int bOpened = lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] );
if (!bOpened) if (!bOpened)
g_error("main: lok_docview_open_document() failed with '%s'", pOffice->pClass->getError(pOffice)); g_error("main: lok_docview_open_document() failed with '%s'", pOffice->pClass->getError(pOffice));
assert( LOK_DOCVIEW(pDocView)->pDocument ); assert(lok_docview_get_document(LOK_DOCVIEW(pDocView)));
// GtkComboBox requires gtk 2.24 or later // GtkComboBox requires gtk 2.24 or later
#if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2 #if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment