Kaydet (Commit) 6718482c authored tarafından SJacobi's avatar SJacobi Kaydeden (comit) Miklos Vajna

fixed table width, supporting rel table width, fixed grid handling

Change-Id: I28e66ed19e22f0e520f6b16a86a9e032e03d5bd8
Reviewed-on: https://gerrit.libreoffice.org/3110Reviewed-by: 's avatarMiklos Vajna <vmiklos@suse.cz>
Tested-by: 's avatarMiklos Vajna <vmiklos@suse.cz>
üst 0d89580e
......@@ -24,6 +24,7 @@
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
#include <com/sun/star/text/SizeType.hpp>
#include <dmapperLoggers.hxx>
#ifdef DEBUG_DMAPPER_TABLE_HANDLER
......@@ -318,6 +319,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
sal_Int32 nGapHalf = 0;
sal_Int32 nLeftMargin = 0;
sal_Int32 nTableWidth = 0;
sal_Int32 nTableWidthType = text::SizeType::FIX;
PropertyMap::iterator aTableStyleIter =
m_aTableProperties->find( PropertyDefinition( META_PROP_TABLE_STYLE_NAME, false ) );
......@@ -457,8 +459,17 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
}
m_aTableProperties->getValue( TablePropertyMap::TABLE_WIDTH, nTableWidth );
if( nTableWidth > 0 )
m_aTableProperties->Insert( PROP_WIDTH, false, uno::makeAny( nTableWidth ));
m_aTableProperties->getValue( TablePropertyMap::TABLE_WIDTH_TYPE, nTableWidthType );
if( nTableWidthType == text::SizeType::FIX )
{
if( nTableWidth > 0 )
m_aTableProperties->Insert( PROP_WIDTH, false, uno::makeAny( nTableWidth ));
}
else
{
m_aTableProperties->Insert( PROP_RELATIVE_WIDTH, false, uno::makeAny( sal_Int16( nTableWidth ) ) );
m_aTableProperties->Insert( PROP_IS_WIDTH_RELATIVE, false, uno::makeAny( sal_Bool( sal_True ) ) );
}
sal_Int32 nHoriOrient = text::HoriOrientation::LEFT_AND_WIDTH;
m_aTableProperties->getValue( TablePropertyMap::HORI_ORIENT, nHoriOrient ) ;
......
......@@ -115,7 +115,23 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
{
m_nTableWidth = pMeasureHandler->getMeasureValue();
if( m_nTableWidth )
{
pPropMap->setValue( TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::FIX );
pPropMap->setValue( TablePropertyMap::TABLE_WIDTH, m_nTableWidth );
}
else if( pMeasureHandler->getUnit() == NS_ooxml::LN_Value_ST_TblWidth_pct )
{
sal_Int32 nPercent = pMeasureHandler->getValue() / 50;
if(nPercent > 100)
nPercent = 100;
pPropMap->setValue( TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::VARIABLE );
pPropMap->setValue( TablePropertyMap::TABLE_WIDTH, nPercent );
}
else if( pMeasureHandler->getUnit() == NS_ooxml::LN_Value_ST_TblWidth_auto )
{
pPropMap->setValue( TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::VARIABLE );
pPropMap->setValue( TablePropertyMap::TABLE_WIDTH, 100 );
}
}
#ifdef DEBUG_DOMAINMAPPER
pPropMap->dumpXml( dmapper_logger );
......@@ -477,13 +493,6 @@ void DomainMapperTableManager::endOfRowAction()
m_nTableWidth += *aCellIter++;
}
if( m_nTableWidth > 0)
{
TablePropertyMapPtr pPropMap( new TablePropertyMap );
pPropMap->setValue( TablePropertyMap::TABLE_WIDTH, m_nTableWidth );
insertTableProps(pPropMap);
}
#ifdef DEBUG_DOMAINMAPPER
dmapper_logger->endElement();
#endif
......@@ -520,10 +529,14 @@ 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.;
// sj: the grid is having no units... they is containing only relative values.
// a table with a grid of "1:2:1" looks identical as if the table is having
// a grid of "20:40:20" and it doesn't have to do something with the tableWidth
// -> so we have get the sum of each grid entry for the fullWidthRelative:
int nFullWidthRelative = 0;
for (unsigned int i = 0 ; i < (*pTableGrid.get()).size(); i++ )
nFullWidthRelative += (*pTableGrid.get())[ i ];
if( pTableGrid->size() == ( m_nGridBefore + nGrids + m_nGridAfter ) && m_nCell.back( ) > 0 )
{
uno::Sequence< text::TableColumnSeparator > aSeparators( m_nCell.back( ) - 1 );
......@@ -542,7 +555,7 @@ void DomainMapperTableManager::endOfRowAction()
}while( --nGridCount );
sal_Int16 nRelPos =
sal::static_int_cast< sal_Int16 >( floor( fGridWidth * nFullWidthRelative / nFullWidth + 0.5 ) );
sal::static_int_cast< sal_Int16 >((fGridWidth * 10000) / nFullWidthRelative);
pSeparators[nBorder].Position = nRelPos + nLastRelPos;
pSeparators[nBorder].IsVisible = sal_True;
......@@ -574,7 +587,7 @@ void DomainMapperTableManager::endOfRowAction()
for (sal_uInt32 i = 0; i < pCellWidths->size() - 1; ++i)
{
nSum += (*pCellWidths.get())[i];
pSeparators[nPos].Position = nSum * nFullWidthRelative / nFullWidth;
pSeparators[nPos].Position = (nSum * 10000) / nFullWidthRelative; // Relative position
pSeparators[nPos].IsVisible = sal_True;
nPos++;
}
......
......@@ -46,6 +46,9 @@ public:
sal_Int32 getMeasureValue() const;
sal_Int32 getValue() const { return m_nMeasureValue; }
sal_Int32 getUnit() const { return m_nUnit; }
sal_Int16 GetRowHeightSizeType() const { return m_nRowHeightSizeType;}
};
typedef boost::shared_ptr
......
......@@ -320,6 +320,8 @@ const OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_EMBED_FONTS: sName = "EmbedFonts"; break;
case PROP_EMBED_SYSTEM_FONTS: sName = "EmbedSystemFonts"; break;
case PROP_SHADOW_FORMAT: sName = "ShadowFormat"; break;
case PROP_RELATIVE_WIDTH: sName = "RelativeWidth"; break;
case PROP_IS_WIDTH_RELATIVE: sName = "IsWidthRelative"; break;
}
::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
......
......@@ -292,6 +292,8 @@ enum PropertyIds
,PROP_EMBED_FONTS
,PROP_EMBED_SYSTEM_FONTS
,PROP_SHADOW_FORMAT
,PROP_RELATIVE_WIDTH
,PROP_IS_WIDTH_RELATIVE
};
struct PropertyNameSupplier_Impl;
class PropertyNameSupplier
......
......@@ -499,6 +499,7 @@ public:
CELL_MAR_TOP,
CELL_MAR_BOTTOM,
TABLE_WIDTH,
TABLE_WIDTH_TYPE,
GAP_HALF,
LEFT_MARGIN,
HORI_ORIENT,
......
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