2014-06-12 17:38:10 +01:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sal/types.h>
|
2015-01-14 17:57:47 +01:00
|
|
|
#include <math.h>
|
2015-01-16 15:47:51 +01:00
|
|
|
#include <string.h>
|
2014-06-12 17:38:10 +01:00
|
|
|
|
|
|
|
#define LOK_USE_UNSTABLE_API
|
|
|
|
#include <LibreOfficeKit/LibreOfficeKit.h>
|
|
|
|
|
|
|
|
#include <LibreOfficeKit/LibreOfficeKitGtk.h>
|
|
|
|
|
2015-01-12 11:58:18 +00:00
|
|
|
#ifndef G_SOURCE_REMOVE
|
|
|
|
#define G_SOURCE_REMOVE FALSE
|
|
|
|
#endif
|
|
|
|
|
2014-06-12 17:38:10 +01:00
|
|
|
static void lok_docview_class_init( LOKDocViewClass* pClass );
|
|
|
|
static void lok_docview_init( LOKDocView* pDocView );
|
2015-01-20 17:50:46 +01:00
|
|
|
static float pixelToTwip(float nInput);
|
2014-06-12 17:38:10 +01:00
|
|
|
|
2014-06-24 21:13:42 +01:00
|
|
|
// We specifically need to destroy the document when closing in order to ensure
|
|
|
|
// that lock files etc. are cleaned up.
|
|
|
|
void lcl_onDestroy( LOKDocView* pDocView, gpointer pData )
|
|
|
|
{
|
|
|
|
(void) pData;
|
2014-06-26 11:14:50 +01:00
|
|
|
if ( pDocView->pDocument )
|
|
|
|
pDocView->pDocument->pClass->destroy( pDocView->pDocument );
|
|
|
|
pDocView->pDocument = NULL;
|
2014-06-24 21:13:42 +01:00
|
|
|
}
|
|
|
|
|
2015-01-20 10:20:24 +01:00
|
|
|
/// Receives a button press event.
|
|
|
|
void lcl_signalButton(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocView* pDocView)
|
|
|
|
{
|
2015-01-20 17:50:46 +01:00
|
|
|
g_info("lcl_signalButton: %d, %d (in twips: %d, %d)", (int)pEvent->x, (int)pEvent->y, (int)pixelToTwip(pEvent->x), (int)pixelToTwip(pEvent->y));
|
2015-01-20 10:20:24 +01:00
|
|
|
(void) pEventBox;
|
|
|
|
|
|
|
|
lok_docview_set_edit(pDocView, TRUE);
|
|
|
|
|
|
|
|
switch (pEvent->type)
|
|
|
|
{
|
|
|
|
case GDK_BUTTON_PRESS:
|
2015-01-21 12:42:08 +01:00
|
|
|
pDocView->pDocument->pClass->postMouseEvent(pDocView->pDocument, LOK_MOUSEEVENT_MOUSEBUTTONDOWN, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
|
2015-01-20 10:20:24 +01:00
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
2015-01-21 12:42:08 +01:00
|
|
|
pDocView->pDocument->pClass->postMouseEvent(pDocView->pDocument, LOK_MOUSEEVENT_MOUSEBUTTONUP, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
|
2015-01-20 10:20:24 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-12 17:38:10 +01:00
|
|
|
SAL_DLLPUBLIC_EXPORT guint lok_docview_get_type()
|
|
|
|
{
|
|
|
|
static guint lok_docview_type = 0;
|
|
|
|
|
|
|
|
if (!lok_docview_type)
|
|
|
|
{
|
|
|
|
GtkTypeInfo lok_docview_info =
|
|
|
|
{
|
|
|
|
"LokDocView",
|
|
|
|
sizeof( LOKDocView ),
|
|
|
|
sizeof( LOKDocViewClass ),
|
|
|
|
(GtkClassInitFunc) lok_docview_class_init,
|
|
|
|
(GtkObjectInitFunc) lok_docview_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GtkClassInitFunc) NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
lok_docview_type = gtk_type_unique( gtk_scrolled_window_get_type(), &lok_docview_info );
|
|
|
|
}
|
|
|
|
return lok_docview_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void lok_docview_class_init( LOKDocViewClass* pClass )
|
|
|
|
{
|
2015-01-07 16:07:55 +01:00
|
|
|
(void)pClass;
|
2014-06-12 17:38:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void lok_docview_init( LOKDocView* pDocView )
|
|
|
|
{
|
2014-06-13 11:21:38 +01:00
|
|
|
// 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.
|
|
|
|
gtk_scrolled_window_set_hadjustment( GTK_SCROLLED_WINDOW( pDocView ), NULL );
|
|
|
|
gtk_scrolled_window_set_vadjustment( GTK_SCROLLED_WINDOW( pDocView ), NULL );
|
|
|
|
|
2014-06-12 17:38:10 +01:00
|
|
|
pDocView->pEventBox = gtk_event_box_new();
|
|
|
|
gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pDocView),
|
|
|
|
pDocView->pEventBox );
|
|
|
|
|
2015-01-20 10:20:24 +01:00
|
|
|
gtk_signal_connect(GTK_OBJECT(pDocView->pEventBox), "button-press-event", GTK_SIGNAL_FUNC(lcl_signalButton), pDocView);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(pDocView->pEventBox), "button-release-event", GTK_SIGNAL_FUNC(lcl_signalButton), pDocView);
|
2015-01-13 16:47:23 +01:00
|
|
|
|
2014-06-12 17:38:10 +01:00
|
|
|
gtk_widget_show( pDocView->pEventBox );
|
|
|
|
|
2015-01-14 17:57:47 +01:00
|
|
|
pDocView->pTable = 0;
|
|
|
|
pDocView->pCanvas = 0;
|
2014-06-12 17:38:10 +01:00
|
|
|
|
|
|
|
// TODO: figure out a clever view of getting paths set up.
|
|
|
|
pDocView->pOffice = 0;
|
|
|
|
pDocView->pDocument = 0;
|
2014-06-23 15:13:25 +01:00
|
|
|
|
|
|
|
pDocView->fZoom = 1;
|
2015-01-13 16:47:23 +01:00
|
|
|
pDocView->m_bEdit = FALSE;
|
2014-06-24 21:13:42 +01:00
|
|
|
|
|
|
|
gtk_signal_connect( GTK_OBJECT(pDocView), "destroy",
|
|
|
|
GTK_SIGNAL_FUNC(lcl_onDestroy), NULL );
|
2014-06-12 17:38:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SAL_DLLPUBLIC_EXPORT GtkWidget* lok_docview_new( LibreOfficeKit* pOffice )
|
|
|
|
{
|
|
|
|
LOKDocView* pDocView = gtk_type_new( lok_docview_get_type() );
|
|
|
|
pDocView->pOffice = pOffice;
|
|
|
|
return GTK_WIDGET( pDocView );
|
|
|
|
}
|
|
|
|
|
2015-01-14 14:37:20 +01:00
|
|
|
// We know that VirtualDevises use a DPI of 96.
|
|
|
|
static const int g_nDPI = 96;
|
|
|
|
|
|
|
|
/// Converts from document coordinates to screen pixels.
|
|
|
|
static float twipToPixel(float nInput)
|
|
|
|
{
|
|
|
|
return nInput / 1440.0f * g_nDPI;
|
|
|
|
}
|
|
|
|
|
2015-01-14 17:57:47 +01:00
|
|
|
/// Converts from screen pixels to document coordinates
|
|
|
|
static float pixelToTwip(float nInput)
|
2014-06-12 17:38:10 +01:00
|
|
|
{
|
2015-01-14 17:57:47 +01:00
|
|
|
return (nInput / g_nDPI) * 1440.0f;
|
|
|
|
}
|
2014-06-25 14:46:57 +01:00
|
|
|
|
2015-01-16 15:47:51 +01:00
|
|
|
void renderDocument(LOKDocView* pDocView, GdkRectangle* pPartial)
|
2015-01-14 17:57:47 +01:00
|
|
|
{
|
|
|
|
long nDocumentWidthTwips, nDocumentHeightTwips, nDocumentWidthPixels, nDocumentHeightPixels;
|
|
|
|
const int nTileSizePixels = 256;
|
2015-01-16 15:47:51 +01:00
|
|
|
// Current row / column.
|
|
|
|
guint nRow, nColumn;
|
|
|
|
// Total number of rows / columns in this document.
|
|
|
|
guint nRows, nColumns;
|
2014-06-12 17:38:10 +01:00
|
|
|
|
2015-01-14 17:57:47 +01:00
|
|
|
// Get document size and find out how many rows / columns we need.
|
|
|
|
pDocView->pDocument->pClass->getDocumentSize(pDocView->pDocument, &nDocumentWidthTwips, &nDocumentHeightTwips);
|
|
|
|
nDocumentWidthPixels = twipToPixel(nDocumentWidthTwips) * pDocView->fZoom;
|
|
|
|
nDocumentHeightPixels = twipToPixel(nDocumentHeightTwips) * pDocView->fZoom;
|
|
|
|
nRows = ceil((double)nDocumentHeightPixels / nTileSizePixels);
|
|
|
|
nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
|
|
|
|
|
|
|
|
// Set up our table and the tile pointers.
|
2015-01-16 15:47:51 +01:00
|
|
|
if (!pDocView->pTable)
|
|
|
|
pPartial = NULL;
|
|
|
|
if (pPartial)
|
|
|
|
{
|
|
|
|
// Same as nRows / nColumns, but from the previous renderDocument() call.
|
|
|
|
guint nOldRows, nOldColumns;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
if (!pPartial)
|
|
|
|
{
|
|
|
|
if (pDocView->pTable)
|
|
|
|
gtk_container_remove(GTK_CONTAINER(pDocView->pEventBox), pDocView->pTable);
|
|
|
|
pDocView->pTable = gtk_table_new(nRows, nColumns, FALSE);
|
|
|
|
gtk_container_add(GTK_CONTAINER(pDocView->pEventBox), pDocView->pTable);
|
|
|
|
gtk_widget_show(pDocView->pTable);
|
|
|
|
if (pDocView->pCanvas)
|
|
|
|
g_free(pDocView->pCanvas);
|
|
|
|
pDocView->pCanvas = g_malloc0(sizeof(GtkWidget*) * nRows * nColumns);
|
|
|
|
}
|
2015-01-14 17:57:47 +01:00
|
|
|
|
|
|
|
// Render the tiles.
|
|
|
|
for (nRow = 0; nRow < nRows; ++nRow)
|
2014-06-12 17:38:10 +01:00
|
|
|
{
|
2015-01-14 17:57:47 +01:00
|
|
|
for (nColumn = 0; nColumn < nColumns; ++nColumn)
|
|
|
|
{
|
2015-01-16 18:42:31 +01:00
|
|
|
GdkRectangle aTileRectangleTwips, aTileRectanglePixels;
|
2015-01-16 15:47:51 +01:00
|
|
|
gboolean bPaint = TRUE;
|
2015-01-14 17:57:47 +01:00
|
|
|
|
2015-01-16 15:47:51 +01:00
|
|
|
// Determine size of the tile: the rightmost/bottommost tiles may be smaller and we need the size to decide if we need to repaint.
|
2015-01-14 17:57:47 +01:00
|
|
|
if (nColumn == nColumns - 1)
|
2015-01-16 18:42:31 +01:00
|
|
|
aTileRectanglePixels.width = nDocumentWidthPixels - nColumn * nTileSizePixels;
|
2015-01-14 17:57:47 +01:00
|
|
|
else
|
2015-01-16 18:42:31 +01:00
|
|
|
aTileRectanglePixels.width = nTileSizePixels;
|
2015-01-14 17:57:47 +01:00
|
|
|
if (nRow == nRows - 1)
|
2015-01-16 18:42:31 +01:00
|
|
|
aTileRectanglePixels.height = nDocumentHeightPixels - nRow * nTileSizePixels;
|
2015-01-14 17:57:47 +01:00
|
|
|
else
|
2015-01-16 18:42:31 +01:00
|
|
|
aTileRectanglePixels.height = nTileSizePixels;
|
2015-01-14 17:57:47 +01:00
|
|
|
|
2015-01-16 15:47:51 +01:00
|
|
|
// Determine size and position of the tile in document coordinates, so we can decide if we can skip painting for partial rendering.
|
2015-01-16 18:42:31 +01:00
|
|
|
aTileRectangleTwips.x = pixelToTwip(nTileSizePixels) / pDocView->fZoom * nColumn;
|
|
|
|
aTileRectangleTwips.y = pixelToTwip(nTileSizePixels) / pDocView->fZoom * nRow;
|
|
|
|
aTileRectangleTwips.width = pixelToTwip(aTileRectanglePixels.width) / pDocView->fZoom;
|
|
|
|
aTileRectangleTwips.height = pixelToTwip(aTileRectanglePixels.height) / pDocView->fZoom;
|
|
|
|
if (pPartial && !gdk_rectangle_intersect(pPartial, &aTileRectangleTwips, NULL))
|
2015-01-16 15:47:51 +01:00
|
|
|
bPaint = FALSE;
|
|
|
|
|
|
|
|
if (bPaint)
|
|
|
|
{
|
2015-01-16 18:42:31 +01:00
|
|
|
// Index of the current tile.
|
|
|
|
guint nTile = nRow * nColumns + nColumn;
|
|
|
|
GdkPixbuf* pPixBuf;
|
|
|
|
unsigned char* pBuffer;
|
|
|
|
int nRowStride;
|
|
|
|
|
|
|
|
pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, aTileRectanglePixels.width, aTileRectanglePixels.height);
|
2015-01-16 15:47:51 +01:00
|
|
|
pBuffer = gdk_pixbuf_get_pixels(pPixBuf);
|
2015-01-16 18:53:45 +01:00
|
|
|
g_info("renderDocument: paintTile(%d, %d)", nRow, nColumn);
|
2015-01-16 15:47:51 +01:00
|
|
|
pDocView->pDocument->pClass->paintTile(pDocView->pDocument,
|
|
|
|
// Buffer and its size, depends on the position only.
|
|
|
|
pBuffer,
|
2015-01-16 18:42:31 +01:00
|
|
|
aTileRectanglePixels.width, aTileRectanglePixels.height,
|
2015-01-16 15:47:51 +01:00
|
|
|
&nRowStride,
|
|
|
|
// Position of the tile.
|
2015-01-16 18:42:31 +01:00
|
|
|
aTileRectangleTwips.x, aTileRectangleTwips.y,
|
2015-01-16 15:47:51 +01:00
|
|
|
// Size of the tile, depends on the zoom factor and the tile position only.
|
2015-01-16 18:42:31 +01:00
|
|
|
aTileRectangleTwips.width, aTileRectangleTwips.height);
|
2015-01-16 15:47:51 +01:00
|
|
|
(void) nRowStride;
|
|
|
|
|
2015-01-16 18:42:31 +01:00
|
|
|
if (pDocView->pCanvas[nTile])
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(pDocView->pCanvas[nTile]));
|
|
|
|
pDocView->pCanvas[nTile] = gtk_image_new();
|
|
|
|
gtk_image_set_from_pixbuf(GTK_IMAGE(pDocView->pCanvas[nTile]), pPixBuf);
|
2015-01-16 15:47:51 +01:00
|
|
|
g_object_unref(G_OBJECT(pPixBuf));
|
2015-01-16 18:42:31 +01:00
|
|
|
gtk_widget_show(pDocView->pCanvas[nTile]);
|
2015-01-16 15:47:51 +01:00
|
|
|
gtk_table_attach(GTK_TABLE(pDocView->pTable),
|
2015-01-16 18:42:31 +01:00
|
|
|
pDocView->pCanvas[nTile],
|
2015-01-16 15:47:51 +01:00
|
|
|
nColumn, nColumn + 1, nRow, nRow + 1,
|
|
|
|
GTK_SHRINK, GTK_SHRINK, 0, 0);
|
|
|
|
}
|
2015-01-14 17:57:47 +01:00
|
|
|
}
|
2014-06-12 17:38:10 +01:00
|
|
|
}
|
2014-06-23 15:13:25 +01:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:16:48 +01:00
|
|
|
/// Callback data, allocated in lok_docview_callback_worker(), released in lok_docview_callback().
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int m_nType;
|
2015-01-16 15:47:51 +01:00
|
|
|
char* m_pPayload;
|
2015-01-15 15:16:48 +01:00
|
|
|
LOKDocView* m_pDocView;
|
|
|
|
}
|
|
|
|
LOKDocViewCallbackData;
|
|
|
|
|
2015-01-16 15:47:51 +01:00
|
|
|
/// Returns the GdkRectangle of a width,height,x,y string.
|
|
|
|
static GdkRectangle lcl_payloadToRectangle(const char* pPayload)
|
|
|
|
{
|
|
|
|
GdkRectangle aRet;
|
|
|
|
gchar** ppCoordinates;
|
|
|
|
|
|
|
|
ppCoordinates = g_strsplit(pPayload, ", ", 4);
|
|
|
|
if (!*ppCoordinates)
|
|
|
|
return aRet;
|
|
|
|
aRet.width = atoi(*ppCoordinates);
|
|
|
|
++ppCoordinates;
|
|
|
|
if (!*ppCoordinates)
|
|
|
|
return aRet;
|
|
|
|
aRet.height = atoi(*ppCoordinates);
|
|
|
|
++ppCoordinates;
|
|
|
|
if (!*ppCoordinates)
|
|
|
|
return aRet;
|
|
|
|
aRet.x = atoi(*ppCoordinates);
|
|
|
|
++ppCoordinates;
|
|
|
|
if (!*ppCoordinates)
|
|
|
|
return aRet;
|
|
|
|
aRet.y = atoi(*ppCoordinates);
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2015-01-09 18:12:52 +01:00
|
|
|
/// Invoked on the main thread if lok_docview_callback_worker() requests so.
|
|
|
|
static gboolean lok_docview_callback(gpointer pData)
|
|
|
|
{
|
2015-01-15 15:16:48 +01:00
|
|
|
LOKDocViewCallbackData* pCallback = pData;
|
2015-01-12 14:57:05 +01:00
|
|
|
|
2015-01-15 15:16:48 +01:00
|
|
|
switch (pCallback->m_nType)
|
|
|
|
{
|
|
|
|
case LOK_CALLBACK_INVALIDATE_TILES:
|
2015-01-16 15:47:51 +01:00
|
|
|
{
|
|
|
|
if (strcmp(pCallback->m_pPayload, "EMPTY") != 0)
|
|
|
|
{
|
|
|
|
GdkRectangle aRectangle = lcl_payloadToRectangle(pCallback->m_pPayload);
|
|
|
|
renderDocument(pCallback->m_pDocView, &aRectangle);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
renderDocument(pCallback->m_pDocView, NULL);
|
|
|
|
}
|
|
|
|
break;
|
2015-01-15 15:16:48 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-01-12 14:57:05 +01:00
|
|
|
|
2015-01-16 15:47:51 +01:00
|
|
|
g_free(pCallback->m_pPayload);
|
2015-01-15 15:16:48 +01:00
|
|
|
g_free(pCallback);
|
2015-01-09 18:12:52 +01:00
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Our LOK callback, runs on the LO thread.
|
|
|
|
static void lok_docview_callback_worker(int nType, const char* pPayload, void* pData)
|
2015-01-06 15:56:23 +01:00
|
|
|
{
|
|
|
|
LOKDocView* pDocView = pData;
|
|
|
|
|
2015-01-15 15:16:48 +01:00
|
|
|
LOKDocViewCallbackData* pCallback = g_new0(LOKDocViewCallbackData, 1);
|
|
|
|
pCallback->m_nType = nType;
|
2015-01-16 15:47:51 +01:00
|
|
|
pCallback->m_pPayload = g_strdup(pPayload);
|
2015-01-15 15:16:48 +01:00
|
|
|
pCallback->m_pDocView = pDocView;
|
2015-01-16 18:53:45 +01:00
|
|
|
g_info("lok_docview_callback_worker: %d, '%s'", nType, pPayload);
|
2015-01-12 14:57:05 +01:00
|
|
|
#if GTK_CHECK_VERSION(2,12,0)
|
2015-01-15 15:16:48 +01:00
|
|
|
gdk_threads_add_idle(lok_docview_callback, pCallback);
|
2015-01-12 14:57:05 +01:00
|
|
|
#else
|
2015-01-15 15:16:48 +01:00
|
|
|
g_idle_add(lok_docview_callback, pDocView);
|
2015-01-12 14:57:05 +01:00
|
|
|
#endif
|
2015-01-06 15:56:23 +01:00
|
|
|
}
|
|
|
|
|
2014-06-23 15:13:25 +01:00
|
|
|
SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, char* pPath )
|
|
|
|
{
|
|
|
|
if ( pDocView->pDocument )
|
|
|
|
{
|
|
|
|
pDocView->pDocument->pClass->destroy( pDocView->pDocument );
|
2014-06-26 11:14:50 +01:00
|
|
|
pDocView->pDocument = NULL;
|
2014-06-23 15:13:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pDocView->pDocument = pDocView->pOffice->pClass->documentLoad( pDocView->pOffice,
|
2014-06-26 11:14:50 +01:00
|
|
|
pPath );
|
|
|
|
if ( !pDocView->pDocument )
|
|
|
|
{
|
|
|
|
// FIXME: should have a GError parameter and populate it.
|
|
|
|
char *pError = pDocView->pOffice->pClass->getError( pDocView->pOffice );
|
|
|
|
fprintf( stderr, "Error opening document '%s'\n", pError );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
2015-01-06 15:56:23 +01:00
|
|
|
{
|
2015-01-13 12:02:00 +01:00
|
|
|
pDocView->pDocument->pClass->initializeForRendering(pDocView->pDocument);
|
2015-01-16 15:47:51 +01:00
|
|
|
renderDocument(pDocView, NULL);
|
2015-01-06 15:56:23 +01:00
|
|
|
}
|
2014-06-12 17:38:10 +01:00
|
|
|
|
2014-06-26 11:14:50 +01:00
|
|
|
return TRUE;
|
2014-06-12 17:38:10 +01:00
|
|
|
}
|
|
|
|
|
2014-06-23 15:13:25 +01:00
|
|
|
SAL_DLLPUBLIC_EXPORT void lok_docview_set_zoom ( LOKDocView* pDocView, float fZoom )
|
|
|
|
{
|
|
|
|
pDocView->fZoom = fZoom;
|
2014-07-08 09:43:09 +02:00
|
|
|
|
|
|
|
if ( pDocView->pDocument )
|
|
|
|
{
|
2015-01-16 15:47:51 +01:00
|
|
|
renderDocument(pDocView, NULL);
|
2014-07-08 09:43:09 +02:00
|
|
|
}
|
2014-06-23 15:13:25 +01:00
|
|
|
// TODO: maybe remember and reset positiong?
|
|
|
|
}
|
|
|
|
|
|
|
|
SAL_DLLPUBLIC_EXPORT float lok_docview_get_zoom ( LOKDocView* pDocView )
|
|
|
|
{
|
|
|
|
return pDocView->fZoom;
|
|
|
|
}
|
|
|
|
|
2014-07-08 15:32:20 +02:00
|
|
|
SAL_DLLPUBLIC_EXPORT int lok_docview_get_parts( LOKDocView* pDocView )
|
|
|
|
{
|
|
|
|
return pDocView->pDocument->pClass->getParts( pDocView->pDocument );
|
|
|
|
}
|
|
|
|
|
|
|
|
SAL_DLLPUBLIC_EXPORT int lok_docview_get_part( LOKDocView* pDocView )
|
|
|
|
{
|
|
|
|
return pDocView->pDocument->pClass->getPart( pDocView->pDocument );
|
|
|
|
}
|
|
|
|
|
|
|
|
SAL_DLLPUBLIC_EXPORT void lok_docview_set_part( LOKDocView* pDocView, int nPart)
|
|
|
|
{
|
|
|
|
pDocView->pDocument->pClass->setPart( pDocView->pDocument, nPart );
|
2015-01-16 15:47:51 +01:00
|
|
|
renderDocument(pDocView, NULL);
|
2014-07-08 15:32:20 +02:00
|
|
|
}
|
|
|
|
|
2014-07-29 13:17:30 +02:00
|
|
|
SAL_DLLPUBLIC_EXPORT char* lok_docview_get_part_name( LOKDocView* pDocView, int nPart )
|
|
|
|
{
|
|
|
|
return pDocView->pDocument->pClass->getPartName( pDocView->pDocument, nPart );
|
|
|
|
}
|
2014-07-29 17:00:33 +02:00
|
|
|
|
|
|
|
SAL_DLLPUBLIC_EXPORT void lok_docview_set_partmode( LOKDocView* pDocView,
|
|
|
|
LibreOfficeKitPartMode ePartMode )
|
|
|
|
{
|
|
|
|
pDocView->pDocument->pClass->setPartMode( pDocView->pDocument, ePartMode );
|
2015-01-16 15:47:51 +01:00
|
|
|
renderDocument(pDocView, NULL);
|
2014-07-29 17:00:33 +02:00
|
|
|
}
|
2015-01-13 16:47:23 +01:00
|
|
|
|
|
|
|
SAL_DLLPUBLIC_EXPORT void lok_docview_set_edit( LOKDocView* pDocView,
|
|
|
|
gboolean bEdit )
|
|
|
|
{
|
|
|
|
if (!pDocView->m_bEdit && bEdit)
|
2015-01-16 18:53:45 +01:00
|
|
|
{
|
|
|
|
g_info("lok_docview_set_edit: entering edit mode, registering callback");
|
2015-01-13 16:47:23 +01:00
|
|
|
pDocView->pDocument->pClass->registerCallback(pDocView->pDocument, &lok_docview_callback_worker, pDocView);
|
2015-01-16 18:53:45 +01:00
|
|
|
}
|
2015-01-13 16:47:23 +01:00
|
|
|
pDocView->m_bEdit = bEdit;
|
|
|
|
}
|
|
|
|
|
2014-06-12 17:38:10 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|