[Libreoffice-commits] core.git: 2 commits - framework/source libreofficekit/qa libreofficekit/source sw/inc sw/source

Jan Holesovsky kendy at collabora.com
Fri Jul 31 17:24:21 PDT 2015


 framework/source/fwe/xml/statusbardocumenthandler.cxx |   16 +++---
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx   |    8 +++
 libreofficekit/source/gtk/lokdocview.cxx              |   18 +++++++
 sw/inc/unotxdoc.hxx                                   |    8 +++
 sw/inc/viscrs.hxx                                     |    3 +
 sw/source/core/crsr/viscrs.cxx                        |   12 ++++
 sw/source/uibase/uno/unotxdoc.cxx                     |   44 ++++++++++++++++++
 7 files changed, 101 insertions(+), 8 deletions(-)

New commits:
commit 512b782cf466a19ed77d818fa660e1a0dc74fc35
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.
    
    Change-Id: I56b3264e0340cd639bdabfa92b74b52bd1f391a5

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 46d3176..73db976 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -359,6 +359,13 @@ static void populatePartSelector()
                               lok_doc_view_get_part( LOK_DOC_VIEW(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) );
@@ -567,6 +574,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);
     g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), NULL);
 
 
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index d13fb9b..b864d6f 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -114,6 +114,7 @@ enum
     COMMAND_CHANGED,
     SEARCH_NOT_FOUND,
     PART_CHANGED,
+    SIZE_CHANGED,
     HYPERLINK_CLICKED,
 
     LAST_SIGNAL
@@ -581,6 +582,8 @@ callback (gpointer pData)
         gtk_widget_set_size_request(GTK_WIDGET(pDocView),
                                     twipToPixel(priv->m_nDocumentWidthTwips, priv->m_fZoom),
                                     twipToPixel(priv->m_nDocumentHeightTwips, priv->m_fZoom));
+
+        g_signal_emit(pDocView, doc_view_signals[SIZE_CHANGED], 0, NULL);
     }
     break;
     case LOK_CALLBACK_SET_PART:
@@ -1707,6 +1710,21 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
                      G_TYPE_INT);
 
     /**
+     * LOKDocView::size-changed:
+     * @pDocView: the #LOKDocView on which the signal is emitted
+     * @aCommand: NULL, we just notify that want to notify the UI elements that are interested.
+     */
+    doc_view_signals[SIZE_CHANGED] =
+        g_signal_new("size-changed",
+                     G_TYPE_FROM_CLASS(pGObjectClass),
+                     G_SIGNAL_RUN_FIRST,
+                     0,
+                     NULL, NULL,
+                     g_cclosure_marshal_VOID__VOID,
+                     G_TYPE_NONE, 1,
+                     G_TYPE_INT);
+
+    /**
      * LOKDocView::hyperlinked-clicked:
      * @pDocView: the #LOKDocView on which the signal is emitted
      * @aHyperlink: the URI which the application should handle
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 5627523..612ea7c 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -406,6 +406,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 44805c6..6ff4596 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 d453ad8..aceb6f4 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3152,6 +3152,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 75a84417af72ce0f540e7a5063a81a1e57a5c6a1
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Sat Aug 1 00:38:47 2015 +0200

    Whitespace.
    
    Change-Id: Ifcccd6376a6a44bf6761e9fa451b46933adb6ce9

diff --git a/framework/source/fwe/xml/statusbardocumenthandler.cxx b/framework/source/fwe/xml/statusbardocumenthandler.cxx
index cea1e3b..ff10d02 100644
--- a/framework/source/fwe/xml/statusbardocumenthandler.cxx
+++ b/framework/source/fwe/xml/statusbardocumenthandler.cxx
@@ -352,14 +352,14 @@ throw(  SAXException, RuntimeException, std::exception )
                             }
                             break;
 
-                                          case SB_ATTRIBUTE_HELPURL:
-                                          {
-                                                aHelpURL = xAttribs->getValueByIndex( n );
-                                          }
-                                          break;
-
-                                          default:
-                                              break;
+                            case SB_ATTRIBUTE_HELPURL:
+                            {
+                                aHelpURL = xAttribs->getValueByIndex( n );
+                            }
+                            break;
+
+                            default:
+                                break;
                         }
                     }
                 } // for


More information about the Libreoffice-commits mailing list