summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorSJacobi <Sven-Jacobi@gmx.de>2013-03-28 14:12:09 +0100
committerMiklos Vajna <vmiklos@suse.cz>2013-03-28 15:56:53 +0000
commit6718482c072defe5d885030826fef5ef833732e9 (patch)
treec5eaa08f132443028b1bca84e7940728cffb34ef /writerfilter
parent0d89580eeb61ae01f1c1f2836f77ffef6a146770 (diff)
fixed table width, supporting rel table width, fixed grid handling
Change-Id: I28e66ed19e22f0e520f6b16a86a9e032e03d5bd8 Reviewed-on: https://gerrit.libreoffice.org/3110 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx15
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.cxx39
-rw-r--r--writerfilter/source/dmapper/MeasureHandler.hxx3
-rw-r--r--writerfilter/source/dmapper/PropertyIds.cxx2
-rw-r--r--writerfilter/source/dmapper/PropertyIds.hxx2
-rw-r--r--writerfilter/source/dmapper/PropertyMap.hxx1
6 files changed, 47 insertions, 15 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 8474a2fc5ffe..176f3c9fe69c 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -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 ) ;
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index 11197099ed4f..1dddd6767707 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -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++;
}
diff --git a/writerfilter/source/dmapper/MeasureHandler.hxx b/writerfilter/source/dmapper/MeasureHandler.hxx
index 1ac87ab6f819..01556145c332 100644
--- a/writerfilter/source/dmapper/MeasureHandler.hxx
+++ b/writerfilter/source/dmapper/MeasureHandler.hxx
@@ -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
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index 1fbf3d1a4af0..1d432fce134d 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -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 ));
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index b29d76017d8d..c61283c19f23 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -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
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index 50878e0822db..6bbb4c72aa46 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -499,6 +499,7 @@ public:
CELL_MAR_TOP,
CELL_MAR_BOTTOM,
TABLE_WIDTH,
+ TABLE_WIDTH_TYPE,
GAP_HALF,
LEFT_MARGIN,
HORI_ORIENT,