summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2012-10-04 15:45:36 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-10-09 05:47:06 +0200
commita00d5c5321959c316f6103e18dddef1ad5f02376 (patch)
tree1f92f0fb93bd262e8253a91ceb2e89b56762f334
parenta4cdd39b154cfc0c7cb9912f8d31b59dec3e5e60 (diff)
xlsx fix import/export of column widths fdo#55623
column widths were never imported or exported correctly in xlsx. Change-Id: I92d469ce52495fe77281cb22341e9c5127e6b506 (cherry picked from commit 8e753f8446554822d97969b0c18eba6cb9d79e26) Signed-off-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--sc/source/filter/excel/xetable.cxx5
-rw-r--r--sc/source/filter/inc/xetable.hxx1
-rw-r--r--sc/source/filter/oox/unitconverter.cxx5
3 files changed, 6 insertions, 5 deletions
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 793155a616ce..7da79aa68c38 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -1483,6 +1483,7 @@ XclExpColinfo::XclExpColinfo( const XclExpRoot& rRoot,
XclExpRecord( EXC_ID_COLINFO, 12 ),
XclExpRoot( rRoot ),
mnWidth( 0 ),
+ mnScWidth( 0 ),
mnFlags( 0 ),
mnFirstXclCol( static_cast< sal_uInt16 >( nScCol ) ),
mnLastXclCol( static_cast< sal_uInt16 >( nScCol ) )
@@ -1497,7 +1498,7 @@ XclExpColinfo::XclExpColinfo( const XclExpRoot& rRoot,
// column width
sal_uInt16 nScWidth = rDoc.GetColWidth( nScCol, nScTab );
mnWidth = XclTools::GetXclColumnWidth( nScWidth, GetCharWidth() );
-
+ mnScWidth = sc::TwipsToHMM( nScWidth );
// column flags
::set_flag( mnFlags, EXC_COLINFO_HIDDEN, rDoc.ColHidden(nScCol, nScTab) );
@@ -1563,7 +1564,7 @@ void XclExpColinfo::SaveXml( XclExpXmlStream& rStrm )
// OOXTODO: XML_outlineLevel,
// OOXTODO: XML_phonetic,
XML_style, lcl_GetStyleId( rStrm, maXFId.mnXFIndex ).getStr(),
- XML_width, OString::valueOf( (double) (mnWidth / 255.0) ).getStr(),
+ XML_width, OString::valueOf( (double) (mnScWidth / (double)sc::TwipsToHMM( GetCharWidth() )) ).getStr(),
FSEND );
}
diff --git a/sc/source/filter/inc/xetable.hxx b/sc/source/filter/inc/xetable.hxx
index 291c37ff4841..d9ce5eac0e21 100644
--- a/sc/source/filter/inc/xetable.hxx
+++ b/sc/source/filter/inc/xetable.hxx
@@ -783,6 +783,7 @@ private:
private:
XclExpXFId maXFId; /// The XF identifier for column default format.
sal_uInt16 mnWidth; /// Excel width of the column.
+ sal_uInt16 mnScWidth; /// Calc width of the column.
sal_uInt16 mnFlags; /// Additional column flags.
sal_uInt16 mnFirstXclCol; /// Index to first column.
sal_uInt16 mnLastXclCol; /// Index to last column.
diff --git a/sc/source/filter/oox/unitconverter.cxx b/sc/source/filter/oox/unitconverter.cxx
index e2feb875882e..2d0431b21be1 100644
--- a/sc/source/filter/oox/unitconverter.cxx
+++ b/sc/source/filter/oox/unitconverter.cxx
@@ -149,18 +149,17 @@ void UnitConverter::finalizeImport()
{
// XDevice expects pixels in font descriptor, but font contains twips
FontDescriptor aDesc = pDefFont->getFontDescriptor();
- aDesc.Height = static_cast< sal_Int16 >( scaleValue( aDesc.Height, UNIT_TWIP, UNIT_REFDEVX ) + 0.5 );
Reference< XFont > xFont = xDevice->getFont( aDesc );
if( xFont.is() )
{
// get maximum width of all digits
sal_Int32 nDigitWidth = 0;
for( sal_Unicode cChar = '0'; cChar <= '9'; ++cChar )
- nDigitWidth = ::std::max( nDigitWidth, scaleToMm100( xFont->getCharWidth( cChar ), UNIT_REFDEVX ) );
+ nDigitWidth = ::std::max( nDigitWidth, scaleToMm100( xFont->getCharWidth( cChar ), UNIT_TWIP ) );
if( nDigitWidth > 0 )
maCoeffs[ UNIT_DIGIT ] = nDigitWidth;
// get width of space character
- sal_Int32 nSpaceWidth = scaleToMm100( xFont->getCharWidth( ' ' ), UNIT_REFDEVX );
+ sal_Int32 nSpaceWidth = scaleToMm100( xFont->getCharWidth( ' ' ), UNIT_TWIP );
if( nSpaceWidth > 0 )
maCoeffs[ UNIT_SPACE ] = nSpaceWidth;
}