Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hey everyone,

I've been meaning to do an easy hack ever since LibreOffice announced. Not to get to political, but recently AOOo and the efforts of it's backers has riled me up enough to push through the build issues I was having and put my money (time) where my mouth is.

I've followed Michael Meek's blog over the years via planet GNOME, but this post struck a chord with me:

http://mail-archives.apache.org/mod_mbox/incubator-ooo-dev/201110.mbox/%3C1319628345.22078.111.camel%40linux-yjtf.site%3E

So here I am with me first contribution.

I was thinking of an easy hack, but I had to submit a brief summary recently where word count was limited and it was a pain to have to continuously open the word count dialog.

I couldn't find a LO bug on this, but there is an OOo one from 2005:

http://openoffice.org/bugzilla/show_bug.cgi?id=46785

I thought it would be easier than it turned out to be, and expect some changes may need to be made, but here it is, a fix for a 6 year old bug.

Patch licensed under LGPLv3+/MPL.

Thanks!
From e55b1ebaf7c21bcf532e571717626be2eebfb8cf Mon Sep 17 00:00:00 2001
From: Matt Pratt <mattpratt.au@gmail.com>
Date: Tue, 1 Nov 2011 22:47:33 -0600
Subject: [PATCH] Word count dialog modeless

---
 sw/Library_sw.mk                         |    1 +
 sw/inc/swabstdlg.hxx                     |   12 ++++-
 sw/source/ui/app/swmodule.cxx            |    2 +
 sw/source/ui/dialog/swdlgfact.cxx        |   45 +++++++++++++++------
 sw/source/ui/dialog/swdlgfact.hxx        |   15 +++++--
 sw/source/ui/dialog/wordcountdialog.cxx  |   56 +++++++++++++++++++++++++-
 sw/source/ui/dialog/wordcountdialog.hrc  |    1 +
 sw/source/ui/dialog/wordcountdialog.src  |   12 +++++-
 sw/source/ui/dialog/wordcountwrapper.cxx |   64 ++++++++++++++++++++++++++++++
 sw/source/ui/docvw/edtwin.cxx            |   16 +++++++
 sw/source/ui/inc/wordcountdialog.hxx     |   38 +++++++++++++++++-
 sw/source/ui/shells/annotsh.cxx          |   23 ++++-------
 sw/source/ui/shells/drawsh.cxx           |   22 ++++------
 sw/source/ui/shells/drwtxtex.cxx         |   22 ++++------
 sw/source/ui/shells/frmsh.cxx            |   22 ++++------
 sw/source/ui/shells/textsh.cxx           |    1 +
 sw/source/ui/shells/textsh1.cxx          |   24 ++++-------
 17 files changed, 280 insertions(+), 96 deletions(-)
 create mode 100644 sw/source/ui/dialog/wordcountwrapper.cxx

diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index b2ce776..a8ee383 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -615,6 +615,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/ui/frmdlg/frmmgr \
     sw/source/ui/globdoc/globdoc \
     sw/source/ui/index/idxmrk \
+    sw/source/ui/dialog/wordcountwrapper \
     sw/source/ui/index/toxmgr \
     sw/source/ui/lingu/hhcwrp \
     sw/source/ui/lingu/hyp \
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index b928169..a8fc6ef 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -200,10 +200,11 @@ public:
     virtual void     SetSectionData(SwSectionData const& rSect) = 0;
 };
 
-class AbstractSwWordCountDialog : public VclAbstractDialog
+class AbstractSwWordCountFloatDlg : public VclAbstractDialog
 {
 public:
-    virtual void    SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc) = 0;
+    virtual void        UpdateCounts() = 0;
+    virtual Window *    GetWindow() = 0; //this method is added for return a Window type pointer
 };
 
 class AbstractSwInsertAbstractDlg : public VclAbstractDialog    // add for SwInsertAbstractDlg
@@ -353,7 +354,12 @@ public:
                                     const ::com::sun::star::uno::Reference< 
::com::sun::star::frame::XFrame >& _rxFrame,
                                                                         sal_uInt32 nResId
                                                                         ) = 0;
