[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 3 commits - desktop/source include/LibreOfficeKit libreofficekit/qa libreofficekit/source sc/inc sc/source sw/inc sw/source

Jan Holesovsky kendy at collabora.com
Mon Aug 3 02:30:30 PDT 2015


 desktop/source/lib/init.cxx                         |   35 +++++++++++----
 include/LibreOfficeKit/LibreOfficeKitGtk.h          |    1 
 libreofficekit/qa/data/calc_sheetnames.ods          |binary
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |    8 +++
 libreofficekit/qa/unit/tiledrendering.cxx           |   24 +++++++++-
 libreofficekit/source/gtk/lokdocview.cxx            |   11 +++++
 sc/inc/docuno.hxx                                   |    3 +
 sc/source/ui/unoobj/docuno.cxx                      |    8 +++
 sw/inc/unotxdoc.hxx                                 |    8 +++
 sw/inc/viscrs.hxx                                   |    3 +
 sw/source/core/crsr/viscrs.cxx                      |   12 +++++
 sw/source/uibase/uno/unotxdoc.cxx                   |   44 ++++++++++++++++++++
 12 files changed, 144 insertions(+), 13 deletions(-)

New commits:
commit 1823208dbd13ec7d4118045084036a59a70c7125
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Sat Aug 1 02:13:47 2015 +0200

    LOK: Implement parts for Writer too.
    
    In Writer, the meaning of 'parts' is a bit different than in Calc or Impress.
    In Writer, the parts mean pages, and the document does not give a completely
    different view, the cursor just jumps to the given page.
    
    It is up to the client to follow the cursor appropriately to have the desired
    effect.
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    	libreofficekit/source/gtk/lokdocview.cxx
    
    Change-Id: I56b3264e0340cd639bdabfa92b74b52bd1f391a5

diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index b3e50d3..f5c9143 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -41,6 +41,7 @@ struct _LOKDocViewClass
   void (* command_changed) (LOKDocView* pView, char* new_state);
   void (* search_not_found) (LOKDocView* pView, char* new_state);
   void (* part_changed) (LOKDocView* pView, int new_part);
+  void (* size_changed) (LOKDocView* pView);
 };
 
 guint           lok_docview_get_type        (void);
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 83ec9d2..144f807 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -300,6 +300,13 @@ static void populatePartSelector()
                               lok_docview_get_part( LOK_DOCVIEW(pDocView) ) );
 }
 
+static void signalSize(LOKDocView* /*pLOKDocView*/, gpointer /*pData*/)
+{
+    g_bPartSelectorBroadcast = false;
+    populatePartSelector();
+    g_bPartSelectorBroadcast = true;
+}
+
 static void changePart( GtkWidget* pSelector, gpointer /* pItem */ )
 {
     int nPart = gtk_combo_box_get_active( GTK_COMBO_BOX(pSelector) );
@@ -463,6 +470,7 @@ int main( int argc, char* argv[] )
     g_signal_connect(pDocView, "command-changed", G_CALLBACK(signalCommand), NULL);
     g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), NULL);
     g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), NULL);
+    g_signal_connect(pDocView, "size-changed", G_CALLBACK(signalSize), NULL);
 
     // Input handling.
     g_signal_connect(pWindow, "key-press-event", G_CALLBACK(signalKey), pDocView);
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 7ab7f09..2adc23e 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1086,6 +1086,7 @@ enum
     COMMAND_CHANGED,
     SEARCH_NOT_FOUND,
     PART_CHANGED,
+    SIZE_CHANGED,
     LAST_SIGNAL
 };
 
@@ -1151,6 +1152,16 @@ static void lok_docview_class_init( gpointer ptr )
                      g_cclosure_marshal_VOID__INT,
                      G_TYPE_NONE, 1,
                      G_TYPE_INT);
