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