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/3175

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/75/3175/1

ooxmlimport: conditional table styles fixed

Change-Id: I84f1d7c718dfc120b76364479ca68f63d2549b9f
---
A sw/qa/extras/ooxmlimport/data/conditionalstyles-tbllook.docx
A writerfilter/source/.DS_Store
M writerfilter/source/dmapper/DomainMapperTableHandler.cxx
M writerfilter/source/dmapper/DomainMapperTableManager.cxx
M writerfilter/source/dmapper/PropertyIds.cxx
M writerfilter/source/dmapper/PropertyIds.hxx
M writerfilter/source/dmapper/StyleSheetTable.cxx
7 files changed, 111 insertions(+), 69 deletions(-)



diff --git a/sw/qa/extras/ooxmlimport/data/conditionalstyles-tbllook.docx 
b/sw/qa/extras/ooxmlimport/data/conditionalstyles-tbllook.docx
new file mode 100644
index 0000000..4222d63
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/conditionalstyles-tbllook.docx
Binary files differ
diff --git a/writerfilter/source/.DS_Store b/writerfilter/source/.DS_Store
new file mode 100644
index 0000000..83b7315
--- /dev/null
+++ b/writerfilter/source/.DS_Store
Binary files differ
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 176f3c9..6a0609b 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -263,6 +263,7 @@
     sal_Int32 nRightBorderDistance;
     sal_Int32 nTopBorderDistance;
     sal_Int32 nBottomBorderDistance;
+    sal_Int32 nTblLook;
     sal_Int32 nNestLevel;
     PropertyMapPtr pTableDefaults;
     PropertyMapPtr pTableBorders;
@@ -274,6 +275,7 @@
     , nRightBorderDistance(DEF_BORDER_DIST)
     , nTopBorderDistance(0)
     , nBottomBorderDistance(0)
+    , nTblLook(0x4a0)
     , nNestLevel(0)
     , pTableDefaults(new PropertyMap)
     , pTableBorders(new PropertyMap)
@@ -358,6 +360,14 @@
                 dmapper_logger->endElement();
 #endif
             }
+        }
+
+        PropertyMap::iterator aTblLookIter =
+        aTblLookIter = m_aTableProperties->find( PropertyDefinition( PROP_TBL_LOOK, false ) );
+        if(aTblLookIter != m_aTableProperties->end())
+        {
+            aTblLookIter->second >>= rInfo.nTblLook;
+            m_aTableProperties->erase( aTblLookIter );
         }
 
         // Set the table default attributes for the cells
@@ -494,6 +504,19 @@
     return pTableStyle;
 }
 
