Line data Source code
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_TABLE_CELL_HXX
21 : #define INCLUDED_SVX_SOURCE_TABLE_CELL_HXX
22 :
23 : #include <com/sun/star/table/XMergeableCell.hpp>
24 : #include <com/sun/star/awt/XLayoutConstrains.hpp>
25 : #include <com/sun/star/beans/XMultiPropertyStates.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 :
37 : class SfxItemSet;
38 : class OutlinerParaObject;
39 : class SdrObject;
40 :
41 : namespace sdr { namespace properties {
42 : class TextProperties;
43 : } }
44 :
45 :
46 :
47 : namespace sdr { namespace table {
48 :
49 :
50 :
51 : class SVX_DLLPUBLIC Cell : public SdrText,
52 : public SvxUnoTextBase,
53 : public ::com::sun::star::table::XMergeableCell,
54 : public ::com::sun::star::awt::XLayoutConstrains,
55 : public ::com::sun::star::lang::XEventListener,
56 : public ::cppu::OWeakObject
57 : {
58 : friend class CellUndo;
59 :
60 : public:
61 : SVX_DLLPRIVATE static rtl::Reference< Cell > create( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject );
62 :
63 : // private
64 : SVX_DLLPRIVATE void dispose();
65 :
66 : // SdrTextShape proxy
67 : bool IsTextEditActive();
68 : SVX_DLLPRIVATE bool hasText() const;
69 :
70 : SVX_DLLPRIVATE void cloneFrom( const CellRef& rCell );
71 :
72 0 : SVX_DLLPRIVATE void setCellRect( ::Rectangle& rCellRect ) { maCellRect = rCellRect; }
73 : SVX_DLLPRIVATE const ::Rectangle& getCellRect() const { return maCellRect; }
74 0 : SVX_DLLPRIVATE ::Rectangle& getCellRect() { return maCellRect; }
75 :
76 : OutlinerParaObject* GetEditOutlinerParaObject() const;
77 : SVX_DLLPRIVATE void SetStyleSheet( SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr );
78 : SVX_DLLPRIVATE virtual SfxStyleSheet* GetStyleSheet() const SAL_OVERRIDE;
79 : SVX_DLLPRIVATE virtual const Rectangle& GetCurrentBoundRect() const;
80 : SVX_DLLPRIVATE virtual void TakeTextAnchorRect(Rectangle& rAnchorRect) const;
81 :
82 : SVX_DLLPRIVATE virtual const SfxItemSet& GetItemSet() const SAL_OVERRIDE;
83 : SVX_DLLPRIVATE void SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems);
84 : void SetMergedItem(const SfxPoolItem& rItem);
85 :
86 : SVX_DLLPRIVATE sal_Int32 getMinimumWidth();
87 : SVX_DLLPRIVATE sal_Int32 getMinimumHeight();
88 :
89 : SVX_DLLPRIVATE long GetTextLeftDistance() const;
90 : SVX_DLLPRIVATE long GetTextRightDistance() const;
91 : SVX_DLLPRIVATE long GetTextUpperDistance() const;
92 : SVX_DLLPRIVATE long GetTextLowerDistance() const;
93 :
94 : SVX_DLLPRIVATE SdrTextVertAdjust GetTextVerticalAdjust() const;
95 : SdrTextHorzAdjust GetTextHorizontalAdjust() const;
96 :
97 : SVX_DLLPRIVATE virtual void SetModel(SdrModel* pNewModel) SAL_OVERRIDE;
98 :
99 : SVX_DLLPRIVATE void merge( sal_Int32 nColumnSpan, sal_Int32 nRowSpan );
100 : SVX_DLLPRIVATE void mergeContent( const CellRef& xSourceCell );
101 : SVX_DLLPRIVATE void replaceContentAndFormating( const CellRef& xSourceCell );
102 :
103 : SVX_DLLPRIVATE void setMerged();
104 :
105 : // XInterface
106 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& Type ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 : SVX_DLLPRIVATE virtual void SAL_CALL acquire() throw () SAL_OVERRIDE;
108 : SVX_DLLPRIVATE virtual void SAL_CALL release() throw () SAL_OVERRIDE;
109 :
110 : // XTypeProvider
111 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 :
114 : // XServiceInfo
115 : SVX_DLLPRIVATE virtual OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 : SVX_DLLPRIVATE virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
117 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 :
119 : // XLayoutConstrains
120 : SVX_DLLPRIVATE virtual ::com::sun::star::awt::Size SAL_CALL getMinimumSize()
121 : throw (::com::sun::star::uno::RuntimeException,
122 : std::exception) SAL_OVERRIDE;
123 : SVX_DLLPRIVATE virtual ::com::sun::star::awt::Size SAL_CALL getPreferredSize()
124 : throw (::com::sun::star::uno::RuntimeException,
125 : std::exception) SAL_OVERRIDE;
126 : SVX_DLLPRIVATE virtual ::com::sun::star::awt::Size SAL_CALL calcAdjustedSize( const ::com::sun::star::awt::Size& aNewSize ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
127 :
128 : // XMergeableCell
129 : SVX_DLLPRIVATE virtual ::sal_Int32 SAL_CALL getRowSpan() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
130 : SVX_DLLPRIVATE virtual ::sal_Int32 SAL_CALL getColumnSpan() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 : SVX_DLLPRIVATE virtual sal_Bool SAL_CALL isMerged() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
132 :
133 : // XCell
134 : SVX_DLLPRIVATE virtual OUString SAL_CALL getFormula() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135 : SVX_DLLPRIVATE virtual void SAL_CALL setFormula( const OUString& aFormula ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
136 : SVX_DLLPRIVATE virtual double SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
137 : SVX_DLLPRIVATE virtual void SAL_CALL setValue( double nValue ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
138 : SVX_DLLPRIVATE virtual ::com::sun::star::table::CellContentType SAL_CALL getType() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
139 : SVX_DLLPRIVATE virtual sal_Int32 SAL_CALL getError() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
140 :
141 : // ::com::sun::star::beans::XPropertySet
142 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
143 : SVX_DLLPRIVATE virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
144 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
145 : SVX_DLLPRIVATE virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
146 : SVX_DLLPRIVATE virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
147 : SVX_DLLPRIVATE virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
148 : SVX_DLLPRIVATE virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
149 :
150 : // XMultiPropertySet
151 : SVX_DLLPRIVATE virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
152 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
153 : SVX_DLLPRIVATE virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
154 : SVX_DLLPRIVATE virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
155 : SVX_DLLPRIVATE virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
156 :
157 : // ::com::sun::star::beans::XPropertyState
158 : SVX_DLLPRIVATE virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
159 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
160 : SVX_DLLPRIVATE virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
161 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
162 :
163 : // XMultiPropertyStates
164 : SVX_DLLPRIVATE virtual void SAL_CALL setAllPropertiesToDefault()
165 : throw (::com::sun::star::uno::RuntimeException,
166 : std::exception) SAL_OVERRIDE;
167 : SVX_DLLPRIVATE virtual void SAL_CALL setPropertiesToDefault( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
168 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyDefaults( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
169 :
170 : // XFastPropertySet
171 : SVX_DLLPRIVATE virtual void SAL_CALL setFastPropertyValue( ::sal_Int32 nHandle, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
172 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
173 :
174 : // XText
175 : SVX_DLLPRIVATE virtual void SAL_CALL insertTextContent( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xRange, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >& xContent, sal_Bool bAbsorb ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
176 : SVX_DLLPRIVATE virtual void SAL_CALL removeTextContent( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >& xContent ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 :
178 : // XSimpleText
179 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursor( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursorByRange( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& aTextPosition ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
181 : SVX_DLLPRIVATE virtual void SAL_CALL insertString( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xRange, const OUString& aString, sal_Bool bAbsorb ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
182 : SVX_DLLPRIVATE virtual void SAL_CALL insertControlCharacter( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xRange, ::sal_Int16 nControlCharacter, sal_Bool bAbsorb ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
183 :
184 : // XTextRange
185 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
186 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
187 : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
188 : SVX_DLLPRIVATE virtual OUString SAL_CALL getString( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
189 : SVX_DLLPRIVATE virtual void SAL_CALL setString( const OUString& aString ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
190 :
191 : // XEventListener
192 : SVX_DLLPRIVATE virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
193 :
194 : SVX_DLLPRIVATE virtual void SetOutlinerParaObject( OutlinerParaObject* pTextObject ) SAL_OVERRIDE;
195 :
196 : SVX_DLLPRIVATE void AddUndo();
197 :
198 : using SvxUnoTextRangeBase::setPropertyValue;
199 : using SvxUnoTextRangeBase::getPropertyValue;
200 :
201 : SVX_DLLPRIVATE sdr::properties::TextProperties* CloneProperties( SdrObject& rNewObj, Cell& rNewCell );
202 :
203 : SVX_DLLPRIVATE static sdr::properties::TextProperties* CloneProperties( sdr::properties::TextProperties* pProperties, SdrObject& rNewObj, Cell& rNewCell );
204 :
205 : SVX_DLLPRIVATE void notifyModified();
206 :
207 : protected:
208 : SVX_DLLPRIVATE virtual const SfxItemSet& GetObjectItemSet() SAL_OVERRIDE;
209 : SVX_DLLPRIVATE virtual void SetObjectItem(const SfxPoolItem& rItem) SAL_OVERRIDE;
210 :
211 : SVX_DLLPRIVATE ::com::sun::star::uno::Any GetAnyForItem( SfxItemSet& aSet, const SfxItemPropertySimpleEntry* pMap );
212 :
213 : private:
214 : SVX_DLLPRIVATE Cell( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject ) throw();
215 : SVX_DLLPRIVATE virtual ~Cell() throw();
216 :
217 : const SvxItemPropertySet* mpPropSet;
218 :
219 : sdr::properties::TextProperties* mpProperties;
220 :
221 : ::com::sun::star::table::CellContentType mnCellContentType;
222 :
223 : OUString msFormula;
224 : double mfValue;
225 : ::sal_Int32 mnError;
226 : sal_Bool mbMerged;
227 : ::sal_Int32 mnRowSpan;
228 : ::sal_Int32 mnColSpan;
229 :
230 : Rectangle maCellRect;
231 :
232 : ::com::sun::star::uno::Reference< ::com::sun::star::table::XTable > mxTable;
233 : };
234 :
235 :
236 :
237 : } }
238 :
239 : #endif
240 :
241 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|