Kaydet (Commit) 01292f17 authored tarafından Miklos Vajna's avatar Miklos Vajna

fdo#44053 fix RTF import of implicit horizontal table cell merges

üst 2f1c1708
...@@ -48,7 +48,7 @@ using namespace ::com::sun::star; ...@@ -48,7 +48,7 @@ using namespace ::com::sun::star;
using namespace ::std; using namespace ::std;
DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) : DomainMapperTableManager::DomainMapperTableManager(bool bOOXML, bool bImplicitMerges) :
m_nRow(0), m_nRow(0),
m_nCell(0), m_nCell(0),
m_nGridSpan(1), m_nGridSpan(1),
...@@ -56,6 +56,7 @@ DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) : ...@@ -56,6 +56,7 @@ DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) :
m_nHeaderRepeat(0), m_nHeaderRepeat(0),
m_nTableWidth(0), m_nTableWidth(0),
m_bOOXML( bOOXML ), m_bOOXML( bOOXML ),
m_bImplicitMerges(bImplicitMerges),
m_pTablePropsHandler( new TablePropertiesHandler( bOOXML ) ) m_pTablePropsHandler( new TablePropertiesHandler( bOOXML ) )
{ {
m_pTablePropsHandler->SetTableManager( this ); m_pTablePropsHandler->SetTableManager( this );
...@@ -437,12 +438,12 @@ void DomainMapperTableManager::endOfRowAction() ...@@ -437,12 +438,12 @@ void DomainMapperTableManager::endOfRowAction()
for( ; aGridSpanIter != pCurrentSpans->end(); ++aGridSpanIter) for( ; aGridSpanIter != pCurrentSpans->end(); ++aGridSpanIter)
nGrids += *aGridSpanIter; nGrids += *aGridSpanIter;
//determine table width
double nFullWidth = m_nTableWidth;
//the positions have to be distibuted in a range of 10000
const double nFullWidthRelative = 10000.;
if( pTableGrid->size() == nGrids ) if( pTableGrid->size() == nGrids )
{ {
//determine table width
double nFullWidth = m_nTableWidth;
//the positions have to be distibuted in a range of 10000
const double nFullWidthRelative = 10000.;
uno::Sequence< text::TableColumnSeparator > aSeparators( m_nCell - 1 ); uno::Sequence< text::TableColumnSeparator > aSeparators( m_nCell - 1 );
text::TableColumnSeparator* pSeparators = aSeparators.getArray(); text::TableColumnSeparator* pSeparators = aSeparators.getArray();
sal_Int16 nLastRelPos = 0; sal_Int16 nLastRelPos = 0;
...@@ -469,6 +470,33 @@ void DomainMapperTableManager::endOfRowAction() ...@@ -469,6 +470,33 @@ void DomainMapperTableManager::endOfRowAction()
TablePropertyMapPtr pPropMap( new TablePropertyMap ); TablePropertyMapPtr pPropMap( new TablePropertyMap );
pPropMap->Insert( PROP_TABLE_COLUMN_SEPARATORS, false, uno::makeAny( aSeparators ) ); pPropMap->Insert( PROP_TABLE_COLUMN_SEPARATORS, false, uno::makeAny( aSeparators ) );
#ifdef DEBUG_DOMAINMAPPER
dmapper_logger->startElement("rowProperties");
pPropMap->dumpXml( dmapper_logger );
dmapper_logger->endElement();
#endif
insertRowProps(pPropMap);
}
else if (m_bImplicitMerges)
{
// More grid than cells definitions? Then take the last ones.
// This feature is used by the RTF implicit horizontal cell merges.
uno::Sequence< text::TableColumnSeparator > aSeparators(m_nCell - 1);
text::TableColumnSeparator* pSeparators = aSeparators.getArray();
sal_Int16 nSum = 0;
sal_uInt32 nPos = 0;
// Ignoring the i=0 case means we assume that the width of the last cell matches the table width
for (int i = m_nCell; i > 1; i--)
{
nSum += (*pTableGrid.get())[pTableGrid->size() - i]; // Size of the current cell
pSeparators[nPos].Position = nSum * nFullWidthRelative / nFullWidth; // Relative position
pSeparators[nPos].IsVisible = sal_True;
nPos++;
}
TablePropertyMapPtr pPropMap( new TablePropertyMap );
pPropMap->Insert( PROP_TABLE_COLUMN_SEPARATORS, false, uno::makeAny( aSeparators ) );
#ifdef DEBUG_DOMAINMAPPER #ifdef DEBUG_DOMAINMAPPER
dmapper_logger->startElement("rowProperties"); dmapper_logger->startElement("rowProperties");
pPropMap->dumpXml( dmapper_logger ); pPropMap->dumpXml( dmapper_logger );
......
...@@ -50,6 +50,7 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t ...@@ -50,6 +50,7 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t
sal_Int32 m_nHeaderRepeat; //counter of repeated headers - if == -1 then the repeating stops sal_Int32 m_nHeaderRepeat; //counter of repeated headers - if == -1 then the repeating stops
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;
bool m_bImplicitMerges;
::rtl::OUString m_sTableStyleName; ::rtl::OUString m_sTableStyleName;
PropertyMapPtr m_pTableStyleTextProperies; PropertyMapPtr m_pTableStyleTextProperies;
...@@ -63,7 +64,7 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t ...@@ -63,7 +64,7 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t
public: public:
DomainMapperTableManager(bool bOOXML); DomainMapperTableManager(bool bOOXML, bool bImplicitMerges);
virtual ~DomainMapperTableManager(); virtual ~DomainMapperTableManager();
// use this method to avoid adding the properties for the table // use this method to avoid adding the properties for the table
......
...@@ -546,7 +546,7 @@ public: ...@@ -546,7 +546,7 @@ public:
void appendTableManager( ) void appendTableManager( )
{ {
boost::shared_ptr< DomainMapperTableManager > pMngr( boost::shared_ptr< DomainMapperTableManager > pMngr(
new DomainMapperTableManager( m_eDocumentType == DOCUMENT_OOXML || m_eDocumentType == DOCUMENT_RTF ) ); new DomainMapperTableManager( m_eDocumentType == DOCUMENT_OOXML || m_eDocumentType == DOCUMENT_RTF, m_eDocumentType == DOCUMENT_RTF ) );
m_aTableManagers.push( pMngr ); m_aTableManagers.push( pMngr );
} }
......
...@@ -260,7 +260,6 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x ...@@ -260,7 +260,6 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
m_aFontIndexes(), m_aFontIndexes(),
m_aColorTable(), m_aColorTable(),
m_bFirstRun(true), m_bFirstRun(true),
m_bFirstRow(true),
m_bNeedPap(true), m_bNeedPap(true),
m_bNeedCr(false), m_bNeedCr(false),
m_bNeedPar(true), m_bNeedPar(true),
...@@ -452,8 +451,6 @@ void RTFDocumentImpl::parBreak() ...@@ -452,8 +451,6 @@ void RTFDocumentImpl::parBreak()
// If we are not in a table, then the next table row will be the first one. // If we are not in a table, then the next table row will be the first one.
RTFValue::Pointer_t pValue = m_aStates.top().aParagraphSprms.find(NS_sprm::LN_PFInTable); RTFValue::Pointer_t pValue = m_aStates.top().aParagraphSprms.find(NS_sprm::LN_PFInTable);
if (!pValue.get())
m_bFirstRow = true;
// start new one // start new one
Mapper().startParagraphGroup(); Mapper().startParagraphGroup();
...@@ -1362,7 +1359,6 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) ...@@ -1362,7 +1359,6 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
case RTF_ROW: case RTF_ROW:
case RTF_NESTROW: case RTF_NESTROW:
{ {
m_bFirstRow = false;
if (m_aStates.top().nCells) if (m_aStates.top().nCells)
{ {
// Make a backup before we start popping elements // Make a backup before we start popping elements
...@@ -2281,11 +2277,8 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) ...@@ -2281,11 +2277,8 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
{ {
int nCellX = nParam - m_aStates.top().nCellX; int nCellX = nParam - m_aStates.top().nCellX;
m_aStates.top().nCellX = nParam; m_aStates.top().nCellX = nParam;
if (m_bFirstRow) RTFValue::Pointer_t pXValue(new RTFValue(nCellX));
{ m_aStates.top().aTableRowSprms->push_back(make_pair(NS_ooxml::LN_CT_TblGridBase_gridCol, pXValue));
RTFValue::Pointer_t pXValue(new RTFValue(nCellX));
m_aStates.top().aTableRowSprms->push_back(make_pair(NS_ooxml::LN_CT_TblGridBase_gridCol, pXValue));
}
m_aStates.top().nCells++; m_aStates.top().nCells++;
// Push cell properties. // Push cell properties.
......
...@@ -370,8 +370,6 @@ namespace writerfilter { ...@@ -370,8 +370,6 @@ namespace writerfilter {
/// Color index <-> RGB color value map /// Color index <-> RGB color value map
std::vector<sal_uInt32> m_aColorTable; std::vector<sal_uInt32> m_aColorTable;
bool m_bFirstRun; bool m_bFirstRun;
/// If this is the first row in a table - there we send cell widths.
bool m_bFirstRow;
/// If paragraph properties should be emitted on next run. /// If paragraph properties should be emitted on next run.
bool m_bNeedPap; bool m_bNeedPap;
/// If we need to emit a CR at the end of substream. /// If we need to emit a CR at the end of substream.
......
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