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>
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>
54#include <libxml/xmlwriter.h>
56
57#include <boost/property_tree/ptree.hpp>
58
59using ::com::sun::star::uno::Any;
60using ::com::sun::star::uno::Reference;
61using ::com::sun::star::uno::UNO_QUERY;
62using ::com::sun::star::uno::UNO_QUERY_THROW;
63using ::com::sun::star::uno::Exception;
64using ::com::sun::star::container::XIndexAccess;
65using ::com::sun::star::style::XStyle;
66using ::com::sun::star::table::XTableRows;
67using ::com::sun::star::table::XTableColumns;
68using ::com::sun::star::table::XTable;
70using ::com::sun::star::util::XModifyBroadcaster;
73using namespace ::com::sun::star;
74using namespace ::com::sun::star::text;
75using namespace ::com::sun::star::container;
76using namespace ::com::sun::star::style;
77
78namespace sdr::table {
79
80namespace {
81
82class TableProperties : public TextProperties
83{
84protected:
85 // create a new itemset
86 SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
87
88public:
89 // basic constructor
90 explicit TableProperties(SdrObject& rObj );
91
92 // constructor for copying, but using new object
93 TableProperties(const TableProperties& rProps, SdrObject& rObj );
94
95 // Clone() operator, normally just calls the local copy constructor
96 std::unique_ptr<BaseProperties> Clone(SdrObject& rObj) const override;
97
98 virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) override;
99};
100
101}
102
103TableProperties::TableProperties(SdrObject& rObj)
104: TextProperties(rObj)
105{
106}
107
108TableProperties::TableProperties(const TableProperties& rProps, SdrObject& rObj)
109: TextProperties(rProps, rObj)
110{
111}
112
113std::unique_ptr<BaseProperties> TableProperties::Clone(SdrObject& rObj) const
114{
115 return std::unique_ptr<BaseProperties>(new TableProperties(*this, rObj));
116}
117
118void TableProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
119{
120 if( nWhich == SDRATTR_TEXTDIRECTION )
121 AttributeProperties::ItemChange( nWhich, pNewItem );
122 else
123 TextProperties::ItemChange( nWhich, pNewItem );
124}
125
126// create a new itemset
127SfxItemSet TableProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
128{
129 return SfxItemSet(rPool,
130
131 // range from SdrAttrObj
135
136 // range for SdrTableObj
138
139 // range from SdrTextObj
140 EE_ITEMS_START, EE_ITEMS_END>);
141}
142
143namespace {
144
145class TableObjectGeoData : public SdrTextObjGeoData
146{
147public:
149};
150
151}
152
153TableStyleSettings::TableStyleSettings()
154: mbUseFirstRow(true)
155, mbUseLastRow(false)
156, mbUseFirstColumn(false)
157, mbUseLastColumn(false)
158, mbUseRowBanding(true)
159, mbUseColumnBanding(false)
160{
161}
162
164{
165 (*this) = rStyle;
166}
167
169{
171 mbUseLastRow = rStyle.mbUseLastRow;
176 return *this;
177}
178
180{
181 return
182 (mbUseFirstRow == rStyle.mbUseFirstRow) &&
183 (mbUseLastRow == rStyle.mbUseLastRow) &&
185 (mbUseLastColumn == rStyle.mbUseLastColumn) &&
186 (mbUseRowBanding == rStyle.mbUseRowBanding) &&
188}
189
190
191class SdrTableObjImpl : public TableDesignUser, public ::cppu::WeakImplHelper< css::util::XModifyListener >
192{
193public:
197 std::unique_ptr<TableLayouter> mpLayouter;
200 Reference< XIndexAccess > mxTableStyle;
201 std::vector<std::unique_ptr<SdrUndoAction>> maUndos;
203
204 void CropTableModelToSelection(const CellPos& rStart, const CellPos& rEnd);
205
206 CellRef getCell( const CellPos& rPos ) const;
207 void LayoutTable( tools::Rectangle& rArea, bool bFitWidth, bool bFitHeight );
208
209 void ApplyCellStyles();
210 void UpdateCells( tools::Rectangle const & rArea );
211
213 virtual ~SdrTableObjImpl() override;
214
215 void init( SdrTableObj* pTable, sal_Int32 nColumns, sal_Int32 nRows );
216 void dispose();
217
218 sal_Int32 getColumnCount() const;
220 std::vector<sal_Int32> getColumnWidths() const;
221 sal_Int32 getRowCount() const;
222
223 void DragEdge( bool mbHorizontal, int nEdge, sal_Int32 nOffset );
224
225 SdrTableObjImpl& operator=( const SdrTableObjImpl& rSource );
226
227 // XModifyListener
228 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
229
230 // XEventListener
231 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
232
233 void update();
234
235 void connectTableStyle();
237 virtual bool isInUse() override;
238 void dumpAsXml(xmlTextWriterPtr pWriter) const;
239private:
246 static sal_Int32 lastRowCount;
247 static sal_Int32 lastColCount;
248 static std::vector<sal_Int32> lastColWidths;
249 static bool rowSizeChanged;
250};
251
261std::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 static const OUStringLiteral sHeight( u"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 static const OUStringLiteral sWidth( u"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
362
363 // layout cropped table
364 LayoutTable( mpTableObj->maRect, false, false );
365}
366
367void 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
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
587void SdrTableObjImpl::DragEdge( bool mbHorizontal, int nEdge, sal_Int32 nOffset )
588{
589 if( !((nEdge >= 0) && mxTable.is()))
590 return;
591
592 try
593 {
594 static const OUStringLiteral sSize( u"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 rowSizeChanged = true;
608 }
609 }
610 else
611 {
612 /*
613 fixes fdo#59889 and resizing of table in edge dragging
614 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
615 In LTR table vertical edge responsible for dragging of column x(x=0 to N-1) is, Edge x+1
616 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
617 In LTR table dragging of edge 0(for RTL table edge N) does nothing.
618 */
619 //Todo: Implement Dragging functionality for leftmost edge of table.
620 if (nEdge <= getColumnCount())
621 {
622 const bool bRTL = mpTableObj != nullptr && (mpTableObj->GetWritingMode() == WritingMode_RL_TB);
623 sal_Int32 nWidth;
624 if(bRTL)
625 {
626 nWidth = mpLayouter->getColumnWidth( nEdge );
627 }
628 else
629 {
630 nWidth = mpLayouter->getColumnWidth( (!nEdge)?nEdge:(nEdge-1) );
631 }
632 Reference< XIndexAccess > xCols( mxTable->getColumns(), UNO_QUERY_THROW );
633 nWidth += nOffset;
634 if(bRTL && nEdge<getColumnCount())
635 {
636 Reference< XPropertySet > xColSet( xCols->getByIndex( nEdge ), UNO_QUERY_THROW );
637 xColSet->setPropertyValue( sSize, Any( nWidth ) );
638 }
639 else if(!bRTL && nEdge>0)
640 {
641 Reference< XPropertySet > xColSet( xCols->getByIndex( nEdge-1 ), UNO_QUERY_THROW );
642 xColSet->setPropertyValue( sSize, Any( nWidth ) );
643 }
644 /* To prevent the table resizing on edge dragging */
645 if( nEdge > 0 && nEdge < mxTable->getColumnCount() )
646 {
647 if( bRTL )
648 nEdge--;
649
650 nWidth = mpLayouter->getColumnWidth(nEdge);
651 nWidth = std::max(static_cast<sal_Int32>(nWidth - nOffset), sal_Int32(0));
652
653 Reference<XPropertySet> xColSet(xCols->getByIndex(nEdge), UNO_QUERY_THROW);
654 xColSet->setPropertyValue(sSize, Any(nWidth));
655 }
656 }
657 }
658 }
659 catch( Exception& )
660 {
661 TOOLS_WARN_EXCEPTION("svx.table", "");
662 }
663}
664
665
666// XModifyListener
667
668
669void SAL_CALL SdrTableObjImpl::modified( const css::lang::EventObject& aEvent )
670{
671 if (aEvent.Source == mxTableStyle && mpTableObj)
672 static_cast<TextProperties&>(mpTableObj->GetProperties()).increaseVersion();
673
674 update();
675}
676
678{
679 // source can be the table model itself or the assigned table template
680 TableModelNotifyGuard aGuard( mxTable.get() );
681 if( !mpTableObj )
682 return;
683
685 {
688
691
693 }
694
696
698 LayoutTable( mpTableObj->maRect, false, false );
699
703}
704
705
707{
708 if( mxTableStyle.is() )
709 {
710 Reference< XModifyBroadcaster > xBroadcaster( mxTableStyle, UNO_QUERY );
711 if( xBroadcaster.is() )
712 {
713 Reference< XModifyListener > xListener( static_cast< css::util::XModifyListener* >(this) );
714 xBroadcaster->addModifyListener( xListener );
715 }
716 }
717}
718
719
721{
722 if( mxTableStyle.is() )
723 {
724 Reference< XModifyBroadcaster > xBroadcaster( mxTableStyle, UNO_QUERY );
725 if( xBroadcaster.is() )
726 {
727 Reference< XModifyListener > xListener( static_cast< css::util::XModifyListener* >(this) );
728 xBroadcaster->removeModifyListener( xListener );
729 }
730 }
731}
732
733
735{
736 return mpTableObj && mpTableObj->IsInserted();
737}
738
740{
741 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SdrTableObjImpl"));
742 if (mpLayouter)
743 mpLayouter->dumpAsXml(pWriter);
744 mxTable->dumpAsXml(pWriter);
745 (void)xmlTextWriterEndElement(pWriter);
746}
747
748
749// XEventListener
750
751
752void SAL_CALL SdrTableObjImpl::disposing( const css::lang::EventObject& Source )
753{
754 assert(Source.Source == mxTableStyle);
755 (void)Source;
756
757 Reference<XIndexAccess> xDefaultStyle;
758 try
759 {
760 Reference<XStyleFamiliesSupplier> xSupplier(mpTableObj->getSdrModelFromSdrObject().getUnoModel(), UNO_QUERY_THROW);
761 Reference<XNameAccess> xTableFamily(xSupplier->getStyleFamilies()->getByName("table"), UNO_QUERY_THROW);
762 xDefaultStyle.set(xTableFamily->getByName("default"), UNO_QUERY_THROW);
763 }
764 catch( Exception& )
765 {
766 TOOLS_WARN_EXCEPTION("svx.table", "");
767 }
768
769 mpTableObj->setTableStyle(xDefaultStyle);
770}
771
772
774{
775 CellRef xCell;
776 if( mxTable.is() ) try
777 {
778 xCell.set( dynamic_cast< Cell* >( mxTable->getCellByPosition( rPos.mnCol, rPos.mnRow ).get() ) );
779 }
780 catch( Exception& )
781 {
782 TOOLS_WARN_EXCEPTION("svx.table", "");
783 }
784 return xCell;
785}
786
787
789{
790 return mxTable.is() ? mxTable->getColumnCount() : 0;
791}
792
793std::vector<sal_Int32> SdrTableObjImpl::getColumnWidths() const
794{
795 std::vector<sal_Int32> aRet;
796
797 if (mxTable.is())
798 aRet = mxTable->getColumnWidths();
799
800 return aRet;
801}
802
804{
805 return mxTable.is() ? mxTable->getRowCount() : 0;
806}
807
808void SdrTableObjImpl::LayoutTable( tools::Rectangle& rArea, bool bFitWidth, bool bFitHeight )
809{
811 return;
812 if(!mpLayouter)
813 return;
814
815 // Optimization: SdrTableObj::SetChanged() can call this very often, repeatedly
816 // with the same settings, noticeably increasing load time. Skip if already done.
817 bool bInteractiveMightGrowBecauseTextChanged =
819 WritingMode writingMode = mpTableObj->GetWritingMode();
820 if( bInteractiveMightGrowBecauseTextChanged
821 || lastLayoutTable != this || lastLayoutInputRectangle != rArea
822 || lastLayoutFitWidth != bFitWidth || lastLayoutFitHeight != bFitHeight
823 || lastLayoutMode != writingMode
827 || rowSizeChanged )
828 {
829 lastLayoutTable = this;
831 lastLayoutFitWidth = bFitWidth;
832 lastLayoutFitHeight = bFitHeight;
833 lastLayoutMode = writingMode;
836 // Column resize, when the total width and column count of the
837 // table is unchanged, but re-layout is still needed.
839 TableModelNotifyGuard aGuard( mxTable.get() );
840 mpLayouter->LayoutTable( rArea, bFitWidth, bFitHeight );
842 rowSizeChanged = false;
843 }
844 else
845 {
847 mpLayouter->UpdateBorderLayout();
848 }
849}
850
852{
853 if( mpLayouter && mxTable.is() )
854 {
855 TableModelNotifyGuard aGuard( mxTable.get() );
856 mpLayouter->updateCells( rArea );
857 mxTable->setModified(true);
858 }
859}
860
861
862// BaseProperties section
863
864
865std::unique_ptr<sdr::properties::BaseProperties> SdrTableObj::CreateObjectSpecificProperties()
866{
867 return std::make_unique<TableProperties>(*this);
868}
869
870
871// DrawContact section
872
873
874std::unique_ptr<sdr::contact::ViewContact> SdrTableObj::CreateObjectSpecificViewContact()
875{
876 return std::make_unique<sdr::contact::ViewContactOfTableObj>(*this);
877}
878
880: SdrTextObj(rSdrModel)
881{
882 osl_atomic_increment(&m_refCount); // other I get deleted during construction
883 init( 1, 1 );
884 osl_atomic_decrement(&m_refCount);
885}
886
888: SdrTextObj(rSdrModel, rSource)
889{
890 osl_atomic_increment(&m_refCount);
891
892 init( 1, 1 );
893
894 TableModelNotifyGuard aGuard( mpImpl.is() ? mpImpl->mxTable.get() : nullptr );
895
896 maLogicRect = rSource.maLogicRect;
897 maRect = rSource.maRect;
898 maGeo = rSource.maGeo;
899 meTextKind = rSource.meTextKind;
900 mbTextFrame = rSource.mbTextFrame;
901 maTextSize = rSource.maTextSize;
903 mbNoShear = rSource.mbNoShear;
905
906 // use SdrTableObjImpl::operator= now to
907 // copy model data and other stuff (see there)
908 *mpImpl = *rSource.mpImpl;
909
910 osl_atomic_decrement(&m_refCount);
911}
912
914 SdrModel& rSdrModel,
915 const ::tools::Rectangle& rNewRect,
916 sal_Int32 nColumns,
917 sal_Int32 nRows)
918: SdrTextObj(rSdrModel, rNewRect)
919 ,maLogicRect(rNewRect)
920{
921 osl_atomic_increment(&m_refCount);
922
923 if( nColumns <= 0 )
924 nColumns = 1;
925
926 if( nRows <= 0 )
927 nRows = 1;
928
929 init( nColumns, nRows );
930
931 osl_atomic_decrement(&m_refCount);
932}
933
934
935void SdrTableObj::init( sal_Int32 nColumns, sal_Int32 nRows )
936{
937 m_bClosedObj = true;
938
940 mpImpl->init( this, nColumns, nRows );
941
942 // Stuff done from old SetModel:
943 if( !maLogicRect.IsEmpty() )
944 {
946 mpImpl->LayoutTable( maRect, false, false );
947 }
948}
949
950
952{
953 mpImpl->dispose();
954}
955
956
957// table stuff
958
959
960Reference< XTable > SdrTableObj::getTable() const
961{
962 return mpImpl->mxTable;
963}
964
965
966bool SdrTableObj::isValid( const CellPos& rPos ) const
967{
968 return (rPos.mnCol >= 0) && (rPos.mnCol < mpImpl->getColumnCount()) && (rPos.mnRow >= 0) && (rPos.mnRow < mpImpl->getRowCount());
969}
970
971
973{
974 return CellPos( 0,0 );
975}
976
977
979{
980 CellPos aPos;
981 if( mpImpl->mxTable.is() )
982 {
983 aPos.mnCol = mpImpl->getColumnCount()-1;
984 aPos.mnRow = mpImpl->getRowCount()-1;
985 }
986 return aPos;
987}
988
989
990CellPos SdrTableObj::getLeftCell( const CellPos& rPos, bool bEdgeTravel ) const
991{
992 switch( GetWritingMode() )
993 {
994 default:
995 case WritingMode_LR_TB:
996 return getPreviousCell( rPos, bEdgeTravel );
997 case WritingMode_RL_TB:
998 return getNextCell( rPos, bEdgeTravel );
999 case WritingMode_TB_RL:
1000 return getPreviousRow( rPos, bEdgeTravel );
1001 }
1002}
1003
1004
1005CellPos SdrTableObj::getRightCell( const CellPos& rPos, bool bEdgeTravel ) const
1006{
1007 switch( GetWritingMode() )
1008 {
1009 default:
1010 case WritingMode_LR_TB:
1011 return getNextCell( rPos, bEdgeTravel );
1012 case WritingMode_RL_TB:
1013 return getPreviousCell( rPos, bEdgeTravel );
1014 case WritingMode_TB_RL:
1015 return getNextRow( rPos, bEdgeTravel );
1016 }
1017}
1018
1019
1020CellPos SdrTableObj::getUpCell( const CellPos& rPos, bool bEdgeTravel ) const
1021{
1022 switch( GetWritingMode() )
1023 {
1024 default:
1025 case WritingMode_LR_TB:
1026 case WritingMode_RL_TB:
1027 return getPreviousRow( rPos, bEdgeTravel );
1028 case WritingMode_TB_RL:
1029 return getPreviousCell( rPos, bEdgeTravel );
1030 }
1031}
1032
1033
1034CellPos SdrTableObj::getDownCell( const CellPos& rPos, bool bEdgeTravel ) const
1035{
1036 switch( GetWritingMode() )
1037 {
1038 default:
1039 case WritingMode_LR_TB:
1040 case WritingMode_RL_TB:
1041 return getNextRow( rPos, bEdgeTravel );
1042 case WritingMode_TB_RL:
1043 return getNextCell( rPos, bEdgeTravel );
1044 }
1045}
1046
1047
1048CellPos SdrTableObj::getPreviousCell( const CellPos& rPos, bool bEdgeTravel ) const
1049{
1050 CellPos aPos( rPos );
1051 if( mpImpl.is() )
1052 {
1053 CellRef xCell( mpImpl->getCell( aPos ) );
1054 if( xCell.is() && xCell->isMerged() )
1055 {
1056 sal_Int32 nTemp = 0;
1057 findMergeOrigin( mpImpl->mxTable, aPos.mnCol, aPos.mnRow, aPos.mnCol, nTemp );
1058 }
1059
1060 if( aPos.mnCol > 0 )
1061 {
1062 --aPos.mnCol;
1063 }
1064
1065 else if( bEdgeTravel && (aPos.mnRow > 0) )
1066 {
1067 aPos.mnCol = mpImpl->mxTable->getColumnCount()-1;
1068 --aPos.mnRow;
1069 }
1070 }
1071 return aPos;
1072}
1073
1074
1075CellPos SdrTableObj::getNextCell( const CellPos& rPos, bool bEdgeTravel ) const
1076{
1077 CellPos aPos( rPos );
1078 if( mpImpl.is() )
1079 {
1080 CellRef xCell( mpImpl->getCell( aPos ) );
1081 if( xCell.is() )
1082 {
1083 if( xCell->isMerged() )
1084 {
1085 findMergeOrigin( mpImpl->mxTable, aPos.mnCol, aPos.mnRow, aPos.mnCol, aPos.mnRow );
1086
1087 xCell = mpImpl->getCell(aPos);
1088
1089 if( xCell.is() )
1090 {
1091 aPos.mnCol += xCell->getColumnSpan();
1092 aPos.mnRow = rPos.mnRow;
1093 }
1094 }
1095 else
1096 {
1097 aPos.mnCol += xCell->getColumnSpan();
1098 }
1099
1100 if( aPos.mnCol < mpImpl->mxTable->getColumnCount() )
1101 return aPos;
1102
1103 if( bEdgeTravel && ((aPos.mnRow + 1) < mpImpl->getRowCount()) )
1104 {
1105 aPos.mnCol = 0;
1106 aPos.mnRow += 1;
1107 return aPos;
1108 }
1109 }
1110 }
1111
1112 // last cell reached, no traveling possible
1113 return rPos;
1114}
1115
1116
1117CellPos SdrTableObj::getPreviousRow( const CellPos& rPos, bool bEdgeTravel ) const
1118{
1119 CellPos aPos( rPos );
1120 if( mpImpl.is() )
1121 {
1122 CellRef xCell( mpImpl->getCell( aPos ) );
1123 if( xCell.is() && xCell->isMerged() )
1124 {
1125 sal_Int32 nTemp = 0;
1126 findMergeOrigin( mpImpl->mxTable, aPos.mnCol, aPos.mnRow, nTemp, aPos.mnRow );
1127 }
1128
1129 if( aPos.mnRow > 0 )
1130 {
1131 --aPos.mnRow;
1132 }
1133 else if( bEdgeTravel && (aPos.mnCol > 0) )
1134 {
1135 aPos.mnRow = mpImpl->mxTable->getRowCount()-1;
1136 --aPos.mnCol;
1137 }
1138 }
1139 return aPos;
1140}
1141
1142
1143CellPos SdrTableObj::getNextRow( const CellPos& rPos, bool bEdgeTravel ) const
1144{
1145 CellPos aPos( rPos );
1146
1147 if( mpImpl.is() )
1148 {
1149 CellRef xCell( mpImpl->getCell( rPos ) );
1150 if( xCell.is() )
1151 {
1152 if( xCell->isMerged() )
1153 {
1154 findMergeOrigin( mpImpl->mxTable, aPos.mnCol, aPos.mnRow, aPos.mnCol, aPos.mnRow );
1155 xCell = mpImpl->getCell(aPos);
1156 aPos.mnCol = rPos.mnCol;
1157 }
1158
1159 if( xCell.is() )
1160 aPos.mnRow += xCell->getRowSpan();
1161
1162 if( aPos.mnRow < mpImpl->mxTable->getRowCount() )
1163 return aPos;
1164
1165 if( bEdgeTravel && (aPos.mnCol + 1) < mpImpl->mxTable->getColumnCount() )
1166 {
1167 aPos.mnRow = 0;
1168 aPos.mnCol += 1;
1169
1170 while( aPos.mnCol < mpImpl->mxTable->getColumnCount() )
1171 {
1172 xCell = mpImpl->getCell( aPos );
1173 if( xCell.is() && !xCell->isMerged() )
1174 return aPos;
1175 aPos.mnCol += 1;
1176 }
1177 }
1178 }
1179 }
1180
1181 // last position reached, no more traveling possible
1182 return rPos;
1183}
1184
1185
1187{
1188 if( mpImpl.is())
1189 {
1190 return mpImpl->maTableStyle;
1191 }
1192 else
1193 {
1194 static TableStyleSettings aTmp;
1195 return aTmp;
1196 }
1197}
1198
1199
1201{
1202 if( mpImpl.is() )
1203 {
1204 mpImpl->maTableStyle = rStyle;
1205 mpImpl->update();
1206 }
1207}
1208
1209
1210TableHitKind SdrTableObj::CheckTableHit( const Point& rPos, sal_Int32& rnX, sal_Int32& rnY, const sal_uInt16 aTol ) const
1211{
1212 if( !mpImpl.is() || !mpImpl->mxTable.is() )
1213 return TableHitKind::NONE;
1214
1215 rnX = 0;
1216 rnY = 0;
1217
1218 const sal_Int32 nColCount = mpImpl->getColumnCount();
1219 const sal_Int32 nRowCount = mpImpl->getRowCount();
1220
1221 sal_Int32 nX = rPos.X() - maRect.Left();
1222 sal_Int32 nY = rPos.Y() - maRect.Top();
1223
1224 if( (nX < 0) || (nX > maRect.GetWidth()) || (nY < 0) || (nY > maRect.GetHeight() ) )
1225 return TableHitKind::NONE;
1226
1227 // get vertical edge number and check for a hit
1228 const bool bRTL = (GetWritingMode() == WritingMode_RL_TB);
1229 bool bVrtHit = false;
1230 if( !bRTL )
1231 {
1232 while( rnX <= nColCount )
1233 {
1234 if( nX - aTol <= 0 )
1235 {
1236 bVrtHit = true;
1237 break;
1238 }
1239
1240 if( rnX == nColCount )
1241 break;
1242
1243 nX -= mpImpl->mpLayouter->getColumnWidth( rnX );
1244 if( nX < 0 )
1245 break;
1246 rnX++;
1247 }
1248 }
1249 else
1250 {
1251 rnX = nColCount;
1252 while( rnX >= 0 )
1253 {
1254 if( nX - aTol <= 0 )
1255 {
1256 bVrtHit = true;
1257 break;
1258 }
1259
1260 if( rnX == 0 )
1261 break;
1262
1263 rnX--;
1264 nX -= mpImpl->mpLayouter->getColumnWidth( rnX );
1265 if( nX < 0 )
1266 break;
1267 }
1268 }
1269
1270 // rnX is now the edge number left to the pointer, if it was hit bHrzHit is also true
1271
1272 // get vertical edge number and check for a hit
1273 bool bHrzHit = false;
1274 while( rnY <= nRowCount )
1275 {
1276 if( nY - aTol <= 0 )
1277 {
1278 bHrzHit = true;
1279 break;
1280 }
1281
1282 if( rnY == nRowCount )
1283 break;
1284
1285 nY -= mpImpl->mpLayouter->getRowHeight(rnY);
1286 if( nY < 0 )
1287 break;
1288 rnY++;
1289 }
1290
1291 // rnY is now the edge number above the pointer, if it was hit bVrtHit is also true
1292
1293 if( bVrtHit && mpImpl->mpLayouter->isEdgeVisible( rnX, rnY, false ) )
1295
1296 if( bHrzHit && mpImpl->mpLayouter->isEdgeVisible( rnX, rnY, true ) )
1298
1299 CellRef xCell( mpImpl->getCell( CellPos( rnX, rnY ) ) );
1300 if( xCell.is() && xCell->isMerged() )
1301 findMergeOrigin( mpImpl->mxTable, rnX, rnY, rnX, rnY );
1302
1303 if( xCell.is() )
1304 {
1305 nX += mpImpl->mpLayouter->getColumnWidth( rnX );
1306 //Fix for fdo#62673 : non-editable cell in table on cell merge
1307 sal_Int32 i=0;
1308 while(xCell.is() && xCell->isMerged())
1309 {
1310 nX += mpImpl->mpLayouter->getColumnWidth( rnX+i );
1311 i++;
1312 if(rnX+i < nColCount)
1313 xCell=mpImpl->getCell( CellPos( rnX+i, rnY) );
1314 else
1315 break;
1316 }
1317
1318 if( nX < xCell->GetTextLeftDistance() )
1319 return TableHitKind::Cell;
1320 }
1321
1323}
1324
1326{
1327 return getActiveCell()->GetItemSet();
1328}
1329
1330void SdrTableObj::setTableStyle( const Reference< XIndexAccess >& xTableStyle )
1331{
1332 if( mpImpl.is() && (mpImpl->mxTableStyle != xTableStyle) )
1333 {
1334 mpImpl->disconnectTableStyle();
1335 mpImpl->mxTableStyle = xTableStyle;
1336 mpImpl->connectTableStyle();
1337 mpImpl->update();
1338 }
1339}
1340
1341
1342const Reference< XIndexAccess >& SdrTableObj::getTableStyle() const
1343{
1344 if( mpImpl.is() )
1345 {
1346 return mpImpl->mxTableStyle;
1347 }
1348 else
1349 {
1350 static Reference< XIndexAccess > aTmp;
1351 return aTmp;
1352 }
1353}
1354
1355
1356// text stuff
1357
1358
1361{
1362 return getActiveCell().get();
1363}
1364
1365
1367SdrText* SdrTableObj::getText( sal_Int32 nIndex ) const
1368{
1369 if( mpImpl->mxTable.is() )
1370 {
1371 const sal_Int32 nColCount = mpImpl->getColumnCount();
1372 if( nColCount )
1373 {
1374 CellPos aPos( nIndex % nColCount, nIndex / nColCount );
1375
1376 CellRef xCell( mpImpl->getCell( aPos ) );
1377 return xCell.get();
1378 }
1379 }
1380 return nullptr;
1381}
1382
1383
1386{
1387 if( mpImpl->mxTable.is() )
1388 {
1389 const sal_Int32 nColCount = mpImpl->getColumnCount();
1390 const sal_Int32 nRowCount = mpImpl->getRowCount();
1391
1392 return nColCount * nRowCount;
1393 }
1394 else
1395 {
1396 return 0;
1397 }
1398}
1399
1400
1402void SdrTableObj::setActiveText( sal_Int32 nIndex )
1403{
1404 if( mpImpl.is() && mpImpl->mxTable.is() )
1405 {
1406 const sal_Int32 nColCount = mpImpl->mxTable->getColumnCount();
1407 if( nColCount )
1408 {
1409 CellPos aPos( nIndex % nColCount, nIndex / nColCount );
1410 if( isValid( aPos ) )
1411 setActiveCell( aPos );
1412 }
1413 }
1414}
1415
1416
1418sal_Int32 SdrTableObj::CheckTextHit(const Point& rPnt) const
1419{
1420 if( mpImpl.is() && mpImpl->mxTable.is() )
1421 {
1422 CellPos aPos;
1423 if( CheckTableHit( rPnt, aPos.mnCol, aPos.mnRow ) == TableHitKind::CellTextArea )
1424 return aPos.mnRow * mpImpl->mxTable->getColumnCount() + aPos.mnCol;
1425 }
1426
1427 return 0;
1428}
1429
1431{
1432 if( mpImpl.is() && (mpImpl->getCell( mpImpl->maEditPos ).get() == &rCell) )
1433 return mpEditingOutliner;
1434 else
1435 return nullptr;
1436}
1437
1439{
1440 assert(mpImpl.is() && mpImpl->mpLayouter && "getTableLayouter() error: no mpImpl or mpLayouter (!)");
1441 return *(mpImpl->mpLayouter);
1442}
1443
1445{
1446 return true;
1447}
1448
1450{
1451 return true;
1452}
1453
1455{
1456 return true;
1457}
1458
1460{
1461 return mpEditingOutliner && mpImpl.is() && (rPos == mpImpl->maEditPos);
1462}
1463
1464
1466{
1467 if( (pEditStatus->GetStatusWord() & EditStatusFlags::TextHeightChanged) && mpImpl.is() && mpImpl->mpLayouter )
1468 {
1469 tools::Rectangle aRect0( maRect );
1471 mpImpl->LayoutTable( maRect, false, false );
1473 ActionChanged();
1475 if (aRect0 != maRect)
1477 }
1478}
1479
1480
1482{
1483 rInfo.bResizeFreeAllowed=true;
1484 rInfo.bResizePropAllowed=true;
1485 rInfo.bRotateFreeAllowed=false;
1486 rInfo.bRotate90Allowed =false;
1487 rInfo.bMirrorFreeAllowed=false;
1488 rInfo.bMirror45Allowed =false;
1489 rInfo.bMirror90Allowed =false;
1490
1491 // allow transparence
1492 rInfo.bTransparenceAllowed = true;
1493
1494 rInfo.bShearAllowed =false;
1495 rInfo.bEdgeRadiusAllowed=false;
1496 rInfo.bCanConvToPath =false;
1497 rInfo.bCanConvToPoly =false;
1498 rInfo.bCanConvToPathLineToArea=false;
1499 rInfo.bCanConvToPolyLineToArea=false;
1500 rInfo.bCanConvToContour = false;
1501}
1502
1504{
1505 return SdrObjKind::Table;
1506}
1507
1508void SdrTableObj::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText, tools::Rectangle* pAnchorRect, bool /*bLineWidth*/ ) const
1509{
1510 if( mpImpl.is() )
1511 TakeTextRect( mpImpl->maEditPos, rOutliner, rTextRect, bNoEditText, pAnchorRect );
1512}
1513
1514
1515void SdrTableObj::TakeTextRect( const CellPos& rPos, SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText, tools::Rectangle* pAnchorRect ) const
1516{
1517 if( !mpImpl.is())
1518 return;
1519
1520 CellRef xCell( mpImpl->getCell( rPos ) );
1521 if( !xCell.is() )
1522 return;
1523
1524 tools::Rectangle aAnkRect;
1525 TakeTextAnchorRect( rPos, aAnkRect );
1526
1527 SdrTextVertAdjust eVAdj=xCell->GetTextVerticalAdjust();
1528
1529 EEControlBits nStat0=rOutliner.GetControlWord();
1530 nStat0 |= EEControlBits::AUTOPAGESIZE;
1531 rOutliner.SetControlWord(nStat0);
1532 rOutliner.SetMinAutoPaperSize(Size());
1533 rOutliner.SetMaxAutoPaperSize(aAnkRect.GetSize());
1534 rOutliner.SetPaperSize(aAnkRect.GetSize());
1535
1536 // #103516# New try with _BLOCK for hor and ver after completely
1537 // supporting full width for vertical text.
1538// if( SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting())
1539// {
1540 rOutliner.SetMinAutoPaperSize(Size(aAnkRect.GetWidth(), 0));
1541// }
1542// else if(SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting())
1543// {
1544// rOutliner.SetMinAutoPaperSize(Size(0, aAnkRect.GetHeight()));
1545// }
1546
1547
1548 // set text at outliner, maybe from edit outliner
1550 if (xCell->GetOutlinerParaObject())
1551 pPara = *xCell->GetOutlinerParaObject();
1552 if (mpEditingOutliner && !bNoEditText && mpImpl->mxActiveCell == xCell )
1554
1555 if (pPara)
1556 {
1557 const bool bHitTest(&getSdrModelFromSdrObject().GetHitTestOutliner() == &rOutliner);
1558 const SdrTextObj* pTestObj(rOutliner.GetTextObj());
1559
1560 if( !pTestObj || !bHitTest || (pTestObj != this) || (pTestObj->GetOutlinerParaObject() != xCell->GetOutlinerParaObject()) )
1561 {
1562 if( bHitTest ) // #i33696# take back fix #i27510#
1563 rOutliner.SetTextObj( this );
1564
1565 rOutliner.SetUpdateLayout(true);
1566 rOutliner.SetText(*pPara);
1567 }
1568 }
1569 else
1570 {
1571 rOutliner.SetTextObj( nullptr );
1572 }
1573
1574 rOutliner.SetUpdateLayout(true);
1575 rOutliner.SetControlWord(nStat0);
1576
1577 Point aTextPos(aAnkRect.TopLeft());
1578 Size aTextSiz(rOutliner.GetPaperSize());
1580 {
1581 tools::Long nFreeHgt=aAnkRect.GetHeight()-aTextSiz.Height();
1582 if (eVAdj==SDRTEXTVERTADJUST_CENTER)
1583 aTextPos.AdjustY(nFreeHgt/2 );
1584 if (eVAdj==SDRTEXTVERTADJUST_BOTTOM)
1585 aTextPos.AdjustY(nFreeHgt );
1586 }
1587
1588 if (pAnchorRect)
1589 *pAnchorRect=aAnkRect;
1590
1591 rTextRect=tools::Rectangle(aTextPos,aTextSiz);
1592}
1593
1595{
1596 if( mpImpl.is() )
1597 {
1598 if( !mpImpl->mxActiveCell.is() )
1599 {
1600 CellPos aPos;
1601 const_cast< SdrTableObj* >(this)->setActiveCell( aPos );
1602 }
1603 return mpImpl->mxActiveCell;
1604 }
1605 else
1606 {
1607 static CellRef xCell;
1608 return xCell;
1609 }
1610}
1611
1612
1614{
1615 return mpImpl.is() ? mpImpl->getColumnCount() : 0;
1616}
1617
1619{
1620 return mpImpl.is() ? mpImpl->getRowCount() : 0;
1621}
1622
1623void SdrTableObj::changeEdge(bool bHorizontal, int nEdge, sal_Int32 nOffset)
1624{
1625 if (mpImpl.is())
1626 mpImpl->DragEdge(bHorizontal, nEdge, nOffset);
1627}
1628
1630{
1631 if( !(mpImpl.is() && mpImpl->mxTable.is()) )
1632 return;
1633
1634 try
1635 {
1636 mpImpl->mxActiveCell.set( dynamic_cast< Cell* >( mpImpl->mxTable->getCellByPosition( rPos.mnCol, rPos.mnRow ).get() ) );
1637 if( mpImpl->mxActiveCell.is() && mpImpl->mxActiveCell->isMerged() )
1638 {
1639 CellPos aOrigin;
1640 findMergeOrigin( mpImpl->mxTable, rPos.mnCol, rPos.mnRow, aOrigin.mnCol, aOrigin.mnRow );
1641 mpImpl->mxActiveCell.set( dynamic_cast< Cell* >( mpImpl->mxTable->getCellByPosition( aOrigin.mnCol, aOrigin.mnRow ).get() ) );
1642 mpImpl->maEditPos = aOrigin;
1643 }
1644 else
1645 {
1646 mpImpl->maEditPos = rPos;
1647 }
1648 }
1649 catch( Exception& )
1650 {
1651 TOOLS_WARN_EXCEPTION("svx.table", "");
1652 }
1653}
1654
1655
1657{
1658 rPos = mpImpl->maEditPos;
1659}
1660
1661
1663{
1664 if( mpImpl.is() )
1665 {
1666 CellRef xCell( mpImpl->getCell( rPos ) );
1667 if( xCell.is() )
1668 rCellRect = xCell->getCellRect();
1669 }
1670}
1671
1672
1674{
1675 if( mpImpl.is() )
1676 TakeTextAnchorRect( mpImpl->maEditPos, rAnchorRect );
1677}
1678
1679
1680void SdrTableObj::TakeTextAnchorRect( const CellPos& rPos, tools::Rectangle& rAnchorRect ) const
1681{
1682 tools::Rectangle aAnkRect(maRect);
1683
1684 if( mpImpl.is() )
1685 {
1686 CellRef xCell( mpImpl->getCell( rPos ) );
1687 if( xCell.is() )
1688 xCell->TakeTextAnchorRect( aAnkRect );
1689 }
1690
1691 ImpJustifyRect(aAnkRect);
1692 rAnchorRect=aAnkRect;
1693}
1694
1695
1696void SdrTableObj::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, tools::Rectangle* pViewInit, tools::Rectangle* pViewMin) const
1697{
1698 if( mpImpl.is() )
1699 TakeTextEditArea( mpImpl->maEditPos, pPaperMin, pPaperMax, pViewInit, pViewMin );
1700}
1701
1702
1703void SdrTableObj::TakeTextEditArea( const CellPos& rPos, Size* pPaperMin, Size* pPaperMax, tools::Rectangle* pViewInit, tools::Rectangle* pViewMin ) const
1704{
1705 Size aPaperMin,aPaperMax;
1706 tools::Rectangle aViewInit;
1707 TakeTextAnchorRect( rPos, aViewInit );
1708
1709 Size aAnkSiz(aViewInit.GetSize());
1710 aAnkSiz.AdjustWidth( -1 ); aAnkSiz.AdjustHeight( -1 ); // because GetSize() increments by one
1711
1712 Size aMaxSiz(aAnkSiz.Width(),1000000);
1713 Size aTmpSiz(getSdrModelFromSdrObject().GetMaxObjSize());
1714 if (aTmpSiz.Height()!=0)
1715 aMaxSiz.setHeight(aTmpSiz.Height() );
1716
1717 CellRef xCell( mpImpl->getCell( rPos ) );
1718 SdrTextVertAdjust eVAdj = xCell.is() ? xCell->GetTextVerticalAdjust() : SDRTEXTVERTADJUST_TOP;
1719
1720 aPaperMax=aMaxSiz;
1721
1722 aPaperMin.setWidth( aAnkSiz.Width() );
1723
1724 if (pViewMin!=nullptr)
1725 {
1726 *pViewMin=aViewInit;
1727 tools::Long nYFree=aAnkSiz.Height()-aPaperMin.Height();
1728
1729 if (eVAdj==SDRTEXTVERTADJUST_TOP)
1730 {
1731 pViewMin->AdjustBottom( -nYFree );
1732 }
1733 else if (eVAdj==SDRTEXTVERTADJUST_BOTTOM)
1734 {
1735 pViewMin->AdjustTop(nYFree );
1736 }
1737 else
1738 {
1739 pViewMin->AdjustTop(nYFree/2 );
1740 pViewMin->SetBottom(pViewMin->Top()+aPaperMin.Height() );
1741 }
1742 }
1743
1744
1745 if(IsVerticalWriting())
1746 aPaperMin.setWidth( 0 );
1747 else
1748 aPaperMin.setHeight( 0 );
1749
1750 if (pPaperMin!=nullptr) *pPaperMin=aPaperMin;
1751 if (pPaperMax!=nullptr) *pPaperMax=aPaperMax;
1752 if (pViewInit!=nullptr) *pViewInit=aViewInit;
1753}
1754
1755
1757{
1758 EEAnchorMode eRet=EEAnchorMode::TopLeft;
1759 CellRef xCell( getActiveCell() );
1760 if( xCell.is() )
1761 {
1762 SdrTextVertAdjust eV=xCell->GetTextVerticalAdjust();
1763
1764 {
1765 if (eV==SDRTEXTVERTADJUST_TOP)
1766 {
1767 eRet=EEAnchorMode::TopLeft;
1768 }
1769 else if (eV==SDRTEXTVERTADJUST_BOTTOM)
1770 {
1771 eRet=EEAnchorMode::BottomLeft;
1772 }
1773 else
1774 {
1775 eRet=EEAnchorMode::VCenterLeft;
1776 }
1777 }
1778 }
1779 return eRet;
1780}
1781
1782
1784{
1785 OUString sName(SvxResId(STR_ObjNameSingulTable));
1786
1787 OUString aName(GetName());
1788 if (!aName.isEmpty())
1789 sName += " '" + aName + "'";
1790
1791 return sName;
1792}
1793
1794
1796{
1797 return SvxResId(STR_ObjNamePluralTable);
1798}
1799
1800
1802{
1803 return new SdrTableObj(rTargetModel, *this);
1804}
1805
1806
1808{
1809 return maRect;
1810}
1811
1812
1814{
1815 NbcSetLogicRect( rRect );
1816}
1817
1818
1820{
1821 return maLogicRect;
1822}
1823
1824
1826{
1827}
1828
1829
1831{
1832 if( mpEditingOutliner != nullptr )
1833 return false;
1834
1835 mpEditingOutliner=&rOutl;
1836
1837 mbInEditMode = true;
1838
1839 rOutl.Init( OutlinerMode::TextObject );
1840 rOutl.SetRefDevice(getSdrModelFromSdrObject().GetRefDevice());
1841
1842 bool bUpdateMode = rOutl.SetUpdateLayout(false);
1843 Size aPaperMin;
1844 Size aPaperMax;
1845 tools::Rectangle aEditArea;
1846 TakeTextEditArea(&aPaperMin,&aPaperMax,&aEditArea,nullptr);
1847
1848 rOutl.SetMinAutoPaperSize(aPaperMin);
1849 rOutl.SetMaxAutoPaperSize(aPaperMax);
1850 rOutl.SetPaperSize(aPaperMax);
1851
1852 if (bUpdateMode) rOutl.SetUpdateLayout(true);
1853
1854 EEControlBits nStat=rOutl.GetControlWord();
1855 nStat |= EEControlBits::AUTOPAGESIZE;
1856 nStat &=~EEControlBits::STRETCHING;
1857 rOutl.SetControlWord(nStat);
1858
1860 if(pPara)
1861 rOutl.SetText(*pPara);
1862
1863 rOutl.UpdateFields();
1864 rOutl.ClearModifyFlag();
1865
1866 return true;
1867}
1868
1869
1871{
1872
1873 if (getSdrModelFromSdrObject().IsUndoEnabled() && !mpImpl->maUndos.empty())
1874 {
1875 // These actions should be on the undo stack after text edit.
1876 for (std::unique_ptr<SdrUndoAction>& pAction : mpImpl->maUndos)
1877 getSdrModelFromSdrObject().AddUndo( std::move(pAction));
1878 mpImpl->maUndos.clear();
1879
1880 getSdrModelFromSdrObject().AddUndo(getSdrModelFromSdrObject().GetSdrUndoFactory().CreateUndoGeoObject(*this));
1881 }
1882
1883 if(rOutl.IsModified())
1884 {
1886 Paragraph* p1stPara = rOutl.GetParagraph( 0 );
1887 sal_Int32 nParaCnt = rOutl.GetParagraphCount();
1888
1889 if(p1stPara)
1890 {
1891 // to remove the grey field background
1892 rOutl.UpdateFields();
1893
1894 // create new text object
1895 pNewText = rOutl.CreateParaObject( 0, nParaCnt );
1896 }
1897 SetOutlinerParaObject(std::move(pNewText));
1898 }
1899
1900 mpEditingOutliner = nullptr;
1901 rOutl.Clear();
1902 EEControlBits nStat = rOutl.GetControlWord();
1903 nStat &= ~EEControlBits::AUTOPAGESIZE;
1904 rOutl.SetControlWord(nStat);
1905
1906 mbInEditMode = false;
1907}
1908
1909
1911{
1912 CellRef xCell( getActiveCell() );
1913 if( xCell.is() )
1914 return xCell->GetOutlinerParaObject();
1915 else
1916 return nullptr;
1917}
1918
1919
1921{
1922 CellRef xCell( getActiveCell() );
1923 if( !xCell.is() )
1924 return;
1925
1926 // Update HitTestOutliner
1927 const SdrTextObj* pTestObj(getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj());
1928
1929 if(pTestObj && pTestObj->GetOutlinerParaObject() == xCell->GetOutlinerParaObject())
1930 {
1932 }
1933
1934 xCell->SetOutlinerParaObject( std::move(pTextObject) );
1937}
1938
1939
1941{
1942 maLogicRect=rRect;
1944 const bool bWidth = maLogicRect.getOpenWidth() != maRect.getOpenWidth();
1945 const bool bHeight = maLogicRect.getOpenHeight() != maRect.getOpenHeight();
1947 if (mpImpl->mbSkipChangeLayout)
1948 // Avoid distributing newly available space between existing cells.
1950 else
1951 NbcAdjustTextFrameWidthAndHeight(!bHeight, !bWidth);
1953}
1954
1955
1956void SdrTableObj::AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool /* bShrinkOnly = false */ )
1957{
1958 tools::Rectangle aAdjustRect( rMaxRect );
1959 aAdjustRect.setHeight( GetLogicRect().getOpenHeight() );
1960 SetLogicRect( aAdjustRect );
1961}
1962
1963
1965{
1966 maLogicRect.Move(rSiz);
1967 SdrTextObj::NbcMove( rSiz );
1968 if( mpImpl.is() )
1969 mpImpl->UpdateCells( maRect );
1970}
1971
1972
1973void SdrTableObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
1974{
1975 tools::Rectangle aOldRect( maLogicRect );
1976 ResizeRect(maLogicRect,rRef,xFact,yFact);
1977
1981}
1982
1983
1985{
1986 tools::Rectangle aNewRect(maLogicRect);
1987 bool bRet=AdjustTextFrameWidthAndHeight(aNewRect);
1988 if (bRet)
1989 {
1990 tools::Rectangle aBoundRect0;
1991 if (m_pUserCall!=nullptr)
1992 aBoundRect0=GetLastBoundRect();
1993 maRect = aNewRect;
1995 SetChanged();
1998 }
1999 return bRet;
2000}
2001
2002
2003bool SdrTableObj::AdjustTextFrameWidthAndHeight(tools::Rectangle& rR, bool bHeight, bool bWidth) const
2004{
2005 if(rR.IsEmpty() || !mpImpl.is() || !mpImpl->mxTable.is())
2006 return false;
2007
2008 tools::Rectangle aRectangle( rR );
2009 mpImpl->LayoutTable( aRectangle, !bWidth, !bHeight );
2010
2011 if( aRectangle != rR )
2012 {
2013 rR = aRectangle;
2014 return true;
2015 }
2016 else
2017 {
2018 return false;
2019 }
2020}
2021
2022
2024{
2026}
2027
2028
2030{
2032 return rModeItem.GetValue() == css::text::WritingMode_TB_RL;
2033}
2034
2035
2037{
2038 if(bVertical != IsVerticalWriting() )
2039 {
2040 SvxWritingModeItem aModeItem( css::text::WritingMode_LR_TB, SDRATTR_TEXTDIRECTION );
2041 SetObjectItem( aModeItem );
2042 }
2043}
2044
2045
2047{
2048 SfxStyleSheet* pStyle = GetStyleSheet();
2049 if ( !pStyle )
2050 return WritingMode_LR_TB;
2051
2052 WritingMode eWritingMode = WritingMode_LR_TB;
2053 const SfxItemSet &rSet = pStyle->GetItemSet();
2054
2056 eWritingMode = pItem->GetValue();
2057
2058 if ( const SvxFrameDirectionItem *pItem;
2059 ( eWritingMode != WritingMode_TB_RL ) &&
2060 ( pItem = rSet.GetItemIfSet( EE_PARA_WRITINGDIR, false ) ) )
2061 {
2062 if ( pItem->GetValue() == SvxFrameDirection::Horizontal_LR_TB )
2063 eWritingMode = WritingMode_LR_TB;
2064 else
2065 eWritingMode = WritingMode_RL_TB;
2066 }
2067
2068 return eWritingMode;
2069}
2070
2072{
2073 mpImpl->maUndos.push_back(std::unique_ptr<SdrUndoAction>(pUndo));
2074}
2075
2076void SdrTableObj::SetSkipChangeLayout(bool bSkipChangeLayout)
2077{
2078 mpImpl->mbSkipChangeLayout = bSkipChangeLayout;
2079}
2080
2082{
2084}
2085
2087{
2088 return false;
2089}
2090
2092{
2093 sal_uInt32 nCount = SdrTextObj::GetHdlCount();
2094 const sal_Int32 nRowCount = mpImpl->getRowCount();
2095 const sal_Int32 nColCount = mpImpl->getColumnCount();
2096
2097 if( nRowCount && nColCount )
2098 nCount += nRowCount + nColCount + 2 + 1;
2099
2100 return nCount;
2101}
2102
2104{
2105 const sal_Int32 nRowCount = mpImpl->getRowCount();
2106 const sal_Int32 nColCount = mpImpl->getColumnCount();
2107
2108 // first add row handles
2109 std::vector<TableEdgeHdl*> aRowEdges(nRowCount + 1);
2110 for (auto const & rEdge : mpImpl->mpLayouter->getHorizontalEdges())
2111 {
2112 Point aPoint(maRect.TopLeft());
2113 aPoint.AdjustY(rEdge.nPosition);
2114
2115 std::unique_ptr<TableEdgeHdl> pHdl(new TableEdgeHdl(aPoint, true, rEdge.nMin, rEdge.nMax, nColCount + 1));
2116 pHdl->SetPointNum(rEdge.nIndex);
2117 aRowEdges[rEdge.nIndex] = pHdl.get();
2118 rHdlList.AddHdl(std::move(pHdl));
2119 }
2120
2121 // second add column handles
2122 std::vector<TableEdgeHdl*> aColEdges(nColCount + 1);
2123 for (auto const & rEdge : mpImpl->mpLayouter->getVerticalEdges())
2124 {
2125 Point aPoint(maRect.TopLeft());
2126 aPoint.AdjustX(rEdge.nPosition);
2127
2128 std::unique_ptr<TableEdgeHdl> pHdl(new TableEdgeHdl(aPoint, false, rEdge.nMin, rEdge.nMax, nRowCount + 1));
2129 pHdl->SetPointNum(rEdge.nIndex);
2130 aColEdges[rEdge.nIndex] = pHdl.get();
2131 rHdlList.AddHdl(std::move(pHdl));
2132 }
2133
2134 // now add visible edges to row and column handles
2135 if( mpImpl->mpLayouter )
2136 {
2137 TableLayouter& rLayouter = *mpImpl->mpLayouter;
2138
2139 sal_Int32 nY = 0;
2140
2141 for( sal_Int32 nRow = 0; nRow <= nRowCount; ++nRow )
2142 {
2143 const sal_Int32 nRowHeight = (nRow == nRowCount) ? 0 : rLayouter.getRowHeight(nRow);
2144 sal_Int32 nX = 0;
2145
2146 for( sal_Int32 nCol = 0; nCol <= nColCount; ++nCol )
2147 {
2148 const sal_Int32 nColWidth = (nCol == nColCount) ? 0 : rLayouter.getColumnWidth(nCol);
2149
2150 if( nRowHeight > 0 )
2151 {
2152 if( rLayouter.isEdgeVisible( nCol, nRow, false ) )
2153 aColEdges[nCol]->SetEdge( nRow, nY, nY + nRowHeight, (rLayouter.getBorderLine( nCol, nRow, false ) == nullptr) ? Visible : Invisible);
2154 }
2155
2156 if( nColWidth > 0 )
2157 {
2158 if( rLayouter.isEdgeVisible( nCol, nRow, true ) )
2159 aRowEdges[nRow]->SetEdge( nCol, nX, nX + nColWidth, (rLayouter.getBorderLine( nCol, nRow, true ) == nullptr) ? Visible : Invisible);
2160 }
2161
2162 nX += nColWidth;
2163 }
2164
2165 nY += nRowHeight;
2166 }
2167 }
2168
2169 // add remaining handles
2170 SdrHdlList tempList(nullptr);
2171 tempList.AddHdl( std::make_unique<TableBorderHdl>( maRect, !IsTextEditActive() ) );
2172 tempList.AddHdl( std::make_unique<SdrHdl>(maRect.TopLeft(),SdrHdlKind::UpperLeft) );
2173 tempList.AddHdl( std::make_unique<SdrHdl>(maRect.TopCenter(),SdrHdlKind::Upper) );
2174 tempList.AddHdl( std::make_unique<SdrHdl>(maRect.TopRight(),SdrHdlKind::UpperRight) );
2175 tempList.AddHdl( std::make_unique<SdrHdl>(maRect.LeftCenter(),SdrHdlKind::Left) );
2176 tempList.AddHdl( std::make_unique<SdrHdl>(maRect.RightCenter(),SdrHdlKind::Right) );
2177 tempList.AddHdl( std::make_unique<SdrHdl>(maRect.BottomLeft(),SdrHdlKind::LowerLeft) );
2178 tempList.AddHdl( std::make_unique<SdrHdl>(maRect.BottomCenter(),SdrHdlKind::Lower) );
2179 tempList.AddHdl( std::make_unique<SdrHdl>(maRect.BottomRight(),SdrHdlKind::LowerRight) );
2180 for( size_t nHdl = 0; nHdl < tempList.GetHdlCount(); ++nHdl )
2181 tempList.GetHdl(nHdl)->SetMoveOutside(true);
2182 tempList.MoveTo(rHdlList);
2183
2184 const size_t nHdlCount = rHdlList.GetHdlCount();
2185 for( size_t nHdl = 0; nHdl < nHdlCount; ++nHdl )
2186 rHdlList.GetHdl(nHdl)->SetObj(const_cast<SdrTableObj*>(this));
2187}
2188
2189// Dragging
2190
2192{
2193 return true;
2194}
2195
2197{
2198 const SdrHdl* pHdl = rDrag.GetHdl();
2199 const SdrHdlKind eHdl((pHdl == nullptr) ? SdrHdlKind::Move : pHdl->GetKind());
2200
2201 switch( eHdl )
2202 {
2204 case SdrHdlKind::Upper:
2206 case SdrHdlKind::Left:
2207 case SdrHdlKind::Right:
2209 case SdrHdlKind::Lower:
2211 case SdrHdlKind::Move:
2212 {
2213 break;
2214 }
2215
2216 case SdrHdlKind::User:
2217 {
2218 rDrag.SetEndDragChangesAttributes(false);
2219 rDrag.SetNoSnap();
2220 break;
2221 }
2222
2223 default:
2224 {
2225 return false;
2226 }
2227 }
2228
2229 return true;
2230}
2231
2233{
2234 bool bRet(true);
2235 const SdrHdl* pHdl = rDrag.GetHdl();
2236 const SdrHdlKind eHdl((pHdl == nullptr) ? SdrHdlKind::Move : pHdl->GetKind());
2237
2238 switch( eHdl )
2239 {
2241 case SdrHdlKind::Upper:
2243 case SdrHdlKind::Left:
2244 case SdrHdlKind::Right:
2246 case SdrHdlKind::Lower:
2248 {
2249 const tools::Rectangle aNewRectangle(ImpDragCalcRect(rDrag));
2250
2251 if (aNewRectangle != maRect)
2252 {
2253 NbcSetLogicRect(aNewRectangle);
2254 }
2255
2256 break;
2257 }
2258
2259 case SdrHdlKind::Move:
2260 {
2261 NbcMove( Size( rDrag.GetDX(), rDrag.GetDY() ) );
2262 break;
2263 }
2264
2265 case SdrHdlKind::User:
2266 {
2267 rDrag.SetEndDragChangesAttributes(false);
2268 rDrag.SetNoSnap();
2269 const TableEdgeHdl* pEdgeHdl = dynamic_cast< const TableEdgeHdl* >( pHdl );
2270
2271 if( pEdgeHdl )
2272 {
2273 if( IsInserted() )
2274 {
2275 rDrag.SetEndDragChangesAttributes(true);
2276 rDrag.SetEndDragChangesLayout(true);
2277 }
2278
2279 mpImpl->DragEdge( pEdgeHdl->IsHorizontalEdge(), pEdgeHdl->GetPointNum(), pEdgeHdl->GetValidDragOffset( rDrag ) );
2280 }
2281 break;
2282 }
2283
2284 default:
2285 {
2286 bRet = false;
2287 }
2288 }
2289
2290 return bRet;
2291}
2292
2294{
2296 const SdrHdl* pHdl = rDrag.GetHdl();
2297
2298 if( pHdl && (SdrHdlKind::User == pHdl->GetKind()) )
2299 {
2300 const TableEdgeHdl* pEdgeHdl = dynamic_cast< const TableEdgeHdl* >( pHdl );
2301
2302 if( pEdgeHdl )
2303 {
2304 aRetval = pEdgeHdl->getSpecialDragPoly( rDrag );
2305 }
2306 }
2307
2308 return aRetval;
2309}
2310
2311
2312// Create
2313
2314
2316{
2317 rStat.SetOrtho4Possible();
2318 tools::Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
2319 aRect1.Normalize();
2320 rStat.SetActionRect(aRect1);
2321 maRect = aRect1;
2322 return true;
2323}
2324
2325
2327{
2328 tools::Rectangle aRect1;
2329 rStat.TakeCreateRect(aRect1);
2330 ImpJustifyRect(aRect1);
2331 rStat.SetActionRect(aRect1);
2332 maRect = aRect1; // for ObjName
2334 m_bSnapRectDirty=true;
2335 return true;
2336}
2337
2338
2340{
2341 rStat.TakeCreateRect(maRect);
2343 return (eCmd==SdrCreateCmd::ForceEnd || rStat.GetPointCount()>=2);
2344}
2345
2347{
2348}
2349
2350
2352{
2353 return true;
2354}
2355
2356
2358{
2359 tools::Rectangle aRect1;
2360 rDrag.TakeCreateRect(aRect1);
2361 aRect1.Normalize();
2362
2366 return aRetval;
2367}
2368
2369
2371{
2372 return PointerStyle::Cross;
2373}
2374
2375
2377{
2378 xNewCell = Cell::create( *this );
2379}
2380
2381
2382std::unique_ptr<SdrObjGeoData> SdrTableObj::NewGeoData() const
2383{
2384 return std::make_unique<TableObjectGeoData>();
2385}
2386
2387
2389{
2390 DBG_ASSERT( dynamic_cast< TableObjectGeoData* >( &rGeo ), "svx::SdrTableObj::SaveGeoData(), illegal geo data!" );
2392
2393 static_cast<TableObjectGeoData &>(rGeo).maLogicRect = maLogicRect;
2394}
2395
2396
2398{
2399 DBG_ASSERT( dynamic_cast< const TableObjectGeoData* >( &rGeo ), "svx::SdrTableObj::RestoreGeoData(), illegal geo data!" );
2400
2401 maLogicRect = static_cast<const TableObjectGeoData &>(rGeo).maLogicRect;
2402
2404
2405 if( mpImpl.is() )
2406 mpImpl->LayoutTable(maRect, false, false);
2407 ActionChanged();
2408}
2409
2411{
2412 if(!mpImpl.is())
2413 {
2414 return;
2415 }
2416
2417 mpImpl->CropTableModelToSelection(rStart, rEnd);
2418}
2419
2421{
2422 if( mpImpl.is() && mpImpl->mpLayouter)
2423 {
2424 mpImpl->mpLayouter->LayoutTableHeight(rArea, bFit);
2425 }
2426}
2427
2428void SdrTableObj::DistributeColumns( sal_Int32 nFirstColumn, sal_Int32 nLastColumn, const bool bOptimize, const bool bMinimize )
2429{
2430 if( mpImpl.is() && mpImpl->mpLayouter )
2431 {
2432 TableModelNotifyGuard aGuard( mpImpl->mxTable.get() );
2433 mpImpl->mpLayouter->DistributeColumns( maRect, nFirstColumn, nLastColumn, bOptimize, bMinimize );
2434 }
2435}
2436
2437
2438void SdrTableObj::DistributeRows( sal_Int32 nFirstRow, sal_Int32 nLastRow, const bool bOptimize, const bool bMinimize )
2439{
2440 if( mpImpl.is() && mpImpl->mpLayouter )
2441 {
2442 TableModelNotifyGuard aGuard( mpImpl->mxTable.get() );
2443 mpImpl->mpLayouter->DistributeRows( maRect, nFirstRow, nLastRow, bOptimize, bMinimize );
2444 }
2445}
2446
2447
2449{
2450 if( mpImpl.is() )
2451 {
2452 mpImpl->LayoutTable( maRect, false, false );
2453 }
2454
2456}
2457
2458
2460{
2461 if( mpImpl.is() && mpImpl->mxTable.is() )
2462 mpImpl->mxTable->lockBroadcasts();
2463}
2464
2465
2467{
2468 if( mpImpl.is() && mpImpl->mxTable.is() )
2469 mpImpl->mxTable->unlockBroadcasts();
2470}
2471
2473{
2474 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SdrTableObj"));
2475 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
2476
2477 SdrObject::dumpAsXml(pWriter);
2478
2479 mpImpl->dumpAsXml(pWriter);
2480
2481 (void)xmlTextWriterEndElement(pWriter);
2482}
2483
2484bool SdrTableObj::createTableEdgesJson(boost::property_tree::ptree & rJsonRoot)
2485{
2486 if (!mpImpl.is() || !mpImpl->mxTable.is())
2487 return false;
2488
2490 boost::property_tree::ptree aTableColumns;
2491 {
2492 aTableColumns.put("tableOffset", o3tl::toTwips(aRect.Left(), o3tl::Length::mm100));
2493
2494 boost::property_tree::ptree aEntries;
2495 auto const & aEdges = mpImpl->mpLayouter->getVerticalEdges();
2496 for (auto & rEdge : aEdges)
2497 {
2498 if (rEdge.nIndex == 0)
2499 {
2500 aTableColumns.put("left", o3tl::toTwips(rEdge.nPosition, o3tl::Length::mm100));
2501 }
2502 else if (rEdge.nIndex == sal_Int32(aEdges.size() - 1))
2503 {
2504 aTableColumns.put("right", o3tl::toTwips(rEdge.nPosition, o3tl::Length::mm100));
2505 }
2506 else
2507 {
2508 boost::property_tree::ptree aEntry;
2509 aEntry.put("position", o3tl::toTwips(rEdge.nPosition, o3tl::Length::mm100));
2510 aEntry.put("min", o3tl::toTwips(rEdge.nPosition + rEdge.nMin, o3tl::Length::mm100));
2511 aEntry.put("max", o3tl::toTwips(rEdge.nPosition + rEdge.nMax, o3tl::Length::mm100));
2512 aEntry.put("hidden", false);
2513 aEntries.push_back(std::make_pair("", aEntry));
2514 }
2515 }
2516 aTableColumns.push_back(std::make_pair("entries", aEntries));
2517 }
2518 rJsonRoot.add_child("columns", aTableColumns);
2519
2520 boost::property_tree::ptree aTableRows;
2521 {
2522 aTableRows.put("tableOffset", o3tl::toTwips(aRect.Top(), o3tl::Length::mm100));
2523
2524 boost::property_tree::ptree aEntries;
2525 auto const & aEdges = mpImpl->mpLayouter->getHorizontalEdges();
2526 for (auto & rEdge : aEdges)
2527 {
2528 if (rEdge.nIndex == 0)
2529 {
2530 aTableRows.put("left", o3tl::toTwips(rEdge.nPosition, o3tl::Length::mm100));
2531 }
2532 else if (rEdge.nIndex == sal_Int32(aEdges.size() - 1))
2533 {
2534 aTableRows.put("right", o3tl::toTwips(rEdge.nPosition, o3tl::Length::mm100));
2535 }
2536 else
2537 {
2538 boost::property_tree::ptree aEntry;
2539 aEntry.put("position", o3tl::toTwips(rEdge.nPosition, o3tl::Length::mm100));
2540 aEntry.put("min", o3tl::toTwips(rEdge.nPosition + rEdge.nMin, o3tl::Length::mm100));
2541 aEntry.put("max", o3tl::toTwips(rEdge.nPosition + rEdge.nMax, o3tl::Length::mm100));
2542 aEntry.put("hidden", false);
2543 aEntries.push_back(std::make_pair("", aEntry));
2544 }
2545 }
2546 aTableRows.push_back(std::make_pair("entries", aEntries));
2547 }
2548 rJsonRoot.add_child("rows", aTableRows);
2549 return true;
2550}
2551
2552}
2553
2554/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
EditStatusFlags GetStatusWord() const
void SetMaxAutoPaperSize(const Size &rSz)
void SetText(const OutlinerParaObject &)
const Size & GetPaperSize() const
Paragraph * GetParagraph(sal_Int32 nAbsPos) const
void SetMinAutoPaperSize(const Size &rSz)
std::optional< OutlinerParaObject > CreateParaObject(sal_Int32 nStartPara=0, sal_Int32 nParaCount=EE_PARA_ALL) const
void SetPaperSize(const Size &rSize)
void Clear()
bool SetUpdateLayout(bool bUpdate)
EEControlBits GetControlWord() const
void SetControlWord(EEControlBits nWord)
bool UpdateFields()
void SetRefDevice(OutputDevice *pRefDev)
void ClearModifyFlag()
void Init(OutlinerMode nMode)
bool IsModified() const
sal_Int32 GetParagraphCount() const
void SetActionRect(const tools::Rectangle &rR)
Definition: svddrag.hxx:167
sal_Int32 GetPointCount() const
Definition: svddrag.hxx:101
void TakeCreateRect(tools::Rectangle &rRect) const
Definition: svddrag.cxx:115
tools::Long GetDY() const
Definition: svddrag.hxx:159
void SetOrtho4Possible(bool bOn=true)
Definition: svddrag.hxx:136
const Point & GetStart() const
Definition: svddrag.hxx:102
const SdrHdl * GetHdl() const
Definition: svddrag.hxx:111
const Point & GetNow() const
Definition: svddrag.hxx:105
void SetNoSnap(bool bOn=true)
Definition: svddrag.hxx:131
void SetEndDragChangesAttributes(bool bOn)
Definition: svddrag.hxx:143
tools::Long GetDX() const
Definition: svddrag.hxx:158
void SetEndDragChangesLayout(bool bOn)
Definition: svddrag.hxx:147
void MoveTo(SdrHdlList &rOther)
Definition: svdhdl.cxx:2325
size_t GetHdlCount() const
Definition: svdhdl.hxx:459
void AddHdl(std::unique_ptr< SdrHdl > pHdl)
Definition: svdhdl.cxx:2291
SdrHdl * GetHdl(size_t nNum) const
Definition: svdhdl.hxx:460
SdrHdlKind GetKind() const
Definition: svdhdl.hxx:194
void SetMoveOutside(bool bMoveOutside)
Definition: svdhdl.cxx:322
void SetObj(SdrObject *pNewObj)
Definition: svdhdl.cxx:380
sal_uInt32 GetPointNum() const
Definition: svdhdl.hxx:222
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
Definition: svdmodel.cxx:494
css::uno::Reference< css::uno::XInterface > const & getUnoModel()
Definition: svdmodel.cxx:1572
SdrOutliner & GetHitTestOutliner() const
Definition: svdmodel.hxx:323
All geometrical data of an arbitrary object for use in undo/redo.
Definition: svdobj.hxx:175
Provides information about various ZObject properties.
Definition: svdobj.hxx:197
Abstract DrawObject.
Definition: svdobj.hxx:261
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: svdobj.cxx:1774
void ActionChanged() const
Definition: svdobj.cxx:273
void SetOutlinerParaObject(std::optional< OutlinerParaObject > pTextObject)
Definition: svdobj.cxx:1801
virtual sdr::properties::BaseProperties & GetProperties() const
Definition: svdobj.cxx:220
void BroadcastObjectChange() const
Definition: svdobj.cxx:978
void SetObjectItem(const SfxPoolItem &rItem)
Definition: svdobj.cxx:1982
const SfxPoolItem & GetObjectItem(const sal_uInt16 nWhich) const
Definition: svdobj.cxx:2007
bool m_bSnapRectDirty
Definition: svdobj.hxx:908
virtual const tools::Rectangle & GetCurrentBoundRect() const
Definition: svdobj.cxx:926
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:289
SdrObjUserCall * m_pUserCall
Definition: svdobj.hxx:903
virtual void SetLogicRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1699
SfxStyleSheet * GetStyleSheet() const
Definition: svdobj.cxx:2247
virtual const OUString & GetName() const
Definition: svdobj.cxx:769
void SendUserCall(SdrUserCallType eUserCall, const tools::Rectangle &rBoundRect) const
Definition: svdobj.cxx:2766
virtual void SetChanged()
Definition: svdobj.cxx:1002
virtual const tools::Rectangle & GetLastBoundRect() const
Definition: svdobj.cxx:940
bool IsInserted() const
Definition: svdobj.hxx:750
bool m_bClosedObj
Definition: svdobj.hxx:921
virtual void SetBoundRectDirty()
Definition: svdobj.cxx:329
virtual void SetBoundAndSnapRectsDirty(bool bNotMyself=false, bool bRecursive=true)
Definition: svdobj.cxx:509
void SetTextObj(const SdrTextObj *pObj)
Definition: svdoutl.cxx:40
const SdrTextObj * GetTextObj() const
Definition: svdoutl.cxx:87
GeoStat maGeo
Definition: svdotext.hxx:171
virtual void SaveGeoData(SdrObjGeoData &rGeo) const override
Definition: svdotext.cxx:1431
virtual void RestoreGeoData(const SdrObjGeoData &rGeo) override
Definition: svdotext.cxx:1439
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 sal_uInt32 GetHdlCount() const override
Via GetHdlCount the number of Handles can be retrieved.
Definition: svdotxdr.cxx:36
bool mbInEditMode
Definition: svdotext.hxx:221
SdrOutliner * mpEditingOutliner
Definition: svdotext.hxx:182
tools::Rectangle maRect
Definition: svdotext.hxx:168
virtual OutlinerParaObject * GetOutlinerParaObject() const override
Definition: svdotext.cxx:1344
tools::Long GetTextLeftDistance() const
Left inner spacing to borders
Definition: svdotext.cxx:1751
virtual bool NbcAdjustTextFrameWidthAndHeight(bool bHgt=true, bool bWdt=true)
Definition: svdotxat.cxx:241
static void ImpJustifyRect(tools::Rectangle &rRect)
Definition: svdotext.cxx:405
bool mbDisableAutoWidthOnDragging
Definition: svdotext.hxx:231
void SetTextSizeDirty()
Definition: svdotext.hxx:274
tools::Rectangle ImpDragCalcRect(const SdrDragStat &rDrag) const
Definition: svdotxdr.cxx:72
bool mbTextSizeDirty
Definition: svdotext.hxx:219
SdrObjKind meTextKind
Definition: svdotext.hxx:190
bool mbNoShear
Definition: svdotext.hxx:218
Size maTextSize
Definition: svdotext.hxx:177
bool mbTextFrame
Definition: svdotext.hxx:217
Abstract base class (ABC) for all UndoActions of DrawingEngine.
Definition: svdundo.hxx:61
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
virtual SfxItemSet & GetItemSet()
static SfxUnoStyleSheet * getUnoStyleSheet(const css::uno::Reference< css::style::XStyle > &xStyle)
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
css::text::WritingMode GetValue() const
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
oslInterlockedCount m_refCount
virtual bool isInUse() override
Definition: svdotable.cxx:734
CellRef getCell(const CellPos &rPos) const
Definition: svdotable.cxx:773
SdrTableObjImpl & operator=(const SdrTableObjImpl &rSource)
Definition: svdotable.cxx:380
static sal_Int32 lastColCount
Definition: svdotable.cxx:247
TableStyleSettings maTableStyle
Definition: svdotable.cxx:199
std::unique_ptr< TableLayouter > mpLayouter
Definition: svdotable.cxx:197
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: svdotable.cxx:739
static tools::Rectangle lastLayoutResultRectangle
Definition: svdotable.cxx:242
void UpdateCells(tools::Rectangle const &rArea)
Definition: svdotable.cxx:851
sal_Int32 getRowCount() const
Definition: svdotable.cxx:803
static WritingMode lastLayoutMode
Definition: svdotable.cxx:245
void CropTableModelToSelection(const CellPos &rStart, const CellPos &rEnd)
Definition: svdotable.cxx:277
static sal_Int32 lastRowCount
Definition: svdotable.cxx:246
std::vector< sal_Int32 > getColumnWidths() const
Get widths of the columns in the table.
Definition: svdotable.cxx:793
static SdrTableObjImpl * lastLayoutTable
Definition: svdotable.cxx:240
Reference< XIndexAccess > mxTableStyle
Definition: svdotable.cxx:200
void LayoutTable(tools::Rectangle &rArea, bool bFitWidth, bool bFitHeight)
Definition: svdotable.cxx:808
void DragEdge(bool mbHorizontal, int nEdge, sal_Int32 nOffset)
Definition: svdotable.cxx:587
static tools::Rectangle lastLayoutInputRectangle
Definition: svdotable.cxx:241
virtual ~SdrTableObjImpl() override
Definition: svdotable.cxx:270
std::vector< std::unique_ptr< SdrUndoAction > > maUndos
Definition: svdotable.cxx:201
sal_Int32 getColumnCount() const
Definition: svdotable.cxx:788
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: svdotable.cxx:752
static std::vector< sal_Int32 > lastColWidths
Definition: svdotable.cxx:248
void init(SdrTableObj *pTable, sal_Int32 nColumns, sal_Int32 nRows)
Definition: svdotable.cxx:367
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
Definition: svdotable.cxx:669
CellPos getLastCell() const
Definition: svdotable.cxx:978
bool IsTextEditActive() const
Definition: svdotable.hxx:180
const TableLayouter & getTableLayouter() const
Definition: svdotable.cxx:1438
virtual SdrObjKind GetObjIdentifier() const override
Definition: svdotable.cxx:1503
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...
virtual void AdjustToMaxRect(const tools::Rectangle &rMaxRect, bool bShrinkOnly=false) override
Definition: svdotable.cxx:1956
void setTableStyleSettings(const sdr::table::TableStyleSettings &rStyle)
Definition: svdotable.cxx:1200
virtual void SaveGeoData(SdrObjGeoData &rGeo) const override
Definition: svdotable.cxx:2388
virtual bool BckCreate(SdrDragStat &rStat) override
Definition: svdotable.cxx:2351
virtual OutlinerParaObject * GetOutlinerParaObject() const override
Definition: svdotable.cxx:1910
CellPos getRightCell(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:1005
virtual SdrText * getActiveText() const override
Returns the currently active text.
Definition: svdotable.cxx:1360
virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat &rDrag) const override
Polygon dragged by the user when creating the object.
Definition: svdotable.cxx:2357
virtual void NbcMove(const Size &rSiz) override
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdotable.cxx:1964
void changeEdge(bool bHorizontal, int nEdge, sal_Int32 nOffset)
Definition: svdotable.cxx:1623
SdrTableObj(SdrModel &rSdrModel)
Definition: svdotable.cxx:879
CellPos getDownCell(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:1034
virtual bool BegCreate(SdrDragStat &rStat) override
Every object must be able to create itself interactively.
Definition: svdotable.cxx:2315
const css::uno::Reference< css::container::XIndexAccess > & getTableStyle() const
Definition: svdotable.cxx:1342
sal_Int32 getColumnCount() const
Definition: svdotable.cxx:1613
CellPos getPreviousCell(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:1048
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: svdotable.cxx:874
CellPos getLeftCell(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:990
void AddUndo(SdrUndoAction *pUndo)
Add an undo action that should be on the undo stack after ending text edit.
Definition: svdotable.cxx:2071
virtual bool beginSpecialDrag(SdrDragStat &rDrag) const override
Definition: svdotable.cxx:2196
void TakeTextAnchorRect(const sdr::table::CellPos &rPos, ::tools::Rectangle &rAnchorRect) const
virtual bool applySpecialDrag(SdrDragStat &rDrag) override
Definition: svdotable.cxx:2232
virtual bool MovCreate(SdrDragStat &rStat) override
Definition: svdotable.cxx:2326
const sdr::table::TableStyleSettings & getTableStyleSettings() const
Definition: svdotable.cxx:1186
static CellPos getFirstCell()
Definition: svdotable.cxx:972
virtual const tools::Rectangle & GetLogicRect() const override
Definition: svdotable.cxx:1819
virtual bool IsFontwork() const override
Definition: svdotable.cxx:2086
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
Definition: svdotable.cxx:1481
sal_Int32 getRowCount() const
Definition: svdotable.cxx:1618
virtual bool BegTextEdit(SdrOutliner &rOutl) override
Definition: svdotable.cxx:1830
virtual void SetVerticalWriting(bool bVertical) override
Definition: svdotable.cxx:2036
CellPos getUpCell(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:1020
virtual ~SdrTableObj() override
Definition: svdotable.cxx:951
css::text::WritingMode GetWritingMode() const
Definition: svdotable.cxx:2046
virtual OUString TakeObjNameSingul() const override
Definition: svdotable.cxx:1783
void getActiveCellPos(sdr::table::CellPos &rPos) const
Definition: svdotable.cxx:1656
virtual void NbcSetSnapRect(const tools::Rectangle &rRect) override
Definition: svdotable.cxx:1813
const SfxItemSet & GetActiveCellItemSet() const
Definition: svdotable.cxx:1325
virtual bool hasSpecialDrag() const override
The standard transformations (Move,Resize,Rotate,Mirror,Shear) are taken over by the View (TakeXorPol...
Definition: svdotable.cxx:2191
virtual bool IsAutoGrowHeight() const override
Definition: svdotable.cxx:1444
bool createTableEdgesJson(boost::property_tree::ptree &rJsonRoot)
Definition: svdotable.cxx:2484
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:2382
virtual void onEditOutlinerStatusEvent(EditStatus *pEditStatus) override
called from the SdrObjEditView during text edit when the status of the edit outliner changes
Definition: svdotable.cxx:1465
void DistributeColumns(sal_Int32 nFirstColumn, sal_Int32 nLastColumn, const bool bOptimize, const bool bMinimize)
Definition: svdotable.cxx:2428
CellPos getPreviousRow(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:1117
void CropTableModelToSelection(const CellPos &rStart, const CellPos &rEnd)
Definition: svdotable.cxx:2410
virtual void NbcReformatText() override
Definition: svdotable.cxx:2023
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: svdotable.cxx:1973
virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat &rDrag) const override
Definition: svdotable.cxx:2293
virtual void NbcSetOutlinerParaObject(std::optional< OutlinerParaObject > pTextObject) override
Definition: svdotable.cxx:1920
void createCell(sdr::table::CellRef &xCell)
Definition: svdotable.cxx:2376
virtual void RecalcSnapRect() override
Snap is not done on the BoundRect but if possible on logic coordinates (i.e.
Definition: svdotable.cxx:1825
void LayoutTableHeight(tools::Rectangle &rArea, bool bFit)
Definition: svdotable.cxx:2420
virtual bool IsVerticalWriting() const override
Definition: svdotable.cxx:2029
void init(sal_Int32 nColumns, sal_Int32 nRows)
Definition: svdotable.cxx:935
virtual bool IsReallyEdited() const override
Returns true only if we are in edit mode and the user actually changed anything.
Definition: svdotable.cxx:2081
void SetSkipChangeLayout(bool bSkipChangeLayout)
Next time layouting would be done, skip it (to layout at the end of multiple actions).
Definition: svdotable.cxx:2076
friend class SdrTableObjImpl
Definition: svdotable.hxx:96
virtual void NbcSetLogicRect(const tools::Rectangle &rRect) override
Definition: svdotable.cxx:1940
virtual bool HasText() const override
Definition: svdotable.cxx:1454
virtual sal_uInt32 GetHdlCount() const override
Via GetHdlCount the number of Handles can be retrieved.
Definition: svdotable.cxx:2091
void setTableStyle(const css::uno::Reference< css::container::XIndexAccess > &xAutoFormatStyle)
Definition: svdotable.cxx:1330
void getCellBounds(const sdr::table::CellPos &rPos, ::tools::Rectangle &rCellRect)
Definition: svdotable.cxx:1662
virtual EEAnchorMode GetOutlinerViewAnchorMode() const override
Definition: svdotable.cxx:1756
virtual void TakeTextEditArea(Size *pPaperMin, Size *pPaperMax, tools::Rectangle *pViewInit, tools::Rectangle *pViewMin) const override
Definition: svdotable.cxx:1696
css::uno::Reference< css::table::XTable > getTable() const
Definition: svdotable.cxx:960
virtual void AddToHdlList(SdrHdlList &rHdlList) const override
Definition: svdotable.cxx:2103
void setActiveCell(const sdr::table::CellPos &rPos)
Definition: svdotable.cxx:1629
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: svdotable.cxx:2472
virtual void setActiveText(sal_Int32 nIndex) override
Changes the current active text.
Definition: svdotable.cxx:1402
virtual void SetChanged() override
Definition: svdotable.cxx:2448
tools::Rectangle maLogicRect
Definition: svdotable.hxx:279
void DistributeRows(sal_Int32 nFirstRow, sal_Int32 nLastRow, const bool bOptimize, const bool bMinimize)
Definition: svdotable.cxx:2438
virtual const tools::Rectangle & GetSnapRect() const override
Definition: svdotable.cxx:1807
virtual rtl::Reference< SdrObject > CloneSdrObject(SdrModel &rTargetModel) const override
Definition: svdotable.cxx:1801
SdrOutliner * GetCellTextEditOutliner(const sdr::table::Cell &rCell) const
Definition: svdotable.cxx:1430
virtual PointerStyle GetCreatePointer() const override
get the cursor/pointer that signals creating this object
Definition: svdotable.cxx:2370
virtual void RestoreGeoData(const SdrObjGeoData &rGeo) override
Definition: svdotable.cxx:2397
bool isValid(const sdr::table::CellPos &rPos) const
Definition: svdotable.cxx:966
virtual void BrkCreate(SdrDragStat &rStat) override
Definition: svdotable.cxx:2346
rtl::Reference< SdrTableObjImpl > mpImpl
Definition: svdotable.hxx:280
virtual OUString TakeObjNamePlural() const override
Definition: svdotable.cxx:1795
virtual sal_Int32 getTextCount() const override
Returns the number of texts available for this object.
Definition: svdotable.cxx:1385
virtual bool AdjustTextFrameWidthAndHeight() override
Definition: svdotable.cxx:1984
virtual SdrText * getText(sal_Int32 nIndex) const override
Returns the nth available text.
Definition: svdotable.cxx:1367
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: svdotable.cxx:865
TableHitKind CheckTableHit(const Point &rPos, sal_Int32 &rnX, sal_Int32 &rnY, const sal_uInt16 aTol=0) const
Definition: svdotable.cxx:1210
virtual void EndTextEdit(SdrOutliner &rOutl) override
Definition: svdotable.cxx:1870
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:1418
virtual bool IsAutoGrowWidth() const override
Definition: svdotable.cxx:1449
const sdr::table::CellRef & getActiveCell() const
The active table has the focus or is currently edited.
Definition: svdotable.cxx:1594
CellPos getNextCell(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:1075
CellPos getNextRow(const CellPos &rPos, bool bEdgeTravel) const
Definition: svdotable.cxx:1143
virtual bool EndCreate(SdrDragStat &rStat, SdrCreateCmd eCmd) override
Definition: svdotable.cxx:2339
bool IsHorizontalEdge() const
sal_Int32 GetValidDragOffset(const SdrDragStat &rDrag) const
basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat &rDrag) const
bool isEdgeVisible(sal_Int32 nEdgeX, sal_Int32 nEdgeY, bool bHorizontal) const
checks if the given edge is visible.
sal_Int32 getColumnWidth(sal_Int32 nColumn) const
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
sal_Int32 getRowHeight(sal_Int32 nRow) const
constexpr tools::Long GetWidth() const
constexpr tools::Long Top() const
constexpr Point TopLeft() const
tools::Long getOpenHeight() const
constexpr Size GetSize() const
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
tools::Long AdjustTop(tools::Long nVertMoveDelta)
constexpr Point RightCenter() const
constexpr Point BottomCenter() const
constexpr void SetBottom(tools::Long v)
constexpr Point BottomRight() const
constexpr Point TopRight() const
constexpr tools::Long GetHeight() const
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
constexpr Point LeftCenter() const
constexpr Point TopCenter() const
void setHeight(tools::Long n)
tools::Long getOpenWidth() const
constexpr tools::Long Left() const
constexpr bool IsEmpty() const
constexpr Point BottomLeft() const
static bool IsFuzzing()
int nCount
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
float u
ScXMLEditAttributeMap::Entry const aEntries[]
EEAnchorMode
EEControlBits
constexpr TypedWhichId< SvxFrameDirectionItem > EE_PARA_WRITINGDIR(EE_PARA_START+0)
struct _xmlTextWriter * xmlTextWriterPtr
OUString sName
sal_Int32 nIndex
OUString aName
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
@ Exception
class SAL_NO_VTABLE XPropertySet
Definition: xmlexchg.hxx:28
int i
constexpr auto toTwips(N number, Length from)
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
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.
TableHitKind
SdrTableHitKind.
Definition: svdotable.hxx:51
const sal_Int32 last_column_style
Definition: tabledesign.hxx:32
rtl::Reference< Cell > CellRef
Definition: celltypes.hxx:33
const sal_Int32 first_column_style
Definition: tabledesign.hxx:31
const sal_Int32 odd_columns_style
Definition: tabledesign.hxx:36
const sal_Int32 body_style
Definition: tabledesign.hxx:37
const sal_Int32 even_rows_style
Definition: tabledesign.hxx:33
const sal_Int32 first_row_style
Definition: tabledesign.hxx:29
const sal_Int32 last_row_style
Definition: tabledesign.hxx:30
const sal_Int32 even_columns_style
Definition: tabledesign.hxx:35
const sal_Int32 odd_rows_style
Definition: tabledesign.hxx:34
static constexpr auto Items
long Long
basegfx::B2DRange b2DRectangleFromRectangle(const ::tools::Rectangle &rRect)
PointerStyle
SdrTextVertAdjust
Definition: sdtaitm.hxx:29
@ SDRTEXTVERTADJUST_BOTTOM
Definition: sdtaitm.hxx:31
@ SDRTEXTVERTADJUST_CENTER
Definition: sdtaitm.hxx:30
@ SDRTEXTVERTADJUST_TOP
Definition: sdtaitm.hxx:29
static SfxItemSet & rSet
TableStyleSettings.
Definition: svdotable.hxx:75
TableStyleSettings & operator=(const TableStyleSettings &rStyle)
Definition: svdotable.cxx:168
bool operator==(const TableStyleSettings &r) const
Definition: svdotable.cxx:179
constexpr sal_uInt16 SDRATTR_TABLE_FIRST(SDRATTR_CUSTOMSHAPE_LAST+1)
constexpr sal_uInt16 SDRATTR_START(XATTR_START)
constexpr sal_uInt16 SDRATTR_TABLE_LAST(SDRATTR_TABLE_TEXT_ROTATION)
constexpr sal_uInt16 SDRATTR_MISC_FIRST(SDRATTR_CAPTION_LAST+1)
constexpr sal_uInt16 SDRATTR_SHADOW_LAST(SDRATTR_SHADOWBLUR)
constexpr sal_uInt16 SDRATTR_MISC_LAST(SDRATTR_TEXT_CHAINNEXTNAME)
constexpr TypedWhichId< SvxWritingModeItem > SDRATTR_TEXTDIRECTION(SDRATTR_NOTPERSIST_FIRST+34)
SdrHdlKind
Definition: svdhdl.hxx:53
SdrObjKind
Definition: svdobjkind.hxx:25
@ Table
media shape
tools::Rectangle maLogicRect
Definition: svdotable.cxx:148
void ResizeRect(tools::Rectangle &rRect, const Point &rRef, const Fraction &rxFact, const Fraction &ryFact)
Definition: svdtrans.cxx:38
SdrCreateCmd
Definition: svdtypes.hxx:27