LibreOffice Module svx (master) 1
cell.hxx
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#ifndef INCLUDED_SVX_SOURCE_INC_CELL_HXX
21#define INCLUDED_SVX_SOURCE_INC_CELL_HXX
22
23#include <config_options.h>
24#include <com/sun/star/table/XMergeableCell.hpp>
25#include <com/sun/star/awt/XLayoutConstrains.hpp>
26#include <com/sun/star/lang/XEventListener.hpp>
27
28#include <rtl/ref.hxx>
29#include <svl/style.hxx>
30#include <svl/grabbagitem.hxx>
31#include <svx/sdtaitm.hxx>
32#include "tablemodel.hxx"
33#include <editeng/unotext.hxx>
34#include <svx/svdtext.hxx>
35
36
37class SfxItemSet;
39class SdrObject;
40namespace sdr::properties { class CellProperties; }
41
42
43namespace sdr::table {
44
45
46class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) Cell final : public SdrText,
47 public SvxUnoTextBase,
48 public css::table::XMergeableCell,
49 public css::awt::XLayoutConstrains,
50 public css::lang::XEventListener
51{
52 friend class CellUndo;
53
54public:
55 SVX_DLLPRIVATE static rtl::Reference< Cell > create( SdrTableObj& rTableObj );
56
57 // private
59
60 // SdrTextShape proxy
61 bool IsActiveCell() const;
62 bool IsTextEditActive() const;
63 SVX_DLLPRIVATE bool hasText() const;
64
65 SVX_DLLPRIVATE void cloneFrom( const CellRef& rCell );
66
67 SVX_DLLPRIVATE void setCellRect( ::tools::Rectangle const & rCellRect ) { maCellRect = rCellRect; }
68 SVX_DLLPRIVATE const ::tools::Rectangle& getCellRect() const { return maCellRect; }
69 SVX_DLLPRIVATE ::tools::Rectangle& getCellRect() { return maCellRect; }
70
71 bool CanCreateEditOutlinerParaObject() const;
72 std::optional<OutlinerParaObject> CreateEditOutlinerParaObject() const;
73 SVX_DLLPRIVATE void SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr );
74 SVX_DLLPRIVATE virtual SfxStyleSheet* GetStyleSheet() const override;
75 SVX_DLLPRIVATE void TakeTextAnchorRect(tools::Rectangle& rAnchorRect) const;
76
77 SVX_DLLPRIVATE void SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, bool bClearAllItems);
78 void SetMergedItem(const SfxPoolItem& rItem);
79
80 SVX_DLLPRIVATE sal_Int32 calcPreferredWidth( const Size aSize );
81 SVX_DLLPRIVATE sal_Int32 getMinimumWidth() const;
82 SVX_DLLPRIVATE sal_Int32 getMinimumHeight();
83
84 SVX_DLLPRIVATE tools::Long GetTextLeftDistance() const;
85 SVX_DLLPRIVATE tools::Long GetTextRightDistance() const;
86 SVX_DLLPRIVATE tools::Long GetTextUpperDistance() const;
87 SVX_DLLPRIVATE tools::Long GetTextLowerDistance() const;
88
90 SdrTextHorzAdjust GetTextHorizontalAdjust() const;
91
92 SVX_DLLPRIVATE void merge( sal_Int32 nColumnSpan, sal_Int32 nRowSpan );
93 SVX_DLLPRIVATE void mergeContent( const CellRef& xSourceCell );
94 SVX_DLLPRIVATE void replaceContentAndFormatting( const CellRef& xSourceCell );
95
96 SVX_DLLPRIVATE void setMerged();
97
98 SVX_DLLPRIVATE void copyFormatFrom( const CellRef& xSourceCell );
99
100 // XInterface
101 SVX_DLLPRIVATE virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& Type ) override;
102 virtual void SAL_CALL acquire() noexcept override;
103 virtual void SAL_CALL release() noexcept override;
104
105 // XTypeProvider
106 SVX_DLLPRIVATE virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
107 SVX_DLLPRIVATE virtual css::uno::Sequence< ::sal_Int8 > SAL_CALL getImplementationId( ) override;
108
109 // XLayoutConstrains
110 SVX_DLLPRIVATE virtual css::awt::Size SAL_CALL getMinimumSize() override;
111 SVX_DLLPRIVATE virtual css::awt::Size SAL_CALL getPreferredSize() override;
112 SVX_DLLPRIVATE virtual css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override;
113
114 // XMergeableCell
115 SVX_DLLPRIVATE virtual ::sal_Int32 SAL_CALL getRowSpan() override;
116 SVX_DLLPRIVATE virtual ::sal_Int32 SAL_CALL getColumnSpan() override;
117 virtual sal_Bool SAL_CALL isMerged() override;
118
119 // XCell
120 SVX_DLLPRIVATE virtual OUString SAL_CALL getFormula() override;
121 SVX_DLLPRIVATE virtual void SAL_CALL setFormula( const OUString& aFormula ) override;
122 SVX_DLLPRIVATE virtual double SAL_CALL getValue() override;
123 SVX_DLLPRIVATE virtual void SAL_CALL setValue( double nValue ) override;
124 SVX_DLLPRIVATE virtual css::table::CellContentType SAL_CALL getType() override;
125 SVX_DLLPRIVATE virtual sal_Int32 SAL_CALL getError() override;
126
127 // css::beans::XPropertySet
128 SVX_DLLPRIVATE virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
129 SVX_DLLPRIVATE virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
130 SVX_DLLPRIVATE virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
131 SVX_DLLPRIVATE virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
132 SVX_DLLPRIVATE virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
133 SVX_DLLPRIVATE virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
134 SVX_DLLPRIVATE virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
135
136 // XMultiPropertySet
137 SVX_DLLPRIVATE virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override;
138 SVX_DLLPRIVATE virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
139 SVX_DLLPRIVATE virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
140 SVX_DLLPRIVATE virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
141 SVX_DLLPRIVATE virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
142
143 // css::beans::XPropertyState
144 SVX_DLLPRIVATE virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
145 SVX_DLLPRIVATE virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
146 SVX_DLLPRIVATE virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
147 SVX_DLLPRIVATE virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
148
149 // XMultiPropertyStates
150 SVX_DLLPRIVATE virtual void SAL_CALL setAllPropertiesToDefault() override;
151 SVX_DLLPRIVATE virtual void SAL_CALL setPropertiesToDefault( const css::uno::Sequence< OUString >& aPropertyNames ) override;
152 SVX_DLLPRIVATE virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) override;
153
154 // XText
155 SVX_DLLPRIVATE virtual void SAL_CALL insertTextContent( const css::uno::Reference< css::text::XTextRange >& xRange, const css::uno::Reference< css::text::XTextContent >& xContent, sal_Bool bAbsorb ) override;
156 SVX_DLLPRIVATE virtual void SAL_CALL removeTextContent( const css::uno::Reference< css::text::XTextContent >& xContent ) override;
157
158 // XSimpleText
159 SVX_DLLPRIVATE virtual void SAL_CALL insertString( const css::uno::Reference< css::text::XTextRange >& xRange, const OUString& aString, sal_Bool bAbsorb ) override;
160 SVX_DLLPRIVATE virtual void SAL_CALL insertControlCharacter( const css::uno::Reference< css::text::XTextRange >& xRange, ::sal_Int16 nControlCharacter, sal_Bool bAbsorb ) override;
161
162 // XTextRange
163 SVX_DLLPRIVATE virtual OUString SAL_CALL getString( ) override;
164 SVX_DLLPRIVATE virtual void SAL_CALL setString( const OUString& aString ) override;
165
166 // XEventListener
167 SVX_DLLPRIVATE virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
168
169 SVX_DLLPRIVATE virtual void SetOutlinerParaObject( std::optional<OutlinerParaObject> pTextObject ) override;
170
171 SVX_DLLPRIVATE void AddUndo();
172
173 using SvxUnoTextRangeBase::setPropertyValue;
174 using SvxUnoTextRangeBase::getPropertyValue;
175
176 SVX_DLLPRIVATE sdr::properties::CellProperties* CloneProperties( SdrObject& rNewObj, Cell& rNewCell );
177
178 SVX_DLLPRIVATE void notifyModified();
179
180 void dumpAsXml(xmlTextWriterPtr pWriter, sal_Int32 nRow, sal_Int32 nCol) const;
181
182private:
183 SVX_DLLPRIVATE virtual const SfxItemSet& GetObjectItemSet() override;
184 SVX_DLLPRIVATE void SetObjectItem(const SfxPoolItem& rItem);
185
186 SVX_DLLPRIVATE static css::uno::Any GetAnyForItem( SfxItemSet const & aSet, const SfxItemPropertyMapEntry* pMap );
187
189 SVX_DLLPRIVATE Cell( SdrTableObj& rTableObj );
190 SVX_DLLPRIVATE virtual ~Cell() COVERITY_NOEXCEPT_FALSE override;
191
192 Cell(Cell const &) = delete;
193 void operator =(Cell const &) = delete;
194
195 const SvxItemPropertySet* mpPropSet;
196
197 std::unique_ptr<sdr::properties::CellProperties> mpProperties;
198
199 css::table::CellContentType mnCellContentType;
200
201 OUString msFormula;
202 double mfValue;
203 ::sal_Int32 mnError;
204 bool mbMerged;
205 ::sal_Int32 mnRowSpan;
206 ::sal_Int32 mnColSpan;
207
208 tools::Rectangle maCellRect;
209
210 css::uno::Reference< css::table::XTable > mxTable;
211
212 std::unique_ptr<SfxGrabBagItem> mpGrabBagItem = {};
213};
214
215
216}
217
218#endif
219
220/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Abstract DrawObject.
Definition: svdobj.hxx:260
struct _xmlTextWriter * xmlTextWriterPtr
sal_Int16 nValue
Definition: fmsrccfg.cxx:81
Type
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
TextVerticalAdjust GetTextVerticalAdjust(sal_Int32 nToken)
rtl::Reference< Cell > CellRef
Definition: celltypes.hxx:33
void dispose()
long Long
SdrTextVertAdjust
Definition: sdtaitm.hxx:29
SdrTextHorzAdjust
Definition: sdtaitm.hxx:53
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30
sal_Int32 mnColSpan
sal_Int32 mnRowSpan
unsigned char sal_Bool
signed char sal_Int8