diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2016-07-19 00:26:54 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-07-28 23:23:49 +0200 |
commit | 40d892a2db4d750aaf0562c63004e693c028273c (patch) | |
tree | 51269039375cd34ad3df04e6abcc04d9d9f37128 /sc/source/filter/oox/worksheethelper.cxx | |
parent | 72e6f08c692c0625db5ce377fb478a99660adb0d (diff) |
tdf#100946 Fix width calculation and add customWidth support (.xlsx)
On some MS Excel version (OS X), the column "width" is
not applied, if "customWidth" key (in "col") is not set to "true".
It means that in case of .xlsx files, exported by LibreOffice,
all columns have default width. To resolve that "customWidth"
key was added during export into .xlsx file format.
During development it appears that Default Column Width is wrongly
calculated, and it was done not according to MS documentation.
This issue was also fixed. After fix default column width is
properly set.
MS documentation:
https://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column.aspx
Change-Id: I0d1944081a5ea445d1e4284db62e9b4d504bf1c0
Diffstat (limited to 'sc/source/filter/oox/worksheethelper.cxx')
-rw-r--r-- | sc/source/filter/oox/worksheethelper.cxx | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index 53c1cf3c5fab..febfd2fed15f 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -1193,11 +1193,10 @@ sal_Int32 getColumnWidth(UnitConverter& rConverter, double nWidth) long nPixel = aDev->LogicToPixel(Point(nCoeff, 0), MapMode(MAP_100TH_MM)).getX(); - // the 1.047 has been experimentally chosen based on measurements with a 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; + 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(); } |