diff options
author | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-04-07 03:28:05 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-04-07 03:28:05 +0200 |
commit | 3f84441d255574b2ec37fe30f5f47465adff6f8e (patch) | |
tree | e0c0813f83b7ed21791e4b0e517276ce38abe309 | |
parent | 47a5f4fccb2be6111062feed78073575dbe58e71 (diff) |
temporary work for improved dxf xls exportprivate/moggi/improved-dxf-xls-export
Change-Id: Ie8177dae226f1b208e28a653e3db168b76c1aa38
-rw-r--r-- | sc/source/filter/excel/xecontent.cxx | 49 | ||||
-rw-r--r-- | sc/source/filter/excel/xestyle.cxx | 18 | ||||
-rw-r--r-- | sc/source/filter/inc/xestyle.hxx | 8 |
3 files changed, 66 insertions, 9 deletions
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 290f79fb4f51..f928427945c5 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -47,6 +47,8 @@ #include "xename.hxx" #include <rtl/uuid.h> +#include <svl/intitem.hxx> + using namespace ::oox; using ::com::sun::star::uno::Reference; @@ -578,6 +580,7 @@ private: const ScCondFormatEntry& mrFormatEntry; /// Calc conditional format entry. XclFontData maFontData; /// Font formatting attributes. XclExpCellBorder maBorder; /// Border formatting attributes. + XclExpCellAlign maAlign; /// Alignment formatting attributes XclExpCellArea maArea; /// Pattern formatting attributes. XclTokenArrayRef mxTokArr1; /// Formula for first condition. XclTokenArrayRef mxTokArr2; /// Formula for second condition. @@ -585,6 +588,8 @@ private: sal_uInt8 mnType; /// Type of the condition (cell/formula). sal_uInt8 mnOperator; /// Comparison operator for cell type. sal_Int32 mnPriority; /// Priority of this entry; needed for oox export + OUString maFormat; + bool mbNumFmtUsed; bool mbFontUsed; /// true = Any font attribute used. bool mbHeightUsed; /// true = Font height used. bool mbWeightUsed; /// true = Font weight used. @@ -593,6 +598,7 @@ private: bool mbItalicUsed; /// true = Font posture used. bool mbStrikeUsed; /// true = Font strikeout used. bool mbBorderUsed; /// true = Border attribute used. + bool mbAlignUsed; /// true = Alignment attributes used bool mbPattUsed; /// true = Pattern attribute used. }; @@ -603,6 +609,7 @@ XclExpCFImpl::XclExpCFImpl( const XclExpRoot& rRoot, const ScCondFormatEntry& rF mnType( EXC_CF_TYPE_CELL ), mnOperator( EXC_CF_CMP_NONE ), mnPriority( nPriority ), + mbNumFmtUsed( false ), mbFontUsed( false ), mbHeightUsed( false ), mbWeightUsed( false ), @@ -611,6 +618,7 @@ XclExpCFImpl::XclExpCFImpl( const XclExpRoot& rRoot, const ScCondFormatEntry& rF mbItalicUsed( false ), mbStrikeUsed( false ), mbBorderUsed( false ), + mbAlignUsed( false ), mbPattUsed( false ) { /* Get formatting attributes here, and not in WriteBody(). This is needed to @@ -620,6 +628,21 @@ XclExpCFImpl::XclExpCFImpl( const XclExpRoot& rRoot, const ScCondFormatEntry& rF { const SfxItemSet& rItemSet = pStyleSheet->GetItemSet(); + //number format + bool bNumFmtUsed = ScfTools::CheckItem( rItemSet, ATTR_VALUE_FORMAT, true ); + if( bNumFmtUsed ) + { + const SfxPoolItem *pPoolItem = NULL; + if( rItemSet.GetItemState( ATTR_VALUE_FORMAT, true, &pPoolItem ) == SFX_ITEM_SET ) + { + sal_uLong nScNumFmt = static_cast< sal_uInt32 >( static_cast< const SfxInt32Item* >(pPoolItem)->GetValue()); + maFormat = XclExpNumFmt::GetNumberFormatCode( *this, nScNumFmt, + GetRoot().GetNumFmtBuffer().getFormatter(), GetRoot().GetNumFmtBuffer().getKeywordTable() ); + } + else + bNumFmtUsed = false; + } + // font mbHeightUsed = ScfTools::CheckItem( rItemSet, ATTR_FONT_HEIGHT, true ); mbWeightUsed = ScfTools::CheckItem( rItemSet, ATTR_FONT_WEIGHT, true ); @@ -641,6 +664,8 @@ XclExpCFImpl::XclExpCFImpl( const XclExpRoot& rRoot, const ScCondFormatEntry& rF if( mbBorderUsed ) maBorder.FillFromItemSet( rItemSet, GetPalette(), GetBiff() ); + mbAlignUsed = maAlign.FillFromItemSet( rItemSet, false, GetBiff() ); + // pattern mbPattUsed = ScfTools::CheckItem( rItemSet, ATTR_BACKGROUND, true ); if( mbPattUsed ) @@ -694,19 +719,31 @@ void XclExpCFImpl::WriteBody( XclExpStream& rStrm ) // *** formatting blocks *** - if( mbFontUsed || mbBorderUsed || mbPattUsed ) + if( mbNumFmtUsed || mbFontUsed || mbBorderUsed || + mbPattUsed ) { sal_uInt32 nFlags = EXC_CF_ALLDEFAULT; + ::set_flag( nFlags, EXC_CF_BLOCK_NUMFMT, mbNumFmtUsed ); ::set_flag( nFlags, EXC_CF_BLOCK_FONT, mbFontUsed ); ::set_flag( nFlags, EXC_CF_BLOCK_BORDER, mbBorderUsed ); + ::set_flag( nFlags, EXC_CF_BLOCK_ALIGNMENT, mbAlignUsed ); ::set_flag( nFlags, EXC_CF_BLOCK_AREA, mbPattUsed ); // attributes used -> set flags to 0. ::set_flag( nFlags, EXC_CF_BORDER_ALL, !mbBorderUsed ); ::set_flag( nFlags, EXC_CF_AREA_ALL, !mbPattUsed ); - rStrm << nFlags << sal_uInt16( 0 ); + sal_uInt16 nExtendedFlags = 1; + + rStrm << nFlags << nExtendedFlags; + + if( mbNumFmtUsed ) + { + XclExpString aNumFmtString; + aNumFmtString.Assign(maFormat); + aNumFmtString.WriteBuffer( rStrm ); + } if( mbFontUsed ) { @@ -750,6 +787,14 @@ void XclExpCFImpl::WriteBody( XclExpStream& rStrm ) rStrm << nLineStyle << nLineColor << sal_uInt16( 0 ); } + if( mbAlignUsed ) + { + sal_uInt16 nAlign = 0; + sal_uInt16 nMiscFlags = 0; + maAlign.FillToXF8(nAlign, nMiscFlags); + rStrm << nAlign << nMiscFlags; + } + if( mbPattUsed ) { sal_uInt16 nPattern = 0, nColor = 0; diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index ccfb3e3d8e37..f1c016fcd018 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -1288,9 +1288,17 @@ void XclExpNumFmtBuffer::WriteFormatRecord( XclExpStream& rStrm, const XclExpNum WriteFormatRecord( rStrm, rFormat.mnXclNumFmt, GetFormatCode( rFormat.mnScNumFmt ) ); } -namespace { +NfKeywordTable* XclExpNumFmtBuffer::getKeywordTable() +{ + return mpKeywordTable.get(); +} + +SvNumberFormatter* XclExpNumFmtBuffer::getFormatter() +{ + return mxFormatter.get(); +} -OUString GetNumberFormatCode(XclRoot& rRoot, const sal_uInt16 nScNumFmt, SvNumberFormatter* xFormatter, NfKeywordTable* pKeywordTable) +OUString XclExpNumFmt::GetNumberFormatCode(XclRoot& rRoot, const sal_uInt16 nScNumFmt, SvNumberFormatter* xFormatter, NfKeywordTable* pKeywordTable) { OUString aFormatStr; @@ -1334,11 +1342,9 @@ OUString GetNumberFormatCode(XclRoot& rRoot, const sal_uInt16 nScNumFmt, SvNumbe return( aFormatStr ); } -} - OUString XclExpNumFmtBuffer::GetFormatCode( sal_uInt16 nScNumFmt ) { - return GetNumberFormatCode( *this, nScNumFmt, mxFormatter.get(), mpKeywordTable.get() ); + return XclExpNumFmt::GetNumberFormatCode( *this, nScNumFmt, mxFormatter.get(), mpKeywordTable.get() ); } // XF, STYLE record - Cell formatting ========================================= @@ -2938,7 +2944,7 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot ) { sal_uLong nScNumFmt = static_cast< sal_uInt32 >( static_cast< const SfxInt32Item* >(pPoolItem)->GetValue()); sal_Int32 nXclNumFmt = GetRoot().GetNumFmtBuffer().Insert(nScNumFmt); - pNumFormat = new XclExpNumFmt( nScNumFmt, nXclNumFmt, GetNumberFormatCode( *this, nScNumFmt, mxFormatter.get(), mpKeywordTable.get() )); + pNumFormat = new XclExpNumFmt( nScNumFmt, nXclNumFmt, XclExpNumFmt::GetNumberFormatCode( *this, nScNumFmt, mxFormatter.get(), mpKeywordTable.get() )); } maDxf.push_back(new XclExpDxf( rRoot, pAlign, pBorder, pFont, pNumFormat, pCellProt, pColor )); diff --git a/sc/source/filter/inc/xestyle.hxx b/sc/source/filter/inc/xestyle.hxx index 507b8d2ec59d..6856fa197ef0 100644 --- a/sc/source/filter/inc/xestyle.hxx +++ b/sc/source/filter/inc/xestyle.hxx @@ -273,12 +273,15 @@ struct XclExpNumFmt mnScNumFmt( nScNumFmt ), mnXclNumFmt( nXclNumFmt ), maNumFmtString( rFrmt ) {} void SaveXml( XclExpXmlStream& rStrm ); + + static OUString GetNumberFormatCode(XclRoot& rRoot, const sal_uInt16 nScNumFmt, + SvNumberFormatter* xFormatter, NfKeywordTable* pKeywoardTable ); }; class SvNumberFormatter; -typedef ::std::auto_ptr< SvNumberFormatter > SvNumberFormatterPtr; +typedef boost::scoped_ptr< SvNumberFormatter > SvNumberFormatterPtr; /** Stores all number formats used in the document. */ class XclExpNumFmtBuffer : public XclExpRecordBase, protected XclExpRoot @@ -299,6 +302,9 @@ public: virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE; virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE; + NfKeywordTable* getKeywordTable(); + SvNumberFormatter* getFormatter(); + private: /** Writes the FORMAT record with index nXclIx and format string rFormatStr. */ void WriteFormatRecord( XclExpStream& rStrm, sal_uInt16 nXclNumFmt, const OUString& rFormatStr ); |