Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / inc / shapeuno.hxx
blob977c58be75c4e79d1fe99e17db475c46891b76db
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 <com/sun/star/beans/XPropertyState.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/text/XTextContent.hpp>
25 #include <com/sun/star/text/XText.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/document/XEventsSupplier.hpp>
28 #include <com/sun/star/container/XChild.hpp>
30 #include <cppuhelper/implbase.hxx>
31 #include <cppuhelper/implbase1.hxx>
33 namespace com::sun::star {
34 namespace uno {
35 class XAggregation;
37 namespace drawing {
38 class XShape;
42 class SdrObject;
43 struct SvEventDescription;
44 class ScMacroInfo;
46 // object which aggregates all svx shape objects,
47 // to add own properties
49 typedef ::cppu::WeakImplHelper < css::beans::XPropertySet
50 , css::beans::XPropertyState
51 , css::text::XTextContent
52 , css::document::XEventsSupplier
53 , css::lang::XServiceInfo
54 > ScShapeObj_Base;
55 typedef ::cppu::ImplHelper1 < css::text::XText
56 > ScShapeObj_TextBase;
57 typedef ::cppu::ImplHelper1 < css::container::XChild
58 > ScShapeObj_ChildBase;
59 class ScShapeObj final : public ScShapeObj_Base
60 ,public ScShapeObj_TextBase
61 ,public ScShapeObj_ChildBase
63 private:
64 friend ScMacroInfo* ScShapeObj_getShapeHyperMacroInfo( const ScShapeObj* pShape, bool bCreate );
65 css::uno::Reference< css::uno::XAggregation > mxShapeAgg;
66 // cached pointers to avoid repeated queryAggregation calls:
67 css::beans::XPropertySet* pShapePropertySet;
68 css::beans::XPropertyState* pShapePropertyState;
69 css::uno::Reference< css::beans::XPropertySetInfo > mxPropSetInfo;
70 bool bIsTextShape;
71 bool bIsNoteCaption;
73 SdrObject* GetSdrObject() const noexcept;
75 void GetShapePropertySet();
76 void GetShapePropertyState();
78 friend class ShapeUnoEventAccessImpl;
80 public:
81 static const SvEventDescription* GetSupportedMacroItems();
83 // ctor modifies xShape parameter
84 ScShapeObj( css::uno::Reference<
85 css::drawing::XShape > & xShape );
86 virtual ~ScShapeObj() override;
88 // XInterface
89 virtual css::uno::Any SAL_CALL queryInterface(
90 const css::uno::Type & rType ) override;
91 virtual void SAL_CALL acquire() noexcept override;
92 virtual void SAL_CALL release() noexcept override;
94 // XPropertySet
95 virtual css::uno::Reference< css::beans::XPropertySetInfo >
96 SAL_CALL getPropertySetInfo() override;
97 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
98 const css::uno::Any& aValue ) override;
99 virtual css::uno::Any SAL_CALL getPropertyValue(
100 const OUString& PropertyName ) override;
101 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
102 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
103 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
104 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
105 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
106 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
107 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
108 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
110 // XPropertyState
111 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
112 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL
113 getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
114 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
115 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
117 // XTextContent
118 virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > & xTextRange) override;
119 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
120 getAnchor() override;
122 // XComponent
123 virtual void SAL_CALL dispose() override;
124 virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override;
125 virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override;
127 // XText
128 virtual void SAL_CALL insertTextContent( const css::uno::Reference< css::text::XTextRange >& xRange,
129 const css::uno::Reference< css::text::XTextContent >& xContent,
130 sal_Bool bAbsorb ) override;
131 virtual void SAL_CALL removeTextContent( const css::uno::Reference< css::text::XTextContent >& xContent ) override;
133 // XSimpleText
134 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL
135 createTextCursor() override;
136 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL
137 createTextCursorByRange( const css::uno::Reference< css::text::XTextRange >& aTextPosition ) override;
138 virtual void SAL_CALL insertString( const css::uno::Reference< css::text::XTextRange >& xRange,
139 const OUString& aString, sal_Bool bAbsorb ) override;
140 virtual void SAL_CALL insertControlCharacter( const css::uno::Reference< css::text::XTextRange >& xRange,
141 sal_Int16 nControlCharacter, sal_Bool bAbsorb ) override;
143 // XTextRange
144 virtual css::uno::Reference< css::text::XText > SAL_CALL
145 getText() override;
146 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
147 getStart() override;
148 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
149 getEnd() override;
150 virtual OUString SAL_CALL getString() override;
151 virtual void SAL_CALL setString( const OUString& aString ) override;
153 // XChild
154 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override;
155 virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& xParent ) override;
157 // XTypeProvider
158 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
159 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
161 // XEventsSupplier
162 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents() override;
164 // XServiceInfo
165 virtual OUString SAL_CALL getImplementationName( ) override ;
166 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
167 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */