[Libreoffice-commits] core.git: 2 commits - sw/qa writerfilter/source
SJacobi
Sven-Jacobi at gmx.de
Thu Mar 28 08:57:14 PDT 2013
sw/qa/extras/ooxmlimport/data/table_width.docx |binary
writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 15 +++++
writerfilter/source/dmapper/DomainMapperTableManager.cxx | 39 ++++++++++-----
writerfilter/source/dmapper/MeasureHandler.hxx | 3 +
writerfilter/source/dmapper/PropertyIds.cxx | 2
writerfilter/source/dmapper/PropertyIds.hxx | 2
writerfilter/source/dmapper/PropertyMap.hxx | 1
7 files changed, 47 insertions(+), 15 deletions(-)
New commits:
commit d9f882a5e399708cb0eecedebee49e7ed4a511a3
Author: SJacobi <Sven-Jacobi at gmx.de>
Date: Thu Mar 28 14:42:07 2013 +0100
added table width test document
Change-Id: I313eda77cef5f4747decb5ab7c261012954a0a32
Reviewed-on: https://gerrit.libreoffice.org/3112
Reviewed-by: Miklos Vajna <vmiklos at suse.cz>
Tested-by: Miklos Vajna <vmiklos at suse.cz>
diff --git a/sw/qa/extras/ooxmlimport/data/table_width.docx b/sw/qa/extras/ooxmlimport/data/table_width.docx
new file mode 100644
index 0000000..26deb6d
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/table_width.docx differ
commit 6718482c072defe5d885030826fef5ef833732e9
Author: SJacobi <Sven-Jacobi at gmx.de>
Date: Thu Mar 28 14:12:09 2013 +0100
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 at suse.cz>
Tested-by: Miklos Vajna <vmiklos at suse.cz>
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 8474a2f..176f3c9 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 1119709..1dddd67 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 1ac87ab..0155614 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 1fbf3d1..1d432fc 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 b29d760..c61283c 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 50878e0..6bbb4c7 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,
More information about the Libreoffice-commits
mailing list