23 #include <tablemodel.hxx>
25 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
26 #include <com/sun/star/container/XIndexAccess.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/table/XMergeableCellRange.hpp>
30 #include <com/sun/star/table/XMergeableCell.hpp>
47 #include <svx/svxids.hrc>
60 #include <svx/strings.hrc>
67 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
78 using ::editeng::SvxBorderLine;
114 class SvxTableControllerModifyListener :
public ::cppu::WeakImplHelper< css::util::XModifyListener >
121 virtual void SAL_CALL modified(
const css::lang::EventObject& aEvent )
override;
124 virtual void SAL_CALL disposing(
const css::lang::EventObject& Source )
override;
134 void SAL_CALL SvxTableControllerModifyListener::modified(
const css::lang::EventObject& )
144 void SAL_CALL SvxTableControllerModifyListener::disposing(
const css::lang::EventObject& )
166 if( xRefController.is() )
170 if(pController && (pController->
mxTableObj.get() == &rObj) && (&pController->
mrView == &rView))
172 return xRefController;
183 : mbCellSelectionMode(
false)
184 ,mbHasJustMerged(
false)
185 ,mbLeftButtonDown(
false)
188 ,mnUpdateEvent( nullptr )
193 Reference< XTable > xTable(
mxTableObj->getTable() );
199 mxTable.set( dynamic_cast< TableModel* >( xTable.get() ) );
212 Reference< XTable > xTable(
mxTableObj->getTable() );
230 if( rModel.IsReadOnly())
237 case awt::Key::RIGHT:
245 case awt::Key::ESCAPE:
279 pWindow = pOutputDevice->GetOwnerWindow();
327 bool bEmptyOutliner =
false;
330 if (pOutliner->GetParagraphCount() == 1)
332 if (
Paragraph* pParagraph = pOutliner->GetParagraph(0))
333 bEmptyOutliner = pOutliner->GetText(pParagraph).isEmpty();
395 bool bSelected =
false;
437 std::optional<SfxItemSet> oSet;
438 bool bVertDone(
false);
447 case SID_TABLE_VERT_BOTTOM:
448 case SID_TABLE_VERT_CENTER:
449 case SID_TABLE_VERT_NONE:
455 oSet.emplace(rModel.GetItemPool());
471 case SID_TABLE_DELETE_ROW:
475 case SID_TABLE_DELETE_COL:
479 case SID_TABLE_DELETE_TABLE:
483 case SID_TABLE_MERGE_CELLS:
487 case SID_TABLE_SPLIT_CELLS:
492 case SID_TABLE_OPTIMAL_ROW_HEIGHT:
493 case SID_TABLE_DISTRIBUTE_COLUMNS:
494 case SID_TABLE_DISTRIBUTE_ROWS:
496 bool bDistributeColumns =
false;
497 bool bDistributeRows =
false;
503 bDistributeColumns = aStart.
mnCol != aEnd.
mnCol;
506 if( !bDistributeColumns )
508 if( !bDistributeRows )
531 bool bInsertAfter =
true;
542 bInsertAfter = pItem2->GetValue();
566 static const OUStringLiteral sSize(
u"Size" );
567 const bool bUndo(rModel.IsUndoEnabled());
571 case SID_TABLE_INSERT_COL:
577 rModel.BegUndo(
SvxResId(STR_TABLE_INSCOL) );
578 rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
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 );
586 for( sal_Int32 nOffset = 0; nOffset < nNewColumns; nOffset++ )
595 Reference< XPropertySet >(xCols->getByIndex( bInsertAfter?nNewStartColumn-1:nNewStartColumn+nNewColumns ), UNO_QUERY_THROW )->
600 sal_Int32 nPropSrcCol = (bInsertAfter ? aEnd.
mnCol : aStart.
mnCol + nNewColumns);
601 sal_Int32 nRowSpan = 0;
602 bool bNewSpan =
false;
604 for( sal_Int32 nRow = 0; nRow <
mxTable->getRowCount(); ++nRow )
606 CellRef xSourceCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nPropSrcCol, nRow ).get() ) );
609 if (xSourceCell.is() && nRowSpan == 0)
612 sal_Int32 nColSpan = sal_Int32();
613 sal_Int32 nSpanInfoCol = sal_Int32();
615 if( xSourceCell->getRowSpan() > 1 )
619 nRowSpan = xSourceCell->getRowSpan();
620 nColSpan = xSourceCell->getColumnSpan();
621 nSpanInfoCol = nPropSrcCol;
623 else if( xSourceCell->isMerged() )
627 for( nSpanInfoCol = nPropSrcCol - 1; nSpanInfoCol >= 0; --nSpanInfoCol )
629 CellRef xMergeInfoCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nSpanInfoCol, nRow ).get() ) );
630 if (xMergeInfoCell.is() && !xMergeInfoCell->isMerged())
632 nRowSpan = xMergeInfoCell->getRowSpan();
633 nColSpan = xMergeInfoCell->getColumnSpan();
642 if( nRowSpan > 0 && ( nNewStartColumn < nSpanInfoCol || nSpanInfoCol + nColSpan <= nNewStartColumn ) )
647 for( sal_Int32 nOffset = 0; nOffset < nNewColumns; nOffset++ )
649 CellRef xTargetCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nNewStartColumn + nOffset, nRow ).get() ) );
650 if( xTargetCell.is() )
655 xTargetCell->merge( 1, nRowSpan );
657 xTargetCell->setMerged();
659 xTargetCell->copyFormatFrom( xSourceCell );
673 aStart.
mnCol = nNewStartColumn;
680 case SID_TABLE_INSERT_ROW:
686 rModel.BegUndo(
SvxResId(STR_TABLE_INSROW ) );
687 rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
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 );
695 for( sal_Int32 nOffset = 0; nOffset < nNewRows; nOffset++ )
704 sal_Int32 nPropSrcRow = (bInsertAfter ? aEnd.
mnRow : aStart.
mnRow + nNewRows);
705 sal_Int32 nColSpan = 0;
706 bool bNewSpan =
false;
708 for( sal_Int32 nCol = 0; nCol <
mxTable->getColumnCount(); ++nCol )
710 CellRef xSourceCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nCol, nPropSrcRow ).get() ) );
712 if (!xSourceCell.is())
719 sal_Int32 nRowSpan = sal_Int32();
720 sal_Int32 nSpanInfoRow = sal_Int32();
722 if( xSourceCell->getColumnSpan() > 1 )
726 nColSpan = xSourceCell->getColumnSpan();
727 nRowSpan = xSourceCell->getRowSpan();
728 nSpanInfoRow = nPropSrcRow;
730 else if( xSourceCell->isMerged() )
734 for( nSpanInfoRow = nPropSrcRow - 1; nSpanInfoRow >= 0; --nSpanInfoRow )
736 CellRef xMergeInfoCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nCol, nSpanInfoRow ).get() ) );
737 if (xMergeInfoCell.is() && !xMergeInfoCell->isMerged())
739 nColSpan = xMergeInfoCell->getColumnSpan();
740 nRowSpan = xMergeInfoCell->getRowSpan();
749 if( nColSpan > 0 && ( nNewRowStart < nSpanInfoRow || nSpanInfoRow + nRowSpan <= nNewRowStart ) )
754 for( sal_Int32 nOffset = 0; nOffset < nNewRows; ++nOffset )
756 CellRef xTargetCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nCol, nNewRowStart + nOffset ).get() ) );
757 if( xTargetCell.is() )
762 xTargetCell->merge( nColSpan, 1 );
764 xTargetCell->setMerged();
766 xTargetCell->copyFormatFrom( xSourceCell );
781 aStart.
mnRow = nNewRowStart;
796 if( !pTableObj || !
mxTable.is() )
799 if( nSId == SID_TABLE_DELETE_TABLE )
816 bool bDeleteTable =
false;
819 case SID_TABLE_DELETE_COL:
821 const sal_Int32 nRemovedColumns = aEnd.
mnCol - aStart.
mnCol + 1;
822 if( nRemovedColumns ==
mxTable->getColumnCount() )
828 Reference< XTableColumns > xCols(
mxTable->getColumns() );
829 xCols->removeByIndex( aStart.
mnCol, nRemovedColumns );
835 case SID_TABLE_DELETE_ROW:
837 const sal_Int32 nRemovedRows = aEnd.
mnRow - aStart.
mnRow + 1;
838 if( nRemovedRows ==
mxTable->getRowCount() )
844 Reference< XTableRows > xRows(
mxTable->getRows() );
845 xRows->removeByIndex( aStart.
mnRow, nRemovedRows );
865 const sal_Int32 nRowCount =
mxTable->getRowCount();
866 const sal_Int32 nColCount =
mxTable->getColumnCount();
867 if( !(nRowCount && nColCount) )
875 case SID_TABLE_SELECT_ALL:
877 aStart.
mnCol = nColCount - 1; aStart.
mnRow = nRowCount - 1;
879 case SID_TABLE_SELECT_COL:
880 aEnd.
mnRow = nRowCount - 1;
883 case SID_TABLE_SELECT_ROW:
884 aEnd.
mnCol = nColCount - 1;
900 aBoxItem.SetDistance( sal::static_int_cast< sal_uInt16 >( rAttrSet.
Get(
SDRATTR_TEXT_RIGHTDIST).GetValue()), SvxBoxItemLine::RIGHT );
901 aBoxItem.SetDistance( sal::static_int_cast< sal_uInt16 >( rAttrSet.
Get(
SDRATTR_TEXT_UPPERDIST).GetValue()), SvxBoxItemLine::TOP );
902 aBoxItem.SetDistance( sal::static_int_cast< sal_uInt16 >( rAttrSet.
Get(
SDRATTR_TEXT_LOWERDIST).GetValue()), SvxBoxItemLine::BOTTOM );
922 SvxBoxItem aBoxItem(mergeDrawinglayerTextDistancesAndSvxBoxItem(aNewAttr));
928 aNewAttr.Put( aBoxItem );
929 aNewAttr.Put( aBoxInfoItem );
935 if (rTableItemSet.
GetItemState(nWhich,
false) != SfxItemState::SET)
940 aNewAttr.
Put(rTableItemSet.
Get(nWhich));
950 xDlg->StartExecuteAsync([xDlg,
this, aBoxItem, aBoxInfoItem](
int nResult){
962 aNewSet.
Put(aBoxItem);
966 aNewSet.
Put(aBoxInfoItem);
971 if( aNewBoxItem.GetDistance( SvxBoxItemLine::LEFT ) != aBoxItem.GetDistance( SvxBoxItemLine::LEFT ) )
974 if( aNewBoxItem.GetDistance( SvxBoxItemLine::RIGHT ) != aBoxItem.GetDistance( SvxBoxItemLine::RIGHT ) )
977 if( aNewBoxItem.GetDistance( SvxBoxItemLine::TOP ) != aBoxItem.GetDistance( SvxBoxItemLine::TOP ) )
980 if( aNewBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) != aBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) )
991 rSdrModel.BegUndo(
SvxResId(STR_TABLE_NUMFORMAT));
1000 rSdrModel.EndUndo();
1005 xDlg->disposeOnce();
1011 const sal_uInt16 nSId = rReq.
GetSlot();
1014 case SID_TABLE_INSERT_ROW:
1015 case SID_TABLE_INSERT_COL:
1018 case SID_TABLE_DELETE_ROW:
1019 case SID_TABLE_DELETE_COL:
1020 case SID_TABLE_DELETE_TABLE:
1023 case SID_TABLE_SELECT_ALL:
1024 case SID_TABLE_SELECT_COL:
1025 case SID_TABLE_SELECT_ROW:
1028 case SID_FORMAT_TABLE_DLG:
1032 case SID_FRAME_LINESTYLE:
1033 case SID_FRAME_LINECOLOR:
1034 case SID_ATTR_BORDER:
1042 case SID_ATTR_FILL_STYLE:
1050 case SID_TABLE_MERGE_CELLS:
1054 case SID_TABLE_SPLIT_CELLS:
1058 case SID_TABLE_MINIMAL_COLUMN_WIDTH:
1062 case SID_TABLE_OPTIMAL_COLUMN_WIDTH:
1066 case SID_TABLE_DISTRIBUTE_COLUMNS:
1070 case SID_TABLE_MINIMAL_ROW_HEIGHT:
1074 case SID_TABLE_OPTIMAL_ROW_HEIGHT:
1078 case SID_TABLE_DISTRIBUTE_ROWS:
1082 case SID_TABLE_VERT_BOTTOM:
1083 case SID_TABLE_VERT_CENTER:
1084 case SID_TABLE_VERT_NONE:
1088 case SID_AUTOFORMAT:
1089 case SID_TABLE_SORT_DIALOG:
1090 case SID_TABLE_AUTOSUM:
1094 case SID_TABLE_STYLE:
1098 case SID_TABLE_STYLE_SETTINGS:
1101 case SID_TABLE_CHANGE_CURRENT_BORDER_POSITION:
1115 if(!pArgs || (SfxItemState::SET != pArgs->
GetItemState(SID_TABLE_STYLE,
false)))
1124 Reference< XStyleFamiliesSupplier > xSFS( rModel.getUnoModel(), UNO_QUERY_THROW );
1128 if( xTableFamilyAccess->hasByName( pArg->
GetValue() ) )
1131 Reference< XIndexAccess > xNewTableStyle( xTableFamilyAccess->getByName( pArg->
GetValue() ), UNO_QUERY_THROW );
1133 const bool bUndo = rModel.IsUndoEnabled();
1137 rModel.BegUndo(
SvxResId(STR_TABLE_STYLE));
1138 rModel.AddUndo(std::make_unique<TableStyleUndo>(rTableObj));
1143 const sal_Int32 nRowCount =
mxTable->getRowCount();
1144 const sal_Int32 nColCount =
mxTable->getColumnCount();
1145 for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
1147 for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ )
try
1149 CellRef xCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nCol, nRow ).get() ) );
1153 bool bChanges =
false;
1155 SAL_WARN_IF(!pStyleSheet,
"svx",
"no stylesheet for table cell?");
1162 if( (rStyleAttribs.
GetItemState( nWhich ) == SfxItemState::SET) && (aSet.GetItemState( nWhich ) == SfxItemState::SET) )
1175 xCell->SetMergedItemSetAndBroadcast( aSet,
true );
1206 if( (pPoolItem = pArgs->
GetItemIfSet(ID_VAL_USEFIRSTROWSTYLE,
false)) )
1207 aSettings.mbUseFirstRow = pPoolItem->
GetValue();
1209 if( (pPoolItem = pArgs->
GetItemIfSet(ID_VAL_USELASTROWSTYLE,
false)) )
1210 aSettings.mbUseLastRow = pPoolItem->GetValue();
1212 if( (pPoolItem = pArgs->
GetItemIfSet(ID_VAL_USEBANDINGROWSTYLE,
false)) )
1213 aSettings.mbUseRowBanding = pPoolItem->GetValue();
1215 if( (pPoolItem = pArgs->
GetItemIfSet(ID_VAL_USEFIRSTCOLUMNSTYLE,
false)) )
1216 aSettings.mbUseFirstColumn = pPoolItem->GetValue();
1218 if( (pPoolItem = pArgs->
GetItemIfSet(ID_VAL_USELASTCOLUMNSTYLE,
false)) )
1219 aSettings.mbUseLastColumn = pPoolItem->GetValue();
1221 if( (pPoolItem = pArgs->
GetItemIfSet(ID_VAL_USEBANDINGCOLUMNSTYLE,
false)) )
1222 aSettings.mbUseColumnBanding = pPoolItem->GetValue();
1227 const bool bUndo(rModel.IsUndoEnabled());
1231 rModel.BegUndo(
SvxResId(STR_TABLE_STYLE_SETTINGS) );
1232 rModel.AddUndo(std::make_unique<TableStyleUndo>(rTableObj));
1250 const bool bUndo(rModel.IsUndoEnabled());
1254 rModel.BegUndo(
SvxResId(STR_TABLE_NUMFORMAT));
1255 rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoAttrObject(rTableObj));
1265 case SID_TABLE_VERT_BOTTOM:
1268 case SID_TABLE_VERT_CENTER:
1278 for( sal_Int32 nRow = aStart.
mnRow; nRow <= aEnd.
mnRow; nRow++ )
1280 for( sal_Int32 nCol = aStart.
mnCol; nCol <= aEnd.
mnCol; nCol++ )
1282 CellRef xCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nCol, nRow ).get() ) );
1289 xCell->SetMergedItemSetAndBroadcast(aSet,
false);
1331 Reference< XMergeableCellRange > xRange(
mxTable->createCursorByRange(
mxTable->getCellRangeByPosition( aStart.
mnCol, aStart.
mnRow, aEnd.
mnCol, aEnd.
mnRow ) ), UNO_QUERY_THROW );
1332 const sal_Int32 nRowCount =
mxTable->getRowCount();
1333 const sal_Int32 nColCount =
mxTable->getColumnCount();
1341 const bool bUndo(rModel.IsUndoEnabled());
1346 rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
1351 xRange->split( 0, nCount );
1355 xRange->split( nCount, 0 );
1377 const bool bUndo(rModel.IsUndoEnabled());
1382 rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
1400 const bool bUndo(rModel.IsUndoEnabled());
1405 rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
1428 const bool bUndo(rModel.IsUndoEnabled());
1429 bool bDeleteTable =
false;
1436 const sal_Int32 nRemovedColumns = aEnd.
mnCol - aStart.
mnCol + 1;
1437 const sal_Int32 nRemovedRows = aEnd.
mnRow - aStart.
mnRow + 1;
1438 if( nRemovedColumns ==
mxTable->getColumnCount() && nRemovedRows ==
mxTable->getRowCount())
1440 bDeleteTable =
true;
1444 for( sal_Int32 nRow = aStart.
mnRow; nRow <= aEnd.
mnRow; nRow++ )
1446 for( sal_Int32 nCol = aStart.
mnCol; nCol <= aEnd.
mnCol; nCol++ )
1448 CellRef xCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nCol, nRow ).get() ) );
1449 if (xCell.is() && xCell->hasText())
1453 xCell->SetOutlinerParaObject(std::nullopt);
1474 rpStyleSheet =
nullptr;
1484 for( sal_Int32 nRow = aStart.
mnRow; nRow <= aEnd.
mnRow; nRow++ )
1486 for( sal_Int32 nCol = aStart.
mnCol; nCol <= aEnd.
mnCol; nCol++ )
1488 CellRef xCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nCol, nRow ).get() ) );
1496 else if(pRet != pSS)
1504 rpStyleSheet = pRet;
1520 for( sal_Int32 nRow = aStart.
mnRow; nRow <= aEnd.
mnRow; nRow++ )
1522 for( sal_Int32 nCol = aStart.
mnCol; nCol <= aEnd.
mnCol; nCol++ )
1524 CellRef xCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nCol, nRow ).get() ) );
1526 xCell->SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
1546 if (!(pType && pIndex && pOffset))
1549 const OUString
sType = pType->GetValue();
1555 sal_Int32 nEdgeIndex = -1;
1556 bool bHorizontal = sType.startsWith(
"row");
1558 if (sType ==
"column-left" || sType ==
"row-left")
1562 else if (sType ==
"column-right")
1565 nEdgeIndex = rTableObj.getColumnCount();
1567 else if (sType ==
"row-right")
1570 nEdgeIndex = rTableObj.getRowCount();
1572 else if (sType ==
"column-middle" || sType ==
"row-middle")
1574 nEdgeIndex = nIndex + 1;
1581 SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
1582 const bool bUndo(rModel.IsUndoEnabled());
1586 rModel.BegUndo(pUndoObject->GetComment());
1588 auto* pGeoUndo =
static_cast<SdrUndoGeoObj*
>(pUndoObject.get());
1592 rModel.AddUndo(std::move(pUndoObject));
1595 if (rTableObj.GetUserCall())
1596 aBoundRect = rTableObj.GetLastBoundRect();
1597 rTableObj.changeEdge(bHorizontal, nEdgeIndex, nOffset);
1598 rTableObj.SetChanged();
1629 case awt::Key::ESCAPE:
1643 case awt::Key::RETURN:
1645 if( !bMod1 && !bMod2 && !bTextEdit )
1655 if( bMod1 || bMod2 )
1658 else if( bTextEdit )
1676 case awt::Key::HOME:
1677 case awt::Key::NUM7:
1681 if( bMod1 && !bMod2 )
1686 else if( !bMod1 && bMod2 )
1695 case awt::Key::NUM1:
1699 if( bMod1 && !bMod2 )
1704 else if( !bMod1 && bMod2 )
1721 case awt::Key::NUM8:
1722 case awt::Key::DOWN:
1723 case awt::Key::NUM2:
1724 case awt::Key::LEFT:
1725 case awt::Key::NUM4:
1726 case awt::Key::RIGHT:
1727 case awt::Key::NUM6:
1730 if( !bMod1 && bMod2 )
1734 if( (nCode == awt::Key::UP) || (nCode == awt::Key::NUM8) )
1739 else if( (nCode == awt::Key::DOWN) || (nCode == awt::Key::NUM2) )
1747 bool bTextMove =
false;
1767 case awt::Key::LEFT:
1768 case awt::Key::NUM4:
1771 case awt::Key::RIGHT:
1772 case awt::Key::NUM6:
1775 case awt::Key::DOWN:
1776 case awt::Key::NUM2:
1780 case awt::Key::NUM8:
1787 case awt::Key::PAGEUP:
1792 case awt::Key::PAGEDOWN:
1835 gotoCell( aPos, bSelect, pWindow, nAction );
1842 gotoCell( aPos, bSelect, pWindow, nAction );
1849 gotoCell( aPos, bSelect, pWindow, nAction );
1868 gotoCell( aPos, bSelect, pWindow, nAction );
1892 if( aSelectionEnd == aNextCell )
1895 aNextCell = pTableObj->
getNextCell( aSelectionEnd,
true );
1897 gotoCell( aNextCell,
false, pWindow, nAction );
1932 EditCell( rPos, pWindow, nAction );
1964 Reference< XMergeableCellRange > xRange(
mxTable->createCursorByRange(
mxTable->getCellRangeByPosition( nFirstCol, nFirstRow,nLastCol, nLastRow ) ), UNO_QUERY_THROW );
1966 if( xRange->isMergeable() )
1970 const bool bUndo(rModel.IsUndoEnabled());
1975 rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
2020 Reference< XMergeableCell > xCell(
mxTable->getCellByPosition( rPos.
mnCol, rPos.
mnRow ), UNO_QUERY_THROW );
2021 if( xCell->isMerged() )
2045 bool bEmptyOutliner =
false;
2053 if(nParaCnt==1 && p1stPara)
2056 if (pOutl->
GetText(p1stPara).isEmpty())
2058 bEmptyOutliner =
true;
2076 std::unique_ptr<SdrOutliner> pOutl(
SdrMakeOutliner(OutlinerMode::OutlineObject, rModel));
2079 pOutl->SetVertical(
true );
2134 for( sal_Int32 nRow = rFirst.
mnRow; nRow <= rLast.
mnRow && !bExt; nRow++ )
2136 for( sal_Int32 nCol = rFirst.
mnCol; nCol <= rLast.
mnCol && !bExt; nCol++ )
2138 Reference< XMergeableCell > xCell(
mxTable->getCellByPosition( nCol, nRow ), UNO_QUERY );
2142 if( xCell->isMerged() )
2155 if( ((nCol + xCell->getColumnSpan() - 1) > rLast.
mnCol) || (nRow + xCell->getRowSpan() - 1 ) > rLast.
mnRow )
2157 rLast.
mnCol = std::max( rLast.
mnCol, nCol + xCell->getColumnSpan() - 1 );
2158 rLast.
mnRow = std::max( rLast.
mnRow, nRow + xCell->getRowSpan() - 1 );
2175 Reference< XMergeableCell > xCell(
mxTable->getCellByPosition( rLast.
mnCol, rLast.
mnRow ), UNO_QUERY );
2178 rLast.
mnCol += xCell->getColumnSpan() - 1;
2179 rLast.
mnRow += xCell->getRowSpan() - 1;
2244 for (sal_Int32 nRow = aStart.
mnRow; nRow <= aEnd.
mnRow; nRow++)
2246 for (sal_Int32 nCol = aStart.
mnCol; nCol <= aEnd.
mnCol; nCol++)
2248 CellRef xCell(dynamic_cast< Cell* >(
mxTable->getCellByPosition(nCol, nRow).get()));
2251 if (rModel.IsUndoEnabled())
2257 xCell->SetMergedItemSetAndBroadcast(aCellSet,
false);
2287 if( (aPos2.mnCol >= 0) && (aPos2.mnRow >= 0) )
2342 aRanges.push_back( a2DRange );
2356 if( xOverlayManager.is() )
2360 xOverlayManager->add(*pOverlay);
2378 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_SELECTION_AREA, aSelection.toString().getStr());
2379 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, aSelection.toString().getStr());
2396 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_SELECTION_AREA,
"EMPTY");
2397 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_START,
"EMPTY");
2398 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_END,
"EMPTY");
2399 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION,
"EMPTY");
2413 for( sal_Int32 nRow = aStart.
mnRow; nRow <= aEnd.
mnRow; nRow++ )
2415 for( sal_Int32 nCol = aStart.
mnCol; nCol <= aEnd.
mnCol; nCol++ )
2417 CellRef xCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nCol, nRow ).get() ) );
2418 if( xCell.is() && !xCell->isMerged() )
2420 const SfxItemSet& rSet = xCell->GetItemSet();
2427 if(SfxItemState::DONTCARE == rSet.
GetItemState(nWhich,
false))
2432 else if(SfxItemState::SET == rSet.
GetItemState(nWhich,
false))
2450 const SvxBorderLine* pOld = rNewFrame.
GetLine(nLine);
2453 SvxBorderLine aNewLine( *pNew );
2454 aNewLine.SetColor( pOld->GetColor() );
2455 rNewFrame.
SetLine( &aNewLine, nLine );
2459 rNewFrame.
SetLine( pNew, nLine );
2465 if (nCellPosFlags & (CellPosFlag::Before|CellPosFlag::After|CellPosFlag::Upper|CellPosFlag::Lower))
2469 if (!(nCellPosFlags & (CellPosFlag::Before|CellPosFlag::After)))
2471 if (nCellPosFlags & CellPosFlag::Upper)
2473 if( pBoxInfoItem->
IsValid(SvxBoxInfoItemValidFlags::TOP) )
2474 rNewFrame.
SetLine(
nullptr, SvxBoxItemLine::BOTTOM );
2476 else if (nCellPosFlags & CellPosFlag::Lower)
2478 if( pBoxInfoItem->
IsValid(SvxBoxInfoItemValidFlags::BOTTOM) )
2479 rNewFrame.
SetLine(
nullptr, SvxBoxItemLine::TOP );
2482 else if (!(nCellPosFlags & (CellPosFlag::Upper|CellPosFlag::Lower)))
2484 if (nCellPosFlags & CellPosFlag::Before)
2486 if( pBoxInfoItem->
IsValid(SvxBoxInfoItemValidFlags::LEFT) )
2487 rNewFrame.
SetLine(
nullptr, SvxBoxItemLine::RIGHT );
2489 else if (nCellPosFlags & CellPosFlag::After)
2491 if( pBoxInfoItem->
IsValid(SvxBoxInfoItemValidFlags::RIGHT) )
2492 rNewFrame.
SetLine(
nullptr, SvxBoxItemLine::LEFT );
2500 if ((nCellPosFlags & CellPosFlag::Left) ? pBoxInfoItem->
IsValid(SvxBoxInfoItemValidFlags::LEFT)
2501 : pBoxInfoItem->
IsValid(SvxBoxInfoItemValidFlags::VERT))
2502 rNewFrame.
SetLine( (nCellPosFlags & CellPosFlag::Left) ? pBoxItem->
GetLeft() : pBoxInfoItem->
GetVert(), SvxBoxItemLine::LEFT );
2504 if( (nCellPosFlags & CellPosFlag::Right) ? pBoxInfoItem->
IsValid(SvxBoxInfoItemValidFlags::RIGHT) : pBoxInfoItem->
IsValid(SvxBoxInfoItemValidFlags::VERT) )
2505 rNewFrame.
SetLine( (nCellPosFlags & CellPosFlag::Right) ? pBoxItem->
GetRight() : pBoxInfoItem->
GetVert(), SvxBoxItemLine::RIGHT );
2507 if( (nCellPosFlags & CellPosFlag::Top) ? pBoxInfoItem->
IsValid(SvxBoxInfoItemValidFlags::TOP) : pBoxInfoItem->
IsValid(SvxBoxInfoItemValidFlags::HORI) )
2508 rNewFrame.
SetLine( (nCellPosFlags & CellPosFlag::Top) ? pBoxItem->
GetTop() : pBoxInfoItem->
GetHori(), SvxBoxItemLine::TOP );
2510 if( (nCellPosFlags & CellPosFlag::Bottom) ? pBoxInfoItem->
IsValid(SvxBoxInfoItemValidFlags::BOTTOM) : pBoxInfoItem->
IsValid(SvxBoxInfoItemValidFlags::HORI) )
2511 rNewFrame.
SetLine( (nCellPosFlags & CellPosFlag::Bottom) ? pBoxItem->
GetBottom() : pBoxInfoItem->
GetHori(), SvxBoxItemLine::BOTTOM );
2514 if( pBoxInfoItem->
IsValid( SvxBoxInfoItemValidFlags::DISTANCE ) )
2523 const SvxBorderLine* pSourceLine = rNewFrame.
GetLine( nLine );
2526 SvxBorderLine aLine( *pSourceLine );
2527 aLine.SetColor( rColor );
2528 rNewFrame.
SetLine( &aLine, nLine );
2537 if (!(nCellPosFlags & (CellPosFlag::Lower|CellPosFlag::Before|CellPosFlag::After)))
2540 if (!(nCellPosFlags & (CellPosFlag::Upper|CellPosFlag::Before|CellPosFlag::After)))
2543 if (!(nCellPosFlags & (CellPosFlag::Upper|CellPosFlag::Lower|CellPosFlag::After)))
2546 if (!(nCellPosFlags & (CellPosFlag::Upper|CellPosFlag::Lower|CellPosFlag::Before)))
2553 if (nCellPosFlags & (CellPosFlag::Before|CellPosFlag::After|CellPosFlag::Upper|CellPosFlag::Lower))
2555 if (!(nCellPosFlags & (CellPosFlag::Before|CellPosFlag::After)))
2557 if (nCellPosFlags & CellPosFlag::Upper)
2562 else if (nCellPosFlags & CellPosFlag::Lower)
2568 else if (!(nCellPosFlags & (CellPosFlag::Upper|CellPosFlag::Lower)))
2570 if (nCellPosFlags & CellPosFlag::Before)
2575 else if (nCellPosFlags & CellPosFlag::After)
2601 const sal_Int32 nRowCount =
mxTable->getRowCount();
2602 const sal_Int32 nColCount =
mxTable->getColumnCount();
2603 if( !(nRowCount && nColCount) )
2615 if(SfxItemState::SET == rAttr.
GetItemState(SID_FRAME_LINECOLOR,
false) )
2616 pLineColorItem = &rAttr.
Get( SID_FRAME_LINECOLOR );
2618 const SvxBorderLine* pBorderLineItem =
nullptr;
2619 if(SfxItemState::SET == rAttr.
GetItemState(SID_FRAME_LINESTYLE,
false) )
2620 pBorderLineItem = rAttr.
Get( SID_FRAME_LINESTYLE ).GetLine();
2622 if( pBoxInfoItem && !pBoxItem )
2625 pBoxItem = &gaEmptyBoxItem;
2627 else if( pBoxItem && !pBoxInfoItem )
2630 pBoxInfoItem = &gaEmptyBoxInfoItem;
2636 const sal_Int32 nLastRow = std::min( aEnd.
mnRow + 2, nRowCount );
2637 const sal_Int32 nLastCol = std::min( aEnd.
mnCol + 2, nColCount );
2639 for( sal_Int32 nRow = std::max( aStart.
mnRow - 1, sal_Int32(0) ); nRow < nLastRow; nRow++ )
2647 for( sal_Int32 nCol = std::max( aStart.
mnCol - 1, sal_Int32(0) ); nCol < nLastCol; nCol++ )
2649 CellRef xCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nCol, nRow ).get() ) );
2653 const SfxItemSet& rSet = xCell->GetItemSet();
2664 if( pBoxItem && pBoxInfoItem )
2667 if( pLineColorItem )
2670 if( pBorderLineItem )
2673 if (aNewFrame != *pOldOuter)
2676 aAttr.
Put(aNewFrame);
2677 xCell->SetMergedItemSetAndBroadcast( aAttr,
false );
2703 const bool bUndo(rModel.IsUndoEnabled());
2722 for( sal_Int32 nRow = aStart.
mnRow; nRow <= aEnd.
mnRow; nRow++ )
2724 for( sal_Int32 nCol = aStart.
mnCol; nCol <= aEnd.
mnCol; nCol++ )
2726 CellRef xCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nCol, nRow ).get() ) );
2731 xCell->SetMergedItemSetAndBroadcast(aAttr, bReplaceAll);
2769 if(pTextEditOutlinerView)
2800 if(
nullptr == pCurrentSdrTableObj)
2817 if(aStart != aFullStart || aEnd != aFullEnd)
2834 if( pPastePage && pPastePage->
GetObjCount() == 1 )
2837 if( pPasteTableObj )
2850 if( !pPasteTableObj )
2853 Reference< XTable > xPasteTable( pPasteTableObj->
getTable() );
2854 if( !xPasteTable.is() )
2860 sal_Int32 nPasteColumns = xPasteTable->getColumnCount();
2861 sal_Int32 nPasteRows = xPasteTable->getRowCount();
2869 sal_Int32 nColumns =
mxTable->getColumnCount();
2870 sal_Int32 nRows =
mxTable->getRowCount();
2872 const sal_Int32 nMissing = nPasteRows - ( nRows - aStart.
mnRow );
2875 Reference< XTableRows > xRows(
mxTable->getRows() );
2876 xRows->insertByIndex( nRows, nMissing );
2877 nRows =
mxTable->getRowCount();
2880 nPasteRows = std::min( nPasteRows, nRows - aStart.
mnRow );
2881 nPasteColumns = std::min( nPasteColumns, nColumns - aStart.
mnCol );
2884 for( sal_Int32 nRow = 0; nRow < nPasteRows; ++nRow )
2886 for( sal_Int32 nCol = 0, nTargetCol = aStart.
mnCol; nCol < nPasteColumns; ++nCol )
2888 CellRef xTargetCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nTargetCol, aStart.
mnRow + nRow ).get() ) );
2889 if( xTargetCell.is() && !xTargetCell->isMerged() )
2891 CellRef xSourceCell(dynamic_cast<Cell*>(xPasteTable->getCellByPosition(nCol, nRow).get()));
2892 if (xSourceCell.is())
2894 xTargetCell->AddUndo();
2896 if (nColumns < nTargetCol + xSourceCell->getColumnSpan())
2897 xTargetCell->replaceContentAndFormatting(xSourceCell);
2899 xTargetCell->cloneFrom(xSourceCell);
2901 nCol += xSourceCell->getColumnSpan() - 1;
2902 nTargetCol += xTargetCell->getColumnSpan();
2925 const bool bUndo(rModel.IsUndoEnabled());
2934 for( sal_Int32 nRow = aStart.
mnRow; nRow <= aEnd.
mnRow; nRow++ )
2936 for( sal_Int32 nCol = aStart.
mnCol; nCol <= aEnd.
mnCol; nCol++ )
2938 CellRef xCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nCol, nRow ).get() ) );
2965 mnUpdateEvent =
nullptr;
2967 if( mbCellSelectionMode )
2969 CellPos aStart( maCursorFirstPos );
2970 CellPos aEnd( maCursorLastPos );
2973 if( aStart != maCursorFirstPos || aEnd != maCursorLastPos )
2975 setSelectedCells( aStart, aEnd );
2979 updateSelectionOverlay();
2980 mbHasJustMerged =
false;
3012 class BoxItemWrapper
3017 const SvxBorderLine* getLine()
const;
3018 void setLine(
const SvxBorderLine* pLine);
3028 BoxItemWrapper::BoxItemWrapper(
3039 const SvxBorderLine* BoxItemWrapper::getLine()
const
3047 void BoxItemWrapper::setLine(
const SvxBorderLine* pLine)
3055 void lcl_MergeBorderLine(
3056 LinesState& rLinesState,
const SvxBorderLine*
const pLine,
const SvxBoxItemLine nLine,
3059 const SvxBoxInfoItemLine nInnerLine(bBorder ? SvxBoxInfoItemLine::HORI : ((nValidFlag & SvxBoxInfoItemValidFlags::HORI) ? SvxBoxInfoItemLine::HORI : SvxBoxInfoItemLine::VERT));
3060 BoxItemWrapper aBoxItem(rLinesState.rBoxItem, rLinesState.rBoxInfoItem, nLine, nInnerLine, bBorder);
3061 bool& rbSet(bBorder ? rLinesState.aBorderSet[nLine] : rLinesState.aInnerLineSet[nInnerLine]);
3065 bool& rbIndeterminate(bBorder ? rLinesState.aBorderIndeterminate[nLine] : rLinesState.aInnerLineIndeterminate[nInnerLine]);
3066 if (!rbIndeterminate)
3068 const SvxBorderLine*
const pMergedLine(aBoxItem.getLine());
3069 if ((pLine && !pMergedLine) || (!pLine && pMergedLine) || (pLine && (*pLine != *pMergedLine)))
3071 aBoxItem.setLine(
nullptr);
3072 rbIndeterminate =
true;
3078 aBoxItem.setLine(pLine);
3083 void lcl_MergeBorderOrInnerLine(
3084 LinesState& rLinesState,
const SvxBorderLine*
const pLine,
const SvxBoxItemLine nLine,
3088 lcl_MergeBorderLine(rLinesState, pLine, nLine, nValidFlag);
3091 const bool bVertical = (nLine == SvxBoxItemLine::LEFT) || (nLine == SvxBoxItemLine::RIGHT);
3092 lcl_MergeBorderLine(rLinesState, pLine, nLine, bVertical ? SvxBoxInfoItemValidFlags::VERT : SvxBoxInfoItemValidFlags::HORI,
false);
3096 void lcl_MergeDistance(
3097 LinesState& rLinesState,
const SvxBoxItemLine nIndex,
const sal_uInt16 nDistance)
3099 if (rLinesState.aDistanceSet[nIndex])
3101 if (!rLinesState.bDistanceIndeterminate)
3102 rLinesState.bDistanceIndeterminate = nDistance != rLinesState.aDistance[nIndex];
3106 rLinesState.aDistance[nIndex] = nDistance;
3107 rLinesState.aDistanceSet[nIndex] =
true;
3111 void lcl_MergeCommonBorderAttr(LinesState& rLinesState,
const SvxBoxItem& rCellBoxItem,
const CellPosFlag nCellPosFlags)
3113 if (nCellPosFlags & (CellPosFlag::Before|CellPosFlag::After|CellPosFlag::Upper|CellPosFlag::Lower))
3117 if (!(nCellPosFlags & (CellPosFlag::Before|CellPosFlag::After)))
3119 if (nCellPosFlags & CellPosFlag::Upper)
3120 lcl_MergeBorderLine(rLinesState, rCellBoxItem.
GetBottom(), SvxBoxItemLine::TOP, SvxBoxInfoItemValidFlags::TOP);
3121 else if (nCellPosFlags & CellPosFlag::Lower)
3122 lcl_MergeBorderLine(rLinesState, rCellBoxItem.
GetTop(), SvxBoxItemLine::BOTTOM, SvxBoxInfoItemValidFlags::BOTTOM);
3124 else if (!(nCellPosFlags & (CellPosFlag::Upper|CellPosFlag::Lower)))
3126 if (nCellPosFlags & CellPosFlag::Before)
3127 lcl_MergeBorderLine(rLinesState, rCellBoxItem.
GetRight(), SvxBoxItemLine::LEFT, SvxBoxInfoItemValidFlags::LEFT);
3128 else if (nCellPosFlags & CellPosFlag::After)
3129 lcl_MergeBorderLine(rLinesState, rCellBoxItem.
GetLeft(), SvxBoxItemLine::RIGHT, SvxBoxInfoItemValidFlags::RIGHT);
3139 lcl_MergeBorderOrInnerLine(rLinesState, rCellBoxItem.
GetTop(), SvxBoxItemLine::TOP, SvxBoxInfoItemValidFlags::TOP,
static_cast<bool>(nCellPosFlags & CellPosFlag::Top));
3140 lcl_MergeBorderOrInnerLine(rLinesState, rCellBoxItem.
GetBottom(), SvxBoxItemLine::BOTTOM, SvxBoxInfoItemValidFlags::BOTTOM,
static_cast<bool>(nCellPosFlags & CellPosFlag::Bottom));
3141 lcl_MergeBorderOrInnerLine(rLinesState, rCellBoxItem.
GetLeft(), SvxBoxItemLine::LEFT, SvxBoxInfoItemValidFlags::LEFT,
static_cast<bool>(nCellPosFlags & CellPosFlag::Left));
3142 lcl_MergeBorderOrInnerLine(rLinesState, rCellBoxItem.
GetRight(), SvxBoxItemLine::RIGHT, SvxBoxInfoItemValidFlags::RIGHT,
static_cast<bool>(nCellPosFlags & CellPosFlag::Right));
3144 lcl_MergeDistance(rLinesState, SvxBoxItemLine::TOP, rCellBoxItem.
GetDistance(SvxBoxItemLine::TOP));
3145 lcl_MergeDistance(rLinesState, SvxBoxItemLine::BOTTOM, rCellBoxItem.
GetDistance(SvxBoxItemLine::BOTTOM));
3146 lcl_MergeDistance(rLinesState, SvxBoxItemLine::LEFT, rCellBoxItem.
GetDistance(SvxBoxItemLine::LEFT));
3147 lcl_MergeDistance(rLinesState, SvxBoxItemLine::RIGHT, rCellBoxItem.
GetDistance(SvxBoxItemLine::RIGHT));
3158 const sal_Int32 nRowCount =
mxTable->getRowCount();
3159 const sal_Int32 nColCount =
mxTable->getColumnCount();
3160 if( !(nRowCount && nColCount) )
3168 const sal_Int32 nLastRow = std::min( aEnd.
mnRow + 2, nRowCount );
3169 const sal_Int32 nLastCol = std::min( aEnd.
mnCol + 2, nColCount );
3171 rBoxInfoItem.
SetValid( SvxBoxInfoItemValidFlags::ALL,
false );
3172 LinesState aLinesState( rBoxItem, rBoxInfoItem );
3183 for( sal_Int32 nRow = std::max( aStart.
mnRow - 1, sal_Int32(0) ); nRow < nLastRow; nRow++ )
3191 for( sal_Int32 nCol = std::max( aStart.
mnCol - 1, sal_Int32(0) ); nCol < nLastCol; nCol++ )
3193 CellRef xCell( dynamic_cast< Cell* >(
mxTable->getCellByPosition( nCol, nRow ).get() ) );
3203 const SfxItemSet& rSet = xCell->GetItemSet();
3204 SvxBoxItem aCellBoxItem(mergeDrawinglayerTextDistancesAndSvxBoxItem(rSet));
3205 lcl_MergeCommonBorderAttr( aLinesState, aCellBoxItem, nCellPosFlags );
3209 if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::TOP])
3210 aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::TOP);
3211 if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::BOTTOM])
3212 aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::BOTTOM);
3213 if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::LEFT])
3214 aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::LEFT);
3215 if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::RIGHT])
3216 aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::RIGHT);
3217 if (!aLinesState.aInnerLineIndeterminate[SvxBoxInfoItemLine::HORI])
3218 aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::HORI);
3219 if (!aLinesState.aInnerLineIndeterminate[SvxBoxInfoItemLine::VERT])
3220 aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::VERT);
3222 if (!aLinesState.bDistanceIndeterminate)
3224 if (aLinesState.aDistanceSet[SvxBoxItemLine::TOP])
3225 aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::TOP], SvxBoxItemLine::TOP);
3226 if (aLinesState.aDistanceSet[SvxBoxItemLine::BOTTOM])
3227 aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::BOTTOM], SvxBoxItemLine::BOTTOM);
3228 if (aLinesState.aDistanceSet[SvxBoxItemLine::LEFT])
3229 aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::LEFT], SvxBoxItemLine::LEFT);
3230 if (aLinesState.aDistanceSet[SvxBoxItemLine::RIGHT])
3231 aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::RIGHT], SvxBoxItemLine::RIGHT);
3232 aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::DISTANCE);
3240 CellPos aStart( 0, row ), aEnd(
mxTable->getColumnCount() - 1, row );
3250 CellPos aStart( column, 0 ), aEnd( column,
mxTable->getRowCount() - 1 );
3260 CellPos aStart( 0, row ), aEnd(
mxTable->getColumnCount() - 1, row );
3262 gotoCell( aStart,
false,
nullptr );
3270 CellPos aStart( column, 0 ), aEnd( column,
mxTable->getRowCount() - 1 );
3272 gotoCell( aStart,
false,
nullptr );
3282 if( (aFirstPos.
mnCol == 0) && (nRow >= aFirstPos.
mnRow && nRow <= aLastPos.
mnRow) && (
mxTable->getColumnCount() - 1 == aLastPos.
mnCol) )
3294 if( (aFirstPos.
mnRow == 0) && (nColumn >= aFirstPos.
mnCol && nColumn <= aLastPos.
mnCol) && (
mxTable->getRowCount() - 1 == aLastPos.
mnRow) )
#define LINK(Instance, Class, Member)
SdrMetricItem makeSdrTextUpperDistItem(tools::Long mnHeight)
IMPL_LINK_NOARG(SvxTableController, UpdateHdl, void *, void)
void expand(const B2DTuple &rTuple)
CellPos getRightCell(const CellPos &rPos, bool bEdgeTravel) const
virtual OutlinerParaObject * GetOutlinerParaObject() const override
virtual SVX_DLLPRIVATE ~SvxTableController() override
constexpr sal_uInt16 SDRATTR_SHADOW_FIRST(XATTR_END+1)
size_t GetMarkCount() const
o3tl::enumarray< SvxBoxInfoItemLine, bool > aInnerLineSet
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SVX_DLLPRIVATE void destroySelectionOverlay()
css::uno::Reference< css::table::XTable > getTable() const
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
void setTableStyle(const css::uno::Reference< css::container::XIndexAccess > &xAutoFormatStyle)
constexpr auto toTwips(N number, Length from)
CellPos getUpCell(const CellPos &rPos, bool bEdgeTravel) const
rtl::Reference< sdr::overlay::OverlayManager > const & GetOverlayManager() const
void SetSkipChangeLayout(bool bOn)
virtual const SfxItemSet * GetOutputItemSet() const =0
SVX_DLLPRIVATE void RemoveSelection()
static void ImplApplyLineColorItem(CellPosFlag nCellPosFlags, const SvxColorItem *pLineColorItem, SvxBoxItem &rNewFrame)
SVX_DLLPRIVATE void findMergeOrigin(CellPos &rPos)
SVX_DLLPRIVATE void onDelete(sal_uInt16 nSId)
SdrTextObj * GetTextEditObject() const
static SvxAbstractDialogFactory * Create()
SVX_DLLPRIVATE bool HasMarked() const
bool deselectRow(sal_Int32 row)
const StyleSettings & GetStyleSettings() const
void MergeValue(const SfxPoolItem &rItem, bool bOverwriteDefaults=false)
const editeng::SvxBorderLine * GetVert() const
css::uno::Reference< css::util::XModifyListener > mxModifyListener
#define EE_INDEX_NOT_FOUND
rtl::Reference< sdr::SelectionController > CreateTableController(SdrView &rView, const SdrTableObj &rObj, const rtl::Reference< sdr::SelectionController > &xRefController)
SvxTableController * mpController
const WhichRangesContainer & GetRanges() const
SvxBoxInfoItem & rBoxInfoItem
SdrObject * GetObj(size_t nNum) const
size_t GetObjCount() const
sal_uInt16 GetValue() const
void InvalidateItem(sal_uInt16 nWhich)
sal_uInt16 GetDistance(SvxBoxItemLine nLine) const
void CropTableModelToSelection(const CellPos &rStart, const CellPos &rEnd)
virtual VclPtr< SfxAbstractTabDialog > CreateSvxFormatCellsDialog(weld::Window *pParent, const SfxItemSet *pAttr, const SdrModel &rModel)=0
SVX_DLLPRIVATE void StartSelection(const CellPos &rPos)
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
const MapMode & GetMapMode() const
sal_uInt16 GetCode() const
void SetAttrToSelectedShape(const SfxItemSet &rAttr)
Changing the geometry of an object.
SdrMark * GetMark(size_t nNum) const
sal_Int32 GetParagraphCount() const
void ChangeFontSize(bool bGrow, const FontList *pList)
virtual SVX_DLLPRIVATE bool hasSelectedCells() const override
This is a table object, and one or more of its cells are selected.
static void ImplApplyBorderLineItem(CellPosFlag nCellPosFlags, const SvxBorderLine *pBorderLineItem, SvxBoxItem &rNewFrame)
bool bDistanceIndeterminate
virtual SfxItemSet & GetItemSet()
SdrMetricItem makeSdrTextRightDistItem(tools::Long mnHeight)
SdrHitKind PickAnything(const MouseEvent &rMEvt, SdrMouseEventKind nMouseDownOrMoveOrUp, SdrViewEvent &rVEvt) const
SdrMetricItem makeSdrTextLowerDistItem(tools::Long mnHeight)
const SfxItemSet * GetArgs() const
virtual SVX_DLLPRIVATE bool GetStyleSheet(SfxStyleSheet *&rpStyleSheet) const override
const editeng::SvxBorderLine * GetRight() const
SfxStyleFamily GetFamily() const
o3tl::enumarray< SvxBoxInfoItemLine, bool > aInnerLineIndeterminate
SVX_DLLPRIVATE void changeTableEdge(const SfxRequest &rReq)
CellPos getLeftCell(const CellPos &rPos, bool bEdgeTravel) const
static void ImplSetLineColor(SvxBoxItem &rNewFrame, SvxBoxItemLine nLine, const Color &rColor)
virtual void MarkListHasChanged() override
bool deselectColumn(sal_Int32 column)
constexpr sal_uInt16 SDRATTR_START(XATTR_START)
const Color & GetHighlightColor() const
SVX_DLLPRIVATE void DistributeColumns(const bool bOptimize, const bool bMinimize)
ImplSVEvent * mnUpdateEvent
virtual bool IsHorizontal() const =0
constexpr auto convertTwipToMm100(N n)
tools::WeakReference< SdrTableObj > mxTableObj
#define EE_PARA_NOT_FOUND
::std::vector< basegfx::B2DRange > RangeVector
sal_uInt16 GetClicks() const
SVX_DLLPRIVATE bool PasteObject(SdrTableObj const *pPasteTableObj)
void SetAttrToMarked(const SfxItemSet &rAttr, bool bReplaceAll)
sdr::table::SdrTableObj * GetTableObj()
SVX_DLLPRIVATE void setSelectionStart(const CellPos &rPos)
ESelection aNewSelection(GetSelection())
SdrPage * getSdrPageFromSdrObject() const
virtual SVX_DLLPRIVATE bool onMouseMove(const MouseEvent &rMEvt, vcl::Window *pWin) override
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
static void ImplSetLinePreserveColor(SvxBoxItem &rNewFrame, const SvxBorderLine *pNew, SvxBoxItemLine nLine)
OUString SvxResId(TranslateId aId)
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.
o3tl::enumarray< SvxBoxItemLine, bool > aBorderIndeterminate
static SfxViewShell * Current()
SVX_DLLPRIVATE void UpdateSelection(const CellPos &rPos)
void DistributeColumns(sal_Int32 nFirstColumn, sal_Int32 nLastColumn, const bool bOptimize, const bool bMinimize)
void SetEditMode(SdrViewEditMode eMode)
const sdr::table::TableStyleSettings & getTableStyleSettings() const
virtual SVX_DLLPRIVATE void onSelectAll() override
const editeng::SvxBorderLine * GetLine(SvxBoxItemLine nLine) const
CellPos getPreviousCell(const CellPos &rPos, bool bEdgeTravel) const
OutputDevice * GetFirstOutputDevice() const
void DistributeRows(sal_Int32 nFirstRow, sal_Int32 nLastRow, const bool bOptimize, const bool bMinimize)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_TEXT_LOWERDIST(SDRATTR_MISC_FIRST+7)
void getActiveCellPos(sdr::table::CellPos &rPos) const
bool selectColumn(sal_Int32 column)
sal_uInt32 PaintWindowCount() const
o3tl::enumarray< SvxBoxItemLine, bool > aDistanceSet
constexpr TypedWhichId< SvxBoxInfoItem > SDRATTR_TABLE_BORDER_INNER(SDRATTR_TABLE_FIRST+1)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
SdrObject * GetMarkedSdrObj() const
const editeng::SvxBorderLine * GetHori() const
const editeng::SvxBorderLine * GetTop() const
SVX_DLLPRIVATE TblAction getKeyboardAction(const KeyEvent &rKEvt)
const SvxBoxItemLine m_nBorderLine
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
const SdrOutliner * GetTextEditOutliner() const
#define TOOLS_WARN_EXCEPTION(area, stream)
const editeng::SvxBorderLine * GetLeft() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
SVX_DLLPRIVATE void DistributeRows(const bool bOptimize, const bool bMinimize)
bool IsUndoEnabled() const
returns true if undo is currently enabled This returns false if undo was disabled using EnableUndo( f...
TableHitKind
SdrTableHitKind.
SVX_DLLPRIVATE void gotoCell(const CellPos &rCell, bool bSelect, vcl::Window *pWindow, TblAction nAction=TblAction::NONE)
SVX_DLLPRIVATE void onFormatTable(const SfxRequest &rReq)
virtual SVX_DLLPRIVATE bool PasteObjModel(const SdrModel &rModel) override
rtl::Reference< TableModel > mxTable
bool isRowSelected(sal_Int32 nRow)
void setSelectedCells(const CellPos &rFirstPos, const CellPos &rLastPos)
void BroadcastObjectChange() const
constexpr TypedWhichId< SdrTextVertAdjustItem > SDRATTR_TEXT_VERTADJUST(SDRATTR_MISC_FIRST+8)
const OUString & GetValue() const
const SdrMarkList & GetMarkedObjectList() const
CellPos getLastCell() const
const T * GetArg(sal_uInt16 nSlotId) const
constexpr TypedWhichId< SdrMetricItem > SDRATTR_TEXT_LEFTDIST(SDRATTR_MISC_FIRST+4)
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxInfoItemLine nLine)
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)
std::optional< sdr::overlay::OverlayObjectList > mpSelectionOverlay
const SdrPage * GetPage(sal_uInt16 nPgNum) const
void ActionChanged() const
virtual SVX_DLLPRIVATE bool DeleteMarked() override
SdrHdl * PickHandle(const Point &rPnt) const
const SvxBoxInfoItemLine m_nInnerLine
SdrModel & getSdrModelFromSdrObject() const
void SetCurrentObj(SdrObjKind nIdent, SdrInventor nInvent=SdrInventor::Default)
SVX_DLLPRIVATE void SplitMarkedCells(const SfxRequest &rReq)
virtual bool ChangeFontSize(bool bGrow, const FontList *pFontList) override
Changes the font (grow/shrink) according to the input parameters.
SVX_DLLPRIVATE void SetAttrToSelectedCells(const SfxItemSet &rAttr, bool bReplaceAll)
const OutlinerView * GetTextEditOutlinerView() const
SVX_DLLPRIVATE void SetTableStyle(const SfxItemSet *pArgs)
SVX_DLLPRIVATE const CellPos & getSelectionEnd()
OUString GetText(Paragraph const *pPara, sal_Int32 nParaCount=1) const
const AllSettings & GetSettings() const
MapUnit GetMapUnit() const
void SetDistance(sal_uInt16 nNew, SvxBoxItemLine nLine)
Point PixelToLogic(const Point &rDevicePt) const
bool setPropertyValue(uno::Sequence< beans::PropertyValue > &aProp, const OUString &aName, const uno::Any &aValue)
SvxBoxInfoItem & m_rBoxInfoItem
virtual void Execute(SfxRequest &rReq) override
SVX_DLLPRIVATE void onInsert(sal_uInt16 nSId, const SfxItemSet *pArgs=nullptr)
bool StartExecuteAsync(const std::function< void(sal_Int32)> &rEndDialogFn)
SfxItemPool * GetPool() const
TableHitKind CheckTableHit(const Point &rPos, sal_Int32 &rnX, sal_Int32 &rnY, const sal_uInt16 aTol=0) const
SdrUndoFactory & GetSdrUndoFactory() const
returns the models undo factory.
SVX_DLLPRIVATE void EditCell(const CellPos &rPos, vcl::Window *pWindow, TblAction nAction)
virtual SVX_DLLPRIVATE bool onKeyInput(const KeyEvent &rKEvt, vcl::Window *pWin) override
CellPos getDownCell(const CellPos &rPos, bool bEdgeTravel) const
SVX_DLLPRIVATE void StopTextEdit()
virtual SdrTableObj * CloneSdrObject(SdrModel &rTargetModel) const override
SdrMetricItem makeSdrTextLeftDistItem(tools::Long mnHeight)
css::text::WritingMode GetWritingMode() const
Paragraph * GetParagraph(sal_Int32 nAbsPos) const
void setTableStyleSettings(const sdr::table::TableStyleSettings &rStyle)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_TEXT_UPPERDIST(SDRATTR_MISC_FIRST+6)
SVX_DLLPRIVATE void MergeMarkedCells()
virtual std::unique_ptr< SdrUndoAction > CreateUndoGeoObject(SdrObject &rObject)
bool IsValid(SvxBoxInfoItemValidFlags nValid) const
SVX_DLLPRIVATE void MergeAttrFromSelectedCells(SfxItemSet &rAttr, bool bOnlyHardAttr) const
ESelection GetSelection() const
weld::Window * GetFrameWeld() const
SVX_DLLPRIVATE void checkCell(CellPos &rPos) const
virtual SVX_DLLPRIVATE bool setCursorLogicPosition(const Point &rPosition, bool bPoint) override
bool selectRow(sal_Int32 row)
static SVX_DLLPRIVATE rtl::Reference< sdr::SelectionController > create(SdrView &rView, const SdrTableObj &rObj, const rtl::Reference< sdr::SelectionController > &xRefController)
constexpr TypedWhichId< SvxBoxItem > SDRATTR_TABLE_BORDER(SDRATTR_TABLE_FIRST+0)
static CellPos getFirstCell()
virtual tools::Long GetCount() const =0
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
constexpr sal_uInt16 SDRATTR_SHADOW_LAST(SDRATTR_SHADOWBLUR)
const vcl::KeyCode & GetKeyCode() const
sal_uInt16 GetSlot() const
constexpr sal_uInt16 SDRATTR_TABLE_LAST(SDRATTR_TABLE_TEXT_ROTATION)
void SetSelection(const ESelection &)
bool IsTextEditActive() const
o3tl::enumarray< SvxBoxItemLine, bool > aBorderSet
virtual bool IsTextEdit() const final override
void DisableItem(sal_uInt16 nWhich)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_TEXT_RIGHTDIST(SDRATTR_MISC_FIRST+5)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SVX_DLLPRIVATE void SetVertical(sal_uInt16 nSId)
#define SAL_WARN_IF(condition, area, stream)
virtual bool IsVerticalWriting() const override
const SfxItemSet & GetMergedItemSet() const
CellPos getNextCell(const CellPos &rPos, bool bEdgeTravel) const
std::unique_ptr< SdrOutliner > SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel &rModel)
Create an Outliner with the engine-global default settings on the heap.
bool PostKeyEvent(const KeyEvent &rKEvt, vcl::Window const *pFrameWin=nullptr)
void AdjustMarkHdl(SfxViewShell *pOtherShell=nullptr)
SVX_DLLPRIVATE void ApplyBorderAttr(const SfxItemSet &rAttr)
virtual SVX_DLLPRIVATE SdrObject * GetMarkedSdrObjClone(SdrModel &rTargetModel) override
const Point & GetPosPixel() const
void setActiveCell(const sdr::table::CellPos &rPos)
SVX_DLLPRIVATE void SetTableStyleSettings(const SfxItemSet *pArgs)
SdrPageView * GetSdrPageView() const
virtual SVX_DLLPRIVATE void onSelectionHasChanged() override
void SetValid(SvxBoxInfoItemValidFlags nValid, bool bValid=true)
void getSelectedCells(CellPos &rFirstPos, CellPos &rLastPos) override
bool isColumnSelected(sal_Int32 nColumn)
SVX_DLLPRIVATE bool executeAction(TblAction nAction, bool bSelect, vcl::Window *pWindow)
constexpr::Color COL_BLUE(0x00, 0x00, 0x80)
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
SVX_DLLPRIVATE void FillCommonBorderAttrFromSelectedCells(SvxBoxItem &rBox, SvxBoxInfoItem &rBoxInfo) const
Fill the values that are common for all selected cells.
o3tl::enumarray< SvxBoxItemLine, sal_uInt16 > aDistance
static void ImplApplyBoxItem(CellPosFlag nCellPosFlags, const SvxBoxItem *pBoxItem, const SvxBoxInfoItem *pBoxInfoItem, SvxBoxItem &rNewFrame)
SVX_DLLPRIVATE void UpdateTableShape()
SVX_DLLPRIVATE void onTableModified()
SVX_DLLPRIVATE void updateSelectionOverlay()
SVX_DLLPRIVATE void onSelect(sal_uInt16 nSId)
virtual SVX_DLLPRIVATE bool GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr) const override
virtual SVX_DLLPRIVATE bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll) override
virtual SVX_DLLPRIVATE bool SetStyleSheet(SfxStyleSheet *pStyleSheet, bool bDontRemoveHardAttr) override
const editeng::SvxBorderLine * GetBottom() const
virtual VclPtr< SvxAbstractSplitTableDialog > CreateSvxSplitTableDialog(weld::Window *pParent, bool bIsTableVertical, tools::Long nMaxVertical)=0
SdrPaintWindow * GetPaintWindow(sal_uInt32 nIndex) const
SVX_DLLPRIVATE void MergeRange(sal_Int32 nFirstCol, sal_Int32 nFirstRow, sal_Int32 nLastCol, sal_Int32 nLastRow)
virtual SVX_DLLPRIVATE bool onMouseButtonDown(const MouseEvent &rMEvt, vcl::Window *pWin) override
virtual SVX_DLLPRIVATE bool onMouseButtonUp(const MouseEvent &rMEvt, vcl::Window *pWin) override
SVX_DLLPRIVATE bool checkTableObject()
virtual SVX_DLLPRIVATE bool ApplyFormatPaintBrush(SfxItemSet &rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats) override
applies a format paint brush set from the current selection.
SVX_DLLPRIVATE SvxTableController(SdrView &rView, const SdrTableObj &rObj)
SVX_DLLPRIVATE const CellPos & getSelectionStart()
sal_uInt16 GetPageCount() const
const Color & GetValue() const
virtual SVX_DLLPRIVATE void GetState(SfxItemSet &rSet) override
void getCellBounds(const sdr::table::CellPos &rPos,::tools::Rectangle &rCellRect)
bool m_bDetectedRangeSegmentation false
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)