-    virtual AbstractSwWordCountDialog* CreateSwWordCountDialog( Window* pWindow ) = 0;
+    virtual AbstractSwWordCountFloatDlg* CreateSwWordCountDialog(int nResId,
+                                                    SfxBindings* pBindings,
+                                                       SfxChildWindow* pChild,
+                                                       Window *pParent,
+                                                    SfxChildWinInfo* pInfo) = 0;
+
     virtual AbstractSwInsertAbstractDlg * CreateSwInsertAbstractDlg ( Window* pParent, int nResId) 
= 0; // add for SwInsertAbstractDlg
     virtual AbstractSwAsciiFilterDlg*  CreateSwAsciiFilterDlg ( Window* pParent, SwDocShell& 
rDocSh,
                                                                 SvStream* pStream, int nResId ) = 
0;// add for SwAsciiFilterDlg
diff --git a/sw/source/ui/app/swmodule.cxx b/sw/source/ui/app/swmodule.cxx
index 4a66362..e1bdf64 100644
--- a/sw/source/ui/app/swmodule.cxx
+++ b/sw/source/ui/app/swmodule.cxx
@@ -122,6 +122,7 @@
 #include <sfx2/appuno.hxx>
 #include <swatrset.hxx>
 #include <idxmrk.hxx>
+#include <wordcountdialog.hxx>
 #include <dlelstnr.hxx>
 #include <barcfg.hxx>
 #include <svx/rubydialog.hxx>
@@ -397,6 +398,7 @@ void SwDLL::RegisterControls()
     SwMailMergeChildWindow::RegisterChildWindow( sal_False, pMod );
     SwInsertIdxMarkWrapper::RegisterChildWindow( sal_False, pMod );
     SwInsertAuthMarkWrapper::RegisterChildWindow( sal_False, pMod );
+    SwWordCountWrapper::RegisterChildWindow( sal_False, pMod );
     SvxRubyChildWindow::RegisterChildWindow( sal_False, pMod);
     SwSpellDialogChildWindow::RegisterChildWindow(sal_False, pMod);
 
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index 1b5f9ad..c552833 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -112,7 +112,7 @@
 
 using namespace ::com::sun::star;
 
-IMPL_ABSTDLG_BASE(AbstractSwWordCountDialog_Impl);
+IMPL_ABSTDLG_BASE(AbstractSwWordCountFloatDlg_Impl);
 IMPL_ABSTDLG_BASE(AbstractSwInsertAbstractDlg_Impl);
 IMPL_ABSTDLG_BASE(AbstractSfxDialog_Impl);
 IMPL_ABSTDLG_BASE(AbstractSwAsciiFilterDlg_Impl);
@@ -175,11 +175,6 @@ String AbstractTabDialog_Impl::GetText() const
     return pDlg->GetText();
 }
 
-void    AbstractSwWordCountDialog_Impl::SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc)
-{
-    pDlg->SetValues(rCurrent, rDoc);
-}
-
 sal_uInt8 AbstractSwInsertAbstractDlg_Impl::GetLevel() const
 {
     return pDlg->GetLevel();
@@ -572,6 +567,18 @@ Window* AbstractAuthMarkFloatDlg_Impl::GetWindow()
     return (Window*)pDlg;
 }
 
+
+Window* AbstractSwWordCountFloatDlg_Impl::GetWindow()
+{
+    return (Window*)pDlg;
+}
+
+void AbstractSwWordCountFloatDlg_Impl::UpdateCounts()
+{
+    pDlg->UpdateCounts();
+}
+
+
 AbstractMailMergeWizard_Impl::~AbstractMailMergeWizard_Impl()
 {
     delete pDlg;
@@ -624,12 +631,6 @@ sal_uInt16 AbstractMailMergeWizard_Impl::GetRestartPage() const
     return pDlg->GetRestartPage();
 }
 
