LibreOffice Module svx (master) 1
tablecontroller.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 <algorithm>
21
23#include <tablemodel.hxx>
24
25#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
26#include <com/sun/star/container/XIndexAccess.hpp>
27
28#include <com/sun/star/beans/XPropertySet.hpp>
29#include <com/sun/star/table/XMergeableCellRange.hpp>
30#include <com/sun/star/table/XMergeableCell.hpp>
31
32#include <sal/config.h>
33#include <sal/log.hxx>
34
35#include <vcl/svapp.hxx>
36#include <vcl/settings.hxx>
37#include <vcl/window.hxx>
38
39#include <svl/whiter.hxx>
40#include <svl/stritem.hxx>
41
42#include <sfx2/request.hxx>
43
44#include <svx/svdotable.hxx>
47#include <svx/svxids.hrc>
48#include <svx/svdoutl.hxx>
49#include <svx/svdpagv.hxx>
50#include <svx/svdetc.hxx>
52#include <svx/svdmodel.hxx>
54#include <svx/svxdlg.hxx>
55#include <editeng/boxitem.hxx>
56#include <cell.hxx>
58#include <editeng/colritem.hxx>
59#include <editeng/lineitem.hxx>
60#include <svx/strings.hrc>
61#include <svx/dialmgr.hxx>
62#include <svx/svdpage.hxx>
63#include <svx/sdmetitm.hxx>
64#include <svx/sdtditm.hxx>
65#include "tableundo.hxx"
66#include "tablelayouter.hxx"
67#include <LibreOfficeKit/LibreOfficeKitEnums.h>
68#include <memory>
69#include <o3tl/enumarray.hxx>
70#include <o3tl/enumrange.hxx>
72#include <comphelper/lok.hxx>
73#include <sfx2/viewsh.hxx>
74#include <editeng/editview.hxx>
77
78using ::editeng::SvxBorderLine;
79using namespace sdr::table;
80using namespace ::com::sun::star;
81using namespace ::com::sun::star::uno;
82using namespace ::com::sun::star::table;
83using namespace ::com::sun::star::beans;
84using namespace ::com::sun::star::container;
85using namespace ::com::sun::star::text;
86using namespace ::com::sun::star::style;
87
88namespace {
89
90enum class CellPosFlag // signals the relative position of a cell to a selection
91{
92 NONE = 0x0000, // not set or inside
93 // row
94 Before = 0x0001,
95 Left = 0x0002,
96 Right = 0x0004,
97 After = 0x0008,
98 // column
99 Upper = 0x0010,
100 Top = 0x0020,
101 Bottom = 0x0040,
102 Lower = 0x0080
103};
104
105}
106
107namespace o3tl
108{ template<> struct typed_flags<CellPosFlag> : is_typed_flags<CellPosFlag, 0xff> {}; }
109
110namespace sdr::table {
111
112namespace {
113
114class SvxTableControllerModifyListener : public ::cppu::WeakImplHelper< css::util::XModifyListener >
115{
116public:
117 explicit SvxTableControllerModifyListener( SvxTableController* pController )
118 : mpController( pController ) {}
119
120 // XModifyListener
121 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
122
123 // XEventListener
124 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
125
127};
128
129}
130
131// XModifyListener
132
133
134void SAL_CALL SvxTableControllerModifyListener::modified( const css::lang::EventObject& )
135{
136 if( mpController )
138}
139
140
141// XEventListener
142
143
144void SAL_CALL SvxTableControllerModifyListener::disposing( const css::lang::EventObject& )
145{
146 mpController = nullptr;
147}
148
149
150
151
153 SdrView& rView,
154 const SdrTableObj& rObj,
155 const rtl::Reference< sdr::SelectionController >& xRefController )
156{
157 return SvxTableController::create(rView, rObj, xRefController);
158}
159
160
162 SdrView& rView,
163 const SdrTableObj& rObj,
164 const rtl::Reference< sdr::SelectionController >& xRefController )
165{
166 if( xRefController.is() )
167 {
168 SvxTableController* pController = dynamic_cast< SvxTableController* >( xRefController.get() );
169
170 if(pController && (pController->mxTableObj.get() == &rObj) && (&pController->mrView == &rView))
171 {
172 return xRefController;
173 }
174 }
175
176 return new SvxTableController(rView, rObj);
177}
178
179
181 SdrView& rView,
182 const SdrTableObj& rObj)
183: mbCellSelectionMode(false)
184 ,mbHasJustMerged(false)
185 ,mbLeftButtonDown(false)
186 ,mrView(rView)
187 ,mxTableObj(const_cast< SdrTableObj* >(&rObj))
188 ,mnUpdateEvent( nullptr )
189{
192
193 Reference< XTable > xTable( mxTableObj.get()->getTable() );
194 if( xTable.is() )
195 {
196 mxModifyListener = new SvxTableControllerModifyListener( this );
197 xTable->addModifyListener( mxModifyListener );
198
199 mxTable.set( dynamic_cast< TableModel* >( xTable.get() ) );
200 }
201}
202
204{
205 if( mnUpdateEvent )
206 {
208 }
209
210 if( mxModifyListener.is() && mxTableObj.get() )
211 {
212 Reference< XTable > xTable( mxTableObj.get()->getTable() );
213 if( xTable.is() )
214 {
215 xTable->removeModifyListener( mxModifyListener );
216 mxModifyListener.clear();
217 }
218 }
219}
220
222{
223 if(!checkTableObject())
224 return false;
225
226 SdrTableObj& rTableObj(*mxTableObj.get());
227 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
228
229 // check if we are read only
230 if( rModel.IsReadOnly())
231 {
232 switch( rKEvt.GetKeyCode().GetCode() )
233 {
234 case awt::Key::DOWN:
235 case awt::Key::UP:
236 case awt::Key::LEFT:
237 case awt::Key::RIGHT:
238 case awt::Key::TAB:
239 case awt::Key::HOME:
240 case awt::Key::END:
241 case awt::Key::NUM2:
242 case awt::Key::NUM4:
243 case awt::Key::NUM6:
244 case awt::Key::NUM8:
245 case awt::Key::ESCAPE:
246 case awt::Key::F2:
247 break;
248 default:
249 // tell the view we eat the event, no further processing needed
250 return true;
251 }
252 }
253
254 TblAction nAction = getKeyboardAction(rKEvt);
255
256 return executeAction( nAction, rKEvt.GetKeyCode().IsShift(), pWindow );
257}
258
259namespace {
260
261Point pixelToLogic(const Point& rPoint, vcl::Window const * pWindow)
262{
263 if (!pWindow)
264 return rPoint;
265
266 return pWindow->PixelToLogic(rPoint);
267}
268
269}
270
272{
273 if (comphelper::LibreOfficeKit::isActive() && !pWindow)
274 {
275 // Tiled rendering: get the window that has the disabled map mode.
276 if (OutputDevice* pOutputDevice = mrView.GetFirstOutputDevice())
277 {
278 if (pOutputDevice->GetOutDevType() == OUTDEV_WINDOW)
279 pWindow = pOutputDevice->GetOwnerWindow();
280 }
281 }
282
283 if( !pWindow || !checkTableObject() )
284 return false;
285
286 SdrViewEvent aVEvt;
288 return false;
289
290 TableHitKind eHit = mxTableObj.get()->CheckTableHit(pixelToLogic(rMEvt.GetPosPixel(), pWindow), maMouseDownPos.mnCol, maMouseDownPos.mnRow);
291
292 mbLeftButtonDown = (rMEvt.GetClicks() == 1) && rMEvt.IsLeft();
293
294 if( eHit == TableHitKind::Cell )
295 {
297 return true;
298 }
299
300 if( rMEvt.IsRight() && eHit != TableHitKind::NONE )
301 return true; // right click will become context menu
302
303 // for cell selection with the mouse remember our first hit
304 if( mbLeftButtonDown )
305 {
307
308 SdrHdl* pHdl = mrView.PickHandle(pixelToLogic(rMEvt.GetPosPixel(), pWindow));
309
310 if( pHdl )
311 {
312 mbLeftButtonDown = false;
313 }
314 else
315 {
317
318 if (!pTableObj || eHit == TableHitKind::NONE)
319 {
320 mbLeftButtonDown = false;
321 }
322 }
323 }
324
325 if (comphelper::LibreOfficeKit::isActive() && rMEvt.GetClicks() == 2 && rMEvt.IsLeft() && eHit == TableHitKind::CellTextArea)
326 {
327 bool bEmptyOutliner = false;
328 if (Outliner* pOutliner = mrView.GetTextEditOutliner())
329 {
330 if (pOutliner->GetParagraphCount() == 1)
331 {
332 if (Paragraph* pParagraph = pOutliner->GetParagraph(0))
333 bEmptyOutliner = pOutliner->GetText(pParagraph).isEmpty();
334 }
335 }
336 if (bEmptyOutliner)
337 {
338 // Tiled rendering: a left double-click in an empty cell: select it.
341 // Update graphic selection, should be hidden now.
343 return true;
344 }
345 }
346
347 return false;
348}
349
350
352{
353 if( !checkTableObject() )
354 return false;
355
356 mbLeftButtonDown = false;
357
358 return rMEvt.GetClicks() == 2;
359}
360
361
363{
364 if( !checkTableObject() )
365 return false;
366
367 rtl::Reference<SdrTableObj> pTableObj = mxTableObj.get();
368 CellPos aPos;
369 if (mbLeftButtonDown && pTableObj && pTableObj->CheckTableHit(pixelToLogic(rMEvt.GetPosPixel(), pWindow), aPos.mnCol, aPos.mnRow ) != TableHitKind::NONE)
370 {
371 if(aPos != maMouseDownPos)
372 {
374 {
376 return true;
377 }
378 else
379 {
381 }
382 }
383 else if( mbCellSelectionMode )
384 {
385 UpdateSelection( aPos );
386 return true;
387 }
388 }
389 return false;
390}
391
392
394{
395 bool bSelected = false;
396
397 rtl::Reference<SdrTableObj> pTableObj = mxTableObj.get();
398 if( pTableObj && pTableObj->IsTextEditActive() )
399 {
400 pTableObj->getActiveCellPos( maCursorFirstPos );
402 mbCellSelectionMode = false;
403 }
404 else
405 {
406 const SdrMarkList& rMarkList= mrView.GetMarkedObjectList();
407 if( rMarkList.GetMarkCount() == 1 )
408 bSelected = mxTableObj.get().get() == rMarkList.GetMark(0)->GetMarkedSdrObj();
409 }
410
411 if( bSelected )
412 {
414 }
415 else
416 {
418 }
419}
421{
423 if ( pTableObj && !pTableObj->IsTextEditActive())
424 {
425 selectAll();
426 }
427}
428
429
431{
432 if(!mxTable.is() || !mxTableObj.get().is())
433 return;
434
435 SdrTableObj& rTableObj(*mxTableObj.get());
436 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
437 std::optional<SfxItemSet> oSet;
438 bool bVertDone(false);
439
440 // Iterate over all requested items in the set.
441 SfxWhichIter aIter( rSet );
442 sal_uInt16 nWhich = aIter.FirstWhich();
443 while (nWhich)
444 {
445 switch (nWhich)
446 {
447 case SID_TABLE_VERT_BOTTOM:
448 case SID_TABLE_VERT_CENTER:
449 case SID_TABLE_VERT_NONE:
450 {
451 if(!bVertDone)
452 {
453 if (!oSet)
454 {
455 oSet.emplace(rModel.GetItemPool());
456 MergeAttrFromSelectedCells(*oSet, false);
457 }
458
460
461 if (oSet->GetItemState( SDRATTR_TEXT_VERTADJUST ) != SfxItemState::DONTCARE)
462 eAdj = oSet->Get(SDRATTR_TEXT_VERTADJUST).GetValue();
463
464 rSet.Put(SfxBoolItem(SID_TABLE_VERT_BOTTOM, eAdj == SDRTEXTVERTADJUST_BOTTOM));
465 rSet.Put(SfxBoolItem(SID_TABLE_VERT_CENTER, eAdj == SDRTEXTVERTADJUST_CENTER));
466 rSet.Put(SfxBoolItem(SID_TABLE_VERT_NONE, eAdj == SDRTEXTVERTADJUST_TOP));
467 bVertDone = true;
468 }
469 break;
470 }
471 case SID_TABLE_DELETE_ROW:
472 if( !mxTable.is() || !hasSelectedCells() || (!comphelper::LibreOfficeKit::isActive() && mxTable->getRowCount() <= 1) )
473 rSet.DisableItem(SID_TABLE_DELETE_ROW);
474 break;
475 case SID_TABLE_DELETE_COL:
476 if( !mxTable.is() || !hasSelectedCells() || (!comphelper::LibreOfficeKit::isActive() && mxTable->getColumnCount() <= 1) )
477 rSet.DisableItem(SID_TABLE_DELETE_COL);
478 break;
479 case SID_TABLE_DELETE_TABLE:
480 if( !mxTable.is() )
481 rSet.DisableItem(SID_TABLE_DELETE_TABLE);
482 break;
483 case SID_TABLE_MERGE_CELLS:
484 if( !mxTable.is() || !hasSelectedCells() )
485 rSet.DisableItem(SID_TABLE_MERGE_CELLS);
486 break;
487 case SID_TABLE_SPLIT_CELLS:
488 if( !hasSelectedCells() || !mxTable.is() )
489 rSet.DisableItem(SID_TABLE_SPLIT_CELLS);
490 break;
491
492 case SID_TABLE_OPTIMAL_ROW_HEIGHT:
493 case SID_TABLE_DISTRIBUTE_COLUMNS:
494 case SID_TABLE_DISTRIBUTE_ROWS:
495 {
496 bool bDistributeColumns = false;
497 bool bDistributeRows = false;
498 if( mxTable.is() )
499 {
500 CellPos aStart, aEnd;
501 getSelectedCells( aStart, aEnd );
502
503 bDistributeColumns = aStart.mnCol != aEnd.mnCol;
504 bDistributeRows = aStart.mnRow != aEnd.mnRow;
505 }
506 if( !bDistributeColumns )
507 rSet.DisableItem(SID_TABLE_DISTRIBUTE_COLUMNS);
508 if( !bDistributeRows )
509 {
510 rSet.DisableItem(SID_TABLE_OPTIMAL_ROW_HEIGHT);
511 rSet.DisableItem(SID_TABLE_DISTRIBUTE_ROWS);
512 }
513 break;
514 }
515
516 default:
517 break;
518 }
519 nWhich = aIter.NextWhich();
520 }
521}
522
523
524void SvxTableController::onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs )
525{
526 if(!checkTableObject())
527 return;
528
529 SdrTableObj& rTableObj(*mxTableObj.get());
530 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
531 bool bInsertAfter = true;
532 sal_uInt16 nCount = 0;
533
534 if( pArgs )
535 {
536 const SfxPoolItem* pItem = nullptr;
537 pArgs->GetItemState(nSId, false, &pItem);
538 if (pItem)
539 {
540 nCount = static_cast<const SfxInt16Item*>(pItem)->GetValue();
541 if(const SfxBoolItem* pItem2 = pArgs->GetItemIfSet(SID_TABLE_PARAM_INSERT_AFTER))
542 bInsertAfter = pItem2->GetValue();
543 }
544 }
545
546 CellPos aStart, aEnd;
547 if( hasSelectedCells() )
548 {
549 getSelectedCells( aStart, aEnd );
550 }
551 else
552 {
553 if( bInsertAfter )
554 {
555 aStart.mnCol = mxTable->getColumnCount() - 1;
556 aStart.mnRow = mxTable->getRowCount() - 1;
557 aEnd = aStart;
558 }
559 }
560
561 if( rTableObj.IsTextEditActive() )
563
565
566 static const OUStringLiteral sSize( u"Size" );
567 const bool bUndo(rModel.IsUndoEnabled());
568
569 switch( nSId )
570 {
571 case SID_TABLE_INSERT_COL:
572 {
573 TableModelNotifyGuard aGuard( mxTable.get() );
574
575 if( bUndo )
576 {
577 rModel.BegUndo( SvxResId(STR_TABLE_INSCOL) );
578 rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
579 }
580
581 Reference< XTableColumns > xCols( mxTable->getColumns() );
582 const sal_Int32 nNewColumns = (nCount == 0) ? (aEnd.mnCol - aStart.mnCol + 1) : nCount;
583 const sal_Int32 nNewStartColumn = aEnd.mnCol + (bInsertAfter ? 1 : 0);
584 xCols->insertByIndex( nNewStartColumn, nNewColumns );
585
586 for( sal_Int32 nOffset = 0; nOffset < nNewColumns; nOffset++ )
587 {
588 // Resolves fdo#61540
589 // On Insert before, the reference column whose size is going to be
590 // used for newly created column(s) is wrong. As the new columns are
591 // inserted before the reference column, the reference column moved
592 // to the new position by no., of new columns i.e (earlier+newcolumns).
593 Reference< XPropertySet >(xCols->getByIndex(nNewStartColumn+nOffset), UNO_QUERY_THROW )->
594 setPropertyValue( sSize,
595 Reference< XPropertySet >(xCols->getByIndex( bInsertAfter?nNewStartColumn-1:nNewStartColumn+nNewColumns ), UNO_QUERY_THROW )->
596 getPropertyValue( sSize ) );
597 }
598
599 // Copy cell properties
600 sal_Int32 nPropSrcCol = (bInsertAfter ? aEnd.mnCol : aStart.mnCol + nNewColumns);
601 sal_Int32 nRowSpan = 0;
602 bool bNewSpan = false;
603
604 for( sal_Int32 nRow = 0; nRow < mxTable->getRowCount(); ++nRow )
605 {
606 CellRef xSourceCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nPropSrcCol, nRow ).get() ) );
607
608 // When we insert new COLUMNs, we want to copy ROW spans.
609 if (xSourceCell.is() && nRowSpan == 0)
610 {
611 // we are not in a span yet. Let's find out if the current cell is in a span.
612 sal_Int32 nColSpan = sal_Int32();
613 sal_Int32 nSpanInfoCol = sal_Int32();
614
615 if( xSourceCell->getRowSpan() > 1 )
616 {
617 // The current cell is the top-left cell in a span.
618 // Get the span info and propagate it to the target.
619 nRowSpan = xSourceCell->getRowSpan();
620 nColSpan = xSourceCell->getColumnSpan();
621 nSpanInfoCol = nPropSrcCol;
622 }
623 else if( xSourceCell->isMerged() )
624 {
625 // The current cell is a middle cell in a 2D span.
626 // Look for the top-left cell in the span.
627 for( nSpanInfoCol = nPropSrcCol - 1; nSpanInfoCol >= 0; --nSpanInfoCol )
628 {
629 CellRef xMergeInfoCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nSpanInfoCol, nRow ).get() ) );
630 if (xMergeInfoCell.is() && !xMergeInfoCell->isMerged())
631 {
632 nRowSpan = xMergeInfoCell->getRowSpan();
633 nColSpan = xMergeInfoCell->getColumnSpan();
634 break;
635 }
636 }
637 if( nRowSpan == 1 )
638 nRowSpan = 0;
639 }
640
641 // The target columns are outside the span; Start a new span.
642 if( nRowSpan > 0 && ( nNewStartColumn < nSpanInfoCol || nSpanInfoCol + nColSpan <= nNewStartColumn ) )
643 bNewSpan = true;
644 }
645
646 // Now copy the properties from the source to the targets
647 for( sal_Int32 nOffset = 0; nOffset < nNewColumns; nOffset++ )
648 {
649 CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nNewStartColumn + nOffset, nRow ).get() ) );
650 if( xTargetCell.is() )
651 {
652 if( nRowSpan > 0 )
653 {
654 if( bNewSpan )
655 xTargetCell->merge( 1, nRowSpan );
656 else
657 xTargetCell->setMerged();
658 }
659 xTargetCell->copyFormatFrom( xSourceCell );
660 }
661 }
662
663 if( nRowSpan > 0 )
664 {
665 --nRowSpan;
666 bNewSpan = false;
667 }
668 }
669
670 if( bUndo )
671 rModel.EndUndo();
672
673 aStart.mnCol = nNewStartColumn;
674 aStart.mnRow = 0;
675 aEnd.mnCol = aStart.mnCol + nNewColumns - 1;
676 aEnd.mnRow = mxTable->getRowCount() - 1;
677 break;
678 }
679
680 case SID_TABLE_INSERT_ROW:
681 {
682 TableModelNotifyGuard aGuard( mxTable.get() );
683
684 if( bUndo )
685 {
686 rModel.BegUndo( SvxResId(STR_TABLE_INSROW ) );
687 rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
688 }
689
690 Reference< XTableRows > xRows( mxTable->getRows() );
691 const sal_Int32 nNewRows = (nCount == 0) ? (aEnd.mnRow - aStart.mnRow + 1) : nCount;
692 const sal_Int32 nNewRowStart = aEnd.mnRow + (bInsertAfter ? 1 : 0);
693 xRows->insertByIndex( nNewRowStart, nNewRows );
694
695 for( sal_Int32 nOffset = 0; nOffset < nNewRows; nOffset++ )
696 {
697 Reference< XPropertySet >( xRows->getByIndex( aEnd.mnRow + nOffset + 1 ), UNO_QUERY_THROW )->
698 setPropertyValue( sSize,
699 Reference< XPropertySet >( xRows->getByIndex( aStart.mnRow + nOffset ), UNO_QUERY_THROW )->
700 getPropertyValue( sSize ) );
701 }
702
703 // Copy the cell properties
704 sal_Int32 nPropSrcRow = (bInsertAfter ? aEnd.mnRow : aStart.mnRow + nNewRows);
705 sal_Int32 nColSpan = 0;
706 bool bNewSpan = false;
707
708 for( sal_Int32 nCol = 0; nCol < mxTable->getColumnCount(); ++nCol )
709 {
710 CellRef xSourceCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nPropSrcRow ).get() ) );
711
712 if (!xSourceCell.is())
713 continue;
714
715 // When we insert new ROWs, we want to copy COLUMN spans.
716 if( nColSpan == 0 )
717 {
718 // we are not in a span yet. Let's find out if the current cell is in a span.
719 sal_Int32 nRowSpan = sal_Int32();
720 sal_Int32 nSpanInfoRow = sal_Int32();
721
722 if( xSourceCell->getColumnSpan() > 1 )
723 {
724 // The current cell is the top-left cell in a span.
725 // Get the span info and propagate it to the target.
726 nColSpan = xSourceCell->getColumnSpan();
727 nRowSpan = xSourceCell->getRowSpan();
728 nSpanInfoRow = nPropSrcRow;
729 }
730 else if( xSourceCell->isMerged() )
731 {
732 // The current cell is a middle cell in a 2D span.
733 // Look for the top-left cell in the span.
734 for( nSpanInfoRow = nPropSrcRow - 1; nSpanInfoRow >= 0; --nSpanInfoRow )
735 {
736 CellRef xMergeInfoCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nSpanInfoRow ).get() ) );
737 if (xMergeInfoCell.is() && !xMergeInfoCell->isMerged())
738 {
739 nColSpan = xMergeInfoCell->getColumnSpan();
740 nRowSpan = xMergeInfoCell->getRowSpan();
741 break;
742 }
743 }
744 if( nColSpan == 1 )
745 nColSpan = 0;
746 }
747
748 // Inserted rows are outside the span; Start a new span.
749 if( nColSpan > 0 && ( nNewRowStart < nSpanInfoRow || nSpanInfoRow + nRowSpan <= nNewRowStart ) )
750 bNewSpan = true;
751 }
752
753 // Now copy the properties from the source to the targets
754 for( sal_Int32 nOffset = 0; nOffset < nNewRows; ++nOffset )
755 {
756 CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nNewRowStart + nOffset ).get() ) );
757 if( xTargetCell.is() )
758 {
759 if( nColSpan > 0 )
760 {
761 if( bNewSpan )
762 xTargetCell->merge( nColSpan, 1 );
763 else
764 xTargetCell->setMerged();
765 }
766 xTargetCell->copyFormatFrom( xSourceCell );
767 }
768 }
769
770 if( nColSpan > 0 )
771 {
772 --nColSpan;
773 bNewSpan = false;
774 }
775 }
776
777 if( bUndo )
778 rModel.EndUndo();
779
780 aStart.mnCol = 0;
781 aStart.mnRow = nNewRowStart;
782 aEnd.mnCol = mxTable->getColumnCount() - 1;
783 aEnd.mnRow = aStart.mnRow + nNewRows - 1;
784 break;
785 }
786 }
787
788 StartSelection( aStart );
789 UpdateSelection( aEnd );
790}
791
792
793void SvxTableController::onDelete( sal_uInt16 nSId )
794{
796 if( !pTableObj || !mxTable.is() )
797 return;
798
799 if( nSId == SID_TABLE_DELETE_TABLE )
800 {
801 if( pTableObj->IsTextEditActive() )
803
805 }
806 else if( hasSelectedCells() )
807 {
808 CellPos aStart, aEnd;
809 getSelectedCells( aStart, aEnd );
810
811 if( pTableObj->IsTextEditActive() )
813
815
816 bool bDeleteTable = false;
817 switch( nSId )
818 {
819 case SID_TABLE_DELETE_COL:
820 {
821 const sal_Int32 nRemovedColumns = aEnd.mnCol - aStart.mnCol + 1;
822 if( nRemovedColumns == mxTable->getColumnCount() )
823 {
824 bDeleteTable = true;
825 }
826 else
827 {
828 Reference< XTableColumns > xCols( mxTable->getColumns() );
829 xCols->removeByIndex( aStart.mnCol, nRemovedColumns );
830 EditCell(aStart, nullptr, TblAction::NONE);
831 }
832 break;
833 }
834
835 case SID_TABLE_DELETE_ROW:
836 {
837 const sal_Int32 nRemovedRows = aEnd.mnRow - aStart.mnRow + 1;
838 if( nRemovedRows == mxTable->getRowCount() )
839 {
840 bDeleteTable = true;
841 }
842 else
843 {
844 Reference< XTableRows > xRows( mxTable->getRows() );
845 xRows->removeByIndex( aStart.mnRow, nRemovedRows );
846 EditCell(aStart, nullptr, TblAction::NONE);
847 }
848 break;
849 }
850 }
851
852 if( bDeleteTable )
854 else
856 }
857}
858
859
860void SvxTableController::onSelect( sal_uInt16 nSId )
861{
862 if( !mxTable.is() )
863 return;
864
865 const sal_Int32 nRowCount = mxTable->getRowCount();
866 const sal_Int32 nColCount = mxTable->getColumnCount();
867 if( !(nRowCount && nColCount) )
868 return;
869
870 CellPos aStart, aEnd;
871 getSelectedCells( aStart, aEnd );
872
873 switch( nSId )
874 {
875 case SID_TABLE_SELECT_ALL:
876 aEnd.mnCol = 0; aEnd.mnRow = 0;
877 aStart.mnCol = nColCount - 1; aStart.mnRow = nRowCount - 1;
878 break;
879 case SID_TABLE_SELECT_COL:
880 aEnd.mnRow = nRowCount - 1;
881 aStart.mnRow = 0;
882 break;
883 case SID_TABLE_SELECT_ROW:
884 aEnd.mnCol = nColCount - 1;
885 aStart.mnCol = 0;
886 break;
887 }
888
889 StartSelection( aEnd );
890 gotoCell( aStart, true, nullptr );
891}
892
894{
895 // merge drawing layer text distance items into SvxBoxItem used by the dialog
896 SvxBoxItem aBoxItem( rAttrSet.Get( SDRATTR_TABLE_BORDER ) );
897 aBoxItem.SetDistance( sal::static_int_cast< sal_uInt16 >( rAttrSet.Get(SDRATTR_TEXT_LEFTDIST).GetValue()), SvxBoxItemLine::LEFT );
898 aBoxItem.SetDistance( sal::static_int_cast< sal_uInt16 >( rAttrSet.Get(SDRATTR_TEXT_RIGHTDIST).GetValue()), SvxBoxItemLine::RIGHT );
899 aBoxItem.SetDistance( sal::static_int_cast< sal_uInt16 >( rAttrSet.Get(SDRATTR_TEXT_UPPERDIST).GetValue()), SvxBoxItemLine::TOP );
900 aBoxItem.SetDistance( sal::static_int_cast< sal_uInt16 >( rAttrSet.Get(SDRATTR_TEXT_LOWERDIST).GetValue()), SvxBoxItemLine::BOTTOM );
901 return aBoxItem;
902}
903
905{
906 const SvxBoxItem* pNewItem( rAttrSet.GetItemIfSet( SDRATTR_TABLE_BORDER ) );
907 if ( !pNewItem )
908 return;
909
910 if( pNewItem->GetDistance( SvxBoxItemLine::LEFT ) != pOriginalItem.GetDistance( SvxBoxItemLine::LEFT ) )
911 rAttrSet.Put(makeSdrTextLeftDistItem( pNewItem->GetDistance( SvxBoxItemLine::LEFT ) ) );
912
913 if( pNewItem->GetDistance( SvxBoxItemLine::RIGHT ) != pOriginalItem.GetDistance( SvxBoxItemLine::RIGHT ) )
914 rAttrSet.Put(makeSdrTextRightDistItem( pNewItem->GetDistance( SvxBoxItemLine::RIGHT ) ) );
915
916 if( pNewItem->GetDistance( SvxBoxItemLine::TOP ) != pOriginalItem.GetDistance( SvxBoxItemLine::TOP ) )
917 rAttrSet.Put(makeSdrTextUpperDistItem( pNewItem->GetDistance( SvxBoxItemLine::TOP ) ) );
918
919 if( pNewItem->GetDistance( SvxBoxItemLine::BOTTOM ) != pOriginalItem.GetDistance( SvxBoxItemLine::BOTTOM ) )
920 rAttrSet.Put(makeSdrTextLowerDistItem( pNewItem->GetDistance( SvxBoxItemLine::BOTTOM ) ) );
921}
922
924{
925 if(!mxTableObj.get().is())
926 return;
927
928 SdrTableObj& rTableObj(*mxTableObj.get());
929 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
930 const SfxItemSet* pArgs = rReq.GetArgs();
931
932 if(pArgs)
933 return;
934
935 SfxItemSet aNewAttr(rModel.GetItemPool());
936
937 // merge drawing layer text distance items into SvxBoxItem used by the dialog
938 SvxBoxItem aBoxItem(TextDistancesToSvxBoxItem(aNewAttr));
939
940 SvxBoxInfoItem aBoxInfoItem( aNewAttr.Get( SDRATTR_TABLE_BORDER_INNER ) );
941
942 MergeAttrFromSelectedCells(aNewAttr, false);
943 FillCommonBorderAttrFromSelectedCells( aBoxItem, aBoxInfoItem );
944 aNewAttr.Put( aBoxItem );
945 aNewAttr.Put( aBoxInfoItem );
946
947 // Fill in shadow properties.
948 const SfxItemSet& rTableItemSet = rTableObj.GetMergedItemSet();
949 for (sal_uInt16 nWhich = SDRATTR_SHADOW_FIRST; nWhich <= SDRATTR_SHADOW_LAST; ++nWhich)
950 {
951 if (rTableItemSet.GetItemState(nWhich, false) != SfxItemState::SET)
952 {
953 continue;
954 }
955
956 aNewAttr.Put(rTableItemSet.Get(nWhich));
957 }
958
961 rReq.GetFrameWeld(),
962 &aNewAttr,
963 rModel, false) );
964
965 // Even Cancel Button is returning positive(101) value,
966 xDlg->StartExecuteAsync([xDlg, this, aBoxItem, aBoxInfoItem](int nResult){
967 if (nResult == RET_OK)
968 {
969 SfxItemSet aNewSet(*(xDlg->GetOutputItemSet()));
970
971 //Only properties that were unchanged by the dialog appear in this
972 //itemset. We had constructed these two properties from other
973 //ones, so if they were not changed, then forcible set them back to
974 //their originals in the new result set so we can decompose that
975 //unchanged state back to their input properties
976 if (aNewSet.GetItemState(SDRATTR_TABLE_BORDER, false) != SfxItemState::SET)
977 {
978 aNewSet.Put(aBoxItem);
979 }
980 if (aNewSet.GetItemState(SDRATTR_TABLE_BORDER_INNER, false) != SfxItemState::SET)
981 {
982 aNewSet.Put(aBoxInfoItem);
983 }
984
985 SvxBoxItemToTextDistances(aBoxItem, aNewSet);
986
987 if (checkTableObject() && mxTable.is())
988 {
989 // Create a single undo action when applying the result of the dialog.
990 SdrTableObj& rTableObject(*mxTableObj.get());
991 SdrModel& rSdrModel(rTableObject.getSdrModelFromSdrObject());
992 bool bUndo = rSdrModel.IsUndoEnabled() && !mrView.IsTextEdit();
993 if (bUndo)
994 {
995 rSdrModel.BegUndo(SvxResId(STR_TABLE_NUMFORMAT));
996 }
997
998 this->SetAttrToSelectedCells(aNewSet, false);
999
1000 this->SetAttrToSelectedShape(aNewSet);
1001
1002 if (bUndo)
1003 {
1004 rSdrModel.EndUndo();
1005 }
1006 }
1007 }
1008
1009 xDlg->disposeOnce();
1010 });
1011}
1012
1014{
1015 const sal_uInt16 nSId = rReq.GetSlot();
1016 switch( nSId )
1017 {
1018 case SID_TABLE_INSERT_ROW:
1019 case SID_TABLE_INSERT_COL:
1020 onInsert( nSId, rReq.GetArgs() );
1021 break;
1022 case SID_TABLE_DELETE_ROW:
1023 case SID_TABLE_DELETE_COL:
1024 case SID_TABLE_DELETE_TABLE:
1025 onDelete( nSId );
1026 break;
1027 case SID_TABLE_SELECT_ALL:
1028 case SID_TABLE_SELECT_COL:
1029 case SID_TABLE_SELECT_ROW:
1030 onSelect( nSId );
1031 break;
1032 case SID_FORMAT_TABLE_DLG:
1033 onFormatTable( rReq );
1034 break;
1035
1036 case SID_FRAME_LINESTYLE:
1037 case SID_FRAME_LINECOLOR:
1038 case SID_ATTR_BORDER:
1039 {
1040 const SfxItemSet* pArgs = rReq.GetArgs();
1041 if( pArgs )
1042 ApplyBorderAttr( *pArgs );
1043 }
1044 break;
1045
1046 case SID_ATTR_FILL_STYLE:
1047 {
1048 const SfxItemSet* pArgs = rReq.GetArgs();
1049 if( pArgs )
1050 SetAttributes( *pArgs, false );
1051 }
1052 break;
1053
1054 case SID_TABLE_MERGE_CELLS:
1056 break;
1057
1058 case SID_TABLE_SPLIT_CELLS:
1059 SplitMarkedCells(rReq);
1060 break;
1061
1062 case SID_TABLE_MINIMAL_COLUMN_WIDTH:
1063 DistributeColumns(/*bOptimize=*/true, /*bMinimize=*/true);
1064 break;
1065
1066 case SID_TABLE_OPTIMAL_COLUMN_WIDTH:
1067 DistributeColumns(/*bOptimize=*/true, /*bMinimize=*/false);
1068 break;
1069
1070 case SID_TABLE_DISTRIBUTE_COLUMNS:
1071 DistributeColumns(/*bOptimize=*/false, /*bMinimize=*/false);
1072 break;
1073
1074 case SID_TABLE_MINIMAL_ROW_HEIGHT:
1075 DistributeRows(/*bOptimize=*/true, /*bMinimize=*/true);
1076 break;
1077
1078 case SID_TABLE_OPTIMAL_ROW_HEIGHT:
1079 DistributeRows(/*bOptimize=*/true, /*bMinimize=*/false);
1080 break;
1081
1082 case SID_TABLE_DISTRIBUTE_ROWS:
1083 DistributeRows(/*bOptimize=*/false, /*bMinimize=*/false);
1084 break;
1085
1086 case SID_TABLE_VERT_BOTTOM:
1087 case SID_TABLE_VERT_CENTER:
1088 case SID_TABLE_VERT_NONE:
1089 SetVertical( nSId );
1090 break;
1091
1092 case SID_AUTOFORMAT:
1093 case SID_TABLE_SORT_DIALOG:
1094 case SID_TABLE_AUTOSUM:
1095 default:
1096 break;
1097
1098 case SID_TABLE_STYLE:
1099 SetTableStyle( rReq.GetArgs() );
1100 break;
1101
1102 case SID_TABLE_STYLE_SETTINGS:
1104 break;
1105 case SID_TABLE_CHANGE_CURRENT_BORDER_POSITION:
1106 changeTableEdge(rReq);
1107 break;
1108 }
1109}
1110
1112{
1113 if(!checkTableObject())
1114 return;
1115
1116 SdrTableObj& rTableObj(*mxTableObj.get());
1117 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
1118
1119 if(!pArgs || (SfxItemState::SET != pArgs->GetItemState(SID_TABLE_STYLE, false)))
1120 return;
1121
1122 const SfxStringItem* pArg = dynamic_cast< const SfxStringItem* >( &pArgs->Get( SID_TABLE_STYLE ) );
1123 if( !(pArg && mxTable.is()) )
1124 return;
1125
1126 try
1127 {
1128 Reference< XStyleFamiliesSupplier > xSFS( rModel.getUnoModel(), UNO_QUERY_THROW );
1129 Reference< XNameAccess > xFamilyNameAccess( xSFS->getStyleFamilies(), UNO_SET_THROW );
1130 Reference< XNameAccess > xTableFamilyAccess( xFamilyNameAccess->getByName( "table" ), UNO_QUERY_THROW );
1131
1132 if( xTableFamilyAccess->hasByName( pArg->GetValue() ) )
1133 {
1134 // found table style with the same name
1135 Reference< XIndexAccess > xNewTableStyle( xTableFamilyAccess->getByName( pArg->GetValue() ), UNO_QUERY_THROW );
1136
1137 const bool bUndo = rModel.IsUndoEnabled();
1138
1139 if( bUndo )
1140 {
1141 rModel.BegUndo(SvxResId(STR_TABLE_STYLE));
1142 rModel.AddUndo(std::make_unique<TableStyleUndo>(rTableObj));
1143 }
1144
1145 rTableObj.setTableStyle( xNewTableStyle );
1146
1147 const sal_Int32 nRowCount = mxTable->getRowCount();
1148 const sal_Int32 nColCount = mxTable->getColumnCount();
1149 for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
1150 {
1151 for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ ) try
1152 {
1153 CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
1154 if( xCell.is() )
1155 {
1156 SfxItemSet aSet( xCell->GetItemSet() );
1157 bool bChanges = false;
1158 SfxStyleSheet *pStyleSheet = xCell->GetStyleSheet();
1159 SAL_WARN_IF(!pStyleSheet, "svx", "no stylesheet for table cell?");
1160 if (pStyleSheet)
1161 {
1162 const SfxItemSet& rStyleAttribs = pStyleSheet->GetItemSet();
1163
1164 for ( sal_uInt16 nWhich = SDRATTR_START; nWhich <= SDRATTR_TABLE_LAST; nWhich++ )
1165 {
1166 if( (rStyleAttribs.GetItemState( nWhich ) == SfxItemState::SET) && (aSet.GetItemState( nWhich ) == SfxItemState::SET) )
1167 {
1168 aSet.ClearItem( nWhich );
1169 bChanges = true;
1170 }
1171 }
1172 }
1173
1174 if( bChanges )
1175 {
1176 if( bUndo )
1177 xCell->AddUndo();
1178
1179 xCell->SetMergedItemSetAndBroadcast( aSet, true );
1180 }
1181 }
1182 }
1183 catch( Exception& )
1184 {
1185 TOOLS_WARN_EXCEPTION("svx.table", "");
1186 }
1187 }
1188
1189 if( bUndo )
1190 rModel.EndUndo();
1191 }
1192 }
1193 catch( Exception& )
1194 {
1195 TOOLS_WARN_EXCEPTION("svx.table", "");
1196 }
1197}
1198
1200{
1201 if(!checkTableObject())
1202 return;
1203
1204 SdrTableObj& rTableObj(*mxTableObj.get());
1205 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
1206
1207 TableStyleSettings aSettings(rTableObj.getTableStyleSettings() );
1208 const SfxBoolItem *pPoolItem=nullptr;
1209
1210 if( (pPoolItem = pArgs->GetItemIfSet(ID_VAL_USEFIRSTROWSTYLE, false)) )
1211 aSettings.mbUseFirstRow = pPoolItem->GetValue();
1212
1213 if( (pPoolItem = pArgs->GetItemIfSet(ID_VAL_USELASTROWSTYLE, false)) )
1214 aSettings.mbUseLastRow = pPoolItem->GetValue();
1215
1216 if( (pPoolItem = pArgs->GetItemIfSet(ID_VAL_USEBANDINGROWSTYLE, false)) )
1217 aSettings.mbUseRowBanding = pPoolItem->GetValue();
1218
1219 if( (pPoolItem = pArgs->GetItemIfSet(ID_VAL_USEFIRSTCOLUMNSTYLE, false)) )
1220 aSettings.mbUseFirstColumn = pPoolItem->GetValue();
1221
1222 if( (pPoolItem = pArgs->GetItemIfSet(ID_VAL_USELASTCOLUMNSTYLE, false)) )
1223 aSettings.mbUseLastColumn = pPoolItem->GetValue();
1224
1225 if( (pPoolItem = pArgs->GetItemIfSet(ID_VAL_USEBANDINGCOLUMNSTYLE, false)) )
1226 aSettings.mbUseColumnBanding = pPoolItem->GetValue();
1227
1228 if( aSettings == rTableObj.getTableStyleSettings() )
1229 return;
1230
1231 const bool bUndo(rModel.IsUndoEnabled());
1232
1233 if( bUndo )
1234 {
1235 rModel.BegUndo( SvxResId(STR_TABLE_STYLE_SETTINGS) );
1236 rModel.AddUndo(std::make_unique<TableStyleUndo>(rTableObj));
1237 }
1238
1239 rTableObj.setTableStyleSettings( aSettings );
1240
1241 if( bUndo )
1242 rModel.EndUndo();
1243}
1244
1245void SvxTableController::SetVertical( sal_uInt16 nSId )
1246{
1247 if(!checkTableObject())
1248 return;
1249
1250 SdrTableObj& rTableObj(*mxTableObj.get());
1251 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
1252
1253 TableModelNotifyGuard aGuard( mxTable.get() );
1254 const bool bUndo(rModel.IsUndoEnabled());
1255
1256 if (bUndo)
1257 {
1258 rModel.BegUndo(SvxResId(STR_TABLE_NUMFORMAT));
1259 rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoAttrObject(rTableObj));
1260 }
1261
1262 CellPos aStart, aEnd;
1263 getSelectedCells( aStart, aEnd );
1264
1266
1267 switch( nSId )
1268 {
1269 case SID_TABLE_VERT_BOTTOM:
1271 break;
1272 case SID_TABLE_VERT_CENTER:
1274 break;
1275 //case SID_TABLE_VERT_NONE:
1276 default:
1277 break;
1278 }
1279
1280 SdrTextVertAdjustItem aItem( eAdj );
1281
1282 for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
1283 {
1284 for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
1285 {
1286 CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
1287 if( xCell.is() )
1288 {
1289 if (bUndo)
1290 xCell->AddUndo();
1291 SfxItemSet aSet(xCell->GetItemSet());
1292 aSet.Put(aItem);
1293 xCell->SetMergedItemSetAndBroadcast(aSet, /*bClearAllItems=*/false);
1294 }
1295 }
1296 }
1297
1299
1300 if (bUndo)
1301 rModel.EndUndo();
1302}
1303
1305{
1306 CellPos aStart, aEnd;
1307 getSelectedCells( aStart, aEnd );
1308 rtl::Reference<SdrTableObj> pTableObj = mxTableObj.get();
1309 if( pTableObj )
1310 {
1311 if( pTableObj->IsTextEditActive() )
1312 mrView.SdrEndTextEdit(true);
1313
1314 TableModelNotifyGuard aGuard( mxTable.get() );
1315 MergeRange( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow );
1316 }
1317}
1318
1320{
1321 if(!checkTableObject() || !mxTable.is())
1322 return;
1323
1326
1327 xDlg->StartExecuteAsync([xDlg, this](int) {
1328 const sal_Int32 nCount = xDlg->GetCount() - 1;
1329
1330 if( nCount < 1 )
1331 return;
1332
1333 CellPos aStart, aEnd;
1334 getSelectedCells( aStart, aEnd );
1335 Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow ) ), UNO_QUERY_THROW );
1336 const sal_Int32 nRowCount = mxTable->getRowCount();
1337 const sal_Int32 nColCount = mxTable->getColumnCount();
1338 SdrTableObj& rTableObj(*mxTableObj.get());
1339
1340 if( rTableObj.IsTextEditActive() )
1341 mrView.SdrEndTextEdit(true);
1342
1343 TableModelNotifyGuard aGuard( mxTable.get() );
1344 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
1345 const bool bUndo(rModel.IsUndoEnabled());
1346
1347 if( bUndo )
1348 {
1349 rModel.BegUndo( SvxResId(STR_TABLE_SPLIT) );
1350 rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
1351 }
1352
1353 if( xDlg->IsHorizontal() )
1354 {
1355 xRange->split( 0, nCount );
1356 }
1357 else
1358 {
1359 xRange->split( nCount, 0 );
1360 }
1361
1362 if( bUndo )
1363 rModel.EndUndo();
1364
1365 aEnd.mnRow += mxTable->getRowCount() - nRowCount;
1366 aEnd.mnCol += mxTable->getColumnCount() - nColCount;
1367
1368 setSelectedCells( aStart, aEnd );
1369
1370 xDlg->disposeOnce();
1371 });
1372}
1373
1374void SvxTableController::DistributeColumns(const bool bOptimize, const bool bMinimize)
1375{
1376 if(!checkTableObject())
1377 return;
1378
1379 SdrTableObj& rTableObj(*mxTableObj.get());
1380 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
1381 const bool bUndo(rModel.IsUndoEnabled());
1382
1383 if( bUndo )
1384 {
1385 rModel.BegUndo( SvxResId(STR_TABLE_DISTRIBUTE_COLUMNS) );
1386 rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
1387 }
1388
1389 CellPos aStart, aEnd;
1390 getSelectedCells( aStart, aEnd );
1391 rTableObj.DistributeColumns( aStart.mnCol, aEnd.mnCol, bOptimize, bMinimize );
1392
1393 if( bUndo )
1394 rModel.EndUndo();
1395}
1396
1397void SvxTableController::DistributeRows(const bool bOptimize, const bool bMinimize)
1398{
1399 if(!checkTableObject())
1400 return;
1401
1402 SdrTableObj& rTableObj(*mxTableObj.get());
1403 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
1404 const bool bUndo(rModel.IsUndoEnabled());
1405
1406 if( bUndo )
1407 {
1408 rModel.BegUndo( SvxResId(STR_TABLE_DISTRIBUTE_ROWS) );
1409 rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
1410 }
1411
1412 CellPos aStart, aEnd;
1413 getSelectedCells( aStart, aEnd );
1414 rTableObj.DistributeRows( aStart.mnRow, aEnd.mnRow, bOptimize, bMinimize );
1415
1416 if( bUndo )
1417 rModel.EndUndo();
1418}
1419
1421{
1422 return mbCellSelectionMode && mxTable.is();
1423}
1424
1426{
1427 if(!checkTableObject() || !HasMarked())
1428 return false;
1429
1430 SdrTableObj& rTableObj(*mxTableObj.get());
1431 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
1432 const bool bUndo(rModel.IsUndoEnabled());
1433 bool bDeleteTable = false;
1434
1435 if (bUndo)
1436 rModel.BegUndo(SvxResId(STR_TABLE_DELETE_CELL_CONTENTS));
1437
1438 CellPos aStart, aEnd;
1439 getSelectedCells( aStart, aEnd );
1440 const sal_Int32 nRemovedColumns = aEnd.mnCol - aStart.mnCol + 1;
1441 const sal_Int32 nRemovedRows = aEnd.mnRow - aStart.mnRow + 1;
1442 if( nRemovedColumns == mxTable->getColumnCount() && nRemovedRows == mxTable->getRowCount())
1443 {
1444 bDeleteTable = true;
1445 }
1446 else
1447 {
1448 for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
1449 {
1450 for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
1451 {
1452 CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
1453 if (xCell.is() && xCell->hasText())
1454 {
1455 if (bUndo)
1456 xCell->AddUndo();
1457 xCell->SetOutlinerParaObject(std::nullopt);
1458 }
1459 }
1460 }
1461 }
1462
1463 if (bDeleteTable)
1465
1466 if (bUndo)
1467 rModel.EndUndo();
1468
1469 if (!bDeleteTable)
1471 return true;
1472}
1473
1475{
1476 if( hasSelectedCells() )
1477 {
1478 rpStyleSheet = nullptr;
1479
1480 if( mxTable.is() )
1481 {
1482 SfxStyleSheet* pRet=nullptr;
1483 bool b1st=true;
1484
1485 CellPos aStart, aEnd;
1486 const_cast<SvxTableController&>(*this).getSelectedCells( aStart, aEnd );
1487
1488 for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
1489 {
1490 for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
1491 {
1492 CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
1493 if( xCell.is() )
1494 {
1495 SfxStyleSheet* pSS=xCell->GetStyleSheet();
1496 if(b1st)
1497 {
1498 pRet=pSS;
1499 }
1500 else if(pRet != pSS)
1501 {
1502 return true;
1503 }
1504 b1st=false;
1505 }
1506 }
1507 }
1508 rpStyleSheet = pRet;
1509 return true;
1510 }
1511 }
1512 return false;
1513}
1514
1515bool SvxTableController::SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr )
1516{
1517 if( hasSelectedCells() && (!pStyleSheet || pStyleSheet->GetFamily() == SfxStyleFamily::Frame) )
1518 {
1519 if( mxTable.is() )
1520 {
1521 CellPos aStart, aEnd;
1522 getSelectedCells( aStart, aEnd );
1523
1524 for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
1525 {
1526 for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
1527 {
1528 CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
1529 if( xCell.is() )
1530 xCell->SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
1531 }
1532 }
1533
1535 return true;
1536 }
1537 }
1538 return false;
1539}
1540
1542{
1543 if (!checkTableObject())
1544 return;
1545
1546 const auto* pType = rReq.GetArg<SfxStringItem>(SID_TABLE_BORDER_TYPE);
1547 const auto* pIndex = rReq.GetArg<SfxUInt16Item>(SID_TABLE_BORDER_INDEX);
1548 const auto* pOffset = rReq.GetArg<SfxInt32Item>(SID_TABLE_BORDER_OFFSET);
1549
1550 if (!(pType && pIndex && pOffset))
1551 return;
1552
1553 const OUString sType = pType->GetValue();
1554 const sal_uInt16 nIndex = pIndex->GetValue();
1555 const sal_Int32 nOffset = convertTwipToMm100(pOffset->GetValue());
1556
1557 SdrTableObj& rTableObj(*mxTableObj.get());
1558
1559 sal_Int32 nEdgeIndex = -1;
1560 bool bHorizontal = sType.startsWith("row");
1561
1562 if (sType == "column-left" || sType == "row-left")
1563 {
1564 nEdgeIndex = 0;
1565 }
1566 else if (sType == "column-right")
1567 {
1568 // Number of edges = number of columns + 1
1569 nEdgeIndex = rTableObj.getColumnCount();
1570 }
1571 else if (sType == "row-right")
1572 {
1573 // Number of edges = number of rows + 1
1574 nEdgeIndex = rTableObj.getRowCount();
1575 }
1576 else if (sType == "column-middle" || sType == "row-middle")
1577 {
1578 nEdgeIndex = nIndex + 1;
1579 }
1580
1581 if (nEdgeIndex < 0)
1582 return;
1583
1584 TableModelNotifyGuard aGuard(mxTable.get());
1585 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
1586 const bool bUndo(rModel.IsUndoEnabled());
1587 if (bUndo)
1588 {
1589 auto pUndoObject = rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj);
1590 rModel.BegUndo(pUndoObject->GetComment());
1591
1592 auto* pGeoUndo = static_cast<SdrUndoGeoObj*>(pUndoObject.get());
1593 if (pGeoUndo)
1594 pGeoUndo->SetSkipChangeLayout(true);
1595
1596 rModel.AddUndo(std::move(pUndoObject));
1597 }
1598 tools::Rectangle aBoundRect;
1599 if (rTableObj.GetUserCall())
1600 aBoundRect = rTableObj.GetLastBoundRect();
1601 rTableObj.changeEdge(bHorizontal, nEdgeIndex, nOffset);
1602 rTableObj.SetChanged();
1603 rTableObj.SendUserCall(SdrUserCallType::Resize, aBoundRect);
1604 if (bUndo)
1605 rModel.EndUndo();
1606}
1607
1608// internals
1609
1610
1612{
1613 return mxTableObj.get().is();
1614}
1615
1616
1618{
1619 const bool bMod1 = rKEvt.GetKeyCode().IsMod1(); // ctrl
1620 const bool bMod2 = rKEvt.GetKeyCode().IsMod2(); // Alt
1621 const bool bTextEdit = mrView.IsTextEdit();
1622
1624
1626 if( !pTableObj )
1627 return nAction;
1628
1629 // handle special keys
1630 const sal_Int16 nCode = rKEvt.GetKeyCode().GetCode();
1631 switch( nCode )
1632 {
1633 case awt::Key::ESCAPE: // handle escape
1634 {
1635 if( bTextEdit )
1636 {
1637 // escape during text edit ends text edit
1638 nAction = TblAction::StopTextEdit;
1639 }
1641 {
1642 // escape with selected cells removes selection
1644 }
1645 break;
1646 }
1647 case awt::Key::RETURN: // handle return
1648 {
1649 if( !bMod1 && !bMod2 && !bTextEdit )
1650 {
1651 // when not already editing, return starts text edit
1653 nAction = TblAction::EditCell;
1654 }
1655 break;
1656 }
1657 case awt::Key::F2: // f2 toggles text edit
1658 {
1659 if( bMod1 || bMod2 ) // f2 with modifiers is handled by the view
1660 {
1661 }
1662 else if( bTextEdit )
1663 {
1664 // f2 during text edit stops text edit
1665 nAction = TblAction::StopTextEdit;
1666 }
1667 else if( mbCellSelectionMode )
1668 {
1669 // f2 with selected cells removes selection
1671 }
1672 else
1673 {
1674 // f2 with no selection and no text edit starts text edit
1676 nAction = TblAction::EditCell;
1677 }
1678 break;
1679 }
1680 case awt::Key::HOME:
1681 case awt::Key::NUM7:
1682 {
1683 if( (bMod1 || bMod2) && (bTextEdit || mbCellSelectionMode) )
1684 {
1685 if( bMod1 && !bMod2 )
1686 {
1687 // ctrl + home jumps to first cell
1688 nAction = TblAction::GotoFirstCell;
1689 }
1690 else if( !bMod1 && bMod2 )
1691 {
1692 // alt + home jumps to first column
1694 }
1695 }
1696 break;
1697 }
1698 case awt::Key::END:
1699 case awt::Key::NUM1:
1700 {
1701 if( (bMod1 || bMod2) && (bTextEdit || mbCellSelectionMode) )
1702 {
1703 if( bMod1 && !bMod2 )
1704 {
1705 // ctrl + end jumps to last cell
1706 nAction = TblAction::GotoLastCell;
1707 }
1708 else if( !bMod1 && bMod2 )
1709 {
1710 // alt + home jumps to last column
1711 nAction = TblAction::GotoLastColumn;
1712 }
1713 }
1714 break;
1715 }
1716
1717 case awt::Key::TAB:
1718 {
1719 if( bTextEdit || mbCellSelectionMode )
1720 nAction = TblAction::Tab;
1721 break;
1722 }
1723
1724 case awt::Key::UP:
1725 case awt::Key::NUM8:
1726 case awt::Key::DOWN:
1727 case awt::Key::NUM2:
1728 case awt::Key::LEFT:
1729 case awt::Key::NUM4:
1730 case awt::Key::RIGHT:
1731 case awt::Key::NUM6:
1732 {
1733
1734 if( !bMod1 && bMod2 )
1735 {
1736 if(bTextEdit || mbCellSelectionMode)
1737 {
1738 if( (nCode == awt::Key::UP) || (nCode == awt::Key::NUM8) )
1739 {
1740 nAction = TblAction::GotoLeftCell;
1741 break;
1742 }
1743 else if( (nCode == awt::Key::DOWN) || (nCode == awt::Key::NUM2) )
1744 {
1745 nAction = TblAction::GotoRightCell;
1746 break;
1747 }
1748 }
1749 }
1750
1751 bool bTextMove = false;
1753 if( pOLV )
1754 {
1756 // during text edit, check if we navigate out of the cell
1757 ESelection aOldSelection = pOLV->GetSelection();
1758 pOLV->PostKeyEvent(rKEvt);
1759 bTextMove = aOldSelection == pOLV->GetSelection();
1760 if( !bTextMove )
1761 {
1762 nAction = TblAction::NONE;
1763 }
1764 }
1765
1766 if( mbCellSelectionMode || bTextMove )
1767 {
1768 // no text edit, navigate in cells if selection active
1769 switch( nCode )
1770 {
1771 case awt::Key::LEFT:
1772 case awt::Key::NUM4:
1773 nAction = TblAction::GotoLeftCell;
1774 break;
1775 case awt::Key::RIGHT:
1776 case awt::Key::NUM6:
1777 nAction = TblAction::GotoRightCell;
1778 break;
1779 case awt::Key::DOWN:
1780 case awt::Key::NUM2:
1781 nAction = TblAction::GotoDownCell;
1782 break;
1783 case awt::Key::UP:
1784 case awt::Key::NUM8:
1785 nAction = TblAction::GotoUpCell;
1786 break;
1787 }
1788 }
1789 break;
1790 }
1791 case awt::Key::PAGEUP:
1792 if( bMod2 )
1793 nAction = TblAction::GotoFirstRow;
1794 break;
1795
1796 case awt::Key::PAGEDOWN:
1797 if( bMod2 )
1798 nAction = TblAction::GotoLastRow;
1799 break;
1800 }
1801 return nAction;
1802}
1803
1804bool SvxTableController::executeAction(TblAction nAction, bool bSelect, vcl::Window* pWindow)
1805{
1807 if( !pTableObj )
1808 return false;
1809
1810 switch( nAction )
1811 {
1813 {
1814 gotoCell( SdrTableObj::getFirstCell(), bSelect, pWindow, nAction );
1815 break;
1816 }
1817
1819 {
1820 gotoCell( pTableObj->getLeftCell( getSelectionEnd(), !bSelect ), bSelect, pWindow, nAction );
1821 break;
1822 }
1823
1825 {
1826 gotoCell( pTableObj->getRightCell( getSelectionEnd(), !bSelect ), bSelect, pWindow, nAction);
1827 break;
1828 }
1829
1831 {
1832 gotoCell( pTableObj->getLastCell(), bSelect, pWindow, nAction );
1833 break;
1834 }
1835
1837 {
1839 gotoCell( aPos, bSelect, pWindow, nAction );
1840 break;
1841 }
1842
1844 {
1845 CellPos aPos( pTableObj->getLastCell().mnCol, getSelectionEnd().mnRow );
1846 gotoCell( aPos, bSelect, pWindow, nAction );
1847 break;
1848 }
1849
1851 {
1853 gotoCell( aPos, bSelect, pWindow, nAction );
1854 break;
1855 }
1856
1858 {
1859 gotoCell( pTableObj->getUpCell(getSelectionEnd(), !bSelect), bSelect, pWindow, nAction );
1860 break;
1861 }
1862
1864 {
1865 gotoCell( pTableObj->getDownCell(getSelectionEnd(), !bSelect), bSelect, pWindow, nAction );
1866 break;
1867 }
1868
1870 {
1871 CellPos aPos( getSelectionEnd().mnCol, pTableObj->getLastCell().mnRow );
1872 gotoCell( aPos, bSelect, pWindow, nAction );
1873 break;
1874 }
1875
1877 EditCell( getSelectionStart(), pWindow, nAction );
1878 break;
1879
1881 StopTextEdit();
1882 break;
1883
1886 break;
1887
1888 case TblAction::Tab:
1889 {
1890 if( bSelect )
1891 gotoCell( pTableObj->getPreviousCell( getSelectionEnd(), true ), false, pWindow, nAction );
1892 else
1893 {
1894 CellPos aSelectionEnd( getSelectionEnd() );
1895 CellPos aNextCell( pTableObj->getNextCell( aSelectionEnd, true ) );
1896 if( aSelectionEnd == aNextCell )
1897 {
1898 onInsert( SID_TABLE_INSERT_ROW );
1899 aNextCell = pTableObj->getNextCell( aSelectionEnd, true );
1900 }
1901 gotoCell( aNextCell, false, pWindow, nAction );
1902 }
1903 break;
1904 }
1905 default:
1906 break;
1907 }
1908
1909 return nAction != TblAction::HandledByView;
1910}
1911
1912
1913void SvxTableController::gotoCell(const CellPos& rPos, bool bSelect, vcl::Window* pWindow, TblAction nAction /*= TblAction::NONE */)
1914{
1915 auto pTable = mxTableObj.get();
1916 if( pTable && pTable->IsTextEditActive() )
1917 mrView.SdrEndTextEdit(true);
1918
1919 if( bSelect )
1920 {
1921 maCursorLastPos = rPos;
1922 if( pTable )
1923 pTable->setActiveCell( rPos );
1924
1925 if( !mbCellSelectionMode )
1926 {
1928 }
1929 else
1930 {
1931 UpdateSelection( rPos );
1932 }
1933 }
1934 else
1935 {
1937 EditCell( rPos, pWindow, nAction );
1938 }
1939}
1940
1941
1943{
1945 return maCursorFirstPos;
1946}
1947
1948
1950{
1951 maCursorFirstPos = rPos;
1952}
1953
1954
1956{
1958 return maCursorLastPos;
1959}
1960
1961
1962void SvxTableController::MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, sal_Int32 nLastCol, sal_Int32 nLastRow )
1963{
1964 if(!checkTableObject() || !mxTable.is())
1965 return;
1966
1967 try
1968 {
1969 Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( nFirstCol, nFirstRow,nLastCol, nLastRow ) ), UNO_QUERY_THROW );
1970
1971 if( xRange->isMergeable() )
1972 {
1973 SdrTableObj& rTableObj(*mxTableObj.get());
1974 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
1975 const bool bUndo(rModel.IsUndoEnabled());
1976
1977 if( bUndo )
1978 {
1979 rModel.BegUndo( SvxResId(STR_TABLE_MERGE) );
1980 rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
1981 }
1982
1983 xRange->merge();
1984 mbHasJustMerged = true;
1986
1987 if( bUndo )
1988 rModel.EndUndo();
1989 }
1990 }
1991 catch( Exception& )
1992 {
1993 TOOLS_WARN_EXCEPTION( "svx.table", "" );
1994 }
1995}
1996
1997
1999{
2000 if( !mxTable.is() )
2001 return;
2002
2003 try
2004 {
2005 if( rPos.mnCol >= mxTable->getColumnCount() )
2006 rPos.mnCol = mxTable->getColumnCount()-1;
2007
2008 if( rPos.mnRow >= mxTable->getRowCount() )
2009 rPos.mnRow = mxTable->getRowCount()-1;
2010 }
2011 catch( Exception& )
2012 {
2013 TOOLS_WARN_EXCEPTION("svx.table", "");
2014 }
2015}
2016
2017
2019{
2020 if( !mxTable.is() )
2021 return;
2022
2023 try
2024 {
2025 Reference< XMergeableCell > xCell( mxTable->getCellByPosition( rPos.mnCol, rPos.mnRow ), UNO_QUERY_THROW );
2026 if( xCell->isMerged() )
2027 {
2028 ::findMergeOrigin( mxTable, rPos.mnCol, rPos.mnRow, rPos.mnCol, rPos.mnRow );
2029 }
2030 }
2031 catch( Exception& )
2032 {
2033 TOOLS_WARN_EXCEPTION("svx.table", "");
2034 }
2035}
2036
2037
2038void SvxTableController::EditCell(const CellPos& rPos, vcl::Window* pWindow, TblAction nAction /*= TblAction::NONE */)
2039{
2041
2042 if(nullptr == pPV || !checkTableObject())
2043 return;
2044
2045 SdrTableObj& rTableObj(*mxTableObj.get());
2046
2047 if(rTableObj.getSdrPageFromSdrObject() != pPV->GetPage())
2048 return;
2049
2050 bool bEmptyOutliner = false;
2051
2053 {
2055 sal_Int32 nParaCnt = pOutl->GetParagraphCount();
2056 Paragraph* p1stPara = pOutl->GetParagraph( 0 );
2057
2058 if(nParaCnt==1 && p1stPara)
2059 {
2060 // with only one paragraph
2061 if (pOutl->GetText(p1stPara).isEmpty())
2062 {
2063 bEmptyOutliner = true;
2064 }
2065 }
2066 }
2067
2068 CellPos aPos( rPos );
2069 findMergeOrigin( aPos );
2070
2071 if( &rTableObj == mrView.GetTextEditObject() && !bEmptyOutliner && rTableObj.IsTextEditActive( aPos ) )
2072 return;
2073
2074 if( rTableObj.IsTextEditActive() )
2075 mrView.SdrEndTextEdit(true);
2076
2077 rTableObj.setActiveCell( aPos );
2078
2079 // create new outliner, owner will be the SdrObjEditView
2080 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
2081 std::unique_ptr<SdrOutliner> pOutl(SdrMakeOutliner(OutlinerMode::OutlineObject, rModel));
2082
2083 if (pOutl && rTableObj.IsVerticalWriting())
2084 pOutl->SetVertical( true );
2085
2086 if (!mrView.SdrBeginTextEdit(&rTableObj, pPV, pWindow, true, pOutl.release()))
2087 return;
2088
2090
2092
2093 // Move cursor to end of text
2095
2096 const WritingMode eMode = rTableObj.GetWritingMode();
2097 if (((nAction == TblAction::GotoLeftCell) || (nAction == TblAction::GotoRightCell)) && (eMode != WritingMode_TB_RL))
2098 {
2099 const bool bLast = ((nAction == TblAction::GotoLeftCell) && (eMode == WritingMode_LR_TB)) ||
2100 ((nAction == TblAction::GotoRightCell) && (eMode == WritingMode_RL_TB));
2101
2102 if( bLast )
2104 }
2106}
2107
2108
2110{
2111 if(mrView.IsTextEdit())
2112 {
2116 }
2117}
2118
2119
2121{
2123 {
2126
2127 rFirst.mnCol = std::min( maCursorFirstPos.mnCol, maCursorLastPos.mnCol );
2128 rFirst.mnRow = std::min( maCursorFirstPos.mnRow, maCursorLastPos.mnRow );
2129 rLast.mnCol = std::max( maCursorFirstPos.mnCol, maCursorLastPos.mnCol );
2130 rLast.mnRow = std::max( maCursorFirstPos.mnRow, maCursorLastPos.mnRow );
2131
2132 if( !mxTable.is() )
2133 return;
2134
2135 bool bExt = false;
2136 do
2137 {
2138 bExt = false;
2139 for( sal_Int32 nRow = rFirst.mnRow; nRow <= rLast.mnRow && !bExt; nRow++ )
2140 {
2141 for( sal_Int32 nCol = rFirst.mnCol; nCol <= rLast.mnCol && !bExt; nCol++ )
2142 {
2143 Reference< XMergeableCell > xCell( mxTable->getCellByPosition( nCol, nRow ), UNO_QUERY );
2144 if( !xCell.is() )
2145 continue;
2146
2147 if( xCell->isMerged() )
2148 {
2149 CellPos aPos( nCol, nRow );
2150 findMergeOrigin( aPos );
2151 if( (aPos.mnCol < rFirst.mnCol) || (aPos.mnRow < rFirst.mnRow) )
2152 {
2153 rFirst.mnCol = std::min( rFirst.mnCol, aPos.mnCol );
2154 rFirst.mnRow = std::min( rFirst.mnRow, aPos.mnRow );
2155 bExt = true;
2156 }
2157 }
2158 else
2159 {
2160 if( ((nCol + xCell->getColumnSpan() - 1) > rLast.mnCol) || (nRow + xCell->getRowSpan() - 1 ) > rLast.mnRow )
2161 {
2162 rLast.mnCol = std::max( rLast.mnCol, nCol + xCell->getColumnSpan() - 1 );
2163 rLast.mnRow = std::max( rLast.mnRow, nRow + xCell->getRowSpan() - 1 );
2164 bExt = true;
2165 }
2166 }
2167 }
2168 }
2169 }
2170 while(bExt);
2171 }
2172 else if(mrView.IsTextEdit())
2173 {
2174 rFirst = getSelectionStart();
2175 findMergeOrigin( rFirst );
2176 rLast = rFirst;
2177
2178 if( mxTable.is() )
2179 {
2180 Reference< XMergeableCell > xCell( mxTable->getCellByPosition( rLast.mnCol, rLast.mnRow ), UNO_QUERY );
2181 if( xCell.is() )
2182 {
2183 rLast.mnCol += xCell->getColumnSpan() - 1;
2184 rLast.mnRow += xCell->getRowSpan() - 1;
2185 }
2186 }
2187 }
2188 else
2189 {
2190 rFirst.mnCol = 0;
2191 rFirst.mnRow = 0;
2192 if( mxTable.is() )
2193 {
2194 rLast.mnRow = mxTable->getRowCount()-1;
2195 rLast.mnCol = mxTable->getColumnCount()-1;
2196 }
2197 else
2198 {
2199 rLast.mnRow = 0;
2200 rLast.mnCol = 0;
2201 }
2202 }
2203}
2204
2205
2207{
2208 StopTextEdit();
2209 mbCellSelectionMode = true;
2212}
2213
2214
2215void SvxTableController::setSelectedCells( const CellPos& rStart, const CellPos& rEnd )
2216{
2217 StopTextEdit();
2218 mbCellSelectionMode = true;
2219 maCursorFirstPos = rStart;
2220 UpdateSelection( rEnd );
2221}
2222
2223
2224bool SvxTableController::ChangeFontSize(bool bGrow, const FontList* pFontList)
2225{
2226 if(!checkTableObject() || !mxTable.is())
2227 return false;
2228
2229 SdrTableObj& rTableObj(*mxTableObj.get());
2230 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
2231
2232 if (mrView.IsTextEdit())
2233 return true;
2234
2235 CellPos aStart, aEnd;
2236
2237 if(hasSelectedCells())
2238 {
2239 getSelectedCells(aStart, aEnd);
2240 }
2241 else
2242 {
2243 aStart.mnRow = 0;
2244 aStart.mnCol = 0;
2245 aEnd.mnRow = mxTable->getRowCount() - 1;
2246 aEnd.mnCol = mxTable->getColumnCount() - 1;
2247 }
2248
2249 for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++)
2250 {
2251 for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++)
2252 {
2253 CellRef xCell(dynamic_cast< Cell* >(mxTable->getCellByPosition(nCol, nRow).get()));
2254 if (xCell.is())
2255 {
2256 if (rModel.IsUndoEnabled())
2257 xCell->AddUndo();
2258
2259 SfxItemSet aCellSet(xCell->GetItemSet());
2260 if (EditView::ChangeFontSize(bGrow, aCellSet, pFontList))
2261 {
2262 xCell->SetMergedItemSetAndBroadcast(aCellSet, false);
2263 }
2264 }
2265 }
2266 }
2267
2269
2270 return true;
2271}
2272
2273
2275{
2276 maCursorLastPos = rPos;
2278}
2279
2280
2282{
2284}
2285
2286
2288{
2289 if( mxTable.is() )
2290 {
2291 CellPos aPos2( mxTable->getColumnCount()-1, mxTable->getRowCount()-1 );
2292 if( (aPos2.mnCol >= 0) && (aPos2.mnRow >= 0) )
2293 {
2294 CellPos aPos1;
2295 setSelectedCells( aPos1, aPos2 );
2296 }
2297 }
2298}
2299
2300
2302{
2304 {
2305 mbCellSelectionMode = false;
2307 }
2308}
2309
2310
2312{
2313 if( mnUpdateEvent == nullptr )
2315}
2316
2317
2319{
2320 // There is no need to update selection overlay after merging cells
2321 // since the selection overlay should remain the same
2322 if ( mbHasJustMerged )
2323 return;
2324
2326 if( !mbCellSelectionMode )
2327 return;
2328
2330 if( !pTableObj )
2331 return;
2332
2334
2335 tools::Rectangle aStartRect, aEndRect;
2336 CellPos aStart,aEnd;
2337 getSelectedCells( aStart, aEnd );
2338 pTableObj->getCellBounds( aStart, aStartRect );
2339
2340 basegfx::B2DRange a2DRange( basegfx::B2DPoint(aStartRect.Left(), aStartRect.Top()) );
2341 a2DRange.expand( basegfx::B2DPoint(aStartRect.Right(), aStartRect.Bottom()) );
2342
2343 findMergeOrigin( aEnd );
2344 pTableObj->getCellBounds( aEnd, aEndRect );
2345 a2DRange.expand( basegfx::B2DPoint(aEndRect.Left(), aEndRect.Top()) );
2346 a2DRange.expand( basegfx::B2DPoint(aEndRect.Right(), aEndRect.Bottom()) );
2347 aRanges.push_back( a2DRange );
2348
2349 ::Color aHighlight( COL_BLUE );
2351 if( pOutDev )
2352 aHighlight = pOutDev->GetSettings().GetStyleSettings().GetHighlightColor();
2353
2354 const sal_uInt32 nCount = mrView.PaintWindowCount();
2355 for( sal_uInt32 nIndex = 0; nIndex < nCount; nIndex++ )
2356 {
2357 SdrPaintWindow* pPaintWindow = mrView.GetPaintWindow(nIndex);
2358 if( pPaintWindow )
2359 {
2360 const rtl::Reference < sdr::overlay::OverlayManager >& xOverlayManager = pPaintWindow->GetOverlayManager();
2361 if( xOverlayManager.is() )
2362 {
2363 std::unique_ptr<sdr::overlay::OverlayObjectCell> pOverlay(new sdr::overlay::OverlayObjectCell( aHighlight, std::vector(aRanges) ));
2364
2365 xOverlayManager->add(*pOverlay);
2366 mpSelectionOverlay.emplace();
2367 mpSelectionOverlay->append(std::move(pOverlay));
2368 }
2369 }
2370 }
2371
2372 // If tiled rendering, emit callbacks for sdr table selection.
2373 if (!(pOutDev && comphelper::LibreOfficeKit::isActive()))
2374 return;
2375
2376 tools::Rectangle aSelection(a2DRange.getMinX(), a2DRange.getMinY(), a2DRange.getMaxX(), a2DRange.getMaxY());
2377
2378 if (pOutDev->GetMapMode().GetMapUnit() == MapUnit::Map100thMM)
2379 aSelection = o3tl::toTwips(aSelection, o3tl::Length::mm100);
2380
2381 if(SfxViewShell* pViewShell = SfxViewShell::Current())
2382 {
2383 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_SELECTION_AREA, aSelection.toString().getStr());
2384 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, aSelection.toString().getStr());
2385 }
2386}
2387
2388
2390{
2391 if( !mpSelectionOverlay )
2392 return;
2393
2394 mpSelectionOverlay.reset();
2395
2397 {
2398 // Clear the LOK text selection so far provided by this table.
2399 if(SfxViewShell* pViewShell = SfxViewShell::Current())
2400 {
2401 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_SELECTION_AREA, "EMPTY");
2402 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_START, "EMPTY");
2403 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_END, "EMPTY");
2404 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, "EMPTY");
2405 }
2406 }
2407}
2408
2409
2411{
2412 if( !mxTable.is() )
2413 return;
2414
2415 CellPos aStart, aEnd;
2416 const_cast<SvxTableController&>(*this).getSelectedCells( aStart, aEnd );
2417
2418 for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
2419 {
2420 for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
2421 {
2422 CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
2423 if( xCell.is() && !xCell->isMerged() )
2424 {
2425 const SfxItemSet& rSet = xCell->GetItemSet();
2426 SfxWhichIter aIter(rSet);
2427 sal_uInt16 nWhich(aIter.FirstWhich());
2428 while(nWhich)
2429 {
2430 SfxItemState nState = aIter.GetItemState(false);
2431 if(!bOnlyHardAttr)
2432 {
2433 if(SfxItemState::DONTCARE == nState)
2434 rAttr.InvalidateItem(nWhich);
2435 else
2436 rAttr.MergeValue(rSet.Get(nWhich), true);
2437 }
2438 else if(SfxItemState::SET == nState)
2439 {
2440 const SfxPoolItem& rItem = rSet.Get(nWhich);
2441 rAttr.MergeValue(rItem, true);
2442 }
2443
2444 nWhich = aIter.NextWhich();
2445 }
2446 }
2447 }
2448 }
2449}
2450
2451
2452static void ImplSetLinePreserveColor( SvxBoxItem& rNewFrame, const SvxBorderLine* pNew, SvxBoxItemLine nLine )
2453{
2454 if( pNew )
2455 {
2456 const SvxBorderLine* pOld = rNewFrame.GetLine(nLine);
2457 if( pOld )
2458 {
2459 SvxBorderLine aNewLine( *pNew );
2460 aNewLine.SetColor( pOld->GetColor() );
2461 rNewFrame.SetLine( &aNewLine, nLine );
2462 return;
2463 }
2464 }
2465 rNewFrame.SetLine( pNew, nLine );
2466}
2467
2468
2469static void ImplApplyBoxItem( CellPosFlag nCellPosFlags, const SvxBoxItem* pBoxItem, const SvxBoxInfoItem* pBoxInfoItem, SvxBoxItem& rNewFrame )
2470{
2471 if (nCellPosFlags & (CellPosFlag::Before|CellPosFlag::After|CellPosFlag::Upper|CellPosFlag::Lower))
2472 {
2473 // current cell is outside the selection
2474
2475 if (!(nCellPosFlags & (CellPosFlag::Before|CellPosFlag::After))) // check if it's not any corner
2476 {
2477 if (nCellPosFlags & CellPosFlag::Upper)
2478 {
2479 if( pBoxInfoItem->IsValid(SvxBoxInfoItemValidFlags::TOP) )
2480 rNewFrame.SetLine(nullptr, SvxBoxItemLine::BOTTOM );
2481 }
2482 else if (nCellPosFlags & CellPosFlag::Lower)
2483 {
2484 if( pBoxInfoItem->IsValid(SvxBoxInfoItemValidFlags::BOTTOM) )
2485 rNewFrame.SetLine( nullptr, SvxBoxItemLine::TOP );
2486 }
2487 }
2488 else if (!(nCellPosFlags & (CellPosFlag::Upper|CellPosFlag::Lower))) // check if it's not any corner
2489 {
2490 if (nCellPosFlags & CellPosFlag::Before)
2491 {
2492 if( pBoxInfoItem->IsValid(SvxBoxInfoItemValidFlags::LEFT) )
2493 rNewFrame.SetLine( nullptr, SvxBoxItemLine::RIGHT );
2494 }
2495 else if (nCellPosFlags & CellPosFlag::After)
2496 {
2497 if( pBoxInfoItem->IsValid(SvxBoxInfoItemValidFlags::RIGHT) )
2498 rNewFrame.SetLine( nullptr, SvxBoxItemLine::LEFT );
2499 }
2500 }
2501 }
2502 else
2503 {
2504 // current cell is inside the selection
2505
2506 if ((nCellPosFlags & CellPosFlag::Left) ? pBoxInfoItem->IsValid(SvxBoxInfoItemValidFlags::LEFT)
2507 : pBoxInfoItem->IsValid(SvxBoxInfoItemValidFlags::VERT))
2508 rNewFrame.SetLine( (nCellPosFlags & CellPosFlag::Left) ? pBoxItem->GetLeft() : pBoxInfoItem->GetVert(), SvxBoxItemLine::LEFT );
2509
2510 if( (nCellPosFlags & CellPosFlag::Right) ? pBoxInfoItem->IsValid(SvxBoxInfoItemValidFlags::RIGHT) : pBoxInfoItem->IsValid(SvxBoxInfoItemValidFlags::VERT) )
2511 rNewFrame.SetLine( (nCellPosFlags & CellPosFlag::Right) ? pBoxItem->GetRight() : pBoxInfoItem->GetVert(), SvxBoxItemLine::RIGHT );
2512
2513 if( (nCellPosFlags & CellPosFlag::Top) ? pBoxInfoItem->IsValid(SvxBoxInfoItemValidFlags::TOP) : pBoxInfoItem->IsValid(SvxBoxInfoItemValidFlags::HORI) )
2514 rNewFrame.SetLine( (nCellPosFlags & CellPosFlag::Top) ? pBoxItem->GetTop() : pBoxInfoItem->GetHori(), SvxBoxItemLine::TOP );
2515
2516 if( (nCellPosFlags & CellPosFlag::Bottom) ? pBoxInfoItem->IsValid(SvxBoxInfoItemValidFlags::BOTTOM) : pBoxInfoItem->IsValid(SvxBoxInfoItemValidFlags::HORI) )
2517 rNewFrame.SetLine( (nCellPosFlags & CellPosFlag::Bottom) ? pBoxItem->GetBottom() : pBoxInfoItem->GetHori(), SvxBoxItemLine::BOTTOM );
2518
2519 // apply distance to borders
2520 if( pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::DISTANCE ) )
2522 rNewFrame.SetDistance( pBoxItem->GetDistance( nLine ), nLine );
2523 }
2524}
2525
2526
2527static void ImplSetLineColor( SvxBoxItem& rNewFrame, SvxBoxItemLine nLine, const Color& rColor )
2528{
2529 const SvxBorderLine* pSourceLine = rNewFrame.GetLine( nLine );
2530 if( pSourceLine )
2531 {
2532 SvxBorderLine aLine( *pSourceLine );
2533 aLine.SetColor( rColor );
2534 rNewFrame.SetLine( &aLine, nLine );
2535 }
2536}
2537
2538
2539static void ImplApplyLineColorItem( CellPosFlag nCellPosFlags, const SvxColorItem* pLineColorItem, SvxBoxItem& rNewFrame )
2540{
2541 const Color aColor( pLineColorItem->GetValue() );
2542
2543 if (!(nCellPosFlags & (CellPosFlag::Lower|CellPosFlag::Before|CellPosFlag::After)))
2544 ImplSetLineColor( rNewFrame, SvxBoxItemLine::BOTTOM, aColor );
2545
2546 if (!(nCellPosFlags & (CellPosFlag::Upper|CellPosFlag::Before|CellPosFlag::After)))
2547 ImplSetLineColor( rNewFrame, SvxBoxItemLine::TOP, aColor );
2548
2549 if (!(nCellPosFlags & (CellPosFlag::Upper|CellPosFlag::Lower|CellPosFlag::After)))
2550 ImplSetLineColor( rNewFrame, SvxBoxItemLine::RIGHT, aColor );
2551
2552 if (!(nCellPosFlags & (CellPosFlag::Upper|CellPosFlag::Lower|CellPosFlag::Before)))
2553 ImplSetLineColor( rNewFrame, SvxBoxItemLine::LEFT, aColor );
2554}
2555
2556
2557static void ImplApplyBorderLineItem( CellPosFlag nCellPosFlags, const SvxBorderLine* pBorderLineItem, SvxBoxItem& rNewFrame )
2558{
2559 if (nCellPosFlags & (CellPosFlag::Before|CellPosFlag::After|CellPosFlag::Upper|CellPosFlag::Lower))
2560 {
2561 if (!(nCellPosFlags & (CellPosFlag::Before|CellPosFlag::After))) // check if it's not any corner
2562 {
2563 if (nCellPosFlags & CellPosFlag::Upper)
2564 {
2565 if( rNewFrame.GetBottom() )
2566 ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, SvxBoxItemLine::BOTTOM );
2567 }
2568 else if (nCellPosFlags & CellPosFlag::Lower)
2569 {
2570 if( rNewFrame.GetTop() )
2571 ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, SvxBoxItemLine::TOP );
2572 }
2573 }
2574 else if (!(nCellPosFlags & (CellPosFlag::Upper|CellPosFlag::Lower))) // check if it's not any corner
2575 {
2576 if (nCellPosFlags & CellPosFlag::Before)
2577 {
2578 if( rNewFrame.GetRight() )
2579 ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, SvxBoxItemLine::RIGHT );
2580 }
2581 else if (nCellPosFlags & CellPosFlag::After)
2582 {
2583 if( rNewFrame.GetLeft() )
2584 ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, SvxBoxItemLine::LEFT );
2585 }
2586 }
2587 }
2588 else
2589 {
2590 if( rNewFrame.GetBottom() )
2591 ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, SvxBoxItemLine::BOTTOM );
2592 if( rNewFrame.GetTop() )
2593 ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, SvxBoxItemLine::TOP );
2594 if( rNewFrame.GetRight() )
2595 ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, SvxBoxItemLine::RIGHT );
2596 if( rNewFrame.GetLeft() )
2597 ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, SvxBoxItemLine::LEFT );
2598 }
2599}
2600
2601
2603{
2604 if( !mxTable.is() )
2605 return;
2606
2607 const sal_Int32 nRowCount = mxTable->getRowCount();
2608 const sal_Int32 nColCount = mxTable->getColumnCount();
2609 if( !(nRowCount && nColCount) )
2610 return;
2611
2612 const SvxBoxItem* pBoxItem = nullptr;
2613 if(SfxItemState::SET == rAttr.GetItemState(SDRATTR_TABLE_BORDER, false) )
2614 pBoxItem = &rAttr.Get( SDRATTR_TABLE_BORDER );
2615
2616 const SvxBoxInfoItem* pBoxInfoItem = nullptr;
2617 if(SfxItemState::SET == rAttr.GetItemState(SDRATTR_TABLE_BORDER_INNER, false) )
2618 pBoxInfoItem = &rAttr.Get( SDRATTR_TABLE_BORDER_INNER );
2619
2620 const SvxColorItem* pLineColorItem = nullptr;
2621 if(SfxItemState::SET == rAttr.GetItemState(SID_FRAME_LINECOLOR, false) )
2622 pLineColorItem = &rAttr.Get( SID_FRAME_LINECOLOR );
2623
2624 const SvxBorderLine* pBorderLineItem = nullptr;
2625 if(SfxItemState::SET == rAttr.GetItemState(SID_FRAME_LINESTYLE, false) )
2626 pBorderLineItem = rAttr.Get( SID_FRAME_LINESTYLE ).GetLine();
2627
2628 if( pBoxInfoItem && !pBoxItem )
2629 {
2630 const static SvxBoxItem gaEmptyBoxItem( SDRATTR_TABLE_BORDER );
2631 pBoxItem = &gaEmptyBoxItem;
2632 }
2633 else if( pBoxItem && !pBoxInfoItem )
2634 {
2635 const static SvxBoxInfoItem gaEmptyBoxInfoItem( SDRATTR_TABLE_BORDER_INNER );
2636 pBoxInfoItem = &gaEmptyBoxInfoItem;
2637 }
2638
2639 CellPos aStart, aEnd;
2640 getSelectedCells( aStart, aEnd );
2641
2642 const sal_Int32 nLastRow = std::min( aEnd.mnRow + 2, nRowCount );
2643 const sal_Int32 nLastCol = std::min( aEnd.mnCol + 2, nColCount );
2644
2645 for( sal_Int32 nRow = std::max( aStart.mnRow - 1, sal_Int32(0) ); nRow < nLastRow; nRow++ )
2646 {
2647 CellPosFlag nRowFlags = CellPosFlag::NONE;
2648 nRowFlags |= (nRow == aStart.mnRow) ? CellPosFlag::Top : CellPosFlag::NONE;
2649 nRowFlags |= (nRow == aEnd.mnRow) ? CellPosFlag::Bottom : CellPosFlag::NONE;
2650 nRowFlags |= (nRow < aStart.mnRow) ? CellPosFlag::Upper : CellPosFlag::NONE;
2651 nRowFlags |= (nRow > aEnd.mnRow) ? CellPosFlag::Lower : CellPosFlag::NONE;
2652
2653 for( sal_Int32 nCol = std::max( aStart.mnCol - 1, sal_Int32(0) ); nCol < nLastCol; nCol++ )
2654 {
2655 CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
2656 if( !xCell.is() )
2657 continue;
2658
2659 const SfxItemSet& rSet = xCell->GetItemSet();
2660 const SvxBoxItem* pOldOuter = &rSet.Get( SDRATTR_TABLE_BORDER );
2661
2662 SvxBoxItem aNewFrame( *pOldOuter );
2663
2664 CellPosFlag nCellPosFlags = nRowFlags;
2665 nCellPosFlags |= (nCol == aStart.mnCol) ? CellPosFlag::Left : CellPosFlag::NONE;
2666 nCellPosFlags |= (nCol == aEnd.mnCol) ? CellPosFlag::Right : CellPosFlag::NONE;
2667 nCellPosFlags |= (nCol < aStart.mnCol) ? CellPosFlag::Before : CellPosFlag::NONE;
2668 nCellPosFlags |= (nCol > aEnd.mnCol) ? CellPosFlag::After : CellPosFlag::NONE;
2669
2670 if( pBoxItem && pBoxInfoItem )
2671 ImplApplyBoxItem( nCellPosFlags, pBoxItem, pBoxInfoItem, aNewFrame );
2672
2673 if( pLineColorItem )
2674 ImplApplyLineColorItem( nCellPosFlags, pLineColorItem, aNewFrame );
2675
2676 if( pBorderLineItem )
2677 ImplApplyBorderLineItem( nCellPosFlags, pBorderLineItem, aNewFrame );
2678
2679 if (aNewFrame != *pOldOuter)
2680 {
2681 SfxItemSet aAttr(*rSet.GetPool(), rSet.GetRanges());
2682 aAttr.Put(aNewFrame);
2683 xCell->SetMergedItemSetAndBroadcast( aAttr, false );
2684 }
2685 }
2686 }
2687}
2688
2689
2691{
2692 rtl::Reference<SdrObject> pTableObj = mxTableObj.get();
2693 if( pTableObj )
2694 {
2695 pTableObj->ActionChanged();
2696 pTableObj->BroadcastObjectChange();
2697 }
2699}
2700
2701
2702void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bReplaceAll)
2703{
2704 if(!checkTableObject() || !mxTable.is())
2705 return;
2706
2707 SdrTableObj& rTableObj(*mxTableObj.get());
2708 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
2709 const bool bUndo(rModel.IsUndoEnabled());
2710
2711 if( bUndo )
2712 rModel.BegUndo( SvxResId(STR_TABLE_NUMFORMAT) );
2713
2714 CellPos aStart, aEnd;
2715 getSelectedCells( aStart, aEnd );
2716
2717 SfxItemSet aAttr(*rAttr.GetPool(), rAttr.GetRanges());
2718 aAttr.Put(rAttr);
2719
2720 const bool bFrame = (rAttr.GetItemState( SDRATTR_TABLE_BORDER ) == SfxItemState::SET) || (rAttr.GetItemState( SDRATTR_TABLE_BORDER_INNER ) == SfxItemState::SET);
2721
2722 if( bFrame )
2723 {
2726 }
2727
2728 for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
2729 {
2730 for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
2731 {
2732 CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
2733 if( xCell.is() )
2734 {
2735 if( bUndo )
2736 xCell->AddUndo();
2737 xCell->SetMergedItemSetAndBroadcast(aAttr, bReplaceAll);
2738 }
2739 }
2740 }
2741
2742 if( bFrame )
2743 {
2744 ApplyBorderAttr( rAttr );
2745 }
2746
2748
2749 if( bUndo )
2750 rModel.EndUndo();
2751}
2752
2754{
2755 if (!checkTableObject() || !mxTable.is())
2756 return;
2757
2758 // Filter out non-shadow items from rAttr.
2760 aSet.Put(rAttr);
2761
2762 if (!aSet.Count())
2763 {
2764 // If there are no items to be applied on the shape, then don't set anything, it would
2765 // terminate text edit without a good reason, which affects undo/redo.
2766 return;
2767 }
2768
2769 // Set shadow items on the marked shape.
2770 mrView.SetAttrToMarked(aSet, /*bReplaceAll=*/false);
2771}
2772
2773bool SvxTableController::GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const
2774{
2775 if( mxTableObj.get().is() && hasSelectedCells() )
2776 {
2777 MergeAttrFromSelectedCells( rTargetSet, bOnlyHardAttr );
2778
2779 if( mrView.IsTextEdit() )
2780 {
2781 OutlinerView* pTextEditOutlinerView = mrView.GetTextEditOutlinerView();
2782 if(pTextEditOutlinerView)
2783 {
2784 // FALSE= consider InvalidItems not as the default, but as "holes"
2785 rTargetSet.Put(pTextEditOutlinerView->GetAttribs(), false);
2786 }
2787 }
2788
2789 return true;
2790 }
2791 else
2792 {
2793 return false;
2794 }
2795}
2796
2797
2798bool SvxTableController::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
2799{
2801 {
2802 SetAttrToSelectedCells( rSet, bReplaceAll );
2803 return true;
2804 }
2805 return false;
2806}
2807
2809{
2811 sdr::table::SdrTableObj* pCurrentSdrTableObj(GetTableObj());
2812
2813 if(nullptr == pCurrentSdrTableObj)
2814 {
2815 return pRetval;
2816 }
2817
2818 if(!mxTableObj.get().is())
2819 {
2820 return pRetval;
2821 }
2822
2823 // get selection and create full selection
2824 CellPos aStart, aEnd;
2825 const CellPos aFullStart, aFullEnd(mxTable->getColumnCount()-1, mxTable->getRowCount()-1);
2826
2827 getSelectedCells(aStart, aEnd);
2828
2829 // compare to see if we have a partial selection
2830 if(aStart != aFullStart || aEnd != aFullEnd)
2831 {
2832 // create full clone
2833 pRetval = SdrObject::Clone(*pCurrentSdrTableObj, rTargetModel);
2834
2835 // limit SdrObject's TableModel to partial selection
2836 pRetval->CropTableModelToSelection(aStart, aEnd);
2837 }
2838
2839 return pRetval;
2840}
2841
2843{
2844 if( mxTableObj.get().is() && (rModel.GetPageCount() >= 1) )
2845 {
2846 const SdrPage* pPastePage = rModel.GetPage(0);
2847 if( pPastePage && pPastePage->GetObjCount() == 1 )
2848 {
2849 SdrTableObj* pPasteTableObj = dynamic_cast< SdrTableObj* >( pPastePage->GetObj(0) );
2850 if( pPasteTableObj )
2851 {
2852 return PasteObject( pPasteTableObj );
2853 }
2854 }
2855 }
2856
2857 return false;
2858}
2859
2860
2861bool SvxTableController::PasteObject( SdrTableObj const * pPasteTableObj )
2862{
2863 if( !pPasteTableObj )
2864 return false;
2865
2866 Reference< XTable > xPasteTable( pPasteTableObj->getTable() );
2867 if( !xPasteTable.is() )
2868 return false;
2869
2870 if( !mxTable.is() )
2871 return false;
2872
2873 sal_Int32 nPasteColumns = xPasteTable->getColumnCount();
2874 sal_Int32 nPasteRows = xPasteTable->getRowCount();
2875
2876 CellPos aStart, aEnd;
2877 getSelectedCells( aStart, aEnd );
2878
2879 if( mrView.IsTextEdit() )
2880 mrView.SdrEndTextEdit(true);
2881
2882 sal_Int32 nColumns = mxTable->getColumnCount();
2883 sal_Int32 nRows = mxTable->getRowCount();
2884
2885 const sal_Int32 nMissing = nPasteRows - ( nRows - aStart.mnRow );
2886 if( nMissing > 0 )
2887 {
2888 Reference< XTableRows > xRows( mxTable->getRows() );
2889 xRows->insertByIndex( nRows, nMissing );
2890 nRows = mxTable->getRowCount();
2891 }
2892
2893 nPasteRows = std::min( nPasteRows, nRows - aStart.mnRow );
2894 nPasteColumns = std::min( nPasteColumns, nColumns - aStart.mnCol );
2895
2896 // copy cell contents
2897 for( sal_Int32 nRow = 0; nRow < nPasteRows; ++nRow )
2898 {
2899 for( sal_Int32 nCol = 0, nTargetCol = aStart.mnCol; nCol < nPasteColumns; ++nCol )
2900 {
2901 CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nTargetCol, aStart.mnRow + nRow ).get() ) );
2902 if( xTargetCell.is() && !xTargetCell->isMerged() )
2903 {
2904 CellRef xSourceCell(dynamic_cast<Cell*>(xPasteTable->getCellByPosition(nCol, nRow).get()));
2905 if (xSourceCell.is())
2906 {
2907 xTargetCell->AddUndo();
2908 // Prevent cell span exceeding the pasting range.
2909 if (nColumns < nTargetCol + xSourceCell->getColumnSpan())
2910 xTargetCell->replaceContentAndFormatting(xSourceCell);
2911 else
2912 xTargetCell->cloneFrom(xSourceCell);
2913
2914 nCol += xSourceCell->getColumnSpan() - 1;
2915 nTargetCol += xTargetCell->getColumnSpan();
2916 }
2917 }
2918 }
2919 }
2920
2922
2923 return true;
2924}
2925
2926bool SvxTableController::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats )
2927{
2929 {
2930 return false;
2931 }
2932
2933 if(!checkTableObject())
2934 return false;
2935
2936 SdrTableObj& rTableObj(*mxTableObj.get());
2937 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
2938 const bool bUndo(rModel.IsUndoEnabled());
2939
2940 if( bUndo )
2941 rModel.BegUndo(SvxResId(STR_TABLE_NUMFORMAT));
2942
2943 CellPos aStart, aEnd;
2944 getSelectedCells( aStart, aEnd );
2945 const bool bFrame = (rFormatSet.GetItemState( SDRATTR_TABLE_BORDER ) == SfxItemState::SET) || (rFormatSet.GetItemState( SDRATTR_TABLE_BORDER_INNER ) == SfxItemState::SET);
2946
2947 for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
2948 {
2949 for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
2950 {
2951 CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
2952 if( xCell.is() )
2953 {
2954 if (bUndo)
2955 xCell->AddUndo();
2956 SdrText* pText = xCell.get();
2957 SdrObjEditView::ApplyFormatPaintBrushToText( rFormatSet, rTableObj, pText, bNoCharacterFormats, bNoParagraphFormats );
2958 }
2959 }
2960 }
2961
2962 if( bFrame )
2963 {
2964 ApplyBorderAttr( rFormatSet );
2965 }
2966
2968
2969 if( bUndo )
2970 rModel.EndUndo();
2971
2972 return true;
2973}
2974
2975
2976IMPL_LINK_NOARG(SvxTableController, UpdateHdl, void*, void)
2977{
2978 mnUpdateEvent = nullptr;
2979
2980 if( mbCellSelectionMode )
2981 {
2982 CellPos aStart( maCursorFirstPos );
2983 CellPos aEnd( maCursorLastPos );
2984 checkCell(aStart);
2985 checkCell(aEnd);
2986 if( aStart != maCursorFirstPos || aEnd != maCursorLastPos )
2987 {
2988 setSelectedCells( aStart, aEnd );
2989 }
2990 }
2991
2992 updateSelectionOverlay();
2993 mbHasJustMerged = false;
2994}
2995
2996namespace
2997{
2998
2999struct LinesState
3000{
3001 LinesState(SvxBoxItem& rBoxItem_, SvxBoxInfoItem& rBoxInfoItem_)
3002 : rBoxItem(rBoxItem_)
3003 , rBoxInfoItem(rBoxInfoItem_)
3004 , bDistanceIndeterminate(false)
3005 {
3006 aBorderSet.fill(false);
3007 aInnerLineSet.fill(false);
3008 aBorderIndeterminate.fill(false);
3009 aInnerLineIndeterminate.fill(false);
3010 aDistanceSet.fill(false);
3011 aDistance.fill(0);
3012 }
3013
3023};
3024
3025class BoxItemWrapper
3026{
3027public:
3028 BoxItemWrapper(SvxBoxItem& rBoxItem, SvxBoxInfoItem& rBoxInfoItem, SvxBoxItemLine nBorderLine, SvxBoxInfoItemLine nInnerLine, bool bBorder);
3029
3030 const SvxBorderLine* getLine() const;
3031 void setLine(const SvxBorderLine* pLine);
3032
3033private:
3038 const bool m_bBorder;
3039};
3040
3041BoxItemWrapper::BoxItemWrapper(
3043 const SvxBoxItemLine nBorderLine, const SvxBoxInfoItemLine nInnerLine, const bool bBorder)
3046 , m_nBorderLine(nBorderLine)
3047 , m_nInnerLine(nInnerLine)
3048 , m_bBorder(bBorder)
3049{
3050}
3051
3052const SvxBorderLine* BoxItemWrapper::getLine() const
3053{
3054 if (m_bBorder)
3056 else
3057 return (m_nInnerLine == SvxBoxInfoItemLine::HORI) ? m_rBoxInfoItem.GetHori() : m_rBoxInfoItem.GetVert();
3058}
3059
3060void BoxItemWrapper::setLine(const SvxBorderLine* pLine)
3061{
3062 if (m_bBorder)
3064 else
3066}
3067
3068void lcl_MergeBorderLine(
3069 LinesState& rLinesState, const SvxBorderLine* const pLine, const SvxBoxItemLine nLine,
3070 SvxBoxInfoItemValidFlags nValidFlag, const bool bBorder = true)
3071{
3072 const SvxBoxInfoItemLine nInnerLine(bBorder ? SvxBoxInfoItemLine::HORI : ((nValidFlag & SvxBoxInfoItemValidFlags::HORI) ? SvxBoxInfoItemLine::HORI : SvxBoxInfoItemLine::VERT));
3073 BoxItemWrapper aBoxItem(rLinesState.rBoxItem, rLinesState.rBoxInfoItem, nLine, nInnerLine, bBorder);
3074 bool& rbSet(bBorder ? rLinesState.aBorderSet[nLine] : rLinesState.aInnerLineSet[nInnerLine]);
3075
3076 if (rbSet)
3077 {
3078 bool& rbIndeterminate(bBorder ? rLinesState.aBorderIndeterminate[nLine] : rLinesState.aInnerLineIndeterminate[nInnerLine]);
3079 if (!rbIndeterminate)
3080 {
3081 const SvxBorderLine* const pMergedLine(aBoxItem.getLine());
3082 if ((pLine && !pMergedLine) || (!pLine && pMergedLine) || (pLine && (*pLine != *pMergedLine)))
3083 {
3084 aBoxItem.setLine(nullptr);
3085 rbIndeterminate = true;
3086 }
3087 }
3088 }
3089 else
3090 {
3091 aBoxItem.setLine(pLine);
3092 rbSet = true;
3093 }
3094}
3095
3096void lcl_MergeBorderOrInnerLine(
3097 LinesState& rLinesState, const SvxBorderLine* const pLine, const SvxBoxItemLine nLine,
3098 SvxBoxInfoItemValidFlags nValidFlag, const bool bBorder)
3099{
3100 if (bBorder)
3101 lcl_MergeBorderLine(rLinesState, pLine, nLine, nValidFlag);
3102 else
3103 {
3104 const bool bVertical = (nLine == SvxBoxItemLine::LEFT) || (nLine == SvxBoxItemLine::RIGHT);
3105 lcl_MergeBorderLine(rLinesState, pLine, nLine, bVertical ? SvxBoxInfoItemValidFlags::VERT : SvxBoxInfoItemValidFlags::HORI, false);
3106 }
3107}
3108
3109void lcl_MergeDistance(
3110 LinesState& rLinesState, const SvxBoxItemLine nIndex, const sal_uInt16 nDistance)
3111{
3112 if (rLinesState.aDistanceSet[nIndex])
3113 {
3114 if (!rLinesState.bDistanceIndeterminate)
3115 rLinesState.bDistanceIndeterminate = nDistance != rLinesState.aDistance[nIndex];
3116 }
3117 else
3118 {
3119 rLinesState.aDistance[nIndex] = nDistance;
3120 rLinesState.aDistanceSet[nIndex] = true;
3121 }
3122}
3123
3124void lcl_MergeCommonBorderAttr(LinesState& rLinesState, const SvxBoxItem& rCellBoxItem, const CellPosFlag nCellPosFlags)
3125{
3126 if (nCellPosFlags & (CellPosFlag::Before|CellPosFlag::After|CellPosFlag::Upper|CellPosFlag::Lower))
3127 {
3128 // current cell is outside the selection
3129
3130 if (!(nCellPosFlags & (CellPosFlag::Before|CellPosFlag::After))) // check if it's not any corner
3131 {
3132 if (nCellPosFlags & CellPosFlag::Upper)
3133 lcl_MergeBorderLine(rLinesState, rCellBoxItem.GetBottom(), SvxBoxItemLine::TOP, SvxBoxInfoItemValidFlags::TOP);
3134 else if (nCellPosFlags & CellPosFlag::Lower)
3135 lcl_MergeBorderLine(rLinesState, rCellBoxItem.GetTop(), SvxBoxItemLine::BOTTOM, SvxBoxInfoItemValidFlags::BOTTOM);
3136 }
3137 else if (!(nCellPosFlags & (CellPosFlag::Upper|CellPosFlag::Lower))) // check if it's not any corner
3138 {
3139 if (nCellPosFlags & CellPosFlag::Before)
3140 lcl_MergeBorderLine(rLinesState, rCellBoxItem.GetRight(), SvxBoxItemLine::LEFT, SvxBoxInfoItemValidFlags::LEFT);
3141 else if (nCellPosFlags & CellPosFlag::After)
3142 lcl_MergeBorderLine(rLinesState, rCellBoxItem.GetLeft(), SvxBoxItemLine::RIGHT, SvxBoxInfoItemValidFlags::RIGHT);
3143 }
3144
3145 // NOTE: inner distances for cells outside the selected range
3146 // are not relevant -> we ignore them.
3147 }
3148 else
3149 {
3150 // current cell is inside the selection
3151
3152 lcl_MergeBorderOrInnerLine(rLinesState, rCellBoxItem.GetTop(), SvxBoxItemLine::TOP, SvxBoxInfoItemValidFlags::TOP, static_cast<bool>(nCellPosFlags & CellPosFlag::Top));
3153 lcl_MergeBorderOrInnerLine(rLinesState, rCellBoxItem.GetBottom(), SvxBoxItemLine::BOTTOM, SvxBoxInfoItemValidFlags::BOTTOM, static_cast<bool>(nCellPosFlags & CellPosFlag::Bottom));
3154 lcl_MergeBorderOrInnerLine(rLinesState, rCellBoxItem.GetLeft(), SvxBoxItemLine::LEFT, SvxBoxInfoItemValidFlags::LEFT, static_cast<bool>(nCellPosFlags & CellPosFlag::Left));
3155 lcl_MergeBorderOrInnerLine(rLinesState, rCellBoxItem.GetRight(), SvxBoxItemLine::RIGHT, SvxBoxInfoItemValidFlags::RIGHT, static_cast<bool>(nCellPosFlags & CellPosFlag::Right));
3156
3157 lcl_MergeDistance(rLinesState, SvxBoxItemLine::TOP, rCellBoxItem.GetDistance(SvxBoxItemLine::TOP));
3158 lcl_MergeDistance(rLinesState, SvxBoxItemLine::BOTTOM, rCellBoxItem.GetDistance(SvxBoxItemLine::BOTTOM));
3159 lcl_MergeDistance(rLinesState, SvxBoxItemLine::LEFT, rCellBoxItem.GetDistance(SvxBoxItemLine::LEFT));
3160 lcl_MergeDistance(rLinesState, SvxBoxItemLine::RIGHT, rCellBoxItem.GetDistance(SvxBoxItemLine::RIGHT));
3161 }
3162}
3163
3164}
3165
3166void SvxTableController::FillCommonBorderAttrFromSelectedCells( SvxBoxItem& rBoxItem, SvxBoxInfoItem& rBoxInfoItem ) const
3167{
3168 if( !mxTable.is() )
3169 return;
3170
3171 const sal_Int32 nRowCount = mxTable->getRowCount();
3172 const sal_Int32 nColCount = mxTable->getColumnCount();
3173 if( !(nRowCount && nColCount) )
3174 return;
3175
3176 CellPos aStart, aEnd;
3177 const_cast< SvxTableController* >( this )->getSelectedCells( aStart, aEnd );
3178
3179 // We are adding one more row/column around the block of selected cells.
3180 // We will be checking the adjoining border of these too.
3181 const sal_Int32 nLastRow = std::min( aEnd.mnRow + 2, nRowCount );
3182 const sal_Int32 nLastCol = std::min( aEnd.mnCol + 2, nColCount );
3183
3184 rBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::ALL, false );
3185 LinesState aLinesState( rBoxItem, rBoxInfoItem );
3186
3187 /* Here we go through all the selected cells (enhanced by
3188 * the adjoining row/column on each side) and determine the
3189 * lines for presentation. The algorithm is simple:
3190 * 1. if a border or inner line is set (or unset) in all
3191 * cells to the same value, it will be used.
3192 * 2. if a border or inner line is set only in some cells,
3193 * it will be set to indeterminate state (SetValid() on
3194 * rBoxInfoItem).
3195 */
3196 for( sal_Int32 nRow = std::max( aStart.mnRow - 1, sal_Int32(0) ); nRow < nLastRow; nRow++ )
3197 {
3198 CellPosFlag nRowFlags = CellPosFlag::NONE;
3199 nRowFlags |= (nRow == aStart.mnRow) ? CellPosFlag::Top : CellPosFlag::NONE;
3200 nRowFlags |= (nRow == aEnd.mnRow) ? CellPosFlag::Bottom : CellPosFlag::NONE;
3201 nRowFlags |= (nRow < aStart.mnRow) ? CellPosFlag::Upper : CellPosFlag::NONE;
3202 nRowFlags |= (nRow > aEnd.mnRow) ? CellPosFlag::Lower : CellPosFlag::NONE;
3203
3204 for( sal_Int32 nCol = std::max( aStart.mnCol - 1, sal_Int32(0) ); nCol < nLastCol; nCol++ )
3205 {
3206 CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
3207 if( !xCell.is() )
3208 continue;
3209
3210 CellPosFlag nCellPosFlags = nRowFlags;
3211 nCellPosFlags |= (nCol == aStart.mnCol) ? CellPosFlag::Left : CellPosFlag::NONE;
3212 nCellPosFlags |= (nCol == aEnd.mnCol) ? CellPosFlag::Right : CellPosFlag::NONE;
3213 nCellPosFlags |= (nCol < aStart.mnCol) ? CellPosFlag::Before : CellPosFlag::NONE;
3214 nCellPosFlags |= (nCol > aEnd.mnCol) ? CellPosFlag::After : CellPosFlag::NONE;
3215
3216 const SfxItemSet& rSet = xCell->GetItemSet();
3218 lcl_MergeCommonBorderAttr( aLinesState, aCellBoxItem, nCellPosFlags );
3219 }
3220 }
3221
3222 if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::TOP])
3223 aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::TOP);
3224 if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::BOTTOM])
3225 aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::BOTTOM);
3226 if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::LEFT])
3227 aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::LEFT);
3228 if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::RIGHT])
3229 aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::RIGHT);
3230 if (!aLinesState.aInnerLineIndeterminate[SvxBoxInfoItemLine::HORI])
3231 aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::HORI);
3232 if (!aLinesState.aInnerLineIndeterminate[SvxBoxInfoItemLine::VERT])
3233 aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::VERT);
3234
3235 if (!aLinesState.bDistanceIndeterminate)
3236 {
3237 if (aLinesState.aDistanceSet[SvxBoxItemLine::TOP])
3238 aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::TOP], SvxBoxItemLine::TOP);
3239 if (aLinesState.aDistanceSet[SvxBoxItemLine::BOTTOM])
3240 aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::BOTTOM], SvxBoxItemLine::BOTTOM);
3241 if (aLinesState.aDistanceSet[SvxBoxItemLine::LEFT])
3242 aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::LEFT], SvxBoxItemLine::LEFT);
3243 if (aLinesState.aDistanceSet[SvxBoxItemLine::RIGHT])
3244 aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::RIGHT], SvxBoxItemLine::RIGHT);
3245 aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::DISTANCE);
3246 }
3247}
3248
3250{
3251 if( !mxTable.is() )
3252 return false;
3253 CellPos aStart( 0, row ), aEnd( mxTable->getColumnCount() - 1, row );
3254 StartSelection( aEnd );
3255 gotoCell( aStart, true, nullptr );
3256 return true;
3257}
3258
3259bool SvxTableController::selectColumn( sal_Int32 column )
3260{
3261 if( !mxTable.is() )
3262 return false;
3263 CellPos aStart( column, 0 ), aEnd( column, mxTable->getRowCount() - 1 );
3264 StartSelection( aEnd );
3265 gotoCell( aStart, true, nullptr );
3266 return true;
3267}
3268
3270{
3271 if( !mxTable.is() )
3272 return false;
3273 CellPos aStart( 0, row ), aEnd( mxTable->getColumnCount() - 1, row );
3274 StartSelection( aEnd );
3275 gotoCell( aStart, false, nullptr );
3276 return true;
3277}
3278
3280{
3281 if( !mxTable.is() )
3282 return false;
3283 CellPos aStart( column, 0 ), aEnd( column, mxTable->getRowCount() - 1 );
3284 StartSelection( aEnd );
3285 gotoCell( aStart, false, nullptr );
3286 return true;
3287}
3288
3290{
3291 if( hasSelectedCells() )
3292 {
3293 CellPos aFirstPos, aLastPos;
3294 getSelectedCells( aFirstPos, aLastPos );
3295 if( (aFirstPos.mnCol == 0) && (nRow >= aFirstPos.mnRow && nRow <= aLastPos.mnRow) && (mxTable->getColumnCount() - 1 == aLastPos.mnCol) )
3296 return true;
3297 }
3298 return false;
3299}
3300
3302{
3303 if( hasSelectedCells() )
3304 {
3305 CellPos aFirstPos, aLastPos;
3306 getSelectedCells( aFirstPos, aLastPos );
3307 if( (aFirstPos.mnRow == 0) && (nColumn >= aFirstPos.mnCol && nColumn <= aLastPos.mnCol) && (mxTable->getRowCount() - 1 == aLastPos.mnRow) )
3308 return true;
3309 }
3310 return false;
3311}
3312
3314{
3315 if(!checkTableObject())
3316 return false;
3317
3318 SdrTableObj& rTableObj(*mxTableObj.get());
3319 TableStyleSettings aSettings(rTableObj.getTableStyleSettings());
3320
3321 return aSettings.mbUseFirstRow;
3322}
3323
3325{
3326 if(!checkTableObject())
3327 return false;
3328
3329 SdrTableObj& rTableObj(*mxTableObj.get());
3330 TableStyleSettings aSettings(rTableObj.getTableStyleSettings());
3331
3332 return aSettings.mbUseFirstColumn;
3333}
3334
3335bool SvxTableController::setCursorLogicPosition(const Point& rPosition, bool bPoint)
3336{
3337 rtl::Reference<SdrTableObj> pTableObj = mxTableObj.get();
3338 if (pTableObj->GetObjIdentifier() != SdrObjKind::Table)
3339 return false;
3340
3341 CellPos aCellPos;
3342 if (pTableObj->CheckTableHit(rPosition, aCellPos.mnCol, aCellPos.mnRow) != TableHitKind::NONE)
3343 {
3344 // Position is a table cell.
3346 {
3347 // We have a table selection already: adjust the point or the mark.
3348 if (bPoint)
3350 else
3352 return true;
3353 }
3354 else if (aCellPos != maMouseDownPos)
3355 {
3356 // No selection, but rPosition is at another cell: start table selection.
3358 // Update graphic selection, should be hidden now.
3360 }
3361 }
3362
3363 return false;
3364}
3365
3366}
3367
3368/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OptionalString sType
SlideSorterView & mrView
constexpr auto convertTwipToMm100(N n)
SvxBoxInfoItemValidFlags
SvxBoxItemLine
SvxBoxInfoItemLine
const StyleSettings & GetStyleSettings() const
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
sal_uInt16 GetValue() const
const OUString & GetValue() const
void ChangeFontSize(bool bGrow, const FontList *pList)
const vcl::KeyCode & GetKeyCode() const
MapUnit GetMapUnit() const
sal_uInt16 GetClicks() const
bool IsRight() const
const Point & GetPosPixel() const
bool IsLeft() const
void SetSelection(const ESelection &)
ESelection GetSelection() const
bool PostKeyEvent(const KeyEvent &rKEvt, vcl::Window const *pFrameWin=nullptr)
SfxItemSet GetAttribs()
OUString GetText(Paragraph const *pPara, sal_Int32 nParaCount=1) const
Paragraph * GetParagraph(sal_Int32 nAbsPos) const
sal_Int32 GetParagraphCount() const
const MapMode & GetMapMode() const
const AllSettings & GetSettings() const
void SetEditMode(SdrViewEditMode eMode)
Definition: svdcrtv.hxx:89
void SetCurrentObj(SdrObjKind nIdent, SdrInventor nInvent=SdrInventor::Default)
Definition: svdcrtv.cxx:334
void SetAttrToMarked(const SfxItemSet &rAttr, bool bReplaceAll)
Definition: svdedtv1.cxx:1063
void DeleteMarkedObj()
Definition: svdedtv.cxx:794
size_t GetMarkCount() const
Definition: svdmark.hxx:178
SdrMark * GetMark(size_t nNum) const
Definition: svdmark.cxx:230
SdrHdl * PickHandle(const Point &rPnt) const
Definition: svdmrkv.cxx:1931
const SdrMarkList & GetMarkedObjectList() const
Definition: svdmrkv.hxx:258
void AdjustMarkHdl(SfxViewShell *pOtherShell=nullptr)
Definition: svdmrkv.cxx:2612
SdrObject * GetMarkedSdrObj() const
Definition: svdmark.hxx:68
void BegUndo()
Definition: svdmodel.cxx:364
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
Definition: svdmodel.cxx:498
virtual bool IsReadOnly() const
Definition: svdmodel.cxx:245
const SfxItemPool & GetItemPool() const
Definition: svdmodel.hxx:317
SdrUndoFactory & GetSdrUndoFactory() const
returns the models undo factory.
Definition: svdmodel.cxx:1862
css::uno::Reference< css::uno::XInterface > const & getUnoModel()
Definition: svdmodel.cxx:1552
bool IsUndoEnabled() const
returns true if undo is currently enabled This returns false if undo was disabled using EnableUndo( f...
Definition: svdmodel.cxx:529
const SdrPage * GetPage(sal_uInt16 nPgNum) const
Definition: svdmodel.cxx:1807
sal_uInt16 GetPageCount() const
Definition: svdmodel.cxx:1817
void EndUndo()
Definition: svdmodel.cxx:435
SdrTextObj * GetTextEditObject() const
Definition: svdedxv.hxx:234
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
Definition: svdedxv.cxx:1566
const OutlinerView * GetTextEditOutlinerView() const
Definition: svdedxv.hxx:252
static void ApplyFormatPaintBrushToText(SfxItemSet const &rFormatSet, SdrTextObj &rTextObj, SdrText *pText, bool bNoCharacterFormats, bool bNoParagraphFormats)
helper function for selections with multiple SdrText for one SdrTextObj (f.e.
Definition: svdedxv.cxx:2866
virtual bool IsTextEdit() const final override
Definition: svdedxv.cxx:1834
virtual void MarkListHasChanged() override
Definition: svdedxv.cxx:2648
virtual bool SdrBeginTextEdit(SdrObject *pObj, SdrPageView *pPV=nullptr, vcl::Window *pWin=nullptr, bool bIsNewObj=false, SdrOutliner *pGivenOutliner=nullptr, OutlinerView *pGivenOutlinerView=nullptr, bool bDontDeleteOutliner=false, bool bOnlyOneView=false, bool bGrabFocus=true)
Definition: svdedxv.cxx:1223
const SdrOutliner * GetTextEditOutliner() const
Definition: svdedxv.hxx:244
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:823
size_t GetObjCount() const
Definition: svdpage.cxx:817
SdrObjUserCall * GetUserCall() const
Definition: svdobj.hxx:844
static rtl::Reference< T > Clone(T const &rObj, SdrModel &rTargetModel)
Definition: svdobj.hxx:449
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:289
void SendUserCall(SdrUserCallType eUserCall, const tools::Rectangle &rBoundRect) const
Definition: svdobj.cxx:2766
virtual const tools::Rectangle & GetLastBoundRect() const
Definition: svdobj.cxx:940
SdrPage * getSdrPageFromSdrObject() const
Definition: svdobj.cxx:279
const SfxItemSet & GetMergedItemSet() const
Definition: svdobj.cxx:1977
SdrPage * GetPage() const
Definition: svdpagv.hxx:166
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:377
SdrPaintWindow * GetPaintWindow(sal_uInt32 nIndex) const
Definition: svdpntv.cxx:75
OutputDevice * GetFirstOutputDevice() const
Definition: svdpntv.cxx:91
sal_uInt32 PaintWindowCount() const
Definition: svdpntv.hxx:218
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:300
rtl::Reference< sdr::overlay::OverlayManager > const & GetOverlayManager() const
virtual std::unique_ptr< SdrUndoAction > CreateUndoAttrObject(SdrObject &rObject, bool bStyleSheet1=false, bool bSaveText=false)
Definition: svdundo.cxx:1654
virtual std::unique_ptr< SdrUndoAction > CreateUndoGeoObject(SdrObject &rObject)
Definition: svdundo.cxx:1643
Changing the geometry of an object.
Definition: svdundo.hxx:213
void SetSkipChangeLayout(bool bOn)
Definition: svdundo.hxx:229
SdrHitKind PickAnything(const MouseEvent &rMEvt, SdrMouseEventKind nMouseDownOrMoveOrUp, SdrViewEvent &rVEvt) const
Definition: svdview.cxx:249
bool GetValue() const
const WhichRangesContainer & GetRanges() const
SfxItemPool * GetPool() const
sal_uInt16 Count() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
void MergeValue(const SfxPoolItem &rItem, bool bOverwriteDefaults=false)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
void InvalidateItem(sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
weld::Window * GetFrameWeld() const
SfxStyleFamily GetFamily() const
virtual SfxItemSet & GetItemSet()
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
sal_uInt16 FirstWhich()
SfxItemState GetItemState(bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
sal_uInt16 NextWhich()
const Color & GetHighlightColor() const
virtual VclPtr< SvxAbstractSplitTableDialog > CreateSvxSplitTableDialog(weld::Window *pParent, bool bIsTableVertical, tools::Long nMaxVertical)=0
virtual VclPtr< SfxAbstractTabDialog > CreateSvxFormatCellsDialog(weld::Window *pParent, const SfxItemSet *pAttr, const SdrModel &rModel, bool bStyle)=0
static SvxAbstractDialogFactory * Create()
Definition: svxdlg.cxx:22
bool IsValid(SvxBoxInfoItemValidFlags nValid) const
const editeng::SvxBorderLine * GetHori() const
const editeng::SvxBorderLine * GetVert() const
void SetValid(SvxBoxInfoItemValidFlags nValid, bool bValid=true)
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxInfoItemLine nLine)
const editeng::SvxBorderLine * GetTop() const
const editeng::SvxBorderLine * GetLine(SvxBoxItemLine nLine) const
const editeng::SvxBorderLine * GetRight() const
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)
const editeng::SvxBorderLine * GetLeft() const
sal_Int16 GetDistance(SvxBoxItemLine nLine, bool bAllowNegative=false) const
void SetDistance(sal_Int16 nNew, SvxBoxItemLine nLine)
const editeng::SvxBorderLine * GetBottom() const
const Color & GetValue() const
void release() const
TYPE getMaxX() const
TYPE getMinX() const
TYPE getMinY() const
void expand(const Tuple2D< TYPE > &rTuple)
TYPE getMaxY() const
::std::vector< basegfx::B2DRange > RangeVector
bool IsTextEditActive() const
Definition: svdotable.hxx:180
void setTableStyleSettings(const sdr::table::TableStyleSettings &rStyle)
Definition: svdotable.cxx:1140
virtual OutlinerParaObject * GetOutlinerParaObject() const override
Definition: svdotable.cxx:1850
void changeEdge(bool bHorizontal, int nEdge, sal_Int32 nOffset)
Definition: svdotable.cxx:1563
sal_Int32 getColumnCount() const
Definition: svdotable.cxx:1553
const sdr::table::TableStyleSettings & getTableStyleSettings() const
Definition: svdotable.cxx:1126
static CellPos getFirstCell()
Definition: svdotable.cxx:912
sal_Int32 getRowCount() const
Definition: svdotable.cxx:1558
css::text::WritingMode GetWritingMode() const
Definition: svdotable.cxx:1986
void getActiveCellPos(sdr::table::CellPos &rPos) const
Definition: svdotable.cxx:1596
void DistributeColumns(sal_Int32 nFirstColumn, sal_Int32 nLastColumn, const bool bOptimize, const bool bMinimize)
Definition: svdotable.cxx:2368
virtual bool IsVerticalWriting() const override
Definition: svdotable.cxx:1969
void setTableStyle(const css::uno::Reference< css::container::XIndexAccess > &xAutoFormatStyle)
Definition: svdotable.cxx:1270
css::uno::Reference< css::table::XTable > getTable() const
Definition: svdotable.cxx:900
void setActiveCell(const sdr::table::CellPos &rPos)
Definition: svdotable.cxx:1569
virtual void SetChanged() override
Definition: svdotable.cxx:2388
void DistributeRows(sal_Int32 nFirstRow, sal_Int32 nLastRow, const bool bOptimize, const bool bMinimize)
Definition: svdotable.cxx:2378
virtual bool ChangeFontSize(bool bGrow, const FontList *pFontList) override
Changes the font (grow/shrink) according to the input parameters.
SVX_DLLPRIVATE void DistributeColumns(const bool bOptimize, const bool bMinimize)
virtual SVX_DLLPRIVATE ~SvxTableController() override
SVX_DLLPRIVATE void SetTableStyleSettings(const SfxItemSet *pArgs)
bool deselectColumn(sal_Int32 column)
virtual SVX_DLLPRIVATE bool PasteObjModel(const SdrModel &rModel) override
SVX_DLLPRIVATE void destroySelectionOverlay()
void SetAttrToSelectedShape(const SfxItemSet &rAttr)
SVX_DLLPRIVATE void FillCommonBorderAttrFromSelectedCells(SvxBoxItem &rBox, SvxBoxInfoItem &rBoxInfo) const
Fill the values that are common for all selected cells.
virtual SVX_DLLPRIVATE bool ApplyFormatPaintBrush(SfxItemSet &rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats) override
applies a format paint brush set from the current selection.
SVX_DLLPRIVATE void onFormatTable(const SfxRequest &rReq)
SVX_DLLPRIVATE void SetTableStyle(const SfxItemSet *pArgs)
virtual SVX_DLLPRIVATE void onSelectAll() override
virtual SVX_DLLPRIVATE rtl::Reference< SdrObject > GetMarkedSdrObjClone(SdrModel &rTargetModel) override
SVX_DLLPRIVATE TblAction getKeyboardAction(const KeyEvent &rKEvt)
SVX_DLLPRIVATE void SetAttrToSelectedCells(const SfxItemSet &rAttr, bool bReplaceAll)
SVX_DLLPRIVATE void findMergeOrigin(CellPos &rPos)
SVX_DLLPRIVATE void UpdateSelection(const CellPos &rPos)
SVX_DLLPRIVATE void changeTableEdge(const SfxRequest &rReq)
virtual SVX_DLLPRIVATE bool DeleteMarked() override
SVX_DLLPRIVATE void StopTextEdit()
SVX_DLLPRIVATE void MergeRange(sal_Int32 nFirstCol, sal_Int32 nFirstRow, sal_Int32 nLastCol, sal_Int32 nLastRow)
static SVX_DLLPRIVATE rtl::Reference< sdr::SelectionController > create(SdrView &rView, const SdrTableObj &rObj, const rtl::Reference< sdr::SelectionController > &xRefController)
SVX_DLLPRIVATE void EditCell(const CellPos &rPos, vcl::Window *pWindow, TblAction nAction)
void getSelectedCells(CellPos &rFirstPos, CellPos &rLastPos) override
bool isColumnSelected(sal_Int32 nColumn)
SVX_DLLPRIVATE void onDelete(sal_uInt16 nSId)
sdr::table::SdrTableObj * GetTableObj()
virtual SVX_DLLPRIVATE bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll) override
SVX_DLLPRIVATE const CellPos & getSelectionStart()
virtual SVX_DLLPRIVATE bool onMouseButtonDown(const MouseEvent &rMEvt, vcl::Window *pWin) override
static SvxBoxItem TextDistancesToSvxBoxItem(const SfxItemSet &rAttrSet)
SVX_DLLPRIVATE void UpdateTableShape()
SVX_DLLPRIVATE void gotoCell(const CellPos &rCell, bool bSelect, vcl::Window *pWindow, TblAction nAction=TblAction::NONE)
std::optional< sdr::overlay::OverlayObjectList > mpSelectionOverlay
SVX_DLLPRIVATE void StartSelection(const CellPos &rPos)
static void SvxBoxItemToTextDistances(const SvxBoxItem &pOriginalItem, SfxItemSet &rAttrSet)
virtual SVX_DLLPRIVATE void onSelectionHasChanged() override
virtual SVX_DLLPRIVATE bool setCursorLogicPosition(const Point &rPosition, bool bPoint) override
css::uno::Reference< css::util::XModifyListener > mxModifyListener
SVX_DLLPRIVATE void setSelectionStart(const CellPos &rPos)
virtual SVX_DLLPRIVATE bool onMouseMove(const MouseEvent &rMEvt, vcl::Window *pWin) override
SVX_DLLPRIVATE void ApplyBorderAttr(const SfxItemSet &rAttr)
SVX_DLLPRIVATE void onSelect(sal_uInt16 nSId)
rtl::Reference< TableModel > mxTable
SVX_DLLPRIVATE void checkCell(CellPos &rPos) const
virtual SVX_DLLPRIVATE bool GetStyleSheet(SfxStyleSheet *&rpStyleSheet) const override
unotools::WeakReference< SdrTableObj > mxTableObj
SVX_DLLPRIVATE void updateSelectionOverlay()
SVX_DLLPRIVATE void SplitMarkedCells(const SfxRequest &rReq)
virtual SVX_DLLPRIVATE bool onMouseButtonUp(const MouseEvent &rMEvt, vcl::Window *pWin) override
virtual SVX_DLLPRIVATE bool onKeyInput(const KeyEvent &rKEvt, vcl::Window *pWin) override
bool selectColumn(sal_Int32 column)
SVX_DLLPRIVATE SvxTableController(SdrView &rView, const SdrTableObj &rObj)
SVX_DLLPRIVATE bool executeAction(TblAction nAction, bool bSelect, vcl::Window *pWindow)
SVX_DLLPRIVATE bool checkTableObject()
SVX_DLLPRIVATE bool HasMarked() const
SVX_DLLPRIVATE bool PasteObject(SdrTableObj const *pPasteTableObj)
SVX_DLLPRIVATE void MergeMarkedCells()
SVX_DLLPRIVATE void DistributeRows(const bool bOptimize, const bool bMinimize)
virtual SVX_DLLPRIVATE bool hasSelectedCells() const override
This is a table object, and one or more of its cells are selected.
SVX_DLLPRIVATE void onInsert(sal_uInt16 nSId, const SfxItemSet *pArgs=nullptr)
void setSelectedCells(const CellPos &rFirstPos, const CellPos &rLastPos)
SVX_DLLPRIVATE void RemoveSelection()
virtual void Execute(SfxRequest &rReq) override
SVX_DLLPRIVATE void onTableModified()
SVX_DLLPRIVATE const CellPos & getSelectionEnd()
SVX_DLLPRIVATE void SetVertical(sal_uInt16 nSId)
bool isRowSelected(sal_Int32 nRow)
SVX_DLLPRIVATE void MergeAttrFromSelectedCells(SfxItemSet &rAttr, bool bOnlyHardAttr) const
virtual SVX_DLLPRIVATE void GetState(SfxItemSet &rSet) override
virtual SVX_DLLPRIVATE bool SetStyleSheet(SfxStyleSheet *pStyleSheet, bool bDontRemoveHardAttr) override
virtual SVX_DLLPRIVATE bool GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr) const override
constexpr tools::Long Top() const
constexpr tools::Long Right() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
rtl::OString toString() const
bool IsMod1() const
sal_uInt16 GetCode() const
bool IsShift() const
bool IsMod2() const
Point PixelToLogic(const Point &rDevicePt) const
constexpr ::Color COL_BLUE(0x00, 0x00, 0x80)
int nCount
#define TOOLS_WARN_EXCEPTION(area, stream)
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
float u
ESelection aNewSelection(GetSelection())
#define EE_PARA_NOT_FOUND
#define EE_INDEX_NOT_FOUND
sal_Int32 nState
sal_Int32 mnRow
sal_Int32 mnCol
sal_Int32 nIndex
Mode eMode
#define SAL_WARN_IF(condition, area, stream)
sal_uInt16 nCode
NONE
@ Exception
constexpr auto toTwips(N number, Length from)
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
IMPL_LINK_NOARG(SvxTableController, UpdateHdl, void *, void)
TableHitKind
SdrTableHitKind.
Definition: svdotable.hxx:51
static void ImplApplyBorderLineItem(CellPosFlag nCellPosFlags, const SvxBorderLine *pBorderLineItem, SvxBoxItem &rNewFrame)
static void ImplSetLinePreserveColor(SvxBoxItem &rNewFrame, const SvxBorderLine *pNew, SvxBoxItemLine nLine)
static void ImplApplyBoxItem(CellPosFlag nCellPosFlags, const SvxBoxItem *pBoxItem, const SvxBoxInfoItem *pBoxInfoItem, SvxBoxItem &rNewFrame)
static void ImplApplyLineColorItem(CellPosFlag nCellPosFlags, const SvxColorItem *pLineColorItem, SvxBoxItem &rNewFrame)
rtl::Reference< sdr::SelectionController > CreateTableController(SdrView &rView, const SdrTableObj &rObj, const rtl::Reference< sdr::SelectionController > &xRefController)
static void ImplSetLineColor(SvxBoxItem &rNewFrame, SvxBoxItemLine nLine, const Color &rColor)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
const char GetValue[]
OUTDEV_WINDOW
SfxItemState
SdrTextVertAdjust
Definition: sdtaitm.hxx:29
@ SDRTEXTVERTADJUST_BOTTOM
Definition: sdtaitm.hxx:31
@ SDRTEXTVERTADJUST_BLOCK
Definition: sdtaitm.hxx:32
@ SDRTEXTVERTADJUST_CENTER
Definition: sdtaitm.hxx:30
@ SDRTEXTVERTADJUST_TOP
Definition: sdtaitm.hxx:29
SdrMetricItem makeSdrTextUpperDistItem(tools::Long mnHeight)
Definition: sdtditm.hxx:35
SdrMetricItem makeSdrTextRightDistItem(tools::Long mnHeight)
Definition: sdtditm.hxx:30
SdrMetricItem makeSdrTextLowerDistItem(tools::Long mnHeight)
Definition: sdtditm.hxx:40
SdrMetricItem makeSdrTextLeftDistItem(tools::Long mnHeight)
Definition: sdtditm.hxx:25
static SfxItemSet & rSet
TableStyleSettings.
Definition: svdotable.hxx:75
constexpr TypedWhichId< SdrMetricItem > SDRATTR_TEXT_LEFTDIST(SDRATTR_MISC_FIRST+4)
constexpr sal_uInt16 SDRATTR_START(XATTR_START)
constexpr TypedWhichId< SvxBoxInfoItem > SDRATTR_TABLE_BORDER_INNER(SDRATTR_TABLE_FIRST+1)
constexpr sal_uInt16 SDRATTR_SHADOW_FIRST(XATTR_END+1)
constexpr sal_uInt16 SDRATTR_TABLE_LAST(SDRATTR_TABLE_TEXT_ROTATION)
constexpr sal_uInt16 SDRATTR_SHADOW_LAST(SDRATTR_SHADOWBLUR)
constexpr TypedWhichId< SdrTextVertAdjustItem > SDRATTR_TEXT_VERTADJUST(SDRATTR_MISC_FIRST+8)
constexpr TypedWhichId< SvxBoxItem > SDRATTR_TABLE_BORDER(SDRATTR_TABLE_FIRST+0)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_TEXT_RIGHTDIST(SDRATTR_MISC_FIRST+5)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_TEXT_LOWERDIST(SDRATTR_MISC_FIRST+7)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_TEXT_UPPERDIST(SDRATTR_MISC_FIRST+6)
std::unique_ptr< SdrOutliner > SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel &rModel)
Create an Outliner with the engine-global default settings on the heap.
Definition: svdetc.cxx:340
@ Table
media shape
SvxBoxInfoItem & m_rBoxInfoItem
o3tl::enumarray< SvxBoxInfoItemLine, bool > aInnerLineSet
const SvxBoxItemLine m_nBorderLine
const SvxBoxInfoItemLine m_nInnerLine
SvxBoxInfoItem & rBoxInfoItem
o3tl::enumarray< SvxBoxItemLine, bool > aBorderSet
const bool m_bBorder
SvxBoxItem & rBoxItem
o3tl::enumarray< SvxBoxInfoItemLine, bool > aInnerLineIndeterminate
o3tl::enumarray< SvxBoxItemLine, sal_uInt16 > aDistance
SvxTableController * mpController
o3tl::enumarray< SvxBoxItemLine, bool > aBorderIndeterminate
bool bDistanceIndeterminate
o3tl::enumarray< SvxBoxItemLine, bool > aDistanceSet
SvxBoxItem & m_rBoxItem
Left
Right
RET_OK