1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_SC_INC_LINKUNO_HXX
21 #define INCLUDED_SC_INC_LINKUNO_HXX
23 #include <svl/lstner.hxx>
24 #include <svl/itemprop.hxx>
25 #include <com/sun/star/sheet/XDDELink.hpp>
26 #include <com/sun/star/sheet/XDDELinkResults.hpp>
27 #include <com/sun/star/sheet/XDDELinks.hpp>
28 #include <com/sun/star/sheet/XExternalDocLink.hpp>
29 #include <com/sun/star/sheet/XExternalDocLinks.hpp>
30 #include <com/sun/star/sheet/XExternalSheetCache.hpp>
31 #include <com/sun/star/sheet/XAreaLink.hpp>
32 #include <com/sun/star/sheet/XAreaLinks.hpp>
33 #include <com/sun/star/util/XRefreshable.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/container/XEnumerationAccess.hpp>
37 #include <com/sun/star/container/XNameAccess.hpp>
38 #include <com/sun/star/container/XIndexAccess.hpp>
39 #include <com/sun/star/container/XNamed.hpp>
40 #include <cppuhelper/implbase.hxx>
42 #include "externalrefmgr.hxx"
49 typedef std::vector
< css::uno::Reference
< css::util::XRefreshListener
> > XRefreshListenerArr_Impl
;
51 class ScSheetLinkObj
: public cppu::WeakImplHelper
<
52 css::container::XNamed
,
53 css::util::XRefreshable
,
54 css::beans::XPropertySet
,
55 css::lang::XServiceInfo
>,
59 SfxItemPropertySet aPropSet
;
60 ScDocShell
* pDocShell
;
62 XRefreshListenerArr_Impl aRefreshListeners
;
64 ScTableLink
* GetLink_Impl() const;
65 void Refreshed_Impl();
66 void ModifyRefreshDelay_Impl( sal_Int32 nRefresh
);
69 ScSheetLinkObj(ScDocShell
* pDocSh
, const OUString
& rName
);
70 virtual ~ScSheetLinkObj() override
;
72 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
75 virtual OUString SAL_CALL
getName() override
;
76 virtual void SAL_CALL
setName( const OUString
& aName
) override
;
79 virtual void SAL_CALL
refresh() override
;
80 virtual void SAL_CALL
addRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
81 virtual void SAL_CALL
removeRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
84 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
85 SAL_CALL
getPropertySetInfo( ) override
;
86 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
87 const css::uno::Any
& aValue
) override
;
88 virtual css::uno::Any SAL_CALL
getPropertyValue(
89 const OUString
& PropertyName
) override
;
90 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
91 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
92 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
93 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
94 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
95 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
96 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
97 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
99 // called from get/setPropertyValue:
100 OUString
getFileName() const;
101 void setFileName(const OUString
& FileName
);
102 OUString
getFilter() const;
103 void setFilter(const OUString
& Filter
);
104 OUString
getFilterOptions() const;
105 void setFilterOptions(const OUString
& FilterOptions
);
106 sal_Int32
getRefreshDelay() const;
107 void setRefreshDelay(sal_Int32 nRefreshDelay
);
110 virtual OUString SAL_CALL
getImplementationName() override
;
111 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
112 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
115 class ScSheetLinksObj
: public cppu::WeakImplHelper
<
116 css::container::XNameAccess
,
117 css::container::XEnumerationAccess
,
118 css::container::XIndexAccess
,
119 css::lang::XServiceInfo
>,
123 ScDocShell
* pDocShell
;
125 ScSheetLinkObj
* GetObjectByIndex_Impl(sal_Int32 nIndex
);
126 ScSheetLinkObj
* GetObjectByName_Impl(const OUString
& aName
);
129 ScSheetLinksObj(ScDocShell
* pDocSh
);
130 virtual ~ScSheetLinksObj() override
;
132 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
135 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
136 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
137 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
140 virtual sal_Int32 SAL_CALL
getCount() override
;
141 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
143 // XEnumerationAccess
144 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
145 createEnumeration() override
;
148 virtual css::uno::Type SAL_CALL
getElementType() override
;
149 virtual sal_Bool SAL_CALL
hasElements() override
;
152 virtual OUString SAL_CALL
getImplementationName() override
;
153 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
154 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
157 class ScAreaLinkObj
: public cppu::WeakImplHelper
<
158 css::sheet::XAreaLink
,
159 css::util::XRefreshable
,
160 css::beans::XPropertySet
,
161 css::lang::XServiceInfo
>,
165 SfxItemPropertySet aPropSet
;
166 ScDocShell
* pDocShell
;
168 XRefreshListenerArr_Impl aRefreshListeners
;
170 void Modify_Impl( const OUString
* pNewFile
, const OUString
* pNewFilter
,
171 const OUString
* pNewOptions
, const OUString
* pNewSource
,
172 const css::table::CellRangeAddress
* pNewDest
);
173 void ModifyRefreshDelay_Impl( sal_Int32 nRefresh
);
174 void Refreshed_Impl();
177 ScAreaLinkObj(ScDocShell
* pDocSh
, size_t nP
);
178 virtual ~ScAreaLinkObj() override
;
180 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
183 virtual void SAL_CALL
refresh() override
;
184 virtual void SAL_CALL
addRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
185 virtual void SAL_CALL
removeRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
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( const OUString
& PropertyName
) override
;
193 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
194 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
195 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
196 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
197 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
198 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
199 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
200 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
202 // called from get/setPropertyValue:
203 OUString
getFileName() const;
204 void setFileName(const OUString
& FileName
);
205 OUString
getFilter() const;
206 void setFilter(const OUString
& Filter
);
207 OUString
getFilterOptions() const;
208 void setFilterOptions(const OUString
& FilterOptions
);
209 sal_Int32
getRefreshDelay() const;
210 void setRefreshDelay(sal_Int32 nRefreshDelay
);
213 virtual OUString SAL_CALL
getSourceArea() override
;
214 virtual void SAL_CALL
setSourceArea( const OUString
& aSourceArea
) override
;
215 virtual css::table::CellRangeAddress SAL_CALL
getDestArea() override
;
216 virtual void SAL_CALL
setDestArea( const css::table::CellRangeAddress
& aDestArea
) override
;
219 virtual OUString SAL_CALL
getImplementationName() override
;
220 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
221 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
224 class ScAreaLinksObj
: public cppu::WeakImplHelper
<
225 css::sheet::XAreaLinks
,
226 css::container::XEnumerationAccess
,
227 css::lang::XServiceInfo
>,
231 ScDocShell
* pDocShell
;
233 ScAreaLinkObj
* GetObjectByIndex_Impl(sal_Int32 nIndex
);
236 ScAreaLinksObj(ScDocShell
* pDocSh
);
237 virtual ~ScAreaLinksObj() override
;
239 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
242 virtual void SAL_CALL
insertAtPosition( const css::table::CellAddress
& aDestPos
,
243 const OUString
& aFileName
,
244 const OUString
& aSourceArea
,
245 const OUString
& aFilter
,
246 const OUString
& aFilterOptions
) override
;
247 virtual void SAL_CALL
removeByIndex( sal_Int32 nIndex
) override
;
250 virtual sal_Int32 SAL_CALL
getCount() override
;
251 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
253 // XEnumerationAccess
254 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
255 createEnumeration() override
;
258 virtual css::uno::Type SAL_CALL
getElementType() override
;
259 virtual sal_Bool SAL_CALL
hasElements() override
;
262 virtual OUString SAL_CALL
getImplementationName() override
;
263 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
264 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
267 //! order of XNamed and DDELink changed to avoid "duplicate comdat" symbols
269 class ScDDELinkObj
: public cppu::WeakImplHelper
<
270 css::sheet::XDDELink
,
271 css::container::XNamed
,
272 css::util::XRefreshable
,
273 css::sheet::XDDELinkResults
,
274 css::lang::XServiceInfo
>,
278 ScDocShell
* pDocShell
;
282 XRefreshListenerArr_Impl aRefreshListeners
;
284 void Refreshed_Impl();
287 ScDDELinkObj(ScDocShell
* pDocSh
, const OUString
& rA
,
288 const OUString
& rT
, const OUString
& rI
);
289 virtual ~ScDDELinkObj() override
;
291 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
294 virtual OUString SAL_CALL
getName() override
;
295 virtual void SAL_CALL
setName( const OUString
& aName
) override
;
298 virtual OUString SAL_CALL
getApplication() override
;
299 virtual OUString SAL_CALL
getTopic() override
;
300 virtual OUString SAL_CALL
getItem() override
;
303 virtual void SAL_CALL
refresh() override
;
304 virtual void SAL_CALL
addRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
305 virtual void SAL_CALL
removeRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
308 virtual css::uno::Sequence
< css::uno::Sequence
< css::uno::Any
> >
309 SAL_CALL
getResults( ) override
;
310 virtual void SAL_CALL
setResults(
311 const css::uno::Sequence
< css::uno::Sequence
< css::uno::Any
> >& aResults
) override
;
314 virtual OUString SAL_CALL
getImplementationName() override
;
315 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
316 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
319 class ScDDELinksObj
: public cppu::WeakImplHelper
<
320 css::container::XEnumerationAccess
,
321 css::container::XIndexAccess
,
322 css::sheet::XDDELinks
,
323 css::lang::XServiceInfo
>,
327 ScDocShell
* pDocShell
;
329 ScDDELinkObj
* GetObjectByIndex_Impl(sal_Int32 nIndex
);
330 ScDDELinkObj
* GetObjectByName_Impl(const OUString
& aName
);
333 ScDDELinksObj(ScDocShell
* pDocSh
);
334 virtual ~ScDDELinksObj() override
;
336 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
339 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
340 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
341 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
344 virtual sal_Int32 SAL_CALL
getCount() override
;
345 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
347 // XEnumerationAccess
348 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
349 createEnumeration() override
;
352 virtual css::uno::Type SAL_CALL
getElementType() override
;
353 virtual sal_Bool SAL_CALL
hasElements() override
;
356 virtual css::uno::Reference
< css::sheet::XDDELink
> SAL_CALL
addDDELink(
357 const OUString
& aApplication
, const OUString
& aTopic
,
358 const OUString
& aItem
, css::sheet::DDELinkMode nMode
) override
;
361 virtual OUString SAL_CALL
getImplementationName() override
;
362 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
363 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
366 class ScExternalSheetCacheObj
: public cppu::WeakImplHelper
< css::sheet::XExternalSheetCache
>
369 explicit ScExternalSheetCacheObj(ScDocShell
* pDocShell
, ScExternalRefCache::TableTypeRef
const & pTable
, size_t nIndex
);
370 virtual ~ScExternalSheetCacheObj() override
;
372 // XExternalSheetCache
373 virtual void SAL_CALL
setCellValue(
374 sal_Int32 nCol
, sal_Int32 nRow
, const css::uno::Any
& rAny
) override
;
376 virtual css::uno::Any SAL_CALL
getCellValue(sal_Int32 nCol
, sal_Int32 nRow
) override
;
378 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
getAllRows() override
;
380 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
getAllColumns(sal_Int32 nRow
) override
;
383 virtual sal_Int32 SAL_CALL
getTokenIndex() override
;
386 ScExternalSheetCacheObj(const ScExternalSheetCacheObj
&) = delete;
389 ScDocShell
* mpDocShell
;
390 ScExternalRefCache::TableTypeRef mpTable
;
394 class ScExternalDocLinkObj
: public cppu::WeakImplHelper
< css::sheet::XExternalDocLink
>
397 ScExternalDocLinkObj(ScDocShell
* pDocShell
, ScExternalRefManager
* pRefMgr
, sal_uInt16 nFileId
);
398 virtual ~ScExternalDocLinkObj() override
;
401 virtual css::uno::Reference
< css::sheet::XExternalSheetCache
>
402 SAL_CALL
addSheetCache( const OUString
& aSheetName
, sal_Bool bDynamicCache
) override
;
405 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
406 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
407 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
410 virtual sal_Int32 SAL_CALL
getCount() override
;
411 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 nIndex
) override
;
413 // XEnumerationAccess
414 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
415 createEnumeration() override
;
418 virtual css::uno::Type SAL_CALL
getElementType() override
;
419 virtual sal_Bool SAL_CALL
hasElements() override
;
422 virtual sal_Int32 SAL_CALL
getTokenIndex() override
;
425 ScDocShell
* mpDocShell
;
426 ScExternalRefManager
* mpRefMgr
;
430 /** This is the UNO API equivalent of ScExternalRefManager. */
431 class ScExternalDocLinksObj
: public cppu::WeakImplHelper
< css::sheet::XExternalDocLinks
>
434 ScExternalDocLinksObj(ScDocShell
* pDocShell
);
435 virtual ~ScExternalDocLinksObj() override
;
438 virtual css::uno::Reference
< css::sheet::XExternalDocLink
>
439 SAL_CALL
addDocLink( const OUString
& aDocName
) override
;
442 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
443 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
444 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
447 virtual sal_Int32 SAL_CALL
getCount() override
;
448 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 nIndex
) override
;
450 // XEnumerationAccess
451 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
452 createEnumeration() override
;
455 virtual css::uno::Type SAL_CALL
getElementType() override
;
456 virtual sal_Bool SAL_CALL
hasElements() override
;
459 ScExternalDocLinksObj(const ScExternalDocLinksObj
&) = delete;
462 ScDocShell
* mpDocShell
;
463 ScExternalRefManager
* mpRefMgr
;
468 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */