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
38using 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
71uno::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
98sal_Bool SwXRedlines::supportsService(const OUString& ServiceName)
99{
101}
102
103uno::Sequence< OUString > SwXRedlines::getSupportedServiceNames()
104{
105 OSL_FAIL("not implemented");
106 return uno::Sequence< OUString >();
107}
108
109beans::XPropertySet* SwXRedlines::GetObject( SwRangeRedline& rRedline, SwDoc& rDoc )
110{
111 SwXRedline* pXRedline(nullptr);
112 sw::FindRedlineHint aHint(rRedline, &pXRedline);
113 rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier().Broadcast(aHint);
114 return pXRedline ? pXRedline : new SwXRedline(rRedline, rDoc);
115}
116
118 m_pDoc(&rDoc),
120{
122}
123
125{
126}
127
129{
130 if(!m_pDoc)
131 throw uno::RuntimeException();
133}
134
136{
137 if(!m_pDoc)
138 throw uno::RuntimeException();
140 if( rRedTable.size() <= m_nCurrentIndex )
141 throw container::NoSuchElementException();
142 uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( *rRedTable[m_nCurrentIndex++], *m_pDoc );
143 uno::Any aRet;
144 aRet <<= xRet;
145 return aRet;
146}
147
149{
150 return "SwXRedlineEnumeration";
151}
152
154{
156}
157
159{
160 return uno::Sequence< OUString >();
161}
162
164{
165 if(rHint.GetId() == SfxHintId::Dying)
166 m_pDoc = nullptr;
167}
168
169/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t m_nCurrentIndex
virtual const SwRedlineTable & GetRedlineTable() const =0
virtual SwPageDesc * GetPageDescFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return required automatic page style.
SfxHintId GetId() const
bool StartListening(SvtBroadcaster &rBroadcaster)
Definition: doc.hxx:195
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:343
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:434
bool empty() const
Definition: docary.hxx:266
size_type size() const
Definition: docary.hxx:267
SwDoc * GetDoc() const
Definition: unocoll.hxx:59
bool IsValid() const
Definition: unocoll.hxx:57
SwRedlineTable::size_type m_nCurrentIndex
Definition: unoredlines.hxx:72
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void Notify(const SfxHint &) override
SwXRedlineEnumeration(SwDoc &rDoc)
virtual ~SwXRedlineEnumeration() override
virtual sal_Bool SAL_CALL hasMoreElements() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Any SAL_CALL nextElement() override
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unoredlines.cxx:58
SwXRedlines(SwDoc *pDoc)
Definition: unoredlines.cxx:40
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoredlines.cxx:98
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unoredlines.cxx:71
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoredlines.cxx:49
virtual OUString SAL_CALL getImplementationName() override
Definition: unoredlines.cxx:93
virtual ~SwXRedlines() override
Definition: unoredlines.cxx:45
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoredlines.cxx:84
static css::beans::XPropertySet * GetObject(SwRangeRedline &rRedline, SwDoc &rDoc)
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoredlines.cxx:79
css::uno::Type const & get()
sal_Int32 nIndex
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
@ RES_POOLPAGE_STANDARD
Standard page.
Definition: poolfmt.hxx:170
unsigned char sal_Bool