LibreOffice Module sw (master)  1
proofreadingiterator.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #include <sal/config.h>
11 
12 #include <com/sun/star/lang/XComponent.hpp>
13 #include <com/sun/star/linguistic2/ProofreadingIterator.hpp>
14 #include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
15 #include <com/sun/star/uno/Reference.hxx>
16 #include <com/sun/star/uno/XComponentContext.hpp>
17 #include <vcl/svapp.hxx>
18 
19 #include <proofreadingiterator.hxx>
20 
21 namespace {
22 
23 css::uno::Reference<css::linguistic2::XProofreadingIterator> instance;
24 bool disposed = false;
25 
26 void doDispose(
27  css::uno::Reference<css::linguistic2::XProofreadingIterator> const &
28  inst)
29 {
30  css::uno::Reference<css::lang::XComponent> comp(inst, css::uno::UNO_QUERY);
31  if (comp.is()) {
33  comp->dispose();
34  }
35 }
36 
37 }
38 
39 css::uno::Reference<css::linguistic2::XProofreadingIterator>
41  css::uno::Reference<css::uno::XComponentContext> const & context)
42 {
43  css::uno::Reference<css::linguistic2::XProofreadingIterator> inst(
44  css::linguistic2::ProofreadingIterator::create(context));
45  bool disp;
46  {
48  instance = inst;
49  disp = disposed;
50  }
51  if (disp) {
52  doDispose(inst);
53  }
54  return inst;
55 }
56 
58  css::uno::Reference<css::linguistic2::XProofreadingIterator> inst;
59  {
61  inst = instance;
62  instance.clear();
63  disposed = true;
64  }
65  doDispose(inst);
66 }
67 
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
tuple comp