Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3110

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/10/3110/1

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

Change-Id: I28e66ed19e22f0e520f6b16a86a9e032e03d5bd8
---
M writerfilter/source/dmapper/DomainMapperTableHandler.cxx
M writerfilter/source/dmapper/DomainMapperTableManager.cxx
M writerfilter/source/dmapper/MeasureHandler.hxx
M writerfilter/source/dmapper/PropertyIds.cxx
M writerfilter/source/dmapper/PropertyIds.hxx
M writerfilter/source/dmapper/PropertyMap.hxx
6 files changed, 47 insertions(+), 15 deletions(-)



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 @@
         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 @@
         }
 
         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 1f9853b..2cf7e53 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -114,7 +114,23 @@
                     {
                         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 );
@@ -474,13 +490,6 @@
              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
@@ -517,10 +526,14 @@
     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 );
@@ -539,7 +552,7 @@
             }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;
@@ -570,7 +583,7 @@
         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 @@
 
     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 @@
             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 @@
         ,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 @@
         CELL_MAR_TOP,
         CELL_MAR_BOTTOM,
         TABLE_WIDTH,
+        TABLE_WIDTH_TYPE,
         GAP_HALF,
         LEFT_MARGIN,
         HORI_ORIENT,

-- 
To view, visit https://gerrit.libreoffice.org/3110
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I28e66ed19e22f0e520f6b16a86a9e032e03d5bd8
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Sven Jacobi <Sven-Jacobi@gmx.de>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.