summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/Library_sw.mk1
-rw-r--r--sw/inc/proofreadingiterator.hxx39
-rw-r--r--sw/source/core/bastyp/init.cxx2
-rw-r--r--sw/source/core/bastyp/proofreadingiterator.cxx69
-rw-r--r--sw/source/core/doc/docnew.cxx4
-rw-r--r--sw/source/uibase/uno/dlelstnr.cxx4
6 files changed, 115 insertions, 4 deletions
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 5254e3a3b973..d27dbf6d7b08 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -130,6 +130,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/core/bastyp/checkit \
sw/source/core/bastyp/index \
sw/source/core/bastyp/init \
+ sw/source/core/bastyp/proofreadingiterator \
sw/source/core/bastyp/swcache \
sw/source/core/bastyp/swrect \
sw/source/core/bastyp/swregion \
diff --git a/sw/inc/proofreadingiterator.hxx b/sw/inc/proofreadingiterator.hxx
new file mode 100644
index 000000000000..953efcf3b7af
--- /dev/null
+++ b/sw/inc/proofreadingiterator.hxx
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * 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 INCLUDED_SW_INC_PROOFREADINGITERATOR_HXX
+#define INCLUDED_SW_INC_PROOFREADINGITERATOR_HXX
+
+#include <sal/config.h>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <sal/types.h>
+
+namespace com { namespace sun { namespace star {
+ namespace linguistic2 { class XProofreadingIterator; }
+ namespace uno { class XComponentContext; }
+} } }
+
+// A simple wrapper around the css.linguistic2.ProofreadingIterator
+// single-instance service. The first time that service implementation gets
+// instantiated it immediately starts a GrammarCheckingIterator thread that
+// eventually needs to be joined (via dispose):
+
+namespace sw { namespace proofreadingiterator {
+
+css::uno::Reference<css::linguistic2::XProofreadingIterator> get(
+ css::uno::Reference<css::uno::XComponentContext> const & context);
+
+void dispose();
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx
index 074e372a190c..6e39a13a3221 100644
--- a/sw/source/core/bastyp/init.cxx
+++ b/sw/source/core/bastyp/init.cxx
@@ -109,6 +109,7 @@
#include <init.hxx>
#include <pam.hxx>
#include <paratr.hxx>
+#include <proofreadingiterator.hxx>
#include <rtl/instance.hxx>
#include <svl/macitem.hxx>
#include <svx/dialogs.hrc>
@@ -749,6 +750,7 @@ void _FinitCore()
_FrmFinit();
_TextFinit();
+ sw::proofreadingiterator::dispose();
SwBreakIt::_Delete();
delete pCheckIt;
delete pAppCharClass;
diff --git a/sw/source/core/bastyp/proofreadingiterator.cxx b/sw/source/core/bastyp/proofreadingiterator.cxx
new file mode 100644
index 000000000000..b0f75471d942
--- /dev/null
+++ b/sw/source/core/bastyp/proofreadingiterator.cxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * 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 <sal/config.h>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/linguistic2/ProofreadingIterator.hpp>
+#include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <sal/types.h>
+#include <vcl/svapp.hxx>
+
+#include <proofreadingiterator.hxx>
+
+namespace {
+
+css::uno::Reference<css::linguistic2::XProofreadingIterator> instance;
+bool disposed = false;
+
+void doDispose(
+ css::uno::Reference<css::linguistic2::XProofreadingIterator> const &
+ inst)
+{
+ css::uno::Reference<css::lang::XComponent> comp(inst, css::uno::UNO_QUERY);
+ if (comp.is()) {
+ SolarMutexReleaser r;
+ comp->dispose();
+ }
+}
+
+}
+
+css::uno::Reference<css::linguistic2::XProofreadingIterator>
+sw::proofreadingiterator::get(
+ css::uno::Reference<css::uno::XComponentContext> const & context)
+{
+ css::uno::Reference<css::linguistic2::XProofreadingIterator> inst(
+ css::linguistic2::ProofreadingIterator::create(context));
+ bool disp;
+ {
+ SolarMutexGuard g;
+ instance = inst;
+ disp = disposed;
+ }
+ if (disp) {
+ doDispose(inst);
+ }
+ return inst;
+}
+
+void sw::proofreadingiterator::dispose() {
+ css::uno::Reference<css::linguistic2::XProofreadingIterator> inst;
+ {
+ SolarMutexGuard g;
+ inst = instance;
+ instance.clear();
+ disposed = true;
+ }
+ doDispose(inst);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 2fc0dced4cc3..b45451f2147c 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -21,10 +21,10 @@
#include <doc.hxx>
#include <dcontact.hxx>
+#include <proofreadingiterator.hxx>
#include <com/sun/star/document/PrinterIndependentLayout.hpp>
#include <com/sun/star/document/UpdateDocMode.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
-#include <com/sun/star/linguistic2/ProofreadingIterator.hpp>
#include <com/sun/star/text/XFlatParagraphIteratorProvider.hpp>
#include <comphelper/processfactory.hxx>
@@ -140,7 +140,7 @@ const sal_Char sGrfCollStr[] = "Graphikformatvorlage";
uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
try
{
- m_xGCIterator = linguistic2::ProofreadingIterator::create( xContext );
+ m_xGCIterator = sw::proofreadingiterator::get( xContext );
}
catch (const uno::Exception &)
{
diff --git a/sw/source/uibase/uno/dlelstnr.cxx b/sw/source/uibase/uno/dlelstnr.cxx
index da97f5f18d56..195ebae5edc6 100644
--- a/sw/source/uibase/uno/dlelstnr.cxx
+++ b/sw/source/uibase/uno/dlelstnr.cxx
@@ -22,7 +22,6 @@
#include <com/sun/star/linguistic2/XDictionaryList.hpp>
#include <com/sun/star/linguistic2/LinguServiceManager.hpp>
#include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
-#include <com/sun/star/linguistic2/ProofreadingIterator.hpp>
#include <com/sun/star/linguistic2/LinguServiceEventFlags.hpp>
#include <unotools/lingucfg.hxx>
@@ -32,6 +31,7 @@
#include <osl/mutex.hxx>
#include <vcl/svapp.hxx>
#include "dlelstnr.hxx"
+#include <proofreadingiterator.hxx>
#include <swmodule.hxx>
#include <wrtsh.hxx>
#include <view.hxx>
@@ -56,7 +56,7 @@ SwLinguServiceEventListener::SwLinguServiceEventListener()
if (SvtLinguConfig().HasGrammarChecker())
{
- xGCIterator = ProofreadingIterator::create(xContext);
+ xGCIterator = sw::proofreadingiterator::get(xContext);
Reference< XLinguServiceEventBroadcaster > xBC( xGCIterator, UNO_QUERY );
if (xBC.is())
xBC->addLinguServiceEventListener( (XLinguServiceEventListener *) this );