-AbstractSwWordCountDialog* SwAbstractDialogFactory_Impl::CreateSwWordCountDialog(Window* pParent)
-{
-    SwWordCountDialog* pDlg = new SwWordCountDialog( pParent );
-    return new AbstractSwWordCountDialog_Impl( pDlg );
-}
-
 AbstractSwInsertAbstractDlg * SwAbstractDialogFactory_Impl::CreateSwInsertAbstractDlg( Window* 
pParent,
                                                                                       int nResId )
 {
@@ -1546,6 +1547,26 @@ AbstractMarkFloatDlg * SwAbstractDialogFactory_Impl::CreateAuthMarkFloatDlg( 
int
     return 0;
 }
 
+AbstractSwWordCountFloatDlg * SwAbstractDialogFactory_Impl::CreateSwWordCountDialog( int nResId,
+                                                                              SfxBindings* 
pBindings,
+                                                                              SfxChildWindow* 
pChild,
+                                                                              Window *pParent,
+                                                                              SfxChildWinInfo* 
pInfo )
+{
+    SwWordCountFloatDlg* pDlg=NULL;
+    switch ( nResId )
+    {
+        case DLG_WORDCOUNT :
+            pDlg = new SwWordCountFloatDlg( pBindings, pChild, pParent, pInfo );
+            break;
+        default:
+            break;
+    }
+    if ( pDlg )
+        return new AbstractSwWordCountFloatDlg_Impl( pDlg );
+    return 0;
+}
+
 //add for SwIndexMarkModalDlg begin
 VclAbstractDialog * SwAbstractDialogFactory_Impl::CreateIndexMarkModalDlg( int nResId,
                                                 Window *pParent, SwWrtShell& rSh, SwTOXMark* 
pCurTOXMark ) //add for SwIndexMarkModalDlg
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index e13ccfd..bb3a046 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -76,11 +76,12 @@ short Class::Execute()                             \
     return pDlg->Execute();                         \
 }
 
-
-class AbstractSwWordCountDialog_Impl : public AbstractSwWordCountDialog
+class SwWordCountFloatDlg;
+class AbstractSwWordCountFloatDlg_Impl : public AbstractSwWordCountFloatDlg
 {
-    DECL_ABSTDLG_BASE(AbstractSwWordCountDialog_Impl,SwWordCountDialog)
-    void    SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc);
+    DECL_ABSTDLG_BASE(AbstractSwWordCountFloatDlg_Impl,SwWordCountFloatDlg)
+    virtual void                UpdateCounts();
+    virtual Window *            GetWindow(); //this method is added for return a Window type 
pointer
 };
 
 //add for SwInsertAbstractDlg begin
@@ -437,7 +438,11 @@ public:
                                     const ::com::sun::star::uno::Reference< 
::com::sun::star::frame::XFrame >& _rxFrame,
                                                                         sal_uInt32 nResId
                                                                         );
-    virtual AbstractSwWordCountDialog* CreateSwWordCountDialog(Window* pParent);
+    virtual AbstractSwWordCountFloatDlg* CreateSwWordCountDialog(int nResId,
+                                                    SfxBindings* pBindings,
+                                                       SfxChildWindow* pChild,
+                                                       Window *pParent,
+                                                    SfxChildWinInfo* pInfo);
     virtual AbstractSwInsertAbstractDlg * CreateSwInsertAbstractDlg( Window* pParent,int nResId );
     virtual AbstractSwAsciiFilterDlg*  CreateSwAsciiFilterDlg ( Window* pParent, SwDocShell& 
rDocSh,
                                                                 SvStream* pStream, int nResId ); 
//add for SwAsciiFilterDlg
diff --git a/sw/source/ui/dialog/wordcountdialog.cxx b/sw/source/ui/dialog/wordcountdialog.cxx
index 4a98a4e..2ff37ed 100644
--- a/sw/source/ui/dialog/wordcountdialog.cxx
+++ b/sw/source/ui/dialog/wordcountdialog.cxx
@@ -34,10 +34,16 @@
 #include <swtypes.hxx>
 #include <wordcountdialog.hxx>
 #include <docstat.hxx>
-
 #include <dialog.hrc>
 #include <layout/layout-pre.hxx>
 #include <wordcountdialog.hrc>
+#include <cmdid.h>
+#include "vcl/msgbox.hxx" // RET_CANCEL
+#include <swmodule.hxx>
+#include <wview.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <swwait.hxx>
+#include <wrtsh.hxx>
 
 #if ENABLE_LAYOUT
 #undef SW_RES
@@ -49,7 +55,7 @@
 #endif /* ENABLE_LAYOUT */
 
 SwWordCountDialog::SwWordCountDialog(Window* pParent) :
-    SfxModalDialog(pParent, SW_RES(DLG_WORDCOUNT)),
+    Window(pParent, SW_RES(WINDOW_DLG)),
 #if defined _MSC_VER
 #pragma warning (disable : 4355)
 #endif
