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

gtktiledviewer: allow passing initializeForRendering() arguments

Change-Id: Ic7b52764cf2fedbf73d4dcaaf36d1055b8ee22f2
üst 479325de
......@@ -65,6 +65,7 @@ GtkWidget* lok_doc_view_new_from_widget (LOKDocView*
* lok_doc_view_open_document:
* @pDocView: The #LOKDocView instance
* @pPath: (transfer full): The path of the document that #LOKDocView widget should try to open
* @pRenderingArguments: lok::Document::initializeForRendering() arguments.
* @cancellable:
* @callback:
* @userdata:
......@@ -73,6 +74,7 @@ GtkWidget* lok_doc_view_new_from_widget (LOKDocView*
*/
void lok_doc_view_open_document (LOKDocView* pDocView,
const gchar* pPath,
const gchar* pRenderingArguments,
GCancellable* cancellable,
GAsyncReadyCallback callback,
gpointer userdata);
......
......@@ -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();
......
......@@ -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);
......
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