[Libreoffice-commits] .: 2 commits - sw/inc sw/Library_sw.mk sw/sdi sw/source sw/uiconfig

Tor Lillqvist tml at kemper.freedesktop.org
Fri May 25 00:01:04 PDT 2012


 sw/Library_sw.mk                            |    1 
 sw/inc/cmdid.h                              |    1 
 sw/sdi/_viewsh.sdi                          |    5 ++++
 sw/sdi/swriter.sdi                          |   25 +++++++++++++++++++++
 sw/sdi/viewsh.sdi                           |   23 ++++++++++++--------
 sw/source/ui/app/app.src                    |   10 ++++++++
 sw/source/ui/app/swmodule.cxx               |    2 +
 sw/source/ui/inc/app.hrc                    |    6 ++++-
 sw/source/ui/inc/wordcountctrl.hxx          |   32 ++++++++++++++++++++++++++++
 sw/source/ui/uiview/view2.cxx               |   32 ++++++++++++++++++++++++++++
 sw/source/ui/utlui/wordcountctrl.cxx        |   26 ++++++++++++++++++++++
 sw/uiconfig/swriter/statusbar/statusbar.xml |    1 
 12 files changed, 154 insertions(+), 10 deletions(-)

New commits:
commit 8ed3a427245a07bb787c521a178cfb421fa46854
Author: Muhammad Haggag <mhaggag at gmail.com>
Date:   Thu May 24 19:49:41 2012 +0200

    Followup to fdo#34772: Add resource strings for word-count messages
    
    Change-Id: I7b32f5b6ed973fd4ad4635a5265d75d4e51f04ba

diff --git a/sw/source/ui/app/app.src b/sw/source/ui/app/app.src
index 890e8b9..3dc412b 100644
--- a/sw/source/ui/app/app.src
+++ b/sw/source/ui/app/app.src
@@ -550,6 +550,16 @@ String STR_OUTLINE_NUMBERING
     Text [ en-US ] = "Outline Numbering";
 };
 
+String STR_STATUSBAR_WORDCOUNT_NO_SELECTION
+{
+    Text [ en-US ] = "Words: $1";
+};
+
+String STR_STATUSBAR_WORDCOUNT
+{
+    Text [ en-US ] = "Words: $1 Selected: $2";
+};
+
 ToolBox RID_MODULE_TOOLBOX
 {
     HelpID = HID_MODULE_TOOLBOX ;
diff --git a/sw/source/ui/inc/app.hrc b/sw/source/ui/inc/app.hrc
index 5de0537..95356a5 100644
--- a/sw/source/ui/inc/app.hrc
+++ b/sw/source/ui/inc/app.hrc
@@ -125,7 +125,11 @@
 #define STR_FDLG_STYLE                  (RC_APP_BEGIN + 106)
 //<-end,zhaojianwei
 
-#define APP_ACT_END                     STR_FDLG_STYLE
+// Status bar strings
+#define STR_STATUSBAR_WORDCOUNT_NO_SELECTION (RC_APP_BEGIN + 110)
+#define STR_STATUSBAR_WORDCOUNT              (RC_APP_BEGIN + 111)
+
+#define APP_ACT_END                     STR_STATUSBAR_WORDCOUNT
 
 #if APP_ACT_END > RC_APP_END
 #error Resource-Id Ueberlauf in #file, #line
diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx
index 9292185..58b5ce4 100644
--- a/sw/source/ui/uiview/view2.cxx
+++ b/sw/source/ui/uiview/view2.cxx
@@ -1210,10 +1210,15 @@ void SwView::StateStatusLine(SfxItemSet &rSet)
                     documentStats = rShell.GetUpdatedDocStat();
                     rShell.EndAction();
                 }
-                rSet.Put(SfxStringItem(FN_STAT_WORDCOUNT, rtl::OUStringBuffer("Words: ")
-                                                            .append(rtl::OUString::valueOf(static_cast<sal_Int64>(selectionStats.nWord)))
-                                                            .append('/')
-                                                            .append(rtl::OUString::valueOf(static_cast<sal_Int64>(documentStats.nWord))).makeStringAndClear()));
+
+                const sal_uInt32 stringId = selectionStats.nWord? STR_STATUSBAR_WORDCOUNT : STR_STATUSBAR_WORDCOUNT_NO_SELECTION;
+                rtl::OUString wordCount(SW_RES(stringId));
+                wordCount = wordCount.replaceAll("$1", rtl::OUString::valueOf(static_cast<sal_Int64>(documentStats.nWord)));
+                if (selectionStats.nWord)
+                {
+                    wordCount = wordCount.replaceAll("$2", rtl::OUString::valueOf(static_cast<sal_Int64>(selectionStats.nWord)));
+                }
+                rSet.Put(SfxStringItem(FN_STAT_WORDCOUNT, wordCount));
             }
             break;
 
commit ce14342c4292628a641a72d4f63d9c048e030c6a
Author: Muhammad Haggag <mhaggag at gmail.com>
Date:   Tue May 22 16:59:37 2012 +0200

    fdo#34772 Add word count to the status bar in writer
    
    This change adds a new status bar control,
    "SwWordCountStatusBarControl". The control shows the number of words
    selected as well as the number of words in the whole
    document. Double-clicking the control launches the modeless word count
    dialog.
    
    Change-Id: I756183ab1aaf4d059e782dfb05508370178cfbe3

diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 45975a0..1ddc142 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -708,6 +708,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/ui/utlui/uitool \
     sw/source/ui/utlui/unotools \
     sw/source/ui/utlui/viewlayoutctrl \
+    sw/source/ui/utlui/wordcountctrl \
     sw/source/ui/utlui/zoomctrl \
     sw/source/ui/web/wdocsh \
     sw/source/ui/web/wformsh \
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 7802db7..ca5a872 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -1165,6 +1165,7 @@ included in c-context files, so c++ style stuff will cause problems.
 #define FN_STAT_SELMODE             (FN_STAT + 5)
 #define FN_STAT_CONTEXT             (FN_STAT + 7)
 #define FN_STAT_BOOKMARK            (FN_STAT + 8)  /* For Popup Bookmarks*/
+#define FN_STAT_WORDCOUNT           (FN_STAT + 9)
 
 /*--------------------------------------------------------------------
     Region: Page preview
diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi
index a17fbb8..d4486af 100644
--- a/sw/sdi/_viewsh.sdi
+++ b/sw/sdi/_viewsh.sdi
@@ -317,6 +317,11 @@ interface BaseTextEditView
         ExecMethod = ExecuteStatusLine ;
         StateMethod = StateStatusLine ;
     ]
+    FN_STAT_WORDCOUNT // status()
+    [
+        ExecMethod = ExecuteStatusLine ;
+        StateMethod = StateStatusLine ;
+    ]
     FN_STAT_BOOKMARK // status()
     [
         ExecMethod = ExecuteStatusLine ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index edb7809..89e1530 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -8027,6 +8027,31 @@ SfxStringItem StateZoom FN_STAT_ZOOM
 ]
 
 //--------------------------------------------------------------------------
+SfxStringItem StateWordCount FN_STAT_WORDCOUNT
+()
+[
+    /* flags: */
+    AutoUpdate = FALSE,
+    Cachable = Cachable,
+    FastCall = FALSE,
+    HasCoreId = FALSE,
+    HasDialog = FALSE,
+    ReadOnlyDoc = TRUE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Synchron;
+
+    /* config: */
+    AccelConfig = FALSE,
+    MenuConfig = FALSE,
+    StatusBarConfig = TRUE,
+    ToolBoxConfig = FALSE,
+    GroupId = GID_VIEW;
+]
+
+//--------------------------------------------------------------------------
 SfxBoolItem SubScript FN_SET_SUB_SCRIPT
 
 [
diff --git a/sw/sdi/viewsh.sdi b/sw/sdi/viewsh.sdi
index 1005c96..d5d8380 100644
--- a/sw/sdi/viewsh.sdi
+++ b/sw/sdi/viewsh.sdi
@@ -275,8 +275,8 @@ interface TextPrintPreview
     [
         StateMethod = StateUndo ;
     ]
-     //---------------------------------------------------------------------
-     //Ab hier Statusleiste
+    //---------------------------------------------------------------------
+    // Begin StatusBar
     FN_STAT_ZOOM // status()
     [
         ExecMethod = Execute ;
@@ -307,13 +307,18 @@ interface TextPrintPreview
         ExecMethod = Execute ;
         StateMethod = GetState ;
     ]
-        SID_ATTR_ZOOMSLIDER // status()
-        [
-                ExecMethod = Execute ;
-                StateMethod = GetState ;
-        ]
-     //----------------------------------------------
-     //End mit Statusleiste
+    SID_ATTR_ZOOMSLIDER // status()
+    [
+            ExecMethod = Execute ;
+            StateMethod = GetState ;
+    ]
+    FN_STAT_WORDCOUNT // status()
+    [
+        ExecMethod = Execute ;
+        StateMethod = GetState ;
+    ]
+    //----------------------------------------------
+    // End StatusBar
 }
 
  //=========================================================================
diff --git a/sw/source/ui/app/swmodule.cxx b/sw/source/ui/app/swmodule.cxx
index 03bb5a2..4c97524 100644
--- a/sw/source/ui/app/swmodule.cxx
+++ b/sw/source/ui/app/swmodule.cxx
@@ -107,6 +107,7 @@
 #include <svx/zoomsliderctrl.hxx>
 #include <tblctrl.hxx>
 #include <zoomctrl.hxx>
+#include <wordcountctrl.hxx>
 #include <workctrl.hxx>
 #include <tbxanchr.hxx>
 #include <fldwrap.hxx>
@@ -372,6 +373,7 @@ void SwDLL::RegisterControls()
     SvxInsertStatusBarControl::RegisterControl(SID_ATTR_INSERT, pMod );
     SvxSelectionModeControl::RegisterControl(FN_STAT_SELMODE, pMod );
     XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod );
+    SwWordCountStatusBarControl::RegisterControl(FN_STAT_WORDCOUNT, pMod);
 
     SwBookmarkControl::RegisterControl(FN_STAT_PAGE, pMod );
     SwTemplateControl::RegisterControl(FN_STAT_TEMPLATE, pMod );
diff --git a/sw/source/ui/inc/wordcountctrl.hxx b/sw/source/ui/inc/wordcountctrl.hxx
new file mode 100644
index 0000000..d62652f
--- /dev/null
+++ b/sw/source/ui/inc/wordcountctrl.hxx
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * 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 _WORDCOUNTCTRL_HXX
+#define _WORDCOUNTCTRL_HXX
+
+#include <sfx2/stbitem.hxx>
+
+/**
+Word count status bar control for Writer.
+
+ at remarks This is a simple status bar control of type SfxStringItem, and it has no custom
+logic whatsoever. The actual updating of the word count string happens in
+SwView::StateStatusLine (see sw/source/ui/uiview/view2.cxx).
+*/
+class SwWordCountStatusBarControl : public SfxStatusBarControl
+{
+public:
+    SFX_DECL_STATUSBAR_CONTROL();
+
+    SwWordCountStatusBarControl(sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb);
+    ~SwWordCountStatusBarControl();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx
index febc076..9292185 100644
--- a/sw/source/ui/uiview/view2.cxx
+++ b/sw/source/ui/uiview/view2.cxx
@@ -140,6 +140,7 @@
 #include <fmthdft.hxx>
 #include <svx/ofaitem.hxx>
 #include <unomid.h>
+#include <docstat.hxx>
 
 const char sStatusDelim[] = " : ";
 const char sStatusComma[] = " , ";//#outlinelevel, define a Variable for "," add by zhaojianwei
@@ -1197,6 +1198,25 @@ void SwView::StateStatusLine(SfxItemSet &rSet)
                 }
             }
             break;
+
+            case FN_STAT_WORDCOUNT:
+            {
+                SwDocStat selectionStats;
+                SwDocStat documentStats;
+                {
+                    SwWait aWait( *GetDocShell(), sal_True );
+                    rShell.StartAction();
+                    rShell.CountWords(selectionStats);
+                    documentStats = rShell.GetUpdatedDocStat();
+                    rShell.EndAction();
+                }
+                rSet.Put(SfxStringItem(FN_STAT_WORDCOUNT, rtl::OUStringBuffer("Words: ")
+                                                            .append(rtl::OUString::valueOf(static_cast<sal_Int64>(selectionStats.nWord)))
+                                                            .append('/')
+                                                            .append(rtl::OUString::valueOf(static_cast<sal_Int64>(documentStats.nWord))).makeStringAndClear()));
+            }
+            break;
+
             case FN_STAT_TEMPLATE:
             {
                 rSet.Put(SfxStringItem( FN_STAT_TEMPLATE,
@@ -1471,6 +1491,13 @@ void SwView::ExecuteStatusLine(SfxRequest &rReq)
         }
         break;
 
+        case FN_STAT_WORDCOUNT:
+        {
+            GetViewFrame()->GetDispatcher()->Execute(FN_WORDCOUNT_DIALOG,
+                                      SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
+        }
+        break;
+
         case FN_STAT_BOOKMARK:
         if ( pArgs )
         {
diff --git a/sw/source/ui/utlui/wordcountctrl.cxx b/sw/source/ui/utlui/wordcountctrl.cxx
new file mode 100644
index 0000000..a0146d0
--- /dev/null
+++ b/sw/source/ui/utlui/wordcountctrl.cxx
@@ -0,0 +1,26 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * 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 "wordcountctrl.hxx"
+#include <svl/stritem.hxx>
+
+SFX_IMPL_STATUSBAR_CONTROL(SwWordCountStatusBarControl, SfxStringItem);
+
+SwWordCountStatusBarControl::SwWordCountStatusBarControl(
+        sal_uInt16 _nSlotId,
+        sal_uInt16 _nId,
+        StatusBar& rStb) :
+    SfxStatusBarControl(_nSlotId, _nId, rStb)
+{
+}
+
+SwWordCountStatusBarControl::~SwWordCountStatusBarControl()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/uiconfig/swriter/statusbar/statusbar.xml b/sw/uiconfig/swriter/statusbar/statusbar.xml
index 87b3edd..d5e2271 100644
--- a/sw/uiconfig/swriter/statusbar/statusbar.xml
+++ b/sw/uiconfig/swriter/statusbar/statusbar.xml
@@ -2,6 +2,7 @@
 <!DOCTYPE statusbar:statusbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "statusbar.dtd">
 <statusbar:statusbar xmlns:statusbar="http://openoffice.org/2001/statusbar" xmlns:xlink="http://www.w3.org/1999/xlink">
  <statusbar:statusbaritem xlink:href=".uno:StatePageNumber" statusbar:align="left" statusbar:autosize="true" statusbar:width="54" statusbar:helpid="helpid:21181"/>
+ <statusbar:statusbaritem xlink:href=".uno:StateWordCount" statusbar:align="left" statusbar:autosize="true" statusbar:helpid="helpid:21184"/>
  <statusbar:statusbaritem xlink:href=".uno:PageStyleName" statusbar:align="left" statusbar:autosize="true" statusbar:width="79" statusbar:helpid="helpid:21182"/>
  <statusbar:statusbaritem xlink:href=".uno:LanguageStatus" statusbar:align="center" statusbar:autosize="true" statusbar:width="100" />
  <statusbar:statusbaritem xlink:href=".uno:InsertMode" statusbar:align="center" statusbar:width="55" statusbar:helpid="helpid:10221"/>


More information about the Libreoffice-commits mailing list