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