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;
using namespace ::std;
DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) :
DomainMapperTableManager::DomainMapperTableManager(bool bOOXML, bool bImplicitMerges) :
m_nRow(0),
m_nCell(0),
m_nGridSpan(1),
......@@ -56,6 +56,7 @@ DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) :
m_nHeaderRepeat(0),
m_nTableWidth(0),
m_bOOXML( bOOXML ),
m_bImplicitMerges(bImplicitMerges),
m_pTablePropsHandler( new TablePropertiesHandler( bOOXML ) )
{
m_pTablePropsHandler->SetTableManager( this );
......@@ -437,12 +438,12 @@ void DomainMapperTableManager::endOfRowAction()
for( ; aGridSpanIter != pCurrentSpans->end(); ++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 )
{
//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 );
text::TableColumnSeparator* pSeparators = aSeparators.getArray();
sal_Int16 nLastRelPos = 0;
......@@ -469,6 +470,33 @@ void DomainMapperTableManager::endOfRowAction()
TablePropertyMapPtr pPropMap( new TablePropertyMap );
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
dmapper_logger->startElement("rowProperties");
pPropMap->dumpXml( dmapper_logger );
......
......@@ -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_nTableWidth; //might be set directly or has to be calculated from the column positions
bool m_bOOXML;
bool m_bImplicitMerges;
::rtl::OUString m_sTableStyleName;
PropertyMapPtr m_pTableStyleTextProperies;
......@@ -63,7 +64,7 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t
public:
DomainMapperTableManager(bool bOOXML);
DomainMapperTableManager(bool bOOXML, bool bImplicitMerges);
virtual ~DomainMapperTableManager();
// use this method to avoid adding the properties for the table
......
......@@ -546,7 +546,7 @@ public:
void appendTableManager( )
{
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 );
}
......
......@@ -260,7 +260,6 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
m_aFontIndexes(),
m_aColorTable(),
m_bFirstRun(true),
m_bFirstRow(true),
m_bNeedPap(true),
m_bNeedCr(false),
m_bNeedPar(true),
......@@ -452,8 +451,6 @@ void RTFDocumentImpl::parBreak()
// 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);
if (!pValue.get())
m_bFirstRow = true;
// start new one
Mapper().startParagraphGroup();
......@@ -1362,7 +1359,6 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
case RTF_ROW:
case RTF_NESTROW:
{
m_bFirstRow = false;
if (m_aStates.top().nCells)
{
// Make a backup before we start popping elements
......@@ -2281,11 +2277,8 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
{
int nCellX = nParam - m_aStates.top().nCellX;
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++;
// Push cell properties.
......
......@@ -370,8 +370,6 @@ namespace writerfilter {
/// Color index <-> RGB color value map
std::vector<sal_uInt32> m_aColorTable;
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.
bool m_bNeedPap;
/// 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