sfx2/source/dialog/infobar.cxx | 33 +++-------------- sw/inc/tblafmt.hxx | 3 + sw/qa/extras/htmlimport/data/reqif-table.xhtml | 48 ++++++++++++++++++++++++- sw/qa/extras/htmlimport/htmlimport.cxx | 12 +++++- sw/source/core/doc/tblafmt.cxx | 23 ++++++++++- sw/source/core/docnode/ndtbl.cxx | 33 +++++++++++------ sw/source/filter/html/htmltab.cxx | 2 - 7 files changed, 110 insertions(+), 44 deletions(-)
New commits: commit 46fcf87725818666fee34226afdac4a64edd94eb Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Fri Nov 15 21:16:52 2019 +0300 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Nov 19 09:51:30 2019 +0100 tdf#115576 sw: fix borders for single row/col autotable styles The 4*4 autostyle table matrix has no box format that can handle a table with a single column or single row. So the first and last row/column boxes need to be combined to get all of the necessary borders. This could easily be seen by setting one column and X rows using the default table style - missing right border. It could also be seen by setting one row and X columns using Box List yellow - missing bottom border. Change-Id: Ib2cf873b6d4e10ba5145e680ea7b3e2e3aea3970 Reviewed-on: https://gerrit.libreoffice.org/82998 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_l...@sil.org> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx index 3e8382930c13..2d87284eb3a6 100644 --- a/sw/inc/tblafmt.hxx +++ b/sw/inc/tblafmt.hxx @@ -209,7 +209,8 @@ public: void UpdateFromSet( sal_uInt8 nPos, const SfxItemSet& rSet, SwTableAutoFormatUpdateFlags eFlags, SvNumberFormatter const * ); - void UpdateToSet( sal_uInt8 nPos, SfxItemSet& rSet, SwTableAutoFormatUpdateFlags eFlags, + void UpdateToSet( const sal_uInt8 nPos, const bool bSingleRowTable, const bool bSingleColTable, + SfxItemSet& rSet, SwTableAutoFormatUpdateFlags eFlags, SvNumberFormatter* ) const ; void RestoreTableProperties(SwTable &table) const; diff --git a/sw/qa/extras/htmlimport/data/reqif-table.xhtml b/sw/qa/extras/htmlimport/data/reqif-table.xhtml index 242201de817d..a169a079e27a 100644 --- a/sw/qa/extras/htmlimport/data/reqif-table.xhtml +++ b/sw/qa/extras/htmlimport/data/reqif-table.xhtml @@ -2,14 +2,58 @@ <reqif-xhtml:table width="100%" cellpadding="4" cellspacing="0"> <reqif-xhtml:col width="128*"/> - <reqif-xhtml:col width="128*"/> + <reqif-xhtml:tr valign="top"> + <reqif-xhtml:td><reqif-xhtml:p align="left" style="text-decoration: none"> + <reqif-xhtml:br/> + + </reqif-xhtml:p> + </reqif-xhtml:td> + </reqif-xhtml:tr> +</reqif-xhtml:table> + +<reqif-xhtml:p>Table 2.</reqif-xhtml:p> + +<reqif-xhtml:table width="100%" cellpadding="4" cellspacing="0"> + <reqif-xhtml:tr valign="top"> + <reqif-xhtml:td><reqif-xhtml:p align="left" style="text-decoration: none"> + <reqif-xhtml:br/> + + </reqif-xhtml:p> + </reqif-xhtml:td> + <reqif-xhtml:td><reqif-xhtml:p align="left" style="text-decoration: none"> + <reqif-xhtml:br/> + + </reqif-xhtml:p> + </reqif-xhtml:td> + <reqif-xhtml:td><reqif-xhtml:p align="left" style="text-decoration: none"> + <reqif-xhtml:br/> + + </reqif-xhtml:p> + </reqif-xhtml:td> + <reqif-xhtml:td><reqif-xhtml:p align="left" style="text-decoration: none"> + <reqif-xhtml:br/> + + </reqif-xhtml:p> + </reqif-xhtml:td> + <reqif-xhtml:td><reqif-xhtml:p align="left" style="text-decoration: none"> + <reqif-xhtml:br/> + </reqif-xhtml:p> + </reqif-xhtml:td> + </reqif-xhtml:tr> +</reqif-xhtml:table> + +<reqif-xhtml:p>Table 3.</reqif-xhtml:p> + +<reqif-xhtml:table width="100%" cellpadding="4" cellspacing="0"> <reqif-xhtml:tr valign="top"> <reqif-xhtml:td><reqif-xhtml:p align="left" style="text-decoration: none"> <reqif-xhtml:br/> </reqif-xhtml:p> </reqif-xhtml:td> + </reqif-xhtml:tr> + <reqif-xhtml:tr valign="top"> <reqif-xhtml:td><reqif-xhtml:p align="left" style="text-decoration: none"> <reqif-xhtml:br/> @@ -22,6 +66,8 @@ </reqif-xhtml:p> </reqif-xhtml:td> + </reqif-xhtml:tr> + <reqif-xhtml:tr valign="top"> <reqif-xhtml:td><reqif-xhtml:p align="left" style="text-decoration: none"> <reqif-xhtml:br/> diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index 6ab84cf1c7df..714eb6d4bf81 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -316,17 +316,25 @@ DECLARE_HTMLIMPORT_TEST(testReqIfBr, "reqif-br.xhtml") DECLARE_HTMLIMPORT_TEST(testReqIfTable, "reqif-table.xhtml") { + // to see this: soffice --infilter="HTML (StarWriter):xhtmlns=reqif-xhtml" sw/qa/extras/htmlimport/data/reqif-table.xhtml // Load a table with xhtmlns=reqif-xhtml filter param. uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xTables->getCount()); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xTables->getCount()); uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); auto aBorder = getProperty<table::BorderLine2>(xCell, "TopBorder"); // This was 0, tables had no borders, even if the default autoformat has // borders and the markup allows no custom borders. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(18), aBorder.LineWidth); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Top Border", static_cast<sal_uInt32>(18), aBorder.LineWidth); + aBorder = getProperty<table::BorderLine2>(xCell, "BottomBorder"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Bottom Border", static_cast<sal_uInt32>(18), aBorder.LineWidth); + aBorder = getProperty<table::BorderLine2>(xCell, "LeftBorder"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Left Border", static_cast<sal_uInt32>(18), aBorder.LineWidth); + aBorder = getProperty<table::BorderLine2>(xCell, "RightBorder"); + // This was 0. Single column tables had no right border. tdf#115576 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Right Border", static_cast<sal_uInt32>(18), aBorder.LineWidth); } DECLARE_HTMLIMPORT_TEST(testImageSize, "image-size.html") diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index 1954bc3bc163..765154b3e862 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -559,7 +559,7 @@ void SwTableAutoFormat::UpdateFromSet( sal_uInt8 nPos, // we cannot handle the rest, that's specific to StarCalc } -void SwTableAutoFormat::UpdateToSet(sal_uInt8 nPos, SfxItemSet& rSet, +void SwTableAutoFormat::UpdateToSet(const sal_uInt8 nPos, const bool bSingleRowTable, const bool bSingleColTable, SfxItemSet& rSet, SwTableAutoFormatUpdateFlags eFlags, SvNumberFormatter* pNFormatr) const { const SwBoxAutoFormat& rChg = GetBoxFormat( nPos ); @@ -617,7 +617,26 @@ void SwTableAutoFormat::UpdateToSet(sal_uInt8 nPos, SfxItemSet& rSet, { if( IsFrame() ) { - rSet.Put( rChg.GetBox() ); + SvxBoxItem aAutoFormatBox = rChg.GetBox(); + + // No format box is adequate to specify the borders of single column/row tables, so combine first/last. + if ( bSingleRowTable || bSingleColTable ) + { + sal_uInt8 nSingleRowOrColumnId = 15; //LAST_ROW_END_COLUMN + if ( !bSingleRowTable ) + nSingleRowOrColumnId = nPos + 3; //LAST COLUMN (3, 7, 11, 15) + else if ( !bSingleColTable ) + nSingleRowOrColumnId = nPos + 12; //LAST ROW (12, 13, 14, 15) + + assert( nSingleRowOrColumnId < 16 ); + const SvxBoxItem aLastAutoFormatBox( GetBoxFormat(nSingleRowOrColumnId).GetBox() ); + if ( bSingleRowTable ) + aAutoFormatBox.SetLine( aLastAutoFormatBox.GetLine(SvxBoxItemLine::BOTTOM), SvxBoxItemLine::BOTTOM ); + if ( bSingleColTable ) + aAutoFormatBox.SetLine( aLastAutoFormatBox.GetLine(SvxBoxItemLine::RIGHT), SvxBoxItemLine::RIGHT ); + } + + rSet.Put( aAutoFormatBox ); // FIXME - uncomment the lines to put the diagonal line items // rSet.Put( rChg.GetTLBR() ); // rSet.Put( rChg.GetBLTR() ); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 8a6cc42617d6..00e249b9e0fb 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -162,7 +162,8 @@ lcl_SetDfltBoxAttr(SwTableBox& rBox, DfltBoxAttrList_t & rBoxFormatArr, pNewTableBoxFormat->SetFormatAttr( pBoxFrameFormat->GetAttrSet().Get( RES_FRM_SIZE ) ); if( pAutoFormat ) - pAutoFormat->UpdateToSet( nId, const_cast<SfxItemSet&>(static_cast<SfxItemSet const &>(pNewTableBoxFormat->GetAttrSet())), + pAutoFormat->UpdateToSet( nId, false, false, + const_cast<SfxItemSet&>(static_cast<SfxItemSet const &>(pNewTableBoxFormat->GetAttrSet())), SwTableAutoFormatUpdateFlags::Box, pDoc->GetNumberFormatter() ); else @@ -190,12 +191,13 @@ static SwTableBoxFormat *lcl_CreateDfltBoxFormat( SwDoc &rDoc, std::vector<SwTab static SwTableBoxFormat *lcl_CreateAFormatBoxFormat( SwDoc &rDoc, std::vector<SwTableBoxFormat*> &rBoxFormatArr, const SwTableAutoFormat& rAutoFormat, - sal_uInt16 nCols, sal_uInt8 nId ) + const sal_uInt16 nRows, const sal_uInt16 nCols, sal_uInt8 nId ) { if( !rBoxFormatArr[nId] ) { SwTableBoxFormat* pBoxFormat = rDoc.MakeTableBoxFormat(); - rAutoFormat.UpdateToSet( nId, const_cast<SfxItemSet&>(static_cast<SfxItemSet const &>(pBoxFormat->GetAttrSet())), + rAutoFormat.UpdateToSet( nId, nRows==1, nCols==1, + const_cast<SfxItemSet&>(static_cast<SfxItemSet const &>(pBoxFormat->GetAttrSet())), SwTableAutoFormatUpdateFlags::Box, rDoc.GetNumberFormatter( ) ); if( USHRT_MAX != nCols ) @@ -488,13 +490,13 @@ const SwTable* SwDoc::InsertTable( const SwInsertTableOptions& rInsTableOpts, { sal_uInt8 nId = SwTableAutoFormat::CountPos(i, nCols, n, nRows); pBoxF = ::lcl_CreateAFormatBoxFormat( *this, aBoxFormatArr, *pTAFormat, - nCols, nId ); + nRows, nCols, nId ); // Set the Paragraph/Character Attributes if needed if( pTAFormat->IsFont() || pTAFormat->IsJustify() ) { aCharSet.ClearItem(); - pTAFormat->UpdateToSet( nId, aCharSet, + pTAFormat->UpdateToSet( nId, nRows==1, nCols==1, aCharSet, SwTableAutoFormatUpdateFlags::Char, nullptr ); if( aCharSet.Count() ) GetNodes()[ aNdIdx.GetIndex()+1 ]->GetContentNode()-> @@ -786,14 +788,14 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTableOpts, { bChgSz = nullptr == (*aBoxFormatArr2)[ nId ]; pBoxF = ::lcl_CreateAFormatBoxFormat( *this, *aBoxFormatArr2, - *pTAFormat, USHRT_MAX, nId ); + *pTAFormat, USHRT_MAX, USHRT_MAX, nId ); } // Set Paragraph/Character Attributes if needed if( pTAFormat->IsFont() || pTAFormat->IsJustify() ) { aCharSet.ClearItem(); - pTAFormat->UpdateToSet( nId, aCharSet, + pTAFormat->UpdateToSet( nId, nRows==1, nCols==1, aCharSet, SwTableAutoFormatUpdateFlags::Char, nullptr ); if( aCharSet.Count() ) { @@ -3588,10 +3590,11 @@ struct SetAFormatTabPara SwUndoTableAutoFormat* pUndo; sal_uInt16 nEndBox, nCurBox; sal_uInt8 nAFormatLine, nAFormatBox; + bool bSingleRowTable; explicit SetAFormatTabPara( const SwTableAutoFormat& rNew ) : rTableFormat( const_cast<SwTableAutoFormat&>(rNew) ), pUndo( nullptr ), - nEndBox( 0 ), nCurBox( 0 ), nAFormatLine( 0 ), nAFormatBox( 0 ) + nEndBox( 0 ), nCurBox( 0 ), nAFormatLine( 0 ), nAFormatBox( 0 ), bSingleRowTable(false) {} }; @@ -3616,7 +3619,7 @@ static bool lcl_SetAFormatBox(FndBox_ & rBox, SetAFormatTabPara *pSetPara, bool pSetPara->nAFormatBox = 0; else if( pSetPara->nCurBox == pSetPara->nEndBox ) pSetPara->nAFormatBox = 3; - else + else //Even column(1) or Odd column(2) pSetPara->nAFormatBox = static_cast<sal_uInt8>(1 + ((pSetPara->nCurBox-1) & 1)); } @@ -3632,8 +3635,10 @@ static bool lcl_SetAFormatBox(FndBox_ & rBox, SetAFormatTabPara *pSetPara, bool SfxItemSet aCharSet(pDoc->GetAttrPool(), svl::Items<RES_CHRATR_BEGIN, RES_PARATR_LIST_END-1>{}); SfxItemSet aBoxSet(pDoc->GetAttrPool(), aTableBoxSetRange); sal_uInt8 nPos = pSetPara->nAFormatLine * 4 + pSetPara->nAFormatBox; - pSetPara->rTableFormat.UpdateToSet(nPos, aCharSet, SwTableAutoFormatUpdateFlags::Char, nullptr); - pSetPara->rTableFormat.UpdateToSet(nPos, aBoxSet, SwTableAutoFormatUpdateFlags::Box, pDoc->GetNumberFormatter()); + const bool bSingleRowTable = pSetPara->bSingleRowTable; + const bool bSingleColTable = pSetPara->nEndBox == 0; + pSetPara->rTableFormat.UpdateToSet(nPos, bSingleRowTable, bSingleColTable, aCharSet, SwTableAutoFormatUpdateFlags::Char, nullptr); + pSetPara->rTableFormat.UpdateToSet(nPos, bSingleRowTable, bSingleColTable, aBoxSet, SwTableAutoFormatUpdateFlags::Box, pDoc->GetNumberFormatter()); if (aCharSet.Count()) { @@ -3658,10 +3663,15 @@ static bool lcl_SetAFormatBox(FndBox_ & rBox, SetAFormatTabPara *pSetPara, bool } else { + // Not sure how this situation can occur, but apparently we have some kind of table in table. + // I am guessing at how to best handle singlerow in this situation. + const bool bOrigSingleRowTable = pSetPara->bSingleRowTable; + pSetPara->bSingleRowTable = rBox.GetLines().size() == 1; for (auto const& rpFndLine : rBox.GetLines()) { lcl_SetAFormatLine(*rpFndLine, pSetPara, bResetDirect); } + pSetPara->bSingleRowTable = bOrigSingleRowTable; } if (!rBox.GetUpper()->GetUpper()) // a BaseLine @@ -3717,6 +3727,7 @@ bool SwDoc::SetTableAutoFormat(const SwSelBoxes& rBoxes, const SwTableAutoFormat SetAFormatTabPara aPara( rNew ); FndLines_t& rFLns = pFndBox->GetLines(); + aPara.bSingleRowTable = rFLns.size() == 1; for (FndLines_t::size_type n = 0; n < rFLns.size(); ++n) { diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index f04aa013330b..0d659d7dfd65 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -1478,7 +1478,7 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox, if (pTableFormat) { sal_uInt8 nPos = SwTableAutoFormat::CountPos(nCol, m_nCols, nRow, m_nRows); - pTableFormat->UpdateToSet(nPos, + pTableFormat->UpdateToSet(nPos, m_nRows==1, m_nCols==1, const_cast<SfxItemSet&>(static_cast<SfxItemSet const&>( pFrameFormat->GetAttrSet())), SwTableAutoFormatUpdateFlags::Box, commit 1562e094fc6a57cd9738109d5202497bcc043d80 Author: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> AuthorDate: Mon Nov 18 15:25:11 2019 +0100 Commit: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> CommitDate: Tue Nov 19 09:51:22 2019 +0100 tdf#125359 Don't overlap multiple infobars Change-Id: Ieda7dce84daec2e94501c69584f3df21d63d60bb Reviewed-on: https://gerrit.libreoffice.org/83101 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx index ea99fc6b67d3..8dd52ed32a92 100644 --- a/sfx2/source/dialog/infobar.cxx +++ b/sfx2/source/dialog/infobar.cxx @@ -339,7 +339,7 @@ void SfxInfoBarWindow::Resize() m_pSecondaryMessage->SetPosSizePixel(aSecondaryMessagePosition, aSecondaryTextSize); m_pImage->SetPosSizePixel(Point(4, 4), Size(32 * fScaleFactor, 32 * fScaleFactor)); - SetPosSizePixel(Point(0, 0), Size(nWidth, INFO_BAR_BASE_HEIGHT * fScaleFactor + aExtraHeight * fScaleFactor)); + SetPosSizePixel(GetPosPixel(), Size(nWidth, INFO_BAR_BASE_HEIGHT * fScaleFactor + aExtraHeight * fScaleFactor)); } void SfxInfoBarWindow::Update( const OUString& sPrimaryMessage, const OUString& sSecondaryMessage, InfobarType eType ) @@ -387,8 +387,6 @@ SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, const OUString& sP const OUString& sSecondaryMessage, InfobarType ibType, WinBits nMessageStyle, bool bShowCloseButton) { - Size aSize = GetSizePixel(); - auto pInfoBar = VclPtr<SfxInfoBarWindow>::Create(this, sId, sPrimaryMessage, sSecondaryMessage, ibType, nMessageStyle, bShowCloseButton); @@ -398,14 +396,9 @@ SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, const OUString& sP GetInfoBarColors(ibType,aBackgroundColor,aForegroundColor,aMessageColor); pInfoBar->m_aBackgroundColor = aBackgroundColor; pInfoBar->m_aForegroundColor = aForegroundColor; - - pInfoBar->SetPosPixel(Point(0, aSize.getHeight())); - pInfoBar->Show(); m_pInfoBars.push_back(pInfoBar); - long nHeight = pInfoBar->GetSizePixel().getHeight(); - aSize.setHeight(aSize.getHeight() + nHeight); - SetSizePixel(aSize); + Resize(); return pInfoBar; } @@ -434,24 +427,13 @@ void SfxInfoBarContainerWindow::removeInfoBar(VclPtr<SfxInfoBarWindow> const & p m_pInfoBars.erase(it); } - // Resize - long nY = 0; - for (auto const& infoBar : m_pInfoBars) - { - infoBar->SetPosPixel(Point(0, nY)); - nY += infoBar->GetSizePixel().getHeight(); - } - - Size aSize = GetSizePixel(); - aSize.setHeight(nY); - SetSizePixel(aSize); + Resize(); m_pChildWin->Update(); } void SfxInfoBarContainerWindow::Resize() { - // Only need to change the width of the infobars long nWidth = GetSizePixel().getWidth(); long nHeight = 0; @@ -459,14 +441,13 @@ void SfxInfoBarContainerWindow::Resize() { Size aSize = rxInfoBar->GetSizePixel(); aSize.setWidth(nWidth); - rxInfoBar->SetSizePixel(aSize); + Point aPos(0, nHeight); + rxInfoBar->SetPosSizePixel(aPos, aSize); rxInfoBar->Resize(); + rxInfoBar->Show(); // Stretch to fit the infobar(s) - if (aSize.getHeight() > nHeight) - { - nHeight = aSize.getHeight(); - } + nHeight += aSize.getHeight(); } SetSizePixel(Size(nWidth, nHeight)); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits