LCOV - code coverage report
Current view: top level - sw/source/filter/xml - xmltble.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 542 0.6 %
Date: 2012-08-25 Functions: 1 39 2.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 924 0.1 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <com/sun/star/text/XTextTable.hpp>
      31                 :            : #include <com/sun/star/text/XTextSection.hpp>
      32                 :            : 
      33                 :            : #include <hintids.hxx>
      34                 :            : #include <rtl/ustrbuf.hxx>
      35                 :            : #include <xmloff/xmlnmspe.hxx>
      36                 :            : #include <xmloff/xmltoken.hxx>
      37                 :            : #include <xmloff/xmluconv.hxx>
      38                 :            : #include <xmloff/numehelp.hxx>
      39                 :            : #include <svl/zforlist.hxx>
      40                 :            : #include <editeng/brshitem.hxx>
      41                 :            : #include <editeng/boxitem.hxx>
      42                 :            : #include <fmtrowsplt.hxx>
      43                 :            : #include <editeng/frmdiritem.hxx>
      44                 :            : #include <list>
      45                 :            : #include "swtable.hxx"
      46                 :            : #include "doc.hxx"
      47                 :            : #include "pam.hxx"
      48                 :            : #include "frmfmt.hxx"
      49                 :            : #include "wrtswtbl.hxx"
      50                 :            : #include "fmtfsize.hxx"
      51                 :            : #include "fmtornt.hxx"
      52                 :            : #include "cellatr.hxx"
      53                 :            : #include "ddefld.hxx"
      54                 :            : #include "swddetbl.hxx"
      55                 :            : #include <ndole.hxx>
      56                 :            : #include <xmloff/nmspmap.hxx>
      57                 :            : #include <sfx2/linkmgr.hxx>  // for cTokenSeperator
      58                 :            : #include "unotbl.hxx"
      59                 :            : #include "xmltexte.hxx"
      60                 :            : #include "xmlexp.hxx"
      61                 :            : #include <boost/foreach.hpp>
      62                 :            : #include <o3tl/sorted_vector.hxx>
      63                 :            : 
      64                 :            : using ::rtl::OUString;
      65                 :            : using ::rtl::OUStringBuffer;
      66                 :            : using namespace ::com::sun::star;
      67                 :            : using namespace ::com::sun::star::uno;
      68                 :            : using namespace ::com::sun::star::text;
      69                 :            : using namespace ::com::sun::star::beans;
      70                 :            : using namespace ::com::sun::star::lang;
      71                 :            : using namespace ::com::sun::star::container;
      72                 :            : using namespace ::xmloff::token;
      73                 :            : using table::XCell;
      74                 :            : using ::std::vector;
      75                 :            : using ::std::advance;
      76                 :            : 
      77                 :          0 : class SwXMLTableColumn_Impl : public SwWriteTableCol
      78                 :            : {
      79                 :            :     OUString    sStyleName;
      80                 :            :     sal_uInt32  nRelWidth;
      81                 :            : 
      82                 :            : public:
      83                 :            : 
      84                 :            : 
      85                 :          0 :     SwXMLTableColumn_Impl( sal_uInt32 nPosition ) :
      86                 :            :         SwWriteTableCol( nPosition ),
      87                 :          0 :         nRelWidth( 0UL )
      88                 :          0 :     {};
      89                 :            : 
      90                 :          0 :     void SetStyleName( const OUString& rName ) { sStyleName = rName; }
      91                 :          0 :     const OUString& GetStyleName() const { return sStyleName; }
      92                 :            : 
      93                 :          0 :     void SetRelWidth( sal_uInt32 nSet ) { nRelWidth = nSet; }
      94                 :          0 :     sal_uInt32 GetRelWidth() const { return nRelWidth; }
      95                 :            : };
      96                 :            : 
      97                 :            : struct SwXMLTableColumnCmpWidth_Impl
      98                 :            : {
      99                 :          0 :     bool operator()( SwXMLTableColumn_Impl* const& lhs, SwXMLTableColumn_Impl* const& rhs ) const
     100                 :            :     {
     101                 :          0 :         sal_Int32 n = (sal_Int32)lhs->GetWidthOpt() - (sal_Int32)rhs->GetWidthOpt();
     102         [ #  # ]:          0 :         if( !n )
     103                 :          0 :             n = (sal_Int32)lhs->GetRelWidth() - (sal_Int32)rhs->GetRelWidth();
     104                 :          0 :         return n < 0;
     105                 :            :     }
     106                 :            : };
     107                 :            : 
     108                 :            : // ---------------------------------------------------------------------
     109                 :            : 
     110                 :          0 : class SwXMLTableColumns_Impl : public o3tl::sorted_vector<SwXMLTableColumn_Impl*, o3tl::less_ptr_to<SwXMLTableColumn_Impl> > {
     111                 :            : public:
     112         [ #  # ]:          0 :     ~SwXMLTableColumns_Impl() { DeleteAndDestroyAll(); }
     113                 :            : };
     114                 :            : 
     115                 :          0 : class SwXMLTableColumnsSortByWidth_Impl : public o3tl::sorted_vector<SwXMLTableColumn_Impl*, SwXMLTableColumnCmpWidth_Impl> {};
     116                 :            : 
     117                 :            : class SwXMLTableLines_Impl
     118                 :            : {
     119                 :            :     SwXMLTableColumns_Impl  aCols;
     120                 :            :     const SwTableLines      *pLines;
     121                 :            :     sal_uInt32              nWidth;
     122                 :            : 
     123                 :            : public:
     124                 :            : 
     125                 :            :     SwXMLTableLines_Impl( const SwTableLines& rLines );
     126                 :            : 
     127                 :          0 :     ~SwXMLTableLines_Impl() {}
     128                 :            : 
     129                 :          0 :     sal_uInt32 GetWidth() const { return nWidth; }
     130                 :          0 :     const SwTableLines *GetLines() const { return pLines; }
     131                 :            : 
     132                 :          0 :     const SwXMLTableColumns_Impl& GetColumns() const { return aCols; }
     133                 :            : };
     134                 :            : 
     135                 :          0 : SwXMLTableLines_Impl::SwXMLTableLines_Impl( const SwTableLines& rLines ) :
     136                 :            :     pLines( &rLines ),
     137                 :          0 :     nWidth( 0UL )
     138                 :            : {
     139                 :            : #if OSL_DEBUG_LEVEL > 0
     140                 :            :     sal_uInt32 nEndCPos = 0U;
     141                 :            : #endif
     142                 :          0 :     sal_uInt16 nLines = rLines.size();
     143                 :            :     sal_uInt16 nLine;
     144         [ #  # ]:          0 :     for( nLine=0U; nLine<nLines; nLine++ )
     145                 :            :     {
     146                 :          0 :         const SwTableLine *pLine = rLines[nLine];
     147                 :          0 :         const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
     148                 :          0 :         sal_uInt16 nBoxes = rBoxes.size();
     149                 :            : 
     150                 :          0 :         sal_uInt32 nCPos = 0U;
     151         [ #  # ]:          0 :         for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
     152                 :            :         {
     153                 :          0 :             const SwTableBox *pBox = rBoxes[nBox];
     154                 :            : 
     155 [ #  # ][ #  # ]:          0 :             if( nBox < nBoxes-1U || nWidth==0UL )
     156                 :            :             {
     157         [ #  # ]:          0 :                 nCPos = nCPos + SwWriteTable::GetBoxWidth( pBox );
     158                 :            :                 SwXMLTableColumn_Impl *pCol =
     159 [ #  # ][ #  # ]:          0 :                     new SwXMLTableColumn_Impl( nCPos );
     160                 :            : 
     161 [ #  # ][ #  # ]:          0 :                 if( !aCols.insert( pCol ).second )
     162         [ #  # ]:          0 :                     delete pCol;
     163                 :            : 
     164         [ #  # ]:          0 :                 if( nBox==nBoxes-1U )
     165                 :            :                 {
     166                 :            :                     OSL_ENSURE( nLine==0U && nWidth==0UL,
     167                 :            :                             "parent width will be lost" );
     168                 :          0 :                     nWidth = nCPos;
     169                 :          0 :                 }
     170                 :            :             }
     171                 :            :             else
     172                 :            :             {
     173                 :            : #if OSL_DEBUG_LEVEL > 0
     174                 :            :                 sal_uInt32 nCheckPos =
     175                 :            :                     nCPos + SwWriteTable::GetBoxWidth( pBox );
     176                 :            :                 if( !nEndCPos )
     177                 :            :                 {
     178                 :            :                     nEndCPos = nCheckPos;
     179                 :            :                 }
     180                 :            : #endif
     181                 :          0 :                 nCPos = nWidth;
     182                 :            : #if OSL_DEBUG_LEVEL > 0
     183                 :            :                 SwXMLTableColumn_Impl aCol( nWidth );
     184                 :            :                 OSL_ENSURE( aCols.find(&aCol) != aCols.end(), "couldn't find last column" );
     185                 :            :                 OSL_ENSURE( SwXMLTableColumn_Impl(nCheckPos) ==
     186                 :            :                                             SwXMLTableColumn_Impl(nCPos),
     187                 :            :                         "rows have different total widths" );
     188                 :            : #endif
     189                 :            :             }
     190                 :            :         }
     191                 :            :     }
     192                 :          0 : }
     193                 :            : 
     194                 :            : // ---------------------------------------------------------------------
     195                 :            : 
     196                 :            : typedef vector< SwFrmFmt* > SwXMLFrmFmts_Impl;
     197                 :            : 
     198                 :          0 : class SwXMLTableFrmFmtsSort_Impl
     199                 :            : {
     200                 :            : private:
     201                 :            :     SwXMLFrmFmts_Impl aFormatList;
     202                 :            : 
     203                 :            : public:
     204                 :          0 :     SwXMLTableFrmFmtsSort_Impl ( sal_uInt16 /* nInit */, sal_uInt16 /*nGrow*/ )
     205                 :          0 :     {}
     206                 :            : 
     207                 :            :     sal_Bool AddRow( SwFrmFmt& rFrmFmt, const OUString& rNamePrefix, sal_uInt32 nLine );
     208                 :            :     sal_Bool AddCell( SwFrmFmt& rFrmFmt, const OUString& rNamePrefix,
     209                 :            :                   sal_uInt32 nCol, sal_uInt32 nRow, sal_Bool bTop );
     210                 :            : };
     211                 :            : 
     212                 :          0 : sal_Bool SwXMLTableFrmFmtsSort_Impl::AddRow( SwFrmFmt& rFrmFmt,
     213                 :            :                                          const OUString& rNamePrefix,
     214                 :            :                                             sal_uInt32 nLine )
     215                 :            : {
     216                 :          0 :     const SwFmtFrmSize *pFrmSize = 0;
     217                 :          0 :     const SwFmtRowSplit* pRowSplit = 0;
     218                 :          0 :     const SvxBrushItem *pBrush = 0;
     219                 :            : 
     220                 :          0 :     const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
     221                 :            :     const SfxPoolItem *pItem;
     222 [ #  # ][ #  # ]:          0 :     if( SFX_ITEM_SET == rItemSet.GetItemState( RES_FRM_SIZE, sal_False, &pItem ) )
     223                 :          0 :         pFrmSize = (const SwFmtFrmSize *)pItem;
     224                 :            : 
     225 [ #  # ][ #  # ]:          0 :     if( SFX_ITEM_SET == rItemSet.GetItemState( RES_ROW_SPLIT, sal_False, &pItem ) )
     226                 :          0 :         pRowSplit = (const SwFmtRowSplit *)pItem;
     227                 :            : 
     228 [ #  # ][ #  # ]:          0 :     if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, sal_False, &pItem ) )
     229                 :          0 :         pBrush = (const SvxBrushItem *)pItem;
     230                 :            : 
     231                 :            :     // empty styles have not to be exported
     232 [ #  # ][ #  # ]:          0 :     if( !pFrmSize && !pBrush && !pRowSplit )
                 [ #  # ]
     233                 :          0 :         return sal_False;
     234                 :            : 
     235                 :            :     // order is: -/brush, size/-, size/brush
     236                 :          0 :     sal_Bool bInsert = sal_True;
     237                 :          0 :     SwXMLFrmFmts_Impl::iterator i;
     238 [ #  # ][ #  # ]:          0 :     for( i = aFormatList.begin(); i < aFormatList.end(); ++i )
                 [ #  # ]
     239                 :            :     {
     240                 :          0 :         const SwFmtFrmSize *pTestFrmSize = 0;
     241                 :          0 :         const SwFmtRowSplit* pTestRowSplit = 0;
     242                 :          0 :         const SvxBrushItem *pTestBrush = 0;
     243         [ #  # ]:          0 :         const SwFrmFmt *pTestFmt = *i;
     244                 :          0 :         const SfxItemSet& rTestSet = pTestFmt->GetAttrSet();
     245         [ #  # ]:          0 :         if( SFX_ITEM_SET == rTestSet.GetItemState( RES_FRM_SIZE, sal_False,
     246         [ #  # ]:          0 :                                                   &pItem ) )
     247                 :            :         {
     248         [ #  # ]:          0 :             if( !pFrmSize )
     249                 :          0 :                 break;
     250                 :            : 
     251                 :          0 :             pTestFrmSize = (const SwFmtFrmSize *)pItem;
     252                 :            :         }
     253                 :            :         else
     254                 :            :         {
     255         [ #  # ]:          0 :             if( pFrmSize )
     256                 :          0 :                 continue;
     257                 :            :         }
     258                 :            : 
     259         [ #  # ]:          0 :         if( SFX_ITEM_SET == rTestSet.GetItemState( RES_BACKGROUND, sal_False,
     260         [ #  # ]:          0 :                                                   &pItem ) )
     261                 :            :         {
     262         [ #  # ]:          0 :             if( !pBrush )
     263                 :          0 :                 break;
     264                 :            : 
     265                 :          0 :             pTestBrush = (const SvxBrushItem *)pItem;
     266                 :            :         }
     267                 :            :         else
     268                 :            :         {
     269         [ #  # ]:          0 :             if( pBrush )
     270                 :          0 :                 continue;
     271                 :            :         }
     272                 :            : 
     273         [ #  # ]:          0 :         if( SFX_ITEM_SET == rTestSet.GetItemState( RES_ROW_SPLIT, sal_False,
     274         [ #  # ]:          0 :                                                   &pItem ) )
     275                 :            :         {
     276         [ #  # ]:          0 :             if( !pRowSplit )
     277                 :          0 :                 break;
     278                 :            : 
     279                 :          0 :             pTestRowSplit = (const SwFmtRowSplit *)pItem;
     280                 :            :         }
     281                 :            :         else
     282                 :            :         {
     283         [ #  # ]:          0 :             if( pRowSplit )
     284                 :          0 :                 continue;
     285                 :            :         }
     286                 :            : 
     287                 :            : 
     288   [ #  #  #  #  :          0 :         if( pFrmSize &&
           #  # ][ #  # ]
     289                 :          0 :             ( pFrmSize->GetHeightSizeType() != pTestFrmSize->GetHeightSizeType() ||
     290                 :          0 :               pFrmSize->GetHeight() != pTestFrmSize->GetHeight() ) )
     291                 :          0 :             continue;
     292                 :            : 
     293 [ #  # ][ #  # ]:          0 :         if( pBrush && (*pBrush != *pTestBrush) )
         [ #  # ][ #  # ]
     294                 :          0 :             continue;
     295                 :            : 
     296 [ #  # ][ #  # ]:          0 :         if( pRowSplit && (!pRowSplit->GetValue() != !pTestRowSplit->GetValue()) )
                 [ #  # ]
     297                 :          0 :             continue;
     298                 :            : 
     299                 :            :         // found!
     300                 :          0 :         const String& rFmtName = pTestFmt->GetName();
     301         [ #  # ]:          0 :         rFrmFmt.SetName( rFmtName );
     302                 :          0 :         bInsert = sal_False;
     303                 :          0 :         break;
     304                 :            :     }
     305                 :            : 
     306         [ #  # ]:          0 :     if( bInsert )
     307                 :            :     {
     308                 :          0 :         OUStringBuffer sBuffer( rNamePrefix.getLength() + 4UL );
     309         [ #  # ]:          0 :         sBuffer.append( rNamePrefix );
     310         [ #  # ]:          0 :         sBuffer.append( (sal_Unicode)'.' );
     311         [ #  # ]:          0 :         sBuffer.append( (sal_Int32)(nLine+1UL) );
     312                 :            : 
     313 [ #  # ][ #  # ]:          0 :         rFrmFmt.SetName( sBuffer.makeStringAndClear() );
         [ #  # ][ #  # ]
     314 [ #  # ][ #  # ]:          0 :         if ( i != aFormatList.end() ) ++i;
                 [ #  # ]
     315         [ #  # ]:          0 :         aFormatList.insert( i, &rFrmFmt );
     316                 :            :     }
     317                 :            : 
     318                 :          0 :     return bInsert;
     319                 :            : }
     320                 :            : 
     321                 :            : void lcl_GetTblBoxColStr( sal_uInt16 nCol, String& rNm );
     322                 :          0 : void lcl_xmltble_appendBoxPrefix( OUStringBuffer& rBuffer,
     323                 :            :                                   const OUString& rNamePrefix,
     324                 :            :                                   sal_uInt32 nCol, sal_uInt32 nRow, sal_Bool bTop )
     325                 :            : {
     326                 :          0 :     rBuffer.append( rNamePrefix );
     327                 :          0 :     rBuffer.append( (sal_Unicode)'.' );
     328         [ #  # ]:          0 :     if( bTop )
     329                 :            :     {
     330         [ #  # ]:          0 :         String sTmp;
     331         [ #  # ]:          0 :         lcl_GetTblBoxColStr( (sal_uInt16)nCol, sTmp );
     332 [ #  # ][ #  # ]:          0 :         rBuffer.append( sTmp );
                 [ #  # ]
     333                 :            :     }
     334                 :            :     else
     335                 :            :     {
     336                 :          0 :         rBuffer.append( (sal_Int32)(nCol + 1));
     337                 :          0 :         rBuffer.append( (sal_Unicode)'.' );
     338                 :            :     }
     339                 :          0 :     rBuffer.append( (sal_Int32)(nRow + 1));
     340                 :          0 : }
     341                 :            : 
     342                 :          0 : sal_Bool SwXMLTableFrmFmtsSort_Impl::AddCell( SwFrmFmt& rFrmFmt,
     343                 :            :                                          const OUString& rNamePrefix,
     344                 :            :                                             sal_uInt32 nCol, sal_uInt32 nRow, sal_Bool bTop )
     345                 :            : {
     346                 :          0 :     const SwFmtVertOrient *pVertOrient = 0;
     347                 :          0 :     const SvxBrushItem *pBrush = 0;
     348                 :          0 :     const SvxBoxItem *pBox = 0;
     349                 :          0 :     const SwTblBoxNumFormat *pNumFmt = 0;
     350                 :          0 :     const SvxFrameDirectionItem *pFrameDir = 0;
     351                 :            : 
     352                 :          0 :     const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
     353                 :            :     const SfxPoolItem *pItem;
     354         [ #  # ]:          0 :     if( SFX_ITEM_SET == rItemSet.GetItemState( RES_VERT_ORIENT, sal_False,
     355         [ #  # ]:          0 :                                                &pItem ) )
     356                 :          0 :         pVertOrient = (const SwFmtVertOrient *)pItem;
     357                 :            : 
     358 [ #  # ][ #  # ]:          0 :     if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, sal_False, &pItem ) )
     359                 :          0 :         pBrush = (const SvxBrushItem *)pItem;
     360                 :            : 
     361 [ #  # ][ #  # ]:          0 :     if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BOX, sal_False, &pItem ) )
     362                 :          0 :         pBox = (const SvxBoxItem *)pItem;
     363                 :            : 
     364         [ #  # ]:          0 :     if ( SFX_ITEM_SET == rItemSet.GetItemState( RES_BOXATR_FORMAT,
     365         [ #  # ]:          0 :                                                 sal_False, &pItem ) )
     366                 :          0 :         pNumFmt = (const SwTblBoxNumFormat *)pItem;
     367         [ #  # ]:          0 :     if ( SFX_ITEM_SET == rItemSet.GetItemState( RES_FRAMEDIR,
     368         [ #  # ]:          0 :                                                 sal_False, &pItem ) )
     369                 :          0 :         pFrameDir = (const SvxFrameDirectionItem *)pItem;
     370                 :            : 
     371                 :            :     // empty styles have not to be exported
     372 [ #  # ][ #  # ]:          0 :     if( !pVertOrient && !pBrush && !pBox && !pNumFmt && !pFrameDir )
         [ #  # ][ #  # ]
                 [ #  # ]
     373                 :          0 :         return sal_False;
     374                 :            : 
     375                 :            :     // order is: -/-/-/num,
     376                 :            :     //           -/-/box/-, --/-/box/num,
     377                 :            :     //           -/brush/-/-, -/brush/-/num, -/brush/box/-, -/brush/box/num,
     378                 :            :     //           vert/-/-/-, vert/-/-/num, vert/-/box/-, ver/-/box/num,
     379                 :            :     //           vert/brush/-/-, vert/brush/-/num, vert/brush/box/-,
     380                 :            :     //           vert/brush/box/num
     381                 :          0 :     sal_Bool bInsert = sal_True;
     382                 :          0 :     SwXMLFrmFmts_Impl::iterator i;
     383 [ #  # ][ #  # ]:          0 :     for( i = aFormatList.begin(); i < aFormatList.end(); ++i )
                 [ #  # ]
     384                 :            :     {
     385                 :          0 :         const SwFmtVertOrient *pTestVertOrient = 0;
     386                 :          0 :         const SvxBrushItem *pTestBrush = 0;
     387                 :          0 :         const SvxBoxItem *pTestBox = 0;
     388                 :          0 :         const SwTblBoxNumFormat *pTestNumFmt = 0;
     389                 :          0 :         const SvxFrameDirectionItem *pTestFrameDir = 0;
     390         [ #  # ]:          0 :         const SwFrmFmt* pTestFmt = *i;
     391                 :          0 :         const SfxItemSet& rTestSet = pTestFmt->GetAttrSet();
     392         [ #  # ]:          0 :         if( SFX_ITEM_SET == rTestSet.GetItemState( RES_VERT_ORIENT, sal_False,
     393         [ #  # ]:          0 :                                                   &pItem ) )
     394                 :            :         {
     395         [ #  # ]:          0 :             if( !pVertOrient )
     396                 :          0 :                 break;
     397                 :            : 
     398                 :          0 :             pTestVertOrient = (const SwFmtVertOrient *)pItem;
     399                 :            :         }
     400                 :            :         else
     401                 :            :         {
     402         [ #  # ]:          0 :             if( pVertOrient )
     403                 :          0 :                 continue;
     404                 :            :         }
     405                 :            : 
     406         [ #  # ]:          0 :         if( SFX_ITEM_SET == rTestSet.GetItemState( RES_BACKGROUND, sal_False,
     407         [ #  # ]:          0 :                                                   &pItem ) )
     408                 :            :         {
     409         [ #  # ]:          0 :             if( !pBrush )
     410                 :          0 :                 break;
     411                 :            : 
     412                 :          0 :             pTestBrush = (const SvxBrushItem *)pItem;
     413                 :            :         }
     414                 :            :         else
     415                 :            :         {
     416         [ #  # ]:          0 :             if( pBrush )
     417                 :          0 :                 continue;
     418                 :            :         }
     419                 :            : 
     420 [ #  # ][ #  # ]:          0 :         if( SFX_ITEM_SET == rTestSet.GetItemState( RES_BOX, sal_False, &pItem ) )
     421                 :            :         {
     422         [ #  # ]:          0 :             if( !pBox )
     423                 :          0 :                 break;
     424                 :            : 
     425                 :          0 :             pTestBox = (const SvxBoxItem *)pItem;
     426                 :            :         }
     427                 :            :         else
     428                 :            :         {
     429         [ #  # ]:          0 :             if( pBox )
     430                 :          0 :                 continue;
     431                 :            :         }
     432                 :            : 
     433         [ #  # ]:          0 :         if ( SFX_ITEM_SET == rTestSet.GetItemState( RES_BOXATR_FORMAT,
     434         [ #  # ]:          0 :                                                 sal_False, &pItem ) )
     435                 :            :         {
     436         [ #  # ]:          0 :             if( !pNumFmt )
     437                 :          0 :                 break;
     438                 :            : 
     439                 :          0 :             pTestNumFmt = (const SwTblBoxNumFormat *)pItem;
     440                 :            :         }
     441                 :            :         else
     442                 :            :         {
     443         [ #  # ]:          0 :             if( pNumFmt )
     444                 :          0 :                 continue;
     445                 :            : 
     446                 :            :         }
     447                 :            : 
     448         [ #  # ]:          0 :         if ( SFX_ITEM_SET == rTestSet.GetItemState( RES_FRAMEDIR,
     449         [ #  # ]:          0 :                                                 sal_False, &pItem ) )
     450                 :            :         {
     451         [ #  # ]:          0 :             if( !pFrameDir )
     452                 :          0 :                 break;
     453                 :            : 
     454                 :          0 :             pTestFrameDir = (const SvxFrameDirectionItem *)pItem;
     455                 :            :         }
     456                 :            :         else
     457                 :            :         {
     458         [ #  # ]:          0 :             if( pFrameDir )
     459                 :          0 :                 continue;
     460                 :            : 
     461                 :            :         }
     462                 :            : 
     463   [ #  #  #  # ]:          0 :         if( pVertOrient &&
                 [ #  # ]
     464                 :          0 :             pVertOrient->GetVertOrient() != pTestVertOrient->GetVertOrient() )
     465                 :          0 :             continue;
     466                 :            : 
     467 [ #  # ][ #  # ]:          0 :         if( pBrush && ( *pBrush != *pTestBrush ) )
         [ #  # ][ #  # ]
     468                 :          0 :             continue;
     469                 :            : 
     470 [ #  # ][ #  # ]:          0 :         if( pBox && ( *pBox != *pTestBox ) )
         [ #  # ][ #  # ]
     471                 :          0 :             continue;
     472                 :            : 
     473 [ #  # ][ #  # ]:          0 :         if( pNumFmt && pNumFmt->GetValue() != pTestNumFmt->GetValue() )
                 [ #  # ]
     474                 :          0 :             continue;
     475                 :            : 
     476 [ #  # ][ #  # ]:          0 :         if( pFrameDir && pFrameDir->GetValue() != pTestFrameDir->GetValue() )
                 [ #  # ]
     477                 :          0 :             continue;
     478                 :            : 
     479                 :            :         // found!
     480                 :          0 :         const String& rFmtName = pTestFmt->GetName();
     481         [ #  # ]:          0 :         rFrmFmt.SetName( rFmtName );
     482                 :          0 :         bInsert = sal_False;
     483                 :          0 :         break;
     484                 :            :     }
     485                 :            : 
     486         [ #  # ]:          0 :     if( bInsert )
     487                 :            :     {
     488                 :          0 :         OUStringBuffer sBuffer( rNamePrefix.getLength() + 8UL );
     489         [ #  # ]:          0 :         lcl_xmltble_appendBoxPrefix( sBuffer, rNamePrefix, nCol, nRow, bTop );
     490 [ #  # ][ #  # ]:          0 :         rFrmFmt.SetName( sBuffer.makeStringAndClear() );
         [ #  # ][ #  # ]
     491 [ #  # ][ #  # ]:          0 :         if ( i != aFormatList.end() ) ++i;
                 [ #  # ]
     492         [ #  # ]:          0 :         aFormatList.insert( i, &rFrmFmt );
     493                 :            :     }
     494                 :            : 
     495                 :          0 :     return bInsert;
     496                 :            : }
     497                 :            : // ---------------------------------------------------------------------
     498                 :            : 
     499                 :          0 : class SwXMLTableInfo_Impl
     500                 :            : {
     501                 :            :     const SwTable *pTable;
     502                 :            :     Reference < XTextSection > xBaseSection;
     503                 :            :     sal_Bool bBaseSectionValid;
     504                 :            : 
     505                 :            : public:
     506                 :            : 
     507                 :            :     inline SwXMLTableInfo_Impl( const SwTable *pTbl );
     508                 :            : 
     509                 :          0 :     const SwTable *GetTable() const { return pTable; }
     510                 :          0 :     const SwFrmFmt *GetTblFmt() const { return pTable->GetFrmFmt(); }
     511                 :            : 
     512                 :          0 :     sal_Bool IsBaseSectionValid() const { return bBaseSectionValid; }
     513                 :          0 :     const Reference < XTextSection >& GetBaseSection() const { return xBaseSection; }
     514                 :            :     inline void SetBaseSection( const Reference < XTextSection >& rBase );
     515                 :            : };
     516                 :            : 
     517                 :          0 : inline SwXMLTableInfo_Impl::SwXMLTableInfo_Impl( const SwTable *pTbl ) :
     518                 :            :     pTable( pTbl ),
     519                 :          0 :     bBaseSectionValid( sal_False )
     520                 :            : {
     521                 :          0 : }
     522                 :            : 
     523                 :          0 : inline void SwXMLTableInfo_Impl::SetBaseSection(
     524                 :            :         const Reference < XTextSection >& rBaseSection )
     525                 :            : {
     526                 :          0 :     xBaseSection = rBaseSection;
     527                 :          0 :     bBaseSectionValid = sal_True;
     528                 :          0 : }
     529                 :            : 
     530                 :            : // ---------------------------------------------------------------------
     531                 :            : 
     532                 :            : 
     533                 :          0 : void SwXMLExport::ExportTableColumnStyle( const SwXMLTableColumn_Impl& rCol )
     534                 :            : {
     535                 :            :     // <style:style ...>
     536                 :          0 :     CheckAttrList();
     537                 :            : 
     538                 :            :     // style:name="..."
     539                 :          0 :     sal_Bool bEncoded = sal_False;
     540                 :            :     AddAttribute( XML_NAMESPACE_STYLE, XML_NAME,
     541 [ #  # ][ #  # ]:          0 :                     EncodeStyleName( rCol.GetStyleName(), &bEncoded ) );
     542         [ #  # ]:          0 :     if( bEncoded )
     543         [ #  # ]:          0 :         AddAttribute( XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, rCol.GetStyleName() );
     544                 :            : 
     545                 :            :     // style:family="table-column"
     546         [ #  # ]:          0 :     AddAttribute( XML_NAMESPACE_STYLE, XML_FAMILY, XML_TABLE_COLUMN );
     547                 :            : 
     548                 :            :     {
     549                 :            :         SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, XML_STYLE, sal_True,
     550         [ #  # ]:          0 :                                   sal_True );
     551                 :          0 :         OUStringBuffer sValue;
     552         [ #  # ]:          0 :         if( rCol.GetWidthOpt() )
     553                 :            :         {
     554                 :          0 :             GetTwipUnitConverter().convertMeasureToXML( sValue,
     555         [ #  # ]:          0 :                     rCol.GetWidthOpt() );
     556                 :            :             AddAttribute( XML_NAMESPACE_STYLE, XML_COLUMN_WIDTH,
     557 [ #  # ][ #  # ]:          0 :                           sValue.makeStringAndClear() );
     558                 :            :         }
     559         [ #  # ]:          0 :         if( rCol.GetRelWidth() )
     560                 :            :         {
     561         [ #  # ]:          0 :             sValue.append( (sal_Int32)rCol.GetRelWidth() );
     562         [ #  # ]:          0 :             sValue.append( (sal_Unicode)'*' );
     563                 :            :             AddAttribute( XML_NAMESPACE_STYLE, XML_REL_COLUMN_WIDTH,
     564 [ #  # ][ #  # ]:          0 :                           sValue.makeStringAndClear() );
     565                 :            :         }
     566                 :            : 
     567                 :            :         {
     568                 :            :             SvXMLElementExport aElemExport( *this, XML_NAMESPACE_STYLE,
     569                 :            :                                       XML_TABLE_COLUMN_PROPERTIES,
     570 [ #  # ][ #  # ]:          0 :                                       sal_True, sal_True );
     571         [ #  # ]:          0 :         }
     572                 :            :     }
     573                 :          0 : }
     574                 :            : 
     575                 :          0 : void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
     576                 :            :                                     sal_uInt32 nAbsWidth, sal_uInt32 nBaseWidth,
     577                 :            :                                     const OUString& rNamePrefix,
     578                 :            :                                     SwXMLTableColumnsSortByWidth_Impl& rExpCols,
     579                 :            :                                     SwXMLTableFrmFmtsSort_Impl& rExpRows,
     580                 :            :                                     SwXMLTableFrmFmtsSort_Impl& rExpCells,
     581                 :            :                                     SwXMLTableInfo_Impl& rTblInfo,
     582                 :            :                                     sal_Bool bTop )
     583                 :            : {
     584                 :            :     // pass 1: calculate columns
     585 [ #  # ][ #  # ]:          0 :     SwXMLTableLines_Impl *pLines = new SwXMLTableLines_Impl( rLines );
     586         [ #  # ]:          0 :     if( !pTableLines )
     587 [ #  # ][ #  # ]:          0 :         pTableLines = new SwXMLTableLinesCache_Impl();
     588                 :            : 
     589         [ #  # ]:          0 :     pTableLines->push_back( pLines );
     590                 :            : 
     591                 :          0 :     OUStringBuffer sBuffer( rNamePrefix.getLength() + 8L );
     592                 :            : 
     593                 :            :     // pass 2: export column styles
     594                 :            :     {
     595                 :          0 :         const SwXMLTableColumns_Impl& rCols = pLines->GetColumns();
     596                 :          0 :         sal_uInt32 nCPos = 0U;
     597                 :          0 :         sal_uInt16 nColumns = rCols.size();
     598         [ #  # ]:          0 :         for( sal_uInt16 nColumn=0U; nColumn<nColumns; nColumn++ )
     599                 :            :         {
     600         [ #  # ]:          0 :             SwXMLTableColumn_Impl *pColumn = rCols[nColumn];
     601                 :            : 
     602                 :          0 :             sal_uInt32 nOldCPos = nCPos;
     603                 :          0 :             nCPos = pColumn->GetPos();
     604                 :            : 
     605                 :          0 :             sal_uInt32 nWidth = nCPos - nOldCPos;
     606                 :            : 
     607                 :            :             // If a base width is given, the table has either an automatic
     608                 :            :             // or margin alignment, or an percentage width. In either case,
     609                 :            :             // relative widths should be exported.
     610         [ #  # ]:          0 :             if( nBaseWidth )
     611                 :            :             {
     612                 :          0 :                 pColumn->SetRelWidth( nWidth );
     613                 :            :             }
     614                 :            : 
     615                 :            :             // If an absolute width is given, the table either has a fixed
     616                 :            :             // width, or the current width is known from the layout. In the
     617                 :            :             // later case, a base width is set in addition and must be used
     618                 :            :             // to "absoultize" the relative column width.
     619         [ #  # ]:          0 :             if( nAbsWidth )
     620                 :            :             {
     621                 :          0 :                 sal_uInt32 nColAbsWidth = nWidth;
     622         [ #  # ]:          0 :                 if( nBaseWidth )
     623                 :            :                 {
     624                 :          0 :                     nColAbsWidth *= nAbsWidth;
     625                 :          0 :                     nColAbsWidth += (nBaseWidth/2UL);
     626                 :          0 :                     nColAbsWidth /= nBaseWidth;
     627                 :            :                 }
     628                 :          0 :                 pColumn->SetWidthOpt( nColAbsWidth, sal_False );
     629                 :            :             }
     630                 :            : 
     631         [ #  # ]:          0 :             SwXMLTableColumnsSortByWidth_Impl::const_iterator it = rExpCols.find( pColumn );
     632 [ #  # ][ #  # ]:          0 :             if( it != rExpCols.end() )
     633                 :            :             {
     634                 :          0 :                 pColumn->SetStyleName( (*it)->GetStyleName() );
     635                 :            :             }
     636                 :            :             else
     637                 :            :             {
     638         [ #  # ]:          0 :                 sBuffer.append( rNamePrefix );
     639         [ #  # ]:          0 :                 sBuffer.append( (sal_Unicode)'.' );
     640         [ #  # ]:          0 :                 if( bTop )
     641                 :            :                 {
     642         [ #  # ]:          0 :                     String sTmp;
     643         [ #  # ]:          0 :                     lcl_GetTblBoxColStr( nColumn, sTmp );
     644 [ #  # ][ #  # ]:          0 :                     sBuffer.append( sTmp );
                 [ #  # ]
     645                 :            :                 }
     646                 :            :                 else
     647                 :            :                 {
     648         [ #  # ]:          0 :                     sBuffer.append( (sal_Int32)(nColumn + 1U) );
     649                 :            :                 }
     650                 :            : 
     651         [ #  # ]:          0 :                 pColumn->SetStyleName( sBuffer.makeStringAndClear() );
     652         [ #  # ]:          0 :                 ExportTableColumnStyle( *pColumn );
     653         [ #  # ]:          0 :                 rExpCols.insert( pColumn );
     654                 :            :             }
     655                 :            :         }
     656                 :            :     }
     657                 :            : 
     658                 :            :     // pass 3: export line/rows
     659                 :          0 :     sal_uInt16 nLines = rLines.size();
     660         [ #  # ]:          0 :     for( sal_uInt16 nLine=0U; nLine<nLines; nLine++ )
     661                 :            :     {
     662                 :          0 :         SwTableLine *pLine = rLines[nLine];
     663                 :            : 
     664                 :          0 :         SwFrmFmt *pFrmFmt = pLine->GetFrmFmt();
     665 [ #  # ][ #  # ]:          0 :         if( rExpRows.AddRow( *pFrmFmt, rNamePrefix, nLine ) )
     666         [ #  # ]:          0 :             ExportFmt( *pFrmFmt, XML_TABLE_ROW );
     667                 :            : 
     668                 :          0 :         const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
     669                 :          0 :         sal_uInt16 nBoxes = rBoxes.size();
     670                 :            : 
     671                 :          0 :         sal_uInt32 nCPos = 0U;
     672                 :          0 :         sal_uInt16 nCol = 0U;
     673         [ #  # ]:          0 :         for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
     674                 :            :         {
     675                 :          0 :             SwTableBox *pBox = rBoxes[nBox];
     676                 :            : 
     677         [ #  # ]:          0 :             if( nBox < nBoxes-1U )
     678         [ #  # ]:          0 :                 nCPos = nCPos + SwWriteTable::GetBoxWidth( pBox );
     679                 :            :             else
     680                 :          0 :                 nCPos = pLines->GetWidth();
     681                 :            : 
     682                 :            : 
     683                 :            :             // Und ihren Index
     684                 :          0 :             sal_uInt16 nOldCol = nCol;
     685         [ #  # ]:          0 :             SwXMLTableColumn_Impl aCol( nCPos );
     686         [ #  # ]:          0 :             SwXMLTableColumns_Impl::const_iterator it = pLines->GetColumns().find( &aCol );
     687                 :            :             OSL_ENSURE( it != pLines->GetColumns().end(), "couldn't find column" );
     688         [ #  # ]:          0 :             nCol = it - pLines->GetColumns().begin();
     689                 :            : 
     690                 :          0 :             const SwStartNode *pBoxSttNd = pBox->GetSttNd();
     691         [ #  # ]:          0 :             if( pBoxSttNd )
     692                 :            :             {
     693                 :          0 :                 SwFrmFmt *pFrmFmt2 = pBox->GetFrmFmt();
     694         [ #  # ]:          0 :                 if( rExpCells.AddCell( *pFrmFmt2, rNamePrefix, nOldCol, nLine,
     695         [ #  # ]:          0 :                                        bTop) )
     696         [ #  # ]:          0 :                     ExportFmt( *pFrmFmt2, XML_TABLE_CELL );
     697                 :            : 
     698                 :            :                 Reference < XCell > xCell = SwXCell::CreateXCell(
     699                 :          0 :                                                 (SwFrmFmt *)rTblInfo.GetTblFmt(),
     700                 :            :                                                   pBox,
     701 [ #  # ][ #  # ]:          0 :                                                  (SwTable *)rTblInfo.GetTable() );
                 [ #  # ]
     702         [ #  # ]:          0 :                 if (xCell.is())
     703                 :            :                 {
     704         [ #  # ]:          0 :                     Reference < XText > xText( xCell, UNO_QUERY );
     705         [ #  # ]:          0 :                     if( !rTblInfo.IsBaseSectionValid() )
     706                 :            :                     {
     707                 :            :                         Reference<XPropertySet> xCellPropertySet( xCell,
     708         [ #  # ]:          0 :                                                                  UNO_QUERY );
     709         [ #  # ]:          0 :                         OUString sTextSection( RTL_CONSTASCII_USTRINGPARAM("TextSection") );
     710 [ #  # ][ #  # ]:          0 :                         Any aAny = xCellPropertySet->getPropertyValue(sTextSection);
     711                 :          0 :                         Reference < XTextSection > xTextSection;
     712         [ #  # ]:          0 :                         aAny >>= xTextSection;
     713         [ #  # ]:          0 :                         rTblInfo.SetBaseSection( xTextSection );
     714                 :            :                     }
     715                 :            : 
     716                 :          0 :                     const bool bExportContent = (getExportFlags() & EXPORT_CONTENT ) != 0;
     717         [ #  # ]:          0 :                     if ( !bExportContent )
     718                 :            :                     {
     719                 :            :                         // AUTOSTYLES - not needed anymore if we are currently exporting content.xml
     720                 :            :                         GetTextParagraphExport()->collectTextAutoStyles(
     721 [ #  # ][ #  # ]:          0 :                             xText, rTblInfo.GetBaseSection(), IsShowProgress() );
         [ #  # ][ #  # ]
     722                 :          0 :                     }
     723                 :            :                 }
     724                 :            :                 else {
     725                 :            :                     OSL_FAIL("here should be a XCell");
     726                 :          0 :                 }
     727                 :            :             }
     728                 :            :             else
     729                 :            :             {
     730                 :            :                 lcl_xmltble_appendBoxPrefix( sBuffer, rNamePrefix, nOldCol,
     731         [ #  # ]:          0 :                                              nLine, bTop );
     732                 :            : 
     733                 :          0 :                 ExportTableLinesAutoStyles( pBox->GetTabLines(),
     734                 :            :                                             nAbsWidth, nBaseWidth,
     735                 :            :                                             sBuffer.makeStringAndClear(),
     736                 :            :                                             rExpCols, rExpRows, rExpCells,
     737   [ #  #  #  # ]:          0 :                                              rTblInfo );
     738                 :            :             }
     739                 :            : 
     740                 :          0 :             nCol++;
     741                 :          0 :         }
     742                 :          0 :     }
     743                 :          0 : }
     744                 :            : 
     745                 :          0 : void SwXMLExport::ExportTableAutoStyles( const SwTableNode& rTblNd )
     746                 :            : {
     747                 :          0 :     const SwTable& rTbl = rTblNd.GetTable();
     748                 :          0 :     const SwFrmFmt *pTblFmt = rTbl.GetFrmFmt();
     749                 :            : 
     750         [ #  # ]:          0 :     if( pTblFmt )
     751                 :            :     {
     752         [ #  # ]:          0 :         sal_Int16 eTabHoriOri = pTblFmt->GetHoriOrient().GetHoriOrient();
     753         [ #  # ]:          0 :         const SwFmtFrmSize& rFrmSize = pTblFmt->GetFrmSize();
     754                 :            : 
     755                 :          0 :         sal_uInt32 nAbsWidth = rFrmSize.GetSize().Width();
     756                 :          0 :         sal_uInt32 nBaseWidth = 0UL;
     757                 :          0 :         sal_Int8 nPrcWidth = rFrmSize.GetWidthPercent();
     758                 :            : 
     759                 :            :         sal_Bool bFixAbsWidth = nPrcWidth != 0 || /*text::*/HoriOrientation::NONE == eTabHoriOri
     760 [ #  # ][ #  # ]:          0 :                                            || /*text::*/HoriOrientation::FULL == eTabHoriOri;
                 [ #  # ]
     761         [ #  # ]:          0 :         if( bFixAbsWidth )
     762                 :            :         {
     763                 :          0 :             nBaseWidth = nAbsWidth;
     764         [ #  # ]:          0 :             nAbsWidth = pTblFmt->FindLayoutRect(sal_True).Width();
     765                 :            :             if( !nAbsWidth )
     766                 :            :             {
     767                 :            :                 // TODO???
     768                 :            :             }
     769                 :            :         }
     770         [ #  # ]:          0 :         ExportTableFmt( *pTblFmt, nAbsWidth );
     771                 :            : 
     772         [ #  # ]:          0 :         OUString sName( pTblFmt->GetName() );
     773         [ #  # ]:          0 :         SwXMLTableColumnsSortByWidth_Impl aExpCols;
     774         [ #  # ]:          0 :         SwXMLTableFrmFmtsSort_Impl aExpRows( 10, 10 );
     775         [ #  # ]:          0 :         SwXMLTableFrmFmtsSort_Impl aExpCells( 10, 10 );
     776         [ #  # ]:          0 :         SwXMLTableInfo_Impl aTblInfo( &rTbl );
     777                 :          0 :         ExportTableLinesAutoStyles( rTbl.GetTabLines(), nAbsWidth, nBaseWidth,
     778                 :            :                                     sName, aExpCols, aExpRows, aExpCells,
     779 [ #  # ][ #  # ]:          0 :                                     aTblInfo, sal_True);
     780                 :            :     }
     781                 :          0 : }
     782                 :            : 
     783                 :            : // ---------------------------------------------------------------------
     784                 :            : 
     785                 :          0 : void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
     786                 :            :                                   sal_uInt16 nColSpan,
     787                 :            :                                   sal_uInt16 nRowSpan,
     788                 :            :                                   SwXMLTableInfo_Impl& rTblInfo )
     789                 :            : {
     790                 :          0 :     const SwStartNode *pBoxSttNd = rBox.GetSttNd();
     791         [ #  # ]:          0 :     if( pBoxSttNd )
     792                 :            :     {
     793                 :          0 :         const SwFrmFmt *pFrmFmt = rBox.GetFrmFmt();
     794         [ #  # ]:          0 :         if( pFrmFmt )
     795                 :            :         {
     796                 :          0 :             const String& rName = pFrmFmt->GetName();
     797         [ #  # ]:          0 :             if( rName.Len() )
     798                 :            :             {
     799 [ #  # ][ #  # ]:          0 :                 AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME, EncodeStyleName(rName) );
     800                 :            :             }
     801                 :            :         }
     802                 :            :     }
     803                 :            : 
     804         [ #  # ]:          0 :     if( nRowSpan != 1 )
     805                 :            :     {
     806                 :          0 :         OUStringBuffer sTmp;
     807         [ #  # ]:          0 :         sTmp.append( (sal_Int32)nRowSpan );
     808                 :            :         AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED,
     809 [ #  # ][ #  # ]:          0 :                       sTmp.makeStringAndClear() );
     810                 :            :     }
     811                 :            : 
     812         [ #  # ]:          0 :     if( nColSpan != 1 )
     813                 :            :     {
     814                 :          0 :         OUStringBuffer sTmp;
     815         [ #  # ]:          0 :         sTmp.append( (sal_Int32)nColSpan );
     816                 :            :         AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED,
     817 [ #  # ][ #  # ]:          0 :                       sTmp.makeStringAndClear() );
     818                 :            :     }
     819                 :            : 
     820                 :            :     {
     821         [ #  # ]:          0 :         if( pBoxSttNd )
     822                 :            :         {
     823                 :            :             // start node -> normal cell
     824                 :            : 
     825                 :            :             // get cell range for table
     826                 :          0 :             Reference<XCell> xCell = SwXCell::CreateXCell( (SwFrmFmt *)rTblInfo.GetTblFmt(),
     827                 :            :                                                             (SwTableBox *)&rBox,
     828 [ #  # ][ #  # ]:          0 :                                                             (SwTable *)rTblInfo.GetTable() );
                 [ #  # ]
     829                 :            : 
     830         [ #  # ]:          0 :             if (xCell.is())
     831                 :            :             {
     832         [ #  # ]:          0 :                 Reference<XText> xText( xCell, UNO_QUERY );
     833                 :            : 
     834                 :            :                 // get formula (and protection)
     835 [ #  # ][ #  # ]:          0 :                 OUString sCellFormula = xCell->getFormula();
     836                 :            : 
     837                 :            :                 // if this cell has a formula, export it
     838                 :            :                 //     (with value and number format)
     839         [ #  # ]:          0 :                 if (!sCellFormula.isEmpty())
     840                 :            :                 {
     841                 :            :                     OUString sQValue =
     842                 :          0 :                         GetNamespaceMap().GetQNameByKey(
     843         [ #  # ]:          0 :                                 XML_NAMESPACE_OOOW, sCellFormula, sal_False );
     844                 :            :                     // formula
     845         [ #  # ]:          0 :                     AddAttribute(XML_NAMESPACE_TABLE, XML_FORMULA, sQValue );
     846                 :            :                 }
     847                 :            : 
     848                 :            :                 // value and format (if NumberFormat != -1)
     849                 :            :                 Reference<XPropertySet> xCellPropertySet(xCell,
     850         [ #  # ]:          0 :                                                         UNO_QUERY);
     851         [ #  # ]:          0 :                 if (xCellPropertySet.is())
     852                 :            :                 {
     853                 :          0 :                     sal_Int32 nNumberFormat = 0;
     854 [ #  # ][ #  # ]:          0 :                     Any aAny = xCellPropertySet->getPropertyValue(sNumberFormat);
     855                 :          0 :                     aAny >>= nNumberFormat;
     856                 :            : 
     857         [ #  # ]:          0 :                     if (NUMBERFORMAT_TEXT == nNumberFormat)
     858                 :            :                     {
     859                 :            :                         // text format
     860                 :            :                         AddAttribute( XML_NAMESPACE_OFFICE,
     861         [ #  # ]:          0 :                                     XML_VALUE_TYPE, XML_STRING );
     862                 :            :                     }
     863 [ #  # ][ #  # ]:          0 :                     else if ( (-1 != nNumberFormat) && !xText->getString().isEmpty() )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     864                 :            :                     {
     865                 :            :                         // number format key:
     866                 :            :                         // (export values only if cell contains text;)
     867                 :            :                         XMLNumberFormatAttributesExportHelper::
     868                 :            :                             SetNumberFormatAttributes(
     869 [ #  # ][ #  # ]:          0 :                                 *this, nNumberFormat, xCell->getValue(),
     870         [ #  # ]:          0 :                                  sal_True );
     871                 :            :                     }
     872                 :            :                     // else: invalid key; ignore
     873                 :            : 
     874                 :            :                     // cell protection
     875 [ #  # ][ #  # ]:          0 :                     aAny = xCellPropertySet->getPropertyValue(sIsProtected);
     876         [ #  # ]:          0 :                     if (*(sal_Bool*)aAny.getValue())
     877                 :            :                     {
     878                 :            :                         AddAttribute( XML_NAMESPACE_TABLE, XML_PROTECTED,
     879         [ #  # ]:          0 :                                         XML_TRUE );
     880                 :            :                     }
     881                 :            : 
     882         [ #  # ]:          0 :                     if( !rTblInfo.IsBaseSectionValid() )
     883                 :            :                     {
     884         [ #  # ]:          0 :                         OUString sTextSection( RTL_CONSTASCII_USTRINGPARAM("TextSection") );
     885 [ #  # ][ #  # ]:          0 :                         aAny = xCellPropertySet->getPropertyValue(sTextSection);
     886                 :          0 :                         Reference < XTextSection > xTextSection;
     887         [ #  # ]:          0 :                         aAny >>= xTextSection;
     888         [ #  # ]:          0 :                         rTblInfo.SetBaseSection( xTextSection );
     889                 :          0 :                     }
     890                 :            :                 }
     891                 :            : 
     892                 :            :                 // export cell element
     893                 :            :                 SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
     894         [ #  # ]:          0 :                                         XML_TABLE_CELL, sal_True, sal_True );
     895                 :            : 
     896                 :            :                 // export cell content
     897                 :            :                 GetTextParagraphExport()->exportText( xText,
     898                 :          0 :                                                     rTblInfo.GetBaseSection(),
     899 [ #  # ][ #  # ]:          0 :                                                     IsShowProgress() );
         [ #  # ][ #  # ]
                 [ #  # ]
     900                 :            :             }
     901                 :            :             else
     902                 :            :             {
     903                 :            :                 OSL_FAIL("here should be a XCell");
     904         [ #  # ]:          0 :                 ClearAttrList();
     905                 :          0 :             }
     906                 :            :         }
     907                 :            :         else
     908                 :            :         {
     909                 :            :             // no start node -> merged cells: export subtable in cell
     910                 :            :             SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
     911         [ #  # ]:          0 :                                       XML_TABLE_CELL, sal_True, sal_True );
     912                 :            :             {
     913                 :            :                 AddAttribute( XML_NAMESPACE_TABLE, XML_IS_SUB_TABLE,
     914 [ #  # ][ #  # ]:          0 :                                 GetXMLToken( XML_TRUE ) );
     915                 :            : 
     916                 :            :                 SvXMLElementExport aElemExport( *this, XML_NAMESPACE_TABLE,
     917         [ #  # ]:          0 :                                           XML_TABLE, sal_True, sal_True );
     918 [ #  # ][ #  # ]:          0 :                 ExportTableLines( rBox.GetTabLines(), rTblInfo );
     919         [ #  # ]:          0 :             }
     920                 :            :         }
     921                 :            :     }
     922                 :          0 : }
     923                 :            : 
     924                 :          0 : void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
     925                 :            :                                    const SwXMLTableLines_Impl& rLines,
     926                 :            :                                    SwXMLTableInfo_Impl& rTblInfo )
     927                 :            : {
     928         [ #  # ]:          0 :     if( rLine.hasSoftPageBreak() )
     929                 :            :     {
     930                 :            :         SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT,
     931 [ #  # ][ #  # ]:          0 :                                   XML_SOFT_PAGE_BREAK, sal_True, sal_True );
     932                 :            :     }
     933                 :          0 :     const SwFrmFmt *pFrmFmt = rLine.GetFrmFmt();
     934         [ #  # ]:          0 :     if( pFrmFmt )
     935                 :            :     {
     936                 :          0 :         const String& rName = pFrmFmt->GetName();
     937         [ #  # ]:          0 :         if( rName.Len() )
     938                 :            :         {
     939 [ #  # ][ #  # ]:          0 :             AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME, EncodeStyleName(rName) );
     940                 :            :         }
     941                 :            :     }
     942                 :            : 
     943                 :            :     {
     944                 :            :         SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
     945         [ #  # ]:          0 :                                   XML_TABLE_ROW, sal_True, sal_True );
     946                 :          0 :         const SwTableBoxes& rBoxes = rLine.GetTabBoxes();
     947                 :          0 :         sal_uInt16 nBoxes = rBoxes.size();
     948                 :            : 
     949                 :          0 :         sal_uInt32 nCPos = 0U;
     950                 :          0 :         sal_uInt16 nCol = 0U;
     951         [ #  # ]:          0 :         for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
     952                 :            :         {
     953                 :          0 :             const SwTableBox *pBox = rBoxes[nBox];
     954                 :            : 
     955                 :            :             // NEW TABLES
     956         [ #  # ]:          0 :             const long nRowSpan = pBox->getRowSpan();
     957         [ #  # ]:          0 :             if( nRowSpan < 1 )
     958                 :            :             {
     959                 :            :                 SvXMLElementExport aElem2( *this, XML_NAMESPACE_TABLE,
     960                 :            :                                           XML_COVERED_TABLE_CELL, sal_True,
     961 [ #  # ][ #  # ]:          0 :                                           sal_False );
     962                 :            :             }
     963                 :            : 
     964         [ #  # ]:          0 :             if( nBox < nBoxes-1U )
     965         [ #  # ]:          0 :                 nCPos = nCPos + SwWriteTable::GetBoxWidth( pBox );
     966                 :            :             else
     967                 :          0 :                 nCPos = rLines.GetWidth();
     968                 :            : 
     969                 :            :             // Und ihren Index
     970                 :          0 :             const sal_uInt16 nOldCol = nCol;
     971         [ #  # ]:          0 :             SwXMLTableColumn_Impl aCol( nCPos );
     972         [ #  # ]:          0 :             SwXMLTableColumns_Impl::const_iterator it = rLines.GetColumns().find( &aCol );
     973                 :            :             OSL_ENSURE( it != rLines.GetColumns().end(), "couldn't find column" );
     974         [ #  # ]:          0 :             nCol = it - rLines.GetColumns().begin();
     975                 :            : 
     976                 :            :             // #i95726# - Some fault tolerance, if table is somehow corrupted.
     977         [ #  # ]:          0 :             if ( nCol < nOldCol )
     978                 :            :             {
     979                 :            :                 OSL_FAIL( "table and/or table information seems to be corrupted." );
     980         [ #  # ]:          0 :                 if ( nBox == nBoxes - 1 )
     981                 :            :                 {
     982                 :          0 :                     nCol = rLines.GetColumns().size() - 1;
     983                 :            :                 }
     984                 :            :                 else
     985                 :            :                 {
     986                 :          0 :                     nCol = nOldCol;
     987                 :            :                 }
     988                 :            :             }
     989                 :            : 
     990                 :          0 :             sal_uInt16 nColSpan = nCol - nOldCol + 1U;
     991                 :            : 
     992         [ #  # ]:          0 :             if ( nRowSpan >= 1 )
     993         [ #  # ]:          0 :                 ExportTableBox( *pBox, nColSpan, static_cast< sal_uInt16 >(nRowSpan), rTblInfo );
     994                 :            : 
     995         [ #  # ]:          0 :             for( sal_uInt16 i=nOldCol; i<nCol; i++ )
     996                 :            :             {
     997                 :            :                 SvXMLElementExport aElemExport( *this, XML_NAMESPACE_TABLE,
     998                 :            :                                           XML_COVERED_TABLE_CELL, sal_True,
     999         [ #  # ]:          0 :                                           sal_False );
    1000         [ #  # ]:          0 :             }
    1001                 :            : 
    1002                 :          0 :             nCol++;
    1003         [ #  # ]:          0 :         }
    1004                 :            :     }
    1005                 :          0 : }
    1006                 :            : 
    1007                 :          0 : void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
    1008                 :            :                                     SwXMLTableInfo_Impl& rTblInfo,
    1009                 :            :                                     sal_uInt16 nHeaderRows )
    1010                 :            : {
    1011                 :            :     OSL_ENSURE( pTableLines && !pTableLines->empty(),
    1012                 :            :             "SwXMLExport::ExportTableLines: table columns infos missing" );
    1013 [ #  # ][ #  # ]:          0 :     if( !pTableLines || pTableLines->empty() )
                 [ #  # ]
    1014                 :            :         return;
    1015                 :            : 
    1016                 :          0 :     SwXMLTableLines_Impl* pLines = NULL;
    1017                 :            :     size_t nInfoPos;
    1018         [ #  # ]:          0 :     for( nInfoPos=0; nInfoPos < pTableLines->size(); nInfoPos++ )
    1019                 :            :     {
    1020 [ #  # ][ #  # ]:          0 :         if( pTableLines->at( nInfoPos )->GetLines() == &rLines )
    1021                 :            :         {
    1022         [ #  # ]:          0 :             pLines = pTableLines->at( nInfoPos );
    1023                 :          0 :             break;
    1024                 :            :         }
    1025                 :            :     }
    1026                 :            :     OSL_ENSURE( pLines,
    1027                 :            :             "SwXMLExport::ExportTableLines: table columns info missing" );
    1028                 :            :     OSL_ENSURE( 0==nInfoPos,
    1029                 :            :             "SwXMLExport::ExportTableLines: table columns infos are unsorted" );
    1030         [ #  # ]:          0 :     if( !pLines )
    1031                 :            :         return;
    1032                 :            : 
    1033                 :          0 :     SwXMLTableLinesCache_Impl::iterator it = pTableLines->begin();
    1034         [ #  # ]:          0 :     advance( it, nInfoPos );
    1035         [ #  # ]:          0 :     pTableLines->erase( it );
    1036                 :            : 
    1037         [ #  # ]:          0 :     if( pTableLines->empty() )
    1038                 :            :     {
    1039         [ #  # ]:          0 :         delete pTableLines ;
    1040                 :          0 :         pTableLines = NULL;
    1041                 :            :     }
    1042                 :            : 
    1043                 :            :     // pass 2: export columns
    1044                 :          0 :     const SwXMLTableColumns_Impl& rCols = pLines->GetColumns();
    1045                 :          0 :     sal_uInt16 nColumn = 0U;
    1046                 :          0 :     sal_uInt16 nColumns = rCols.size();
    1047                 :          0 :     sal_uInt16 nColRep = 1U;
    1048 [ #  # ][ #  # ]:          0 :     SwXMLTableColumn_Impl *pColumn = (nColumns > 0) ? rCols[0U] : 0;
    1049         [ #  # ]:          0 :     while( pColumn )
    1050                 :            :     {
    1051                 :          0 :         nColumn++;
    1052                 :            :         SwXMLTableColumn_Impl *pNextColumn =
    1053 [ #  # ][ #  # ]:          0 :             (nColumn < nColumns) ? rCols[nColumn] : 0;
    1054   [ #  #  #  # ]:          0 :         if( pNextColumn &&
                 [ #  # ]
    1055                 :          0 :             pNextColumn->GetStyleName() == pColumn->GetStyleName() )
    1056                 :            :         {
    1057                 :          0 :             nColRep++;
    1058                 :            :         }
    1059                 :            :         else
    1060                 :            :         {
    1061                 :            :             AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME,
    1062 [ #  # ][ #  # ]:          0 :                           EncodeStyleName(pColumn->GetStyleName()) );
    1063                 :            : 
    1064         [ #  # ]:          0 :             if( nColRep > 1U )
    1065                 :            :             {
    1066                 :          0 :                 OUStringBuffer sTmp(4);
    1067         [ #  # ]:          0 :                 sTmp.append( (sal_Int32)nColRep );
    1068                 :            :                 AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED,
    1069 [ #  # ][ #  # ]:          0 :                               sTmp.makeStringAndClear() );
    1070                 :            :             }
    1071                 :            : 
    1072                 :            :             {
    1073                 :            :                 SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
    1074 [ #  # ][ #  # ]:          0 :                                           XML_TABLE_COLUMN, sal_True, sal_True );
    1075                 :            :             }
    1076                 :            : 
    1077                 :          0 :             nColRep = 1U;
    1078                 :            :         }
    1079                 :          0 :         pColumn = pNextColumn;
    1080                 :            :     }
    1081                 :            : 
    1082                 :            :     // pass 3: export line/rows
    1083                 :          0 :     sal_uInt16 nLines = rLines.size();
    1084                 :            :     // export header rows, if present
    1085         [ #  # ]:          0 :     if( nHeaderRows > 0 )
    1086                 :            :     {
    1087                 :            :         SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
    1088         [ #  # ]:          0 :                                   XML_TABLE_HEADER_ROWS, sal_True, sal_True );
    1089                 :            : 
    1090                 :            :         OSL_ENSURE( nHeaderRows <= nLines, "more headers then lines?" );
    1091         [ #  # ]:          0 :         for( sal_uInt16 nLine = 0U; nLine < nHeaderRows; nLine++ )
    1092 [ #  # ][ #  # ]:          0 :             ExportTableLine( *(rLines[nLine]), *pLines, rTblInfo );
    1093                 :            :     }
    1094                 :            :     // export remaining rows
    1095         [ #  # ]:          0 :     for( sal_uInt16 nLine = nHeaderRows; nLine < nLines; nLine++ )
    1096                 :            :     {
    1097         [ #  # ]:          0 :         ExportTableLine( *(rLines[nLine]), *pLines, rTblInfo );
    1098                 :            :     }
    1099                 :            : 
    1100 [ #  # ][ #  # ]:          0 :     delete pLines;
    1101                 :            : }
    1102                 :            : 
    1103                 :            : static void lcl_xmltble_ClearName_Line( SwTableLine* pLine );
    1104                 :            : 
    1105                 :          0 : static void lcl_xmltble_ClearName_Box( SwTableBox* pBox )
    1106                 :            : {
    1107         [ #  # ]:          0 :     if( !pBox->GetSttNd() )
    1108                 :            :     {
    1109 [ #  # ][ #  # ]:          0 :         BOOST_FOREACH( SwTableLine* pLine, pBox->GetTabLines() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1110         [ #  # ]:          0 :             lcl_xmltble_ClearName_Line( pLine );
    1111                 :            :     }
    1112                 :            :     else
    1113                 :            :     {
    1114                 :          0 :         SwFrmFmt *pFrmFmt = pBox->GetFrmFmt();
    1115 [ #  # ][ #  # ]:          0 :         if( pFrmFmt && pFrmFmt->GetName().Len() )
                 [ #  # ]
    1116                 :          0 :             pFrmFmt->SetName( aEmptyStr );
    1117                 :            :     }
    1118                 :          0 : }
    1119                 :            : 
    1120                 :          0 : void lcl_xmltble_ClearName_Line( SwTableLine* pLine )
    1121                 :            : {
    1122 [ #  # ][ #  # ]:          0 :     BOOST_FOREACH( SwTableBox* pBox, pLine->GetTabBoxes() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1123         [ #  # ]:          0 :         lcl_xmltble_ClearName_Box( pBox );
    1124                 :          0 : }
    1125                 :            : 
    1126                 :          0 : void SwXMLExport::ExportTable( const SwTableNode& rTblNd )
    1127                 :            : {
    1128                 :          0 :     const SwTable& rTbl = rTblNd.GetTable();
    1129                 :          0 :     const SwFrmFmt *pTblFmt = rTbl.GetFrmFmt();
    1130 [ #  # ][ #  # ]:          0 :     if( pTblFmt && pTblFmt->GetName().Len() )
                 [ #  # ]
    1131                 :            :     {
    1132         [ #  # ]:          0 :         AddAttribute( XML_NAMESPACE_TABLE, XML_NAME, pTblFmt->GetName() );
    1133                 :            :         AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME,
    1134 [ #  # ][ #  # ]:          0 :                       EncodeStyleName( pTblFmt->GetName() ) );
    1135                 :            :     }
    1136                 :            : 
    1137                 :            :     {
    1138                 :            :         SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_TABLE,
    1139         [ #  # ]:          0 :                                   sal_True, sal_True );
    1140                 :            : 
    1141                 :            :         // export DDE source (if this is a DDE table)
    1142 [ #  # ][ #  # ]:          0 :         if ( rTbl.ISA(SwDDETable) )
                 [ #  # ]
    1143                 :            :         {
    1144                 :            :             // get DDE Field Type (contains the DDE connection)
    1145                 :            :             const SwDDEFieldType* pDDEFldType =
    1146         [ #  # ]:          0 :                 ((SwDDETable&)rTbl).GetDDEFldType();
    1147                 :            : 
    1148                 :            :             // connection name
    1149                 :            :             AddAttribute( XML_NAMESPACE_OFFICE, XML_NAME,
    1150 [ #  # ][ #  # ]:          0 :                           pDDEFldType->GetName() );
    1151                 :            : 
    1152                 :            :             // DDE command
    1153         [ #  # ]:          0 :             const String sCmd = pDDEFldType->GetCmd();
    1154                 :            :             AddAttribute( XML_NAMESPACE_OFFICE, XML_DDE_APPLICATION,
    1155 [ #  # ][ #  # ]:          0 :                           sCmd.GetToken(0, sfx2::cTokenSeperator) );
         [ #  # ][ #  # ]
    1156                 :            :             AddAttribute( XML_NAMESPACE_OFFICE, XML_DDE_ITEM,
    1157 [ #  # ][ #  # ]:          0 :                           sCmd.GetToken(1, sfx2::cTokenSeperator) );
         [ #  # ][ #  # ]
    1158                 :            :             AddAttribute( XML_NAMESPACE_OFFICE, XML_DDE_TOPIC,
    1159 [ #  # ][ #  # ]:          0 :                           sCmd.GetToken(2, sfx2::cTokenSeperator) );
         [ #  # ][ #  # ]
    1160                 :            : 
    1161                 :            :             // auto update
    1162 [ #  # ][ #  # ]:          0 :             if (pDDEFldType->GetType() == sfx2::LINKUPDATE_ALWAYS)
    1163                 :            :             {
    1164                 :            :                 AddAttribute( XML_NAMESPACE_OFFICE,
    1165         [ #  # ]:          0 :                               XML_AUTOMATIC_UPDATE, XML_TRUE );
    1166                 :            :             }
    1167                 :            : 
    1168                 :            :             // DDE source element (always empty)
    1169                 :            :             SvXMLElementExport aSource(*this, XML_NAMESPACE_OFFICE,
    1170 [ #  # ][ #  # ]:          0 :                                        XML_DDE_SOURCE, sal_True, sal_False);
                 [ #  # ]
    1171                 :            :         }
    1172                 :            : 
    1173         [ #  # ]:          0 :         SwXMLTableInfo_Impl aTblInfo( &rTbl );
    1174 [ #  # ][ #  # ]:          0 :         ExportTableLines( rTbl.GetTabLines(), aTblInfo, rTbl.GetRowsToRepeat() );
    1175                 :            : 
    1176 [ #  # ][ #  # ]:          0 :         BOOST_FOREACH( SwTableLine *pLine, ((SwTable &)rTbl).GetTabLines() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1177 [ #  # ][ #  # ]:          0 :             lcl_xmltble_ClearName_Line( pLine );
                 [ #  # ]
    1178                 :            :     }
    1179                 :          0 : }
    1180                 :            : 
    1181                 :          0 : void SwXMLTextParagraphExport::exportTable(
    1182                 :            :         const Reference < XTextContent > & rTextContent,
    1183                 :            :         sal_Bool bAutoStyles, sal_Bool _bProgress )
    1184                 :            : {
    1185                 :          0 :     sal_Bool bOldShowProgress = ((SwXMLExport&)GetExport()).IsShowProgress();
    1186                 :          0 :     ((SwXMLExport&)GetExport()).SetShowProgress( _bProgress );
    1187                 :            : 
    1188         [ #  # ]:          0 :     Reference < XTextTable > xTxtTbl( rTextContent, UNO_QUERY );
    1189                 :            :     OSL_ENSURE( xTxtTbl.is(), "text table missing" );
    1190         [ #  # ]:          0 :     if( xTxtTbl.is() )
    1191                 :            :     {
    1192                 :          0 :         const SwXTextTable *pXTable = 0;
    1193         [ #  # ]:          0 :         Reference<XUnoTunnel> xTableTunnel( rTextContent, UNO_QUERY);
    1194         [ #  # ]:          0 :         if( xTableTunnel.is() )
    1195                 :            :         {
    1196                 :            :             pXTable = reinterpret_cast< SwXTextTable * >(
    1197 [ #  # ][ #  # ]:          0 :                     sal::static_int_cast< sal_IntPtr >( xTableTunnel->getSomething( SwXTextTable::getUnoTunnelId() )));
                 [ #  # ]
    1198                 :            :             OSL_ENSURE( pXTable, "SwXTextTable missing" );
    1199                 :            :         }
    1200         [ #  # ]:          0 :         if( pXTable )
    1201                 :            :         {
    1202                 :          0 :             SwFrmFmt *pFmt = pXTable->GetFrmFmt();
    1203                 :            :             OSL_ENSURE( pFmt, "table format missing" );
    1204         [ #  # ]:          0 :             const SwTable *pTbl = SwTable::FindTable( pFmt );
    1205                 :            :             OSL_ENSURE( pTbl, "table missing" );
    1206         [ #  # ]:          0 :             const SwTableNode *pTblNd = pTbl->GetTableNode();
    1207                 :            :             OSL_ENSURE( pTblNd, "table node missing" );
    1208         [ #  # ]:          0 :             if( bAutoStyles )
    1209                 :            :             {
    1210         [ #  # ]:          0 :                 SwNodeIndex aIdx( *pTblNd );
    1211                 :            :                 // AUTOSTYLES: Optimization: Do not export table autostyle if
    1212                 :            :                 // we are currently exporting the content.xml stuff and
    1213                 :            :                 // the table is located in header/footer:
    1214                 :            :                 // During the flat XML export (used e.g. by .sdw-export)
    1215                 :            :                 // ALL flags are set at the same time.
    1216                 :          0 :                 const bool bExportStyles = ( GetExport().getExportFlags() & EXPORT_STYLES ) != 0;
    1217 [ #  # ][ #  # ]:          0 :                 if ( bExportStyles || !pFmt->GetDoc()->IsInHeaderFooter( aIdx ) )
         [ #  # ][ #  # ]
    1218 [ #  # ][ #  # ]:          0 :                     ((SwXMLExport&)GetExport()).ExportTableAutoStyles( *pTblNd );
    1219                 :            :             }
    1220                 :            :             else
    1221                 :            :             {
    1222         [ #  # ]:          0 :                 ((SwXMLExport&)GetExport()).ExportTable( *pTblNd );
    1223                 :            :             }
    1224                 :          0 :         }
    1225                 :            :     }
    1226                 :            : 
    1227                 :          0 :     ((SwXMLExport&)GetExport()).SetShowProgress( bOldShowProgress );
    1228                 :          0 : }
    1229                 :            : 
    1230                 :         92 : void SwXMLExport::DeleteTableLines()
    1231                 :            : {
    1232         [ -  + ]:         92 :     if ( pTableLines )
    1233                 :            :     {
    1234         [ #  # ]:          0 :         for ( size_t i = 0, n = pTableLines->size(); i < n; ++i )
    1235         [ #  # ]:          0 :             delete pTableLines->at( i );
    1236                 :          0 :         pTableLines->clear();
    1237         [ #  # ]:          0 :         delete pTableLines;
    1238                 :            :     }
    1239                 :         92 : }
    1240                 :            : 
    1241                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10