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