@@ -79,10 +85,23 @@ SwWordCountDialog::SwWordCountDialog(Window* pParent) :
     SetHelpId (HID_DLG_WORDCOUNT);
 #endif /* ENABLE_LAYOUT */
     FreeResource();
+
+    aOK.SetClickHdl(LINK(this,SwWordCountDialog,        OkHdl));
+}
+
+IMPL_LINK( SwWordCountDialog, OkHdl, void*, EMPTYARG )
+{   
+    SfxViewFrame* pVFrame = ::GetActiveView()->GetViewFrame();
+    if (pVFrame != NULL)
+    {
+        pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
+    }
+    return 0;
 }
 
 SwWordCountDialog::~SwWordCountDialog()
 {
+    ViewShell::SetCareWin( 0 );
 }
 
 void  SwWordCountDialog::SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc)
@@ -95,4 +114,37 @@ void  SwWordCountDialog::SetValues(const SwDocStat& rCurrent, const SwDocStat& r
     aDocCharacterExcludingSpacesFI.SetText(    String::CreateFromInt32(rDoc.nCharExcludingSpaces 
));
 }
 
+
+SwWordCountFloatDlg::SwWordCountFloatDlg(SfxBindings* _pBindings,
+                                         SfxChildWindow* pChild,
+                                         Window *pParent,
+                                         SfxChildWinInfo* pInfo)
+    : SfxModelessDialog(_pBindings, pChild, pParent, SW_RES(DLG_WORDCOUNT)),
+      aDlg(this)
+{
+    FreeResource();
+    Initialize(pInfo);
+}
+
+void SwWordCountFloatDlg::Activate()
+{
+    SfxModelessDialog::Activate();
+    aDlg.Activate();
+}
+
+void SwWordCountFloatDlg::UpdateCounts()
+{
+    SwWrtShell &rSh = ::GetActiveView()->GetWrtShell();
+    SwDocStat aCurrCnt;
+    SwDocStat aDocStat;
+    {
+        SwWait aWait( *::GetActiveView()->GetDocShell(), sal_True );
+        rSh.StartAction();
+        rSh.CountWords( aCurrCnt );
+        aDocStat = rSh.GetUpdatedDocStat();
+        rSh.EndAction();
+    }
+    aDlg.SetValues(aCurrCnt, aDocStat);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/dialog/wordcountdialog.hrc b/sw/source/ui/dialog/wordcountdialog.hrc
index af6f3a7..0db5c87 100644
--- a/sw/source/ui/dialog/wordcountdialog.hrc
+++ b/sw/source/ui/dialog/wordcountdialog.hrc
@@ -43,5 +43,6 @@
 #define FL_BOTTOM                                15
 #define PB_OK                                    16
 #define PB_HELP                                  17
+#define WINDOW_DLG                               18
 
 #endif
diff --git a/sw/source/ui/dialog/wordcountdialog.src b/sw/source/ui/dialog/wordcountdialog.src
index 767913a..a324c45 100644
--- a/sw/source/ui/dialog/wordcountdialog.src
+++ b/sw/source/ui/dialog/wordcountdialog.src
@@ -27,7 +27,7 @@
 #include <helpid.h>
 #include <dialog.hrc>
 #include <wordcountdialog.hrc>
-ModalDialog DLG_WORDCOUNT
+ModelessDialog DLG_WORDCOUNT
 {
     HelpID = HID_DLG_WORDCOUNT ;
     OutputSize = TRUE ;
@@ -36,6 +36,15 @@ ModalDialog DLG_WORDCOUNT
     Text [ en-US ] = "Word Count" ;
     Moveable = TRUE ;
 
+    Closeable = TRUE;
+    Sizeable = FALSE ;
+    Hide = TRUE ;
+
+  Window WINDOW_DLG
+  {
+    Pos = MAP_APPFONT ( 0 , 0 ) ;
+    Size = MAP_APPFONT ( 170 , 132 ) ;
+
     FixedLine  FL_CURRENT
     {
         Pos = MAP_APPFONT ( 6 , 3 ) ;
@@ -136,4 +145,5 @@ ModalDialog DLG_WORDCOUNT
         Pos = MAP_APPFONT ( 114 , 112 ) ;
         Size = MAP_APPFONT ( 50 , 14 ) ;
     };
+  };
 };
diff --git a/sw/source/ui/dialog/wordcountwrapper.cxx b/sw/source/ui/dialog/wordcountwrapper.cxx
new file mode 100644
index 0000000..764f9f9
--- /dev/null
+++ b/sw/source/ui/dialog/wordcountwrapper.cxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Matt Pratt <mattpratt.au@gmail.com>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+#include <swtypes.hxx>
+#include <wordcountdialog.hxx>
+#include <docstat.hxx>
+#include <dialog.hrc>
+#include <layout/layout-pre.hxx>
+#include <wordcountdialog.hrc>
+#include <wordcountwrapper.hxx>
+#include <cmdid.h>
+
+SFX_IMPL_CHILDWINDOW(SwWordCountWrapper, FN_WORDCOUNT_DIALOG)
+
+SwWordCountWrapper::SwWordCountWrapper(   Window *pParentWindow,
+                            sal_uInt16 nId,
+                            SfxBindings* pBindings,
+                            SfxChildWinInfo* pInfo ) :
+        SfxChildWindow(pParentWindow, nId)
+{
+    SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+    OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+    pAbstDlg = pFact->CreateSwWordCountDialog( DLG_WORDCOUNT, pBindings, this, pParentWindow, 
pInfo );
+    OSL_ENSURE(pAbstDlg, "Dialog contruction faiedl!");
+    pWindow = pAbstDlg->GetWindow();
+
+    eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+}
+
+SfxChildWinInfo SwWordCountWrapper::GetInfo() const
+{
+    SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
+    return aInfo;
+}
+
+void SwWordCountWrapper::UpdateCounts()
+{
+    pAbstDlg->UpdateCounts();
+}
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 0599176..f18433c 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -134,6 +134,9 @@
 #include "formatclipboard.hxx"
 #include <osl/mutex.hxx>
 #include <vcl/svapp.hxx>
+#include <docstat.hxx>
+#include <wordcountdialog.hxx>
+#include <swwait.hxx>
 
 #include <IMark.hxx>
 #include <doc.hxx>
@@ -2602,6 +2605,12 @@ KEYINPUT_CHECKTABLE_INSDEL:
             ShowAutoTextCorrectQuickHelp(sWord, pACfg, pACorr);
         }
     }
+
+    // get the word count dialog to update itself
+    SwWordCountWrapper *pWrdCnt = 
(SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+    if (pWrdCnt)
+        pWrdCnt->UpdateCounts();
+
 }
 
 /*--------------------------------------------------------------------
@@ -3668,6 +3677,13 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
                 }
                 return;
             }
+
+            {
+            SwWordCountWrapper *pWrdCnt = 
(SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+            if (pWrdCnt)
+                pWrdCnt->UpdateCounts();
+            }
+
         case MOUSE_LEFT + KEY_SHIFT:
         case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
             if ( !bMBPressed )
diff --git a/sw/source/ui/inc/wordcountdialog.hxx b/sw/source/ui/inc/wordcountdialog.hxx
index 5c6dbab..d4c996c 100644
--- a/sw/source/ui/inc/wordcountdialog.hxx
+++ b/sw/source/ui/inc/wordcountdialog.hxx
@@ -33,7 +33,12 @@
 #include <layout/layout.hxx>
 #include <layout/layout-pre.hxx>
 struct SwDocStat;
-class SwWordCountDialog : public SfxModalDialog
+#include <sfx2/childwin.hxx>
+#include "swabstdlg.hxx"
+
+class SwWrtShell;
+
+class SwWordCountDialog : public Window
 {
     FixedLine       aCurrentFL;
     FixedText       aCurrentWordFT;
@@ -56,11 +61,42 @@ class SwWordCountDialog : public SfxModalDialog
     OKButton        aOK;
     HelpButton      aHelp;
 
+    void InitControls();
+
 public:
     SwWordCountDialog(Window* pParent);
     ~SwWordCountDialog();
 
     void    SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc);
+
+    SW_DLLPRIVATE DECL_LINK( OkHdl,     void* );
+};
+
+class SwWordCountFloatDlg : public SfxModelessDialog
+{
+    SwWordCountDialog   aDlg;
+    virtual void    Activate();
+    public:
+    SwWordCountFloatDlg(     SfxBindings* pBindings,
+                             SfxChildWindow* pChild,
+                             Window *pParent,
+                             SfxChildWinInfo* pInfo);
+    void    UpdateCounts();
+};
+
+class SwWordCountWrapper : public SfxChildWindow
+{
+    AbstractSwWordCountFloatDlg*   pAbstDlg;
+protected:
+    SwWordCountWrapper(    Window *pParentWindow,
+                            sal_uInt16 nId,
+                            SfxBindings* pBindings,
+                            SfxChildWinInfo* pInfo );
+
+    SFX_DECL_CHILDWINDOW(SwWordCountWrapper);
+
+public:
+    void    UpdateCounts();
 };
 
 #include <layout/layout-post.hxx>
diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx
index 8b03568..cf38a16 100644
--- a/sw/source/ui/shells/annotsh.cxx
+++ b/sw/source/ui/shells/annotsh.cxx
@@ -410,23 +410,16 @@ void SwAnnotationShell::Exec( SfxRequest &rReq )
         break;
         case FN_WORDCOUNT_DIALOG:
         {
-            SwWrtShell &rSh = rView.GetWrtShell();
-            SwDocStat aCurr;
-            SwDocStat aDocStat;
+            SfxViewFrame* pVFrame = GetView().GetViewFrame();
+            if (pVFrame != NULL)
             {
-                SwWait aWait( *rView.GetDocShell(), sal_True );
-                rSh.StartAction();
-                rSh.CountWords( aCurr );
-                aDocStat = rSh.GetUpdatedDocStat();
-                rSh.EndAction();
-            }
+                pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
+                Invalidate(rReq.GetSlot());
 
-            SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
-            OSL_ENSURE(pFact, "Dialogdiet fail!");
-            AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( rView.GetWindow() 
);
-            pDialog->SetValues(aCurr, aDocStat );
-            pDialog->Execute();
-            delete pDialog;
+                SwWordCountWrapper *pWrdCnt = 
(SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+                if (pWrdCnt)
+                    pWrdCnt->UpdateCounts();
+            }
         }
         break;
         case SID_CHAR_DLG:
diff --git a/sw/source/ui/shells/drawsh.cxx b/sw/source/ui/shells/drawsh.cxx
index 695dddc..7dc94e0 100644
--- a/sw/source/ui/shells/drawsh.cxx
+++ b/sw/source/ui/shells/drawsh.cxx
@@ -232,22 +232,16 @@ void SwDrawShell::Execute(SfxRequest &rReq)
         break;
         case FN_WORDCOUNT_DIALOG:
         {
-            SwDocStat aCurr;
-            SwDocStat aDocStat;
+            SfxViewFrame* pVFrame = GetView().GetViewFrame();
+            if (pVFrame != NULL)
             {
-                SwWait aWait( *GetView().GetDocShell(), sal_True );
-                rSh.StartAction();
-                rSh.CountWords( aCurr );
-                aDocStat = rSh.GetUpdatedDocStat();
-                rSh.EndAction();
-            }
+                pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
+                Invalidate(rReq.GetSlot());
 
-            SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
-            OSL_ENSURE(pFact, "Dialogdiet fail!");
-            AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( 
GetView().GetWindow() );
-            pDialog->SetValues(aCurr, aDocStat );
-            pDialog->Execute();
-            delete pDialog;
+                SwWordCountWrapper *pWrdCnt = 
(SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+                if (pWrdCnt)
+                    pWrdCnt->UpdateCounts();
+            }
         }
         break;
         case SID_EXTRUSION_TOOGLE:
diff --git a/sw/source/ui/shells/drwtxtex.cxx b/sw/source/ui/shells/drwtxtex.cxx
index 47a6b1a..b21da6d 100644
--- a/sw/source/ui/shells/drwtxtex.cxx
+++ b/sw/source/ui/shells/drwtxtex.cxx
@@ -346,22 +346,16 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
         break;
         case FN_WORDCOUNT_DIALOG:
         {
-            SwDocStat aCurr;
-            SwDocStat aDocStat;
+            SfxViewFrame* pVFrame = GetView().GetViewFrame();
+            if (pVFrame != NULL)
             {
-                SwWait aWait( *GetView().GetDocShell(), sal_True );
-                rSh.StartAction();
-                rSh.CountWords( aCurr );
-                aDocStat = rSh.GetUpdatedDocStat();
-                rSh.EndAction();
-            }
+                pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
+                Invalidate(rReq.GetSlot());
 
-            SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
-            OSL_ENSURE(pFact, "Dialogdiet fail!");
-            AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( 
GetView().GetWindow() );
-            pDialog->SetValues(aCurr, aDocStat );
-            pDialog->Execute();
-            delete pDialog;
+                SwWordCountWrapper *pWrdCnt = 
(SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+                if (pWrdCnt)
+                    pWrdCnt->UpdateCounts();
+            }
         }
         break;
         case SID_PARA_DLG:
diff --git a/sw/source/ui/shells/frmsh.cxx b/sw/source/ui/shells/frmsh.cxx
index ce35e49..6eb2ea71 100644
--- a/sw/source/ui/shells/frmsh.cxx
+++ b/sw/source/ui/shells/frmsh.cxx
@@ -418,22 +418,16 @@ void SwFrameShell::Execute(SfxRequest &rReq)
         break;
         case FN_WORDCOUNT_DIALOG:
         {
-            SwDocStat aCurr;
-            SwDocStat aDocStat;
+            SfxViewFrame* pVFrame = GetView().GetViewFrame();
+            if (pVFrame != NULL)
             {
-                SwWait aWait( *GetView().GetDocShell(), sal_True );
-                rSh.StartAction();
-                rSh.CountWords( aCurr );
-                aDocStat = rSh.GetUpdatedDocStat();
-                rSh.EndAction();
-            }
+                pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
+                Invalidate(rReq.GetSlot());
 
-            SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
-            OSL_ENSURE(pFact, "Dialogdiet fail!");
-            AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( 
GetView().GetWindow() );
-            pDialog->SetValues(aCurr, aDocStat );
-            pDialog->Execute();
-            delete pDialog;
+                SwWordCountWrapper *pWrdCnt = 
(SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+                if (pWrdCnt)
+                    pWrdCnt->UpdateCounts();
+            }
         }
         break;
         default: bMore = sal_True;
diff --git a/sw/source/ui/shells/textsh.cxx b/sw/source/ui/shells/textsh.cxx
index 5835e5c..f379a61 100644
--- a/sw/source/ui/shells/textsh.cxx
+++ b/sw/source/ui/shells/textsh.cxx
@@ -137,6 +137,7 @@ SFX_IMPL_INTERFACE(SwTextShell, SwBaseShell, SW_RES(STR_SHELLNAME_TEXT))
     SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_IDX_ENTRY_DLG);
     SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_AUTH_ENTRY_DLG);
     SFX_CHILDWINDOW_REGISTRATION(SID_RUBY_DIALOG);
+    SFX_CHILDWINDOW_REGISTRATION(FN_WORDCOUNT_DIALOG);
 }
 
 TYPEINIT1(SwTextShell,SwBaseShell)
diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx
index 9fdb4b4..aeda86e 100644
--- a/sw/source/ui/shells/textsh1.cxx
+++ b/sw/source/ui/shells/textsh1.cxx
@@ -124,6 +124,7 @@
 #include <sfx2/objface.hxx>
 #include <langhelper.hxx>
 #include <uiitems.hxx>
+#include <wordcountdialog.hxx>
 
 using namespace ::com::sun::star;
 
@@ -1287,23 +1288,16 @@ void SwTextShell::Execute(SfxRequest &rReq)
     break;
     case FN_WORDCOUNT_DIALOG:
     {
-        SwWrtShell &rSh = GetShell();
-        SwDocStat aCurr;
-        SwDocStat aDocStat;
+        SfxViewFrame* pVFrame = GetView().GetViewFrame();
+        if (pVFrame != NULL)
         {
-            SwWait aWait( *GetView().GetDocShell(), sal_True );
-            rSh.StartAction();
-            rSh.CountWords( aCurr );
-            aDocStat = rSh.GetUpdatedDocStat();
-            rSh.EndAction();
-        }
+            pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
+            Invalidate(rReq.GetSlot());
 
-        SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
-        OSL_ENSURE(pFact, "Dialogdiet fail!");
-        AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() 
);
-        pDialog->SetValues(aCurr, aDocStat );
-        pDialog->Execute();
-        delete pDialog;
+            SwWordCountWrapper *pWrdCnt = 
(SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+            if (pWrdCnt)
+                pWrdCnt->UpdateCounts();
+        }
     }
     break;
     default:
-- 
1.7.4.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.