LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / inc / nameuno.hxx
bloba286266cd2edfe2972792baf89fe558d2717e2bd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <svl/lstner.hxx>
23 #include "address.hxx"
24 #include "rangenam.hxx"
25 #include <formula/grammar.hxx>
26 #include <com/sun/star/sheet/XLabelRange.hpp>
27 #include <com/sun/star/sheet/XLabelRanges.hpp>
28 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
29 #include <com/sun/star/sheet/XNamedRange.hpp>
30 #include <com/sun/star/sheet/XFormulaTokens.hpp>
31 #include <com/sun/star/sheet/XNamedRanges.hpp>
32 #include <com/sun/star/container/XEnumerationAccess.hpp>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/lang/XUnoTunnel.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/document/XActionLockable.hpp>
37 #include <cppuhelper/implbase.hxx>
38 #include <rtl/ref.hxx>
40 namespace com::sun::star::container { class XNamed; }
42 class ScDocShell;
43 class ScNamedRangesObj;
45 class SC_DLLPUBLIC ScNamedRangeObj final : public ::cppu::WeakImplHelper<
46 css::sheet::XNamedRange,
47 css::sheet::XFormulaTokens,
48 css::sheet::XCellRangeReferrer,
49 css::beans::XPropertySet,
50 css::lang::XUnoTunnel,
51 css::lang::XServiceInfo >,
52 public SfxListener
54 private:
55 rtl::Reference< ScNamedRangesObj > mxParent;
56 ScDocShell* pDocShell;
57 OUString aName;
58 css::uno::Reference< css::container::XNamed > mxSheet;
60 private:
61 friend class ScVbaName;
62 ScRangeData* GetRangeData_Impl();
63 void Modify_Impl( const OUString* pNewName,
64 const ScTokenArray* pNewTokens, const OUString* pNewContent,
65 const ScAddress* pNewPos, const ScRangeData::Type* pNewType,
66 const formula::FormulaGrammar::Grammar eGrammar );
67 SCTAB GetTab_Impl();
69 public:
70 ScNamedRangeObj( rtl::Reference< ScNamedRangesObj > const & xParent, ScDocShell* pDocSh, const OUString& rNm,
71 css::uno::Reference< css::container::XNamed > const & xSheet = css::uno::Reference< css::container::XNamed > ());
72 virtual ~ScNamedRangeObj() override;
74 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
76 /// XNamedRange
77 virtual OUString SAL_CALL getContent() override;
78 virtual void SAL_CALL setContent( const OUString& aContent ) override;
79 virtual css::table::CellAddress SAL_CALL getReferencePosition() override;
80 virtual void SAL_CALL setReferencePosition(
81 const css::table::CellAddress& aReferencePosition ) override;
82 virtual sal_Int32 SAL_CALL getType() override;
83 virtual void SAL_CALL setType( sal_Int32 nType ) override;
85 /// XFormulaTokens
86 virtual css::uno::Sequence< css::sheet::FormulaToken > SAL_CALL getTokens() override;
87 virtual void SAL_CALL setTokens( const css::uno::Sequence< css::sheet::FormulaToken >& aTokens ) override;
89 /// XNamed
90 virtual OUString SAL_CALL getName() override;
91 virtual void SAL_CALL setName( const OUString& aName ) override;
93 /// XCellRangeReferrer
94 virtual css::uno::Reference< css::table::XCellRange > SAL_CALL
95 getReferredCells() override;
97 /// XPropertySet
98 virtual css::uno::Reference< css::beans::XPropertySetInfo >
99 SAL_CALL getPropertySetInfo() override;
100 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
101 const css::uno::Any& aValue ) override;
102 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
103 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
104 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
105 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
106 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
107 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
108 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
109 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
110 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
112 /// XUnoTunnel
113 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
115 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
117 /// XServiceInfo
118 virtual OUString SAL_CALL getImplementationName() override;
119 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
120 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
123 class ScNamedRangesObj : public ::cppu::WeakImplHelper<
124 css::sheet::XNamedRanges,
125 css::container::XEnumerationAccess,
126 css::container::XIndexAccess,
127 css::beans::XPropertySet,
128 css::document::XActionLockable,
129 css::lang::XServiceInfo >,
130 public SfxListener
132 private:
134 /** if true, adding new name or modifying existing one will set the
135 document 'modified' and broadcast the change. We turn this off during
136 import. */
137 bool mbModifyAndBroadcast;
139 virtual rtl::Reference<ScNamedRangeObj> GetObjectByIndex_Impl(sal_uInt16 nIndex) = 0;
140 virtual rtl::Reference<ScNamedRangeObj> GetObjectByName_Impl(const OUString& aName) = 0;
142 virtual ScRangeName* GetRangeName_Impl() = 0;
143 virtual SCTAB GetTab_Impl() = 0;
145 protected:
147 ScDocShell* pDocShell;
148 /** called from the XActionLockable interface methods on initial locking */
149 void lock();
151 /** called from the XActionLockable interface methods on final unlock */
152 void unlock();
154 public:
155 ScNamedRangesObj(ScDocShell* pDocSh);
156 virtual ~ScNamedRangesObj() override;
158 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
160 bool IsModifyAndBroadcast() const { return mbModifyAndBroadcast;}
162 /// XNamedRanges
163 virtual void SAL_CALL addNewByName( const OUString& aName, const OUString& aContent,
164 const css::table::CellAddress& aPosition, sal_Int32 nType ) override;
165 virtual void SAL_CALL addNewFromTitles( const css::table::CellRangeAddress& aSource,
166 css::sheet::Border aBorder ) override;
167 virtual void SAL_CALL removeByName( const OUString& aName ) override;
168 virtual void SAL_CALL outputList( const css::table::CellAddress& aOutputPosition ) override;
170 /// XNameAccess
171 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
172 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
173 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
175 /// XIndexAccess
176 virtual sal_Int32 SAL_CALL getCount() override;
177 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
179 /// XEnumerationAccess
180 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
181 createEnumeration() override;
183 /// XElementAccess
184 virtual css::uno::Type SAL_CALL getElementType() override;
185 virtual sal_Bool SAL_CALL hasElements() override;
187 /// XPropertySet
188 virtual css::uno::Reference< css::beans::XPropertySetInfo >
189 SAL_CALL getPropertySetInfo() override;
190 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
191 const css::uno::Any& aValue ) override;
192 virtual css::uno::Any SAL_CALL getPropertyValue(
193 const OUString& PropertyName ) override;
194 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
195 const css::uno::Reference<
196 css::beans::XPropertyChangeListener >& xListener ) override;
197 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
198 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
199 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
200 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
201 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
202 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
204 /// XActionLockable
205 virtual sal_Bool SAL_CALL isActionLocked() override;
206 virtual void SAL_CALL addActionLock() override;
207 virtual void SAL_CALL removeActionLock() override;
208 virtual void SAL_CALL setActionLocks( sal_Int16 nLock ) override;
209 virtual sal_Int16 SAL_CALL resetActionLocks() override;
211 /// XServiceInfo
212 virtual OUString SAL_CALL getImplementationName() override;
213 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
214 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
217 class ScGlobalNamedRangesObj final : public ScNamedRangesObj
219 private:
221 virtual rtl::Reference<ScNamedRangeObj> GetObjectByIndex_Impl(sal_uInt16 nIndex) override;
222 virtual rtl::Reference<ScNamedRangeObj> GetObjectByName_Impl(const OUString& aName) override;
224 virtual ScRangeName* GetRangeName_Impl() override;
225 virtual SCTAB GetTab_Impl() override;
227 public:
228 ScGlobalNamedRangesObj(ScDocShell* pDocSh);
229 virtual ~ScGlobalNamedRangesObj() override;
232 class ScLocalNamedRangesObj final : public ScNamedRangesObj
234 private:
236 virtual rtl::Reference<ScNamedRangeObj> GetObjectByIndex_Impl(sal_uInt16 nIndex) override;
237 virtual rtl::Reference<ScNamedRangeObj> GetObjectByName_Impl(const OUString& aName) override;
239 virtual ScRangeName* GetRangeName_Impl() override;
240 virtual SCTAB GetTab_Impl() override;
242 css::uno::Reference< css::container::XNamed > mxSheet;
243 public:
244 ScLocalNamedRangesObj(ScDocShell* pDocSh, css::uno::Reference< css::container::XNamed > const & xNamed );
245 virtual ~ScLocalNamedRangesObj() override;
248 class ScLabelRangeObj final : public ::cppu::WeakImplHelper<
249 css::sheet::XLabelRange,
250 css::lang::XServiceInfo >,
251 public SfxListener
253 private:
254 ScDocShell* pDocShell;
255 bool bColumn;
256 ScRange aRange; ///< criterion to find range
258 private:
259 ScRangePair* GetData_Impl();
260 void Modify_Impl( const ScRange* pLabel, const ScRange* pData );
262 public:
263 ScLabelRangeObj(ScDocShell* pDocSh, bool bCol, const ScRange& rR);
264 virtual ~ScLabelRangeObj() override;
266 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
268 /// XLabelRange
269 virtual css::table::CellRangeAddress SAL_CALL getLabelArea() override;
270 virtual void SAL_CALL setLabelArea( const css::table::CellRangeAddress& aLabelArea ) override;
271 virtual css::table::CellRangeAddress SAL_CALL getDataArea() override;
272 virtual void SAL_CALL setDataArea( const css::table::CellRangeAddress& aDataArea ) override;
274 /// XServiceInfo
275 virtual OUString SAL_CALL getImplementationName() override;
276 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
277 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
280 class ScLabelRangesObj final : public ::cppu::WeakImplHelper<
281 css::sheet::XLabelRanges,
282 css::container::XEnumerationAccess,
283 css::lang::XServiceInfo >,
284 public SfxListener
286 private:
287 ScDocShell* pDocShell;
288 bool bColumn;
290 rtl::Reference<ScLabelRangeObj> GetObjectByIndex_Impl(size_t nIndex);
292 public:
293 ScLabelRangesObj(ScDocShell* pDocSh, bool bCol);
294 virtual ~ScLabelRangesObj() override;
296 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
298 /// XLabelRanges
299 virtual void SAL_CALL addNew( const css::table::CellRangeAddress& aLabelArea,
300 const css::table::CellRangeAddress& aDataArea ) override;
301 virtual void SAL_CALL removeByIndex( sal_Int32 nIndex ) override;
303 /// XIndexAccess
304 virtual sal_Int32 SAL_CALL getCount() override;
305 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
307 /// XEnumerationAccess
308 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
309 createEnumeration() override;
311 /// XElementAccess
312 virtual css::uno::Type SAL_CALL getElementType() override;
313 virtual sal_Bool SAL_CALL hasElements() override;
315 /// XServiceInfo
316 virtual OUString SAL_CALL getImplementationName() override;
317 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
318 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
321 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */