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

lok::Document: add createView()

Change-Id: Ic871ec41992b611b10958799b2dc12375a91efe4
üst 58b5c13b
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include <sfx2/viewfrm.hxx> #include <sfx2/viewfrm.hxx>
#include <sfx2/msgpool.hxx> #include <sfx2/msgpool.hxx>
#include <sfx2/dispatch.hxx> #include <sfx2/dispatch.hxx>
#include <sfx2/lokhelper.hxx>
#include <svx/svxids.hrc> #include <svx/svxids.hrc>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vcl/svpforlokit.hxx> #include <vcl/svpforlokit.hxx>
...@@ -246,6 +247,7 @@ static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis, ...@@ -246,6 +247,7 @@ static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis,
static void doc_resetSelection (LibreOfficeKitDocument* pThis); static void doc_resetSelection (LibreOfficeKitDocument* pThis);
static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCommand); static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCommand);
static int doc_createView(LibreOfficeKitDocument* pThis);
LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) : LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) :
mxComponent( xComponent ) mxComponent( xComponent )
...@@ -277,6 +279,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone ...@@ -277,6 +279,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->resetSelection = doc_resetSelection; m_pDocumentClass->resetSelection = doc_resetSelection;
m_pDocumentClass->getCommandValues = doc_getCommandValues; m_pDocumentClass->getCommandValues = doc_getCommandValues;
m_pDocumentClass->createView = doc_createView;
gDocumentClass = m_pDocumentClass; gDocumentClass = m_pDocumentClass;
} }
pClass = m_pDocumentClass.get(); pClass = m_pDocumentClass.get();
...@@ -1029,6 +1033,21 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo ...@@ -1029,6 +1033,21 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
} }
} }
static int doc_createView(LibreOfficeKitDocument* pThis)
{
SolarMutexGuard aGuard;
ITiledRenderable* pDoc = getTiledRenderable(pThis);
if (!pDoc)
{
gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
return -1;
}
SfxViewShell* pViewShell = pDoc->getCurrentViewShell();
return SfxLokHelper::createView(pViewShell);
}
static char* lo_getError (LibreOfficeKit *pThis) static char* lo_getError (LibreOfficeKit *pThis)
{ {
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis); LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
......
...@@ -162,6 +162,9 @@ struct _LibreOfficeKitDocumentClass ...@@ -162,6 +162,9 @@ struct _LibreOfficeKitDocumentClass
/// @see lok::Document:getStyles /// @see lok::Document:getStyles
char* (*getCommandValues) (LibreOfficeKitDocument* pThis, const char* pCommand); char* (*getCommandValues) (LibreOfficeKitDocument* pThis, const char* pCommand);
/// @see lok::Document::createView().
int (*createView) (LibreOfficeKitDocument* pThis);
#endif // LOK_USE_UNSTABLE_API #endif // LOK_USE_UNSTABLE_API
}; };
......
...@@ -257,6 +257,16 @@ public: ...@@ -257,6 +257,16 @@ public:
{ {
return mpDoc->pClass->getCommandValues(mpDoc, pCommand); return mpDoc->pClass->getCommandValues(mpDoc, pCommand);
} }
/**
* Create a new view for an existing document.
* By default a loaded document has 1 view.
* @return the ID of the new view.
*/
int createView()
{
return mpDoc->pClass->createView(mpDoc);
}
#endif // LOK_USE_UNSTABLE_API #endif // LOK_USE_UNSTABLE_API
}; };
......
...@@ -147,6 +147,14 @@ static void toggleFindbar(GtkWidget* /*pButton*/, gpointer /*pItem*/) ...@@ -147,6 +147,14 @@ static void toggleFindbar(GtkWidget* /*pButton*/, gpointer /*pItem*/)
} }
} }
/// Calls lok::Document::createView().
static void createView(GtkWidget* /*pButton*/, gpointer /*pItem*/)
{
LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView);
LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pLOKDocView);
pDocument->pClass->createView(pDocument);
}
/// Our GtkClipboardGetFunc implementation for HTML. /// Our GtkClipboardGetFunc implementation for HTML.
static void htmlGetFunc(GtkClipboard* /*pClipboard*/, GtkSelectionData* pSelectionData, guint /*info*/, gpointer pUserData) static void htmlGetFunc(GtkClipboard* /*pClipboard*/, GtkSelectionData* pSelectionData, guint /*info*/, gpointer pUserData)
{ {
...@@ -555,6 +563,12 @@ int main( int argc, char* argv[] ) ...@@ -555,6 +563,12 @@ int main( int argc, char* argv[] )
gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pFindButton, -1); gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pFindButton, -1);
g_signal_connect(G_OBJECT(pFindButton), "clicked", G_CALLBACK(toggleFindbar), NULL); g_signal_connect(G_OBJECT(pFindButton), "clicked", G_CALLBACK(toggleFindbar), NULL);
GtkToolItem* pNewViewButton = gtk_tool_button_new( NULL, NULL);
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pNewViewButton), "view-continuous-symbolic");
gtk_tool_item_set_tooltip_text(pNewViewButton, "New View");
gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pNewViewButton, -1);
g_signal_connect(G_OBJECT(pNewViewButton), "clicked", G_CALLBACK(createView), NULL);
gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1); gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
pBold = gtk_toggle_tool_button_new(); pBold = gtk_toggle_tool_button_new();
......
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