Author: zhangjf Date: Sun Aug 26 12:55:17 2012 New Revision: 1377430 URL: http://svn.apache.org/viewvc?rev=1377430&view=rev Log: #i120576#, the background color from table style are lost for table in the docx file
Refer to wiki document http://wiki.openoffice.org/wiki/Table_Style_in_Writerfilter The change is composed of below parts: 1. For the w:tcPr under w:style, it's used for whole table. It should be sprmed. 2. On how to apply different kinds of table styles, it follows the sequence from wiki as below. That means ne/nw/se/sw table style can overwrite all other types if existing. wholeTable band1Horz band2Horz band1Vert band2Vert firstCol lastCol firstRow lastRow neCell nwCell seCell swCell 3. Fix a typo for resetRowProp. It's related to all row properties. Found by: bjcheny Patch by: bjcheny Review by: zhangjf Modified: incubator/ooo/trunk/main/writerfilter/inc/resourcemodel/TableManager.hxx incubator/ooo/trunk/main/writerfilter/source/dmapper/StyleSheetTable.cxx incubator/ooo/trunk/main/writerfilter/source/dmapper/StyleSheetTable.hxx Modified: incubator/ooo/trunk/main/writerfilter/inc/resourcemodel/TableManager.hxx URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/writerfilter/inc/resourcemodel/TableManager.hxx?rev=1377430&r1=1377429&r2=1377430&view=diff ============================================================================== --- incubator/ooo/trunk/main/writerfilter/inc/resourcemodel/TableManager.hxx (original) +++ incubator/ooo/trunk/main/writerfilter/inc/resourcemodel/TableManager.hxx Sun Aug 26 12:55:17 2012 @@ -218,7 +218,7 @@ class TableManager void resetRowProps() { - mpCellProps.reset(); + mpRowProps.reset(); } void setRowProps(PropertiesPointer pProps) Modified: incubator/ooo/trunk/main/writerfilter/source/dmapper/StyleSheetTable.cxx URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/writerfilter/source/dmapper/StyleSheetTable.cxx?rev=1377430&r1=1377429&r2=1377430&view=diff ============================================================================== --- incubator/ooo/trunk/main/writerfilter/source/dmapper/StyleSheetTable.cxx (original) +++ incubator/ooo/trunk/main/writerfilter/source/dmapper/StyleSheetTable.cxx Sun Aug 26 12:55:17 2012 @@ -221,7 +221,19 @@ void lcl_mergeProps( PropertyMapPtr pToF pToFill->insert( pToAdd ); } -PropertyMapPtr TableStyleSheetEntry::GetLocalPropertiesFromMask( sal_Int32 nMask ) +void TableStyleSheetEntry::MergePropertiesFromMask(const short nBit, const sal_Int32 nMask, + const TblStyleType nStyleId, + PropertyMapPtr pToFill) +{ + TblStylePrs::iterator pIt = m_aStyles.find( nStyleId ); + + short nTestBit = 1 << nBit; + sal_Int32 nBitMask = sal_Int32( nTestBit ); + if ( ( nMask & nBitMask ) && ( pIt != m_aStyles.end( ) ) ) + lcl_mergeProps( pToFill, pIt->second, nStyleId ); +} + +PropertyMapPtr TableStyleSheetEntry::GetLocalPropertiesFromMask( const sal_Int32 nMask ) { // Order from right to left static TblStyleType aBitsOrder[] = @@ -243,21 +255,22 @@ PropertyMapPtr TableStyleSheetEntry::Get // Get the properties applying according to the mask PropertyMapPtr pProps( new PropertyMap( ) ); - short nBit = 0; + short nBit = 4; do { - TblStyleType nStyleId = aBitsOrder[nBit]; - TblStylePrs::iterator pIt = m_aStyles.find( nStyleId ); - - short nTestBit = 1 << nBit; - sal_Int32 nBitMask = sal_Int32( nTestBit ); - if ( ( nMask & nBitMask ) && ( pIt != m_aStyles.end( ) ) ) - lcl_mergeProps( pProps, pIt->second, nStyleId ); - + MergePropertiesFromMask(nBit, nMask, aBitsOrder[nBit], pProps); nBit++; } while ( nBit < 13 ); + nBit = 0; + do + { + MergePropertiesFromMask(nBit, nMask, aBitsOrder[nBit], pProps); + nBit++; + } + while ( nBit < 4 ); // nw/ne/sw/se overwrite others + return pProps; } @@ -543,9 +556,13 @@ void StyleSheetTable::lcl_sprm(Sprm & rS case NS_ooxml::LN_CT_Style_personalReply: case NS_ooxml::LN_CT_Style_rsid: case NS_ooxml::LN_CT_Style_trPr: - case NS_ooxml::LN_CT_Style_tcPr: /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */ break; + case NS_ooxml::LN_CT_Style_tcPr: + { + resolveSprmProps(rSprm); + } + break; case NS_ooxml::LN_CT_Style_tblPr: //contains table properties case NS_ooxml::LN_CT_Style_tblStylePr: //contains to table properties Modified: incubator/ooo/trunk/main/writerfilter/source/dmapper/StyleSheetTable.hxx URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/writerfilter/source/dmapper/StyleSheetTable.hxx?rev=1377430&r1=1377429&r2=1377430&view=diff ============================================================================== --- incubator/ooo/trunk/main/writerfilter/source/dmapper/StyleSheetTable.hxx (original) +++ incubator/ooo/trunk/main/writerfilter/source/dmapper/StyleSheetTable.hxx Sun Aug 26 12:55:17 2012 @@ -145,7 +145,9 @@ public: virtual ~TableStyleSheetEntry( ); protected: - PropertyMapPtr GetLocalPropertiesFromMask( sal_Int32 nMask ); + PropertyMapPtr GetLocalPropertiesFromMask( const sal_Int32 nMask ); + void MergePropertiesFromMask(const short nBit, const sal_Int32 nMask, + const TblStyleType nStyleId, PropertyMapPtr pToFill); }; typedef boost::shared_ptr<TableStyleSheetEntry> TableStyleSheetEntryPtr;
