Rebased ref, commits from common ancestor: commit 23c75e1b367b7687d42e8b77cedc72fb4f802748 Author: Pranav Kant <pran...@gnome.org> Date: Mon Jun 22 15:27:24 2015 +0530
lokdocview: fixed a signal name Change-Id: I645516d43562dfa03c27e2bea366e9a161829bfe diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index c746b84..cff02ea 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -1352,7 +1352,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass) * @pDocView: the #LOKDocView on which the signal is emitted * @aHyperlink: the URI which the application should handle */ - doc_view_signals[PART_CHANGED] = + doc_view_signals[HYPERLINK_CLICKED] = g_signal_new("hyperlinked-clicked", G_TYPE_FROM_CLASS(pGObjectClass), G_SIGNAL_RUN_FIRST, commit a2451a94a680a05f6beef639a0c75b4e615197d1 Author: Pranav Kant <pran...@gnome.org> Date: Fri Jun 19 01:06:50 2015 +0530 lokdocview: Use *get_instance_private () to get private structure Let lok_doc_view_get_instance_private () do the pointer arithmatic. Additionally, we are saving sizeof (void*) already in the _LOKDocView struct with this approach. Change-Id: I6d991d5834ef15dad24acb14a1d4bbf7d03df762 diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h index 3eaf283..3a1628b 100644 --- a/include/LibreOfficeKit/LibreOfficeKitGtk.h +++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h @@ -32,7 +32,6 @@ typedef struct _LOKDocViewPrivate LOKDocViewPrivate; struct _LOKDocView { GtkDrawingArea aDrawingArea; - LOKDocViewPrivate* priv; }; struct _LOKDocViewClass diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index bc383c5..c746b84 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -229,7 +229,7 @@ isEmptyRectangle(const GdkRectangle& rRectangle) static void signalKey (LOKDocView* pDocView, const GdkEvent* pEvent) { - LOKDocViewPrivate* priv = pDocView->priv; + LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); int nCharCode = 0; int nKeyCode = 0; guint keyval; @@ -292,7 +292,7 @@ static gboolean handleTimeout (gpointer pData) { LOKDocView* pDocView = LOK_DOC_VIEW (pData); - LOKDocViewPrivate* priv = pDocView->priv; + LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); if (priv->m_bEdit) { @@ -366,7 +366,7 @@ globalCallbackWorker(int nType, const char* pPayload, void* pData) static GdkRectangle payloadToRectangle (LOKDocView* pDocView, const char* pPayload) { - LOKDocViewPrivate* priv = pDocView->priv; + LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); GdkRectangle aRet; gchar** ppCoordinates = g_strsplit(pPayload, ", ", 4); gchar** ppCoordinate = ppCoordinates; @@ -418,7 +418,7 @@ payloadToRectangles(LOKDocView* pDocView, const char* pPayload) static void setTilesInvalid (LOKDocView* pDocView, const GdkRectangle& rRectangle) { - LOKDocViewPrivate* priv = pDocView->priv; + LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); GdkRectangle aRectanglePixels; GdkPoint aStart, aEnd; @@ -442,7 +442,7 @@ callback (gpointer pData) { CallbackData* pCallback = static_cast<CallbackData*>(pData); LOKDocView* pDocView = LOK_DOC_VIEW (pCallback->m_pDocView); - LOKDocViewPrivate* priv = pDocView->priv; + LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); switch (pCallback->m_nType) { @@ -560,7 +560,7 @@ renderHandle(LOKDocView* pDocView, cairo_surface_t* pHandle, GdkRectangle& rRectangle) { - LOKDocViewPrivate* priv = pDocView->priv; + LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); GdkPoint aCursorBottom; int nHandleWidth, nHandleHeight; double fHandleScale; @@ -593,7 +593,7 @@ renderGraphicHandle(LOKDocView* pDocView, const GdkRectangle& rSelection, cairo_surface_t* pHandle) { - LOKDocViewPrivate* priv = pDocView->priv; + LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); int nHandleWidth, nHandleHeight; GdkRectangle aSelection; @@ -660,7 +660,7 @@ renderGraphicHandle(LOKDocView* pDocView, static gboolean renderDocument(LOKDocView* pDocView, cairo_t* pCairo) { - LOKDocViewPrivate *priv = pDocView->priv; + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); GdkRectangle aVisibleArea; long nDocumentWidthPixels = twipToPixel(priv->m_nDocumentWidthTwips, priv->m_fZoom); long nDocumentHeightPixels = twipToPixel(priv->m_nDocumentHeightTwips, priv->m_fZoom); @@ -721,7 +721,7 @@ renderDocument(LOKDocView* pDocView, cairo_t* pCairo) static gboolean renderOverlay(LOKDocView* pDocView, cairo_t* pCairo) { - LOKDocViewPrivate *priv = pDocView->priv; + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); if (priv->m_bEdit && priv->m_bCursorVisible && priv->m_bCursorOverlayVisible && !isEmptyRectangle(priv->m_aVisibleCursor)) { @@ -799,7 +799,7 @@ static gboolean lok_doc_view_signal_button(GtkWidget* pWidget, GdkEventButton* pEvent) { LOKDocView* pDocView = LOK_DOC_VIEW (pWidget); - LOKDocViewPrivate *priv = pDocView->priv; + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); g_info("LOKDocView_Impl::signalButton: %d, %d (in twips: %d, %d)", (int)pEvent->x, (int)pEvent->y, @@ -942,7 +942,7 @@ static gboolean lok_doc_view_signal_motion (GtkWidget* pWidget, GdkEventMotion* pEvent) { LOKDocView* pDocView = LOK_DOC_VIEW (pWidget); - LOKDocViewPrivate *priv = pDocView->priv; + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); GdkPoint aPoint; if (priv->m_bInDragMiddleHandle) @@ -1001,8 +1001,8 @@ lok_doc_view_signal_motion (GtkWidget* pWidget, GdkEventMotion* pEvent) static void lok_doc_view_init (LOKDocView* pDocView) { - pDocView->priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); - pDocView->priv->m_bCursorVisible = true; + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + priv->m_bCursorVisible = true; gtk_widget_add_events(GTK_WIDGET(pDocView), GDK_BUTTON_PRESS_MASK @@ -1015,7 +1015,7 @@ static void lok_doc_view_init (LOKDocView* pDocView) static void lok_doc_view_set_property (GObject* object, guint propId, const GValue *value, GParamSpec *pspec) { LOKDocView* pDocView = LOK_DOC_VIEW (object); - LOKDocViewPrivate* priv = pDocView->priv; + LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); switch (propId) { @@ -1045,7 +1045,7 @@ static void lok_doc_view_set_property (GObject* object, guint propId, const GVal static void lok_doc_view_get_property (GObject* object, guint propId, GValue *value, GParamSpec *pspec) { LOKDocView* pDocView = LOK_DOC_VIEW (object); - LOKDocViewPrivate* priv = pDocView->priv; + LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); switch (propId) { @@ -1097,7 +1097,7 @@ static gboolean lok_doc_view_draw (GtkWidget* pWidget, cairo_t* pCairo) static void lok_doc_view_finalize (GObject* object) { LOKDocView* pDocView = LOK_DOC_VIEW (object); - LOKDocViewPrivate* priv = pDocView->priv; + LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); if (priv->m_pDocument) priv->m_pDocument->pClass->destroy (priv->m_pDocument); @@ -1110,18 +1110,19 @@ static void lok_doc_view_finalize (GObject* object) static gboolean lok_doc_view_initable_init (GInitable *initable, GCancellable* /*cancellable*/, GError **error) { LOKDocView *pDocView = LOK_DOC_VIEW (initable); + LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); - if (pDocView->priv->m_pOffice != NULL) + if (priv->m_pOffice != NULL) return TRUE; - pDocView->priv->m_pOffice = lok_init (pDocView->priv->m_aLOPath); + priv->m_pOffice = lok_init (priv->m_aLOPath); - if (pDocView->priv->m_pOffice == NULL) + if (priv->m_pOffice == NULL) { g_set_error (error, g_quark_from_static_string ("LOK initialization error"), 0, "Failed to get LibreOfficeKit context. Make sure path (%s) is correct", - pDocView->priv->m_aLOPath); + priv->m_aLOPath); return FALSE; } @@ -1387,39 +1388,41 @@ lok_doc_view_new (const gchar* pPath, GCancellable *cancellable, GError **error) SAL_DLLPUBLIC_EXPORT gboolean lok_doc_view_open_document (LOKDocView* pDocView, const gchar* pPath) { - if ( pDocView->priv->m_pDocument ) + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + + if ( priv->m_pDocument ) { - pDocView->priv->m_pDocument->pClass->destroy( pDocView->priv->m_pDocument ); - pDocView->priv->m_pDocument = 0; + priv->m_pDocument->pClass->destroy( priv->m_pDocument ); + priv->m_pDocument = 0; } - pDocView->priv->m_pOffice->pClass->registerCallback(pDocView->priv->m_pOffice, globalCallbackWorker, pDocView); - pDocView->priv->m_pDocument = pDocView->priv->m_pOffice->pClass->documentLoad( pDocView->priv->m_pOffice, pPath ); - if ( !pDocView->priv->m_pDocument ) + priv->m_pOffice->pClass->registerCallback(priv->m_pOffice, globalCallbackWorker, pDocView); + priv->m_pDocument = priv->m_pOffice->pClass->documentLoad( priv->m_pOffice, pPath ); + if ( !priv->m_pDocument ) { // FIXME: should have a GError parameter and populate it. - char *pError = pDocView->priv->m_pOffice->pClass->getError( pDocView->priv->m_pOffice ); + char *pError = priv->m_pOffice->pClass->getError( priv->m_pOffice ); fprintf( stderr, "Error opening document '%s'\n", pError ); return FALSE; } else { - pDocView->priv->m_pDocument->pClass->initializeForRendering(pDocView->priv->m_pDocument); - pDocView->priv->m_pDocument->pClass->registerCallback(pDocView->priv->m_pDocument, callbackWorker, pDocView); - pDocView->priv->m_pDocument->pClass->getDocumentSize(pDocView->priv->m_pDocument, &pDocView->priv->m_nDocumentWidthTwips, &pDocView->priv->m_nDocumentHeightTwips); + priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument); + priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, callbackWorker, pDocView); + priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, &priv->m_nDocumentWidthTwips, &priv->m_nDocumentHeightTwips); g_timeout_add(600, handleTimeout, pDocView); - float zoom = pDocView->priv->m_fZoom; - long nDocumentWidthTwips = pDocView->priv->m_nDocumentWidthTwips; - long nDocumentHeightTwips = pDocView->priv->m_nDocumentHeightTwips; + float zoom = priv->m_fZoom; + long nDocumentWidthTwips = priv->m_nDocumentWidthTwips; + long nDocumentHeightTwips = priv->m_nDocumentHeightTwips; long nDocumentWidthPixels = twipToPixel(nDocumentWidthTwips, zoom); long nDocumentHeightPixels = twipToPixel(nDocumentHeightTwips, zoom); // Total number of columns in this document. guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels); - pDocView->priv->m_aTileBuffer = TileBuffer(pDocView->priv->m_pDocument, - nColumns); + priv->m_aTileBuffer = TileBuffer(priv->m_pDocument, + nColumns); gtk_widget_set_size_request(GTK_WIDGET(pDocView), nDocumentWidthPixels, nDocumentHeightPixels); @@ -1436,7 +1439,8 @@ lok_doc_view_open_document (LOKDocView* pDocView, const gchar* pPath) SAL_DLLPUBLIC_EXPORT LibreOfficeKitDocument* lok_doc_view_get_document (LOKDocView* pDocView) { - return pDocView->priv->m_pDocument; + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + return priv->m_pDocument; } /** @@ -1449,14 +1453,16 @@ lok_doc_view_get_document (LOKDocView* pDocView) SAL_DLLPUBLIC_EXPORT void lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom) { - pDocView->priv->m_fZoom = fZoom; - long nDocumentWidthPixels = twipToPixel(pDocView->priv->m_nDocumentWidthTwips, fZoom); - long nDocumentHeightPixels = twipToPixel(pDocView->priv->m_nDocumentHeightTwips, fZoom); + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + + priv->m_fZoom = fZoom; + long nDocumentWidthPixels = twipToPixel(priv->m_nDocumentWidthTwips, fZoom); + long nDocumentHeightPixels = twipToPixel(priv->m_nDocumentHeightTwips, fZoom); // Total number of columns in this document. guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels); - pDocView->priv->m_aTileBuffer = TileBuffer(pDocView->priv->m_pDocument, - nColumns); + priv->m_aTileBuffer = TileBuffer(priv->m_pDocument, + nColumns); gtk_widget_set_size_request(GTK_WIDGET(pDocView), nDocumentWidthPixels, nDocumentHeightPixels); @@ -1471,38 +1477,44 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom) SAL_DLLPUBLIC_EXPORT float lok_doc_view_get_zoom (LOKDocView* pDocView) { - return pDocView->priv->m_fZoom; + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + return priv->m_fZoom; } SAL_DLLPUBLIC_EXPORT int lok_doc_view_get_parts (LOKDocView* pDocView) { - return pDocView->priv->m_pDocument->pClass->getParts( pDocView->priv->m_pDocument ); + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + return priv->m_pDocument->pClass->getParts( priv->m_pDocument ); } SAL_DLLPUBLIC_EXPORT int lok_doc_view_get_part (LOKDocView* pDocView) { - return pDocView->priv->m_pDocument->pClass->getPart( pDocView->priv->m_pDocument ); + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + return priv->m_pDocument->pClass->getPart( priv->m_pDocument ); } SAL_DLLPUBLIC_EXPORT void lok_doc_view_set_part (LOKDocView* pDocView, int nPart) { - pDocView->priv->m_pDocument->pClass->setPart( pDocView->priv->m_pDocument, nPart ); + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + priv->m_pDocument->pClass->setPart( priv->m_pDocument, nPart ); } SAL_DLLPUBLIC_EXPORT char* lok_doc_view_get_part_name (LOKDocView* pDocView, int nPart) { - return pDocView->priv->m_pDocument->pClass->getPartName( pDocView->priv->m_pDocument, nPart ); + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + return priv->m_pDocument->pClass->getPartName( priv->m_pDocument, nPart ); } SAL_DLLPUBLIC_EXPORT void lok_doc_view_set_partmode(LOKDocView* pDocView, int nPartMode) { - pDocView->priv->m_pDocument->pClass->setPartMode( pDocView->priv->m_pDocument, nPartMode ); + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + priv->m_pDocument->pClass->setPartMode( priv->m_pDocument, nPartMode ); } /** @@ -1516,16 +1528,17 @@ SAL_DLLPUBLIC_EXPORT void lok_doc_view_set_edit(LOKDocView* pDocView, gboolean bEdit) { - gboolean bWasEdit = pDocView->priv->m_bEdit; + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + gboolean bWasEdit = priv->m_bEdit; - if (!pDocView->priv->m_bEdit && bEdit) + if (!priv->m_bEdit && bEdit) g_info("lok_doc_view_set_edit: entering edit mode"); - else if (pDocView->priv->m_bEdit && !bEdit) + else if (priv->m_bEdit && !bEdit) { g_info("lok_doc_view_set_edit: leaving edit mode"); - pDocView->priv->m_pDocument->pClass->resetSelection(pDocView->priv->m_pDocument); + priv->m_pDocument->pClass->resetSelection(priv->m_pDocument); } - pDocView->priv->m_bEdit = bEdit; + priv->m_bEdit = bEdit; g_signal_emit(pDocView, doc_view_signals[EDIT_CHANGED], 0, bWasEdit); gtk_widget_queue_draw(GTK_WIDGET(pDocView)); } @@ -1539,7 +1552,8 @@ lok_doc_view_set_edit(LOKDocView* pDocView, SAL_DLLPUBLIC_EXPORT gboolean lok_doc_view_get_edit (LOKDocView* pDocView) { - return pDocView->priv->m_bEdit; + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + return priv->m_bEdit; } /** @@ -1555,7 +1569,8 @@ lok_doc_view_post_command (LOKDocView* pDocView, const char* pCommand, const char* pArguments) { - pDocView->priv->m_pDocument->pClass->postUnoCommand(pDocView->priv->m_pDocument, pCommand, pArguments); + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + priv->m_pDocument->pClass->postUnoCommand(priv->m_pDocument, pCommand, pArguments); } /** @@ -1583,7 +1598,8 @@ lok_doc_view_post_key (LOKDocView* pDocView, GdkEvent* pEvent) SAL_DLLPUBLIC_EXPORT float lok_doc_view_pixel_to_twip (LOKDocView* pDocView, float fInput) { - return pixelToTwip(fInput, pDocView->priv->m_fZoom); + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + return pixelToTwip(fInput, priv->m_fZoom); } /** @@ -1598,7 +1614,8 @@ lok_doc_view_pixel_to_twip (LOKDocView* pDocView, float fInput) SAL_DLLPUBLIC_EXPORT float lok_doc_view_twip_to_pixel (LOKDocView* pDocView, float fInput) { - return twipToPixel(fInput, pDocView->priv->m_fZoom); + LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + return twipToPixel(fInput, priv->m_fZoom); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit cc00f73778e02f7d0f2630801d2e72a0a4231fc3 Author: Pranav Kant <pran...@gnome.org> Date: Thu Jun 18 21:52:22 2015 +0530 lokdocview: Use GInitable The construction of LokDocView widget can fail because it involves initializing the lok context via lok_init. Having lok_init calls in constructed virtual method is a bad idea since it assumes that construction will never fail. So, implement GInitable for this class, and move the object initialization from constructed to initable. Change-Id: Idf18a054cf8ef2e946392458ec52cb0107bd7454 diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h index 7048dbe..3eaf283 100644 --- a/include/LibreOfficeKit/LibreOfficeKitGtk.h +++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h @@ -42,10 +42,12 @@ struct _LOKDocViewClass GType lok_doc_view_get_type (void) G_GNUC_CONST; -GtkWidget* lok_doc_view_new (const char* pPath); +GtkWidget* lok_doc_view_new (const gchar* pPath, + GCancellable *cancellable, + GError **error); gboolean lok_doc_view_open_document (LOKDocView* pDocView, - char* pPath); + const gchar* pPath); /// Gets the document the viewer displays. LibreOfficeKitDocument* lok_doc_view_get_document (LOKDocView* pDocView); diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 575588e..a583323 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -521,7 +521,7 @@ int main( int argc, char* argv[] ) gtk_box_pack_end(GTK_BOX(pVBox), pFindbar, FALSE, FALSE, 0); // Docview - pDocView = lok_doc_view_new(argv[1]); + pDocView = lok_doc_view_new (argv[1], NULL, NULL); if (pDocView == NULL) g_error ("Error while creating LOKDocView widget"); g_signal_connect(pDocView, "edit-changed", G_CALLBACK(signalEdit), NULL); diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 9e8cabb..bc383c5 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -137,12 +137,16 @@ enum static guint doc_view_signals[LAST_SIGNAL] = { 0 }; +static void lok_doc_view_initable_iface_init (GInitableIface *iface); + SAL_DLLPUBLIC_EXPORT GType lok_doc_view_get_type(); #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" #endif -G_DEFINE_TYPE_WITH_PRIVATE (LOKDocView, lok_doc_view, GTK_TYPE_DRAWING_AREA) +G_DEFINE_TYPE_WITH_CODE (LOKDocView, lok_doc_view, GTK_TYPE_DRAWING_AREA, + G_ADD_PRIVATE (LOKDocView) + G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, lok_doc_view_initable_iface_init)); #ifdef __GNUC__ #pragma GCC diagnostic pop #endif @@ -1103,14 +1107,30 @@ static void lok_doc_view_finalize (GObject* object) G_OBJECT_CLASS (lok_doc_view_parent_class)->finalize (object); } -static void lok_doc_view_constructed (GObject* object) +static gboolean lok_doc_view_initable_init (GInitable *initable, GCancellable* /*cancellable*/, GError **error) { - LOKDocView* pDocView = LOK_DOC_VIEW (object); - LOKDocViewPrivate* priv = pDocView->priv; + LOKDocView *pDocView = LOK_DOC_VIEW (initable); + + if (pDocView->priv->m_pOffice != NULL) + return TRUE; + + pDocView->priv->m_pOffice = lok_init (pDocView->priv->m_aLOPath); + + if (pDocView->priv->m_pOffice == NULL) + { + g_set_error (error, + g_quark_from_static_string ("LOK initialization error"), 0, + "Failed to get LibreOfficeKit context. Make sure path (%s) is correct", + pDocView->priv->m_aLOPath); + return FALSE; + } - G_OBJECT_CLASS (lok_doc_view_parent_class)->constructed (object); + return TRUE; +} - pDocView->priv->m_pOffice = lok_init (priv->m_aLOPath); +static void lok_doc_view_initable_iface_init (GInitableIface *iface) +{ + iface->init = lok_doc_view_initable_init; } static void lok_doc_view_class_init (LOKDocViewClass* pClass) @@ -1121,7 +1141,6 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass) pGObjectClass->get_property = lok_doc_view_get_property; pGObjectClass->set_property = lok_doc_view_set_property; pGObjectClass->finalize = lok_doc_view_finalize; - pGObjectClass->constructed = lok_doc_view_constructed; pWidgetClass->draw = lok_doc_view_draw; pWidgetClass->button_press_event = lok_doc_view_signal_button; @@ -1343,18 +1362,19 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass) G_TYPE_STRING); } - - /** * lok_doc_view_new: * @pPath: LibreOffice install path. + * @cancellable: The cancellable object that you can use to cancel this + * operation. + * @error: The error that will be set if the object fails to initialize. * - * Returns: The #LOKDocView widget instance. + * Returns: (transfer none): The #LOKDocView widget instance. */ SAL_DLLPUBLIC_EXPORT GtkWidget* -lok_doc_view_new (const char* pPath) +lok_doc_view_new (const gchar* pPath, GCancellable *cancellable, GError **error) { - return GTK_WIDGET (g_object_new(LOK_TYPE_DOC_VIEW, "lopath", pPath, NULL)); + return GTK_WIDGET (g_initable_new (LOK_TYPE_DOC_VIEW, cancellable, error, "lopath", pPath, NULL)); } /** @@ -1365,7 +1385,7 @@ lok_doc_view_new (const char* pPath) * Returns: %TRUE if the document is loaded succesfully, %FALSE otherwise */ SAL_DLLPUBLIC_EXPORT gboolean -lok_doc_view_open_document (LOKDocView* pDocView, char* pPath) +lok_doc_view_open_document (LOKDocView* pDocView, const gchar* pPath) { if ( pDocView->priv->m_pDocument ) { @@ -1374,8 +1394,7 @@ lok_doc_view_open_document (LOKDocView* pDocView, char* pPath) } pDocView->priv->m_pOffice->pClass->registerCallback(pDocView->priv->m_pOffice, globalCallbackWorker, pDocView); - pDocView->priv->m_pDocument = pDocView->priv->m_pOffice->pClass->documentLoad( pDocView->priv->m_pOffice, - pPath ); + pDocView->priv->m_pDocument = pDocView->priv->m_pOffice->pClass->documentLoad( pDocView->priv->m_pOffice, pPath ); if ( !pDocView->priv->m_pDocument ) { // FIXME: should have a GError parameter and populate it. commit 35fd66e8648c6d82396486a9469dcb061c832b91 Author: Laurent Balland-Poirier <laurent.balland-poir...@laposte.net> Date: Thu Apr 16 22:32:07 2015 +0200 tdf#70673 Power trendline: enable negative Y values With a negative intercept, Y values can be negative Change-Id: I9c23cc89b74498f7e7c7bcee00057627768f48aa Reviewed-on: https://gerrit.libreoffice.org/15357 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Philippe Jung <phil.j...@free.fr> diff --git a/chart2/source/inc/PotentialRegressionCurveCalculator.hxx b/chart2/source/inc/PotentialRegressionCurveCalculator.hxx index dba739e..d9ad473 100644 --- a/chart2/source/inc/PotentialRegressionCurveCalculator.hxx +++ b/chart2/source/inc/PotentialRegressionCurveCalculator.hxx @@ -57,9 +57,10 @@ private: throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE; - // formula is: f(x) = x ^ m_fSlope * m_fIntercept + // formula is: f(x) = x ^ m_fSlope * m_fSign * m_fIntercept double m_fSlope; double m_fIntercept; + double m_fSign; }; } // namespace chart diff --git a/chart2/source/inc/RegressionCalculationHelper.hxx b/chart2/source/inc/RegressionCalculationHelper.hxx index 2e0e3a4..7f0a693 100644 --- a/chart2/source/inc/RegressionCalculationHelper.hxx +++ b/chart2/source/inc/RegressionCalculationHelper.hxx @@ -127,6 +127,19 @@ public: } }; +class isValidAndXPositiveAndYNegative : public ::std::binary_function< double, double, bool > +{ +public: + inline bool operator()( double x, double y ) + { return ! ( ::rtl::math::isNan( x ) || + ::rtl::math::isNan( y ) || + ::rtl::math::isInf( x ) || + ::rtl::math::isInf( y ) || + x <= 0.0 || + y >= 0.0 ); + } +}; + } // namespace RegressionCalculationHelper } // namespace chart diff --git a/chart2/source/tools/PotentialRegressionCurveCalculator.cxx b/chart2/source/tools/PotentialRegressionCurveCalculator.cxx index 7495c91..0e4f4cd 100644 --- a/chart2/source/tools/PotentialRegressionCurveCalculator.cxx +++ b/chart2/source/tools/PotentialRegressionCurveCalculator.cxx @@ -50,14 +50,23 @@ void SAL_CALL PotentialRegressionCurveCalculator::recalculateRegression( RegressionCalculationHelper::cleanup( aXValues, aYValues, RegressionCalculationHelper::isValidAndBothPositive())); + m_fSign = 1.0; - const size_t nMax = aValues.first.size(); + size_t nMax = aValues.first.size(); if( nMax == 0 ) { - ::rtl::math::setNan( & m_fSlope ); - ::rtl::math::setNan( & m_fIntercept ); - ::rtl::math::setNan( & m_fCorrelationCoeffitient ); - return; + aValues = RegressionCalculationHelper::cleanup( + aXValues, aYValues, + RegressionCalculationHelper::isValidAndXPositiveAndYNegative()); + nMax = aValues.first.size(); + if( nMax == 0 ) + { + ::rtl::math::setNan( & m_fSlope ); + ::rtl::math::setNan( & m_fIntercept ); + ::rtl::math::setNan( & m_fCorrelationCoeffitient ); + return; + } + m_fSign = -1.0; } double fAverageX = 0.0, fAverageY = 0.0; @@ -65,7 +74,7 @@ void SAL_CALL PotentialRegressionCurveCalculator::recalculateRegression( for( i = 0; i < nMax; ++i ) { fAverageX += log( aValues.first[i] ); - fAverageY += log( aValues.second[i] ); + fAverageY += log( m_fSign * aValues.second[i] ); } const double fN = static_cast< double >( nMax ); @@ -76,7 +85,7 @@ void SAL_CALL PotentialRegressionCurveCalculator::recalculateRegression( for( i = 0; i < nMax; ++i ) { double fDeltaX = log( aValues.first[i] ) - fAverageX; - double fDeltaY = log( aValues.second[i] ) - fAverageY; + double fDeltaY = log( m_fSign * aValues.second[i] ) - fAverageY; fQx += fDeltaX * fDeltaX; fQy += fDeltaY * fDeltaY; @@ -87,7 +96,7 @@ void SAL_CALL PotentialRegressionCurveCalculator::recalculateRegression( m_fIntercept = fAverageY - m_fSlope * fAverageX; m_fCorrelationCoeffitient = fQxy / sqrt( fQx * fQy ); - m_fIntercept = exp( m_fIntercept ); + m_fIntercept = m_fSign * exp( m_fIntercept ); } double SAL_CALL PotentialRegressionCurveCalculator::getCurveValue( double x ) commit cad19fa8414b419f2e0f9ee88139e9b7a2dd4ff4 Author: Laurent Balland-Poirier <laurent.balland-poir...@laposte.net> Date: Thu Apr 16 21:45:58 2015 +0200 tdf#70673 Exponential trendline: enable negative Y values With a negative intercept, Y values can be negative Rebase with forced intercept fec037e68f0dea164915fbfe1db4699a3861adf4 Conflicts: chart2/source/tools/ExponentialRegressionCurveCalculator.cxx Change-Id: Ie351c006fb1688ef3e657da7ce0789a9da1317f0 Reviewed-on: https://gerrit.libreoffice.org/15353 Reviewed-by: Philippe Jung <phil.j...@free.fr> Tested-by: Philippe Jung <phil.j...@free.fr> diff --git a/chart2/source/inc/ExponentialRegressionCurveCalculator.hxx b/chart2/source/inc/ExponentialRegressionCurveCalculator.hxx index 1247d41..782fb57 100644 --- a/chart2/source/inc/ExponentialRegressionCurveCalculator.hxx +++ b/chart2/source/inc/ExponentialRegressionCurveCalculator.hxx @@ -56,10 +56,11 @@ private: throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE; - // formula is: f(x) = exp(m_fLogIntercept) * exp( m_fLogSlope * x ) + // formula is: f(x) = m_fSign * exp(m_fLogIntercept) * exp( m_fLogSlope * x ) // mathematical model f(x) = Intercept * Slope^x double m_fLogSlope; double m_fLogIntercept; + double m_fSign; }; } // namespace chart diff --git a/chart2/source/inc/RegressionCalculationHelper.hxx b/chart2/source/inc/RegressionCalculationHelper.hxx index 32456cf..2e0e3a4 100644 --- a/chart2/source/inc/RegressionCalculationHelper.hxx +++ b/chart2/source/inc/RegressionCalculationHelper.hxx @@ -102,6 +102,18 @@ public: } }; +class isValidAndYNegative : public ::std::binary_function< double, double, bool > +{ +public: + inline bool operator()( double x, double y ) + { return ! ( ::rtl::math::isNan( x ) || + ::rtl::math::isNan( y ) || + ::rtl::math::isInf( x ) || + ::rtl::math::isInf( y ) || + y >= 0.0 ); + } +}; + class isValidAndBothPositive : public ::std::binary_function< double, double, bool > { public: diff --git a/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx b/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx index 3738d68..2e1dedd 100644 --- a/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx +++ b/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx @@ -50,25 +50,34 @@ void SAL_CALL ExponentialRegressionCurveCalculator::recalculateRegression( RegressionCalculationHelper::cleanup( aXValues, aYValues, RegressionCalculationHelper::isValidAndYPositive())); + m_fSign = 1.0; - const size_t nMax = aValues.first.size(); + size_t nMax = aValues.first.size(); if( nMax == 0 ) { - ::rtl::math::setNan( & m_fLogSlope ); - ::rtl::math::setNan( & m_fLogIntercept ); - ::rtl::math::setNan( & m_fCorrelationCoeffitient );// actual it is coefficient of determination - return; + aValues = RegressionCalculationHelper::cleanup( + aXValues, aYValues, + RegressionCalculationHelper::isValidAndYNegative()); + nMax = aValues.first.size(); + if( nMax == 0 ) + { + ::rtl::math::setNan( & m_fLogSlope ); + ::rtl::math::setNan( & m_fLogIntercept ); + ::rtl::math::setNan( & m_fCorrelationCoeffitient );// actual it is coefficient of determination + return; + } + m_fSign = -1.0; } double fAverageX = 0.0, fAverageY = 0.0; - double fLogIntercept = mForceIntercept ? log(mInterceptValue) : 0.0; + double fLogIntercept = ( mForceIntercept && (m_fSign * mInterceptValue)>0 ) ? log(m_fSign * mInterceptValue) : 0.0; std::vector<double> yVector; yVector.resize(nMax, 0.0); size_t i = 0; for( i = 0; i < nMax; ++i ) { - double yValue = log(aValues.second[i]); + double yValue = log( m_fSign *aValues.second[i] ); if (mForceIntercept) { yValue -= fLogIntercept; @@ -111,7 +120,7 @@ double SAL_CALL ExponentialRegressionCurveCalculator::getCurveValue( double x ) if( ! ( ::rtl::math::isNan( m_fLogSlope ) || ::rtl::math::isNan( m_fLogIntercept ))) { - fResult = exp(m_fLogIntercept + x * m_fLogSlope); + fResult = m_fSign * exp(m_fLogIntercept + x * m_fLogSlope); } return fResult; @@ -146,7 +155,7 @@ OUString ExponentialRegressionCurveCalculator::ImplGetRepresentation( const uno::Reference< util::XNumberFormatter >& xNumFormatter, ::sal_Int32 nNumberFormatKey ) const { - double fIntercept = exp(m_fLogIntercept); + double fIntercept = m_fSign * exp(m_fLogIntercept); double fSlope = exp(m_fLogSlope); bool bHasSlope = !rtl::math::approxEqual( fSlope, 1.0 ); bool bHasIntercept = !rtl::math::approxEqual( fIntercept, 1.0 ); commit 733f5887af46d1d5e2fbea6be93cabb2a1749752 Author: Philippe Jung <phil.j...@free.fr> Date: Mon Jun 22 11:41:43 2015 +0200 Add unit tests for chart2 trend calculators Will be used to check tdf#70673 is fixed. Test will fail before the fix and should pass after. Change-Id: I9e0fdc696fb99ac2f0e24b04273391d526c629a6 Reviewed-on: https://gerrit.libreoffice.org/16406 Reviewed-by: Philippe Jung <phil.j...@free.fr> Tested-by: Philippe Jung <phil.j...@free.fr> diff --git a/chart2/CppunitTest_chart2_trendcalculators.mk b/chart2/CppunitTest_chart2_trendcalculators.mk new file mode 100644 index 0000000..5187298 --- /dev/null +++ b/chart2/CppunitTest_chart2_trendcalculators.mk @@ -0,0 +1,136 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# 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/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,chart2_trendcalculators)) + +$(eval $(call gb_CppunitTest_use_externals,chart2_trendcalculators, \ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_add_exception_objects,chart2_trendcalculators, \ + chart2/qa/extras/chart2_trendcalculators \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,chart2_trendcalculators, \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + drawinglayer \ + editeng \ + for \ + forui \ + i18nlangtag \ + msfilter \ + vcl \ + oox \ + sal \ + salhelper \ + sax \ + sb \ + sc \ + sw \ + sd \ + sfx \ + sot \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tl \ + tk \ + ucbhelper \ + unotest \ + utl \ + vbahelper \ + xo \ + sw \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_CppunitTest_set_include,chart2_trendcalculators,\ + -I$(SRCDIR)/chart2/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,chart2_trendcalculators,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,chart2_trendcalculators)) +$(eval $(call gb_CppunitTest_use_vcl,chart2_trendcalculators)) + +$(eval $(call gb_CppunitTest_use_components,chart2_trendcalculators,\ + basic/util/sb \ + animations/source/animcore/animcore \ + chart2/source/controller/chartcontroller \ + chart2/source/chartcore \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + dtrans/util/mcnttype \ + embeddedobj/util/embobj \ + eventattacher/source/evtatt \ + filter/source/config/cache/filterconfig1 \ + filter/source/odfflatxml/odfflatxml \ + filter/source/storagefilterdetect/storagefd \ + filter/source/xmlfilteradaptor/xmlfa \ + filter/source/xmlfilterdetect/xmlfd \ + forms/util/frm \ + framework/util/fwk \ + i18npool/util/i18npool \ + linguistic/source/lng \ + oox/util/oox \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + sc/util/sc \ + sc/util/scd \ + sc/util/scfilt \ + sw/util/sw \ + sw/util/swd \ + sw/util/msword \ + sd/util/sd \ + sd/util/sdfilt \ + sd/util/sdd \ + $(call gb_Helper_optional,SCRIPTING, \ + sc/util/vbaobj) \ + scaddins/source/analysis/analysis \ + scaddins/source/datefunc/date \ + scripting/source/basprov/basprov \ + scripting/util/scriptframe \ + sfx2/util/sfx \ + sot/util/sot \ + svl/source/fsstor/fsstorage \ + svl/util/svl \ + svtools/util/svt \ + svx/util/svx \ + svx/util/svxcore \ + toolkit/util/tk \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + ucb/source/ucp/tdoc/ucptdoc1 \ + unotools/util/utl \ + unoxml/source/rdf/unordf \ + unoxml/source/service/unoxml \ + writerfilter/util/writerfilter \ + xmloff/util/xo \ + xmlscript/util/xmlscript \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,chart2_trendcalculators)) + +$(call gb_CppunitTest_get_target,chart2_trendcalculators): \ + $(call gb_AllLangResTarget_get_target,sd) + +# vim: set noet sw=4 ts=4: diff --git a/chart2/Module_chart2.mk b/chart2/Module_chart2.mk index 16a74a1..de0ab12 100644 --- a/chart2/Module_chart2.mk +++ b/chart2/Module_chart2.mk @@ -24,6 +24,7 @@ $(eval $(call gb_Module_add_l10n_targets,chart2,\ $(eval $(call gb_Module_add_slowcheck_targets,chart2,\ CppunitTest_chart2_export \ CppunitTest_chart2_import \ + CppunitTest_chart2_trendcalculators \ )) ifeq ($(ENABLE_CHART_TESTS),TRUE) diff --git a/chart2/qa/extras/chart2_trendcalculators.cxx b/chart2/qa/extras/chart2_trendcalculators.cxx new file mode 100644 index 0000000..7ddb4d8 --- /dev/null +++ b/chart2/qa/extras/chart2_trendcalculators.cxx @@ -0,0 +1,214 @@ +/* -*- 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 "charttest.hxx" +#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> +#include <com/sun/star/chart2/XRegressionCurveCalculator.hpp> + +// Define the index of sheets in the test document +#define SHEET_POTENTIAL1 0 +#define SHEET_POTENTIAL2 ( SHEET_POTENTIAL1 + 1) +#define SHEET_POTENTIAL_LAST ( SHEET_POTENTIAL2 ) + +#define SHEET_LINEAR1 ( SHEET_POTENTIAL_LAST + 1 ) +#define SHEET_LINEAR_LAST ( SHEET_LINEAR1 ) + +#define SHEET_POLYNOMIAL1 ( SHEET_LINEAR_LAST + 1 ) +#define SHEET_POLYNOMIAL_LAST ( SHEET_POLYNOMIAL1 ) + +#define SHEET_EXPONENTIAL1 ( SHEET_POLYNOMIAL_LAST + 1 ) +#define SHEET_EXPONENTIAL2 ( SHEET_EXPONENTIAL1 + 1 ) +#define SHEET_EXPONENTIAL_LAST ( SHEET_EXPONENTIAL2 ) + +class Chart2TrendCalculators : public ChartTest +{ +public: + void setUp(); + void tearDown(); + + void testPotentialRegression1(); + void testPotentialRegression2(); + void testLinearRegression1(); + void testPolynomialRegression1(); + void testExponentialRegression1(); + void testExponentialRegression2(); + + CPPUNIT_TEST_SUITE(Chart2TrendCalculators); + CPPUNIT_TEST(testPotentialRegression1); + CPPUNIT_TEST(testPotentialRegression2); + CPPUNIT_TEST(testLinearRegression1); + CPPUNIT_TEST(testPolynomialRegression1); + CPPUNIT_TEST(testExponentialRegression1); + CPPUNIT_TEST(testExponentialRegression2); + CPPUNIT_TEST_SUITE_END(); + +private: + + Reference<chart2::XRegressionCurve> m_xCurve; + Reference< chart2::XRegressionCurveCalculator > m_xRegressionCurveCalculator; + + void loadCalculatorFromSheet(sal_Int32 nSheet); + void checkCalculator( + Sequence< double > xValues, Sequence< double > yValues, + OUString sExpectedFormula ); + +}; + +void Chart2TrendCalculators::setUp() +{ + ChartTest::setUp(); + load("/chart2/qa/extras/data/ods/", "trend_calculators.ods"); +} + +void Chart2TrendCalculators::tearDown() +{ + m_xRegressionCurveCalculator.clear(); + m_xCurve.clear(); + ChartTest::tearDown(); +} + +void Chart2TrendCalculators::loadCalculatorFromSheet(sal_Int32 nSheet) +{ + Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(nSheet, mxComponent); + CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); + CPPUNIT_ASSERT(xChartDoc.is()); + + Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); + CPPUNIT_ASSERT(xDataSeries.is()); + + Reference<chart2::XRegressionCurveContainer> xRegressionCurveContainer(xDataSeries, UNO_QUERY_THROW); + CPPUNIT_ASSERT( xRegressionCurveContainer.is() ); + + Sequence< Reference< chart2::XRegressionCurve > > xRegressionCurveSequence = xRegressionCurveContainer->getRegressionCurves(); + CPPUNIT_ASSERT_EQUAL((sal_Int32) 1, xRegressionCurveSequence.getLength()); + + m_xCurve = xRegressionCurveSequence[0]; + CPPUNIT_ASSERT(m_xCurve.is()); + + m_xRegressionCurveCalculator = m_xCurve->getCalculator(); + CPPUNIT_ASSERT(m_xRegressionCurveCalculator.is()); +} + +void Chart2TrendCalculators::checkCalculator( + Sequence< double > xValues, Sequence< double > yValues, + OUString sExpectedFormula ) +{ + m_xRegressionCurveCalculator->recalculateRegression( xValues, yValues ); + OUString aRepresentation = m_xRegressionCurveCalculator->getRepresentation (); + CPPUNIT_ASSERT_EQUAL( sExpectedFormula, aRepresentation ); + double r2 = m_xRegressionCurveCalculator->getCorrelationCoefficient(); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, r2, 1e-8 ); +} + +// test y = A x ^ B +void Chart2TrendCalculators::testPotentialRegression1() +{ + loadCalculatorFromSheet( SHEET_POTENTIAL1 ); + m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0 ); + Sequence< double > xValues( 7 ); + Sequence< double > yValues( 7 ); + double d; + for (int i=0; i<7; i++) + { + d = (double) i; + xValues[i] = d; + yValues[i] = 2.0 * pow ( d, 3 ); + } + checkCalculator( xValues, yValues, "f(x) = 2 x^3"); +} + +// test y = A x ^ B +void Chart2TrendCalculators::testPotentialRegression2() +{ + loadCalculatorFromSheet( SHEET_POTENTIAL2 ); + m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0 ); + Sequence< double > xValues( 7 ); + Sequence< double > yValues( 7 ); + double d; + for (int i=0; i<7; i++) + { + d = (double) i; + xValues[i] = d; + yValues[i] = -2.0 * pow ( d, 3 ); + } + checkCalculator( xValues, yValues, "f(x) = -2 x^3"); +} + +// test y = - 2 X - 5 +void Chart2TrendCalculators::testLinearRegression1() +{ + loadCalculatorFromSheet( SHEET_LINEAR1 ); + m_xRegressionCurveCalculator->setRegressionProperties( 1, false, 0, 0 ); + Sequence< double > xValues( 7 ); + Sequence< double > yValues( 7 ); + double d; + for (int i=0; i<7; i++) + { + d = (double) i; + xValues[i] = d; + yValues[i] = - 2.0 * d - 5.0 ; + } + checkCalculator( xValues, yValues, "f(x) = - 2x - 5"); +} + +// test y = A x ^ B +void Chart2TrendCalculators::testPolynomialRegression1() +{ + loadCalculatorFromSheet( SHEET_POLYNOMIAL1 ); + m_xRegressionCurveCalculator->setRegressionProperties( 2, false, 0, 0 ); + Sequence< double > xValues( 7 ); + Sequence< double > yValues( 7 ); + double d; + for (int i=0; i<7; i++) + { + d = (double) i; + xValues[i] = d; + yValues[i] = - 2.0 * d * d + 4 * d - 5; + } + checkCalculator( xValues, yValues, "f(x) = - 2x^2 + 4x - 5"); +} + +void Chart2TrendCalculators::testExponentialRegression1() +{ + loadCalculatorFromSheet( SHEET_EXPONENTIAL1 ); + m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0 ); + Sequence< double > xValues( 7 ); + Sequence< double > yValues( 7 ); + double d; + for (int i=0; i<7; i++) + { + d = (double) i; + xValues[i] = d; + yValues[i] = 2.0 * exp ( 0.3 * d ); + } + checkCalculator( xValues, yValues, "f(x) = 2 exp( 0.3 x )"); +} + +void Chart2TrendCalculators::testExponentialRegression2() +{ + loadCalculatorFromSheet( SHEET_EXPONENTIAL2 ); + m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0 ); + Sequence< double > xValues( 7 ); + Sequence< double > yValues( 7 ); + double d; + for (int i=0; i<7; i++) + { + d = (double) i; + xValues[i] = d; + yValues[i] = -2.0 * exp ( 0.3 * d ); + } + checkCalculator( xValues, yValues, "f(x) = -2 exp( 0.3 x )"); +} + + +CPPUNIT_TEST_SUITE_REGISTRATION(Chart2TrendCalculators); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/qa/extras/data/ods/trend_calculators.ods b/chart2/qa/extras/data/ods/trend_calculators.ods new file mode 100644 index 0000000..fdc5ea4 Binary files /dev/null and b/chart2/qa/extras/data/ods/trend_calculators.ods differ commit 9908b6447ebbeec16544bd61eca6f22f1ecefbaa Author: Stephan Bergmann <sberg...@redhat.com> Date: Mon Jun 22 11:03:45 2015 +0200 Work around change in JNI func sigs between Java 6 and 7 (same as dfba745437324b8e1a352ab5280c665c543fc37f) Change-Id: I3c79b406c2bf661717880def94989614860f9cb6 diff --git a/connectivity/source/drivers/jdbc/Blob.cxx b/connectivity/source/drivers/jdbc/Blob.cxx index c8bc791..43db9c1 100644 --- a/connectivity/source/drivers/jdbc/Blob.cxx +++ b/connectivity/source/drivers/jdbc/Blob.cxx @@ -114,7 +114,15 @@ sal_Int64 SAL_CALL java_sql_Blob::position( const ::com::sun::star::uno::Sequenc obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID); // convert Parameter jbyteArray pByteArray = t.pEnv->NewByteArray(pattern.getLength()); - t.pEnv->SetByteArrayRegion(pByteArray,0,pattern.getLength(),pattern.getConstArray()); + jbyte * patternData = reinterpret_cast<jbyte *>( + const_cast<sal_Int8 *>(pattern.getConstArray())); + // 4th param of Set*ArrayRegion changed from pointer to non-const to + // pointer to const between <http://docs.oracle.com/javase/6/docs/ + // technotes/guides/jni/spec/functions.html#wp22933> and + // <http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/ + // functions.html#wp22933>; work around that difference in a way + // that doesn't trigger loplugin:redundantcast + t.pEnv->SetByteArrayRegion(pByteArray,0,pattern.getLength(),patternData); out = t.pEnv->CallLongMethod( object, mID, pByteArray,start ); t.pEnv->DeleteLocalRef(pByteArray); ThrowSQLException(t.pEnv,*this); commit b990cdf57d6a85a36de713004a67a90ba2650623 Author: Dennis Roczek <dennisroc...@libreoffice.org> Date: Tue Jun 9 06:01:37 2015 +0200 improve lo-commit-stat script 'resolved' should also be removed and updating bug urls Change-Id: Ie8e71727856bcc44bd7f3311a9e1472327c9bf21 Reviewed-on: https://gerrit.libreoffice.org/16207 Reviewed-by: David Tardon <dtar...@redhat.com> Tested-by: David Tardon <dtar...@redhat.com> diff --git a/bin/lo-commit-stat b/bin/lo-commit-stat index 5a68820..92dd5e5 100755 --- a/bin/lo-commit-stat +++ b/bin/lo-commit-stat @@ -17,7 +17,8 @@ my %module_dirname = ( my %bugzillas = ( - fdo => "https://bugs.libreoffice.org/show_bug.cgi?id=", + fdo => "https://bugs.documentfoundation.org/show_bug.cgi?id=", + tdf => "https://bugs.documentfoundation.org/show_bug.cgi?id=", bnc => "https://bugzilla.novell.com/show_bug.cgi?id=", rhbz => "https://bugzilla.redhat.com/show_bug.cgi?id=", i => "https://bz.apache.org/ooo/show_bug.cgi?id=", @@ -54,7 +55,7 @@ sub search_bugs($$$$) # print " found $bug\n"; # remove bug number from the comment; it will be added later a standardized way $bug_orig =~ s/\#/\\#/; - $line =~ s/[Rr]esolve[ds]:?\s*$bug_orig\s*//; + $line =~ s/(,\s)*[Rr](elated|esolve[ds]):?\s*$bug_orig\s*//; $line =~ s/\s*-\s*$bug_orig\s*//; $line =~ s/\(?$bug_orig\)?\s*[:,-]?\s*//; commit 2885e157674dbefa7d9b984a399fabd1238eeedd Author: Stephan Bergmann <sberg...@redhat.com> Date: Mon Jun 22 09:45:29 2015 +0200 loplugin:vclwidgets Change-Id: I5f65681bf3e44cbce62f46b9ffc0e5bef3aeeda4 diff --git a/include/sfx2/sidebar/UnoPanel.hxx b/include/sfx2/sidebar/UnoPanel.hxx index 051a00d..0d396e9 100644 --- a/include/sfx2/sidebar/UnoPanel.hxx +++ b/include/sfx2/sidebar/UnoPanel.hxx @@ -74,8 +74,8 @@ private: const OUString mPanelId; const OUString mDeckId; - sfx2::sidebar::Deck* mpDeck; - sfx2::sidebar::Panel* mpPanel; + VclPtr<sfx2::sidebar::Deck> mpDeck; + VclPtr<sfx2::sidebar::Panel> mpPanel; sal_Int32 GetMaxOrderIndex(sfx2::sidebar::ResourceManager::PanelContextDescriptorContainer aPanels); sal_Int32 GetMinOrderIndex(sfx2::sidebar::ResourceManager::PanelContextDescriptorContainer aPanels); commit 284534679333ebe9b6a05e6f80436e836fa35da1 Author: Stephan Bergmann <sberg...@redhat.com> Date: Mon Jun 22 09:43:02 2015 +0200 -Werror,-Wunused-private-field Change-Id: Icf9b843eff90c39110fc5b0436f85b0783cddb17 diff --git a/include/sfx2/sidebar/UnoDeck.hxx b/include/sfx2/sidebar/UnoDeck.hxx index 1d9fcc2..8bf416b 100644 --- a/include/sfx2/sidebar/UnoDeck.hxx +++ b/include/sfx2/sidebar/UnoDeck.hxx @@ -67,7 +67,6 @@ private: sfx2::sidebar::SidebarController* getSidebarController(); const OUString mDeckId; - const OUString mTitle; sal_Int32 GetMaxOrderIndex(sfx2::sidebar::ResourceManager::DeckContextDescriptorContainer aDecks); sal_Int32 GetMinOrderIndex(sfx2::sidebar::ResourceManager::DeckContextDescriptorContainer aDecks); diff --git a/sfx2/source/sidebar/UnoDeck.cxx b/sfx2/source/sidebar/UnoDeck.cxx index b90b266..f65b215 100644 --- a/sfx2/source/sidebar/UnoDeck.cxx +++ b/sfx2/source/sidebar/UnoDeck.cxx @@ -24,8 +24,7 @@ using namespace ::sfx2::sidebar; SfxUnoDeck::SfxUnoDeck(const uno::Reference<frame::XFrame>& rFrame, const OUString& deckId): xFrame(rFrame), -mDeckId(deckId), -mTitle(deckId) +mDeckId(deckId) { } commit b998be6e42eeb57abf5131adc06aa45588542f62 Author: Stephan Bergmann <sberg...@redhat.com> Date: Mon Jun 22 09:41:16 2015 +0200 loplugin:salbool Change-Id: If5a3d79167264240ce9083800f15ed166eedd8bf diff --git a/sfx2/source/sidebar/UnoDecks.cxx b/sfx2/source/sidebar/UnoDecks.cxx index e088733..30882ea 100644 --- a/sfx2/source/sidebar/UnoDecks.cxx +++ b/sfx2/source/sidebar/UnoDecks.cxx @@ -94,7 +94,7 @@ sal_Bool SAL_CALL SfxUnoDecks::hasByName( const OUString& aName ) SidebarController* pSidebarController = getSidebarController(); - sal_Bool bFound = false; + bool bFound = false; if (pSidebarController) { @@ -165,4 +165,4 @@ sal_Bool SAL_CALL SfxUnoDecks::hasElements() throw(::com::sun::star::uno::Runtim return decks.hasElements(); } -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 92252af5fdea7268ef954bc2f95c50f905c39078 Author: Stephan Bergmann <sberg...@redhat.com> Date: Mon Jun 22 09:37:49 2015 +0200 -Werror,-Wunused-private-field Change-Id: I47416559cc3d6c6679e1f9df3f24a24385903e04 diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx index 0e1fe0e..58bca04 100644 --- a/include/sfx2/sidebar/SidebarController.hxx +++ b/include/sfx2/sidebar/SidebarController.hxx @@ -170,7 +170,6 @@ private: /// Use a combination of SwitchFlag_* as value. sal_Int32 mnRequestedForceFlags; ::rtl::OUString msCurrentDeckId; - ::rtl::OUString msCurrentDeckTitle; AsynchronousCall maPropertyChangeForwarder; AsynchronousCall maContextChangeUpdate; AsynchronousCall maAsynchronousDeckSwitch; diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index c81927e..cb03b2d 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -107,7 +107,6 @@ SidebarController::SidebarController ( maRequestedContext(), mnRequestedForceFlags(SwitchFlag_NoForce), msCurrentDeckId(gsDefaultDeckId), - msCurrentDeckTitle(), maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)), maContextChangeUpdate(::boost::bind(&SidebarController::UpdateConfigurations, this)), maAsynchronousDeckSwitch(), commit 8d4cb9cd86c04b9ae73943dded4ccc253942e70e Author: andreask <kain...@gmail.com> Date: Sun Jun 21 23:21:41 2015 +0200 Breeze: StartCenter close icons Change-Id: I2ae4876dfec86849991aa1199046c071e2cd6263 Reviewed-on: https://gerrit.libreoffice.org/16404 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/icon-themes/breeze/res/recentdoc_remove.png b/icon-themes/breeze/res/recentdoc_remove.png new file mode 100644 index 0000000..7bd7b03 Binary files /dev/null and b/icon-themes/breeze/res/recentdoc_remove.png differ diff --git a/icon-themes/breeze/res/recentdoc_remove_highlighted.png b/icon-themes/breeze/res/recentdoc_remove_highlighted.png new file mode 100644 index 0000000..9589680 Binary files /dev/null and b/icon-themes/breeze/res/recentdoc_remove_highlighted.png differ commit ab7d58d4f240bb31461748926eb6db936546fe7d Author: andreask <kain...@gmail.com> Date: Sun Jun 21 23:10:10 2015 +0200 Breeze Signet - Icon is missing the ribbon part (StarShapes.signet) Change-Id: I589d34f24dbdc7017a19c0de57b1bcfc543c7a2d Reviewed-on: https://gerrit.libreoffice.org/16403 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/icon-themes/breeze/cmd/lc_starshapes.signet.png b/icon-themes/breeze/cmd/lc_starshapes.signet.png index 2bbe072..321f6d3 100644 Binary files a/icon-themes/breeze/cmd/lc_starshapes.signet.png and b/icon-themes/breeze/cmd/lc_starshapes.signet.png differ diff --git a/icon-themes/breeze/cmd/sc_starshapes.signet.png b/icon-themes/breeze/cmd/sc_starshapes.signet.png index 76f2b5e..7bc8f7f 100644 Binary files a/icon-themes/breeze/cmd/sc_starshapes.signet.png and b/icon-themes/breeze/cmd/sc_starshapes.signet.png differ commit 097406006266f1d59a57e0379fd195190c214df2 Author: Stephan Bergmann <sberg...@redhat.com> Date: Mon Jun 22 09:35:30 2015 +0200 loplugin:passstuffbyref Change-Id: Ib356214e2aee699d7def22ab84ad806cb801bcb5 diff --git a/include/sfx2/sidebar/Deck.hxx b/include/sfx2/sidebar/Deck.hxx index edd735c..43fddcc 100644 --- a/include/sfx2/sidebar/Deck.hxx +++ b/include/sfx2/sidebar/Deck.hxx @@ -51,7 +51,7 @@ public: void ResetPanels (const SharedPanelContainer& rPanels); const SharedPanelContainer& GetPanels() const { return maPanels; } - Panel* GetPanel(OUString panelId); + Panel* GetPanel(OUString const & panelId); void RequestLayout(); vcl::Window* GetPanelParentWindow(); diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx index b2eb225..9866f4d 100644 --- a/sfx2/source/sidebar/Deck.cxx +++ b/sfx2/source/sidebar/Deck.cxx @@ -223,7 +223,7 @@ vcl::Window* Deck::GetPanelParentWindow() return mpScrollContainer.get(); } -Panel* Deck::GetPanel(const OUString panelId) +Panel* Deck::GetPanel(const OUString & panelId) { for (size_t i = 0; i < maPanels.size(); i++) { commit 2e32eff6f1a6ac8bc0ef65e07300531d6f45275b Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Jun 22 09:10:09 2015 +0200 Use SAL_WARN{,_IF} Change-Id: Idd4693bd48b4bbe3ebfb5c86922ab0edfeba0def diff --git a/writerfilter/source/dmapper/CellMarginHandler.cxx b/writerfilter/source/dmapper/CellMarginHandler.cxx index 6e28f62..6d223c2 100644 --- a/writerfilter/source/dmapper/CellMarginHandler.cxx +++ b/writerfilter/source/dmapper/CellMarginHandler.cxx @@ -21,7 +21,6 @@ #include <ConversionHelper.hxx> #include <ooxml/resourceids.hxx> #include <comphelper/sequence.hxx> -#include <osl/diagnose.h> namespace writerfilter { namespace dmapper { @@ -61,11 +60,11 @@ void CellMarginHandler::lcl_attribute(Id rName, Value & rVal) m_nValue = ConversionHelper::convertTwipToMM100Unsigned( nIntValue ); break; case NS_ooxml::LN_CT_TblWidth_type: - OSL_ENSURE( NS_ooxml::LN_Value_ST_TblWidth_dxa == sal::static_int_cast<Id>(nIntValue), "cell margins work for absolute values, only"); + SAL_WARN_IF(NS_ooxml::LN_Value_ST_TblWidth_dxa != sal::static_int_cast<Id>(nIntValue), "writerfilter", "CellMarginHandler: cell margins work for absolute values only"); m_nType = nIntValue; break; default: - OSL_FAIL( "unknown attribute"); + SAL_WARN("writerfilter", "CellMarginHandler::lcl_attribute: unknown attribute"); } } @@ -153,7 +152,7 @@ void CellMarginHandler::lcl_sprm(Sprm & rSprm) createGrabBag("right"); break; default: - OSL_FAIL( "unknown sprm"); + SAL_WARN("writerfilter", "CellMarginHandler::lcl_sprm: unknown sprm"); } } m_nValue = 0; commit f43dd61f092e3df6c58a48f587f3cd2fe4238675 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Jun 22 09:08:22 2015 +0200 Use comphelper::containerToSequence Change-Id: Ib227023eceacbcc3ca303af47794561eab708a39 diff --git a/writerfilter/source/dmapper/CellMarginHandler.cxx b/writerfilter/source/dmapper/CellMarginHandler.cxx index 922a50b..6e28f62 100644 --- a/writerfilter/source/dmapper/CellMarginHandler.cxx +++ b/writerfilter/source/dmapper/CellMarginHandler.cxx @@ -20,6 +20,7 @@ #include <PropertyMap.hxx> #include <ConversionHelper.hxx> #include <ooxml/resourceids.hxx> +#include <comphelper/sequence.hxx> #include <osl/diagnose.h> namespace writerfilter { @@ -167,13 +168,7 @@ beans::PropertyValue CellMarginHandler::getInteropGrabBag() { beans::PropertyValue aRet; aRet.Name = m_aInteropGrabBagName; - - uno::Sequence<beans::PropertyValue> aSeq(m_aInteropGrabBag.size()); - beans::PropertyValue* pSeq = aSeq.getArray(); - for (std::vector<beans::PropertyValue>::iterator i = m_aInteropGrabBag.begin(); i != m_aInteropGrabBag.end(); ++i) - *pSeq++ = *i; - - aRet.Value = uno::makeAny(aSeq); + aRet.Value = uno::makeAny(comphelper::containerToSequence(m_aInteropGrabBag)); return aRet; } diff --git a/writerfilter/source/dmapper/LatentStyleHandler.cxx b/writerfilter/source/dmapper/LatentStyleHandler.cxx index 67e2cb6f..0e9eb58 100644 --- a/writerfilter/source/dmapper/LatentStyleHandler.cxx +++ b/writerfilter/source/dmapper/LatentStyleHandler.cxx @@ -68,13 +68,9 @@ void LatentStyleHandler::lcl_sprm(Sprm& /*rSprm*/) { } -uno::Sequence<beans::PropertyValue> LatentStyleHandler::getAttributes() const +std::vector<beans::PropertyValue> LatentStyleHandler::getAttributes() const { - uno::Sequence<beans::PropertyValue> aAttributes(m_aAttributes.size()); - beans::PropertyValue* pAttributes = aAttributes.getArray(); - for (std::vector<beans::PropertyValue>::const_iterator i = m_aAttributes.begin(); i != m_aAttributes.end(); ++i) - *pAttributes++ = *i; - return aAttributes; + return m_aAttributes; } } // namespace dmapper diff --git a/writerfilter/source/dmapper/LatentStyleHandler.hxx b/writerfilter/source/dmapper/LatentStyleHandler.hxx index 8b1a697..fd7bf6a 100644 --- a/writerfilter/source/dmapper/LatentStyleHandler.hxx +++ b/writerfilter/source/dmapper/LatentStyleHandler.hxx @@ -33,7 +33,7 @@ public: LatentStyleHandler(); virtual ~LatentStyleHandler(); - css::uno::Sequence<css::beans::PropertyValue> getAttributes() const; + std::vector<css::beans::PropertyValue> getAttributes() const; }; typedef std::shared_ptr<LatentStyleHandler> LatentStyleHandlerPtr; diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 713c107..9e652ea 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -737,7 +737,7 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm) pProperties->resolve(*pLatentStyleHandler); beans::PropertyValue aValue; aValue.Name = "lsdException"; - aValue.Value = uno::makeAny(pLatentStyleHandler->getAttributes()); + aValue.Value = uno::makeAny(comphelper::containerToSequence(pLatentStyleHandler->getAttributes())); m_pImpl->m_pCurrentEntry->aLsdExceptions.push_back(aValue); } } commit f403cecdaedf263f11081c91bed62640362a3a3e Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Jun 22 09:06:31 2015 +0200 gtktiledviewer: do HTML copying if possible Change-Id: I24e7b18442cb08814a73dd33b368b368039a11e4 diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 7d4960d..575588e 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -125,16 +125,49 @@ static void toggleFindbar(GtkWidget* /*pButton*/, gpointer /*pItem*/) } } +/// Our GtkClipboardGetFunc implementation for HTML. +static void htmlGetFunc(GtkClipboard* /*pClipboard*/, GtkSelectionData* pSelectionData, guint /*info*/, gpointer pUserData) +{ + GdkAtom aAtom(gdk_atom_intern("text/html", false)); + const gchar* pSelection = static_cast<const gchar*>(pUserData); + gtk_selection_data_set(pSelectionData, aAtom, 8, reinterpret_cast<const guchar *>(pSelection), strlen(pSelection)); +} + +/// Our GtkClipboardClearFunc implementation for HTML. +static void htmlClearFunc(GtkClipboard* /*pClipboard*/, gpointer pData) +{ + g_free(pData); +} + +/// Same as gtk_clipboard_set_text(), but sets HTML. +static void clipboardSetHtml(GtkClipboard* pClipboard, const char* pSelection) +{ + GtkTargetList* pList = gtk_target_list_new(0, 0); + GdkAtom aAtom(gdk_atom_intern("text/html", false)); + gtk_target_list_add(pList, aAtom, 0, 0); + gint nTargets = 0; + GtkTargetEntry* pTargets = gtk_target_table_new_from_list(pList, &nTargets); + + gtk_clipboard_set_with_data(pClipboard, pTargets, nTargets, htmlGetFunc, htmlClearFunc, g_strdup(pSelection)); + + gtk_target_table_free(pTargets, nTargets); + gtk_target_list_unref(pList); +} + /// Handler for the copy button: write clipboard. static void doCopy(GtkWidget* /*pButton*/, gpointer /*pItem*/) { LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView); LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pLOKDocView); char* pUsedFormat = 0; - char* pSelection = pDocument->pClass->getTextSelection(pDocument, "text/plain;charset=utf-8", &pUsedFormat); + char* pSelection = pDocument->pClass->getTextSelection(pDocument, "text/html", &pUsedFormat); GtkClipboard* pClipboard = gtk_clipboard_get_for_display(gtk_widget_get_display(pDocView), GDK_SELECTION_CLIPBOARD); - gtk_clipboard_set_text(pClipboard, pSelection, -1); + std::string aUsedFormat(pUsedFormat); + if (aUsedFormat == "text/plain;charset=utf-8") + gtk_clipboard_set_text(pClipboard, pSelection, -1); + else + clipboardSetHtml(pClipboard, pSelection); free(pSelection); free(pUsedFormat); commit 7b08304b55cf2284a3c583426c60baef618ba206 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Jun 22 09:05:30 2015 +0200 tdf#92061 RTF import: fix missing body text after footnote A missing seek in the \footnote handler could result in a situation that the missed text contained a "{" but not its matching "}", which resulted in the parser terminating earlier than the end of the document. Change-Id: I6df476b2d6397dfa918111b33854dc2f95fbe81d diff --git a/sw/qa/extras/rtfimport/data/tdf92061.rtf b/sw/qa/extras/rtfimport/data/tdf92061.rtf new file mode 100644 index 0000000..03978b4 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/tdf92061.rtf @@ -0,0 +1,5 @@ +{\rtf1 +body-before +{\footnote AAAAA {B} C} +body-after\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 8171b6d..8a22358 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -2307,6 +2307,12 @@ DECLARE_RTFIMPORT_TEST(testBinSkipping, "bin-skipping.rtf") CPPUNIT_ASSERT_EQUAL(OUString("text"), getRun(getParagraph(1), 1)->getString()); } +DECLARE_RTFIMPORT_TEST(testTdf92061, "tdf92061.rtf") +{ + // This was "C", i.e. part of the footnote ended up in the body text. + CPPUNIT_ASSERT_EQUAL(OUString("body-after"), getRun(getParagraph(1), 3)->getString()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 31e62ee..9b16e5a 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1682,11 +1682,13 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) // Check if this is an endnote. OStringBuffer aBuf; char ch; + sal_Size nCurrent = Strm().Tell(); for (int i = 0; i < 7; ++i) { Strm().ReadChar(ch); aBuf.append(ch); } + Strm().Seek(nCurrent); OString aKeyword = aBuf.makeStringAndClear(); if (aKeyword.equals("\\ftnalt")) nId = NS_ooxml::LN_endnote; commit 16c2b60fc10b5fdfd36df64f8fca50b95d81871b Author: Julien Nabet <serval2...@yahoo.fr> Date: Mon Jun 22 07:31:57 2015 +0200 Typo: erturn->return Change-Id: I6cb57f77c723fa252e7c21279e0c1b80e92010e1 diff --git a/include/editeng/unoedsrc.hxx b/include/editeng/unoedsrc.hxx index 43c516a..9af69b3 100644 --- a/include/editeng/unoedsrc.hxx +++ b/include/editeng/unoedsrc.hxx @@ -525,7 +525,7 @@ public: /** Cut current selection to clipboard. - @eturn false if no selection or no view (the empty selection _is_ a selection) + @return false if no selection or no view (the empty selection _is_ a selection) */ virtual bool Cut() = 0; commit a64999511ae654131d997eec9a3d78478cfc1c75 Author: Laurent Godard <lgodard.li...@laposte.net> Date: Thu Apr 30 16:56:14 2015 +0200 new uno sidebar api tdf#91806 the entry point is SfxBaseController::getSidebar() the Decks and panels are now per SidebarController and not global anymore ' macro example Sub testSidebarApi controller = thisComponent.currentcontroller frameIni = thisComponent.currentcontroller.frame sidebar = thisComponent.currentcontroller.getSidebar() sidebar.setVisible(true) frame = sidebar.getFrame() decks = sidebar.getdecks() c = decks.count h = decks.hasElements() e = decks.getElementNames() a = decks.hasByName("MyDeck") deck = decks.getByName("MyDeck") deck.activate(true) t = deck.getTitle() deck.setTitle("new deck title") deck.moveFirst() deck.moveLast() deck.moveUp() deck.moveDown() index = deck.getOrderIndex() panels = deck.getPanels() ep = panels.getElementnames() ap = panels.hasByName("aPanelName") panel = panels.getByName("aPanelName") panel.setTitle("new panel title") panel.collapse() panel.expand(true) ' expand and collapse other index = panel.getOrderIndex() panel.moveLast() panel.moveFirst() panel.moveDown() panel.moveUp() End Sub Change-Id: I7a4b953f2277dea483bb296ba6ead35de7205ace Reviewed-on: https://gerrit.libreoffice.org/15856 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx index 405bb91..42bd37f 100644 --- a/dbaccess/source/ui/browser/genericcontroller.cxx +++ b/dbaccess/source/ui/browser/genericcontroller.cxx @@ -45,6 +45,10 @@ #include "UITools.hxx" #include "commontypes.hxx" +#include <com/sun/star/ui/XSidebarProvider.hpp> +#include <sfx2/sidebar/UnoSidebar.hxx> + + #include <vcl/waitobj.hxx> #include <svl/urihelper.hxx> #include "datasourceconnector.hxx" @@ -72,6 +76,7 @@ using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::task; using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::ui; using namespace ::dbtools; using namespace ::comphelper; @@ -367,6 +372,11 @@ Reference< XWindow > SAL_CALL OGenericUnoController::getComponentWindow() throw return VCLUnoHelper::GetInterface( getView() ); } +Reference<XSidebarProvider> SAL_CALL OGenericUnoController::getSidebar() throw (RuntimeException, std::exception) +{ + return NULL; +} + OUString SAL_CALL OGenericUnoController::getViewControllerName() throw (::com::sun::star::uno::RuntimeException, std::exception) { return OUString( "Default" ); diff --git a/include/dbaccess/genericcontroller.hxx b/include/dbaccess/genericcontroller.hxx index 07a9dec..f195321 100644 --- a/include/dbaccess/genericcontroller.hxx +++ b/include/dbaccess/genericcontroller.hxx @@ -61,6 +61,8 @@ #include <sfx2/userinputinterception.hxx> #include <vcl/vclptr.hxx> +#include <com/sun/star/ui/XSidebarProvider.hpp> + namespace dbtools { class SQLExceptionInfo; @@ -465,6 +467,9 @@ namespace dbaui virtual OUString SAL_CALL getViewControllerName() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getCreationArguments() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XSidebarProvider > SAL_CALL getSidebar() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + // ::com::sun::star::frame::XController virtual void SAL_CALL attachFrame(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & xFrame) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; virtual sal_Bool SAL_CALL attachModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; diff --git a/include/sfx2/sfxbasecontroller.hxx b/include/sfx2/sfxbasecontroller.hxx index 0f77a44..d387d80 100644 --- a/include/sfx2/sfxbasecontroller.hxx +++ b/include/sfx2/sfxbasecontroller.hxx @@ -48,6 +48,8 @@ #include <tools/link.hxx> #include <vcl/button.hxx> +#include <com/sun/star/ui/XSidebarProvider.hpp> + #include <sfx2/viewsh.hxx> #include <sfx2/sfxuno.hxx> @@ -101,6 +103,8 @@ public: virtual OUString SAL_CALL getViewControllerName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCreationArguments() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual css::uno::Reference< css::ui::XSidebarProvider > SAL_CALL getSidebar() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + // XController diff --git a/sfx2/source/sidebar/Accessible.hxx b/include/sfx2/sidebar/Accessible.hxx similarity index 100% rename from sfx2/source/sidebar/Accessible.hxx rename to include/sfx2/sidebar/Accessible.hxx diff --git a/sfx2/source/sidebar/AccessibleTitleBar.hxx b/include/sfx2/sidebar/AccessibleTitleBar.hxx similarity index 100% rename from sfx2/source/sidebar/AccessibleTitleBar.hxx rename to include/sfx2/sidebar/AccessibleTitleBar.hxx diff --git a/sfx2/source/sidebar/AsynchronousCall.hxx b/include/sfx2/sidebar/AsynchronousCall.hxx similarity index 100% rename from sfx2/source/sidebar/AsynchronousCall.hxx rename to include/sfx2/sidebar/AsynchronousCall.hxx diff --git a/sfx2/source/sidebar/Context.hxx b/include/sfx2/sidebar/Context.hxx similarity index 100% rename from sfx2/source/sidebar/Context.hxx rename to include/sfx2/sidebar/Context.hxx diff --git a/sfx2/source/sidebar/ContextList.hxx b/include/sfx2/sidebar/ContextList.hxx similarity index 96% rename from sfx2/source/sidebar/ContextList.hxx rename to include/sfx2/sidebar/ContextList.hxx index 9886007..5171072 100644 --- a/sfx2/source/sidebar/ContextList.hxx +++ b/include/sfx2/sidebar/ContextList.hxx @@ -19,7 +19,7 @@ #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_CONTEXTLIST_HXX #define INCLUDED_SFX2_SOURCE_SIDEBAR_CONTEXTLIST_HXX -#include "Context.hxx" +#include <sfx2/sidebar/Context.hxx> #include <sal/types.h> #include <rtl/ustring.hxx> @@ -55,6 +55,8 @@ public: const bool bIsInitiallyVisible, const ::rtl::OUString& rsMenuCommand); + sal_Int32 GetCount(); + private: ::std::vector<Entry> maEntries; diff --git a/sfx2/source/sidebar/Deck.hxx b/include/sfx2/sidebar/Deck.hxx similarity index 94% rename from sfx2/source/sidebar/Deck.hxx rename to include/sfx2/sidebar/Deck.hxx index 9efaadc..edd735c 100644 --- a/sfx2/source/sidebar/Deck.hxx +++ b/include/sfx2/sidebar/Deck.hxx @@ -19,7 +19,7 @@ #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_DECK_HXX #define INCLUDED_SFX2_SOURCE_SIDEBAR_DECK_HXX -#include "Panel.hxx" +#include <sfx2/sidebar/Panel.hxx> #include <vcl/window.hxx> #include <vcl/image.hxx> @@ -44,17 +44,15 @@ public: virtual ~Deck(); virtual void dispose() SAL_OVERRIDE; - const OUString& GetId() const - { - return msId; - } + const OUString& GetId() const { return msId; } + DeckTitleBar* GetTitleBar() const; Rectangle GetContentArea() const; void ResetPanels (const SharedPanelContainer& rPanels); - const SharedPanelContainer& GetPanels() const - { - return maPanels; - } + const SharedPanelContainer& GetPanels() const { return maPanels; } + + Panel* GetPanel(OUString panelId); + void RequestLayout(); vcl::Window* GetPanelParentWindow(); diff --git a/sfx2/source/sidebar/DeckDescriptor.hxx b/include/sfx2/sidebar/DeckDescriptor.hxx similarity index 96% rename from sfx2/source/sidebar/DeckDescriptor.hxx rename to include/sfx2/sidebar/DeckDescriptor.hxx index 77f811e..a0980c6 100644 --- a/sfx2/source/sidebar/DeckDescriptor.hxx +++ b/include/sfx2/sidebar/DeckDescriptor.hxx @@ -23,6 +23,8 @@ #include "ContextList.hxx" #include <boost/shared_ptr.hpp> +#include <sfx2/sidebar/Deck.hxx> + namespace sfx2 { namespace sidebar { class DeckDescriptor @@ -41,6 +43,8 @@ public: sal_Int32 mnOrderIndex; bool mbExperimental; + VclPtr<Deck> mpDeck; + DeckDescriptor(); DeckDescriptor (const DeckDescriptor& rOther); ~DeckDescriptor(); diff --git a/sfx2/source/sidebar/DeckLayouter.hxx b/include/sfx2/sidebar/DeckLayouter.hxx similarity index 98% rename from sfx2/source/sidebar/DeckLayouter.hxx rename to include/sfx2/sidebar/DeckLayouter.hxx index 965fb56..8b3b248 100644 --- a/sfx2/source/sidebar/DeckLayouter.hxx +++ b/include/sfx2/sidebar/DeckLayouter.hxx @@ -19,7 +19,7 @@ #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_DECKLAYOUTER_HXX #define INCLUDED_SFX2_SOURCE_SIDEBAR_DECKLAYOUTER_HXX -#include "Panel.hxx" +#include <sfx2/sidebar/Panel.hxx> #include <tools/gen.hxx> diff --git a/sfx2/source/sidebar/DeckTitleBar.hxx b/include/sfx2/sidebar/DeckTitleBar.hxx similarity index 98% rename from sfx2/source/sidebar/DeckTitleBar.hxx rename to include/sfx2/sidebar/DeckTitleBar.hxx index bd47883..3b42958 100644 --- a/sfx2/source/sidebar/DeckTitleBar.hxx +++ b/include/sfx2/sidebar/DeckTitleBar.hxx @@ -19,7 +19,7 @@ #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_DECKTITLEBAR_HXX #define INCLUDED_SFX2_SOURCE_SIDEBAR_DECKTITLEBAR_HXX -#include "TitleBar.hxx" +#include <sfx2/sidebar/TitleBar.hxx> namespace sfx2 { namespace sidebar { diff --git a/sfx2/source/sidebar/DrawHelper.hxx b/include/sfx2/sidebar/DrawHelper.hxx similarity index 100% rename from sfx2/source/sidebar/DrawHelper.hxx rename to include/sfx2/sidebar/DrawHelper.hxx diff --git a/sfx2/source/sidebar/FocusManager.hxx b/include/sfx2/sidebar/FocusManager.hxx similarity index 100% rename from sfx2/source/sidebar/FocusManager.hxx rename to include/sfx2/sidebar/FocusManager.hxx diff --git a/sfx2/source/sidebar/MenuButton.hxx b/include/sfx2/sidebar/MenuButton.hxx similarity index 100% rename from sfx2/source/sidebar/MenuButton.hxx rename to include/sfx2/sidebar/MenuButton.hxx diff --git a/sfx2/source/sidebar/Paint.hxx b/include/sfx2/sidebar/Paint.hxx similarity index 100% rename from sfx2/source/sidebar/Paint.hxx rename to include/sfx2/sidebar/Paint.hxx diff --git a/sfx2/source/sidebar/Panel.hxx b/include/sfx2/sidebar/Panel.hxx similarity index 91% rename from sfx2/source/sidebar/Panel.hxx rename to include/sfx2/sidebar/Panel.hxx index 52e6e49..b42dbc9 100644 --- a/sfx2/source/sidebar/Panel.hxx +++ b/include/sfx2/sidebar/Panel.hxx @@ -19,11 +19,13 @@ #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_PANEL_HXX #define INCLUDED_SFX2_SOURCE_SIDEBAR_PANEL_HXX -#include "Context.hxx" +#include <sfx2/sidebar/Context.hxx> + #include <vcl/window.hxx> #include <com/sun/star/ui/XUIElement.hpp> #include <com/sun/star/ui/XSidebarPanel.hpp> +#include <com/sun/star/frame/XFrame.hpp> #include <boost/scoped_ptr.hpp> #include <boost/shared_ptr.hpp> @@ -40,7 +42,9 @@ class Panel : public vcl::Window public: Panel(const PanelDescriptor& rPanelDescriptor, vcl::Window* pParentWindow, const bool bIsInitiallyExpanded, const std::function<void()>& rDeckLayoutTrigger, - const std::function<Context()>& rContextAccess); + const std::function<Context()>& rContextAccess, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + virtual ~Panel(); virtual void dispose() SAL_OVERRIDE; @@ -69,6 +73,9 @@ private: bool mbIsExpanded; const std::function<void()> maDeckLayoutTrigger; const std::function<Context()> maContextAccess; + + const css::uno::Reference<css::frame::XFrame>& mxFrame; + }; typedef std::vector<VclPtr<Panel> > SharedPanelContainer; diff --git a/sfx2/source/sidebar/PanelDescriptor.hxx b/include/sfx2/sidebar/PanelDescriptor.hxx similarity index 97% rename from sfx2/source/sidebar/PanelDescriptor.hxx rename to include/sfx2/sidebar/PanelDescriptor.hxx index f67a128..fa490b9 100644 --- a/sfx2/source/sidebar/PanelDescriptor.hxx +++ b/include/sfx2/sidebar/PanelDescriptor.hxx @@ -20,7 +20,7 @@ #define INCLUDED_SFX2_SOURCE_SIDEBAR_PANELDESCRIPTOR_HXX #include <sfx2/sidebar/EnumContext.hxx> -#include "ContextList.hxx" +#include <sfx2/sidebar/ContextList.hxx> #include <boost/shared_ptr.hpp> namespace sfx2 { namespace sidebar { diff --git a/sfx2/source/sidebar/PanelTitleBar.hxx b/include/sfx2/sidebar/PanelTitleBar.hxx similarity index 98% rename from sfx2/source/sidebar/PanelTitleBar.hxx rename to include/sfx2/sidebar/PanelTitleBar.hxx index 8c0f7e8..c081402 100644 --- a/sfx2/source/sidebar/PanelTitleBar.hxx +++ b/include/sfx2/sidebar/PanelTitleBar.hxx @@ -19,7 +19,7 @@ #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_PANELTITLEBAR_HXX #define INCLUDED_SFX2_SOURCE_SIDEBAR_PANELTITLEBAR_HXX -#include "TitleBar.hxx" +#include <sfx2/sidebar/TitleBar.hxx> #include <com/sun/star/frame/XFrame.hpp> #include <boost/function.hpp> diff --git a/sfx2/source/sidebar/ResourceManager.hxx b/include/sfx2/sidebar/ResourceManager.hxx similarity index 93% rename from sfx2/source/sidebar/ResourceManager.hxx rename to include/sfx2/sidebar/ResourceManager.hxx index 9151760..4e6247d 100644 --- a/sfx2/source/sidebar/ResourceManager.hxx +++ b/include/sfx2/sidebar/ResourceManager.hxx @@ -21,7 +21,7 @@ #include "DeckDescriptor.hxx" #include "PanelDescriptor.hxx" -#include "Context.hxx" +#include <sfx2/sidebar/Context.hxx> #include <unotools/confignode.hxx> #include <com/sun/star/frame/XFrame.hpp> #include <set> @@ -40,6 +40,10 @@ class ContextList; class ResourceManager { public: + + ResourceManager(); + ~ResourceManager(); + static ResourceManager& Instance(); const DeckDescriptor* GetDeckDescriptor(const OUString& rsDeckId) const; @@ -54,6 +58,13 @@ public: */ void SetIsDeckEnabled(const OUString& rsDeckId, const bool bIsEnabled); + void SetDeckToDescriptor(const OUString& rsDeckId, VclPtr<Deck> aDeck); + + void SetDeckOrderIndex(const OUString& rsDeckId, const sal_Int32 orderIndex); + + void SetPanelOrderIndex(const OUString& rsPanelId, const sal_Int32 orderIndex); + + class DeckContextDescriptor { public: @@ -92,8 +103,7 @@ public: const Context& rContext); private: - ResourceManager(); - ~ResourceManager(); + typedef std::vector<DeckDescriptor> DeckContainer; DeckContainer maDecks; diff --git a/sfx2/source/sidebar/Sidebar.hrc b/include/sfx2/sidebar/Sidebar.hrc similarity index 100% rename from sfx2/source/sidebar/Sidebar.hrc rename to include/sfx2/sidebar/Sidebar.hrc diff --git a/sfx2/source/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx similarity index 91% rename from sfx2/source/sidebar/SidebarController.hxx rename to include/sfx2/sidebar/SidebarController.hxx index 5fb8466..0e1fe0e 100644 --- a/sfx2/source/sidebar/SidebarController.hxx +++ b/include/sfx2/sidebar/SidebarController.hxx @@ -23,12 +23,12 @@ #include <map> -#include "AsynchronousCall.hxx" -#include "Context.hxx" -#include "FocusManager.hxx" -#include "Panel.hxx" -#include "ResourceManager.hxx" -#include "TabBar.hxx" +#include <sfx2/sidebar/AsynchronousCall.hxx> +#include <sfx2/sidebar/Context.hxx> +#include <sfx2/sidebar/FocusManager.hxx> +#include <sfx2/sidebar/Panel.hxx> +#include <sfx2/sidebar/ResourceManager.hxx> +#include <sfx2/sidebar/TabBar.hxx> #include <vcl/menu.hxx> @@ -45,6 +45,8 @@ #include <cppuhelper/basemutex.hxx> #include <cppuhelper/weakref.hxx> + + namespace { typedef ::cppu::WeakComponentImplHelper4 < @@ -137,6 +139,21 @@ public: FocusManager& GetFocusManager() { return maFocusManager;} + ResourceManager* GetResourceManager() { return mpResourceManager.get();} + + // std::unique_ptr<ResourceManager> GetResourceManager() { return mpResourceManager;} + + Context GetCurrentContext() const { return maCurrentContext;} + bool IsDocumentReadOnly (void) const { return mbIsDocumentReadOnly;} + + void SwitchToDeck ( const ::rtl::OUString& rsDeckId); + void SwitchToDefaultDeck(); + + void CreateDeck(const ::rtl::OUString& rDeckId); + + ResourceManager::DeckContextDescriptorContainer GetMatchingDecks(); + ResourceManager::PanelContextDescriptorContainer GetMatchingPanels( const ::rtl::OUString& rDeckId); + private: typedef ::std::map< const css::uno::Reference<css::frame::XFrame>, @@ -198,13 +215,13 @@ private: const ::rtl::OUString& rsImplementationURL, const bool bWantsCanvas, const Context& rContext); + VclPtr<Panel> CreatePanel ( const ::rtl::OUString& rsPanelId, vcl::Window* pParentWindow, const bool bIsInitiallyExpanded, const Context& rContext); - void SwitchToDeck ( - const ::rtl::OUString& rsDeckId); + void SwitchToDeck ( const DeckDescriptor& rDeckDescriptor, const Context& rContext); @@ -245,9 +262,10 @@ private: */ void ShowPanel (const Panel& rPanel); - Context GetCurrentContext() const { return maCurrentContext;} - virtual void SAL_CALL disposing() SAL_OVERRIDE; + + std::unique_ptr<ResourceManager> mpResourceManager; + }; } } // end of namespace sfx2::sidebar diff --git a/sfx2/source/sidebar/SidebarDockingWindow.hxx b/include/sfx2/sidebar/SidebarDockingWindow.hxx similarity index 100% rename from sfx2/source/sidebar/SidebarDockingWindow.hxx rename to include/sfx2/sidebar/SidebarDockingWindow.hxx diff --git a/sfx2/source/sidebar/SidebarResource.hxx b/include/sfx2/sidebar/SidebarResource.hxx similarity index 97% rename from sfx2/source/sidebar/SidebarResource.hxx rename to include/sfx2/sidebar/SidebarResource.hxx index 3a6363a..78ce96b 100644 --- a/sfx2/source/sidebar/SidebarResource.hxx +++ b/include/sfx2/sidebar/SidebarResource.hxx @@ -19,7 +19,7 @@ #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARRESOURCE_HXX #define INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARRESOURCE_HXX -#include "Sidebar.hrc" +#include <sfx2/sidebar/Sidebar.hrc> #include <sfx2/sfxresid.hxx> #include <tools/rc.hxx> diff --git a/sfx2/source/sidebar/TabBar.hxx b/include/sfx2/sidebar/TabBar.hxx similarity index 94% rename from sfx2/source/sidebar/TabBar.hxx rename to include/sfx2/sidebar/TabBar.hxx index 37089f8..1fe2a27 100644 --- a/sfx2/source/sidebar/TabBar.hxx +++ b/include/sfx2/sidebar/TabBar.hxx @@ -20,7 +20,8 @@ #define INCLUDED_SFX2_SOURCE_SIDEBAR_TABBAR_HXX #include "DeckDescriptor.hxx" -#include "ResourceManager.hxx" +#include <sfx2/sidebar/ResourceManager.hxx> + #include <vcl/menu.hxx> #include <vcl/window.hxx> @@ -39,6 +40,7 @@ namespace sfx2 { namespace sidebar { class FocusManager; class TabBarConfiguration; class TabItem; +class SidebarController; /** The tab bar is the container for the individual tabs. */ @@ -66,7 +68,9 @@ public: vcl::Window* pParentWindow, const css::uno::Reference<css::frame::XFrame>& rxFrame, const ::boost::function<void(const ::rtl::OUString&rsDeckId)>& rDeckActivationFunctor, - const PopupMenuProvider& rPopupMenuProvider); + const PopupMenuProvider& rPopupMenuProvider, + SidebarController* rParentSidebarController); + virtual ~TabBar(); virtual void dispose() SAL_OVERRIDE; @@ -120,6 +124,8 @@ private: void ShowPopupMenu() const; DECL_LINK(OnToolboxClicked, void*); + SidebarController* pParentSidebarController; + }; diff --git a/sfx2/source/sidebar/TabItem.hxx b/include/sfx2/sidebar/TabItem.hxx similarity index 97% rename from sfx2/source/sidebar/TabItem.hxx rename to include/sfx2/sidebar/TabItem.hxx index f63e4e2..c5eaabb 100644 --- a/sfx2/source/sidebar/TabItem.hxx +++ b/include/sfx2/sidebar/TabItem.hxx @@ -21,7 +21,7 @@ #include <vcl/button.hxx> -#include "DeckDescriptor.hxx" +#include <sfx2/sidebar/DeckDescriptor.hxx> namespace vcl { class Window; } diff --git a/sfx2/source/sidebar/TitleBar.hxx b/include/sfx2/sidebar/TitleBar.hxx similarity index 95% rename from sfx2/source/sidebar/TitleBar.hxx rename to include/sfx2/sidebar/TitleBar.hxx index b0bc5d8..9a4d343 100644 --- a/sfx2/source/sidebar/TitleBar.hxx +++ b/include/sfx2/sidebar/TitleBar.hxx @@ -19,7 +19,7 @@ #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_TITLEBAR_HXX #define INCLUDED_SFX2_SOURCE_SIDEBAR_TITLEBAR_HXX -#include "Paint.hxx" +#include <sfx2/sidebar/Paint.hxx> #include <vcl/fixed.hxx> #include <sfx2/sidebar/SidebarToolBox.hxx> @@ -35,7 +35,9 @@ public: virtual ~TitleBar(); virtual void dispose() SAL_OVERRIDE; - void SetTitle (const ::rtl::OUString& rsTitle); + void SetTitle (const OUString& rsTitle); + const OUString GetTitle() {return msTitle; } + void SetIcon (const Image& rIcon); virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE; diff --git a/sfx2/source/sidebar/ToolBox.hxx b/include/sfx2/sidebar/ToolBox.hxx similarity index 100% rename from sfx2/source/sidebar/ToolBox.hxx rename to include/sfx2/sidebar/ToolBox.hxx diff --git a/include/sfx2/sidebar/UnoDeck.hxx b/include/sfx2/sidebar/UnoDeck.hxx new file mode 100644 index 0000000..1d9fcc2 --- /dev/null +++ b/include/sfx2/sidebar/UnoDeck.hxx @@ -0,0 +1,79 @@ +/* -*- 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/. + * + */ + +#ifndef INCLUDED_SFX2_SIDEBAR_UNODECK_HXX +#define INCLUDED_SFX2_SIDEBAR_UNODECK_HXX + + +#include <com/sun/star/ui/XDeck.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/ui/XPanels.hpp> + +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/weakref.hxx> + +#include <sfx2/sidebar/SidebarController.hxx> +#include <sfx2/sidebar/ResourceManager.hxx> + +/** get the decks +*/ +class SfxUnoDeck : public ::cppu::WeakImplHelper1< css::ui::XDeck > +{ + +public: + + SfxUnoDeck(const css::uno::Reference<css::frame::XFrame>& , const OUString&); + virtual ~SfxUnoDeck() {}; + + virtual OUString SAL_CALL getId() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual OUString SAL_CALL getTitle() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL setTitle( const OUString& newTitle ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual sal_Bool SAL_CALL isActive() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL activate( const sal_Bool bActivate ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual css::uno::Reference<css::ui::XPanels> SAL_CALL getPanels() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual sal_Int32 SAL_CALL getOrderIndex() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL setOrderIndex( const sal_Int32 newOrderIndex ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveFirst() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveLast() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveUp() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveDown() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +private: + + const css::uno::Reference<css::frame::XFrame> xFrame; + sfx2::sidebar::SidebarController* getSidebarController(); + + const OUString mDeckId; + const OUString mTitle; + + sal_Int32 GetMaxOrderIndex(sfx2::sidebar::ResourceManager::DeckContextDescriptorContainer aDecks); + sal_Int32 GetMinOrderIndex(sfx2::sidebar::ResourceManager::DeckContextDescriptorContainer aDecks); + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/UnoDecks.hxx b/include/sfx2/sidebar/UnoDecks.hxx new file mode 100644 index 0000000..5e00899 --- /dev/null +++ b/include/sfx2/sidebar/UnoDecks.hxx @@ -0,0 +1,75 @@ +/* -*- 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/. + * + */ + +#ifndef INCLUDED_SFX2_SIDEBAR_DECKS_HXX +#define INCLUDED_SFX2_SIDEBAR_DECKS_HXX + + +#include <com/sun/star/ui/XDecks.hpp> + +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/frame/XFrame.hpp> + +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/weakref.hxx> + +#include <sfx2/sidebar/SidebarController.hxx> +#include <sfx2/sidebar/ResourceManager.hxx> + +/** get the decks +*/ +class SfxUnoDecks : public ::cppu::WeakImplHelper1< css::ui::XDecks > +{ + +public: + + SfxUnoDecks(const css::uno::Reference<css::frame::XFrame>&); + virtual ~SfxUnoDecks() {}; + +// XNameAccess + + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) + throw(css::container::NoSuchElementException, + css::lang::WrappedTargetException, + css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +// XIndexAccess + + virtual sal_Int32 SAL_CALL getCount() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) + throw(css::lang::IndexOutOfBoundsException, + css::lang::WrappedTargetException, + css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +// XElementAccess + virtual css::uno::Type SAL_CALL getElementType() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual sal_Bool SAL_CALL hasElements() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +private: + + const css::uno::Reference<css::frame::XFrame> xFrame; + sfx2::sidebar::SidebarController* getSidebarController(); + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/include/sfx2/sidebar/UnoPanel.hxx b/include/sfx2/sidebar/UnoPanel.hxx new file mode 100644 index 0000000..051a00d --- /dev/null +++ b/include/sfx2/sidebar/UnoPanel.hxx @@ -0,0 +1,86 @@ +/* -*- 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/. + * + */ + +#ifndef INCLUDED_SFX2_SIDEBAR_UNOPANEL_HXX +#define INCLUDED_SFX2_SIDEBAR_UNOPANEL_HXX + +#include <com/sun/star/ui/XPanel.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/awt/XWindow.hpp> + + +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/weakref.hxx> + +#include <sfx2/sidebar/SidebarController.hxx> +#include <sfx2/sidebar/Panel.hxx> +#include <sfx2/sidebar/Deck.hxx> +#include <sfx2/sidebar/ResourceManager.hxx> + + +/** get the Panel +*/ +class SfxUnoPanel : public ::cppu::WeakImplHelper1< css::ui::XPanel > +{ + +public: + + SfxUnoPanel(const css::uno::Reference<css::frame::XFrame>& , const OUString&, const OUString&); + virtual ~SfxUnoPanel() {}; + + virtual OUString SAL_CALL getId() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual OUString SAL_CALL getTitle() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL setTitle( const OUString& newTitle ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual sal_Bool SAL_CALL isExpanded() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL expand( const sal_Bool bCollapseOther ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL collapse( ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual sal_Int32 SAL_CALL getOrderIndex() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL setOrderIndex( const sal_Int32 newOrderIndex ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveFirst() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveLast() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveUp() ... etc. - the rest is truncated
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits