Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SVX_CELL_HXX_
30 : : #define _SVX_CELL_HXX_
31 : :
32 : : #include <com/sun/star/table/XMergeableCell.hpp>
33 : : #include <com/sun/star/awt/XLayoutConstrains.hpp>
34 : : #include <com/sun/star/beans/XMultiPropertyStates.hpp>
35 : : #include <com/sun/star/lang/XEventListener.hpp>
36 : :
37 : : #include <cppuhelper/implbase3.hxx>
38 : : #include <rtl/ref.hxx>
39 : : #include <svl/style.hxx>
40 : : #include "svx/sdtaitm.hxx"
41 : : #include "tablemodel.hxx"
42 : : #include "editeng/unotext.hxx"
43 : : #include "svx/svdtext.hxx"
44 : :
45 : : // -----------------------------------------------------------------------------
46 : :
47 : : class SfxItemSet;
48 : : class OutlinerParaObject;
49 : : class SdrObject;
50 : :
51 : : namespace sdr { namespace properties {
52 : : class TextProperties;
53 : : } }
54 : :
55 : : // -----------------------------------------------------------------------------
56 : :
57 : : namespace sdr { namespace table {
58 : :
59 : : // -----------------------------------------------------------------------------
60 : :
61 : : typedef
62 : : cppu::AggImplInheritanceHelper3<
63 : : SvxUnoTextBase,
64 : : ::com::sun::star::table::XMergeableCell,
65 : : ::com::sun::star::awt::XLayoutConstrains,
66 : : ::com::sun::star::lang::XEventListener >
67 : : Cell_Base;
68 : :
69 : : class SVX_DLLPUBLIC Cell : public SdrText, public Cell_Base
70 : : {
71 : : friend class CellUndo;
72 : :
73 : : public:
74 : : SVX_DLLPRIVATE static rtl::Reference< Cell > create( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject );
75 : :
76 : : // private
77 : : SVX_DLLPRIVATE void dispose();
78 : :
79 : : // SdrTextShape proxy
80 : : bool IsTextEditActive();
81 : : SVX_DLLPRIVATE bool hasText() const;
82 : :
83 : : SVX_DLLPRIVATE void cloneFrom( const CellRef& rCell );
84 : :
85 : 480 : SVX_DLLPRIVATE void setCellRect( ::Rectangle& rCellRect ) { maCellRect = rCellRect; }
86 : : SVX_DLLPRIVATE const ::Rectangle& getCellRect() const { return maCellRect; }
87 : 0 : SVX_DLLPRIVATE ::Rectangle& getCellRect() { return maCellRect; }
88 : :
89 : : OutlinerParaObject* GetEditOutlinerParaObject() const;
90 : : SVX_DLLPRIVATE void SetStyleSheet( SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr );
91 : : SVX_DLLPRIVATE virtual SfxStyleSheet* GetStyleSheet() const;
92 : : SVX_DLLPRIVATE virtual const Rectangle& GetCurrentBoundRect() const;
93 : : SVX_DLLPRIVATE virtual void TakeTextAnchorRect(Rectangle& rAnchorRect) const;
94 : :
95 : : SVX_DLLPRIVATE virtual const SfxItemSet& GetItemSet() const;
96 : : SVX_DLLPRIVATE void SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems);
97 : : void SetMergedItem(const SfxPoolItem& rItem);
98 : :
99 : : SVX_DLLPRIVATE sal_Int32 getMinimumWidth();
100 : : SVX_DLLPRIVATE sal_Int32 getMinimumHeight();
101 : :
102 : : SVX_DLLPRIVATE long GetTextLeftDistance() const;
103 : : SVX_DLLPRIVATE long GetTextRightDistance() const;
104 : : SVX_DLLPRIVATE long GetTextUpperDistance() const;
105 : : SVX_DLLPRIVATE long GetTextLowerDistance() const;
106 : :
107 : : SVX_DLLPRIVATE SdrTextVertAdjust GetTextVerticalAdjust() const;
108 : : SdrTextHorzAdjust GetTextHorizontalAdjust() const;
109 : :
110 : : SVX_DLLPRIVATE virtual void SetModel(SdrModel* pNewModel);
111 : :
112 : : SVX_DLLPRIVATE void merge( sal_Int32 nColumnSpan, sal_Int32 nRowSpan );
113 : : SVX_DLLPRIVATE void mergeContent( const CellRef& xSourceCell );
114 : : SVX_DLLPRIVATE void replaceContentAndFormating( const CellRef& xSourceCell );
115 : :
116 : : SVX_DLLPRIVATE void setMerged();
117 : :
118 : : // XServiceInfo
119 : : SVX_DLLPRIVATE virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
120 : : SVX_DLLPRIVATE virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
121 : : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
122 : :
123 : : // XLayoutConstrains
124 : : SVX_DLLPRIVATE virtual ::com::sun::star::awt::Size SAL_CALL getMinimumSize( ) throw (::com::sun::star::uno::RuntimeException);
125 : : SVX_DLLPRIVATE virtual ::com::sun::star::awt::Size SAL_CALL getPreferredSize( ) throw (::com::sun::star::uno::RuntimeException);
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);
127 : :
128 : : // XMergeableCell
129 : : SVX_DLLPRIVATE virtual ::sal_Int32 SAL_CALL getRowSpan() throw (::com::sun::star::uno::RuntimeException);
130 : : SVX_DLLPRIVATE virtual ::sal_Int32 SAL_CALL getColumnSpan() throw (::com::sun::star::uno::RuntimeException);
131 : : SVX_DLLPRIVATE virtual ::sal_Bool SAL_CALL isMerged() throw (::com::sun::star::uno::RuntimeException);
132 : :
133 : : // XCell
134 : : SVX_DLLPRIVATE virtual ::rtl::OUString SAL_CALL getFormula() throw (::com::sun::star::uno::RuntimeException);
135 : : SVX_DLLPRIVATE virtual void SAL_CALL setFormula( const ::rtl::OUString& aFormula ) throw (::com::sun::star::uno::RuntimeException);
136 : : SVX_DLLPRIVATE virtual double SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
137 : : SVX_DLLPRIVATE virtual void SAL_CALL setValue( double nValue ) throw (::com::sun::star::uno::RuntimeException);
138 : : SVX_DLLPRIVATE virtual ::com::sun::star::table::CellContentType SAL_CALL getType() throw (::com::sun::star::uno::RuntimeException);
139 : : SVX_DLLPRIVATE virtual sal_Int32 SAL_CALL getError() throw (::com::sun::star::uno::RuntimeException);
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);
143 : : SVX_DLLPRIVATE virtual void SAL_CALL setPropertyValue( const ::rtl::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);
144 : : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
145 : : SVX_DLLPRIVATE virtual void SAL_CALL addPropertyChangeListener( const ::rtl::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);
146 : : SVX_DLLPRIVATE virtual void SAL_CALL removePropertyChangeListener( const ::rtl::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);
147 : : SVX_DLLPRIVATE virtual void SAL_CALL addVetoableChangeListener( const ::rtl::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);
148 : : SVX_DLLPRIVATE virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::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);
149 : :
150 : : // XMultiPropertySet
151 : : SVX_DLLPRIVATE virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::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);
152 : : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException);
153 : : SVX_DLLPRIVATE virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
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);
155 : : SVX_DLLPRIVATE virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
156 : :
157 : : // ::com::sun::star::beans::XPropertyState
158 : : SVX_DLLPRIVATE virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
159 : : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
160 : : SVX_DLLPRIVATE virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
161 : : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
162 : :
163 : : // XMultiPropertyStates
164 : : SVX_DLLPRIVATE virtual void SAL_CALL setAllPropertiesToDefault( ) throw (::com::sun::star::uno::RuntimeException);
165 : : SVX_DLLPRIVATE virtual void SAL_CALL setPropertiesToDefault( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
166 : : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyDefaults( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
167 : :
168 : : // XFastPropertySet
169 : : 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);
170 : : 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);
171 : :
172 : : // XText
173 : : 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);
174 : : 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);
175 : :
176 : : // XSimpleText
177 : : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursor( ) throw (::com::sun::star::uno::RuntimeException);
178 : : 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);
179 : : SVX_DLLPRIVATE virtual void SAL_CALL insertString( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xRange, const ::rtl::OUString& aString, ::sal_Bool bAbsorb ) throw (::com::sun::star::uno::RuntimeException);
180 : : 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);
181 : :
182 : : // XTextRange
183 : : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText( ) throw (::com::sun::star::uno::RuntimeException);
184 : : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart( ) throw (::com::sun::star::uno::RuntimeException);
185 : : SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd( ) throw (::com::sun::star::uno::RuntimeException);
186 : : SVX_DLLPRIVATE virtual ::rtl::OUString SAL_CALL getString( ) throw (::com::sun::star::uno::RuntimeException);
187 : : SVX_DLLPRIVATE virtual void SAL_CALL setString( const ::rtl::OUString& aString ) throw (::com::sun::star::uno::RuntimeException);
188 : :
189 : : // XEventListener
190 : : SVX_DLLPRIVATE virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
191 : :
192 : : SVX_DLLPRIVATE virtual void SetOutlinerParaObject( OutlinerParaObject* pTextObject );
193 : :
194 : : SVX_DLLPRIVATE void AddUndo();
195 : :
196 : : using SvxUnoTextRangeBase::setPropertyValue;
197 : : using SvxUnoTextRangeBase::getPropertyValue;
198 : :
199 : : SVX_DLLPRIVATE sdr::properties::TextProperties* CloneProperties( SdrObject& rNewObj, Cell& rNewCell );
200 : :
201 : : SVX_DLLPRIVATE static sdr::properties::TextProperties* CloneProperties( sdr::properties::TextProperties* pProperties, SdrObject& rNewObj, Cell& rNewCell );
202 : :
203 : : SVX_DLLPRIVATE void notifyModified();
204 : :
205 : : ::rtl::OUString getName();
206 : :
207 : : protected:
208 : : SVX_DLLPRIVATE virtual const SfxItemSet& GetObjectItemSet();
209 : : SVX_DLLPRIVATE virtual void SetObjectItem(const SfxPoolItem& rItem);
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 : : ::rtl::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: */
|