[Libreoffice-commits] core.git: Branch 'feature/lok_sofficemain' - 7 commits - desktop/source include/LibreOfficeKit include/vcl libreofficekit/qa libreofficekit/source sd/source

Andrzej Hunt andrzej.hunt at collabora.com
Tue Jul 29 04:21:45 PDT 2014


 desktop/source/lib/init.cxx                         |   38 ++++++++++++++++++++
 include/LibreOfficeKit/LibreOfficeKit.h             |   23 ++++++++----
 include/LibreOfficeKit/LibreOfficeKit.hxx           |    5 ++
 include/LibreOfficeKit/LibreOfficeKitGtk.h          |    3 +
 include/vcl/ITiledRenderable.hxx                    |   17 ++++++++
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |   20 +++++++---
 libreofficekit/source/gtk/lokdocview.c              |    5 ++
 sd/source/ui/inc/unomodel.hxx                       |    1 
 sd/source/ui/unoidl/unomodel.cxx                    |    7 +++
 9 files changed, 106 insertions(+), 13 deletions(-)

New commits:
commit 3aebefc07bf44568ba468664352d0e59106c0693
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Tue Jul 29 13:19:44 2014 +0200

    Impress: Implement getPartName.
    
    Change-Id: I614838505fef901fc37e8d3906bb59c60b034453

diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 6887663..8fa1904 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -233,6 +233,7 @@ public:
     virtual void setPart(   int nPart ) SAL_OVERRIDE;
     virtual int  getPart() SAL_OVERRIDE;
     virtual int  getParts() SAL_OVERRIDE;
+    virtual OUString getPartName( int nPart ) SAL_OVERRIDE;
 
     // XComponent
 
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 5a162f2..b6754ec 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2261,6 +2261,13 @@ int SdXImpressDocument::getPart()
     return 0;
 }
 
+OUString SdXImpressDocument::getPartName( int nPart )
+{
+    SdPage* pPage = mpDoc->GetSdPage( nPart, PK_STANDARD );
+    assert( pPage );
+    return pPage->GetName();
+}
+
 Size SdXImpressDocument::getDocumentSize()
 {
     SdrPageView* pCurPageView = mpDoc->GetDocSh()->GetViewShell()->GetView()->GetSdrPageView();
commit 881a7fbe74d4a9fac59a43521605935d6bceec03
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Tue Jul 29 13:17:45 2014 +0200

    gtktiledviewer: show part names in selector.
    
    Change-Id: I02ae5b729f96e36b3f226218b32495907cb63cf3

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 21cb179..0678497 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -7,6 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <assert.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -122,10 +123,17 @@ void changeQuadView( GtkWidget* /*pButton*/, gpointer /* pItem */ )
 #if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
 void populatePartSelector( GtkComboBoxText* pSelector, LOKDocView* pView )
 {
-    char sText[10];
-    for ( int i = 0; i < lok_docview_get_parts(pView); i++ )
+    const int nMaxLength = 50;
+    char sText[nMaxLength];
+
+    int nParts = lok_docview_get_parts(pView);
+    for ( int i = 0; i < nParts; i++ )
     {
-        sprintf( sText, "%i", i+1 );
+        char* pName = lok_docview_get_part_name( pView, i );
+        assert( pName );
+        snprintf( sText, nMaxLength, "%i (%s)", i+1, pName );
+        free( pName );
+
         gtk_combo_box_text_append_text( pSelector, sText );
     }
     gtk_combo_box_set_active( GTK_COMBO_BOX(pSelector), 0 );
@@ -219,8 +227,10 @@ int main( int argc, char* argv[] )
     gtk_widget_show_all( pWindow );
 
     pFileName = argv[2];
-    lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] );
-// GtkComboBox requires gtk 2.24 or later
+    assert( lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] ) );
+    assert( LOK_DOCVIEW(pDocView)->pDocument );
+    fprintf( stderr, "We received in the C++: %p\n", LOK_DOCVIEW(pDocView) );
+    // GtkComboBox requires gtk 2.24 or later
 #if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
     populatePartSelector( GTK_COMBO_BOX_TEXT(pComboBox), LOK_DOCVIEW(pDocView) );
 #endif
commit d3a91a16090c2cc98eab05968cee4ba6faf3bf66
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Tue Jul 29 13:17:30 2014 +0200

    LOKDocView: add part name retrieval.
    
    Change-Id: Iac31de0410d7f6187e5884152c329375047a23f4

diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index 37d21f0..a73f98d 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -62,7 +62,8 @@ int             lok_docview_get_parts       (LOKDocView* pDocView);
 int             lok_docview_get_part        (LOKDocView* pDocView);
 void            lok_docview_set_part        (LOKDocView* pDocView,
                                              int nPart);
-
+char*           lok_docview_get_part_name   (LOKDocView* pDocView,
+                                             int nPart);
 #ifdef __cplusplus
 }
 #endif
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index cdc2339..b4a7b8d 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -190,5 +190,8 @@ SAL_DLLPUBLIC_EXPORT void lok_docview_set_part( LOKDocView* pDocView, int nPart)
     renderDocument( pDocView );
 }
 
-
+SAL_DLLPUBLIC_EXPORT gchar* lok_docview_get_part_name( LOKDocView* pDocView, int nPart )
+{
+    return pDocView->pDocument->pClass->getPartName( pDocView->pDocument, nPart );
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit ea08b4274eb364d999ba90b847c38de7e146e170
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Tue Jul 29 09:02:02 2014 +0200

    Remove horrifically outdated comment.
    
    Change-Id: I1362489c9aecf536b31bf6ab57ad8c149f37a876

diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index c935ebc..d7b8e41 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -99,11 +99,6 @@ struct _LibreOfficeKitDocumentClass
   void (*setPartMode)     (LibreOfficeKitDocument* pThis,
                            LibreOfficeKitPartMode eMode);
 
-  // Get a pointer to a raw array, of size 3*nCanvasWidth*nCanvasHeight
-  // Basebmp's bitmap device seems to round the width up if needed
-  // for its internal buffer, i.e. the rowstride for the buffer may be larger
-  // than the desired width, hence we need to be able to return the
-  // rowstride too.
   void (*paintTile)       (LibreOfficeKitDocument* pThis,
                            unsigned char* pBuffer,
                            const int nCanvasWidth,
commit 927a3e8c7657586efc1ec0103566c347aa9fc88b
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Tue Jul 29 08:59:13 2014 +0200

    LOK: add setPartMode.
    
    This API seems to be simplest in the long run where we'll want to be
    able to select between rendering slides/notes/both/embedded objects,
    and maybe even adding the option of switching between continuous
    and single page mode in writer (although I have no idea how hard
    getting a single page mode out of writer would be).
    
    Change-Id: I5bdfdb61854c37281c6992c8f3ed1c50c8aa0919

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a374f4e..e35232d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -190,6 +190,7 @@ static int doc_getParts(LibreOfficeKitDocument* pThis);
 static int doc_getPart(LibreOfficeKitDocument* pThis);
 static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
 static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart);
+static void doc_setPartMode(LibreOfficeKitDocument* pThis, LibreOfficeKitPartMode ePartMode);
 void        doc_paintTile(LibreOfficeKitDocument* pThis,
                           unsigned char* pBuffer,
                           const int nCanvasWidth, const int nCanvasHeight,
@@ -221,6 +222,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
             m_pDocumentClass->getPart = doc_getPart;
             m_pDocumentClass->setPart = doc_setPart;
             m_pDocumentClass->getPartName = doc_getPartName;
+            m_pDocumentClass->setPartMode = doc_setPartMode;
             m_pDocumentClass->paintTile = doc_paintTile;
             m_pDocumentClass->getDocumentSize = doc_getDocumentSize;
 
@@ -496,6 +498,21 @@ static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart)
 
 }
 
+static void doc_setPartMode(LibreOfficeKitDocument* pThis,
+                            LibreOfficeKitPartMode ePartMode)
+{
+    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
+    ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+    if (!pDoc)
+    {
+        gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+        return;
+    }
+
+    pDoc->setPartMode(ePartMode);
+}
+
 void doc_paintTile (LibreOfficeKitDocument* pThis,
                     unsigned char* pBuffer,
                     const int nCanvasWidth, const int nCanvasHeight,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index c90a947..c935ebc 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -40,6 +40,16 @@ typedef enum
   LOK_DOCTYPE_OTHER
 }
 LibreOfficeKitDocumentType;
+
+typedef enum
+{
+    LOK_PARTMODE_DEFAULT,
+    LOK_PARTMODE_SLIDE,
+    LOK_PARTMODE_NOTES,
+    LOK_PARTMODE_SLIDENOTES,
+    LOK_PARTMODE_EMBEDDEDOBJ
+}
+LibreOfficeKitPartMode;
 #endif // LOK_USE_UNSTABLE_API
 
 struct _LibreOfficeKit
@@ -86,6 +96,9 @@ struct _LibreOfficeKitDocumentClass
   char* (*getPartName)    (LibreOfficeKitDocument* pThis,
                            int nPart);
 
+  void (*setPartMode)     (LibreOfficeKitDocument* pThis,
+                           LibreOfficeKitPartMode eMode);
+
   // Get a pointer to a raw array, of size 3*nCanvasWidth*nCanvasHeight
   // Basebmp's bitmap device seems to round the width up if needed
   // for its internal buffer, i.e. the rowstride for the buffer may be larger
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index ca6ee25..a872713 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -11,6 +11,8 @@
 #ifndef INCLUDED_VCL_ITILEDRENDERABLE_HXX
 #define INCLUDED_VCL_ITILEDRENDERABLE_HXX
 
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKit.h>
 #include <tools/gen.hxx>
 #include <vcl/virdev.hxx>
 
