LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unotbl.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1916 2776 69.0 %
Date: 2014-04-11 Functions: 189 263 71.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : // STL includes
      21             : #include <list>
      22             : #include <vector>
      23             : 
      24             : #include <svx/svxids.hrc>
      25             : #include <editeng/memberids.hrc>
      26             : #include <float.h>
      27             : #include <swtypes.hxx>
      28             : #include <cmdid.h>
      29             : #include <unotbl.hxx>
      30             : #include <unostyle.hxx>
      31             : #include <section.hxx>
      32             : #include <unocrsr.hxx>
      33             : #include <svx/unomid.hxx>
      34             : #include <hints.hxx>
      35             : #include <swtblfmt.hxx>
      36             : #include <doc.hxx>
      37             : #include <IDocumentUndoRedo.hxx>
      38             : #include <shellres.hxx>
      39             : #include <docary.hxx>
      40             : #include <ndole.hxx>
      41             : #include <frame.hxx>
      42             : #include <vcl/svapp.hxx>
      43             : #include <fmtfsize.hxx>
      44             : #include <tblafmt.hxx>
      45             : #include <tabcol.hxx>
      46             : #include <cellatr.hxx>
      47             : #include <fmtpdsc.hxx>
      48             : #include <pagedesc.hxx>
      49             : #include <viewsh.hxx>
      50             : #include <tabfrm.hxx>
      51             : #include <redline.hxx>
      52             : #include <unoport.hxx>
      53             : #include <unoprnms.hxx>
      54             : #include <unocrsrhelper.hxx>
      55             : #include <com/sun/star/text/WrapTextMode.hpp>
      56             : #include <com/sun/star/text/TextContentAnchorType.hpp>
      57             : #include <com/sun/star/text/TableColumnSeparator.hpp>
      58             : #include <com/sun/star/text/XTextSection.hpp>
      59             : #include <com/sun/star/table/ShadowFormat.hpp>
      60             : #include <com/sun/star/table/TableBorder.hpp>
      61             : #include <com/sun/star/table/TableBorder2.hpp>
      62             : #include <com/sun/star/table/BorderLine2.hpp>
      63             : #include <com/sun/star/table/BorderLineStyle.hpp>
      64             : #include <com/sun/star/table/TableBorderDistances.hpp>
      65             : #include <com/sun/star/style/PageStyleLayout.hpp>
      66             : #include <com/sun/star/style/BreakType.hpp>
      67             : #include <com/sun/star/style/GraphicLocation.hpp>
      68             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      69             : #include <com/sun/star/chart/XChartDataChangeEventListener.hpp>
      70             : #include <com/sun/star/chart/ChartDataChangeEvent.hpp>
      71             : #include <com/sun/star/chart2/data/XDataSequence.hpp>
      72             : #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
      73             : #include <com/sun/star/table/CellContentType.hpp>
      74             : #include <unotextrange.hxx>
      75             : #include <unotextcursor.hxx>
      76             : #include <unoparagraph.hxx>
      77             : #include <svl/zforlist.hxx>
      78             : #include <editeng/formatbreakitem.hxx>
      79             : #include <editeng/shaditem.hxx>
      80             : #include <editeng/lrspitem.hxx>
      81             : #include <editeng/ulspitem.hxx>
      82             : #include <fmtornt.hxx>
      83             : #include <editeng/keepitem.hxx>
      84             : #include <fmtlsplt.hxx>
      85             : #include <swundo.hxx>
      86             : #include <osl/mutex.hxx>
      87             : #include <SwStyleNameMapper.hxx>
      88             : #include <frmatr.hxx>
      89             : #include <crsskip.hxx>
      90             : #include <unochart.hxx>
      91             : #include <sortopt.hxx>
      92             : #include <rtl/math.hxx>
      93             : #include <editeng/frmdiritem.hxx>
      94             : #include <switerator.hxx>
      95             : #include <comphelper/servicehelper.hxx>
      96             : #include <comphelper/string.hxx>
      97             : #include <cppuhelper/supportsservice.hxx>
      98             : #include <comphelper/sequenceashashmap.hxx>
      99             : 
     100             : using namespace ::com::sun::star;
     101             : using ::editeng::SvxBorderLine;
     102             : 
     103             : // from swtable.cxx
     104             : extern void sw_GetTblBoxColStr( sal_uInt16 nCol, OUString& rNm );
     105             : 
     106             : #define UNO_TABLE_COLUMN_SUM    10000
     107             : 
     108           2 : static void lcl_SendChartEvent(::cppu::OWeakObject & rSource,
     109             :                                ::cppu::OInterfaceContainerHelper & rListeners)
     110             : {
     111             :     //TODO: find appropriate settings of the Event
     112           2 :     chart::ChartDataChangeEvent event;
     113           2 :     event.Source = & rSource;
     114           2 :     event.Type = chart::ChartDataChangeType_ALL;
     115           2 :     event.StartColumn = 0;
     116           2 :     event.EndColumn = 1;
     117           2 :     event.StartRow = 0;
     118           2 :     event.EndRow = 1;
     119             :     rListeners.notifyEach(
     120           2 :             & chart::XChartDataChangeEventListener::chartDataChanged, event);
     121           2 : }
     122             : 
     123        2307 : static void lcl_SendChartEvent(::cppu::OWeakObject & rSource,
     124             :                                ::cppu::OMultiTypeInterfaceContainerHelper & rListeners)
     125             : {
     126             :     ::cppu::OInterfaceContainerHelper *const pContainer(rListeners.getContainer(
     127        2307 :             cppu::UnoType<chart::XChartDataChangeEventListener>::get()));
     128        2307 :     if (pContainer)
     129             :     {
     130           2 :         lcl_SendChartEvent(rSource, *pContainer);
     131             :     }
     132        2307 : }
     133             : 
     134        2316 : static bool lcl_LineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine)
     135             : {
     136        2316 :     rSvxLine.SetColor(Color(rLine.Color));
     137             : 
     138             :     rSvxLine.GuessLinesWidths( table::BorderLineStyle::NONE,
     139        4632 :                                 MM100_TO_TWIP( rLine.OuterLineWidth ),
     140        4632 :                                 MM100_TO_TWIP( rLine.InnerLineWidth ),
     141       11580 :                                 MM100_TO_TWIP( rLine.LineDistance ) );
     142             : 
     143        2316 :     bool bRet = rLine.InnerLineWidth > 0 || rLine.OuterLineWidth > 0;
     144        2316 :     return bRet;
     145             : }
     146             : 
     147         920 : static void lcl_SetSpecialProperty(SwFrmFmt* pFmt,
     148             :                                    const SfxItemPropertySimpleEntry* pEntry,
     149             :                                    const uno::Any& aValue)
     150             :     throw (lang::IllegalArgumentException,
     151             :            uno::RuntimeException)
     152             : {
     153             :     // special treatment for "non-items"
     154         920 :     switch(pEntry->nWID)
     155             :     {
     156             :         case  FN_TABLE_HEADLINE_REPEAT:
     157             :         case  FN_TABLE_HEADLINE_COUNT:
     158             :         {
     159         384 :             SwTable* pTable = SwTable::FindTable( pFmt );
     160             :             {
     161         384 :                 UnoActionContext aAction(pFmt->GetDoc());
     162         384 :                 if( pEntry->nWID == FN_TABLE_HEADLINE_REPEAT)
     163             :                 {
     164           1 :                     sal_Bool bVal = *(sal_Bool*)aValue.getValue();
     165           1 :                     pFmt->GetDoc()->SetRowsToRepeat( *pTable, bVal ? 1 : 0 );
     166             :                 }
     167             :                 else
     168             :                 {
     169         383 :                     sal_Int32 nRepeat = 0;
     170         383 :                     aValue >>= nRepeat;
     171         383 :                     if( nRepeat >= 0 && nRepeat < USHRT_MAX )
     172         383 :                         pFmt->GetDoc()->SetRowsToRepeat( *pTable, (sal_uInt16) nRepeat );
     173         384 :                 }
     174             :             }
     175             :         }
     176         384 :         break;
     177             : 
     178             :         case  FN_TABLE_IS_RELATIVE_WIDTH:
     179             :         case  FN_TABLE_WIDTH:
     180             :         case  FN_TABLE_RELATIVE_WIDTH:
     181             :         {
     182         414 :             SwFmtFrmSize aSz( pFmt->GetFrmSize() );
     183         414 :             if(FN_TABLE_WIDTH == pEntry->nWID)
     184             :             {
     185         357 :                 sal_Int32 nWidth = 0;
     186         357 :                 aValue >>= nWidth;
     187         357 :                 aSz.SetWidthPercent(0);
     188         357 :                 aSz.SetWidth ( MM100_TO_TWIP ( nWidth ) );
     189             :             }
     190          57 :             else if(FN_TABLE_RELATIVE_WIDTH == pEntry->nWID)
     191             :             {
     192          30 :                 sal_Int16 nSet = 0;
     193          30 :                 aValue >>= nSet;
     194          30 :                 if(nSet && nSet <=100)
     195          30 :                     aSz.SetWidthPercent( (sal_uInt8)nSet );
     196             :             }
     197          27 :             else if(FN_TABLE_IS_RELATIVE_WIDTH == pEntry->nWID)
     198             :             {
     199          27 :                 sal_Bool bPercent = *(sal_Bool*)aValue.getValue();
     200          27 :                 if(!bPercent)
     201           1 :                     aSz.SetWidthPercent(0);
     202             :                 else
     203             :                 {
     204          26 :                     lang::IllegalArgumentException aExcept;
     205          26 :                     aExcept.Message = "relative width cannot be switched on with this property";
     206          26 :                     throw aExcept;
     207             :                 }
     208             :             }
     209         414 :             pFmt->GetDoc()->SetAttr(aSz, *pFmt);
     210             :         }
     211         388 :         break;
     212             : 
     213             :         case RES_PAGEDESC:
     214             :         {
     215         122 :             OUString sPageStyle;
     216         122 :             aValue >>= sPageStyle;
     217         122 :             const SwPageDesc* pDesc = 0;
     218         122 :             if (!sPageStyle.isEmpty())
     219             :             {
     220         122 :                 SwStyleNameMapper::FillUIName(sPageStyle, sPageStyle, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true );
     221         122 :                 pDesc = SwPageDesc::GetByName(*pFmt->GetDoc(), sPageStyle);
     222             :             }
     223         244 :             SwFmtPageDesc aDesc( pDesc );
     224         244 :             pFmt->GetDoc()->SetAttr(aDesc, *pFmt);
     225             :         }
     226         122 :         break;
     227             : 
     228             :         default:
     229           0 :             throw lang::IllegalArgumentException();
     230             :     }
     231         894 : }
     232             : 
     233         178 : static uno::Any lcl_GetSpecialProperty(SwFrmFmt* pFmt, const SfxItemPropertySimpleEntry* pEntry )
     234             : {
     235         178 :     uno::Any aRet;
     236         178 :     switch(pEntry->nWID)
     237             :     {
     238             :         case  FN_TABLE_HEADLINE_REPEAT:
     239             :         case  FN_TABLE_HEADLINE_COUNT:
     240             :         {
     241           2 :             SwTable* pTable = SwTable::FindTable( pFmt );
     242           2 :             sal_uInt16 nRepeat = pTable->GetRowsToRepeat();
     243           2 :             if(pEntry->nWID == FN_TABLE_HEADLINE_REPEAT)
     244             :             {
     245           2 :                 sal_Bool bTemp = nRepeat > 0;
     246           2 :                 aRet.setValue(&bTemp, ::getCppuBooleanType());
     247             :             }
     248             :             else
     249           0 :                 aRet <<= (sal_Int32)nRepeat;
     250             :         }
     251           2 :         break;
     252             : 
     253             :         case  FN_TABLE_WIDTH:
     254             :         case  FN_TABLE_IS_RELATIVE_WIDTH:
     255             :         case  FN_TABLE_RELATIVE_WIDTH:
     256             :         {
     257         172 :             const SwFmtFrmSize& rSz = pFmt->GetFrmSize();
     258         172 :             if(FN_TABLE_WIDTH == pEntry->nWID)
     259          39 :                 rSz.QueryValue(aRet, MID_FRMSIZE_WIDTH|CONVERT_TWIPS);
     260         133 :             else if(FN_TABLE_RELATIVE_WIDTH == pEntry->nWID)
     261           5 :                 rSz.QueryValue(aRet, MID_FRMSIZE_REL_WIDTH);
     262             :             else
     263             :             {
     264         128 :                 sal_Bool bTemp = 0 != rSz.GetWidthPercent();
     265         128 :                 aRet.setValue(&bTemp, ::getBooleanCppuType());
     266             :             }
     267             :         }
     268         172 :         break;
     269             : 
     270             :         case RES_PAGEDESC:
     271             :         {
     272           2 :             const SfxItemSet& rSet = pFmt->GetAttrSet();
     273             :             const SfxPoolItem* pItem;
     274           2 :             OUString sPDesc;
     275           2 :             if(SFX_ITEM_SET == rSet.GetItemState(RES_PAGEDESC, false, &pItem))
     276             :             {
     277           1 :                 const SwPageDesc* pDsc = ((const SwFmtPageDesc*)pItem)->GetPageDesc();
     278           1 :                 if(pDsc)
     279             :                 {
     280           1 :                    sPDesc = SwStyleNameMapper::GetProgName(pDsc->GetName(), nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
     281             :                 }
     282             :             }
     283           2 :             aRet <<= OUString(sPDesc);
     284             :         }
     285           2 :         break;
     286             : 
     287             :         case RES_ANCHOR :
     288           0 :             aRet <<= text::TextContentAnchorType_AT_PARAGRAPH;
     289           0 :         break;
     290             : 
     291             :         case FN_UNO_ANCHOR_TYPES :
     292             :         {
     293           2 :             uno::Sequence<text::TextContentAnchorType> aTypes(1);
     294           2 :              text::TextContentAnchorType* pArray = aTypes.getArray();
     295           2 :             pArray[0] = text::TextContentAnchorType_AT_PARAGRAPH;
     296           2 :             aRet <<= aTypes;
     297             :         }
     298           2 :         break;
     299             : 
     300             :         case FN_UNO_WRAP :
     301             :         {
     302           0 :             aRet <<= text::WrapTextMode_NONE;
     303             :         }
     304           0 :         break;
     305             : 
     306             :         case FN_PARAM_LINK_DISPLAY_NAME :
     307           0 :             aRet <<= pFmt->GetName();
     308           0 :         break;
     309             : 
     310             :         case FN_UNO_REDLINE_NODE_START:
     311             :         case FN_UNO_REDLINE_NODE_END:
     312             :         {
     313           0 :             SwTable* pTable = SwTable::FindTable( pFmt );
     314           0 :             SwNode* pTblNode = pTable->GetTableNode();
     315           0 :             if(FN_UNO_REDLINE_NODE_END == pEntry->nWID)
     316           0 :                 pTblNode = pTblNode->EndOfSectionNode();
     317           0 :             const SwRedlineTbl& rRedTbl = pFmt->GetDoc()->GetRedlineTbl();
     318           0 :             for(sal_uInt16 nRed = 0; nRed < rRedTbl.size(); nRed++)
     319             :             {
     320           0 :                 const SwRangeRedline* pRedline = rRedTbl[nRed];
     321           0 :                 const SwNode* pRedPointNode = pRedline->GetNode(true);
     322           0 :                 const SwNode* pRedMarkNode = pRedline->GetNode(false);
     323           0 :                 if(pRedPointNode == pTblNode || pRedMarkNode == pTblNode)
     324             :                 {
     325           0 :                     const SwNode* pStartOfRedline = SwNodeIndex(*pRedPointNode) <= SwNodeIndex(*pRedMarkNode) ?
     326           0 :                         pRedPointNode : pRedMarkNode;
     327           0 :                     sal_Bool bIsStart = pStartOfRedline == pTblNode;
     328           0 :                     aRet <<= SwXRedlinePortion::CreateRedlineProperties(*pRedline, bIsStart);
     329           0 :                     break;
     330             :                 }
     331             :             }
     332             :         }
     333           0 :         break;
     334             :     }
     335         178 :     return aRet;
     336             : }
     337             : 
     338             : /** get position of a cell with a given name
     339             :  *
     340             :  * If everything was OK, the indices for column and row are changed (both >= 0).
     341             :  * In case of errors, at least one of them is < 0.
     342             :  *
     343             :  * Also since the implementations of tables does not really have columns using
     344             :  * this function is appropriate only for tables that are not complex (i.e.
     345             :  * where IsTblComplex() returns false).
     346             :  *
     347             :  * @param rCellName e.g. A1..Z1, a1..z1, AA1..AZ1, Aa1..Az1, BA1..BZ1, Ba1..Bz1, ...
     348             :  * @param [IN,OUT] rColumn (0-based)
     349             :  * @param [IN,OUT] rRow (0-based)
     350             :  */
     351             : //TODO: potential for throwing proper exceptions instead of having every caller to check for errors
     352           4 : void sw_GetCellPosition(const OUString &rCellName,
     353             :                         sal_Int32 &rColumn, sal_Int32 &rRow)
     354             : {
     355           4 :     rColumn = rRow = -1;    // default return values indicating failure
     356           4 :     sal_Int32 nLen = rCellName.getLength();
     357           4 :     if (nLen)
     358             :     {
     359           4 :         const sal_Unicode *pBuf = rCellName.getStr();
     360           4 :         const sal_Unicode *pEnd = pBuf + nLen;
     361          12 :         while (pBuf < pEnd && !('0' <= *pBuf && *pBuf <= '9'))
     362           4 :             ++pBuf;
     363             :         // start of number found?
     364           4 :         if (pBuf < pEnd && ('0' <= *pBuf && *pBuf <= '9'))
     365             :         {
     366           4 :             OUString aColTxt(rCellName.getStr(), pBuf - rCellName.getStr());
     367           8 :             OUString aRowTxt(pBuf, (rCellName.getStr() + nLen - pBuf));
     368           4 :             if (!aColTxt.isEmpty() && !aRowTxt.isEmpty())
     369             :             {
     370           4 :                 sal_Int32 nColIdx = 0;
     371           4 :                 sal_Int32 nLength = aColTxt.getLength();
     372           8 :                 for (sal_Int32 i = 0;  i < nLength;  ++i)
     373             :                 {
     374           4 :                     nColIdx = 52 * nColIdx;
     375           4 :                     if (i < nLength - 1)
     376           0 :                         ++nColIdx;
     377           4 :                     sal_Unicode cChar = aColTxt[i];
     378           4 :                     if ('A' <= cChar && cChar <= 'Z')
     379           4 :                         nColIdx = nColIdx + (cChar - 'A');
     380           0 :                     else if ('a' <= cChar && cChar <= 'z')
     381           0 :                         nColIdx = nColIdx + (26 + cChar - 'a');
     382             :                     else
     383             :                     {
     384           0 :                         nColIdx = -1;   // sth failed
     385           0 :                         break;
     386             :                     }
     387             :                 }
     388             : 
     389           4 :                 rColumn = nColIdx;
     390           4 :                 rRow    = aRowTxt.toInt32() - 1;    // - 1 because indices ought to be 0 based
     391           4 :             }
     392             :         }
     393             :     }
     394             :     OSL_ENSURE( rColumn != -1 && rRow != -1, "failed to get column or row index" );
     395           4 : }
     396             : 
     397             : /** compare position of two cells (check rows first)
     398             :  *
     399             :  * @note this function probably also make sense only
     400             :  *       for cell names of non-complex tables
     401             :  *
     402             :  * @param rCellName1 e.g. "A1" (non-empty string with valid cell name)
     403             :  * @param rCellName2 e.g. "A1" (non-empty string with valid cell name)
     404             :  * @return -1 if cell_1 < cell_2; 0 if both cells are equal; +1 if cell_1 > cell_2
     405             :  */
     406           0 : int sw_CompareCellsByRowFirst( const OUString &rCellName1, const OUString &rCellName2 )
     407             : {
     408           0 :     sal_Int32 nCol1 = -1, nRow1 = -1, nCol2 = -1, nRow2 = -1;
     409           0 :     sw_GetCellPosition( rCellName1, nCol1, nRow1 );
     410           0 :     sw_GetCellPosition( rCellName2, nCol2, nRow2 );
     411             : 
     412           0 :     if (nRow1 < nRow2 || (nRow1 == nRow2 && nCol1 < nCol2))
     413           0 :         return -1;
     414           0 :     else if (nCol1 == nCol2 && nRow1 == nRow2)
     415           0 :         return 0;
     416             :     else
     417           0 :         return +1;
     418             : }
     419             : 
     420             : /** compare position of two cells (check columns first)
     421             :  *
     422             :  * @note this function probably also make sense only
     423             :  *       for cell names of non-complex tables
     424             :  *
     425             :  * @param rCellName1 e.g. "A1" (non-empty string with valid cell name)
     426             :  * @param rCellName2 e.g. "A1" (non-empty string with valid cell name)
     427             :  * @return -1 if cell_1 < cell_2; 0 if both cells are equal; +1 if cell_1 > cell_2
     428             :  */
     429           0 : int sw_CompareCellsByColFirst( const OUString &rCellName1, const OUString &rCellName2 )
     430             : {
     431           0 :     sal_Int32 nCol1 = -1, nRow1 = -1, nCol2 = -1, nRow2 = -1;
     432           0 :     sw_GetCellPosition( rCellName1, nCol1, nRow1 );
     433           0 :     sw_GetCellPosition( rCellName2, nCol2, nRow2 );
     434             : 
     435           0 :     if (nCol1 < nCol2 || (nCol1 == nCol2 && nRow1 < nRow2))
     436           0 :         return -1;
     437           0 :     else if (nRow1 == nRow2 && nCol1 == nCol2)
     438           0 :         return 0;
     439             :     else
     440           0 :         return +1;
     441             : }
     442             : 
     443             : /** compare position of two cell ranges
     444             :  *
     445             :  * @note this function probably also make sense only
     446             :  *       for cell names of non-complex tables
     447             :  *
     448             :  * @param rRange1StartCell e.g. "A1" (non-empty string with valid cell name)
     449             :  * @param rRange1EndCell   e.g. "A1" (non-empty string with valid cell name)
     450             :  * @param rRange2StartCell e.g. "A1" (non-empty string with valid cell name)
     451             :  * @param rRange2EndCell   e.g. "A1" (non-empty string with valid cell name)
     452             :  * @param bCmpColsFirst    if <true> position in columns will be compared first before rows
     453             :  *
     454             :  * @return -1 if cell_range_1 < cell_range_2; 0 if both cell ranges are equal; +1 if cell_range_1 > cell_range_2
     455             :  */
     456           0 : int sw_CompareCellRanges(
     457             :         const OUString &rRange1StartCell, const OUString &rRange1EndCell,
     458             :         const OUString &rRange2StartCell, const OUString &rRange2EndCell,
     459             :         sal_Bool bCmpColsFirst )
     460             : {
     461             :     int (*pCompareCells)( const OUString &, const OUString & ) =
     462           0 :             bCmpColsFirst ? &sw_CompareCellsByColFirst : &sw_CompareCellsByRowFirst;
     463             : 
     464           0 :     int nCmpResStartCells = pCompareCells( rRange1StartCell, rRange2StartCell );
     465           0 :     if ((-1 == nCmpResStartCells ) ||
     466           0 :          ( 0 == nCmpResStartCells &&
     467           0 :           -1 == pCompareCells( rRange1EndCell, rRange2EndCell ) ))
     468           0 :         return -1;
     469           0 :     else if (0 == nCmpResStartCells &&
     470           0 :              0 == pCompareCells( rRange1EndCell, rRange2EndCell ))
     471           0 :         return 0;
     472             :     else
     473           0 :         return +1;
     474             : }
     475             : 
     476             : /** get cell name at a specified coordinate
     477             :  *
     478             :  * @param nColumn column index (0-based)
     479             :  * @param nRow row index (0-based)
     480             :  * @return the cell name
     481             :  */
     482        9611 : OUString sw_GetCellName( sal_Int32 nColumn, sal_Int32 nRow )
     483             : {
     484             : #if OSL_DEBUG_LEVEL > 0
     485             :     {
     486             :         sal_Int32 nCol, nRow2;
     487             :         sw_GetCellPosition( OUString("z1"), nCol, nRow2);
     488             :         OSL_ENSURE( nCol == 51, "sw_GetCellPosition failed" );
     489             :         sw_GetCellPosition( OUString("AA1"), nCol, nRow2);
     490             :         OSL_ENSURE( nCol == 52, "sw_GetCellPosition failed" );
     491             :         sw_GetCellPosition( OUString("AB1"), nCol, nRow2);
     492             :         OSL_ENSURE( nCol == 53, "sw_GetCellPosition failed" );
     493             :         sw_GetCellPosition( OUString("BB1"), nCol, nRow2);
     494             :         OSL_ENSURE( nCol == 105, "sw_GetCellPosition failed" );
     495             :     }
     496             : #endif
     497             : 
     498        9611 :     OUString sCellName;
     499        9611 :     if (nColumn < 0 || nRow < 0)
     500           0 :         return sCellName;
     501        9611 :     sw_GetTblBoxColStr( static_cast< sal_uInt16 >(nColumn), sCellName );
     502        9611 :     sCellName += OUString::number( nRow + 1 );
     503        9611 :     return sCellName;
     504             : }
     505             : 
     506             : /** Find the top left or bottom right corner box in given table.
     507             :   Consider nested lines when finding the box.
     508             : 
     509             :   @param rTableLines the table
     510             :   @param i_bTopLeft if true, find top left box, otherwise find bottom
     511             :          right box
     512             :  */
     513          38 : const SwTableBox* lcl_FindCornerTableBox(const SwTableLines& rTableLines, const bool i_bTopLeft)
     514             : {
     515          38 :     bool bFirst = true;
     516          38 :     const SwTableBox* pBox = 0;
     517          38 :     do
     518             :     {
     519          38 :         const SwTableLines& rLines(bFirst ? rTableLines : pBox->GetTabLines());
     520          38 :         bFirst = false;
     521             :         OSL_ASSERT(rLines.size() != 0);
     522          38 :         if (!rLines.empty())
     523             :         {
     524          38 :             const SwTableLine* pLine(i_bTopLeft ? rLines.front() : rLines.back());
     525             :             OSL_ASSERT(pLine);
     526          38 :             const SwTableBoxes& rBoxes(pLine->GetTabBoxes());
     527             :             OSL_ASSERT(rBoxes.size() != 0);
     528          38 :             pBox = i_bTopLeft ? rBoxes.front() : rBoxes.back();
     529             :             OSL_ASSERT(pBox);
     530             :         }
     531             :         else
     532             :         {
     533           0 :             pBox = 0;
     534             :         }
     535          38 :     } while (pBox && !pBox->GetSttNd());
     536          38 :     return pBox;
     537             : }
     538             : 
     539             : /** cleanup order in a range
     540             :  *
     541             :  * Sorts the input to a uniform format. I.e. for the four possible representation
     542             :  *      A1:C5, C5:A1, A5:C1, C1:A5
     543             :  * the result will be always A1:C5.
     544             :  *
     545             :  * @param [IN,OUT] rCell1 cell name (will be modified to upper-left corner), e.g. "A1" (non-empty string with valid cell name)
     546             :  * @param [IN,OUT] rCell2 cell name (will be modified to lower-right corner), e.g. "A1" (non-empty string with valid cell name)
     547             :  */
     548           0 : void sw_NormalizeRange(OUString &rCell1, OUString &rCell2)
     549             : {
     550           0 :     sal_Int32 nCol1 = -1, nRow1 = -1, nCol2 = -1, nRow2 = -1;
     551           0 :     sw_GetCellPosition( rCell1, nCol1, nRow1 );
     552           0 :     sw_GetCellPosition( rCell2, nCol2, nRow2 );
     553           0 :     if (nCol2 < nCol1 || nRow2 < nRow1)
     554             :     {
     555           0 :         rCell1  = sw_GetCellName( std::min(nCol1, nCol2), std::min(nRow1, nRow2) );
     556           0 :         rCell2  = sw_GetCellName( std::max(nCol1, nCol2), std::max(nRow1, nRow2) );
     557             :     }
     558           0 : }
     559             : 
     560          11 : void SwRangeDescriptor::Normalize()
     561             : {
     562          11 :     if (nTop > nBottom)
     563             :     {
     564           0 :         sal_Int32 nTmp = nTop;
     565           0 :         nTop = nBottom;
     566           0 :         nBottom = nTmp;
     567             :     }
     568          11 :     if (nLeft > nRight)
     569             :     {
     570           0 :         sal_Int32 nTmp = nLeft;
     571           0 :         nLeft = nRight;
     572           0 :         nRight = nTmp;
     573             :     }
     574          11 : }
     575             : 
     576        9596 : static SwXCell* lcl_CreateXCell(SwFrmFmt* pFmt, sal_Int32 nColumn, sal_Int32 nRow)
     577             : {
     578        9596 :     SwXCell* pXCell = 0;
     579        9596 :     OUString sCellName = sw_GetCellName(nColumn, nRow);
     580        9596 :     SwTable* pTable = SwTable::FindTable( pFmt );
     581        9596 :     SwTableBox* pBox = (SwTableBox*)pTable->GetTblBox( sCellName );
     582        9596 :     if(pBox)
     583             :     {
     584        9595 :         pXCell = SwXCell::CreateXCell(pFmt, pBox, pTable);
     585             :     }
     586        9596 :     return pXCell;
     587             : }
     588             : 
     589          30 : static void lcl_InspectLines(SwTableLines& rLines, std::vector<OUString*>& rAllNames)
     590             : {
     591          96 :     for( sal_uInt16 i = 0; i < rLines.size(); i++ )
     592             :     {
     593          66 :         SwTableLine* pLine = rLines[i];
     594          66 :         SwTableBoxes& rBoxes = pLine->GetTabBoxes();
     595         409 :         for(sal_uInt16 j = 0; j < rBoxes.size(); j++)
     596             :         {
     597         343 :             SwTableBox* pBox = rBoxes[j];
     598         343 :             if(!pBox->GetName().isEmpty() && pBox->getRowSpan() > 0 )
     599         343 :                 rAllNames.push_back( new OUString(pBox->GetName()) );
     600         343 :             SwTableLines& rBoxLines = pBox->GetTabLines();
     601         343 :             if(!rBoxLines.empty())
     602             :             {
     603           0 :                 lcl_InspectLines(rBoxLines, rAllNames);
     604             :             }
     605             :         }
     606             :     }
     607          30 : }
     608             : 
     609         379 : static void lcl_FormatTable(SwFrmFmt* pTblFmt)
     610             : {
     611         379 :     SwIterator<SwFrm,SwFmt> aIter( *pTblFmt );
     612         732 :     for( SwFrm* pFrm = aIter.First(); pFrm; pFrm = aIter.Next() )
     613             :     {
     614             :         // mba: no TYPEINFO for SwTabFrm
     615         353 :         if( pFrm->IsTabFrm() )
     616             :         {
     617         353 :             if(pFrm->IsValid())
     618         302 :                 pFrm->InvalidatePos();
     619         353 :             ((SwTabFrm*)pFrm)->SetONECalcLowers();
     620         353 :             ((SwTabFrm*)pFrm)->Calc();
     621             :         }
     622         379 :     }
     623         379 : }
     624             : 
     625          21 : static void lcl_CrsrSelect(SwPaM* pCrsr, sal_Bool bExpand)
     626             : {
     627          21 :     if(bExpand)
     628             :     {
     629           5 :         if(!pCrsr->HasMark())
     630           5 :             pCrsr->SetMark();
     631             :     }
     632          16 :     else if(pCrsr->HasMark())
     633           2 :         pCrsr->DeleteMark();
     634             : 
     635          21 : }
     636             : 
     637          18 : static void lcl_GetTblSeparators(uno::Any& rRet, SwTable* pTable, SwTableBox* pBox, sal_Bool bRow)
     638             : {
     639          18 :     SwTabCols aCols;
     640          18 :     aCols.SetLeftMin ( 0 );
     641          18 :     aCols.SetLeft    ( 0 );
     642          18 :     aCols.SetRight   ( UNO_TABLE_COLUMN_SUM );
     643          18 :     aCols.SetRightMax( UNO_TABLE_COLUMN_SUM );
     644             : 
     645          18 :     pTable->GetTabCols( aCols, pBox, sal_False, bRow );
     646             : 
     647          18 :     const size_t nSepCount = aCols.Count();
     648          36 :     uno::Sequence< text::TableColumnSeparator> aColSeq(nSepCount);
     649          18 :     text::TableColumnSeparator* pArray = aColSeq.getArray();
     650          18 :     bool bError = false;
     651          77 :     for(size_t i = 0; i < nSepCount; ++i)
     652             :     {
     653          59 :         pArray[i].Position = static_cast< sal_Int16 >(aCols[i]);
     654          59 :         pArray[i].IsVisible = !aCols.IsHidden(i);
     655          59 :         if(!bRow && !pArray[i].IsVisible)
     656             :         {
     657           0 :             bError = true;
     658           0 :             break;
     659             :         }
     660             :     }
     661          18 :     if(!bError)
     662          36 :         rRet.setValue(&aColSeq, ::getCppuType((uno::Sequence< text::TableColumnSeparator>*)0));
     663             : 
     664          18 : }
     665             : 
     666        2177 : static void lcl_SetTblSeparators(const uno::Any& rVal, SwTable* pTable, SwTableBox* pBox, sal_Bool bRow, SwDoc* pDoc)
     667             : {
     668        2177 :     SwTabCols aOldCols;
     669             : 
     670        2177 :     aOldCols.SetLeftMin ( 0 );
     671        2177 :     aOldCols.SetLeft    ( 0 );
     672        2177 :     aOldCols.SetRight   ( UNO_TABLE_COLUMN_SUM );
     673        2177 :     aOldCols.SetRightMax( UNO_TABLE_COLUMN_SUM );
     674             : 
     675        2177 :     pTable->GetTabCols( aOldCols, pBox, sal_False, bRow );
     676        2177 :     const size_t nOldCount = aOldCols.Count();
     677             :     // there is no use in setting tab cols if there is only one column
     678        2177 :     if( !nOldCount )
     679        2489 :         return;
     680             : 
     681             :     const uno::Sequence< text::TableColumnSeparator>* pSepSeq =
     682        1865 :                 (uno::Sequence< text::TableColumnSeparator>*) rVal.getValue();
     683        1865 :     if(pSepSeq && static_cast<size_t>(pSepSeq->getLength()) == nOldCount)
     684             :     {
     685        1865 :         SwTabCols aCols(aOldCols);
     686        1865 :         sal_Bool bError = sal_False;
     687        1865 :         const text::TableColumnSeparator* pArray = pSepSeq->getConstArray();
     688        1865 :         long nLastValue = 0;
     689             :         //sal_Int32 nTblWidth = aCols.GetRight() - aCols.GetLeft();
     690        6375 :         for(size_t i = 0; i < nOldCount; ++i)
     691             :         {
     692        4512 :             aCols[i] = pArray[i].Position;
     693       13534 :             if(pArray[i].IsVisible == aCols.IsHidden(i) ||
     694        4510 :                 (!bRow && aCols.IsHidden(i)) ||
     695       13532 :                 aCols[i] < nLastValue ||
     696        4510 :                 UNO_TABLE_COLUMN_SUM < aCols[i] )
     697             :             {
     698           2 :                 bError = sal_True;
     699           2 :                 break;
     700             :             }
     701        4510 :             nLastValue = aCols[i];
     702             :         }
     703        1865 :         if(!bError)
     704             :         {
     705        1863 :             pDoc->SetTabCols(*pTable, aCols, aOldCols, pBox, bRow );
     706        1865 :         }
     707        1865 :     }
     708             : }
     709             : 
     710          32 : static inline OUString lcl_getString( SwXCell &rCell )
     711             : {
     712             :     // getString is a member function of the base class...
     713          32 :     return rCell.getString();
     714             : }
     715             : 
     716             : /* non UNO function call to set string in SwXCell */
     717         119 : void sw_setString( SwXCell &rCell, const OUString &rTxt,
     718             :         sal_Bool bKeepNumberFmt = sal_False )
     719             : {
     720         119 :     if(rCell.IsValid())
     721             :     {
     722         119 :         SwFrmFmt* pBoxFmt = rCell.pBox->ClaimFrmFmt();
     723         119 :         pBoxFmt->LockModify();
     724         119 :         pBoxFmt->ResetFmtAttr( RES_BOXATR_FORMULA );
     725         119 :         pBoxFmt->ResetFmtAttr( RES_BOXATR_VALUE );
     726         119 :         if (!bKeepNumberFmt)
     727          47 :             pBoxFmt->SetFmtAttr( SwTblBoxNumFormat(NUMBERFORMAT_TEXT) );
     728         119 :         pBoxFmt->UnlockModify();
     729             :     }
     730         119 :     rCell.SwXText::setString(rTxt);
     731         119 : }
     732             : 
     733             : /* non UNO function call to get value from SwXCell */
     734          96 : double sw_getValue( SwXCell &rCell )
     735             : {
     736             :     double fRet;
     737          96 :     if(rCell.IsValid() && !rCell.getString().isEmpty())
     738          66 :         fRet = rCell.pBox->GetFrmFmt()->GetTblBoxValue().GetValue();
     739             :     else
     740          30 :         ::rtl::math::setNan( &fRet );
     741          96 :     return fRet;
     742             : }
     743             : 
     744             : /* non UNO function call to set value in SwXCell */
     745          72 : void sw_setValue( SwXCell &rCell, double nVal )
     746             : {
     747          72 :     if(rCell.IsValid())
     748             :     {
     749             :         // first this text (maybe) needs to be deleted
     750          72 :         sal_uLong nNdPos = rCell.pBox->IsValidNumTxtNd( sal_True );
     751          72 :         if(ULONG_MAX != nNdPos)
     752          72 :             sw_setString( rCell, OUString(), sal_True );   // sal_True == keep number format
     753          72 :         SwDoc* pDoc = rCell.GetDoc();
     754          72 :         UnoActionContext aAction(pDoc);
     755          72 :         SwFrmFmt* pBoxFmt = rCell.pBox->ClaimFrmFmt();
     756         144 :         SfxItemSet aSet(pDoc->GetAttrPool(), RES_BOXATR_FORMAT, RES_BOXATR_VALUE);
     757             :         const SfxPoolItem* pItem;
     758             : 
     759             :         //!! do we need to set a new number format? Yes, if
     760             :         // - there is no current number format
     761             :         // - the current number format is not a number format according to the number formatter, but rather a text format
     762             :         // - the current number format is not even a valid number formatter number format, but rather Writer's own 'special' text number format
     763         144 :         if(SFX_ITEM_SET != pBoxFmt->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, true, &pItem)
     764          30 :             ||  pDoc->GetNumberFormatter()->IsTextFormat(((SwTblBoxNumFormat*)pItem)->GetValue())
     765         102 :             ||  ((SwTblBoxNumFormat*)pItem)->GetValue() == NUMBERFORMAT_TEXT)
     766             :         {
     767          67 :             aSet.Put(SwTblBoxNumFormat(0));
     768             :         }
     769             : 
     770         144 :         SwTblBoxValue aVal(nVal);
     771          72 :         aSet.Put(aVal);
     772          72 :         pDoc->SetTblBoxFormulaAttrs( *rCell.pBox, aSet );
     773             :         // update table
     774         144 :         SwTableFmlUpdate aTblUpdate( SwTable::FindTable( rCell.GetFrmFmt() ));
     775         144 :         pDoc->UpdateTblFlds( &aTblUpdate );
     776             :     }
     777          72 : }
     778             : 
     779       45967 : TYPEINIT1(SwXCell, SwClient);
     780             : 
     781        9873 : SwXCell::SwXCell(SwFrmFmt* pTblFmt, SwTableBox* pBx, size_t const nPos) :
     782             :     SwXText(pTblFmt->GetDoc(), CURSOR_TBLTEXT),
     783             :     SwClient(pTblFmt),
     784        9873 :     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_CELL)),
     785             :     pBox(pBx),
     786             :     pStartNode(0),
     787       19746 :     nFndPos(nPos)
     788             : {
     789        9873 : }
     790             : 
     791           0 : SwXCell::SwXCell(SwFrmFmt* pTblFmt, const SwStartNode& rStartNode) :
     792             :     SwXText(pTblFmt->GetDoc(), CURSOR_TBLTEXT),
     793             :     SwClient(pTblFmt),
     794           0 :     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_CELL)),
     795             :     pBox(0),
     796             :     pStartNode(&rStartNode),
     797           0 :     nFndPos(NOTFOUND)
     798             : {
     799           0 : }
     800             : 
     801       19746 : SwXCell::~SwXCell()
     802             : {
     803       19746 : }
     804             : 
     805             : namespace
     806             : {
     807             :     class theSwXCellUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXCellUnoTunnelId > {};
     808             : }
     809             : 
     810         340 : const uno::Sequence< sal_Int8 > & SwXCell::getUnoTunnelId()
     811             : {
     812         340 :     return theSwXCellUnoTunnelId::get().getSeq();
     813             : }
     814             : 
     815         340 : sal_Int64 SAL_CALL SwXCell::getSomething( const uno::Sequence< sal_Int8 >& rId )
     816             :     throw(uno::RuntimeException, std::exception)
     817             : {
     818         680 :     if( rId.getLength() == 16
     819        1020 :         && 0 == memcmp( getUnoTunnelId().getConstArray(),
     820         680 :                                         rId.getConstArray(), 16 ) )
     821             :     {
     822           0 :         return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
     823             :     }
     824             :     else
     825         340 :         return SwXText::getSomething(rId);
     826             : }
     827             : 
     828           0 : uno::Sequence< uno::Type > SAL_CALL SwXCell::getTypes(  ) throw(uno::RuntimeException, std::exception)
     829             : {
     830           0 :     static uno::Sequence< uno::Type > aRetTypes;
     831           0 :     if(!aRetTypes.getLength())
     832             :     {
     833           0 :         aRetTypes = SwXCellBaseClass::getTypes();
     834           0 :         uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes();
     835             : 
     836           0 :         long nIndex = aRetTypes.getLength();
     837             :         aRetTypes.realloc(
     838           0 :             aRetTypes.getLength() +
     839           0 :             aTextTypes.getLength());
     840             : 
     841           0 :         uno::Type* pRetTypes = aRetTypes.getArray();
     842             : 
     843           0 :         const uno::Type* pTextTypes = aTextTypes.getConstArray();
     844           0 :         for(long nPos = 0; nPos <aTextTypes.getLength(); nPos++)
     845           0 :             pRetTypes[nIndex++] = pTextTypes[nPos];
     846             :     }
     847           0 :     return aRetTypes;
     848             : }
     849             : 
     850           0 : uno::Sequence< sal_Int8 > SAL_CALL SwXCell::getImplementationId(  ) throw(uno::RuntimeException, std::exception)
     851             : {
     852           0 :     return css::uno::Sequence<sal_Int8>();
     853             : }
     854             : 
     855       93012 : void SAL_CALL SwXCell::acquire(  ) throw()
     856             : {
     857       93012 :     SwXCellBaseClass::acquire();
     858       93012 : }
     859             : 
     860       93012 : void SAL_CALL SwXCell::release(  ) throw()
     861             : {
     862       93012 :     SwXCellBaseClass::release();
     863       93012 : }
     864             : 
     865       18244 : uno::Any SAL_CALL SwXCell::queryInterface( const uno::Type& aType )
     866             :     throw (uno::RuntimeException, std::exception)
     867             : {
     868       18244 :     uno::Any aRet = SwXCellBaseClass::queryInterface(aType);
     869       18244 :     if(aRet.getValueType() == ::getCppuVoidType())
     870        8608 :         aRet = SwXText::queryInterface(aType);
     871       18244 :     return aRet;
     872             : }
     873             : 
     874         349 : const SwStartNode *SwXCell::GetStartNode() const
     875             : {
     876         349 :     const SwStartNode *pSttNd = 0;
     877             : 
     878         349 :     if( pStartNode || ((SwXCell *)this)->IsValid() )
     879         349 :         pSttNd = pStartNode ? pStartNode : pBox->GetSttNd();
     880             : 
     881         349 :     return pSttNd;
     882             : }
     883             : 
     884             : uno::Reference< text::XTextCursor >
     885         312 : SwXCell::CreateCursor() throw (uno::RuntimeException)
     886             : {
     887         312 :     return createTextCursor();
     888             : }
     889             : 
     890       78764 : bool SwXCell::IsValid() const
     891             : {
     892             :     // FIXME: this is now a const method, to make SwXText::IsValid invisible
     893             :     // but the const_cast here are still ridiculous. TODO: find a better way.
     894       78764 :     SwFrmFmt* pTblFmt = pBox ? GetFrmFmt() : 0;
     895       78764 :     if(!pTblFmt)
     896             :     {
     897           0 :         const_cast<SwXCell*>(this)->pBox = 0;
     898             :     }
     899             :     else
     900             :     {
     901       78764 :         SwTable* pTable = SwTable::FindTable( pTblFmt );
     902             :         SwTableBox const*const pFoundBox =
     903       78764 :             const_cast<SwXCell*>(this)->FindBox(pTable, pBox);
     904       78764 :         if (!pFoundBox)
     905             :         {
     906           0 :             const_cast<SwXCell*>(this)->pBox = 0;
     907             :         }
     908             :     }
     909       78764 :     return 0 != pBox;
     910             : }
     911             : 
     912           0 : OUString SwXCell::getFormula(void) throw( uno::RuntimeException, std::exception )
     913             : {
     914           0 :     SolarMutexGuard aGuard;
     915           0 :     OUString sRet;
     916           0 :     if(IsValid())
     917             :     {
     918           0 :         SwTblBoxFormula aFormula( pBox->GetFrmFmt()->GetTblBoxFormula() );
     919           0 :         SwTable* pTable = SwTable::FindTable( GetFrmFmt() );
     920           0 :         aFormula.PtrToBoxNm( pTable );
     921           0 :         sRet = aFormula.GetFormula();
     922             :     }
     923           0 :     return sRet;
     924             : }
     925             : 
     926             : ///@see sw_setValue (TODO: seems to be C&P programming here)
     927           0 : void SwXCell::setFormula(const OUString& rFormula) throw( uno::RuntimeException, std::exception )
     928             : {
     929           0 :     SolarMutexGuard aGuard;
     930           0 :     if(IsValid())
     931             :     {
     932             :         // first this text (maybe) needs to be deleted
     933           0 :         sal_uInt32 nNdPos = pBox->IsValidNumTxtNd( sal_True );
     934           0 :         if(USHRT_MAX == nNdPos)
     935           0 :             sw_setString( *this, OUString(), sal_True );
     936           0 :         OUString sFml(comphelper::string::stripStart(rFormula, ' '));
     937           0 :         if( !sFml.isEmpty() && '=' == sFml[0] )
     938           0 :                     sFml = sFml.copy( 1 );
     939           0 :         SwTblBoxFormula aFml( sFml );
     940           0 :         SwDoc* pMyDoc = GetDoc();
     941           0 :         UnoActionContext aAction(pMyDoc);
     942           0 :         SfxItemSet aSet(pMyDoc->GetAttrPool(), RES_BOXATR_FORMAT, RES_BOXATR_FORMULA);
     943             :         const SfxPoolItem* pItem;
     944           0 :         SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
     945           0 :         if(SFX_ITEM_SET != pBoxFmt->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, true, &pItem)
     946           0 :             ||  pMyDoc->GetNumberFormatter()->IsTextFormat(((SwTblBoxNumFormat*)pItem)->GetValue()))
     947             :         {
     948           0 :             aSet.Put(SwTblBoxNumFormat(0));
     949             :         }
     950           0 :         aSet.Put(aFml);
     951           0 :         GetDoc()->SetTblBoxFormulaAttrs( *pBox, aSet );
     952             :         // update table
     953           0 :         SwTableFmlUpdate aTblUpdate( SwTable::FindTable( GetFrmFmt() ));
     954           0 :         pMyDoc->UpdateTblFlds( &aTblUpdate );
     955           0 :     }
     956           0 : }
     957             : 
     958          64 : double SwXCell::getValue(void) throw( uno::RuntimeException, std::exception )
     959             : {
     960          64 :     SolarMutexGuard aGuard;
     961             : 
     962          64 :     double const fRet = sw_getValue( *this );
     963             :     // #i112652# a table cell may contain NaN as a value, do not filter that
     964          64 :     return fRet;
     965             : }
     966             : 
     967          40 : void SwXCell::setValue(double rValue) throw( uno::RuntimeException, std::exception )
     968             : {
     969          40 :     SolarMutexGuard aGuard;
     970          40 :     sw_setValue( *this, rValue );
     971          40 : }
     972             : 
     973           0 : table::CellContentType SwXCell::getType(void) throw( uno::RuntimeException, std::exception )
     974             : {
     975           0 :     SolarMutexGuard aGuard;
     976             : 
     977           0 :     table::CellContentType nRes = table::CellContentType_EMPTY;
     978           0 :     sal_uInt32 nNdPos = pBox->IsFormulaOrValueBox();
     979           0 :     switch (nNdPos)
     980             :     {
     981           0 :         case 0 :                    nRes = table::CellContentType_TEXT; break;
     982           0 :         case USHRT_MAX :            nRes = table::CellContentType_EMPTY; break;
     983           0 :         case RES_BOXATR_VALUE :     nRes = table::CellContentType_VALUE; break;
     984           0 :         case RES_BOXATR_FORMULA :   nRes = table::CellContentType_FORMULA; break;
     985             :         default :
     986             :             OSL_FAIL( "unexpected case" );
     987             :     }
     988           0 :     return  nRes;
     989             : }
     990             : 
     991          15 : void SwXCell::setString(const OUString& aString) throw( uno::RuntimeException, std::exception )
     992             : {
     993          15 :     SolarMutexGuard aGuard;
     994          15 :     sw_setString( *this, aString );
     995          15 : }
     996             : 
     997           0 : sal_Int32 SwXCell::getError(void) throw( uno::RuntimeException, std::exception )
     998             : {
     999           0 :     SolarMutexGuard aGuard;
    1000           0 :     OUString sContent = getString();
    1001           0 :     return sal_Int32(sContent.equals(SwViewShell::GetShellRes()->aCalc_Error));
    1002             : }
    1003             : 
    1004        8520 : uno::Reference< text::XTextCursor >  SwXCell::createTextCursor(void) throw( uno::RuntimeException, std::exception )
    1005             : {
    1006        8520 :     SolarMutexGuard aGuard;
    1007        8520 :     uno::Reference< text::XTextCursor >     aRef;
    1008        8520 :     if(pStartNode || IsValid())
    1009             :     {
    1010        8520 :         const SwStartNode* pSttNd = pStartNode ? pStartNode : pBox->GetSttNd();
    1011        8520 :         SwPosition aPos(*pSttNd);
    1012             :         SwXTextCursor *const pXCursor =
    1013        8520 :             new SwXTextCursor(*GetDoc(), this, CURSOR_TBLTEXT, aPos);
    1014        8520 :         SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor();
    1015        8520 :         pUnoCrsr->Move(fnMoveForward, fnGoNode);
    1016        8520 :         aRef =  static_cast<text::XWordCursor*>(pXCursor);
    1017             :     }
    1018             :     else
    1019           0 :         throw uno::RuntimeException();
    1020        8520 :     return aRef;
    1021             : }
    1022             : 
    1023         671 : uno::Reference< text::XTextCursor >  SwXCell::createTextCursorByRange(const uno::Reference< text::XTextRange > & xTextPosition)
    1024             :                                                         throw( uno::RuntimeException, std::exception )
    1025             : {
    1026         671 :     SolarMutexGuard aGuard;
    1027         671 :     uno::Reference< text::XTextCursor >  aRef;
    1028        1342 :     SwUnoInternalPaM aPam(*GetDoc());
    1029        1342 :     if ((pStartNode || IsValid())
    1030        1342 :         && ::sw::XTextRangeToSwPaM(aPam, xTextPosition))
    1031             :     {
    1032         671 :         const SwStartNode* pSttNd = pStartNode ? pStartNode : pBox->GetSttNd();
    1033             :         // skip sections
    1034         671 :         SwStartNode* p1 = aPam.GetNode()->StartOfSectionNode();
    1035        1342 :         while(p1->IsSectionNode())
    1036           0 :             p1 = p1->StartOfSectionNode();
    1037             : 
    1038         671 :         if( p1 == pSttNd )
    1039             :         {
    1040             :             aRef = static_cast<text::XWordCursor*>(
    1041         671 :                     new SwXTextCursor(*GetDoc(), this, CURSOR_TBLTEXT,
    1042         671 :                         *aPam.GetPoint(), aPam.GetMark()));
    1043             :         }
    1044             :     }
    1045             :     else
    1046           0 :         throw uno::RuntimeException();
    1047        1342 :     return aRef;
    1048             : }
    1049             : 
    1050           2 : uno::Reference< beans::XPropertySetInfo >  SwXCell::getPropertySetInfo(void) throw( uno::RuntimeException, std::exception )
    1051             : {
    1052           2 :     static uno::Reference< beans::XPropertySetInfo >  xRef = m_pPropSet->getPropertySetInfo();
    1053           2 :     return xRef;
    1054             : }
    1055             : 
    1056       65898 : void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
    1057             :     throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1058             : {
    1059       65898 :     SolarMutexGuard aGuard;
    1060       65898 :     if(IsValid())
    1061             :     {
    1062             :         // Hack to support hidden property to transfer textDirection
    1063       65898 :         if  ( rPropertyName == "FRMDirection" )
    1064             :         {
    1065          32 :             SvxFrameDirection eDir = FRMDIR_ENVIRONMENT;
    1066          32 :             sal_Int16 nNum = 0;
    1067          32 :             aValue >>= nNum;
    1068             :             OSL_TRACE("FRMDirection val %d", nNum );
    1069          32 :             switch (nNum)
    1070             :             {
    1071             :                 case 0:
    1072          31 :                     eDir = FRMDIR_HORI_LEFT_TOP;
    1073          31 :                     break;
    1074             :                 case 1:
    1075           0 :                     eDir = FRMDIR_HORI_RIGHT_TOP;
    1076           0 :                     break;
    1077             :                 case 2:
    1078           1 :                     eDir = FRMDIR_VERT_TOP_RIGHT;
    1079           1 :                     break;
    1080             :                 default:
    1081             :                     OSL_FAIL( "unknown direction code, maybe it's a bitfield");
    1082             :             }
    1083          32 :             SvxFrameDirectionItem aItem( eDir, RES_FRAMEDIR);
    1084          32 :             pBox->GetFrmFmt()->SetFmtAttr(aItem);
    1085             :         }
    1086       65866 :         else if  ( rPropertyName == "TableRedlineParams" )
    1087             :         {
    1088             :             // Get the table row properties
    1089           6 :             uno::Sequence< beans::PropertyValue > tableCellProperties;
    1090           6 :             tableCellProperties = aValue.get< uno::Sequence< beans::PropertyValue > >();
    1091          12 :             comphelper::SequenceAsHashMap aPropMap( tableCellProperties );
    1092          12 :             OUString sRedlineType;
    1093          12 :             uno::Any sRedlineTypeValue;
    1094           6 :             sRedlineTypeValue = aPropMap.getUnpackedValueOrDefault("RedlineType", sRedlineTypeValue);
    1095           6 :             if( sRedlineTypeValue >>= sRedlineType )
    1096             :             {
    1097             :                 // Create a 'Table Cell Redline' object
    1098           6 :                 SwUnoCursorHelper::makeTableCellRedline( *pBox, sRedlineType, tableCellProperties);
    1099             :             }
    1100             :             else
    1101             :             {
    1102           0 :                 throw beans::UnknownPropertyException(OUString( "No redline type property: " ), static_cast < cppu::OWeakObject * > ( this ) );
    1103           6 :             }
    1104             :         }
    1105             :         else
    1106             :         {
    1107             :             const SfxItemPropertySimpleEntry* pEntry =
    1108       65860 :                 m_pPropSet->getPropertyMap().getByName(rPropertyName);
    1109       65860 :             if( !pEntry )
    1110             :             {
    1111        8163 :                 beans::UnknownPropertyException aEx;
    1112        8163 :                 aEx.Message = rPropertyName;
    1113        8163 :                 throw( aEx );
    1114             :             }
    1115       57697 :             if( pEntry->nWID == FN_UNO_CELL_ROW_SPAN )
    1116             :             {
    1117         125 :                 sal_Int32 nRowSpan = 0;
    1118         125 :                 if( aValue >>= nRowSpan )
    1119         125 :                     pBox->setRowSpan( nRowSpan );
    1120             :             }
    1121             :             else
    1122             :             {
    1123       57572 :                 SwFrmFmt* pBoxFmt = pBox->ClaimFrmFmt();
    1124       57572 :                 SwAttrSet aSet(pBoxFmt->GetAttrSet());
    1125       57572 :                 m_pPropSet->setPropertyValue(rPropertyName, aValue, aSet);
    1126       57572 :                 pBoxFmt->GetDoc()->SetAttr(aSet, *pBoxFmt);
    1127             :             }
    1128             :         }
    1129       65898 :     }
    1130       57735 : }
    1131             : 
    1132         415 : uno::Any SwXCell::getPropertyValue(const OUString& rPropertyName)
    1133             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1134             : {
    1135         415 :     SolarMutexGuard aGuard;
    1136         415 :     uno::Any aRet;
    1137         415 :     if(IsValid())
    1138             :     {
    1139             :         const SfxItemPropertySimpleEntry* pEntry =
    1140         415 :                                     m_pPropSet->getPropertyMap().getByName(rPropertyName);
    1141         415 :         if( !pEntry )
    1142             :         {
    1143           0 :             beans::UnknownPropertyException aEx;
    1144           0 :             aEx.Message = rPropertyName;
    1145           0 :             throw( aEx );
    1146             :         }
    1147         415 :         switch( pEntry->nWID )
    1148             :         {
    1149             :             case FN_UNO_CELL_ROW_SPAN:
    1150           0 :                 aRet <<= pBox->getRowSpan();
    1151           0 :             break;
    1152             :             case FN_UNO_TEXT_SECTION:
    1153             :             {
    1154           0 :                 SwFrmFmt* pTblFmt = GetFrmFmt();
    1155           0 :                 SwTable* pTable = SwTable::FindTable( pTblFmt );
    1156           0 :                 SwTableNode* pTblNode = pTable->GetTableNode();
    1157           0 :                 SwSectionNode* pSectionNode =  pTblNode->FindSectionNode();
    1158           0 :                 if(pSectionNode)
    1159             :                 {
    1160           0 :                     const SwSection& rSect = pSectionNode->GetSection();
    1161             :                     uno::Reference< text::XTextSection >  xSect =
    1162           0 :                                     SwXTextSections::GetObject( *rSect.GetFmt() );
    1163           0 :                     aRet <<= xSect;
    1164             :                 }
    1165             :             }
    1166           0 :             break;
    1167             :             case FN_UNO_CELL_NAME:
    1168           4 :                 aRet <<= OUString ( pBox->GetName() );
    1169           4 :             break;
    1170             :             case FN_UNO_REDLINE_NODE_START:
    1171             :             case FN_UNO_REDLINE_NODE_END:
    1172             :             {
    1173             :                 //redline can only be returned if it's a living object
    1174           2 :                 aRet = SwXText::getPropertyValue(rPropertyName);
    1175             :             }
    1176           2 :             break;
    1177             :             default:
    1178             :             {
    1179         409 :                 const SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
    1180         409 :                 const SwAttrSet& rSet = pBoxFmt->GetAttrSet();
    1181         409 :                 m_pPropSet->getPropertyValue(rPropertyName, rSet, aRet);
    1182             :             }
    1183             :         }
    1184             :     }
    1185         415 :     return aRet;
    1186             : }
    1187             : 
    1188           0 : void SwXCell::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1189             : {
    1190             :     OSL_FAIL("not implemented");
    1191           0 : }
    1192             : 
    1193           0 : void SwXCell::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1194             : {
    1195             :     OSL_FAIL("not implemented");
    1196           0 : }
    1197             : 
    1198           0 : void SwXCell::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1199             : {
    1200             :     OSL_FAIL("not implemented");
    1201           0 : }
    1202             : 
    1203           0 : void SwXCell::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1204             : {
    1205             :     OSL_FAIL("not implemented");
    1206           0 : }
    1207             : 
    1208        2624 : uno::Reference< container::XEnumeration >  SwXCell::createEnumeration(void) throw( uno::RuntimeException, std::exception )
    1209             : {
    1210        2624 :     SolarMutexGuard aGuard;
    1211        2624 :     uno::Reference< container::XEnumeration >  aRef;
    1212        2624 :     if(IsValid())
    1213             :     {
    1214        2624 :         const SwStartNode* pSttNd = pBox->GetSttNd();
    1215        2624 :         SwPosition aPos(*pSttNd);
    1216             :         ::std::auto_ptr<SwUnoCrsr> pUnoCursor(
    1217        5248 :             GetDoc()->CreateUnoCrsr(aPos, false));
    1218        2624 :         pUnoCursor->Move(fnMoveForward, fnGoNode);
    1219             : 
    1220             :         // remember table and start node for later travelling
    1221             :         // (used in export of tables in tables)
    1222        2624 :         SwTable const*const pTable( & pSttNd->FindTableNode()->GetTable() );
    1223             :         SwXParagraphEnumeration *const pEnum =
    1224             :             new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_TBLTEXT,
    1225        2624 :                     pSttNd, pTable);
    1226             : 
    1227        5248 :         aRef = pEnum;
    1228             :     }
    1229        2624 :     return aRef;
    1230             : }
    1231             : 
    1232           1 : uno::Type SAL_CALL SwXCell::getElementType(void) throw( uno::RuntimeException, std::exception )
    1233             : {
    1234           1 :     return ::getCppuType((const uno::Reference<text::XTextRange>*)0);
    1235             : }
    1236             : 
    1237           1 : sal_Bool SwXCell::hasElements(void) throw( uno::RuntimeException, std::exception )
    1238             : {
    1239           1 :     return sal_True;
    1240             : }
    1241             : 
    1242          66 : void SwXCell::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
    1243             : {
    1244          66 :     ClientModify(this, pOld, pNew);
    1245          66 : }
    1246             : 
    1247       10206 : SwXCell* SwXCell::CreateXCell(SwFrmFmt* pTblFmt, SwTableBox* pBox, SwTable *pTable )
    1248             : {
    1249       10206 :     SwXCell* pRet = 0;
    1250       10206 :     if(pTblFmt && pBox)
    1251             :     {
    1252       10206 :         if( !pTable )
    1253         611 :             pTable = SwTable::FindTable( pTblFmt );
    1254       10206 :         SwTableSortBoxes::const_iterator it = pTable->GetTabSortBoxes().find( pBox );
    1255             : 
    1256             :         // if the box exists, then return a cell
    1257       10206 :         if( it != pTable->GetTabSortBoxes().end() )
    1258             :         {
    1259       10206 :             size_t const nPos = it - pTable->GetTabSortBoxes().begin();
    1260       10206 :             SwIterator<SwXCell,SwFmt> aIter( *pTblFmt );
    1261       10206 :             SwXCell* pXCell = aIter.First();
    1262       25120 :             while( pXCell )
    1263             :             {
    1264             :                 // is there already a proper cell?
    1265        5041 :                 if(pXCell->GetTblBox() == pBox)
    1266         333 :                     break;
    1267        4708 :                 pXCell = aIter.Next();
    1268             :             }
    1269             :             // otherwise create it
    1270       10206 :             if(!pXCell)
    1271             :             {
    1272        9873 :                 pXCell = new SwXCell(pTblFmt, pBox, nPos);
    1273             :             }
    1274       10206 :             pRet = pXCell;
    1275             :         }
    1276             :     }
    1277       10206 :     return pRet;
    1278             : }
    1279             : 
    1280             : /** search if a box exists in a table
    1281             :  *
    1282             :  * @param pTable the table to search in
    1283             :  * @param pBox2 box model to find
    1284             :  * @return the box if existent in pTable, 0 (!!!) if not found
    1285             :  */
    1286       78764 : SwTableBox* SwXCell::FindBox(SwTable* pTable, SwTableBox* pBox2)
    1287             : {
    1288             :     // check if nFndPos happens to point to the right table box
    1289      157527 :     if( nFndPos < pTable->GetTabSortBoxes().size() &&
    1290       78763 :         pBox2 == pTable->GetTabSortBoxes()[ nFndPos ] )
    1291       78762 :         return pBox2;
    1292             : 
    1293             :     // if not, seek the entry (and return, if successful)
    1294           2 :     SwTableSortBoxes::const_iterator it = pTable->GetTabSortBoxes().find( pBox2 );
    1295           2 :     if( it != pTable->GetTabSortBoxes().end() )
    1296             :     {
    1297           2 :         nFndPos = it - pTable->GetTabSortBoxes().begin();
    1298           2 :         return pBox2;
    1299             :     }
    1300             : 
    1301             :     // box not found: reset nFndPos pointer
    1302           0 :     nFndPos = NOTFOUND;
    1303           0 :     return 0;
    1304             : }
    1305             : 
    1306           0 : OUString SwXCell::getImplementationName(void) throw( uno::RuntimeException, std::exception )
    1307             : {
    1308           0 :     return OUString("SwXCell");
    1309             : }
    1310             : 
    1311           1 : sal_Bool SwXCell::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
    1312             : {
    1313           1 :     return cppu::supportsService(this, rServiceName);
    1314             : }
    1315             : 
    1316           1 : uno::Sequence< OUString > SwXCell::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
    1317             : {
    1318           1 :     uno::Sequence< OUString > aRet(1);
    1319           1 :     OUString* pArray = aRet.getArray();
    1320           1 :     pArray[0] = "com.sun.star.text.CellProperties";
    1321           1 :     return aRet;
    1322             : }
    1323             : 
    1324           0 : OUString SwXTextTableRow::getImplementationName(void) throw( uno::RuntimeException, std::exception )
    1325             : {
    1326           0 :     return OUString("SwXTextTableRow");
    1327             : }
    1328             : 
    1329           1 : sal_Bool SwXTextTableRow::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
    1330             : {
    1331           1 :     return cppu::supportsService(this, rServiceName);
    1332             : }
    1333             : 
    1334           1 : uno::Sequence< OUString > SwXTextTableRow::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
    1335             : {
    1336           1 :     uno::Sequence< OUString > aRet(1);
    1337           1 :     OUString* pArray = aRet.getArray();
    1338           1 :     pArray[0] = "com.sun.star.text.TextTableRow";
    1339           1 :     return aRet;
    1340             : }
    1341        2247 : TYPEINIT1(SwXTextTableRow, SwClient);
    1342             : 
    1343        2198 : SwXTextTableRow::SwXTextTableRow(SwFrmFmt* pFmt, SwTableLine* pLn) :
    1344             :     SwClient(pFmt),
    1345        2198 :     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_ROW)),
    1346        4396 :     pLine(pLn)
    1347             : {
    1348        2198 : }
    1349             : 
    1350        4396 : SwXTextTableRow::~SwXTextTableRow()
    1351             : {
    1352        4396 : }
    1353             : 
    1354          19 : uno::Reference< beans::XPropertySetInfo >  SwXTextTableRow::getPropertySetInfo(void) throw( uno::RuntimeException, std::exception )
    1355             : {
    1356          19 :     static uno::Reference< beans::XPropertySetInfo >  xRef = m_pPropSet->getPropertySetInfo();
    1357          19 :     return xRef;
    1358             : }
    1359             : 
    1360        6799 : void SwXTextTableRow::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
    1361             :     throw (beans::UnknownPropertyException,
    1362             :            beans::PropertyVetoException,
    1363             :            lang::IllegalArgumentException,
    1364             :            lang::WrappedTargetException,
    1365             :            uno::RuntimeException,
    1366             :            std::exception)
    1367             : {
    1368        6799 :     SolarMutexGuard aGuard;
    1369        6799 :     SwFrmFmt* pFmt = GetFrmFmt();
    1370        6799 :     if(pFmt)
    1371             :     {
    1372        6799 :         SwTable* pTable = SwTable::FindTable( pFmt );
    1373        6799 :         SwTableLine* pLn = SwXTextTableRow::FindLine(pTable, pLine);
    1374        6799 :         if(pLn)
    1375             :         {
    1376             :             // Check for a specific property
    1377        6799 :             if  ( rPropertyName == "TableRedlineParams" )
    1378             :             {
    1379             :                 // Get the table row properties
    1380          28 :                 uno::Sequence< beans::PropertyValue > tableRowProperties;
    1381          28 :                 tableRowProperties = aValue.get< uno::Sequence< beans::PropertyValue > >();
    1382          56 :                 comphelper::SequenceAsHashMap aPropMap( tableRowProperties );
    1383          56 :                 OUString sRedlineType;
    1384          56 :                 uno::Any sRedlineTypeValue;
    1385          28 :                 sRedlineTypeValue = aPropMap.getUnpackedValueOrDefault("RedlineType", sRedlineTypeValue);
    1386          28 :                 if( sRedlineTypeValue >>= sRedlineType )
    1387             :                 {
    1388             :                     // Create a 'Table Row Redline' object
    1389          28 :                     SwUnoCursorHelper::makeTableRowRedline( *pLn, sRedlineType, tableRowProperties);
    1390             :                 }
    1391             :                 else
    1392             :                 {
    1393           0 :                     throw beans::UnknownPropertyException(OUString( "No redline type property: " ), static_cast < cppu::OWeakObject * > ( this ) );
    1394          28 :                 }
    1395             :             }
    1396             :             else
    1397             :             {
    1398             :                 const SfxItemPropertySimpleEntry* pEntry =
    1399        6771 :                     m_pPropSet->getPropertyMap().getByName(rPropertyName);
    1400        6771 :                 SwDoc* pDoc = pFmt->GetDoc();
    1401        6771 :                 if (!pEntry)
    1402           0 :                     throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
    1403        6771 :                 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
    1404           0 :                     throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
    1405             : 
    1406        6771 :                 switch(pEntry->nWID)
    1407             :                 {
    1408             :                     case FN_UNO_ROW_HEIGHT:
    1409             :                     case FN_UNO_ROW_AUTO_HEIGHT:
    1410             :                     {
    1411        1201 :                         SwFmtFrmSize aFrmSize(pLn->GetFrmFmt()->GetFrmSize());
    1412        1201 :                         if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID)
    1413             :                         {
    1414           3 :                             sal_Bool bSet = *(sal_Bool*)aValue.getValue();
    1415           3 :                             aFrmSize.SetHeightSizeType(bSet ? ATT_VAR_SIZE : ATT_FIX_SIZE);
    1416             :                         }
    1417             :                         else
    1418             :                         {
    1419        1198 :                             sal_Int32 nHeight = 0;
    1420        1198 :                             aValue >>= nHeight;
    1421        1198 :                              Size aSz(aFrmSize.GetSize());
    1422        1198 :                             aSz.Height() = MM100_TO_TWIP(nHeight);
    1423        1198 :                             aFrmSize.SetSize(aSz);
    1424             :                         }
    1425        1201 :                         pDoc->SetAttr(aFrmSize, *pLn->ClaimFrmFmt());
    1426             :                     }
    1427        1201 :                     break;
    1428             : 
    1429             :                     case FN_UNO_TABLE_COLUMN_SEPARATORS:
    1430             :                     {
    1431        2176 :                         UnoActionContext aContext(pDoc);
    1432        2176 :                         SwTable* pTable2 = SwTable::FindTable( pFmt );
    1433        2176 :                         lcl_SetTblSeparators(aValue, pTable2, pLine->GetTabBoxes()[0], sal_True, pDoc);
    1434             :                     }
    1435        2176 :                     break;
    1436             : 
    1437             :                     default:
    1438             :                     {
    1439        3394 :                         SwFrmFmt* pLnFmt = pLn->ClaimFrmFmt();
    1440        3394 :                         SwAttrSet aSet(pLnFmt->GetAttrSet());
    1441        3394 :                         m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
    1442        3394 :                         pDoc->SetAttr(aSet, *pLnFmt);
    1443             :                     }
    1444             :                 }
    1445             :             }
    1446             :         }
    1447        6799 :     }
    1448        6798 : }
    1449             : 
    1450          74 : uno::Any SwXTextTableRow::getPropertyValue(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1451             : {
    1452          74 :     SolarMutexGuard aGuard;
    1453          74 :     uno::Any aRet;
    1454          74 :     SwFrmFmt* pFmt = GetFrmFmt();
    1455          74 :     if(pFmt)
    1456             :     {
    1457          74 :         SwTable* pTable = SwTable::FindTable( pFmt );
    1458          74 :         SwTableLine* pLn = SwXTextTableRow::FindLine(pTable, pLine);
    1459          74 :         if(pLn)
    1460             :         {
    1461             :             const SfxItemPropertySimpleEntry* pEntry =
    1462          74 :                                     m_pPropSet->getPropertyMap().getByName(rPropertyName);
    1463          74 :             if (!pEntry)
    1464           0 :                 throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
    1465             : 
    1466          74 :             switch(pEntry->nWID)
    1467             :             {
    1468             :                 case FN_UNO_ROW_HEIGHT:
    1469             :                 case FN_UNO_ROW_AUTO_HEIGHT:
    1470             :                 {
    1471          15 :                     const SwFmtFrmSize& rSize = pLn->GetFrmFmt()->GetFrmSize();
    1472          15 :                     if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID)
    1473             :                     {
    1474           7 :                         sal_Bool bTmp =  ATT_VAR_SIZE == rSize.GetHeightSizeType();
    1475           7 :                         aRet.setValue(&bTmp, ::getCppuBooleanType());
    1476             :                     }
    1477             :                     else
    1478           8 :                         aRet <<= (sal_Int32)(TWIP_TO_MM100(rSize.GetSize().Height()));
    1479             :                 }
    1480          15 :                 break;
    1481             : 
    1482             :                 case FN_UNO_TABLE_COLUMN_SEPARATORS:
    1483             :                 {
    1484          16 :                     lcl_GetTblSeparators(aRet, pTable, pLine->GetTabBoxes()[0], sal_True);
    1485             :                 }
    1486          16 :                 break;
    1487             : 
    1488             :                 default:
    1489             :                 {
    1490          43 :                     const SwAttrSet& rSet = pLn->GetFrmFmt()->GetAttrSet();
    1491          43 :                     m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
    1492             :                 }
    1493             :             }
    1494             :         }
    1495             :     }
    1496          74 :     return aRet;
    1497             : }
    1498             : 
    1499           0 : void SwXTextTableRow::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1500             : {
    1501             :     OSL_FAIL("not implemented");
    1502           0 : }
    1503             : 
    1504           0 : void SwXTextTableRow::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1505             : {
    1506             :     OSL_FAIL("not implemented");
    1507           0 : }
    1508             : 
    1509           0 : void SwXTextTableRow::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1510             : {
    1511             :     OSL_FAIL("not implemented");
    1512           0 : }
    1513             : 
    1514           0 : void SwXTextTableRow::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1515             : {
    1516             :     OSL_FAIL("not implemented");
    1517           0 : }
    1518             : 
    1519           3 : void SwXTextTableRow::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
    1520             : {
    1521           3 :     ClientModify(this, pOld, pNew);
    1522           3 : }
    1523             : 
    1524        6873 : SwTableLine* SwXTextTableRow::FindLine(SwTable* pTable, SwTableLine* pLine)
    1525             : {
    1526        6873 :     SwTableLine* pRet = 0;
    1527        6873 :     SwTableLines &rLines = pTable->GetTabLines();
    1528      263038 :     for(sal_uInt16 i = 0; i < rLines.size(); i++)
    1529      263038 :         if(rLines[i] == pLine)
    1530             :         {
    1531        6873 :             pRet = pLine;
    1532        6873 :             break;
    1533             :         }
    1534        6873 :     return pRet;
    1535             : }
    1536             : 
    1537             : // SwXTextTableCursor
    1538             : 
    1539           0 : OUString SwXTextTableCursor::getImplementationName(void) throw( uno::RuntimeException, std::exception )
    1540             : {
    1541           0 :     return OUString("SwXTextTableCursor");
    1542             : }
    1543             : 
    1544           3 : sal_Bool SwXTextTableCursor::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
    1545             : {
    1546           3 :     return cppu::supportsService(this, rServiceName);
    1547             : }
    1548             : 
    1549          80 : IMPLEMENT_FORWARD_XINTERFACE2(SwXTextTableCursor,SwXTextTableCursor_Base,OTextCursorHelper)
    1550           0 : const SwPaM*        SwXTextTableCursor::GetPaM() const  { return GetCrsr(); }
    1551           0 : SwPaM*              SwXTextTableCursor::GetPaM()        { return GetCrsr(); }
    1552           0 : const SwDoc*        SwXTextTableCursor::GetDoc() const  { return GetFrmFmt()->GetDoc(); }
    1553           0 : SwDoc*              SwXTextTableCursor::GetDoc()        { return GetFrmFmt()->GetDoc(); }
    1554           0 : const SwUnoCrsr*    SwXTextTableCursor::GetCrsr() const { return (SwUnoCrsr*)aCrsrDepend.GetRegisteredIn(); }
    1555         327 : SwUnoCrsr*          SwXTextTableCursor::GetCrsr()       { return (SwUnoCrsr*)aCrsrDepend.GetRegisteredIn(); }
    1556             : 
    1557           3 : uno::Sequence< OUString > SwXTextTableCursor::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
    1558             : {
    1559           3 :     uno::Sequence< OUString > aRet(1);
    1560           3 :     OUString* pArray = aRet.getArray();
    1561           3 :     pArray[0] = "com.sun.star.text.TextTableCursor";
    1562           3 :     return aRet;
    1563             : }
    1564             : 
    1565           6 : SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt* pFmt, SwTableBox* pBox) :
    1566             :     SwClient(pFmt),
    1567             :     aCrsrDepend(this, 0),
    1568           6 :     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR))
    1569             : {
    1570           6 :     SwDoc* pDoc = pFmt->GetDoc();
    1571           6 :     const SwStartNode* pSttNd = pBox->GetSttNd();
    1572           6 :     SwPosition aPos(*pSttNd);
    1573           6 :     SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(aPos, true);
    1574           6 :     pUnoCrsr->Move( fnMoveForward, fnGoNode );
    1575           6 :     pUnoCrsr->Add(&aCrsrDepend);
    1576           6 :     SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    1577           6 :     pTblCrsr->MakeBoxSels();
    1578           6 : }
    1579             : 
    1580           0 : SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt& rTableFmt, const SwTableCursor* pTableSelection) :
    1581             :     SwClient(&rTableFmt),
    1582             :     aCrsrDepend(this, 0),
    1583           0 :     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR))
    1584             : {
    1585           0 :     SwUnoCrsr* pUnoCrsr = pTableSelection->GetDoc()->CreateUnoCrsr(*pTableSelection->GetPoint(), true);
    1586           0 :     if(pTableSelection->HasMark())
    1587             :     {
    1588           0 :         pUnoCrsr->SetMark();
    1589           0 :         *pUnoCrsr->GetMark() = *pTableSelection->GetMark();
    1590             :     }
    1591           0 :     const SwSelBoxes& rBoxes = pTableSelection->GetSelectedBoxes();
    1592           0 :     SwTableCursor* pTableCrsr = dynamic_cast<SwTableCursor*>(pUnoCrsr);
    1593           0 :     for (size_t i = 0; i < rBoxes.size(); i++)
    1594             :     {
    1595           0 :         pTableCrsr->InsertBox( *rBoxes[i] );
    1596             :     }
    1597             : 
    1598           0 :     pUnoCrsr->Add(&aCrsrDepend);
    1599           0 :     SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    1600           0 :     pTblCrsr->MakeBoxSels();
    1601           0 : }
    1602             : 
    1603          18 : SwXTextTableCursor::~SwXTextTableCursor()
    1604             : {
    1605           6 :     SolarMutexGuard aGuard;
    1606           6 :     SwUnoCrsr* pUnoCrsr = GetCrsr();
    1607           6 :     delete pUnoCrsr;
    1608          12 : }
    1609             : 
    1610           7 : OUString SwXTextTableCursor::getRangeName()
    1611             :     throw (uno::RuntimeException, std::exception)
    1612             : {
    1613           7 :     SolarMutexGuard aGuard;
    1614           7 :     OUString aRet;
    1615           7 :     SwUnoCrsr* pUnoCrsr = GetCrsr();
    1616             : 
    1617             :     //!! see also SwChartDataSequence::getSourceRangeRepresentation
    1618           7 :     if(pUnoCrsr)
    1619             :     {
    1620           7 :         SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    1621           7 :         pTblCrsr->MakeBoxSels();
    1622           7 :         const SwStartNode* pNode = pTblCrsr->GetPoint()->nNode.GetNode().FindTableBoxStartNode();
    1623           7 :         const SwTable* pTable = SwTable::FindTable( GetFrmFmt() );
    1624           7 :         const SwTableBox* pEndBox = pTable->GetTblBox( pNode->GetIndex());
    1625           7 :         OUString aTmp( pEndBox->GetName() );
    1626             : 
    1627           7 :         if(pTblCrsr->HasMark())
    1628             :         {
    1629           0 :             pNode = pTblCrsr->GetMark()->nNode.GetNode().FindTableBoxStartNode();
    1630           0 :             const SwTableBox* pStartBox = pTable->GetTblBox( pNode->GetIndex());
    1631           0 :             if(pEndBox != pStartBox)
    1632             :             {
    1633             :                 // need to switch start and end?
    1634           0 :                 if (*pTblCrsr->GetPoint() < *pTblCrsr->GetMark())
    1635             :                 {
    1636           0 :                     const SwTableBox* pTmpBox = pStartBox;
    1637           0 :                     pStartBox = pEndBox;
    1638           0 :                     pEndBox = pTmpBox;
    1639             :                 }
    1640             : 
    1641           0 :                 aTmp  = pStartBox->GetName();
    1642           0 :                 aTmp += ":";
    1643           0 :                 aTmp += pEndBox->GetName();
    1644             :             }
    1645             :         }
    1646           7 :         aRet = aTmp;
    1647             :     }
    1648           7 :     return aRet;
    1649             : }
    1650             : 
    1651           3 : sal_Bool SwXTextTableCursor::gotoCellByName(const OUString& CellName, sal_Bool Expand)
    1652             :     throw( uno::RuntimeException, std::exception )
    1653             : {
    1654           3 :     SolarMutexGuard aGuard;
    1655           3 :     sal_Bool bRet = sal_False;
    1656           3 :     SwUnoCrsr* pUnoCrsr = GetCrsr();
    1657           3 :     if(pUnoCrsr)
    1658             :     {
    1659           3 :         SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    1660           3 :         lcl_CrsrSelect( pTblCrsr, Expand );
    1661           3 :         OUString sCellName(CellName);
    1662           3 :         bRet = pTblCrsr->GotoTblBox(sCellName);
    1663             :     }
    1664           3 :     return bRet;
    1665             : }
    1666             : 
    1667           2 : sal_Bool SwXTextTableCursor::goLeft(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException, std::exception )
    1668             : {
    1669           2 :     SolarMutexGuard aGuard;
    1670           2 :     sal_Bool bRet = sal_False;
    1671           2 :     SwUnoCrsr* pUnoCrsr = GetCrsr();
    1672           2 :     if(pUnoCrsr)
    1673             :     {
    1674           2 :         SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    1675           2 :         lcl_CrsrSelect( pTblCrsr, Expand );
    1676           2 :         bRet = pTblCrsr->Left( Count,CRSR_SKIP_CHARS, sal_False, sal_False);
    1677             :     }
    1678           2 :     return bRet;
    1679             : }
    1680             : 
    1681           2 : sal_Bool SwXTextTableCursor::goRight(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException, std::exception )
    1682             : {
    1683           2 :     SolarMutexGuard aGuard;
    1684           2 :     sal_Bool bRet = sal_False;
    1685           2 :     SwUnoCrsr* pUnoCrsr = GetCrsr();
    1686           2 :     if(pUnoCrsr)
    1687             :     {
    1688           2 :         SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    1689           2 :         lcl_CrsrSelect( pTblCrsr, Expand );
    1690           2 :         bRet = pTblCrsr->Right( Count, CRSR_SKIP_CHARS, sal_False, sal_False);
    1691             :     }
    1692           2 :     return bRet;
    1693             : }
    1694             : 
    1695           2 : sal_Bool SwXTextTableCursor::goUp(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException, std::exception )
    1696             : {
    1697           2 :     SolarMutexGuard aGuard;
    1698           2 :     sal_Bool bRet = sal_False;
    1699           2 :     SwUnoCrsr* pUnoCrsr = GetCrsr();
    1700           2 :     if(pUnoCrsr)
    1701             :     {
    1702           2 :         SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    1703           2 :         lcl_CrsrSelect( pTblCrsr, Expand );
    1704           2 :         bRet = pTblCrsr->UpDown(true, Count, 0, 0);
    1705             :     }
    1706           2 :     return bRet;
    1707             : }
    1708             : 
    1709           1 : sal_Bool SwXTextTableCursor::goDown(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException, std::exception )
    1710             : {
    1711           1 :     SolarMutexGuard aGuard;
    1712           1 :     sal_Bool bRet = sal_False;
    1713           1 :     SwUnoCrsr* pUnoCrsr = GetCrsr();
    1714           1 :     if(pUnoCrsr)
    1715             :     {
    1716           1 :         SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    1717           1 :         lcl_CrsrSelect( pTblCrsr, Expand );
    1718           1 :         bRet = pTblCrsr->UpDown(false, Count, 0, 0);
    1719             :     }
    1720           1 :     return bRet;
    1721             : }
    1722             : 
    1723           4 : void SwXTextTableCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException, std::exception )
    1724             : {
    1725           4 :     SolarMutexGuard aGuard;
    1726           4 :     SwUnoCrsr* pUnoCrsr = GetCrsr();
    1727           4 :     if(pUnoCrsr)
    1728             :     {
    1729           4 :         SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    1730           4 :         lcl_CrsrSelect( pTblCrsr, Expand );
    1731           4 :         pTblCrsr->MoveTable(fnTableCurr, fnTableStart);
    1732           4 :     }
    1733           4 : }
    1734             : 
    1735           7 : void SwXTextTableCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException, std::exception )
    1736             : {
    1737           7 :     SolarMutexGuard aGuard;
    1738           7 :     SwUnoCrsr* pUnoCrsr = GetCrsr();
    1739           7 :     if(pUnoCrsr)
    1740             :     {
    1741           7 :         SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    1742           7 :         lcl_CrsrSelect( pTblCrsr, Expand );
    1743           7 :         pTblCrsr->MoveTable(fnTableCurr, fnTableEnd);
    1744           7 :     }
    1745           7 : }
    1746             : 
    1747           3 : sal_Bool SwXTextTableCursor::mergeRange()
    1748             :     throw (uno::RuntimeException, std::exception)
    1749             : {
    1750           3 :     SolarMutexGuard aGuard;
    1751           3 :     sal_Bool bRet = sal_False;
    1752           3 :     SwUnoCrsr* pUnoCrsr = GetCrsr();
    1753           3 :     if(pUnoCrsr)
    1754             :     {
    1755             :         {
    1756             :             // hier muessen die Actions aufgehoben werden
    1757           3 :             UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
    1758             :         }
    1759           3 :         SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    1760           3 :         pTblCrsr->MakeBoxSels();
    1761             : 
    1762             :         {
    1763           3 :             UnoActionContext aContext(pUnoCrsr->GetDoc());
    1764           3 :             bRet = TBLMERGE_OK == pTblCrsr->GetDoc()->MergeTbl(*pTblCrsr);
    1765           3 :             if(bRet)
    1766             :             {
    1767           3 :                 size_t nCount = pTblCrsr->GetSelectedBoxesCount();
    1768          10 :                 while (nCount--)
    1769             :                 {
    1770           4 :                     pTblCrsr->DeleteBox(nCount);
    1771             :                 }
    1772           3 :             }
    1773             :         }
    1774           3 :         pTblCrsr->MakeBoxSels();
    1775             :     }
    1776           3 :     return bRet;
    1777             : }
    1778             : 
    1779           2 : sal_Bool SwXTextTableCursor::splitRange(sal_Int16 Count, sal_Bool Horizontal)
    1780             :     throw (uno::RuntimeException, std::exception)
    1781             : {
    1782           2 :     SolarMutexGuard aGuard;
    1783           2 :     if (Count <= 0)
    1784           0 :         throw uno::RuntimeException("Illegal first argument: needs to be > 0", static_cast < cppu::OWeakObject * > ( this ) );
    1785           2 :     sal_Bool bRet = sal_False;
    1786           2 :     SwUnoCrsr* pUnoCrsr = GetCrsr();
    1787           2 :     if(pUnoCrsr)
    1788             :     {
    1789             :         {
    1790             :             // hier muessen die Actions aufgehoben werden
    1791           2 :             UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
    1792             :         }
    1793           2 :         SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    1794           2 :         pTblCrsr->MakeBoxSels();
    1795             :         {
    1796           2 :             UnoActionContext aContext(pUnoCrsr->GetDoc());
    1797             :             bRet = pTblCrsr->GetDoc()->SplitTbl(
    1798           2 :                     pTblCrsr->GetSelectedBoxes(), !Horizontal, Count);
    1799             :         }
    1800           2 :         pTblCrsr->MakeBoxSels();
    1801             :     }
    1802           2 :     return bRet;
    1803             : }
    1804             : 
    1805         151 : uno::Reference< beans::XPropertySetInfo >  SwXTextTableCursor::getPropertySetInfo(void) throw( uno::RuntimeException, std::exception )
    1806             : {
    1807         151 :     static uno::Reference< beans::XPropertySetInfo >  xRef = m_pPropSet->getPropertySetInfo();
    1808         151 :     return xRef;
    1809             : }
    1810             : 
    1811          93 : void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
    1812             :     throw (beans::UnknownPropertyException,
    1813             :            beans::PropertyVetoException,
    1814             :            lang::IllegalArgumentException,
    1815             :            lang::WrappedTargetException,
    1816             :            uno::RuntimeException,
    1817             :            std::exception)
    1818             : {
    1819          93 :     SolarMutexGuard aGuard;
    1820          93 :     SwUnoCrsr* pUnoCrsr = GetCrsr();
    1821          93 :     if(pUnoCrsr)
    1822             :     {
    1823          93 :         SwStartNode* pSttNode = pUnoCrsr->GetNode()->StartOfSectionNode();
    1824          93 :         const SwTableNode* pTblNode = pSttNode->FindTableNode();
    1825          93 :         lcl_FormatTable((SwFrmFmt*)pTblNode->GetTable().GetFrmFmt());
    1826          93 :         SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    1827             :         const SfxItemPropertySimpleEntry* pEntry =
    1828          93 :                                     m_pPropSet->getPropertyMap().getByName(rPropertyName);
    1829          93 :         if(pEntry)
    1830             :         {
    1831          93 :             if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
    1832           0 :                 throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
    1833          93 :             pTblCrsr->MakeBoxSels();
    1834          93 :             SwDoc* pDoc = pUnoCrsr->GetDoc();
    1835          93 :             switch(pEntry->nWID )
    1836             :             {
    1837             :                 case FN_UNO_TABLE_CELL_BACKGROUND:
    1838             :                 {
    1839           0 :                     SvxBrushItem aBrush( RES_BACKGROUND );
    1840           0 :                     pDoc->GetBoxAttr( *pUnoCrsr, aBrush );
    1841           0 :                     aBrush.PutValue(aValue, pEntry->nMemberId);
    1842           0 :                     pDoc->SetBoxAttr( *pUnoCrsr, aBrush );
    1843             : 
    1844             :                 }
    1845           0 :                 break;
    1846             :                 case RES_BOXATR_FORMAT:
    1847             :                 {
    1848           0 :                     SfxUInt32Item aNumberFormat(RES_BOXATR_FORMAT);
    1849           0 :                     aNumberFormat.PutValue(aValue, 0);
    1850           0 :                     pDoc->SetBoxAttr( *pUnoCrsr, aNumberFormat);
    1851             :                 }
    1852           0 :                 break;
    1853             :                 case FN_UNO_PARA_STYLE:
    1854           0 :                     SwUnoCursorHelper::SetTxtFmtColl(aValue, *pUnoCrsr);
    1855           0 :                 break;
    1856             :                 default:
    1857             :                 {
    1858          93 :                     SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID );
    1859          93 :                     SwUnoCursorHelper::GetCrsrAttr(pTblCrsr->GetSelRing(),
    1860          93 :                             aItemSet);
    1861             : 
    1862          93 :                     if (!SwUnoCursorHelper::SetCursorPropertyValue(
    1863          93 :                             *pEntry, aValue, pTblCrsr->GetSelRing(), aItemSet))
    1864             :                     {
    1865          92 :                         m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet);
    1866             :                     }
    1867          92 :                     SwUnoCursorHelper::SetCrsrAttr(pTblCrsr->GetSelRing(),
    1868          93 :                             aItemSet, nsSetAttrMode::SETATTR_DEFAULT, true);
    1869             :                 }
    1870             :             }
    1871             :         }
    1872             :         else
    1873           0 :             throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
    1874          93 :     }
    1875          92 : }
    1876             : 
    1877         195 : uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName)
    1878             :     throw (beans::UnknownPropertyException,
    1879             :            lang::WrappedTargetException,
    1880             :            uno::RuntimeException,
    1881             :            std::exception)
    1882             : {
    1883         195 :     SolarMutexGuard aGuard;
    1884         195 :     uno::Any aRet;
    1885         195 :     SwUnoCrsr* pUnoCrsr = GetCrsr();
    1886         195 :     if(pUnoCrsr)
    1887             :     {
    1888         195 :         SwStartNode* pSttNode = pUnoCrsr->GetNode()->StartOfSectionNode();
    1889         195 :         const SwTableNode* pTblNode = pSttNode->FindTableNode();
    1890         195 :         lcl_FormatTable((SwFrmFmt*)pTblNode->GetTable().GetFrmFmt());
    1891         195 :         SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    1892             :         const SfxItemPropertySimpleEntry* pEntry =
    1893         195 :                                     m_pPropSet->getPropertyMap().getByName(rPropertyName);
    1894         195 :         if(pEntry)
    1895             :         {
    1896         195 :             pTblCrsr->MakeBoxSels();
    1897         195 :             switch(pEntry->nWID )
    1898             :             {
    1899             :                 case FN_UNO_TABLE_CELL_BACKGROUND:
    1900             :                 {
    1901           0 :                     SvxBrushItem aBrush( RES_BACKGROUND );
    1902           0 :                     if(pTblCrsr->GetDoc()->GetBoxAttr( *pUnoCrsr, aBrush ))
    1903           0 :                         aBrush.QueryValue(aRet, pEntry->nMemberId);
    1904             : 
    1905             :                 }
    1906           0 :                 break;
    1907             :                 case RES_BOXATR_FORMAT:
    1908             :                     //GetAttr fuer Tabellenselektion am Doc fehlt noch
    1909             :                     OSL_FAIL("not implemented");
    1910           0 :                 break;
    1911             :                 case FN_UNO_PARA_STYLE:
    1912             :                 {
    1913             :                     SwFmtColl *const pFmt =
    1914           0 :                         SwUnoCursorHelper::GetCurTxtFmtColl(*pUnoCrsr, false);
    1915           0 :                     OUString sRet;
    1916           0 :                     if(pFmt)
    1917           0 :                         sRet = pFmt->GetName();
    1918           0 :                     aRet <<= sRet;
    1919             :                 }
    1920           0 :                 break;
    1921             :                 default:
    1922             :                 {
    1923         195 :                     SfxItemSet aSet(pTblCrsr->GetDoc()->GetAttrPool(),
    1924             :                         RES_CHRATR_BEGIN,       RES_FRMATR_END -1,
    1925             :                         RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
    1926         195 :                         0L);
    1927             :                     // erstmal die Attribute des Cursors
    1928         195 :                     SwUnoCursorHelper::GetCrsrAttr(pTblCrsr->GetSelRing(),
    1929         195 :                             aSet);
    1930         195 :                     m_pPropSet->getPropertyValue(*pEntry, aSet, aRet);
    1931             :                 }
    1932             :             }
    1933             :         }
    1934             :         else
    1935           0 :             throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
    1936             :     }
    1937         195 :     return aRet;
    1938             : }
    1939             : 
    1940           0 : void SwXTextTableCursor::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1941             : {
    1942             :     OSL_FAIL("not implemented");
    1943           0 : }
    1944             : 
    1945           0 : void SwXTextTableCursor::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1946             : {
    1947             :     OSL_FAIL("not implemented");
    1948           0 : }
    1949             : 
    1950           0 : void SwXTextTableCursor::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1951             : {
    1952             :     OSL_FAIL("not implemented");
    1953           0 : }
    1954             : 
    1955           0 : void SwXTextTableCursor::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    1956             : {
    1957             :     OSL_FAIL("not implemented");
    1958           0 : }
    1959             : 
    1960           4 : void SwXTextTableCursor::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
    1961             : {
    1962           4 :     ClientModify(this, pOld, pNew);
    1963           4 : }
    1964             : 
    1965             : // SwXTextTable
    1966             : 
    1967         816 : class SwXTextTable::Impl
    1968             : {
    1969             : private:
    1970             :     ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper
    1971             : 
    1972             : public:
    1973             :     ::cppu::OMultiTypeInterfaceContainerHelper m_Listeners;
    1974             : 
    1975         816 :     Impl() : m_Listeners(m_Mutex) { }
    1976             : };
    1977             : 
    1978             : // SwTableProperties_Impl
    1979             : 
    1980             : class SwTableProperties_Impl
    1981             : {
    1982             :     SwUnoCursorHelper::SwAnyMapHelper aAnyMap;
    1983             : public:
    1984             :     SwTableProperties_Impl();
    1985             :     ~SwTableProperties_Impl();
    1986             : 
    1987             :     void        SetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& aVal);
    1988             :     sal_Bool    GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& rpAny);
    1989             : 
    1990             :     void        ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc);
    1991             : };
    1992             : 
    1993          84 : SwTableProperties_Impl::SwTableProperties_Impl()
    1994             : {
    1995          84 : }
    1996             : 
    1997          84 : SwTableProperties_Impl::~SwTableProperties_Impl()
    1998             : {
    1999          84 : }
    2000             : 
    2001           1 : void SwTableProperties_Impl::SetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& rVal)
    2002             : {
    2003           1 :     aAnyMap.SetValue( nWhichId, nMemberId, rVal );
    2004           1 : }
    2005             : 
    2006        1512 : sal_Bool SwTableProperties_Impl::GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& rpAny )
    2007             : {
    2008        1512 :     return aAnyMap.FillValue( nWhichId, nMemberId, rpAny );
    2009             : }
    2010             : 
    2011          72 : void SwTableProperties_Impl::ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc)
    2012             : {
    2013          72 :     SfxItemSet aSet(rDoc.GetAttrPool(),
    2014             :         RES_LAYOUT_SPLIT,   RES_LAYOUT_SPLIT,
    2015             :         RES_BACKGROUND,     RES_BACKGROUND,
    2016             :         RES_FRM_SIZE,       RES_UL_SPACE,
    2017             :         RES_HORI_ORIENT,    RES_HORI_ORIENT,
    2018             :         RES_BREAK,          RES_BREAK,
    2019             :         RES_KEEP,           RES_KEEP,
    2020             :         RES_SHADOW,         RES_SHADOW,
    2021             :         RES_PAGEDESC,       RES_PAGEDESC,
    2022             :         0
    2023          72 :         );
    2024             :     const uno::Any* pRepHead;
    2025          72 :     const SwFrmFmt &rFrmFmt = *rTbl.GetFrmFmt();
    2026          72 :     if(GetProperty(FN_TABLE_HEADLINE_REPEAT, 0xff, pRepHead ))
    2027             :     {
    2028           0 :         sal_Bool bVal = *(sal_Bool*)pRepHead->getValue();
    2029           0 :         ((SwTable&)rTbl).SetRowsToRepeat( bVal ? 1 : 0 );  // TODO MULTIHEADER
    2030             :     }
    2031             : 
    2032          72 :     const uno::Any* pBackColor   = 0;
    2033          72 :     GetProperty(RES_BACKGROUND, MID_BACK_COLOR, pBackColor );
    2034          72 :     const uno::Any* pBackTrans  = 0;
    2035          72 :     GetProperty(RES_BACKGROUND, MID_GRAPHIC_TRANSPARENT, pBackTrans );
    2036          72 :     const uno::Any* pGrLoc      = 0;
    2037          72 :     GetProperty(RES_BACKGROUND, MID_GRAPHIC_POSITION, pGrLoc    );
    2038          72 :     const uno::Any* pGrURL      = 0;
    2039          72 :     GetProperty(RES_BACKGROUND, MID_GRAPHIC_URL, pGrURL     );
    2040          72 :     const uno::Any* pGrFilter   = 0;
    2041          72 :     GetProperty(RES_BACKGROUND, MID_GRAPHIC_FILTER, pGrFilter     );
    2042             : 
    2043          72 :     if(pBackColor||pBackTrans||pGrURL||pGrFilter||pGrLoc)
    2044             :     {
    2045           1 :         SvxBrushItem aBrush ( rFrmFmt.GetBackground() );
    2046           1 :         if(pBackColor)
    2047           1 :             aBrush.PutValue(*pBackColor, MID_BACK_COLOR);
    2048           1 :         if(pBackTrans)
    2049           0 :             aBrush.PutValue(*pBackTrans, MID_GRAPHIC_TRANSPARENT);
    2050           1 :         if(pGrURL)
    2051           0 :             aBrush.PutValue(*pGrURL, MID_GRAPHIC_URL);
    2052           1 :         if(pGrFilter)
    2053           0 :             aBrush.PutValue(*pGrFilter, MID_GRAPHIC_FILTER);
    2054           1 :         if(pGrLoc)
    2055           0 :             aBrush.PutValue(*pGrLoc, MID_GRAPHIC_POSITION);
    2056           1 :         aSet.Put(aBrush);
    2057             :     }
    2058             : 
    2059          72 :     bool bPutBreak = true;
    2060             :     const uno::Any* pPage;
    2061          72 :     if(GetProperty(FN_UNO_PAGE_STYLE, 0, pPage) || GetProperty(RES_PAGEDESC, 0xff, pPage))
    2062             :     {
    2063           0 :         OUString sPageStyle;
    2064           0 :         (*pPage) >>= sPageStyle;
    2065           0 :         if (!sPageStyle.isEmpty())
    2066             :         {
    2067           0 :             SwStyleNameMapper::FillUIName(sPageStyle, sPageStyle, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true );
    2068           0 :             const SwPageDesc* pDesc = SwPageDesc::GetByName(rDoc, sPageStyle);
    2069           0 :             if(pDesc)
    2070             :             {
    2071           0 :                 SwFmtPageDesc aDesc( pDesc );
    2072             :                 const uno::Any* pPgNo;
    2073           0 :                 if(GetProperty(RES_PAGEDESC, MID_PAGEDESC_PAGENUMOFFSET, pPgNo ))
    2074             :                 {
    2075           0 :                     sal_Int16 nTmp = 0;
    2076           0 :                     (*pPgNo) >>= nTmp;
    2077           0 :                     aDesc.SetNumOffset( nTmp );
    2078             :                 }
    2079           0 :                 aSet.Put(aDesc);
    2080           0 :                 bPutBreak = false;
    2081             :             }
    2082             : 
    2083           0 :         }
    2084             :     }
    2085             :     const uno::Any* pBreak;
    2086          72 :     if(bPutBreak && GetProperty(RES_BREAK, 0, pBreak))
    2087             :     {
    2088           0 :         SvxFmtBreakItem aBreak ( rFrmFmt.GetBreak() );
    2089           0 :         aBreak.PutValue(*pBreak, 0);
    2090           0 :         aSet.Put(aBreak);
    2091             :     }
    2092             :     const uno::Any* pShadow;
    2093          72 :     if(GetProperty(RES_SHADOW, 0, pShadow))
    2094             :     {
    2095           0 :         SvxShadowItem aShd ( rFrmFmt.GetShadow() );
    2096           0 :         aShd.PutValue(*pShadow, CONVERT_TWIPS);
    2097           0 :         aSet.Put(aShd);
    2098             :     }
    2099             :     const uno::Any* pKeep;
    2100          72 :     if(GetProperty(RES_KEEP, 0, pKeep))
    2101             :     {
    2102           0 :         SvxFmtKeepItem aKeep( rFrmFmt.GetKeep() );
    2103           0 :         aKeep.PutValue(*pKeep, 0);
    2104           0 :         aSet.Put(aKeep);
    2105             :     }
    2106             : 
    2107             :     const uno::Any* pHOrient;
    2108          72 :     if(GetProperty(RES_HORI_ORIENT, MID_HORIORIENT_ORIENT, pHOrient))
    2109             :     {
    2110           0 :         SwFmtHoriOrient aOrient ( rFrmFmt.GetHoriOrient() );
    2111           0 :         ((SfxPoolItem&)aOrient).PutValue(*pHOrient, MID_HORIORIENT_ORIENT|CONVERT_TWIPS);
    2112           0 :         aSet.Put(aOrient);
    2113             :     }
    2114             : 
    2115          72 :     const uno::Any* pSzRel       = 0;
    2116          72 :     GetProperty(FN_TABLE_IS_RELATIVE_WIDTH, 0xff, pSzRel  );
    2117          72 :     const uno::Any* pRelWidth   = 0;
    2118          72 :     GetProperty(FN_TABLE_RELATIVE_WIDTH, 0xff, pRelWidth);
    2119          72 :     const uno::Any* pWidth      = 0;
    2120          72 :     GetProperty(FN_TABLE_WIDTH, 0xff, pWidth  );
    2121             : 
    2122          72 :     bool bPutSize = pWidth != 0;
    2123         144 :     SwFmtFrmSize aSz( ATT_VAR_SIZE);
    2124          72 :     if(pWidth)
    2125             :     {
    2126           0 :         ((SfxPoolItem&)aSz).PutValue(*pWidth, MID_FRMSIZE_WIDTH);
    2127           0 :         bPutSize = true;
    2128             :     }
    2129          72 :     sal_Bool bTemp = pSzRel ? *(sal_Bool*)pSzRel->getValue() : sal_False;
    2130          72 :     if(pSzRel && bTemp && pRelWidth)
    2131             :     {
    2132           0 :         ((SfxPoolItem&)aSz).PutValue(*pRelWidth, MID_FRMSIZE_REL_WIDTH|CONVERT_TWIPS);
    2133           0 :         bPutSize = true;
    2134             :     }
    2135          72 :     if(bPutSize)
    2136             :     {
    2137           0 :         if(!aSz.GetWidth())
    2138           0 :             aSz.SetWidth(MINLAY);
    2139           0 :         aSet.Put(aSz);
    2140             :     }
    2141          72 :     const uno::Any* pL      = 0;
    2142          72 :     GetProperty(RES_LR_SPACE, MID_L_MARGIN|CONVERT_TWIPS, pL);
    2143          72 :     const uno::Any* pR      = 0;
    2144          72 :     GetProperty(RES_LR_SPACE, MID_R_MARGIN|CONVERT_TWIPS, pR);
    2145          72 :     if(pL||pR)
    2146             :     {
    2147           0 :         SvxLRSpaceItem aLR ( rFrmFmt.GetLRSpace() );
    2148           0 :         if(pL)
    2149           0 :             ((SfxPoolItem&)aLR).PutValue(*pL, MID_L_MARGIN|CONVERT_TWIPS);
    2150           0 :         if(pR)
    2151           0 :             ((SfxPoolItem&)aLR).PutValue(*pR, MID_R_MARGIN|CONVERT_TWIPS);
    2152           0 :         aSet.Put(aLR);
    2153             :     }
    2154          72 :     const uno::Any* pU      = 0;
    2155          72 :     GetProperty(RES_UL_SPACE, MID_UP_MARGIN|CONVERT_TWIPS, pU);
    2156          72 :     const uno::Any* pLo     = 0;
    2157          72 :     GetProperty(RES_UL_SPACE, MID_LO_MARGIN|CONVERT_TWIPS, pLo);
    2158          72 :     if(pU||pLo)
    2159             :     {
    2160           0 :         SvxULSpaceItem aUL ( rFrmFmt.GetULSpace() );
    2161           0 :         if(pU)
    2162           0 :             ((SfxPoolItem&)aUL).PutValue(*pU, MID_UP_MARGIN|CONVERT_TWIPS);
    2163           0 :         if(pLo)
    2164           0 :             ((SfxPoolItem&)aUL).PutValue(*pLo, MID_LO_MARGIN|CONVERT_TWIPS);
    2165           0 :         aSet.Put(aUL);
    2166             :     }
    2167             :     const::uno::Any* pSplit;
    2168          72 :     if(GetProperty(RES_LAYOUT_SPLIT, 0, pSplit ))
    2169             :     {
    2170           0 :         sal_Bool bTmp = *(sal_Bool*)pSplit->getValue();
    2171           0 :         SwFmtLayoutSplit aSp(bTmp);
    2172           0 :         aSet.Put(aSp);
    2173             :     }
    2174             : 
    2175          72 :     if(aSet.Count())
    2176             :     {
    2177           1 :         rDoc.SetAttr( aSet, *rTbl.GetFrmFmt() );
    2178          72 :     }
    2179          72 : }
    2180             : 
    2181             : namespace
    2182             : {
    2183             :     class theSwXTextTableUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextTableUnoTunnelId > {};
    2184             : }
    2185             : 
    2186         578 : const uno::Sequence< sal_Int8 > & SwXTextTable::getUnoTunnelId()
    2187             : {
    2188         578 :     return theSwXTextTableUnoTunnelId::get().getSeq();
    2189             : }
    2190             : 
    2191         522 : sal_Int64 SAL_CALL SwXTextTable::getSomething( const uno::Sequence< sal_Int8 >& rId )
    2192             :     throw(uno::RuntimeException, std::exception)
    2193             : {
    2194        1044 :     if( rId.getLength() == 16
    2195        1566 :         && 0 == memcmp( getUnoTunnelId().getConstArray(),
    2196        1044 :                                         rId.getConstArray(), 16 ) )
    2197             :     {
    2198          52 :         return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
    2199             :     }
    2200         470 :     return 0;
    2201             : }
    2202             : 
    2203       47134 : TYPEINIT1(SwXTextTable, SwClient)
    2204             : 
    2205          84 : SwXTextTable::SwXTextTable()
    2206          84 :     : m_pImpl(new Impl)
    2207             :     ,
    2208          84 :     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)),
    2209          84 :     pTableProps(new SwTableProperties_Impl),
    2210             :     bIsDescriptor(sal_True),
    2211             :     nRows(2),
    2212             :     nColumns(2),
    2213             :     bFirstRowAsLabel(sal_False),
    2214         336 :     bFirstColumnAsLabel(sal_False)
    2215             : {
    2216          84 : }
    2217             : 
    2218         732 : SwXTextTable::SwXTextTable(SwFrmFmt& rFrmFmt)
    2219             :     : SwClient( &rFrmFmt )
    2220         732 :     , m_pImpl(new Impl)
    2221             :     ,
    2222         732 :     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)),
    2223             :     pTableProps(0),
    2224             :     bIsDescriptor(sal_False),
    2225             :     nRows(0),
    2226             :     nColumns(0),
    2227             :     bFirstRowAsLabel(sal_False),
    2228        2196 :     bFirstColumnAsLabel(sal_False)
    2229             : {
    2230         732 : }
    2231             : 
    2232        2448 : SwXTextTable::~SwXTextTable()
    2233             : {
    2234         816 :     delete pTableProps;
    2235        1632 : }
    2236             : 
    2237          67 : void SwXTextTable::initialize(sal_Int32 nR, sal_Int32 nC) throw( uno::RuntimeException, std::exception )
    2238             : {
    2239          67 :     if(!bIsDescriptor || nR <= 0 || nC <= 0 || nR >= USHRT_MAX || nC >= USHRT_MAX )
    2240           0 :         throw uno::RuntimeException();
    2241             :     else
    2242             :     {
    2243          67 :         nRows = (sal_uInt16)nR;
    2244          67 :         nColumns = (sal_uInt16)nC;
    2245             :     }
    2246          67 : }
    2247             : 
    2248         400 : uno::Reference< table::XTableRows >  SwXTextTable::getRows(void) throw( uno::RuntimeException, std::exception )
    2249             : {
    2250         400 :     SolarMutexGuard aGuard;
    2251         400 :     uno::Reference< table::XTableRows >  xRet;
    2252         400 :     if (SwFrmFmt* pFmt = GetFrmFmt())
    2253             :     {
    2254         400 :         SwXTableRows* pRows = SwIterator<SwXTableRows,SwFmt>::FirstElement(*pFmt);
    2255         400 :         if (!pRows)
    2256         400 :             pRows = new SwXTableRows(*pFmt);
    2257         400 :         xRet = pRows;
    2258             :     }
    2259         400 :     if (!xRet.is())
    2260           0 :         throw uno::RuntimeException();
    2261         400 :     return xRet;
    2262             : }
    2263             : 
    2264           2 : uno::Reference< table::XTableColumns >  SwXTextTable::getColumns(void) throw( uno::RuntimeException, std::exception )
    2265             : {
    2266           2 :     SolarMutexGuard aGuard;
    2267           2 :     uno::Reference< table::XTableColumns >  xRet;
    2268           2 :     if (SwFrmFmt* pFmt = GetFrmFmt())
    2269             :     {
    2270           2 :         SwXTableColumns* pCols = SwIterator<SwXTableColumns,SwFmt>::FirstElement(*pFmt);
    2271           2 :         if (!pCols)
    2272           2 :             pCols = new SwXTableColumns(*pFmt);
    2273           2 :         xRet = pCols;
    2274             :     }
    2275           2 :     if (!xRet.is())
    2276           0 :         throw uno::RuntimeException();
    2277           2 :     return xRet;
    2278             : }
    2279             : 
    2280         306 : uno::Reference< table::XCell > SwXTextTable::getCellByName(const OUString& CellName) throw( uno::RuntimeException, std::exception )
    2281             : {
    2282         306 :     SolarMutexGuard aGuard;
    2283         306 :     uno::Reference< table::XCell >  xRet;
    2284         306 :     SwFrmFmt* pFmt = GetFrmFmt();
    2285         306 :     if(pFmt)
    2286             :     {
    2287         306 :         SwTable* pTable = SwTable::FindTable( pFmt );
    2288         306 :         OUString sCellName(CellName);
    2289         306 :         SwTableBox* pBox = (SwTableBox*)pTable->GetTblBox( sCellName );
    2290         306 :         if(pBox)
    2291             :         {
    2292         306 :             xRet = SwXCell::CreateXCell(pFmt, pBox);
    2293         306 :         }
    2294             :     }
    2295             :     else
    2296           0 :         throw uno::RuntimeException();
    2297         306 :     return xRet;
    2298             : }
    2299             : 
    2300          30 : uno::Sequence< OUString > SwXTextTable::getCellNames(void) throw( uno::RuntimeException, std::exception )
    2301             : {
    2302          30 :     SolarMutexGuard aGuard;
    2303          30 :     SwFrmFmt* pFmt = GetFrmFmt();
    2304          30 :     if(pFmt)
    2305             :     {
    2306          30 :         SwTable* pTable = SwTable::FindTable( pFmt );
    2307             :           // exists at the table and at all boxes
    2308          30 :         SwTableLines& rTblLines = pTable->GetTabLines();
    2309          30 :         std::vector<OUString*> aAllNames;
    2310          30 :         lcl_InspectLines(rTblLines, aAllNames);
    2311          60 :         uno::Sequence< OUString > aRet( static_cast<sal_uInt16>(aAllNames.size()) );
    2312          30 :         OUString* pArray = aRet.getArray();
    2313         373 :         for( size_t i = 0; i < aAllNames.size(); ++i)
    2314             :         {
    2315         343 :             pArray[i] = *aAllNames[i];
    2316         343 :             delete aAllNames[i];
    2317             :         }
    2318          60 :         return aRet;
    2319             :     }
    2320           0 :     return uno::Sequence< OUString >();
    2321             : }
    2322             : 
    2323           6 : uno::Reference< text::XTextTableCursor > SwXTextTable::createCursorByCellName(const OUString& CellName)
    2324             :     throw (uno::RuntimeException, std::exception)
    2325             : {
    2326           6 :     SolarMutexGuard aGuard;
    2327           6 :     uno::Reference< text::XTextTableCursor >  xRet;
    2328           6 :     SwFrmFmt* pFmt = GetFrmFmt();
    2329           6 :     if(pFmt)
    2330             :     {
    2331           6 :         SwTable* pTable = SwTable::FindTable( pFmt );
    2332           6 :         OUString sCellName(CellName);
    2333           6 :         SwTableBox* pBox = (SwTableBox*)pTable->GetTblBox( sCellName );
    2334           6 :         if(pBox && pBox->getRowSpan() > 0 )
    2335             :         {
    2336           6 :             xRet = new SwXTextTableCursor(pFmt, pBox);
    2337           6 :         }
    2338             :     }
    2339           6 :     if(!xRet.is())
    2340           0 :         throw uno::RuntimeException();
    2341           6 :     return xRet;
    2342             : }
    2343             : 
    2344          72 : void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTextRange)
    2345             :     throw( lang::IllegalArgumentException, uno::RuntimeException )
    2346             : {
    2347             :     // attachToRange must only be called once
    2348          72 :     if(!bIsDescriptor)  /* already attached ? */
    2349           0 :         throw uno::RuntimeException("SwXTextTable: already attached to range.", static_cast < cppu::OWeakObject * > ( this ) );
    2350             : 
    2351          72 :     uno::Reference<XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
    2352          72 :     SwXTextRange* pRange = 0;
    2353          72 :     OTextCursorHelper* pCursor = 0;
    2354          72 :     if(xRangeTunnel.is())
    2355             :     {
    2356             :         pRange  = reinterpret_cast< SwXTextRange * >(
    2357          72 :                 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
    2358             :         pCursor = reinterpret_cast< OTextCursorHelper * >(
    2359          72 :                 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
    2360             :     }
    2361          72 :     SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0;
    2362          72 :     if(pDoc && nRows && nColumns)
    2363             :     {
    2364          72 :         SwUnoInternalPaM aPam(*pDoc);
    2365             :         //das muss jetzt sal_True liefern
    2366          72 :         ::sw::XTextRangeToSwPaM(aPam, xTextRange);
    2367             : 
    2368             :         {
    2369          72 :             UnoActionContext aCont( pDoc );
    2370             : 
    2371          72 :             pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL);
    2372          72 :             const SwTable *pTable = 0;
    2373          72 :             if( 0 != aPam.Start()->nContent.GetIndex() )
    2374             :             {
    2375           0 :                 pDoc->SplitNode(*aPam.Start(), false );
    2376             :             }
    2377             :             //TODO: if it is the last paragraph than add another one!
    2378          72 :             if( aPam.HasMark() )
    2379             :             {
    2380           0 :                 pDoc->DeleteAndJoin(aPam);
    2381           0 :                 aPam.DeleteMark();
    2382             :             }
    2383             :             pTable = pDoc->InsertTable( SwInsertTableOptions( tabopts::HEADLINE | tabopts::DEFAULT_BORDER | tabopts::SPLIT_LAYOUT, 0 ),
    2384          72 :                                         *aPam.GetPoint(),
    2385             :                                         nRows,
    2386             :                                         nColumns,
    2387         144 :                                         text::HoriOrientation::FULL );
    2388          72 :             if(pTable)
    2389             :             {
    2390             :                 // here, the properties of the descriptor need to be analyzed
    2391          72 :                 pTableProps->ApplyTblAttr(*pTable, *pDoc);
    2392          72 :                 SwFrmFmt* pTblFmt = pTable->GetFrmFmt();
    2393          72 :                 lcl_FormatTable( pTblFmt );
    2394             : 
    2395          72 :                 pTblFmt->Add(this);
    2396          72 :                 if(!m_sTableName.isEmpty())
    2397             :                 {
    2398           2 :                     sal_uInt16 nIndex = 1;
    2399           2 :                     const OUString sTmpName(m_sTableName);
    2400           4 :                     OUString sTmpNameIndex(sTmpName);
    2401           4 :                     while(pDoc->FindTblFmtByName( sTmpNameIndex, sal_True ) && nIndex < USHRT_MAX)
    2402             :                     {
    2403           0 :                         sTmpNameIndex = sTmpName + OUString::number(nIndex++);
    2404             :                     }
    2405           4 :                     pDoc->SetTableName( *pTblFmt, sTmpNameIndex);
    2406             :                 }
    2407             : 
    2408             :                 const::uno::Any* pName;
    2409          72 :                 if(pTableProps->GetProperty(FN_UNO_TABLE_NAME, 0, pName))
    2410             :                 {
    2411           0 :                     OUString sTmp;
    2412           0 :                     (*pName) >>= sTmp;
    2413           0 :                     setName(sTmp);
    2414             :                 }
    2415          72 :                 bIsDescriptor = sal_False;
    2416          72 :                 DELETEZ(pTableProps);
    2417             :             }
    2418          72 :             pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
    2419          72 :         }
    2420             :     }
    2421             :     else
    2422           0 :         throw lang::IllegalArgumentException();
    2423          72 : }
    2424             : 
    2425          72 : void SwXTextTable::attach(const uno::Reference< text::XTextRange > & xTextRange)
    2426             :         throw( lang::IllegalArgumentException, uno::RuntimeException, std::exception )
    2427             : {
    2428          72 :     SolarMutexGuard aGuard;
    2429          72 :     attachToRange( xTextRange );
    2430          72 : }
    2431             : 
    2432         387 : uno::Reference< text::XTextRange >  SwXTextTable::getAnchor(void)
    2433             :         throw( uno::RuntimeException, std::exception )
    2434             : {
    2435         387 :     SolarMutexGuard aGuard;
    2436         387 :     SwFrmFmt* pFmt = GetFrmFmt();
    2437         387 :     if(!pFmt)
    2438           0 :         throw uno::RuntimeException();
    2439         387 :     uno::Reference< text::XTextRange >  xRet = new SwXTextRange(*pFmt);
    2440         387 :     return xRet;
    2441             : }
    2442             : 
    2443           4 : void SwXTextTable::dispose(void) throw( uno::RuntimeException, std::exception )
    2444             : {
    2445           4 :     SolarMutexGuard aGuard;
    2446           4 :     SwFrmFmt* pFmt = GetFrmFmt();
    2447           4 :     if(pFmt)
    2448             :     {
    2449           4 :         SwTable* pTable = SwTable::FindTable( pFmt );
    2450           4 :         SwTableSortBoxes& rBoxes = pTable->GetTabSortBoxes();
    2451           4 :         SwSelBoxes aSelBoxes;
    2452          88 :         for(SwTableSortBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it )
    2453          84 :             aSelBoxes.insert( *it );
    2454           4 :         pFmt->GetDoc()->DeleteRowCol(aSelBoxes);
    2455             :     }
    2456             :     else
    2457           0 :         throw uno::RuntimeException();
    2458           4 : }
    2459             : 
    2460           2 : void SAL_CALL SwXTextTable::addEventListener(
    2461             :         const uno::Reference<lang::XEventListener> & xListener)
    2462             : throw (uno::RuntimeException, std::exception)
    2463             : {
    2464             :     // no need to lock here as m_pImpl is const and container threadsafe
    2465           2 :     m_pImpl->m_Listeners.addInterface(
    2466           4 :             cppu::UnoType<lang::XEventListener>::get(), xListener);
    2467           2 : }
    2468             : 
    2469           1 : void SAL_CALL SwXTextTable::removeEventListener(
    2470             :         const uno::Reference< lang::XEventListener > & xListener)
    2471             : throw (uno::RuntimeException, std::exception)
    2472             : {
    2473             :     // no need to lock here as m_pImpl is const and container threadsafe
    2474           1 :     m_pImpl->m_Listeners.removeInterface(
    2475           2 :             cppu::UnoType<lang::XEventListener>::get(), xListener);
    2476           1 : }
    2477             : 
    2478        9408 : uno::Reference< table::XCell >  SwXTextTable::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
    2479             :     throw( uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception )
    2480             : {
    2481        9408 :     SolarMutexGuard aGuard;
    2482        9408 :     uno::Reference< table::XCell >  aRef;
    2483        9408 :     SwFrmFmt* pFmt = GetFrmFmt();
    2484             :     // sheet is unimportant
    2485        9408 :     if(nColumn >= 0 && nRow >= 0 && nColumn < USHRT_MAX && nRow < USHRT_MAX && pFmt)
    2486             :     {
    2487        9407 :         SwXCell* pXCell = lcl_CreateXCell(pFmt, nColumn, nRow);
    2488        9407 :         if(pXCell)
    2489        9406 :             aRef = pXCell;
    2490             :     }
    2491        9408 :     if(!aRef.is())
    2492           2 :         throw lang::IndexOutOfBoundsException();
    2493        9408 :     return aRef;
    2494             : }
    2495             : 
    2496           5 : uno::Reference< table::XCellRange >  SwXTextTable::GetRangeByName(SwFrmFmt* pFmt, SwTable* pTable,
    2497             :                     const OUString& rTLName, const OUString& rBRName,
    2498             :                     SwRangeDescriptor& rDesc)
    2499             : {
    2500           5 :     SolarMutexGuard aGuard;
    2501           5 :     uno::Reference< table::XCellRange >  aRef;
    2502          10 :     OUString sTLName(rTLName);
    2503          10 :     OUString sBRName(rBRName);
    2504           5 :     const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
    2505           5 :     if(pTLBox)
    2506             :     {
    2507             :         // invalidate all actions
    2508           5 :         UnoActionRemoveContext aRemoveContext(pFmt->GetDoc());
    2509           5 :         const SwStartNode* pSttNd = pTLBox->GetSttNd();
    2510          10 :         SwPosition aPos(*pSttNd);
    2511             :         // set cursor to the upper-left cell of the range
    2512           5 :         SwUnoCrsr* pUnoCrsr = pFmt->GetDoc()->CreateUnoCrsr(aPos, true);
    2513           5 :         pUnoCrsr->Move( fnMoveForward, fnGoNode );
    2514           5 :         pUnoCrsr->SetRemainInSection( sal_False );
    2515           5 :         const SwTableBox* pBRBox = pTable->GetTblBox( sBRName );
    2516           5 :         if(pBRBox)
    2517             :         {
    2518           5 :             pUnoCrsr->SetMark();
    2519           5 :             pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd();
    2520           5 :             pUnoCrsr->Move( fnMoveForward, fnGoNode );
    2521           5 :             SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    2522           5 :             pCrsr->MakeBoxSels();
    2523             :             // pUnoCrsr will be provided and will not be deleted
    2524           5 :             SwXCellRange* pCellRange = new SwXCellRange(pUnoCrsr, *pFmt, rDesc);
    2525           5 :             aRef = pCellRange;
    2526             :         }
    2527             :         else
    2528           5 :             delete pUnoCrsr;
    2529             :     }
    2530          10 :     return aRef;
    2531             : }
    2532             : 
    2533           5 : uno::Reference< table::XCellRange >  SwXTextTable::getCellRangeByPosition(sal_Int32 nLeft, sal_Int32 nTop,
    2534             :                 sal_Int32 nRight, sal_Int32 nBottom)
    2535             :     throw (uno::RuntimeException,
    2536             :            lang::IndexOutOfBoundsException,
    2537             :            std::exception)
    2538             : {
    2539           5 :     SolarMutexGuard aGuard;
    2540           5 :     uno::Reference< table::XCellRange >  aRef;
    2541           5 :     SwFrmFmt* pFmt = GetFrmFmt();
    2542           5 :     if(pFmt && nRight < USHRT_MAX && nBottom < USHRT_MAX &&
    2543           5 :         nLeft <= nRight && nTop <= nBottom &&
    2544           4 :             nLeft >= 0 && nRight >= 0 && nTop >= 0 && nBottom >= 0 )
    2545             :     {
    2546           4 :         SwTable* pTable = SwTable::FindTable( pFmt );
    2547           4 :         if(!pTable->IsTblComplex())
    2548             :         {
    2549             :             SwRangeDescriptor aDesc;
    2550           4 :             aDesc.nTop    = nTop;
    2551           4 :             aDesc.nBottom = nBottom;
    2552           4 :             aDesc.nLeft   = nLeft;
    2553           4 :             aDesc.nRight  = nRight;
    2554           4 :             OUString sTLName = sw_GetCellName(aDesc.nLeft, aDesc.nTop);
    2555           8 :             OUString sBRName = sw_GetCellName(aDesc.nRight, aDesc.nBottom);
    2556             : 
    2557             :             // please note that according to the 'if' statement at the begin
    2558             :             // sTLName:sBRName already denotes the normalized range string
    2559             : 
    2560           8 :             aRef = GetRangeByName(pFmt, pTable, sTLName, sBRName, aDesc);
    2561             :         }
    2562             :     }
    2563           5 :     if(!aRef.is())
    2564           1 :         throw lang::IndexOutOfBoundsException();
    2565           5 :     return aRef;
    2566             : }
    2567             : 
    2568           1 : uno::Reference< table::XCellRange >  SwXTextTable::getCellRangeByName(const OUString& aRange)
    2569             :     throw (uno::RuntimeException, std::exception)
    2570             : {
    2571           1 :     SolarMutexGuard aGuard;
    2572           1 :     uno::Reference< table::XCellRange >  aRef;
    2573           1 :     SwFrmFmt* pFmt = GetFrmFmt();
    2574           1 :     if(pFmt)
    2575             :     {
    2576           1 :         SwTable* pTable = SwTable::FindTable( pFmt );
    2577           1 :         if(!pTable->IsTblComplex())
    2578             :         {
    2579           1 :             OUString sRange(aRange);
    2580           2 :             OUString sTLName(sRange.getToken(0, ':'));
    2581           2 :             OUString sBRName(sRange.getToken(1, ':'));
    2582           1 :             if(sTLName.isEmpty() || sBRName.isEmpty())
    2583           0 :                 throw uno::RuntimeException();
    2584             :             SwRangeDescriptor aDesc;
    2585           1 :             aDesc.nTop = aDesc.nLeft = aDesc.nBottom = aDesc.nRight = -1;
    2586           1 :             sw_GetCellPosition(sTLName, aDesc.nLeft, aDesc.nTop );
    2587           1 :             sw_GetCellPosition(sBRName, aDesc.nRight, aDesc.nBottom );
    2588             : 
    2589             :             // we should normalize the range now (e.g. A5:C1 will become A1:C5)
    2590             :             // since (depending on what is done later) it will be troublesome
    2591             :             // elsewhere when the cursor in the implementation does not
    2592             :             // point to the top-left and bottom-right cells
    2593           1 :             aDesc.Normalize();
    2594             : 
    2595           2 :             aRef = GetRangeByName(pFmt, pTable, sTLName, sBRName, aDesc);
    2596             :         }
    2597             :     }
    2598           1 :     if(!aRef.is())
    2599           0 :         throw uno::RuntimeException();
    2600           1 :     return aRef;
    2601             : }
    2602             : 
    2603           2 : uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray()
    2604             :     throw (uno::RuntimeException, std::exception)
    2605             : {
    2606             :     // see SwXTextTable::getData(...) also
    2607             : 
    2608           2 :     SolarMutexGuard aGuard;
    2609           2 :     sal_Int16 nRowCount = getRowCount();
    2610           2 :     sal_Int16 nColCount = getColumnCount();
    2611           2 :     if(!nRowCount || !nColCount)
    2612             :     {
    2613           0 :         uno::RuntimeException aRuntime;
    2614           0 :         aRuntime.Message = "Table too complex";
    2615           0 :         throw aRuntime;
    2616             :     }
    2617           2 :     SwFrmFmt* pFmt = GetFrmFmt();
    2618           2 :     uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount);
    2619           2 :     if(pFmt)
    2620             :     {
    2621           2 :         uno::Sequence< uno::Any > * pRowArray = aRowSeq.getArray();
    2622          14 :         for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++)
    2623             :         {
    2624          12 :             uno::Sequence< uno::Any >  aColSeq(nColCount);
    2625          12 :             uno::Any * pColArray = aColSeq.getArray();
    2626          24 :             uno::Reference< table::XCell > xCellRef;
    2627          36 :             for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++)
    2628             :             {
    2629          24 :                 SwXCell* pXCell = lcl_CreateXCell(pFmt, nCol, nRow);
    2630             :                 //! keep (additional) reference to object to prevent implicit destruction
    2631             :                 //! in following UNO calls (when object will get referenced)
    2632          24 :                 xCellRef = pXCell;
    2633          24 :                 SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0;
    2634          24 :                 if(!pBox)
    2635             :                 {
    2636           0 :                     throw uno::RuntimeException();
    2637             :                 }
    2638             :                 else
    2639             :                 {
    2640             :                     // check if table box value item is set
    2641          24 :                     SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
    2642          24 :                     bool bIsNum = pBoxFmt->GetItemState( RES_BOXATR_VALUE, sal_False ) == SFX_ITEM_SET;
    2643          24 :                     if(!bIsNum)
    2644          12 :                         pColArray[nCol] <<= lcl_getString(*pXCell);
    2645             :                     else
    2646          12 :                         pColArray[nCol] <<= sw_getValue(*pXCell);
    2647             :                 }
    2648             :             }
    2649          12 :             pRowArray[nRow] = aColSeq;
    2650          12 :         }
    2651             :     }
    2652             :     else
    2653           0 :         throw uno::RuntimeException();
    2654           2 :     return aRowSeq;
    2655             : }
    2656             : 
    2657           2 : void SAL_CALL SwXTextTable::setDataArray(
    2658             :         const uno::Sequence< uno::Sequence< uno::Any > >& rArray )
    2659             :     throw (uno::RuntimeException, std::exception)
    2660             : {
    2661             :     // see SwXTextTable::setData(...) also
    2662             : 
    2663           2 :     SolarMutexGuard aGuard;
    2664           2 :     sal_Int16 nRowCount = getRowCount();
    2665           2 :     sal_Int16 nColCount = getColumnCount();
    2666             : 
    2667           2 :     SwFrmFmt* pFmt = GetFrmFmt();
    2668           2 :     if(pFmt)
    2669             :     {
    2670           2 :         SwTable* pTable = SwTable::FindTable( pFmt );
    2671           2 :         if(pTable->IsTblComplex())
    2672             :         {
    2673           0 :             uno::RuntimeException aRuntime;
    2674           0 :             aRuntime.Message = "Table too complex";
    2675           0 :             throw aRuntime;
    2676             :         }
    2677             : 
    2678           2 :         if(rArray.getLength() != nRowCount)
    2679             :         {
    2680           0 :             throw uno::RuntimeException();
    2681             :         }
    2682           2 :         const uno::Sequence< uno::Any >* pRowArray = rArray.getConstArray();
    2683          14 :         for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++)
    2684             :         {
    2685          12 :             const uno::Sequence< uno::Any >& rColSeq = pRowArray[nRow];
    2686          12 :             if(rColSeq.getLength() != nColCount)
    2687             :             {
    2688           0 :                 throw uno::RuntimeException();
    2689             :             }
    2690          12 :             const uno::Any * pColArray = rColSeq.getConstArray();
    2691          12 :             uno::Reference< table::XCell > xCellRef;
    2692          36 :             for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++)
    2693             :             {
    2694          24 :                 SwXCell* pXCell = lcl_CreateXCell(pFmt, nCol, nRow);
    2695             :                 //! keep (additional) reference to object to prevent implicit destruction
    2696             :                 //! in following UNO calls (when object will get referenced)
    2697          24 :                 xCellRef = pXCell;
    2698          24 :                 SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0;
    2699          24 :                 if(!pBox)
    2700             :                 {
    2701           0 :                     throw uno::RuntimeException();
    2702             :                 }
    2703             :                 else
    2704             :                 {
    2705          24 :                     const uno::Any &rAny = pColArray[nCol];
    2706          24 :                     if (uno::TypeClass_STRING == rAny.getValueTypeClass())
    2707          12 :                         sw_setString( *pXCell, *(OUString *) rAny.getValue() );
    2708             :                     else
    2709             :                     {
    2710          12 :                         double d = 0;
    2711             :                         // #i20067# don't throw exception just do nothing if
    2712             :                         // there is no value set
    2713          12 :                         if( (rAny >>= d) )
    2714          12 :                             sw_setValue( *pXCell, d );
    2715             :                         else
    2716           0 :                             sw_setString( *pXCell, OUString(), sal_True );
    2717             : 
    2718             :                     }
    2719             :                 }
    2720             :             }
    2721          12 :         }
    2722           2 :     }
    2723           2 : }
    2724             : 
    2725           4 : uno::Sequence< uno::Sequence< double > > SwXTextTable::getData(void)
    2726             :                                         throw( uno::RuntimeException, std::exception )
    2727             : {
    2728           4 :     SolarMutexGuard aGuard;
    2729           4 :     sal_Int16 nRowCount = getRowCount();
    2730           4 :     sal_Int16 nColCount = getColumnCount();
    2731           4 :     if(!nRowCount || !nColCount)
    2732             :     {
    2733           0 :         uno::RuntimeException aRuntime;
    2734           0 :         aRuntime.Message = "Table too complex";
    2735           0 :         throw aRuntime;
    2736             :     }
    2737             : 
    2738           4 :     SwFrmFmt* pFmt = GetFrmFmt();
    2739           4 :     uno::Sequence< uno::Sequence< double > > aRowSeq(bFirstRowAsLabel ? nRowCount - 1 : nRowCount);
    2740           4 :     if(pFmt)
    2741             :     {
    2742           4 :         uno::Sequence< double >* pArray = aRowSeq.getArray();
    2743             : 
    2744           4 :         sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
    2745          24 :         for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
    2746             :         {
    2747          20 :             uno::Sequence< double >  aColSeq(bFirstColumnAsLabel ? nColCount - 1 : nColCount);
    2748          20 :             double* pColArray = aColSeq.getArray();
    2749          20 :             sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
    2750          40 :             for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
    2751             :             {
    2752          20 :                 uno::Reference< table::XCell >  xCell = getCellByPosition(nCol, nRow);
    2753          20 :                 if(!xCell.is())
    2754             :                 {
    2755           0 :                     throw uno::RuntimeException();
    2756             :                 }
    2757          20 :                 pColArray[nCol - nColStart] = xCell->getValue();
    2758          20 :             }
    2759          20 :             pArray[nRow - nRowStart] = aColSeq;
    2760          20 :         }
    2761             :     }
    2762             :     else
    2763           0 :         throw uno::RuntimeException();
    2764           4 :     return aRowSeq;
    2765             : }
    2766             : 
    2767           3 : void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData)
    2768             :                                         throw( uno::RuntimeException, std::exception )
    2769             : {
    2770           3 :     SolarMutexGuard aGuard;
    2771           3 :     sal_Int16 nRowCount = getRowCount();
    2772           3 :     sal_Int16 nColCount = getColumnCount();
    2773           3 :     bool bChanged = false;
    2774             : 
    2775           3 :     if(!nRowCount || !nColCount)
    2776             :     {
    2777           0 :         uno::RuntimeException aRuntime;
    2778           0 :         aRuntime.Message = "Table too complex";
    2779           0 :         throw aRuntime;
    2780             :     }
    2781             : 
    2782           3 :     SwFrmFmt* pFmt = GetFrmFmt();
    2783           3 :     if(pFmt )
    2784             :     {
    2785           3 :         sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
    2786           3 :         if(rData.getLength() < nRowCount - nRowStart)
    2787             :         {
    2788           0 :             throw uno::RuntimeException();
    2789             :         }
    2790           3 :         const uno::Sequence< double >* pRowArray = rData.getConstArray();
    2791          18 :         for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
    2792             :         {
    2793          15 :             const uno::Sequence< double >& rColSeq = pRowArray[nRow - nRowStart];
    2794          15 :             sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
    2795          15 :             if(rColSeq.getLength() < nColCount - nColStart)
    2796             :             {
    2797           0 :                 throw uno::RuntimeException();
    2798             :             }
    2799          15 :             const double * pColArray = rColSeq.getConstArray();
    2800          30 :             for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
    2801             :             {
    2802          15 :                 uno::Reference< table::XCell >  xCell = getCellByPosition(nCol, nRow);
    2803          15 :                 if(!xCell.is())
    2804             :                 {
    2805           0 :                     throw uno::RuntimeException();
    2806             :                 }
    2807          15 :                 xCell->setValue(pColArray[nCol - nColStart]);
    2808          15 :                 bChanged=true;
    2809          15 :             }
    2810             :         }
    2811           3 :         if ( bChanged )
    2812             :         {
    2813           3 :             lcl_SendChartEvent(*this, m_pImpl->m_Listeners);
    2814             :         }
    2815           3 :     }
    2816           3 : }
    2817             : 
    2818           3 : uno::Sequence< OUString > SwXTextTable::getRowDescriptions(void) throw( uno::RuntimeException, std::exception )
    2819             : {
    2820           3 :     SolarMutexGuard aGuard;
    2821           3 :     sal_Int16 nRowCount = getRowCount();
    2822           3 :     if(!nRowCount)
    2823             :     {
    2824           0 :         uno::RuntimeException aRuntime;
    2825           0 :         aRuntime.Message = "Table too complex";
    2826           0 :         throw aRuntime;
    2827             :     }
    2828           3 :     uno::Sequence< OUString > aRet(bFirstColumnAsLabel ? nRowCount - 1 : nRowCount);
    2829             : 
    2830           3 :     SwFrmFmt* pFmt = GetFrmFmt();
    2831           3 :     if(pFmt)
    2832             :     {
    2833           3 :         OUString* pArray = aRet.getArray();
    2834           3 :         if(bFirstColumnAsLabel)
    2835             :         {
    2836           3 :             sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
    2837          18 :             for(sal_uInt16 i = nStart; i < nRowCount; i++)
    2838             :             {
    2839          15 :                 uno::Reference< table::XCell >  xCell = getCellByPosition(0, i);
    2840          15 :                 if(!xCell.is())
    2841             :                 {
    2842             :                     //exception ...
    2843           0 :                     break;
    2844             :                 }
    2845          30 :                 uno::Reference< text::XText >  xText(xCell, uno::UNO_QUERY);
    2846          15 :                 pArray[i - nStart] = xText->getString();
    2847          15 :             }
    2848             :         }
    2849             :         else
    2850             :         {
    2851             :             OSL_FAIL("Where do these labels come from?");
    2852             :         }
    2853             :     }
    2854             :     else
    2855           0 :         throw uno::RuntimeException();
    2856           3 :     return aRet;
    2857             : }
    2858             : 
    2859           1 : void SwXTextTable::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc) throw( uno::RuntimeException, std::exception )
    2860             : {
    2861           1 :     SolarMutexGuard aGuard;
    2862           1 :     SwFrmFmt* pFmt = GetFrmFmt();
    2863           1 :     if(pFmt)
    2864             :     {
    2865           1 :         sal_Int16 nRowCount = getRowCount();
    2866           1 :         if(!nRowCount || rRowDesc.getLength() < (bFirstRowAsLabel ? nRowCount - 1 : nRowCount))
    2867             :         {
    2868           0 :             throw uno::RuntimeException();
    2869             :         }
    2870           1 :         const OUString* pArray = rRowDesc.getConstArray();
    2871           1 :         if(bFirstColumnAsLabel)
    2872             :         {
    2873           1 :             sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
    2874           6 :             for(sal_uInt16 i = nStart; i < nRowCount; i++)
    2875             :             {
    2876           5 :                 uno::Reference< table::XCell >  xCell = getCellByPosition(0, i);
    2877           5 :                 if(!xCell.is())
    2878             :                 {
    2879           0 :                     throw uno::RuntimeException();
    2880             :                 }
    2881          10 :                 uno::Reference< text::XText >  xText(xCell, uno::UNO_QUERY);
    2882           5 :                 xText->setString(pArray[i - nStart]);
    2883           5 :             }
    2884             :         }
    2885             :         else
    2886             :         {
    2887             :             OSL_FAIL("Where to put theses labels?");
    2888             :         }
    2889             :     }
    2890             :     else
    2891           0 :         throw uno::RuntimeException();
    2892           1 : }
    2893             : 
    2894           3 : uno::Sequence< OUString > SwXTextTable::getColumnDescriptions(void)
    2895             :                                                 throw( uno::RuntimeException, std::exception )
    2896             : {
    2897           3 :     SolarMutexGuard aGuard;
    2898           3 :     sal_Int16 nColCount = getColumnCount();
    2899           3 :     if(!nColCount)
    2900             :     {
    2901           0 :         uno::RuntimeException aRuntime;
    2902           0 :         aRuntime.Message = "Table too complex";
    2903           0 :         throw aRuntime;
    2904             :     }
    2905           3 :     uno::Sequence< OUString > aRet(bFirstRowAsLabel ? nColCount - 1 : nColCount);
    2906           3 :     SwFrmFmt* pFmt = GetFrmFmt();
    2907           3 :     if(pFmt)
    2908             :     {
    2909           3 :         OUString* pArray = aRet.getArray();
    2910           3 :         if(bFirstRowAsLabel)
    2911             :         {
    2912           3 :             sal_uInt16 nStart = bFirstColumnAsLabel ? 1 : 0;
    2913           6 :             for(sal_uInt16 i = nStart; i < nColCount; i++)
    2914             :             {
    2915           3 :                 uno::Reference< table::XCell >  xCell = getCellByPosition(i, 0);
    2916           3 :                 if(!xCell.is())
    2917             :                 {
    2918           0 :                     throw uno::RuntimeException();
    2919             :                 }
    2920           6 :                 uno::Reference< text::XText >  xText(xCell, uno::UNO_QUERY);
    2921             : 
    2922           3 :                 pArray[i - nStart] = xText->getString();
    2923           3 :             }
    2924             :         }
    2925             :         else
    2926             :         {
    2927             :             OSL_FAIL("Where do these labels come from?");
    2928             :         }
    2929             :     }
    2930             :     else
    2931           0 :         throw uno::RuntimeException();
    2932           3 :     return aRet;
    2933             : }
    2934             : 
    2935           1 : void SwXTextTable::setColumnDescriptions(const uno::Sequence< OUString >& rColumnDesc) throw( uno::RuntimeException, std::exception )
    2936             : {
    2937           1 :     SolarMutexGuard aGuard;
    2938           1 :     sal_Int16 nColCount = getColumnCount();
    2939           1 :     if(!nColCount)
    2940             :     {
    2941           0 :         uno::RuntimeException aRuntime;
    2942           0 :         aRuntime.Message = "Table too complex";
    2943           0 :         throw aRuntime;
    2944             :     }
    2945           1 :     SwFrmFmt* pFmt = GetFrmFmt();
    2946           1 :     if(pFmt)
    2947             :     {
    2948           1 :         const OUString* pArray = rColumnDesc.getConstArray();
    2949           1 :         if(bFirstRowAsLabel && rColumnDesc.getLength() >= nColCount - bFirstColumnAsLabel ? 1 : 0)
    2950             :         {
    2951           1 :             sal_uInt16 nStart = bFirstColumnAsLabel ? 1 : 0;
    2952           2 :             for(sal_uInt16 i = nStart; i < nColCount; i++)
    2953             :             {
    2954           1 :                 uno::Reference< table::XCell >  xCell = getCellByPosition(i, 0);
    2955           1 :                 if(!xCell.is())
    2956             :                 {
    2957           0 :                     throw uno::RuntimeException();
    2958             :                 }
    2959           2 :                 uno::Reference< text::XText >  xText(xCell, uno::UNO_QUERY);
    2960           1 :                 xText->setString(pArray[i - nStart]);
    2961           1 :             }
    2962             :         }
    2963             :         else
    2964             :         {
    2965             :             OSL_FAIL("Where do these labels come from?");
    2966             :         }
    2967             :     }
    2968             :     else
    2969           0 :         throw uno::RuntimeException();
    2970           1 : }
    2971             : 
    2972           2 : void SAL_CALL SwXTextTable::addChartDataChangeEventListener(
    2973             :     const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
    2974             : throw (uno::RuntimeException, std::exception)
    2975             : {
    2976             :     // no need to lock here as m_pImpl is const and container threadsafe
    2977           2 :     m_pImpl->m_Listeners.addInterface(
    2978           4 :             cppu::UnoType<chart::XChartDataChangeEventListener>::get(), xListener);
    2979           2 : }
    2980             : 
    2981           2 : void SAL_CALL SwXTextTable::removeChartDataChangeEventListener(
    2982             :     const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
    2983             : throw (uno::RuntimeException, std::exception)
    2984             : {
    2985             :     // no need to lock here as m_pImpl is const and container threadsafe
    2986           2 :     m_pImpl->m_Listeners.removeInterface(
    2987           4 :             cppu::UnoType<chart::XChartDataChangeEventListener>::get(), xListener);
    2988           2 : }
    2989             : 
    2990           2 : sal_Bool SwXTextTable::isNotANumber(double nNumber) throw( uno::RuntimeException, std::exception )
    2991             : {
    2992             :     // We use DBL_MIN because starcalc does (which uses it because chart
    2993             :     // wants it that way!)
    2994           2 :     return ( nNumber == DBL_MIN );
    2995             : }
    2996             : 
    2997           1 : double SwXTextTable::getNotANumber(void) throw( uno::RuntimeException, std::exception )
    2998             : {
    2999             :     // We use DBL_MIN because starcalc does (which uses it because chart
    3000             :     // wants it that way!)
    3001           1 :     return DBL_MIN;
    3002             : }
    3003             : 
    3004           1 : uno::Sequence< beans::PropertyValue > SwXTextTable::createSortDescriptor(void)
    3005             :     throw( uno::RuntimeException, std::exception )
    3006             : {
    3007           1 :     SolarMutexGuard aGuard;
    3008             : 
    3009           1 :     return SwUnoCursorHelper::CreateSortDescriptor(true);
    3010             : }
    3011             : 
    3012           4 : void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor)
    3013             :     throw (uno::RuntimeException, std::exception)
    3014             : {
    3015           4 :     SolarMutexGuard aGuard;
    3016           8 :     SwSortOptions aSortOpt;
    3017           4 :     SwFrmFmt* pFmt = GetFrmFmt();
    3018           8 :     if(pFmt &&
    3019           4 :         SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt))
    3020             :     {
    3021           4 :         SwTable* pTable = SwTable::FindTable( pFmt );
    3022           4 :         SwSelBoxes aBoxes;
    3023           4 :         const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
    3024          52 :         for (size_t n = 0; n < rTBoxes.size(); ++n)
    3025             :         {
    3026          48 :             SwTableBox* pBox = rTBoxes[ n ];
    3027          48 :             aBoxes.insert( pBox );
    3028             :         }
    3029           8 :         UnoActionContext aContext( pFmt->GetDoc() );
    3030           8 :         pFmt->GetDoc()->SortTbl(aBoxes, aSortOpt);
    3031           4 :     }
    3032           4 : }
    3033             : 
    3034           0 : void SwXTextTable::autoFormat(const OUString& aName)
    3035             :     throw (lang::IllegalArgumentException, uno::RuntimeException,
    3036             :            std::exception)
    3037             : {
    3038           0 :     SolarMutexGuard aGuard;
    3039           0 :     SwFrmFmt* pFmt = GetFrmFmt();
    3040           0 :     if(pFmt)
    3041             :     {
    3042           0 :         SwTable* pTable = SwTable::FindTable( pFmt );
    3043           0 :         if(!pTable->IsTblComplex())
    3044             :         {
    3045             : 
    3046           0 :             OUString sAutoFmtName(aName);
    3047           0 :             SwTableAutoFmtTbl aAutoFmtTbl;
    3048           0 :             aAutoFmtTbl.Load();
    3049           0 :             for (sal_uInt16 i = aAutoFmtTbl.size(); i;)
    3050           0 :                 if( sAutoFmtName == aAutoFmtTbl[ --i ].GetName() )
    3051             :                 {
    3052           0 :                     SwSelBoxes aBoxes;
    3053           0 :                     const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
    3054           0 :                     for (size_t n = 0; n < rTBoxes.size(); ++n)
    3055             :                     {
    3056           0 :                         SwTableBox* pBox = rTBoxes[ n ];
    3057           0 :                         aBoxes.insert( pBox );
    3058             :                     }
    3059           0 :                     UnoActionContext aContext( pFmt->GetDoc() );
    3060           0 :                     pFmt->GetDoc()->SetTableAutoFmt( aBoxes, aAutoFmtTbl[i] );
    3061           0 :                     break;
    3062           0 :                 }
    3063             :         }
    3064             :     }
    3065             :     else
    3066           0 :         throw uno::RuntimeException();
    3067           0 : }
    3068             : 
    3069          57 : uno::Reference< beans::XPropertySetInfo >  SwXTextTable::getPropertySetInfo(void) throw( uno::RuntimeException, std::exception )
    3070             : {
    3071          57 :     static uno::Reference< beans::XPropertySetInfo >  xRef = m_pPropSet->getPropertySetInfo();
    3072          57 :     return xRef;
    3073             : }
    3074             : 
    3075        4971 : void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
    3076             :     throw(beans::UnknownPropertyException, beans::PropertyVetoException,
    3077             :           lang::IllegalArgumentException, lang::WrappedTargetException,
    3078             :           uno::RuntimeException, std::exception)
    3079             : {
    3080        4971 :     SolarMutexGuard aGuard;
    3081        4971 :     SwFrmFmt* pFmt = GetFrmFmt();
    3082        4971 :     if(!aValue.hasValue())
    3083           0 :         throw lang::IllegalArgumentException();
    3084             :     const SfxItemPropertySimpleEntry* pEntry =
    3085        4971 :                                 m_pPropSet->getPropertyMap().getByName(rPropertyName);
    3086        4971 :     if( !pEntry )
    3087        1528 :         throw lang::IllegalArgumentException();
    3088        3443 :     if(pFmt)
    3089             :     {
    3090        3442 :         if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
    3091           4 :             throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
    3092             : 
    3093        3438 :         if(0xFF == pEntry->nMemberId)
    3094             :         {
    3095         920 :             lcl_SetSpecialProperty(pFmt, pEntry, aValue);
    3096             :         }
    3097             :         else
    3098             :         {
    3099        2518 :             switch(pEntry->nWID)
    3100             :             {
    3101             :                 case FN_UNO_TABLE_NAME :
    3102             :                 {
    3103           0 :                     OUString sName;
    3104           0 :                     aValue >>= sName;
    3105           0 :                     setName( sName );
    3106             :                 }
    3107           0 :                 break;
    3108             : 
    3109             :                 case FN_UNO_RANGE_ROW_LABEL:
    3110             :                 {
    3111           7 :                     sal_Bool bTmp = *(sal_Bool*)aValue.getValue();
    3112           7 :                     if(bFirstRowAsLabel != bTmp)
    3113             :                     {
    3114           7 :                         lcl_SendChartEvent(*this, m_pImpl->m_Listeners);
    3115           7 :                         bFirstRowAsLabel = bTmp;
    3116             :                     }
    3117             :                 }
    3118           7 :                 break;
    3119             : 
    3120             :                 case FN_UNO_RANGE_COL_LABEL:
    3121             :                 {
    3122           7 :                     sal_Bool bTmp = *(sal_Bool*)aValue.getValue();
    3123           7 :                     if(bFirstColumnAsLabel != bTmp)
    3124             :                     {
    3125           7 :                         lcl_SendChartEvent(*this, m_pImpl->m_Listeners);
    3126           7 :                         bFirstColumnAsLabel = bTmp;
    3127             :                     }
    3128             :                 }
    3129           7 :                 break;
    3130             : 
    3131             :                 case FN_UNO_TABLE_BORDER:
    3132             :                 case FN_UNO_TABLE_BORDER2:
    3133             :                 {
    3134         388 :                     table::TableBorder oldBorder;
    3135         388 :                     table::TableBorder2 aBorder;
    3136         388 :                     SvxBorderLine aTopLine;
    3137         388 :                     SvxBorderLine aBottomLine;
    3138         388 :                     SvxBorderLine aLeftLine;
    3139         388 :                     SvxBorderLine aRightLine;
    3140         388 :                     SvxBorderLine aHoriLine;
    3141         388 :                     SvxBorderLine aVertLine;
    3142         388 :                     if (aValue >>= oldBorder)
    3143             :                     {
    3144         386 :                         aBorder.IsTopLineValid = oldBorder.IsTopLineValid;
    3145         386 :                         aBorder.IsBottomLineValid = oldBorder.IsBottomLineValid;
    3146         386 :                         aBorder.IsLeftLineValid = oldBorder.IsLeftLineValid;
    3147         386 :                         aBorder.IsRightLineValid = oldBorder.IsRightLineValid;
    3148         386 :                         aBorder.IsHorizontalLineValid = oldBorder.IsHorizontalLineValid;
    3149         386 :                         aBorder.IsVerticalLineValid = oldBorder.IsVerticalLineValid;
    3150         386 :                         aBorder.Distance = oldBorder.Distance;
    3151         386 :                         aBorder.IsDistanceValid = oldBorder.IsDistanceValid;
    3152             :                         lcl_LineToSvxLine(
    3153         386 :                                 oldBorder.TopLine, aTopLine);
    3154             :                         lcl_LineToSvxLine(
    3155         386 :                                 oldBorder.BottomLine, aBottomLine);
    3156             :                         lcl_LineToSvxLine(
    3157         386 :                                 oldBorder.LeftLine, aLeftLine);
    3158             :                         lcl_LineToSvxLine(
    3159         386 :                                 oldBorder.RightLine, aRightLine);
    3160             :                         lcl_LineToSvxLine(
    3161         386 :                                 oldBorder.HorizontalLine, aHoriLine);
    3162             :                         lcl_LineToSvxLine(
    3163         386 :                                 oldBorder.VerticalLine, aVertLine);
    3164             :                     }
    3165           2 :                     else if (aValue >>= aBorder)
    3166             :                     {
    3167             :                         SvxBoxItem::LineToSvxLine(
    3168           2 :                                 aBorder.TopLine, aTopLine, true);
    3169             :                         SvxBoxItem::LineToSvxLine(
    3170           2 :                                 aBorder.BottomLine, aBottomLine, true);
    3171             :                         SvxBoxItem::LineToSvxLine(
    3172           2 :                                 aBorder.LeftLine, aLeftLine, true);
    3173             :                         SvxBoxItem::LineToSvxLine(
    3174           2 :                                 aBorder.RightLine, aRightLine, true);
    3175             :                         SvxBoxItem::LineToSvxLine(
    3176           2 :                                 aBorder.HorizontalLine, aHoriLine, true);
    3177             :                         SvxBoxItem::LineToSvxLine(
    3178           2 :                                 aBorder.VerticalLine, aVertLine, true);
    3179             :                     }
    3180             :                     else
    3181             :                     {
    3182         383 :                         break; // something else
    3183             :                     }
    3184         388 :                     SwDoc* pDoc = pFmt->GetDoc();
    3185         388 :                     SwFrm* pFrm = SwIterator<SwFrm,SwFmt>::FirstElement( *pFmt );
    3186             :                     // tables without layout (invisible header/footer?)
    3187         388 :                     if (!pFrm)
    3188             :                     {
    3189         383 :                         break;
    3190             :                     }
    3191           5 :                     lcl_FormatTable(pFmt);
    3192           5 :                     SwTable* pTable = SwTable::FindTable( pFmt );
    3193           5 :                     SwTableLines &rLines = pTable->GetTabLines();
    3194             : 
    3195             :                     // invalidate all actions
    3196           5 :                     UnoActionRemoveContext aRemoveContext(pDoc);
    3197           5 :                     const SwTableBox* pTLBox = lcl_FindCornerTableBox(rLines, true);
    3198           5 :                     const SwStartNode* pSttNd = pTLBox->GetSttNd();
    3199          10 :                     SwPosition aPos(*pSttNd);
    3200             :                     // set cursor to top left cell
    3201           5 :                     SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(aPos, true);
    3202           5 :                     pUnoCrsr->Move( fnMoveForward, fnGoNode );
    3203           5 :                     pUnoCrsr->SetRemainInSection( sal_False );
    3204             : 
    3205           5 :                     const SwTableBox* pBRBox = lcl_FindCornerTableBox(rLines, false);
    3206           5 :                     pUnoCrsr->SetMark();
    3207           5 :                     pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd();
    3208           5 :                     pUnoCrsr->Move( fnMoveForward, fnGoNode );
    3209           5 :                     SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    3210           5 :                     pCrsr->MakeBoxSels();
    3211             : 
    3212           5 :                     SfxItemSet aSet(pDoc->GetAttrPool(),
    3213             :                                     RES_BOX, RES_BOX,
    3214             :                                     SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
    3215          10 :                                     0);
    3216             : 
    3217          10 :                     SvxBoxItem aBox( RES_BOX );
    3218          10 :                     SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
    3219             : 
    3220           5 :                     aBox.SetLine(aTopLine.isEmpty() ? 0 : &aTopLine, BOX_LINE_TOP);
    3221           5 :                     aBoxInfo.SetValid(VALID_TOP, aBorder.IsTopLineValid);
    3222             : 
    3223           5 :                     aBox.SetLine(aBottomLine.isEmpty() ? 0 : &aBottomLine, BOX_LINE_BOTTOM);
    3224           5 :                     aBoxInfo.SetValid(VALID_BOTTOM, aBorder.IsBottomLineValid);
    3225             : 
    3226           5 :                     aBox.SetLine(aLeftLine.isEmpty() ? 0 : &aLeftLine, BOX_LINE_LEFT);
    3227           5 :                     aBoxInfo.SetValid(VALID_LEFT, aBorder.IsLeftLineValid);
    3228             : 
    3229           5 :                     aBox.SetLine(aRightLine.isEmpty() ? 0 : &aRightLine, BOX_LINE_RIGHT);
    3230           5 :                     aBoxInfo.SetValid(VALID_RIGHT, aBorder.IsRightLineValid);
    3231             : 
    3232           5 :                     aBoxInfo.SetLine(aHoriLine.isEmpty() ? 0 : &aHoriLine, BOXINFO_LINE_HORI);
    3233           5 :                     aBoxInfo.SetValid(VALID_HORI, aBorder.IsHorizontalLineValid);
    3234             : 
    3235           5 :                     aBoxInfo.SetLine(aVertLine.isEmpty() ? 0 : &aVertLine, BOXINFO_LINE_VERT);
    3236           5 :                     aBoxInfo.SetValid(VALID_VERT, aBorder.IsVerticalLineValid);
    3237             : 
    3238           5 :                     aBox.SetDistance((sal_uInt16)MM100_TO_TWIP(aBorder.Distance));
    3239           5 :                     aBoxInfo.SetValid(VALID_DISTANCE, aBorder.IsDistanceValid);
    3240             : 
    3241           5 :                     aSet.Put(aBox);
    3242           5 :                     aSet.Put(aBoxInfo);
    3243             : 
    3244           5 :                     pDoc->SetTabBorders(*pCrsr, aSet);
    3245          10 :                     delete pUnoCrsr;
    3246             :                 }
    3247           5 :                 break;
    3248             : 
    3249             :                 case FN_UNO_TABLE_BORDER_DISTANCES:
    3250             :                 {
    3251         383 :                     table::TableBorderDistances aTableBorderDistances;
    3252         766 :                     if( !(aValue >>= aTableBorderDistances) ||
    3253         383 :                         (!aTableBorderDistances.IsLeftDistanceValid &&
    3254           0 :                         !aTableBorderDistances.IsRightDistanceValid &&
    3255           0 :                         !aTableBorderDistances.IsTopDistanceValid &&
    3256           0 :                         !aTableBorderDistances.IsBottomDistanceValid ))
    3257           0 :                         break;
    3258             : 
    3259         383 :                     sal_uInt16 nLeftDistance =     MM100_TO_TWIP_UNSIGNED( aTableBorderDistances.LeftDistance);
    3260         383 :                     sal_uInt16 nRightDistance =    MM100_TO_TWIP_UNSIGNED( aTableBorderDistances.RightDistance);
    3261         383 :                     sal_uInt16 nTopDistance =      MM100_TO_TWIP_UNSIGNED( aTableBorderDistances.TopDistance);
    3262         383 :                     sal_uInt16 nBottomDistance =   MM100_TO_TWIP_UNSIGNED( aTableBorderDistances.BottomDistance);
    3263         383 :                     SwDoc* pDoc = pFmt->GetDoc();
    3264         383 :                     SwTable* pTable = SwTable::FindTable( pFmt );
    3265         383 :                     SwTableLines &rLines = pTable->GetTabLines();
    3266         383 :                     pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_START, NULL);
    3267        2561 :                     for(sal_uInt16 i = 0; i < rLines.size(); i++)
    3268             :                     {
    3269        2178 :                         SwTableLine* pLine = rLines[i];
    3270        2178 :                         SwTableBoxes& rBoxes = pLine->GetTabBoxes();
    3271        8871 :                         for(sal_uInt16 k = 0; k < rBoxes.size(); k++)
    3272             :                         {
    3273        6693 :                             SwTableBox* pBox = rBoxes[k];
    3274        6693 :                             const SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
    3275        6693 :                             const SvxBoxItem& rBox = pBoxFmt->GetBox();
    3276        6693 :                             if(
    3277        6693 :                                 (aTableBorderDistances.IsLeftDistanceValid && nLeftDistance !=   rBox.GetDistance( BOX_LINE_LEFT )) ||
    3278         486 :                                 (aTableBorderDistances.IsRightDistanceValid && nRightDistance !=  rBox.GetDistance( BOX_LINE_RIGHT )) ||
    3279       13386 :                                 (aTableBorderDistances.IsTopDistanceValid && nTopDistance !=    rBox.GetDistance( BOX_LINE_TOP )) ||
    3280         426 :                                 (aTableBorderDistances.IsBottomDistanceValid && nBottomDistance != rBox.GetDistance( BOX_LINE_BOTTOM )))
    3281             :                             {
    3282        6267 :                                 SvxBoxItem aSetBox( rBox );
    3283        6267 :                                 SwFrmFmt* pSetBoxFmt = pBox->ClaimFrmFmt();
    3284        6267 :                                 if( aTableBorderDistances.IsLeftDistanceValid )
    3285        6267 :                                     aSetBox.SetDistance( nLeftDistance, BOX_LINE_LEFT );
    3286        6267 :                                 if( aTableBorderDistances.IsRightDistanceValid )
    3287        6267 :                                     aSetBox.SetDistance( nRightDistance, BOX_LINE_RIGHT );
    3288        6267 :                                 if( aTableBorderDistances.IsTopDistanceValid )
    3289        6267 :                                     aSetBox.SetDistance( nTopDistance, BOX_LINE_TOP );
    3290        6267 :                                 if( aTableBorderDistances.IsBottomDistanceValid )
    3291        6267 :                                     aSetBox.SetDistance( nBottomDistance, BOX_LINE_BOTTOM );
    3292        6267 :                                 pDoc->SetAttr( aSetBox, *pSetBoxFmt );
    3293             :                             }
    3294             :                         }
    3295             :                     }
    3296         383 :                     pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL);
    3297             :                 }
    3298         383 :                 break;
    3299             : 
    3300             :                 case FN_UNO_TABLE_COLUMN_SEPARATORS:
    3301             :                 {
    3302           1 :                     UnoActionContext aContext(pFmt->GetDoc());
    3303           1 :                     SwTable* pTable = SwTable::FindTable( pFmt );
    3304           1 :                     lcl_SetTblSeparators(aValue, pTable, pTable->GetTabLines()[0]->GetTabBoxes()[0], sal_False, pFmt->GetDoc());
    3305             :                 }
    3306           1 :                 break;
    3307             : 
    3308           0 :                 case FN_UNO_TABLE_COLUMN_RELATIVE_SUM:/*_readonly_*/ break;
    3309             : 
    3310             :                 default:
    3311             :                 {
    3312        1732 :                     SwAttrSet aSet(pFmt->GetAttrSet());
    3313        1732 :                     m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
    3314        1732 :                     pFmt->GetDoc()->SetAttr(aSet, *pFmt);
    3315             :                 }
    3316             :             }
    3317             :         }
    3318             :     }
    3319           1 :     else if(bIsDescriptor)
    3320             :     {
    3321           1 :         pTableProps->SetProperty( pEntry->nWID, pEntry->nMemberId, aValue);
    3322             :     }
    3323             :     else
    3324           0 :         throw uno::RuntimeException();
    3325        3413 : }
    3326             : 
    3327         240 : uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
    3328             :     throw (beans::UnknownPropertyException,
    3329             :            lang::WrappedTargetException,
    3330             :            uno::RuntimeException,
    3331             :            std::exception)
    3332             : {
    3333         240 :     SolarMutexGuard aGuard;
    3334         240 :     uno::Any aRet;
    3335         240 :     SwFrmFmt* pFmt = GetFrmFmt();
    3336             :     const SfxItemPropertySimpleEntry* pEntry =
    3337         240 :                                 m_pPropSet->getPropertyMap().getByName(rPropertyName);
    3338             : 
    3339         240 :     if (!pEntry)
    3340           0 :         throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
    3341             : 
    3342         240 :     if(pFmt)
    3343             :     {
    3344         240 :         if(0xFF == pEntry->nMemberId)
    3345             :         {
    3346         178 :             aRet = lcl_GetSpecialProperty(pFmt, pEntry );
    3347             :         }
    3348             :         else
    3349             :         {
    3350          62 :             switch(pEntry->nWID)
    3351             :             {
    3352             :                 case FN_UNO_TABLE_NAME:
    3353             :                 {
    3354           0 :                     aRet <<= getName();
    3355             :                 }
    3356           0 :                 break;
    3357             : 
    3358             :                 case  FN_UNO_ANCHOR_TYPES:
    3359             :                 case  FN_UNO_TEXT_WRAP:
    3360             :                 case  FN_UNO_ANCHOR_TYPE:
    3361             :                     ::sw::GetDefaultTextContentValue(
    3362           4 :                             aRet, OUString(), pEntry->nWID);
    3363           4 :                 break;
    3364             : 
    3365             :                 case FN_UNO_RANGE_ROW_LABEL:
    3366             :                 {
    3367           3 :                     sal_Bool bTemp = bFirstRowAsLabel;
    3368           3 :                     aRet.setValue(&bTemp, ::getCppuBooleanType());
    3369             :                 }
    3370           3 :                 break;
    3371             : 
    3372             :                 case FN_UNO_RANGE_COL_LABEL:
    3373             :                 {
    3374           3 :                     sal_Bool bTemp = bFirstColumnAsLabel;
    3375           3 :                     aRet.setValue(&bTemp, ::getCppuBooleanType());
    3376             :                 }
    3377           3 :                 break;
    3378             : 
    3379             :                 case FN_UNO_TABLE_BORDER:
    3380             :                 case FN_UNO_TABLE_BORDER2:
    3381             :                 {
    3382          14 :                     SwDoc* pDoc = pFmt->GetDoc();
    3383          14 :                     SwFrm* pFrm = SwIterator<SwFrm,SwFmt>::FirstElement( *pFmt );
    3384             :                     // tables without layout (invisible header/footer?)
    3385          14 :                     if (!pFrm)
    3386             :                     {
    3387           0 :                         break;
    3388             :                     }
    3389          14 :                     lcl_FormatTable(pFmt);
    3390          14 :                     SwTable* pTable = SwTable::FindTable( pFmt );
    3391          14 :                     SwTableLines &rLines = pTable->GetTabLines();
    3392             : 
    3393             :                     // invalidate all actions
    3394          14 :                     UnoActionRemoveContext aRemoveContext(pDoc);
    3395          14 :                     const SwTableBox* pTLBox = lcl_FindCornerTableBox(rLines, true);
    3396          14 :                     const SwStartNode* pSttNd = pTLBox->GetSttNd();
    3397          28 :                     SwPosition aPos(*pSttNd);
    3398             :                     // set cursor to top left cell
    3399          14 :                     SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(aPos, true);
    3400          14 :                     pUnoCrsr->Move( fnMoveForward, fnGoNode );
    3401          14 :                     pUnoCrsr->SetRemainInSection( sal_False );
    3402             : 
    3403          14 :                     const SwTableBox* pBRBox = lcl_FindCornerTableBox(rLines, false);
    3404          14 :                     pUnoCrsr->SetMark();
    3405          14 :                     const SwStartNode* pLastNd = pBRBox->GetSttNd();
    3406          14 :                     pUnoCrsr->GetPoint()->nNode = *pLastNd;
    3407             : 
    3408          14 :                     pUnoCrsr->Move( fnMoveForward, fnGoNode );
    3409          14 :                     SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    3410          14 :                     pCrsr->MakeBoxSels();
    3411             : 
    3412          14 :                     SfxItemSet aSet(pDoc->GetAttrPool(),
    3413             :                                     RES_BOX, RES_BOX,
    3414             :                                     SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
    3415          28 :                                     0);
    3416          14 :                     aSet.Put(SvxBoxInfoItem( SID_ATTR_BORDER_INNER ));
    3417          14 :                     pDoc->GetTabBorders(*pCrsr, aSet);
    3418             :                     const SvxBoxInfoItem& rBoxInfoItem =
    3419          14 :                         (const SvxBoxInfoItem&)aSet.Get(SID_ATTR_BORDER_INNER);
    3420          14 :                     const SvxBoxItem& rBox = (const SvxBoxItem&)aSet.Get(RES_BOX);
    3421             : 
    3422          14 :                     if (FN_UNO_TABLE_BORDER == pEntry->nWID)
    3423             :                     {
    3424           7 :                         table::TableBorder aTableBorder;
    3425           7 :                         aTableBorder.TopLine                = SvxBoxItem::SvxLineToLine(rBox.GetTop(), true);
    3426           7 :                         aTableBorder.IsTopLineValid         = rBoxInfoItem.IsValid(VALID_TOP);
    3427           7 :                         aTableBorder.BottomLine             = SvxBoxItem::SvxLineToLine(rBox.GetBottom(), true);
    3428           7 :                         aTableBorder.IsBottomLineValid      = rBoxInfoItem.IsValid(VALID_BOTTOM);
    3429           7 :                         aTableBorder.LeftLine               = SvxBoxItem::SvxLineToLine(rBox.GetLeft(), true);
    3430           7 :                         aTableBorder.IsLeftLineValid        = rBoxInfoItem.IsValid(VALID_LEFT);
    3431           7 :                         aTableBorder.RightLine              = SvxBoxItem::SvxLineToLine(rBox.GetRight(), true);
    3432           7 :                         aTableBorder.IsRightLineValid       = rBoxInfoItem.IsValid(VALID_RIGHT );
    3433           7 :                         aTableBorder.HorizontalLine         = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetHori(), true);
    3434           7 :                         aTableBorder.IsHorizontalLineValid  = rBoxInfoItem.IsValid(VALID_HORI);
    3435           7 :                         aTableBorder.VerticalLine           = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetVert(), true);
    3436           7 :                         aTableBorder.IsVerticalLineValid    = rBoxInfoItem.IsValid(VALID_VERT);
    3437           7 :                         aTableBorder.Distance               = TWIP_TO_MM100_UNSIGNED( rBox.GetDistance() );
    3438           7 :                         aTableBorder.IsDistanceValid        = rBoxInfoItem.IsValid(VALID_DISTANCE);
    3439           7 :                         aRet <<= aTableBorder;
    3440             :                     }
    3441             :                     else
    3442             :                     {
    3443           7 :                         table::TableBorder2 aTableBorder;
    3444           7 :                         aTableBorder.TopLine                = SvxBoxItem::SvxLineToLine(rBox.GetTop(), true);
    3445           7 :                         aTableBorder.IsTopLineValid         = rBoxInfoItem.IsValid(VALID_TOP);
    3446           7 :                         aTableBorder.BottomLine             = SvxBoxItem::SvxLineToLine(rBox.GetBottom(), true);
    3447           7 :                         aTableBorder.IsBottomLineValid      = rBoxInfoItem.IsValid(VALID_BOTTOM);
    3448           7 :                         aTableBorder.LeftLine               = SvxBoxItem::SvxLineToLine(rBox.GetLeft(), true);
    3449           7 :                         aTableBorder.IsLeftLineValid        = rBoxInfoItem.IsValid(VALID_LEFT);
    3450           7 :                         aTableBorder.RightLine              = SvxBoxItem::SvxLineToLine(rBox.GetRight(), true);
    3451           7 :                         aTableBorder.IsRightLineValid       = rBoxInfoItem.IsValid(VALID_RIGHT );
    3452           7 :                         aTableBorder.HorizontalLine         = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetHori(), true);
    3453           7 :                         aTableBorder.IsHorizontalLineValid  = rBoxInfoItem.IsValid(VALID_HORI);
    3454           7 :                         aTableBorder.VerticalLine           = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetVert(), true);
    3455           7 :                         aTableBorder.IsVerticalLineValid    = rBoxInfoItem.IsValid(VALID_VERT);
    3456           7 :                         aTableBorder.Distance               = TWIP_TO_MM100_UNSIGNED( rBox.GetDistance() );
    3457           7 :                         aTableBorder.IsDistanceValid        = rBoxInfoItem.IsValid(VALID_DISTANCE);
    3458           7 :                         aRet <<= aTableBorder;
    3459             :                     }
    3460          28 :                     delete pUnoCrsr;
    3461             :                 }
    3462          14 :                 break;
    3463             : 
    3464             :                 case FN_UNO_TABLE_BORDER_DISTANCES :
    3465             :                 {
    3466           0 :                     table::TableBorderDistances aTableBorderDistances( 0, sal_True, 0, sal_True, 0, sal_True, 0, sal_True ) ;
    3467           0 :                     SwTable* pTable = SwTable::FindTable( pFmt );
    3468           0 :                     const SwTableLines &rLines = pTable->GetTabLines();
    3469           0 :                     bool bFirst = true;
    3470           0 :                     sal_uInt16 nLeftDistance = 0;
    3471           0 :                     sal_uInt16 nRightDistance = 0;
    3472           0 :                     sal_uInt16 nTopDistance = 0;
    3473           0 :                     sal_uInt16 nBottomDistance = 0;
    3474             : 
    3475           0 :                     for(sal_uInt16 i = 0; i < rLines.size(); i++)
    3476             :                     {
    3477           0 :                         const SwTableLine* pLine = rLines[i];
    3478           0 :                         const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
    3479           0 :                         for(sal_uInt16 k = 0; k < rBoxes.size(); k++)
    3480             :                         {
    3481           0 :                             const SwTableBox* pBox = rBoxes[k];
    3482           0 :                             SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
    3483           0 :                             const SvxBoxItem& rBox = pBoxFmt->GetBox();
    3484           0 :                             if( bFirst )
    3485             :                             {
    3486           0 :                                 nLeftDistance =     TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_LEFT   ));
    3487           0 :                                 nRightDistance =    TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_RIGHT  ));
    3488           0 :                                 nTopDistance =      TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_TOP    ));
    3489           0 :                                 nBottomDistance =   TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_BOTTOM ));
    3490           0 :                                 bFirst = false;
    3491             :                             }
    3492             :                             else
    3493             :                             {
    3494           0 :                                 if( aTableBorderDistances.IsLeftDistanceValid &&
    3495           0 :                                     nLeftDistance != TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_LEFT   )))
    3496           0 :                                     aTableBorderDistances.IsLeftDistanceValid = sal_False;
    3497           0 :                                 if( aTableBorderDistances.IsRightDistanceValid &&
    3498           0 :                                     nRightDistance != TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_RIGHT   )))
    3499           0 :                                     aTableBorderDistances.IsRightDistanceValid = sal_False;
    3500           0 :                                 if( aTableBorderDistances.IsTopDistanceValid &&
    3501           0 :                                     nTopDistance != TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_TOP   )))
    3502           0 :                                     aTableBorderDistances.IsTopDistanceValid = sal_False;
    3503           0 :                                 if( aTableBorderDistances.IsBottomDistanceValid &&
    3504           0 :                                     nBottomDistance != TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_BOTTOM   )))
    3505           0 :                                     aTableBorderDistances.IsBottomDistanceValid = sal_False;
    3506             :                             }
    3507             : 
    3508             :                         }
    3509           0 :                         if( !aTableBorderDistances.IsLeftDistanceValid &&
    3510           0 :                                 !aTableBorderDistances.IsRightDistanceValid &&
    3511           0 :                                 !aTableBorderDistances.IsTopDistanceValid &&
    3512           0 :                                 !aTableBorderDistances.IsBottomDistanceValid )
    3513           0 :                             break;
    3514             :                     }
    3515           0 :                     if( aTableBorderDistances.IsLeftDistanceValid)
    3516           0 :                         aTableBorderDistances.LeftDistance = nLeftDistance;
    3517           0 :                     if( aTableBorderDistances.IsRightDistanceValid)
    3518           0 :                         aTableBorderDistances.RightDistance  = nRightDistance;
    3519           0 :                     if( aTableBorderDistances.IsTopDistanceValid)
    3520           0 :                         aTableBorderDistances.TopDistance    = nTopDistance;
    3521           0 :                     if( aTableBorderDistances.IsBottomDistanceValid)
    3522           0 :                         aTableBorderDistances.BottomDistance = nBottomDistance;
    3523             : 
    3524           0 :                     aRet <<= aTableBorderDistances;
    3525             :                 }
    3526           0 :                 break;
    3527             : 
    3528             :                 case FN_UNO_TABLE_COLUMN_SEPARATORS:
    3529             :                 {
    3530           2 :                     SwTable* pTable = SwTable::FindTable( pFmt );
    3531           2 :                     lcl_GetTblSeparators(aRet, pTable, pTable->GetTabLines()[0]->GetTabBoxes()[0], sal_False);
    3532             :                 }
    3533           2 :                 break;
    3534             : 
    3535             :                 case FN_UNO_TABLE_COLUMN_RELATIVE_SUM:
    3536           2 :                     aRet <<= (sal_Int16) UNO_TABLE_COLUMN_SUM;
    3537           2 :                 break;
    3538             : 
    3539             :                 case RES_ANCHOR:
    3540             :                     // AnchorType is readonly and might be void (no return value)
    3541           0 :                 break;
    3542             : 
    3543             :                 case FN_UNO_TEXT_SECTION:
    3544             :                 {
    3545           0 :                     SwTable* pTable = SwTable::FindTable( pFmt );
    3546           0 :                     SwTableNode* pTblNode = pTable->GetTableNode();
    3547           0 :                     SwSectionNode* pSectionNode =  pTblNode->FindSectionNode();
    3548           0 :                     if(pSectionNode)
    3549             :                     {
    3550           0 :                         const SwSection& rSect = pSectionNode->GetSection();
    3551             :                         uno::Reference< text::XTextSection >  xSect =
    3552           0 :                                         SwXTextSections::GetObject( *rSect.GetFmt() );
    3553           0 :                         aRet <<= xSect;
    3554             :                     }
    3555             :                 }
    3556           0 :                 break;
    3557             : 
    3558             :                 default:
    3559             :                 {
    3560          34 :                     const SwAttrSet& rSet = pFmt->GetAttrSet();
    3561          34 :                     m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
    3562             :                 }
    3563             :             }
    3564             :         }
    3565             :     }
    3566           0 :     else if(bIsDescriptor)
    3567             :     {
    3568           0 :         const uno::Any* pAny = 0;
    3569           0 :         if(!pTableProps->GetProperty(pEntry->nWID, pEntry->nMemberId, pAny))
    3570           0 :             throw lang::IllegalArgumentException();
    3571           0 :         else if(pAny)
    3572           0 :             aRet = *pAny;
    3573             :     }
    3574             :     else
    3575           0 :         throw uno::RuntimeException();
    3576         240 :     return aRet;
    3577             : }
    3578             : 
    3579           0 : void SwXTextTable::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    3580             : {
    3581             :     OSL_FAIL("not implemented");
    3582           0 : }
    3583             : 
    3584           0 : void SwXTextTable::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    3585             : {
    3586             :     OSL_FAIL("not implemented");
    3587           0 : }
    3588             : 
    3589           0 : void SwXTextTable::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    3590             : {
    3591             :     OSL_FAIL("not implemented");
    3592           0 : }
    3593             : 
    3594           0 : void SwXTextTable::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    3595             : {
    3596             :     OSL_FAIL("not implemented");
    3597           0 : }
    3598             : 
    3599           3 : OUString SwXTextTable::getName(void) throw( uno::RuntimeException, std::exception )
    3600             : {
    3601           3 :     SolarMutexGuard aGuard;
    3602           3 :     SwFrmFmt* pFmt = GetFrmFmt();
    3603           3 :     if(!pFmt && !bIsDescriptor)
    3604           0 :         throw uno::RuntimeException();
    3605           3 :     if(pFmt)
    3606             :     {
    3607           3 :         return pFmt->GetName();
    3608             :     }
    3609           0 :     return m_sTableName;
    3610             : }
    3611             : 
    3612           4 : void SwXTextTable::setName(const OUString& rName) throw( uno::RuntimeException, std::exception )
    3613             : {
    3614           4 :     SolarMutexGuard aGuard;
    3615           4 :     SwFrmFmt* pFmt = GetFrmFmt();
    3616          10 :     if((!pFmt && !bIsDescriptor) ||
    3617           8 :        rName.isEmpty() ||
    3618          12 :        rName.indexOf('.')>=0 ||
    3619           4 :        rName.indexOf(' ')>=0 )
    3620           0 :         throw uno::RuntimeException();
    3621             : 
    3622           4 :     if(pFmt)
    3623             :     {
    3624           2 :         const OUString aOldName( pFmt->GetName() );
    3625             :         SwFrmFmt* pTmpFmt;
    3626           2 :         const SwFrmFmts* pTbl = pFmt->GetDoc()->GetTblFrmFmts();
    3627           6 :         for( sal_uInt16 i = pTbl->size(); i; )
    3628          12 :             if( !( pTmpFmt = (*pTbl)[ --i ] )->IsDefault() &&
    3629          12 :                 pTmpFmt->GetName() == rName &&
    3630           0 :                             pFmt->GetDoc()->IsUsed( *pTmpFmt ))
    3631             :             {
    3632           0 :                 throw uno::RuntimeException();
    3633             :             }
    3634             : 
    3635           2 :         pFmt->SetName( rName );
    3636             : 
    3637             :         SwStartNode *pStNd;
    3638           4 :         SwNodeIndex aIdx( *pFmt->GetDoc()->GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
    3639           4 :         while ( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
    3640             :         {
    3641           0 :             ++aIdx;
    3642           0 :             SwNode *const pNd = & aIdx.GetNode();
    3643           0 :             if ( pNd->IsOLENode() &&
    3644           0 :                 aOldName == ((SwOLENode*)pNd)->GetChartTblName() )
    3645             :             {
    3646           0 :                 ((SwOLENode*)pNd)->SetChartTblName( rName );
    3647             : 
    3648           0 :                 ((SwOLENode*)pNd)->GetOLEObj();
    3649             : 
    3650           0 :                 SwTable* pTable = SwTable::FindTable( pFmt );
    3651             :                 //TL_CHART2: chart needs to be notfied about name changes
    3652           0 :                 pFmt->GetDoc()->UpdateCharts( pTable->GetFrmFmt()->GetName() );
    3653             :             }
    3654           0 :             aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
    3655             :         }
    3656           4 :         pFmt->GetDoc()->SetModified();
    3657             :     }
    3658             :     else
    3659           2 :         m_sTableName = rName;
    3660           4 : }
    3661             : 
    3662          15 : sal_uInt16 SwXTextTable::getRowCount(void)
    3663             : {
    3664          15 :     SolarMutexGuard aGuard;
    3665          15 :     sal_Int16 nRet = 0;
    3666          15 :     SwFrmFmt* pFmt = GetFrmFmt();
    3667          15 :     if(pFmt)
    3668             :     {
    3669          15 :         SwTable* pTable = SwTable::FindTable( pFmt );
    3670          15 :         if(!pTable->IsTblComplex())
    3671             :         {
    3672          15 :             nRet = pTable->GetTabLines().size();
    3673             :         }
    3674             :     }
    3675          15 :     return nRet;
    3676             : }
    3677             : 
    3678          15 : sal_uInt16 SwXTextTable::getColumnCount(void)
    3679             : {
    3680          15 :     SolarMutexGuard aGuard;
    3681          15 :     SwFrmFmt* pFmt = GetFrmFmt();
    3682          15 :     sal_Int16 nRet = 0;
    3683          15 :     if(pFmt)
    3684             :     {
    3685          15 :         SwTable* pTable = SwTable::FindTable( pFmt );
    3686          15 :         if(!pTable->IsTblComplex())
    3687             :         {
    3688          15 :             SwTableLines& rLines = pTable->GetTabLines();
    3689          15 :             SwTableLine* pLine = rLines.front();
    3690          15 :             nRet = pLine->GetTabBoxes().size();
    3691             :         }
    3692             :     }
    3693          15 :     return nRet;
    3694             : }
    3695             : 
    3696        2327 : void SwXTextTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
    3697             : {
    3698        2364 :     if(pOld && pOld->Which() == RES_REMOVE_UNO_OBJECT &&
    3699          37 :         (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject )
    3700          37 :             ((SwModify*)GetRegisteredIn())->Remove(this);
    3701             :     else
    3702        2290 :         ClientModify(this, pOld, pNew);
    3703        2327 :     if(!GetRegisteredIn())
    3704             :     {
    3705          37 :         lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
    3706          37 :         m_pImpl->m_Listeners.disposeAndClear(ev);
    3707             :     }
    3708             :     else
    3709             :     {
    3710        2290 :         lcl_SendChartEvent(*this, m_pImpl->m_Listeners);
    3711             :     }
    3712        2327 : }
    3713             : 
    3714           0 : OUString SAL_CALL SwXTextTable::getImplementationName(void) throw( uno::RuntimeException, std::exception )
    3715             : {
    3716           0 :     return OUString("SwXTextTable");
    3717             : }
    3718             : 
    3719          28 : sal_Bool SwXTextTable::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
    3720             : {
    3721          28 :     return cppu::supportsService(this, rServiceName);
    3722             : }
    3723             : 
    3724          28 : uno::Sequence< OUString > SwXTextTable::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
    3725             : {
    3726          28 :     uno::Sequence< OUString > aRet(4);
    3727          28 :     OUString* pArr = aRet.getArray();
    3728          28 :     pArr[0] = "com.sun.star.document.LinkTarget";
    3729          28 :     pArr[1] = "com.sun.star.text.TextTable";
    3730          28 :     pArr[2] = "com.sun.star.text.TextContent";
    3731          28 :     pArr[2] = "com.sun.star.text.TextSortable";
    3732          28 :     return aRet;
    3733             : }
    3734             : 
    3735             : namespace
    3736             : {
    3737             :     class theSwXCellRangeUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXCellRangeUnoTunnelId > {};
    3738             : }
    3739             : 
    3740           0 : const uno::Sequence< sal_Int8 > & SwXCellRange::getUnoTunnelId()
    3741             : {
    3742           0 :     return theSwXCellRangeUnoTunnelId::get().getSeq();
    3743             : }
    3744             : 
    3745           0 : sal_Int64 SAL_CALL SwXCellRange::getSomething( const uno::Sequence< sal_Int8 >& rId )
    3746             :     throw(uno::RuntimeException, std::exception)
    3747             : {
    3748           0 :     if( rId.getLength() == 16
    3749           0 :         && 0 == memcmp( getUnoTunnelId().getConstArray(),
    3750           0 :                                         rId.getConstArray(), 16 ) )
    3751             :     {
    3752           0 :         return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
    3753             :     }
    3754           0 :     return 0;
    3755             : }
    3756             : 
    3757         444 : TYPEINIT1(SwXCellRange, SwClient);
    3758             : 
    3759           3 : OUString SwXCellRange::getImplementationName(void) throw( uno::RuntimeException, std::exception )
    3760             : {
    3761           3 :     return OUString("SwXCellRange");
    3762             : }
    3763             : 
    3764           5 : sal_Bool SwXCellRange::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
    3765             : {
    3766           5 :     return cppu::supportsService(this, rServiceName);
    3767             : }
    3768             : 
    3769           5 : uno::Sequence< OUString > SwXCellRange::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
    3770             : {
    3771           5 :     uno::Sequence< OUString > aRet(7);
    3772           5 :     OUString* pArray = aRet.getArray();
    3773           5 :     pArray[0] = "com.sun.star.text.CellRange";
    3774           5 :     pArray[1] = "com.sun.star.style.CharacterProperties";
    3775           5 :     pArray[2] = "com.sun.star.style.CharacterPropertiesAsian";
    3776           5 :     pArray[3] = "com.sun.star.style.CharacterPropertiesComplex";
    3777           5 :     pArray[4] = "com.sun.star.style.ParagraphProperties";
    3778           5 :     pArray[5] = "com.sun.star.style.ParagraphPropertiesAsian";
    3779           5 :     pArray[6] = "com.sun.star.style.ParagraphPropertiesComplex";
    3780           5 :     return aRet;
    3781             : }
    3782             : 
    3783           7 : SwXCellRange::SwXCellRange(SwUnoCrsr* pCrsr, SwFrmFmt& rFrmFmt,
    3784             :     SwRangeDescriptor& rDesc)
    3785             :     : SwClient(&rFrmFmt)
    3786             :     , aCursorDepend(this, pCrsr)
    3787             :     , m_ChartListeners(m_Mutex)
    3788             :     ,
    3789             :     aRgDesc(rDesc),
    3790           7 :     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_RANGE)),
    3791             :     pTblCrsr(pCrsr),
    3792             :     bFirstRowAsLabel(sal_False),
    3793          14 :     bFirstColumnAsLabel(sal_False)
    3794             : {
    3795           7 :     aRgDesc.Normalize();
    3796           7 : }
    3797             : 
    3798          21 : SwXCellRange::~SwXCellRange()
    3799             : {
    3800           7 :     SolarMutexGuard aGuard;
    3801           7 :     delete pTblCrsr;
    3802          14 : }
    3803             : 
    3804          62 : uno::Reference< table::XCell >  SwXCellRange::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
    3805             :     throw( uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception )
    3806             : {
    3807          62 :     SolarMutexGuard aGuard;
    3808          62 :     uno::Reference< table::XCell >  aRet;
    3809          62 :     SwFrmFmt* pFmt = GetFrmFmt();
    3810          62 :     if(pFmt)
    3811             :     {
    3812         184 :         if(nColumn >= 0 && nRow >= 0 &&
    3813         184 :              getColumnCount() > nColumn && getRowCount() > nRow )
    3814             :         {
    3815             :             SwXCell* pXCell = lcl_CreateXCell(pFmt,
    3816          61 :                     aRgDesc.nLeft + nColumn, aRgDesc.nTop + nRow);
    3817          61 :             if(pXCell)
    3818          61 :                 aRet = pXCell;
    3819             :         }
    3820             :     }
    3821          62 :     if(!aRet.is())
    3822           1 :         throw lang::IndexOutOfBoundsException();
    3823          62 :     return aRet;
    3824             : }
    3825             : 
    3826           3 : uno::Reference< table::XCellRange >  SwXCellRange::getCellRangeByPosition(
    3827             :         sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom)
    3828             :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException,
    3829             :            std::exception)
    3830             : {
    3831           3 :     SolarMutexGuard aGuard;
    3832           3 :     uno::Reference< table::XCellRange >  aRet;
    3833           3 :     SwFrmFmt* pFmt = GetFrmFmt();
    3834           6 :     if(pFmt && getColumnCount() > nRight && getRowCount() > nBottom &&
    3835           3 :         nLeft <= nRight && nTop <= nBottom
    3836           6 :         && nLeft >= 0 && nRight >= 0 && nTop >= 0 && nBottom >= 0 )
    3837             :     {
    3838           2 :         SwTable* pTable = SwTable::FindTable( pFmt );
    3839           2 :         if(!pTable->IsTblComplex())
    3840             :         {
    3841             :             SwRangeDescriptor aNewDesc;
    3842           2 :             aNewDesc.nTop    = nTop + aRgDesc.nTop;
    3843           2 :             aNewDesc.nBottom = nBottom + aRgDesc.nTop;
    3844           2 :             aNewDesc.nLeft   = nLeft + aRgDesc.nLeft;
    3845           2 :             aNewDesc.nRight  = nRight + aRgDesc.nLeft;
    3846           2 :             aNewDesc.Normalize();
    3847           2 :             OUString sTLName = sw_GetCellName(aNewDesc.nLeft, aNewDesc.nTop);
    3848           4 :             OUString sBRName = sw_GetCellName(aNewDesc.nRight, aNewDesc.nBottom);
    3849           2 :             const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
    3850           2 :             if(pTLBox)
    3851             :             {
    3852             :                 // invalidate all actions
    3853           2 :                 UnoActionRemoveContext aRemoveContext(pFmt->GetDoc());
    3854           2 :                 const SwStartNode* pSttNd = pTLBox->GetSttNd();
    3855           4 :                 SwPosition aPos(*pSttNd);
    3856             :                 // set cursor in the upper-left cell of the range
    3857           2 :                 SwUnoCrsr* pUnoCrsr = pFmt->GetDoc()->CreateUnoCrsr(aPos, true);
    3858           2 :                 pUnoCrsr->Move( fnMoveForward, fnGoNode );
    3859           2 :                 pUnoCrsr->SetRemainInSection( sal_False );
    3860           2 :                 const SwTableBox* pBRBox = pTable->GetTblBox( sBRName );
    3861           2 :                 if(pBRBox)
    3862             :                 {
    3863           2 :                     pUnoCrsr->SetMark();
    3864           2 :                     pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd();
    3865           2 :                     pUnoCrsr->Move( fnMoveForward, fnGoNode );
    3866           2 :                     SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    3867           2 :                     pCrsr->MakeBoxSels();
    3868             :                     // pUnoCrsr will be provided and will not be deleted
    3869           2 :                     SwXCellRange* pCellRange = new SwXCellRange(pUnoCrsr, *pFmt, aNewDesc);
    3870           2 :                     aRet = pCellRange;
    3871             :                 }
    3872             :                 else
    3873           2 :                     delete pUnoCrsr;
    3874           2 :             }
    3875             :         }
    3876             :     }
    3877           3 :     if(!aRet.is())
    3878           1 :         throw lang::IndexOutOfBoundsException();
    3879           3 :     return aRet;
    3880             : }
    3881             : 
    3882           1 : uno::Reference< table::XCellRange >  SwXCellRange::getCellRangeByName(const OUString& rRange)
    3883             :         throw( uno::RuntimeException, std::exception )
    3884             : {
    3885           1 :     SolarMutexGuard aGuard;
    3886           2 :     OUString sRange(rRange);
    3887           2 :     OUString sTLName(sRange.getToken(0, ':'));
    3888           2 :     OUString sBRName(sRange.getToken(1, ':'));
    3889           1 :     if(sTLName.isEmpty() || sBRName.isEmpty())
    3890           0 :         throw uno::RuntimeException();
    3891             :     SwRangeDescriptor aDesc;
    3892           1 :     aDesc.nTop = aDesc.nLeft = aDesc.nBottom = aDesc.nRight = -1;
    3893           1 :     sw_GetCellPosition( sTLName, aDesc.nLeft, aDesc.nTop );
    3894           1 :     sw_GetCellPosition( sBRName, aDesc.nRight, aDesc.nBottom );
    3895           1 :     aDesc.Normalize();
    3896             :     return getCellRangeByPosition(aDesc.nLeft - aRgDesc.nLeft, aDesc.nTop - aRgDesc.nTop,
    3897           2 :                 aDesc.nRight - aRgDesc.nLeft, aDesc.nBottom - aRgDesc.nTop);
    3898             : }
    3899             : 
    3900         155 : uno::Reference< beans::XPropertySetInfo >  SwXCellRange::getPropertySetInfo(void) throw( uno::RuntimeException, std::exception )
    3901             : {
    3902         155 :     static uno::Reference< beans::XPropertySetInfo >  xRef = m_pPropSet->getPropertySetInfo();
    3903         155 :     return xRef;
    3904             : }
    3905             : 
    3906          73 : void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
    3907             :     throw (beans::UnknownPropertyException,
    3908             :            beans::PropertyVetoException,
    3909             :            lang::IllegalArgumentException,
    3910             :            lang::WrappedTargetException,
    3911             :            uno::RuntimeException,
    3912             :            std::exception)
    3913             : {
    3914          73 :     SolarMutexGuard aGuard;
    3915          73 :     SwFrmFmt* pFmt = GetFrmFmt();
    3916          73 :     if(pFmt)
    3917             :     {
    3918             :         const SfxItemPropertySimpleEntry* pEntry =
    3919          73 :                                     m_pPropSet->getPropertyMap().getByName(rPropertyName);
    3920          73 :         if(pEntry)
    3921             :         {
    3922          73 :             if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
    3923           0 :                 throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
    3924             : 
    3925          73 :             SwDoc* pDoc = pTblCrsr->GetDoc();
    3926             :             {
    3927             :                 // remove actions to enable box selection
    3928          73 :                 UnoActionRemoveContext aRemoveContext(pDoc);
    3929             :             }
    3930          73 :             SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr);
    3931          73 :             pCrsr->MakeBoxSels();
    3932          73 :             switch(pEntry->nWID )
    3933             :             {
    3934             :                 case FN_UNO_TABLE_CELL_BACKGROUND:
    3935             :                 {
    3936           0 :                     SvxBrushItem aBrush( RES_BACKGROUND );
    3937           0 :                     pDoc->GetBoxAttr( *pTblCrsr, aBrush );
    3938           0 :                     ((SfxPoolItem&)aBrush).PutValue(aValue, pEntry->nMemberId);
    3939           0 :                     pDoc->SetBoxAttr( *pTblCrsr, aBrush );
    3940             : 
    3941             :                 }
    3942           0 :                 break;
    3943             :                 case RES_BOX :
    3944             :                 {
    3945           0 :                     SfxItemSet aSet(pDoc->GetAttrPool(),
    3946             :                                     RES_BOX, RES_BOX,
    3947             :                                     SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
    3948           0 :                                     0);
    3949           0 :                     SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
    3950           0 :                     aBoxInfo.SetValid(0xff, false);
    3951           0 :                     sal_uInt8 nValid = 0;
    3952           0 :                     switch(pEntry->nMemberId & ~CONVERT_TWIPS)
    3953             :                     {
    3954           0 :                         case  LEFT_BORDER :             nValid = VALID_LEFT; break;
    3955           0 :                         case  RIGHT_BORDER:             nValid = VALID_RIGHT; break;
    3956           0 :                         case  TOP_BORDER  :             nValid = VALID_TOP; break;
    3957           0 :                         case  BOTTOM_BORDER:            nValid = VALID_BOTTOM; break;
    3958             :                         case  LEFT_BORDER_DISTANCE :
    3959             :                         case  RIGHT_BORDER_DISTANCE:
    3960             :                         case  TOP_BORDER_DISTANCE  :
    3961             :                         case  BOTTOM_BORDER_DISTANCE:
    3962           0 :                             nValid = VALID_DISTANCE;
    3963           0 :                         break;
    3964             :                     }
    3965           0 :                     aBoxInfo.SetValid(nValid, true);
    3966             : 
    3967           0 :                     aSet.Put(aBoxInfo);
    3968           0 :                     pDoc->GetTabBorders(*pCrsr, aSet);
    3969             : 
    3970           0 :                     aSet.Put(aBoxInfo);
    3971           0 :                     SvxBoxItem aBoxItem((const SvxBoxItem&)aSet.Get(RES_BOX));
    3972           0 :                     ((SfxPoolItem&)aBoxItem).PutValue(aValue, pEntry->nMemberId);
    3973           0 :                     aSet.Put(aBoxItem);
    3974           0 :                     pDoc->SetTabBorders( *pTblCrsr, aSet );
    3975             :                 }
    3976           0 :                 break;
    3977             :                 case RES_BOXATR_FORMAT:
    3978             :                 {
    3979           0 :                     SfxUInt32Item aNumberFormat(RES_BOXATR_FORMAT);
    3980           0 :                     ((SfxPoolItem&)aNumberFormat).PutValue(aValue, 0);
    3981           0 :                     pDoc->SetBoxAttr( *pCrsr, aNumberFormat);
    3982             :                 }
    3983           0 :                 break;
    3984             :                 case FN_UNO_RANGE_ROW_LABEL:
    3985             :                 {
    3986           0 :                     sal_Bool bTmp = *(sal_Bool*)aValue.getValue();
    3987           0 :                     if(bFirstRowAsLabel != bTmp)
    3988             :                     {
    3989           0 :                         lcl_SendChartEvent(*this, m_ChartListeners);
    3990           0 :                         bFirstRowAsLabel = bTmp;
    3991             :                     }
    3992             :                 }
    3993           0 :                 break;
    3994             :                 case FN_UNO_RANGE_COL_LABEL:
    3995             :                 {
    3996           0 :                     sal_Bool bTmp = *(sal_Bool*)aValue.getValue();
    3997           0 :                     if(bFirstColumnAsLabel != bTmp)
    3998             :                     {
    3999           0 :                         lcl_SendChartEvent(*this, m_ChartListeners);
    4000           0 :                         bFirstColumnAsLabel = bTmp;
    4001             :                     }
    4002             :                 }
    4003           0 :                 break;
    4004             :                 default:
    4005             :                 {
    4006          73 :                     SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID );
    4007          73 :                     SwUnoCursorHelper::GetCrsrAttr(pCrsr->GetSelRing(),
    4008          73 :                             aItemSet);
    4009             : 
    4010          73 :                     if (!SwUnoCursorHelper::SetCursorPropertyValue(
    4011          73 :                             *pEntry, aValue, pCrsr->GetSelRing(), aItemSet))
    4012             :                     {
    4013          72 :                         m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet);
    4014             :                     }
    4015          73 :                     SwUnoCursorHelper::SetCrsrAttr(pCrsr->GetSelRing(),
    4016          73 :                             aItemSet, nsSetAttrMode::SETATTR_DEFAULT, true);
    4017             :                 }
    4018             :             }
    4019             :         }
    4020             :         else
    4021           0 :             throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
    4022          73 :     }
    4023          73 : }
    4024             : 
    4025         149 : uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
    4026             :     throw (beans::UnknownPropertyException,
    4027             :            lang::WrappedTargetException,
    4028             :            uno::RuntimeException,
    4029             :            std::exception)
    4030             : {
    4031         149 :     SolarMutexGuard aGuard;
    4032         149 :     uno::Any aRet;
    4033         149 :     SwFrmFmt* pFmt = GetFrmFmt();
    4034         149 :     if(pFmt)
    4035             :     {
    4036             :         const SfxItemPropertySimpleEntry* pEntry =
    4037         149 :                                     m_pPropSet->getPropertyMap().getByName(rPropertyName);
    4038         149 :         if(pEntry)
    4039             :         {
    4040         149 :             switch(pEntry->nWID )
    4041             :             {
    4042             :                 case FN_UNO_TABLE_CELL_BACKGROUND:
    4043             :                 {
    4044           0 :                     SvxBrushItem aBrush( RES_BACKGROUND );
    4045           0 :                     if(pTblCrsr->GetDoc()->GetBoxAttr( *pTblCrsr, aBrush ))
    4046           0 :                         aBrush.QueryValue(aRet, pEntry->nMemberId);
    4047             : 
    4048             :                 }
    4049           0 :                 break;
    4050             :                 case RES_BOX :
    4051             :                 {
    4052           0 :                     SwDoc* pDoc = pTblCrsr->GetDoc();
    4053           0 :                     SfxItemSet aSet(pDoc->GetAttrPool(),
    4054             :                                     RES_BOX, RES_BOX,
    4055             :                                     SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
    4056           0 :                                     0);
    4057           0 :                     aSet.Put(SvxBoxInfoItem( SID_ATTR_BORDER_INNER ));
    4058           0 :                     pDoc->GetTabBorders(*pTblCrsr, aSet);
    4059           0 :                     const SvxBoxItem& rBoxItem = ((const SvxBoxItem&)aSet.Get(RES_BOX));
    4060           0 :                     rBoxItem.QueryValue(aRet, pEntry->nMemberId);
    4061             :                 }
    4062           0 :                 break;
    4063             :                 case RES_BOXATR_FORMAT:
    4064             :                     OSL_FAIL("not implemented");
    4065           0 :                 break;
    4066             :                 case FN_UNO_PARA_STYLE:
    4067             :                 {
    4068             :                     SwFmtColl *const pTmpFmt =
    4069           0 :                         SwUnoCursorHelper::GetCurTxtFmtColl(*pTblCrsr, false);
    4070           0 :                     OUString sRet;
    4071           0 :                     if(pFmt)
    4072           0 :                         sRet = pTmpFmt->GetName();
    4073           0 :                     aRet <<= sRet;
    4074             :                 }
    4075           0 :                 break;
    4076             :                 case FN_UNO_RANGE_ROW_LABEL:
    4077             :                 {
    4078           0 :                     sal_Bool bTemp = bFirstRowAsLabel;
    4079           0 :                     aRet.setValue(&bTemp, ::getCppuBooleanType());
    4080             :                 }
    4081           0 :                 break;
    4082             :                 case FN_UNO_RANGE_COL_LABEL:
    4083             :                 {
    4084           0 :                     sal_Bool bTemp = bFirstColumnAsLabel;
    4085           0 :                     aRet.setValue(&bTemp, ::getCppuBooleanType());
    4086             :                 }
    4087           0 :                 break;
    4088             :                 default:
    4089             :                 {
    4090         149 :                     SfxItemSet aSet(pTblCrsr->GetDoc()->GetAttrPool(),
    4091             :                         RES_CHRATR_BEGIN,       RES_FRMATR_END -1,
    4092             :                         RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
    4093             :                         RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
    4094         149 :                         0L);
    4095             :                     // first look at the attributes of the cursor
    4096         149 :                     SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr);
    4097         149 :                     SwUnoCursorHelper::GetCrsrAttr(pCrsr->GetSelRing(), aSet);
    4098         149 :                     m_pPropSet->getPropertyValue(*pEntry, aSet, aRet);
    4099             :                 }
    4100             :             }
    4101             :         }
    4102             :         else
    4103           0 :            throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
    4104             :     }
    4105         149 :     return aRet;
    4106             : }
    4107             : 
    4108           0 : void SwXCellRange::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    4109             : {
    4110             :     OSL_FAIL("not implemented");
    4111           0 : }
    4112             : 
    4113           0 : void SwXCellRange::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    4114             : {
    4115             :     OSL_FAIL("not implemented");
    4116           0 : }
    4117             : 
    4118           0 : void SwXCellRange::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    4119             : {
    4120             :     OSL_FAIL("not implemented");
    4121           0 : }
    4122             : 
    4123           0 : void SwXCellRange::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    4124             : {
    4125             :     OSL_FAIL("not implemented");
    4126           0 : }
    4127             : 
    4128           0 : void SwXCellRange::GetDataSequence(
    4129             :         uno::Sequence< uno::Any >   *pAnySeq,   //-> first pointer != 0 is used
    4130             :         uno::Sequence< OUString >   *pTxtSeq,   //-> as output sequence
    4131             :         uno::Sequence< double >     *pDblSeq,   //-> (previous data gets overwritten)
    4132             :         sal_Bool bForceNumberResults )          //-> when 'true' requires to make an
    4133             :                                                 // extra effort to return a value different
    4134             :                                                 // from 0 even if the cell is formatted to text
    4135             :     throw (uno::RuntimeException)
    4136             : {
    4137           0 :     SolarMutexGuard aGuard;
    4138             : 
    4139             :     // compare to SwXCellRange::getDataArray (note different return types though)
    4140             : 
    4141           0 :     sal_Int16 nRowCount = getRowCount();
    4142           0 :     sal_Int16 nColCount = getColumnCount();
    4143             : 
    4144           0 :     if(!nRowCount || !nColCount)
    4145             :     {
    4146           0 :         uno::RuntimeException aRuntime;
    4147           0 :         aRuntime.Message = "Table too complex";
    4148           0 :         throw aRuntime;
    4149             :     }
    4150             : 
    4151           0 :     sal_Int32 nSize = nRowCount * nColCount;
    4152           0 :     if (pAnySeq)
    4153           0 :         pAnySeq->realloc( nSize );
    4154           0 :     else if (pTxtSeq)
    4155           0 :         pTxtSeq->realloc( nSize );
    4156           0 :     else if (pDblSeq)
    4157           0 :         pDblSeq->realloc( nSize );
    4158             :     else
    4159             :     {
    4160             :         OSL_FAIL( "argument missing" );
    4161           0 :         return;
    4162             :     }
    4163           0 :     uno::Any   *pAnyData = pAnySeq ? pAnySeq->getArray() : 0;
    4164           0 :     OUString   *pTxtData = pTxtSeq ? pTxtSeq->getArray() : 0;
    4165           0 :     double     *pDblData = pDblSeq ? pDblSeq->getArray() : 0;
    4166             : 
    4167           0 :     sal_Int32 nDtaCnt = 0;
    4168           0 :     SwFrmFmt* pFmt = GetFrmFmt();
    4169           0 :     if(pFmt)
    4170             :     {
    4171             :         double fNan;
    4172           0 :         ::rtl::math::setNan( & fNan );
    4173             : 
    4174           0 :         uno::Reference< table::XCell > xCellRef;
    4175           0 :         for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++)
    4176             :         {
    4177           0 :             for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++)
    4178             :             {
    4179             :                 SwXCell * pXCell = lcl_CreateXCell(pFmt,
    4180             :                                     aRgDesc.nLeft + nCol,
    4181           0 :                                     aRgDesc.nTop + nRow);
    4182             :                 //! keep (additional) reference to object to prevent implicit destruction
    4183             :                 //! in following UNO calls (when object will get referenced)
    4184           0 :                 xCellRef = pXCell;
    4185           0 :                 SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0;
    4186           0 :                 if(!pBox)
    4187             :                 {
    4188           0 :                     throw uno::RuntimeException();
    4189             :                 }
    4190             :                 else
    4191             :                 {
    4192           0 :                     if (pAnyData)
    4193             :                     {
    4194             :                         // check if table box value item is set
    4195           0 :                         bool bIsNum = pBox->GetFrmFmt()->GetItemState( RES_BOXATR_VALUE, sal_False ) == SFX_ITEM_SET;
    4196           0 :                         if (!bIsNum)
    4197           0 :                             pAnyData[nDtaCnt++] <<= lcl_getString(*pXCell);
    4198             :                         else
    4199           0 :                             pAnyData[nDtaCnt++] <<= sw_getValue(*pXCell);
    4200             :                     }
    4201           0 :                     else if (pTxtData)
    4202           0 :                         pTxtData[nDtaCnt++] = lcl_getString(*pXCell);
    4203           0 :                     else if (pDblData)
    4204             :                     {
    4205           0 :                         double fVal = fNan;
    4206           0 :                         if (!bForceNumberResults || table::CellContentType_TEXT != pXCell->getType())
    4207           0 :                             fVal = sw_getValue(*pXCell);
    4208             :                         else
    4209             :                         {
    4210             :                             OSL_ENSURE( table::CellContentType_TEXT == pXCell->getType(),
    4211             :                                     "this branch of 'if' is only for text formatted cells" );
    4212             : 
    4213             :                             // now we'll try to get a useful numerical value
    4214             :                             // from the text in the cell...
    4215             : 
    4216             :                             sal_uInt32 nFIndex;
    4217           0 :                             SvNumberFormatter* pNumFormatter = pTblCrsr->GetDoc()->GetNumberFormatter();
    4218             : 
    4219             :                             // look for SwTblBoxNumFormat value in parents as well
    4220             :                             const SfxPoolItem* pItem;
    4221           0 :                             SwFrmFmt *pBoxFmt = pXCell->GetTblBox()->GetFrmFmt();
    4222           0 :                             SfxItemState eState = pBoxFmt->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, true, &pItem);
    4223             : 
    4224           0 :                             if (eState == SFX_ITEM_SET)
    4225             :                             {
    4226             :                                 // please note that the language of the numberformat
    4227             :                                 // is implicitly coded into the below value as well
    4228           0 :                                 nFIndex = ((SwTblBoxNumFormat*)pItem)->GetValue();
    4229             : 
    4230             :                                 // since the current value indicates a text format but the call
    4231             :                                 // to 'IsNumberFormat' below won't work for text formats
    4232             :                                 // we need to get rid of the part that indicates the text format.
    4233             :                                 // According to ER this can be done like this:
    4234           0 :                                 nFIndex -= (nFIndex % SV_COUNTRY_LANGUAGE_OFFSET);
    4235             :                             }
    4236             :                             else
    4237             :                             {
    4238             :                                 // system language is probably not the best possible choice
    4239             :                                 // but since we have to guess anyway (because the language of at
    4240             :                                 // the text is NOT the one used for the number format!)
    4241             :                                 // it is at least conform to to what is used in
    4242             :                                 // SwTableShell::Execute when
    4243             :                                 // SID_ATTR_NUMBERFORMAT_VALUE is set...
    4244           0 :                                 LanguageType eLang = LANGUAGE_SYSTEM;
    4245           0 :                                 nFIndex = pNumFormatter->GetStandardIndex( eLang );
    4246             :                             }
    4247             : 
    4248           0 :                             OUString aTxt( lcl_getString(*pXCell) );
    4249             :                             double fTmp;
    4250           0 :                             if (pNumFormatter->IsNumberFormat( aTxt, nFIndex, fTmp ))
    4251           0 :                                 fVal = fTmp;
    4252             :                         }
    4253           0 :                         pDblData[nDtaCnt++] = fVal;
    4254             :                     }
    4255             :                     else {
    4256             :                         OSL_FAIL( "output sequence missing" );
    4257             :                     }
    4258             :                 }
    4259             :             }
    4260           0 :         }
    4261             :     }
    4262             :     OSL_ENSURE( nDtaCnt == nSize, "size mismatch. Invalid cell range?" );
    4263           0 :     if (pAnySeq)
    4264           0 :         pAnySeq->realloc( nDtaCnt );
    4265           0 :     else if (pTxtSeq)
    4266           0 :         pTxtSeq->realloc( nDtaCnt );
    4267           0 :     else if (pDblSeq)
    4268           0 :         pDblSeq->realloc( nDtaCnt );
    4269             : }
    4270             : 
    4271             : ///@see SwXCellRange::getData
    4272             : ///@see SwXCellRange::GetDataSequence
    4273           2 : uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray()
    4274             :     throw (uno::RuntimeException, std::exception)
    4275             : {
    4276           2 :     SolarMutexGuard aGuard;
    4277           2 :     sal_Int16 nRowCount = getRowCount();
    4278           2 :     sal_Int16 nColCount = getColumnCount();
    4279             : 
    4280           2 :     if(!nRowCount || !nColCount)
    4281             :     {
    4282           0 :         uno::RuntimeException aRuntime;
    4283           0 :         aRuntime.Message = "Table too complex";
    4284           0 :         throw aRuntime;
    4285             :     }
    4286           2 :     uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount);
    4287           2 :     SwFrmFmt* pFmt = GetFrmFmt();
    4288           2 :     if(pFmt)
    4289             :     {
    4290           2 :         uno::Sequence< uno::Any >* pRowArray = aRowSeq.getArray();
    4291           2 :         uno::Reference< table::XCell > xCellRef;
    4292          12 :         for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++)
    4293             :         {
    4294          10 :             uno::Sequence< uno::Any > aColSeq(nColCount);
    4295          10 :             uno::Any * pColArray = aColSeq.getArray();
    4296          50 :             for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++)
    4297             :             {
    4298             :                 SwXCell * pXCell = lcl_CreateXCell(pFmt,
    4299             :                                     aRgDesc.nLeft + nCol,
    4300          40 :                                     aRgDesc.nTop + nRow);
    4301             :                 //! keep (additional) reference to object to prevent implicit destruction
    4302             :                 //! in following UNO calls (when object will get referenced)
    4303          40 :                 xCellRef = pXCell;
    4304          40 :                 SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0;
    4305          40 :                 if(!pBox)
    4306             :                 {
    4307           0 :                     throw uno::RuntimeException();
    4308             :                 }
    4309             :                 else
    4310             :                 {
    4311             :                     // check if table box value item is set
    4312          40 :                     SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
    4313          40 :                     bool bIsNum = pBoxFmt->GetItemState( RES_BOXATR_VALUE, sal_False ) == SFX_ITEM_SET;
    4314          40 :                     if(!bIsNum)
    4315          20 :                         pColArray[nCol] <<= lcl_getString(*pXCell);
    4316             :                     else
    4317          20 :                         pColArray[nCol] <<= sw_getValue(*pXCell);
    4318             :                 }
    4319             :             }
    4320          10 :             pRowArray[nRow] = aColSeq;
    4321          12 :         }
    4322             :     }
    4323           2 :     return aRowSeq;
    4324             : }
    4325             : 
    4326             : ///@see SwXCellRange::setData
    4327           2 : void SAL_CALL SwXCellRange::setDataArray(
    4328             :         const uno::Sequence< uno::Sequence< uno::Any > >& rArray )
    4329             :     throw (uno::RuntimeException, std::exception)
    4330             : {
    4331           2 :     SolarMutexGuard aGuard;
    4332           2 :     sal_Int16 nRowCount = getRowCount();
    4333           2 :     sal_Int16 nColCount = getColumnCount();
    4334           2 :     if(!nRowCount || !nColCount)
    4335             :     {
    4336           0 :         uno::RuntimeException aRuntime;
    4337           0 :         aRuntime.Message = "Table too complex";
    4338           0 :         throw aRuntime;
    4339             :     }
    4340           2 :     SwFrmFmt* pFmt = GetFrmFmt();
    4341           2 :     if(pFmt )
    4342             :     {
    4343           2 :         if(rArray.getLength() != nRowCount)
    4344             :         {
    4345           0 :             throw uno::RuntimeException();
    4346             :         }
    4347           2 :         const uno::Sequence< uno::Any >* pRowArray = rArray.getConstArray();
    4348          12 :         for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++)
    4349             :         {
    4350          10 :             const uno::Sequence< uno::Any >& rColSeq = pRowArray[nRow];
    4351          10 :             if(rColSeq.getLength() != nColCount)
    4352             :             {
    4353           0 :                 throw uno::RuntimeException();
    4354             :             }
    4355          10 :             const uno::Any * pColArray = rColSeq.getConstArray();
    4356          10 :             uno::Reference< table::XCell > xCellRef;
    4357          50 :             for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++)
    4358             :             {
    4359             :                 SwXCell * pXCell = lcl_CreateXCell(pFmt,
    4360             :                                     aRgDesc.nLeft + nCol,
    4361          40 :                                     aRgDesc.nTop + nRow);
    4362             :                 //! keep (additional) reference to object to prevent implicit destruction
    4363             :                 //! in following UNO calls (when object will get referenced)
    4364          40 :                 xCellRef = pXCell;
    4365          40 :                 SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0;
    4366          40 :                 if(!pBox)
    4367             :                 {
    4368           0 :                     throw uno::RuntimeException();
    4369             :                 }
    4370             :                 else
    4371             :                 {
    4372          40 :                     const uno::Any &rAny = pColArray[nCol];
    4373          40 :                     if (uno::TypeClass_STRING == rAny.getValueTypeClass())
    4374          20 :                         sw_setString( *pXCell, *(OUString *) rAny.getValue() );
    4375             :                     else
    4376             :                     {
    4377          20 :                         double d = 0;
    4378             :                         // #i20067# don't throw exception just do nothing if
    4379             :                         // there is no value set
    4380          20 :                         if( (rAny >>= d) )
    4381          20 :                             sw_setValue( *pXCell, d );
    4382             :                         else
    4383           0 :                             sw_setString( *pXCell, OUString(), sal_True );
    4384             :                     }
    4385             :                 }
    4386             :             }
    4387          10 :         }
    4388           2 :     }
    4389           2 : }
    4390             : 
    4391           2 : uno::Sequence< uno::Sequence< double > > SwXCellRange::getData(void) throw( uno::RuntimeException, std::exception )
    4392             : {
    4393           2 :     SolarMutexGuard aGuard;
    4394           2 :     sal_Int16 nRowCount = getRowCount();
    4395           2 :     sal_Int16 nColCount = getColumnCount();
    4396             : 
    4397           2 :     if(!nRowCount || !nColCount)
    4398             :     {
    4399           0 :         uno::RuntimeException aRuntime;
    4400           0 :         aRuntime.Message = "Table too complex";
    4401           0 :         throw aRuntime;
    4402             :     }
    4403           2 :     uno::Sequence< uno::Sequence< double > > aRowSeq(bFirstRowAsLabel ? nRowCount - 1 : nRowCount);
    4404           2 :     SwFrmFmt* pFmt = GetFrmFmt();
    4405           2 :     if(pFmt)
    4406             :     {
    4407           2 :         uno::Sequence< double >* pRowArray = aRowSeq.getArray();
    4408             : 
    4409           2 :         sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
    4410          12 :         for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
    4411             :         {
    4412          10 :             uno::Sequence< double > aColSeq(bFirstColumnAsLabel ? nColCount - 1 : nColCount);
    4413          10 :             double * pArray = aColSeq.getArray();
    4414          10 :             sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
    4415          50 :             for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
    4416             :             {
    4417          40 :                 uno::Reference< table::XCell >  xCell = getCellByPosition(nCol, nRow);
    4418          40 :                 if(!xCell.is())
    4419             :                 {
    4420           0 :                     throw uno::RuntimeException();
    4421             :                 }
    4422          40 :                 pArray[nCol - nColStart] = xCell->getValue();
    4423          40 :             }
    4424          10 :             pRowArray[nRow - nRowStart] = aColSeq;
    4425          10 :         }
    4426             :     }
    4427           2 :     return aRowSeq;
    4428             : }
    4429             : 
    4430           1 : void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData)
    4431             :                                                 throw( uno::RuntimeException, std::exception )
    4432             : {
    4433           1 :     SolarMutexGuard aGuard;
    4434           1 :     sal_Int16 nRowCount = getRowCount();
    4435           1 :     sal_Int16 nColCount = getColumnCount();
    4436           1 :     if(!nRowCount || !nColCount)
    4437             :     {
    4438           0 :         uno::RuntimeException aRuntime;
    4439           0 :         aRuntime.Message = "Table too complex";
    4440           0 :         throw aRuntime;
    4441             :     }
    4442           1 :     SwFrmFmt* pFmt = GetFrmFmt();
    4443           1 :     if(pFmt )
    4444             :     {
    4445           1 :         sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
    4446           1 :         if(rData.getLength() < nRowCount - nRowStart)
    4447             :         {
    4448           0 :             throw uno::RuntimeException();
    4449             :         }
    4450           1 :         const uno::Sequence< double >* pRowArray = rData.getConstArray();
    4451           6 :         for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
    4452             :         {
    4453           5 :             const uno::Sequence< double >& rColSeq = pRowArray[nRow - nRowStart];
    4454           5 :             sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
    4455           5 :             if(rColSeq.getLength() < nColCount - nColStart)
    4456             :             {
    4457           0 :                 throw uno::RuntimeException();
    4458             :             }
    4459           5 :             const double * pColArray = rColSeq.getConstArray();
    4460          25 :             for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
    4461             :             {
    4462          20 :                 uno::Reference< table::XCell >  xCell = getCellByPosition(nCol, nRow);
    4463          20 :                 if(!xCell.is())
    4464             :                 {
    4465           0 :                     throw uno::RuntimeException();
    4466             :                 }
    4467          20 :                 xCell->setValue(pColArray[nCol - nColStart]);
    4468          20 :             }
    4469             :         }
    4470           1 :     }
    4471           1 : }
    4472             : 
    4473             : ///@see SwXTextTable::getRowDescriptions (TODO: seems to be C&P programming here)
    4474           2 : uno::Sequence< OUString > SwXCellRange::getRowDescriptions(void)
    4475             :                                             throw( uno::RuntimeException, std::exception )
    4476             : {
    4477           2 :     SolarMutexGuard aGuard;
    4478           2 :     sal_Int16 nRowCount = getRowCount();
    4479           2 :     if(!nRowCount)
    4480             :     {
    4481           0 :         uno::RuntimeException aRuntime;
    4482           0 :         aRuntime.Message = "Table too complex";
    4483           0 :         throw aRuntime;
    4484             :     }
    4485           2 :     uno::Sequence< OUString > aRet(bFirstColumnAsLabel ? nRowCount - 1 : nRowCount);
    4486           2 :     SwFrmFmt* pFmt = GetFrmFmt();
    4487           2 :     if(pFmt)
    4488             :     {
    4489           2 :         OUString* pArray = aRet.getArray();
    4490           2 :         if(bFirstColumnAsLabel)
    4491             :         {
    4492           0 :             sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
    4493           0 :             for(sal_uInt16 i = nStart; i < nRowCount; i++)
    4494             :             {
    4495           0 :                 uno::Reference< table::XCell >  xCell = getCellByPosition(0, i);
    4496           0 :                 if(!xCell.is())
    4497             :                 {
    4498           0 :                     throw uno::RuntimeException();
    4499             :                 }
    4500           0 :                 uno::Reference< text::XText >  xText(xCell, uno::UNO_QUERY);
    4501           0 :                 pArray[i - nStart] = xText->getString();
    4502           0 :             }
    4503             :         }
    4504             :         else
    4505             :         {
    4506             :             OSL_FAIL("Where do these labels come from?");
    4507             :         }
    4508             :     }
    4509             :     else
    4510           0 :         throw uno::RuntimeException();
    4511           2 :     return aRet;
    4512             : }
    4513             : 
    4514             : ///@see SwXTextTable::setRowDescriptions (TODO: seems to be C&P programming here)
    4515           0 : void SwXCellRange::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc)
    4516             :                                                     throw( uno::RuntimeException, std::exception )
    4517             : {
    4518           0 :     SolarMutexGuard aGuard;
    4519           0 :     SwFrmFmt* pFmt = GetFrmFmt();
    4520           0 :     if(pFmt)
    4521             :     {
    4522           0 :         sal_Int16 nRowCount = getRowCount();
    4523           0 :         if(!nRowCount || rRowDesc.getLength() < bFirstRowAsLabel ? nRowCount - 1 : nRowCount)
    4524             :         {
    4525           0 :             throw uno::RuntimeException();
    4526             :         }
    4527           0 :         const OUString* pArray = rRowDesc.getConstArray();
    4528           0 :         if(bFirstColumnAsLabel)
    4529             :         {
    4530           0 :             sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
    4531           0 :             for(sal_uInt16 i = nStart; i < nRowCount; i++)
    4532             :             {
    4533           0 :                 uno::Reference< table::XCell >  xCell = getCellByPosition(0, i);
    4534           0 :                 if(!xCell.is())
    4535             :                 {
    4536           0 :                     throw uno::RuntimeException();
    4537             :                 }
    4538           0 :                 uno::Reference< text::XText >  xText(xCell, uno::UNO_QUERY);
    4539           0 :                 xText->setString(pArray[i - nStart]);
    4540           0 :             }
    4541             :         }
    4542             :         else
    4543             :         {
    4544             :             OSL_FAIL("Where to put theses labels?");
    4545             :         }
    4546           0 :     }
    4547           0 : }
    4548             : 
    4549             : ///@see SwXTextTable::setColumnDescriptions (TODO: seems to be C&P programming here)
    4550           2 : uno::Sequence< OUString > SwXCellRange::getColumnDescriptions(void)
    4551             :                                         throw( uno::RuntimeException, std::exception )
    4552             : {
    4553           2 :     SolarMutexGuard aGuard;
    4554           2 :     sal_Int16 nColCount = getColumnCount();
    4555           2 :     if(!nColCount)
    4556             :     {
    4557           0 :         uno::RuntimeException aRuntime;
    4558           0 :         aRuntime.Message = "Table too complex";
    4559           0 :         throw aRuntime;
    4560             :     }
    4561           2 :     uno::Sequence< OUString > aRet(bFirstRowAsLabel ? nColCount - 1 : nColCount);
    4562           2 :     SwFrmFmt* pFmt = GetFrmFmt();
    4563           2 :     if(pFmt)
    4564             :     {
    4565           2 :         OUString* pArray = aRet.getArray();
    4566           2 :         if(bFirstRowAsLabel)
    4567             :         {
    4568           0 :             sal_uInt16 nStart = bFirstColumnAsLabel ? 1 : 0;
    4569           0 :             for(sal_uInt16 i = nStart; i < nColCount; i++)
    4570             :             {
    4571           0 :                 uno::Reference< table::XCell >  xCell = getCellByPosition(i, 0);
    4572           0 :                 if(!xCell.is())
    4573             :                 {
    4574           0 :                     throw uno::RuntimeException();
    4575             :                 }
    4576           0 :                 uno::Reference< text::XText >  xText(xCell, uno::UNO_QUERY);
    4577           0 :                 pArray[i - nStart] = xText->getString();
    4578           0 :             }
    4579             :         }
    4580             :         else
    4581             :         {
    4582             :             OSL_FAIL("Where do these labels come from?");
    4583             :         }
    4584             :     }
    4585             :     else
    4586           0 :         throw uno::RuntimeException();
    4587           2 :     return aRet;
    4588             : }
    4589             : 
    4590             : ///@see SwXTextTable::setColumnDescriptions (TODO: seems to be C&P programming here)
    4591           0 : void SwXCellRange::setColumnDescriptions(const uno::Sequence< OUString >& ColumnDesc)
    4592             :                                                         throw( uno::RuntimeException, std::exception )
    4593             : {
    4594           0 :     SolarMutexGuard aGuard;
    4595           0 :     sal_Int16 nColCount = getColumnCount();
    4596           0 :     SwFrmFmt* pFmt = GetFrmFmt();
    4597           0 :     if(pFmt)
    4598             :     {
    4599           0 :         const OUString* pArray = ColumnDesc.getConstArray();
    4600           0 :         if(bFirstRowAsLabel && ColumnDesc.getLength() >= nColCount - bFirstColumnAsLabel ? 1 : 0)
    4601             :         {
    4602           0 :             sal_uInt16 nStart = bFirstColumnAsLabel ? 1 : 0;
    4603           0 :             for(sal_uInt16 i = nStart; i < nColCount; i++)
    4604             :             {
    4605           0 :                 uno::Reference< table::XCell >  xCell = getCellByPosition(i, 0);
    4606           0 :                 if(!xCell.is())
    4607             :                 {
    4608           0 :                     throw uno::RuntimeException();
    4609             :                 }
    4610           0 :                 uno::Reference< text::XText >  xText(xCell, uno::UNO_QUERY);
    4611             : 
    4612           0 :                 xText->setString(pArray[i - nStart]);
    4613           0 :             }
    4614             :         }
    4615             :         else
    4616             :         {
    4617             :             OSL_FAIL("Where to put theses labels?");
    4618             :         }
    4619           0 :     }
    4620           0 : }
    4621             : 
    4622           0 : void SAL_CALL SwXCellRange::addChartDataChangeEventListener(
    4623             :         const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
    4624             : throw (uno::RuntimeException, std::exception)
    4625             : {
    4626             :     // no need to lock here as m_pImpl is const and container threadsafe
    4627           0 :     m_ChartListeners.addInterface(xListener);
    4628           0 : }
    4629             : 
    4630           0 : void SAL_CALL SwXCellRange::removeChartDataChangeEventListener(
    4631             :         const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
    4632             : throw (uno::RuntimeException, std::exception)
    4633             : {
    4634             :     // no need to lock here as m_pImpl is const and container threadsafe
    4635           0 :     m_ChartListeners.removeInterface(xListener);
    4636           0 : }
    4637             : 
    4638           0 : sal_Bool SwXCellRange::isNotANumber(double /*fNumber*/) throw( uno::RuntimeException, std::exception )
    4639             : {
    4640             :     OSL_FAIL("not implemented");
    4641           0 :     return sal_False;
    4642             : }
    4643             : 
    4644           0 : double SwXCellRange::getNotANumber(void) throw( uno::RuntimeException, std::exception )
    4645             : {
    4646             :     OSL_FAIL("not implemented");
    4647           0 :     return 0.;
    4648             : }
    4649             : 
    4650           0 : uno::Sequence< beans::PropertyValue > SwXCellRange::createSortDescriptor(void) throw( uno::RuntimeException, std::exception )
    4651             : {
    4652           0 :     SolarMutexGuard aGuard;
    4653             : 
    4654           0 :     return SwUnoCursorHelper::CreateSortDescriptor(true);
    4655             : }
    4656             : 
    4657           0 : void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor)
    4658             :     throw (uno::RuntimeException,
    4659             :            std::exception)
    4660             : {
    4661           0 :     SolarMutexGuard aGuard;
    4662           0 :     SwSortOptions aSortOpt;
    4663           0 :     SwFrmFmt* pFmt = GetFrmFmt();
    4664           0 :     if(pFmt &&
    4665           0 :         SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt))
    4666             :     {
    4667           0 :         SwUnoTableCrsr* pTableCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr);
    4668           0 :         pTableCrsr->MakeBoxSels();
    4669           0 :         UnoActionContext aContext( pFmt->GetDoc() );
    4670           0 :         pFmt->GetDoc()->SortTbl(pTableCrsr->GetSelectedBoxes(), aSortOpt);
    4671           0 :     }
    4672           0 : }
    4673             : 
    4674          73 : sal_uInt16 SwXCellRange::getColumnCount(void)
    4675             : {
    4676          73 :     return static_cast< sal_uInt16 >(aRgDesc.nRight - aRgDesc.nLeft + 1);
    4677             : }
    4678             : 
    4679          73 : sal_uInt16 SwXCellRange::getRowCount(void)
    4680             : {
    4681          73 :     return static_cast< sal_uInt16 >(aRgDesc.nBottom - aRgDesc.nTop + 1);
    4682             : }
    4683             : 
    4684           0 : const SwUnoCrsr* SwXCellRange::GetTblCrsr() const
    4685             : {
    4686           0 :     const SwUnoCrsr* pRet = 0;
    4687           0 :     SwFrmFmt* pFmt = GetFrmFmt();
    4688           0 :     if(pFmt)
    4689           0 :         pRet = pTblCrsr;
    4690           0 :     return pRet;
    4691             : }
    4692             : 
    4693           7 : void SwXCellRange::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
    4694             : {
    4695           7 :     ClientModify(this, pOld, pNew );
    4696           7 :     if(!GetRegisteredIn() || !aCursorDepend.GetRegisteredIn())
    4697             :     {
    4698             :         /*
    4699             :          * Not sure if this will cause a memory leak - this pTblCrsr
    4700             :          * is deleted in SwDoc and GPFs here when deleted again
    4701             :          * if(!aCursorDepend.GetRegisteredIn())
    4702             :             delete pTblCrsr;
    4703             :          */
    4704           7 :         pTblCrsr = 0;
    4705           7 :         lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
    4706           7 :         m_ChartListeners.disposeAndClear(ev);
    4707             :     }
    4708             :     else
    4709             :     {
    4710           0 :         lcl_SendChartEvent(*this, m_ChartListeners);
    4711             :     }
    4712           7 : }
    4713             : 
    4714             : //  SwXTableRows
    4715             : 
    4716           0 : OUString SwXTableRows::getImplementationName(void) throw( uno::RuntimeException, std::exception )
    4717             : {
    4718           0 :     return OUString("SwXTableRows");
    4719             : }
    4720             : 
    4721           0 : sal_Bool SwXTableRows::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
    4722             : {
    4723           0 :     return cppu::supportsService(this, rServiceName);
    4724             : }
    4725             : 
    4726           0 : uno::Sequence< OUString > SwXTableRows::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
    4727             : {
    4728           0 :     uno::Sequence< OUString > aRet(1);
    4729           0 :     OUString* pArray = aRet.getArray();
    4730           0 :     pArray[0] = "com.sun.star.text.TableRows";
    4731           0 :     return aRet;
    4732             : }
    4733       27100 : TYPEINIT1(SwXTableRows, SwClient);
    4734             : 
    4735         400 : SwXTableRows::SwXTableRows(SwFrmFmt& rFrmFmt) :
    4736         400 :     SwClient(&rFrmFmt)
    4737             : {
    4738         400 : }
    4739             : 
    4740         800 : SwXTableRows::~SwXTableRows()
    4741             : {
    4742         800 : }
    4743             : 
    4744        2565 : sal_Int32 SwXTableRows::getCount(void) throw( uno::RuntimeException, std::exception )
    4745             : {
    4746        2565 :     SolarMutexGuard aGuard;
    4747        2565 :     sal_Int32 nRet = 0;
    4748        2565 :     SwFrmFmt* pFrmFmt = GetFrmFmt();
    4749        2565 :     if(!pFrmFmt)
    4750           0 :         throw uno::RuntimeException();
    4751             :     else
    4752             :     {
    4753        2565 :         SwTable* pTable = SwTable::FindTable( pFrmFmt );
    4754        2565 :         nRet = pTable->GetTabLines().size();
    4755             :     }
    4756        2565 :     return nRet;
    4757             : }
    4758             : 
    4759             : ///@see SwXCell::CreateXCell (TODO: seems to be C&P programming here)
    4760        2200 : uno::Any SwXTableRows::getByIndex(sal_Int32 nIndex)
    4761             :     throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    4762             : {
    4763        2200 :     SolarMutexGuard aGuard;
    4764        2200 :     uno::Any aRet;
    4765        2200 :     SwFrmFmt* pFrmFmt = GetFrmFmt();
    4766        2200 :     if(!pFrmFmt || nIndex < 0 )
    4767           0 :         throw lang::IndexOutOfBoundsException();
    4768             :     else
    4769             :     {
    4770        2200 :         SwTable* pTable = SwTable::FindTable( pFrmFmt );
    4771        2200 :         if( (sal_uInt16)pTable->GetTabLines().size() > nIndex)
    4772             :         {
    4773        2199 :             SwTableLine* pLine = pTable->GetTabLines()[(sal_uInt16)nIndex];
    4774        2199 :             SwIterator<SwXTextTableRow,SwFmt> aIter( *pFrmFmt );
    4775        2199 :             SwXTextTableRow* pXRow = aIter.First();
    4776        4400 :             while( pXRow )
    4777             :             {
    4778             :                 // is there already a proper cell?
    4779           3 :                 if(pXRow->GetTblRow() == pLine)
    4780           1 :                     break;
    4781           2 :                 pXRow = aIter.Next();
    4782             :             }
    4783             :             // otherwise create it
    4784        2199 :             if(!pXRow)
    4785        2198 :                 pXRow = new SwXTextTableRow(pFrmFmt, pLine);
    4786             :             uno::Reference< beans::XPropertySet >  xRet =
    4787        4398 :                                     (beans::XPropertySet*)pXRow;
    4788        4398 :             aRet.setValue(&xRet, ::getCppuType((const uno::Reference<beans::XPropertySet>*)0));
    4789             :         }
    4790             :         else
    4791           1 :             throw lang::IndexOutOfBoundsException();
    4792             :     }
    4793        2200 :     return aRet;
    4794             : }
    4795             : 
    4796           1 : uno::Type SAL_CALL SwXTableRows::getElementType(void) throw( uno::RuntimeException, std::exception )
    4797             : {
    4798           1 :     return ::getCppuType((const uno::Reference<beans::XPropertySet>*)0);
    4799             : }
    4800             : 
    4801           1 : sal_Bool SwXTableRows::hasElements(void) throw( uno::RuntimeException, std::exception )
    4802             : {
    4803           1 :     SolarMutexGuard aGuard;
    4804           1 :     SwFrmFmt* pFrmFmt = GetFrmFmt();
    4805           1 :     if(!pFrmFmt)
    4806           0 :         throw uno::RuntimeException();
    4807             :     // a table always has rows
    4808           1 :     return sal_True;
    4809             : }
    4810             : 
    4811           2 : void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
    4812             :     throw (uno::RuntimeException, std::exception)
    4813             : {
    4814           2 :     SolarMutexGuard aGuard;
    4815           2 :     if (nCount == 0)
    4816           1 :         return;
    4817           2 :     SwFrmFmt* pFrmFmt = GetFrmFmt();
    4818           2 :     if(!pFrmFmt)
    4819           0 :         throw uno::RuntimeException();
    4820             :     else
    4821             :     {
    4822           2 :         SwTable* pTable = SwTable::FindTable( pFrmFmt );
    4823           2 :         if(!pTable->IsTblComplex())
    4824             :         {
    4825           2 :             sal_uInt16 nRowCount = pTable->GetTabLines().size();
    4826           2 :             if (nCount <= 0 || !(0 <= nIndex && nIndex <= nRowCount))
    4827             :             {
    4828           1 :                 uno::RuntimeException aExcept;
    4829           1 :                 aExcept.Message = "Illegal arguments";
    4830           1 :                 throw aExcept;
    4831             :             }
    4832             : 
    4833           1 :             OUString sTLName = sw_GetCellName(0, nIndex);
    4834           1 :             const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
    4835           1 :             bool bAppend = false;
    4836           1 :             if(!pTLBox)
    4837             :             {
    4838           0 :                 bAppend = true;
    4839             :                 // to append at the end the cursor must be in the last line
    4840           0 :                 SwTableLines& rLines = pTable->GetTabLines();
    4841           0 :                 SwTableLine* pLine = rLines.back();
    4842           0 :                 SwTableBoxes& rBoxes = pLine->GetTabBoxes();
    4843           0 :                 pTLBox = rBoxes.front();
    4844             :             }
    4845           1 :             if(pTLBox)
    4846             :             {
    4847           1 :                 const SwStartNode* pSttNd = pTLBox->GetSttNd();
    4848           1 :                 SwPosition aPos(*pSttNd);
    4849             :                 // set cursor to the upper-left cell of the range
    4850           2 :                 UnoActionContext aAction(pFrmFmt->GetDoc());
    4851           1 :                 SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
    4852           1 :                 pUnoCrsr->Move( fnMoveForward, fnGoNode );
    4853             : 
    4854             :                 {
    4855             :                     // remove actions
    4856           1 :                     UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
    4857             :                 }
    4858             : 
    4859           1 :                 pFrmFmt->GetDoc()->InsertRow(*pUnoCrsr, (sal_uInt16)nCount, bAppend);
    4860           2 :                 delete pUnoCrsr;
    4861           1 :             }
    4862             :         }
    4863           2 :     }
    4864             : }
    4865             : 
    4866           2 : void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
    4867             :     throw (uno::RuntimeException, std::exception)
    4868             : {
    4869           2 :     SolarMutexGuard aGuard;
    4870           2 :     if (nCount == 0)
    4871           1 :         return;
    4872           2 :     SwFrmFmt* pFrmFmt = GetFrmFmt();
    4873           2 :     if(!pFrmFmt || nIndex < 0 || nCount <=0 )
    4874           1 :         throw uno::RuntimeException();
    4875             :     else
    4876             :     {
    4877           1 :         bool bSuccess = false;
    4878           1 :         SwTable* pTable = SwTable::FindTable( pFrmFmt );
    4879           1 :         if(!pTable->IsTblComplex())
    4880             :         {
    4881           1 :             OUString sTLName = sw_GetCellName(0, nIndex);
    4882           1 :             const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
    4883           1 :             if(pTLBox)
    4884             :             {
    4885             :                 {
    4886             :                     // invalidate all actions
    4887           1 :                     UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc());
    4888             :                 }
    4889           1 :                 const SwStartNode* pSttNd = pTLBox->GetSttNd();
    4890           1 :                 SwPosition aPos(*pSttNd);
    4891             :                 // set cursor to the upper-left cell of the range
    4892           1 :                 SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
    4893           1 :                 pUnoCrsr->Move( fnMoveForward, fnGoNode );
    4894           1 :                 pUnoCrsr->SetRemainInSection( sal_False );
    4895           2 :                 OUString sBLName = sw_GetCellName(0, nIndex + nCount - 1);
    4896           1 :                 const SwTableBox* pBLBox = pTable->GetTblBox( sBLName );
    4897           1 :                 if(pBLBox)
    4898             :                 {
    4899           1 :                     pUnoCrsr->SetMark();
    4900           1 :                     pUnoCrsr->GetPoint()->nNode = *pBLBox->GetSttNd();
    4901           1 :                     pUnoCrsr->Move( fnMoveForward, fnGoNode );
    4902             :                     SwUnoTableCrsr* pCrsr =
    4903           1 :                         dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    4904           1 :                     pCrsr->MakeBoxSels();
    4905             :                     {   // these braces are important
    4906           1 :                         UnoActionContext aAction(pFrmFmt->GetDoc());
    4907           1 :                         pFrmFmt->GetDoc()->DeleteRow(*pUnoCrsr);
    4908           1 :                         delete pUnoCrsr;
    4909           1 :                         bSuccess = true;
    4910             :                     }
    4911             :                     {
    4912             :                         // invalidate all actions
    4913           1 :                         UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc());
    4914             :                     }
    4915           1 :                 }
    4916           1 :             }
    4917             :         }
    4918           1 :         if(!bSuccess)
    4919             :         {
    4920           0 :             uno::RuntimeException aExcept;
    4921           0 :             aExcept.Message = "Illegal arguments";
    4922           0 :             throw aExcept;
    4923             :         }
    4924           2 :     }
    4925             : }
    4926             : 
    4927           3 : void SwXTableRows::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
    4928             : {
    4929           3 :     ClientModify(this, pOld, pNew);
    4930           3 : }
    4931             : 
    4932             : // SwXTableColumns
    4933             : 
    4934           0 : OUString SwXTableColumns::getImplementationName(void) throw( uno::RuntimeException, std::exception )
    4935             : {
    4936           0 :     return OUString("SwXTableColumns");
    4937             : }
    4938             : 
    4939           0 : sal_Bool SwXTableColumns::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
    4940             : {
    4941           0 :     return cppu::supportsService(this, rServiceName);
    4942             : }
    4943             : 
    4944           0 : uno::Sequence< OUString > SwXTableColumns::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
    4945             : {
    4946           0 :     uno::Sequence< OUString > aRet(1);
    4947           0 :     OUString* pArray = aRet.getArray();
    4948           0 :     pArray[0] = "com.sun.star.text.TableColumns";
    4949           0 :     return aRet;
    4950             : }
    4951             : 
    4952          11 : TYPEINIT1(SwXTableColumns, SwClient);
    4953             : 
    4954           2 : SwXTableColumns::SwXTableColumns(SwFrmFmt& rFrmFmt) :
    4955           2 :     SwClient(&rFrmFmt)
    4956             : {
    4957           2 : }
    4958             : 
    4959           4 : SwXTableColumns::~SwXTableColumns()
    4960             : {
    4961           4 : }
    4962             : 
    4963           2 : sal_Int32 SwXTableColumns::getCount(void) throw( uno::RuntimeException, std::exception )
    4964             : {
    4965           2 :     SolarMutexGuard aGuard;
    4966           2 :     sal_Int32 nRet = 0;
    4967           2 :     SwFrmFmt* pFrmFmt = GetFrmFmt();
    4968           2 :     if(!pFrmFmt)
    4969           0 :         throw uno::RuntimeException();
    4970             :     else
    4971             :     {
    4972           2 :         SwTable* pTable = SwTable::FindTable( pFrmFmt );
    4973           2 :         if(!pTable->IsTblComplex())
    4974             :         {
    4975           2 :             SwTableLines& rLines = pTable->GetTabLines();
    4976           2 :             SwTableLine* pLine = rLines.front();
    4977           2 :             nRet = pLine->GetTabBoxes().size();
    4978             :         }
    4979             :     }
    4980           2 :     return nRet;
    4981             : }
    4982             : 
    4983           4 : uno::Any SwXTableColumns::getByIndex(sal_Int32 nIndex)
    4984             :     throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    4985             : {
    4986           4 :     SolarMutexGuard aGuard;
    4987           8 :     uno::Reference< uno::XInterface >  xRet;
    4988           4 :     SwFrmFmt* pFrmFmt = GetFrmFmt();
    4989           4 :     if(!pFrmFmt)
    4990           0 :         throw uno::RuntimeException();
    4991             :     else
    4992             :     {
    4993           4 :         sal_uInt16 nCount = 0;
    4994           4 :         SwTable* pTable = SwTable::FindTable( pFrmFmt );
    4995           4 :         if(!pTable->IsTblComplex())
    4996             :         {
    4997           4 :             SwTableLines& rLines = pTable->GetTabLines();
    4998           4 :             SwTableLine* pLine = rLines.front();
    4999           4 :             nCount = pLine->GetTabBoxes().size();
    5000             :         }
    5001           4 :         if(nCount <= nIndex || nIndex < 0)
    5002           1 :             throw lang::IndexOutOfBoundsException();
    5003           3 :         xRet = uno::Reference<uno::XInterface>();   //!! writer tables do not have columns !!
    5004             :     }
    5005           7 :     return uno::Any(&xRet, ::getCppuType((const uno::Reference<uno::XInterface>*)0));
    5006             : }
    5007             : 
    5008           1 : uno::Type SAL_CALL SwXTableColumns::getElementType(void) throw( uno::RuntimeException, std::exception )
    5009             : {
    5010           1 :     return ::getCppuType((uno::Reference<uno::XInterface>*)0);
    5011             : }
    5012             : 
    5013           1 : sal_Bool SwXTableColumns::hasElements(void) throw( uno::RuntimeException, std::exception )
    5014             : {
    5015           1 :     SolarMutexGuard aGuard;
    5016           1 :     SwFrmFmt* pFrmFmt = GetFrmFmt();
    5017           1 :     if(!pFrmFmt)
    5018           0 :         throw uno::RuntimeException();
    5019           1 :     return sal_True;
    5020             : }
    5021             : 
    5022             : ///@see SwXTableRows::insertByIndex (TODO: seems to be C&P programming here)
    5023           0 : void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
    5024             :     throw (uno::RuntimeException, std::exception)
    5025             : {
    5026           0 :     SolarMutexGuard aGuard;
    5027           0 :     if (nCount == 0)
    5028           0 :         return;
    5029           0 :     SwFrmFmt* pFrmFmt = GetFrmFmt();
    5030           0 :     if(!pFrmFmt)
    5031           0 :         throw uno::RuntimeException();
    5032             :     else
    5033             :     {
    5034           0 :         SwTable* pTable = SwTable::FindTable( pFrmFmt );
    5035           0 :         if(!pTable->IsTblComplex())
    5036             :         {
    5037           0 :             SwTableLines& rLines = pTable->GetTabLines();
    5038           0 :             SwTableLine* pLine = rLines.front();
    5039           0 :             sal_uInt16 nColCount = pLine->GetTabBoxes().size();
    5040           0 :             if (nCount <= 0 || !(0 <= nIndex && nIndex <= nColCount))
    5041             :             {
    5042           0 :                 uno::RuntimeException aExcept;
    5043           0 :                 aExcept.Message = "Illegal arguments";
    5044           0 :                 throw aExcept;
    5045             :             }
    5046             : 
    5047           0 :             OUString sTLName = sw_GetCellName(nIndex, 0);
    5048           0 :             const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
    5049           0 :             bool bAppend = false;
    5050           0 :             if(!pTLBox)
    5051             :             {
    5052           0 :                 bAppend = true;
    5053             :                 // to append at the end the cursor must be in the last line
    5054           0 :                 SwTableBoxes& rBoxes = pLine->GetTabBoxes();
    5055           0 :                 pTLBox = rBoxes.back();
    5056             :             }
    5057           0 :             if(pTLBox)
    5058             :             {
    5059           0 :                 const SwStartNode* pSttNd = pTLBox->GetSttNd();
    5060           0 :                 SwPosition aPos(*pSttNd);
    5061           0 :                 UnoActionContext aAction(pFrmFmt->GetDoc());
    5062           0 :                 SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
    5063           0 :                 pUnoCrsr->Move( fnMoveForward, fnGoNode );
    5064             : 
    5065             :                 {
    5066             :                     // remove actions
    5067           0 :                     UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
    5068             :                 }
    5069             : 
    5070           0 :                 pFrmFmt->GetDoc()->InsertCol(*pUnoCrsr, (sal_uInt16)nCount, bAppend);
    5071           0 :                 delete pUnoCrsr;
    5072           0 :             }
    5073             :         }
    5074           0 :     }
    5075             : }
    5076             : 
    5077             : ///@see SwXTableRows::removeByIndex (TODO: seems to be C&P programming here)
    5078           0 : void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
    5079             :     throw (uno::RuntimeException, std::exception)
    5080             : {
    5081           0 :     SolarMutexGuard aGuard;
    5082           0 :     if (nCount == 0)
    5083           0 :         return;
    5084           0 :     SwFrmFmt* pFrmFmt = GetFrmFmt();
    5085           0 :     if(!pFrmFmt|| nIndex < 0 || nCount <=0 )
    5086           0 :         throw uno::RuntimeException();
    5087             :     else
    5088             :     {
    5089           0 :         bool bSuccess = false;
    5090           0 :         SwTable* pTable = SwTable::FindTable( pFrmFmt );
    5091           0 :         if(!pTable->IsTblComplex())
    5092             :         {
    5093           0 :             OUString sTLName = sw_GetCellName(nIndex, 0);
    5094           0 :             const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
    5095           0 :             if(pTLBox)
    5096             :             {
    5097             :                 {
    5098             :                     // invalidate all actions
    5099           0 :                     UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc());
    5100             :                 }
    5101           0 :                 const SwStartNode* pSttNd = pTLBox->GetSttNd();
    5102           0 :                 SwPosition aPos(*pSttNd);
    5103             :                 // set cursor to the upper-left cell of the range
    5104           0 :                 SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
    5105           0 :                 pUnoCrsr->Move( fnMoveForward, fnGoNode );
    5106           0 :                 pUnoCrsr->SetRemainInSection( sal_False );
    5107           0 :                 OUString sTRName = sw_GetCellName(nIndex + nCount - 1, 0);
    5108           0 :                 const SwTableBox* pTRBox = pTable->GetTblBox( sTRName );
    5109           0 :                 if(pTRBox)
    5110             :                 {
    5111           0 :                     pUnoCrsr->SetMark();
    5112           0 :                     pUnoCrsr->GetPoint()->nNode = *pTRBox->GetSttNd();
    5113           0 :                     pUnoCrsr->Move( fnMoveForward, fnGoNode );
    5114             :                     SwUnoTableCrsr* pCrsr =
    5115           0 :                         dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
    5116           0 :                     pCrsr->MakeBoxSels();
    5117             :                     {   // these braces are important
    5118           0 :                         UnoActionContext aAction(pFrmFmt->GetDoc());
    5119           0 :                         pFrmFmt->GetDoc()->DeleteCol(*pUnoCrsr);
    5120           0 :                         delete pUnoCrsr;
    5121           0 :                         bSuccess = true;
    5122             :                     }
    5123             :                     {
    5124             :                         // invalidate all actions
    5125           0 :                         UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc());
    5126             :                     }
    5127           0 :                 }
    5128           0 :             }
    5129             :         }
    5130           0 :         if(!bSuccess)
    5131             :         {
    5132           0 :             uno::RuntimeException aExcept;
    5133           0 :             aExcept.Message = "Illegal arguments";
    5134           0 :             throw aExcept;
    5135             :         }
    5136           0 :     }
    5137             : }
    5138             : 
    5139           2 : void SwXTableColumns::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
    5140             : {
    5141           2 :     ClientModify(this, pOld, pNew);
    5142           2 : }
    5143             : 
    5144             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10