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 <o3tl/safeint.hxx>
26 #include <osl/diagnose.h>
27 
28 #include <unoredlines.hxx>
29 #include <unoredline.hxx>
30 #include <pagedesc.hxx>
31 #include <poolfmt.hxx>
32 #include <doc.hxx>
35 #include <docary.hxx>
36 #include <redline.hxx>
37 
38 using namespace ::com::sun::star;
39 
41  SwUnoCollection(_pDoc)
42 {
43 }
44 
46 {
47 }
48 
50 {
51  SolarMutexGuard aGuard;
52  if(!IsValid())
53  throw uno::RuntimeException();
55  return rRedTable.size();
56 }
57 
59 {
60  SolarMutexGuard aGuard;
61  if(!IsValid())
62  throw uno::RuntimeException();
64  if ((nIndex < 0) || (rRedTable.size() <= o3tl::make_unsigned(nIndex)))
65  throw lang::IndexOutOfBoundsException();
66 
67  uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( *rRedTable[nIndex], *GetDoc() );
68  return uno::Any(xRet);
69 }
70 
71 uno::Reference< container::XEnumeration > SwXRedlines::createEnumeration()
72 {
73  SolarMutexGuard aGuard;
74  if(!IsValid())
75  throw uno::RuntimeException();
76  return uno::Reference< container::XEnumeration >(new SwXRedlineEnumeration(*GetDoc()));
77 }
78 
80 {
82 }
83 
85 {
86  SolarMutexGuard aGuard;
87  if(!IsValid())
88  throw uno::RuntimeException();
90  return !rRedTable.empty();
91 }
92 
94 {
95  return "SwXRedlines";
96 }
97 
98 sal_Bool SwXRedlines::supportsService(const OUString& ServiceName)
99 {
100  return cppu::supportsService(this, ServiceName);
101 }
102 
103 uno::Sequence< OUString > SwXRedlines::getSupportedServiceNames()
104 {
105  OSL_FAIL("not implemented");
106  return uno::Sequence< OUString >();
107 }
108 
109 beans::XPropertySet* SwXRedlines::GetObject( SwRangeRedline& rRedline, SwDoc& rDoc )
110 {
111  SwXRedline* pXRedline(nullptr);
112  sw::FindRedlineHint aHint(rRedline, &pXRedline);
114  return pXRedline ? pXRedline : new SwXRedline(rRedline, rDoc);
115 }
116 
118  pDoc(&rDoc),
119  nCurrentIndex(0)
120 {
122 }
123 
125 {
126 }
127 
129 {
130  if(!pDoc)
131  throw uno::RuntimeException();
133 }
134 
136 {
137  if(!pDoc)
138  throw uno::RuntimeException();
140  if( rRedTable.size() <= nCurrentIndex )
141  throw container::NoSuchElementException();
142  uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( *rRedTable[nCurrentIndex++], *pDoc );
143  uno::Any aRet;
144  aRet <<= xRet;
145  return aRet;
146 }
147 
149 {
150  return "SwXRedlineEnumeration";
151 }
152 
154 {
155  return cppu::supportsService(this, ServiceName);
156 }
157 
159 {
160  return uno::Sequence< OUString >();
161 }
162 
164 {
165  if(rHint.GetId() == SfxHintId::Dying)
166  pDoc = nullptr;
167 }
168 
169 /* 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:79
Definition: doc.hxx:186
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoredlines.cxx:84
static css::beans::XPropertySet * GetObject(SwRangeRedline &rRedline, SwDoc &rDoc)
SfxHintId GetId() const
size_type size() const
Definition: docary.hxx:266
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoredlines.cxx:49
bool empty() const
Definition: docary.hxx:265
virtual OUString SAL_CALL getImplementationName() override
Definition: unoredlines.cxx:93
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:426
bool IsValid() const
Definition: unocoll.hxx:57
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
SwRedlineTable::size_type nCurrentIndex
Definition: unoredlines.hxx:72
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:40
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoredlines.cxx:98
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
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:71
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:58
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:96
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
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:170
virtual ~SwXRedlines() override
Definition: unoredlines.cxx:45
virtual css::uno::Any SAL_CALL nextElement() override
virtual void Notify(const SfxHint &) override