n#779642: table positions need to be stacked to handle nested table

This commit is contained in:
Cédric Bosdonnat
2013-02-21 10:27:31 +01:00
parent b6ff19fba3
commit 36c64bc194
3 changed files with 27 additions and 7 deletions

View File

@@ -717,7 +717,7 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel)
uno::Reference<text::XTextRange> xStart;
uno::Reference<text::XTextRange> xEnd;
// If we want to make this table a floating one.
uno::Sequence<beans::PropertyValue> aFrameProperties = m_rDMapper_Impl.getTableManager().getTablePosition();
uno::Sequence<beans::PropertyValue> aFrameProperties = m_rDMapper_Impl.getTableManager().getCurrentTablePosition();
bool bFloating = aFrameProperties.hasElements();
// Additional checks: if we can do this.
if (bFloating && (*m_pTableSeq)[0].getLength() > 0 && (*m_pTableSeq)[0][0].getLength() > 0)

View File

@@ -24,7 +24,6 @@
#include <CellMarginHandler.hxx>
#include <ConversionHelper.hxx>
#include <MeasureHandler.hxx>
#include <TablePositionHandler.hxx>
#include <TDefTableHandler.hxx>
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/SizeType.hpp>
@@ -322,9 +321,14 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
if (pProperties.get())
{
TablePositionHandlerPtr pHandler( new TablePositionHandler );
TablePositionHandlerPtr pHandler = m_aTablePositions.back();
if ( !pHandler )
{
m_aTablePositions.pop_back();
pHandler.reset( new TablePositionHandler );
m_aTablePositions.push_back( pHandler );
}
pProperties->resolve(*pHandler);
m_aTablePosition = pHandler->getTablePosition();
}
}
break;
@@ -360,6 +364,14 @@ boost::shared_ptr< vector< sal_Int32 > > DomainMapperTableManager::getCurrentCel
return m_aCellWidths.back( );
}
const uno::Sequence<beans::PropertyValue> DomainMapperTableManager::getCurrentTablePosition( )
{
if ( !m_aTablePositions.empty( ) && m_aTablePositions.back() )
return m_aTablePositions.back( )->getTablePosition();
else
return uno::Sequence< beans::PropertyValue >( 0 );
}
void DomainMapperTableManager::startLevel( )
{
DomainMapperTableManager_Base_t::startLevel( );
@@ -375,9 +387,11 @@ void DomainMapperTableManager::startLevel( )
IntVectorPtr pNewGrid( new vector<sal_Int32> );
IntVectorPtr pNewSpans( new vector<sal_Int32> );
IntVectorPtr pNewCellWidths( new vector<sal_Int32> );
TablePositionHandlerPtr pNewPositionHandler;
m_aTableGrid.push_back( pNewGrid );
m_aGridSpans.push_back( pNewSpans );
m_aCellWidths.push_back( pNewCellWidths );
m_aTablePositions.push_back( pNewPositionHandler );
m_nCell.push_back( 0 );
m_nTableWidth = 0;
@@ -394,6 +408,7 @@ void DomainMapperTableManager::endLevel( )
m_nCell.pop_back( );
m_nTableWidth = 0;
DomainMapperTableManager_Base_t::endLevel( );
#ifdef DEBUG_DOMAINMAPPER
dmapper_logger->startElement("dmappertablemanager.endLevel");
@@ -403,6 +418,10 @@ void DomainMapperTableManager::endLevel( )
dmapper_logger->endElement();
#endif
// Pop back the table position after endLevel as it's used
// in the endTable method called in endLevel.
m_aTablePositions.pop_back();
}
@@ -576,7 +595,6 @@ void DomainMapperTableManager::clearData()
m_nRow = m_nCellBorderIndex = m_nHeaderRepeat = m_nTableWidth = 0;
m_sTableStyleName = OUString();
m_pTableStyleTextProperies.reset();
m_aTablePosition = uno::Sequence<beans::PropertyValue>(0);
}

View File

@@ -20,6 +20,7 @@
#define INCLUDED_DOMAIN_MAPPER_TABLE_MANAGER_HXX
#include "TablePropertiesHandler.hxx"
#include <TablePositionHandler.hxx>
#include <resourcemodel/TableManager.hxx>
#include <PropertyMap.hxx>
@@ -44,7 +45,7 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t
sal_Int32 m_nTableWidth; //might be set directly or has to be calculated from the column positions
bool m_bOOXML;
OUString m_sTableStyleName;
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> m_aTablePosition;
std::vector< TablePositionHandlerPtr > m_aTablePositions;
PropertyMapPtr m_pTableStyleTextProperies;
::std::vector< IntVectorPtr > m_aTableGrid;
@@ -81,7 +82,8 @@ public:
IntVectorPtr getCurrentCellWidths( );
const OUString& getTableStyleName() const { return m_sTableStyleName; }
const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> getTablePosition() { return m_aTablePosition; }
const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> getCurrentTablePosition();
/// copy the text properties of the table style and its parent into pContext
void CopyTextProperties(PropertyMapPtr pContext, StyleSheetTablePtr pStyleSheetTable);