summaryrefslogtreecommitdiffstats
path: root/libreofficekit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-11-18 15:57:36 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-11-18 16:39:18 +0100
commit0ea68eecddf0211f842645c4d257899531692770 (patch)
tree91dbac9bcffa06c65f0acd553939deadb7e53cb2 /libreofficekit
parentvcl::ITiledRenderable::initializeForTiledRendering: support init. arguments (diff)
downloadcore-0ea68eecddf0211f842645c4d257899531692770.tar.gz
core-0ea68eecddf0211f842645c4d257899531692770.zip
gtktiledviewer: allow passing initializeForRendering() arguments
Change-Id: Ic7b52764cf2fedbf73d4dcaaf36d1055b8ee22f2
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx25
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx5
2 files changed, 25 insertions, 5 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index fe35f2ec0daa..f76ad1a12c55 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -29,7 +29,9 @@
static int help()
{
- fprintf( stderr, "Usage: gtktiledviewer <absolute-path-to-libreoffice-install's-program-directory> <path-to-document>\n" );
+ fprintf(stderr, "Usage: gtktiledviewer <absolute-path-to-libreoffice-install's-program-directory> <path-to-document> [<options> ... ]\n\n");
+ fprintf(stderr, "Options:\n\n");
+ fprintf(stderr, "--hide-whitespace: Hide whitespace between pages in text documents.\n");
return 1;
}
@@ -475,13 +477,25 @@ static void createView(GtkWidget* pButton, gpointer /*pItem*/)
}
/// Creates a new model, i.e. LOK init and document load, one view implicitly.
-static void createModelAndView(const char* pLOPath, const char* pDocPath)
+static void createModelAndView(const char* pLOPath, const char* pDocPath, const std::vector<std::string>& rArguments)
{
GtkWidget* pDocView = lok_doc_view_new(pLOPath, nullptr, nullptr);
setupWidgetAndCreateWindow(pDocView);
- lok_doc_view_open_document(LOK_DOC_VIEW(pDocView), pDocPath, nullptr, openDocumentCallback, pDocView);
+ boost::property_tree::ptree aTree;
+ for (const std::string& rArgument : rArguments)
+ {
+ if (rArgument == "--hide-whitespace")
+ {
+ aTree.put(boost::property_tree::ptree::path_type(".uno:HideWhitespace/type", '/'), "boolean");
+ aTree.put(boost::property_tree::ptree::path_type(".uno:HideWhitespace/value", '/'), true);
+ }
+ }
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree);
+ std::string aArguments = aStream.str();
+ lok_doc_view_open_document(LOK_DOC_VIEW(pDocView), pDocPath, aArguments.c_str(), nullptr, openDocumentCallback, pDocView);
}
/// Our GtkClipboardGetFunc implementation for HTML.
@@ -1263,7 +1277,10 @@ int main( int argc, char* argv[] )
gtk_init( &argc, &argv );
- createModelAndView(argv[1], argv[2]);
+ std::vector<std::string> aArguments;
+ for (int i = 3; i < argc; ++i)
+ aArguments.push_back(argv[i]);
+ createModelAndView(argv[1], argv[2], aArguments);
gtk_main();
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 55822cdbc0db..6e9fc190e560 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -44,6 +44,7 @@ struct LOKDocViewPrivateImpl
{
const gchar* m_aLOPath;
const gchar* m_aDocPath;
+ std::string m_aRenderingArguments;
gdouble m_nLoadProgress;
gboolean m_bIsLoading;
gboolean m_bCanZoomIn;
@@ -530,7 +531,7 @@ static gboolean postDocumentLoad(gpointer pData)
LOKDocViewPrivate& priv = getPrivate(pLOKDocView);
priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
- priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, nullptr);
+ priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, priv->m_aRenderingArguments.c_str());
priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, callbackWorker, pLOKDocView);
priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, &priv->m_nDocumentWidthTwips, &priv->m_nDocumentHeightTwips);
g_timeout_add(600, handleTimeout, pLOKDocView);
@@ -2312,6 +2313,7 @@ lok_doc_view_open_document_finish (LOKDocView* pDocView, GAsyncResult* res, GErr
SAL_DLLPUBLIC_EXPORT void
lok_doc_view_open_document (LOKDocView* pDocView,
const gchar* pPath,
+ const gchar* pRenderingArguments,
GCancellable* cancellable,
GAsyncReadyCallback callback,
gpointer userdata)
@@ -2324,6 +2326,7 @@ lok_doc_view_open_document (LOKDocView* pDocView,
pLOEvent->m_pPath = pPath;
priv->m_aDocPath = pPath;
+ priv->m_aRenderingArguments = pRenderingArguments;
g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), &error);