LibreOffice Module svx (master)  1
svdotable.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <memory>
21 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
22 #include <com/sun/star/container/XNamed.hpp>
23 #include <com/sun/star/container/XNameAccess.hpp>
24 #include <com/sun/star/container/XIndexAccess.hpp>
25 #include <unotools/configmgr.hxx>
26 #include <vcl/canvastools.hxx>
27 #include <vcl/ptrstyle.hxx>
28 #include <com/sun/star/style/XStyle.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include <svl/style.hxx>
34 #include <editeng/editstat.hxx>
35 #include <editeng/outlobj.hxx>
36 #include <svx/svdview.hxx>
38 #include <svx/svdotable.hxx>
39 #include <svx/svdhdl.hxx>
41 #include <svx/svdoutl.hxx>
42 #include <svx/svddrag.hxx>
43 #include <svx/svdpagv.hxx>
44 #include <tablemodel.hxx>
45 #include <cell.hxx>
46 #include <svx/xflclit.hxx>
47 #include "tablelayouter.hxx"
48 #include <svx/svdetc.hxx>
49 #include "tablehandles.hxx"
50 #include <editeng/boxitem.hxx>
51 #include <svx/framelink.hxx>
53 #include <svx/svdundo.hxx>
54 #include <svx/strings.hrc>
55 #include <svx/dialmgr.hxx>
57 #include <editeng/frmdiritem.hxx>
58 #include <svx/xflhtit.hxx>
59 #include <svx/xflftrit.hxx>
60 #include <svx/xfltrit.hxx>
61 #include <cppuhelper/implbase.hxx>
62 #include <libxml/xmlwriter.h>
63 
64 #include <boost/property_tree/json_parser.hpp>
65 
66 using ::com::sun::star::uno::Any;
67 using ::com::sun::star::uno::Reference;
68 using ::com::sun::star::uno::UNO_QUERY;
69 using ::com::sun::star::uno::UNO_QUERY_THROW;
70 using ::com::sun::star::uno::Exception;
71 using ::com::sun::star::container::XIndexAccess;
72 using ::com::sun::star::style::XStyle;
73 using ::com::sun::star::table::XTableRows;
74 using ::com::sun::star::table::XTableColumns;
75 using ::com::sun::star::table::XTable;
77 using ::com::sun::star::util::XModifyBroadcaster;
80 using namespace ::com::sun::star;
81 using namespace ::com::sun::star::text;
82 using namespace ::com::sun::star::container;
83 using namespace ::com::sun::star::style;
84 
85 namespace sdr { namespace table {
86 
87 namespace {
88 
89 class TableProperties : public TextProperties
90 {
91 protected:
92  // create a new itemset
93  std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
94 
95 public:
96  // basic constructor
97  explicit TableProperties(SdrObject& rObj );
98 
99  // constructor for copying, but using new object
100  TableProperties(const TableProperties& rProps, SdrObject& rObj );
101 
102  // Clone() operator, normally just calls the local copy constructor
103  std::unique_ptr<BaseProperties> Clone(SdrObject& rObj) const override;
104 
105  virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) override;
106 };
107 
108 }
109 
110 TableProperties::TableProperties(SdrObject& rObj)
111 : TextProperties(rObj)
112 {
113 }
114 
115 TableProperties::TableProperties(const TableProperties& rProps, SdrObject& rObj)
116 : TextProperties(rProps, rObj)
117 {
118 }
119 
120 std::unique_ptr<BaseProperties> TableProperties::Clone(SdrObject& rObj) const
121 {
122  return std::unique_ptr<BaseProperties>(new TableProperties(*this, rObj));
123 }
124 
125 void TableProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
126 {
127  if( nWhich == SDRATTR_TEXTDIRECTION )
128  AttributeProperties::ItemChange( nWhich, pNewItem );
129  else
130  TextProperties::ItemChange( nWhich, pNewItem );
131 }
132 
133 // create a new itemset
134 std::unique_ptr<SfxItemSet> TableProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
135 {
136  return std::make_unique<SfxItemSet>(rPool,
137 
138  // range from SdrAttrObj
142 
143  // range for SdrTableObj
145 
146  // range from SdrTextObj
148 }
149 
150 namespace {
151 
152 class TableObjectGeoData : public SdrTextObjGeoData
153 {
154 public:
156 };
157 
158 }
159 
160 TableStyleSettings::TableStyleSettings()
161 : mbUseFirstRow(true)
162 , mbUseLastRow(false)
163 , mbUseFirstColumn(false)
164 , mbUseLastColumn(false)
165 , mbUseRowBanding(true)
166 , mbUseColumnBanding(false)
167 {
168 }
169 
171 {
172  (*this) = rStyle;
173 }
174 
176 {
177  mbUseFirstRow = rStyle.mbUseFirstRow;
178  mbUseLastRow = rStyle.mbUseLastRow;
183  return *this;
184 }
185 
187 {
188  return
189  (mbUseFirstRow == rStyle.mbUseFirstRow) &&
190  (mbUseLastRow == rStyle.mbUseLastRow) &&
191  (mbUseFirstColumn == rStyle.mbUseFirstColumn) &&
192  (mbUseLastColumn == rStyle.mbUseLastColumn) &&
193  (mbUseRowBanding == rStyle.mbUseRowBanding) &&
195 }
196 
197 
198 class SdrTableObjImpl : public TableDesignUser, public ::cppu::WeakImplHelper< css::util::XModifyListener >
199 {
200 public:
204  std::unique_ptr<TableLayouter> mpLayouter;
207  Reference< XIndexAccess > mxTableStyle;
208  std::vector<std::unique_ptr<SdrUndoAction>> maUndos;
210 
211  void CropTableModelToSelection(const CellPos& rStart, const CellPos& rEnd);
212 
213  CellRef getCell( const CellPos& rPos ) const;
214  void LayoutTable( tools::Rectangle& rArea, bool bFitWidth, bool bFitHeight );
215 
216  void ApplyCellStyles();
217  void UpdateCells( tools::Rectangle const & rArea );
218 
219  SdrTableObjImpl();
220  virtual ~SdrTableObjImpl() override;
221 
222  void init( SdrTableObj* pTable, sal_Int32 nColumns, sal_Int32 nRows );
223  void dispose();
224 
225  sal_Int32 getColumnCount() const;
227  std::vector<sal_Int32> getColumnWidths() const;
228  sal_Int32 getRowCount() const;
229 
230  void DragEdge( bool mbHorizontal, int nEdge, sal_Int32 nOffset );
231 
232  SdrTableObjImpl& operator=( const SdrTableObjImpl& rSource );
233 
234  // XModifyListener
235  virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
236 
237  // XEventListener
238  virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
239 
240  void update();
241 
242  void connectTableStyle();
243  void disconnectTableStyle();
244  virtual bool isInUse() override;
245  void dumpAsXml(xmlTextWriterPtr pWriter) const;
246 private:
250  static bool lastLayoutFitWidth;
251  static bool lastLayoutFitHeight;
253  static sal_Int32 lastRowCount;
254  static sal_Int32 lastColCount;
255  static std::vector<sal_Int32> lastColWidths;
256 };
257 
266 std::vector<sal_Int32> SdrTableObjImpl::lastColWidths;
267 
269 : mpTableObj( nullptr )
270 , mbSkipChangeLayout(false)
271 {
272 }
273 
274 
276 {
277  if( lastLayoutTable == this )
278  lastLayoutTable = nullptr;
279 }
280 
281 
283 {
284  if(!mxTable.is())
285  {
286  return;
287  }
288 
289  const sal_Int32 nColumns(rEnd.mnCol - rStart.mnCol + 1);
290  const sal_Int32 nRows(rEnd.mnRow - rStart.mnRow + 1);
291 
292  if(nColumns < 1 || nRows < 1 || nColumns > getColumnCount() || nRows > getRowCount())
293  {
294  return;
295  }
296 
297  // tdf#116977 First thought was to create the new TableModel, copy data to it and then exchange
298  // mxTable and dispose old one. This does *not* work, even when all stuff looks nicely referenced
299  // and safe *because* Cell::create gets handed over the current SdrTableObj, hands it to
300  // ::Cell and there the local mxTable is initialized using rTableObj.getTable() (!). Due to This,
301  // the new created Cells in a new created TableModel based on given mpTableObj *will be disposed*
302  // when the old mxTable gets disposed - ARGH!
303  // To avoid, change strategy: Remember old TableModel, reset mxTable immediately - this is the
304  // SdrTableObjImpl of the current SdrTableObj anyways. Luckily, this works as intended...
305 
306  // remember old TableModel
307  TableModelRef xOldTable(mxTable);
308 
309  // immediately create new one and initialize. This creates ::Cell's which then will use
310  // the correct TableModel (accessed through SdrTableObj, but using local mxTable)
312  mxTable->init(nColumns, nRows);
313 
314  // copy cells
315  for( sal_Int32 nRow = 0; nRow < nRows; ++nRow )
316  {
317  for( sal_Int32 nCol = 0; nCol < nColumns; ++nCol ) try
318  {
319  CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
320  if( xTargetCell.is() )
321  xTargetCell->cloneFrom( dynamic_cast< Cell* >( xOldTable->getCellByPosition( rStart.mnCol + nCol, rStart.mnRow + nRow ).get() ) );
322  }
323  catch( Exception& )
324  {
325  OSL_FAIL( "SdrTableObj::CropTableModelToSelection(), exception caught!" );
326  }
327  }
328 
329  // copy row heights
330  Reference< XTableRows > xNewRows(mxTable->getRows(), css::uno::UNO_SET_THROW );
331  const OUString sHeight( "Height" );
332  for( sal_Int32 nRow = 0; nRow < nRows; ++nRow )
333  {
334  Reference< XPropertySet > xNewSet( xNewRows->getByIndex( nRow ), UNO_QUERY_THROW );
335  xNewSet->setPropertyValue( sHeight, Any( mpLayouter->getRowHeight( rStart.mnRow + nRow ) ) );
336  }
337 
338  // copy column widths
339  Reference< XTableColumns > xNewColumns( mxTable->getColumns(), css::uno::UNO_SET_THROW );
340  const OUString sWidth( "Width" );
341  for( sal_Int32 nCol = 0; nCol < nColumns; ++nCol )
342  {
343  Reference< XPropertySet > xNewSet( xNewColumns->getByIndex( nCol ), UNO_QUERY_THROW );
344  xNewSet->setPropertyValue( sWidth, Any( mpLayouter->getColumnWidth( rStart.mnCol + nCol ) ) );
345  }
346 
347  // reset layouter which still holds a copy to old TableModel
348  mpLayouter.reset();
349 
350  // cleanup old TableModel
351  {
352  Reference< XModifyListener > xListener( static_cast< css::util::XModifyListener* >(this) );
353  xOldTable->removeModifyListener( xListener );
354  xOldTable->dispose();
355  xOldTable.clear();
356  }
357 
358  // create and hand over to new TableLayouter
359  mpLayouter.reset(new TableLayouter( mxTable ));
360 
361  // add needed listener to react on changes
362  Reference< XModifyListener > xListener( static_cast< css::util::XModifyListener* >(this) );
363  mxTable->addModifyListener( xListener );
364 
365  // Apply Style to Cells
366  ApplyCellStyles();
367 
368  // layout cropped table
369  LayoutTable( mpTableObj->maRect, false, false );
370 }
371 
372 void SdrTableObjImpl::init( SdrTableObj* pTable, sal_Int32 nColumns, sal_Int32 nRows )
373 {
374  mpTableObj = pTable;
375  mxTable = new TableModel( pTable );
376  mxTable->init( nColumns, nRows );
377  Reference< XModifyListener > xListener( static_cast< css::util::XModifyListener* >(this) );
378  mxTable->addModifyListener( xListener );
379  mpLayouter.reset(new TableLayouter( mxTable ));
380  LayoutTable( mpTableObj->maRect, true, true );
382 }
383 
384 
386 {
387  if(this == &rSource)
388  {
389  return *this;
390  }
391 
392  if(nullptr == mpTableObj || nullptr == rSource.mpTableObj)
393  {
394  // error: need both SdrObjects to successfully copy data
395  return *this;
396  }
397 
398  // remove evtl. listeners from local
400 
401  // reset layouter which holds a copy
402  mpLayouter.reset();
403 
404  // cleanup local mxTable if used
405  if( mxTable.is() )
406  {
407  Reference< XModifyListener > xListener( static_cast< css::util::XModifyListener* >(this) );
408  mxTable->removeModifyListener( xListener );
409  mxTable->dispose();
410  mxTable.clear();
411  }
412 
413  // copy TableStyle (short internal data)
414  maTableStyle = rSource.maTableStyle;
415 
416  // create/copy new mxTable. This will copy all needed cells, too
417  mxTable = new TableModel( mpTableObj, rSource.mxTable );
418 
419  // create and hand over to new TableLayouter
420  mpLayouter.reset(new TableLayouter( mxTable ));
421 
422  // add needed listener to react on changes
423  Reference< XModifyListener > xListener( static_cast< css::util::XModifyListener* >(this) );
424  mxTable->addModifyListener( xListener );
425 
426  // handle TableStyle
427  Reference< XIndexAccess > xNewTableStyle;
428  SdrModel& rSourceSdrModel(rSource.mpTableObj->getSdrModelFromSdrObject());
429  SdrModel& rTargetSdrModel(mpTableObj->getSdrModelFromSdrObject());
430 
431  if(rSource.mxTableStyle.is() && &rSourceSdrModel == &rTargetSdrModel)
432  {
433  // source and target model the same -> keep current TableStyle
434  xNewTableStyle = rSource.mxTableStyle;
435  }
436 
437  if(!xNewTableStyle.is() && rSource.mxTableStyle.is()) try
438  {
439  // search in traget SdrModel for that TableStyle
440  const OUString sStyleName( Reference< XNamed >( rSource.mxTableStyle, UNO_QUERY_THROW )->getName() );
441  Reference< XStyleFamiliesSupplier > xSFS(rTargetSdrModel.getUnoModel(), UNO_QUERY_THROW );
442  Reference< XNameAccess > xFamilyNameAccess( xSFS->getStyleFamilies(), css::uno::UNO_SET_THROW );
443  const OUString sFamilyName( "table" );
444  Reference< XNameAccess > xTableFamilyAccess( xFamilyNameAccess->getByName( sFamilyName ), UNO_QUERY_THROW );
445 
446  if( xTableFamilyAccess->hasByName( sStyleName ) )
447  {
448  // found table style with the same name
449  xTableFamilyAccess->getByName( sStyleName ) >>= xNewTableStyle;
450  }
451  else
452  {
453  // copy or? Not found, use 1st existing TableStyle (or none)
454  Reference< XIndexAccess > xIndexAccess( xTableFamilyAccess, UNO_QUERY_THROW );
455  xIndexAccess->getByIndex( 0 ) >>= xNewTableStyle;
456  }
457  }
458  catch( Exception& )
459  {
460  OSL_FAIL("svx::SdrTableObjImpl::operator=(), exception caught!");
461  }
462 
463  // set that TableStyle
464  mxTableStyle = xNewTableStyle;
465 
466  // Apply Style to Cells
467  ApplyCellStyles();
468 
469  // copy geometry
471 
472  // layout cloned table
473  LayoutTable( mpTableObj->maRect, false, false );
474 
475  // re-connect to styles (evtl. in new SdrModel)
477 
478  return *this;
479 }
480 
482 {
483  if( !mxTable.is() || !mxTableStyle.is() )
484  return;
485 
486  const sal_Int32 nColCount = getColumnCount();
487  const sal_Int32 nRowCount = getRowCount();
488 
489  const TableStyleSettings& rStyle = maTableStyle;
490 
491  CellPos aPos;
492  for( aPos.mnRow = 0; aPos.mnRow < nRowCount; ++aPos.mnRow )
493  {
494  const bool bFirstRow = (aPos.mnRow == 0) && rStyle.mbUseFirstRow;
495  const bool bLastRow = (aPos.mnRow == nRowCount-1) && rStyle.mbUseLastRow;
496 
497  for( aPos.mnCol = 0; aPos.mnCol < nColCount; ++aPos.mnCol )
498  {
499  Reference< XStyle > xStyle;
500 
501  // first and last row win first, if used and available
502  if( bFirstRow )
503  {
504  mxTableStyle->getByIndex(first_row_style) >>= xStyle;
505  }
506  else if( bLastRow )
507  {
508  mxTableStyle->getByIndex(last_row_style) >>= xStyle;
509  }
510 
511  if( !xStyle.is() )
512  {
513  // next come first and last column, if used and available
514  if( rStyle.mbUseFirstColumn && (aPos.mnCol == 0) )
515  {
516  mxTableStyle->getByIndex(first_column_style) >>= xStyle;
517  }
518  else if( rStyle.mbUseLastColumn && (aPos.mnCol == nColCount-1) )
519  {
520  mxTableStyle->getByIndex(last_column_style) >>= xStyle;
521  }
522  }
523 
524  if( !xStyle.is() && rStyle.mbUseRowBanding )
525  {
526  if( (aPos.mnRow & 1) == 0 )
527  {
528  mxTableStyle->getByIndex(even_rows_style) >>= xStyle;
529  }
530  else
531  {
532  mxTableStyle->getByIndex(odd_rows_style) >>= xStyle;
533  }
534  }
535 
536  if( !xStyle.is() && rStyle.mbUseColumnBanding )
537  {
538  if( (aPos.mnCol & 1) == 0 )
539  {
540  mxTableStyle->getByIndex(even_columns_style) >>= xStyle;
541  }
542  else
543  {
544  mxTableStyle->getByIndex(odd_columns_style) >>= xStyle;
545  }
546  }
547 
548  if( !xStyle.is() )
549  {
550  // use default cell style if non found yet
551  mxTableStyle->getByIndex(body_style) >>= xStyle;
552  }
553 
554 
555  if( xStyle.is() )
556  {
558 
559  if( pStyle )
560  {
561  CellRef xCell( getCell( aPos ) );
562  if( xCell.is() && ( xCell->GetStyleSheet() != pStyle ) )
563  {
564  xCell->SetStyleSheet( pStyle, true );
565  }
566  }
567  }
568  }
569  }
570 }
571 
572 
574 {
576  mxTableStyle.clear();
577 
578  mpLayouter.reset();
579 
580  if( mxTable.is() )
581  {
582  Reference< XModifyListener > xListener( static_cast< css::util::XModifyListener* >(this) );
583  mxTable->removeModifyListener( xListener );
584  mxTable->dispose();
585  mxTable.clear();
586  }
587 }
588 
589 
590 void SdrTableObjImpl::DragEdge( bool mbHorizontal, int nEdge, sal_Int32 nOffset )
591 {
592  if( (nEdge >= 0) && mxTable.is()) try
593  {
594  const OUString sSize( "Size" );
595  if( mbHorizontal )
596  {
597  if (nEdge <= getRowCount())
598  {
599  sal_Int32 nHeight = mpLayouter->getRowHeight( (!nEdge)?nEdge:(nEdge-1) );
600  if(nEdge==0)
601  nHeight -= nOffset;
602  else
603  nHeight += nOffset;
604  Reference< XIndexAccess > xRows( mxTable->getRows(), UNO_QUERY_THROW );
605  Reference< XPropertySet > xRowSet( xRows->getByIndex( (!nEdge)?nEdge:(nEdge-1) ), UNO_QUERY_THROW );
606  xRowSet->setPropertyValue( sSize, Any( nHeight ) );
607  }
608  }
609  else
610  {
611  /*
612  fixes fdo#59889 and resizing of table in edge dragging
613  Total vertical edges in a NxN table is N+1, indexed from 0 to N and total Columns is N, indexed from 0 to N-1
614  In LTR table vertical edge responsible for dragging of column x(x=0 to N-1) is, Edge x+1
615  But in RTL table vertical edge responsible for dragging of column x(x=0 to N-1, but from right to left)is, Edge x
616  In LTR table dragging of edge 0(for RTL table edge N) does nothing.
617  */
618  //Todo: Implement Dragging functionality for leftmost edge of table.
619  if (nEdge <= getColumnCount())
620  {
621  const bool bRTL = mpTableObj != nullptr && (mpTableObj->GetWritingMode() == WritingMode_RL_TB);
622  sal_Int32 nWidth;
623  if(bRTL)
624  {
625  nWidth = mpLayouter->getColumnWidth( nEdge );
626  }
627  else
628  {
629  nWidth = mpLayouter->getColumnWidth( (!nEdge)?nEdge:(nEdge-1) );
630  }
631  Reference< XIndexAccess > xCols( mxTable->getColumns(), UNO_QUERY_THROW );
632  nWidth += nOffset;
633  if(bRTL && nEdge<getColumnCount())
634  {
635  Reference< XPropertySet > xColSet( xCols->getByIndex( nEdge ), UNO_QUERY_THROW );
636  xColSet->setPropertyValue( sSize, Any( nWidth ) );
637  }
638  else if(!bRTL && nEdge>0)
639  {
640  Reference< XPropertySet > xColSet( xCols->getByIndex( nEdge-1 ), UNO_QUERY_THROW );
641  xColSet->setPropertyValue( sSize, Any( nWidth ) );
642  }
643  /* To prevent the table resizing on edge dragging */
644  if( nEdge > 0 && nEdge < mxTable->getColumnCount() )
645  {
646  if( bRTL )
647  nEdge--;
648 
649  nWidth = mpLayouter->getColumnWidth(nEdge);
650  nWidth = std::max(static_cast<sal_Int32>(nWidth - nOffset), sal_Int32(0));
651 
652  Reference<XPropertySet> xColSet(xCols->getByIndex(nEdge), UNO_QUERY_THROW);
653  xColSet->setPropertyValue(sSize, Any(nWidth));
654  }
655  }
656  }
657  }
658  catch( Exception& )
659  {
660  OSL_FAIL( "svx::SdrTableObjImpl::DragEdge(), exception caught!" );
661  }
662 }
663 
664 
665 // XModifyListener
666 
667 
668 void SAL_CALL SdrTableObjImpl::modified( const css::lang::EventObject& /*aEvent*/ )
669 {
670  update();
671 }
672 
674 {
675  // source can be the table model itself or the assigned table template
676  TableModelNotifyGuard aGuard( mxTable.get() );
677  if( mpTableObj )
678  {
680  {
681  if(maEditPos.mnRow >= getRowCount())
683 
686 
688  }
689 
690  ApplyCellStyles();
691 
693  LayoutTable( mpTableObj->maRect, false, false );
694 
698  }
699 }
700 
701 
703 {
704  if( mxTableStyle.is() )
705  {
706  Reference< XModifyBroadcaster > xBroadcaster( mxTableStyle, UNO_QUERY );
707  if( xBroadcaster.is() )
708  {
709  Reference< XModifyListener > xListener( static_cast< css::util::XModifyListener* >(this) );
710  xBroadcaster->addModifyListener( xListener );
711  }
712  }
713 }
714 
715 
717 {
718  if( mxTableStyle.is() )
719  {
720  Reference< XModifyBroadcaster > xBroadcaster( mxTableStyle, UNO_QUERY );
721  if( xBroadcaster.is() )
722  {
723  Reference< XModifyListener > xListener( static_cast< css::util::XModifyListener* >(this) );
724  xBroadcaster->removeModifyListener( xListener );
725  }
726  }
727 }
728 
729 
731 {
732  return mpTableObj && mpTableObj->IsInserted();
733 }
734 
736 {
737  xmlTextWriterStartElement(pWriter, BAD_CAST("SdrTableObjImpl"));
738  if (mpLayouter)
739  mpLayouter->dumpAsXml(pWriter);
740  mxTable->dumpAsXml(pWriter);
741  xmlTextWriterEndElement(pWriter);
742 }
743 
744 
745 // XEventListener
746 
747 
748 void SAL_CALL SdrTableObjImpl::disposing( const css::lang::EventObject& /*Source*/ )
749 {
750  mxActiveCell.clear();
751  mxTable.clear();
752  mpLayouter.reset();
753  mpTableObj = nullptr;
754 }
755 
756 
758 {
759  CellRef xCell;
760  if( mxTable.is() ) try
761  {
762  xCell.set( dynamic_cast< Cell* >( mxTable->getCellByPosition( rPos.mnCol, rPos.mnRow ).get() ) );
763  }
764  catch( Exception& )
765  {
766  OSL_FAIL( "svx::SdrTableObjImpl::getCell(), exception caught!" );
767  }
768  return xCell;
769 }
770 
771 
773 {
774  return mxTable.is() ? mxTable->getColumnCount() : 0;
775 }
776 
777 std::vector<sal_Int32> SdrTableObjImpl::getColumnWidths() const
778 {
779  std::vector<sal_Int32> aRet;
780 
781  if (mxTable.is())
782  aRet = mxTable->getColumnWidths();
783 
784  return aRet;
785 }
786 
788 {
789  return mxTable.is() ? mxTable->getRowCount() : 0;
790 }
791 
792 void SdrTableObjImpl::LayoutTable( tools::Rectangle& rArea, bool bFitWidth, bool bFitHeight )
793 {
795  return;
796  if(mpLayouter)
797  {
798  // Optimization: SdrTableObj::SetChanged() can call this very often, repeatedly
799  // with the same settings, noticeably increasing load time. Skip if already done.
800  bool bInteractiveMightGrowBecauseTextChanged =
802  WritingMode writingMode = mpTableObj->GetWritingMode();
803  if( bInteractiveMightGrowBecauseTextChanged
804  || lastLayoutTable != this || lastLayoutInputRectangle != rArea
805  || lastLayoutFitWidth != bFitWidth || lastLayoutFitHeight != bFitHeight
806  || lastLayoutMode != writingMode
807  || lastRowCount != getRowCount()
810  {
811  lastLayoutTable = this;
812  lastLayoutInputRectangle = rArea;
813  lastLayoutFitWidth = bFitWidth;
814  lastLayoutFitHeight = bFitHeight;
815  lastLayoutMode = writingMode;
818  // Column resize, when the total width and column count of the
819  // table is unchanged, but re-layout is still needed.
821  TableModelNotifyGuard aGuard( mxTable.get() );
822  mpLayouter->LayoutTable( rArea, bFitWidth, bFitHeight );
824  }
825  else
826  {
828  mpLayouter->UpdateBorderLayout();
829  }
830  }
831 }
832 
834 {
835  if( mpLayouter && mxTable.is() )
836  {
837  TableModelNotifyGuard aGuard( mxTable.get() );
838  mpLayouter->updateCells( rArea );
839  mxTable->setModified(true);
840  }
841 }
842 
843 
844 // BaseProperties section
845 
846 
847 std::unique_ptr<sdr::properties::BaseProperties> SdrTableObj::CreateObjectSpecificProperties()
848 {
849  return std::make_unique<TableProperties>(*this);
850 }
851 
852 
853 // DrawContact section
854 
855 
856 std::unique_ptr<sdr::contact::ViewContact> SdrTableObj::CreateObjectSpecificViewContact()
857 {
858  return std::make_unique<sdr::contact::ViewContactOfTableObj>(*this);
859 }
860 
862 : SdrTextObj(rSdrModel)
863 {
864  init( 1, 1 );
865 }
866 
868  SdrModel& rSdrModel,
869  const ::tools::Rectangle& rNewRect,
870  sal_Int32 nColumns,
871  sal_Int32 nRows)
872 : SdrTextObj(rSdrModel, rNewRect)
873  ,maLogicRect(rNewRect)
874 {
875  if( nColumns <= 0 )
876  nColumns = 1;
877 
878  if( nRows <= 0 )
879  nRows = 1;
880 
881  init( nColumns, nRows );
882 }
883 
884 
885 void SdrTableObj::init( sal_Int32 nColumns, sal_Int32 nRows )
886 {
887  bClosedObj = true;
888 
889  mpImpl = new SdrTableObjImpl;
890  mpImpl->init( this, nColumns, nRows );
891 
892  // Stuff done from old SetModel:
893  if( !maLogicRect.IsEmpty() )
894  {
896  mpImpl->LayoutTable( maRect, false, false );
897  }
898 }
899 
900 
902 {
903  mpImpl->dispose();
904 }
905 
906 
907 // table stuff
908 
909 
910 Reference< XTable > SdrTableObj::getTable() const
911 {
912  return Reference< XTable >( mpImpl->mxTable.get() );
913 }
914 
915 
916 bool SdrTableObj::isValid( const CellPos& rPos ) const
917 {
918  return (rPos.mnCol >= 0) && (rPos.mnCol < mpImpl->getColumnCount()) && (rPos.mnRow >= 0) && (rPos.mnRow < mpImpl->getRowCount());
919 }
920 
921 
923 {
924  return CellPos( 0,0 );
925 }
926 
927 
929 {
930  CellPos aPos;
931  if( mpImpl->mxTable.is() )
932  {
933  aPos.mnCol = mpImpl->getColumnCount()-1;
934  aPos.mnRow = mpImpl->getRowCount()-1;
935  }
936  return aPos;
937 }
938 
939 
940 CellPos SdrTableObj::getLeftCell( const CellPos& rPos, bool bEdgeTravel ) const
941 {
942  switch( GetWritingMode() )
943  {
944  default:
945  case WritingMode_LR_TB:
946  return getPreviousCell( rPos, bEdgeTravel );
947  case WritingMode_RL_TB:
948  return getNextCell( rPos, bEdgeTravel );
949  case WritingMode_TB_RL:
950  return getPreviousRow( rPos, bEdgeTravel );
951  }
952 }
953 
954 
955 CellPos SdrTableObj::getRightCell( const CellPos& rPos, bool bEdgeTravel ) const
956 {
957  switch( GetWritingMode() )
958  {
959  default:
960  case WritingMode_LR_TB:
961  return getNextCell( rPos, bEdgeTravel );
962  case WritingMode_RL_TB:
963  return getPreviousCell( rPos, bEdgeTravel );
964  case WritingMode_TB_RL:
965  return getNextRow( rPos, bEdgeTravel );
966  }
967 }
968 
969 
970 CellPos SdrTableObj::getUpCell( const CellPos& rPos, bool bEdgeTravel ) const
971 {
972  switch( GetWritingMode() )
973  {
974  default:
975  case WritingMode_LR_TB:
976  case WritingMode_RL_TB:
977  return getPreviousRow( rPos, bEdgeTravel );
978  case WritingMode_TB_RL:
979  return getPreviousCell( rPos, bEdgeTravel );
980  }
981 }
982 
983 
984 CellPos SdrTableObj::getDownCell( const CellPos& rPos, bool bEdgeTravel ) const
985 {
986  switch( GetWritingMode() )
987  {
988  default:
989  case WritingMode_LR_TB:
990  case WritingMode_RL_TB:
991  return getNextRow( rPos, bEdgeTravel );
992  case WritingMode_TB_RL:
993  return getNextCell( rPos, bEdgeTravel );
994  }
995 }
996 
997 
998 CellPos SdrTableObj::getPreviousCell( const CellPos& rPos, bool bEdgeTravel ) const
999 {
1000  CellPos aPos( rPos );
1001  if( mpImpl.is() )
1002  {
1003  CellRef xCell( mpImpl->getCell( aPos ) );
1004  if( xCell.is() && xCell->isMerged() )
1005  {
1006  sal_Int32 nTemp = 0;
1007  findMergeOrigin( mpImpl->mxTable.get(), aPos.mnCol, aPos.mnRow, aPos.mnCol, nTemp );
1008  }
1009 
1010  if( aPos.mnCol > 0 )
1011  {
1012  --aPos.mnCol;
1013  }
1014 
1015  else if( bEdgeTravel && (aPos.mnRow > 0) )
1016  {
1017  aPos.mnCol = mpImpl->mxTable->getColumnCount()-1;
1018  --aPos.mnRow;
1019  }
1020  }
1021  return aPos;
1022 }
1023 
1024 
1025 CellPos SdrTableObj::getNextCell( const CellPos& rPos, bool bEdgeTravel ) const
1026 {
1027  CellPos aPos( rPos );
1028  if( mpImpl.is() )
1029  {
1030  CellRef xCell( mpImpl->getCell( aPos ) );
1031  if( xCell.is() )
1032  {
1033  if( xCell->isMerged() )
1034  {
1035  findMergeOrigin( mpImpl->mxTable, aPos.mnCol, aPos.mnRow, aPos.mnCol, aPos.mnRow );
1036 
1037  xCell = mpImpl->getCell(aPos);
1038 
1039  if( xCell.is() )
1040  {
1041  aPos.mnCol += xCell->getColumnSpan();
1042  aPos.mnRow = rPos.mnRow;
1043  }
1044  }
1045  else
1046  {
1047  aPos.mnCol += xCell->getColumnSpan();
1048  }
1049 
1050  if( aPos.mnCol < mpImpl->mxTable->getColumnCount() )
1051  return aPos;
1052 
1053  if( bEdgeTravel && ((aPos.mnRow + 1) < mpImpl->getRowCount()) )
1054  {
1055  aPos.mnCol = 0;
1056  aPos.mnRow += 1;
1057  return aPos;
1058  }
1059  }
1060  }
1061 
1062  // last cell reached, no traveling possible
1063  return rPos;
1064 }
1065 
1066 
1067 CellPos SdrTableObj::getPreviousRow( const CellPos& rPos, bool bEdgeTravel ) const
1068 {
1069  CellPos aPos( rPos );
1070  if( mpImpl.is() )
1071  {
1072  CellRef xCell( mpImpl->getCell( aPos ) );
1073  if( xCell.is() && xCell->isMerged() )
1074  {
1075  sal_Int32 nTemp = 0;
1076  findMergeOrigin( mpImpl->mxTable, aPos.mnCol, aPos.mnRow, nTemp, aPos.mnRow );
1077  }
1078 
1079  if( aPos.mnRow > 0 )
1080  {
1081  --aPos.mnRow;
1082  }
1083  else if( bEdgeTravel && (aPos.mnCol > 0) )
1084  {
1085  aPos.mnRow = mpImpl->mxTable->getRowCount()-1;
1086  --aPos.mnCol;
1087  }
1088  }
1089  return aPos;
1090 }
1091 
1092 
1093 CellPos SdrTableObj::getNextRow( const CellPos& rPos, bool bEdgeTravel ) const
1094 {
1095  CellPos aPos( rPos );
1096 
1097  if( mpImpl.is() )
1098  {
1099  CellRef xCell( mpImpl->getCell( rPos ) );
1100  if( xCell.is() )
1101  {
1102  if( xCell->isMerged() )
1103  {
1104  findMergeOrigin( mpImpl->mxTable, aPos.mnCol, aPos.mnRow, aPos.mnCol, aPos.mnRow );
1105  xCell = mpImpl->getCell(aPos);
1106  aPos.mnCol = rPos.mnCol;
1107  }
1108 
1109  if( xCell.is() )
1110  aPos.mnRow += xCell->getRowSpan();
1111 
1112  if( aPos.mnRow < mpImpl->mxTable->getRowCount() )
1113  return aPos;
1114 
1115  if( bEdgeTravel && (aPos.mnCol + 1) < mpImpl->mxTable->getColumnCount() )
1116  {
1117  aPos.mnRow = 0;
1118  aPos.mnCol += 1;
1119 
1120  while( aPos.mnCol < mpImpl->mxTable->getColumnCount() )
1121  {
1122  xCell = mpImpl->getCell( aPos );
1123  if( xCell.is() && !xCell->isMerged() )
1124  return aPos;
1125  aPos.mnCol += 1;
1126  }
1127  }
1128  }
1129  }
1130 
1131  // last position reached, no more traveling possible
1132  return rPos;
1133 }
1134 
1135 
1137 {
1138  if( mpImpl.is())
1139  {
1140  return mpImpl->maTableStyle;
1141  }
1142  else
1143  {
1144  static TableStyleSettings aTmp;
1145  return aTmp;
1146  }
1147 }
1148 
1149 
1151 {
1152  if( mpImpl.is() )
1153  {
1154  mpImpl->maTableStyle = rStyle;
1155  mpImpl->update();
1156  }
1157 }
1158 
1159 
1160 TableHitKind SdrTableObj::CheckTableHit( const Point& rPos, sal_Int32& rnX, sal_Int32& rnY, const sal_uInt16 aTol ) const
1161 {
1162  if( !mpImpl.is() || !mpImpl->mxTable.is() )
1163  return TableHitKind::NONE;
1164 
1165  rnX = 0;
1166  rnY = 0;
1167 
1168  const sal_Int32 nColCount = mpImpl->getColumnCount();
1169  const sal_Int32 nRowCount = mpImpl->getRowCount();
1170 
1171  sal_Int32 nX = rPos.X() - maRect.Left();
1172  sal_Int32 nY = rPos.Y() - maRect.Top();
1173 
1174  if( (nX < 0) || (nX > maRect.GetWidth()) || (nY < 0) || (nY > maRect.GetHeight() ) )
1175  return TableHitKind::NONE;
1176 
1177  // get vertical edge number and check for a hit
1178  const bool bRTL = (GetWritingMode() == WritingMode_RL_TB);
1179  bool bVrtHit = false;
1180  if( !bRTL )
1181  {
1182  while( rnX <= nColCount )
1183  {
1184  if( nX - aTol <= 0 )
1185  {
1186  bVrtHit = true;
1187  break;
1188  }
1189 
1190  if( rnX == nColCount )
1191  break;
1192 
1193  nX -= mpImpl->mpLayouter->getColumnWidth( rnX );
1194  if( nX < 0 )
1195  break;
1196  rnX++;
1197  }
1198  }
1199  else
1200  {
1201  rnX = nColCount;
1202  while( rnX >= 0 )
1203  {
1204  if( nX - aTol <= 0 )
1205  {
1206  bVrtHit = true;
1207  break;
1208  }
1209 
1210  if( rnX == 0 )
1211  break;
1212 
1213  rnX--;
1214  nX -= mpImpl->mpLayouter->getColumnWidth( rnX );
1215  if( nX < 0 )
1216  break;
1217  }
1218  }
1219 
1220  // rnX is now the edge number left to the pointer, if it was hit bHrzHit is also true
1221 
1222  // get vertical edge number and check for a hit
1223  bool bHrzHit = false;
1224  while( rnY <= nRowCount )
1225  {
1226  if( nY - aTol <= 0 )
1227  {
1228  bHrzHit = true;
1229  break;
1230  }
1231 
1232  if( rnY == nRowCount )
1233  break;
1234 
1235  nY -= mpImpl->mpLayouter->getRowHeight(rnY);
1236  if( nY < 0 )
1237  break;
1238  rnY++;
1239  }
1240 
1241  // rnY is now the edge number above the pointer, if it was hit bVrtHit is also true
1242 
1243  if( bVrtHit && mpImpl->mpLayouter->isEdgeVisible( rnX, rnY, false ) )
1245 
1246  if( bHrzHit && mpImpl->mpLayouter->isEdgeVisible( rnX, rnY, true ) )
1248 
1249  CellRef xCell( mpImpl->getCell( CellPos( rnX, rnY ) ) );
1250  if( xCell.is() && xCell->isMerged() )
1251  findMergeOrigin( mpImpl->mxTable.get(), rnX, rnY, rnX, rnY );
1252 
1253  if( xCell.is() )
1254  {
1255  nX += mpImpl->mpLayouter->getColumnWidth( rnX );
1256  //Fix for fdo#62673 : non-editable cell in table on cell merge
1257  sal_Int32 i=0;
1258  while(xCell.is() && xCell->isMerged())
1259  {
1260  nX += mpImpl->mpLayouter->getColumnWidth( rnX+i );
1261  i++;
1262  if(rnX+i < nColCount)
1263  xCell=mpImpl->getCell( CellPos( rnX+i, rnY) );
1264  else
1265  break;
1266  }
1267 
1268  if( nX < xCell->GetTextLeftDistance() )
1269  return TableHitKind::Cell;
1270  }
1271 
1273 }
1274 
1276 {
1277  return getActiveCell()->GetItemSet();
1278 }
1279 
1280 void SdrTableObj::setTableStyle( const Reference< XIndexAccess >& xTableStyle )
1281 {
1282  if( mpImpl.is() && (mpImpl->mxTableStyle != xTableStyle) )
1283  {
1284  mpImpl->disconnectTableStyle();
1285  mpImpl->mxTableStyle = xTableStyle;
1286  mpImpl->connectTableStyle();
1287  mpImpl->update();
1288  }
1289 }
1290 
1291 
1292 const Reference< XIndexAccess >& SdrTableObj::getTableStyle() const
1293 {
1294  if( mpImpl.is() )
1295  {
1296  return mpImpl->mxTableStyle;
1297  }
1298  else
1299  {
1300  static Reference< XIndexAccess > aTmp;
1301  return aTmp;
1302  }
1303 }
1304 
1305 
1306 // text stuff
1307 
1308 
1311 {
1312  return dynamic_cast< SdrText* >( getActiveCell().get() );
1313 }
1314 
1315 
1317 SdrText* SdrTableObj::getText( sal_Int32 nIndex ) const
1318 {
1319  if( mpImpl->mxTable.is() )
1320  {
1321  const sal_Int32 nColCount = mpImpl->getColumnCount();
1322  if( nColCount )
1323  {
1324  CellPos aPos( nIndex % nColCount, nIndex / nColCount );
1325 
1326  CellRef xCell( mpImpl->getCell( aPos ) );
1327  return dynamic_cast< SdrText* >( xCell.get() );
1328  }
1329  }
1330  return nullptr;
1331 }
1332 
1333 
1335 sal_Int32 SdrTableObj::getTextCount() const
1336 {
1337  if( mpImpl->mxTable.is() )
1338  {
1339  const sal_Int32 nColCount = mpImpl->getColumnCount();
1340  const sal_Int32 nRowCount = mpImpl->getRowCount();
1341 
1342  return nColCount * nRowCount;
1343  }
1344  else
1345  {
1346  return 0;
1347  }
1348 }
1349 
1350 
1352 void SdrTableObj::setActiveText( sal_Int32 nIndex )
1353 {
1354  if( mpImpl.is() && mpImpl->mxTable.is() )
1355  {
1356  const sal_Int32 nColCount = mpImpl->mxTable->getColumnCount();
1357  if( nColCount )
1358  {
1359  CellPos aPos( nIndex % nColCount, nIndex / nColCount );
1360  if( isValid( aPos ) )
1361  setActiveCell( aPos );
1362  }
1363  }
1364 }
1365 
1366 
1368 sal_Int32 SdrTableObj::CheckTextHit(const Point& rPnt) const
1369 {
1370  if( mpImpl.is() && mpImpl->mxTable.is() )
1371  {
1372  CellPos aPos;
1373  if( CheckTableHit( rPnt, aPos.mnCol, aPos.mnRow ) == TableHitKind::CellTextArea )
1374  return aPos.mnRow * mpImpl->mxTable->getColumnCount() + aPos.mnCol;
1375  }
1376 
1377  return 0;
1378 }
1379 
1381 {
1382  if( mpImpl.is() && (mpImpl->getCell( mpImpl->maEditPos ).get() == &rCell) )
1383  return pEdtOutl;
1384  else
1385  return nullptr;
1386 }
1387 
1389 {
1390  assert(mpImpl.is() && mpImpl->mpLayouter && "getTableLayouter() error: no mpImpl or mpLayouter (!)");
1391  return *(mpImpl->mpLayouter);
1392 }
1393 
1395 {
1396  return true;
1397 }
1398 
1400 {
1401  return true;
1402 }
1403 
1405 {
1406  return true;
1407 }
1408 
1410 {
1411  return pEdtOutl && mpImpl.is() && (rPos == mpImpl->maEditPos);
1412 }
1413 
1414 
1416 {
1417  if( (pEditStatus->GetStatusWord() & EditStatusFlags::TextHeightChanged) && mpImpl.is() && mpImpl->mpLayouter )
1418  {
1419  tools::Rectangle aRect0( maRect );
1420  maRect = maLogicRect;
1421  mpImpl->LayoutTable( maRect, false, false );
1422  SetRectsDirty();
1423  ActionChanged();
1425  if (aRect0 != maRect)
1427  }
1428 }
1429 
1430 
1432 {
1433  rInfo.bResizeFreeAllowed=true;
1434  rInfo.bResizePropAllowed=true;
1435  rInfo.bRotateFreeAllowed=false;
1436  rInfo.bRotate90Allowed =false;
1437  rInfo.bMirrorFreeAllowed=false;
1438  rInfo.bMirror45Allowed =false;
1439  rInfo.bMirror90Allowed =false;
1440 
1441  // allow transparence
1442  rInfo.bTransparenceAllowed = true;
1443 
1444  rInfo.bShearAllowed =false;
1445  rInfo.bEdgeRadiusAllowed=false;
1446  rInfo.bCanConvToPath =false;
1447  rInfo.bCanConvToPoly =false;
1448  rInfo.bCanConvToPathLineToArea=false;
1449  rInfo.bCanConvToPolyLineToArea=false;
1450  rInfo.bCanConvToContour = false;
1451 }
1452 
1453 
1455 {
1456  return static_cast<sal_uInt16>(OBJ_TABLE);
1457 }
1458 
1459 void SdrTableObj::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText, tools::Rectangle* pAnchorRect, bool /*bLineWidth*/ ) const
1460 {
1461  if( mpImpl.is() )
1462  TakeTextRect( mpImpl->maEditPos, rOutliner, rTextRect, bNoEditText, pAnchorRect );
1463 }
1464 
1465 
1466 void SdrTableObj::TakeTextRect( const CellPos& rPos, SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText, tools::Rectangle* pAnchorRect ) const
1467 {
1468  if( !mpImpl.is())
1469  return;
1470 
1471  CellRef xCell( mpImpl->getCell( rPos ) );
1472  if( !xCell.is() )
1473  return;
1474 
1475  tools::Rectangle aAnkRect;
1476  TakeTextAnchorRect( rPos, aAnkRect );
1477 
1478  SdrTextVertAdjust eVAdj=xCell->GetTextVerticalAdjust();
1479 
1480  EEControlBits nStat0=rOutliner.GetControlWord();
1481  nStat0 |= EEControlBits::AUTOPAGESIZE;
1482  rOutliner.SetControlWord(nStat0);
1483  rOutliner.SetMinAutoPaperSize(Size());
1484  rOutliner.SetMaxAutoPaperSize(aAnkRect.GetSize());
1485  rOutliner.SetPaperSize(aAnkRect.GetSize());
1486 
1487  // #103516# New try with _BLOCK for hor and ver after completely
1488  // supporting full width for vertical text.
1489 // if( SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting())
1490 // {
1491  rOutliner.SetMinAutoPaperSize(Size(aAnkRect.GetWidth(), 0));
1492 // }
1493 // else if(SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting())
1494 // {
1495 // rOutliner.SetMinAutoPaperSize(Size(0, aAnkRect.GetHeight()));
1496 // }
1497 
1498 
1499  // set text at outliner, maybe from edit outliner
1500  OutlinerParaObject* pPara= xCell->GetOutlinerParaObject();
1501  if (pEdtOutl && !bNoEditText && mpImpl->mxActiveCell == xCell )
1502  pPara=pEdtOutl->CreateParaObject().release();
1503 
1504  if (pPara)
1505  {
1506  const bool bHitTest(&getSdrModelFromSdrObject().GetHitTestOutliner() == &rOutliner);
1507  const SdrTextObj* pTestObj(rOutliner.GetTextObj());
1508 
1509  if( !pTestObj || !bHitTest || (pTestObj != this) || (pTestObj->GetOutlinerParaObject() != xCell->GetOutlinerParaObject()) )
1510  {
1511  if( bHitTest ) // #i33696# take back fix #i27510#
1512  rOutliner.SetTextObj( this );
1513 
1514  rOutliner.SetUpdateMode(true);
1515  rOutliner.SetText(*pPara);
1516  }
1517  }
1518  else
1519  {
1520  rOutliner.SetTextObj( nullptr );
1521  }
1522 
1523  if (pEdtOutl && !bNoEditText && pPara && mpImpl->mxActiveCell == xCell )
1524  delete pPara;
1525 
1526  rOutliner.SetUpdateMode(true);
1527  rOutliner.SetControlWord(nStat0);
1528 
1529  Point aTextPos(aAnkRect.TopLeft());
1530  Size aTextSiz(rOutliner.GetPaperSize());
1532  {
1533  long nFreeHgt=aAnkRect.GetHeight()-aTextSiz.Height();
1534  if (eVAdj==SDRTEXTVERTADJUST_CENTER)
1535  aTextPos.AdjustY(nFreeHgt/2 );
1536  if (eVAdj==SDRTEXTVERTADJUST_BOTTOM)
1537  aTextPos.AdjustY(nFreeHgt );
1538  }
1539 
1540  if (pAnchorRect)
1541  *pAnchorRect=aAnkRect;
1542 
1543  rTextRect=tools::Rectangle(aTextPos,aTextSiz);
1544 }
1545 
1546 
1548 {
1549  if( mpImpl.is() )
1550  {
1551  if( !mpImpl->mxActiveCell.is() )
1552  {
1553  CellPos aPos;
1554  const_cast< SdrTableObj* >(this)->setActiveCell( aPos );
1555  }
1556  return mpImpl->mxActiveCell;
1557  }
1558  else
1559  {
1560  static CellRef xCell;
1561  return xCell;
1562  }
1563 }
1564 
1565 
1567 {
1568  return mpImpl.is() ? mpImpl->getColumnCount() : 0;
1569 }
1570 
1571 sal_Int32 SdrTableObj::getRowCount() const
1572 {
1573  return mpImpl.is() ? mpImpl->getRowCount() : 0;
1574 }
1575 
1576 void SdrTableObj::changeEdge(bool bHorizontal, int nEdge, sal_Int32 nOffset)
1577 {
1578  if (mpImpl.is())
1579  mpImpl->DragEdge(bHorizontal, nEdge, nOffset);
1580 }
1581 
1583 {
1584  if( mpImpl.is() && mpImpl->mxTable.is() ) try
1585  {
1586  mpImpl->mxActiveCell.set( dynamic_cast< Cell* >( mpImpl->mxTable->getCellByPosition( rPos.mnCol, rPos.mnRow ).get() ) );
1587  if( mpImpl->mxActiveCell.is() && mpImpl->mxActiveCell->isMerged() )
1588  {
1589  CellPos aOrigin;
1590  findMergeOrigin( mpImpl->mxTable.get(), rPos.mnCol, rPos.mnRow, aOrigin.mnCol, aOrigin.mnRow );
1591  mpImpl->mxActiveCell.set( dynamic_cast< Cell* >( mpImpl->mxTable->getCellByPosition( aOrigin.mnCol, aOrigin.mnRow ).get() ) );
1592  mpImpl->maEditPos = aOrigin;
1593  }
1594  else
1595  {
1596  mpImpl->maEditPos = rPos;
1597  }
1598  }
1599  catch( Exception& )
1600  {
1601  OSL_FAIL("SdrTableObj::setActiveCell(), exception caught!");
1602  }
1603 }
1604 
1605 
1607 {
1608  rPos = mpImpl->maEditPos;
1609 }
1610 
1611 
1612 void SdrTableObj::getCellBounds( const CellPos& rPos, ::tools::Rectangle& rCellRect )
1613 {
1614  if( mpImpl.is() )
1615  {
1616  CellRef xCell( mpImpl->getCell( rPos ) );
1617  if( xCell.is() )
1618  rCellRect = xCell->getCellRect();
1619  }
1620 }
1621 
1622 
1623 void SdrTableObj::TakeTextAnchorRect(tools::Rectangle& rAnchorRect) const
1624 {
1625  if( mpImpl.is() )
1626  TakeTextAnchorRect( mpImpl->maEditPos, rAnchorRect );
1627 }
1628 
1629 
1630 void SdrTableObj::TakeTextAnchorRect( const CellPos& rPos, tools::Rectangle& rAnchorRect ) const
1631 {
1632  tools::Rectangle aAnkRect(maRect);
1633 
1634  if( mpImpl.is() )
1635  {
1636  CellRef xCell( mpImpl->getCell( rPos ) );
1637  if( xCell.is() )
1638  xCell->TakeTextAnchorRect( aAnkRect );
1639  }
1640 
1641  ImpJustifyRect(aAnkRect);
1642  rAnchorRect=aAnkRect;
1643 }
1644 
1645 
1646 void SdrTableObj::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, tools::Rectangle* pViewInit, tools::Rectangle* pViewMin) const
1647 {
1648  if( mpImpl.is() )
1649  TakeTextEditArea( mpImpl->maEditPos, pPaperMin, pPaperMax, pViewInit, pViewMin );
1650 }
1651 
1652 
1653 void SdrTableObj::TakeTextEditArea( const CellPos& rPos, Size* pPaperMin, Size* pPaperMax, tools::Rectangle* pViewInit, tools::Rectangle* pViewMin ) const
1654 {
1655  Size aPaperMin,aPaperMax;
1656  tools::Rectangle aViewInit;
1657  TakeTextAnchorRect( rPos, aViewInit );
1658 
1659  Size aAnkSiz(aViewInit.GetSize());
1660  aAnkSiz.AdjustWidth( -1 ); aAnkSiz.AdjustHeight( -1 ); // because GetSize() increments by one
1661 
1662  Size aMaxSiz(aAnkSiz.Width(),1000000);
1663  Size aTmpSiz(getSdrModelFromSdrObject().GetMaxObjSize());
1664  if (aTmpSiz.Height()!=0)
1665  aMaxSiz.setHeight(aTmpSiz.Height() );
1666 
1667  CellRef xCell( mpImpl->getCell( rPos ) );
1668  SdrTextVertAdjust eVAdj = xCell.is() ? xCell->GetTextVerticalAdjust() : SDRTEXTVERTADJUST_TOP;
1669 
1670  aPaperMax=aMaxSiz;
1671 
1672  aPaperMin.setWidth( aAnkSiz.Width() );
1673 
1674  if (pViewMin!=nullptr)
1675  {
1676  *pViewMin=aViewInit;
1677  long nYFree=aAnkSiz.Height()-aPaperMin.Height();
1678 
1679  if (eVAdj==SDRTEXTVERTADJUST_TOP)
1680  {
1681  pViewMin->AdjustBottom( -nYFree );
1682  }
1683  else if (eVAdj==SDRTEXTVERTADJUST_BOTTOM)
1684  {
1685  pViewMin->AdjustTop(nYFree );
1686  }
1687  else
1688  {
1689  pViewMin->AdjustTop(nYFree/2 );
1690  pViewMin->SetBottom(pViewMin->Top()+aPaperMin.Height() );
1691  }
1692  }
1693 
1694 
1695  if(IsVerticalWriting())
1696  aPaperMin.setWidth( 0 );
1697  else
1698  aPaperMin.setHeight( 0 );
1699 
1700  if (pPaperMin!=nullptr) *pPaperMin=aPaperMin;
1701  if (pPaperMax!=nullptr) *pPaperMax=aPaperMax;
1702  if (pViewInit!=nullptr) *pViewInit=aViewInit;
1703 }
1704 
1705 
1707 {
1708  EEAnchorMode eRet=EEAnchorMode::TopLeft;
1709  CellRef xCell( getActiveCell() );
1710  if( xCell.is() )
1711  {
1712  SdrTextVertAdjust eV=xCell->GetTextVerticalAdjust();
1713 
1714  {
1715  if (eV==SDRTEXTVERTADJUST_TOP)
1716  {
1717  eRet=EEAnchorMode::TopLeft;
1718  }
1719  else if (eV==SDRTEXTVERTADJUST_BOTTOM)
1720  {
1721  eRet=EEAnchorMode::BottomLeft;
1722  }
1723  else
1724  {
1725  eRet=EEAnchorMode::VCenterLeft;
1726  }
1727  }
1728  }
1729  return eRet;
1730 }
1731 
1732 
1734 {
1735  OUStringBuffer sName(SvxResId(STR_ObjNameSingulTable));
1736 
1737  OUString aName(GetName());
1738  if (!aName.isEmpty())
1739  {
1740  sName.append(' ');
1741  sName.append('\'');
1742  sName.append(aName);
1743  sName.append('\'');
1744  }
1745 
1746  return sName.makeStringAndClear();
1747 }
1748 
1749 
1751 {
1752  return SvxResId(STR_ObjNamePluralTable);
1753 }
1754 
1755 
1757 {
1758  return CloneHelper< SdrTableObj >(rTargetModel);
1759 }
1760 
1762 {
1763  if( this == &rObj )
1764  {
1765  return *this;
1766  }
1767 
1768  // call parent
1769  // before SdrObject::operator= was called which is wrong from
1770  // the derivation hierarchy and may leave quite some entries
1771  // uninitialized. Changed to SdrTextObj::operator=, but had to adapt
1772  // usage of pNewOutlinerParaObject/mpText there due to nullptr access
1773  SdrTextObj::operator=(rObj);
1774 
1775  TableModelNotifyGuard aGuard( mpImpl.is() ? mpImpl->mxTable.get() : nullptr );
1776 
1777  maLogicRect = rObj.maLogicRect;
1778  maRect = rObj.maRect;
1779  aGeo = rObj.aGeo;
1780  eTextKind = rObj.eTextKind;
1781  bTextFrame = rObj.bTextFrame;
1782  aTextSize = rObj.aTextSize;
1784  bNoShear = rObj.bNoShear;
1786 
1787  // use SdrTableObjImpl::operator= now to
1788  // copy model data and other stuff (see there)
1789  *mpImpl = *rObj.mpImpl;
1790 
1791  return *this;
1792 }
1793 
1794 
1796 {
1797  return maRect;
1798 }
1799 
1800 
1802 {
1803  NbcSetLogicRect( rRect );
1804 }
1805 
1806 
1808 {
1809  return maLogicRect;
1810 }
1811 
1812 
1814 {
1815 }
1816 
1817 
1819 {
1820  if( pEdtOutl != nullptr )
1821  return false;
1822 
1823  pEdtOutl=&rOutl;
1824 
1825  mbInEditMode = true;
1826 
1827  rOutl.Init( OutlinerMode::TextObject );
1828  rOutl.SetRefDevice(getSdrModelFromSdrObject().GetRefDevice());
1829 
1830  bool bUpdateMode=rOutl.GetUpdateMode();
1831  if (bUpdateMode) rOutl.SetUpdateMode(false);
1832  Size aPaperMin;
1833  Size aPaperMax;
1834  tools::Rectangle aEditArea;
1835  TakeTextEditArea(&aPaperMin,&aPaperMax,&aEditArea,nullptr);
1836 
1837  rOutl.SetMinAutoPaperSize(aPaperMin);
1838  rOutl.SetMaxAutoPaperSize(aPaperMax);
1839  rOutl.SetPaperSize(aPaperMax);
1840 
1841  if (bUpdateMode) rOutl.SetUpdateMode(true);
1842 
1843  EEControlBits nStat=rOutl.GetControlWord();
1844  nStat |= EEControlBits::AUTOPAGESIZE;
1845  nStat &=~EEControlBits::STRETCHING;
1846  rOutl.SetControlWord(nStat);
1847 
1849  if(pPara)
1850  rOutl.SetText(*pPara);
1851 
1852  rOutl.UpdateFields();
1853  rOutl.ClearModifyFlag();
1854 
1855  return true;
1856 }
1857 
1858 
1860 {
1861 
1862  if (getSdrModelFromSdrObject().IsUndoEnabled() && !mpImpl->maUndos.empty())
1863  {
1864  // These actions should be on the undo stack after text edit.
1865  for (std::unique_ptr<SdrUndoAction>& pAction : mpImpl->maUndos)
1866  getSdrModelFromSdrObject().AddUndo( std::move(pAction));
1867  mpImpl->maUndos.clear();
1868 
1869  getSdrModelFromSdrObject().AddUndo(getSdrModelFromSdrObject().GetSdrUndoFactory().CreateUndoGeoObject(*this));
1870  }
1871 
1872  if(rOutl.IsModified())
1873  {
1874  std::unique_ptr<OutlinerParaObject> pNewText;
1875  Paragraph* p1stPara = rOutl.GetParagraph( 0 );
1876  sal_Int32 nParaCnt = rOutl.GetParagraphCount();
1877 
1878  if(p1stPara)
1879  {
1880  // to remove the grey field background
1881  rOutl.UpdateFields();
1882 
1883  // create new text object
1884  pNewText = rOutl.CreateParaObject( 0, nParaCnt );
1885  }
1886  SetOutlinerParaObject(std::move(pNewText));
1887  }
1888 
1889  pEdtOutl = nullptr;
1890  rOutl.Clear();
1891  EEControlBits nStat = rOutl.GetControlWord();
1892  nStat &= ~EEControlBits::AUTOPAGESIZE;
1893  rOutl.SetControlWord(nStat);
1894 
1895  mbInEditMode = false;
1896 }
1897 
1898 
1900 {
1901  CellRef xCell( getActiveCell() );
1902  if( xCell.is() )
1903  return xCell->GetOutlinerParaObject();
1904  else
1905  return nullptr;
1906 }
1907 
1908 
1909 void SdrTableObj::NbcSetOutlinerParaObject( std::unique_ptr<OutlinerParaObject> pTextObject)
1910 {
1911  CellRef xCell( getActiveCell() );
1912  if( xCell.is() )
1913  {
1914  // Update HitTestOutliner
1915  const SdrTextObj* pTestObj(getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj());
1916 
1917  if(pTestObj && pTestObj->GetOutlinerParaObject() == xCell->GetOutlinerParaObject())
1918  {
1920  }
1921 
1922  xCell->SetOutlinerParaObject( std::move(pTextObject) );
1923  SetTextSizeDirty();
1925  }
1926 }
1927 
1928 
1930 {
1931  maLogicRect=rRect;
1933  const bool bWidth = maLogicRect.getWidth() != maRect.getWidth();
1934  const bool bHeight = maLogicRect.getHeight() != maRect.getHeight();
1935  maRect = maLogicRect;
1936  if (mpImpl->mbSkipChangeLayout)
1937  // Avoid distributing newly available space between existing cells.
1939  else
1940  NbcAdjustTextFrameWidthAndHeight(!bHeight, !bWidth);
1941  SetRectsDirty();
1942 }
1943 
1944 
1945 void SdrTableObj::AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool /* bShrinkOnly = false */ )
1946 {
1947  tools::Rectangle aAdjustRect( rMaxRect );
1948  aAdjustRect.setHeight( GetLogicRect().getHeight() );
1949  SetLogicRect( aAdjustRect );
1950 }
1951 
1952 
1953 void SdrTableObj::NbcMove(const Size& rSiz)
1954 {
1955  maLogicRect.Move(rSiz);
1956  SdrTextObj::NbcMove( rSiz );
1957  if( mpImpl.is() )
1958  mpImpl->UpdateCells( maRect );
1959 }
1960 
1961 
1962 void SdrTableObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
1963 {
1964  tools::Rectangle aOldRect( maLogicRect );
1965  ResizeRect(maLogicRect,rRef,xFact,yFact);
1966 
1967  maRect = maLogicRect;
1969  SetRectsDirty();
1970 }
1971 
1972 
1974 {
1975  tools::Rectangle aNewRect(maLogicRect);
1976  bool bRet=AdjustTextFrameWidthAndHeight(aNewRect);
1977  if (bRet)
1978  {
1979  tools::Rectangle aBoundRect0;
1980  if (pUserCall!=nullptr)
1981  aBoundRect0=GetLastBoundRect();
1982  maRect = aNewRect;
1983  SetRectsDirty();
1984  SetChanged();
1987  }
1988  return bRet;
1989 }
1990 
1991 
1992 bool SdrTableObj::AdjustTextFrameWidthAndHeight(tools::Rectangle& rR, bool bHeight, bool bWidth) const
1993 {
1994  if(rR.IsEmpty() || !mpImpl.is() || !mpImpl->mxTable.is())
1995  return false;
1996 
1997  tools::Rectangle aRectangle( rR );
1998  mpImpl->LayoutTable( aRectangle, !bWidth, !bHeight );
1999 
2000  if( aRectangle != rR )
2001  {
2002  rR = aRectangle;
2003  return true;
2004  }
2005  else
2006  {
2007  return false;
2008  }
2009 }
2010 
2011 
2013 {
2015 }
2016 
2017 
2019 {
2021  return rModeItem.GetValue() == css::text::WritingMode_TB_RL;
2022 }
2023 
2024 
2026 {
2027  if(bVertical != IsVerticalWriting() )
2028  {
2029  SvxWritingModeItem aModeItem( css::text::WritingMode_LR_TB, SDRATTR_TEXTDIRECTION );
2030  SetObjectItem( aModeItem );
2031  }
2032 }
2033 
2034 
2036 {
2037  SfxStyleSheet* pStyle = GetStyleSheet();
2038  if ( !pStyle )
2039  return WritingMode_LR_TB;
2040 
2041  WritingMode eWritingMode = WritingMode_LR_TB;
2042  const SfxItemSet &rSet = pStyle->GetItemSet();
2043  const SfxPoolItem *pItem;
2044 
2045  if ( rSet.GetItemState( SDRATTR_TEXTDIRECTION, false, &pItem ) == SfxItemState::SET )
2046  eWritingMode = static_cast< const SvxWritingModeItem * >( pItem )->GetValue();
2047 
2048  if ( ( eWritingMode != WritingMode_TB_RL ) &&
2049  ( rSet.GetItemState( EE_PARA_WRITINGDIR, false, &pItem ) == SfxItemState::SET ) )
2050  {
2051  if ( static_cast< const SvxFrameDirectionItem * >( pItem )->GetValue() == SvxFrameDirection::Horizontal_LR_TB )
2052  eWritingMode = WritingMode_LR_TB;
2053  else
2054  eWritingMode = WritingMode_RL_TB;
2055  }
2056 
2057  return eWritingMode;
2058 }
2059 
2061 {
2062  mpImpl->maUndos.push_back(std::unique_ptr<SdrUndoAction>(pUndo));
2063 }
2064 
2065 void SdrTableObj::SetSkipChangeLayout(bool bSkipChangeLayout)
2066 {
2067  mpImpl->mbSkipChangeLayout = bSkipChangeLayout;
2068 }
2069 
2071 {
2072  return pEdtOutl && pEdtOutl->IsModified();
2073 }
2074 
2076 {
2077  return false;
2078 }
2079 
2080 sal_uInt32 SdrTableObj::GetHdlCount() const
2081 {
2082  sal_uInt32 nCount = SdrTextObj::GetHdlCount();
2083  const sal_Int32 nRowCount = mpImpl->getRowCount();
2084  const sal_Int32 nColCount = mpImpl->getColumnCount();
2085 
2086  if( nRowCount && nColCount )
2087  nCount += nRowCount + nColCount + 2 + 1;
2088 
2089  return nCount;
2090 }
2091 
2093 {
2094  const sal_Int32 nRowCount = mpImpl->getRowCount();
2095  const sal_Int32 nColCount = mpImpl->getColumnCount();
2096 
2097  // first add row handles
2098  std::vector<TableEdgeHdl*> aRowEdges(nRowCount + 1);
2099  for (auto const & rEdge : mpImpl->mpLayouter->getHorizontalEdges())
2100  {
2101  Point aPoint(maRect.TopLeft());
2102  aPoint.AdjustY(rEdge.nPosition);
2103 
2104  std::unique_ptr<TableEdgeHdl> pHdl(new TableEdgeHdl(aPoint, true, rEdge.nMin, rEdge.nMax, nColCount + 1));
2105  pHdl->SetPointNum(rEdge.nIndex);
2106  aRowEdges[rEdge.nIndex] = pHdl.get();
2107  rHdlList.AddHdl(std::move(pHdl));
2108  }
2109 
2110  // second add column handles
2111  std::vector<TableEdgeHdl*> aColEdges(nColCount + 1);
2112  for (auto const & rEdge : mpImpl->mpLayouter->getVerticalEdges())
2113  {
2114  Point aPoint(maRect.TopLeft());
2115  aPoint.AdjustX(rEdge.nPosition);
2116 
2117  std::unique_ptr<TableEdgeHdl> pHdl(new TableEdgeHdl(aPoint, false, rEdge.nMin, rEdge.nMax, nRowCount + 1));
2118  pHdl->SetPointNum(rEdge.nIndex);
2119  aColEdges[rEdge.nIndex] = pHdl.get();
2120  rHdlList.AddHdl(std::move(pHdl));
2121  }
2122 
2123  // now add visible edges to row and column handles
2124  if( mpImpl->mpLayouter )
2125  {
2126  TableLayouter& rLayouter = *mpImpl->mpLayouter;
2127 
2128  sal_Int32 nY = 0;
2129 
2130  for( sal_Int32 nRow = 0; nRow <= nRowCount; ++nRow )
2131  {
2132  const sal_Int32 nRowHeight = (nRow == nRowCount) ? 0 : rLayouter.getRowHeight(nRow);
2133  sal_Int32 nX = 0;
2134 
2135  for( sal_Int32 nCol = 0; nCol <= nColCount; ++nCol )
2136  {
2137  const sal_Int32 nColWidth = (nCol == nColCount) ? 0 : rLayouter.getColumnWidth(nCol);
2138 
2139  if( nRowHeight > 0 )
2140  {
2141  if( rLayouter.isEdgeVisible( nCol, nRow, false ) )
2142  aColEdges[nCol]->SetEdge( nRow, nY, nY + nRowHeight, (rLayouter.getBorderLine( nCol, nRow, false ) == nullptr) ? Visible : Invisible);
2143  }
2144 
2145  if( nColWidth > 0 )
2146  {
2147  if( rLayouter.isEdgeVisible( nCol, nRow, true ) )
2148  aRowEdges[nRow]->SetEdge( nCol, nX, nX + nColWidth, (rLayouter.getBorderLine( nCol, nRow, true ) == nullptr) ? Visible : Invisible);
2149  }
2150 
2151  nX += nColWidth;
2152  }
2153 
2154  nY += nRowHeight;
2155  }
2156  }
2157 
2158  // add remaining handles
2159  SdrHdlList tempList(nullptr);
2160  tempList.AddHdl( std::make_unique<TableBorderHdl>( maRect, !IsTextEditActive() ) );
2161  tempList.AddHdl( std::make_unique<SdrHdl>(maRect.TopLeft(),SdrHdlKind::UpperLeft) );
2162  tempList.AddHdl( std::make_unique<SdrHdl>(maRect.TopCenter(),SdrHdlKind::Upper) );
2163  tempList.AddHdl( std::make_unique<SdrHdl>(maRect.TopRight(),SdrHdlKind::UpperRight) );
2164  tempList.AddHdl( std::make_unique<SdrHdl>(maRect.LeftCenter(),SdrHdlKind::Left) );
2165  tempList.AddHdl( std::make_unique<SdrHdl>(maRect.RightCenter(),SdrHdlKind::Right) );
2166  tempList.AddHdl( std::make_unique<SdrHdl>(maRect.BottomLeft(),SdrHdlKind::LowerLeft) );
2167  tempList.AddHdl( std::make_unique<SdrHdl>(maRect.BottomCenter(),SdrHdlKind::Lower) );
2168  tempList.AddHdl( std::make_unique<SdrHdl>(maRect.BottomRight(),SdrHdlKind::LowerRight) );
2169  for( size_t nHdl = 0; nHdl < tempList.GetHdlCount(); ++nHdl )
2170  tempList.GetHdl(nHdl)->SetMoveOutside(true);
2171  tempList.MoveTo(rHdlList);
2172 
2173  const size_t nHdlCount = rHdlList.GetHdlCount();
2174  for( size_t nHdl = 0; nHdl < nHdlCount; ++nHdl )
2175  rHdlList.GetHdl(nHdl)->SetObj(const_cast<SdrTableObj*>(this));
2176 }
2177 
2178 // Dragging
2179 
2181 {
2182  return true;
2183 }
2184 
2186 {
2187  const SdrHdl* pHdl = rDrag.GetHdl();
2188  const SdrHdlKind eHdl((pHdl == nullptr) ? SdrHdlKind::Move : pHdl->GetKind());
2189 
2190  switch( eHdl )
2191  {
2192  case SdrHdlKind::UpperLeft:
2193  case SdrHdlKind::Upper:
2195  case SdrHdlKind::Left:
2196  case SdrHdlKind::Right:
2197  case SdrHdlKind::LowerLeft:
2198  case SdrHdlKind::Lower:
2200  case SdrHdlKind::Move:
2201  {
2202  break;
2203  }
2204 
2205  case SdrHdlKind::User:
2206  {
2207  rDrag.SetEndDragChangesAttributes(false);
2208  rDrag.SetNoSnap();
2209  break;
2210  }
2211 
2212  default:
2213  {
2214  return false;
2215  }
2216  }
2217 
2218  return true;
2219 }
2220 
2222 {
2223  bool bRet(true);
2224  const SdrHdl* pHdl = rDrag.GetHdl();
2225  const SdrHdlKind eHdl((pHdl == nullptr) ? SdrHdlKind::Move : pHdl->GetKind());
2226 
2227  switch( eHdl )
2228  {
2229  case SdrHdlKind::UpperLeft:
2230  case SdrHdlKind::Upper:
2232  case SdrHdlKind::Left:
2233  case SdrHdlKind::Right:
2234  case SdrHdlKind::LowerLeft:
2235  case SdrHdlKind::Lower:
2237  {
2238  const tools::Rectangle aNewRectangle(ImpDragCalcRect(rDrag));
2239 
2240  if (aNewRectangle != maRect)
2241  {
2242  NbcSetLogicRect(aNewRectangle);
2243  }
2244 
2245  break;
2246  }
2247 
2248  case SdrHdlKind::Move:
2249  {
2250  NbcMove( Size( rDrag.GetDX(), rDrag.GetDY() ) );
2251  break;
2252  }
2253 
2254  case SdrHdlKind::User:
2255  {
2256  rDrag.SetEndDragChangesAttributes(false);
2257  rDrag.SetNoSnap();
2258  const TableEdgeHdl* pEdgeHdl = dynamic_cast< const TableEdgeHdl* >( pHdl );
2259 
2260  if( pEdgeHdl )
2261  {
2262  if( IsInserted() )
2263  {
2264  rDrag.SetEndDragChangesAttributes(true);
2265  rDrag.SetEndDragChangesLayout(true);
2266  }
2267 
2268  mpImpl->DragEdge( pEdgeHdl->IsHorizontalEdge(), pEdgeHdl->GetPointNum(), pEdgeHdl->GetValidDragOffset( rDrag ) );
2269  }
2270  break;
2271  }
2272 
2273  default:
2274  {
2275  bRet = false;
2276  }
2277  }
2278 
2279  return bRet;
2280 }
2281 
2283 {
2284  basegfx::B2DPolyPolygon aRetval;
2285  const SdrHdl* pHdl = rDrag.GetHdl();
2286 
2287  if( pHdl && (SdrHdlKind::User == pHdl->GetKind()) )
2288  {
2289  const TableEdgeHdl* pEdgeHdl = dynamic_cast< const TableEdgeHdl* >( pHdl );
2290 
2291  if( pEdgeHdl )
2292  {
2293  aRetval = pEdgeHdl->getSpecialDragPoly( rDrag );
2294  }
2295  }
2296 
2297  return aRetval;
2298 }
2299 
2300 
2301 // Create
2302 
2303 
2305 {
2306  rStat.SetOrtho4Possible();
2307  tools::Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
2308  aRect1.Justify();
2309  rStat.SetActionRect(aRect1);
2310  maRect = aRect1;
2311  return true;
2312 }
2313 
2314 
2316 {
2317  tools::Rectangle aRect1;
2318  rStat.TakeCreateRect(aRect1);
2319  ImpJustifyRect(aRect1);
2320  rStat.SetActionRect(aRect1);
2321  maRect = aRect1; // for ObjName
2323  bSnapRectDirty=true;
2324  return true;
2325 }
2326 
2327 
2329 {
2330  rStat.TakeCreateRect(maRect);
2332  return (eCmd==SdrCreateCmd::ForceEnd || rStat.GetPointCount()>=2);
2333 }
2334 
2336 {
2337 }
2338 
2339 
2341 {
2342  return true;
2343 }
2344 
2345 
2347 {
2348  tools::Rectangle aRect1;
2349  rDrag.TakeCreateRect(aRect1);
2350  aRect1.Justify();
2351 
2352  basegfx::B2DPolyPolygon aRetval;
2355  return aRetval;
2356 }
2357 
2358 
2360 {
2361  return PointerStyle::Cross;
2362 }
2363 
2364 
2366 {
2367  xNewCell = Cell::create( *this );
2368 }
2369 
2370 
2372 {
2373  return new TableObjectGeoData;
2374 }
2375 
2376 
2378 {
2379  DBG_ASSERT( dynamic_cast< TableObjectGeoData* >( &rGeo ), "svx::SdrTableObj::SaveGeoData(), illegal geo data!" );
2380  SdrTextObj::SaveGeoData (rGeo);
2381 
2382  static_cast<TableObjectGeoData &>(rGeo).maLogicRect = maLogicRect;
2383 }
2384 
2385 
2387 {
2388  DBG_ASSERT( dynamic_cast< const TableObjectGeoData* >( &rGeo ), "svx::SdrTableObj::SaveGeoData(), illegal geo data!" );
2389 
2390  maLogicRect = static_cast<const TableObjectGeoData &>(rGeo).maLogicRect;
2391 
2392  SdrTextObj::RestGeoData (rGeo);
2393 
2394  if( mpImpl.is() )
2395  mpImpl->LayoutTable(maRect, false, false);
2396  ActionChanged();
2397 }
2398 
2400 {
2401  if(!mpImpl.is())
2402  {
2403  return;
2404  }
2405 
2406  mpImpl->CropTableModelToSelection(rStart, rEnd);
2407 }
2408 
2409 void SdrTableObj::DistributeColumns( sal_Int32 nFirstColumn, sal_Int32 nLastColumn, const bool bOptimize, const bool bMinimize )
2410 {
2411  if( mpImpl.is() && mpImpl->mpLayouter )
2412  {
2413  TableModelNotifyGuard aGuard( mpImpl->mxTable.get() );
2414  mpImpl->mpLayouter->DistributeColumns( maRect, nFirstColumn, nLastColumn, bOptimize, bMinimize );
2415  }
2416 }
2417 
2418 
2419 void SdrTableObj::DistributeRows( sal_Int32 nFirstRow, sal_Int32 nLastRow, const bool bOptimize, const bool bMinimize )
2420 {
2421  if( mpImpl.is() && mpImpl->mpLayouter )
2422  {
2423  TableModelNotifyGuard aGuard( mpImpl->mxTable.get() );
2424  mpImpl->mpLayouter->DistributeRows( maRect, nFirstRow, nLastRow, bOptimize, bMinimize );
2425  }
2426 }
2427 
2428 
2430 {
2431  if( mpImpl.is() )
2432  {
2433  mpImpl->LayoutTable( maRect, false, false );
2434  }
2435 
2437 }
2438 
2439 
2441 {
2442  if( mpImpl.is() && mpImpl->mxTable.is() )
2443  mpImpl->mxTable->lockBroadcasts();
2444 }
2445 
2446 
2448 {
2449  if( mpImpl.is() && mpImpl->mxTable.is() )
2450  mpImpl->mxTable->unlockBroadcasts();
2451 }
2452 
2454 {
2455  xmlTextWriterStartElement(pWriter, BAD_CAST("SdrTableObj"));
2456  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
2457 
2458  SdrObject::dumpAsXml(pWriter);
2459 
2460  mpImpl->dumpAsXml(pWriter);
2461 
2462  xmlTextWriterEndElement(pWriter);
2463 }
2464 
2465 bool SdrTableObj::createTableEdgesJson(boost::property_tree::ptree & rJsonRoot)
2466 {
2467  if (!mpImpl.is() || !mpImpl->mxTable.is())
2468  return false;
2469 
2471  boost::property_tree::ptree aTableColumns;
2472  {
2473  aTableColumns.put("tableOffset", convertMm100ToTwip(aRect.Left()));
2474 
2475  boost::property_tree::ptree aEntries;
2476  auto const & aEdges = mpImpl->mpLayouter->getVerticalEdges();
2477  for (auto & rEdge : aEdges)
2478  {
2479  if (rEdge.nIndex == 0)
2480  {
2481  aTableColumns.put("left", convertMm100ToTwip(rEdge.nPosition));
2482  }
2483  else if (rEdge.nIndex == sal_Int32(aEdges.size() - 1))
2484  {
2485  aTableColumns.put("right", convertMm100ToTwip(rEdge.nPosition));
2486  }
2487  else
2488  {
2489  boost::property_tree::ptree aEntry;
2490  aEntry.put("position", convertMm100ToTwip(rEdge.nPosition));
2491  aEntry.put("min", convertMm100ToTwip(rEdge.nPosition + rEdge.nMin));
2492  aEntry.put("max", convertMm100ToTwip(rEdge.nPosition + rEdge.nMax));
2493  aEntry.put("hidden", false);
2494  aEntries.push_back(std::make_pair("", aEntry));
2495  }
2496  }
2497  aTableColumns.push_back(std::make_pair("entries", aEntries));
2498  }
2499  rJsonRoot.add_child("columns", aTableColumns);
2500 
2501  boost::property_tree::ptree aTableRows;
2502  {
2503  aTableRows.put("tableOffset", convertMm100ToTwip(aRect.Top()));
2504 
2505  boost::property_tree::ptree aEntries;
2506  auto const & aEdges = mpImpl->mpLayouter->getHorizontalEdges();
2507  for (auto & rEdge : aEdges)
2508  {
2509  if (rEdge.nIndex == 0)
2510  {
2511  aTableRows.put("left", convertMm100ToTwip(rEdge.nPosition));
2512  }
2513  else if (rEdge.nIndex == sal_Int32(aEdges.size() - 1))
2514  {
2515  aTableRows.put("right", convertMm100ToTwip(rEdge.nPosition));
2516  }
2517  else
2518  {
2519  boost::property_tree::ptree aEntry;
2520  aEntry.put("position", convertMm100ToTwip(rEdge.nPosition));
2521  aEntry.put("min", convertMm100ToTwip(rEdge.nPosition + rEdge.nMin));
2522  aEntry.put("max", convertMm100ToTwip(rEdge.nPosition + rEdge.nMax));
2523  aEntry.put("hidden", false);
2524  aEntries.push_back(std::make_pair("", aEntry));
2525  }
2526  }
2527  aTableRows.push_back(std::make_pair("entries", aEntries));
2528  }
2529  rJsonRoot.add_child("rows", aTableRows);
2530  return true;
2531 }
2532 
2533 } }
2534 
2535 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool findMergeOrigin(const TableModelRef &xTable, sal_Int32 nMergedX, sal_Int32 nMergedY, sal_Int32 &rOriginX, sal_Int32 &rOriginY)
returns true if the cell(nMergedX,nMergedY) is merged with other cells.
Point TopLeft() const
long getHeight() const
const int nColCount
void LayoutTable(tools::Rectangle &rArea, bool bFitWidth, bool bFitHeight)
Definition: svdotable.cxx:792
virtual sal_uInt16 GetObjIdentifier() const override
Definition: svdotable.cxx:1454
CellPos getNextRow(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:1093
long GetWidth() const
#define EE_ITEMS_START
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: svdotable.cxx:847
CellPos getRightCell(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:955
virtual OutlinerParaObject * GetOutlinerParaObject() const override
Definition: svdotable.cxx:1899
void setHeight(long n)
virtual void RestGeoData(const SdrObjGeoData &rGeo) override
Definition: svdotable.cxx:2386
static sal_Int32 lastRowCount
Definition: svdotable.cxx:253
long GetHeight() const
css::uno::Reference< css::table::XTable > getTable() const
Definition: svdotable.cxx:910
virtual bool NbcAdjustTextFrameWidthAndHeight(bool bHgt=true, bool bWdt=true)
Definition: svdotxat.cxx:256
virtual const tools::Rectangle & GetCurrentBoundRect() const
Definition: svdobj.cxx:881
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: svdotable.cxx:856
void setTableStyle(const css::uno::Reference< css::container::XIndexAccess > &xAutoFormatStyle)
Definition: svdotable.cxx:1280
sal_Int32 getRowCount() const
Definition: svdotable.cxx:787
CellPos getUpCell(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:970
long AdjustWidth(long n)
SdrObjUserCall * pUserCall
Definition: svdobj.hxx:923
long AdjustX(long nHorzMove)
media shape
Definition: svdobj.hxx:148
long Height() const
virtual bool IsAutoGrowWidth() const override
Definition: svdotable.cxx:1399
const Point & GetStart() const
Definition: svddrag.hxx:92
Point BottomLeft() const
virtual SdrObjGeoData * NewGeoData() const override
A derived class must override these 3 methods if it has own geometric data that must be saved for Und...
Definition: svdotable.cxx:2371
GeoStat aGeo
Definition: svdotext.hxx:185
CellRef getCell(const CellPos &rPos) const
Definition: svdotable.cxx:757
SdrHdlKind
Definition: svdhdl.hxx:52
long getWidth() const
void SetPaperSize(const Size &rSize)
virtual bool beginSpecialDrag(SdrDragStat &rDrag) const override
Definition: svdotable.cxx:2185
bool isValid(const sdr::table::CellPos &rPos) const
Definition: svdotable.cxx:916
virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat &rDrag) const override
Polygon dragged by the user when creating the object.
Definition: svdotable.cxx:2346
basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat &rDrag) const
void CropTableModelToSelection(const CellPos &rStart, const CellPos &rEnd)
Definition: svdotable.cxx:282
SdrOutliner * pEdtOutl
Definition: svdotext.hxx:196
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: svdotable.cxx:1962
void TakeTextRect(const sdr::table::CellPos &rPos, SdrOutliner &rOutliner,::tools::Rectangle &rTextRect, bool bNoEditText,::tools::Rectangle *pAnchorRect) const
At the same time, we set the text in the outliner (if applicable the EditOutliners') as well as the P...
void createCell(sdr::table::CellRef &xCell)
Definition: svdotable.cxx:2365
virtual void setActiveText(sal_Int32 nIndex) override
Changes the current active text.
Definition: svdotable.cxx:1352
virtual bool IsFontwork() const override
Definition: svdotable.cxx:2075
bool bDisableAutoWidthOnDragging
Definition: svdotext.hxx:245
Abstract base class (ABC) for all UndoActions of DrawingEngine.
Definition: svdundo.hxx:53
bool IsInserted() const
Definition: svdobj.hxx:792
virtual void TakeTextEditArea(Size *pPaperMin, Size *pPaperMax, tools::Rectangle *pViewInit, tools::Rectangle *pViewMin) const override
Definition: svdotable.cxx:1646
sal_uInt32 GetPointNum() const
Definition: svdhdl.hxx:222
virtual sal_uInt32 GetHdlCount() const override
Via GetHdlCount the number of Handles can be retrieved.
Definition: svdotxdr.cxx:36
virtual void SetBoundRectDirty()
Definition: svdobj.cxx:336
SdrOutliner * GetCellTextEditOutliner(const sdr::table::Cell &rCell) const
Definition: svdotable.cxx:1380
void CropTableModelToSelection(const CellPos &rStart, const CellPos &rEnd)
Definition: svdotable.cxx:2399
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
Definition: svdotable.cxx:1431
const sal_Int32 first_column_style
Definition: tabledesign.hxx:31
sal_Int32 GetParagraphCount() const
#define SDRATTR_MISC_LAST
Definition: svddef.hxx:220
virtual SfxItemSet & GetItemSet()
virtual void BrkCreate(SdrDragStat &rStat) override
Definition: svdotable.cxx:2335
rtl::Reference< SdrTableObjImpl > mpImpl
Definition: svdotable.hxx:285
virtual void EndTextEdit(SdrOutliner &rOutl) override
Definition: svdotable.cxx:1859
const sal_Int32 last_column_style
Definition: tabledesign.hxx:32
struct _xmlTextWriter * xmlTextWriterPtr
EEControlBits
All geometrical data of an arbitrary object for use in undo/redo.
Definition: svdobj.hxx:226
CellPos getLeftCell(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:940
virtual void NbcMove(const Size &rSiz) override
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdotable.cxx:1953
virtual void SetChanged() override
Definition: svdotable.cxx:2429
long AdjustBottom(long nVertMoveDelta)
virtual sal_uInt32 GetHdlCount() const override
Via GetHdlCount the number of Handles can be retrieved.
Definition: svdotable.cxx:2080
bool mbInEditMode
Definition: svdotext.hxx:235
void Move(long nHorzMoveDelta, long nVertMoveDelta)
bool bSnapRectDirty
Definition: svdobj.hxx:928
Point RightCenter() const
virtual PointerStyle GetCreatePointer() const override
get the cursor/pointer that signals creating this object
Definition: svdotable.cxx:2359
bool IsEmpty() const
TableStyleSettings maTableStyle
Definition: svdotable.cxx:206
editeng::SvxBorderLine * getBorderLine(sal_Int32 nEdgeX, sal_Int32 nEdgeY, bool bHorizontal) const
returns the requested borderline in rpBorderLine or a null pointer if there is no border at this edge...
Provides information about various ZObject properties.
Definition: svdobj.hxx:248
const SdrHdl * GetHdl() const
Definition: svddrag.hxx:101
virtual bool applySpecialDrag(SdrDragStat &rDrag) override
Definition: svdotable.cxx:2221
virtual SdrText * getText(sal_Int32 nIndex) const override
Returns the nth available text.
Definition: svdotable.cxx:1317
virtual const tools::Rectangle & GetLogicRect() const override
Definition: svdotable.cxx:1807
void SetControlWord(EEControlBits nWord)
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
long GetDX() const
Definition: svddrag.hxx:148
#define SDRATTR_SHADOW_LAST
Definition: svddef.hxx:178
virtual const tools::Rectangle & GetSnapRect() const override
Definition: svdotable.cxx:1795
void DragEdge(bool mbHorizontal, int nEdge, sal_Int32 nOffset)
Definition: svdotable.cxx:590
virtual void SaveGeoData(SdrObjGeoData &rGeo) const override
Definition: svdotext.cxx:1440
void SetTextSizeDirty()
Definition: svdotext.hxx:288
rtl::Reference< Cell > CellRef
Definition: celltypes.hxx:33
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
Definition: svdmodel.cxx:559
static bool IsFuzzing()
Point BottomCenter() const
int nCount
virtual void NbcSetSnapRect(const tools::Rectangle &rRect) override
Definition: svdotable.cxx:1801
css::text::WritingMode GetValue() const
virtual bool IsReallyEdited() const override
Returns true only if we are in edit mode and the user actually changed anything.
Definition: svdotable.cxx:2070
SfxStyleSheet * GetStyleSheet() const
Definition: svdobj.cxx:2162
tools::Rectangle maRect
Definition: svdotext.hxx:182
void SetOrtho4Possible(bool bOn=true)
Definition: svddrag.hxx:126
bool bNoShear
Definition: svdotext.hxx:232
SdrTableObjImpl & operator=(const SdrTableObjImpl &rSource)
Definition: svdotable.cxx:385
void TakeCreateRect(tools::Rectangle &rRect) const
Definition: svddrag.cxx:115
void DistributeColumns(sal_Int32 nFirstColumn, sal_Int32 nLastColumn, const bool bOptimize, const bool bMinimize)
Definition: svdotable.cxx:2409
const sdr::table::TableStyleSettings & getTableStyleSettings() const
Definition: svdotable.cxx:1136
bool bClosedObj
Definition: svdobj.hxx:941
long Top() const
CellPos getPreviousCell(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:998
EEControlBits GetControlWord() const
void SetObjectItem(const SfxPoolItem &rItem)
Definition: svdobj.cxx:1916
Point LeftCenter() const
void DistributeRows(sal_Int32 nFirstRow, sal_Int32 nLastRow, const bool bOptimize, const bool bMinimize)
Definition: svdotable.cxx:2419
void getActiveCellPos(sdr::table::CellPos &rPos) const
Definition: svdotable.cxx:1606
virtual EEAnchorMode GetOutlinerViewAnchorMode() const override
Definition: svdotable.cxx:1706
static SdrTableObjImpl * lastLayoutTable
Definition: svdotable.cxx:247
virtual bool HasText() const override
Definition: svdotable.cxx:1404
tools::Rectangle ImpDragCalcRect(const SdrDragStat &rDrag) const
Definition: svdotxdr.cxx:72
void SetEndDragChangesLayout(bool bOn)
Definition: svddrag.hxx:137
SdrOutliner & GetHitTestOutliner() const
Definition: svdmodel.hxx:319
CellPos getPreviousRow(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:1067
virtual ~SdrTableObjImpl() override
Definition: svdotable.cxx:275
Point BottomRight() const
const SfxPoolItem & GetObjectItem(const sal_uInt16 nWhich) const
Definition: svdobj.cxx:1941
virtual void AddToHdlList(SdrHdlList &rHdlList) const override
Definition: svdotable.cxx:2092
void SetNoSnap(bool bOn=true)
Definition: svddrag.hxx:121
std::vector< sal_Int32 > getColumnWidths() const
Get widths of the columns in the table.
Definition: svdotable.cxx:777
void ResizeRect(tools::Rectangle &rRect, const Point &rRef, const Fraction &rxFact, const Fraction &ryFact)
Definition: svdtrans.cxx:36
Reference< XIndexAccess > mxTableStyle
Definition: svdotable.cxx:207
SdrTableObj & operator=(const SdrTableObj &rObj)
Definition: svdotable.cxx:1761
void SetObj(SdrObject *pNewObj)
Definition: svdhdl.cxx:382
void init(sal_Int32 nColumns, sal_Int32 nRows)
Definition: svdotable.cxx:885
long GetTextLeftDistance() const
Left inner spacing to borders.
Definition: svdotext.cxx:1750
void SetText(const OutlinerParaObject &)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
Definition: svdotable.cxx:668
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
const sal_Int32 first_row_style
Definition: tabledesign.hxx:29
long AdjustY(long nVertMove)
#define EE_PARA_WRITINGDIR
virtual void NbcSetLogicRect(const tools::Rectangle &rRect) override
Definition: svdotable.cxx:1929
void MoveTo(SdrHdlList &rOther)
Definition: svdhdl.cxx:2333
class SAL_NO_VTABLE XPropertySet
Definition: xmlexchg.hxx:31
bool bTextSizeDirty
Definition: svdotext.hxx:233
TableHitKind
SdrTableHitKind.
Definition: svdotable.hxx:51
OUString sName
virtual bool isInUse() override
Definition: svdotable.cxx:730
#define SDRATTR_TABLE_FIRST
Definition: svddef.hxx:398
const sal_Int32 even_columns_style
Definition: tabledesign.hxx:35
int i
void BroadcastObjectChange() const
Definition: svdobj.cxx:932
sal_Int32 getColumnWidth(sal_Int32 nColumn) const
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
CellPos getLastCell() const
Definition: svdotable.cxx:928
sal_Int32 GetPointCount() const
Definition: svddrag.hxx:91
#define SDRATTR_MISC_FIRST
Definition: svddef.hxx:193
SdrTextObj & operator=(const SdrTextObj &rObj)
Definition: svdotext.cxx:1015
void ActionChanged() const
Definition: svdobj.cxx:283
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: svdotable.cxx:748
void changeEdge(bool bHorizontal, int nEdge, sal_Int32 nOffset)
Definition: svdotable.cxx:1576
static SVX_DLLPRIVATE rtl::Reference< Cell > create(SdrTableObj &rTableObj)
Definition: cell.cxx:391
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:299
bool IsModified() const
#define SDRATTR_TEXTDIRECTION
Definition: svddef.hxx:302
void TakeTextAnchorRect(const sdr::table::CellPos &rPos,::tools::Rectangle &rAnchorRect) const
virtual void SetLogicRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1658
virtual bool EndCreate(SdrDragStat &rStat, SdrCreateCmd eCmd) override
Definition: svdotable.cxx:2328
virtual void NbcMove(const Size &rSiz) override
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdotxtr.cxx:98
#define SDRATTR_START
Definition: svddef.hxx:168
virtual void SaveGeoData(SdrObjGeoData &rGeo) const override
Definition: svdotable.cxx:2377
void SetEndDragChangesAttributes(bool bOn)
Definition: svddrag.hxx:133
void SetMoveOutside(bool bMoveOutside)
Definition: svdhdl.cxx:324
static std::vector< sal_Int32 > lastColWidths
Definition: svdotable.cxx:255
Abstract DrawObject.
Definition: svdobj.hxx:312
SdrObjKind eTextKind
Definition: svdotext.hxx:204
void ClearModifyFlag()
TableHitKind CheckTableHit(const Point &rPos, sal_Int32 &rnX, sal_Int32 &rnY, const sal_uInt16 aTol=0) const
Definition: svdotable.cxx:1160
long X() const
std::unique_ptr< TableLayouter > mpLayouter
Definition: svdotable.cxx:204
OUString GetName() const
Definition: svdobj.cxx:725
tools::Rectangle maLogicRect
Definition: svdotable.hxx:284
Size GetSize() const
CellPos getDownCell(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:984
virtual SdrTableObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: svdotable.cxx:1756
bool operator==(const TableStyleSettings &r) const
Definition: svdotable.cxx:186
bool bTextFrame
Definition: svdotext.hxx:231
css::text::WritingMode GetWritingMode() const
Definition: svdotable.cxx:2035
Paragraph * GetParagraph(sal_Int32 nAbsPos) const
void setTableStyleSettings(const sdr::table::TableStyleSettings &rStyle)
Definition: svdotable.cxx:1150
basegfx::B2DRange b2DRectangleFromRectangle(const ::tools::Rectangle &rRect)
virtual SdrText * getActiveText() const override
Returns the currently active text.
Definition: svdotable.cxx:1310
const css::uno::Reference< css::container::XIndexAccess > & getTableStyle() const
Definition: svdotable.cxx:1292
long GetDY() const
Definition: svddrag.hxx:149
const SfxItemSet & GetActiveCellItemSet() const
Definition: svdotable.cxx:1275
static SfxUnoStyleSheet * getUnoStyleSheet(const css::uno::Reference< css::style::XStyle > &xStyle)
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
bool isEdgeVisible(sal_Int32 nEdgeX, sal_Int32 nEdgeY, bool bHorizontal) const
checks if the given edge is visible.
virtual const tools::Rectangle & GetLastBoundRect() const
Definition: svdobj.cxx:895
virtual void NbcSetOutlinerParaObject(std::unique_ptr< OutlinerParaObject > pTextObject) override
Definition: svdotable.cxx:1909
static CellPos getFirstCell()
Definition: svdotable.cxx:922
size_t GetHdlCount() const
Definition: svdhdl.hxx:461
SdrHdl * GetHdl(size_t nNum) const
Definition: svdhdl.hxx:462
void AddUndo(SdrUndoAction *pUndo)
Add an undo action that should be on the undo stack after ending text edit.
Definition: svdotable.cxx:2060
void SetActionRect(const tools::Rectangle &rR)
Definition: svddrag.hxx:157
std::unique_ptr< OutlinerParaObject > CreateParaObject(sal_Int32 nStartPara=0, sal_Int32 nParaCount=EE_PARA_ALL) const
sal_Int32 getRowCount() const
Definition: svdotable.cxx:1571
friend class SdrTableObjImpl
Definition: svdotable.hxx:97
bool IsTextEditActive() const
Definition: svdotable.hxx:179
EditStatusFlags GetStatusWord() const
void SetMaxAutoPaperSize(const Size &rSz)
virtual bool BegTextEdit(SdrOutliner &rOutl) override
Definition: svdotable.cxx:1818
void init(SdrTableObj *pTable, sal_Int32 nColumns, sal_Int32 nRows)
Definition: svdotable.cxx:372
virtual bool MovCreate(SdrDragStat &rStat) override
Definition: svdotable.cxx:2315
virtual void RestGeoData(const SdrObjGeoData &rGeo) override
Definition: svdotext.cxx:1448
static tools::Rectangle lastLayoutInputRectangle
Definition: svdotable.cxx:248
virtual bool BegCreate(SdrDragStat &rStat) override
Every object must be able to create itself interactively.
Definition: svdotable.cxx:2304
const sal_Int32 odd_columns_style
Definition: tabledesign.hxx:36
static tools::Rectangle lastLayoutResultRectangle
Definition: svdotable.cxx:249
tools::Rectangle maLogicRect
Definition: svdotable.cxx:155
sal_Int32 GetValidDragOffset(const SdrDragStat &rDrag) const
virtual OUString TakeObjNameSingul() const override
Definition: svdotable.cxx:1733
const sal_Int32 body_style
Definition: tabledesign.hxx:37
virtual OutlinerParaObject * GetOutlinerParaObject() const override
Definition: svdotext.cxx:1362
const sal_Int32 even_rows_style
Definition: tabledesign.hxx:33
virtual void AdjustToMaxRect(const tools::Rectangle &rMaxRect, bool bShrinkOnly=false) override
Definition: svdotable.cxx:1945
virtual void onEditOutlinerStatusEvent(EditStatus *pEditStatus) override
called from the SdrObjEditView during text edit when the status of the edit outliner changes ...
Definition: svdotable.cxx:1415
OUString aName
virtual bool IsVerticalWriting() const override
Definition: svdotable.cxx:2018
CellPos getNextCell(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:1025
void SetMinAutoPaperSize(const Size &rSz)
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: svdobj.cxx:1733
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: svdotable.cxx:735
void SetBottom(long v)
virtual void NbcReformatText() override
Definition: svdotable.cxx:2012
void Init(OutlinerMode nOutlinerMode)
void SetOutlinerParaObject(std::unique_ptr< OutlinerParaObject > pTextObject)
Definition: svdobj.cxx:1755
virtual void RecalcSnapRect() override
Snap is not done on the BoundRect but if possible on logic coordinates (i.e.
Definition: svdotable.cxx:1813
void SetRefDevice(OutputDevice *pRefDev)
long AdjustTop(long nVertMoveDelta)
virtual bool hasSpecialDrag() const override
The standard transformations (Move,Resize,Rotate,Mirror,Shear) are taken over by the View (TakeXorPol...
Definition: svdotable.cxx:2180
Size aTextSize
Definition: svdotext.hxx:191
bool IsHorizontalEdge() const
const Point & GetNow() const
Definition: svddrag.hxx:95
sal_Int32 getRowHeight(sal_Int32 nRow) const
void SetUpdateMode(bool bUpdate)
long Left() const
sal_Int32 getColumnCount() const
Definition: svdotable.cxx:1566
static sal_Int32 lastColCount
Definition: svdotable.cxx:254
void setActiveCell(const sdr::table::CellPos &rPos)
Definition: svdotable.cxx:1582
PointerStyle
#define SDRATTR_TABLE_LAST
Definition: svddef.hxx:405
sal_Int32 getColumnCount() const
Definition: svdotable.cxx:772
virtual void SetRectsDirty(bool bNotMyself=false, bool bRecursive=true)
Definition: svdobj.cxx:462
TableStyleSettings.
Definition: svdotable.hxx:75
static WritingMode lastLayoutMode
Definition: svdotable.cxx:252
EEAnchorMode
void UpdateCells(tools::Rectangle const &rArea)
Definition: svdotable.cxx:833
virtual sal_Int32 getTextCount() const override
Returns the number of texts available for this object.
Definition: svdotable.cxx:1335
ScXMLEditAttributeMap::Entry const aEntries[]
void SetTextObj(const SdrTextObj *pObj)
Definition: svdoutl.cxx:43
SdrTableObj(SdrModel &rSdrModel)
Definition: svdotable.cxx:861
virtual bool BckCreate(SdrDragStat &rStat) override
Definition: svdotable.cxx:2340
virtual bool IsAutoGrowHeight() const override
Definition: svdotable.cxx:1394
bool UpdateFields()
std::vector< std::unique_ptr< SdrUndoAction > > maUndos
Definition: svdotable.cxx:208
const SdrTextObj * GetTextObj() const
Definition: svdoutl.cxx:89
void Clear()
virtual sal_Int32 CheckTextHit(const Point &rPnt) const override
Returns the index of the text that contains the given point or -1.
Definition: svdotable.cxx:1368
SdrCreateCmd
Definition: svdtypes.hxx:27
constexpr sal_Int64 convertMm100ToTwip(sal_Int64 n)
virtual void SetVerticalWriting(bool bVertical) override
Definition: svdotable.cxx:2025
virtual void SetChanged()
Definition: svdobj.cxx:956
virtual ~SdrTableObj() override
Definition: svdotable.cxx:901
void SetSkipChangeLayout(bool bSkipChangeLayout)
Next time layouting would be done, skip it (to layout at the end of multiple actions).
Definition: svdotable.cxx:2065
TableStyleSettings & operator=(const TableStyleSettings &rStyle)
Definition: svdotable.cxx:175
void setWidth(long nWidth)
virtual OUString TakeObjNamePlural() const override
Definition: svdotable.cxx:1750
static void ImpJustifyRect(tools::Rectangle &rRect)
Definition: svdotext.cxx:391
virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat &rDrag) const override
Definition: svdotable.cxx:2282
Point TopRight() const
SdrTextVertAdjust
Definition: sdtaitm.hxx:29
void SendUserCall(SdrUserCallType eUserCall, const tools::Rectangle &rBoundRect) const
Definition: svdobj.cxx:2676
virtual bool AdjustTextFrameWidthAndHeight() override
Definition: svdotable.cxx:1973
const sdr::table::CellRef & getActiveCell() const
The active table has the focus or is currently edited.
Definition: svdotable.cxx:1547
const TableLayouter & getTableLayouter() const
Definition: svdotable.cxx:1388
bool GetUpdateMode() const
const sal_Int32 last_row_style
Definition: tabledesign.hxx:30
void AddHdl(std::unique_ptr< SdrHdl > pHdl)
Definition: svdhdl.cxx:2299
long Y() const
Point TopCenter() const
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: svdotable.cxx:2453
SdrHdlKind GetKind() const
Definition: svdhdl.hxx:194
void getCellBounds(const sdr::table::CellPos &rPos,::tools::Rectangle &rCellRect)
Definition: svdotable.cxx:1612
bool createTableEdgesJson(boost::property_tree::ptree &rJsonRoot)
Definition: svdotable.cxx:2465
const sal_Int32 odd_rows_style
Definition: tabledesign.hxx:34
void setHeight(long nHeight)
#define EE_ITEMS_END
const Size & GetPaperSize() const