LibreOffice Module sw (master)  1
unoredlines.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  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <com/sun/star/beans/XPropertySet.hpp>
21 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
23 
24 #include <vcl/svapp.hxx>
25 #include <osl/diagnose.h>
26 
27 #include <unoredlines.hxx>
28 #include <unoredline.hxx>
29 #include <unomid.h>
30 #include <pagedesc.hxx>
31 #include <poolfmt.hxx>
32 #include <doc.hxx>
34 #include <docary.hxx>
35 #include <redline.hxx>
36 
37 using namespace ::com::sun::star;
38 
40  SwUnoCollection(_pDoc)
41 {
42 }
43 
45 {
46 }
47 
49 {
50  SolarMutexGuard aGuard;
51  if(!IsValid())
52  throw uno::RuntimeException();
54  return rRedTable.size();
55 }
56 
58 {
59  SolarMutexGuard aGuard;
60  if(!IsValid())
61  throw uno::RuntimeException();
63  if ((rRedTable.size() <= static_cast<size_t>(nIndex)) || (nIndex < 0))
64  throw lang::IndexOutOfBoundsException();
65 
66  uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( *rRedTable[nIndex], *GetDoc() );
67  return uno::Any(xRet);
68 }
69 
70 uno::Reference< container::XEnumeration > SwXRedlines::createEnumeration()
71 {
72  SolarMutexGuard aGuard;
73  if(!IsValid())
74  throw uno::RuntimeException();
75  return uno::Reference< container::XEnumeration >(new SwXRedlineEnumeration(*GetDoc()));
76 }
77 
79 {
81 }
82 
84 {
85  SolarMutexGuard aGuard;
86  if(!IsValid())
87  throw uno::RuntimeException();
89  return !rRedTable.empty();
90 }
91 
93 {
94  return "SwXRedlines";
95 }
96 
97 sal_Bool SwXRedlines::supportsService(const OUString& ServiceName)
98 {
99  return cppu::supportsService(this, ServiceName);
100 }
101 
102 uno::Sequence< OUString > SwXRedlines::getSupportedServiceNames()
103 {
104  OSL_FAIL("not implemented");
105  return uno::Sequence< OUString >();
106 }
107 
108 beans::XPropertySet* SwXRedlines::GetObject( SwRangeRedline& rRedline, SwDoc& rDoc )
109 {
110  SwXRedline* pXRedline(nullptr);
111  sw::FindRedlineHint aHint(rRedline, &pXRedline);
113  return pXRedline ? pXRedline : new SwXRedline(rRedline, rDoc);
114 }
115 
117  pDoc(&rDoc),
118  nCurrentIndex(0)
119 {
121 }
122 
124 {
125 }
126 
128 {
129  if(!pDoc)
130  throw uno::RuntimeException();
132 }
133 
135 {
136  if(!pDoc)
137  throw uno::RuntimeException();
139  if( rRedTable.size() <= nCurrentIndex )
140  throw container::NoSuchElementException();
141  uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( *rRedTable[nCurrentIndex++], *pDoc );
142  uno::Any aRet;
143  aRet <<= xRet;
144  return aRet;
145 }
146 
148 {
149  return "SwXRedlineEnumeration";
150 }
151 
153 {
154  return cppu::supportsService(this, ServiceName);
155 }
156 
158 {
159  return uno::Sequence< OUString >();
160 }
161 
163 {
164  if(rHint.GetId() == SfxHintId::Dying)
165  pDoc = nullptr;
166 }
167 
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwDoc * GetDoc() const
Definition: unocoll.hxx:59
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoredlines.cxx:78
Definition: doc.hxx:185
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoredlines.cxx:83
static css::beans::XPropertySet * GetObject(SwRangeRedline &rRedline, SwDoc &rDoc)
SfxHintId GetId() const
size_type size() const
Definition: docary.hxx:368
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoredlines.cxx:48
bool empty() const
Definition: docary.hxx:367
virtual OUString SAL_CALL getImplementationName() override
Definition: unoredlines.cxx:92
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:458
bool IsValid() const
Definition: unocoll.hxx:57
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
SwRedlineTable::size_type nCurrentIndex
Definition: unoredlines.hxx:76
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual SwPageDesc * GetPageDescFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return required automatic page style.
void Broadcast(const SfxHint &rHint)
SwXRedlines(SwDoc *pDoc)
Definition: unoredlines.cxx:39
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoredlines.cxx:97
unsigned char sal_Bool
SwXRedlineEnumeration(SwDoc &rDoc)
css::uno::Type const & get()
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unoredlines.cxx:70
bool StartListening(SvtBroadcaster &rBroadcaster)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unoredlines.cxx:57
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:93
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:367
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~SwXRedlineEnumeration() override
virtual sal_Bool SAL_CALL hasMoreElements() override
virtual const SwRedlineTable & GetRedlineTable() const =0
Standard page.
Definition: poolfmt.hxx:171
virtual ~SwXRedlines() override
Definition: unoredlines.cxx:44
virtual css::uno::Any SAL_CALL nextElement() override
virtual void Notify(const SfxHint &) override