xref: /aoo41x/main/svx/source/table/cell.cxx (revision a9ab3c7b)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f6e50924SAndrew Rist  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19f6e50924SAndrew Rist  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/drawing/BitmapMode.hpp>
28cdf0e10cSrcweir #include <com/sun/star/style/XStyle.hpp>
29cdf0e10cSrcweir #include <com/sun/star/text/WritingMode.hpp>
30cdf0e10cSrcweir #include <com/sun/star/table/TableBorder.hpp>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
33cdf0e10cSrcweir #include <svl/style.hxx>
34cdf0e10cSrcweir #include <svl/itemset.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <vos/mutex.hxx>
37cdf0e10cSrcweir #include <vcl/svapp.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include "svx/sdr/properties/textproperties.hxx"
40cdf0e10cSrcweir #include "editeng/outlobj.hxx"
41cdf0e10cSrcweir #include "editeng/writingmodeitem.hxx"
42cdf0e10cSrcweir #include "svx/svdotable.hxx"
43cdf0e10cSrcweir #include "svx/svdoutl.hxx"
44cdf0e10cSrcweir #include "svx/unoshtxt.hxx"
45cdf0e10cSrcweir #include "svx/svdmodel.hxx"
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include "tableundo.hxx"
48cdf0e10cSrcweir #include "cell.hxx"
49cdf0e10cSrcweir #include "svx/svdotable.hxx"
50cdf0e10cSrcweir #include "svx/svdoutl.hxx"
51cdf0e10cSrcweir #include "svx/unoshtxt.hxx"
52cdf0e10cSrcweir #include "svx/unoshprp.hxx"
53cdf0e10cSrcweir #include "svx/unoshape.hxx"
54cdf0e10cSrcweir #include "editeng/editobj.hxx"
55cdf0e10cSrcweir #include "editeng/boxitem.hxx"
56cdf0e10cSrcweir #include "svx/xflbstit.hxx"
57cdf0e10cSrcweir #include "svx/xflbmtit.hxx"
58cdf0e10cSrcweir #include <svx/svdpool.hxx>
59cdf0e10cSrcweir 
60cdf0e10cSrcweir // -----------------------------------------------------------------------------
61cdf0e10cSrcweir 
62cdf0e10cSrcweir using ::rtl::OUString;
63cdf0e10cSrcweir using ::vos::OGuard;
64cdf0e10cSrcweir using namespace ::com::sun::star::uno;
65cdf0e10cSrcweir using namespace ::com::sun::star::beans;
66cdf0e10cSrcweir using namespace ::com::sun::star::lang;
67cdf0e10cSrcweir using namespace ::com::sun::star::text;
68cdf0e10cSrcweir using namespace ::com::sun::star::table;
69cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
70cdf0e10cSrcweir using namespace ::com::sun::star::style;
71cdf0e10cSrcweir using namespace ::com::sun::star::container;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir // -----------------------------------------------------------------------------
74cdf0e10cSrcweir 
ImplGetSvxCellPropertySet()75cdf0e10cSrcweir static const SvxItemPropertySet* ImplGetSvxCellPropertySet()
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 	// Propertymap fuer einen Outliner Text
78cdf0e10cSrcweir     static const SfxItemPropertyMapEntry aSvxCellPropertyMap[] =
79cdf0e10cSrcweir 	{
80cdf0e10cSrcweir 		FILL_PROPERTIES
81cdf0e10cSrcweir //		{ MAP_CHAR_LEN("HasLevels"),					OWN_ATTR_HASLEVELS,				&::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::READONLY,		0},
82cdf0e10cSrcweir 		{ MAP_CHAR_LEN("Style"),						OWN_ATTR_STYLE,					&::com::sun::star::style::XStyle::static_type(),									::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
83cdf0e10cSrcweir 		{ MAP_CHAR_LEN(UNO_NAME_TEXT_WRITINGMODE),		SDRATTR_TEXTDIRECTION,			&::getCppuType( (::com::sun::star::text::WritingMode*) 0 ),							0,		0},
84cdf0e10cSrcweir 		{ MAP_CHAR_LEN(UNO_NAME_TEXT_HORZADJUST),		SDRATTR_TEXT_HORZADJUST,		&::getCppuType((const ::com::sun::star::drawing::TextHorizontalAdjust*)0),	0,		0}, \
85cdf0e10cSrcweir 		{ MAP_CHAR_LEN(UNO_NAME_TEXT_LEFTDIST),			SDRATTR_TEXT_LEFTDIST,			&::getCppuType((const sal_Int32*)0),		0,		SFX_METRIC_ITEM}, \
86cdf0e10cSrcweir 		{ MAP_CHAR_LEN(UNO_NAME_TEXT_LOWERDIST),		SDRATTR_TEXT_LOWERDIST,			&::getCppuType((const sal_Int32*)0),		0,		SFX_METRIC_ITEM}, \
87cdf0e10cSrcweir 		{ MAP_CHAR_LEN(UNO_NAME_TEXT_RIGHTDIST),		SDRATTR_TEXT_RIGHTDIST,			&::getCppuType((const sal_Int32*)0),		0,		SFX_METRIC_ITEM}, \
88cdf0e10cSrcweir 		{ MAP_CHAR_LEN(UNO_NAME_TEXT_UPPERDIST),		SDRATTR_TEXT_UPPERDIST,			&::getCppuType((const sal_Int32*)0),		0,		SFX_METRIC_ITEM}, \
89cdf0e10cSrcweir 		{ MAP_CHAR_LEN(UNO_NAME_TEXT_VERTADJUST),		SDRATTR_TEXT_VERTADJUST,		&::getCppuType((const ::com::sun::star::drawing::TextVerticalAdjust*)0),	0,		0},\
90cdf0e10cSrcweir 		{ MAP_CHAR_LEN(UNO_NAME_TEXT_WORDWRAP),			SDRATTR_TEXT_WORDWRAP,			&::getBooleanCppuType(),		0,		0}, \
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 		{ MAP_CHAR_LEN("TableBorder"),					OWN_ATTR_TABLEBORDER,			&::getCppuType((const TableBorder*)0), 0, 0 }, \
93cdf0e10cSrcweir 		{ MAP_CHAR_LEN("TopBorder"),					SDRATTR_TABLE_BORDER,			&::getCppuType((const BorderLine*)0), 0, TOP_BORDER }, \
94cdf0e10cSrcweir 		{ MAP_CHAR_LEN("BottomBorder"),					SDRATTR_TABLE_BORDER,			&::getCppuType((const BorderLine*)0), 0, BOTTOM_BORDER }, \
95cdf0e10cSrcweir 		{ MAP_CHAR_LEN("LeftBorder"),					SDRATTR_TABLE_BORDER,			&::getCppuType((const BorderLine*)0), 0, LEFT_BORDER }, \
96cdf0e10cSrcweir 		{ MAP_CHAR_LEN("RightBorder"),					SDRATTR_TABLE_BORDER,			&::getCppuType((const BorderLine*)0), 0, RIGHT_BORDER }, \
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 		SVX_UNOEDIT_OUTLINER_PROPERTIES,
99cdf0e10cSrcweir 		SVX_UNOEDIT_CHAR_PROPERTIES,
100cdf0e10cSrcweir 		SVX_UNOEDIT_PARA_PROPERTIES,
101cdf0e10cSrcweir 		{0,0,0,0,0,0}
102cdf0e10cSrcweir 	};
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	static SvxItemPropertySet aSvxCellPropertySet( aSvxCellPropertyMap, SdrObject::GetGlobalDrawObjectItemPool() );
105cdf0e10cSrcweir 	return &aSvxCellPropertySet;
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir namespace sdr
109cdf0e10cSrcweir {
110cdf0e10cSrcweir 	namespace properties
111cdf0e10cSrcweir 	{
112cdf0e10cSrcweir 		class CellProperties : public TextProperties
113cdf0e10cSrcweir 		{
114cdf0e10cSrcweir 		protected:
115cdf0e10cSrcweir 			// create a new itemset
116cdf0e10cSrcweir 			SfxItemSet& CreateObjectSpecificItemSet(SfxItemPool& rPool);
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 		public:
119cdf0e10cSrcweir 			// basic constructor
120cdf0e10cSrcweir 			CellProperties(SdrObject& rObj, sdr::table::Cell* pCell );
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 			// constructor for copying, but using new object
123cdf0e10cSrcweir 			CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 			// destructor
126cdf0e10cSrcweir 			~CellProperties();
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 			// Clone() operator, normally just calls the local copy constructor
129cdf0e10cSrcweir 			BaseProperties& Clone(SdrObject& rObj) const;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 			void ForceDefaultAttributes();
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 			void ItemSetChanged(const SfxItemSet& rSet);
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 			void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir             void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 			sdr::table::CellRef mxCell;
140cdf0e10cSrcweir 		};
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 		// create a new itemset
CreateObjectSpecificItemSet(SfxItemPool & rPool)143cdf0e10cSrcweir 		SfxItemSet& CellProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
144cdf0e10cSrcweir 		{
145cdf0e10cSrcweir 			return *(new SfxItemSet(rPool,
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 				// range from SdrAttrObj
148cdf0e10cSrcweir 				SDRATTR_START, SDRATTR_SHADOW_LAST,
149cdf0e10cSrcweir 				SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
150cdf0e10cSrcweir 				SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 				// range for SdrTableObj
153cdf0e10cSrcweir 				SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 				// range from SdrTextObj
156cdf0e10cSrcweir 				EE_ITEMS_START, EE_ITEMS_END,
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 				// end
159cdf0e10cSrcweir 				0, 0));
160cdf0e10cSrcweir 		}
161cdf0e10cSrcweir 
CellProperties(SdrObject & rObj,sdr::table::Cell * pCell)162cdf0e10cSrcweir 		CellProperties::CellProperties(SdrObject& rObj, sdr::table::Cell* pCell)
163cdf0e10cSrcweir 		:	TextProperties(rObj)
164cdf0e10cSrcweir 		,	mxCell(pCell)
165cdf0e10cSrcweir 		{
166cdf0e10cSrcweir 		}
167cdf0e10cSrcweir 
CellProperties(const CellProperties & rProps,SdrObject & rObj,sdr::table::Cell * pCell)168cdf0e10cSrcweir 		CellProperties::CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell)
169cdf0e10cSrcweir 		:	TextProperties(rProps, rObj)
170cdf0e10cSrcweir 		,	mxCell( pCell )
171cdf0e10cSrcweir 		{
172cdf0e10cSrcweir 		}
173cdf0e10cSrcweir 
~CellProperties()174cdf0e10cSrcweir 		CellProperties::~CellProperties()
175cdf0e10cSrcweir 		{
176cdf0e10cSrcweir 		}
177cdf0e10cSrcweir 
Clone(SdrObject & rObj) const178cdf0e10cSrcweir 		BaseProperties& CellProperties::Clone(SdrObject& rObj) const
179cdf0e10cSrcweir 		{
180cdf0e10cSrcweir 			DBG_ERROR("CellProperties::Clone(), does not work yet!");
181cdf0e10cSrcweir 			return *(new CellProperties(*this, rObj,0));
182cdf0e10cSrcweir 		}
183cdf0e10cSrcweir 
ForceDefaultAttributes()184cdf0e10cSrcweir 		void CellProperties::ForceDefaultAttributes()
185cdf0e10cSrcweir 		{
186cdf0e10cSrcweir 		}
187cdf0e10cSrcweir 
ItemSetChanged(const SfxItemSet & rSet)188cdf0e10cSrcweir 		void CellProperties::ItemSetChanged(const SfxItemSet& rSet )
189cdf0e10cSrcweir 		{
190cdf0e10cSrcweir 			SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 			if( mxCell.is() )
193cdf0e10cSrcweir 			{
194cdf0e10cSrcweir 				OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject();
195cdf0e10cSrcweir 
196cdf0e10cSrcweir                 bool bOwnParaObj = pParaObj != 0;
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 				if( pParaObj == 0 )
199cdf0e10cSrcweir 					pParaObj = mxCell->GetOutlinerParaObject();
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 				if(pParaObj)
202cdf0e10cSrcweir 				{
203cdf0e10cSrcweir 					// handle outliner attributes
204cdf0e10cSrcweir 					Outliner* pOutliner = 0;
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 					if(mxCell->IsTextEditActive())
207cdf0e10cSrcweir 					{
208cdf0e10cSrcweir 						pOutliner = rObj.GetTextEditOutliner();
209cdf0e10cSrcweir 					}
210cdf0e10cSrcweir 					else
211cdf0e10cSrcweir 					{
212cdf0e10cSrcweir 						pOutliner = &rObj.ImpGetDrawOutliner();
213cdf0e10cSrcweir 						pOutliner->SetText(*pParaObj);
214cdf0e10cSrcweir 					}
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 					sal_uInt32 nParaCount(pOutliner->GetParagraphCount());
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 					for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++)
219cdf0e10cSrcweir 					{
220cdf0e10cSrcweir 						SfxItemSet aSet(pOutliner->GetParaAttribs(nPara));
221cdf0e10cSrcweir 						aSet.Put(rSet);
222cdf0e10cSrcweir 						pOutliner->SetParaAttribs(nPara, aSet);
223cdf0e10cSrcweir 					}
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 					if(!mxCell->IsTextEditActive())
226cdf0e10cSrcweir 					{
227cdf0e10cSrcweir 						if(nParaCount)
228cdf0e10cSrcweir 						{
229cdf0e10cSrcweir 							// force ItemSet
230cdf0e10cSrcweir 							GetObjectItemSet();
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 							SfxItemSet aNewSet(pOutliner->GetParaAttribs(0L));
233cdf0e10cSrcweir 							mpItemSet->Put(aNewSet);
234cdf0e10cSrcweir 						}
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 						OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount);
237cdf0e10cSrcweir 						pOutliner->Clear();
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 						mxCell->SetOutlinerParaObject(pTemp);
240cdf0e10cSrcweir 					}
241cdf0e10cSrcweir 
242cdf0e10cSrcweir                     if( bOwnParaObj )
243cdf0e10cSrcweir                         delete pParaObj;
244cdf0e10cSrcweir 				}
245cdf0e10cSrcweir 			}
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 			// call parent
248cdf0e10cSrcweir 			AttributeProperties::ItemSetChanged(rSet);
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 			if( mxCell.is() )
251cdf0e10cSrcweir 				mxCell->notifyModified();
252cdf0e10cSrcweir 		}
253cdf0e10cSrcweir 
ItemChange(const sal_uInt16 nWhich,const SfxPoolItem * pNewItem)254cdf0e10cSrcweir 		void CellProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
255cdf0e10cSrcweir 		{
256cdf0e10cSrcweir 			if(pNewItem && (SDRATTR_TEXTDIRECTION == nWhich))
257cdf0e10cSrcweir 			{
258cdf0e10cSrcweir 				sal_Bool bVertical(com::sun::star::text::WritingMode_TB_RL == ((SvxWritingModeItem*)pNewItem)->GetValue());
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 				sdr::table::SdrTableObj& rObj = (sdr::table::SdrTableObj&)GetSdrObject();
261cdf0e10cSrcweir 				if( rObj.IsVerticalWriting() != bVertical )
262cdf0e10cSrcweir 					rObj.SetVerticalWriting(bVertical);
2634323f6b5SJürgen Schmidt 
2644323f6b5SJürgen Schmidt 				// Set a cell vertical property
2654323f6b5SJürgen Schmidt 				OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject();
2664323f6b5SJürgen Schmidt 				if( pParaObj == 0 )
2674323f6b5SJürgen Schmidt 					pParaObj = mxCell->GetOutlinerParaObject();
2684323f6b5SJürgen Schmidt 				if(pParaObj)
2694323f6b5SJürgen Schmidt 				{
2704323f6b5SJürgen Schmidt 					pParaObj->SetVertical(bVertical);
2714323f6b5SJürgen Schmidt 				}
2724323f6b5SJürgen Schmidt 
273cdf0e10cSrcweir 			}
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 			// call parent
276cdf0e10cSrcweir 			AttributeProperties::ItemChange( nWhich, pNewItem );
277cdf0e10cSrcweir 		}
278cdf0e10cSrcweir 
SetStyleSheet(SfxStyleSheet * pNewStyleSheet,sal_Bool bDontRemoveHardAttr)279cdf0e10cSrcweir         void CellProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
280cdf0e10cSrcweir         {
281cdf0e10cSrcweir             TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr );
282cdf0e10cSrcweir         }
283cdf0e10cSrcweir 	} // end of namespace properties
284cdf0e10cSrcweir } // end of namespace sdr
285cdf0e10cSrcweir 
286cdf0e10cSrcweir namespace sdr { namespace table {
287cdf0e10cSrcweir 
288cdf0e10cSrcweir // -----------------------------------------------------------------------------
289cdf0e10cSrcweir // Cell
290cdf0e10cSrcweir // -----------------------------------------------------------------------------
291cdf0e10cSrcweir 
create(SdrTableObj & rTableObj,OutlinerParaObject * pOutlinerParaObject)292cdf0e10cSrcweir rtl::Reference< Cell > Cell::create( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject )
293cdf0e10cSrcweir {
294cdf0e10cSrcweir     rtl::Reference< Cell > xCell( new Cell( rTableObj, pOutlinerParaObject ) );
295cdf0e10cSrcweir     if( xCell->mxTable.is() )
296cdf0e10cSrcweir     {
297cdf0e10cSrcweir         Reference< XEventListener > xListener( xCell.get() );
298cdf0e10cSrcweir         xCell->mxTable->addEventListener( xListener );
299cdf0e10cSrcweir     }
300cdf0e10cSrcweir     return xCell;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir 
303cdf0e10cSrcweir // -----------------------------------------------------------------------------
304cdf0e10cSrcweir 
Cell(SdrTableObj & rTableObj,OutlinerParaObject * pOutlinerParaObject)305cdf0e10cSrcweir Cell::Cell( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject ) throw()
306cdf0e10cSrcweir : SdrText( rTableObj, pOutlinerParaObject )
307cdf0e10cSrcweir , SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
308cdf0e10cSrcweir , mpPropSet( ImplGetSvxCellPropertySet() )
309cdf0e10cSrcweir , mpProperties( new sdr::properties::CellProperties( rTableObj, this ) )
310cdf0e10cSrcweir , mnCellContentType( CellContentType_EMPTY )
311cdf0e10cSrcweir , mfValue( 0.0 )
312cdf0e10cSrcweir , mnError( 0 )
313cdf0e10cSrcweir , mbMerged( sal_False )
314cdf0e10cSrcweir , mnRowSpan( 1 )
315cdf0e10cSrcweir , mnColSpan( 1 )
316cdf0e10cSrcweir , mxTable( rTableObj.getTable() )
317cdf0e10cSrcweir {
318cdf0e10cSrcweir 	if( rTableObj.GetModel() )
319cdf0e10cSrcweir 		SetModel( rTableObj.GetModel() );
320cdf0e10cSrcweir }
321cdf0e10cSrcweir 
322cdf0e10cSrcweir // -----------------------------------------------------------------------------
323cdf0e10cSrcweir 
~Cell()324cdf0e10cSrcweir Cell::~Cell() throw()
325cdf0e10cSrcweir {
326cdf0e10cSrcweir 	dispose();
327cdf0e10cSrcweir }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir // -----------------------------------------------------------------------------
330cdf0e10cSrcweir 
dispose()331cdf0e10cSrcweir void Cell::dispose()
332cdf0e10cSrcweir {
333cdf0e10cSrcweir     if( mxTable.is() )
334cdf0e10cSrcweir     {
335cdf0e10cSrcweir         try
336cdf0e10cSrcweir         {
337cdf0e10cSrcweir             Reference< XEventListener > xThis( this );
338cdf0e10cSrcweir             mxTable->removeEventListener( xThis );
339cdf0e10cSrcweir         }
340cdf0e10cSrcweir         catch( Exception& )
341cdf0e10cSrcweir         {
342cdf0e10cSrcweir             DBG_ERROR("Cell::dispose(), exception caught!");
343cdf0e10cSrcweir         }
344cdf0e10cSrcweir 	    mxTable.clear();
345cdf0e10cSrcweir     }
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 	if( mpProperties )
348cdf0e10cSrcweir 	{
349cdf0e10cSrcweir 		delete mpProperties;
350cdf0e10cSrcweir 		mpProperties = 0;
351cdf0e10cSrcweir 	}
352cdf0e10cSrcweir 	SetOutlinerParaObject( 0 );
353cdf0e10cSrcweir }
354cdf0e10cSrcweir 
355cdf0e10cSrcweir // -----------------------------------------------------------------------------
356cdf0e10cSrcweir 
SetModel(SdrModel * pNewModel)357cdf0e10cSrcweir void Cell::SetModel(SdrModel* pNewModel)
358cdf0e10cSrcweir {
359cdf0e10cSrcweir 	SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( GetEditSource() );
360cdf0e10cSrcweir 	if( (GetModel() != pNewModel) || ( pNewModel && !pTextEditSource) )
361cdf0e10cSrcweir 	{
362cdf0e10cSrcweir 		if( mpProperties )
363cdf0e10cSrcweir 		{
364cdf0e10cSrcweir 			SfxItemPool* pItemPool = mpProperties->GetObjectItemSet().GetPool();
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 			// test for correct pool in ItemSet; move to new pool if necessary
367cdf0e10cSrcweir 			if( pNewModel && pItemPool && pItemPool != &pNewModel->GetItemPool())
368cdf0e10cSrcweir 				mpProperties->MoveToItemPool(pItemPool, &pNewModel->GetItemPool(), pNewModel);
369cdf0e10cSrcweir 		}
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 		if( pTextEditSource )
372cdf0e10cSrcweir 		{
373cdf0e10cSrcweir 			pTextEditSource->ChangeModel( pNewModel );
374cdf0e10cSrcweir 		}
375cdf0e10cSrcweir 		else
376cdf0e10cSrcweir 		{
377cdf0e10cSrcweir 			SetEditSource( new SvxTextEditSource( &GetObject(), this, static_cast< XWeak * >( this ) ) );
378cdf0e10cSrcweir 		}
379cdf0e10cSrcweir 
380cdf0e10cSrcweir 		SetStyleSheet( 0, sal_True );
381cdf0e10cSrcweir 		SdrText::SetModel( pNewModel );
382cdf0e10cSrcweir 		ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
383cdf0e10cSrcweir 	}
384cdf0e10cSrcweir }
385cdf0e10cSrcweir 
386cdf0e10cSrcweir // -----------------------------------------------------------------------------
387cdf0e10cSrcweir 
merge(sal_Int32 nColumnSpan,sal_Int32 nRowSpan)388cdf0e10cSrcweir void Cell::merge( sal_Int32 nColumnSpan, sal_Int32 nRowSpan )
389cdf0e10cSrcweir {
390cdf0e10cSrcweir 	if( (mnColSpan != nColumnSpan) || (mnRowSpan != nRowSpan) || (mbMerged != sal_False) )
391cdf0e10cSrcweir 	{
392cdf0e10cSrcweir 		mnColSpan = nColumnSpan;
393cdf0e10cSrcweir 		mnRowSpan = nRowSpan;
394cdf0e10cSrcweir 		mbMerged = sal_False;
395cdf0e10cSrcweir 		notifyModified();
396cdf0e10cSrcweir 	}
397cdf0e10cSrcweir }
398cdf0e10cSrcweir 
399cdf0e10cSrcweir // -----------------------------------------------------------------------------
400cdf0e10cSrcweir 
mergeContent(const CellRef & xSourceCell)401cdf0e10cSrcweir void Cell::mergeContent( const CellRef& xSourceCell )
402cdf0e10cSrcweir {
403cdf0e10cSrcweir 	SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 	if( xSourceCell->hasText() )
406cdf0e10cSrcweir 	{
407cdf0e10cSrcweir 		SdrOutliner& rOutliner=rTableObj.ImpGetDrawOutliner();
408cdf0e10cSrcweir 		rOutliner.SetUpdateMode(sal_True);
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 		if( hasText() )
411cdf0e10cSrcweir 		{
412cdf0e10cSrcweir 			rOutliner.SetText(*GetOutlinerParaObject());
413cdf0e10cSrcweir 			rOutliner.AddText(*xSourceCell->GetOutlinerParaObject());
414cdf0e10cSrcweir 		}
415cdf0e10cSrcweir 		else
416cdf0e10cSrcweir 		{
417cdf0e10cSrcweir 			rOutliner.SetText(*xSourceCell->GetOutlinerParaObject());
418cdf0e10cSrcweir 		}
419cdf0e10cSrcweir 
420cdf0e10cSrcweir 		SetOutlinerParaObject( rOutliner.CreateParaObject() );
421cdf0e10cSrcweir 		rOutliner.Clear();
422cdf0e10cSrcweir 		xSourceCell->SetOutlinerParaObject(rOutliner.CreateParaObject());
423cdf0e10cSrcweir 		rOutliner.Clear();
424cdf0e10cSrcweir 		SetStyleSheet( GetStyleSheet(), sal_True );
425cdf0e10cSrcweir 	}
426cdf0e10cSrcweir }
427cdf0e10cSrcweir 
428cdf0e10cSrcweir // -----------------------------------------------------------------------------
429cdf0e10cSrcweir 
cloneFrom(const CellRef & xCell)430cdf0e10cSrcweir void Cell::cloneFrom( const CellRef& xCell )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir 	if( xCell.is() )
433cdf0e10cSrcweir 	{
434cdf0e10cSrcweir 		replaceContentAndFormating( xCell );
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 		mnCellContentType = xCell->mnCellContentType;
437cdf0e10cSrcweir 
438cdf0e10cSrcweir 		msFormula = xCell->msFormula;
439cdf0e10cSrcweir 		mfValue = xCell->mfValue;
440cdf0e10cSrcweir 		mnError = xCell->mnError;
441cdf0e10cSrcweir 
442cdf0e10cSrcweir         mbMerged = xCell->mbMerged;
443cdf0e10cSrcweir         mnRowSpan = xCell->mnRowSpan;
444cdf0e10cSrcweir         mnColSpan = xCell->mnColSpan;
445cdf0e10cSrcweir 
446cdf0e10cSrcweir     }
447cdf0e10cSrcweir 	notifyModified();
448cdf0e10cSrcweir }
449cdf0e10cSrcweir 
replaceContentAndFormating(const CellRef & xSourceCell)450cdf0e10cSrcweir void Cell::replaceContentAndFormating( const CellRef& xSourceCell )
451cdf0e10cSrcweir {
452cdf0e10cSrcweir 	if( xSourceCell.is() && mpProperties )
453cdf0e10cSrcweir 	{
454cdf0e10cSrcweir 		mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() );
455cdf0e10cSrcweir 		SetOutlinerParaObject( new OutlinerParaObject(*xSourceCell->GetOutlinerParaObject()) );
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 		SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
458cdf0e10cSrcweir 		SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() );
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 		if(rSourceTableObj.GetModel() != rTableObj.GetModel())
461cdf0e10cSrcweir 		{
462cdf0e10cSrcweir 			SetStyleSheet( 0, sal_True );
463cdf0e10cSrcweir 		}
464cdf0e10cSrcweir 	}
465cdf0e10cSrcweir }
466cdf0e10cSrcweir 
467cdf0e10cSrcweir // -----------------------------------------------------------------------------
468cdf0e10cSrcweir 
setMerged()469cdf0e10cSrcweir void Cell::setMerged()
470cdf0e10cSrcweir {
471cdf0e10cSrcweir 	if( !mbMerged )
472cdf0e10cSrcweir 	{
473cdf0e10cSrcweir 		mbMerged = sal_True;
474cdf0e10cSrcweir 		notifyModified();
475cdf0e10cSrcweir 	}
476cdf0e10cSrcweir }
477cdf0e10cSrcweir 
478cdf0e10cSrcweir // -----------------------------------------------------------------------------
479cdf0e10cSrcweir 
notifyModified()480cdf0e10cSrcweir void Cell::notifyModified()
481cdf0e10cSrcweir {
482cdf0e10cSrcweir 	if( mxTable.is() )
483cdf0e10cSrcweir 		mxTable->setModified( sal_True );
484cdf0e10cSrcweir }
485cdf0e10cSrcweir 
486cdf0e10cSrcweir // -----------------------------------------------------------------------------
487cdf0e10cSrcweir // SdrTextShape proxy
488cdf0e10cSrcweir // -----------------------------------------------------------------------------
489cdf0e10cSrcweir 
IsTextEditActive()490cdf0e10cSrcweir bool Cell::IsTextEditActive()
491cdf0e10cSrcweir {
492cdf0e10cSrcweir     bool isActive = false;
493cdf0e10cSrcweir 	SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
494cdf0e10cSrcweir 	if(rTableObj.getActiveCell().get() == this )
495cdf0e10cSrcweir     {
496cdf0e10cSrcweir         OutlinerParaObject* pParaObj = rTableObj.GetEditOutlinerParaObject();
497cdf0e10cSrcweir         if( pParaObj != 0 )
498cdf0e10cSrcweir         {
499cdf0e10cSrcweir             isActive = true;
500cdf0e10cSrcweir 		    delete pParaObj;
501cdf0e10cSrcweir         }
502cdf0e10cSrcweir     }
503cdf0e10cSrcweir 	return isActive;
504cdf0e10cSrcweir }
505cdf0e10cSrcweir 
506cdf0e10cSrcweir // -----------------------------------------------------------------------------
507cdf0e10cSrcweir 
hasText() const508cdf0e10cSrcweir bool Cell::hasText() const
509cdf0e10cSrcweir {
510cdf0e10cSrcweir 	OutlinerParaObject* pParaObj = GetOutlinerParaObject();
511cdf0e10cSrcweir 	if( pParaObj )
512cdf0e10cSrcweir 	{
513cdf0e10cSrcweir 		const EditTextObject& rTextObj = pParaObj->GetTextObject();
514cdf0e10cSrcweir 		if( rTextObj.GetParagraphCount() >= 1 )
515cdf0e10cSrcweir 		{
516cdf0e10cSrcweir 			if( rTextObj.GetParagraphCount() == 1 )
517cdf0e10cSrcweir 			{
518cdf0e10cSrcweir 				if( rTextObj.GetText(0).Len() == 0 )
519cdf0e10cSrcweir 					return false;
520cdf0e10cSrcweir 			}
521cdf0e10cSrcweir 			return true;
522cdf0e10cSrcweir 		}
523cdf0e10cSrcweir 	}
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 	return false;
526cdf0e10cSrcweir }
527cdf0e10cSrcweir 
528cdf0e10cSrcweir // -----------------------------------------------------------------------------
529cdf0e10cSrcweir 
GetEditOutlinerParaObject() const530cdf0e10cSrcweir OutlinerParaObject* Cell::GetEditOutlinerParaObject() const
531cdf0e10cSrcweir {
532cdf0e10cSrcweir 	SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
533cdf0e10cSrcweir 	if( rTableObj.getActiveCell().get() == this )
534cdf0e10cSrcweir 		return rTableObj.GetEditOutlinerParaObject();
535cdf0e10cSrcweir 	return 0;
536cdf0e10cSrcweir }
537cdf0e10cSrcweir 
538cdf0e10cSrcweir // -----------------------------------------------------------------------------
539cdf0e10cSrcweir 
SetStyleSheet(SfxStyleSheet * pStyleSheet,sal_Bool bDontRemoveHardAttr)540cdf0e10cSrcweir void Cell::SetStyleSheet( SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr )
541cdf0e10cSrcweir {
542cdf0e10cSrcweir 	// only allow cell styles for cells
543cdf0e10cSrcweir 	if( pStyleSheet && pStyleSheet->GetFamily() != SFX_STYLE_FAMILY_FRAME )
544cdf0e10cSrcweir 		return;
545cdf0e10cSrcweir 
546cdf0e10cSrcweir 	if( mpProperties && (mpProperties->GetStyleSheet() != pStyleSheet) )
547cdf0e10cSrcweir 	{
548cdf0e10cSrcweir 		mpProperties->SetStyleSheet( pStyleSheet, bDontRemoveHardAttr );
549cdf0e10cSrcweir 	}
550cdf0e10cSrcweir }
551cdf0e10cSrcweir 
552cdf0e10cSrcweir // -----------------------------------------------------------------------------
553cdf0e10cSrcweir 
GetObjectItemSet()554cdf0e10cSrcweir const SfxItemSet& Cell::GetObjectItemSet()
555cdf0e10cSrcweir {
556cdf0e10cSrcweir 	if( mpProperties )
557cdf0e10cSrcweir 	{
558cdf0e10cSrcweir 		return mpProperties->GetObjectItemSet();
559cdf0e10cSrcweir 	}
560cdf0e10cSrcweir 	else
561cdf0e10cSrcweir 	{
562cdf0e10cSrcweir 		DBG_ERROR("Cell::GetObjectItemSet(), called without properties!");
563cdf0e10cSrcweir         return GetObject().GetObjectItemSet();
564cdf0e10cSrcweir 	}
565cdf0e10cSrcweir }
566cdf0e10cSrcweir 
SetObjectItem(const SfxPoolItem & rItem)567cdf0e10cSrcweir void Cell::SetObjectItem(const SfxPoolItem& rItem)
568cdf0e10cSrcweir {
569cdf0e10cSrcweir 	if( mpProperties )
570cdf0e10cSrcweir 	{
571cdf0e10cSrcweir 		mpProperties->SetObjectItem( rItem );
572cdf0e10cSrcweir 		notifyModified();
573cdf0e10cSrcweir 	}
574cdf0e10cSrcweir }
575cdf0e10cSrcweir 
SetMergedItem(const SfxPoolItem & rItem)576cdf0e10cSrcweir void Cell::SetMergedItem(const SfxPoolItem& rItem)
577cdf0e10cSrcweir {
578cdf0e10cSrcweir 	SetObjectItem(rItem);
579cdf0e10cSrcweir }
580cdf0e10cSrcweir 
GetStyleSheet() const581cdf0e10cSrcweir SfxStyleSheet* Cell::GetStyleSheet() const
582cdf0e10cSrcweir {
583cdf0e10cSrcweir 	if( mpProperties )
584cdf0e10cSrcweir 		return mpProperties->GetStyleSheet();
585cdf0e10cSrcweir 	else
586cdf0e10cSrcweir 		return 0;
587cdf0e10cSrcweir }
588cdf0e10cSrcweir 
589cdf0e10cSrcweir // -----------------------------------------------------------------------------
590cdf0e10cSrcweir 
GetStyleSheetPool() const591cdf0e10cSrcweir SfxStyleSheetPool* Cell::GetStyleSheetPool() const
592cdf0e10cSrcweir {
593cdf0e10cSrcweir 	if( mpProperties && mpProperties->GetStyleSheet() )
594cdf0e10cSrcweir 		return dynamic_cast< SfxStyleSheetPool* >( &mpProperties->GetStyleSheet()->GetPool() );
595cdf0e10cSrcweir 	else
596cdf0e10cSrcweir 		return 0;
597cdf0e10cSrcweir }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir // -----------------------------------------------------------------------------
600cdf0e10cSrcweir 
GetCurrentBoundRect() const601cdf0e10cSrcweir const Rectangle& Cell::GetCurrentBoundRect() const
602cdf0e10cSrcweir {
603cdf0e10cSrcweir 	return maCellRect;
604cdf0e10cSrcweir }
605cdf0e10cSrcweir 
606cdf0e10cSrcweir // -----------------------------------------------------------------------------
607cdf0e10cSrcweir 
TakeTextAnchorRect(Rectangle & rAnchorRect) const608cdf0e10cSrcweir void Cell::TakeTextAnchorRect(Rectangle& rAnchorRect) const
609cdf0e10cSrcweir {
610cdf0e10cSrcweir 	rAnchorRect.nLeft = maCellRect.nLeft + GetTextLeftDistance();
611cdf0e10cSrcweir 	rAnchorRect.nRight = maCellRect.nRight - GetTextRightDistance();
612cdf0e10cSrcweir 	rAnchorRect.nTop = maCellRect.nTop + GetTextUpperDistance();
613cdf0e10cSrcweir 	rAnchorRect.nBottom = maCellRect.nBottom - GetTextLowerDistance();
614cdf0e10cSrcweir }
615cdf0e10cSrcweir 
616cdf0e10cSrcweir // -----------------------------------------------------------------------------
617cdf0e10cSrcweir 
GetItemSet() const618cdf0e10cSrcweir const SfxItemSet& Cell::GetItemSet() const
619cdf0e10cSrcweir {
620cdf0e10cSrcweir 	return mpProperties->GetObjectItemSet();
621cdf0e10cSrcweir }
622cdf0e10cSrcweir 
623cdf0e10cSrcweir // -----------------------------------------------------------------------------
624cdf0e10cSrcweir 
SetMergedItemSetAndBroadcast(const SfxItemSet & rSet,sal_Bool bClearAllItems)625cdf0e10cSrcweir void Cell::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems)
626cdf0e10cSrcweir {
627cdf0e10cSrcweir 	if( mpProperties )
628cdf0e10cSrcweir 	{
629cdf0e10cSrcweir 		mpProperties->SetMergedItemSetAndBroadcast(rSet, bClearAllItems);
630cdf0e10cSrcweir 		notifyModified();
631cdf0e10cSrcweir 	}
632cdf0e10cSrcweir }
633cdf0e10cSrcweir 
634cdf0e10cSrcweir // -----------------------------------------------------------------------------
635cdf0e10cSrcweir 
getMinimumWidth()636cdf0e10cSrcweir sal_Int32 Cell::getMinimumWidth()
637cdf0e10cSrcweir {
638cdf0e10cSrcweir 	return GetTextLeftDistance() + GetTextRightDistance() + 100;
639cdf0e10cSrcweir }
640cdf0e10cSrcweir 
641cdf0e10cSrcweir // -----------------------------------------------------------------------------
642cdf0e10cSrcweir 
getMinimumHeight()643cdf0e10cSrcweir sal_Int32 Cell::getMinimumHeight()
644cdf0e10cSrcweir {
645cdf0e10cSrcweir 	if( !mpProperties )
646cdf0e10cSrcweir 		return 0;
647cdf0e10cSrcweir 
648cdf0e10cSrcweir 	SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
649cdf0e10cSrcweir 	sal_Int32 nMinimumHeight = 0;
650cdf0e10cSrcweir 
651cdf0e10cSrcweir 	Rectangle aTextRect;
652cdf0e10cSrcweir 	TakeTextAnchorRect( aTextRect );
653cdf0e10cSrcweir 	Size aSize( aTextRect.GetSize() );
654cdf0e10cSrcweir 	aSize.Height()=0x0FFFFFFF;
655cdf0e10cSrcweir 
656cdf0e10cSrcweir 	SdrOutliner* pEditOutliner = rTableObj.GetCellTextEditOutliner( *this );
657cdf0e10cSrcweir 	if(pEditOutliner)
658cdf0e10cSrcweir 	{
659cdf0e10cSrcweir 		pEditOutliner->SetMaxAutoPaperSize(aSize);
660cdf0e10cSrcweir 		nMinimumHeight = pEditOutliner->GetTextHeight()+1;
661cdf0e10cSrcweir 	}
662cdf0e10cSrcweir 	else /*if ( hasText() )*/
663cdf0e10cSrcweir 	{
664cdf0e10cSrcweir 		Outliner& rOutliner=rTableObj.ImpGetDrawOutliner();
665cdf0e10cSrcweir 		rOutliner.SetPaperSize(aSize);
666cdf0e10cSrcweir 		rOutliner.SetUpdateMode(sal_True);
667cdf0e10cSrcweir 		ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
668cdf0e10cSrcweir 
669cdf0e10cSrcweir 		if( GetOutlinerParaObject() )
670cdf0e10cSrcweir 		{
671cdf0e10cSrcweir 			rOutliner.SetText(*GetOutlinerParaObject());
672cdf0e10cSrcweir 		}
673cdf0e10cSrcweir 		nMinimumHeight=rOutliner.GetTextHeight()+1;
674cdf0e10cSrcweir 		rOutliner.Clear();
675cdf0e10cSrcweir 	}
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 	nMinimumHeight += GetTextUpperDistance() + GetTextLowerDistance();
678cdf0e10cSrcweir 	return nMinimumHeight;
679cdf0e10cSrcweir }
680cdf0e10cSrcweir 
681cdf0e10cSrcweir // -----------------------------------------------------------------------------
682cdf0e10cSrcweir 
GetTextLeftDistance() const683cdf0e10cSrcweir long Cell::GetTextLeftDistance() const
684cdf0e10cSrcweir {
685cdf0e10cSrcweir 	return ((SdrTextLeftDistItem&)(GetItemSet().Get(SDRATTR_TEXT_LEFTDIST))).GetValue();
686cdf0e10cSrcweir }
687cdf0e10cSrcweir 
688cdf0e10cSrcweir // -----------------------------------------------------------------------------
689cdf0e10cSrcweir 
GetTextRightDistance() const690cdf0e10cSrcweir long Cell::GetTextRightDistance() const
691cdf0e10cSrcweir {
692cdf0e10cSrcweir 	return ((SdrTextRightDistItem&)(GetItemSet().Get(SDRATTR_TEXT_RIGHTDIST))).GetValue();
693cdf0e10cSrcweir }
694cdf0e10cSrcweir 
695cdf0e10cSrcweir // -----------------------------------------------------------------------------
696cdf0e10cSrcweir 
GetTextUpperDistance() const697cdf0e10cSrcweir long Cell::GetTextUpperDistance() const
698cdf0e10cSrcweir {
699cdf0e10cSrcweir 	return ((SdrTextUpperDistItem&)(GetItemSet().Get(SDRATTR_TEXT_UPPERDIST))).GetValue();
700cdf0e10cSrcweir }
701cdf0e10cSrcweir 
702cdf0e10cSrcweir // -----------------------------------------------------------------------------
703cdf0e10cSrcweir 
GetTextLowerDistance() const704cdf0e10cSrcweir long Cell::GetTextLowerDistance() const
705cdf0e10cSrcweir {
706cdf0e10cSrcweir 	return ((SdrTextLowerDistItem&)(GetItemSet().Get(SDRATTR_TEXT_LOWERDIST))).GetValue();
707cdf0e10cSrcweir }
708cdf0e10cSrcweir 
709cdf0e10cSrcweir // -----------------------------------------------------------------------------
710cdf0e10cSrcweir 
GetTextVerticalAdjust() const711cdf0e10cSrcweir SdrTextVertAdjust Cell::GetTextVerticalAdjust() const
712cdf0e10cSrcweir {
713cdf0e10cSrcweir 	return ((SdrTextVertAdjustItem&)(GetItemSet().Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
714cdf0e10cSrcweir }
715cdf0e10cSrcweir 
716cdf0e10cSrcweir // -----------------------------------------------------------------------------
717cdf0e10cSrcweir 
GetTextHorizontalAdjust() const718cdf0e10cSrcweir SdrTextHorzAdjust Cell::GetTextHorizontalAdjust() const
719cdf0e10cSrcweir {
720cdf0e10cSrcweir 	return ((SdrTextHorzAdjustItem&)(GetItemSet().Get(SDRATTR_TEXT_HORZADJUST))).GetValue();
721cdf0e10cSrcweir }
722cdf0e10cSrcweir 
723cdf0e10cSrcweir // -----------------------------------------------------------------------------
724cdf0e10cSrcweir 
SetOutlinerParaObject(OutlinerParaObject * pTextObject)725cdf0e10cSrcweir void Cell::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
726cdf0e10cSrcweir {
727cdf0e10cSrcweir 	SdrText::SetOutlinerParaObject( pTextObject );
728cdf0e10cSrcweir     maSelection.nStartPara = 0xffff;
729cdf0e10cSrcweir 
730cdf0e10cSrcweir     if( pTextObject == 0 )
731cdf0e10cSrcweir         ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
732cdf0e10cSrcweir }
733cdf0e10cSrcweir 
734cdf0e10cSrcweir // -----------------------------------------------------------------------------
735cdf0e10cSrcweir 
AddUndo()736cdf0e10cSrcweir void Cell::AddUndo()
737cdf0e10cSrcweir {
738cdf0e10cSrcweir 	SdrObject& rObj = GetObject();
739cdf0e10cSrcweir 	if( rObj.IsInserted() && GetModel() && GetModel()->IsUndoEnabled() )
740cdf0e10cSrcweir 	{
741cdf0e10cSrcweir 		CellRef xCell( this );
742cdf0e10cSrcweir 		GetModel()->AddUndo( new CellUndo( &rObj, xCell ) );
743cdf0e10cSrcweir 	}
744cdf0e10cSrcweir }
745cdf0e10cSrcweir 
746cdf0e10cSrcweir // -----------------------------------------------------------------------------
747cdf0e10cSrcweir 
CloneProperties(sdr::properties::TextProperties * pProperties,SdrObject & rNewObj,Cell & rNewCell)748cdf0e10cSrcweir sdr::properties::TextProperties* Cell::CloneProperties( sdr::properties::TextProperties* pProperties, SdrObject& rNewObj, Cell& rNewCell )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir 	if( pProperties )
751cdf0e10cSrcweir 		return new sdr::properties::CellProperties( *static_cast<sdr::properties::CellProperties*>(pProperties), rNewObj, &rNewCell );
752cdf0e10cSrcweir 	else
753cdf0e10cSrcweir 		return 0;
754cdf0e10cSrcweir }
755cdf0e10cSrcweir 
756cdf0e10cSrcweir // -----------------------------------------------------------------------------
757cdf0e10cSrcweir 
CloneProperties(SdrObject & rNewObj,Cell & rNewCell)758cdf0e10cSrcweir sdr::properties::TextProperties* Cell::CloneProperties( SdrObject& rNewObj, Cell& rNewCell )
759cdf0e10cSrcweir {
760cdf0e10cSrcweir     return CloneProperties(mpProperties,rNewObj,rNewCell);
761cdf0e10cSrcweir }
762cdf0e10cSrcweir 
763cdf0e10cSrcweir // -----------------------------------------------------------------------------
764cdf0e10cSrcweir // XInterface
765cdf0e10cSrcweir // -----------------------------------------------------------------------------
766cdf0e10cSrcweir 
queryInterface(const Type & rType)767cdf0e10cSrcweir Any SAL_CALL Cell::queryInterface( const Type & rType ) throw(RuntimeException)
768cdf0e10cSrcweir {
769cdf0e10cSrcweir 	if( rType == XMergeableCell::static_type() )
770cdf0e10cSrcweir 		return Any( Reference< XMergeableCell >( this ) );
771cdf0e10cSrcweir 
772cdf0e10cSrcweir 	if( rType == XCell::static_type() )
773cdf0e10cSrcweir 		return Any( Reference< XCell >( this ) );
774cdf0e10cSrcweir 
775cdf0e10cSrcweir 	if( rType == XLayoutConstrains::static_type() )
776cdf0e10cSrcweir 		return Any( Reference< XLayoutConstrains >( this ) );
777cdf0e10cSrcweir 
778cdf0e10cSrcweir     if( rType == XEventListener::static_type() )
779cdf0e10cSrcweir         return Any( Reference< XEventListener >( this ) );
780cdf0e10cSrcweir 
781cdf0e10cSrcweir 	Any aRet( SvxUnoTextBase::queryAggregation( rType ) );
782cdf0e10cSrcweir 	if( aRet.hasValue() )
783cdf0e10cSrcweir 		return aRet;
784cdf0e10cSrcweir 
785cdf0e10cSrcweir 	return ::cppu::OWeakObject::queryInterface( rType );
786cdf0e10cSrcweir }
787cdf0e10cSrcweir 
788cdf0e10cSrcweir // -----------------------------------------------------------------------------
789cdf0e10cSrcweir 
acquire()790cdf0e10cSrcweir void SAL_CALL Cell::acquire() throw ()
791cdf0e10cSrcweir {
792cdf0e10cSrcweir 	::cppu::OWeakObject::acquire();
793cdf0e10cSrcweir }
794cdf0e10cSrcweir 
795cdf0e10cSrcweir // -----------------------------------------------------------------------------
796cdf0e10cSrcweir 
release()797cdf0e10cSrcweir void SAL_CALL Cell::release() throw ()
798cdf0e10cSrcweir {
799cdf0e10cSrcweir 	::cppu::OWeakObject::release();
800cdf0e10cSrcweir }
801cdf0e10cSrcweir 
802cdf0e10cSrcweir // -----------------------------------------------------------------------------
803cdf0e10cSrcweir // XTypeProvider
804cdf0e10cSrcweir // -----------------------------------------------------------------------------
805cdf0e10cSrcweir 
getTypes()806cdf0e10cSrcweir Sequence< Type > SAL_CALL Cell::getTypes(  ) throw (RuntimeException)
807cdf0e10cSrcweir {
808cdf0e10cSrcweir     Sequence< Type > aTypes( SvxUnoTextBase::getTypes() );
809cdf0e10cSrcweir 
810cdf0e10cSrcweir     sal_Int32 nLen = aTypes.getLength();
811cdf0e10cSrcweir     aTypes.realloc(nLen + 2);
812cdf0e10cSrcweir 	aTypes[nLen++] = XMergeableCell::static_type();
813cdf0e10cSrcweir 	aTypes[nLen++] = XLayoutConstrains::static_type();
814cdf0e10cSrcweir 
815cdf0e10cSrcweir 	return aTypes;
816cdf0e10cSrcweir }
817cdf0e10cSrcweir 
818cdf0e10cSrcweir // -----------------------------------------------------------------------------
819cdf0e10cSrcweir 
getImplementationId()820cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL Cell::getImplementationId(  ) throw (RuntimeException)
821cdf0e10cSrcweir {
822cdf0e10cSrcweir     static ::cppu::OImplementationId* pId = 0;
823cdf0e10cSrcweir 	if (! pId)
824cdf0e10cSrcweir 	{
825cdf0e10cSrcweir         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
826cdf0e10cSrcweir 		if (! pId)
827cdf0e10cSrcweir 		{
828cdf0e10cSrcweir 			static ::cppu::OImplementationId aId;
829cdf0e10cSrcweir 			pId = &aId;
830cdf0e10cSrcweir 		}
831cdf0e10cSrcweir 	}
832cdf0e10cSrcweir 	return pId->getImplementationId();
833cdf0e10cSrcweir }
834cdf0e10cSrcweir 
835cdf0e10cSrcweir // -----------------------------------------------------------------------------
836cdf0e10cSrcweir // XServiceInfo
837cdf0e10cSrcweir // -----------------------------------------------------------------------------
838cdf0e10cSrcweir 
getImplementationName()839cdf0e10cSrcweir OUString SAL_CALL Cell::getImplementationName(  ) throw (RuntimeException)
840cdf0e10cSrcweir {
841cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.table.Cell" ) );
842cdf0e10cSrcweir }
843cdf0e10cSrcweir 
844cdf0e10cSrcweir // -----------------------------------------------------------------------------
845cdf0e10cSrcweir 
supportsService(const OUString & ServiceName)846cdf0e10cSrcweir sal_Bool SAL_CALL Cell::supportsService( const OUString& ServiceName ) throw (RuntimeException)
847cdf0e10cSrcweir {
848cdf0e10cSrcweir 	if( ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.table.cell" ) ) == 0 )
849cdf0e10cSrcweir 		return sal_True;
850cdf0e10cSrcweir 
851cdf0e10cSrcweir 	if( ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.cell" ) ) == 0 )
852cdf0e10cSrcweir 		return sal_True;
853cdf0e10cSrcweir 
854cdf0e10cSrcweir 	return SvxUnoTextBase::supportsService( ServiceName );
855cdf0e10cSrcweir }
856cdf0e10cSrcweir 
857cdf0e10cSrcweir // -----------------------------------------------------------------------------
858cdf0e10cSrcweir 
getSupportedServiceNames()859cdf0e10cSrcweir Sequence< OUString > SAL_CALL Cell::getSupportedServiceNames(  ) throw (RuntimeException)
860cdf0e10cSrcweir {
861cdf0e10cSrcweir 	Sequence< OUString > aSeq( SvxUnoTextBase::getSupportedServiceNames() );
862cdf0e10cSrcweir 	sal_Int32 nIndex = aSeq.getLength();
863cdf0e10cSrcweir 	aSeq.realloc( nIndex + 2 );
864cdf0e10cSrcweir 	aSeq[nIndex++] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.cell" ) );
865cdf0e10cSrcweir 	aSeq[nIndex++] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.cell" ) );
866cdf0e10cSrcweir 	return aSeq;
867cdf0e10cSrcweir }
868cdf0e10cSrcweir 
869cdf0e10cSrcweir // -----------------------------------------------------------------------------
870cdf0e10cSrcweir // XLayoutConstrains
871cdf0e10cSrcweir // -----------------------------------------------------------------------------
872cdf0e10cSrcweir 
getMinimumSize()873cdf0e10cSrcweir ::com::sun::star::awt::Size SAL_CALL Cell::getMinimumSize(  ) throw (RuntimeException)
874cdf0e10cSrcweir {
875cdf0e10cSrcweir 	return ::com::sun::star::awt::Size( getMinimumWidth(),  getMinimumHeight() );
876cdf0e10cSrcweir }
877cdf0e10cSrcweir 
878cdf0e10cSrcweir // -----------------------------------------------------------------------------
879cdf0e10cSrcweir 
getPreferredSize()880cdf0e10cSrcweir ::com::sun::star::awt::Size SAL_CALL Cell::getPreferredSize(  ) throw (RuntimeException)
881cdf0e10cSrcweir {
882cdf0e10cSrcweir 	return getMinimumSize();
883cdf0e10cSrcweir }
884cdf0e10cSrcweir 
885cdf0e10cSrcweir // -----------------------------------------------------------------------------
886cdf0e10cSrcweir 
calcAdjustedSize(const::com::sun::star::awt::Size & aNewSize)887cdf0e10cSrcweir ::com::sun::star::awt::Size SAL_CALL Cell::calcAdjustedSize( const ::com::sun::star::awt::Size& aNewSize ) throw (RuntimeException)
888cdf0e10cSrcweir {
889cdf0e10cSrcweir 	return aNewSize;
890cdf0e10cSrcweir }
891cdf0e10cSrcweir 
892cdf0e10cSrcweir // -----------------------------------------------------------------------------
893cdf0e10cSrcweir // XMergeableCell
894cdf0e10cSrcweir // -----------------------------------------------------------------------------
895cdf0e10cSrcweir 
getRowSpan()896cdf0e10cSrcweir sal_Int32 SAL_CALL Cell::getRowSpan() throw (RuntimeException)
897cdf0e10cSrcweir {
898cdf0e10cSrcweir 	return mnRowSpan;
899cdf0e10cSrcweir }
900cdf0e10cSrcweir 
901cdf0e10cSrcweir // -----------------------------------------------------------------------------
902cdf0e10cSrcweir 
getColumnSpan()903cdf0e10cSrcweir sal_Int32 SAL_CALL Cell::getColumnSpan() throw (RuntimeException)
904cdf0e10cSrcweir {
905cdf0e10cSrcweir 	return mnColSpan;
906cdf0e10cSrcweir }
907cdf0e10cSrcweir 
908cdf0e10cSrcweir // -----------------------------------------------------------------------------
909cdf0e10cSrcweir 
isMerged()910cdf0e10cSrcweir sal_Bool SAL_CALL Cell::isMerged() throw (RuntimeException)
911cdf0e10cSrcweir {
912cdf0e10cSrcweir 	return mbMerged;
913cdf0e10cSrcweir }
914cdf0e10cSrcweir 
915cdf0e10cSrcweir // -----------------------------------------------------------------------------
916cdf0e10cSrcweir // XCell
917cdf0e10cSrcweir // -----------------------------------------------------------------------------
918cdf0e10cSrcweir 
getFormula()919cdf0e10cSrcweir OUString SAL_CALL Cell::getFormula(  ) throw (RuntimeException)
920cdf0e10cSrcweir {
921cdf0e10cSrcweir 	return msFormula;
922cdf0e10cSrcweir }
923cdf0e10cSrcweir 
924cdf0e10cSrcweir // -----------------------------------------------------------------------------
925cdf0e10cSrcweir 
setFormula(const OUString & aFormula)926cdf0e10cSrcweir void SAL_CALL Cell::setFormula( const OUString& aFormula ) throw (RuntimeException)
927cdf0e10cSrcweir {
928cdf0e10cSrcweir 	if( msFormula != aFormula )
929cdf0e10cSrcweir 	{
930cdf0e10cSrcweir 		msFormula = aFormula;
931cdf0e10cSrcweir 	}
932cdf0e10cSrcweir }
933cdf0e10cSrcweir 
934cdf0e10cSrcweir // -----------------------------------------------------------------------------
935cdf0e10cSrcweir 
getValue()936cdf0e10cSrcweir double SAL_CALL Cell::getValue(  ) throw (RuntimeException)
937cdf0e10cSrcweir {
938cdf0e10cSrcweir 	return mfValue;
939cdf0e10cSrcweir }
940cdf0e10cSrcweir 
941cdf0e10cSrcweir // -----------------------------------------------------------------------------
942cdf0e10cSrcweir 
setValue(double nValue)943cdf0e10cSrcweir void SAL_CALL Cell::setValue( double nValue ) throw (RuntimeException)
944cdf0e10cSrcweir {
945cdf0e10cSrcweir 	if( mfValue == nValue )
946cdf0e10cSrcweir 	{
947cdf0e10cSrcweir 		mfValue = nValue;
948cdf0e10cSrcweir 		mnCellContentType = CellContentType_VALUE;
949cdf0e10cSrcweir 	}
950cdf0e10cSrcweir }
951cdf0e10cSrcweir 
952cdf0e10cSrcweir // -----------------------------------------------------------------------------
953cdf0e10cSrcweir 
getType()954cdf0e10cSrcweir CellContentType SAL_CALL Cell::getType() throw (RuntimeException)
955cdf0e10cSrcweir {
956cdf0e10cSrcweir 	return mnCellContentType;
957cdf0e10cSrcweir }
958cdf0e10cSrcweir 
959cdf0e10cSrcweir // -----------------------------------------------------------------------------
960cdf0e10cSrcweir 
getError()961cdf0e10cSrcweir sal_Int32 SAL_CALL Cell::getError(  ) throw (RuntimeException)
962cdf0e10cSrcweir {
963cdf0e10cSrcweir 	return mnError;
964cdf0e10cSrcweir }
965cdf0e10cSrcweir 
966cdf0e10cSrcweir // -----------------------------------------------------------------------------
967cdf0e10cSrcweir // XPropertySet
968cdf0e10cSrcweir // -----------------------------------------------------------------------------
969cdf0e10cSrcweir 
GetAnyForItem(SfxItemSet & aSet,const SfxItemPropertySimpleEntry * pMap)970cdf0e10cSrcweir Any Cell::GetAnyForItem( SfxItemSet& aSet, const SfxItemPropertySimpleEntry* pMap )
971cdf0e10cSrcweir {
972cdf0e10cSrcweir 	Any aAny( SvxItemPropertySet_getPropertyValue( *mpPropSet, pMap, aSet ) );
973cdf0e10cSrcweir 
974cdf0e10cSrcweir 	if( *pMap->pType != aAny.getValueType() )
975cdf0e10cSrcweir 	{
976cdf0e10cSrcweir 		// since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
977cdf0e10cSrcweir 		if( ( *pMap->pType == ::getCppuType((const sal_Int16*)0)) && aAny.getValueType() == ::getCppuType((const sal_Int32*)0) )
978cdf0e10cSrcweir 		{
979cdf0e10cSrcweir 			sal_Int32 nValue = 0;
980cdf0e10cSrcweir 			aAny >>= nValue;
981cdf0e10cSrcweir 			aAny <<= (sal_Int16)nValue;
982cdf0e10cSrcweir 		}
983cdf0e10cSrcweir 		else
984cdf0e10cSrcweir 		{
985cdf0e10cSrcweir 			DBG_ERROR("GetAnyForItem() Returnvalue has wrong Type!" );
986cdf0e10cSrcweir 		}
987cdf0e10cSrcweir 	}
988cdf0e10cSrcweir 
989cdf0e10cSrcweir 	return aAny;
990cdf0e10cSrcweir }
991cdf0e10cSrcweir 
getPropertySetInfo()992cdf0e10cSrcweir Reference< XPropertySetInfo > SAL_CALL Cell::getPropertySetInfo() throw(RuntimeException)
993cdf0e10cSrcweir {
994cdf0e10cSrcweir 	return mpPropSet->getPropertySetInfo();
995cdf0e10cSrcweir }
996cdf0e10cSrcweir 
997cdf0e10cSrcweir // -----------------------------------------------------------------------------
998cdf0e10cSrcweir 
setPropertyValue(const OUString & rPropertyName,const Any & rValue)999cdf0e10cSrcweir void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any& rValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
1000cdf0e10cSrcweir {
1001cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir 	if( (mpProperties == 0) || (GetModel() == 0) )
1004cdf0e10cSrcweir 		throw DisposedException();
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName);
1007cdf0e10cSrcweir 	if( pMap )
1008cdf0e10cSrcweir 	{
1009cdf0e10cSrcweir 		if( (pMap->nFlags & PropertyAttribute::READONLY ) != 0 )
1010cdf0e10cSrcweir 			throw PropertyVetoException();
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir 		switch( pMap->nWID )
1013cdf0e10cSrcweir 		{
1014cdf0e10cSrcweir 		case OWN_ATTR_STYLE:
1015cdf0e10cSrcweir 		{
1016cdf0e10cSrcweir 			Reference< XStyle > xStyle;
1017cdf0e10cSrcweir 			if( !( rValue >>= xStyle ) )
1018cdf0e10cSrcweir 				throw IllegalArgumentException();
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir 			SfxUnoStyleSheet* pStyle = SfxUnoStyleSheet::getUnoStyleSheet(xStyle);
1021cdf0e10cSrcweir 			SetStyleSheet( pStyle, sal_True );
1022cdf0e10cSrcweir 			return;
1023cdf0e10cSrcweir 		}
1024cdf0e10cSrcweir 		case OWN_ATTR_TABLEBORDER:
1025cdf0e10cSrcweir 		{
1026cdf0e10cSrcweir 			if(rValue.getValueType() != ::getCppuType((const TableBorder*)0) )
1027cdf0e10cSrcweir 				break;
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir 			const TableBorder* pBorder = (const TableBorder* )rValue.getValue();
1030cdf0e10cSrcweir 			if( pBorder == NULL )
1031cdf0e10cSrcweir 				break;
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir             SvxBoxItem aBox( SDRATTR_TABLE_BORDER );
1034cdf0e10cSrcweir             SvxBoxInfoItem aBoxInfo( SDRATTR_TABLE_BORDER_INNER );
1035cdf0e10cSrcweir 			SvxBorderLine aLine;
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir 			sal_Bool bSet = SvxBoxItem::LineToSvxLine(pBorder->TopLine, aLine, false);
1038cdf0e10cSrcweir 			aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_TOP);
1039cdf0e10cSrcweir 			aBoxInfo.SetValid(VALID_TOP, pBorder->IsTopLineValid);
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir 			bSet = SvxBoxItem::LineToSvxLine(pBorder->BottomLine, aLine, false);
1042cdf0e10cSrcweir 			aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_BOTTOM);
1043cdf0e10cSrcweir 			aBoxInfo.SetValid(VALID_BOTTOM, pBorder->IsBottomLineValid);
1044cdf0e10cSrcweir 
1045cdf0e10cSrcweir 			bSet = SvxBoxItem::LineToSvxLine(pBorder->LeftLine, aLine, false);
1046cdf0e10cSrcweir 			aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_LEFT);
1047cdf0e10cSrcweir 			aBoxInfo.SetValid(VALID_LEFT, pBorder->IsLeftLineValid);
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir 			bSet = SvxBoxItem::LineToSvxLine(pBorder->RightLine, aLine, false);
1050cdf0e10cSrcweir 			aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_RIGHT);
1051cdf0e10cSrcweir 			aBoxInfo.SetValid(VALID_RIGHT, pBorder->IsRightLineValid);
1052cdf0e10cSrcweir 
1053cdf0e10cSrcweir 			bSet = SvxBoxItem::LineToSvxLine(pBorder->HorizontalLine, aLine, false);
1054cdf0e10cSrcweir 			aBoxInfo.SetLine(bSet ? &aLine : 0, BOXINFO_LINE_HORI);
1055cdf0e10cSrcweir 			aBoxInfo.SetValid(VALID_HORI, pBorder->IsHorizontalLineValid);
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 			bSet = SvxBoxItem::LineToSvxLine(pBorder->VerticalLine, aLine, false);
1058cdf0e10cSrcweir 			aBoxInfo.SetLine(bSet ? &aLine : 0, BOXINFO_LINE_VERT);
1059cdf0e10cSrcweir 			aBoxInfo.SetValid(VALID_VERT, pBorder->IsVerticalLineValid);
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir 			aBox.SetDistance(pBorder->Distance, false);
1062cdf0e10cSrcweir 			aBoxInfo.SetValid(VALID_DISTANCE, pBorder->IsDistanceValid);
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir 			mpProperties->SetObjectItem(aBox);
1065cdf0e10cSrcweir 			mpProperties->SetObjectItem(aBoxInfo);
1066cdf0e10cSrcweir 			return;
1067cdf0e10cSrcweir 		}
1068cdf0e10cSrcweir 		case OWN_ATTR_FILLBMP_MODE:
1069cdf0e10cSrcweir 		{
1070cdf0e10cSrcweir 			BitmapMode eMode;
1071cdf0e10cSrcweir 			if(!(rValue >>= eMode) )
1072cdf0e10cSrcweir 			{
1073cdf0e10cSrcweir 				sal_Int32 nMode = 0;
1074cdf0e10cSrcweir 				if(!(rValue >>= nMode))
1075cdf0e10cSrcweir 					throw IllegalArgumentException();
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir 					eMode = (BitmapMode)nMode;
1078cdf0e10cSrcweir 			}
1079cdf0e10cSrcweir 
1080cdf0e10cSrcweir 			mpProperties->SetObjectItem( XFillBmpStretchItem( eMode == BitmapMode_STRETCH ) );
1081cdf0e10cSrcweir 			mpProperties->SetObjectItem( XFillBmpTileItem( eMode == BitmapMode_REPEAT ) );
1082cdf0e10cSrcweir 			return;
1083cdf0e10cSrcweir 		}
1084cdf0e10cSrcweir 		default:
1085cdf0e10cSrcweir 		{
1086cdf0e10cSrcweir 			SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
1087cdf0e10cSrcweir 			aSet.Put(mpProperties->GetItem(pMap->nWID));
1088cdf0e10cSrcweir 
1089cdf0e10cSrcweir 			bool bSpecial = false;
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir 			switch( pMap->nWID )
1092cdf0e10cSrcweir 			{
1093cdf0e10cSrcweir 				case XATTR_FILLBITMAP:
1094cdf0e10cSrcweir 				case XATTR_FILLGRADIENT:
1095cdf0e10cSrcweir 				case XATTR_FILLHATCH:
1096cdf0e10cSrcweir 				case XATTR_FILLFLOATTRANSPARENCE:
1097cdf0e10cSrcweir 				case XATTR_LINEEND:
1098cdf0e10cSrcweir 				case XATTR_LINESTART:
1099cdf0e10cSrcweir 				case XATTR_LINEDASH:
1100cdf0e10cSrcweir 				{
1101cdf0e10cSrcweir 					if( pMap->nMemberId == MID_NAME )
1102cdf0e10cSrcweir 					{
1103cdf0e10cSrcweir 						OUString aApiName;
1104cdf0e10cSrcweir 						if( rValue >>= aApiName )
1105cdf0e10cSrcweir 						{
1106cdf0e10cSrcweir 							if( SvxShape::SetFillAttribute( pMap->nWID, aApiName, aSet, GetModel() ) )
1107cdf0e10cSrcweir 								bSpecial = true;
1108cdf0e10cSrcweir 						}
1109cdf0e10cSrcweir 					}
1110cdf0e10cSrcweir 				}
1111cdf0e10cSrcweir 				break;
1112cdf0e10cSrcweir 			}
1113cdf0e10cSrcweir 
1114cdf0e10cSrcweir 			if( !bSpecial )
1115cdf0e10cSrcweir 			{
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir 				if( !SvxUnoTextRangeBase::SetPropertyValueHelper( aSet, pMap, rValue, aSet ))
1118cdf0e10cSrcweir 				{
1119cdf0e10cSrcweir 					if( aSet.GetItemState( pMap->nWID ) != SFX_ITEM_SET )
1120cdf0e10cSrcweir 					{
1121cdf0e10cSrcweir 						// Default aus ItemPool holen
1122cdf0e10cSrcweir 						if(GetModel()->GetItemPool().IsWhich(pMap->nWID))
1123cdf0e10cSrcweir 							aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
1124cdf0e10cSrcweir 					}
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir 					if( aSet.GetItemState( pMap->nWID ) == SFX_ITEM_SET )
1127cdf0e10cSrcweir 					{
1128cdf0e10cSrcweir 						SvxItemPropertySet_setPropertyValue( *mpPropSet, pMap, rValue, aSet );
1129cdf0e10cSrcweir 					}
1130cdf0e10cSrcweir 				}
1131cdf0e10cSrcweir 			}
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir 			GetModel()->SetChanged();
1134cdf0e10cSrcweir 			mpProperties->SetMergedItemSetAndBroadcast( aSet );
1135cdf0e10cSrcweir 			return;
1136cdf0e10cSrcweir 		}
1137cdf0e10cSrcweir 		}
1138cdf0e10cSrcweir 	}
1139cdf0e10cSrcweir 	throw UnknownPropertyException();
1140cdf0e10cSrcweir }
1141cdf0e10cSrcweir 
1142cdf0e10cSrcweir // -----------------------------------------------------------------------------
1143cdf0e10cSrcweir 
getPropertyValue(const OUString & PropertyName)1144cdf0e10cSrcweir Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1145cdf0e10cSrcweir {
1146cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
1147cdf0e10cSrcweir 
1148cdf0e10cSrcweir 	if( (mpProperties == 0) || (GetModel() == 0) )
1149cdf0e10cSrcweir 		throw DisposedException();
1150cdf0e10cSrcweir 
1151cdf0e10cSrcweir     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
1152cdf0e10cSrcweir 	if( pMap )
1153cdf0e10cSrcweir 	{
1154cdf0e10cSrcweir 		switch( pMap->nWID )
1155cdf0e10cSrcweir 		{
1156cdf0e10cSrcweir /*
1157cdf0e10cSrcweir         case OWN_ATTR_HASLEVELS:
1158cdf0e10cSrcweir 		{
1159cdf0e10cSrcweir 			return Any( hasLevels() );
1160cdf0e10cSrcweir 		}
1161cdf0e10cSrcweir */
1162cdf0e10cSrcweir 		case OWN_ATTR_STYLE:
1163cdf0e10cSrcweir 		{
1164cdf0e10cSrcweir 			return Any( Reference< XStyle >( dynamic_cast< SfxUnoStyleSheet* >( GetStyleSheet() ) ) );
1165cdf0e10cSrcweir 		}
1166cdf0e10cSrcweir 		case OWN_ATTR_TABLEBORDER:
1167cdf0e10cSrcweir 		{
1168cdf0e10cSrcweir 			const SvxBoxInfoItem& rBoxInfoItem = static_cast<const SvxBoxInfoItem&>(mpProperties->GetItem(SDRATTR_TABLE_BORDER_INNER));
1169cdf0e10cSrcweir 			const SvxBoxItem& rBox = static_cast<const SvxBoxItem&>(mpProperties->GetItem(SDRATTR_TABLE_BORDER));
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir 		 	TableBorder aTableBorder;
1172cdf0e10cSrcweir 			aTableBorder.TopLine 				= SvxBoxItem::SvxLineToLine(rBox.GetTop(), false);
1173cdf0e10cSrcweir 			aTableBorder.IsTopLineValid 		= rBoxInfoItem.IsValid(VALID_TOP);
1174cdf0e10cSrcweir 			aTableBorder.BottomLine				= SvxBoxItem::SvxLineToLine(rBox.GetBottom(), false);
1175cdf0e10cSrcweir 			aTableBorder.IsBottomLineValid		= rBoxInfoItem.IsValid(VALID_BOTTOM);
1176cdf0e10cSrcweir 			aTableBorder.LeftLine				= SvxBoxItem::SvxLineToLine(rBox.GetLeft(), false);
1177cdf0e10cSrcweir 			aTableBorder.IsLeftLineValid		= rBoxInfoItem.IsValid(VALID_LEFT);
1178cdf0e10cSrcweir 			aTableBorder.RightLine				= SvxBoxItem::SvxLineToLine(rBox.GetRight(), false);
1179cdf0e10cSrcweir 			aTableBorder.IsRightLineValid		= rBoxInfoItem.IsValid(VALID_RIGHT );
1180cdf0e10cSrcweir 			aTableBorder.HorizontalLine			= SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetHori(), false);
1181cdf0e10cSrcweir 			aTableBorder.IsHorizontalLineValid 	= rBoxInfoItem.IsValid(VALID_HORI);
1182cdf0e10cSrcweir 			aTableBorder.VerticalLine			= SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetVert(), false);
1183cdf0e10cSrcweir 			aTableBorder.IsVerticalLineValid	= rBoxInfoItem.IsValid(VALID_VERT);
1184cdf0e10cSrcweir 			aTableBorder.Distance 				= rBox.GetDistance();
1185cdf0e10cSrcweir 			aTableBorder.IsDistanceValid 		= rBoxInfoItem.IsValid(VALID_DISTANCE);
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir 			return Any( aTableBorder );
1188cdf0e10cSrcweir 		}
1189cdf0e10cSrcweir 		case OWN_ATTR_FILLBMP_MODE:
1190cdf0e10cSrcweir 		{
1191cdf0e10cSrcweir 			const XFillBmpStretchItem& rStretchItem = static_cast<const XFillBmpStretchItem&>(mpProperties->GetItem(XATTR_FILLBMP_STRETCH));
1192cdf0e10cSrcweir 			const XFillBmpTileItem& rTileItem = static_cast<const XFillBmpTileItem&>(mpProperties->GetItem(XATTR_FILLBMP_TILE));
1193cdf0e10cSrcweir 			if( rTileItem.GetValue() )
1194cdf0e10cSrcweir 			{
1195cdf0e10cSrcweir 				return Any( BitmapMode_REPEAT );
1196cdf0e10cSrcweir 			}
1197cdf0e10cSrcweir 			else if( rStretchItem.GetValue() )
1198cdf0e10cSrcweir 			{
1199cdf0e10cSrcweir 				return Any(  BitmapMode_STRETCH );
1200cdf0e10cSrcweir 			}
1201cdf0e10cSrcweir 			else
1202cdf0e10cSrcweir 			{
1203cdf0e10cSrcweir 				return Any(  BitmapMode_NO_REPEAT );
1204cdf0e10cSrcweir 			}
1205cdf0e10cSrcweir 		}
1206cdf0e10cSrcweir 		default:
1207cdf0e10cSrcweir 		{
1208cdf0e10cSrcweir 			SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
1209cdf0e10cSrcweir 			aSet.Put(mpProperties->GetItem(pMap->nWID));
1210cdf0e10cSrcweir 
1211cdf0e10cSrcweir 			Any aAny;
1212cdf0e10cSrcweir 			if(!SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pMap, aAny ))
1213cdf0e10cSrcweir 			{
1214cdf0e10cSrcweir 				if(!aSet.Count())
1215cdf0e10cSrcweir 				{
1216cdf0e10cSrcweir 					// Default aus ItemPool holen
1217cdf0e10cSrcweir 					if(GetModel()->GetItemPool().IsWhich(pMap->nWID))
1218cdf0e10cSrcweir 						aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
1219cdf0e10cSrcweir 				}
1220cdf0e10cSrcweir 
1221cdf0e10cSrcweir 				if( aSet.Count() )
1222cdf0e10cSrcweir 					aAny = GetAnyForItem( aSet, pMap );
1223cdf0e10cSrcweir 			}
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir 			return aAny;
1226cdf0e10cSrcweir 		}
1227cdf0e10cSrcweir 		}
1228cdf0e10cSrcweir 	}
1229cdf0e10cSrcweir 	throw UnknownPropertyException();
1230cdf0e10cSrcweir }
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir // -----------------------------------------------------------------------------
1233cdf0e10cSrcweir 
addPropertyChangeListener(const OUString &,const Reference<XPropertyChangeListener> &)1234cdf0e10cSrcweir void SAL_CALL Cell::addPropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*xListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1235cdf0e10cSrcweir {
1236cdf0e10cSrcweir }
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir // -----------------------------------------------------------------------------
1239cdf0e10cSrcweir 
removePropertyChangeListener(const OUString &,const Reference<XPropertyChangeListener> &)1240cdf0e10cSrcweir void SAL_CALL Cell::removePropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1241cdf0e10cSrcweir {
1242cdf0e10cSrcweir }
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir // -----------------------------------------------------------------------------
1245cdf0e10cSrcweir 
addVetoableChangeListener(const OUString &,const Reference<XVetoableChangeListener> &)1246cdf0e10cSrcweir void SAL_CALL Cell::addVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1247cdf0e10cSrcweir {
1248cdf0e10cSrcweir }
1249cdf0e10cSrcweir 
1250cdf0e10cSrcweir // -----------------------------------------------------------------------------
1251cdf0e10cSrcweir 
removeVetoableChangeListener(const OUString &,const Reference<XVetoableChangeListener> &)1252cdf0e10cSrcweir void SAL_CALL Cell::removeVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1253cdf0e10cSrcweir {
1254cdf0e10cSrcweir }
1255cdf0e10cSrcweir 
1256cdf0e10cSrcweir // -----------------------------------------------------------------------------
1257cdf0e10cSrcweir // XMultiPropertySet
1258cdf0e10cSrcweir // -----------------------------------------------------------------------------
1259cdf0e10cSrcweir 
setPropertyValues(const Sequence<OUString> & aPropertyNames,const Sequence<Any> & aValues)1260cdf0e10cSrcweir void SAL_CALL Cell::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues ) throw (PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
1261cdf0e10cSrcweir {
1262cdf0e10cSrcweir 	OGuard aSolarGuard( Application::GetSolarMutex() );
1263cdf0e10cSrcweir 
1264cdf0e10cSrcweir 	if( (mpProperties == 0) || (GetModel() == 0) )
1265cdf0e10cSrcweir 		throw DisposedException();
1266cdf0e10cSrcweir 
1267cdf0e10cSrcweir 	const sal_Int32 nCount = aPropertyNames.getLength();
1268cdf0e10cSrcweir 
1269cdf0e10cSrcweir 	const OUString* pNames = aPropertyNames.getConstArray();
1270cdf0e10cSrcweir 	const Any* pValues = aValues.getConstArray();
1271cdf0e10cSrcweir 
1272cdf0e10cSrcweir 	for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ )
1273cdf0e10cSrcweir 	{
1274cdf0e10cSrcweir 		try
1275cdf0e10cSrcweir 		{
1276cdf0e10cSrcweir 			setPropertyValue( *pNames, *pValues );
1277cdf0e10cSrcweir 		}
1278cdf0e10cSrcweir 		catch( UnknownPropertyException& )
1279cdf0e10cSrcweir 		{
1280cdf0e10cSrcweir 			DBG_ERROR("svx::Cell::setPropertyValues(), unknown property!" );
1281cdf0e10cSrcweir 		}
1282cdf0e10cSrcweir         catch( Exception& )
1283cdf0e10cSrcweir         {
1284cdf0e10cSrcweir 			DBG_ERROR("svx::Cell::setPropertyValues(), Exception caught!" );
1285cdf0e10cSrcweir         }
1286cdf0e10cSrcweir 	}
1287cdf0e10cSrcweir }
1288cdf0e10cSrcweir 
1289cdf0e10cSrcweir // -----------------------------------------------------------------------------
1290cdf0e10cSrcweir 
getPropertyValues(const Sequence<OUString> & aPropertyNames)1291cdf0e10cSrcweir Sequence< Any > SAL_CALL Cell::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw (RuntimeException)
1292cdf0e10cSrcweir {
1293cdf0e10cSrcweir 	OGuard aSolarGuard( Application::GetSolarMutex() );
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir 	if( (mpProperties == 0) || (GetModel() == 0) )
1296cdf0e10cSrcweir 		throw DisposedException();
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir 	const sal_Int32 nCount = aPropertyNames.getLength();
1299cdf0e10cSrcweir 	const OUString* pNames = aPropertyNames.getConstArray();
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir 	Sequence< Any > aRet( nCount );
1302cdf0e10cSrcweir 	Any* pValue = aRet.getArray();
1303cdf0e10cSrcweir 
1304cdf0e10cSrcweir 	for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ )
1305cdf0e10cSrcweir 	{
1306cdf0e10cSrcweir 		try
1307cdf0e10cSrcweir 		{
1308cdf0e10cSrcweir 			*pValue = getPropertyValue( *pNames );
1309cdf0e10cSrcweir 		}
1310cdf0e10cSrcweir 		catch( UnknownPropertyException& )
1311cdf0e10cSrcweir 		{
1312cdf0e10cSrcweir 			DBG_ERROR("svx::Cell::setPropertyValues(), unknown property!" );
1313cdf0e10cSrcweir 		}
1314cdf0e10cSrcweir 		catch( Exception& )
1315cdf0e10cSrcweir 		{
1316cdf0e10cSrcweir 			DBG_ERROR( "svx::Cell::getPropertyValues(), Exception caught!" );
1317cdf0e10cSrcweir 		}
1318cdf0e10cSrcweir 	}
1319cdf0e10cSrcweir 
1320cdf0e10cSrcweir 	return aRet;
1321cdf0e10cSrcweir }
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir // -----------------------------------------------------------------------------
1324cdf0e10cSrcweir 
addPropertiesChangeListener(const Sequence<OUString> &,const Reference<XPropertiesChangeListener> &)1325cdf0e10cSrcweir void SAL_CALL Cell::addPropertiesChangeListener( const Sequence< OUString >& /*aPropertyNames*/, const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException)
1326cdf0e10cSrcweir {
1327cdf0e10cSrcweir }
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir // -----------------------------------------------------------------------------
1330cdf0e10cSrcweir 
removePropertiesChangeListener(const Reference<XPropertiesChangeListener> &)1331cdf0e10cSrcweir void SAL_CALL Cell::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException)
1332cdf0e10cSrcweir {
1333cdf0e10cSrcweir }
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir // -----------------------------------------------------------------------------
1336cdf0e10cSrcweir 
firePropertiesChangeEvent(const Sequence<OUString> &,const Reference<XPropertiesChangeListener> &)1337cdf0e10cSrcweir void SAL_CALL Cell::firePropertiesChangeEvent( const Sequence< OUString >& /*aPropertyNames*/, const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException)
1338cdf0e10cSrcweir {
1339cdf0e10cSrcweir }
1340cdf0e10cSrcweir 
1341cdf0e10cSrcweir // -----------------------------------------------------------------------------
1342cdf0e10cSrcweir // XPropertyState
1343cdf0e10cSrcweir // -----------------------------------------------------------------------------
1344cdf0e10cSrcweir 
getPropertyState(const OUString & PropertyName)1345cdf0e10cSrcweir PropertyState SAL_CALL Cell::getPropertyState( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException)
1346cdf0e10cSrcweir {
1347cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir 	if( (mpProperties == 0) || (GetModel() == 0) )
1350cdf0e10cSrcweir 		throw DisposedException();
1351cdf0e10cSrcweir 
1352cdf0e10cSrcweir     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
1353cdf0e10cSrcweir 
1354cdf0e10cSrcweir 	if( pMap )
1355cdf0e10cSrcweir 	{
1356cdf0e10cSrcweir 		PropertyState eState;
1357cdf0e10cSrcweir 		switch( pMap->nWID )
1358cdf0e10cSrcweir 		{
1359cdf0e10cSrcweir 		case OWN_ATTR_FILLBMP_MODE:
1360cdf0e10cSrcweir 		{
1361cdf0e10cSrcweir 			const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
1362cdf0e10cSrcweir 
1363cdf0e10cSrcweir 			const bool bStretch = rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET;
1364cdf0e10cSrcweir 			const bool bTile = rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET;
1365cdf0e10cSrcweir 			if( bStretch || bTile )
1366cdf0e10cSrcweir 			{
1367cdf0e10cSrcweir 				eState = PropertyState_DIRECT_VALUE;
1368cdf0e10cSrcweir 			}
1369cdf0e10cSrcweir 			else
1370cdf0e10cSrcweir 			{
1371cdf0e10cSrcweir 				eState = PropertyState_DEFAULT_VALUE;
1372cdf0e10cSrcweir 			}
1373cdf0e10cSrcweir 		}
1374cdf0e10cSrcweir /*
1375cdf0e10cSrcweir 		case OWN_ATTR_HASLEVELS:
1376cdf0e10cSrcweir 		{
1377cdf0e10cSrcweir 			return PropertyState_DIRECT_VALUE;
1378cdf0e10cSrcweir 		}
1379cdf0e10cSrcweir */
1380cdf0e10cSrcweir 		case OWN_ATTR_STYLE:
1381cdf0e10cSrcweir 		{
1382cdf0e10cSrcweir 			return PropertyState_DIRECT_VALUE;
1383cdf0e10cSrcweir 		}
1384cdf0e10cSrcweir 		case OWN_ATTR_TABLEBORDER:
1385cdf0e10cSrcweir 		{
1386cdf0e10cSrcweir 			const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
1387cdf0e10cSrcweir 			if( (rSet.GetItemState( SDRATTR_TABLE_BORDER_INNER, sal_False ) == SFX_ITEM_DEFAULT) && (rSet.GetItemState( SDRATTR_TABLE_BORDER, sal_False ) == SFX_ITEM_DEFAULT) )
1388cdf0e10cSrcweir 				return PropertyState_DEFAULT_VALUE;
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir 			return PropertyState_DIRECT_VALUE;
1391cdf0e10cSrcweir 		}
1392cdf0e10cSrcweir 		default:
1393cdf0e10cSrcweir 		{
1394cdf0e10cSrcweir 			const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
1395cdf0e10cSrcweir 
1396cdf0e10cSrcweir 			switch( rSet.GetItemState( pMap->nWID, sal_False ) )
1397cdf0e10cSrcweir 			{
1398cdf0e10cSrcweir 			case SFX_ITEM_READONLY:
1399cdf0e10cSrcweir 			case SFX_ITEM_SET:
1400cdf0e10cSrcweir 				eState = PropertyState_DIRECT_VALUE;
1401cdf0e10cSrcweir 				break;
1402cdf0e10cSrcweir 			case SFX_ITEM_DEFAULT:
1403cdf0e10cSrcweir 				eState = PropertyState_DEFAULT_VALUE;
1404cdf0e10cSrcweir 				break;
1405cdf0e10cSrcweir 	//		case SFX_ITEM_UNKNOWN:
1406cdf0e10cSrcweir 	//		case SFX_ITEM_DONTCARE:
1407cdf0e10cSrcweir 	//		case SFX_ITEM_DISABLED:
1408cdf0e10cSrcweir 			default:
1409cdf0e10cSrcweir 				eState = PropertyState_AMBIGUOUS_VALUE;
1410cdf0e10cSrcweir 				break;
1411cdf0e10cSrcweir 			}
1412cdf0e10cSrcweir 
1413cdf0e10cSrcweir 			// if a item is set, this doesn't mean we want it :)
1414cdf0e10cSrcweir 			if( ( PropertyState_DIRECT_VALUE == eState ) )
1415cdf0e10cSrcweir 			{
1416cdf0e10cSrcweir 				switch( pMap->nWID )
1417cdf0e10cSrcweir 				{
1418cdf0e10cSrcweir 				// the following items are disabled by changing the
1419cdf0e10cSrcweir 				// fill style or the line style. so there is no need
1420cdf0e10cSrcweir 				// to export items without names which should be empty
1421cdf0e10cSrcweir 				case XATTR_FILLBITMAP:
1422cdf0e10cSrcweir 				case XATTR_FILLGRADIENT:
1423cdf0e10cSrcweir 				case XATTR_FILLHATCH:
1424cdf0e10cSrcweir 				case XATTR_LINEDASH:
1425cdf0e10cSrcweir 					{
1426cdf0e10cSrcweir 						NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((sal_uInt16)pMap->nWID);
1427cdf0e10cSrcweir 						if( ( pItem == NULL ) || ( pItem->GetName().Len() == 0) )
1428cdf0e10cSrcweir 							eState = PropertyState_DEFAULT_VALUE;
1429cdf0e10cSrcweir 					}
1430cdf0e10cSrcweir 					break;
1431cdf0e10cSrcweir 
1432cdf0e10cSrcweir 				// #i36115#
1433cdf0e10cSrcweir 				// If e.g. the LineStart is on NONE and thus the string has length 0, it still
1434cdf0e10cSrcweir 				// may be a hard attribute covering the set LineStart of the parent (Style).
1435cdf0e10cSrcweir 				// #i37644#
1436cdf0e10cSrcweir 				// same is for fill float transparency
1437cdf0e10cSrcweir 				case XATTR_LINEEND:
1438cdf0e10cSrcweir 				case XATTR_LINESTART:
1439cdf0e10cSrcweir 				case XATTR_FILLFLOATTRANSPARENCE:
1440cdf0e10cSrcweir 					{
1441cdf0e10cSrcweir 						NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((sal_uInt16)pMap->nWID);
1442*a9ab3c7bSHerbert Dürr 						if( pItem == NULL )
1443cdf0e10cSrcweir 							eState = PropertyState_DEFAULT_VALUE;
1444cdf0e10cSrcweir 					}
1445cdf0e10cSrcweir 					break;
1446cdf0e10cSrcweir 				}
1447cdf0e10cSrcweir 			}
1448cdf0e10cSrcweir 		}
1449cdf0e10cSrcweir 		}
1450cdf0e10cSrcweir 		return eState;
1451cdf0e10cSrcweir 	}
1452cdf0e10cSrcweir 	throw UnknownPropertyException();
1453cdf0e10cSrcweir }
1454cdf0e10cSrcweir 
1455cdf0e10cSrcweir // -----------------------------------------------------------------------------
1456cdf0e10cSrcweir 
getPropertyStates(const Sequence<OUString> & aPropertyName)1457cdf0e10cSrcweir Sequence< PropertyState > SAL_CALL Cell::getPropertyStates( const Sequence< OUString >& aPropertyName ) throw(UnknownPropertyException, RuntimeException)
1458cdf0e10cSrcweir {
1459cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
1460cdf0e10cSrcweir 
1461cdf0e10cSrcweir 	if( (mpProperties == 0) || (GetModel() == 0) )
1462cdf0e10cSrcweir 		throw DisposedException();
1463cdf0e10cSrcweir 
1464cdf0e10cSrcweir 	const sal_Int32 nCount = aPropertyName.getLength();
1465cdf0e10cSrcweir 
1466cdf0e10cSrcweir 	Sequence< PropertyState > aRet( nCount );
1467cdf0e10cSrcweir 
1468cdf0e10cSrcweir 	const OUString* pNames = aPropertyName.getConstArray();
1469cdf0e10cSrcweir 	PropertyState* pState = aRet.getArray();
1470cdf0e10cSrcweir 
1471cdf0e10cSrcweir 	for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pState++ )
1472cdf0e10cSrcweir 	{
1473cdf0e10cSrcweir 		try
1474cdf0e10cSrcweir 		{
1475cdf0e10cSrcweir 			*pState = getPropertyState( *pNames );
1476cdf0e10cSrcweir 		}
1477cdf0e10cSrcweir 		catch( Exception& )
1478cdf0e10cSrcweir 		{
1479cdf0e10cSrcweir 			*pState = PropertyState_AMBIGUOUS_VALUE;
1480cdf0e10cSrcweir 		}
1481cdf0e10cSrcweir 	}
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir 	return aRet;
1484cdf0e10cSrcweir }
1485cdf0e10cSrcweir 
1486cdf0e10cSrcweir // -----------------------------------------------------------------------------
1487cdf0e10cSrcweir 
setPropertyToDefault(const OUString & PropertyName)1488cdf0e10cSrcweir void SAL_CALL Cell::setPropertyToDefault( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException)
1489cdf0e10cSrcweir {
1490cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
1491cdf0e10cSrcweir 
1492cdf0e10cSrcweir 	if( (mpProperties == 0) || (GetModel() == 0) )
1493cdf0e10cSrcweir 		throw DisposedException();
1494cdf0e10cSrcweir 
1495cdf0e10cSrcweir     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
1496cdf0e10cSrcweir 	if( pMap )
1497cdf0e10cSrcweir 	{
1498cdf0e10cSrcweir 		switch( pMap->nWID )
1499cdf0e10cSrcweir 		{
1500cdf0e10cSrcweir 		case OWN_ATTR_FILLBMP_MODE:
1501cdf0e10cSrcweir 		{
1502cdf0e10cSrcweir 			mpProperties->ClearObjectItem( XATTR_FILLBMP_STRETCH );
1503cdf0e10cSrcweir 			mpProperties->ClearObjectItem( XATTR_FILLBMP_TILE );
1504cdf0e10cSrcweir 			break;
1505cdf0e10cSrcweir 		}
1506cdf0e10cSrcweir //		case OWN_ATTR_HASLEVELS:
1507cdf0e10cSrcweir 		case OWN_ATTR_STYLE:
1508cdf0e10cSrcweir 			break;
1509cdf0e10cSrcweir 
1510cdf0e10cSrcweir 		case OWN_ATTR_TABLEBORDER:
1511cdf0e10cSrcweir 		{
1512cdf0e10cSrcweir 			mpProperties->ClearObjectItem( SDRATTR_TABLE_BORDER_INNER );
1513cdf0e10cSrcweir 			mpProperties->ClearObjectItem( SDRATTR_TABLE_BORDER );
1514cdf0e10cSrcweir 			break;
1515cdf0e10cSrcweir 		}
1516cdf0e10cSrcweir 
1517cdf0e10cSrcweir 		default:
1518cdf0e10cSrcweir 		{
1519cdf0e10cSrcweir 			mpProperties->ClearObjectItem( pMap->nWID );
1520cdf0e10cSrcweir 		}
1521cdf0e10cSrcweir 		}
1522cdf0e10cSrcweir 
1523cdf0e10cSrcweir 		GetModel()->SetChanged();
1524cdf0e10cSrcweir 		return;
1525cdf0e10cSrcweir 	}
1526cdf0e10cSrcweir 	throw UnknownPropertyException();
1527cdf0e10cSrcweir }
1528cdf0e10cSrcweir 
1529cdf0e10cSrcweir // -----------------------------------------------------------------------------
1530cdf0e10cSrcweir 
getPropertyDefault(const OUString & aPropertyName)1531cdf0e10cSrcweir Any SAL_CALL Cell::getPropertyDefault( const OUString& aPropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1532cdf0e10cSrcweir {
1533cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
1534cdf0e10cSrcweir 
1535cdf0e10cSrcweir 	if( (mpProperties == 0) || (GetModel() == 0) )
1536cdf0e10cSrcweir 		throw DisposedException();
1537cdf0e10cSrcweir 
1538cdf0e10cSrcweir     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName);
1539cdf0e10cSrcweir 	if( pMap )
1540cdf0e10cSrcweir 	{
1541cdf0e10cSrcweir 		switch( pMap->nWID )
1542cdf0e10cSrcweir 		{
1543cdf0e10cSrcweir 		case OWN_ATTR_FILLBMP_MODE:
1544cdf0e10cSrcweir 			return Any(  BitmapMode_NO_REPEAT );
1545cdf0e10cSrcweir 
1546cdf0e10cSrcweir /*
1547cdf0e10cSrcweir         case OWN_ATTR_HASLEVELS:
1548cdf0e10cSrcweir 			return Any( sal_False );
1549cdf0e10cSrcweir */
1550cdf0e10cSrcweir 		case OWN_ATTR_STYLE:
1551cdf0e10cSrcweir 		{
1552cdf0e10cSrcweir 			Reference< XStyle > xStyle;
1553cdf0e10cSrcweir 			return Any( xStyle );
1554cdf0e10cSrcweir 		}
1555cdf0e10cSrcweir 
1556cdf0e10cSrcweir 		case OWN_ATTR_TABLEBORDER:
1557cdf0e10cSrcweir 		{
1558cdf0e10cSrcweir 			TableBorder aBorder;
1559cdf0e10cSrcweir 			return Any( aBorder );
1560cdf0e10cSrcweir 		}
1561cdf0e10cSrcweir 
1562cdf0e10cSrcweir 		default:
1563cdf0e10cSrcweir 		{
1564cdf0e10cSrcweir 			if(  GetModel()->GetItemPool().IsWhich(pMap->nWID) )
1565cdf0e10cSrcweir 			{
1566cdf0e10cSrcweir 				SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
1567cdf0e10cSrcweir 				aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
1568cdf0e10cSrcweir 				return GetAnyForItem( aSet, pMap );
1569cdf0e10cSrcweir 			}
1570cdf0e10cSrcweir 		}
1571cdf0e10cSrcweir 		}
1572cdf0e10cSrcweir 	}
1573cdf0e10cSrcweir 	throw UnknownPropertyException();
1574cdf0e10cSrcweir }
1575cdf0e10cSrcweir 
1576cdf0e10cSrcweir // -----------------------------------------------------------------------------
1577cdf0e10cSrcweir // XMultiPropertyStates
1578cdf0e10cSrcweir // -----------------------------------------------------------------------------
1579cdf0e10cSrcweir 
setAllPropertiesToDefault()1580cdf0e10cSrcweir void SAL_CALL Cell::setAllPropertiesToDefault(  ) throw (RuntimeException)
1581cdf0e10cSrcweir {
1582cdf0e10cSrcweir 	if( mpProperties )
1583cdf0e10cSrcweir 		delete mpProperties;
1584cdf0e10cSrcweir 	mpProperties = new sdr::properties::CellProperties( static_cast< SdrTableObj& >( GetObject() ), this );
1585cdf0e10cSrcweir 
1586cdf0e10cSrcweir 	SdrOutliner& rOutliner = GetObject().ImpGetDrawOutliner();
1587cdf0e10cSrcweir 
1588cdf0e10cSrcweir 	OutlinerParaObject* pParaObj = GetOutlinerParaObject();
1589cdf0e10cSrcweir 	if( pParaObj )
1590cdf0e10cSrcweir 	{
1591cdf0e10cSrcweir 		rOutliner.SetText(*pParaObj);
1592cdf0e10cSrcweir 		sal_uInt32 nParaCount(rOutliner.GetParagraphCount());
1593cdf0e10cSrcweir 
1594cdf0e10cSrcweir 		if(nParaCount)
1595cdf0e10cSrcweir 		{
1596cdf0e10cSrcweir 			ESelection aSelection( 0, 0, EE_PARA_ALL, EE_PARA_ALL);
1597cdf0e10cSrcweir 			rOutliner.RemoveAttribs(aSelection, sal_True, 0);
1598cdf0e10cSrcweir 
1599cdf0e10cSrcweir 			OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount);
1600cdf0e10cSrcweir 			rOutliner.Clear();
1601cdf0e10cSrcweir 
1602cdf0e10cSrcweir 			SetOutlinerParaObject(pTemp);
1603cdf0e10cSrcweir 		}
1604cdf0e10cSrcweir 	}
1605cdf0e10cSrcweir }
1606cdf0e10cSrcweir 
1607cdf0e10cSrcweir // -----------------------------------------------------------------------------
1608cdf0e10cSrcweir 
setPropertiesToDefault(const Sequence<OUString> & aPropertyNames)1609cdf0e10cSrcweir void SAL_CALL Cell::setPropertiesToDefault( const Sequence< OUString >& aPropertyNames ) throw (UnknownPropertyException, RuntimeException)
1610cdf0e10cSrcweir {
1611cdf0e10cSrcweir 	sal_Int32 nCount = aPropertyNames.getLength();
1612cdf0e10cSrcweir 	const OUString* pName = aPropertyNames.getConstArray();
1613cdf0e10cSrcweir 
1614cdf0e10cSrcweir 	while(nCount--)
1615cdf0e10cSrcweir 		setPropertyToDefault( *pName++ );
1616cdf0e10cSrcweir }
1617cdf0e10cSrcweir 
1618cdf0e10cSrcweir // -----------------------------------------------------------------------------
1619cdf0e10cSrcweir 
getPropertyDefaults(const Sequence<OUString> & aPropertyNames)1620cdf0e10cSrcweir Sequence< Any > SAL_CALL Cell::getPropertyDefaults( const Sequence< OUString >& aPropertyNames ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
1621cdf0e10cSrcweir {
1622cdf0e10cSrcweir 	sal_Int32 nCount = aPropertyNames.getLength();
1623cdf0e10cSrcweir 	Sequence< Any > aDefaults( nCount );
1624cdf0e10cSrcweir 	Any* pDefaults = aDefaults.getArray();
1625cdf0e10cSrcweir 	const OUString* pName = aPropertyNames.getConstArray();
1626cdf0e10cSrcweir 
1627cdf0e10cSrcweir 	while(nCount--)
1628cdf0e10cSrcweir 		*pDefaults++ = getPropertyDefault( *pName++ );
1629cdf0e10cSrcweir 
1630cdf0e10cSrcweir 	return aDefaults;
1631cdf0e10cSrcweir }
1632cdf0e10cSrcweir 
1633cdf0e10cSrcweir // -----------------------------------------------------------------------------
1634cdf0e10cSrcweir // XFastPropertySet
1635cdf0e10cSrcweir // -----------------------------------------------------------------------------
1636cdf0e10cSrcweir 
setFastPropertyValue(sal_Int32 nHandle,const Any & aValue)1637cdf0e10cSrcweir void SAL_CALL Cell::setFastPropertyValue( sal_Int32 nHandle, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
1638cdf0e10cSrcweir {
1639cdf0e10cSrcweir 	(void)aValue;
1640cdf0e10cSrcweir 	(void)nHandle;
1641cdf0e10cSrcweir     throw UnknownPropertyException();
1642cdf0e10cSrcweir }
1643cdf0e10cSrcweir 
1644cdf0e10cSrcweir // -----------------------------------------------------------------------------
1645cdf0e10cSrcweir // TODO: Refactor this method!
getFastPropertyValue(sal_Int32 nHandle)1646cdf0e10cSrcweir Any SAL_CALL Cell::getFastPropertyValue( sal_Int32 nHandle ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
1647cdf0e10cSrcweir {
1648cdf0e10cSrcweir     (void)nHandle;
1649cdf0e10cSrcweir     throw UnknownPropertyException();
1650cdf0e10cSrcweir }
1651cdf0e10cSrcweir 
1652cdf0e10cSrcweir // -----------------------------------------------------------------------------
1653cdf0e10cSrcweir // XText
1654cdf0e10cSrcweir // -----------------------------------------------------------------------------
1655cdf0e10cSrcweir 
insertTextContent(const Reference<XTextRange> & xRange,const Reference<XTextContent> & xContent,sal_Bool bAbsorb)1656cdf0e10cSrcweir void SAL_CALL Cell::insertTextContent( const Reference< XTextRange >& xRange, const Reference< XTextContent >& xContent, sal_Bool bAbsorb ) throw (IllegalArgumentException, RuntimeException)
1657cdf0e10cSrcweir {
1658cdf0e10cSrcweir 	SvxUnoTextBase::insertTextContent( xRange, xContent, bAbsorb );
1659cdf0e10cSrcweir 	notifyModified();
1660cdf0e10cSrcweir }
1661cdf0e10cSrcweir 
1662cdf0e10cSrcweir // -----------------------------------------------------------------------------
1663cdf0e10cSrcweir 
removeTextContent(const Reference<XTextContent> & xContent)1664cdf0e10cSrcweir void SAL_CALL Cell::removeTextContent( const Reference< XTextContent >& xContent ) throw (NoSuchElementException, RuntimeException)
1665cdf0e10cSrcweir {
1666cdf0e10cSrcweir 	SvxUnoTextBase::removeTextContent( xContent );
1667cdf0e10cSrcweir 	notifyModified();
1668cdf0e10cSrcweir }
1669cdf0e10cSrcweir 
1670cdf0e10cSrcweir // -----------------------------------------------------------------------------
1671cdf0e10cSrcweir // XSimpleText
1672cdf0e10cSrcweir // -----------------------------------------------------------------------------
1673cdf0e10cSrcweir 
createTextCursor()1674cdf0e10cSrcweir Reference< XTextCursor > SAL_CALL Cell::createTextCursor(  ) throw (RuntimeException)
1675cdf0e10cSrcweir {
1676cdf0e10cSrcweir 	return SvxUnoTextBase::createTextCursor();
1677cdf0e10cSrcweir }
1678cdf0e10cSrcweir 
1679cdf0e10cSrcweir // -----------------------------------------------------------------------------
1680cdf0e10cSrcweir 
createTextCursorByRange(const Reference<XTextRange> & aTextPosition)1681cdf0e10cSrcweir Reference< XTextCursor > SAL_CALL Cell::createTextCursorByRange( const Reference< XTextRange >& aTextPosition ) throw (RuntimeException)
1682cdf0e10cSrcweir {
1683cdf0e10cSrcweir 	return SvxUnoTextBase::createTextCursorByRange( aTextPosition );
1684cdf0e10cSrcweir }
1685cdf0e10cSrcweir 
1686cdf0e10cSrcweir // -----------------------------------------------------------------------------
1687cdf0e10cSrcweir 
insertString(const Reference<XTextRange> & xRange,const OUString & aString,sal_Bool bAbsorb)1688cdf0e10cSrcweir void SAL_CALL Cell::insertString( const Reference< XTextRange >& xRange, const OUString& aString, sal_Bool bAbsorb ) throw (RuntimeException)
1689cdf0e10cSrcweir {
1690cdf0e10cSrcweir 	SvxUnoTextBase::insertString( xRange, aString, bAbsorb );
1691cdf0e10cSrcweir 	notifyModified();
1692cdf0e10cSrcweir }
1693cdf0e10cSrcweir 
1694cdf0e10cSrcweir // -----------------------------------------------------------------------------
1695cdf0e10cSrcweir 
insertControlCharacter(const Reference<XTextRange> & xRange,sal_Int16 nControlCharacter,sal_Bool bAbsorb)1696cdf0e10cSrcweir void SAL_CALL Cell::insertControlCharacter( const Reference< XTextRange >& xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb ) throw (IllegalArgumentException, RuntimeException)
1697cdf0e10cSrcweir {
1698cdf0e10cSrcweir 	SvxUnoTextBase::insertControlCharacter( xRange, nControlCharacter, bAbsorb );
1699cdf0e10cSrcweir 	notifyModified();
1700cdf0e10cSrcweir }
1701cdf0e10cSrcweir 
1702cdf0e10cSrcweir // -----------------------------------------------------------------------------
1703cdf0e10cSrcweir // XTextRange
1704cdf0e10cSrcweir // -----------------------------------------------------------------------------
1705cdf0e10cSrcweir 
getText()1706cdf0e10cSrcweir Reference< XText > SAL_CALL Cell::getText(  ) throw (RuntimeException)
1707cdf0e10cSrcweir {
1708cdf0e10cSrcweir 	return SvxUnoTextBase::getText();
1709cdf0e10cSrcweir }
1710cdf0e10cSrcweir 
1711cdf0e10cSrcweir // -----------------------------------------------------------------------------
1712cdf0e10cSrcweir 
getStart()1713cdf0e10cSrcweir Reference< XTextRange > SAL_CALL Cell::getStart(  ) throw (RuntimeException)
1714cdf0e10cSrcweir {
1715cdf0e10cSrcweir 	return SvxUnoTextBase::getStart();
1716cdf0e10cSrcweir }
1717cdf0e10cSrcweir 
1718cdf0e10cSrcweir // -----------------------------------------------------------------------------
1719cdf0e10cSrcweir 
getEnd()1720cdf0e10cSrcweir Reference< XTextRange > SAL_CALL Cell::getEnd(  ) throw (RuntimeException)
1721cdf0e10cSrcweir {
1722cdf0e10cSrcweir 	return SvxUnoTextBase::getEnd();
1723cdf0e10cSrcweir }
1724cdf0e10cSrcweir 
1725cdf0e10cSrcweir // -----------------------------------------------------------------------------
1726cdf0e10cSrcweir 
getString()1727cdf0e10cSrcweir OUString SAL_CALL Cell::getString(  ) throw (RuntimeException)
1728cdf0e10cSrcweir {
1729cdf0e10cSrcweir     maSelection.nStartPara = 0xffff;
1730cdf0e10cSrcweir 	return SvxUnoTextBase::getString();
1731cdf0e10cSrcweir }
1732cdf0e10cSrcweir 
1733cdf0e10cSrcweir // -----------------------------------------------------------------------------
1734cdf0e10cSrcweir 
setString(const OUString & aString)1735cdf0e10cSrcweir void SAL_CALL Cell::setString( const OUString& aString ) throw (RuntimeException)
1736cdf0e10cSrcweir {
1737cdf0e10cSrcweir 	SvxUnoTextBase::setString( aString );
1738cdf0e10cSrcweir 	notifyModified();
1739cdf0e10cSrcweir }
1740cdf0e10cSrcweir 
1741cdf0e10cSrcweir // XEventListener
disposing(const EventObject &)1742cdf0e10cSrcweir void SAL_CALL Cell::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
1743cdf0e10cSrcweir {
1744cdf0e10cSrcweir 	mxTable.clear();
1745cdf0e10cSrcweir     dispose();
1746cdf0e10cSrcweir }
1747cdf0e10cSrcweir 
getCellName(sal_Int32 nCol,sal_Int32 nRow)1748cdf0e10cSrcweir static OUString getCellName( sal_Int32 nCol, sal_Int32 nRow )
1749cdf0e10cSrcweir {
1750cdf0e10cSrcweir     rtl::OUStringBuffer aBuf;
1751cdf0e10cSrcweir 
1752cdf0e10cSrcweir     if (nCol < 26*26)
1753cdf0e10cSrcweir     {
1754cdf0e10cSrcweir         if (nCol < 26)
1755cdf0e10cSrcweir             aBuf.append( static_cast<sal_Unicode>( 'A' +
1756cdf0e10cSrcweir                         static_cast<sal_uInt16>(nCol)));
1757cdf0e10cSrcweir         else
1758cdf0e10cSrcweir         {
1759cdf0e10cSrcweir             aBuf.append( static_cast<sal_Unicode>( 'A' +
1760cdf0e10cSrcweir                         (static_cast<sal_uInt16>(nCol) / 26) - 1));
1761cdf0e10cSrcweir             aBuf.append( static_cast<sal_Unicode>( 'A' +
1762cdf0e10cSrcweir                         (static_cast<sal_uInt16>(nCol) % 26)));
1763cdf0e10cSrcweir         }
1764cdf0e10cSrcweir     }
1765cdf0e10cSrcweir     else
1766cdf0e10cSrcweir     {
1767cdf0e10cSrcweir         String aStr;
1768cdf0e10cSrcweir         while (nCol >= 26)
1769cdf0e10cSrcweir         {
1770cdf0e10cSrcweir             sal_Int32 nC = nCol % 26;
1771cdf0e10cSrcweir             aStr += static_cast<sal_Unicode>( 'A' +
1772cdf0e10cSrcweir                     static_cast<sal_uInt16>(nC));
1773cdf0e10cSrcweir             nCol = nCol - nC;
1774cdf0e10cSrcweir             nCol = nCol / 26 - 1;
1775cdf0e10cSrcweir         }
1776cdf0e10cSrcweir         aStr += static_cast<sal_Unicode>( 'A' +
1777cdf0e10cSrcweir                 static_cast<sal_uInt16>(nCol));
1778cdf0e10cSrcweir         aStr.Reverse();
1779cdf0e10cSrcweir         aBuf.append( aStr);
1780cdf0e10cSrcweir     }
1781cdf0e10cSrcweir     aBuf.append( OUString::valueOf(nRow+1) );
1782cdf0e10cSrcweir     return aBuf.makeStringAndClear();
1783cdf0e10cSrcweir }
1784cdf0e10cSrcweir 
getName()1785cdf0e10cSrcweir OUString Cell::getName()
1786cdf0e10cSrcweir {
1787cdf0e10cSrcweir     // todo: optimize!
1788cdf0e10cSrcweir     OUString sName;
1789cdf0e10cSrcweir     if( mxTable.is() ) try
1790cdf0e10cSrcweir     {
1791cdf0e10cSrcweir         Reference< XCell > xThis( static_cast< XCell* >( this ) );
1792cdf0e10cSrcweir 
1793cdf0e10cSrcweir         sal_Int32 nRowCount = mxTable->getRowCount();
1794cdf0e10cSrcweir         sal_Int32 nColCount = mxTable->getColumnCount();
1795cdf0e10cSrcweir         for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
1796cdf0e10cSrcweir         {
1797cdf0e10cSrcweir             for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ )
1798cdf0e10cSrcweir             {
1799cdf0e10cSrcweir                 Reference< XCell > xCell( mxTable->getCellByPosition( nCol, nRow ) );
1800cdf0e10cSrcweir                 if( xCell == xThis )
1801cdf0e10cSrcweir                 {
1802cdf0e10cSrcweir                     return getCellName( nCol, nRow );
1803cdf0e10cSrcweir                 }
1804cdf0e10cSrcweir             }
1805cdf0e10cSrcweir         }
1806cdf0e10cSrcweir     }
1807cdf0e10cSrcweir     catch( Exception& )
1808cdf0e10cSrcweir     {
1809cdf0e10cSrcweir     }
1810cdf0e10cSrcweir 
1811cdf0e10cSrcweir     return sName;
1812cdf0e10cSrcweir }
1813cdf0e10cSrcweir 
1814cdf0e10cSrcweir } }
1815cdf0e10cSrcweir 
1816