LCOV - code coverage report
Current view: top level - writerfilter/source/dmapper - DomainMapperTableHandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 261 337 77.4 %
Date: 2012-08-25 Functions: 19 20 95.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 312 733 42.6 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : #include <DomainMapperTableHandler.hxx>
      20                 :            : #include <DomainMapper_Impl.hxx>
      21                 :            : #include <StyleSheetTable.hxx>
      22                 :            : #include <com/sun/star/table/TableBorderDistances.hpp>
      23                 :            : #include <com/sun/star/table/TableBorder.hpp>
      24                 :            : #include <com/sun/star/table/BorderLine2.hpp>
      25                 :            : #include <com/sun/star/text/HoriOrientation.hpp>
      26                 :            : #include <com/sun/star/text/RelOrientation.hpp>
      27                 :            : #include <dmapperLoggers.hxx>
      28                 :            : 
      29                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
      30                 :            : #include <PropertyMapHelper.hxx>
      31                 :            : #include <rtl/oustringostreaminserter.hxx>
      32                 :            : #endif
      33                 :            : 
      34                 :            : namespace writerfilter {
      35                 :            : namespace dmapper {
      36                 :            : 
      37                 :            : using namespace ::com::sun::star;
      38                 :            : using namespace ::std;
      39                 :            : 
      40                 :            : #define DEF_BORDER_DIST 190  //0,19cm
      41                 :            : 
      42                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
      43                 :            : static void  lcl_printProperties( PropertyMapPtr pProps )
      44                 :            : {
      45                 :            :     if( pProps.get() )
      46                 :            :     {
      47                 :            :         dmapper_logger->startElement("properties");
      48                 :            : 
      49                 :            :         PropertyMap::const_iterator aMapIter = pProps->begin();
      50                 :            :         PropertyMap::const_iterator aEndIter = pProps->end();
      51                 :            :         PropertyNameSupplier& rPropSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
      52                 :            :         for( ; aMapIter != aEndIter; ++aMapIter )
      53                 :            :         {
      54                 :            :             SAL_INFO("writerfilter", rPropSupplier.GetName(aMapIter->first.eId));
      55                 :            : 
      56                 :            :             table::BorderLine2 aLine;
      57                 :            :             sal_Int32 nColor;
      58                 :            :             if ( aMapIter->second >>= aLine )
      59                 :            :             {
      60                 :            :                 dmapper_logger->startElement("borderline");
      61                 :            :                 dmapper_logger->attribute("color", aLine.Color);
      62                 :            :                 dmapper_logger->attribute("inner", aLine.InnerLineWidth);
      63                 :            :                 dmapper_logger->attribute("outer", aLine.OuterLineWidth);
      64                 :            :                 dmapper_logger->endElement();
      65                 :            :             }
      66                 :            :             else if ( aMapIter->second >>= nColor )
      67                 :            :             {
      68                 :            :                 dmapper_logger->startElement("color");
      69                 :            :                 dmapper_logger->attribute("number", nColor);
      70                 :            :                 dmapper_logger->endElement();
      71                 :            :             }
      72                 :            :         }
      73                 :            : 
      74                 :            :         dmapper_logger->endElement();
      75                 :            :     }
      76                 :            : }
      77                 :            : #endif
      78                 :            : 
      79                 :        506 : DomainMapperTableHandler::DomainMapperTableHandler(TextReference_t xText, DomainMapper_Impl& rDMapper_Impl)
      80                 :            :     : m_xText(xText),
      81                 :            :         m_rDMapper_Impl( rDMapper_Impl ),
      82                 :            :         m_nCellIndex(0),
      83 [ +  - ][ +  - ]:        506 :         m_nRowIndex(0)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      84                 :            : {
      85                 :        506 : }
      86                 :            : 
      87 [ +  - ][ +  - ]:        506 : DomainMapperTableHandler::~DomainMapperTableHandler()
         [ +  - ][ +  - ]
      88                 :            : {
      89         [ -  + ]:       1012 : }
      90                 :            : 
      91                 :        671 : void DomainMapperTableHandler::startTable(unsigned int nRows,
      92                 :            :                                           unsigned int /*nDepth*/,
      93                 :            :                                           TablePropertyMapPtr pProps)
      94                 :            : {
      95                 :        671 :     m_aTableProperties = pProps;
      96 [ +  - ][ +  - ]:        671 :     m_pTableSeq = TableSequencePointer_t(new TableSequence_t(nRows));
      97                 :        671 :     m_nRowIndex = 0;
      98                 :            : 
      99                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     100                 :            :     dmapper_logger->startElement("tablehandler.table");
     101                 :            :     dmapper_logger->attribute("rows", nRows);
     102                 :            : 
     103                 :            :     if (pProps.get() != NULL)
     104                 :            :         pProps->dumpXml( dmapper_logger );
     105                 :            : #endif
     106                 :        671 : }
     107                 :            : 
     108                 :            : 
     109                 :            : 
     110                 :          0 : PropertyMapPtr lcl_SearchParentStyleSheetAndMergeProperties(const StyleSheetEntryPtr pStyleSheet, StyleSheetTablePtr pStyleSheetTable)
     111                 :            : {
     112                 :          0 :     PropertyMapPtr pRet;
     113         [ #  # ]:          0 :     if(!pStyleSheet->sBaseStyleIdentifier.isEmpty())
     114                 :            :     {
     115         [ #  # ]:          0 :         const StyleSheetEntryPtr pParentStyleSheet = pStyleSheetTable->FindStyleSheetByISTD( pStyleSheet->sBaseStyleIdentifier );
     116 [ #  # ][ #  # ]:          0 :         pRet = lcl_SearchParentStyleSheetAndMergeProperties( pParentStyleSheet, pStyleSheetTable );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     117                 :            :     }
     118                 :            :     else
     119                 :            :     {
     120 [ #  # ][ #  # ]:          0 :         pRet.reset( new PropertyMap );
                 [ #  # ]
     121                 :            :     }
     122                 :            : 
     123 [ #  # ][ #  # ]:          0 :     pRet->insert(  pStyleSheet->pProperties, true );
                 [ #  # ]
     124                 :            : 
     125                 :          0 :     return pRet;
     126                 :            : }
     127                 :            : 
     128                 :       1121 : void lcl_mergeBorder( PropertyIds nId, PropertyMapPtr pOrig, PropertyMapPtr pDest )
     129                 :            : {
     130                 :       1121 :     PropertyDefinition aDef( nId, false );
     131         [ +  - ]:       1121 :     PropertyMap::iterator pOrigIt = pOrig->find( aDef );
     132                 :            : 
     133         [ +  + ]:       1121 :     if ( pOrigIt != pOrig->end( ) )
     134                 :            :     {
     135         [ +  - ]:        348 :         pDest->Insert( nId, false, pOrigIt->second, false );
     136                 :            :     }
     137                 :       1121 : }
     138                 :            : 
     139                 :        514 : void lcl_computeCellBorders( PropertyMapPtr pTableBorders, PropertyMapPtr pCellProps,
     140                 :            :         sal_Int32 nCell, sal_Int32 nRow, bool bIsEndCol, bool bIsEndRow )
     141                 :            : {
     142                 :        514 :     PropertyDefinition aVertPDef( META_PROP_VERTICAL_BORDER, false );
     143                 :        514 :     PropertyDefinition aHorizPDef( META_PROP_HORIZONTAL_BORDER, false );
     144                 :            : 
     145         [ +  - ]:        514 :     PropertyMap::iterator aVerticalIter = pCellProps->find( aVertPDef );
     146         [ +  - ]:        514 :     PropertyMap::iterator aHorizontalIter = pCellProps->find( aHorizPDef );
     147                 :            : 
     148                 :            :     // Handle the vertical and horizontal borders
     149                 :        514 :     bool bHasVert = ( aVerticalIter != pCellProps->end(  ) );
     150                 :        514 :     uno::Any aVertProp;
     151         [ +  - ]:        514 :     if ( !bHasVert )
     152                 :            :     {
     153         [ +  - ]:        514 :         aVerticalIter = pTableBorders->find( aVertPDef );
     154                 :        514 :         bHasVert = ( aVerticalIter != pTableBorders->end( ) );
     155         [ +  + ]:        514 :         if ( bHasVert )
     156                 :        162 :             aVertProp = aVerticalIter->second;
     157                 :            :     }
     158                 :            :     else
     159                 :            :     {
     160                 :          0 :         aVertProp = aVerticalIter->second;
     161         [ #  # ]:          0 :         pCellProps->erase( aVerticalIter );
     162                 :            :     }
     163                 :            : 
     164                 :        514 :     bool bHasHoriz = ( aHorizontalIter != pCellProps->end(  ) );
     165                 :        514 :     uno::Any aHorizProp;
     166         [ +  - ]:        514 :     if ( !bHasHoriz )
     167                 :            :     {
     168         [ +  - ]:        514 :         aHorizontalIter = pTableBorders->find( aHorizPDef );
     169                 :        514 :         bHasHoriz = ( aHorizontalIter != pTableBorders->end( ) );
     170         [ +  + ]:        514 :         if ( bHasHoriz )
     171                 :        144 :             aHorizProp = aHorizontalIter->second;
     172                 :            :     }
     173                 :            :     else
     174                 :            :     {
     175                 :          0 :         aHorizProp = aHorizontalIter->second;
     176         [ #  # ]:          0 :         pCellProps->erase( aHorizontalIter );
     177                 :            :     }
     178                 :            : 
     179         [ +  + ]:        514 :     if ( nCell == 0 )
     180                 :            :     {
     181 [ +  - ][ +  - ]:        106 :         lcl_mergeBorder( PROP_LEFT_BORDER, pTableBorders, pCellProps );
         [ +  - ][ +  - ]
                 [ +  - ]
     182         [ +  + ]:        106 :         if ( bHasVert )
     183         [ +  - ]:         21 :             pCellProps->Insert( PROP_RIGHT_BORDER, false, aVertProp, false );
     184                 :            :     }
     185                 :            : 
     186         [ +  + ]:        514 :     if ( bIsEndCol )
     187                 :            :     {
     188 [ +  - ][ +  - ]:        106 :         lcl_mergeBorder( PROP_RIGHT_BORDER, pTableBorders, pCellProps );
         [ +  - ][ +  - ]
                 [ +  - ]
     189         [ +  + ]:        106 :         if ( bHasVert )
     190         [ +  - ]:         21 :             pCellProps->Insert( PROP_LEFT_BORDER, false, aVertProp, false );
     191                 :            :     }
     192                 :            : 
     193 [ +  + ][ +  + ]:        514 :     if ( nCell > 0 && !bIsEndCol )
     194                 :            :     {
     195         [ +  + ]:        308 :         if ( bHasVert )
     196                 :            :         {
     197         [ +  - ]:        120 :             pCellProps->Insert( PROP_RIGHT_BORDER, false, aVertProp, false );
     198         [ +  - ]:        120 :             pCellProps->Insert( PROP_LEFT_BORDER, false, aVertProp, false );
     199                 :            :         }
     200                 :            :     }
     201                 :            : 
     202         [ +  + ]:        514 :     if ( nRow == 0 )
     203                 :            :     {
     204 [ +  - ][ +  - ]:        456 :         lcl_mergeBorder( PROP_TOP_BORDER, pTableBorders, pCellProps );
         [ +  - ][ +  - ]
                 [ +  - ]
     205         [ +  + ]:        456 :         if ( bHasHoriz )
     206         [ +  - ]:        144 :             pCellProps->Insert( PROP_BOTTOM_BORDER, false, aHorizProp, false );
     207                 :            :     }
     208                 :            : 
     209         [ +  + ]:        514 :     if ( bIsEndRow )
     210                 :            :     {
     211 [ +  - ][ +  - ]:        453 :         lcl_mergeBorder( PROP_BOTTOM_BORDER, pTableBorders, pCellProps );
         [ +  - ][ +  - ]
                 [ +  - ]
     212         [ +  + ]:        453 :         if ( bHasHoriz )
     213         [ +  - ]:        144 :             pCellProps->Insert( PROP_TOP_BORDER, false, aHorizProp, false );
     214                 :            :     }
     215                 :            : 
     216 [ +  + ][ +  + ]:        514 :     if ( nRow > 0 && !bIsEndRow )
     217                 :            :     {
     218         [ -  + ]:         35 :         if ( bHasHoriz )
     219                 :            :         {
     220         [ #  # ]:          0 :             pCellProps->Insert( PROP_TOP_BORDER, false, aHorizProp, false );
     221         [ #  # ]:          0 :             pCellProps->Insert( PROP_BOTTOM_BORDER, false, aHorizProp, false );
     222                 :            :         }
     223                 :        514 :     }
     224                 :        514 : }
     225                 :            : 
     226                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     227                 :            : 
     228                 :            : void lcl_debug_BorderLine(table::BorderLine & rLine)
     229                 :            : {
     230                 :            :     dmapper_logger->startElement("BorderLine");
     231                 :            :     dmapper_logger->attribute("Color", rLine.Color);
     232                 :            :     dmapper_logger->attribute("InnerLineWidth", rLine.InnerLineWidth);
     233                 :            :     dmapper_logger->attribute("OuterLineWidth", rLine.OuterLineWidth);
     234                 :            :     dmapper_logger->attribute("LineDistance", rLine.LineDistance);
     235                 :            :     dmapper_logger->endElement();
     236                 :            : }
     237                 :            : 
     238                 :            : void lcl_debug_TableBorder(table::TableBorder & rBorder)
     239                 :            : {
     240                 :            :     dmapper_logger->startElement("TableBorder");
     241                 :            :     lcl_debug_BorderLine(rBorder.TopLine);
     242                 :            :     dmapper_logger->attribute("IsTopLineValid", rBorder.IsTopLineValid);
     243                 :            :     lcl_debug_BorderLine(rBorder.BottomLine);
     244                 :            :     dmapper_logger->attribute("IsBottomLineValid", rBorder.IsBottomLineValid);
     245                 :            :     lcl_debug_BorderLine(rBorder.LeftLine);
     246                 :            :     dmapper_logger->attribute("IsLeftLineValid", rBorder.IsLeftLineValid);
     247                 :            :     lcl_debug_BorderLine(rBorder.RightLine);
     248                 :            :     dmapper_logger->attribute("IsRightLineValid", rBorder.IsRightLineValid);
     249                 :            :     lcl_debug_BorderLine(rBorder.VerticalLine);
     250                 :            :     dmapper_logger->attribute("IsVerticalLineValid", rBorder.IsVerticalLineValid);
     251                 :            :     lcl_debug_BorderLine(rBorder.HorizontalLine);
     252                 :            :     dmapper_logger->attribute("IsHorizontalLineValid", rBorder.IsHorizontalLineValid);
     253                 :            :     dmapper_logger->attribute("Distance", rBorder.Distance);
     254                 :            :     dmapper_logger->attribute("IsDistanceValid", rBorder.IsDistanceValid);
     255                 :            :     dmapper_logger->endElement();
     256                 :            : }
     257                 :            : #endif
     258                 :            : 
     259 [ +  - ][ +  - ]:        671 : struct WRITERFILTER_DLLPRIVATE TableInfo
     260                 :            : {
     261                 :            :     sal_Int32 nLeftBorderDistance;
     262                 :            :     sal_Int32 nRightBorderDistance;
     263                 :            :     sal_Int32 nTopBorderDistance;
     264                 :            :     sal_Int32 nBottomBorderDistance;
     265                 :            :     PropertyMapPtr pTableDefaults;
     266                 :            :     PropertyMapPtr pTableBorders;
     267                 :            :     TableStyleSheetEntry* pTableStyle;
     268                 :            :     TablePropertyValues_t aTableProperties;
     269                 :            : 
     270                 :        671 :     TableInfo()
     271                 :            :     : nLeftBorderDistance(DEF_BORDER_DIST)
     272                 :            :     , nRightBorderDistance(DEF_BORDER_DIST)
     273                 :            :     , nTopBorderDistance(0)
     274                 :            :     , nBottomBorderDistance(0)
     275         [ +  - ]:        671 :     , pTableDefaults(new PropertyMap)
     276         [ +  - ]:        671 :     , pTableBorders(new PropertyMap)
     277 [ +  - ][ +  - ]:       2013 :     , pTableStyle(NULL)
                 [ +  - ]
     278                 :            :     {
     279                 :        671 :     }
     280                 :            : 
     281                 :            : };
     282                 :            : 
     283                 :            : namespace
     284                 :            : {
     285                 :            : 
     286                 :        522 : bool lcl_extractTableBorderProperty(PropertyMapPtr pTableProperties, const PropertyIds nId, TableInfo& rInfo, table::BorderLine2& rLine)
     287                 :            : {
     288         [ +  - ]:        522 :     PropertyMap::iterator aTblBorderIter = pTableProperties->find( PropertyDefinition(nId, false) );
     289         [ +  + ]:        522 :     if( aTblBorderIter != pTableProperties->end() )
     290                 :            :     {
     291         [ +  - ]:        120 :         OSL_VERIFY(aTblBorderIter->second >>= rLine);
     292                 :            : 
     293 [ +  - ][ +  - ]:        120 :         rInfo.pTableBorders->Insert( nId, false, uno::makeAny( rLine ) );
     294         [ +  - ]:        120 :         PropertyMap::iterator pIt = rInfo.pTableDefaults->find( PropertyDefinition( nId, false ) );
     295         [ +  - ]:        120 :         if ( pIt != rInfo.pTableDefaults->end( ) )
     296         [ +  - ]:        120 :             rInfo.pTableDefaults->erase( pIt );
     297                 :            : 
     298                 :        120 :         return true;
     299                 :            :     }
     300                 :            : 
     301                 :        522 :     return false;
     302                 :            : }
     303                 :            : 
     304                 :            : }
     305                 :            : 
     306                 :        671 : TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo & rInfo)
     307                 :            : {
     308                 :            :     // will receive the table style if any
     309                 :        671 :     TableStyleSheetEntry* pTableStyle = NULL;
     310                 :            : 
     311         [ +  + ]:        671 :     if( m_aTableProperties.get() )
     312                 :            :     {
     313                 :            :         //create properties from the table attributes
     314                 :            :         //...pPropMap->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( m_nLeftMargin - m_nGapHalf ));
     315                 :            :         //pPropMap->Insert( PROP_HORI_ORIENT, false, uno::makeAny( text::HoriOrientation::RIGHT ));
     316                 :         87 :         sal_Int32 nGapHalf = 0;
     317                 :         87 :         sal_Int32 nLeftMargin = 0;
     318                 :         87 :         sal_Int32 nTableWidth = 0;
     319                 :            : 
     320                 :            :         PropertyMap::iterator aTableStyleIter =
     321         [ +  - ]:         87 :         m_aTableProperties->find( PropertyDefinition( META_PROP_TABLE_STYLE_NAME, false ) );
     322         [ +  + ]:         87 :         if(aTableStyleIter != m_aTableProperties->end())
     323                 :            :         {
     324                 :            :             // Apply table style properties recursively
     325                 :         36 :             OUString sTableStyleName;
     326                 :         36 :             aTableStyleIter->second >>= sTableStyleName;
     327         [ +  - ]:         36 :             StyleSheetTablePtr pStyleSheetTable = m_rDMapper_Impl.GetStyleSheetTable();
     328         [ +  - ]:         36 :             const StyleSheetEntryPtr pStyleSheet = pStyleSheetTable->FindStyleSheetByISTD( sTableStyleName );
     329         [ +  - ]:         36 :             pTableStyle = dynamic_cast<TableStyleSheetEntry*>( pStyleSheet.get( ) );
     330         [ +  - ]:         36 :             m_aTableProperties->erase( aTableStyleIter );
     331                 :            : 
     332         [ -  + ]:         36 :             if( pStyleSheet )
     333                 :            :             {
     334                 :            :                 // First get the style properties, then the table ones
     335         [ #  # ]:          0 :                 PropertyMapPtr pTableProps( m_aTableProperties );
     336 [ #  # ][ #  # ]:          0 :                 TablePropertyMapPtr pEmptyProps( new TablePropertyMap );
                 [ #  # ]
     337                 :            : 
     338         [ #  # ]:          0 :                 m_aTableProperties = pEmptyProps;
     339                 :            : 
     340 [ #  # ][ #  # ]:          0 :                 PropertyMapPtr pMergedProperties = lcl_SearchParentStyleSheetAndMergeProperties(pStyleSheet, pStyleSheetTable);
         [ #  # ][ #  # ]
                 [ #  # ]
     341                 :            : 
     342                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     343                 :            :                 dmapper_logger->startElement("mergedProps");
     344                 :            :                 pMergedProperties->dumpXml( dmapper_logger );
     345                 :            :                 dmapper_logger->endElement();
     346                 :            : #endif
     347                 :            : 
     348 [ #  # ][ #  # ]:          0 :                 m_aTableProperties->insert( pMergedProperties );
                 [ #  # ]
     349 [ #  # ][ #  # ]:          0 :                 m_aTableProperties->insert( pTableProps );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     350                 :            : 
     351                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     352                 :            :                 dmapper_logger->startElement("TableProperties");
     353                 :            :                 m_aTableProperties->dumpXml( dmapper_logger );
     354                 :            :                 dmapper_logger->endElement();
     355                 :            : #endif
     356 [ +  - ][ +  - ]:         36 :             }
     357                 :            :         }
     358                 :            : 
     359                 :            :         // Set the table default attributes for the cells
     360 [ +  - ][ +  - ]:         87 :         rInfo.pTableDefaults->insert( m_aTableProperties );
                 [ +  - ]
     361                 :            : 
     362                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     363                 :            :         dmapper_logger->startElement("TableDefaults");
     364                 :            :         rInfo.pTableDefaults->dumpXml( dmapper_logger );
     365                 :            :         dmapper_logger->endElement();
     366                 :            : #endif
     367                 :            : 
     368         [ +  - ]:         87 :         m_aTableProperties->getValue( TablePropertyMap::GAP_HALF, nGapHalf );
     369         [ +  - ]:         87 :         m_aTableProperties->getValue( TablePropertyMap::LEFT_MARGIN, nLeftMargin );
     370                 :            : 
     371                 :            :         m_aTableProperties->getValue( TablePropertyMap::CELL_MAR_LEFT,
     372         [ +  - ]:         87 :                                      rInfo.nLeftBorderDistance );
     373                 :            :         m_aTableProperties->getValue( TablePropertyMap::CELL_MAR_RIGHT,
     374         [ +  - ]:         87 :                                      rInfo.nRightBorderDistance );
     375                 :            :         m_aTableProperties->getValue( TablePropertyMap::CELL_MAR_TOP,
     376         [ +  - ]:         87 :                                      rInfo.nTopBorderDistance );
     377                 :            :         m_aTableProperties->getValue( TablePropertyMap::CELL_MAR_BOTTOM,
     378         [ +  - ]:         87 :                                      rInfo.nBottomBorderDistance );
     379                 :            : 
     380                 :         87 :         table::TableBorderDistances aDistances;
     381                 :            :         aDistances.IsTopDistanceValid =
     382                 :            :         aDistances.IsBottomDistanceValid =
     383                 :            :         aDistances.IsLeftDistanceValid =
     384                 :         87 :         aDistances.IsRightDistanceValid = sal_True;
     385                 :         87 :         aDistances.TopDistance = static_cast<sal_Int16>( rInfo.nTopBorderDistance );
     386                 :         87 :         aDistances.BottomDistance = static_cast<sal_Int16>( rInfo.nBottomBorderDistance );
     387                 :         87 :         aDistances.LeftDistance = static_cast<sal_Int16>( rInfo.nLeftBorderDistance );
     388                 :         87 :         aDistances.RightDistance = static_cast<sal_Int16>( rInfo.nRightBorderDistance );
     389                 :            : 
     390 [ +  - ][ +  - ]:         87 :         m_aTableProperties->Insert( PROP_TABLE_BORDER_DISTANCES, false, uno::makeAny( aDistances ) );
     391                 :            : 
     392                 :            :         //table border settings
     393                 :         87 :         table::TableBorder aTableBorder;
     394                 :         87 :         table::BorderLine2 aBorderLine;
     395                 :            : 
     396 [ +  - ][ +  - ]:         87 :         if (lcl_extractTableBorderProperty(m_aTableProperties, PROP_TOP_BORDER, rInfo, aBorderLine))
         [ +  + ][ +  - ]
     397                 :            :         {
     398                 :         18 :             aTableBorder.TopLine = aBorderLine;
     399                 :         18 :             aTableBorder.IsTopLineValid = sal_True;
     400                 :            :         }
     401 [ +  - ][ +  - ]:         87 :         if (lcl_extractTableBorderProperty(m_aTableProperties, PROP_BOTTOM_BORDER, rInfo, aBorderLine))
         [ +  - ][ +  + ]
     402                 :            :         {
     403                 :         21 :             aTableBorder.BottomLine = aBorderLine;
     404                 :         21 :             aTableBorder.IsBottomLineValid = sal_True;
     405                 :            :         }
     406 [ +  - ][ +  - ]:         87 :         if (lcl_extractTableBorderProperty(m_aTableProperties, PROP_LEFT_BORDER, rInfo, aBorderLine))
         [ +  - ][ +  + ]
     407                 :            :         {
     408                 :         21 :             aTableBorder.LeftLine = aBorderLine;
     409                 :         21 :             aTableBorder.IsLeftLineValid = sal_True;
     410                 :            :         }
     411 [ +  - ][ +  - ]:         87 :         if (lcl_extractTableBorderProperty(m_aTableProperties, PROP_RIGHT_BORDER, rInfo, aBorderLine))
         [ +  - ][ +  + ]
     412                 :            :         {
     413                 :         21 :             aTableBorder.RightLine = aBorderLine;
     414                 :         21 :             aTableBorder.IsRightLineValid = sal_True;
     415                 :            :         }
     416 [ +  - ][ +  - ]:         87 :         if (lcl_extractTableBorderProperty(m_aTableProperties, META_PROP_HORIZONTAL_BORDER, rInfo, aBorderLine))
         [ +  - ][ +  + ]
     417                 :            :         {
     418                 :         18 :             aTableBorder.HorizontalLine = aBorderLine;
     419                 :         18 :             aTableBorder.IsHorizontalLineValid = sal_True;
     420                 :            :         }
     421 [ +  - ][ +  - ]:         87 :         if (lcl_extractTableBorderProperty(m_aTableProperties, META_PROP_VERTICAL_BORDER, rInfo, aBorderLine))
         [ +  - ][ +  + ]
     422                 :            :         {
     423                 :         21 :             aTableBorder.VerticalLine = aBorderLine;
     424                 :         21 :             aTableBorder.IsVerticalLineValid = sal_True;
     425                 :            :         }
     426                 :            : 
     427                 :         87 :         aTableBorder.Distance = 0;
     428                 :         87 :         aTableBorder.IsDistanceValid = sal_False;
     429                 :            : 
     430 [ +  - ][ +  - ]:         87 :         m_aTableProperties->Insert( PROP_TABLE_BORDER, false, uno::makeAny( aTableBorder ) );
     431                 :            : 
     432                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     433                 :            :         lcl_debug_TableBorder(aTableBorder);
     434                 :            : #endif
     435                 :            : 
     436 [ +  - ][ +  - ]:         87 :         m_aTableProperties->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( nLeftMargin - nGapHalf - rInfo.nLeftBorderDistance));
     437                 :            : 
     438         [ +  - ]:         87 :         m_aTableProperties->getValue( TablePropertyMap::TABLE_WIDTH, nTableWidth );
     439         [ +  - ]:         87 :         if( nTableWidth > 0 )
     440 [ +  - ][ +  - ]:         87 :             m_aTableProperties->Insert( PROP_WIDTH, false, uno::makeAny( nTableWidth ));
     441                 :            : 
     442                 :         87 :         sal_Int32 nHoriOrient = text::HoriOrientation::LEFT_AND_WIDTH;
     443         [ +  - ]:         87 :         m_aTableProperties->getValue( TablePropertyMap::HORI_ORIENT, nHoriOrient ) ;
     444 [ +  - ][ +  - ]:         87 :         m_aTableProperties->Insert( PROP_HORI_ORIENT, false, uno::makeAny( sal_Int16(nHoriOrient) ) );
     445                 :            : 
     446                 :            :         //fill default value - if not available
     447                 :            :         const PropertyMap::const_iterator aRepeatIter =
     448         [ +  - ]:         87 :         m_aTableProperties->find( PropertyDefinition( PROP_HEADER_ROW_COUNT, false ) );
     449         [ +  + ]:         87 :         if( aRepeatIter == m_aTableProperties->end() )
     450 [ +  - ][ +  - ]:         83 :             m_aTableProperties->Insert( PROP_HEADER_ROW_COUNT, false, uno::makeAny( (sal_Int32)0 ));
     451                 :            : 
     452 [ +  - ][ +  - ]:         87 :         rInfo.aTableProperties = m_aTableProperties->GetPropertyValues();
                 [ +  - ]
     453                 :            : 
     454                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     455                 :            :         dmapper_logger->startElement("debug.tableprops");
     456                 :            :         m_aTableProperties->dumpXml( dmapper_logger );
     457                 :            :         dmapper_logger->endElement();
     458                 :            : #endif
     459                 :            : 
     460                 :            :     }
     461                 :            : 
     462                 :        671 :     return pTableStyle;
     463                 :            : }
     464                 :            : 
     465                 :        671 : CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(TableInfo & rInfo)
     466                 :            : {
     467                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     468                 :            :     dmapper_logger->startElement("getCellProperties");
     469                 :            : #endif
     470                 :            : 
     471         [ +  - ]:        671 :     CellPropertyValuesSeq_t aCellProperties( m_aCellProperties.size() );
     472                 :            : 
     473         [ +  + ]:        671 :     if ( !m_aCellProperties.size() )
     474                 :            :     {
     475                 :            :         #ifdef DEBUG_DOMAINMAPPER
     476                 :            :         dmapper_logger->endElement();
     477                 :            :         #endif
     478                 :            :         return aCellProperties;
     479                 :            :     }
     480                 :            :     // std::vector< std::vector<PropertyMapPtr> > m_aCellProperties
     481         [ +  - ]:        108 :     PropertyMapVector2::const_iterator aRowOfCellsIterator = m_aCellProperties.begin();
     482         [ +  - ]:        108 :     PropertyMapVector2::const_iterator aRowOfCellsIteratorEnd = m_aCellProperties.end();
     483 [ +  - ][ +  - ]:        108 :     PropertyMapVector2::const_iterator aLastRowIterator = m_aCellProperties.end() - 1;
     484                 :        108 :     sal_Int32 nRow = 0;
     485                 :            : 
     486                 :            :     //it's a uno::Sequence< beans::PropertyValues >*
     487         [ +  - ]:        108 :     RowPropertyValuesSeq_t* pCellProperties = aCellProperties.getArray();
     488 [ +  - ][ +  + ]:        798 :     while( aRowOfCellsIterator != aRowOfCellsIteratorEnd )
     489                 :            :     {
     490                 :            :         //aRowOfCellsIterator points to a vector of PropertyMapPtr
     491                 :        127 :         PropertyMapVector1::const_iterator aCellIterator = aRowOfCellsIterator->begin();
     492                 :        127 :         PropertyMapVector1::const_iterator aCellIteratorEnd = aRowOfCellsIterator->end();
     493                 :            : 
     494                 :            :         // Get the row style properties
     495                 :        127 :         sal_Int32 nRowStyleMask = sal_Int32( 0 );
     496         [ +  - ]:        127 :         PropertyMapPtr pRowProps = m_aRowProperties[nRow];
     497         [ +  + ]:        127 :         if ( pRowProps.get( ) )
     498                 :            :         {
     499         [ +  - ]:        106 :             PropertyMap::iterator pTcCnfStyleIt = pRowProps->find( PropertyDefinition( PROP_CNF_STYLE, true ) );
     500         [ -  + ]:        106 :             if ( pTcCnfStyleIt != pRowProps->end( ) )
     501                 :            :             {
     502         [ #  # ]:          0 :                 if ( rInfo.pTableStyle )
     503                 :            :                 {
     504                 :          0 :                     OUString sMask;
     505                 :          0 :                     pTcCnfStyleIt->second >>= sMask;
     506                 :          0 :                     nRowStyleMask = sMask.toInt32( 2 );
     507                 :            :                 }
     508         [ #  # ]:        106 :                 pRowProps->erase( pTcCnfStyleIt );
     509                 :            :             }
     510                 :            :         }
     511                 :            : 
     512                 :        127 :         sal_Int32 nCell = 0;
     513         [ +  - ]:        127 :         pCellProperties[nRow].realloc( aRowOfCellsIterator->size() );
     514         [ +  - ]:        127 :         beans::PropertyValues* pSingleCellProperties = pCellProperties[nRow].getArray();
     515 [ +  - ][ +  + ]:        641 :         while( aCellIterator != aCellIteratorEnd )
     516                 :            :         {
     517 [ +  - ][ +  - ]:        514 :             PropertyMapPtr pAllCellProps( new PropertyMap );
                 [ +  - ]
     518                 :            : 
     519         [ +  - ]:        514 :             PropertyMapVector1::const_iterator aLastCellIterator = aRowOfCellsIterator->end() - 1;
     520         [ +  - ]:        514 :             bool bIsEndCol = aCellIterator == aLastCellIterator;
     521         [ +  - ]:        514 :             bool bIsEndRow = aRowOfCellsIterator == aLastRowIterator;
     522                 :            : 
     523                 :            :             //aCellIterator points to a PropertyMapPtr;
     524         [ +  - ]:        514 :             if( aCellIterator->get() )
     525                 :            :             {
     526         [ +  + ]:        514 :                 if ( rInfo.pTableDefaults->size( ) )
     527 [ +  - ][ +  - ]:         28 :                     pAllCellProps->insert( rInfo.pTableDefaults );
                 [ +  - ]
     528                 :            : 
     529                 :            :                     // Fill the cell properties with the ones of the style
     530                 :        514 :                     sal_Int32 nCellStyleMask = 0;
     531                 :            :                     const PropertyMap::iterator aCnfStyleIter =
     532         [ +  - ]:        514 :                     aCellIterator->get()->find( PropertyDefinition( PROP_CNF_STYLE, false ) );
     533         [ -  + ]:        514 :                     if ( aCnfStyleIter != aCellIterator->get( )->end( ) )
     534                 :            :                     {
     535         [ #  # ]:          0 :                         if ( rInfo.pTableStyle ) {
     536                 :          0 :                             OUString sMask;
     537                 :          0 :                             aCnfStyleIter->second >>= sMask;
     538                 :          0 :                             nCellStyleMask = sMask.toInt32( 2 );
     539                 :            :                         }
     540         [ #  # ]:          0 :                         aCellIterator->get( )->erase( aCnfStyleIter );
     541                 :            :                     }
     542                 :            : 
     543         [ -  + ]:        514 :                 if ( rInfo.pTableStyle )
     544                 :            :                 {
     545 [ #  # ][ #  # ]:          0 :                     PropertyMapPtr pStyleProps = rInfo.pTableStyle->GetProperties( nCellStyleMask + nRowStyleMask );
                 [ #  # ]
     546 [ #  # ][ #  # ]:          0 :                     pAllCellProps->insert( pStyleProps );
         [ #  # ][ #  # ]
     547                 :            :                 }
     548                 :            : 
     549                 :            :                 // Remove properties from style/row that aren't allowed in cells
     550                 :            :                 const PropertyMap::iterator aDefaultRepeatIt =
     551                 :        514 :                     pAllCellProps->find(
     552         [ +  - ]:       1028 :                         PropertyDefinition( PROP_HEADER_ROW_COUNT, false ) );
     553         [ +  + ]:        514 :                 if ( aDefaultRepeatIt != pAllCellProps->end( ) )
     554         [ +  - ]:         28 :                     pAllCellProps->erase( aDefaultRepeatIt );
     555                 :            : 
     556                 :            :                 // Then add the cell properties
     557 [ +  - ][ +  - ]:        514 :                 pAllCellProps->insert( *aCellIterator );
                 [ +  - ]
     558         [ +  - ]:        514 :                 aCellIterator->get( )->swap( *pAllCellProps.get( ) );
     559                 :            : 
     560                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     561                 :            :                 dmapper_logger->startElement("cell");
     562                 :            :                 dmapper_logger->attribute("cell", nCell);
     563                 :            :                 dmapper_logger->attribute("row", nRow);
     564                 :            : #endif
     565                 :            : 
     566 [ +  - ][ +  - ]:        514 :                 lcl_computeCellBorders( rInfo.pTableBorders, *aCellIterator, nCell, nRow, bIsEndCol, bIsEndRow );
         [ +  - ][ +  - ]
                 [ +  - ]
     567                 :            : 
     568                 :            :                 //now set the default left+right border distance TODO: there's an sprm containing the default distance!
     569                 :            :                 const PropertyMap::const_iterator aLeftDistanceIter =
     570         [ +  - ]:        514 :                 aCellIterator->get()->find( PropertyDefinition(PROP_LEFT_BORDER_DISTANCE, false) );
     571         [ +  - ]:        514 :                 if( aLeftDistanceIter == aCellIterator->get()->end() )
     572                 :            :                     aCellIterator->get()->Insert( PROP_LEFT_BORDER_DISTANCE, false,
     573 [ +  - ][ +  - ]:        514 :                                                  uno::makeAny(rInfo.nLeftBorderDistance ) );
     574                 :            :                 const PropertyMap::const_iterator aRightDistanceIter =
     575         [ +  - ]:        514 :                 aCellIterator->get()->find( PropertyDefinition(PROP_RIGHT_BORDER_DISTANCE, false) );
     576         [ +  - ]:        514 :                 if( aRightDistanceIter == aCellIterator->get()->end() )
     577                 :            :                     aCellIterator->get()->Insert( PROP_RIGHT_BORDER_DISTANCE, false,
     578 [ +  - ][ +  - ]:        514 :                                                  uno::makeAny((sal_Int32) rInfo.nRightBorderDistance ) );
     579                 :            : 
     580                 :            :                 const PropertyMap::const_iterator aTopDistanceIter =
     581         [ +  - ]:        514 :                 aCellIterator->get()->find( PropertyDefinition(PROP_TOP_BORDER_DISTANCE, false) );
     582         [ +  - ]:        514 :                 if( aTopDistanceIter == aCellIterator->get()->end() )
     583                 :            :                     aCellIterator->get()->Insert( PROP_TOP_BORDER_DISTANCE, false,
     584 [ +  - ][ +  - ]:        514 :                                                  uno::makeAny((sal_Int32) rInfo.nTopBorderDistance ) );
     585                 :            : 
     586                 :            :                 const PropertyMap::const_iterator aBottomDistanceIter =
     587         [ +  - ]:        514 :                 aCellIterator->get()->find( PropertyDefinition(PROP_BOTTOM_BORDER_DISTANCE, false) );
     588         [ +  - ]:        514 :                 if( aBottomDistanceIter == aCellIterator->get()->end() )
     589                 :            :                     aCellIterator->get()->Insert( PROP_BOTTOM_BORDER_DISTANCE, false,
     590 [ +  - ][ +  - ]:        514 :                                                  uno::makeAny((sal_Int32) rInfo.nBottomBorderDistance ) );
     591                 :            : 
     592 [ +  - ][ +  - ]:        514 :                 pSingleCellProperties[nCell] = aCellIterator->get()->GetPropertyValues();
                 [ +  - ]
     593                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     594                 :            :                 dmapper_logger->endElement();
     595                 :            : #endif
     596                 :            :             }
     597                 :        514 :             ++nCell;
     598                 :        514 :             ++aCellIterator;
     599         [ +  - ]:        514 :         }
     600                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     601                 :            :         //-->debug cell properties
     602                 :            :         {
     603                 :            :             OUString sNames;
     604                 :            :             const uno::Sequence< beans::PropertyValues > aDebugCurrentRow = aCellProperties[nRow];
     605                 :            :             sal_Int32 nDebugCells = aDebugCurrentRow.getLength();
     606                 :            :             (void) nDebugCells;
     607                 :            :             for( sal_Int32  nDebugCell = 0; nDebugCell < nDebugCells; ++nDebugCell)
     608                 :            :             {
     609                 :            :                 const uno::Sequence< beans::PropertyValue >& aDebugCellProperties = aDebugCurrentRow[nDebugCell];
     610                 :            :                 sal_Int32 nDebugCellProperties = aDebugCellProperties.getLength();
     611                 :            :                 for( sal_Int32  nDebugProperty = 0; nDebugProperty < nDebugCellProperties; ++nDebugProperty)
     612                 :            :                 {
     613                 :            :                     const OUString sName = aDebugCellProperties[nDebugProperty].Name;
     614                 :            :                     sNames += sName;
     615                 :            :                     sNames += OUString('-');
     616                 :            :                 }
     617                 :            :                 sNames += OUString('\n');
     618                 :            :             }
     619                 :            :             (void)sNames;
     620                 :            :         }
     621                 :            :         //--<
     622                 :            : #endif
     623                 :        127 :         ++nRow;
     624                 :        127 :         ++aRowOfCellsIterator;
     625         [ +  - ]:        127 :     }
     626                 :            : 
     627                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     628                 :            :     dmapper_logger->endElement();
     629                 :            : #endif
     630                 :            : 
     631                 :          0 :     return aCellProperties;
     632                 :            : }
     633                 :            : 
     634                 :        671 : RowPropertyValuesSeq_t DomainMapperTableHandler::endTableGetRowProperties()
     635                 :            : {
     636                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     637                 :            :     dmapper_logger->startElement("getRowProperties");
     638                 :            : #endif
     639                 :            : 
     640         [ +  - ]:        671 :     RowPropertyValuesSeq_t aRowProperties( m_aRowProperties.size() );
     641         [ +  - ]:        671 :     PropertyMapVector1::const_iterator aRowIter = m_aRowProperties.begin();
     642         [ +  - ]:        671 :     PropertyMapVector1::const_iterator aRowIterEnd = m_aRowProperties.end();
     643                 :        671 :     sal_Int32 nRow = 0;
     644 [ +  - ][ +  + ]:        798 :     while( aRowIter != aRowIterEnd )
     645                 :            :     {
     646                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     647                 :            :         dmapper_logger->startElement("rowProps.row");
     648                 :            : #endif
     649         [ +  + ]:        127 :         if( aRowIter->get() )
     650                 :            :         {
     651                 :            :             //set default to 'break across pages"
     652 [ +  - ][ +  + ]:        106 :             if( aRowIter->get()->find( PropertyDefinition( PROP_IS_SPLIT_ALLOWED, false )) == aRowIter->get()->end())
     653 [ +  - ][ +  - ]:        104 :                 aRowIter->get()->Insert( PROP_IS_SPLIT_ALLOWED, false, uno::makeAny(sal_True ) );
     654                 :            : 
     655 [ +  - ][ +  - ]:        106 :             aRowProperties[nRow] = (*aRowIter)->GetPropertyValues();
         [ +  - ][ +  - ]
     656                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     657                 :            :             ((*aRowIter)->dumpXml( dmapper_logger ));
     658                 :            :             lcl_DumpPropertyValues(dmapper_logger, aRowProperties[nRow]);
     659                 :            : #endif
     660                 :            :         }
     661                 :        127 :         ++nRow;
     662                 :        127 :         ++aRowIter;
     663                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     664                 :            :         dmapper_logger->endElement();
     665                 :            : #endif
     666                 :            :     }
     667                 :            : 
     668                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     669                 :            :     dmapper_logger->endElement();
     670                 :            : #endif
     671                 :            : 
     672                 :        671 :     return aRowProperties;
     673                 :            : }
     674                 :            : 
     675                 :        671 : void DomainMapperTableHandler::endTable()
     676                 :            : {
     677                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     678                 :            :     dmapper_logger->startElement("tablehandler.endTable");
     679                 :            : #endif
     680                 :            : 
     681         [ +  - ]:        671 :     TableInfo aTableInfo;
     682         [ +  - ]:        671 :     aTableInfo.pTableStyle = endTableGetTableStyle(aTableInfo);
     683                 :            :     //  expands to uno::Sequence< Sequence< beans::PropertyValues > >
     684                 :            : 
     685         [ +  - ]:        671 :     CellPropertyValuesSeq_t aCellProperties = endTableGetCellProperties(aTableInfo);
     686                 :            : 
     687         [ +  - ]:        671 :     RowPropertyValuesSeq_t aRowProperties = endTableGetRowProperties();
     688                 :            : 
     689                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     690                 :            :     lcl_DumpPropertyValueSeq(dmapper_logger, aRowProperties);
     691                 :            : #endif
     692                 :            : 
     693         [ +  + ]:        671 :     if (m_pTableSeq->getLength() > 0)
     694                 :            :     {
     695                 :        108 :         uno::Reference<text::XTextRange> xStart;
     696                 :        108 :         uno::Reference<text::XTextRange> xEnd;
     697                 :            :         // If we want to make this table a floating one.
     698 [ +  - ][ +  - ]:        108 :         bool bFloating = !m_rDMapper_Impl.getTableManager().getTableVertAnchor().isEmpty();
     699                 :            :         // Additional checks: if we can do this.
     700 [ #  # ][ #  # ]:        108 :         if (bFloating && (*m_pTableSeq)[0].getLength() > 0 && (*m_pTableSeq)[0][0].getLength() > 0)
         [ #  # ][ #  # ]
         [ #  # ][ -  + ]
                 [ -  + ]
     701                 :            :         {
     702 [ #  # ][ #  # ]:          0 :             xStart = (*m_pTableSeq)[0][0][0];
         [ #  # ][ #  # ]
     703         [ #  # ]:          0 :             uno::Sequence< uno::Sequence< uno::Reference<text::XTextRange> > >& rLastRow = (*m_pTableSeq)[m_pTableSeq->getLength() - 1];
     704         [ #  # ]:          0 :             uno::Sequence< uno::Reference<text::XTextRange> >& rLastCell = rLastRow[rLastRow.getLength() - 1];
     705 [ #  # ][ #  # ]:          0 :             xEnd = rLastCell[1];
     706                 :            :         }
     707                 :        108 :         uno::Reference<text::XTextTable> xTable;
     708                 :            :         try
     709                 :            :         {
     710         [ +  + ]:        108 :             if (m_xText.is())
     711                 :            :             {
     712         [ +  - ]:         72 :                 xTable = m_xText->convertToTable(*m_pTableSeq,
     713                 :            :                         aCellProperties,
     714                 :            :                         aRowProperties,
     715 [ +  - ][ +  - ]:         72 :                         aTableInfo.aTableProperties);
     716                 :            : 
     717         [ +  - ]:         72 :                 if (xTable.is())
     718 [ +  - ][ +  - ]:         72 :                     m_xTableRange = xTable->getAnchor( );
                 [ +  - ]
              [ #  #  # ]
     719                 :            :             }
     720                 :            :         }
     721         [ #  # ]:          0 :         catch ( const lang::IllegalArgumentException &e )
     722                 :            :         {
     723                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     724                 :            :             fprintf( stderr, "Conversion to table error: %s\n",
     725                 :            :                     OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
     726                 :            :             dmapper_logger->chars(std::string("failed to import table!"));
     727                 :            : #else
     728                 :            :             (void)e;
     729                 :            : #endif
     730                 :            :         }
     731         [ #  # ]:          0 :         catch ( const uno::Exception &e )
     732                 :            :         {
     733                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     734                 :            :             fprintf( stderr, "Exception during table creation: %s\n",
     735                 :            :                     OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr( ) );
     736                 :            : #else
     737                 :            :             (void) e;
     738                 :            : #endif
     739                 :            :         }
     740                 :            : 
     741                 :            :         // If we have a table with a start and an end position, we should make it a floating one.
     742 [ +  + ][ -  + ]:        108 :         if (xTable.is() && xStart.is() && xEnd.is())
         [ #  # ][ -  + ]
     743                 :            :         {
     744         [ #  # ]:          0 :             uno::Reference<beans::XPropertySet> xTableProperties(xTable, uno::UNO_QUERY);
     745         [ #  # ]:          0 :             uno::Sequence< beans::PropertyValue > aFrameProperties(16);
     746         [ #  # ]:          0 :             beans::PropertyValue* pFrameProperties = aFrameProperties.getArray();
     747                 :          0 :             pFrameProperties[0].Name = "Width";
     748 [ #  # ][ #  # ]:          0 :             pFrameProperties[0].Value = xTableProperties->getPropertyValue("Width");
     749                 :            : 
     750                 :          0 :             pFrameProperties[1].Name = "LeftBorderDistance";
     751         [ #  # ]:          0 :             pFrameProperties[1].Value <<= sal_Int32(0);
     752                 :          0 :             pFrameProperties[2].Name = "RightBorderDistance";
     753         [ #  # ]:          0 :             pFrameProperties[2].Value <<= sal_Int32(0);
     754                 :          0 :             pFrameProperties[3].Name = "TopBorderDistance";
     755         [ #  # ]:          0 :             pFrameProperties[3].Value <<= sal_Int32(0);
     756                 :          0 :             pFrameProperties[4].Name = "BottomBorderDistance";
     757         [ #  # ]:          0 :             pFrameProperties[4].Value <<= sal_Int32(0);
     758                 :            : 
     759                 :          0 :             pFrameProperties[5].Name = "LeftMargin";
     760         [ #  # ]:          0 :             pFrameProperties[5].Value <<= sal_Int32(0);
     761                 :          0 :             pFrameProperties[6].Name = "RightMargin";
     762         [ #  # ]:          0 :             pFrameProperties[6].Value <<= sal_Int32(0);
     763                 :          0 :             pFrameProperties[7].Name = "TopMargin";
     764         [ #  # ]:          0 :             pFrameProperties[7].Value <<= sal_Int32(0);
     765                 :          0 :             pFrameProperties[8].Name = "BottomMargin";
     766         [ #  # ]:          0 :             pFrameProperties[8].Value <<= sal_Int32(0);
     767                 :            : 
     768                 :          0 :             table::BorderLine2 aEmptyBorder;
     769                 :          0 :             pFrameProperties[9].Name = "TopBorder";
     770         [ #  # ]:          0 :             pFrameProperties[9].Value <<= aEmptyBorder;
     771                 :          0 :             pFrameProperties[10].Name = "BottomBorder";
     772         [ #  # ]:          0 :             pFrameProperties[10].Value <<= aEmptyBorder;
     773                 :          0 :             pFrameProperties[11].Name = "LeftBorder";
     774         [ #  # ]:          0 :             pFrameProperties[11].Value <<= aEmptyBorder;
     775                 :          0 :             pFrameProperties[12].Name = "RightBorder";
     776         [ #  # ]:          0 :             pFrameProperties[12].Value <<= aEmptyBorder;
     777                 :            : 
     778                 :          0 :             pFrameProperties[13].Name = "HoriOrient";
     779         [ #  # ]:          0 :             pFrameProperties[13].Value <<= text::HoriOrientation::NONE;
     780                 :          0 :             pFrameProperties[14].Name = "HoriOrientRelation";
     781         [ #  # ]:          0 :             pFrameProperties[14].Value <<= text::RelOrientation::FRAME;
     782                 :            :             // A non-zero left margin would move the table out of the frame, move the frame itself instead.
     783                 :          0 :             pFrameProperties[15].Name = "HoriOrientPosition";
     784 [ #  # ][ #  # ]:          0 :             pFrameProperties[15].Value <<= xTableProperties->getPropertyValue("LeftMargin");
                 [ #  # ]
     785 [ #  # ][ #  # ]:          0 :             xTableProperties->setPropertyValue("LeftMargin", uno::makeAny(sal_Int32(0)));
                 [ #  # ]
     786                 :            : 
     787 [ #  # ][ #  # ]:          0 :             uno::Reference< text::XTextContent > xFrame = m_xText->convertToTextFrame(xStart, xEnd, aFrameProperties);
                 [ #  # ]
     788                 :        108 :         }
     789                 :            :     }
     790                 :            : 
     791         [ +  - ]:        671 :     m_aTableProperties.reset();
     792                 :        671 :     m_aCellProperties.clear();
     793 [ +  - ][ +  - ]:        671 :     m_aRowProperties.clear();
                 [ +  - ]
     794                 :            : 
     795                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     796                 :            :     dmapper_logger->endElement();
     797                 :            :     dmapper_logger->endElement();
     798                 :            : #endif
     799                 :        671 : }
     800                 :            : 
     801                 :        127 : void DomainMapperTableHandler::startRow(unsigned int nCells,
     802                 :            :                                         TablePropertyMapPtr pProps)
     803                 :            : {
     804 [ +  - ][ +  - ]:        127 :     m_aRowProperties.push_back( pProps );
                 [ +  - ]
     805         [ +  - ]:        127 :     m_aCellProperties.push_back( PropertyMapVector1() );
     806                 :            : 
     807                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     808                 :            :     dmapper_logger->startElement("table.row");
     809                 :            :     dmapper_logger->attribute("cells", nCells);
     810                 :            :     if (pProps != NULL)
     811                 :            :         pProps->dumpXml(dmapper_logger);
     812                 :            : #endif
     813                 :            : 
     814 [ +  - ][ +  - ]:        127 :     m_pRowSeq = RowSequencePointer_t(new RowSequence_t(nCells));
     815                 :        127 :     m_nCellIndex = 0;
     816                 :        127 : }
     817                 :            : 
     818                 :        127 : void DomainMapperTableHandler::endRow()
     819                 :            : {
     820                 :        127 :     (*m_pTableSeq)[m_nRowIndex] = *m_pRowSeq;
     821                 :        127 :     ++m_nRowIndex;
     822                 :        127 :     m_nCellIndex = 0;
     823                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     824                 :            :     dmapper_logger->endElement();
     825                 :            : #endif
     826                 :        127 : }
     827                 :            : 
     828                 :        514 : void DomainMapperTableHandler::startCell(const Handle_t & start,
     829                 :            :                                          TablePropertyMapPtr pProps )
     830                 :            : {
     831                 :        514 :     sal_uInt32 nRow = m_aRowProperties.size();
     832         [ +  + ]:        514 :     if ( pProps.get( ) )
     833 [ +  - ][ +  - ]:        442 :         m_aCellProperties[nRow - 1].push_back( pProps );
                 [ +  - ]
     834                 :            :     else
     835                 :            :     {
     836                 :            :         // Adding an empty cell properties map to be able to get
     837                 :            :         // the table defaults properties
     838 [ +  - ][ +  - ]:         72 :         TablePropertyMapPtr pEmptyProps( new TablePropertyMap( ) );
                 [ +  - ]
     839 [ +  - ][ +  - ]:         72 :         m_aCellProperties[nRow - 1].push_back( pEmptyProps );
         [ +  - ][ +  - ]
     840                 :            :     }
     841                 :            : 
     842                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     843                 :            :     dmapper_logger->startElement("table.cell");
     844                 :            :     dmapper_logger->startElement("table.cell.start");
     845                 :            :     dmapper_logger->chars(toString(start));
     846                 :            :     dmapper_logger->endElement();
     847                 :            :     lcl_printProperties( pProps );
     848                 :            : #endif
     849                 :            : 
     850                 :            :     //add a new 'row' of properties
     851 [ +  - ][ +  - ]:        514 :     m_pCellSeq = CellSequencePointer_t(new CellSequence_t(2));
     852         [ +  + ]:        514 :     if (!start.get())
     853                 :        514 :         return;
     854 [ +  - ][ +  - ]:        436 :     (*m_pCellSeq)[0] = start->getStart();
     855                 :            : }
     856                 :            : 
     857                 :        514 : void DomainMapperTableHandler::endCell(const Handle_t & end)
     858                 :            : {
     859                 :            : #ifdef DEBUG_DMAPPER_TABLE_HANDLER
     860                 :            :     dmapper_logger->startElement("table.cell.end");
     861                 :            :     dmapper_logger->chars(toString(end));
     862                 :            :     dmapper_logger->endElement();
     863                 :            :     dmapper_logger->endElement();
     864                 :            : #endif
     865                 :            : 
     866         [ +  + ]:        514 :     if (!end.get())
     867                 :        514 :         return;
     868 [ +  - ][ +  - ]:        436 :     (*m_pCellSeq)[1] = end->getEnd();
     869                 :        436 :     (*m_pRowSeq)[m_nCellIndex] = *m_pCellSeq;
     870                 :        436 :     ++m_nCellIndex;
     871                 :            : }
     872                 :            : 
     873 [ +  - ][ +  - ]:         60 : }}
     874                 :            : 
     875                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10