+    pClass->size_changed = 0;
+    docview_signals[SIZE_CHANGED] =
+        g_signal_new("size-changed",
+                     G_TYPE_FROM_CLASS(gobject_class),
+                     G_SIGNAL_RUN_FIRST,
+                     G_STRUCT_OFFSET(LOKDocViewClass, size_changed),
+                     NULL, NULL,
+                     g_cclosure_marshal_VOID__VOID,
+                     G_TYPE_NONE, 1,
+                     G_TYPE_INT);
 }
 
 static void lok_docview_init( GTypeInstance* pInstance, gpointer )
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index c90a852..9f0b03b 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -407,6 +407,14 @@ public:
                             long nTileHeight ) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::getDocumentSize().
     virtual Size getDocumentSize() SAL_OVERRIDE;
+    /// @see vcl::ITiledRenderable::setPart().
+    virtual void setPart(int nPart) SAL_OVERRIDE;
+    /// @see vcl::ITiledRenderable::getParts().
+    virtual int getParts() SAL_OVERRIDE;
+    /// @see vcl::ITiledRenderable::getPart().
+    virtual int getPart() SAL_OVERRIDE;
+    /// @see vcl::ITiledRenderable::getPartName().
+    virtual OUString getPartName(int nPart) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::initializeForTiledRendering().
     virtual void initializeForTiledRendering() SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::registerCallback().
diff --git a/sw/inc/viscrs.hxx b/sw/inc/viscrs.hxx
index 159fb2f..525b551 100644
--- a/sw/inc/viscrs.hxx
+++ b/sw/inc/viscrs.hxx
@@ -43,6 +43,9 @@ class SwVisCrsr
     vcl::Cursor m_aTextCrsr;
     const SwCrsrShell* m_pCrsrShell;
 
+    /// For LibreOfficeKit only - remember what page we were at the last time.
+    sal_uInt16 m_nPageLastTime;
+
     void _SetPosAndShow();
 
 public:
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index c3d591c..03c25f1 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -67,6 +67,7 @@ MapMode* SwSelPaintRects::s_pMapMode = 0;
 // Starting from here: classes / methods for the non-text-cursor
 SwVisCrsr::SwVisCrsr( const SwCrsrShell * pCShell )
     : m_pCrsrShell( pCShell )
+    , m_nPageLastTime(0)
 {
     pCShell->GetWin()->SetCursor( &m_aTextCrsr );
     m_bIsVisible = m_aTextCrsr.IsVisible();
@@ -179,6 +180,17 @@ void SwVisCrsr::_SetPosAndShow()
 
     if (m_pCrsrShell->isTiledRendering())
     {
+        // notify about page number change (if that happened)
+        sal_uInt16 nPage, nVirtPage;
+        const_cast<SwCrsrShell*>(m_pCrsrShell)->GetPageNum(nPage, nVirtPage);
+        if (nPage != m_nPageLastTime)
+        {
+            m_nPageLastTime = nPage;
+            OString aPayload = OString::number(nPage - 1);
+            m_pCrsrShell->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
+        }
+
+        // notify about the cursor position & size
         Rectangle aSVRect(aRect.Pos().getX(), aRect.Pos().getY(), aRect.Pos().getX() + aRect.SSize().Width(), aRect.Pos().getY() + aRect.SSize().Height());
         OString sRect = aSVRect.toString();
         m_pCrsrShell->libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index b7cdf1d..cf9f257 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3151,6 +3151,50 @@ Size SwXTextDocument::getDocumentSize()
                 aDocSize.Height() + 2L * DOCUMENTBORDER);
 }
 
+void SwXTextDocument::setPart(int nPart)
+{
+    SolarMutexGuard aGuard;
+
+    SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+    if (!pWrtShell)
+        return;
+
+    pWrtShell->GotoPage(nPart + 1, true);
+}
+
+int SwXTextDocument::getParts()
+{
+    SolarMutexGuard aGuard;
+
+    SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+    if (!pWrtShell)
+        return 0;
+
+    return pWrtShell->GetPageCnt();
+}
+
+int SwXTextDocument::getPart()
+{
+    SolarMutexGuard aGuard;
+
+    SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+    if (!pWrtShell)
+        return 0;
+
+    sal_uInt16 nPage, nLogPage;
+    OUString sDisplay;
+    pWrtShell->GetPageNumber(-1, pWrtShell->IsCrsrVisible(), nPage, nLogPage, sDisplay);
+
+    return nPage - 1;
+}
+
+OUString SwXTextDocument::getPartName(int nPart)
+{
+    SolarMutexGuard aGuard;
+
+    return OUString(SW_RES(STR_PAGE)) + OUString::number(nPart + 1);
+}
+
 void SwXTextDocument::initializeForTiledRendering()
 {
     SolarMutexGuard aGuard;
commit ef6d95bc75b06573bf5342933b1ac35aada5dbc8
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Wed Jul 22 16:21:08 2015 +0300

    tiledrendering: added getPartName method for calc
    
    This method is used to get the sheet's name and to display it
    in the tabs (sheet selector)
    I've also added an unit test for it and uncommented a similar one
    
    Change-Id: Ia866815c594a873812c71a6c86e303c869e1f093
    Reviewed-on: https://gerrit.libreoffice.org/17294
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/libreofficekit/qa/data/calc_sheetnames.ods b/libreofficekit/qa/data/calc_sheetnames.ods
new file mode 100644
index 0000000..f6627a0
Binary files /dev/null and b/libreofficekit/qa/data/calc_sheetnames.ods differ
diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx
index 63eb756..fb2f741 100644
--- a/libreofficekit/qa/unit/tiledrendering.cxx
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
@@ -65,8 +65,9 @@ public:
 
     void testDocumentLoadFail( Office* pOffice );
     void testDocumentTypes( Office* pOffice );
-#if 0
     void testImpressSlideNames( Office* pOffice );
+    void testCalcSheetNames( Office* pOffice );
+#if 0
     void testOverlay( Office* pOffice );
 #endif
 
@@ -90,8 +91,9 @@ void TiledRenderingTest::runAllTests()
 
     testDocumentLoadFail( pOffice.get() );
     testDocumentTypes( pOffice.get() );
-#if 0
     testImpressSlideNames( pOffice.get() );
+    testCalcSheetNames( pOffice.get() );
+#if 0
     testOverlay( pOffice.get() );
 #endif
 }
@@ -142,7 +144,6 @@ void TiledRenderingTest::testDocumentTypes( Office* pOffice )
     // TODO: do this for all supported document types
 }
 
-#if 0
 void TiledRenderingTest::testImpressSlideNames( Office* pOffice )
 {
     const string sDocPath = m_sSrcRoot + "/libreofficekit/qa/data/impress_slidenames.odp";
@@ -164,6 +165,23 @@ void TiledRenderingTest::testImpressSlideNames( Office* pOffice )
     // have a localised version of "Slide 3".
 }
 
+void TiledRenderingTest::testCalcSheetNames( Office* pOffice )
+{
+    const string sDocPath = m_sSrcRoot + "/libreofficekit/qa/data/calc_sheetnames.ods";
+    const string sLockFile = m_sSrcRoot +"/libreofficekit/qa/data/.~lock.calc_sheetnames.ods#";
+
+    // FIXME: LOK will fail when trying to open a locked file
+    remove( sLockFile.c_str() );
+
+    scoped_ptr< Document> pDocument( pOffice->documentLoad( sDocPath.c_str() ) );
+
+    CPPUNIT_ASSERT( pDocument->getParts() == 3 );
+    CPPUNIT_ASSERT( strcmp( pDocument->getPartName( 0 ), "TestText1" ) == 0 );
+    CPPUNIT_ASSERT( strcmp( pDocument->getPartName( 1 ), "TestText2" ) == 0 );
+    CPPUNIT_ASSERT( strcmp( pDocument->getPartName( 2 ), "Sheet3" ) == 0 );
+}
+
+#if 0
 static void dumpRGBABitmap( const OUString& rPath, const unsigned char* pBuffer,
                             const int nWidth, const int nHeight )
 {
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index a7e9af5..cd68885 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -388,6 +388,9 @@ public:
     /// @see vcl::ITiledRenderable::getParts().
     virtual int getParts() SAL_OVERRIDE;
 
+    /// @see vcl::ITiledRenderable::getPartName().
+    virtual OUString getPartName(int nPart) SAL_OVERRIDE;
+
     /// @see vcl::ITiledRenderable::initializeForTiledRendering().
     virtual void initializeForTiledRendering() SAL_OVERRIDE;
 
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 5375176..69a5c65 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -510,6 +510,14 @@ int ScModelObj::getPart()
     return pViewData->GetTabNo();
 }
 
