diff options
-rw-r--r-- | sw/inc/doc.hxx | 3 | ||||
-rw-r--r-- | sw/inc/fesh.hxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/data2/tdf126784_distributeSelectedColumns.odt | bin | 0 -> 21302 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 29 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl1.cxx | 32 | ||||
-rw-r--r-- | sw/source/core/frmedt/fetab.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/shells/tabsh.cxx | 3 |
7 files changed, 50 insertions, 23 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index b5a5d3bb1139..af2e97aa9985 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1498,8 +1498,7 @@ public: /// Adjusts selected cell widths in such a way, that their content does not need to be wrapped (if possible). /// bBalance evenly re-distributes the available space regardless of content or wrapping. /// bNoShrink keeps table size the same by distributing excess space proportionately. - /// bColumnWidth tests the entire column for content width, not just selected cells. - void AdjustCellWidth( const SwCursor& rCursor, const bool bBalance, const bool bNoShrink, const bool bColumnWidth ); + void AdjustCellWidth( const SwCursor& rCursor, const bool bBalance, const bool bNoShrink ); SwChainRet Chainable( const SwFrameFormat &rSource, const SwFrameFormat &rDest ); SwChainRet Chain( SwFrameFormat &rSource, const SwFrameFormat &rDest ); diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx index 25bf062c1e82..6f6a5e860802 100644 --- a/sw/inc/fesh.hxx +++ b/sw/inc/fesh.hxx @@ -710,7 +710,7 @@ public: bool IsInRepeatedHeadline() const { return CheckHeadline( true ); } bool IsInHeadline() const { return CheckHeadline( false ); } - void AdjustCellWidth( bool bBalance, const bool bNoShrink, const bool bColumnWidth ); + void AdjustCellWidth( const bool bBalance, const bool bNoShrink ); /// Not allowed if only empty cells are selected. bool IsAdjustCellWidthAllowed( bool bBalance = false ) const; diff --git a/sw/qa/extras/uiwriter/data2/tdf126784_distributeSelectedColumns.odt b/sw/qa/extras/uiwriter/data2/tdf126784_distributeSelectedColumns.odt Binary files differnew file mode 100644 index 000000000000..90c23c56a32d --- /dev/null +++ b/sw/qa/extras/uiwriter/data2/tdf126784_distributeSelectedColumns.odt diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 0d35c0cec77f..eb85d96d25fe 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -16,6 +16,7 @@ #include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/frame/DispatchHelper.hpp> #include <com/sun/star/style/LineSpacing.hpp> +#include <com/sun/star/text/TableColumnSeparator.hpp> #include <comphelper/propertysequence.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <i18nlangtag/languagetag.hxx> @@ -627,6 +628,34 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf64242_optimizeTable) CPPUNIT_ASSERT_EQUAL_MESSAGE("Row set to auto-height", double(0), minimalRowHeight); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf126784_distributeSelectedColumns) +{ + SwDoc* pDoc = createDoc("tdf126784_distributeSelectedColumns.odt"); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + + uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), + uno::UNO_QUERY); + uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY); + uno::Reference<table::XTableRows> xTableRows = xTextTable->getRows(); + + auto aSeq = getProperty<uno::Sequence<text::TableColumnSeparator>>(xTableRows->getByIndex(0), + "TableColumnSeparators"); + sal_Int16 nOrigCol2Pos = aSeq[0].Position; + sal_Int16 nOrigCol3Pos = aSeq[1].Position; + + //Select column 1 and 2 + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false); + + lcl_dispatchCommand(mxComponent, ".uno:DistributeColumns", {}); + + aSeq = getProperty<uno::Sequence<text::TableColumnSeparator>>(xTableRows->getByIndex(0), + "TableColumnSeparators"); + CPPUNIT_ASSERT_MESSAGE("Second column should shrink", nOrigCol2Pos < aSeq[0].Position); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Last column shouldn't change", nOrigCol3Pos, aSeq[1].Position); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf108687_tabstop) { SwDoc* pDoc = createDoc("tdf108687_tabstop.odt"); diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index 564fd5d25972..e330c56466ee 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -1370,24 +1370,25 @@ static void lcl_CalcSubColValues( std::vector<sal_uInt16> &rToFill, const SwTabC * We do not iterate over the TabCols' entries, but over the gaps that describe Cells. * We set TabCol entries for which we did not calculate Cells to 0. * - * @param bWishValues == true: Calculate the desired width of the content - * The highest desired value is returned. - * @param bWishValues == false: Calculate the minimum width of the content - * @param bColumnWidth == false: We calculate the desired value of all affected - * Cells for the current Selection only. - * @param bColumnWidth == true: The Selection is expanded vertically. - * We calculate the wish/minimum value for - * each cell in every Column that intersects - * with the Selection. + * @param bWishValues == true: We calculate the desired value of all affected + * Cells for the current Selection/current Cell. + * If more Cells are within a Column, the highest + * desired value is returned. + * We set TabCol entries for which we did not calculate + * Cells to 0. + * + * @param bWishValues == false: The Selection is expanded vertically. + * We calculate the minimum value for every + * Column in the TabCols that intersects with the + * Selection. */ static void lcl_CalcColValues( std::vector<sal_uInt16> &rToFill, const SwTabCols &rCols, const SwLayoutFrame *pStart, const SwLayoutFrame *pEnd, - bool bWishValues, - bool bColumnWidth ) + bool bWishValues ) { SwSelUnions aUnions; ::MakeSelUnions( aUnions, pStart, pEnd, - bColumnWidth ? SwTableSearchType::Col : SwTableSearchType::NONE ); + bWishValues ? SwTableSearchType::NONE : SwTableSearchType::Col ); for ( auto &rU : aUnions ) { @@ -1468,8 +1469,7 @@ static void lcl_CalcColValues( std::vector<sal_uInt16> &rToFill, const SwTabCols void SwDoc::AdjustCellWidth( const SwCursor& rCursor, const bool bBalance, - const bool bNoShrink, - const bool bColumnWidth ) + const bool bNoShrink ) { // Check whether the current Cursor has it's Point/Mark in a Table SwContentNode* pCntNd = rCursor.GetPoint()->nNode.GetNode().GetContentNode(); @@ -1497,7 +1497,7 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor, std::vector<sal_uInt16> aWish(aTabCols.Count() + 1); std::vector<sal_uInt16> aMins(aTabCols.Count() + 1); - ::lcl_CalcColValues( aWish, aTabCols, pStart, pEnd, true, bColumnWidth ); + ::lcl_CalcColValues( aWish, aTabCols, pStart, pEnd, /*bWishValues=*/true ); // It's more robust if we calculate the minimum values for the whole Table const SwTabFrame *pTab = pStart->ImplFindTabFrame(); @@ -1505,7 +1505,7 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor, pEnd = const_cast<SwLayoutFrame*>(pTab->FindLastContentOrTable()->GetUpper()); while( !pEnd->IsCellFrame() ) pEnd = pEnd->GetUpper(); - ::lcl_CalcColValues( aMins, aTabCols, pStart, pEnd, false, /*bColumnWidth=*/true ); + ::lcl_CalcColValues( aMins, aTabCols, pStart, pEnd, /*bWishValues=*/false ); sal_uInt16 nSelectedWidth = 0, nCols = 0; float fTotalWish = 0; diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index a60eff107e9a..f4f7cac1accf 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -1112,7 +1112,7 @@ bool SwFEShell::CheckHeadline( bool bRepeat ) const return bRet; } -void SwFEShell::AdjustCellWidth( bool bBalance, const bool bNoShrink, const bool bColumnWidth ) +void SwFEShell::AdjustCellWidth( const bool bBalance, const bool bNoShrink ) { SET_CURR_SHELL( this ); StartAllAction(); @@ -1122,7 +1122,7 @@ void SwFEShell::AdjustCellWidth( bool bBalance, const bool bNoShrink, const bool TableWait aWait(std::numeric_limits<size_t>::max(), nullptr, *GetDoc()->GetDocShell()); - GetDoc()->AdjustCellWidth( *getShellCursor( false ), bBalance, bNoShrink, bColumnWidth ); + GetDoc()->AdjustCellWidth( *getShellCursor( false ), bBalance, bNoShrink ); EndAllActionAndCall(); } diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx index 4a37848da7a7..3555f79b8217 100644 --- a/sw/source/uibase/shells/tabsh.cxx +++ b/sw/source/uibase/shells/tabsh.cxx @@ -769,14 +769,13 @@ void SwTableShell::Execute(SfxRequest &rReq) { bool bBalance = (FN_TABLE_BALANCE_CELLS == nSlot); const bool bNoShrink = FN_TABLE_ADJUST_CELLS == nSlot; - const bool bSelectedWidth = SID_TABLE_MINIMAL_COLUMN_WIDTH == nSlot; if ( rSh.IsAdjustCellWidthAllowed(bBalance) ) { { // remove actions to make a valid table selection UnoActionRemoveContext aRemoveContext(rSh.GetDoc()); } - rSh.AdjustCellWidth(bBalance, bNoShrink, !bSelectedWidth); + rSh.AdjustCellWidth(bBalance, bNoShrink); } bCallDone = true; break; |