[Libreoffice-commits] core.git: Branch 'distro/suse/suse-4.0' - sw/qa writerfilter/source
Miklos Vajna
vmiklos at suse.cz
Thu May 23 07:44:04 PDT 2013
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 2
sw/qa/extras/rtfimport/rtfimport.cxx | 4 -
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
8 files changed, 50 insertions(+), 18 deletions(-)
New commits:
commit 361cc86a7ea8ad265a4afa03aa132d3fb5f73ff4
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Thu May 23 16:33:22 2013 +0200
bnc#819882 DOCX import: backport table-related fixes from libreoffice-4-1
6718482c072defe5d885030826fef5ef833732e9 2013-03-28 fixed table width, supporting rel table width, fixed grid handling
84f1fa190fc2b91d21b685f4d0ea99aaeea26fe0 2013-03-28 WaE: -Wsign-compare
584322cbbd063e0a8d2c18a5e6a12f213af56057 2013-03-28 fix failing testcases
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index b735879..38f3df3 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1156,7 +1156,7 @@ void Test::testFdo59273()
uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
// Was 9997, so the 4th column had ~zero width
- CPPUNIT_ASSERT_EQUAL(sal_Int16(7498), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[2].Position);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(7499), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[2].Position);
}
void Test::testN592908_Frame()
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index a22159d..e31fa98 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1024,7 +1024,7 @@ void Test::testFdo55525()
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1877), getProperty<sal_Int32>(xTable, "LeftMargin"));
// Cell width of A1 was 3332 (e.g. not set, 30% percent of total width)
uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(sal_Int16(1016), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(896), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
}
void Test::testFdo57708()
@@ -1129,7 +1129,7 @@ void Test::testFdo59953()
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
// Cell width of A1 was 4998 (e.g. not set / not wide enough, ~50% of total width)
uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(sal_Int16(7650), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(7649), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
}
void Test::testFdo59638()
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 217c7f8..2a5f503 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 ) );
@@ -455,8 +457,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 0298690..28135cc 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -113,7 +113,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( sal::static_int_cast<Id>(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( sal::static_int_cast<Id>(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 );
@@ -469,13 +485,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
@@ -512,10 +521,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 );
@@ -534,7 +547,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;
@@ -566,7 +579,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