+OUString ScModelObj::getPartName( int nPart )
+{
+    OUString sTabName;
+    ScViewData* pViewData = ScDocShell::GetViewData();
+    pViewData->GetDocument()->GetName(nPart, sTabName);
+    return sTabName;
+}
+
 Size ScModelObj::getDocumentSize()
 {
     Size aSize(10, 10); // minimum size
commit 82436291303dacfb3e9ea2f41c53eb057df9ee30
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Jul 6 15:16:56 2015 +0200

    LOK: Cleanup absolutizing of URLs.
    
    Thanks to Stephan Bergmann.
    
    Change-Id: I22aa3bb827db28bce3eabebb9b8c514663fad860

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 1457e0f..48727d3 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -26,8 +26,9 @@
 #include <osl/file.hxx>
 #include <osl/process.h>
 #include <osl/thread.h>
-#include <rtl/strbuf.hxx>
 #include <rtl/bootstrap.hxx>
+#include <rtl/strbuf.hxx>
+#include <rtl/uri.hxx>
 #include <cppuhelper/bootstrap.hxx>
 #include <comphelper/dispatchcommand.hxx>
 #include <comphelper/lok.hxx>
@@ -165,19 +166,21 @@ static OUString getUString(const char* pString)
 static OUString getAbsoluteURL(const char* pURL)
 {
     OUString aURL(getUString(pURL));
-
-    // return unchanged if it likely is an URL already
-    if (aURL.indexOf("://") > 0)
+    if (aURL.isEmpty())
         return aURL;
 
-    OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl;
-
     // convert relative paths to absolute ones
-    osl_getProcessWorkingDir(&sWorkingDir.pData);
-    osl::FileBase::getFileURLFromSystemPath( aURL, sDocPathUrl );
-    osl::FileBase::getAbsoluteFileURL(sWorkingDir, sDocPathUrl, sAbsoluteDocUrl);
+    OUString aWorkingDir;
+    osl_getProcessWorkingDir(&aWorkingDir.pData);
+
+    try {
+        return rtl::Uri::convertRelToAbs(aWorkingDir + "/", aURL);
+    }
+    catch (const rtl::MalformedUriException &)
+    {
+    }
 
-    return sAbsoluteDocUrl;
+    return OUString();
 }
 
 extern "C"
@@ -349,6 +352,12 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
     SolarMutexGuard aGuard;
 
     OUString aURL(getAbsoluteURL(pURL));
+    if (aURL.isEmpty())
+    {
+        pLib->maLastExceptionMsg = "Filename to load was not provided.";
+        SAL_INFO("lok", "URL for load is empty");
+        return NULL;
+    }
 
     pLib->maLastExceptionMsg.clear();
 
@@ -415,6 +424,12 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha
 
     OUString sFormat = getUString(pFormat);
     OUString aURL(getAbsoluteURL(sUrl));
+    if (aURL.isEmpty())
+    {
+        gImpl->maLastExceptionMsg = "Filename to save to was not provided.";
+        SAL_INFO("lok", "URL for save is empty");
+        return false;
+    }
 
     try
     {


More information about the Libreoffice-commits mailing list