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