+#define CNF_FIRST_ROW               0x800
+#define CNF_LAST_ROW                0x400
+#define CNF_FIRST_COLUMN            0x200
+#define CNF_LAST_COLUMN             0x100
+#define CNF_ODD_VBAND               0x080
+#define CNF_EVEN_VBAND              0x040
+#define CNF_ODD_HBAND               0x020
+#define CNF_EVEN_HBAND              0x010
+#define CNF_FIRST_ROW_LAST_COLUMN   0x008
+#define CNF_FIRST_ROW_FIRST_COLUMN  0x004
+#define CNF_LAST_ROW_LAST_COLUMN    0x002
+#define CNF_LAST_ROW_FIRST_COLUMN   0x001
+
 CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(TableInfo & rInfo)
 {
 #ifdef DEBUG_DMAPPER_TABLE_HANDLER
@@ -523,21 +546,30 @@
         PropertyMapVector1::const_iterator aCellIterator = aRowOfCellsIterator->begin();
         PropertyMapVector1::const_iterator aCellIteratorEnd = aRowOfCellsIterator->end();
 
-        // Get the row style properties
-        sal_Int32 nRowStyleMask = sal_Int32( 0 );
-        PropertyMapPtr pRowProps = m_aRowProperties[nRow];
-        if ( pRowProps.get( ) )
+        sal_Int32 nRowStyleMask = 0;
+
+        if (aRowOfCellsIterator==m_aCellProperties.begin())
         {
-            PropertyMap::iterator pTcCnfStyleIt = pRowProps->find( PropertyDefinition( 
PROP_CNF_STYLE, true ) );
-            if ( pTcCnfStyleIt != pRowProps->end( ) )
-            {
-                if ( rInfo.pTableStyle )
-                {
-                    OUString sMask;
-                    pTcCnfStyleIt->second >>= sMask;
-                    nRowStyleMask = sMask.toInt32( 2 );
-                }
-                pRowProps->erase( pTcCnfStyleIt );
+            if(rInfo.nTblLook&0x20)
+                nRowStyleMask |= CNF_FIRST_ROW;     // first row style used
+        }
+        else if (aRowOfCellsIterator==aLastRowIterator)
+        {
+            if(rInfo.nTblLook&0x40)
+                nRowStyleMask |= CNF_LAST_ROW;      // last row style used
+        }
+        if(!nRowStyleMask)                          // if no row style used yet
+        {
+            // banding used only if not first and or last row style used
+            if(!(rInfo.nTblLook&0x200))
+            {   // hbanding used
+                int n = nRow + 1;
+                if(rInfo.nTblLook&0x20)
+                    n++;
+                if(n & 1)
+                    nRowStyleMask = CNF_ODD_HBAND;
+                else
+                    nRowStyleMask = CNF_EVEN_HBAND;
             }
         }
 
@@ -558,24 +590,44 @@
                 if ( rInfo.pTableDefaults->size( ) )
                     pAllCellProps->InsertProps(rInfo.pTableDefaults);
 
-                // Fill the cell properties with the ones of the style
                 sal_Int32 nCellStyleMask = 0;
-                const PropertyMap::iterator aCnfStyleIter =
-                    aCellIterator->get()->find( PropertyDefinition( PROP_CNF_STYLE, false ) );
-                if ( aCnfStyleIter != aCellIterator->get( )->end( ) )
+                if (aCellIterator==aRowOfCellsIterator->begin())
                 {
-                    if ( rInfo.pTableStyle ) {
-                        OUString sMask;
-                        aCnfStyleIter->second >>= sMask;
-                        nCellStyleMask = sMask.toInt32( 2 );
-                    }
-                    aCellIterator->get( )->erase( aCnfStyleIter );
+                    if(rInfo.nTblLook&0x80)
+                        nCellStyleMask = CNF_FIRST_COLUMN;      // first col style used
                 }
+                else if (bIsEndCol)
+                {
+                    if(rInfo.nTblLook&0x100)
+                        nCellStyleMask = CNF_LAST_COLUMN;       // last col style used
+                }
+                if(!nCellStyleMask)                 // if no cell style is used yet
+                {
+                    if(!(rInfo.nTblLook&0x400))
+                    {   // vbanding used
+                        int n = nCell + 1;
+                        if(rInfo.nTblLook&0x80)
+                            n++;
+                        if(n & 1)
+                            nCellStyleMask = CNF_ODD_VBAND;
+                        else
+                            nCellStyleMask = CNF_EVEN_VBAND;
+                    }
+                }
+                sal_Int32 nCnfStyleMask = nCellStyleMask + nRowStyleMask;
+                if(nCnfStyleMask == CNF_FIRST_COLUMN + CNF_FIRST_ROW)
+                    nCnfStyleMask |= CNF_FIRST_ROW_FIRST_COLUMN;
+                else if(nCnfStyleMask == CNF_FIRST_COLUMN + CNF_LAST_ROW)
+                    nCnfStyleMask |= CNF_LAST_ROW_FIRST_COLUMN;
+                else if(nCnfStyleMask == CNF_LAST_COLUMN + CNF_FIRST_ROW)
+                    nCnfStyleMask |= CNF_FIRST_ROW_LAST_COLUMN;
+                else if(nCnfStyleMask == CNF_LAST_COLUMN + CNF_LAST_ROW)
+                    nCnfStyleMask |= CNF_LAST_ROW_LAST_COLUMN;
 
                 if ( rInfo.pTableStyle )
                 {
-                    PropertyMapPtr pStyleProps = rInfo.pTableStyle->GetProperties( nCellStyleMask 
+ nRowStyleMask );
-                    pAllCellProps->InsertProps(pStyleProps);
+                    PropertyMapPtr pStyleProps = rInfo.pTableStyle->GetProperties( nCnfStyleMask );
+                    pAllCellProps->InsertProps( pStyleProps );
                 }
 
                 // Remove properties from style/row that aren't allowed in cells
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx 
b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index cb96046..bbdb53d 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -267,7 +267,12 @@
             }
             break;
             case NS_ooxml::LN_CT_TblPrBase_tblLook:
-                break; //todo: table look specifier
+            {
+                TablePropertyMapPtr pPropMap( new TablePropertyMap );
+                pPropMap->Insert( PROP_TBL_LOOK, false, uno::makeAny( nIntValue ));
+                insertTableProps(pPropMap);
+            }
+            break;
             case NS_ooxml::LN_CT_TcPrBase_textDirection:
             {
                 TablePropertyMapPtr pPropMap( new TablePropertyMap );
@@ -328,22 +333,12 @@
                 }
                 break;
             case NS_ooxml::LN_CT_TrPrBase_cnfStyle:
-                {
-                    TablePropertyMapPtr pProps( new TablePropertyMap );
-                    pProps->Insert( PROP_CNF_STYLE, true, uno::makeAny( pValue->getString( ) ) );
-                    insertRowProps( pProps );
-                }
-                break;
+                break;  // the cnfStyle doesn't matter, instead the tblLook property is used to 
specify conditional styles that are to be used
             case NS_ooxml::LN_CT_PPrBase_cnfStyle:
                 // TODO cnfStyle on a paragraph
                 break;
             case NS_ooxml::LN_CT_TcPrBase_cnfStyle:
-                {
-                    TablePropertyMapPtr pProps( new TablePropertyMap );
-                    pProps->Insert( PROP_CNF_STYLE, true, uno::makeAny( pValue->getString( ) ) );
-                    cellProps( pProps );
-                }
-                break;
+                break;  // the cnfStyle doesn't matter, instead the tblLook property is used to 
specify conditional styles that are to be used
             case NS_ooxml::LN_CT_TblPrBase_tblpPr:
                 {
                     writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx 
b/writerfilter/source/dmapper/PropertyIds.cxx
index 1d432fc..1ad4c11 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -279,7 +279,8 @@
             case PROP_SOURCE_NAME:    sName = "SourceName"; break;
             case PROP_REFERENCE_FIELD_SOURCE :    sName = "ReferenceFieldSource"; break;
             case PROP_WIDTH_TYPE :    sName = "WidthType"; break;
-            case  PROP_TEXT_RANGE:    sName = "TextRange"; break;
+            case PROP_TBL_LOOK : sName = "TblLook"; break;
+            case PROP_TEXT_RANGE:    sName = "TextRange"; break;
             case PROP_SERVICE_CHAR_STYLE       :    sName = "com.sun.star.style.CharacterStyle"; 
break;
             case PROP_SERVICE_PARA_STYLE       :    sName = "com.sun.star.style.ParagraphStyle"; 
break;
             case PROP_CHARACTER_STYLES :    sName = "CharacterStyles"; break;
@@ -302,7 +303,6 @@
             case PROP_BITMAP :    sName = "Bitmap"; break;
             case PROP_IS_DATE :   sName = "IsDate"; break;
             case PROP_TAB_STOP_DISTANCE :    sName = "TabStopDistance"; break;
-            case PROP_CNF_STYLE  :    sName = "CnfStyle"; break;
             case PROP_INDENT_AT :    sName = "IndentAt"; break;
             case PROP_FIRST_LINE_INDENT :    sName = "FirstLineIndent"; break;
             case PROP_NUMBERING_STYLE_NAME  :    sName = "NumberingStyleName"; break;
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx 
b/writerfilter/source/dmapper/PropertyIds.hxx
index c61283c..460ff33 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -107,7 +107,6 @@
         ,PROP_CHAR_WEIGHT_ASIAN
         ,PROP_CHAR_WEIGHT_COMPLEX
         ,PROP_CHAR_WORD_MODE
-        ,PROP_CNF_STYLE
         ,PROP_CONTENT
         ,PROP_CONTOUR_OUTSIDE
         ,PROP_CONTOUR_POLY_POLYGON
@@ -283,6 +282,7 @@
         ,PROP_VERT_ORIENT_RELATION
         ,PROP_WIDTH
         ,PROP_WIDTH_TYPE
+        ,PROP_TBL_LOOK
         ,PROP_WRITING_MODE
 /*253*/ ,PROP_FRM_DIRECTION
         ,PROP_EMBEDDED_OBJECT
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx 
b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 6e38673..2a216fe 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -217,40 +217,35 @@
 PropertyMapPtr TableStyleSheetEntry::GetLocalPropertiesFromMask( sal_Int32 nMask )
 {
     // Order from right to left
-    static const TblStyleType aBitsOrder[] =
+    struct TblStyleTypeAndMask {
+        sal_Int32       mask;
+        TblStyleType    type;
+    };
+
+    static const TblStyleTypeAndMask aOrderedStyleTable[] =
     {
-        TBL_STYLE_SWCELL,
-        TBL_STYLE_SECELL,
-        TBL_STYLE_NWCELL,
-        TBL_STYLE_NECELL,
-        TBL_STYLE_BAND2HORZ,
-        TBL_STYLE_BAND1HORZ,
-        TBL_STYLE_BAND2VERT,
-        TBL_STYLE_BAND1VERT,
-        TBL_STYLE_LASTCOL,
-        TBL_STYLE_FIRSTCOL,
-        TBL_STYLE_LASTROW,
-        TBL_STYLE_FIRSTROW,
-        TBL_STYLE_UNKNOWN
+        { 0x010, TBL_STYLE_BAND2HORZ },
+        { 0x020, TBL_STYLE_BAND1HORZ },
+        { 0x040, TBL_STYLE_BAND2VERT },
+        { 0x080, TBL_STYLE_BAND1VERT },
+        { 0x100, TBL_STYLE_LASTCOL  },
+        { 0x200, TBL_STYLE_FIRSTCOL },
+        { 0x400, TBL_STYLE_LASTROW  },
+        { 0x800, TBL_STYLE_FIRSTROW },
+        { 0x001, TBL_STYLE_SWCELL },
+        { 0x002, TBL_STYLE_SECELL },
+        { 0x004, TBL_STYLE_NWCELL },
+        { 0x008, TBL_STYLE_NECELL }
     };
 
     // Get the properties applying according to the mask
     PropertyMapPtr pProps( new PropertyMap( ) );
-    short nBit = 0;
-    do
+    for( int i = 0; i < sizeof( aOrderedStyleTable ); i++ )
     {
-        TblStyleType nStyleId = aBitsOrder[nBit];
-        TblStylePrs::iterator pIt = m_aStyles.find( nStyleId );
-
-        short nTestBit = 1 << nBit;
-        sal_Int32 nBitMask = sal_Int32( nTestBit );
-        if ( ( nMask & nBitMask ) && ( pIt != m_aStyles.end( ) ) )
-            lcl_mergeProps( pProps, pIt->second, nStyleId );
-
-        nBit++;
+        TblStylePrs::iterator pIt = m_aStyles.find( aOrderedStyleTable[ i ].type );
+        if ( ( nMask & aOrderedStyleTable[ i ].mask ) && ( pIt != m_aStyles.end( ) ) )
+            lcl_mergeProps( pProps, pIt->second, aOrderedStyleTable[ i ].type );
     }
-    while ( nBit < 13 );
-
     return pProps;
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I84f1d7c718dfc120b76364479ca68f63d2549b9f
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.