Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / inc / targuno.hxx
blobb45c56f5752fbe47468afdd81dc30a90e01edc77
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 <com/sun/star/document/XLinkTargetSupplier.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/container/XNameAccess.hpp>
27 #include <cppuhelper/implbase.hxx>
29 namespace com::sun::star::beans { class XPropertyChangeListener; }
30 namespace com::sun::star::beans { class XPropertySetInfo; }
31 namespace com::sun::star::beans { class XVetoableChangeListener; }
33 class ScDocShell;
35 #define SC_LINKTARGETTYPE_SHEET 0
36 #define SC_LINKTARGETTYPE_RANGENAME 1
37 #define SC_LINKTARGETTYPE_DBAREA 2
39 #define SC_LINKTARGETTYPE_COUNT 3
41 inline constexpr OUString SCLINKTARGET_SERVICE = u"com.sun.star.document.LinkTarget"_ustr;
43 //! Graphic / OleObject (need separate collections!)
45 class ScLinkTargetTypesObj final : public ::cppu::WeakImplHelper<
46 css::container::XNameAccess,
47 css::lang::XServiceInfo >,
48 public SfxListener
50 private:
51 ScDocShell* pDocShell;
52 OUString aNames[SC_LINKTARGETTYPE_COUNT];
54 public:
55 ScLinkTargetTypesObj(ScDocShell* pDocSh);
56 virtual ~ScLinkTargetTypesObj() override;
58 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
60 // css::container::XNameAccess
61 virtual css::uno::Any SAL_CALL getByName(const OUString& aName) override;
62 virtual css::uno::Sequence< OUString> SAL_CALL getElementNames() override;
63 virtual sal_Bool SAL_CALL hasByName(const OUString& aName) override;
65 // css::container::XElementAccess
66 virtual css::uno::Type SAL_CALL getElementType() override;
67 virtual sal_Bool SAL_CALL hasElements() override;
69 // css::lang::XServiceInfo
70 virtual OUString SAL_CALL getImplementationName() override;
71 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
72 virtual css::uno::Sequence< OUString> SAL_CALL getSupportedServiceNames() override;
75 class ScLinkTargetTypeObj final : public ::cppu::WeakImplHelper<
76 css::beans::XPropertySet,
77 css::document::XLinkTargetSupplier,
78 css::lang::XServiceInfo >,
79 public SfxListener
81 private:
82 ScDocShell* pDocShell;
83 sal_uInt16 nType;
84 OUString aName;
86 public:
87 ScLinkTargetTypeObj(ScDocShell* pDocSh, sal_uInt16 nT);
88 virtual ~ScLinkTargetTypeObj() override;
90 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
92 static void SetLinkTargetBitmap( css::uno::Any& rRet, sal_uInt16 nType );
94 // css::beans::XPropertySet
95 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
96 virtual void SAL_CALL setPropertyValue(const OUString& aPropertyName,
97 const css::uno::Any& aValue) override;
98 virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& PropertyName) override;
99 virtual void SAL_CALL addPropertyChangeListener(const OUString& aPropertyName,
100 const css::uno::Reference< css::beans::XPropertyChangeListener > & xListener) override;
101 virtual void SAL_CALL removePropertyChangeListener(const OUString& aPropertyName,
102 const css::uno::Reference< css::beans::XPropertyChangeListener > & aListener) override;
103 virtual void SAL_CALL addVetoableChangeListener(const OUString& PropertyName,
104 const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener) override;
105 virtual void SAL_CALL removeVetoableChangeListener(const OUString& PropertyName,
106 const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener) override;
108 // css::document::XLinkTargetSupplier
109 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getLinks() override;
111 // css::lang::XServiceInfo
112 virtual OUString SAL_CALL getImplementationName() override;
113 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
114 virtual css::uno::Sequence< OUString> SAL_CALL getSupportedServiceNames() override;
117 class ScLinkTargetsObj final : public ::cppu::WeakImplHelper<
118 css::container::XNameAccess,
119 css::lang::XServiceInfo >
121 private:
122 css::uno::Reference< css::container::XNameAccess > xCollection;
124 public:
125 ScLinkTargetsObj( css::uno::Reference< css::container::XNameAccess > xColl );
126 virtual ~ScLinkTargetsObj() override;
128 // css::container::XNameAccess
129 virtual css::uno::Any SAL_CALL getByName(const OUString& aName) override;
130 virtual css::uno::Sequence< OUString> SAL_CALL getElementNames() override;
131 virtual sal_Bool SAL_CALL hasByName(const OUString& aName) override;
133 // css::container::XElementAccess
134 virtual css::uno::Type SAL_CALL getElementType() override;
135 virtual sal_Bool SAL_CALL hasElements() override;
137 // css::lang::XServiceInfo
138 virtual OUString SAL_CALL getImplementationName() override;
139 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
140 virtual css::uno::Sequence< OUString> SAL_CALL getSupportedServiceNames() override;
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */