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