@@ -67,6 +69,11 @@ public:
         (void) nPart;
         return "";
     }
+
+    virtual void setPartMode(LibreOfficeKitPartMode ePartMode)
+    {
+        (void) ePartMode;
+    }
 };
 
 } // namespace vcl
commit 469fe8ca50b67257b9e8ed59220ab80dcdf7e748
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Tue Jul 29 08:50:34 2014 +0200

    LOK: Add getPartName.
    
    By default (i.e. for writer) we can just return an empty string,
    and we only actually need to implement ITiledRenderable's
    getPartName for components that actually support it (i.e. calc/impress).
    
    Change-Id: I8b381e5d7a8000638b02f763b4bea8ef0226f8e0

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b17516c..a374f4e 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -189,6 +189,7 @@ static LibreOfficeKitDocumentType doc_getDocumentType(LibreOfficeKitDocument* pT
 static int doc_getParts(LibreOfficeKitDocument* pThis);
 static int doc_getPart(LibreOfficeKitDocument* pThis);
 static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
+static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart);
 void        doc_paintTile(LibreOfficeKitDocument* pThis,
                           unsigned char* pBuffer,
                           const int nCanvasWidth, const int nCanvasHeight,
@@ -219,6 +220,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
             m_pDocumentClass->getParts = doc_getParts;
             m_pDocumentClass->getPart = doc_getPart;
             m_pDocumentClass->setPart = doc_setPart;
+            m_pDocumentClass->getPartName = doc_getPartName;
             m_pDocumentClass->paintTile = doc_paintTile;
             m_pDocumentClass->getDocumentSize = doc_getDocumentSize;
 
@@ -475,6 +477,25 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
     Application::ReleaseSolarMutex();
 }
 
+static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart)
+{
+    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
+    ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+    if (!pDoc)
+    {
+        gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+        return 0;
+    }
+
+    OUString sName = pDoc->getPartName( nPart );
+    OString aString = OUStringToOString(sName, RTL_TEXTENCODING_UTF8);
+    char* pMemory = (char*) malloc(aString.getLength() + 1);
+    strcpy(pMemory, aString.getStr());
+    return pMemory;
+
+}
+
 void doc_paintTile (LibreOfficeKitDocument* pThis,
                     unsigned char* pBuffer,
                     const int nCanvasWidth, const int nCanvasHeight,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 9fb5ace..c90a947 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -83,6 +83,9 @@ struct _LibreOfficeKitDocumentClass
   void (*setPart)         (LibreOfficeKitDocument* pThis,
                            int nPart);
 
+  char* (*getPartName)    (LibreOfficeKitDocument* pThis,
+                           int nPart);
+
   // Get a pointer to a raw array, of size 3*nCanvasWidth*nCanvasHeight
   // Basebmp's bitmap device seems to round the width up if needed
   // for its internal buffer, i.e. the rowstride for the buffer may be larger
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 32faf26..f61a4b8 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -64,6 +64,11 @@ public:
         mpDoc->pClass->setPart(mpDoc, nPart);
     }
 
+    inline char* getPartName(int nPart)
+    {
+        return mpDoc->pClass->getPartName(mpDoc, nPart);
+    }
+
     inline void paintTile(
                           unsigned char* pBuffer,
                           const int nCanvasWidth,
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 55e1b39..ca6ee25 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -57,6 +57,16 @@ public:
      * details.
      */
     virtual int getPart() = 0;
+
+    /**
+     * Get the name of the currently displayed part, i.e. sheet in a spreadsheet
+     * or slide in a presentation.
+     */
+    virtual OUString getPartName(int nPart)
+    {
+        (void) nPart;
+        return "";
+    }
 };
 
 } // namespace vcl
commit 66cc3f6c6ed038cec15091e1390f820bea4ca84f
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Tue Jul 29 08:32:07 2014 +0200

    Fix comment typo.
    
    Change-Id: I8ebe3ad2a6efcf1797a2dc941994c7fc1e36f4bf

diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 9c74634..9fb5ace 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -76,7 +76,7 @@ struct _LibreOfficeKitDocumentClass
   LibreOfficeKitDocumentType (*getDocumentType) (LibreOfficeKitDocument* pThis);
 
   // Part refers to either indivual sheets in a Spreadsheet, or slides
-  // in a Slideshow, and has no relevance for wrtier documents.
+  // in a Slideshow, and has no relevance for writer documents.
   int (*getParts) (LibreOfficeKitDocument* pThis);
 
   int (*getPart)          (LibreOfficeKitDocument* pThis);


More information about the Libreoffice-commits mailing list