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 <sal/types.h>
18 #include <vcl/svapp.hxx>
19 
20 #include <proofreadingiterator.hxx>
21 
22 namespace {
23 
24 css::uno::Reference<css::linguistic2::XProofreadingIterator> instance;
25 bool disposed = false;
26 
27 void doDispose(
28  css::uno::Reference<css::linguistic2::XProofreadingIterator> const &
29  inst)
30 {
31  css::uno::Reference<css::lang::XComponent> comp(inst, css::uno::UNO_QUERY);
32  if (comp.is()) {
34  comp->dispose();
35  }
36 }
37 
38 }
39 
40 css::uno::Reference<css::linguistic2::XProofreadingIterator>
42  css::uno::Reference<css::uno::XComponentContext> const & context)
43 {
44  css::uno::Reference<css::linguistic2::XProofreadingIterator> inst(
45  css::linguistic2::ProofreadingIterator::create(context));
46  bool disp;
47  {
49  instance = inst;
50  disp = disposed;
51  }
52  if (disp) {
53  doDispose(inst);
54  }
55  return inst;
56 }
57 
59  css::uno::Reference<css::linguistic2::XProofreadingIterator> inst;
60  {
62  inst = instance;
63  instance.clear();
64  disposed = true;
65  }
66  doDispose(inst);
67 }
68 
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
tuple comp