sc/qa/unit/subsequent_filters-test.cxx | 2 ++ sc/source/filter/oox/worksheethelper.cxx | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-)
New commits: commit 16726a1b37df8bdcae02b3c7699df814977222bd Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Wed May 20 03:59:49 2015 +0200 better algorithm for OOXML column width import, tdf#91267 This patch contains a magic factor of 1.047 that is necessary as the set value and retrieved value are not the same. When we ahve too much time (propably never) we should explore why the value that we set for the column width is not equal to the one that we see on the screen. Change-Id: I317127ea5b8af2d5e8386758e66907a44fe58579 diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index aaa45a9..3dfbf8a 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -78,6 +78,7 @@ #include <svl/stritem.hxx> #include <editeng/editobj.hxx> #include <editeng/flditem.hxx> +#include <vcl/virdev.hxx> namespace oox { namespace xls { @@ -1166,11 +1167,31 @@ void WorksheetGlobals::convertColumns() convertOutlines( aColLevels, nMaxCol + 1, 0, false, false ); } +namespace { + +sal_Int32 getColumnWidth(UnitConverter& rConverter, double nWidth) +{ + double nCoeff = rConverter.getCoefficient(UNIT_DIGIT); + VirtualDevice aDev; + + long nPixel = aDev.LogicToPixel(Point(nCoeff, 0), MapMode(MAP_100TH_MM)).getX(); + + + // the 1.047 has been experimentally chosen based on measurements witha screen ruler + // TODO: fix the display of cells so that it no longer requires this hack + // algorithm from OOXML spec part1: 18.3.1.13 + sal_Int32 nColWidthPixel= std::floor(((256*nWidth + std::floor(128.0/nPixel))/256.0)*nPixel) * 1.047; + + return aDev.PixelToLogic(Point(nColWidthPixel, 0), MapMode(MAP_100TH_MM)).getX(); +} + +} + void WorksheetGlobals::convertColumns( OutlineLevelVec& orColLevels, const ValueRange& rColRange, const ColumnModel& rModel ) { // column width: convert 'number of characters' to column width in 1/100 mm - sal_Int32 nWidth = getUnitConverter().scaleToMm100( rModel.mfWidth, UNIT_DIGIT ); + sal_Int32 nWidth = getColumnWidth(getUnitConverter(), rModel.mfWidth); // macro sheets have double width if( meSheetType == SHEETTYPE_MACROSHEET ) nWidth *= 2; commit 1d2d037b4defa775b164880b56732af2a837f254 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Tue May 19 05:49:28 2015 +0200 add missing DoClose at end of test Change-Id: Ia06522ba4d3e6b4495e17d260d0bc3618b1a7cf2 diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index c0b12d3..a110cb56 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -3046,6 +3046,8 @@ void ScFiltersTest::testEditEngStrikeThroughXLSX() } } } + + xDocSh->DoClose(); } void ScFiltersTest::testRefStringXLSX() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits