chart2/qa/extras/chart2export.cxx | 23 +++ chart2/qa/extras/data/xlsx/testDataseriesOverlapStackedChart.xlsx |binary chart2/source/view/main/ShapeFactory.cxx | 1 filter/source/msfilter/escherex.cxx | 26 +--- include/oox/core/xmlfilterbase.hxx | 2 oox/source/core/xmlfilterbase.cxx | 50 ++++++-- oox/source/export/chartexport.cxx | 17 ++ oox/source/export/drawingml.cxx | 58 ++++++++-- oox/source/vml/vmlshapecontext.cxx | 2 sc/qa/unit/data/xlsx/open-as-read-only.xlsx |binary sc/qa/unit/data/xlsx/testShapeAutofit.xlsx |binary sc/qa/unit/subsequent_export-test.cxx | 30 ++++- sc/source/filter/excel/excdoc.cxx | 2 sc/source/ui/vba/vbaworkbooks.cxx | 1 sd/qa/unit/data/pptx/open-as-read-only.pptx |binary sd/qa/unit/data/pptx/testShapeAutofit.pptx |binary sd/qa/unit/export-tests-ooxml2.cxx | 29 +++++ sd/source/filter/eppt/pptx-epptooxml.cxx | 14 ++ sfx2/source/doc/objstor.cxx | 27 ++++ sw/CppunitTest_sw_ww8export3.mk | 58 ++++++++++ sw/Module_sw.mk | 1 sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx |binary sw/qa/extras/ooxmlexport/data/dashed_line_custdash_1000th_of_percent.docx |binary sw/qa/extras/ooxmlexport/data/dashed_line_custdash_percentage.docx |binary sw/qa/extras/ooxmlexport/data/open-as-read-only.docx |binary sw/qa/extras/ooxmlexport/data/tdf104354.docx |binary sw/qa/extras/ooxmlexport/data/tdf57589_hashColor.docx |binary sw/qa/extras/ooxmlexport/data/tdf82177_outsideCellBorders.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 37 ++++++ sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 11 - sw/qa/extras/ooxmlexport/ooxmlexport6.cxx | 12 +- sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 29 ----- sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 4 sw/qa/extras/rtfexport/data/fdo82006.rtf | 1 sw/qa/extras/rtfexport/data/tdf107480.rtf | 1 sw/qa/extras/rtfexport/rtfexport.cxx | 14 ++ sw/qa/extras/ww8export/data/tdf119232_startEvenPage.doc |binary sw/qa/extras/ww8export/data/tdf94009_zeroPgMargin.odt |binary sw/qa/extras/ww8export/ww8export2.cxx | 5 sw/qa/extras/ww8export/ww8export3.cxx | 43 +++++++ sw/source/core/docnode/ndtbl1.cxx | 6 - sw/source/filter/ww8/WW8TableInfo.cxx | 1 sw/source/filter/ww8/docxattributeoutput.cxx | 9 + sw/source/filter/ww8/docxexport.cxx | 4 sw/source/filter/ww8/ww8atr.cxx | 2 sw/source/filter/ww8/ww8par6.cxx | 12 +- sw/source/uibase/dochdl/swdtflvr.cxx | 48 +++++++- writerfilter/source/dmapper/DomainMapper.cxx | 9 + writerfilter/source/ooxml/OOXMLPropertySet.cxx | 15 ++ 49 files changed, 507 insertions(+), 97 deletions(-)
New commits: commit 713e8d6ebc5e25c287dcc645cc61b247d50edf3a Author: Justin Luth <[email protected]> AuthorDate: Sat Sep 8 12:11:01 2018 +0300 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 10:19:54 2018 +0200 tdf#82177 docx export: eliminate invalid tcPr insideV/H borders better fix than cecf71c18da5430c10daa8522d38d5144edefc14 since: 17.4.25 insideV (Table Cell Inside Vertical Edges Border) This element specifies the border which shall be displayed on all interior vertical edges of the current group of table cells. [Note: Although individual table cells have no concept of an internal edge, which would render this property useless in most cases, it is used to determine the cell borders to apply to a specific group of cells as part of table conditional formatting in a table style, for example, the inside vertical edges on the set of cells in the header row. end note] So, I interpret this as insideV/H having meaning only within table styles, and not when directly applied to a cell. The only documents I've seen with insideV/H directly applied to a cell seem to have been created by LO - which dumps them everywhere, redundantly. Tablestyle cell groupings are handled elsewhere via grabbag dumps, so insideV/H borders can be eliminated from TableCellProperties. Change-Id: I128417f0a0b485c85ede463daacb8feabc457302 Reviewed-on: https://gerrit.libreoffice.org/60187 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> (cherry picked from commit d934fe802c228d5478cea228b84ba56b6c9b9241) diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index 22ab51aff521..77953b1e6e40 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -687,15 +687,8 @@ DECLARE_OOXMLEXPORT_TEST(testfdo80097, "fdo80097.docx") assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:space = 0]", 1); assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:color = '000000']", 1); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH[@w:val = 'single']",1); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH[@w:sz = 4]", 1); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH[@w:space = 0]", 1); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH[@w:color = '000000']", 1); - - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV[@w:val = 'single']",1); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV[@w:sz = 4]", 1); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV[@w:space = 0]", 1); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV[@w:color = '000000']", 1); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH",0); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV",0); } DECLARE_OOXMLEXPORT_TEST(testFdo77129, "fdo77129.docx") diff --git a/sw/source/filter/ww8/WW8TableInfo.cxx b/sw/source/filter/ww8/WW8TableInfo.cxx index 71fb8d1cd4d7..3339fbe2c599 100644 --- a/sw/source/filter/ww8/WW8TableInfo.cxx +++ b/sw/source/filter/ww8/WW8TableInfo.cxx @@ -119,11 +119,6 @@ void WW8TableNodeInfoInner::setRect(const SwRect & rRect) maRect = rRect; } -bool WW8TableNodeInfoInner::isFinalRow() const -{ - return mpTable && mpTable->GetTabLines().size() - 1 == mnRow; -} - const SwNode * WW8TableNodeInfoInner::getNode() const { const SwNode * pResult = nullptr; diff --git a/sw/source/filter/ww8/WW8TableInfo.hxx b/sw/source/filter/ww8/WW8TableInfo.hxx index f2a2db21806a..a3b6df799180 100644 --- a/sw/source/filter/ww8/WW8TableInfo.hxx +++ b/sw/source/filter/ww8/WW8TableInfo.hxx @@ -94,7 +94,6 @@ public: bool isEndOfCell() const { return mbEndOfCell;} bool isEndOfLine() const { return mbEndOfLine;} bool isFinalEndOfLine() const { return mbFinalEndOfLine;} - bool isFinalRow() const; bool isFirstInTable() const { return mbFirstInTable;} const SwTableBox * getTableBox() const { return mpTableBox;} const SwTable * getTable() const { return mpTable;} diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 5ada807693dc..3afa61c66d6b 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3025,7 +3025,7 @@ static OutputBorderOptions lcl_getTableCellBorderOptions(bool bEcma) rOptions.tag = XML_tcBorders; rOptions.bUseStartEnd = !bEcma; rOptions.bWriteTag = true; - rOptions.bWriteInsideHV = true; + rOptions.bWriteInsideHV = false; rOptions.bWriteDistance = false; return rOptions; @@ -3048,9 +3048,7 @@ static void impl_borders( FSHelperPtr const & pSerializer, const SvxBoxItem& rBox, const OutputBorderOptions& rOptions, std::map<SvxBoxItemLine, - css::table::BorderLine2> &rTableStyleConf, - const bool bIsLastColumn = false, - const bool bIsLastRow = false ) + css::table::BorderLine2> &rTableStyleConf ) { static const SvxBoxItemLine aBorders[] = { @@ -3142,14 +3140,14 @@ static void impl_borders( FSHelperPtr const & pSerializer, bWriteInsideV = true; } } - if (bWriteInsideH && !bIsLastRow) + if (bWriteInsideH) { const table::BorderLine2 *aStyleProps = nullptr; if( rTableStyleConf.find( SvxBoxItemLine::BOTTOM ) != rTableStyleConf.end() ) aStyleProps = &rTableStyleConf[ SvxBoxItemLine::BOTTOM ]; impl_borderLine( pSerializer, XML_insideH, rBox.GetLine(SvxBoxItemLine::BOTTOM), 0, false, aStyleProps ); } - if (bWriteInsideV && !bIsLastColumn) + if (bWriteInsideV) { const table::BorderLine2 *aStyleProps = nullptr; if( rTableStyleConf.find( SvxBoxItemLine::RIGHT ) != rTableStyleConf.end() ) @@ -3218,8 +3216,6 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point const SwTableBox *pTableBox = pTableTextNodeInfoInner->getTableBox( ); bool bEcma = GetExport().GetFilter().getVersion( ) == oox::core::ECMA_DIALECT; - const bool bIsLastColumn = pTableTextNodeInfoInner->isEndOfLine(); - const bool bIsLastRow = pTableTextNodeInfoInner->isFinalRow(); // Output any table cell redlines if there are any attached to this specific cell TableCellRedline( pTableTextNodeInfoInner ); @@ -3279,7 +3275,7 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point const SvxBoxItem& rDefaultBox = (*tableFirstCells.rbegin())->getTableBox( )->GetFrameFormat( )->GetBox( ); { // The cell borders - impl_borders( m_pSerializer, rBox, lcl_getTableCellBorderOptions(bEcma), m_aTableStyleConf, bIsLastColumn, bIsLastRow ); + impl_borders( m_pSerializer, rBox, lcl_getTableCellBorderOptions(bEcma), m_aTableStyleConf ); } TableBackgrounds( pTableTextNodeInfoInner ); commit 5506be988d157ba9c9448ab22bfcc2470dadd3b7 Author: Justin Luth <[email protected]> AuthorDate: Wed Sep 5 11:44:34 2018 +0300 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 10:18:49 2018 +0200 tdf#102290 sw ui: give all columns a chance to grow Previously, if an earlier column wished for the entire table width, then none of the other columns could adjust their size, even if they only wanted one more character. This slight change gives every column a chance to "wish" for an equal portion, and still gives the earlier columns a chance to maximize. So, this should implement very similarly to before, thus workflow should not be impacted. Change-Id: I11e8b94ce333735aa92b5388af6319f8eb0ccc51 Reviewed-on: https://gerrit.libreoffice.org/60027 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> (cherry picked from commit 62159ea8cc806df327461275563e95dfdff25667) diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index fbe12fd69018..0a66e7ea77a4 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -1529,11 +1529,15 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor, bool bBalance ) // only afterwards. // The first column's desired width would be discarded as it would cause // the Table's width to exceed the maximum width. + const sal_uInt16 nEqualWidth = (aTabCols.GetRight() - aTabCols.GetLeft()) / (aTabCols.Count() + 1); for ( int k = 0; k < 2; ++k ) { for ( size_t i = 0; i <= aTabCols.Count(); ++i ) { - int nDiff = aWish[i]; + // First pass is primarily a shrink pass. Give all columns a chance + // to grow by requesting the maximum width as "balanced". + // Second pass is a first-come, first-served chance to max out. + int nDiff = k ? aWish[i] : std::min(aWish[i], nEqualWidth); if ( nDiff ) { int nMin = aMins[i]; commit d6cbf8aa5457052887767d7a355334bc25dcdf15 Author: Justin Luth <[email protected]> AuthorDate: Tue Sep 4 09:38:42 2018 +0300 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 10:13:01 2018 +0200 tdf#94009 ww8export: always export section margins Since the internal SW defaults (0) don't match the import defaults, always write the top/bottom, left/right margins into the document definition. It is very rare indeed to have a zero margin anyway, since the page margin being zero is highly discouraged because of printing. The bug report is for DOCX, but it also affects DOC. I don't have an example where LRSpace is skipped, but it only makes sense to treat these two the same just in case. Change-Id: Ie9a08ad0dd4f73bc976756fe244fc33e2dc804f3 Reviewed-on: https://gerrit.libreoffice.org/59967 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> (cherry picked from commit efd316b6171b9e1827c5e34ddb12658f48268e24) diff --git a/sw/CppunitTest_sw_ww8export3.mk b/sw/CppunitTest_sw_ww8export3.mk new file mode 100644 index 000000000000..564f344d7297 --- /dev/null +++ b/sw/CppunitTest_sw_ww8export3.mk @@ -0,0 +1,58 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sw_ww8export3)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_ww8export3, \ + sw/qa/extras/ww8export/ww8export3 \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sw_ww8export3, \ + comphelper \ + cppu \ + cppuhelper \ + editeng \ + $(if $(filter WNT-TRUE,$(OS)-$(DISABLE_ATL)),,emboleobj) \ + sal \ + sfx \ + test \ + unotest \ + utl \ + sw \ + tl \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_ww8export3,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_ww8export3,\ + -I$(SRCDIR)/sw/inc \ + -I$(SRCDIR)/sw/source/core/inc \ + -I$(SRCDIR)/sw/qa/extras/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sw_ww8export3,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_ww8export3)) +$(eval $(call gb_CppunitTest_use_vcl,sw_ww8export3)) + +$(eval $(call gb_CppunitTest_use_rdb,sw_ww8export3,services)) + +$(eval $(call gb_CppunitTest_use_configuration,sw_ww8export3)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index cdc0b315b050..afb1c546e69b 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -78,6 +78,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_ooxmlimport \ CppunitTest_sw_ww8export \ CppunitTest_sw_ww8export2 \ + CppunitTest_sw_ww8export3 \ CppunitTest_sw_ww8import \ CppunitTest_sw_rtfexport \ CppunitTest_sw_rtfexport2 \ diff --git a/sw/qa/extras/ww8export/data/tdf94009_zeroPgMargin.odt b/sw/qa/extras/ww8export/data/tdf94009_zeroPgMargin.odt new file mode 100644 index 000000000000..e3143ec049f5 Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf94009_zeroPgMargin.odt differ diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx new file mode 100644 index 000000000000..8adc21445a6d --- /dev/null +++ b/sw/qa/extras/ww8export/ww8export3.cxx @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swmodeltestbase.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/text/XTextFramesSupplier.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> + +#include <drawdoc.hxx> + +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/extras/ww8export/data/", "MS Word 97") + { + } + + bool mustTestImportOf(const char* filename) const override + { + // If the testcase is stored in some other format, it's pointless to test. + return OString(filename).endsWith(".doc"); + } +}; +DECLARE_WW8EXPORT_TEST(testTdf94009_zeroPgMargin, "tdf94009_zeroPgMargin.odt") +{ + uno::Reference<beans::XPropertySet> defaultStyle(getStyles("PageStyles")->getByName("Standard"), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(defaultStyle, "TopMargin")); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index ec43c7a5c311..0bdc58b9a995 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -5422,6 +5422,8 @@ void AttributeOutputBase::OutputStyleItemSet( const SfxItemSet& rSet, bool bTest { if ( SfxItemState::SET == pSet->GetItemState( nWhich, true/*bDeep*/, &pItem ) && ( !bTestForDefault || + nWhich == RES_UL_SPACE || + nWhich == RES_LR_SPACE || *pItem != rPool.GetDefaultItem( nWhich ) || ( pSet->GetParent() && *pItem != pSet->GetParent()->Get( nWhich ) ) ) ) { commit ae30aa3ae49fca79d1989bb6df25cbbf80bec414 Author: Justin Luth <[email protected]> AuthorDate: Sat Aug 25 22:22:55 2018 +0300 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 10:13:00 2018 +0200 tdf#82177 docx export: no inside borders on outside cells Well, not on the bottom or right outside cells. Obviously the presence of a bottom or a right in those cases doesn't indicate an inside line. Reviewed-on: https://gerrit.libreoffice.org/59600 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> (cherry picked from commit cecf71c18da5430c10daa8522d38d5144edefc14) Change-Id: I5d0661fd60f478a392b12fe9093c2e47e130631b diff --git a/sw/qa/extras/ooxmlexport/data/tdf82177_outsideCellBorders.docx b/sw/qa/extras/ooxmlexport/data/tdf82177_outsideCellBorders.docx new file mode 100644 index 000000000000..75c9a656da06 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf82177_outsideCellBorders.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index f9c6524cafe8..ca518d554a29 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -344,6 +344,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf112118_DOCX, "tdf112118.docx") } } +DECLARE_OOXMLEXPORT_TEST(testTdf82177_outsideCellBorders, "tdf82177_outsideCellBorders.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 ); + uno::Reference< table::XCell > xCell = xTable->getCellByName( "E4" ); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), getProperty<table::BorderLine2>(xCell, "TopBorder").LineWidth); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), getProperty<table::BorderLine2>(xCell, "LeftBorder").LineWidth); +} + DECLARE_OOXMLEXPORT_TEST(testTdf119143, "tdf119143.docx") { // The runs inside <w:dir> were ignored diff --git a/sw/source/filter/ww8/WW8TableInfo.cxx b/sw/source/filter/ww8/WW8TableInfo.cxx index 00f55e075424..71fb8d1cd4d7 100644 --- a/sw/source/filter/ww8/WW8TableInfo.cxx +++ b/sw/source/filter/ww8/WW8TableInfo.cxx @@ -119,6 +119,10 @@ void WW8TableNodeInfoInner::setRect(const SwRect & rRect) maRect = rRect; } +bool WW8TableNodeInfoInner::isFinalRow() const +{ + return mpTable && mpTable->GetTabLines().size() - 1 == mnRow; +} const SwNode * WW8TableNodeInfoInner::getNode() const { diff --git a/sw/source/filter/ww8/WW8TableInfo.hxx b/sw/source/filter/ww8/WW8TableInfo.hxx index a3b6df799180..f2a2db21806a 100644 --- a/sw/source/filter/ww8/WW8TableInfo.hxx +++ b/sw/source/filter/ww8/WW8TableInfo.hxx @@ -94,6 +94,7 @@ public: bool isEndOfCell() const { return mbEndOfCell;} bool isEndOfLine() const { return mbEndOfLine;} bool isFinalEndOfLine() const { return mbFinalEndOfLine;} + bool isFinalRow() const; bool isFirstInTable() const { return mbFirstInTable;} const SwTableBox * getTableBox() const { return mpTableBox;} const SwTable * getTable() const { return mpTable;} diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 8f69ab6b2e27..5ada807693dc 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3044,8 +3044,13 @@ static OutputBorderOptions lcl_getBoxBorderOptions() return rOptions; } -static void impl_borders( FSHelperPtr const & pSerializer, const SvxBoxItem& rBox, const OutputBorderOptions& rOptions, - std::map<SvxBoxItemLine, css::table::BorderLine2> &rTableStyleConf ) +static void impl_borders( FSHelperPtr const & pSerializer, + const SvxBoxItem& rBox, + const OutputBorderOptions& rOptions, + std::map<SvxBoxItemLine, + css::table::BorderLine2> &rTableStyleConf, + const bool bIsLastColumn = false, + const bool bIsLastRow = false ) { static const SvxBoxItemLine aBorders[] = { @@ -3137,14 +3142,14 @@ static void impl_borders( FSHelperPtr const & pSerializer, const SvxBoxItem& rBo bWriteInsideV = true; } } - if (bWriteInsideH) + if (bWriteInsideH && !bIsLastRow) { const table::BorderLine2 *aStyleProps = nullptr; if( rTableStyleConf.find( SvxBoxItemLine::BOTTOM ) != rTableStyleConf.end() ) aStyleProps = &rTableStyleConf[ SvxBoxItemLine::BOTTOM ]; impl_borderLine( pSerializer, XML_insideH, rBox.GetLine(SvxBoxItemLine::BOTTOM), 0, false, aStyleProps ); } - if (bWriteInsideV) + if (bWriteInsideV && !bIsLastColumn) { const table::BorderLine2 *aStyleProps = nullptr; if( rTableStyleConf.find( SvxBoxItemLine::RIGHT ) != rTableStyleConf.end() ) @@ -3213,6 +3218,8 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point const SwTableBox *pTableBox = pTableTextNodeInfoInner->getTableBox( ); bool bEcma = GetExport().GetFilter().getVersion( ) == oox::core::ECMA_DIALECT; + const bool bIsLastColumn = pTableTextNodeInfoInner->isEndOfLine(); + const bool bIsLastRow = pTableTextNodeInfoInner->isFinalRow(); // Output any table cell redlines if there are any attached to this specific cell TableCellRedline( pTableTextNodeInfoInner ); @@ -3272,7 +3279,7 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point const SvxBoxItem& rDefaultBox = (*tableFirstCells.rbegin())->getTableBox( )->GetFrameFormat( )->GetBox( ); { // The cell borders - impl_borders( m_pSerializer, rBox, lcl_getTableCellBorderOptions(bEcma), m_aTableStyleConf ); + impl_borders( m_pSerializer, rBox, lcl_getTableCellBorderOptions(bEcma), m_aTableStyleConf, bIsLastColumn, bIsLastRow ); } TableBackgrounds( pTableTextNodeInfoInner ); commit 6636362374fc0f0a3dee7f33e5042d840277391e Author: Justin Luth <[email protected]> AuthorDate: Wed Aug 22 20:57:19 2018 +0300 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 10:13:00 2018 +0200 tdf#115670 vml shadow: shadow is off unless explicitly set on The absence of "on=" is treated in Word (tested 2003) as off. Change-Id: Ibc6b0e5ca0f25a9c3ca1b9505fa24c4d821bfd0 Reviewed-on: https://gerrit.libreoffice.org/59457 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> (cherry picked from commit b914c4c98bfca32168ff05fec7cc687c95754d36) diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index 9f43ac3e4c8f..dcaad56ceec4 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -385,7 +385,7 @@ ContextHandlerRef ShapeTypeContext::onCreateContext( sal_Int32 nElement, const A case VML_TOKEN( shadow ): { mrTypeModel.maShadowModel.mbHasShadow = true; - mrTypeModel.maShadowModel.moShadowOn.assignIfUsed(lclDecodeBool(rAttribs, XML_on)); + mrTypeModel.maShadowModel.moShadowOn = lclDecodeBool(rAttribs, XML_on).get(false); mrTypeModel.maShadowModel.moColor.assignIfUsed(rAttribs.getString(XML_color)); mrTypeModel.maShadowModel.moOffset.assignIfUsed(rAttribs.getString(XML_offset)); mrTypeModel.maShadowModel.moOpacity = lclDecodePercent(rAttribs, XML_opacity, 1.0); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 1888d3525e18..dc62f11523ae 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -560,6 +560,10 @@ DECLARE_OOXMLEXPORT_TEST(testTdf103982, "tdf103982.docx") sal_Int32 nDistB = getXPath(pXmlDoc, "//wp:anchor", "distB").toInt32(); // This was -260350, which is not a valid value for an unsigned type. CPPUNIT_ASSERT(nDistB >= 0); + + // tdf#115670 the shadow should not be enabled (no on="t") + uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(!getProperty<bool>(xPropertySet, "Shadow")); } DECLARE_OOXMLEXPORT_TEST(testTdf104115, "tdf104115.docx") commit 40fb5d6c34f88b4a43aedb6d3d7da0d7a5d5409b Author: Justin Luth <[email protected]> AuthorDate: Thu Aug 16 15:49:37 2018 +0300 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 10:12:59 2018 +0200 tdf#119232 ww8import: even page means default to start on page 2 I didn't see this mentioned in the sprm documentation, but that is how MS Word seems to implement it. Change-Id: I5b86ecf99a884e768877cdb0e71f43cdb9f2ad76 Reviewed-on: https://gerrit.libreoffice.org/59221 Reviewed-by: Justin Luth <[email protected]> Tested-by: Jenkins Reviewed-by: Miklos Vajna <[email protected]> (cherry picked from commit 2127581728ae61eca7470b288c21d1c02754fb5b) diff --git a/sw/qa/extras/ww8export/data/tdf119232_startEvenPage.doc b/sw/qa/extras/ww8export/data/tdf119232_startEvenPage.doc new file mode 100644 index 000000000000..c50bf46c0b58 Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf119232_startEvenPage.doc differ diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx index a076e1d4d3dc..fa69fb62736e 100644 --- a/sw/qa/extras/ww8export/ww8export2.cxx +++ b/sw/qa/extras/ww8export/ww8export2.cxx @@ -243,6 +243,11 @@ DECLARE_WW8EXPORT_TEST(testTdf112074_RTLtableJustification, "tdf112074_RTLtableJ CPPUNIT_ASSERT_MESSAGE("Table Indent is 3750", getProperty<long>(xTable, "LeftMargin") < 4000 ); } +DECLARE_WW8EXPORT_TEST(testTdf119232_startEvenPage, "tdf119232_startEvenPage.doc") +{ + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), getProperty<sal_Int16>(getParagraph(1), "PageNumberOffset")); +} + DECLARE_WW8EXPORT_TEST(testTdf104805, "tdf104805.doc") { uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WW8Num1"), uno::UNO_QUERY); diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 11cdf75f4412..d5d8813ce981 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -843,6 +843,8 @@ void wwSectionManager::CreateSep(const long nTextPos) const sal_uInt16* pIds = eVer <= ww::eWW2 ? aVer2Ids0 : eVer <= ww::eWW7 ? aVer67Ids0 : aVer8Ids0; + SprmResult aRes = pSep->HasSprm(pIds[0]); + const sal_uInt8* pSprmBkc = aRes.pSprm; if (!maSegments.empty()) { // Type of break: break codes are: @@ -851,8 +853,6 @@ void wwSectionManager::CreateSep(const long nTextPos) // 2 New page // 3 Even page // 4 Odd page - SprmResult aRes = pSep->HasSprm(pIds[0]); - const sal_uInt8* pSprmBkc = aRes.pSprm; if (pSprmBkc && aRes.nRemainingData >= 1) aNewSection.maSep.bkc = *pSprmBkc; } @@ -1005,7 +1005,13 @@ void wwSectionManager::CreateSep(const long nTextPos) aNewSection.maSep.pgnStart = ReadUSprm( pSep, pIds[7], 0 ); - SprmResult aRes; + // if the document's first page number is unspecified, but it starts with an even page break, + // then set the first page number to two + if ( maSegments.empty() && !aNewSection.maSep.fPgnRestart && pSprmBkc && *pSprmBkc == 3 ) + { + aNewSection.maSep.pgnStart = 2; + aNewSection.maSep.fPgnRestart = 1; + } if (eVer >= ww::eWW6) { commit 5063d9e7e677b0812ecfd81a5c4840fc1e58cbeb Author: Justin Luth <[email protected]> AuthorDate: Sat Aug 18 19:35:01 2018 +0300 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 09:56:11 2018 +0200 tdf#57589 writerfilter: support hash-encoded colors Previously, a hash-encoded value would simply fail to zero and thus the color would be dark black. The unit test covers two conditions. Paragraph 1 has a valid encoding, and pararaph 2 has an invalid coding (which is ignored and fails to COL_AUTO). Change-Id: I68940f5c4b0975a87feb6cab8fb3572b7546a077 Reviewed-on: https://gerrit.libreoffice.org/59295 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> (cherry picked from commit 7d01ce4021bafde8184355f46d1cbe2c370767e1) diff --git a/sw/qa/extras/ooxmlexport/data/tdf57589_hashColor.docx b/sw/qa/extras/ooxmlexport/data/tdf57589_hashColor.docx new file mode 100644 index 000000000000..d12b85b2da9c Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf57589_hashColor.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index ec6153369569..f9c6524cafe8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -42,6 +42,14 @@ protected: } }; +DECLARE_OOXMLEXPORT_TEST(testTdf57589_hashColor, "tdf57589_hashColor.docx") +{ + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(getParagraph(1), "FillStyle")); + CPPUNIT_ASSERT_EQUAL(COL_LIGHTMAGENTA, getProperty<sal_uInt32>(getParagraph(1), "ParaBackColor")); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(getParagraph(2), "FillStyle")); + CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<sal_uInt32>(getParagraph(2), "ParaBackColor")); +} + DECLARE_OOXMLEXPORT_TEST(testTdf92524_autoColor, "tdf92524_autoColor.doc") { CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(getParagraph(1), "FillStyle")); diff --git a/writerfilter/source/ooxml/OOXMLPropertySet.cxx b/writerfilter/source/ooxml/OOXMLPropertySet.cxx index 916c1b9a4902..79af27a96178 100644 --- a/writerfilter/source/ooxml/OOXMLPropertySet.cxx +++ b/writerfilter/source/ooxml/OOXMLPropertySet.cxx @@ -23,6 +23,7 @@ #include <ooxml/QNameToString.hxx> #include <com/sun/star/drawing/XShape.hpp> #include <oox/token/tokens.hxx> +#include <sax/tools/converter.hxx> #include <tools/color.hxx> namespace writerfilter { @@ -590,6 +591,20 @@ OOXMLHexColorValue::OOXMLHexColorValue(const char * pValue) else { mnValue = rtl_str_toUInt32(pValue, 16); + + // Convert hash-encoded values (like #FF0080) + const sal_Int32 nLen = strlen(pValue); + if ( !mnValue && nLen > 1 && pValue[0] == '#' ) + { + sal_Int32 nColor(COL_AUTO); + // Word appears to require strict 6 digit length, else it ignores it + if ( nLen == 7 ) + { + const OUString sHashColor(pValue, nLen, RTL_TEXTENCODING_ASCII_US); + sax::Converter::convertColor( nColor, sHashColor ); + } + mnValue = nColor; + } } } commit 43816e78744afdddd5116d8d598fcdd2f3e8767c Author: László Németh <[email protected]> AuthorDate: Mon Jul 30 21:22:23 2018 +0200 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 09:43:35 2018 +0200 tdf#37223 insert OLE tables in text tables as native text tables to solve the long-standing problem of Calc/Writer integration, ie. now Calc table data are inserted cell by cell in Writer text tables instead of putting an unwanted second table over the original, as an OLE object. First insert the OLE table as a nested native table using paste special as RTF, and cut and paste that to get a native table insertion, removing also the temporary nested table. This fix has got correct undo, but unfortunately, also a small flash during insertion by the temporary nested table. I've tried to fix that by LockView and LockModify, but it seems, they don't help. Note: the planned solution mentioned in the original OOo issue (reported in 2004) suggested to use a hidden temporary document, but that has got poblems with clipboard usage. Change-Id: I49253239f1878bce5fc4c93494f997ed37101a1c Reviewed-on: https://gerrit.libreoffice.org/58346 Tested-by: Jenkins Reviewed-by: László Németh <[email protected]> (cherry picked from commit 80d3d1044a1ad921bff990e2c4bb4dbf7c0a35c6) diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index e82f6d95cb70..a89182f0f8ee 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -1154,9 +1154,11 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt &nActionFlags ); } + bool bInsertOleTable = ( EXCHG_OUT_ACTION_INSERT_OLE == nAction && ( rData.HasFormat( SotClipboardFormatId::SYLK ) || + rData.HasFormat( SotClipboardFormatId::SYLK_BIGCAPS ) ) ); + // content of 1-cell tables is inserted as simple text - if( EXCHG_OUT_ACTION_INSERT_OLE == nAction && ( rData.HasFormat( SotClipboardFormatId::SYLK ) || - rData.HasFormat( SotClipboardFormatId::SYLK_BIGCAPS ) ) ) + if (bInsertOleTable) { OUString aExpand; if( rData.GetString( SotClipboardFormatId::STRING, aExpand )) @@ -1172,8 +1174,11 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt } } + bool bInsertOleTableInTable = (bInsertOleTable && !bSingleCellTable && + (rSh.GetDoc()->IsIdxInTable(rSh.GetCursor()->GetNode()) != nullptr)); + // special case for tables from draw application or 1-cell tables - if( EXCHG_OUT_ACTION_INSERT_DRAWOBJ == nAction || bSingleCellTable ) + if( EXCHG_OUT_ACTION_INSERT_DRAWOBJ == nAction || bSingleCellTable || bInsertOleTableInTable ) { if( rData.HasFormat( SotClipboardFormatId::RTF ) ) { @@ -1187,6 +1192,26 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt } } + // tdf#37223 insert OLE table in text tables as a native text table + // (first as an RTF nested table, and cut and paste that to get a + // native table insertion, removing also the temporary nested table) + // TODO set a working view lock to avoid of showing the temporary nested table for a moment + if (bInsertOleTableInTable && EXCHG_OUT_ACTION_INSERT_STRING == nAction) + { + bool bPasted = SwTransferable::PasteData( rData, rSh, nAction, nActionFlags, nFormat, + nDestination, false, false, nullptr, 0, false, nAnchorType ); + if (bPasted && rSh.DoesUndo()) + { + SfxDispatcher* pDispatch = rSh.GetView().GetViewFrame()->GetDispatcher(); + pDispatch->Execute(FN_PREV_TABLE, SfxCallMode::SYNCHRON); + pDispatch->Execute(FN_TABLE_SELECT_ALL, SfxCallMode::SYNCHRON); + pDispatch->Execute(SID_COPY, SfxCallMode::SYNCHRON); + pDispatch->Execute(SID_UNDO, SfxCallMode::SYNCHRON); + pDispatch->Execute(SID_PASTE, SfxCallMode::SYNCHRON); + } + return bPasted; + } + return EXCHG_INOUT_ACTION_NONE != nAction && SwTransferable::PasteData( rData, rSh, nAction, nActionFlags, nFormat, nDestination, false, false, nullptr, 0, false, nAnchorType ); commit e299a443d67d16a41a82457a660afe28364b7c90 Author: László Németh <[email protected]> AuthorDate: Fri Jul 20 17:49:21 2018 +0200 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 09:43:34 2018 +0200 tdf#37223 Writer: insert 1-cell tables as text instead of OLE object to get a user-friendly solution to copy Calc cell content to a text document and to its native tables. NOTE: MSO does the same for copying 1-cell tables, while LibreOffice was able to do this only with paste special as RTF. Change-Id: I6156333055aa9bed4cf56ff12f913e89d3f5700c Reviewed-on: https://gerrit.libreoffice.org/57783 Tested-by: Jenkins Reviewed-by: László Németh <[email protected]> (cherry picked from commit b9d18daf5b23155a9b4dfcdd5d1f23ed53bc3849) diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 8618a05ca217..e82f6d95cb70 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -1128,6 +1128,7 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt SotExchangeDest nDestination = SwTransferable::GetSotDestination( rSh ); SotClipboardFormatId nFormat = SotClipboardFormatId::NONE; SotExchangeActionFlags nActionFlags = SotExchangeActionFlags::NONE; + bool bSingleCellTable = false; if( GetSwTransferable( rData ) ) { @@ -1153,8 +1154,26 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt &nActionFlags ); } - // special case for tables from draw application - if( EXCHG_OUT_ACTION_INSERT_DRAWOBJ == nAction ) + // content of 1-cell tables is inserted as simple text + if( EXCHG_OUT_ACTION_INSERT_OLE == nAction && ( rData.HasFormat( SotClipboardFormatId::SYLK ) || + rData.HasFormat( SotClipboardFormatId::SYLK_BIGCAPS ) ) ) + { + OUString aExpand; + if( rData.GetString( SotClipboardFormatId::STRING, aExpand )) + { + const sal_Int32 nNewlines{comphelper::string::getTokenCount(aExpand, '\n')}; + const sal_Int32 nRows = nNewlines ? nNewlines-1 : 0; + if ( nRows == 1 ) + { + const sal_Int32 nCols = comphelper::string::getTokenCount(aExpand.getToken(0, '\n'), '\t'); + if (nCols == 1) + bSingleCellTable = true; + } + } + } + + // special case for tables from draw application or 1-cell tables + if( EXCHG_OUT_ACTION_INSERT_DRAWOBJ == nAction || bSingleCellTable ) { if( rData.HasFormat( SotClipboardFormatId::RTF ) ) { commit 84a1586d55b29b7bf9d733f3e8233dfbdc4beb21 Author: László Németh <[email protected]> AuthorDate: Tue Jul 10 13:03:58 2018 +0200 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 09:43:33 2018 +0200 tdf#118533 fix shape import: zero top margin only in first paragraph commit 0307a62790b33ee0c02c2323a8f759e53e2035a4 fixed the top margin import of the paragraphs of document sections, and import of first paragraph of the text frames with beforeAutospacing, but nullified all other paragraph top margins in frames. Note: there is no visible margin difference in the unit test (extended by this commit) before and after the fix, because the first paragraph uses also afterAutospacing, resulting still 14pt paragraph space. But the tested beforeAutospacing value of the next paragraph checks the fix correctly. Change-Id: I0ab3b8bbff33c5488f4b4af1ea4dabf7105103f2 Reviewed-on: https://gerrit.libreoffice.org/57231 Reviewed-by: László Németh <[email protected]> Tested-by: László Németh <[email protected]> (cherry picked from commit 970eaaf1bdade63fd651db591c683e36e662f8f5) diff --git a/sw/qa/extras/ooxmlexport/data/tdf104354.docx b/sw/qa/extras/ooxmlexport/data/tdf104354.docx index 8645743f1fc1..d8655f4e0874 100644 Binary files a/sw/qa/extras/ooxmlexport/data/tdf104354.docx and b/sw/qa/extras/ooxmlexport/data/tdf104354.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 57c0296b1bd9..ec6153369569 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -231,6 +231,9 @@ DECLARE_OOXMLEXPORT_TEST(testTdf104354, "tdf104354.docx") // margin for the first paragraph in a text frame. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(xShape->getStart(), "ParaTopMargin")); + // still 494 in the second paragraph + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), + getProperty<sal_Int32>(xShape->getEnd(), "ParaTopMargin")); } DECLARE_OOXMLEXPORT_TEST(testTdf107035, "tdf107035.docx") diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index beb43a5c07f9..499f402d8ad7 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -669,8 +669,9 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) default_spacing = 49; else { - // tdf#104354 fist paragraph has got zero top margin - if (m_pImpl->GetIsFirstParagraphInSection()) + // tdf#104354, tdf#118533 first paragraph of sections and shapes got zero top margin + if ((m_pImpl->GetIsFirstParagraphInSection() && !m_pImpl->IsInShape()) || + m_pImpl->GetIsFirstParagraphInShape()) default_spacing = 0; else default_spacing = 280; commit 57626bd356f7e01bf5a88a204638ba1687ed545f Author: László Németh <[email protected]> AuthorDate: Fri Jun 29 22:34:21 2018 +0200 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 09:43:33 2018 +0200 tdf#118533 RTF/DOCX import: fix beforeAutospacing for first paragraph of a text frame (first bug of tdf#104354), a table cell or a document by setting zero top margin here. This bug could result non visible paragraph content in narrow frames, as in the test document of the commit. See also commit f737c9386a605cb7d8c9dbc210c557f98f6cdc19 for a similar fix for first paragraph of a shape. Fix top margins of the first paragraphs of the affected tdf#82006 and tdf#107480, adding also new paragraphs to their RTF tests cases to keep the original tests, too. Reviewed-on: https://gerrit.libreoffice.org/56737 Reviewed-by: László Németh <[email protected]> Tested-by: László Németh <[email protected]> (cherry picked from commit 0307a62790b33ee0c02c2323a8f759e53e2035a4) Change-Id: Iea3c735eeb262233b82090fb9491991ed2df2b4e diff --git a/sw/qa/extras/ooxmlexport/data/tdf104354.docx b/sw/qa/extras/ooxmlexport/data/tdf104354.docx new file mode 100644 index 000000000000..8645743f1fc1 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf104354.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 8ef107f51f0e..57c0296b1bd9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -224,6 +224,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf44832_testSectionWithDifferentHeader, "tdf44832_ assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:headerReference", 1); } +DECLARE_OOXMLEXPORT_TEST(testTdf104354, "tdf104354.docx") +{ + uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY); + // This was 494, i.e. automatic spacing resulted in non-zero paragraph top + // margin for the first paragraph in a text frame. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), + getProperty<sal_Int32>(xShape->getStart(), "ParaTopMargin")); +} + DECLARE_OOXMLEXPORT_TEST(testTdf107035, "tdf107035.docx") { // Select the second run containing the page number field diff --git a/sw/qa/extras/rtfexport/data/fdo82006.rtf b/sw/qa/extras/rtfexport/data/fdo82006.rtf index e108d4ceb189..b20ef835244b 100644 --- a/sw/qa/extras/rtfexport/data/fdo82006.rtf +++ b/sw/qa/extras/rtfexport/data/fdo82006.rtf @@ -1,4 +1,5 @@ {\rtf1\htmautsp \pard\plain \ql \sb100\sa100\sbauto1\saauto1 hello\par +hello2\par } diff --git a/sw/qa/extras/rtfexport/data/tdf107480.rtf b/sw/qa/extras/rtfexport/data/tdf107480.rtf index 2edd895e02ab..a11bee98aff6 100644 --- a/sw/qa/extras/rtfexport/data/tdf107480.rtf +++ b/sw/qa/extras/rtfexport/data/tdf107480.rtf @@ -13,4 +13,5 @@ \htmautsp \pard\plain \s3 \sbauto1\saauto1 1.\par +2.\par } diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 576bfea43398..b59e0c6efc6e 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -1012,10 +1012,15 @@ DECLARE_RTFEXPORT_TEST(testNumOverrideStart, "num-override-start.rtf") DECLARE_RTFEXPORT_TEST(testFdo82006, "fdo82006.rtf") { // These were 176 (100 twips), as \sbauto and \sbbefore were ignored. - CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)), + // Exception: first paragraph gets zero top margin, see also tdf#104354. + CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(0)), getProperty<sal_Int32>(getParagraph(1), "ParaTopMargin")); CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)), + getProperty<sal_Int32>(getParagraph(2), "ParaTopMargin")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)), + getProperty<sal_Int32>(getParagraph(2), "ParaBottomMargin")); } DECLARE_RTFEXPORT_TEST(testTdf104081, "tdf104081.rtf") @@ -1450,10 +1455,15 @@ DECLARE_RTFEXPORT_TEST(testTdf112507, "tdf112507.rtf") DECLARE_RTFEXPORT_TEST(testTdf107480, "tdf107480.rtf") { // These were 176 (100 twips), as \htmautsp was parsed too late. - CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)), + // Exception: first paragraph gets zero top margin, see also tdf#104354. + CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(0)), getProperty<sal_Int32>(getParagraph(1), "ParaTopMargin")); CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)), + getProperty<sal_Int32>(getParagraph(2), "ParaTopMargin")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)), + getProperty<sal_Int32>(getParagraph(2), "ParaBottomMargin")); } DECLARE_RTFEXPORT_TEST(testWatermark, "watermark.rtf") diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 8aabcd02bce2..beb43a5c07f9 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -668,7 +668,13 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) if (m_pImpl->GetSettingsTable()->GetView() == NS_ooxml::LN_Value_doc_ST_View_web) default_spacing = 49; else - default_spacing = 280; + { + // tdf#104354 fist paragraph has got zero top margin + if (m_pImpl->GetIsFirstParagraphInSection()) + default_spacing = 0; + else + default_spacing = 280; + } } if (nIntValue) // If auto spacing is set, then only store set value in InteropGrabBag { commit a29b9286896e4e236041a86bf2bbad1bc6d95ca9 Author: László Németh <[email protected]> AuthorDate: Tue Jun 26 15:01:05 2018 +0200 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 09:43:32 2018 +0200 tdf#107690 DOCX, XLSX and PPTX unit tests for "Open as read-only" ie. OOXML export/import of "_MarkAsFinal" MSO document property. Reviewed-on: https://gerrit.libreoffice.org/56475 Tested-by: Jenkins Reviewed-by: László Németh <[email protected]> (cherry picked from commit bbdb6cb8ed0d77eeb2e413b38f29d2084bd8257b) Change-Id: I01f0702d5467e78eb93ce8dce8ba25874839c3e3 diff --git a/sc/qa/unit/data/xlsx/open-as-read-only.xlsx b/sc/qa/unit/data/xlsx/open-as-read-only.xlsx new file mode 100644 index 000000000000..e871a95d3997 Binary files /dev/null and b/sc/qa/unit/data/xlsx/open-as-read-only.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index b872e3bfb570..a071b12b7493 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -207,7 +207,7 @@ public: void testHiddenRepeatedRowsODS(); void testHyperlinkTargetFrameODS(); - + void testOpenDocumentAsReadOnly(); void testTdf118990(); CPPUNIT_TEST_SUITE(ScExportTest); @@ -316,7 +316,7 @@ public: CPPUNIT_TEST(testHiddenRepeatedRowsODS); CPPUNIT_TEST(testHyperlinkTargetFrameODS); - + CPPUNIT_TEST(testOpenDocumentAsReadOnly); CPPUNIT_TEST(testTdf118990); CPPUNIT_TEST_SUITE_END(); @@ -4047,6 +4047,16 @@ void ScExportTest::testHyperlinkTargetFrameODS() CPPUNIT_ASSERT_EQUAL(OUString("_blank"), aTargetFrameExport); } +void ScExportTest::testOpenDocumentAsReadOnly() +{ + ScDocShellRef xDocSh = loadDoc("open-as-read-only.", FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh->IsSecurityOptOpenReadOnly()); + ScDocShellRef xDocSh2 = saveAndReload(xDocSh.get(), FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh2->IsSecurityOptOpenReadOnly()); + xDocSh->DoClose(); + xDocSh2->DoClose(); +} + void ScExportTest::testTdf118990() { ScDocShellRef xDocSh = loadDoc("tdf118990.", FORMAT_XLSX); diff --git a/sd/qa/unit/data/pptx/open-as-read-only.pptx b/sd/qa/unit/data/pptx/open-as-read-only.pptx new file mode 100644 index 000000000000..57a4d32de7f4 Binary files /dev/null and b/sd/qa/unit/data/pptx/open-as-read-only.pptx differ diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index cdf638d841bd..4cf1e8e3e2c2 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -141,6 +141,8 @@ public: void testTdf104786(); void testTdf104789(); void testTdf116350TextEffects(); + void testOpenDocumentAsReadOnly(); + CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); @@ -205,6 +207,7 @@ public: CPPUNIT_TEST(testTdf104786); CPPUNIT_TEST(testTdf104789); CPPUNIT_TEST(testTdf116350TextEffects); + CPPUNIT_TEST(testOpenDocumentAsReadOnly); CPPUNIT_TEST_SUITE_END(); @@ -1702,6 +1705,16 @@ void SdOOXMLExportTest2::testTdf116350TextEffects() xDocShRef->DoClose(); } +void SdOOXMLExportTest2::testOpenDocumentAsReadOnly() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/open-as-read-only.pptx"), PPTX); + CPPUNIT_ASSERT(xDocShRef->IsSecurityOptOpenReadOnly()); + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + CPPUNIT_ASSERT(xDocShRef->IsSecurityOptOpenReadOnly()); + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/ooxmlexport/data/open-as-read-only.docx b/sw/qa/extras/ooxmlexport/data/open-as-read-only.docx new file mode 100644 index 000000000000..057c67ff6dfe Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/open-as-read-only.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index f60a3167efbd..8ef107f51f0e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -344,6 +344,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf119143, "tdf119143.docx") sParaText); } +DECLARE_OOXMLEXPORT_TEST(testOpenDocumentAsReadOnly, "open-as-read-only.docx") +{ + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + CPPUNIT_ASSERT(pTextDoc->GetDocShell()->IsSecurityOptOpenReadOnly()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 3d6ae0441a8eee97e0e5eeff491245055680b829 Author: László Németh <[email protected]> AuthorDate: Wed Jun 20 16:28:13 2018 +0200 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 09:43:32 2018 +0200 tdf#107690 OOXML import/export of setting "Open as read-only" Import custom document property _MarkAsFinal as LoadReadonly setting, export LoadReadonly as _MarkAsFinal in DOCX, XLSX and PPTX documents. Before this fix, LibreOffice opened read-only OOXML documents as editable, also saved and exported _MarkAsFinal=true silently, resulting unintented read-only warning info bar in MSO. This commit improves interoperability a lot, because this is a basic document protection of MSO, recommended on its UI. Note: LoadReadonly (on File->Properties...->Security, property "Open file read-only") doesn't show "Edit read-only" info bar from commit 630186ff4e0eba7317e542f8c3eca39ebd068721, but it's still possible to switch on editing by Edit->Edit Mode. MSO shows info bar for _MarkAsFinal. (There is an advantage to hide the info bar in LibreOffice in a mixed environment, to avoid overwriting of press-ready MSO files by LibreOffice.) Note 2: Other differences of LoadReadonly in LO and _MarkAsFinal in MSO: (1) Switching on editing doesn't remove the LoadReadonly property automatically in LO. (2) Saving with LoadReadonly doesn't switch off editing of the actual (still opened) document in LO. Reviewed-on: https://gerrit.libreoffice.org/56180 Tested-by: Jenkins Reviewed-by: László Németh <[email protected]> (cherry picked from commit 9a5c56a9c4e04589b0a6bb710573922e459d9685) Change-Id: Ie279c0670090d075103384cfa44ff1c2a2898216 diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx index 69586fe020bb..26c4b4b9d5fc 100644 --- a/include/oox/core/xmlfilterbase.hxx +++ b/include/oox/core/xmlfilterbase.hxx @@ -224,7 +224,7 @@ public: @param xProperties The document properties to export. */ - void exportDocumentProperties( const css::uno::Reference< css::document::XDocumentProperties >& xProperties ); + void exportDocumentProperties( const css::uno::Reference< css::document::XDocumentProperties >& xProperties, bool bSecurityOptOpenReadOnly ); /** Write the customXml entries we are preserving (xlsx and pptx only). */ void exportCustomFragments(); diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 39a5858ae642..7ac97f4b3705 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -751,13 +751,31 @@ writeAppProperties( XmlFilterBase& rSelf, const Reference< XDocumentProperties > } static void -writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentProperties >& xProperties ) +writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentProperties >& xProperties, bool bSecurityOptOpenReadOnly ) { uno::Reference<beans::XPropertyAccess> xUserDefinedProperties( xProperties->getUserDefinedProperties(), uno::UNO_QUERY ); Sequence< PropertyValue > aprop( xUserDefinedProperties->getPropertyValues() ); sal_Int32 nbCustomProperties = aprop.getLength(); // tdf#89791 : if no custom properties, no need to add docProps/custom.x - if (!nbCustomProperties) + // tdf#107690: except the case of read-only documents, because that + // is handled by the _MarkAsFinal custom property in MSO. + if (!nbCustomProperties && !bSecurityOptOpenReadOnly) + return; + + std::vector<PropertyValue> aprop2; + for ( sal_Int32 n = 0; n < nbCustomProperties; ++n ) + aprop2.push_back(aprop[n]); + + if (bSecurityOptOpenReadOnly) + { + PropertyValue aPropertyValue; + // MSO custom property for read-only documents + aPropertyValue.Name = "_MarkAsFinal"; + aPropertyValue.Value <<= true; + aprop2.push_back(aPropertyValue); + } + + if (!aprop2.size()) return; rSelf.addRelation( @@ -771,11 +789,12 @@ writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentPropertie FSNS( XML_xmlns, XML_vt ), OUStringToOString(rSelf.getNamespaceURL(OOX_NS(officeDocPropsVT)), RTL_TEXTENCODING_UTF8).getStr(), FSEND ); - for ( sal_Int32 n = 0; n < nbCustomProperties; ++n ) + auto aIt = aprop2.begin(); + for ( size_t n = 0; n < aprop2.size(); ++n ) { - if ( !aprop[n].Name.isEmpty() ) + if ( !aIt->Name.isEmpty() ) { - OString aName = OUStringToOString( aprop[n].Name, RTL_TEXTENCODING_ASCII_US ); + OString aName = OUStringToOString( aIt->Name, RTL_TEXTENCODING_ASCII_US ); // pid starts from 2 not from 1 as MS supports pid from 2 pAppProps->startElement( XML_property , XML_fmtid, "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}", @@ -783,18 +802,18 @@ writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentPropertie XML_name, aName, FSEND); - switch ( ( aprop[n].Value ).getValueTypeClass() ) + switch ( aIt->Value.getValueTypeClass() ) { case TypeClass_STRING: { OUString aValue; - aprop[n].Value >>= aValue; - writeElement( pAppProps, FSNS( XML_vt, XML_lpwstr ), aValue ); + aIt->Value >>= aValue; + writeElement( pAppProps, FSNS( XML_vt, XML_lpwstr ), aValue ); } break; case TypeClass_BOOLEAN: { - bool val = *o3tl::forceAccess<bool>(aprop[n].Value); + bool val = *o3tl::forceAccess<bool>(aIt->Value); writeElement( pAppProps, FSNS( XML_vt, XML_bool ), val ? 1 : 0); } break; @@ -804,23 +823,23 @@ writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentPropertie util::Date aDate; util::Duration aDuration; util::DateTime aDateTime; - if ( ( aprop[n].Value ) >>= num ) + if ( ( aIt->Value ) >>= num ) { writeElement( pAppProps, FSNS( XML_vt, XML_i4 ), num ); } - else if ( ( aprop[n].Value ) >>= aDate ) + else if ( ( aIt->Value ) >>= aDate ) { aDateTime = util::DateTime( 0, 0 , 0, 0, aDate.Year, aDate.Month, aDate.Day, true ); writeElement( pAppProps, FSNS( XML_vt, XML_filetime ), aDateTime); } - else if ( ( aprop[n].Value ) >>= aDuration ) + else if ( ( aIt->Value ) >>= aDuration ) { OUStringBuffer buf; ::sax::Converter::convertDuration( buf, aDuration ); OUString aDurationStr = buf.makeStringAndClear(); writeElement( pAppProps, FSNS( XML_vt, XML_lpwstr ), aDurationStr ); } - else if ( ( aprop[n].Value ) >>= aDateTime ) + else if ( ( aIt->Value ) >>= aDateTime ) writeElement( pAppProps, FSNS( XML_vt, XML_filetime ), aDateTime ); else //no other options @@ -830,17 +849,18 @@ writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentPropertie } pAppProps->endElement( XML_property ); } + ++aIt; } pAppProps->endElement( XML_Properties ); } -void XmlFilterBase::exportDocumentProperties( const Reference< XDocumentProperties >& xProperties ) +void XmlFilterBase::exportDocumentProperties( const Reference< XDocumentProperties >& xProperties, bool bSecurityOptOpenReadOnly ) { if( xProperties.is() ) { writeCoreProperties( *this, xProperties ); writeAppProperties( *this, xProperties ); - writeCustomProperties( *this, xProperties ); + writeCustomProperties( *this, xProperties, bSecurityOptOpenReadOnly ); } } diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx index bc0d4e3de177..50b6d0ffb47b 100644 --- a/sc/source/filter/excel/excdoc.cxx +++ b/sc/source/filter/excel/excdoc.cxx @@ -830,7 +830,7 @@ void ExcDocument::WriteXml( XclExpXmlStream& rStrm ) uno::Reference<document::XDocumentPropertiesSupplier> xDPS( pDocShell->GetModel(), uno::UNO_QUERY_THROW ); uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties(); - rStrm.exportDocumentProperties(xDocProps); + rStrm.exportDocumentProperties(xDocProps, pDocShell->IsSecurityOptOpenReadOnly()); rStrm.exportCustomFragments(); sax_fastparser::FSHelperPtr& rWorkbook = rStrm.GetCurrentStream(); diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index 08551dc325fa..f08b71d91d23 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -358,7 +358,19 @@ void PowerPointExport::writeDocumentProperties() uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties(); if (xDocProps.is()) - exportDocumentProperties(xDocProps); + { + bool bSecurityOptOpenReadOnly = false; + uno::Reference< lang::XMultiServiceFactory > xFactory(mXModel, uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xSettings(xFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); + try + { + xSettings->getPropertyValue("LoadReadonly") >>= bSecurityOptOpenReadOnly; + } + catch( Exception& ) + { + } + exportDocumentProperties(xDocProps, bSecurityOptOpenReadOnly); + } exportCustomFragments(); } diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index dad9c424891c..ad0ffb937416 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -2250,6 +2250,33 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium, } } } + + // tdf#107690 import custom document property _MarkAsFinal as SecurityOptOpenReadonly + // (before this fix, LibreOffice opened read-only OOXML documents as editable, + // also saved and exported _MarkAsFinal=true silently, resulting unintented read-only + // warning info bar in MSO) + uno::Reference< document::XDocumentPropertiesSupplier > xPropSupplier(GetModel(), uno::UNO_QUERY_THROW); + uno::Reference<document::XDocumentProperties> xDocProps = xPropSupplier->getDocumentProperties() ; + uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocProps->getUserDefinedProperties(); + if (xPropertyContainer.is()) + { + uno::Reference<beans::XPropertySet> xPropertySet(xPropertyContainer, uno::UNO_QUERY); + if (xPropertySet.is()) + { + uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo(); + if (xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName("_MarkAsFinal")) + { + if (xPropertySet->getPropertyValue("_MarkAsFinal").get<bool>()) + { + uno::Reference< lang::XMultiServiceFactory > xFactory(GetModel(), uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xSettings(xFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); + xSettings->setPropertyValue("LoadReadonly", uno::makeAny(true)); + } + xPropertyContainer->removeProperty("_MarkAsFinal"); + } + } + } + return bRtn; } catch (const packages::zip::ZipIOException&) diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 952561d31141..becf669cf2fc 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -886,14 +886,16 @@ void DocxExport::WriteProperties( ) // Write the core properties SwDocShell* pDocShell( m_pDoc->GetDocShell( ) ); uno::Reference<document::XDocumentProperties> xDocProps; + bool bSecurityOptOpenReadOnly = false; if ( pDocShell ) { uno::Reference<document::XDocumentPropertiesSupplier> xDPS( pDocShell->GetModel( ), uno::UNO_QUERY ); xDocProps = xDPS->getDocumentProperties(); + bSecurityOptOpenReadOnly = pDocShell->IsSecurityOptOpenReadOnly(); } - m_pFilter->exportDocumentProperties( xDocProps ); + m_pFilter->exportDocumentProperties( xDocProps, bSecurityOptOpenReadOnly ); } void DocxExport::WriteSettings() commit 6685a3b6fb1e4e3c6e109904d0d20fcd00c3e470 Author: László Németh <[email protected]> AuthorDate: Mon Jun 18 17:29:11 2018 +0200 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 09:43:31 2018 +0200 filter clean-up: remove duplicate of checking EMF magic header Change-Id: I63fd380be974c1d15beef0d2cfec42350119ae2f Reviewed-on: https://gerrit.libreoffice.org/56050 Tested-by: Jenkins Reviewed-by: László Németh <[email protected]> (cherry picked from commit 4188a037fbaf3618df26e1661a4586483036f055) diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 98a961f63836..6256032ff665 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -4208,22 +4208,18 @@ sal_uInt32 EscherGraphicProvider::GetBlibID( SvStream& rPicOutStrm, const OStrin case GfxLinkType::NativeWmf : { - if ( pGraphicAry && ( p_EscherBlibEntry->mnSize > 0x2c ) ) + if ( aGraphicLink.IsEMF() ) { - if ( ( pGraphicAry[ 0x28 ] == 0x20 ) && ( pGraphicAry[ 0x29 ] == 0x45 ) // check the magic - && ( pGraphicAry[ 0x2a ] == 0x4d ) && ( pGraphicAry[ 0x2b ] == 0x46 ) ) // number ( emf detection ) - { - p_EscherBlibEntry->meBlibType = EMF; - } - else - { - p_EscherBlibEntry->meBlibType = WMF; - if ( ( pGraphicAry[ 0 ] == 0xd7 ) && ( pGraphicAry[ 1 ] == 0xcd ) - && ( pGraphicAry[ 2 ] == 0xc6 ) && ( pGraphicAry[ 3 ] == 0x9a ) ) - { // we have to get rid of the metafileheader - pGraphicAry += 22; - p_EscherBlibEntry->mnSize -= 22; - } + p_EscherBlibEntry->meBlibType = EMF; + } + else if ( pGraphicAry && ( p_EscherBlibEntry->mnSize > 0x2c ) ) + { + p_EscherBlibEntry->meBlibType = WMF; + if ( ( pGraphicAry[ 0 ] == 0xd7 ) && ( pGraphicAry[ 1 ] == 0xcd ) + && ( pGraphicAry[ 2 ] == 0xc6 ) && ( pGraphicAry[ 3 ] == 0x9a ) ) + { // we have to get rid of the metafileheader + pGraphicAry += 22; + p_EscherBlibEntry->mnSize -= 22; } } } commit 083a7eb44be5a2603a21ce61a294cf02cf1a0368 Author: Adam Kovacs <[email protected]> AuthorDate: Mon Sep 3 11:05:44 2018 -0400 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 09:43:30 2018 +0200 tdf#108064 OOXML export: keep preset dashes with any line width Change-Id: I496e1cbac527383837a4e8fcdee42967ecf555e4 Reviewed-on: https://gerrit.libreoffice.org/59968 Tested-by: Jenkins Reviewed-by: László Németh <[email protected]> (cherry picked from commit f3d6c44c9cb533fe4f1cd28fc95adc36cac4bfd5) diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 8c800eec1fdb..ddea4d2a168b 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -696,35 +696,51 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet ) if( bDashSet && aStyleLineStyle != drawing::LineStyle_DASH ) { - // keep default preset linestyles (instead of custdash) - if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && aLineDash.Dashes == 0 && aLineDash.DashLen == 0 && aLineDash.Distance == 141) + // convert absolute dash/dot length to relative length + int relDotLen = aLineDash.DotLen / nLineWidth; + int relDashLen = aLineDash.DashLen / nLineWidth; + int relDistance = aLineDash.Distance / nLineWidth; + // keep default mso preset linestyles (instead of custdash) + if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 0 && relDashLen == 0 && relDistance == 3) { - mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDot", FSEND); - } - else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && aLineDash.Dashes == 1 && aLineDash.DashLen == 423 && aLineDash.Distance == 141) - { - mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDash", FSEND); + mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dot", FSEND); } - else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && aLineDash.Dashes == 1 && aLineDash.DashLen == 564 && aLineDash.Distance == 423) + else if (aLineDash.Dots == 0 && relDotLen == 0 && aLineDash.Dashes == 1 && relDashLen == 4 && relDistance == 3) { mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dash", FSEND); } - else if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && aLineDash.Dashes == 1 && aLineDash.DashLen == 564 && aLineDash.Distance == 423) + else if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 1 && relDashLen == 4 && relDistance == 3) { mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dashDot", FSEND); } - else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423) + else if (aLineDash.Dots == 0 && relDotLen == 0 && aLineDash.Dashes == 1 && relDashLen == 8 && relDistance == 3) { mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDash", FSEND); } - else if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423) + else if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 1 && relDashLen == 8 && relDistance == 3) { mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDashDot", FSEND); } - else if (aLineDash.Dots == 2 && aLineDash.DotLen == 141 && aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423) + else if (aLineDash.Dots == 2 && relDotLen == 1 && aLineDash.Dashes == 1 && relDashLen == 8 && relDistance == 3) { mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDashDotDot", FSEND); } + else if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 0 && relDashLen == 0 && relDistance == 1) + { + mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDot", FSEND); + } + else if (aLineDash.Dots == 0 && relDotLen == 0 && aLineDash.Dashes == 1 && relDashLen == 3 && relDistance == 1) + { + mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDash", FSEND); + } + else if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 1 && relDashLen == 3 && relDistance == 1) + { + mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDashDot", FSEND); + } + else if (aLineDash.Dots == 2 && relDotLen == 1 && aLineDash.Dashes == 1 && relDashLen == 3 && relDistance == 1) + { + mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDashDotDot", FSEND); + } else { mpFS->startElementNS( XML_a, XML_custDash, FSEND ); diff --git a/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx b/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx index d7997ddc63c6..11b5788317c1 100644 Binary files a/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx and b/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/dashed_line_custdash_1000th_of_percent.docx b/sw/qa/extras/ooxmlexport/data/dashed_line_custdash_1000th_of_percent.docx index d9a922819f68..643ec08ea468 100644 Binary files a/sw/qa/extras/ooxmlexport/data/dashed_line_custdash_1000th_of_percent.docx and b/sw/qa/extras/ooxmlexport/data/dashed_line_custdash_1000th_of_percent.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/dashed_line_custdash_percentage.docx b/sw/qa/extras/ooxmlexport/data/dashed_line_custdash_percentage.docx index a1d0e7db6d63..643ec08ea468 100644 Binary files a/sw/qa/extras/ooxmlexport/data/dashed_line_custdash_percentage.docx and b/sw/qa/extras/ooxmlexport/data/dashed_line_custdash_percentage.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx index 9eda5e4ee205..a46448d4fd9e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx @@ -769,7 +769,7 @@ DECLARE_OOXMLEXPORT_TEST(testShapeThemePreservation, "shape-theme-preservation.d "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:miter", 1); assertXPath(pXmlDocument, - "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:custDash", + "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", 1); uno::Reference<drawing::XShape> xShape1 = getShape(1); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index 3e8a6e0fe333..18c613fddea6 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -805,37 +805,14 @@ DECLARE_OOXMLEXPORT_TEST(testFdo78957, "fdo78957.docx") DECLARE_OOXMLEXPORT_TEST(testfdo79256, "fdo79256.docx") { - /* Corruption issue containing Line Style with Long Dashes and Dots - * After RT checking the Dash Length value. Dash Length value should not be greater than 2147483. + /* corruption issue also solved by fixing tdf#108064: + * since that LO keeps MSO preset dash styles during OOXML export */ xmlDocPtr pXmlDoc = parseExport("word/document.xml"); if (!pXmlDoc) return; - const sal_Int32 maxLimit = 2147483; - sal_Int32 d = getXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln[1]/a:custDash[1]/a:ds[1]","d").toInt32(); - CPPUNIT_ASSERT(d <= maxLimit ); -} - -DECLARE_OOXMLEXPORT_TEST(testDashedLinePreset, "dashed_line_preset.docx") -{ - /* Make sure that preset line is exported correctly as "1000th of a percent". - * This test-file has a PRESET dash-line which will be converted by LO import - * to a custom-dash (dash-dot-dot). This test-case makes sure that the exporter - * outputs the correct values. - */ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln[1]/a:custDash[1]/a:ds[1]", "d" , "800000"); - assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln[1]/a:custDash[1]/a:ds[1]", "sp", "300000"); - - assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln[1]/a:custDash[1]/a:ds[2]", "d" , "100000"); - assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln[1]/a:custDash[1]/a:ds[2]", "sp", "300000"); - - assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln[1]/a:custDash[1]/a:ds[3]", "d" , "100000"); - assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln[1]/a:custDash[1]/a:ds[3]", "sp", "300000"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln/a:prstDash", "val", "lgDash"); } DECLARE_OOXMLEXPORT_TEST(testDashedLine_CustDash1000thOfPercent, "dashed_line_custdash_1000th_of_percent.docx") commit 39cc0cdaf7fb6c290a2c787b2e41437d4723ca8c Author: Adam Kovacs <[email protected]> AuthorDate: Thu Aug 16 09:32:17 2018 -0400 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 09:43:30 2018 +0200 tdf108064 OOXML export: keep preset dashes in shape outlines Extending commit d7551e32609d0e0de8ac419576ca42d65c5015be to all default MSO 2016 preset dashes: Saving an ooxml file with LibreOffice now preserves the prstDash tags with the values sysDot, sysDash, dash, dashDot, lgDash, lgDashDot, lgDashDotDot, instead of converting them to custDash tags. Note: the import of the preset dash outlines are still not relative to the line width, in spite of their original behaviour in MSO. Change-Id: I65eaf06952a968019495664067010c874fce1352 Reviewed-on: https://gerrit.libreoffice.org/59203 Tested-by: Jenkins Reviewed-by: László Németh <[email protected]> Tested-by: László Németh <[email protected]> (cherry picked from commit f5f235051055d24c8aced602078c54261603efea) diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 9663d4db1905..8c800eec1fdb 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -696,14 +696,34 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet ) if( bDashSet && aStyleLineStyle != drawing::LineStyle_DASH ) { - // line style is a dash and it was not set by the shape style - - if (aLineDash.Dashes == 1 && aLineDash.DashLen == 564 && aLineDash.Distance == 423) + // keep default preset linestyles (instead of custdash) + if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && aLineDash.Dashes == 0 && aLineDash.DashLen == 0 && aLineDash.Distance == 141) { - // That's exactly the predefined "dash" value. - mpFS->singleElementNS(XML_a, XML_prstDash, - XML_val, "dash", - FSEND); + mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDot", FSEND); + } + else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && aLineDash.Dashes == 1 && aLineDash.DashLen == 423 && aLineDash.Distance == 141) + { + mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDash", FSEND); + } + else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && aLineDash.Dashes == 1 && aLineDash.DashLen == 564 && aLineDash.Distance == 423) + { + mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dash", FSEND); + } + else if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && aLineDash.Dashes == 1 && aLineDash.DashLen == 564 && aLineDash.Distance == 423) + { + mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dashDot", FSEND); + } + else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423) + { + mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDash", FSEND); + } + else if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423) + { + mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDashDot", FSEND); + } + else if (aLineDash.Dots == 2 && aLineDash.DotLen == 141 && aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423) + { + mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDashDotDot", FSEND); } else { diff --git a/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx b/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx index 9256c3ec7a4e..d7997ddc63c6 100644 Binary files a/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx and b/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx index dbed9fc22384..9eda5e4ee205 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx @@ -823,13 +823,19 @@ DECLARE_OOXMLEXPORT_TEST(testAlignForShape,"Shape.docx") DECLARE_OOXMLEXPORT_TEST(testLineStyle_DashType, "LineStyle_DashType.docx") { /* DOCX contatining Shape with LineStyle as Dash Type should get preserved inside - * an XMl tag <a:prstDash> with value "dash". + * an XMl tag <a:prstDash> with value "dash", "sysDot", "lgDot", etc. */ xmlDocPtr pXmlDoc = parseExport("word/document.xml"); if (!pXmlDoc) return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "dash"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent[7]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "lgDashDotDot"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent[6]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "lgDashDot"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent[5]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "lgDash"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent[4]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "dashDot"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "dash"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "sysDash"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "sysDot"); } DECLARE_OOXMLEXPORT_TEST(testGradientFillPreservation, "gradient-fill-preservation.docx") commit 515d3f22716b42b5afafc66a0ea3aa4e783e7833 Author: Balazs Varga <[email protected]> AuthorDate: Tue Sep 4 16:27:17 2018 +0200 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 09:43:29 2018 +0200 tdf#108028 OOXML: Fix line breaking of chart title With adding the "TextMaximumFrameWidth" property to the chart title's textbox property, it breaks chart titles longer then the chart width, as in OOXML reference implementation. LibreOffice previously distorted the text and squeezed the chart. This patch will fix it. Change-Id: Ic086d25b49e9c5cf9c6f2c79f141592749adc7d8 Reviewed-on: https://gerrit.libreoffice.org/59991 Tested-by: Jenkins Tested-by: László Németh <[email protected]> Reviewed-by: László Németh <[email protected]> (cherry picked from commit 063e92004b65411dbee7fc12ab00c78aa9c69a86) diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index 2f75aef5c1cf..3a846a539904 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -2400,6 +2400,7 @@ uno::Reference< drawing::XShape > aValueMap.insert( { "TextVerticalAdjust", uno::Any(drawing::TextVerticalAdjust_CENTER) } ); //drawing::TextVerticalAdjust aValueMap.insert( { "TextAutoGrowHeight", uno::Any(true) } ); // sal_Bool aValueMap.insert( { "TextAutoGrowWidth", uno::Any(true) } ); // sal_Bool + aValueMap.insert( { "TextMaximumFrameWidth", uno::Any(rSize.Width) } ); // sal_Int32 //set name/classified ObjectID (CID) if( !aName.isEmpty() ) commit 957ae94721fe1ba08215dced0b754d0c6b463e74 Author: Balazs Varga <[email protected]> AuthorDate: Wed Sep 5 15:07:48 2018 +0200 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 09:43:29 2018 +0200 tdf#119617 Fix export of Autofit property of shapes to PPTX With this patch the "Resize shape to fit text" property (TextAutoGrowHeight-->spAutofit/noAutofit) will be exported correctly to PPTX format. Change-Id: I5fa975c6390a17bad30c360b3b17aa944bbe72af Reviewed-on: https://gerrit.libreoffice.org/60043 Tested-by: Jenkins Reviewed-by: László Németh <[email protected]> (cherry picked from commit 86b14cc8bd910651cef422a0f7408adc0fc51a17) diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 3930fb224e28..9663d4db1905 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2419,6 +2419,12 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin mpFS->singleElementNS(XML_a, XML_normAutofit, XML_fontScale, ( nFontScale < MAX_SCALE_VAL && nFontScale > 0 ) ? I32S(nFontScale) : nullptr, FSEND); } + else + { + bool bTextAutoGrowHeight = false; + GET(bTextAutoGrowHeight, TextAutoGrowHeight); + mpFS->singleElementNS(XML_a, (bTextAutoGrowHeight ? XML_spAutoFit : XML_noAutofit), FSEND); + } } mpFS->endElementNS((nXmlNamespace ? nXmlNamespace : XML_a), XML_bodyPr); } diff --git a/sd/qa/unit/data/pptx/testShapeAutofit.pptx b/sd/qa/unit/data/pptx/testShapeAutofit.pptx new file mode 100755 index 000000000000..fd402c01c895 Binary files /dev/null and b/sd/qa/unit/data/pptx/testShapeAutofit.pptx differ diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 4d8de84766f0..cdf638d841bd 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -130,6 +130,7 @@ public: void testTdf107608(); void testTdf111786(); void testFontScale(); + void testShapeAutofitPPTX(); void testTdf115394(); void testTdf115394Zero(); void testTdf111789(); @@ -195,6 +196,7 @@ public: CPPUNIT_TEST(testTdf107608); CPPUNIT_TEST(testTdf111786); CPPUNIT_TEST(testFontScale); + CPPUNIT_TEST(testShapeAutofitPPTX); CPPUNIT_TEST(testTdf115394); CPPUNIT_TEST(testTdf115394Zero); CPPUNIT_TEST(testTdf111789); @@ -1431,6 +1433,20 @@ void SdOOXMLExportTest2::testFontScale() xDocShRef->DoClose(); } +void SdOOXMLExportTest2::testShapeAutofitPPTX() +{ + sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/testShapeAutofit.pptx"), PPTX); + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml"); + CPPUNIT_ASSERT(pXmlDocContent); + + // TextAutoGrowHeight --> "Resize shape to fit text" --> true + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr/a:spAutoFit", 1); + // TextAutoGrowHeight --> "Resize shape to fit text" --> false + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:bodyPr/a:noAutofit", 1); +} + void SdOOXMLExportTest2::testTdf115394() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf115394.pptx"), PPTX); commit 576acb6f764308d5bcd07da5be9851b46b42d48b Author: Balazs Varga <[email protected]> AuthorDate: Wed Aug 29 19:14:56 2018 +0200 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 09:43:28 2018 +0200 tdf#119562 Fix export of AutoFit property of shapes to XLSX With this patch the "Resize shape to fit text" property (TextAutoGrowHeight) will be exported correctly to XLSX format. Change-Id: I488ceead452aef9096e7766f957de425c8486f85 Reviewed-on: https://gerrit.libreoffice.org/59778 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <[email protected]> (cherry picked from commit 7626dc2d81dc5eb647d6f8937cc1d220a8b8ef4b) diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 678543280839..3930fb224e28 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2389,7 +2389,7 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin mpFS->singleElementNS(XML_a, XML_prstTxWarp, XML_prst, presetWarp.toUtf8().getStr(), FSEND ); } - if (GetDocumentType() == DOCUMENT_DOCX) + if (GetDocumentType() == DOCUMENT_DOCX || GetDocumentType() == DOCUMENT_XLSX) { bool bTextAutoGrowHeight = false; GET(bTextAutoGrowHeight, TextAutoGrowHeight); diff --git a/sc/qa/unit/data/xlsx/testShapeAutofit.xlsx b/sc/qa/unit/data/xlsx/testShapeAutofit.xlsx new file mode 100755 index 000000000000..d5742cd1c854 Binary files /dev/null and b/sc/qa/unit/data/xlsx/testShapeAutofit.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 083b9931c971..b872e3bfb570 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -186,6 +186,7 @@ public: void testSheetRunParagraphPropertyXLSX(); void testHiddenShapeXLS(); void testHiddenShapeXLSX(); + void testShapeAutofitXLSX(); void testHyperlinkXLSX(); void testMoveCellAnchoredShapesODS(); void testMatrixMultiplicationXLSX(); @@ -296,6 +297,7 @@ public: CPPUNIT_TEST(testSheetRunParagraphPropertyXLSX); CPPUNIT_TEST(testHiddenShapeXLS); CPPUNIT_TEST(testHiddenShapeXLSX); + CPPUNIT_TEST(testShapeAutofitXLSX); CPPUNIT_TEST(testHyperlinkXLSX); CPPUNIT_TEST(testMoveCellAnchoredShapesODS); CPPUNIT_TEST(testMatrixMultiplicationXLSX); @@ -3547,6 +3549,20 @@ void ScExportTest::testHiddenShapeXLSX() xDocSh->DoClose(); } +void ScExportTest::testShapeAutofitXLSX() +{ + ScDocShellRef xDocSh = loadDoc("testShapeAutofit.", FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh.is()); + + xmlDocPtr pDoc = XPathHelper::parseExport(*xDocSh, m_xSFactory, "xl/drawings/drawing1.xml", FORMAT_XLSX); + CPPUNIT_ASSERT(pDoc); + + // TextAutoGrowHeight --> "Fit height to text" / "Resize shape to fit text" --> true + assertXPath(pDoc, "/xdr:wsDr/xdr:twoCellAnchor[1]/xdr:sp/xdr:txBody/a:bodyPr/a:spAutoFit", 1); + // TextAutoGrowHeight --> "Fit height to text" / "Resize shape to fit text" --> false + assertXPath(pDoc, "/xdr:wsDr/xdr:twoCellAnchor[2]/xdr:sp/xdr:txBody/a:bodyPr/a:noAutofit", 1); +} + void ScExportTest::testHyperlinkXLSX() { ScDocShellRef xDocSh = loadDoc("hyperlink.", FORMAT_XLSX); commit f8d3314f198b70c64a4f45e701fa38151207950f Author: Balazs Varga <[email protected]> AuthorDate: Wed Aug 22 11:15:45 2018 +0200 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 08:24:24 2018 +0200 tdf#94502 Fix overlap export of Stacked Bar Chart to *.xlsx Export the Overlap value with 100% for stacked charts, because the default overlap value of the Bar/Column chart is 0% and LibreOffice do nothing with the overlap value in Stacked Chart case, unlike the MS Office. Change-Id: If4e20b88c2b1180f68a8d2b610c407d674a8498b Reviewed-on: https://gerrit.libreoffice.org/59448 Reviewed-by: Markus Mohrhard <[email protected]> Tested-by: Jenkins (cherry picked from commit 17c2b0af97f73b9103be982b15d7111b3980e027) diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index f8c783d46574..cb1ae992a1dd 100755 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -104,6 +104,7 @@ public: void testChartTitlePropertiesGradientFillXLSX(); void testChartTitlePropertiesBitmapFillXLSX(); void testBarChartDataPointPropXLSX(); + void testDataseriesOverlapStackedChartXLSX(); void testAxisCharacterPropertiesXLSX(); void testTitleCharacterPropertiesXLSX(); void testPlotVisOnlyXLSX(); @@ -185,6 +186,7 @@ public: CPPUNIT_TEST(testChartTitlePropertiesGradientFillXLSX); CPPUNIT_TEST(testChartTitlePropertiesBitmapFillXLSX); CPPUNIT_TEST(testBarChartDataPointPropXLSX); + CPPUNIT_TEST(testDataseriesOverlapStackedChartXLSX); CPPUNIT_TEST(testAxisCharacterPropertiesXLSX); CPPUNIT_TEST(testTitleCharacterPropertiesXLSX); CPPUNIT_TEST(testPlotVisOnlyXLSX); @@ -1608,6 +1610,27 @@ void Chart2ExportTest::testBarChartDataPointPropXLSX() assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:spPr/a:ln/a:solidFill/a:srgbClr", "val", "70ad47"); } +void Chart2ExportTest::testDataseriesOverlapStackedChartXLSX() +{ + load("/chart2/qa/extras/data/xlsx/", "testDataseriesOverlapStackedChart.xlsx"); + + // test the overlap value of a simple Stacked Column Chart + uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent ); + checkSheetForGapWidthAndOverlap(xChartDoc, 100, 0); + + // test the overlap value of a Percent Stacked Bar Chart + xChartDoc = getChartDocFromSheet( 1, mxComponent ); + checkSheetForGapWidthAndOverlap(xChartDoc, 100, 35); + + reload("Calc Office Open XML"); + + xChartDoc = getChartDocFromSheet( 0, mxComponent ); + checkSheetForGapWidthAndOverlap(xChartDoc, 100, 100); + + xChartDoc = getChartDocFromSheet( 1, mxComponent ); + checkSheetForGapWidthAndOverlap(xChartDoc, 100, 100); +} + void Chart2ExportTest::testAxisCharacterPropertiesXLSX() { load("/chart2/qa/extras/data/xlsx/", "axis_character_properties.xlsx"); diff --git a/chart2/qa/extras/data/xlsx/testDataseriesOverlapStackedChart.xlsx b/chart2/qa/extras/data/xlsx/testDataseriesOverlapStackedChart.xlsx new file mode 100755 index 000000000000..ba1c526b41ca Binary files /dev/null and b/chart2/qa/extras/data/xlsx/testDataseriesOverlapStackedChart.xlsx differ diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index e7dbcf90d4c2..a6bd3b4c0618 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -1471,9 +1471,24 @@ void ChartExport::exportBarChart( const Reference< chart2::XChartType >& xChartT if( aBarPositionSequence.getLength() ) { sal_Int32 nOverlap = aBarPositionSequence[0]; - pFS->singleElement( FSNS( XML_c, XML_overlap ), + // Stacked/Percent Bar/Column chart Overlap-workaround + // Export the Overlap value with 100% for stacked charts, + // because the default overlap value of the Bar/Column chart is 0% and + // LibreOffice do nothing with the overlap value in Stacked charts case, + // unlike the MS Office, which is interpreted differently. + if( ( mbStacked || mbPercent ) && nOverlap != 100 ) + { + nOverlap = 100; + pFS->singleElement( FSNS( XML_c, XML_overlap ), + XML_val, I32S( nOverlap ), + FSEND ); + } + else // Normal bar chart + { + pFS->singleElement( FSNS( XML_c, XML_overlap ), XML_val, I32S( nOverlap ), FSEND ); + } } } commit c53039f58b4886c7ff4fb76a8e6f41a356e38083 Author: bvarga91 <[email protected]> AuthorDate: Thu Jul 5 23:14:01 2018 +0200 Commit: Andras Timar <[email protected]> CommitDate: Wed Sep 12 08:24:11 2018 +0200 tdf#118153 VBA Macro: add XLSX support to Workbooks.Open by accepting "MS Excel 2007 XML" in isSpreadSheetFile(). Test example: Workbooks.Open Filename:="/tmp/test.xlsx" Change-Id: Id7102325c96842bb413b1fb7bb8162e8bca41f4e Reviewed-on: https://gerrit.libreoffice.org/57030 Reviewed-by: László Németh <[email protected]> Tested-by: László Németh <[email protected]> (cherry picked from commit fc434c8fd62ccb6d083af075f1ab83da6bd76b8d) diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx index 1fd605d8b972..22dc4a017119 100644 --- a/sc/source/ui/vba/vbaworkbooks.cxx +++ b/sc/source/ui/vba/vbaworkbooks.cxx @@ -170,6 +170,7 @@ ScVbaWorkbooks::isSpreadSheetFile( const OUString& sType ) { // include calc_QPro etc. ? ( not for the moment anyway ) return sType.startsWith( "calc_MS" ) + || sType.startsWith( "MS Excel" ) || sType.startsWith( "calc8" ) || sType.startsWith( "calc_StarOffice" ); } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
