sw/qa/extras/ooxmlexport/data/tdf97090.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 18 ++++++++++++++++++ sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 5 +++++ sw/source/core/layout/frmtool.cxx | 16 ++++------------ writerfilter/source/dmapper/CellColorHandler.cxx | 9 ++++++++- writerfilter/source/dmapper/CellColorHandler.hxx | 1 + writerfilter/source/dmapper/StyleSheetTable.cxx | 14 +++++++++++++- 7 files changed, 49 insertions(+), 14 deletions(-)
New commits: commit d77394eeb4a906ed2fc9d0b24873ada975ae7b0f Author: Justin Luth <[email protected]> Date: Fri Sep 9 23:32:11 2016 +0300 tdf#89315 writerfilter add missing parents to out-of-order styles Styles that inherit from a parent style, but were defined in style.xml before the parent, were losing their base style. Change-Id: Ic12876dddb1aa961cd8ef7579061cca30c320c71 Reviewed-on: https://gerrit.libreoffice.org/28785 Tested-by: Jenkins <[email protected]> Reviewed-by: Justin Luth <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index c575a6a..882c91e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -986,6 +986,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf81345_045Original,"tdf81345.docx") xCursor->jumpToPage(2); OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); CPPUNIT_ASSERT(pageStyleName != "Standard"); + + // tdf89297 Styles were being added before their base/parent/inherited-from style existed, and so were using default settings. + uno::Reference<container::XNameAccess> xParaStyles(getStyles("ParagraphStyles")); + uno::Reference<beans::XPropertySet> xStyle(xParaStyles->getByName("Pull quote"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6736947), getProperty<sal_Int32>(xStyle, "CharColor")); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 8385964..6674c33 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -50,6 +50,7 @@ namespace dmapper { typedef ::std::map< OUString, OUString> StringPairMap_t; +typedef ::std::pair<OUString, uno::Reference< style::XStyle>> ParentOfStylePair_t; StyleSheetEntry::StyleSheetEntry() : @@ -937,6 +938,7 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) xStyleFamilies->getByName("NumberingStyles") >>= xNumberingStyles; if(xCharStyles.is() && xParaStyles.is()) { + std::vector< ParentOfStylePair_t > aMissingParent; std::vector<beans::PropertyValue> aTableStylesVec; std::vector< StyleSheetEntryPtr >::iterator aIt = m_pImpl->m_aStyleSheetEntries.begin(); while( aIt != m_pImpl->m_aStyleSheetEntries.end() ) @@ -949,7 +951,7 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) bool bInsert = false; uno::Reference< container::XNameContainer > xStyles = bParaStyle ? xParaStyles : (bListStyle ? xNumberingStyles : xCharStyles); uno::Reference< style::XStyle > xStyle; - OUString sConvertedStyleName = ConvertStyleName( pEntry->sStyleName ); + const OUString sConvertedStyleName = ConvertStyleName( pEntry->sStyleName ); if(xStyles->hasByName( sConvertedStyleName )) { @@ -1175,6 +1177,10 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) // Numbering style got inserted earlier. if(bInsert && !bListStyle) { + const OUString sParentStyle = xStyle->getParentStyle(); + if( !sParentStyle.isEmpty() && !xStyles->hasByName( sParentStyle ) ) + aMissingParent.push_back( ParentOfStylePair_t(sParentStyle, xStyle) ); + xStyles->insertByName( sConvertedStyleName, uno::makeAny( xStyle) ); } @@ -1198,6 +1204,12 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) ++aIt; } + // Update the styles that were created before their parents + for( auto iter : aMissingParent ) + { + iter.second->setParentStyle( iter.first ); + } + if (!aTableStylesVec.empty()) { // If we had any table styles, add a new document-level InteropGrabBag entry for them. commit 26eec5bf68b6227922434030b05d096de51d93ac Author: Justin Luth <[email protected]> Date: Wed Nov 2 15:15:55 2016 +0300 there is a function for that: CalcLineSpace(xx, bEvenIfNoLine) Change-Id: Ideeb031f20611bd9d2a01343bc75e1d0510ad6e9 Reviewed-on: https://gerrit.libreoffice.org/30513 Reviewed-by: Justin Luth <[email protected]> Tested-by: Justin Luth <[email protected]> (cherry picked from commit 5d9d0f3c979732ade57b9c4c4960dd030ffdc9f9) diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index d57a180..34970bc 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1987,36 +1987,28 @@ long SwBorderAttrs::CalcLeft( const SwFrame *pCaller ) const void SwBorderAttrs::_CalcTopLine() { - m_nTopLine = (m_bBorderDist && !m_rBox.GetTop()) - ? m_rBox.GetDistance (SvxBoxItemLine::TOP) - : m_rBox.CalcLineSpace(SvxBoxItemLine::TOP); + m_nTopLine = m_rBox.CalcLineSpace( SvxBoxItemLine::TOP, /*bEvenIfNoLine*/true ); m_nTopLine = m_nTopLine + m_rShadow.CalcShadowSpace(SvxShadowItemSide::TOP); m_bTopLine = false; } void SwBorderAttrs::_CalcBottomLine() { - m_nBottomLine = (m_bBorderDist && !m_rBox.GetBottom()) - ? m_rBox.GetDistance (SvxBoxItemLine::BOTTOM) - : m_rBox.CalcLineSpace(SvxBoxItemLine::BOTTOM); + m_nBottomLine = m_rBox.CalcLineSpace( SvxBoxItemLine::BOTTOM, true ); m_nBottomLine = m_nBottomLine + m_rShadow.CalcShadowSpace(SvxShadowItemSide::BOTTOM); m_bBottomLine = false; } void SwBorderAttrs::_CalcLeftLine() { - m_nLeftLine = (m_bBorderDist && !m_rBox.GetLeft()) - ? m_rBox.GetDistance (SvxBoxItemLine::LEFT) - : m_rBox.CalcLineSpace(SvxBoxItemLine::LEFT); + m_nLeftLine = m_rBox.CalcLineSpace( SvxBoxItemLine::LEFT, true ); m_nLeftLine = m_nLeftLine + m_rShadow.CalcShadowSpace(SvxShadowItemSide::LEFT); m_bLeftLine = false; } void SwBorderAttrs::_CalcRightLine() { - m_nRightLine = (m_bBorderDist && !m_rBox.GetRight()) - ? m_rBox.GetDistance (SvxBoxItemLine::RIGHT) - : m_rBox.CalcLineSpace(SvxBoxItemLine::RIGHT); + m_nRightLine = m_rBox.CalcLineSpace(SvxBoxItemLine::RIGHT, true ); m_nRightLine = m_nRightLine + m_rShadow.CalcShadowSpace(SvxShadowItemSide::RIGHT); m_bRightLine = false; } commit 7aec25f93038926bd4ffad80743ea48f7e95dd6f Author: Justin Luth <[email protected]> Date: Fri Aug 5 20:21:13 2016 +0300 tdf#97090 writerfilter - don't fill_SOLID with auto color fixes a regression from 24077b2d52ab3d0fd0db5afb25d8b94b62386e3e <w:shd w:val="clear" w:color="auto" w:fill="auto"> seems to be the default "fill disabled" state, so don't force a solid white fill in that case. Change-Id: Ia421e52e228bbf0d3a2cd9af72e0a580042e5dcd Reviewed-on: https://gerrit.libreoffice.org/27915 Tested-by: Jenkins <[email protected]> Reviewed-by: Justin Luth <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/data/tdf97090.docx b/sw/qa/extras/ooxmlexport/data/tdf97090.docx new file mode 100644 index 0000000..3ba4027 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf97090.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 8f41610..36a29e8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -725,6 +725,24 @@ DECLARE_OOXMLEXPORT_TEST(testTdf88583, "tdf88583.odt") CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x00cc00), getProperty<sal_Int32>(getParagraph(1), "FillColor")); } +DECLARE_OOXMLEXPORT_TEST(testTdf97090, "tdf97090.docx") +{ + uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY); + uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x95B3D7), getProperty<sal_Int32>(xTable->getCellByName("A1"), "BackColor")); + + uno::Reference<container::XEnumerationAccess> paraEnumAccess(xTable->getCellByName("A1"), uno::UNO_QUERY); + assert( paraEnumAccess.is() ); + uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration(); + + assert( paraEnum.is() ); + uno::Reference<beans::XPropertySet> paragraphProperties(paraEnum->nextElement(), uno::UNO_QUERY); + assert( paragraphProperties.is() ); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(paragraphProperties, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffffff), getProperty<sal_Int32>(paragraphProperties, "FillColor")); +} + DECLARE_OOXMLEXPORT_TEST(testTdf89791, "tdf89791.docx") { if (mbExported) diff --git a/writerfilter/source/dmapper/CellColorHandler.cxx b/writerfilter/source/dmapper/CellColorHandler.cxx index 6845c8a..47d329d 100644 --- a/writerfilter/source/dmapper/CellColorHandler.cxx +++ b/writerfilter/source/dmapper/CellColorHandler.cxx @@ -37,6 +37,7 @@ LoggedProperties("CellColorHandler"), m_nShadingPattern( drawing::ShadingPattern::CLEAR ), m_nColor( 0xffffffff ), m_nFillColor( 0xffffffff ), +m_bAutoFillColor( true ), m_OutputFormat( Form ) { } @@ -110,6 +111,9 @@ void CellColorHandler::lcl_attribute(Id rName, Value & rVal) createGrabBag("fill", uno::makeAny(OUString::fromUtf8(msfilter::util::ConvertColor(nIntValue, /*bAutoColor=*/true)))); if( nIntValue == OOXML_COLOR_AUTO ) nIntValue = 0xffffff; //fill color auto means white + else + m_bAutoFillColor = false; + m_nFillColor = nIntValue; break; case NS_ooxml::LN_CT_Shd_color: @@ -271,7 +275,10 @@ TablePropertyMapPtr CellColorHandler::getProperties() if (m_OutputFormat == Paragraph) { - pPropertyMap->Insert(PROP_FILL_STYLE, uno::makeAny(drawing::FillStyle_SOLID)); + // If brush style = clear and FillColor = COLOR_AUTO, then don't enable the fill style - just pre-select the default color + if (nWW8BrushStyle || !m_bAutoFillColor) + pPropertyMap->Insert(PROP_FILL_STYLE, uno::makeAny(drawing::FillStyle_SOLID)); + pPropertyMap->Insert(PROP_FILL_COLOR, uno::makeAny(nApplyColor)); } else diff --git a/writerfilter/source/dmapper/CellColorHandler.hxx b/writerfilter/source/dmapper/CellColorHandler.hxx index 98fe791..98c8aaf 100644 --- a/writerfilter/source/dmapper/CellColorHandler.hxx +++ b/writerfilter/source/dmapper/CellColorHandler.hxx @@ -37,6 +37,7 @@ private: sal_Int32 m_nShadingPattern; sal_Int32 m_nColor; sal_Int32 m_nFillColor; + bool m_bAutoFillColor; OutputFormat m_OutputFormat; OUString m_aInteropGrabBagName; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
