Kaydet (Commit) 7803a5d7 authored tarafından Miklos Vajna's avatar Miklos Vajna

DOCX import: handle all attributes of CT_TblLook

Change-Id: I3bbd65af4f52ce28e2962a1b3e0c7f1c348f3a01
üst 0ee72863
...@@ -2458,7 +2458,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) ...@@ -2458,7 +2458,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
{ {
writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
if (pProperties.get()) if (pProperties.get())
{
pProperties->resolve(*this); pProperties->resolve(*this);
m_pImpl->getTableManager().finishTableLook();
}
} }
break; break;
default: default:
......
...@@ -313,8 +313,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo ...@@ -313,8 +313,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
sal_Int32 nTableWidth = 0; sal_Int32 nTableWidth = 0;
sal_Int32 nTableWidthType = text::SizeType::FIX; sal_Int32 nTableWidthType = text::SizeType::FIX;
uno::Sequence< beans::PropertyValue > aGrabBag( 6 ); comphelper::SequenceAsHashMap aGrabBag;
sal_Int32 nGrabBagSize = 0;
if (0 != m_rDMapper_Impl.getTableManager().getCurrentTableRealPosition()) if (0 != m_rDMapper_Impl.getTableManager().getCurrentTableRealPosition())
{ {
...@@ -352,9 +351,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo ...@@ -352,9 +351,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
aGrabBagTS[9].Name = "vertAnchor"; aGrabBagTS[9].Name = "vertAnchor";
aGrabBagTS[9].Value = uno::makeAny( pTablePositions->getVertAnchor() ); aGrabBagTS[9].Value = uno::makeAny( pTablePositions->getVertAnchor() );
aGrabBag[nGrabBagSize].Name = "TablePosition"; aGrabBag["TablePosition"] = uno::makeAny( aGrabBagTS );
aGrabBag[nGrabBagSize].Value = uno::makeAny( aGrabBagTS );
nGrabBagSize++;
} }
boost::optional<PropertyMap::Property> aTableStyleVal = m_aTableProperties->getProperty(META_PROP_TABLE_STYLE_NAME); boost::optional<PropertyMap::Property> aTableStyleVal = m_aTableProperties->getProperty(META_PROP_TABLE_STYLE_NAME);
...@@ -368,9 +365,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo ...@@ -368,9 +365,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
pTableStyle = dynamic_cast<TableStyleSheetEntry*>( pStyleSheet.get( ) ); pTableStyle = dynamic_cast<TableStyleSheetEntry*>( pStyleSheet.get( ) );
m_aTableProperties->Erase( aTableStyleVal->first ); m_aTableProperties->Erase( aTableStyleVal->first );
aGrabBag[nGrabBagSize].Name = "TableStyleName"; aGrabBag["TableStyleName"] = uno::makeAny( sTableStyleName );
aGrabBag[nGrabBagSize].Value = uno::makeAny( sTableStyleName );
nGrabBagSize++;
if( pStyleSheet ) if( pStyleSheet )
{ {
...@@ -386,27 +381,19 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo ...@@ -386,27 +381,19 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
TableInfo rStyleInfo; TableInfo rStyleInfo;
if (lcl_extractTableBorderProperty(pMergedProperties, PROP_TOP_BORDER, rStyleInfo, aBorderLine)) if (lcl_extractTableBorderProperty(pMergedProperties, PROP_TOP_BORDER, rStyleInfo, aBorderLine))
{ {
aGrabBag[nGrabBagSize].Name = "TableStyleTopBorder"; aGrabBag["TableStyleTopBorder"] = uno::makeAny( aBorderLine );
aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine );
nGrabBagSize++;
} }
if (lcl_extractTableBorderProperty(pMergedProperties, PROP_BOTTOM_BORDER, rStyleInfo, aBorderLine)) if (lcl_extractTableBorderProperty(pMergedProperties, PROP_BOTTOM_BORDER, rStyleInfo, aBorderLine))
{ {
aGrabBag[nGrabBagSize].Name = "TableStyleBottomBorder"; aGrabBag["TableStyleBottomBorder"] = uno::makeAny( aBorderLine );
aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine );
nGrabBagSize++;
} }
if (lcl_extractTableBorderProperty(pMergedProperties, PROP_LEFT_BORDER, rStyleInfo, aBorderLine)) if (lcl_extractTableBorderProperty(pMergedProperties, PROP_LEFT_BORDER, rStyleInfo, aBorderLine))
{ {
aGrabBag[nGrabBagSize].Name = "TableStyleLeftBorder"; aGrabBag["TableStyleLeftBorder"] = uno::makeAny( aBorderLine );
aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine );
nGrabBagSize++;
} }
if (lcl_extractTableBorderProperty(pMergedProperties, PROP_RIGHT_BORDER, rStyleInfo, aBorderLine)) if (lcl_extractTableBorderProperty(pMergedProperties, PROP_RIGHT_BORDER, rStyleInfo, aBorderLine))
{ {
aGrabBag[nGrabBagSize].Name = "TableStyleRightBorder"; aGrabBag["TableStyleRightBorder"] = uno::makeAny( aBorderLine );
aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine );
nGrabBagSize++;
} }
#ifdef DEBUG_DOMAINMAPPER #ifdef DEBUG_DOMAINMAPPER
...@@ -426,6 +413,15 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo ...@@ -426,6 +413,15 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
} }
} }
// This is the one preserving just all the table look attributes.
boost::optional<PropertyMap::Property> oTableLook = m_aTableProperties->getProperty(META_PROP_TABLE_LOOK);
if (oTableLook)
{
aGrabBag["TableStyleLook"] = oTableLook->second;
m_aTableProperties->Erase(oTableLook->first);
}
// This is just the "val" attribute's numeric value.
const boost::optional<PropertyMap::Property> aTblLook = m_aTableProperties->getProperty(PROP_TBL_LOOK); const boost::optional<PropertyMap::Property> aTblLook = m_aTableProperties->getProperty(PROP_TBL_LOOK);
if(aTblLook) if(aTblLook)
{ {
...@@ -442,10 +438,9 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo ...@@ -442,10 +438,9 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
dmapper_logger->endElement(); dmapper_logger->endElement();
#endif #endif
if( nGrabBagSize > 0 ) if (!aGrabBag.empty())
{ {
aGrabBag.realloc( nGrabBagSize ); m_aTableProperties->Insert( PROP_TABLE_INTEROP_GRAB_BAG, uno::makeAny( aGrabBag.getAsConstPropertyValueList() ) );
m_aTableProperties->Insert( PROP_TABLE_INTEROP_GRAB_BAG, uno::makeAny( aGrabBag ) );
} }
m_aTableProperties->getValue( TablePropertyMap::GAP_HALF, nGapHalf ); m_aTableProperties->getValue( TablePropertyMap::GAP_HALF, nGapHalf );
......
...@@ -85,8 +85,27 @@ bool DomainMapperTableManager::attribute(Id nName, Value& rValue) ...@@ -85,8 +85,27 @@ bool DomainMapperTableManager::attribute(Id nName, Value& rValue)
TablePropertyMapPtr pPropMap(new TablePropertyMap()); TablePropertyMapPtr pPropMap(new TablePropertyMap());
pPropMap->Insert(PROP_TBL_LOOK, uno::makeAny(rValue.getInt())); pPropMap->Insert(PROP_TBL_LOOK, uno::makeAny(rValue.getInt()));
insertTableProps(pPropMap); insertTableProps(pPropMap);
m_aTableLook["val"] = uno::makeAny(rValue.getInt());
} }
break; break;
case NS_ooxml::LN_CT_TblLook_noVBand:
m_aTableLook["noVBand"] = uno::makeAny(rValue.getInt());
break;
case NS_ooxml::LN_CT_TblLook_noHBand:
m_aTableLook["noHBand"] = uno::makeAny(rValue.getInt());
break;
case NS_ooxml::LN_CT_TblLook_lastColumn:
m_aTableLook["lastColumn"] = uno::makeAny(rValue.getInt());
break;
case NS_ooxml::LN_CT_TblLook_lastRow:
m_aTableLook["lastRow"] = uno::makeAny(rValue.getInt());
break;
case NS_ooxml::LN_CT_TblLook_firstColumn:
m_aTableLook["firstColumn"] = uno::makeAny(rValue.getInt());
break;
case NS_ooxml::LN_CT_TblLook_firstRow:
m_aTableLook["firstRow"] = uno::makeAny(rValue.getInt());
break;
default: default:
bRet = false; bRet = false;
} }
...@@ -94,6 +113,14 @@ bool DomainMapperTableManager::attribute(Id nName, Value& rValue) ...@@ -94,6 +113,14 @@ bool DomainMapperTableManager::attribute(Id nName, Value& rValue)
return bRet; return bRet;
} }
void DomainMapperTableManager::finishTableLook()
{
TablePropertyMapPtr pPropMap(new TablePropertyMap());
pPropMap->Insert(META_PROP_TABLE_LOOK, uno::makeAny(m_aTableLook.getAsConstPropertyValueList()));
m_aTableLook.clear();
insertTableProps(pPropMap);
}
bool DomainMapperTableManager::sprm(Sprm & rSprm) bool DomainMapperTableManager::sprm(Sprm & rSprm)
{ {
#ifdef DEBUG_DOMAINMAPPER #ifdef DEBUG_DOMAINMAPPER
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "StyleSheetTable.hxx" #include "StyleSheetTable.hxx"
#include <com/sun/star/text/XTextRange.hpp> #include <com/sun/star/text/XTextRange.hpp>
#include <vector> #include <vector>
#include <comphelper/sequenceashashmap.hxx>
namespace writerfilter { namespace writerfilter {
namespace dmapper { namespace dmapper {
...@@ -45,6 +46,8 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t ...@@ -45,6 +46,8 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t
sal_Int32 m_nTableWidth; //might be set directly or has to be calculated from the column positions sal_Int32 m_nTableWidth; //might be set directly or has to be calculated from the column positions
bool m_bOOXML; bool m_bOOXML;
OUString m_sTableStyleName; OUString m_sTableStyleName;
/// Grab-bag of table look attributes for preserving.
comphelper::SequenceAsHashMap m_aTableLook;
std::vector< TablePositionHandlerPtr > m_aTablePositions; std::vector< TablePositionHandlerPtr > m_aTablePositions;
std::vector< TablePositionHandlerPtr > m_aTmpPosition; ///< Temporarily stores the position to compare it later std::vector< TablePositionHandlerPtr > m_aTmpPosition; ///< Temporarily stores the position to compare it later
std::vector< TablePropertyMapPtr > m_aTmpTableProperties; ///< Temporarily stores the table properties until end of row std::vector< TablePropertyMapPtr > m_aTmpTableProperties; ///< Temporarily stores the table properties until end of row
...@@ -94,6 +97,8 @@ public: ...@@ -94,6 +97,8 @@ public:
IntVectorPtr getCurrentCellWidths( ); IntVectorPtr getCurrentCellWidths( );
const OUString& getTableStyleName() const { return m_sTableStyleName; } const OUString& getTableStyleName() const { return m_sTableStyleName; }
/// Turn the attributes collected so far in m_aTableLook into a property and clear the container.
void finishTableLook();
const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> getCurrentTablePosition(); const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> getCurrentTablePosition();
TablePositionHandler* getCurrentTableRealPosition(); TablePositionHandler* getCurrentTableRealPosition();
......
...@@ -395,6 +395,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const ...@@ -395,6 +395,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_CELL_DIRECTION: sName = "CellDirection"; break; case PROP_CELL_DIRECTION: sName = "CellDirection"; break;
case PROP_SDT_END_BEFORE: sName = "SdtEndBefore"; break; case PROP_SDT_END_BEFORE: sName = "SdtEndBefore"; break;
case PROP_PARA_SDT_END_BEFORE: sName = "ParaSdtEndBefore"; break; case PROP_PARA_SDT_END_BEFORE: sName = "ParaSdtEndBefore"; break;
case META_PROP_TABLE_LOOK: sName = "TableStyleLook"; break;
} }
::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt = ::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName )); m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
......
...@@ -367,6 +367,7 @@ enum PropertyIds ...@@ -367,6 +367,7 @@ enum PropertyIds
,PROP_CELL_DIRECTION ,PROP_CELL_DIRECTION
,PROP_SDT_END_BEFORE ,PROP_SDT_END_BEFORE
,PROP_PARA_SDT_END_BEFORE ,PROP_PARA_SDT_END_BEFORE
,META_PROP_TABLE_LOOK
}; };
struct PropertyNameSupplier_Impl; struct PropertyNameSupplier_Impl;
class PropertyNameSupplier class PropertyNameSupplier
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment