xref: /aoo42x/main/svx/source/table/svdotable.cxx (revision cdf0e10c)
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 #define ITEMID_BOX SDRATTR_TABLE_BORDER
32*cdf0e10cSrcweir #define ITEMID_BOXINFO SDRATTR_TABLE_BORDER_INNER
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <vcl/canvastools.hxx>
40*cdf0e10cSrcweir #include <com/sun/star/style/XStyle.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
42*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
43*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygon.hxx>
44*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
45*cdf0e10cSrcweir #include <svl/style.hxx>
46*cdf0e10cSrcweir #include "editeng/editstat.hxx"
47*cdf0e10cSrcweir #include "editeng/outlobj.hxx"
48*cdf0e10cSrcweir #include "svx/svdview.hxx"
49*cdf0e10cSrcweir #include "svx/sdr/properties/textproperties.hxx"
50*cdf0e10cSrcweir #include "svx/svdotable.hxx"
51*cdf0e10cSrcweir #include "svx/svdhdl.hxx"
52*cdf0e10cSrcweir #include "viewcontactoftableobj.hxx"
53*cdf0e10cSrcweir #include "svx/svdoutl.hxx"
54*cdf0e10cSrcweir #include "svx/svddrag.hxx"
55*cdf0e10cSrcweir #include "svx/svdpagv.hxx"
56*cdf0e10cSrcweir #include "tablemodel.hxx"
57*cdf0e10cSrcweir #include "cell.hxx"
58*cdf0e10cSrcweir #include "svx/xflclit.hxx"
59*cdf0e10cSrcweir #include "tablelayouter.hxx"
60*cdf0e10cSrcweir #include "svx/svdetc.hxx"
61*cdf0e10cSrcweir #include "tablehandles.hxx"
62*cdf0e10cSrcweir #include "editeng/boxitem.hxx"
63*cdf0e10cSrcweir #include "svx/framelink.hxx"
64*cdf0e10cSrcweir #include "svx/sdr/table/tabledesign.hxx"
65*cdf0e10cSrcweir #include "svx/svdundo.hxx"
66*cdf0e10cSrcweir #include "svx/svdstr.hrc"
67*cdf0e10cSrcweir #include "svx/svdglob.hxx"
68*cdf0e10cSrcweir #include "editeng/writingmodeitem.hxx"
69*cdf0e10cSrcweir #include "editeng/frmdiritem.hxx"
70*cdf0e10cSrcweir #include "svx/xflhtit.hxx"
71*cdf0e10cSrcweir #include "svx/xflftrit.hxx"
72*cdf0e10cSrcweir #include "svx/xfltrit.hxx"
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir // -----------------------------------------------------------------------------
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir using ::rtl::OUString;
77*cdf0e10cSrcweir using ::com::sun::star::uno::Any;
78*cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
79*cdf0e10cSrcweir using ::com::sun::star::uno::XInterface;
80*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY;
81*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW;
82*cdf0e10cSrcweir using ::com::sun::star::uno::Exception;
83*cdf0e10cSrcweir using ::com::sun::star::container::XIndexAccess;
84*cdf0e10cSrcweir using ::com::sun::star::style::XStyle;
85*cdf0e10cSrcweir using ::com::sun::star::table::XTableRows;
86*cdf0e10cSrcweir using ::com::sun::star::table::XTableColumns;
87*cdf0e10cSrcweir using ::com::sun::star::table::XTable;
88*cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet;
89*cdf0e10cSrcweir using ::com::sun::star::util::XModifyBroadcaster;
90*cdf0e10cSrcweir using sdr::properties::TextProperties;
91*cdf0e10cSrcweir using sdr::properties::BaseProperties;
92*cdf0e10cSrcweir using namespace ::com::sun::star::text;
93*cdf0e10cSrcweir using namespace ::com::sun::star::container;
94*cdf0e10cSrcweir using namespace ::com::sun::star::style;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir namespace sdr { namespace table {
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir class TableProperties : public TextProperties
99*cdf0e10cSrcweir {
100*cdf0e10cSrcweir protected:
101*cdf0e10cSrcweir 	// create a new itemset
102*cdf0e10cSrcweir 	SfxItemSet& CreateObjectSpecificItemSet(SfxItemPool& rPool);
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir public:
105*cdf0e10cSrcweir 	// basic constructor
106*cdf0e10cSrcweir 	TableProperties(SdrObject& rObj );
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 	// constructor for copying, but using new object
109*cdf0e10cSrcweir 	TableProperties(const TableProperties& rProps, SdrObject& rObj );
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	// destructor
112*cdf0e10cSrcweir 	~TableProperties();
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 	// Clone() operator, normally just calls the local copy constructor
115*cdf0e10cSrcweir 	BaseProperties& Clone(SdrObject& rObj) const;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem);
118*cdf0e10cSrcweir };
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir TableProperties::TableProperties(SdrObject& rObj)
121*cdf0e10cSrcweir : TextProperties(rObj)
122*cdf0e10cSrcweir {
123*cdf0e10cSrcweir }
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir TableProperties::TableProperties(const TableProperties& rProps, SdrObject& rObj)
126*cdf0e10cSrcweir : TextProperties(rProps, rObj)
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir TableProperties::~TableProperties()
131*cdf0e10cSrcweir {
132*cdf0e10cSrcweir }
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir BaseProperties& TableProperties::Clone(SdrObject& rObj) const
135*cdf0e10cSrcweir {
136*cdf0e10cSrcweir 	return *(new TableProperties(*this, rObj));
137*cdf0e10cSrcweir }
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir void TableProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
140*cdf0e10cSrcweir {
141*cdf0e10cSrcweir 	if( nWhich == SDRATTR_TEXTDIRECTION )
142*cdf0e10cSrcweir 		AttributeProperties::ItemChange( nWhich, pNewItem );
143*cdf0e10cSrcweir 	else
144*cdf0e10cSrcweir 		TextProperties::ItemChange( nWhich, pNewItem );
145*cdf0e10cSrcweir }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir // create a new itemset
148*cdf0e10cSrcweir SfxItemSet& TableProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
149*cdf0e10cSrcweir {
150*cdf0e10cSrcweir 	return *(new SfxItemSet(rPool,
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 		// range from SdrAttrObj
153*cdf0e10cSrcweir 		SDRATTR_START, SDRATTR_SHADOW_LAST,
154*cdf0e10cSrcweir 		SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
155*cdf0e10cSrcweir 		SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 		// range for SdrTableObj
158*cdf0e10cSrcweir 		SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 		// range from SdrTextObj
161*cdf0e10cSrcweir 		EE_ITEMS_START, EE_ITEMS_END,
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 		// end
164*cdf0e10cSrcweir 		0, 0));
165*cdf0e10cSrcweir }
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir class TableObjectGeoData : public SdrTextObjGeoData
168*cdf0e10cSrcweir {
169*cdf0e10cSrcweir public:
170*cdf0e10cSrcweir 	Rectangle	maLogicRect;
171*cdf0e10cSrcweir };
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir //------------------------------------------------------------------------
174*cdf0e10cSrcweir // TableStyleSettings
175*cdf0e10cSrcweir //------------------------------------------------------------------------
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir TableStyleSettings::TableStyleSettings()
178*cdf0e10cSrcweir : mbUseFirstRow(true)
179*cdf0e10cSrcweir , mbUseLastRow(false)
180*cdf0e10cSrcweir , mbUseFirstColumn(false)
181*cdf0e10cSrcweir , mbUseLastColumn(false)
182*cdf0e10cSrcweir , mbUseRowBanding(true)
183*cdf0e10cSrcweir , mbUseColumnBanding(false)
184*cdf0e10cSrcweir {
185*cdf0e10cSrcweir }
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir TableStyleSettings::TableStyleSettings( const TableStyleSettings& rStyle )
188*cdf0e10cSrcweir {
189*cdf0e10cSrcweir 	(*this) = rStyle;
190*cdf0e10cSrcweir }
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir TableStyleSettings& TableStyleSettings::operator=(const TableStyleSettings& rStyle)
193*cdf0e10cSrcweir {
194*cdf0e10cSrcweir 	mbUseFirstRow = rStyle.mbUseFirstRow;
195*cdf0e10cSrcweir 	mbUseLastRow = rStyle.mbUseLastRow;
196*cdf0e10cSrcweir 	mbUseFirstColumn = rStyle.mbUseFirstColumn;
197*cdf0e10cSrcweir 	mbUseLastColumn = rStyle.mbUseLastColumn;
198*cdf0e10cSrcweir 	mbUseRowBanding = rStyle.mbUseRowBanding;
199*cdf0e10cSrcweir 	mbUseColumnBanding = rStyle.mbUseColumnBanding;
200*cdf0e10cSrcweir 	return *this;
201*cdf0e10cSrcweir }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir bool TableStyleSettings::operator==( const TableStyleSettings& rStyle ) const
204*cdf0e10cSrcweir {
205*cdf0e10cSrcweir 	return
206*cdf0e10cSrcweir 		(mbUseFirstRow == rStyle.mbUseFirstRow) &&
207*cdf0e10cSrcweir 		(mbUseLastRow == rStyle.mbUseLastRow) &&
208*cdf0e10cSrcweir 		(mbUseFirstColumn == rStyle.mbUseFirstColumn) &&
209*cdf0e10cSrcweir 		(mbUseLastColumn == rStyle.mbUseLastColumn) &&
210*cdf0e10cSrcweir 		(mbUseRowBanding == rStyle.mbUseRowBanding) &&
211*cdf0e10cSrcweir 		(mbUseColumnBanding == rStyle.mbUseColumnBanding);
212*cdf0e10cSrcweir }
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir // -----------------------------------------------------------------------------
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir class SdrTableObjImpl : public TableDesignUser, public ::cppu::WeakImplHelper1< ::com::sun::star::util::XModifyListener >
217*cdf0e10cSrcweir {
218*cdf0e10cSrcweir public:
219*cdf0e10cSrcweir 	CellRef	mxActiveCell;
220*cdf0e10cSrcweir 	TableModelRef mxTable;
221*cdf0e10cSrcweir 	SdrTableObj* mpTableObj;
222*cdf0e10cSrcweir 	TableLayouter* mpLayouter;
223*cdf0e10cSrcweir 	CellPos maEditPos;
224*cdf0e10cSrcweir 	TableStyleSettings maTableStyle;
225*cdf0e10cSrcweir 	Reference< XIndexAccess > mxTableStyle;
226*cdf0e10cSrcweir 	bool mbModifyPending;
227*cdf0e10cSrcweir //	sal_Int32 mnSavedEditRowHeight;
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 	void SetModel(SdrModel* pOldModel, SdrModel* pNewModel);
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 	CellRef getCell( const CellPos& rPos ) const;
232*cdf0e10cSrcweir 	void LayoutTable( Rectangle& rArea, bool bFitWidth, bool bFitHeight );
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir 	bool ApplyCellStyles();
235*cdf0e10cSrcweir 	void UpdateCells( Rectangle& rArea );
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 	SdrTableObjImpl();
238*cdf0e10cSrcweir 	virtual ~SdrTableObjImpl();
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 	void init( SdrTableObj* pTable, sal_Int32 nColumns, sal_Int32 nRows );
241*cdf0e10cSrcweir 	void dispose();
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 	sal_Int32 getColumnCount() const;
244*cdf0e10cSrcweir 	sal_Int32 getRowCount() const;
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir 	void DragEdge( bool mbHorizontal, int nEdge, sal_Int32 nOffset );
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 	const SfxPoolItem* GetCellItem( const CellPos& rPos, sal_uInt16 nWhich ) const;
249*cdf0e10cSrcweir //	void GetBorderLines( const CellPos& rPos, const SvxBorderLine** ppLeft, const SvxBorderLine** ppTop, const SvxBorderLine** ppRight, const SvxBorderLine** ppBottom ) const;
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir 	void operator=( const SdrTableObjImpl& rSource );
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir     // XModifyListener
254*cdf0e10cSrcweir     virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir     // XEventListener
257*cdf0e10cSrcweir     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 	void update();
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 	void connectTableStyle();
262*cdf0e10cSrcweir 	void disconnectTableStyle();
263*cdf0e10cSrcweir 	virtual bool isInUse();
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 	bool UpdateWritingMode();
266*cdf0e10cSrcweir };
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir // -----------------------------------------------------------------------------
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir SdrTableObjImpl::SdrTableObjImpl()
271*cdf0e10cSrcweir : mpTableObj( 0 )
272*cdf0e10cSrcweir , mpLayouter( 0 )
273*cdf0e10cSrcweir {
274*cdf0e10cSrcweir }
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir // -----------------------------------------------------------------------------
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir SdrTableObjImpl::~SdrTableObjImpl()
279*cdf0e10cSrcweir {
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir // -----------------------------------------------------------------------------
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir void SdrTableObjImpl::init( SdrTableObj* pTable, sal_Int32 nColumns, sal_Int32 nRows )
285*cdf0e10cSrcweir {
286*cdf0e10cSrcweir 	mpTableObj = pTable;
287*cdf0e10cSrcweir 	mxTable = new TableModel( pTable );
288*cdf0e10cSrcweir 	mxTable->init( nColumns, nRows );
289*cdf0e10cSrcweir 	mpLayouter = new TableLayouter( mxTable );
290*cdf0e10cSrcweir 	Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) );
291*cdf0e10cSrcweir 	mxTable->addModifyListener( xListener );
292*cdf0e10cSrcweir 	UpdateWritingMode();
293*cdf0e10cSrcweir 	LayoutTable( mpTableObj->aRect, true, true );
294*cdf0e10cSrcweir 	mpTableObj->maLogicRect = mpTableObj->aRect;
295*cdf0e10cSrcweir }
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir // -----------------------------------------------------------------------------
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir void SdrTableObjImpl::operator=( const SdrTableObjImpl& rSource )
300*cdf0e10cSrcweir {
301*cdf0e10cSrcweir 	if( mpLayouter )
302*cdf0e10cSrcweir 	{
303*cdf0e10cSrcweir 		delete mpLayouter;
304*cdf0e10cSrcweir 		mpLayouter = 0;
305*cdf0e10cSrcweir 	}
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir 	if( mxTable.is() )
308*cdf0e10cSrcweir 	{
309*cdf0e10cSrcweir 		Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) );
310*cdf0e10cSrcweir 		mxTable->removeModifyListener( xListener );
311*cdf0e10cSrcweir 		mxTable->dispose();
312*cdf0e10cSrcweir 		mxTable.clear();
313*cdf0e10cSrcweir 	}
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir 	maTableStyle = rSource.maTableStyle;
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir 	mxTable = new TableModel( mpTableObj, rSource.mxTable );
318*cdf0e10cSrcweir 	mpLayouter = new TableLayouter( mxTable );
319*cdf0e10cSrcweir 	Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) );
320*cdf0e10cSrcweir 	mxTable->addModifyListener( xListener );
321*cdf0e10cSrcweir 	mxTableStyle = rSource.mxTableStyle;
322*cdf0e10cSrcweir 	UpdateWritingMode();
323*cdf0e10cSrcweir 	ApplyCellStyles();
324*cdf0e10cSrcweir 	mpTableObj->aRect = mpTableObj->maLogicRect;
325*cdf0e10cSrcweir 	LayoutTable( mpTableObj->aRect, false, false );
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir // -----------------------------------------------------------------------------
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir void SdrTableObjImpl::SetModel(SdrModel* /*pOldModel*/, SdrModel* pNewModel)
331*cdf0e10cSrcweir {
332*cdf0e10cSrcweir 	// try to find new table style
333*cdf0e10cSrcweir 	disconnectTableStyle();
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir 	Reference< XIndexAccess > xNewTableStyle;
336*cdf0e10cSrcweir 	if( mxTableStyle.is() ) try
337*cdf0e10cSrcweir 	{
338*cdf0e10cSrcweir 		const OUString sStyleName( Reference< XNamed >( mxTableStyle, UNO_QUERY_THROW )->getName() );
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir 		Reference< XStyleFamiliesSupplier > xSFS( pNewModel->getUnoModel(), UNO_QUERY_THROW );
341*cdf0e10cSrcweir 		Reference< XNameAccess > xFamilyNameAccess( xSFS->getStyleFamilies(), UNO_QUERY_THROW );
342*cdf0e10cSrcweir 		const rtl::OUString sFamilyName( RTL_CONSTASCII_USTRINGPARAM( "table" ) );
343*cdf0e10cSrcweir 		Reference< XNameAccess > xTableFamilyAccess( xFamilyNameAccess->getByName( sFamilyName ), UNO_QUERY_THROW );
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 		if( xTableFamilyAccess->hasByName( sStyleName ) )
346*cdf0e10cSrcweir 		{
347*cdf0e10cSrcweir 			// found table style with the same name
348*cdf0e10cSrcweir 			xTableFamilyAccess->getByName( sStyleName ) >>= xNewTableStyle;
349*cdf0e10cSrcweir 		}
350*cdf0e10cSrcweir 		else
351*cdf0e10cSrcweir 		{
352*cdf0e10cSrcweir 			// copy or?
353*cdf0e10cSrcweir 			Reference< XIndexAccess > xIndexAccess( xTableFamilyAccess, UNO_QUERY_THROW );
354*cdf0e10cSrcweir 			xIndexAccess->getByIndex( 0 ) >>= xNewTableStyle;
355*cdf0e10cSrcweir 		}
356*cdf0e10cSrcweir 	}
357*cdf0e10cSrcweir 	catch( Exception& )
358*cdf0e10cSrcweir 	{
359*cdf0e10cSrcweir 		DBG_ERROR("svx::SdrTableObjImpl::SetModel(), exception caught!");
360*cdf0e10cSrcweir 	}
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir 	mxTableStyle = xNewTableStyle;
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 	connectTableStyle();
365*cdf0e10cSrcweir 	update();
366*cdf0e10cSrcweir }
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir // -----------------------------------------------------------------------------
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir bool SdrTableObjImpl::ApplyCellStyles()
371*cdf0e10cSrcweir {
372*cdf0e10cSrcweir 	if( !mxTable.is() || !mxTable.is() || !mxTableStyle.is() )
373*cdf0e10cSrcweir 		return false;
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir 	bool bChanges = false;
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir 	const sal_Int32 nColCount = getColumnCount();
378*cdf0e10cSrcweir 	const sal_Int32 nRowCount = getRowCount();
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir 	const TableStyleSettings& rStyle = maTableStyle;
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 	CellPos aPos;
383*cdf0e10cSrcweir 	for( aPos.mnRow = 0; aPos.mnRow < nRowCount; ++aPos.mnRow )
384*cdf0e10cSrcweir 	{
385*cdf0e10cSrcweir 		const bool bFirstRow = (aPos.mnRow == 0) && rStyle.mbUseFirstRow;
386*cdf0e10cSrcweir 		const bool bLastRow = (aPos.mnRow == nRowCount-1) && rStyle.mbUseLastRow;
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir 		for( aPos.mnCol = 0; aPos.mnCol < nColCount; ++aPos.mnCol )
389*cdf0e10cSrcweir 		{
390*cdf0e10cSrcweir 			Reference< XStyle > xStyle;
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir 			// first and last row win first, if used and available
393*cdf0e10cSrcweir 			if( bFirstRow )
394*cdf0e10cSrcweir 			{
395*cdf0e10cSrcweir 				mxTableStyle->getByIndex(first_row_style) >>= xStyle;
396*cdf0e10cSrcweir 			}
397*cdf0e10cSrcweir 			else if( bLastRow )
398*cdf0e10cSrcweir 			{
399*cdf0e10cSrcweir 				mxTableStyle->getByIndex(last_row_style) >>= xStyle;
400*cdf0e10cSrcweir 			}
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir 			if( !xStyle.is() )
403*cdf0e10cSrcweir 			{
404*cdf0e10cSrcweir 				// next come first and last column, if used and available
405*cdf0e10cSrcweir 				if( rStyle.mbUseFirstColumn && (aPos.mnCol == 0)  )
406*cdf0e10cSrcweir 				{
407*cdf0e10cSrcweir 					mxTableStyle->getByIndex(first_column_style) >>= xStyle;
408*cdf0e10cSrcweir 				}
409*cdf0e10cSrcweir 				else if( rStyle.mbUseLastColumn && (aPos.mnCol == nColCount-1) )
410*cdf0e10cSrcweir 				{
411*cdf0e10cSrcweir 					mxTableStyle->getByIndex(last_column_style) >>= xStyle;
412*cdf0e10cSrcweir 				}
413*cdf0e10cSrcweir 			}
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir 			if( !xStyle.is() && rStyle.mbUseRowBanding )
416*cdf0e10cSrcweir 			{
417*cdf0e10cSrcweir 				if( (aPos.mnRow & 1) == 0 )
418*cdf0e10cSrcweir 				{
419*cdf0e10cSrcweir 					mxTableStyle->getByIndex(even_rows_style) >>= xStyle;
420*cdf0e10cSrcweir 				}
421*cdf0e10cSrcweir 				else
422*cdf0e10cSrcweir 				{
423*cdf0e10cSrcweir 					mxTableStyle->getByIndex(odd_rows_style) >>= xStyle;
424*cdf0e10cSrcweir 				}
425*cdf0e10cSrcweir 			}
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir 			if( !xStyle.is() && rStyle.mbUseColumnBanding )
428*cdf0e10cSrcweir 			{
429*cdf0e10cSrcweir 				if( (aPos.mnCol & 1) == 0 )
430*cdf0e10cSrcweir 				{
431*cdf0e10cSrcweir 					mxTableStyle->getByIndex(even_columns_style) >>= xStyle;
432*cdf0e10cSrcweir 				}
433*cdf0e10cSrcweir 				else
434*cdf0e10cSrcweir 				{
435*cdf0e10cSrcweir 					mxTableStyle->getByIndex(odd_columns_style) >>= xStyle;
436*cdf0e10cSrcweir 				}
437*cdf0e10cSrcweir 			}
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir 			if( !xStyle.is() )
440*cdf0e10cSrcweir 			{
441*cdf0e10cSrcweir 				// use default cell style if non found yet
442*cdf0e10cSrcweir 				mxTableStyle->getByIndex(body_style) >>= xStyle;
443*cdf0e10cSrcweir 			}
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir 			if( xStyle.is() )
447*cdf0e10cSrcweir 			{
448*cdf0e10cSrcweir 				SfxUnoStyleSheet* pStyle = SfxUnoStyleSheet::getUnoStyleSheet(xStyle);
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir 				if( pStyle )
451*cdf0e10cSrcweir 				{
452*cdf0e10cSrcweir 					CellRef xCell( getCell( aPos ) );
453*cdf0e10cSrcweir 					if( xCell.is() && ( xCell->GetStyleSheet() != pStyle ) )
454*cdf0e10cSrcweir 					{
455*cdf0e10cSrcweir 						bChanges = true;
456*cdf0e10cSrcweir 						xCell->SetStyleSheet( pStyle, sal_True );
457*cdf0e10cSrcweir 					}
458*cdf0e10cSrcweir 				}
459*cdf0e10cSrcweir 			}
460*cdf0e10cSrcweir 		}
461*cdf0e10cSrcweir 	}
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir 	return bChanges;
464*cdf0e10cSrcweir }
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir // -----------------------------------------------------------------------------
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir void SdrTableObjImpl::dispose()
469*cdf0e10cSrcweir {
470*cdf0e10cSrcweir 	if( mxTable.is() )
471*cdf0e10cSrcweir 		mxTable->dispose();
472*cdf0e10cSrcweir }
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir // -----------------------------------------------------------------------------
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir void SdrTableObjImpl::DragEdge( bool mbHorizontal, int nEdge, sal_Int32 nOffset )
477*cdf0e10cSrcweir {
478*cdf0e10cSrcweir 	if( (nEdge > 0) && mxTable.is()) try
479*cdf0e10cSrcweir 	{
480*cdf0e10cSrcweir 		const OUString sSize( RTL_CONSTASCII_USTRINGPARAM( "Size" ) );
481*cdf0e10cSrcweir 		nEdge--;
482*cdf0e10cSrcweir 		if( mbHorizontal )
483*cdf0e10cSrcweir 		{
484*cdf0e10cSrcweir 			if( (nEdge >= 0) && (nEdge < getRowCount()) )
485*cdf0e10cSrcweir 			{
486*cdf0e10cSrcweir 				sal_Int32 nHeigth = mpLayouter->getRowHeight( nEdge );
487*cdf0e10cSrcweir 				nHeigth += nOffset;
488*cdf0e10cSrcweir 				Reference< XIndexAccess > xRows( mxTable->getRows(), UNO_QUERY_THROW );
489*cdf0e10cSrcweir 				Reference< XPropertySet > xRowSet( xRows->getByIndex( nEdge ), UNO_QUERY_THROW );
490*cdf0e10cSrcweir 				xRowSet->setPropertyValue( sSize, Any( nHeigth ) );
491*cdf0e10cSrcweir 			}
492*cdf0e10cSrcweir 		}
493*cdf0e10cSrcweir 		else
494*cdf0e10cSrcweir 		{
495*cdf0e10cSrcweir 			if( (nEdge >= 0) && (nEdge < getColumnCount()) )
496*cdf0e10cSrcweir 			{
497*cdf0e10cSrcweir 				sal_Int32 nWidth = mpLayouter->getColumnWidth( nEdge );
498*cdf0e10cSrcweir 				nWidth += nOffset;
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 				Reference< XIndexAccess > xCols( mxTable->getColumns(), UNO_QUERY_THROW );
501*cdf0e10cSrcweir 				Reference< XPropertySet > xColSet( xCols->getByIndex( nEdge ), UNO_QUERY_THROW );
502*cdf0e10cSrcweir 				xColSet->setPropertyValue( sSize, Any( nWidth ) );
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir 				if( nEdge > 0 && nEdge < mxTable->getColumnCount() )
505*cdf0e10cSrcweir 				{
506*cdf0e10cSrcweir 					const bool bRTL = mpLayouter->GetWritingMode() == WritingMode_RL_TB;
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir 					if( bRTL )
509*cdf0e10cSrcweir 						nEdge--;
510*cdf0e10cSrcweir 					else
511*cdf0e10cSrcweir 						nEdge++;
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir 					if( (bRTL && (nEdge >= 0)) || (!bRTL && (nEdge < mxTable->getColumnCount())) )
514*cdf0e10cSrcweir 					{
515*cdf0e10cSrcweir 						nWidth = mpLayouter->getColumnWidth( nEdge );
516*cdf0e10cSrcweir 						nWidth = std::max( (sal_Int32)(nWidth - nOffset), (sal_Int32)0 );
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir 						xColSet = Reference< XPropertySet >( xCols->getByIndex( nEdge ), UNO_QUERY_THROW );
519*cdf0e10cSrcweir 						xColSet->setPropertyValue( sSize, Any( nWidth ) );
520*cdf0e10cSrcweir 					}
521*cdf0e10cSrcweir 				}
522*cdf0e10cSrcweir 			}
523*cdf0e10cSrcweir 		}
524*cdf0e10cSrcweir 	}
525*cdf0e10cSrcweir 	catch( Exception& )
526*cdf0e10cSrcweir 	{
527*cdf0e10cSrcweir 		DBG_ERROR( "svx::SdrTableObjImpl::DragEdge(), exception caught!" );
528*cdf0e10cSrcweir 	}
529*cdf0e10cSrcweir }
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir // -----------------------------------------------------------------------------
532*cdf0e10cSrcweir // XModifyListener
533*cdf0e10cSrcweir // -----------------------------------------------------------------------------
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir void SAL_CALL SdrTableObjImpl::modified( const ::com::sun::star::lang::EventObject& /*aEvent*/ ) throw (::com::sun::star::uno::RuntimeException)
536*cdf0e10cSrcweir {
537*cdf0e10cSrcweir 	update();
538*cdf0e10cSrcweir }
539*cdf0e10cSrcweir 
540*cdf0e10cSrcweir void SdrTableObjImpl::update()
541*cdf0e10cSrcweir {
542*cdf0e10cSrcweir 	// source can be the table model itself or the assigned table template
543*cdf0e10cSrcweir 	TableModelNotifyGuard aGuard( mxTable.get() );
544*cdf0e10cSrcweir 	if( mpTableObj )
545*cdf0e10cSrcweir 	{
546*cdf0e10cSrcweir 		if( (maEditPos.mnRow >= getRowCount()) || (maEditPos.mnCol >= getColumnCount()) || (getCell( maEditPos ) != mxActiveCell) )
547*cdf0e10cSrcweir 		{
548*cdf0e10cSrcweir 			if(maEditPos.mnRow >= getRowCount())
549*cdf0e10cSrcweir 				maEditPos.mnRow = getRowCount()-1;
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir 			if(maEditPos.mnCol >= getColumnCount())
552*cdf0e10cSrcweir 				maEditPos.mnCol = getColumnCount()-1;
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir 			mpTableObj->setActiveCell( maEditPos );
555*cdf0e10cSrcweir 		}
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir 		ApplyCellStyles();
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir 		mpTableObj->aRect = mpTableObj->maLogicRect;
560*cdf0e10cSrcweir 		LayoutTable( mpTableObj->aRect, false, false );
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir 		mpTableObj->SetRectsDirty();
563*cdf0e10cSrcweir 		mpTableObj->ActionChanged();
564*cdf0e10cSrcweir 		mpTableObj->BroadcastObjectChange();
565*cdf0e10cSrcweir 	}
566*cdf0e10cSrcweir }
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir // -----------------------------------------------------------------------------
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir void SdrTableObjImpl::connectTableStyle()
571*cdf0e10cSrcweir {
572*cdf0e10cSrcweir 	if( mxTableStyle.is() )
573*cdf0e10cSrcweir 	{
574*cdf0e10cSrcweir 		Reference< XModifyBroadcaster > xBroadcaster( mxTableStyle, UNO_QUERY );
575*cdf0e10cSrcweir 		if( xBroadcaster.is() )
576*cdf0e10cSrcweir 		{
577*cdf0e10cSrcweir 			Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) );
578*cdf0e10cSrcweir 			xBroadcaster->addModifyListener( xListener );
579*cdf0e10cSrcweir 		}
580*cdf0e10cSrcweir 	}
581*cdf0e10cSrcweir }
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir // -----------------------------------------------------------------------------
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir void SdrTableObjImpl::disconnectTableStyle()
586*cdf0e10cSrcweir {
587*cdf0e10cSrcweir 	if( mxTableStyle.is() )
588*cdf0e10cSrcweir 	{
589*cdf0e10cSrcweir 		Reference< XModifyBroadcaster > xBroadcaster( mxTableStyle, UNO_QUERY );
590*cdf0e10cSrcweir 		if( xBroadcaster.is() )
591*cdf0e10cSrcweir 		{
592*cdf0e10cSrcweir 			Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) );
593*cdf0e10cSrcweir 			xBroadcaster->removeModifyListener( xListener );
594*cdf0e10cSrcweir 		}
595*cdf0e10cSrcweir 	}
596*cdf0e10cSrcweir }
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir // -----------------------------------------------------------------------------
599*cdf0e10cSrcweir 
600*cdf0e10cSrcweir bool SdrTableObjImpl::isInUse()
601*cdf0e10cSrcweir {
602*cdf0e10cSrcweir 	return mpTableObj && mpTableObj->IsInserted();
603*cdf0e10cSrcweir }
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir // -----------------------------------------------------------------------------
606*cdf0e10cSrcweir // XEventListener
607*cdf0e10cSrcweir // -----------------------------------------------------------------------------
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir void SAL_CALL SdrTableObjImpl::disposing( const ::com::sun::star::lang::EventObject& /*Source*/ ) throw (::com::sun::star::uno::RuntimeException)
610*cdf0e10cSrcweir {
611*cdf0e10cSrcweir 	mxActiveCell.clear();
612*cdf0e10cSrcweir 	mxTable.clear();
613*cdf0e10cSrcweir 	if( mpLayouter )
614*cdf0e10cSrcweir 	{
615*cdf0e10cSrcweir 		delete mpLayouter;
616*cdf0e10cSrcweir 		mpLayouter = 0;
617*cdf0e10cSrcweir 	}
618*cdf0e10cSrcweir 	mpTableObj = 0;
619*cdf0e10cSrcweir }
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir // -----------------------------------------------------------------------------
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir CellRef SdrTableObjImpl::getCell(  const CellPos& rPos  ) const
624*cdf0e10cSrcweir {
625*cdf0e10cSrcweir 	CellRef xCell;
626*cdf0e10cSrcweir 	if( mxTable.is() ) try
627*cdf0e10cSrcweir 	{
628*cdf0e10cSrcweir 		xCell.set( dynamic_cast< Cell* >( mxTable->getCellByPosition( rPos.mnCol, rPos.mnRow ).get() ) );
629*cdf0e10cSrcweir 	}
630*cdf0e10cSrcweir 	catch( Exception& )
631*cdf0e10cSrcweir 	{
632*cdf0e10cSrcweir 		DBG_ERROR( "svx::SdrTableObjImpl::getCell(), exception caught!" );
633*cdf0e10cSrcweir 	}
634*cdf0e10cSrcweir 	return xCell;
635*cdf0e10cSrcweir }
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir // -----------------------------------------------------------------------------
638*cdf0e10cSrcweir 
639*cdf0e10cSrcweir sal_Int32 SdrTableObjImpl::getColumnCount() const
640*cdf0e10cSrcweir {
641*cdf0e10cSrcweir 	return mxTable.is() ? mxTable->getColumnCount() : 0;
642*cdf0e10cSrcweir }
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir // -----------------------------------------------------------------------------
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir sal_Int32 SdrTableObjImpl::getRowCount() const
647*cdf0e10cSrcweir {
648*cdf0e10cSrcweir 	return mxTable.is() ? mxTable->getRowCount() : 0;
649*cdf0e10cSrcweir }
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir // -----------------------------------------------------------------------------
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir void SdrTableObjImpl::LayoutTable( Rectangle& rArea, bool bFitWidth, bool bFitHeight )
654*cdf0e10cSrcweir {
655*cdf0e10cSrcweir 	if( mpLayouter && mpTableObj->GetModel() )
656*cdf0e10cSrcweir 	{
657*cdf0e10cSrcweir 		TableModelNotifyGuard aGuard( mxTable.get() );
658*cdf0e10cSrcweir 		mpLayouter->LayoutTable( rArea, bFitWidth, bFitHeight );
659*cdf0e10cSrcweir 	}
660*cdf0e10cSrcweir }
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir // -----------------------------------------------------------------------------
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir bool SdrTableObjImpl::UpdateWritingMode()
665*cdf0e10cSrcweir {
666*cdf0e10cSrcweir 	if( mpTableObj && mpLayouter )
667*cdf0e10cSrcweir 	{
668*cdf0e10cSrcweir 		WritingMode eWritingMode = (WritingMode)static_cast< const SvxWritingModeItem& >( mpTableObj->GetObjectItem( SDRATTR_TEXTDIRECTION ) ).GetValue();
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir 		if( eWritingMode != WritingMode_TB_RL )
671*cdf0e10cSrcweir 		{
672*cdf0e10cSrcweir 			if( static_cast< const SvxFrameDirectionItem& >( mpTableObj->GetObjectItem( EE_PARA_WRITINGDIR ) ).GetValue() == FRMDIR_HORI_LEFT_TOP )
673*cdf0e10cSrcweir 				eWritingMode = WritingMode_LR_TB;
674*cdf0e10cSrcweir 			else
675*cdf0e10cSrcweir 				eWritingMode = WritingMode_RL_TB;
676*cdf0e10cSrcweir 		}
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir 		if( eWritingMode != mpLayouter->GetWritingMode() )
679*cdf0e10cSrcweir 		{
680*cdf0e10cSrcweir 			mpLayouter->SetWritingMode( eWritingMode );
681*cdf0e10cSrcweir 			return true;
682*cdf0e10cSrcweir 		}
683*cdf0e10cSrcweir 	}
684*cdf0e10cSrcweir 	return false;
685*cdf0e10cSrcweir }
686*cdf0e10cSrcweir 
687*cdf0e10cSrcweir // -----------------------------------------------------------------------------
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir void SdrTableObjImpl::UpdateCells( Rectangle& rArea )
690*cdf0e10cSrcweir {
691*cdf0e10cSrcweir 	if( mpLayouter && mxTable.is() )
692*cdf0e10cSrcweir 	{
693*cdf0e10cSrcweir 		TableModelNotifyGuard aGuard( mxTable.get() );
694*cdf0e10cSrcweir 		mpLayouter->updateCells( rArea );
695*cdf0e10cSrcweir 		mxTable->setModified(sal_True);
696*cdf0e10cSrcweir 	}
697*cdf0e10cSrcweir }
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir // -----------------------------------------------------------------------------
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir const SfxPoolItem* SdrTableObjImpl::GetCellItem( const CellPos& rPos, sal_uInt16 nWhich ) const
702*cdf0e10cSrcweir {
703*cdf0e10cSrcweir 	CellRef xCell( getCell( rPos  ) );
704*cdf0e10cSrcweir 	if( xCell.is() )
705*cdf0e10cSrcweir 		return xCell->GetItemSet().GetItem( nWhich );
706*cdf0e10cSrcweir 	else
707*cdf0e10cSrcweir 		return 0;
708*cdf0e10cSrcweir }
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir // -----------------------------------------------------------------------------
711*cdf0e10cSrcweir // BaseProperties section
712*cdf0e10cSrcweir // -----------------------------------------------------------------------------
713*cdf0e10cSrcweir 
714*cdf0e10cSrcweir sdr::properties::BaseProperties* SdrTableObj::CreateObjectSpecificProperties()
715*cdf0e10cSrcweir {
716*cdf0e10cSrcweir 	return new TableProperties(*this);
717*cdf0e10cSrcweir }
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir // -----------------------------------------------------------------------------
720*cdf0e10cSrcweir // DrawContact section
721*cdf0e10cSrcweir // -----------------------------------------------------------------------------
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir sdr::contact::ViewContact* SdrTableObj::CreateObjectSpecificViewContact()
724*cdf0e10cSrcweir {
725*cdf0e10cSrcweir 	return new sdr::contact::ViewContactOfTableObj(*this);
726*cdf0e10cSrcweir }
727*cdf0e10cSrcweir 
728*cdf0e10cSrcweir // --------------------------------------------------------------------
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir TYPEINIT1(SdrTableObj,SdrTextObj);
731*cdf0e10cSrcweir 
732*cdf0e10cSrcweir // --------------------------------------------------------------------
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir SdrTableObj::SdrTableObj(SdrModel* _pModel)
735*cdf0e10cSrcweir {
736*cdf0e10cSrcweir 	pModel = _pModel;
737*cdf0e10cSrcweir 	init( 1, 1 );
738*cdf0e10cSrcweir }
739*cdf0e10cSrcweir 
740*cdf0e10cSrcweir // --------------------------------------------------------------------
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir SdrTableObj::SdrTableObj(SdrModel* _pModel, const ::Rectangle& rNewRect, sal_Int32 nColumns, sal_Int32 nRows)
743*cdf0e10cSrcweir : SdrTextObj( rNewRect )
744*cdf0e10cSrcweir , maLogicRect( rNewRect )
745*cdf0e10cSrcweir {
746*cdf0e10cSrcweir 	pModel = _pModel;
747*cdf0e10cSrcweir 
748*cdf0e10cSrcweir 	if( nColumns <= 0 )
749*cdf0e10cSrcweir 		nColumns = 1;
750*cdf0e10cSrcweir 
751*cdf0e10cSrcweir 	if( nRows <= 0 )
752*cdf0e10cSrcweir 		nRows = 1;
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir 	init( nColumns, nRows );
755*cdf0e10cSrcweir }
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir // --------------------------------------------------------------------
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir void SdrTableObj::init( sal_Int32 nColumns, sal_Int32 nRows )
760*cdf0e10cSrcweir {
761*cdf0e10cSrcweir 	bClosedObj = sal_True;
762*cdf0e10cSrcweir 
763*cdf0e10cSrcweir 	mpImpl = new SdrTableObjImpl;
764*cdf0e10cSrcweir 	mpImpl->acquire();
765*cdf0e10cSrcweir 	mpImpl->init( this, nColumns, nRows );
766*cdf0e10cSrcweir }
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir // --------------------------------------------------------------------
769*cdf0e10cSrcweir 
770*cdf0e10cSrcweir SdrTableObj::~SdrTableObj()
771*cdf0e10cSrcweir {
772*cdf0e10cSrcweir 	mpImpl->dispose();
773*cdf0e10cSrcweir 	mpImpl->release();
774*cdf0e10cSrcweir }
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir // --------------------------------------------------------------------
777*cdf0e10cSrcweir // table stuff
778*cdf0e10cSrcweir // --------------------------------------------------------------------
779*cdf0e10cSrcweir 
780*cdf0e10cSrcweir Reference< XTable > SdrTableObj::getTable() const
781*cdf0e10cSrcweir {
782*cdf0e10cSrcweir 	return Reference< XTable >( mpImpl->mxTable.get() );
783*cdf0e10cSrcweir }
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir // --------------------------------------------------------------------
786*cdf0e10cSrcweir 
787*cdf0e10cSrcweir bool SdrTableObj::isValid( const CellPos& rPos ) const
788*cdf0e10cSrcweir {
789*cdf0e10cSrcweir 	return (rPos.mnCol >= 0) && (rPos.mnCol < mpImpl->getColumnCount()) && (rPos.mnRow >= 0) && (rPos.mnRow < mpImpl->getRowCount());
790*cdf0e10cSrcweir }
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir // --------------------------------------------------------------------
793*cdf0e10cSrcweir 
794*cdf0e10cSrcweir CellPos SdrTableObj::getFirstCell() const
795*cdf0e10cSrcweir {
796*cdf0e10cSrcweir 	return CellPos( 0,0 );
797*cdf0e10cSrcweir }
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir // --------------------------------------------------------------------
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir CellPos SdrTableObj::getLastCell() const
802*cdf0e10cSrcweir {
803*cdf0e10cSrcweir 	CellPos aPos;
804*cdf0e10cSrcweir 	if( mpImpl->mxTable.is() )
805*cdf0e10cSrcweir 	{
806*cdf0e10cSrcweir 		aPos.mnCol = mpImpl->getColumnCount()-1;
807*cdf0e10cSrcweir 		aPos.mnRow = mpImpl->getRowCount()-1;
808*cdf0e10cSrcweir 	}
809*cdf0e10cSrcweir 	return aPos;
810*cdf0e10cSrcweir }
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir // --------------------------------------------------------------------
813*cdf0e10cSrcweir 
814*cdf0e10cSrcweir CellPos SdrTableObj::getLeftCell( const CellPos& rPos, bool bEdgeTravel ) const
815*cdf0e10cSrcweir {
816*cdf0e10cSrcweir 	switch( GetWritingMode() )
817*cdf0e10cSrcweir 	{
818*cdf0e10cSrcweir 	default:
819*cdf0e10cSrcweir 	case WritingMode_LR_TB:
820*cdf0e10cSrcweir 		return getPreviousCell( rPos, bEdgeTravel );
821*cdf0e10cSrcweir 	case WritingMode_RL_TB:
822*cdf0e10cSrcweir 		return getNextCell( rPos, bEdgeTravel );
823*cdf0e10cSrcweir 	case WritingMode_TB_RL:
824*cdf0e10cSrcweir 		return getPreviousRow( rPos, bEdgeTravel );
825*cdf0e10cSrcweir 	}
826*cdf0e10cSrcweir }
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir // --------------------------------------------------------------------
829*cdf0e10cSrcweir 
830*cdf0e10cSrcweir CellPos SdrTableObj::getRightCell( const CellPos& rPos, bool bEdgeTravel  ) const
831*cdf0e10cSrcweir {
832*cdf0e10cSrcweir 	switch( GetWritingMode() )
833*cdf0e10cSrcweir 	{
834*cdf0e10cSrcweir 	default:
835*cdf0e10cSrcweir 	case WritingMode_LR_TB:
836*cdf0e10cSrcweir 		return getNextCell( rPos, bEdgeTravel );
837*cdf0e10cSrcweir 	case WritingMode_RL_TB:
838*cdf0e10cSrcweir 		return getPreviousCell( rPos, bEdgeTravel );
839*cdf0e10cSrcweir 	case WritingMode_TB_RL:
840*cdf0e10cSrcweir 		return getNextRow( rPos, bEdgeTravel );
841*cdf0e10cSrcweir 	}
842*cdf0e10cSrcweir }
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir // --------------------------------------------------------------------
845*cdf0e10cSrcweir 
846*cdf0e10cSrcweir CellPos SdrTableObj::getUpCell( const CellPos& rPos, bool bEdgeTravel ) const
847*cdf0e10cSrcweir {
848*cdf0e10cSrcweir 	switch( GetWritingMode() )
849*cdf0e10cSrcweir 	{
850*cdf0e10cSrcweir 	default:
851*cdf0e10cSrcweir 	case WritingMode_LR_TB:
852*cdf0e10cSrcweir 	case WritingMode_RL_TB:
853*cdf0e10cSrcweir 		return getPreviousRow( rPos, bEdgeTravel );
854*cdf0e10cSrcweir 	case WritingMode_TB_RL:
855*cdf0e10cSrcweir 		return getPreviousCell( rPos, bEdgeTravel );
856*cdf0e10cSrcweir 	}
857*cdf0e10cSrcweir }
858*cdf0e10cSrcweir 
859*cdf0e10cSrcweir // --------------------------------------------------------------------
860*cdf0e10cSrcweir 
861*cdf0e10cSrcweir CellPos SdrTableObj::getDownCell( const CellPos& rPos, bool bEdgeTravel ) const
862*cdf0e10cSrcweir {
863*cdf0e10cSrcweir 	switch( GetWritingMode() )
864*cdf0e10cSrcweir 	{
865*cdf0e10cSrcweir 	default:
866*cdf0e10cSrcweir 	case WritingMode_LR_TB:
867*cdf0e10cSrcweir 	case WritingMode_RL_TB:
868*cdf0e10cSrcweir 		return getNextRow( rPos, bEdgeTravel );
869*cdf0e10cSrcweir 	case WritingMode_TB_RL:
870*cdf0e10cSrcweir 		return getNextCell( rPos, bEdgeTravel );
871*cdf0e10cSrcweir 	}
872*cdf0e10cSrcweir }
873*cdf0e10cSrcweir 
874*cdf0e10cSrcweir // --------------------------------------------------------------------
875*cdf0e10cSrcweir 
876*cdf0e10cSrcweir CellPos SdrTableObj::getPreviousCell( const CellPos& rPos, bool bEdgeTravel ) const
877*cdf0e10cSrcweir {
878*cdf0e10cSrcweir 	CellPos aPos( rPos );
879*cdf0e10cSrcweir 	if( mpImpl )
880*cdf0e10cSrcweir 	{
881*cdf0e10cSrcweir 		CellRef xCell( mpImpl->getCell( aPos ) );
882*cdf0e10cSrcweir 		if( xCell.is() && xCell->isMerged() )
883*cdf0e10cSrcweir 		{
884*cdf0e10cSrcweir 			sal_Int32 nTemp = 0;
885*cdf0e10cSrcweir 			findMergeOrigin( mpImpl->mxTable.get(), aPos.mnCol, aPos.mnRow, aPos.mnCol, nTemp );
886*cdf0e10cSrcweir 		}
887*cdf0e10cSrcweir 
888*cdf0e10cSrcweir 		if( aPos.mnCol > 0 )
889*cdf0e10cSrcweir 		{
890*cdf0e10cSrcweir 			--aPos.mnCol;
891*cdf0e10cSrcweir 		}
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir 		else if( bEdgeTravel && (aPos.mnRow > 0) )
894*cdf0e10cSrcweir 		{
895*cdf0e10cSrcweir 			aPos.mnCol = mpImpl->mxTable->getColumnCount()-1;
896*cdf0e10cSrcweir 			--aPos.mnRow;
897*cdf0e10cSrcweir 		}
898*cdf0e10cSrcweir 	}
899*cdf0e10cSrcweir 	return aPos;
900*cdf0e10cSrcweir }
901*cdf0e10cSrcweir 
902*cdf0e10cSrcweir // --------------------------------------------------------------------
903*cdf0e10cSrcweir 
904*cdf0e10cSrcweir CellPos SdrTableObj::getNextCell( const CellPos& rPos, bool bEdgeTravel ) const
905*cdf0e10cSrcweir {
906*cdf0e10cSrcweir 	CellPos aPos( rPos );
907*cdf0e10cSrcweir 	if( mpImpl )
908*cdf0e10cSrcweir 	{
909*cdf0e10cSrcweir 		CellRef xCell( mpImpl->getCell( aPos ) );
910*cdf0e10cSrcweir 		if( xCell.is() )
911*cdf0e10cSrcweir 		{
912*cdf0e10cSrcweir 			if( xCell->isMerged() )
913*cdf0e10cSrcweir 			{
914*cdf0e10cSrcweir 				findMergeOrigin( mpImpl->mxTable, aPos.mnCol, aPos.mnRow, aPos.mnCol, aPos.mnRow );
915*cdf0e10cSrcweir 
916*cdf0e10cSrcweir 				xCell = mpImpl->getCell(aPos);
917*cdf0e10cSrcweir 
918*cdf0e10cSrcweir 				if( xCell.is() )
919*cdf0e10cSrcweir 				{
920*cdf0e10cSrcweir 					aPos.mnCol += xCell->getColumnSpan();
921*cdf0e10cSrcweir 					aPos.mnRow = rPos.mnRow;
922*cdf0e10cSrcweir 				}
923*cdf0e10cSrcweir 			}
924*cdf0e10cSrcweir 			else
925*cdf0e10cSrcweir 			{
926*cdf0e10cSrcweir 				aPos.mnCol += xCell->getColumnSpan();
927*cdf0e10cSrcweir 			}
928*cdf0e10cSrcweir 
929*cdf0e10cSrcweir 			if( aPos.mnCol < mpImpl->mxTable->getColumnCount() )
930*cdf0e10cSrcweir 				return aPos;
931*cdf0e10cSrcweir 
932*cdf0e10cSrcweir 			if( bEdgeTravel && ((aPos.mnRow + 1) < mpImpl->getRowCount()) )
933*cdf0e10cSrcweir 			{
934*cdf0e10cSrcweir 				aPos.mnCol = 0;
935*cdf0e10cSrcweir 				aPos.mnRow += 1;
936*cdf0e10cSrcweir 				return aPos;
937*cdf0e10cSrcweir 			}
938*cdf0e10cSrcweir 		}
939*cdf0e10cSrcweir 	}
940*cdf0e10cSrcweir 
941*cdf0e10cSrcweir 	// last cell reached, no traveling possible
942*cdf0e10cSrcweir 	return rPos;
943*cdf0e10cSrcweir }
944*cdf0e10cSrcweir 
945*cdf0e10cSrcweir // --------------------------------------------------------------------
946*cdf0e10cSrcweir 
947*cdf0e10cSrcweir CellPos SdrTableObj::getPreviousRow( const CellPos& rPos, bool bEdgeTravel ) const
948*cdf0e10cSrcweir {
949*cdf0e10cSrcweir 	CellPos aPos( rPos );
950*cdf0e10cSrcweir 	if( mpImpl )
951*cdf0e10cSrcweir 	{
952*cdf0e10cSrcweir 		CellRef xCell( mpImpl->getCell( aPos ) );
953*cdf0e10cSrcweir 		if( xCell.is() )
954*cdf0e10cSrcweir 		{
955*cdf0e10cSrcweir 			if( xCell->isMerged() )
956*cdf0e10cSrcweir 			{
957*cdf0e10cSrcweir 				sal_Int32 nTemp = 0;
958*cdf0e10cSrcweir 				findMergeOrigin( mpImpl->mxTable, aPos.mnCol, aPos.mnRow, nTemp, aPos.mnRow );
959*cdf0e10cSrcweir 			}
960*cdf0e10cSrcweir 		}
961*cdf0e10cSrcweir 
962*cdf0e10cSrcweir 		if( aPos.mnRow > 0 )
963*cdf0e10cSrcweir 		{
964*cdf0e10cSrcweir 			--aPos.mnRow;
965*cdf0e10cSrcweir 		}
966*cdf0e10cSrcweir 		else if( bEdgeTravel && (aPos.mnCol > 0) )
967*cdf0e10cSrcweir 		{
968*cdf0e10cSrcweir 			aPos.mnRow = mpImpl->mxTable->getRowCount()-1;
969*cdf0e10cSrcweir 			--aPos.mnCol;
970*cdf0e10cSrcweir 		}
971*cdf0e10cSrcweir 	}
972*cdf0e10cSrcweir 	return aPos;
973*cdf0e10cSrcweir }
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir // --------------------------------------------------------------------
976*cdf0e10cSrcweir 
977*cdf0e10cSrcweir CellPos SdrTableObj::getNextRow( const CellPos& rPos, bool bEdgeTravel ) const
978*cdf0e10cSrcweir {
979*cdf0e10cSrcweir 	CellPos aPos( rPos );
980*cdf0e10cSrcweir 
981*cdf0e10cSrcweir 	if( mpImpl )
982*cdf0e10cSrcweir 	{
983*cdf0e10cSrcweir 		CellRef xCell( mpImpl->getCell( rPos ) );
984*cdf0e10cSrcweir 		if( xCell.is() )
985*cdf0e10cSrcweir 		{
986*cdf0e10cSrcweir 			if( xCell->isMerged() )
987*cdf0e10cSrcweir 			{
988*cdf0e10cSrcweir 				findMergeOrigin( mpImpl->mxTable, aPos.mnCol, aPos.mnRow, aPos.mnCol, aPos.mnRow );
989*cdf0e10cSrcweir 				xCell = mpImpl->getCell(aPos);
990*cdf0e10cSrcweir 				aPos.mnCol = rPos.mnCol;
991*cdf0e10cSrcweir 			}
992*cdf0e10cSrcweir 
993*cdf0e10cSrcweir 			if( xCell.is() )
994*cdf0e10cSrcweir 				aPos.mnRow += xCell->getRowSpan();
995*cdf0e10cSrcweir 
996*cdf0e10cSrcweir 			if( aPos.mnRow < mpImpl->mxTable->getRowCount() )
997*cdf0e10cSrcweir 				return aPos;
998*cdf0e10cSrcweir 
999*cdf0e10cSrcweir 			if( bEdgeTravel && (aPos.mnCol + 1) < mpImpl->mxTable->getColumnCount() )
1000*cdf0e10cSrcweir 			{
1001*cdf0e10cSrcweir 				aPos.mnRow = 0;
1002*cdf0e10cSrcweir 				aPos.mnCol += 1;
1003*cdf0e10cSrcweir 
1004*cdf0e10cSrcweir 				while( aPos.mnCol < mpImpl->mxTable->getColumnCount() )
1005*cdf0e10cSrcweir 				{
1006*cdf0e10cSrcweir 					xCell = mpImpl->getCell( aPos );
1007*cdf0e10cSrcweir 					if( xCell.is() && !xCell->isMerged() )
1008*cdf0e10cSrcweir 						return aPos;
1009*cdf0e10cSrcweir 					aPos.mnCol += 1;
1010*cdf0e10cSrcweir 				}
1011*cdf0e10cSrcweir 			}
1012*cdf0e10cSrcweir 		}
1013*cdf0e10cSrcweir 	}
1014*cdf0e10cSrcweir 
1015*cdf0e10cSrcweir 	// last position reached, no more traveling possible
1016*cdf0e10cSrcweir 	return rPos;
1017*cdf0e10cSrcweir }
1018*cdf0e10cSrcweir 
1019*cdf0e10cSrcweir // --------------------------------------------------------------------
1020*cdf0e10cSrcweir 
1021*cdf0e10cSrcweir const TableStyleSettings& SdrTableObj::getTableStyleSettings() const
1022*cdf0e10cSrcweir {
1023*cdf0e10cSrcweir 	if( mpImpl )
1024*cdf0e10cSrcweir 	{
1025*cdf0e10cSrcweir 		return mpImpl->maTableStyle;
1026*cdf0e10cSrcweir 	}
1027*cdf0e10cSrcweir 	else
1028*cdf0e10cSrcweir 	{
1029*cdf0e10cSrcweir 		static TableStyleSettings aTmp;
1030*cdf0e10cSrcweir 		return aTmp;
1031*cdf0e10cSrcweir 	}
1032*cdf0e10cSrcweir }
1033*cdf0e10cSrcweir 
1034*cdf0e10cSrcweir // --------------------------------------------------------------------
1035*cdf0e10cSrcweir 
1036*cdf0e10cSrcweir void SdrTableObj::setTableStyleSettings( const TableStyleSettings& rStyle )
1037*cdf0e10cSrcweir {
1038*cdf0e10cSrcweir 	if( mpImpl )
1039*cdf0e10cSrcweir 	{
1040*cdf0e10cSrcweir 		mpImpl->maTableStyle = rStyle;
1041*cdf0e10cSrcweir 		mpImpl->update();
1042*cdf0e10cSrcweir 	}
1043*cdf0e10cSrcweir }
1044*cdf0e10cSrcweir 
1045*cdf0e10cSrcweir // --------------------------------------------------------------------
1046*cdf0e10cSrcweir 
1047*cdf0e10cSrcweir TableHitKind SdrTableObj::CheckTableHit( const Point& rPos, sal_Int32& rnX, sal_Int32& rnY, int nTol ) const
1048*cdf0e10cSrcweir {
1049*cdf0e10cSrcweir 	if( !mpImpl || !mpImpl->mxTable.is() )
1050*cdf0e10cSrcweir 		return SDRTABLEHIT_NONE;
1051*cdf0e10cSrcweir 
1052*cdf0e10cSrcweir 	rnX = 0;
1053*cdf0e10cSrcweir 	rnY = 0;
1054*cdf0e10cSrcweir 
1055*cdf0e10cSrcweir 	const sal_Int32 nColCount = mpImpl->getColumnCount();
1056*cdf0e10cSrcweir 	const sal_Int32 nRowCount = mpImpl->getRowCount();
1057*cdf0e10cSrcweir 
1058*cdf0e10cSrcweir 	sal_Int32 nX = rPos.X() + nTol - aRect.nLeft;
1059*cdf0e10cSrcweir 	sal_Int32 nY = rPos.Y() + nTol - aRect.nTop;
1060*cdf0e10cSrcweir 
1061*cdf0e10cSrcweir 	if( (nX < 0) || (nX > (aRect.GetWidth() + nTol)) || (nY < 0) || (nY > (aRect.GetHeight() + nTol) ) )
1062*cdf0e10cSrcweir 		return SDRTABLEHIT_NONE;
1063*cdf0e10cSrcweir 
1064*cdf0e10cSrcweir 	// get vertical edge number and check for a hit
1065*cdf0e10cSrcweir 	const bool bRTL = GetWritingMode() == WritingMode_RL_TB;
1066*cdf0e10cSrcweir 	bool bVrtHit = false;
1067*cdf0e10cSrcweir 	if( nX >= 0 )
1068*cdf0e10cSrcweir 	{
1069*cdf0e10cSrcweir 		if( !bRTL )
1070*cdf0e10cSrcweir 		{
1071*cdf0e10cSrcweir 			while( rnX <= nColCount )
1072*cdf0e10cSrcweir 			{
1073*cdf0e10cSrcweir 				if( nX <= (2*nTol) )
1074*cdf0e10cSrcweir 				{
1075*cdf0e10cSrcweir 					bVrtHit = true;
1076*cdf0e10cSrcweir 					break;
1077*cdf0e10cSrcweir 				}
1078*cdf0e10cSrcweir 
1079*cdf0e10cSrcweir 				if( rnX == nColCount )
1080*cdf0e10cSrcweir 					break;
1081*cdf0e10cSrcweir 
1082*cdf0e10cSrcweir 				nX -= mpImpl->mpLayouter->getColumnWidth( rnX );
1083*cdf0e10cSrcweir 				if( nX < 0 )
1084*cdf0e10cSrcweir 					break;
1085*cdf0e10cSrcweir 				rnX++;
1086*cdf0e10cSrcweir 			}
1087*cdf0e10cSrcweir 		}
1088*cdf0e10cSrcweir 		else
1089*cdf0e10cSrcweir 		{
1090*cdf0e10cSrcweir 			rnX = nColCount;
1091*cdf0e10cSrcweir 			while( rnX >= 0 )
1092*cdf0e10cSrcweir 			{
1093*cdf0e10cSrcweir 				if( nX <= (2*nTol) )
1094*cdf0e10cSrcweir 				{
1095*cdf0e10cSrcweir 					bVrtHit = true;
1096*cdf0e10cSrcweir 					break;
1097*cdf0e10cSrcweir 				}
1098*cdf0e10cSrcweir 
1099*cdf0e10cSrcweir 				if( rnX == 0 )
1100*cdf0e10cSrcweir 					break;
1101*cdf0e10cSrcweir 
1102*cdf0e10cSrcweir 				rnX--;
1103*cdf0e10cSrcweir 				nX -= mpImpl->mpLayouter->getColumnWidth( rnX );
1104*cdf0e10cSrcweir 				if( nX < 0 )
1105*cdf0e10cSrcweir 					break;
1106*cdf0e10cSrcweir 			}
1107*cdf0e10cSrcweir 		}
1108*cdf0e10cSrcweir 	}
1109*cdf0e10cSrcweir 
1110*cdf0e10cSrcweir 	// rnX is now the edge number left to the pointer, if it was hit bHrzHit is also true
1111*cdf0e10cSrcweir 
1112*cdf0e10cSrcweir 	// get vertical edge number and check for a hit
1113*cdf0e10cSrcweir 	bool bHrzHit = false;
1114*cdf0e10cSrcweir 	if( nY >= 0 )
1115*cdf0e10cSrcweir 	{
1116*cdf0e10cSrcweir 		while( rnY <= nRowCount )
1117*cdf0e10cSrcweir 		{
1118*cdf0e10cSrcweir 			if( nY <= (2*nTol) )
1119*cdf0e10cSrcweir 			{
1120*cdf0e10cSrcweir 				bHrzHit = true;
1121*cdf0e10cSrcweir 				break;
1122*cdf0e10cSrcweir 			}
1123*cdf0e10cSrcweir 
1124*cdf0e10cSrcweir 			if( rnY == nRowCount )
1125*cdf0e10cSrcweir 				break;
1126*cdf0e10cSrcweir 
1127*cdf0e10cSrcweir 			nY -= mpImpl->mpLayouter->getRowHeight(rnY);
1128*cdf0e10cSrcweir 			if( nY < 0 )
1129*cdf0e10cSrcweir 				break;
1130*cdf0e10cSrcweir 			rnY++;
1131*cdf0e10cSrcweir 		}
1132*cdf0e10cSrcweir 	}
1133*cdf0e10cSrcweir 
1134*cdf0e10cSrcweir 	// rnY is now the edge number above the pointer, if it was hit bVrtHit is also true
1135*cdf0e10cSrcweir 
1136*cdf0e10cSrcweir 	if( bVrtHit && mpImpl->mpLayouter->isEdgeVisible( rnX, rnY, false ) )
1137*cdf0e10cSrcweir 		return SDRTABLEHIT_VERTICAL_BORDER;
1138*cdf0e10cSrcweir 
1139*cdf0e10cSrcweir 	if( bHrzHit && mpImpl->mpLayouter->isEdgeVisible( rnX, rnY, true ) )
1140*cdf0e10cSrcweir 		return SDRTABLEHIT_HORIZONTAL_BORDER;
1141*cdf0e10cSrcweir 
1142*cdf0e10cSrcweir 	CellRef xCell( mpImpl->getCell( CellPos( rnX, rnY ) ) );
1143*cdf0e10cSrcweir 	if( xCell.is() && xCell->isMerged() )
1144*cdf0e10cSrcweir 		findMergeOrigin( mpImpl->mxTable.get(), rnX, rnY, rnX, rnY );
1145*cdf0e10cSrcweir 
1146*cdf0e10cSrcweir 	if( xCell.is() )
1147*cdf0e10cSrcweir 	{
1148*cdf0e10cSrcweir 		nX += mpImpl->mpLayouter->getColumnWidth( rnX );
1149*cdf0e10cSrcweir 		if( nX < xCell->GetTextLeftDistance() )
1150*cdf0e10cSrcweir 			return SDRTABLEHIT_CELL;
1151*cdf0e10cSrcweir 	}
1152*cdf0e10cSrcweir 
1153*cdf0e10cSrcweir 	return SDRTABLEHIT_CELLTEXTAREA;
1154*cdf0e10cSrcweir }
1155*cdf0e10cSrcweir 
1156*cdf0e10cSrcweir const SfxItemSet& SdrTableObj::GetActiveCellItemSet() const
1157*cdf0e10cSrcweir {
1158*cdf0e10cSrcweir 	return getActiveCell()->GetItemSet();
1159*cdf0e10cSrcweir }
1160*cdf0e10cSrcweir 
1161*cdf0e10cSrcweir // --------------------------------------------------------------------
1162*cdf0e10cSrcweir 
1163*cdf0e10cSrcweir void SdrTableObj::InsertRows( sal_Int32 nIndex, sal_Int32 nCount /*= 1*/ )
1164*cdf0e10cSrcweir {
1165*cdf0e10cSrcweir 	if( mpImpl->mxTable.is() ) try
1166*cdf0e10cSrcweir 	{
1167*cdf0e10cSrcweir 		Reference< XTableRows > xRows( mpImpl->mxTable->getRows(), UNO_QUERY_THROW );
1168*cdf0e10cSrcweir 		xRows->insertByIndex( nIndex, nCount );
1169*cdf0e10cSrcweir 	}
1170*cdf0e10cSrcweir 	catch( Exception& )
1171*cdf0e10cSrcweir 	{
1172*cdf0e10cSrcweir 		DBG_ERROR("SdrTableObj::InsertRows(), exception caught!");
1173*cdf0e10cSrcweir 	}
1174*cdf0e10cSrcweir }
1175*cdf0e10cSrcweir 
1176*cdf0e10cSrcweir // --------------------------------------------------------------------
1177*cdf0e10cSrcweir 
1178*cdf0e10cSrcweir void SdrTableObj::InsertColumns( sal_Int32 nIndex, sal_Int32 nCount /*= 1*/ )
1179*cdf0e10cSrcweir {
1180*cdf0e10cSrcweir 	if( mpImpl->mxTable.is() ) try
1181*cdf0e10cSrcweir 	{
1182*cdf0e10cSrcweir 		Reference< XTableColumns > xColumns( mpImpl->mxTable->getColumns(), UNO_QUERY_THROW );
1183*cdf0e10cSrcweir 		xColumns->insertByIndex( nIndex, nCount );
1184*cdf0e10cSrcweir 	}
1185*cdf0e10cSrcweir 	catch( Exception& )
1186*cdf0e10cSrcweir 	{
1187*cdf0e10cSrcweir 		DBG_ERROR("SdrTableObj::InsertColumns(), exception caught!");
1188*cdf0e10cSrcweir 	}
1189*cdf0e10cSrcweir }
1190*cdf0e10cSrcweir 
1191*cdf0e10cSrcweir // --------------------------------------------------------------------
1192*cdf0e10cSrcweir 
1193*cdf0e10cSrcweir void SdrTableObj::DeleteRows( sal_Int32 nIndex, sal_Int32 nCount /*= 1*/ )
1194*cdf0e10cSrcweir {
1195*cdf0e10cSrcweir 	if( mpImpl->mxTable.is() ) try
1196*cdf0e10cSrcweir 	{
1197*cdf0e10cSrcweir 		Reference< XTableRows > xRows( mpImpl->mxTable->getRows(), UNO_QUERY_THROW );
1198*cdf0e10cSrcweir 		xRows->removeByIndex( nIndex, nCount );
1199*cdf0e10cSrcweir 	}
1200*cdf0e10cSrcweir 	catch( Exception& )
1201*cdf0e10cSrcweir 	{
1202*cdf0e10cSrcweir 		DBG_ERROR("SdrTableObj::DeleteRows(), exception caught!");
1203*cdf0e10cSrcweir 	}
1204*cdf0e10cSrcweir }
1205*cdf0e10cSrcweir 
1206*cdf0e10cSrcweir // --------------------------------------------------------------------
1207*cdf0e10cSrcweir 
1208*cdf0e10cSrcweir void SdrTableObj::DeleteColumns( sal_Int32 nIndex, sal_Int32 nCount /*= 1*/ )
1209*cdf0e10cSrcweir {
1210*cdf0e10cSrcweir 	if( mpImpl->mxTable.is() ) try
1211*cdf0e10cSrcweir 	{
1212*cdf0e10cSrcweir 		Reference< XTableColumns > xColumns( mpImpl->mxTable->getColumns(), UNO_QUERY_THROW );
1213*cdf0e10cSrcweir 		xColumns->removeByIndex( nIndex, nCount );
1214*cdf0e10cSrcweir 	}
1215*cdf0e10cSrcweir 	catch( Exception& )
1216*cdf0e10cSrcweir 	{
1217*cdf0e10cSrcweir 		DBG_ERROR("SdrTableObj::DeleteColumns(), exception caught!");
1218*cdf0e10cSrcweir 	}
1219*cdf0e10cSrcweir }
1220*cdf0e10cSrcweir 
1221*cdf0e10cSrcweir // --------------------------------------------------------------------
1222*cdf0e10cSrcweir 
1223*cdf0e10cSrcweir void SdrTableObj::setTableStyle( const Reference< XIndexAccess >& xTableStyle )
1224*cdf0e10cSrcweir {
1225*cdf0e10cSrcweir 	if( mpImpl && (mpImpl->mxTableStyle != xTableStyle) )
1226*cdf0e10cSrcweir 	{
1227*cdf0e10cSrcweir 		mpImpl->disconnectTableStyle();
1228*cdf0e10cSrcweir 		mpImpl->mxTableStyle = xTableStyle;
1229*cdf0e10cSrcweir 		mpImpl->connectTableStyle();
1230*cdf0e10cSrcweir 		mpImpl->update();
1231*cdf0e10cSrcweir 	}
1232*cdf0e10cSrcweir }
1233*cdf0e10cSrcweir 
1234*cdf0e10cSrcweir // --------------------------------------------------------------------
1235*cdf0e10cSrcweir 
1236*cdf0e10cSrcweir const Reference< XIndexAccess >& SdrTableObj::getTableStyle() const
1237*cdf0e10cSrcweir {
1238*cdf0e10cSrcweir 	if( mpImpl )
1239*cdf0e10cSrcweir 	{
1240*cdf0e10cSrcweir 		return mpImpl->mxTableStyle;
1241*cdf0e10cSrcweir 	}
1242*cdf0e10cSrcweir 	else
1243*cdf0e10cSrcweir 	{
1244*cdf0e10cSrcweir 		static Reference< XIndexAccess > aTmp;
1245*cdf0e10cSrcweir 		return aTmp;
1246*cdf0e10cSrcweir 	}
1247*cdf0e10cSrcweir }
1248*cdf0e10cSrcweir 
1249*cdf0e10cSrcweir // --------------------------------------------------------------------
1250*cdf0e10cSrcweir // text stuff
1251*cdf0e10cSrcweir // --------------------------------------------------------------------
1252*cdf0e10cSrcweir 
1253*cdf0e10cSrcweir /** returns the currently active text. */
1254*cdf0e10cSrcweir SdrText* SdrTableObj::getActiveText() const
1255*cdf0e10cSrcweir {
1256*cdf0e10cSrcweir 	return dynamic_cast< SdrText* >( getActiveCell().get() );
1257*cdf0e10cSrcweir }
1258*cdf0e10cSrcweir 
1259*cdf0e10cSrcweir // --------------------------------------------------------------------
1260*cdf0e10cSrcweir 
1261*cdf0e10cSrcweir /** returns the nth available text. */
1262*cdf0e10cSrcweir SdrText* SdrTableObj::getText( sal_Int32 nIndex ) const
1263*cdf0e10cSrcweir {
1264*cdf0e10cSrcweir 	if( mpImpl->mxTable.is() )
1265*cdf0e10cSrcweir 	{
1266*cdf0e10cSrcweir 		const sal_Int32 nColCount = mpImpl->getColumnCount();
1267*cdf0e10cSrcweir 		if( nColCount )
1268*cdf0e10cSrcweir 		{
1269*cdf0e10cSrcweir 			CellPos aPos( nIndex % nColCount, nIndex / nColCount );
1270*cdf0e10cSrcweir 
1271*cdf0e10cSrcweir 			CellRef xCell( mpImpl->getCell( aPos ) );
1272*cdf0e10cSrcweir 			return dynamic_cast< SdrText* >( xCell.get() );
1273*cdf0e10cSrcweir 		}
1274*cdf0e10cSrcweir 	}
1275*cdf0e10cSrcweir 	return 0;
1276*cdf0e10cSrcweir }
1277*cdf0e10cSrcweir 
1278*cdf0e10cSrcweir // --------------------------------------------------------------------
1279*cdf0e10cSrcweir 
1280*cdf0e10cSrcweir /** returns the number of texts available for this object. */
1281*cdf0e10cSrcweir sal_Int32 SdrTableObj::getTextCount() const
1282*cdf0e10cSrcweir {
1283*cdf0e10cSrcweir 	if( mpImpl->mxTable.is() )
1284*cdf0e10cSrcweir 	{
1285*cdf0e10cSrcweir 		const sal_Int32 nColCount = mpImpl->getColumnCount();
1286*cdf0e10cSrcweir 		const sal_Int32 nRowCount = mpImpl->getRowCount();
1287*cdf0e10cSrcweir 
1288*cdf0e10cSrcweir 		return nColCount * nRowCount;
1289*cdf0e10cSrcweir 	}
1290*cdf0e10cSrcweir 	else
1291*cdf0e10cSrcweir 	{
1292*cdf0e10cSrcweir 		return 0;
1293*cdf0e10cSrcweir 	}
1294*cdf0e10cSrcweir }
1295*cdf0e10cSrcweir 
1296*cdf0e10cSrcweir // --------------------------------------------------------------------
1297*cdf0e10cSrcweir 
1298*cdf0e10cSrcweir /** changes the current active text */
1299*cdf0e10cSrcweir void SdrTableObj::setActiveText( sal_Int32 nIndex )
1300*cdf0e10cSrcweir {
1301*cdf0e10cSrcweir 	if( mpImpl && mpImpl->mxTable.is() )
1302*cdf0e10cSrcweir 	{
1303*cdf0e10cSrcweir 		const sal_Int32 nColCount = mpImpl->mxTable->getColumnCount();
1304*cdf0e10cSrcweir 		if( nColCount )
1305*cdf0e10cSrcweir 		{
1306*cdf0e10cSrcweir 			CellPos aPos( nIndex % nColCount, nIndex / nColCount );
1307*cdf0e10cSrcweir 			if( isValid( aPos ) )
1308*cdf0e10cSrcweir 				setActiveCell( aPos );
1309*cdf0e10cSrcweir 		}
1310*cdf0e10cSrcweir 	}
1311*cdf0e10cSrcweir }
1312*cdf0e10cSrcweir 
1313*cdf0e10cSrcweir // --------------------------------------------------------------------
1314*cdf0e10cSrcweir 
1315*cdf0e10cSrcweir /** returns the index of the text that contains the given point or -1 */
1316*cdf0e10cSrcweir sal_Int32 SdrTableObj::CheckTextHit(const Point& rPnt) const
1317*cdf0e10cSrcweir {
1318*cdf0e10cSrcweir 	if( mpImpl && mpImpl->mxTable.is() )
1319*cdf0e10cSrcweir 	{
1320*cdf0e10cSrcweir 		CellPos aPos;
1321*cdf0e10cSrcweir 		if( CheckTableHit( rPnt, aPos.mnCol, aPos.mnRow, 0 ) == SDRTABLEHIT_CELLTEXTAREA )
1322*cdf0e10cSrcweir 			return aPos.mnRow * mpImpl->mxTable->getColumnCount() + aPos.mnCol;
1323*cdf0e10cSrcweir 	}
1324*cdf0e10cSrcweir 
1325*cdf0e10cSrcweir 	return 0;
1326*cdf0e10cSrcweir }
1327*cdf0e10cSrcweir 
1328*cdf0e10cSrcweir // --------------------------------------------------------------------
1329*cdf0e10cSrcweir 
1330*cdf0e10cSrcweir SdrOutliner* SdrTableObj::GetCellTextEditOutliner( const Cell& rCell ) const
1331*cdf0e10cSrcweir {
1332*cdf0e10cSrcweir 	if( mpImpl && (mpImpl->getCell( mpImpl->maEditPos ).get() == &rCell) )
1333*cdf0e10cSrcweir 		return pEdtOutl;
1334*cdf0e10cSrcweir 	else
1335*cdf0e10cSrcweir 		return 0;
1336*cdf0e10cSrcweir }
1337*cdf0e10cSrcweir 
1338*cdf0e10cSrcweir 
1339*cdf0e10cSrcweir // --------------------------------------------------------------------
1340*cdf0e10cSrcweir 
1341*cdf0e10cSrcweir const TableLayouter& SdrTableObj::getTableLayouter() const
1342*cdf0e10cSrcweir {
1343*cdf0e10cSrcweir 	OSL_ENSURE(mpImpl && mpImpl->mpLayouter, "getTableLayouter() error: no mpImpl or mpLayouter (!)");
1344*cdf0e10cSrcweir 	return *(mpImpl->mpLayouter);
1345*cdf0e10cSrcweir }
1346*cdf0e10cSrcweir 
1347*cdf0e10cSrcweir // --------------------------------------------------------------------
1348*cdf0e10cSrcweir 
1349*cdf0e10cSrcweir void SdrTableObj::FitFrameToTextSize()
1350*cdf0e10cSrcweir {
1351*cdf0e10cSrcweir 	// todo
1352*cdf0e10cSrcweir }
1353*cdf0e10cSrcweir 
1354*cdf0e10cSrcweir // --------------------------------------------------------------------
1355*cdf0e10cSrcweir 
1356*cdf0e10cSrcweir FASTBOOL SdrTableObj::IsAutoGrowHeight() const
1357*cdf0e10cSrcweir {
1358*cdf0e10cSrcweir 	return sal_True;
1359*cdf0e10cSrcweir }
1360*cdf0e10cSrcweir 
1361*cdf0e10cSrcweir // --------------------------------------------------------------------
1362*cdf0e10cSrcweir 
1363*cdf0e10cSrcweir FASTBOOL SdrTableObj::IsAutoGrowWidth() const
1364*cdf0e10cSrcweir {
1365*cdf0e10cSrcweir 	return sal_True;
1366*cdf0e10cSrcweir }
1367*cdf0e10cSrcweir 
1368*cdf0e10cSrcweir // --------------------------------------------------------------------
1369*cdf0e10cSrcweir 
1370*cdf0e10cSrcweir bool SdrTableObj::HasText() const
1371*cdf0e10cSrcweir {
1372*cdf0e10cSrcweir 	return true;
1373*cdf0e10cSrcweir }
1374*cdf0e10cSrcweir 
1375*cdf0e10cSrcweir // --------------------------------------------------------------------
1376*cdf0e10cSrcweir 
1377*cdf0e10cSrcweir bool SdrTableObj::IsTextEditActive( const CellPos& rPos )
1378*cdf0e10cSrcweir {
1379*cdf0e10cSrcweir 	return pEdtOutl && mpImpl && (rPos == mpImpl->maEditPos);
1380*cdf0e10cSrcweir }
1381*cdf0e10cSrcweir 
1382*cdf0e10cSrcweir // --------------------------------------------------------------------
1383*cdf0e10cSrcweir 
1384*cdf0e10cSrcweir void SdrTableObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
1385*cdf0e10cSrcweir {
1386*cdf0e10cSrcweir 	if( (pEditStatus->GetStatusWord() & EE_STAT_TEXTHEIGHTCHANGED) && mpImpl && mpImpl->mpLayouter )
1387*cdf0e10cSrcweir 	{
1388*cdf0e10cSrcweir 		Rectangle aRect0( aRect );
1389*cdf0e10cSrcweir 		aRect = maLogicRect;
1390*cdf0e10cSrcweir //		mpImpl->mpLayouter->setRowHeight( mpImpl->maEditPos.mnRow, mpImpl->mnSavedEditRowHeight );
1391*cdf0e10cSrcweir 		mpImpl->LayoutTable( aRect, false, false );
1392*cdf0e10cSrcweir 		SetRectsDirty();
1393*cdf0e10cSrcweir 		ActionChanged();
1394*cdf0e10cSrcweir 		BroadcastObjectChange();
1395*cdf0e10cSrcweir 		if( aRect0 != aRect )
1396*cdf0e10cSrcweir 			SendUserCall(SDRUSERCALL_RESIZE,aRect0);
1397*cdf0e10cSrcweir 	}
1398*cdf0e10cSrcweir }
1399*cdf0e10cSrcweir 
1400*cdf0e10cSrcweir // --------------------------------------------------------------------
1401*cdf0e10cSrcweir 
1402*cdf0e10cSrcweir void SdrTableObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
1403*cdf0e10cSrcweir {
1404*cdf0e10cSrcweir 	rInfo.bResizeFreeAllowed=sal_True;
1405*cdf0e10cSrcweir 	rInfo.bResizePropAllowed=sal_True;
1406*cdf0e10cSrcweir 	rInfo.bRotateFreeAllowed=sal_False;
1407*cdf0e10cSrcweir 	rInfo.bRotate90Allowed  =sal_False;
1408*cdf0e10cSrcweir 	rInfo.bMirrorFreeAllowed=sal_False;
1409*cdf0e10cSrcweir 	rInfo.bMirror45Allowed  =sal_False;
1410*cdf0e10cSrcweir 	rInfo.bMirror90Allowed  =sal_False;
1411*cdf0e10cSrcweir 
1412*cdf0e10cSrcweir 	// allow transparence
1413*cdf0e10cSrcweir 	rInfo.bTransparenceAllowed = sal_True;
1414*cdf0e10cSrcweir 
1415*cdf0e10cSrcweir 	// gradient depends on fillstyle
1416*cdf0e10cSrcweir 	XFillStyle eFillStyle = ((XFillStyleItem&)(GetObjectItem(XATTR_FILLSTYLE))).GetValue();
1417*cdf0e10cSrcweir 	rInfo.bGradientAllowed = (eFillStyle == XFILL_GRADIENT);
1418*cdf0e10cSrcweir 	rInfo.bShearAllowed     =sal_False;
1419*cdf0e10cSrcweir 	rInfo.bEdgeRadiusAllowed=sal_False;
1420*cdf0e10cSrcweir 	rInfo.bCanConvToPath    =sal_False;
1421*cdf0e10cSrcweir 	rInfo.bCanConvToPoly    =sal_False;
1422*cdf0e10cSrcweir 	rInfo.bCanConvToPathLineToArea=sal_False;
1423*cdf0e10cSrcweir 	rInfo.bCanConvToPolyLineToArea=sal_False;
1424*cdf0e10cSrcweir 	rInfo.bCanConvToContour = sal_False;
1425*cdf0e10cSrcweir }
1426*cdf0e10cSrcweir 
1427*cdf0e10cSrcweir // --------------------------------------------------------------------
1428*cdf0e10cSrcweir 
1429*cdf0e10cSrcweir sal_uInt16 SdrTableObj::GetObjIdentifier() const
1430*cdf0e10cSrcweir {
1431*cdf0e10cSrcweir 	return static_cast<sal_uInt16>(OBJ_TABLE);
1432*cdf0e10cSrcweir }
1433*cdf0e10cSrcweir 
1434*cdf0e10cSrcweir // --------------------------------------------------------------------
1435*cdf0e10cSrcweir 
1436*cdf0e10cSrcweir void SdrTableObj::SetPage(SdrPage* pNewPage)
1437*cdf0e10cSrcweir {
1438*cdf0e10cSrcweir 	SdrTextObj::SetPage(pNewPage);
1439*cdf0e10cSrcweir }
1440*cdf0e10cSrcweir 
1441*cdf0e10cSrcweir // --------------------------------------------------------------------
1442*cdf0e10cSrcweir 
1443*cdf0e10cSrcweir void SdrTableObj::SetModel(SdrModel* pNewModel)
1444*cdf0e10cSrcweir {
1445*cdf0e10cSrcweir 	SdrModel* pOldModel = GetModel();
1446*cdf0e10cSrcweir 	if( pNewModel != pOldModel )
1447*cdf0e10cSrcweir 	{
1448*cdf0e10cSrcweir 		SdrTextObj::SetModel(pNewModel);
1449*cdf0e10cSrcweir 
1450*cdf0e10cSrcweir 		if( mpImpl )
1451*cdf0e10cSrcweir 		{
1452*cdf0e10cSrcweir 			mpImpl->SetModel( pOldModel, pNewModel );
1453*cdf0e10cSrcweir 
1454*cdf0e10cSrcweir 			if( !maLogicRect.IsEmpty() )
1455*cdf0e10cSrcweir 			{
1456*cdf0e10cSrcweir 				aRect = maLogicRect;
1457*cdf0e10cSrcweir 				mpImpl->LayoutTable( aRect, false, false );
1458*cdf0e10cSrcweir 			}
1459*cdf0e10cSrcweir 		}
1460*cdf0e10cSrcweir 	}
1461*cdf0e10cSrcweir }
1462*cdf0e10cSrcweir 
1463*cdf0e10cSrcweir // --------------------------------------------------------------------
1464*cdf0e10cSrcweir 
1465*cdf0e10cSrcweir void SdrTableObj::TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, FASTBOOL bNoEditText, Rectangle* pAnchorRect, sal_Bool bLineWidth ) const
1466*cdf0e10cSrcweir {
1467*cdf0e10cSrcweir 	if( mpImpl )
1468*cdf0e10cSrcweir 		TakeTextRect( mpImpl->maEditPos, rOutliner, rTextRect, bNoEditText, pAnchorRect, bLineWidth );
1469*cdf0e10cSrcweir }
1470*cdf0e10cSrcweir 
1471*cdf0e10cSrcweir // --------------------------------------------------------------------
1472*cdf0e10cSrcweir 
1473*cdf0e10cSrcweir void SdrTableObj::TakeTextRect( const CellPos& rPos, SdrOutliner& rOutliner, Rectangle& rTextRect, FASTBOOL bNoEditText, Rectangle* pAnchorRect, sal_Bool /*bLineWidth*/ ) const
1474*cdf0e10cSrcweir {
1475*cdf0e10cSrcweir 	if( !mpImpl )
1476*cdf0e10cSrcweir 		return;
1477*cdf0e10cSrcweir 
1478*cdf0e10cSrcweir 	CellRef xCell( mpImpl->getCell( rPos ) );
1479*cdf0e10cSrcweir 	if( !xCell.is() )
1480*cdf0e10cSrcweir 		return;
1481*cdf0e10cSrcweir 
1482*cdf0e10cSrcweir 	Rectangle aAnkRect;
1483*cdf0e10cSrcweir 	TakeTextAnchorRect( rPos, aAnkRect );
1484*cdf0e10cSrcweir 
1485*cdf0e10cSrcweir 	SdrTextVertAdjust eVAdj=xCell->GetTextVerticalAdjust();
1486*cdf0e10cSrcweir //	SdrTextHorzAdjust eHAdj=xCell->GetTextHorizontalAdjust();
1487*cdf0e10cSrcweir 
1488*cdf0e10cSrcweir 	sal_uIntPtr nStat0=rOutliner.GetControlWord();
1489*cdf0e10cSrcweir 	Size aNullSize;
1490*cdf0e10cSrcweir 	nStat0 |= EE_CNTRL_AUTOPAGESIZE;
1491*cdf0e10cSrcweir 	rOutliner.SetControlWord(nStat0);
1492*cdf0e10cSrcweir 	rOutliner.SetMinAutoPaperSize(aNullSize);
1493*cdf0e10cSrcweir 	rOutliner.SetMaxAutoPaperSize(aAnkRect.GetSize());
1494*cdf0e10cSrcweir 	rOutliner.SetPaperSize(aAnkRect.GetSize());
1495*cdf0e10cSrcweir 
1496*cdf0e10cSrcweir 	// #103516# New try with _BLOCK for hor and ver after completely
1497*cdf0e10cSrcweir 	// supporting full width for vertical text.
1498*cdf0e10cSrcweir //	if( SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting())
1499*cdf0e10cSrcweir //	{
1500*cdf0e10cSrcweir 		rOutliner.SetMinAutoPaperSize(Size(aAnkRect.GetWidth(), 0));
1501*cdf0e10cSrcweir //	}
1502*cdf0e10cSrcweir //	else if(SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting())
1503*cdf0e10cSrcweir //	{
1504*cdf0e10cSrcweir //		rOutliner.SetMinAutoPaperSize(Size(0, aAnkRect.GetHeight()));
1505*cdf0e10cSrcweir //	}
1506*cdf0e10cSrcweir 
1507*cdf0e10cSrcweir 	// ---
1508*cdf0e10cSrcweir 
1509*cdf0e10cSrcweir 	// set text at outliner, maybe from edit outliner
1510*cdf0e10cSrcweir 	OutlinerParaObject* pPara= xCell->GetOutlinerParaObject();
1511*cdf0e10cSrcweir 	if (pEdtOutl && !bNoEditText && mpImpl->mxActiveCell == xCell )
1512*cdf0e10cSrcweir 		pPara=pEdtOutl->CreateParaObject();
1513*cdf0e10cSrcweir 
1514*cdf0e10cSrcweir 	if (pPara)
1515*cdf0e10cSrcweir 	{
1516*cdf0e10cSrcweir 		const bool bHitTest = pModel && (&pModel->GetHitTestOutliner() == &rOutliner);
1517*cdf0e10cSrcweir 
1518*cdf0e10cSrcweir 		const SdrTextObj* pTestObj = rOutliner.GetTextObj();
1519*cdf0e10cSrcweir 		if( !pTestObj || !bHitTest || (pTestObj != this) || (pTestObj->GetOutlinerParaObject() != xCell->GetOutlinerParaObject()) )
1520*cdf0e10cSrcweir 		{
1521*cdf0e10cSrcweir 			if( bHitTest ) // #i33696# take back fix #i27510#
1522*cdf0e10cSrcweir 				rOutliner.SetTextObj( this );
1523*cdf0e10cSrcweir 
1524*cdf0e10cSrcweir 			rOutliner.SetUpdateMode(sal_True);
1525*cdf0e10cSrcweir 			rOutliner.SetText(*pPara);
1526*cdf0e10cSrcweir 		}
1527*cdf0e10cSrcweir 	}
1528*cdf0e10cSrcweir 	else
1529*cdf0e10cSrcweir 	{
1530*cdf0e10cSrcweir 		rOutliner.SetTextObj( NULL );
1531*cdf0e10cSrcweir 	}
1532*cdf0e10cSrcweir 
1533*cdf0e10cSrcweir 	if (pEdtOutl && !bNoEditText && pPara && mpImpl->mxActiveCell == xCell )
1534*cdf0e10cSrcweir 		delete pPara;
1535*cdf0e10cSrcweir 
1536*cdf0e10cSrcweir 	rOutliner.SetUpdateMode(sal_True);
1537*cdf0e10cSrcweir 	rOutliner.SetControlWord(nStat0);
1538*cdf0e10cSrcweir 
1539*cdf0e10cSrcweir 	Point aTextPos(aAnkRect.TopLeft());
1540*cdf0e10cSrcweir 	Size aTextSiz(rOutliner.GetPaperSize());
1541*cdf0e10cSrcweir /*
1542*cdf0e10cSrcweir 	if (eHAdj==SDRTEXTHORZADJUST_CENTER || eHAdj==SDRTEXTHORZADJUST_RIGHT)
1543*cdf0e10cSrcweir 	{
1544*cdf0e10cSrcweir 		long nFreeWdt=aAnkRect.GetWidth()-aTextSiz.Width();
1545*cdf0e10cSrcweir 		if (eHAdj==SDRTEXTHORZADJUST_CENTER)
1546*cdf0e10cSrcweir 			aTextPos.X()+=nFreeWdt/2;
1547*cdf0e10cSrcweir 		if (eHAdj==SDRTEXTHORZADJUST_RIGHT)
1548*cdf0e10cSrcweir 			aTextPos.X()+=nFreeWdt;
1549*cdf0e10cSrcweir 	}
1550*cdf0e10cSrcweir */
1551*cdf0e10cSrcweir 	if (eVAdj==SDRTEXTVERTADJUST_CENTER || eVAdj==SDRTEXTVERTADJUST_BOTTOM)
1552*cdf0e10cSrcweir 	{
1553*cdf0e10cSrcweir 		long nFreeHgt=aAnkRect.GetHeight()-aTextSiz.Height();
1554*cdf0e10cSrcweir 		if (eVAdj==SDRTEXTVERTADJUST_CENTER)
1555*cdf0e10cSrcweir 			aTextPos.Y()+=nFreeHgt/2;
1556*cdf0e10cSrcweir 		if (eVAdj==SDRTEXTVERTADJUST_BOTTOM)
1557*cdf0e10cSrcweir 			aTextPos.Y()+=nFreeHgt;
1558*cdf0e10cSrcweir 	}
1559*cdf0e10cSrcweir 
1560*cdf0e10cSrcweir 	if (pAnchorRect)
1561*cdf0e10cSrcweir 		*pAnchorRect=aAnkRect;
1562*cdf0e10cSrcweir 
1563*cdf0e10cSrcweir 	rTextRect=Rectangle(aTextPos,aTextSiz);
1564*cdf0e10cSrcweir }
1565*cdf0e10cSrcweir 
1566*cdf0e10cSrcweir // --------------------------------------------------------------------
1567*cdf0e10cSrcweir 
1568*cdf0e10cSrcweir const CellRef& SdrTableObj::getActiveCell() const
1569*cdf0e10cSrcweir {
1570*cdf0e10cSrcweir 	if( mpImpl )
1571*cdf0e10cSrcweir 	{
1572*cdf0e10cSrcweir 		if( !mpImpl->mxActiveCell.is() )
1573*cdf0e10cSrcweir 		{
1574*cdf0e10cSrcweir 			CellPos aPos;
1575*cdf0e10cSrcweir 			const_cast< SdrTableObj* >(this)->setActiveCell( aPos );
1576*cdf0e10cSrcweir 		}
1577*cdf0e10cSrcweir 		return mpImpl->mxActiveCell;
1578*cdf0e10cSrcweir 	}
1579*cdf0e10cSrcweir 	else
1580*cdf0e10cSrcweir 	{
1581*cdf0e10cSrcweir 		static CellRef xCell;
1582*cdf0e10cSrcweir 		return xCell;
1583*cdf0e10cSrcweir 	}
1584*cdf0e10cSrcweir }
1585*cdf0e10cSrcweir 
1586*cdf0e10cSrcweir // --------------------------------------------------------------------
1587*cdf0e10cSrcweir 
1588*cdf0e10cSrcweir sal_Int32 SdrTableObj::getRowCount() const
1589*cdf0e10cSrcweir {
1590*cdf0e10cSrcweir 	return mpImpl ? mpImpl->getRowCount() : 0;
1591*cdf0e10cSrcweir }
1592*cdf0e10cSrcweir 
1593*cdf0e10cSrcweir // --------------------------------------------------------------------
1594*cdf0e10cSrcweir 
1595*cdf0e10cSrcweir sal_Int32 SdrTableObj::getColumnCount() const
1596*cdf0e10cSrcweir {
1597*cdf0e10cSrcweir 	return mpImpl ? mpImpl->getColumnCount() : 0;
1598*cdf0e10cSrcweir }
1599*cdf0e10cSrcweir 
1600*cdf0e10cSrcweir // --------------------------------------------------------------------
1601*cdf0e10cSrcweir 
1602*cdf0e10cSrcweir void SdrTableObj::setActiveCell( const CellPos& rPos )
1603*cdf0e10cSrcweir {
1604*cdf0e10cSrcweir 	if( mpImpl && mpImpl->mxTable.is() ) try
1605*cdf0e10cSrcweir 	{
1606*cdf0e10cSrcweir 		mpImpl->mxActiveCell.set( dynamic_cast< Cell* >( mpImpl->mxTable->getCellByPosition( rPos.mnCol, rPos.mnRow ).get() ) );
1607*cdf0e10cSrcweir 		if( mpImpl->mxActiveCell.is() && mpImpl->mxActiveCell->isMerged() )
1608*cdf0e10cSrcweir 		{
1609*cdf0e10cSrcweir 			CellPos aOrigin;
1610*cdf0e10cSrcweir 			findMergeOrigin( mpImpl->mxTable.get(), rPos.mnCol, rPos.mnRow, aOrigin.mnCol, aOrigin.mnRow );
1611*cdf0e10cSrcweir 			mpImpl->mxActiveCell.set( dynamic_cast< Cell* >( mpImpl->mxTable->getCellByPosition( aOrigin.mnCol, aOrigin.mnRow ).get() ) );
1612*cdf0e10cSrcweir 			mpImpl->maEditPos = aOrigin;
1613*cdf0e10cSrcweir 		}
1614*cdf0e10cSrcweir 		else
1615*cdf0e10cSrcweir 		{
1616*cdf0e10cSrcweir 			mpImpl->maEditPos = rPos;
1617*cdf0e10cSrcweir 		}
1618*cdf0e10cSrcweir 	}
1619*cdf0e10cSrcweir 	catch( Exception& )
1620*cdf0e10cSrcweir 	{
1621*cdf0e10cSrcweir 		DBG_ERROR("SdrTableObj::setActiveCell(), exception caught!");
1622*cdf0e10cSrcweir 	}
1623*cdf0e10cSrcweir }
1624*cdf0e10cSrcweir 
1625*cdf0e10cSrcweir // --------------------------------------------------------------------
1626*cdf0e10cSrcweir 
1627*cdf0e10cSrcweir void SdrTableObj::getActiveCellPos( CellPos& rPos ) const
1628*cdf0e10cSrcweir {
1629*cdf0e10cSrcweir 	rPos = mpImpl->maEditPos;
1630*cdf0e10cSrcweir }
1631*cdf0e10cSrcweir 
1632*cdf0e10cSrcweir // --------------------------------------------------------------------
1633*cdf0e10cSrcweir 
1634*cdf0e10cSrcweir void SdrTableObj::getCellBounds( const CellPos& rPos, ::Rectangle& rCellRect )
1635*cdf0e10cSrcweir {
1636*cdf0e10cSrcweir 	if( mpImpl )
1637*cdf0e10cSrcweir 	{
1638*cdf0e10cSrcweir 		CellRef xCell( mpImpl->getCell( rPos ) );
1639*cdf0e10cSrcweir 		if( xCell.is() )
1640*cdf0e10cSrcweir 			rCellRect = xCell->getCellRect();
1641*cdf0e10cSrcweir 	}
1642*cdf0e10cSrcweir }
1643*cdf0e10cSrcweir 
1644*cdf0e10cSrcweir // --------------------------------------------------------------------
1645*cdf0e10cSrcweir 
1646*cdf0e10cSrcweir void SdrTableObj::TakeTextAnchorRect(Rectangle& rAnchorRect) const
1647*cdf0e10cSrcweir {
1648*cdf0e10cSrcweir 	if( mpImpl )
1649*cdf0e10cSrcweir 		TakeTextAnchorRect( mpImpl->maEditPos, rAnchorRect );
1650*cdf0e10cSrcweir }
1651*cdf0e10cSrcweir 
1652*cdf0e10cSrcweir // --------------------------------------------------------------------
1653*cdf0e10cSrcweir 
1654*cdf0e10cSrcweir void SdrTableObj::TakeTextAnchorRect( const CellPos& rPos, Rectangle& rAnchorRect ) const
1655*cdf0e10cSrcweir {
1656*cdf0e10cSrcweir 	Rectangle aAnkRect(aRect);
1657*cdf0e10cSrcweir 
1658*cdf0e10cSrcweir 	if( mpImpl )
1659*cdf0e10cSrcweir 	{
1660*cdf0e10cSrcweir 		CellRef xCell( mpImpl->getCell( rPos ) );
1661*cdf0e10cSrcweir 		if( xCell.is() )
1662*cdf0e10cSrcweir 			xCell->TakeTextAnchorRect( aAnkRect );
1663*cdf0e10cSrcweir 	}
1664*cdf0e10cSrcweir 
1665*cdf0e10cSrcweir 	ImpJustifyRect(aAnkRect);
1666*cdf0e10cSrcweir 	rAnchorRect=aAnkRect;
1667*cdf0e10cSrcweir }
1668*cdf0e10cSrcweir 
1669*cdf0e10cSrcweir // --------------------------------------------------------------------
1670*cdf0e10cSrcweir 
1671*cdf0e10cSrcweir void SdrTableObj::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const
1672*cdf0e10cSrcweir {
1673*cdf0e10cSrcweir 	if( mpImpl )
1674*cdf0e10cSrcweir 		TakeTextEditArea( mpImpl->maEditPos, pPaperMin, pPaperMax, pViewInit, pViewMin );
1675*cdf0e10cSrcweir }
1676*cdf0e10cSrcweir 
1677*cdf0e10cSrcweir // --------------------------------------------------------------------
1678*cdf0e10cSrcweir 
1679*cdf0e10cSrcweir void SdrTableObj::TakeTextEditArea( const CellPos& rPos, Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin ) const
1680*cdf0e10cSrcweir {
1681*cdf0e10cSrcweir 	Size aPaperMin,aPaperMax;
1682*cdf0e10cSrcweir 	Rectangle aViewInit;
1683*cdf0e10cSrcweir 	TakeTextAnchorRect( rPos, aViewInit );
1684*cdf0e10cSrcweir 
1685*cdf0e10cSrcweir 	Size aAnkSiz(aViewInit.GetSize());
1686*cdf0e10cSrcweir 	aAnkSiz.Width()--; aAnkSiz.Height()--; // weil GetSize() ein draufaddiert
1687*cdf0e10cSrcweir 
1688*cdf0e10cSrcweir 	Size aMaxSiz(aAnkSiz.Width(),1000000);
1689*cdf0e10cSrcweir 	if (pModel!=NULL)
1690*cdf0e10cSrcweir 	{
1691*cdf0e10cSrcweir 		Size aTmpSiz(pModel->GetMaxObjSize());
1692*cdf0e10cSrcweir 		if (aTmpSiz.Height()!=0)
1693*cdf0e10cSrcweir 			aMaxSiz.Height()=aTmpSiz.Height();
1694*cdf0e10cSrcweir 	}
1695*cdf0e10cSrcweir 
1696*cdf0e10cSrcweir 	CellRef xCell( mpImpl->getCell( rPos ) );
1697*cdf0e10cSrcweir 	SdrTextVertAdjust eVAdj = xCell.is() ? xCell->GetTextVerticalAdjust() : SDRTEXTVERTADJUST_TOP;
1698*cdf0e10cSrcweir //	SdrTextHorzAdjust eHAdj = xCell.is() ? xCell->GetTextHorizontalAdjust() : SDRTEXTHORZADJUST_LEFT;
1699*cdf0e10cSrcweir 
1700*cdf0e10cSrcweir 	aPaperMax=aMaxSiz;
1701*cdf0e10cSrcweir 
1702*cdf0e10cSrcweir //	if((SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting()) || (SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting()))
1703*cdf0e10cSrcweir 		aPaperMin.Width() = aAnkSiz.Width();
1704*cdf0e10cSrcweir 
1705*cdf0e10cSrcweir 	if (pViewMin!=NULL)
1706*cdf0e10cSrcweir 	{
1707*cdf0e10cSrcweir 		*pViewMin=aViewInit;
1708*cdf0e10cSrcweir /*
1709*cdf0e10cSrcweir 		long nXFree=aAnkSiz.Width()-aPaperMin.Width();
1710*cdf0e10cSrcweir 
1711*cdf0e10cSrcweir 		if (eHAdj==SDRTEXTHORZADJUST_LEFT)
1712*cdf0e10cSrcweir 		{
1713*cdf0e10cSrcweir 			pViewMin->Right()-=nXFree;
1714*cdf0e10cSrcweir 		}
1715*cdf0e10cSrcweir 		else if (eHAdj==SDRTEXTHORZADJUST_RIGHT)
1716*cdf0e10cSrcweir 		{
1717*cdf0e10cSrcweir 			pViewMin->Left()+=nXFree;
1718*cdf0e10cSrcweir 		}
1719*cdf0e10cSrcweir 		else
1720*cdf0e10cSrcweir 		{
1721*cdf0e10cSrcweir 			pViewMin->Left()+=nXFree/2;
1722*cdf0e10cSrcweir 			pViewMin->Right()=pViewMin->Left()+aPaperMin.Width();
1723*cdf0e10cSrcweir 		}
1724*cdf0e10cSrcweir */
1725*cdf0e10cSrcweir 		long nYFree=aAnkSiz.Height()-aPaperMin.Height();
1726*cdf0e10cSrcweir 
1727*cdf0e10cSrcweir 		if (eVAdj==SDRTEXTVERTADJUST_TOP)
1728*cdf0e10cSrcweir 		{
1729*cdf0e10cSrcweir 			pViewMin->Bottom()-=nYFree;
1730*cdf0e10cSrcweir 		}
1731*cdf0e10cSrcweir 		else if (eVAdj==SDRTEXTVERTADJUST_BOTTOM)
1732*cdf0e10cSrcweir 		{
1733*cdf0e10cSrcweir 			pViewMin->Top()+=nYFree;
1734*cdf0e10cSrcweir 		}
1735*cdf0e10cSrcweir 		else
1736*cdf0e10cSrcweir 		{
1737*cdf0e10cSrcweir 			pViewMin->Top()+=nYFree/2;
1738*cdf0e10cSrcweir 			pViewMin->Bottom()=pViewMin->Top()+aPaperMin.Height();
1739*cdf0e10cSrcweir 		}
1740*cdf0e10cSrcweir 	}
1741*cdf0e10cSrcweir 
1742*cdf0e10cSrcweir 
1743*cdf0e10cSrcweir 	if(IsVerticalWriting())
1744*cdf0e10cSrcweir 		aPaperMin.Width() = 0;
1745*cdf0e10cSrcweir 	else
1746*cdf0e10cSrcweir 		aPaperMin.Height() = 0;
1747*cdf0e10cSrcweir 
1748*cdf0e10cSrcweir 	if (pPaperMin!=NULL) *pPaperMin=aPaperMin;
1749*cdf0e10cSrcweir 	if (pPaperMax!=NULL) *pPaperMax=aPaperMax;
1750*cdf0e10cSrcweir 	if (pViewInit!=NULL) *pViewInit=aViewInit;
1751*cdf0e10cSrcweir }
1752*cdf0e10cSrcweir 
1753*cdf0e10cSrcweir // --------------------------------------------------------------------
1754*cdf0e10cSrcweir 
1755*cdf0e10cSrcweir sal_uInt16 SdrTableObj::GetOutlinerViewAnchorMode() const
1756*cdf0e10cSrcweir {
1757*cdf0e10cSrcweir 	EVAnchorMode eRet=ANCHOR_TOP_LEFT;
1758*cdf0e10cSrcweir 	CellRef xCell( getActiveCell() );
1759*cdf0e10cSrcweir 	if( xCell.is() )
1760*cdf0e10cSrcweir 	{
1761*cdf0e10cSrcweir 		SdrTextVertAdjust eV=xCell->GetTextVerticalAdjust();
1762*cdf0e10cSrcweir //		SdrTextHorzAdjust eH=xCell->GetTextHorizontalAdjust();
1763*cdf0e10cSrcweir 
1764*cdf0e10cSrcweir //		if (eH==SDRTEXTHORZADJUST_LEFT)
1765*cdf0e10cSrcweir 		{
1766*cdf0e10cSrcweir 			if (eV==SDRTEXTVERTADJUST_TOP)
1767*cdf0e10cSrcweir 			{
1768*cdf0e10cSrcweir 				eRet=ANCHOR_TOP_LEFT;
1769*cdf0e10cSrcweir 			}
1770*cdf0e10cSrcweir 			else if (eV==SDRTEXTVERTADJUST_BOTTOM)
1771*cdf0e10cSrcweir 			{
1772*cdf0e10cSrcweir 				eRet=ANCHOR_BOTTOM_LEFT;
1773*cdf0e10cSrcweir 			}
1774*cdf0e10cSrcweir 			else
1775*cdf0e10cSrcweir 			{
1776*cdf0e10cSrcweir 				eRet=ANCHOR_VCENTER_LEFT;
1777*cdf0e10cSrcweir 			}
1778*cdf0e10cSrcweir 		}
1779*cdf0e10cSrcweir /*
1780*cdf0e10cSrcweir 		else if (eH==SDRTEXTHORZADJUST_RIGHT)
1781*cdf0e10cSrcweir 		{
1782*cdf0e10cSrcweir 			if (eV==SDRTEXTVERTADJUST_TOP)
1783*cdf0e10cSrcweir 			{
1784*cdf0e10cSrcweir 				eRet=ANCHOR_TOP_RIGHT;
1785*cdf0e10cSrcweir 			}
1786*cdf0e10cSrcweir 			else if (eV==SDRTEXTVERTADJUST_BOTTOM)
1787*cdf0e10cSrcweir 			{
1788*cdf0e10cSrcweir 				eRet=ANCHOR_BOTTOM_RIGHT;
1789*cdf0e10cSrcweir 			}
1790*cdf0e10cSrcweir 			else
1791*cdf0e10cSrcweir 			{
1792*cdf0e10cSrcweir 				eRet=ANCHOR_VCENTER_RIGHT;
1793*cdf0e10cSrcweir 			}
1794*cdf0e10cSrcweir 		}
1795*cdf0e10cSrcweir 		else
1796*cdf0e10cSrcweir 		{
1797*cdf0e10cSrcweir 			if (eV==SDRTEXTVERTADJUST_TOP)
1798*cdf0e10cSrcweir 			{
1799*cdf0e10cSrcweir 				eRet=ANCHOR_TOP_HCENTER;
1800*cdf0e10cSrcweir 			}
1801*cdf0e10cSrcweir 			else if (eV==SDRTEXTVERTADJUST_BOTTOM)
1802*cdf0e10cSrcweir 			{
1803*cdf0e10cSrcweir 				eRet=ANCHOR_BOTTOM_HCENTER;
1804*cdf0e10cSrcweir 			}
1805*cdf0e10cSrcweir 			else
1806*cdf0e10cSrcweir 			{
1807*cdf0e10cSrcweir 				eRet=ANCHOR_VCENTER_HCENTER;
1808*cdf0e10cSrcweir 			}
1809*cdf0e10cSrcweir 		}
1810*cdf0e10cSrcweir */
1811*cdf0e10cSrcweir 	}
1812*cdf0e10cSrcweir 	return (sal_uInt16)eRet;
1813*cdf0e10cSrcweir }
1814*cdf0e10cSrcweir 
1815*cdf0e10cSrcweir // --------------------------------------------------------------------
1816*cdf0e10cSrcweir 
1817*cdf0e10cSrcweir OutlinerParaObject* SdrTableObj::GetEditOutlinerParaObject() const
1818*cdf0e10cSrcweir {
1819*cdf0e10cSrcweir 	return SdrTextObj::GetEditOutlinerParaObject();
1820*cdf0e10cSrcweir }
1821*cdf0e10cSrcweir 
1822*cdf0e10cSrcweir // --------------------------------------------------------------------
1823*cdf0e10cSrcweir 
1824*cdf0e10cSrcweir SdrOutliner* SdrTableObj::GetCellTextEditOutliner( const CellPos& rPos ) const
1825*cdf0e10cSrcweir {
1826*cdf0e10cSrcweir 	if( pEdtOutl && mpImpl && (mpImpl->maEditPos == rPos) )
1827*cdf0e10cSrcweir 		return pEdtOutl;
1828*cdf0e10cSrcweir 	else
1829*cdf0e10cSrcweir 		return 0;
1830*cdf0e10cSrcweir }
1831*cdf0e10cSrcweir 
1832*cdf0e10cSrcweir // --------------------------------------------------------------------
1833*cdf0e10cSrcweir 
1834*cdf0e10cSrcweir struct ImplTableShadowPaintInfo
1835*cdf0e10cSrcweir {
1836*cdf0e10cSrcweir 	Color maShadowColor;
1837*cdf0e10cSrcweir 	sal_uInt32 mnXDistance;
1838*cdf0e10cSrcweir 	sal_uInt32 mnYDistance;
1839*cdf0e10cSrcweir 	sal_uInt16 mnShadowTransparence;
1840*cdf0e10cSrcweir 
1841*cdf0e10cSrcweir 	ImplTableShadowPaintInfo( const SfxItemSet& rSet )
1842*cdf0e10cSrcweir 	{
1843*cdf0e10cSrcweir         const SdrShadowColorItem& rShadColItem = ((const SdrShadowColorItem&)(rSet.Get(SDRATTR_SHADOWCOLOR)));
1844*cdf0e10cSrcweir         maShadowColor = rShadColItem.GetColorValue();
1845*cdf0e10cSrcweir         mnShadowTransparence = ((const SdrShadowTransparenceItem&)(rSet.Get(SDRATTR_SHADOWTRANSPARENCE))).GetValue();
1846*cdf0e10cSrcweir 
1847*cdf0e10cSrcweir 		mnXDistance = ((SdrShadowXDistItem&)(rSet.Get(SDRATTR_SHADOWXDIST))).GetValue();
1848*cdf0e10cSrcweir 		mnYDistance = ((SdrShadowYDistItem&)(rSet.Get(SDRATTR_SHADOWYDIST))).GetValue();
1849*cdf0e10cSrcweir 	}
1850*cdf0e10cSrcweir };
1851*cdf0e10cSrcweir 
1852*cdf0e10cSrcweir // --------------------------------------------------------------------
1853*cdf0e10cSrcweir 
1854*cdf0e10cSrcweir void lcl_VertLineEnds( OutputDevice& rDev, const Point& rTop, const Point& rBottom,
1855*cdf0e10cSrcweir         const Color& rColor, long nXOffs, long nWidth,
1856*cdf0e10cSrcweir         const svx::frame::Style& rTopLine, const svx::frame::Style& rBottomLine )
1857*cdf0e10cSrcweir {
1858*cdf0e10cSrcweir     rDev.SetLineColor(rColor);              // PEN_NULL ???
1859*cdf0e10cSrcweir     rDev.SetFillColor(rColor);
1860*cdf0e10cSrcweir 
1861*cdf0e10cSrcweir 	//	Position oben/unten muss unabhaengig von der Liniendicke sein,
1862*cdf0e10cSrcweir 	//	damit der Winkel stimmt (oder X-Position auch anpassen)
1863*cdf0e10cSrcweir 	long nTopPos = rTop.Y();
1864*cdf0e10cSrcweir 	long nBotPos = rBottom.Y();
1865*cdf0e10cSrcweir 
1866*cdf0e10cSrcweir     long nTopLeft = rTop.X() + nXOffs;
1867*cdf0e10cSrcweir     long nTopRight = nTopLeft + nWidth - 1;
1868*cdf0e10cSrcweir 
1869*cdf0e10cSrcweir     long nBotLeft = rBottom.X() + nXOffs;
1870*cdf0e10cSrcweir     long nBotRight = nBotLeft + nWidth - 1;
1871*cdf0e10cSrcweir 
1872*cdf0e10cSrcweir 	//	oben abschliessen
1873*cdf0e10cSrcweir 
1874*cdf0e10cSrcweir     if ( rTopLine.Prim() )
1875*cdf0e10cSrcweir 	{
1876*cdf0e10cSrcweir         long nLineW = rTopLine.GetWidth();
1877*cdf0e10cSrcweir         if (nLineW >= 2)
1878*cdf0e10cSrcweir 		{
1879*cdf0e10cSrcweir 			Point aTriangle[3];
1880*cdf0e10cSrcweir 			aTriangle[0] = Point( nTopLeft, nTopPos );		// wie aPoints[0]
1881*cdf0e10cSrcweir 			aTriangle[1] = Point( nTopRight, nTopPos );		// wie aPoints[1]
1882*cdf0e10cSrcweir             aTriangle[2] = Point( rTop.X(), nTopPos - (nLineW - 1) / 2 );
1883*cdf0e10cSrcweir 			Polygon aTriPoly( 3, aTriangle );
1884*cdf0e10cSrcweir             rDev.DrawPolygon( aTriPoly );
1885*cdf0e10cSrcweir 		}
1886*cdf0e10cSrcweir 	}
1887*cdf0e10cSrcweir 
1888*cdf0e10cSrcweir 	//	unten abschliessen
1889*cdf0e10cSrcweir 
1890*cdf0e10cSrcweir     if ( rBottomLine.Prim() )
1891*cdf0e10cSrcweir 	{
1892*cdf0e10cSrcweir         long nLineW = rBottomLine.GetWidth();
1893*cdf0e10cSrcweir         if (nLineW >= 2)
1894*cdf0e10cSrcweir 		{
1895*cdf0e10cSrcweir 			Point aTriangle[3];
1896*cdf0e10cSrcweir 			aTriangle[0] = Point( nBotLeft, nBotPos );		// wie aPoints[3]
1897*cdf0e10cSrcweir 			aTriangle[1] = Point( nBotRight, nBotPos );		// wie aPoints[2]
1898*cdf0e10cSrcweir             aTriangle[2] = Point( rBottom.X(), nBotPos - (nLineW - 1) / 2 + nLineW - 1 );
1899*cdf0e10cSrcweir 			Polygon aTriPoly( 3, aTriangle );
1900*cdf0e10cSrcweir             rDev.DrawPolygon( aTriPoly );
1901*cdf0e10cSrcweir 		}
1902*cdf0e10cSrcweir 	}
1903*cdf0e10cSrcweir }
1904*cdf0e10cSrcweir 
1905*cdf0e10cSrcweir void lcl_VertLine( OutputDevice& rDev, const Point& rTop, const Point& rBottom,
1906*cdf0e10cSrcweir                     const svx::frame::Style& rLine,
1907*cdf0e10cSrcweir                     const svx::frame::Style& rTopLine, const svx::frame::Style& rBottomLine,
1908*cdf0e10cSrcweir                     const Color* pForceColor )
1909*cdf0e10cSrcweir {
1910*cdf0e10cSrcweir     if( rLine.Prim() )
1911*cdf0e10cSrcweir     {
1912*cdf0e10cSrcweir         svx::frame::DrawVerFrameBorderSlanted( rDev, rTop, rBottom, rLine, pForceColor );
1913*cdf0e10cSrcweir 
1914*cdf0e10cSrcweir         svx::frame::Style aScaled( rLine );
1915*cdf0e10cSrcweir         aScaled.ScaleSelf( 1.0 / cos( svx::frame::GetVerDiagAngle( rTop, rBottom ) ) );
1916*cdf0e10cSrcweir         if( pForceColor )
1917*cdf0e10cSrcweir             aScaled.SetColor( *pForceColor );
1918*cdf0e10cSrcweir 
1919*cdf0e10cSrcweir         long nXOffs = (aScaled.GetWidth() - 1) / -2L;
1920*cdf0e10cSrcweir 
1921*cdf0e10cSrcweir         lcl_VertLineEnds( rDev, rTop, rBottom, aScaled.GetColor(),
1922*cdf0e10cSrcweir             nXOffs, aScaled.Prim(), rTopLine, rBottomLine );
1923*cdf0e10cSrcweir 
1924*cdf0e10cSrcweir         if( aScaled.Secn() )
1925*cdf0e10cSrcweir             lcl_VertLineEnds( rDev, rTop, rBottom, aScaled.GetColor(),
1926*cdf0e10cSrcweir                 nXOffs + aScaled.Prim() + aScaled.Dist(), aScaled.Secn(), rTopLine, rBottomLine );
1927*cdf0e10cSrcweir     }
1928*cdf0e10cSrcweir }
1929*cdf0e10cSrcweir 
1930*cdf0e10cSrcweir // --------------------------------------------------------------------
1931*cdf0e10cSrcweir 
1932*cdf0e10cSrcweir void SdrTableObj::TakeObjNameSingul(XubString& rName) const
1933*cdf0e10cSrcweir {
1934*cdf0e10cSrcweir 	rName = ImpGetResStr(STR_ObjNameSingulTable);
1935*cdf0e10cSrcweir 
1936*cdf0e10cSrcweir 	String aName( GetName() );
1937*cdf0e10cSrcweir 	if(aName.Len())
1938*cdf0e10cSrcweir 	{
1939*cdf0e10cSrcweir 		rName += sal_Unicode(' ');
1940*cdf0e10cSrcweir 		rName += sal_Unicode('\'');
1941*cdf0e10cSrcweir 		rName += aName;
1942*cdf0e10cSrcweir 		rName += sal_Unicode('\'');
1943*cdf0e10cSrcweir 	}
1944*cdf0e10cSrcweir }
1945*cdf0e10cSrcweir 
1946*cdf0e10cSrcweir // --------------------------------------------------------------------
1947*cdf0e10cSrcweir 
1948*cdf0e10cSrcweir void SdrTableObj::TakeObjNamePlural(XubString& rName) const
1949*cdf0e10cSrcweir {
1950*cdf0e10cSrcweir 	rName = ImpGetResStr(STR_ObjNamePluralTable);
1951*cdf0e10cSrcweir }
1952*cdf0e10cSrcweir 
1953*cdf0e10cSrcweir // --------------------------------------------------------------------
1954*cdf0e10cSrcweir 
1955*cdf0e10cSrcweir void SdrTableObj::operator=(const SdrObject& rObj)
1956*cdf0e10cSrcweir {
1957*cdf0e10cSrcweir 	// call parent
1958*cdf0e10cSrcweir 	SdrObject::operator=(rObj);
1959*cdf0e10cSrcweir 
1960*cdf0e10cSrcweir 	const SdrTableObj* pTableObj = dynamic_cast< const SdrTableObj* >( &rObj );
1961*cdf0e10cSrcweir 	if (pTableObj!=NULL)
1962*cdf0e10cSrcweir 	{
1963*cdf0e10cSrcweir 		TableModelNotifyGuard aGuard( mpImpl ? mpImpl->mxTable.get() : 0 );
1964*cdf0e10cSrcweir 
1965*cdf0e10cSrcweir 		maLogicRect = pTableObj->maLogicRect;
1966*cdf0e10cSrcweir 		aRect = pTableObj->aRect;
1967*cdf0e10cSrcweir 		aGeo = pTableObj->aGeo;
1968*cdf0e10cSrcweir 		eTextKind = pTableObj->eTextKind;
1969*cdf0e10cSrcweir 		bTextFrame = pTableObj->bTextFrame;
1970*cdf0e10cSrcweir 		aTextSize = pTableObj->aTextSize;
1971*cdf0e10cSrcweir 		bTextSizeDirty = pTableObj->bTextSizeDirty;
1972*cdf0e10cSrcweir 		bNoShear = pTableObj->bNoShear;
1973*cdf0e10cSrcweir 		bNoRotate = pTableObj->bNoRotate;
1974*cdf0e10cSrcweir 		bNoMirror = pTableObj->bNoMirror;
1975*cdf0e10cSrcweir 		bDisableAutoWidthOnDragging = pTableObj->bDisableAutoWidthOnDragging;
1976*cdf0e10cSrcweir 
1977*cdf0e10cSrcweir 		if( pTableObj->mpImpl )
1978*cdf0e10cSrcweir 			*mpImpl = *pTableObj->mpImpl;
1979*cdf0e10cSrcweir 	}
1980*cdf0e10cSrcweir }
1981*cdf0e10cSrcweir 
1982*cdf0e10cSrcweir // --------------------------------------------------------------------
1983*cdf0e10cSrcweir 
1984*cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrTableObj::TakeXorPoly() const
1985*cdf0e10cSrcweir {
1986*cdf0e10cSrcweir 	return SdrTextObj::TakeXorPoly();
1987*cdf0e10cSrcweir }
1988*cdf0e10cSrcweir 
1989*cdf0e10cSrcweir // --------------------------------------------------------------------
1990*cdf0e10cSrcweir 
1991*cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrTableObj::TakeContour() const
1992*cdf0e10cSrcweir {
1993*cdf0e10cSrcweir 	return SdrTextObj::TakeContour();
1994*cdf0e10cSrcweir }
1995*cdf0e10cSrcweir 
1996*cdf0e10cSrcweir // --------------------------------------------------------------------
1997*cdf0e10cSrcweir 
1998*cdf0e10cSrcweir const Rectangle& SdrTableObj::GetSnapRect() const
1999*cdf0e10cSrcweir {
2000*cdf0e10cSrcweir 	return aRect;
2001*cdf0e10cSrcweir }
2002*cdf0e10cSrcweir 
2003*cdf0e10cSrcweir // --------------------------------------------------------------------
2004*cdf0e10cSrcweir 
2005*cdf0e10cSrcweir void SdrTableObj::NbcSetSnapRect(const Rectangle& rRect)
2006*cdf0e10cSrcweir {
2007*cdf0e10cSrcweir 	NbcSetLogicRect( rRect );
2008*cdf0e10cSrcweir }
2009*cdf0e10cSrcweir 
2010*cdf0e10cSrcweir // --------------------------------------------------------------------
2011*cdf0e10cSrcweir 
2012*cdf0e10cSrcweir const Rectangle& SdrTableObj::GetLogicRect() const
2013*cdf0e10cSrcweir {
2014*cdf0e10cSrcweir 	return maLogicRect;
2015*cdf0e10cSrcweir }
2016*cdf0e10cSrcweir 
2017*cdf0e10cSrcweir // --------------------------------------------------------------------
2018*cdf0e10cSrcweir 
2019*cdf0e10cSrcweir void SdrTableObj::RecalcSnapRect()
2020*cdf0e10cSrcweir {
2021*cdf0e10cSrcweir }
2022*cdf0e10cSrcweir 
2023*cdf0e10cSrcweir // --------------------------------------------------------------------
2024*cdf0e10cSrcweir 
2025*cdf0e10cSrcweir sal_uInt32 SdrTableObj::GetSnapPointCount() const
2026*cdf0e10cSrcweir {
2027*cdf0e10cSrcweir 	return SdrTextObj::GetSnapPointCount();
2028*cdf0e10cSrcweir }
2029*cdf0e10cSrcweir 
2030*cdf0e10cSrcweir // --------------------------------------------------------------------
2031*cdf0e10cSrcweir 
2032*cdf0e10cSrcweir 
2033*cdf0e10cSrcweir Point SdrTableObj::GetSnapPoint(sal_uInt32 i) const
2034*cdf0e10cSrcweir {
2035*cdf0e10cSrcweir 	return SdrTextObj::GetSnapPoint(i);
2036*cdf0e10cSrcweir }
2037*cdf0e10cSrcweir 
2038*cdf0e10cSrcweir // --------------------------------------------------------------------
2039*cdf0e10cSrcweir 
2040*cdf0e10cSrcweir sal_Bool SdrTableObj::BegTextEdit(SdrOutliner& rOutl)
2041*cdf0e10cSrcweir {
2042*cdf0e10cSrcweir 	if( pEdtOutl != NULL )
2043*cdf0e10cSrcweir 		return sal_False;
2044*cdf0e10cSrcweir 
2045*cdf0e10cSrcweir 	pEdtOutl=&rOutl;
2046*cdf0e10cSrcweir 
2047*cdf0e10cSrcweir //	ForceOutlinerParaObject();
2048*cdf0e10cSrcweir 
2049*cdf0e10cSrcweir 	mbInEditMode = sal_True;
2050*cdf0e10cSrcweir 
2051*cdf0e10cSrcweir 	rOutl.Init( OUTLINERMODE_TEXTOBJECT );
2052*cdf0e10cSrcweir 	rOutl.SetRefDevice( pModel->GetRefDevice() );
2053*cdf0e10cSrcweir 
2054*cdf0e10cSrcweir // --
2055*cdf0e10cSrcweir 		FASTBOOL bUpdMerk=rOutl.GetUpdateMode();
2056*cdf0e10cSrcweir 		if (bUpdMerk) rOutl.SetUpdateMode(sal_False);
2057*cdf0e10cSrcweir 		Size aPaperMin;
2058*cdf0e10cSrcweir 		Size aPaperMax;
2059*cdf0e10cSrcweir 		Rectangle aEditArea;
2060*cdf0e10cSrcweir 		TakeTextEditArea(&aPaperMin,&aPaperMax,&aEditArea,NULL);
2061*cdf0e10cSrcweir 
2062*cdf0e10cSrcweir 		rOutl.SetMinAutoPaperSize(aPaperMin);
2063*cdf0e10cSrcweir 		rOutl.SetMaxAutoPaperSize(aPaperMax);
2064*cdf0e10cSrcweir 		rOutl.SetPaperSize(aPaperMax);
2065*cdf0e10cSrcweir 
2066*cdf0e10cSrcweir 		if (bUpdMerk) rOutl.SetUpdateMode(sal_True);
2067*cdf0e10cSrcweir //---
2068*cdf0e10cSrcweir 
2069*cdf0e10cSrcweir 	sal_uIntPtr nStat=rOutl.GetControlWord();
2070*cdf0e10cSrcweir //	nStat	&= ~EE_CNTRL_AUTOPAGESIZE;
2071*cdf0e10cSrcweir 	nStat	|= EE_CNTRL_AUTOPAGESIZE;
2072*cdf0e10cSrcweir 	nStat	&=~EE_CNTRL_STRETCHING;
2073*cdf0e10cSrcweir 	rOutl.SetControlWord(nStat);
2074*cdf0e10cSrcweir 
2075*cdf0e10cSrcweir 	OutlinerParaObject* pPara = GetOutlinerParaObject();
2076*cdf0e10cSrcweir 	if(pPara)
2077*cdf0e10cSrcweir 		rOutl.SetText(*pPara);
2078*cdf0e10cSrcweir 
2079*cdf0e10cSrcweir 	rOutl.UpdateFields();
2080*cdf0e10cSrcweir 	rOutl.ClearModifyFlag();
2081*cdf0e10cSrcweir 
2082*cdf0e10cSrcweir //	mpImpl->mnSavedEditRowHeight = mpImpl->mpLayouter->getRowHeight( mpImpl->maEditPos.mnRow );
2083*cdf0e10cSrcweir 
2084*cdf0e10cSrcweir 	return sal_True;
2085*cdf0e10cSrcweir }
2086*cdf0e10cSrcweir 
2087*cdf0e10cSrcweir // --------------------------------------------------------------------
2088*cdf0e10cSrcweir 
2089*cdf0e10cSrcweir void SdrTableObj::EndTextEdit(SdrOutliner& rOutl)
2090*cdf0e10cSrcweir {
2091*cdf0e10cSrcweir 	if(rOutl.IsModified())
2092*cdf0e10cSrcweir 	{
2093*cdf0e10cSrcweir 		if( GetModel() && GetModel()->IsUndoEnabled() )
2094*cdf0e10cSrcweir 			GetModel()->AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*this) );
2095*cdf0e10cSrcweir 
2096*cdf0e10cSrcweir 		OutlinerParaObject* pNewText = 0;
2097*cdf0e10cSrcweir 		Paragraph* p1stPara = rOutl.GetParagraph( 0 );
2098*cdf0e10cSrcweir 		sal_uInt32 nParaAnz = rOutl.GetParagraphCount();
2099*cdf0e10cSrcweir 
2100*cdf0e10cSrcweir 		if(p1stPara)
2101*cdf0e10cSrcweir 		{
2102*cdf0e10cSrcweir 			if(nParaAnz == 1)
2103*cdf0e10cSrcweir 			{
2104*cdf0e10cSrcweir 				// if its only one paragraph, check if it is empty
2105*cdf0e10cSrcweir 				XubString aStr(rOutl.GetText(p1stPara));
2106*cdf0e10cSrcweir 
2107*cdf0e10cSrcweir 				if(!aStr.Len())
2108*cdf0e10cSrcweir 				{
2109*cdf0e10cSrcweir 					// gotcha!
2110*cdf0e10cSrcweir 					nParaAnz = 0;
2111*cdf0e10cSrcweir 				}
2112*cdf0e10cSrcweir 			}
2113*cdf0e10cSrcweir 
2114*cdf0e10cSrcweir 			// to remove the grey field background
2115*cdf0e10cSrcweir 			rOutl.UpdateFields();
2116*cdf0e10cSrcweir 
2117*cdf0e10cSrcweir 			if(nParaAnz != 0)
2118*cdf0e10cSrcweir 			{
2119*cdf0e10cSrcweir 				// create new text object
2120*cdf0e10cSrcweir 				pNewText = rOutl.CreateParaObject( 0, (sal_uInt16)nParaAnz );
2121*cdf0e10cSrcweir 			}
2122*cdf0e10cSrcweir 		}
2123*cdf0e10cSrcweir 		SetOutlinerParaObject(pNewText);
2124*cdf0e10cSrcweir 	}
2125*cdf0e10cSrcweir 
2126*cdf0e10cSrcweir 	pEdtOutl = 0;
2127*cdf0e10cSrcweir 	rOutl.Clear();
2128*cdf0e10cSrcweir 	sal_uInt32 nStat = rOutl.GetControlWord();
2129*cdf0e10cSrcweir 	nStat &= ~EE_CNTRL_AUTOPAGESIZE;
2130*cdf0e10cSrcweir 	rOutl.SetControlWord(nStat);
2131*cdf0e10cSrcweir 
2132*cdf0e10cSrcweir 	mbInEditMode = sal_False;
2133*cdf0e10cSrcweir }
2134*cdf0e10cSrcweir 
2135*cdf0e10cSrcweir // --------------------------------------------------------------------
2136*cdf0e10cSrcweir 
2137*cdf0e10cSrcweir OutlinerParaObject* SdrTableObj::GetOutlinerParaObject() const
2138*cdf0e10cSrcweir {
2139*cdf0e10cSrcweir 	CellRef xCell( getActiveCell() );
2140*cdf0e10cSrcweir 	if( xCell.is() )
2141*cdf0e10cSrcweir 		return xCell->GetOutlinerParaObject();
2142*cdf0e10cSrcweir 	else
2143*cdf0e10cSrcweir 		return 0;
2144*cdf0e10cSrcweir }
2145*cdf0e10cSrcweir 
2146*cdf0e10cSrcweir // --------------------------------------------------------------------
2147*cdf0e10cSrcweir 
2148*cdf0e10cSrcweir void SdrTableObj::NbcSetOutlinerParaObject( OutlinerParaObject* pTextObject)
2149*cdf0e10cSrcweir {
2150*cdf0e10cSrcweir 	CellRef xCell( getActiveCell() );
2151*cdf0e10cSrcweir 	if( xCell.is() )
2152*cdf0e10cSrcweir 	{
2153*cdf0e10cSrcweir 		if( pModel )
2154*cdf0e10cSrcweir 		{
2155*cdf0e10cSrcweir 			// Update HitTestOutliner
2156*cdf0e10cSrcweir 			const SdrTextObj* pTestObj = pModel->GetHitTestOutliner().GetTextObj();
2157*cdf0e10cSrcweir 			if( pTestObj && pTestObj->GetOutlinerParaObject() == xCell->GetOutlinerParaObject() )
2158*cdf0e10cSrcweir 				pModel->GetHitTestOutliner().SetTextObj( NULL );
2159*cdf0e10cSrcweir 		}
2160*cdf0e10cSrcweir 
2161*cdf0e10cSrcweir 		xCell->SetOutlinerParaObject( pTextObject );
2162*cdf0e10cSrcweir 
2163*cdf0e10cSrcweir 		SetTextSizeDirty();
2164*cdf0e10cSrcweir 		NbcAdjustTextFrameWidthAndHeight();
2165*cdf0e10cSrcweir //		ImpSetTextStyleSheetListeners();
2166*cdf0e10cSrcweir //		ImpCheckMasterCachable();
2167*cdf0e10cSrcweir 	}
2168*cdf0e10cSrcweir }
2169*cdf0e10cSrcweir 
2170*cdf0e10cSrcweir // --------------------------------------------------------------------
2171*cdf0e10cSrcweir 
2172*cdf0e10cSrcweir void SdrTableObj::NbcSetLogicRect(const Rectangle& rRect)
2173*cdf0e10cSrcweir {
2174*cdf0e10cSrcweir 	maLogicRect=rRect;
2175*cdf0e10cSrcweir 	ImpJustifyRect(maLogicRect);
2176*cdf0e10cSrcweir 	const bool bWidth = maLogicRect.getWidth() != aRect.getWidth();
2177*cdf0e10cSrcweir 	const bool bHeight = maLogicRect.getHeight() != aRect.getHeight();
2178*cdf0e10cSrcweir 	aRect=maLogicRect;
2179*cdf0e10cSrcweir 	NbcAdjustTextFrameWidthAndHeight( !bHeight, !bWidth );
2180*cdf0e10cSrcweir 	SetRectsDirty();
2181*cdf0e10cSrcweir }
2182*cdf0e10cSrcweir 
2183*cdf0e10cSrcweir 
2184*cdf0e10cSrcweir // --------------------------------------------------------------------
2185*cdf0e10cSrcweir 
2186*cdf0e10cSrcweir void SdrTableObj::AdjustToMaxRect( const Rectangle& rMaxRect, bool /* bShrinkOnly = false */ )
2187*cdf0e10cSrcweir {
2188*cdf0e10cSrcweir 	Rectangle aAdjustRect( rMaxRect );
2189*cdf0e10cSrcweir 	aAdjustRect.setHeight( GetLogicRect().getHeight() );
2190*cdf0e10cSrcweir 	SetLogicRect( aAdjustRect );
2191*cdf0e10cSrcweir }
2192*cdf0e10cSrcweir 
2193*cdf0e10cSrcweir // --------------------------------------------------------------------
2194*cdf0e10cSrcweir 
2195*cdf0e10cSrcweir void SdrTableObj::NbcMove(const Size& rSiz)
2196*cdf0e10cSrcweir {
2197*cdf0e10cSrcweir 	MoveRect(maLogicRect,rSiz);
2198*cdf0e10cSrcweir 	SdrTextObj::NbcMove( rSiz );
2199*cdf0e10cSrcweir 	if( mpImpl )
2200*cdf0e10cSrcweir 		mpImpl->UpdateCells( aRect );
2201*cdf0e10cSrcweir }
2202*cdf0e10cSrcweir 
2203*cdf0e10cSrcweir // --------------------------------------------------------------------
2204*cdf0e10cSrcweir 
2205*cdf0e10cSrcweir void SdrTableObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
2206*cdf0e10cSrcweir {
2207*cdf0e10cSrcweir 	Rectangle aOldRect( maLogicRect );
2208*cdf0e10cSrcweir 	ResizeRect(maLogicRect,rRef,xFact,yFact);
2209*cdf0e10cSrcweir 
2210*cdf0e10cSrcweir 	aRect = maLogicRect;
2211*cdf0e10cSrcweir 	NbcAdjustTextFrameWidthAndHeight( maLogicRect.GetHeight() == aOldRect.GetHeight(), maLogicRect.GetWidth() == aOldRect.GetWidth() );
2212*cdf0e10cSrcweir 	SetRectsDirty();
2213*cdf0e10cSrcweir }
2214*cdf0e10cSrcweir 
2215*cdf0e10cSrcweir // --------------------------------------------------------------------
2216*cdf0e10cSrcweir 
2217*cdf0e10cSrcweir FASTBOOL SdrTableObj::AdjustTextFrameWidthAndHeight(FASTBOOL bHgt, FASTBOOL bWdt)
2218*cdf0e10cSrcweir {
2219*cdf0e10cSrcweir 	Rectangle aNeuRect(maLogicRect);
2220*cdf0e10cSrcweir 	FASTBOOL bRet=AdjustTextFrameWidthAndHeight(aNeuRect,bHgt,bWdt);
2221*cdf0e10cSrcweir 	if (bRet)
2222*cdf0e10cSrcweir 	{
2223*cdf0e10cSrcweir 		Rectangle aBoundRect0;
2224*cdf0e10cSrcweir 		if (pUserCall!=NULL)
2225*cdf0e10cSrcweir 			aBoundRect0=GetLastBoundRect();
2226*cdf0e10cSrcweir 		aRect=aNeuRect;
2227*cdf0e10cSrcweir 		SetRectsDirty();
2228*cdf0e10cSrcweir 		SetChanged();
2229*cdf0e10cSrcweir 		BroadcastObjectChange();
2230*cdf0e10cSrcweir 		SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
2231*cdf0e10cSrcweir 	}
2232*cdf0e10cSrcweir 	return bRet;
2233*cdf0e10cSrcweir }
2234*cdf0e10cSrcweir 
2235*cdf0e10cSrcweir // --------------------------------------------------------------------
2236*cdf0e10cSrcweir 
2237*cdf0e10cSrcweir FASTBOOL SdrTableObj::AdjustTextFrameWidthAndHeight(Rectangle& rR, FASTBOOL bHeight, FASTBOOL bWidth) const
2238*cdf0e10cSrcweir {
2239*cdf0e10cSrcweir 	if((pModel == NULL) || rR.IsEmpty() || !mpImpl || !mpImpl->mxTable.is() )
2240*cdf0e10cSrcweir 		return sal_False;
2241*cdf0e10cSrcweir 
2242*cdf0e10cSrcweir 	Rectangle aRectangle( rR );
2243*cdf0e10cSrcweir 	mpImpl->LayoutTable( aRectangle, !bWidth, !bHeight );
2244*cdf0e10cSrcweir 
2245*cdf0e10cSrcweir 	if( aRectangle != rR )
2246*cdf0e10cSrcweir 	{
2247*cdf0e10cSrcweir 		rR = aRectangle;
2248*cdf0e10cSrcweir 		return sal_True;
2249*cdf0e10cSrcweir 	}
2250*cdf0e10cSrcweir 	else
2251*cdf0e10cSrcweir 	{
2252*cdf0e10cSrcweir 		return sal_False;
2253*cdf0e10cSrcweir 	}
2254*cdf0e10cSrcweir }
2255*cdf0e10cSrcweir 
2256*cdf0e10cSrcweir // --------------------------------------------------------------------
2257*cdf0e10cSrcweir 
2258*cdf0e10cSrcweir void SdrTableObj::NbcReformatText()
2259*cdf0e10cSrcweir {
2260*cdf0e10cSrcweir 	NbcAdjustTextFrameWidthAndHeight();
2261*cdf0e10cSrcweir }
2262*cdf0e10cSrcweir 
2263*cdf0e10cSrcweir // --------------------------------------------------------------------
2264*cdf0e10cSrcweir 
2265*cdf0e10cSrcweir void SdrTableObj::ReformatText()
2266*cdf0e10cSrcweir {
2267*cdf0e10cSrcweir 	Rectangle aBoundRect0;
2268*cdf0e10cSrcweir 	if (pUserCall!=NULL)
2269*cdf0e10cSrcweir 		aBoundRect0=GetLastBoundRect();
2270*cdf0e10cSrcweir 	NbcReformatText();
2271*cdf0e10cSrcweir 	SetChanged();
2272*cdf0e10cSrcweir 	BroadcastObjectChange();
2273*cdf0e10cSrcweir 	SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
2274*cdf0e10cSrcweir }
2275*cdf0e10cSrcweir 
2276*cdf0e10cSrcweir // --------------------------------------------------------------------
2277*cdf0e10cSrcweir 
2278*cdf0e10cSrcweir sal_Bool SdrTableObj::IsVerticalWriting() const
2279*cdf0e10cSrcweir {
2280*cdf0e10cSrcweir 	const SvxWritingModeItem* pModeItem = dynamic_cast< const SvxWritingModeItem* >( &GetObjectItem( SDRATTR_TEXTDIRECTION ) );
2281*cdf0e10cSrcweir 	return pModeItem && pModeItem->GetValue() == com::sun::star::text::WritingMode_TB_RL;
2282*cdf0e10cSrcweir }
2283*cdf0e10cSrcweir 
2284*cdf0e10cSrcweir // --------------------------------------------------------------------
2285*cdf0e10cSrcweir 
2286*cdf0e10cSrcweir void SdrTableObj::SetVerticalWriting(sal_Bool bVertical )
2287*cdf0e10cSrcweir {
2288*cdf0e10cSrcweir 	if( bVertical != IsVerticalWriting() )
2289*cdf0e10cSrcweir 	{
2290*cdf0e10cSrcweir 		SvxWritingModeItem aModeItem( com::sun::star::text::WritingMode_LR_TB, SDRATTR_TEXTDIRECTION );
2291*cdf0e10cSrcweir 		SetObjectItem( aModeItem );
2292*cdf0e10cSrcweir 	}
2293*cdf0e10cSrcweir }
2294*cdf0e10cSrcweir 
2295*cdf0e10cSrcweir // --------------------------------------------------------------------
2296*cdf0e10cSrcweir 
2297*cdf0e10cSrcweir WritingMode SdrTableObj::GetWritingMode() const
2298*cdf0e10cSrcweir {
2299*cdf0e10cSrcweir 	WritingMode eMode = WritingMode_LR_TB;
2300*cdf0e10cSrcweir 	if( mpImpl && mpImpl->mpLayouter )
2301*cdf0e10cSrcweir 		eMode = mpImpl->mpLayouter->GetWritingMode();
2302*cdf0e10cSrcweir 	return eMode;
2303*cdf0e10cSrcweir }
2304*cdf0e10cSrcweir 
2305*cdf0e10cSrcweir // --------------------------------------------------------------------
2306*cdf0e10cSrcweir 
2307*cdf0e10cSrcweir // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
2308*cdf0e10cSrcweir // with the base geometry and returns TRUE. Otherwise it returns FALSE.
2309*cdf0e10cSrcweir sal_Bool SdrTableObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon ) const
2310*cdf0e10cSrcweir {
2311*cdf0e10cSrcweir 	return SdrTextObj::TRGetBaseGeometry( rMatrix, rPolyPolygon );
2312*cdf0e10cSrcweir }
2313*cdf0e10cSrcweir 
2314*cdf0e10cSrcweir // --------------------------------------------------------------------
2315*cdf0e10cSrcweir 
2316*cdf0e10cSrcweir // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
2317*cdf0e10cSrcweir // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
2318*cdf0e10cSrcweir // to use (0,0) as upper left and will be scaled to the given size in the matrix.
2319*cdf0e10cSrcweir void SdrTableObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon )
2320*cdf0e10cSrcweir {
2321*cdf0e10cSrcweir 	SdrTextObj::TRSetBaseGeometry( rMatrix, rPolyPolygon );
2322*cdf0e10cSrcweir }
2323*cdf0e10cSrcweir 
2324*cdf0e10cSrcweir // --------------------------------------------------------------------
2325*cdf0e10cSrcweir 
2326*cdf0e10cSrcweir bool SdrTableObj::IsRealyEdited() const
2327*cdf0e10cSrcweir {
2328*cdf0e10cSrcweir 	return pEdtOutl && pEdtOutl->IsModified();
2329*cdf0e10cSrcweir }
2330*cdf0e10cSrcweir 
2331*cdf0e10cSrcweir // --------------------------------------------------------------------
2332*cdf0e10cSrcweir 
2333*cdf0e10cSrcweir FASTBOOL SdrTableObj::IsFontwork() const
2334*cdf0e10cSrcweir {
2335*cdf0e10cSrcweir 	return sal_False;
2336*cdf0e10cSrcweir }
2337*cdf0e10cSrcweir 
2338*cdf0e10cSrcweir // --------------------------------------------------------------------
2339*cdf0e10cSrcweir 
2340*cdf0e10cSrcweir sal_uInt32 SdrTableObj::GetHdlCount() const
2341*cdf0e10cSrcweir {
2342*cdf0e10cSrcweir 	sal_uInt32 nCount = SdrTextObj::GetHdlCount();
2343*cdf0e10cSrcweir 	const sal_Int32 nRowCount = mpImpl->getRowCount();
2344*cdf0e10cSrcweir 	const sal_Int32 nColCount = mpImpl->getColumnCount();
2345*cdf0e10cSrcweir 
2346*cdf0e10cSrcweir 	if( nRowCount && nColCount )
2347*cdf0e10cSrcweir 		nCount += nRowCount + nColCount + 2 + 1;
2348*cdf0e10cSrcweir 
2349*cdf0e10cSrcweir 	return nCount;
2350*cdf0e10cSrcweir }
2351*cdf0e10cSrcweir 
2352*cdf0e10cSrcweir // --------------------------------------------------------------------
2353*cdf0e10cSrcweir 
2354*cdf0e10cSrcweir void SdrTableObj::AddToHdlList(SdrHdlList& rHdlList) const
2355*cdf0e10cSrcweir {
2356*cdf0e10cSrcweir 	const sal_Int32 nRowCount = mpImpl->getRowCount();
2357*cdf0e10cSrcweir 	const sal_Int32 nColCount = mpImpl->getColumnCount();
2358*cdf0e10cSrcweir 
2359*cdf0e10cSrcweir 	// first add row handles
2360*cdf0e10cSrcweir 	std::vector< TableEdgeHdl* > aRowEdges( nRowCount + 1 );
2361*cdf0e10cSrcweir 
2362*cdf0e10cSrcweir 	for( sal_Int32 nRow = 0; nRow <= nRowCount; nRow++ )
2363*cdf0e10cSrcweir 	{
2364*cdf0e10cSrcweir 		sal_Int32 nEdgeMin, nEdgeMax;
2365*cdf0e10cSrcweir 		const sal_Int32 nEdge = mpImpl->mpLayouter->getHorizontalEdge( nRow, &nEdgeMin, &nEdgeMax );
2366*cdf0e10cSrcweir 		nEdgeMin -= nEdge;
2367*cdf0e10cSrcweir 		nEdgeMax -= nEdge;
2368*cdf0e10cSrcweir 
2369*cdf0e10cSrcweir 		Point aPoint( aRect.TopLeft() );
2370*cdf0e10cSrcweir 		aPoint.Y() += nEdge;
2371*cdf0e10cSrcweir 
2372*cdf0e10cSrcweir 		TableEdgeHdl* pHdl= new TableEdgeHdl(aPoint,true,nEdgeMin,nEdgeMax,nColCount+1);
2373*cdf0e10cSrcweir 		pHdl->SetPointNum( nRow );
2374*cdf0e10cSrcweir 		rHdlList.AddHdl( pHdl );
2375*cdf0e10cSrcweir 		aRowEdges[nRow] = pHdl;
2376*cdf0e10cSrcweir 	}
2377*cdf0e10cSrcweir 
2378*cdf0e10cSrcweir 	// second add column handles
2379*cdf0e10cSrcweir 	std::vector< TableEdgeHdl* > aColEdges( nColCount + 1 );
2380*cdf0e10cSrcweir 
2381*cdf0e10cSrcweir 	for( sal_Int32 nCol = 0; nCol <= nColCount; nCol++ )
2382*cdf0e10cSrcweir 	{
2383*cdf0e10cSrcweir 		sal_Int32 nEdgeMin, nEdgeMax;
2384*cdf0e10cSrcweir 		const sal_Int32 nEdge = mpImpl->mpLayouter->getVerticalEdge( nCol, &nEdgeMin, &nEdgeMax );
2385*cdf0e10cSrcweir 		nEdgeMin -= nEdge;
2386*cdf0e10cSrcweir 		nEdgeMax -= nEdge;
2387*cdf0e10cSrcweir 
2388*cdf0e10cSrcweir 		Point aPoint( aRect.TopLeft() );
2389*cdf0e10cSrcweir 		aPoint.X() += nEdge;
2390*cdf0e10cSrcweir 
2391*cdf0e10cSrcweir 		TableEdgeHdl* pHdl = new TableEdgeHdl(aPoint,false,nEdgeMin,nEdgeMax, nRowCount+1);
2392*cdf0e10cSrcweir 		pHdl->SetPointNum( nCol );
2393*cdf0e10cSrcweir 		rHdlList.AddHdl( pHdl );
2394*cdf0e10cSrcweir 		aColEdges[nCol] = pHdl;
2395*cdf0e10cSrcweir 	}
2396*cdf0e10cSrcweir 
2397*cdf0e10cSrcweir 	// now add visible edges to row and column handles
2398*cdf0e10cSrcweir 	if( mpImpl && mpImpl->mpLayouter )
2399*cdf0e10cSrcweir 	{
2400*cdf0e10cSrcweir 		TableLayouter& rLayouter = *mpImpl->mpLayouter;
2401*cdf0e10cSrcweir 
2402*cdf0e10cSrcweir 		sal_Int32 nY = 0;
2403*cdf0e10cSrcweir 
2404*cdf0e10cSrcweir 		for( sal_Int32 nRow = 0; nRow <= nRowCount; ++nRow )
2405*cdf0e10cSrcweir 		{
2406*cdf0e10cSrcweir 			const sal_Int32 nRowHeight = (nRow == nRowCount) ? 0 : rLayouter.getRowHeight(nRow);
2407*cdf0e10cSrcweir 			sal_Int32 nX = 0;
2408*cdf0e10cSrcweir 
2409*cdf0e10cSrcweir 			for( sal_Int32 nCol = 0; nCol <= nColCount; ++nCol )
2410*cdf0e10cSrcweir 			{
2411*cdf0e10cSrcweir 				const sal_Int32 nColWidth = (nCol == nColCount) ? 0 : rLayouter.getColumnWidth(nCol);
2412*cdf0e10cSrcweir 
2413*cdf0e10cSrcweir 				if( nRowHeight > 0 )
2414*cdf0e10cSrcweir 				{
2415*cdf0e10cSrcweir 					if( rLayouter.isEdgeVisible( nCol, nRow, false ) )
2416*cdf0e10cSrcweir 						aColEdges[nCol]->SetEdge( nRow, nY, nY + nRowHeight, (rLayouter.getBorderLine( nCol, nRow, false ) == 0) ? Visible : Invisible);
2417*cdf0e10cSrcweir 				}
2418*cdf0e10cSrcweir 
2419*cdf0e10cSrcweir 				if( nColWidth > 0 )
2420*cdf0e10cSrcweir 				{
2421*cdf0e10cSrcweir 					if( rLayouter.isEdgeVisible( nCol, nRow, true ) )
2422*cdf0e10cSrcweir 						aRowEdges[nRow]->SetEdge( nCol, nX, nX + nColWidth, (rLayouter.getBorderLine( nCol, nRow, true ) == 0) ? Visible : Invisible);
2423*cdf0e10cSrcweir 				}
2424*cdf0e10cSrcweir 
2425*cdf0e10cSrcweir 				nX += nColWidth;
2426*cdf0e10cSrcweir 			}
2427*cdf0e10cSrcweir 
2428*cdf0e10cSrcweir 			nY += nRowHeight;
2429*cdf0e10cSrcweir 		}
2430*cdf0e10cSrcweir 	}
2431*cdf0e10cSrcweir 
2432*cdf0e10cSrcweir 	// add remaining handles
2433*cdf0e10cSrcweir 	SdrHdl* pH=0;
2434*cdf0e10cSrcweir 	rHdlList.AddHdl( pH = new TableBorderHdl( aRect ) ); pH->SetMoveOutside( true );
2435*cdf0e10cSrcweir 	rHdlList.AddHdl( pH = new SdrHdl(aRect.TopLeft(),HDL_UPLFT) ); pH->SetMoveOutside( true );
2436*cdf0e10cSrcweir 	rHdlList.AddHdl( pH = new SdrHdl(aRect.TopCenter(),HDL_UPPER) ); pH->SetMoveOutside( true );
2437*cdf0e10cSrcweir 	rHdlList.AddHdl( pH = new SdrHdl(aRect.TopRight(),HDL_UPRGT) ); pH->SetMoveOutside( true );
2438*cdf0e10cSrcweir 	rHdlList.AddHdl( pH = new SdrHdl(aRect.LeftCenter(),HDL_LEFT) ); pH->SetMoveOutside( true );
2439*cdf0e10cSrcweir 	rHdlList.AddHdl( pH = new SdrHdl(aRect.RightCenter(),HDL_RIGHT) ); pH->SetMoveOutside( true );
2440*cdf0e10cSrcweir 	rHdlList.AddHdl( pH = new SdrHdl(aRect.BottomLeft(),HDL_LWLFT) ); pH->SetMoveOutside( true );
2441*cdf0e10cSrcweir 	rHdlList.AddHdl( pH = new SdrHdl(aRect.BottomCenter(),HDL_LOWER) ); pH->SetMoveOutside( true );
2442*cdf0e10cSrcweir 	rHdlList.AddHdl( pH = new SdrHdl(aRect.BottomRight(),HDL_LWRGT) ); pH->SetMoveOutside( true );
2443*cdf0e10cSrcweir 
2444*cdf0e10cSrcweir 	sal_uIntPtr nHdlCount = rHdlList.GetHdlCount();
2445*cdf0e10cSrcweir 	for( sal_uIntPtr nHdl = 0; nHdl < nHdlCount; nHdl++ )
2446*cdf0e10cSrcweir 		rHdlList.GetHdl(nHdl)->SetObj((SdrObject*)this);
2447*cdf0e10cSrcweir }
2448*cdf0e10cSrcweir 
2449*cdf0e10cSrcweir // --------------------------------------------------------------------
2450*cdf0e10cSrcweir 
2451*cdf0e10cSrcweir SdrHdl* SdrTableObj::GetHdl(sal_uInt32 nHdlNum) const
2452*cdf0e10cSrcweir {
2453*cdf0e10cSrcweir 	// #i73248#
2454*cdf0e10cSrcweir 	// Warn the user that this is ineffective and show alternatives. Should not be used at all.
2455*cdf0e10cSrcweir 	OSL_ENSURE(false, "SdrTableObj::GetHdl(): ineffective, use AddToHdlList instead (!)");
2456*cdf0e10cSrcweir 
2457*cdf0e10cSrcweir 	// to have an alternative, get single handle using the ineffective way
2458*cdf0e10cSrcweir 	SdrHdl* pRetval = 0;
2459*cdf0e10cSrcweir 	SdrHdlList aLocalList(0);
2460*cdf0e10cSrcweir 	AddToHdlList(aLocalList);
2461*cdf0e10cSrcweir 	const sal_uInt32 nHdlCount(aLocalList.GetHdlCount());
2462*cdf0e10cSrcweir 
2463*cdf0e10cSrcweir 	if(nHdlCount && nHdlNum < nHdlCount)
2464*cdf0e10cSrcweir 	{
2465*cdf0e10cSrcweir 		// remove and remember. The other created handles will be deleted again with the
2466*cdf0e10cSrcweir 		// destruction of the local list
2467*cdf0e10cSrcweir 		pRetval = aLocalList.RemoveHdl(nHdlNum);
2468*cdf0e10cSrcweir 	}
2469*cdf0e10cSrcweir 
2470*cdf0e10cSrcweir 	return pRetval;
2471*cdf0e10cSrcweir }
2472*cdf0e10cSrcweir 
2473*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2474*cdf0e10cSrcweir // Draging
2475*cdf0e10cSrcweir 
2476*cdf0e10cSrcweir bool SdrTableObj::hasSpecialDrag() const
2477*cdf0e10cSrcweir {
2478*cdf0e10cSrcweir 	return true;
2479*cdf0e10cSrcweir }
2480*cdf0e10cSrcweir 
2481*cdf0e10cSrcweir bool SdrTableObj::beginSpecialDrag(SdrDragStat& rDrag) const
2482*cdf0e10cSrcweir {
2483*cdf0e10cSrcweir 	const SdrHdl* pHdl = rDrag.GetHdl();
2484*cdf0e10cSrcweir 	const SdrHdlKind eHdl((pHdl == NULL) ? HDL_MOVE : pHdl->GetKind());
2485*cdf0e10cSrcweir 
2486*cdf0e10cSrcweir     switch( eHdl )
2487*cdf0e10cSrcweir 	{
2488*cdf0e10cSrcweir 	    case HDL_UPLFT:
2489*cdf0e10cSrcweir 	    case HDL_UPPER:
2490*cdf0e10cSrcweir 	    case HDL_UPRGT:
2491*cdf0e10cSrcweir 	    case HDL_LEFT:
2492*cdf0e10cSrcweir 	    case HDL_RIGHT:
2493*cdf0e10cSrcweir 	    case HDL_LWLFT:
2494*cdf0e10cSrcweir 	    case HDL_LOWER:
2495*cdf0e10cSrcweir 	    case HDL_LWRGT:
2496*cdf0e10cSrcweir 	    case HDL_MOVE:
2497*cdf0e10cSrcweir         {
2498*cdf0e10cSrcweir 		    break;
2499*cdf0e10cSrcweir         }
2500*cdf0e10cSrcweir 
2501*cdf0e10cSrcweir 	    case HDL_USER:
2502*cdf0e10cSrcweir         {
2503*cdf0e10cSrcweir 		    rDrag.SetEndDragChangesAttributes(false);
2504*cdf0e10cSrcweir 		    rDrag.SetNoSnap(true);
2505*cdf0e10cSrcweir 		    break;
2506*cdf0e10cSrcweir         }
2507*cdf0e10cSrcweir 
2508*cdf0e10cSrcweir 	    default:
2509*cdf0e10cSrcweir         {
2510*cdf0e10cSrcweir 		    return false;
2511*cdf0e10cSrcweir         }
2512*cdf0e10cSrcweir 	}
2513*cdf0e10cSrcweir 
2514*cdf0e10cSrcweir 	return true;
2515*cdf0e10cSrcweir }
2516*cdf0e10cSrcweir 
2517*cdf0e10cSrcweir bool SdrTableObj::applySpecialDrag(SdrDragStat& rDrag)
2518*cdf0e10cSrcweir {
2519*cdf0e10cSrcweir 	bool bRet(true);
2520*cdf0e10cSrcweir 	const SdrHdl* pHdl = rDrag.GetHdl();
2521*cdf0e10cSrcweir 	const SdrHdlKind eHdl((pHdl == NULL) ? HDL_MOVE : pHdl->GetKind());
2522*cdf0e10cSrcweir 
2523*cdf0e10cSrcweir 	switch( eHdl )
2524*cdf0e10cSrcweir 	{
2525*cdf0e10cSrcweir 	    case HDL_UPLFT:
2526*cdf0e10cSrcweir 	    case HDL_UPPER:
2527*cdf0e10cSrcweir 	    case HDL_UPRGT:
2528*cdf0e10cSrcweir 	    case HDL_LEFT:
2529*cdf0e10cSrcweir 	    case HDL_RIGHT:
2530*cdf0e10cSrcweir 	    case HDL_LWLFT:
2531*cdf0e10cSrcweir 	    case HDL_LOWER:
2532*cdf0e10cSrcweir 	    case HDL_LWRGT:
2533*cdf0e10cSrcweir         {
2534*cdf0e10cSrcweir     		const Rectangle aNewRectangle(ImpDragCalcRect(rDrag));
2535*cdf0e10cSrcweir 
2536*cdf0e10cSrcweir             if(aNewRectangle != aRect)
2537*cdf0e10cSrcweir             {
2538*cdf0e10cSrcweir    			    NbcSetLogicRect(aNewRectangle);
2539*cdf0e10cSrcweir             }
2540*cdf0e10cSrcweir 
2541*cdf0e10cSrcweir 		    break;
2542*cdf0e10cSrcweir         }
2543*cdf0e10cSrcweir 
2544*cdf0e10cSrcweir 	    case HDL_MOVE:
2545*cdf0e10cSrcweir         {
2546*cdf0e10cSrcweir    		    NbcMove( Size( rDrag.GetDX(), rDrag.GetDY() ) );
2547*cdf0e10cSrcweir             break;
2548*cdf0e10cSrcweir         }
2549*cdf0e10cSrcweir 
2550*cdf0e10cSrcweir 	    case HDL_USER:
2551*cdf0e10cSrcweir 	    {
2552*cdf0e10cSrcweir 		    rDrag.SetEndDragChangesAttributes(false);
2553*cdf0e10cSrcweir 		    rDrag.SetNoSnap(true);
2554*cdf0e10cSrcweir             const TableEdgeHdl* pEdgeHdl = dynamic_cast< const TableEdgeHdl* >( pHdl );
2555*cdf0e10cSrcweir 
2556*cdf0e10cSrcweir             if( pEdgeHdl )
2557*cdf0e10cSrcweir 		    {
2558*cdf0e10cSrcweir 			    if( GetModel() && IsInserted() )
2559*cdf0e10cSrcweir                 {
2560*cdf0e10cSrcweir                     rDrag.SetEndDragChangesAttributes(true);
2561*cdf0e10cSrcweir                 }
2562*cdf0e10cSrcweir 
2563*cdf0e10cSrcweir 			    mpImpl->DragEdge( pEdgeHdl->IsHorizontalEdge(), pEdgeHdl->GetPointNum(), pEdgeHdl->GetValidDragOffset( rDrag ) );
2564*cdf0e10cSrcweir 		    }
2565*cdf0e10cSrcweir 		    break;
2566*cdf0e10cSrcweir 	    }
2567*cdf0e10cSrcweir 
2568*cdf0e10cSrcweir 	    default:
2569*cdf0e10cSrcweir 	    {
2570*cdf0e10cSrcweir 		    bRet = false;
2571*cdf0e10cSrcweir         }
2572*cdf0e10cSrcweir 	}
2573*cdf0e10cSrcweir 
2574*cdf0e10cSrcweir 	return bRet;
2575*cdf0e10cSrcweir }
2576*cdf0e10cSrcweir 
2577*cdf0e10cSrcweir String SdrTableObj::getSpecialDragComment(const SdrDragStat& rDrag) const
2578*cdf0e10cSrcweir {
2579*cdf0e10cSrcweir 	return SdrTextObj::getSpecialDragComment( rDrag );
2580*cdf0e10cSrcweir }
2581*cdf0e10cSrcweir 
2582*cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrTableObj::getSpecialDragPoly(const SdrDragStat& rDrag) const
2583*cdf0e10cSrcweir {
2584*cdf0e10cSrcweir 	basegfx::B2DPolyPolygon aRetval;
2585*cdf0e10cSrcweir 	const SdrHdl* pHdl = rDrag.GetHdl();
2586*cdf0e10cSrcweir 
2587*cdf0e10cSrcweir     if( pHdl && (HDL_USER == pHdl->GetKind()) )
2588*cdf0e10cSrcweir     {
2589*cdf0e10cSrcweir 		const TableEdgeHdl* pEdgeHdl = dynamic_cast< const TableEdgeHdl* >( pHdl );
2590*cdf0e10cSrcweir 
2591*cdf0e10cSrcweir         if( pEdgeHdl )
2592*cdf0e10cSrcweir         {
2593*cdf0e10cSrcweir 			aRetval = pEdgeHdl->getSpecialDragPoly( rDrag );
2594*cdf0e10cSrcweir         }
2595*cdf0e10cSrcweir     }
2596*cdf0e10cSrcweir 
2597*cdf0e10cSrcweir     return aRetval;
2598*cdf0e10cSrcweir }
2599*cdf0e10cSrcweir 
2600*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2601*cdf0e10cSrcweir // Create
2602*cdf0e10cSrcweir // --------------------------------------------------------------------
2603*cdf0e10cSrcweir 
2604*cdf0e10cSrcweir FASTBOOL SdrTableObj::BegCreate(SdrDragStat& rStat)
2605*cdf0e10cSrcweir {
2606*cdf0e10cSrcweir 	rStat.SetOrtho4Possible();
2607*cdf0e10cSrcweir     Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
2608*cdf0e10cSrcweir 	aRect1.Justify();
2609*cdf0e10cSrcweir 	rStat.SetActionRect(aRect1);
2610*cdf0e10cSrcweir 	aRect = aRect1;
2611*cdf0e10cSrcweir 	return sal_True;
2612*cdf0e10cSrcweir }
2613*cdf0e10cSrcweir 
2614*cdf0e10cSrcweir // --------------------------------------------------------------------
2615*cdf0e10cSrcweir 
2616*cdf0e10cSrcweir FASTBOOL SdrTableObj::MovCreate(SdrDragStat& rStat)
2617*cdf0e10cSrcweir {
2618*cdf0e10cSrcweir 	Rectangle aRect1;
2619*cdf0e10cSrcweir 	rStat.TakeCreateRect(aRect1);
2620*cdf0e10cSrcweir 	ImpJustifyRect(aRect1);
2621*cdf0e10cSrcweir 	rStat.SetActionRect(aRect1);
2622*cdf0e10cSrcweir 	aRect=aRect1; // fuer ObjName
2623*cdf0e10cSrcweir 	SetBoundRectDirty();
2624*cdf0e10cSrcweir 	bSnapRectDirty=sal_True;
2625*cdf0e10cSrcweir 	return sal_True;
2626*cdf0e10cSrcweir }
2627*cdf0e10cSrcweir 
2628*cdf0e10cSrcweir // --------------------------------------------------------------------
2629*cdf0e10cSrcweir 
2630*cdf0e10cSrcweir FASTBOOL SdrTableObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
2631*cdf0e10cSrcweir {
2632*cdf0e10cSrcweir 	rStat.TakeCreateRect(aRect);
2633*cdf0e10cSrcweir 	ImpJustifyRect(aRect);
2634*cdf0e10cSrcweir 	return (eCmd==SDRCREATE_FORCEEND || rStat.GetPointAnz()>=2);
2635*cdf0e10cSrcweir }
2636*cdf0e10cSrcweir 
2637*cdf0e10cSrcweir void SdrTableObj::BrkCreate(SdrDragStat& /*rStat*/)
2638*cdf0e10cSrcweir {
2639*cdf0e10cSrcweir }
2640*cdf0e10cSrcweir 
2641*cdf0e10cSrcweir // --------------------------------------------------------------------
2642*cdf0e10cSrcweir 
2643*cdf0e10cSrcweir FASTBOOL SdrTableObj::BckCreate(SdrDragStat& /*rStat*/)
2644*cdf0e10cSrcweir {
2645*cdf0e10cSrcweir 	return sal_True;
2646*cdf0e10cSrcweir }
2647*cdf0e10cSrcweir 
2648*cdf0e10cSrcweir // --------------------------------------------------------------------
2649*cdf0e10cSrcweir 
2650*cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrTableObj::TakeCreatePoly(const SdrDragStat& rDrag) const
2651*cdf0e10cSrcweir {
2652*cdf0e10cSrcweir 	Rectangle aRect1;
2653*cdf0e10cSrcweir 	rDrag.TakeCreateRect(aRect1);
2654*cdf0e10cSrcweir 	aRect1.Justify();
2655*cdf0e10cSrcweir 
2656*cdf0e10cSrcweir 	basegfx::B2DPolyPolygon aRetval;
2657*cdf0e10cSrcweir 	const basegfx::B2DRange aRange(aRect1.Left(), aRect1.Top(), aRect1.Right(), aRect1.Bottom());
2658*cdf0e10cSrcweir 	aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
2659*cdf0e10cSrcweir 	return aRetval;
2660*cdf0e10cSrcweir }
2661*cdf0e10cSrcweir 
2662*cdf0e10cSrcweir // --------------------------------------------------------------------
2663*cdf0e10cSrcweir 
2664*cdf0e10cSrcweir Pointer SdrTableObj::GetCreatePointer() const
2665*cdf0e10cSrcweir {
2666*cdf0e10cSrcweir 	return Pointer(POINTER_CROSS);
2667*cdf0e10cSrcweir }
2668*cdf0e10cSrcweir 
2669*cdf0e10cSrcweir // --------------------------------------------------------------------
2670*cdf0e10cSrcweir 
2671*cdf0e10cSrcweir void SdrTableObj::createCell( CellRef& xNewCell )
2672*cdf0e10cSrcweir {
2673*cdf0e10cSrcweir     xNewCell = Cell::create( *this, 0 );
2674*cdf0e10cSrcweir }
2675*cdf0e10cSrcweir 
2676*cdf0e10cSrcweir // --------------------------------------------------------------------
2677*cdf0e10cSrcweir 
2678*cdf0e10cSrcweir SdrObjGeoData *SdrTableObj::NewGeoData() const
2679*cdf0e10cSrcweir {
2680*cdf0e10cSrcweir 	return new TableObjectGeoData;
2681*cdf0e10cSrcweir }
2682*cdf0e10cSrcweir 
2683*cdf0e10cSrcweir // --------------------------------------------------------------------
2684*cdf0e10cSrcweir 
2685*cdf0e10cSrcweir void SdrTableObj::SaveGeoData(SdrObjGeoData& rGeo) const
2686*cdf0e10cSrcweir {
2687*cdf0e10cSrcweir 	DBG_ASSERT( dynamic_cast< TableObjectGeoData* >( &rGeo ), "svx::SdrTableObj::SaveGeoData(), illegal geo data!" );
2688*cdf0e10cSrcweir 	SdrTextObj::SaveGeoData (rGeo);
2689*cdf0e10cSrcweir 
2690*cdf0e10cSrcweir 	((TableObjectGeoData &) rGeo).maLogicRect = maLogicRect;
2691*cdf0e10cSrcweir }
2692*cdf0e10cSrcweir 
2693*cdf0e10cSrcweir // --------------------------------------------------------------------
2694*cdf0e10cSrcweir 
2695*cdf0e10cSrcweir void SdrTableObj::RestGeoData(const SdrObjGeoData& rGeo)
2696*cdf0e10cSrcweir {
2697*cdf0e10cSrcweir 	DBG_ASSERT( dynamic_cast< const TableObjectGeoData* >( &rGeo ), "svx::SdrTableObj::SaveGeoData(), illegal geo data!" );
2698*cdf0e10cSrcweir 
2699*cdf0e10cSrcweir 	maLogicRect = ((TableObjectGeoData &) rGeo).maLogicRect;
2700*cdf0e10cSrcweir 
2701*cdf0e10cSrcweir 	SdrTextObj::RestGeoData (rGeo);
2702*cdf0e10cSrcweir 
2703*cdf0e10cSrcweir 	if( mpImpl )
2704*cdf0e10cSrcweir 		mpImpl->LayoutTable( aRect, false, false );
2705*cdf0e10cSrcweir 	ActionChanged();
2706*cdf0e10cSrcweir }
2707*cdf0e10cSrcweir 
2708*cdf0e10cSrcweir // --------------------------------------------------------------------
2709*cdf0e10cSrcweir 
2710*cdf0e10cSrcweir SdrTableObj* SdrTableObj::CloneRange( const CellPos& rStart, const CellPos& rEnd )
2711*cdf0e10cSrcweir {
2712*cdf0e10cSrcweir 	const sal_Int32 nColumns = rEnd.mnCol - rStart.mnCol + 1;
2713*cdf0e10cSrcweir 	const sal_Int32 nRows = rEnd.mnRow - rStart.mnRow + 1;
2714*cdf0e10cSrcweir 
2715*cdf0e10cSrcweir 	SdrTableObj* pNewTableObj = new SdrTableObj( GetModel(), GetCurrentBoundRect(), nColumns, nRows);
2716*cdf0e10cSrcweir 	pNewTableObj->setTableStyleSettings( getTableStyleSettings() );
2717*cdf0e10cSrcweir 	pNewTableObj->setTableStyle( getTableStyle() );
2718*cdf0e10cSrcweir 
2719*cdf0e10cSrcweir 	Reference< XTable > xTable( getTable() );
2720*cdf0e10cSrcweir 	Reference< XTable > xNewTable( pNewTableObj->getTable() );
2721*cdf0e10cSrcweir 
2722*cdf0e10cSrcweir 	if( !xTable.is() || !xNewTable.is() )
2723*cdf0e10cSrcweir 	{
2724*cdf0e10cSrcweir 		delete pNewTableObj;
2725*cdf0e10cSrcweir 		return 0;
2726*cdf0e10cSrcweir 	}
2727*cdf0e10cSrcweir 
2728*cdf0e10cSrcweir 	// copy cells
2729*cdf0e10cSrcweir 	for( sal_Int32 nRow = 0; nRow < nRows; ++nRow )
2730*cdf0e10cSrcweir 	{
2731*cdf0e10cSrcweir 		for( sal_Int32 nCol = 0; nCol < nColumns; ++nCol ) try
2732*cdf0e10cSrcweir 		{
2733*cdf0e10cSrcweir 			CellRef xTargetCell( dynamic_cast< Cell* >( xNewTable->getCellByPosition( nCol, nRow ).get() ) );
2734*cdf0e10cSrcweir 			if( xTargetCell.is() )
2735*cdf0e10cSrcweir 				xTargetCell->cloneFrom( dynamic_cast< Cell* >( xTable->getCellByPosition( rStart.mnCol + nCol, rStart.mnRow + nRow ).get() ) );
2736*cdf0e10cSrcweir 		}
2737*cdf0e10cSrcweir 		catch( Exception& )
2738*cdf0e10cSrcweir 		{
2739*cdf0e10cSrcweir 			DBG_ERROR( "svx::SvxTableController::GetMarkedObjModel(), exception caught!" );
2740*cdf0e10cSrcweir 		}
2741*cdf0e10cSrcweir 	}
2742*cdf0e10cSrcweir 
2743*cdf0e10cSrcweir 	// copy row heights
2744*cdf0e10cSrcweir 	Reference< XTableRows > xNewRows( xNewTable->getRows(), UNO_QUERY_THROW );
2745*cdf0e10cSrcweir 	const OUString sHeight( RTL_CONSTASCII_USTRINGPARAM( "Height" ) );
2746*cdf0e10cSrcweir 	for( sal_Int32 nRow = 0; nRow < nRows; ++nRow )
2747*cdf0e10cSrcweir 	{
2748*cdf0e10cSrcweir 		Reference< XPropertySet > xNewSet( xNewRows->getByIndex( nRow ), UNO_QUERY_THROW );
2749*cdf0e10cSrcweir 		xNewSet->setPropertyValue( sHeight, Any( mpImpl->mpLayouter->getRowHeight( rStart.mnRow + nRow ) ) );
2750*cdf0e10cSrcweir 	}
2751*cdf0e10cSrcweir 
2752*cdf0e10cSrcweir 	// copy column widths
2753*cdf0e10cSrcweir 	Reference< XTableColumns > xNewColumns( xNewTable->getColumns(), UNO_QUERY_THROW );
2754*cdf0e10cSrcweir 	const OUString sWidth( RTL_CONSTASCII_USTRINGPARAM( "Width" ) );
2755*cdf0e10cSrcweir 	for( sal_Int32 nCol = 0; nCol < nColumns; ++nCol )
2756*cdf0e10cSrcweir 	{
2757*cdf0e10cSrcweir 		Reference< XPropertySet > xNewSet( xNewColumns->getByIndex( nCol ), UNO_QUERY_THROW );
2758*cdf0e10cSrcweir 		xNewSet->setPropertyValue( sWidth, Any( mpImpl->mpLayouter->getColumnWidth( rStart.mnCol + nCol ) ) );
2759*cdf0e10cSrcweir 	}
2760*cdf0e10cSrcweir 
2761*cdf0e10cSrcweir 	pNewTableObj->NbcReformatText();
2762*cdf0e10cSrcweir 	pNewTableObj->SetLogicRect( pNewTableObj->GetCurrentBoundRect() );
2763*cdf0e10cSrcweir 
2764*cdf0e10cSrcweir 	return pNewTableObj;
2765*cdf0e10cSrcweir }
2766*cdf0e10cSrcweir 
2767*cdf0e10cSrcweir // --------------------------------------------------------------------
2768*cdf0e10cSrcweir 
2769*cdf0e10cSrcweir void SdrTableObj::DistributeColumns( sal_Int32 nFirstColumn, sal_Int32 nLastColumn )
2770*cdf0e10cSrcweir {
2771*cdf0e10cSrcweir 	if( mpImpl && mpImpl->mpLayouter )
2772*cdf0e10cSrcweir 	{
2773*cdf0e10cSrcweir 		TableModelNotifyGuard aGuard( mpImpl->mxTable.get() );
2774*cdf0e10cSrcweir 		mpImpl->mpLayouter->DistributeColumns( aRect, nFirstColumn, nLastColumn );
2775*cdf0e10cSrcweir 	}
2776*cdf0e10cSrcweir }
2777*cdf0e10cSrcweir 
2778*cdf0e10cSrcweir // --------------------------------------------------------------------
2779*cdf0e10cSrcweir 
2780*cdf0e10cSrcweir void SdrTableObj::DistributeRows( sal_Int32 nFirstRow, sal_Int32 nLastRow )
2781*cdf0e10cSrcweir {
2782*cdf0e10cSrcweir 	if( mpImpl && mpImpl->mpLayouter )
2783*cdf0e10cSrcweir 	{
2784*cdf0e10cSrcweir 		TableModelNotifyGuard aGuard( mpImpl->mxTable.get() );
2785*cdf0e10cSrcweir 		mpImpl->mpLayouter->DistributeRows( aRect, nFirstRow, nLastRow );
2786*cdf0e10cSrcweir 	}
2787*cdf0e10cSrcweir }
2788*cdf0e10cSrcweir 
2789*cdf0e10cSrcweir // --------------------------------------------------------------------
2790*cdf0e10cSrcweir 
2791*cdf0e10cSrcweir void SdrTableObj::SetChanged()
2792*cdf0e10cSrcweir {
2793*cdf0e10cSrcweir 	if( mpImpl )
2794*cdf0e10cSrcweir 	{
2795*cdf0e10cSrcweir 		if( mpImpl->UpdateWritingMode() )
2796*cdf0e10cSrcweir 			mpImpl->LayoutTable( aRect, false, false );
2797*cdf0e10cSrcweir 	}
2798*cdf0e10cSrcweir 
2799*cdf0e10cSrcweir 	::SdrTextObj::SetChanged();
2800*cdf0e10cSrcweir }
2801*cdf0e10cSrcweir 
2802*cdf0e10cSrcweir // --------------------------------------------------------------------
2803*cdf0e10cSrcweir 
2804*cdf0e10cSrcweir void SdrTableObj::uno_lock()
2805*cdf0e10cSrcweir {
2806*cdf0e10cSrcweir 	if( mpImpl && mpImpl->mxTable.is() )
2807*cdf0e10cSrcweir 		mpImpl->mxTable->lockBroadcasts();
2808*cdf0e10cSrcweir }
2809*cdf0e10cSrcweir 
2810*cdf0e10cSrcweir // --------------------------------------------------------------------
2811*cdf0e10cSrcweir 
2812*cdf0e10cSrcweir void SdrTableObj::uno_unlock()
2813*cdf0e10cSrcweir {
2814*cdf0e10cSrcweir 	if( mpImpl && mpImpl->mxTable.is() )
2815*cdf0e10cSrcweir 		mpImpl->mxTable->unlockBroadcasts();
2816*cdf0e10cSrcweir }
2817*cdf0e10cSrcweir 
2818*cdf0e10cSrcweir // --------------------------------------------------------------------
2819*cdf0e10cSrcweir 
2820*cdf0e10cSrcweir 
2821*cdf0e10cSrcweir 
2822*cdf0e10cSrcweir } }
2823