update dev300-m58
[ooovba.git] / sw / source / core / unocore / unotbl.cxx
blob0adf9c79ac8d7179a508602fe112142a4bf5759a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unotbl.cxx,v $
11 * $Revision: 1.123 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sw.hxx"
38 // STL includes
39 #include <list>
41 #include <float.h> // for DBL_MIN
42 #include <swtypes.hxx>
43 #ifndef _CMDID_H
44 #include <cmdid.h>
45 #endif
46 #include <unotbl.hxx>
47 #include <unostyle.hxx>
48 #include <section.hxx>
49 #include <unocrsr.hxx>
50 #include <svx/unomid.hxx>
51 #include <hints.hxx>
52 #include <swtblfmt.hxx>
53 #include <doc.hxx>
54 #include <shellres.hxx>
55 #include <docary.hxx>
56 #include <ndole.hxx>
57 #include <frame.hxx>
58 #include <vcl/svapp.hxx>
59 #include <fmtfsize.hxx>
60 #include <tblafmt.hxx>
61 #include <tabcol.hxx>
62 #include <cellatr.hxx>
63 #include <fmtpdsc.hxx>
64 #include <pagedesc.hxx>
65 #define _SVSTDARR_STRINGS
66 #include <svtools/svstdarr.hxx>
67 #include <viewsh.hxx>
68 #include <tabfrm.hxx>
69 #include <redline.hxx>
70 #include <unoredline.hxx>
71 #include <unoprnms.hxx>
72 #include <unocrsrhelper.hxx>
73 #include <com/sun/star/text/WrapTextMode.hpp>
74 #include <com/sun/star/text/TextContentAnchorType.hpp>
75 #include <com/sun/star/text/TableColumnSeparator.hpp>
76 #include <com/sun/star/table/ShadowFormat.hpp>
77 #include <com/sun/star/table/TableBorder.hpp>
78 #include <com/sun/star/table/TableBorderDistances.hpp>
79 #include <com/sun/star/style/PageStyleLayout.hpp>
80 #include <com/sun/star/style/BreakType.hpp>
81 #include <com/sun/star/style/GraphicLocation.hpp>
82 #include <com/sun/star/beans/PropertyAttribute.hpp>
83 #include <com/sun/star/chart/XChartDataChangeEventListener.hpp>
84 #include <com/sun/star/chart/ChartDataChangeEvent.hpp>
85 #include <com/sun/star/chart2/data/XDataSequence.hpp>
86 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
87 #include <com/sun/star/table/CellContentType.hpp>
88 #include <unotbl.hxx>
89 #include <unoobj.hxx>
90 #include <svtools/zforlist.hxx> // SvNumberFormatter
91 #include <svx/brkitem.hxx>
92 #include <svx/shaditem.hxx>
93 #include <svx/lrspitem.hxx>
94 #include <svx/ulspitem.hxx>
95 #include <fmtornt.hxx>
96 #include <svx/keepitem.hxx>
97 #include <fmtlsplt.hxx>
98 #include <swundo.hxx>
99 #include <vos/mutex.hxx>
100 #include <SwStyleNameMapper.hxx>
101 #include <frmatr.hxx>
102 #include <crsskip.hxx>
103 #include <unochart.hxx>
104 #include <rtl/math.hxx>
106 using namespace ::com::sun::star;
107 using ::rtl::OUString;
109 //-----------------------------------------------------------------------------
110 // from unoobj.cxx
111 extern void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) throw (lang::IllegalArgumentException);
112 extern void lcl_setCharStyle(SwDoc* pDoc, const uno::Any aValue, SfxItemSet& rSet) throw (lang::IllegalArgumentException);
114 // from swtable.cxx
115 extern void lcl_GetTblBoxColStr( sal_uInt16 nCol, String& rNm );
117 #define UNO_TABLE_COLUMN_SUM 10000
119 /* -----------------17.07.98 15:47-------------------
121 * --------------------------------------------------*/
122 table::BorderLine lcl_SvxLineToLine(const SvxBorderLine* pLine)
124 table::BorderLine aLine;
125 if(pLine)
127 aLine.Color = pLine->GetColor().GetColor() ;
128 aLine.InnerLineWidth = TWIP_TO_MM100_UNSIGNED( pLine->GetInWidth() );
129 aLine.OuterLineWidth = TWIP_TO_MM100_UNSIGNED( pLine->GetOutWidth() );
130 aLine.LineDistance = TWIP_TO_MM100_UNSIGNED( pLine->GetDistance() );
132 else
133 aLine.Color = aLine.InnerLineWidth = aLine.OuterLineWidth = aLine.LineDistance = 0;
134 return aLine;
136 /* -----------------17.07.98 15:52-------------------
138 * --------------------------------------------------*/
139 sal_Bool lcl_LineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine)
141 rSvxLine.SetColor( Color(rLine.Color));
142 rSvxLine.SetInWidth( MM100_TO_TWIP( rLine.InnerLineWidth ) );
143 rSvxLine.SetOutWidth(MM100_TO_TWIP( rLine.OuterLineWidth ) );
144 rSvxLine.SetDistance(MM100_TO_TWIP( rLine.LineDistance ) );
145 sal_Bool bRet = rLine.InnerLineWidth > 0 || rLine.OuterLineWidth > 0;
146 return bRet;
148 /* -----------------11.12.98 14:22-------------------
150 * --------------------------------------------------*/
151 void lcl_SetSpecialProperty(SwFrmFmt* pFmt, const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue)
152 throw (lang::IllegalArgumentException)
154 //Sonderbehandlung fuer "Nicht-Items"
155 switch(pEntry->nWID)
157 case FN_TABLE_HEADLINE_REPEAT:
158 case FN_TABLE_HEADLINE_COUNT:
160 SwTable* pTable = SwTable::FindTable( pFmt );
162 UnoActionContext aAction(pFmt->GetDoc());
163 if( pEntry->nWID == FN_TABLE_HEADLINE_REPEAT)
165 sal_Bool bVal = *(sal_Bool*)aValue.getValue();
166 pFmt->GetDoc()->SetRowsToRepeat( *pTable, bVal ? 1 : 0 );
168 else
170 sal_Int32 nRepeat = 0;
171 aValue >>= nRepeat;
172 if( nRepeat >= 0 && nRepeat < USHRT_MAX )
173 pFmt->GetDoc()->SetRowsToRepeat( *pTable, (USHORT) nRepeat );
177 break;
178 case FN_TABLE_IS_RELATIVE_WIDTH:
179 case FN_TABLE_WIDTH:
180 case FN_TABLE_RELATIVE_WIDTH:
182 sal_Int32 nWidth = 0;
183 SwFmtFrmSize aSz( pFmt->GetFrmSize() );
184 if(FN_TABLE_WIDTH == pEntry->nWID)
186 aValue >>= nWidth;
187 aSz.SetWidthPercent(0);
188 aSz.SetWidth ( MM100_TO_TWIP ( nWidth ) );
190 else if(FN_TABLE_RELATIVE_WIDTH == pEntry->nWID)
192 sal_Int16 nSet = 0;
193 aValue >>= nSet;
194 if(nSet && nSet <=100)
195 aSz.SetWidthPercent( (BYTE)nSet );
197 else if(FN_TABLE_IS_RELATIVE_WIDTH == pEntry->nWID)
199 sal_Bool bPercent = *(sal_Bool*)aValue.getValue();
200 if(!bPercent)
201 aSz.SetWidthPercent(0);
202 else
204 lang::IllegalArgumentException aExcept;
205 aExcept.Message = C2U("relative width cannot be switched on with this property");
206 throw aExcept;
209 pFmt->GetDoc()->SetAttr(aSz, *pFmt);
211 break;
212 case RES_PAGEDESC:
214 OUString uTemp;
215 aValue >>= uTemp;
216 String sPageStyle = uTemp;
217 const SwPageDesc* pDesc = 0;
218 if(sPageStyle.Len())
220 SwStyleNameMapper::FillUIName(sPageStyle, sPageStyle, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True );
221 pDesc = ::GetPageDescByName_Impl(*pFmt->GetDoc(), sPageStyle);
223 SwFmtPageDesc aDesc( pDesc );
224 pFmt->GetDoc()->SetAttr(aDesc, *pFmt);
226 break;
227 default:
228 throw lang::IllegalArgumentException();
232 /* -----------------27.04.98 08:50-------------------
234 * --------------------------------------------------*/
235 uno::Any lcl_GetSpecialProperty(SwFrmFmt* pFmt, const SfxItemPropertySimpleEntry* pEntry )
237 uno::Any aRet;
238 switch(pEntry->nWID)
240 case FN_TABLE_HEADLINE_REPEAT:
241 case FN_TABLE_HEADLINE_COUNT:
243 SwTable* pTable = SwTable::FindTable( pFmt );
244 USHORT nRepeat = pTable->GetRowsToRepeat();
245 if(pEntry->nWID == FN_TABLE_HEADLINE_REPEAT)
247 BOOL bTemp = nRepeat > 0;
248 aRet.setValue(&bTemp, ::getCppuBooleanType());
250 else
251 aRet <<= (sal_Int32)nRepeat;
253 break;
254 case FN_TABLE_WIDTH:
255 case FN_TABLE_IS_RELATIVE_WIDTH:
256 case FN_TABLE_RELATIVE_WIDTH:
258 const SwFmtFrmSize& rSz = pFmt->GetFrmSize();
259 if(FN_TABLE_WIDTH == pEntry->nWID)
260 rSz.QueryValue(aRet, MID_FRMSIZE_WIDTH|CONVERT_TWIPS);
261 else if(FN_TABLE_RELATIVE_WIDTH == pEntry->nWID)
262 rSz.QueryValue(aRet, MID_FRMSIZE_REL_WIDTH);
263 else
265 BOOL bTemp = 0 != rSz.GetWidthPercent();
266 aRet.setValue(&bTemp, ::getBooleanCppuType());
269 break;
270 case RES_PAGEDESC:
272 const SfxItemSet& rSet = pFmt->GetAttrSet();
273 const SfxPoolItem* pItem;
274 String sPDesc;
275 if(SFX_ITEM_SET == rSet.GetItemState(RES_PAGEDESC, sal_False, &pItem))
277 const SwPageDesc* pDsc = ((const SwFmtPageDesc*)pItem)->GetPageDesc();
278 if(pDsc)
280 sPDesc = SwStyleNameMapper::GetProgName(pDsc->GetName(), nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
283 aRet <<= OUString(sPDesc);
285 break;
286 case RES_ANCHOR :
287 aRet <<= text::TextContentAnchorType_AT_PARAGRAPH;
288 break;
289 case FN_UNO_ANCHOR_TYPES :
291 uno::Sequence<text::TextContentAnchorType> aTypes(1);
292 text::TextContentAnchorType* pArray = aTypes.getArray();
293 pArray[0] = text::TextContentAnchorType_AT_PARAGRAPH;
294 aRet <<= aTypes;
296 break;
297 case FN_UNO_WRAP :
299 aRet <<= text::WrapTextMode_NONE;
301 break;
302 case FN_PARAM_LINK_DISPLAY_NAME :
303 aRet <<= OUString(pFmt->GetName());
304 break;
305 case FN_UNO_REDLINE_NODE_START:
306 case FN_UNO_REDLINE_NODE_END:
308 SwTable* pTable = SwTable::FindTable( pFmt );
309 SwNode* pTblNode = pTable->GetTableNode();
310 if(FN_UNO_REDLINE_NODE_END == pEntry->nWID)
311 pTblNode = pTblNode->EndOfSectionNode();
312 const SwRedlineTbl& rRedTbl = pFmt->GetDoc()->GetRedlineTbl();
313 for(USHORT nRed = 0; nRed < rRedTbl.Count(); nRed++)
315 const SwRedline* pRedline = rRedTbl[nRed];
316 const SwNode* pRedPointNode = pRedline->GetNode(TRUE);
317 const SwNode* pRedMarkNode = pRedline->GetNode(FALSE);
318 if(pRedPointNode == pTblNode || pRedMarkNode == pTblNode)
320 const SwNode* pStartOfRedline = SwNodeIndex(*pRedPointNode) <= SwNodeIndex(*pRedMarkNode) ?
321 pRedPointNode : pRedMarkNode;
322 BOOL bIsStart = pStartOfRedline == pTblNode;
323 aRet <<= SwXRedlinePortion::CreateRedlineProperties(*pRedline, bIsStart);
324 break;
328 break;
330 return aRet;
332 /* -----------------19.10.05 08:32-------------------
334 * --------------------------------------------------*/
337 // returns the position for the cell with the specified name
338 // (note that the indices rColumn and rRow are 0 based here)
339 // Also since the implementations of tables does not really have
340 // columns using this function is appropriate only for tables
341 // that are not complex (i.e. where IsTblComplex() returns false).
343 // returns: both indices for column and row (all >= 0) if everything was Ok.
344 // At least one value < 0 if sth was wrong.
346 // Sample for naming scheme of cell in a single row (in groups a 26):
347 // A1..Z1, a1..z1, AA1..AZ1, Aa1..Az1, BA1..BZ1, Ba1..Bz1, ...
348 void lcl_GetCellPosition( const String &rCellName,
349 sal_Int32 &rColumn, sal_Int32 &rRow)
351 rColumn = rRow = -1; // default return values indicating failure
352 xub_StrLen nLen = rCellName.Len();
353 if (nLen)
355 const sal_Unicode *pBuf = rCellName.GetBuffer();
356 const sal_Unicode *pEnd = pBuf + nLen;
357 while (pBuf < pEnd && !('0' <= *pBuf && *pBuf <= '9'))
358 ++pBuf;
359 // start of number found?
360 if (pBuf < pEnd && ('0' <= *pBuf && *pBuf <= '9'))
362 String aColTxt( rCellName.GetBuffer(), static_cast< xub_StrLen >(pBuf - rCellName.GetBuffer()) );
363 String aRowTxt( pBuf, static_cast< xub_StrLen >(rCellName.GetBuffer() + nLen - pBuf) );
364 if (aColTxt.Len() && aRowTxt.Len())
366 sal_Int32 nColIdx = 0;
367 sal_Int32 nLength = aColTxt.Len();
368 for (xub_StrLen i = 0; i < nLength; ++i)
370 nColIdx = 52 * nColIdx;
371 if (i < nLength - 1)
372 ++nColIdx;
373 sal_Unicode cChar = aColTxt.GetBuffer()[i];
374 if ('A' <= cChar && cChar <= 'Z')
375 nColIdx = nColIdx + (cChar - 'A');
376 else if ('a' <= cChar && cChar <= 'z')
377 nColIdx = nColIdx + (26 + cChar - 'a');
378 else
380 nColIdx = -1; // sth failed
381 break;
385 rColumn = nColIdx;
386 rRow = aRowTxt.ToInt32() - 1; // - 1 because indices ought to be 0 based
390 #if OSL_DEBUG_LEVEL > 1
391 DBG_ASSERT( rColumn != -1 && rRow != -1, "failed to get column or row index" );
392 #endif
396 // arguments: must be non-empty strings with valid cell names
398 // returns: -1 if first cell < second cell
399 // 0 if both cells are equal
400 // +1 if the first cell > second cell
402 // Note: this function probably also make sense only
403 // for cell names of non-complex tables
404 int lcl_CompareCellsByRowFirst( const String &rCellName1, const String &rCellName2 )
406 sal_Int32 nCol1 = -1, nRow1 = -1, nCol2 = -1, nRow2 = -1;
407 lcl_GetCellPosition( rCellName1, nCol1, nRow1 );
408 lcl_GetCellPosition( rCellName2, nCol2, nRow2 );
410 if (nRow1 < nRow2 || (nRow1 == nRow2 && nCol1 < nCol2))
411 return -1;
412 else if (nCol1 == nCol2 && nRow1 == nRow2)
413 return 0;
414 else
415 return +1;
419 // arguments: must be non-empty strings with valid cell names
421 // returns: -1 if first cell < second cell
422 // 0 if both cells are equal
423 // +1 if the first cell > second cell
425 // Note: this function probably also make sense only
426 // for cell names of non-complex tables
427 int lcl_CompareCellsByColFirst( const String &rCellName1, const String &rCellName2 )
429 sal_Int32 nCol1 = -1, nRow1 = -1, nCol2 = -1, nRow2 = -1;
430 lcl_GetCellPosition( rCellName1, nCol1, nRow1 );
431 lcl_GetCellPosition( rCellName2, nCol2, nRow2 );
433 if (nCol1 < nCol2 || (nCol1 == nCol2 && nRow1 < nRow2))
434 return -1;
435 else if (nRow1 == nRow2 && nCol1 == nCol2)
436 return 0;
437 else
438 return +1;
442 // arguments: must be non-empty strings with valid cell names
444 // returns: -1 if first cell range < second cell range
445 // 0 if both cell ranges are identical
446 // +1 if the first cell range > second cell range
448 // Note: this function probably also make sense only
449 // for cell names of non-complex tables
450 int lcl_CompareCellRanges(
451 const String &rRange1StartCell, const String &rRange1EndCell,
452 const String &rRange2StartCell, const String &rRange2EndCell,
453 sal_Bool bCmpColsFirst )
455 int (*pCompareCells)( const String &, const String & ) =
456 bCmpColsFirst ? &lcl_CompareCellsByColFirst : &lcl_CompareCellsByRowFirst;
458 int nCmpResStartCells = pCompareCells( rRange1StartCell, rRange2StartCell );
459 if ((-1 == nCmpResStartCells ) ||
460 ( 0 == nCmpResStartCells &&
461 -1 == pCompareCells( rRange1EndCell, rRange2EndCell ) ))
462 return -1;
463 else if (0 == nCmpResStartCells &&
464 0 == pCompareCells( rRange1EndCell, rRange2EndCell ))
465 return 0;
466 else
467 return +1;
471 /* -----------------25.06.98 08:32-------------------
473 * --------------------------------------------------*/
475 // returns the cell name for the cell at the specified position
476 // (note that the indices nColumn and nRow are 0 based here)
477 String lcl_GetCellName( sal_Int32 nColumn, sal_Int32 nRow )
479 #if OSL_DEBUG_LEVEL > 1
481 sal_Int32 nCol, nRow2;
482 lcl_GetCellPosition( String::CreateFromAscii("z1"), nCol, nRow2);
483 DBG_ASSERT( nCol == 51, "lcl_GetCellPosition failed" );
484 lcl_GetCellPosition( String::CreateFromAscii("AA1"), nCol, nRow2);
485 DBG_ASSERT( nCol == 52, "lcl_GetCellPosition failed" );
486 lcl_GetCellPosition( String::CreateFromAscii("AB1"), nCol, nRow2);
487 DBG_ASSERT( nCol == 53, "lcl_GetCellPosition failed" );
488 lcl_GetCellPosition( String::CreateFromAscii("BB1"), nCol, nRow2);
489 DBG_ASSERT( nCol == 105, "lcl_GetCellPosition failed" );
491 #endif
493 String sCellName;
494 if (nColumn < 0 || nRow < 0)
495 return sCellName;
496 lcl_GetTblBoxColStr( static_cast< USHORT >(nColumn), sCellName );
497 sCellName += String::CreateFromInt32( nRow + 1 );
498 return sCellName;
502 /* -----------------21.11.05 14:46-------------------
504 --------------------------------------------------*/
505 // start cell should be in the upper-left corner of the range and
506 // end cell in the lower-right.
507 // I.e. from the four possible representation
508 // A1:C5, C5:A1, A5:C1, C1:A5
509 // only A1:C5 is the one to use
510 void lcl_NormalizeRange(
511 String &rCell1, // will hold the upper-left cell of the range upon return
512 String &rCell2 ) // will hold the lower-right cell of the range upon return
514 sal_Int32 nCol1 = -1, nRow1 = -1, nCol2 = -1, nRow2 = -1;
515 lcl_GetCellPosition( rCell1, nCol1, nRow1 );
516 lcl_GetCellPosition( rCell2, nCol2, nRow2 );
517 if (nCol2 < nCol1 || nRow2 < nRow1)
519 rCell1 = lcl_GetCellName( Min(nCol1, nCol2), Min(nRow1, nRow2) );
520 rCell2 = lcl_GetCellName( Max(nCol1, nCol2), Max(nRow1, nRow2) );
525 void SwRangeDescriptor::Normalize()
527 if (nTop > nBottom)
529 sal_Int32 nTmp = nTop;
530 nTop = nBottom;
531 nBottom = nTmp;
533 if (nLeft > nRight)
535 sal_Int32 nTmp = nLeft;
536 nLeft = nRight;
537 nRight = nTmp;
542 /* -----------------25.06.98 08:32-------------------
544 * --------------------------------------------------*/
545 SwXCell* lcl_CreateXCell(SwFrmFmt* pFmt, sal_Int32 nColumn, sal_Int32 nRow)
547 SwXCell* pXCell = 0;
548 String sCellName = lcl_GetCellName(nColumn, nRow);
549 SwTable* pTable = SwTable::FindTable( pFmt );
550 SwTableBox* pBox = (SwTableBox*)pTable->GetTblBox( sCellName );
551 if(pBox)
553 pXCell = SwXCell::CreateXCell(pFmt, pBox, pTable);
555 return pXCell;
557 /* -----------------20.07.98 12:35-------------------
559 * --------------------------------------------------*/
560 void lcl_InspectLines(SwTableLines& rLines, SvStrings& rAllNames)
562 for( sal_uInt16 i = 0; i < rLines.Count(); i++ )
564 SwTableLine* pLine = rLines[i];
565 SwTableBoxes& rBoxes = pLine->GetTabBoxes();
566 for(sal_uInt16 j = 0; j < rBoxes.Count(); j++)
568 SwTableBox* pBox = rBoxes[j];
569 if(pBox->GetName().Len() && pBox->getRowSpan() > 0 )
570 rAllNames.Insert(new String(pBox->GetName()), rAllNames.Count());
571 SwTableLines& rBoxLines = pBox->GetTabLines();
572 if(rBoxLines.Count())
574 lcl_InspectLines(rBoxLines, rAllNames);
579 /* -----------------02.10.98 15:55-------------------
581 * --------------------------------------------------*/
582 void lcl_FormatTable(SwFrmFmt* pTblFmt)
584 SwClientIter aIter( *pTblFmt );
585 for( SwClient* pC = aIter.First( TYPE( SwFrm ));
586 pC; pC = aIter.Next() )
588 if( ((SwFrm*)pC)->IsTabFrm() )
590 if(((SwFrm*)pC)->IsValid())
591 ((SwFrm*)pC)->InvalidatePos();
592 ((SwTabFrm*)pC)->SetONECalcLowers();
593 ((SwTabFrm*)pC)->Calc();
597 /* -----------------20.07.98 13:15-------------------
599 * --------------------------------------------------*/
600 void lcl_CrsrSelect(SwPaM* pCrsr, sal_Bool bExpand)
602 if(bExpand)
604 if(!pCrsr->HasMark())
605 pCrsr->SetMark();
607 else if(pCrsr->HasMark())
608 pCrsr->DeleteMark();
611 /* -----------------17.07.98 14:36-------------------
613 * --------------------------------------------------*/
614 void lcl_GetTblSeparators(uno::Any& rRet, SwTable* pTable, SwTableBox* pBox, sal_Bool bRow)
616 SwTabCols aCols;
617 aCols.SetLeftMin ( 0 );
618 aCols.SetLeft ( 0 );
619 aCols.SetRight ( UNO_TABLE_COLUMN_SUM );
620 aCols.SetRightMax( UNO_TABLE_COLUMN_SUM );
622 pTable->GetTabCols( aCols, pBox, sal_False, bRow );
624 sal_uInt16 nSepCount = aCols.Count();
625 uno::Sequence< text::TableColumnSeparator> aColSeq(nSepCount);
626 text::TableColumnSeparator* pArray = aColSeq.getArray();
627 sal_Bool bError = sal_False;
628 for(sal_uInt16 i = 0; i < nSepCount; i++)
630 pArray[i].Position = static_cast< sal_Int16 >(aCols[i]);
631 pArray[i].IsVisible = !aCols.IsHidden(i);
632 if(!bRow && !pArray[i].IsVisible)
634 bError = sal_True;
635 break;
638 if(!bError)
639 rRet.setValue(&aColSeq, ::getCppuType((uno::Sequence< text::TableColumnSeparator>*)0));
642 /* -----------------17.07.98 14:36-------------------
644 * --------------------------------------------------*/
645 void lcl_SetTblSeparators(const uno::Any& rVal, SwTable* pTable, SwTableBox* pBox, sal_Bool bRow, SwDoc* pDoc)
647 SwTabCols aOldCols;
649 aOldCols.SetLeftMin ( 0 );
650 aOldCols.SetLeft ( 0 );
651 aOldCols.SetRight ( UNO_TABLE_COLUMN_SUM );
652 aOldCols.SetRightMax( UNO_TABLE_COLUMN_SUM );
654 pTable->GetTabCols( aOldCols, pBox, sal_False, bRow );
655 sal_uInt16 nOldCount = aOldCols.Count();
656 //there's no use in setting tab cols if there's only one column
657 if( !nOldCount )
658 return;
660 const uno::Sequence< text::TableColumnSeparator>* pSepSeq =
661 (uno::Sequence< text::TableColumnSeparator>*) rVal.getValue();
662 if(pSepSeq && pSepSeq->getLength() == nOldCount)
664 SwTabCols aCols(aOldCols);
665 sal_Bool bError = sal_False;
666 const text::TableColumnSeparator* pArray = pSepSeq->getConstArray();
667 sal_Int32 nLastValue = 0;
668 //sal_Int32 nTblWidth = aCols.GetRight() - aCols.GetLeft();
669 for(sal_uInt16 i = 0; i < nOldCount; i++)
671 aCols[i] = pArray[i].Position;
672 if(pArray[i].IsVisible == aCols.IsHidden(i) ||
673 !bRow && aCols.IsHidden(i) ||
674 long(aCols[i] - long(nLastValue)) < 0 ||
675 UNO_TABLE_COLUMN_SUM < aCols[i] )
677 bError = sal_True;
678 break;
680 nLastValue = aCols[i];
682 if(!bError)
684 pDoc->SetTabCols(*pTable, aCols, aOldCols, pBox, bRow );
688 /* -----------------30.04.02 08:00-------------------
690 * --------------------------------------------------*/
691 inline rtl::OUString lcl_getString( SwXCell &rCell )
693 // getString is a member function of the base class...
694 return rCell.getString();
696 /* -----------------30.04.02 08:00-------------------
697 * non UNO function call to set string in SwXCell
698 * --------------------------------------------------*/
699 void lcl_setString( SwXCell &rCell, const rtl::OUString &rTxt,
700 BOOL bKeepNumberFmt )
702 if(rCell.IsValid())
704 SwFrmFmt* pBoxFmt = rCell.pBox->ClaimFrmFmt();
705 pBoxFmt->LockModify();
706 pBoxFmt->ResetFmtAttr( RES_BOXATR_FORMULA );
707 pBoxFmt->ResetFmtAttr( RES_BOXATR_VALUE );
708 if (!bKeepNumberFmt)
709 pBoxFmt->SetFmtAttr( SwTblBoxNumFormat(NUMBERFORMAT_TEXT) );
710 pBoxFmt->UnlockModify();
712 rCell.SwXText::setString(rTxt);
714 /* -----------------30.04.02 08:00-------------------
715 * non UNO function call to get value from SwXCell
716 * --------------------------------------------------*/
717 double lcl_getValue( SwXCell &rCell )
719 double fRet;
720 if(rCell.IsValid() && rCell.getString().getLength()!=0)
721 fRet = rCell.pBox->GetFrmFmt()->GetTblBoxValue().GetValue();
722 else
723 ::rtl::math::setNan( &fRet );
724 return fRet;
726 /* -----------------30.04.02 08:00-------------------
727 * non UNO function call to set value in SwXCell
728 * --------------------------------------------------*/
729 void lcl_setValue( SwXCell &rCell, double nVal )
731 if(rCell.IsValid())
733 // Der Text mu? zunaechst (vielleicht) geloescht werden
734 ULONG nNdPos = rCell.pBox->IsValidNumTxtNd( sal_True );
735 if(ULONG_MAX != nNdPos)
736 lcl_setString( rCell, OUString(), TRUE ); // TRUE == keep number format
737 SwDoc* pDoc = rCell.GetDoc();
738 UnoActionContext aAction(pDoc);
739 SwFrmFmt* pBoxFmt = rCell.pBox->ClaimFrmFmt();
740 SfxItemSet aSet(pDoc->GetAttrPool(), RES_BOXATR_FORMAT, RES_BOXATR_VALUE);
741 const SfxPoolItem* pItem;
743 //!! do we need to set a new number format? Yes, if
744 // - there is no current number format
745 // - the current number format is not a number format according to the number formatter, but rather a text format
746 // - the current number format is not even a valid number formatter number format, but rather Writer's own 'special' text number format
747 if(SFX_ITEM_SET != pBoxFmt->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, sal_True, &pItem)
748 || pDoc->GetNumberFormatter()->IsTextFormat(((SwTblBoxNumFormat*)pItem)->GetValue())
749 || ((SwTblBoxNumFormat*)pItem)->GetValue() == NUMBERFORMAT_TEXT)
751 aSet.Put(SwTblBoxNumFormat(0));
754 SwTblBoxValue aVal(nVal);
755 aSet.Put(aVal);
756 pDoc->SetTblBoxFormulaAttrs( *rCell.pBox, aSet );
757 //Tabelle aktualisieren
758 SwTableFmlUpdate aTblUpdate( SwTable::FindTable( rCell.GetFrmFmt() ));
759 pDoc->UpdateTblFlds( &aTblUpdate );
762 /******************************************************************
763 * SwXCell
764 ******************************************************************/
765 TYPEINIT1(SwXCell, SwClient);
766 /*-- 11.12.98 10:56:23---------------------------------------------------
768 -----------------------------------------------------------------------*/
769 SwXCell::SwXCell(SwFrmFmt* pTblFmt, SwTableBox* pBx, sal_uInt16 nPos ) :
770 SwXText(pTblFmt->GetDoc(), CURSOR_TBLTEXT),
771 SwClient(pTblFmt),
772 m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_CELL)),
773 pBox(pBx),
774 pStartNode(0),
775 nFndPos(nPos)
778 /* -----------------------------09.08.00 15:59--------------------------------
780 ---------------------------------------------------------------------------*/
781 SwXCell::SwXCell(SwFrmFmt* pTblFmt, const SwStartNode& rStartNode) :
782 SwXText(pTblFmt->GetDoc(), CURSOR_TBLTEXT),
783 SwClient(pTblFmt),
784 m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_CELL)),
785 pBox(0),
786 pStartNode(&rStartNode),
787 nFndPos(USHRT_MAX)
791 /*-- 11.12.98 10:56:24---------------------------------------------------
793 -----------------------------------------------------------------------*/
794 SwXCell::~SwXCell()
798 /* -----------------------------10.03.00 18:02--------------------------------
800 ---------------------------------------------------------------------------*/
801 const uno::Sequence< sal_Int8 > & SwXCell::getUnoTunnelId()
803 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
804 return aSeq;
806 /* -----------------------------10.03.00 18:04--------------------------------
808 ---------------------------------------------------------------------------*/
809 sal_Int64 SAL_CALL SwXCell::getSomething( const uno::Sequence< sal_Int8 >& rId )
810 throw(uno::RuntimeException)
812 if( rId.getLength() == 16
813 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
814 rId.getConstArray(), 16 ) )
816 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
818 else
819 return SwXText::getSomething(rId);
821 /* -----------------------------18.05.00 10:18--------------------------------
823 ---------------------------------------------------------------------------*/
824 uno::Sequence< uno::Type > SAL_CALL SwXCell::getTypes( ) throw(uno::RuntimeException)
826 static uno::Sequence< uno::Type > aRetTypes;
827 if(!aRetTypes.getLength())
829 aRetTypes = SwXCellBaseClass::getTypes();
830 uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes();
832 long nIndex = aRetTypes.getLength();
833 aRetTypes.realloc(
834 aRetTypes.getLength() +
835 aTextTypes.getLength());
837 uno::Type* pRetTypes = aRetTypes.getArray();
839 const uno::Type* pTextTypes = aTextTypes.getConstArray();
840 for(long nPos = 0; nPos <aTextTypes.getLength(); nPos++)
841 pRetTypes[nIndex++] = pTextTypes[nPos];
843 return aRetTypes;
845 /* -----------------------------18.05.00 10:18--------------------------------
847 ---------------------------------------------------------------------------*/
848 uno::Sequence< sal_Int8 > SAL_CALL SwXCell::getImplementationId( ) throw(uno::RuntimeException)
850 vos::OGuard aGuard(Application::GetSolarMutex());
851 static uno::Sequence< sal_Int8 > aId( 16 );
852 static sal_Bool bInit = sal_False;
853 if(!bInit)
855 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
856 bInit = sal_True;
858 return aId;
860 /* -----------------------------18.05.00 10:18--------------------------------
862 ---------------------------------------------------------------------------*/
863 void SAL_CALL SwXCell::acquire( ) throw()
865 SwXCellBaseClass::acquire();
867 /* -----------------------------18.05.00 10:18--------------------------------
869 ---------------------------------------------------------------------------*/
870 void SAL_CALL SwXCell::release( ) throw()
872 SwXCellBaseClass::release();
874 /* -----------------------------18.05.00 10:23--------------------------------
876 ---------------------------------------------------------------------------*/
877 uno::Any SAL_CALL SwXCell::queryInterface( const uno::Type& aType )
878 throw (uno::RuntimeException)
880 uno::Any aRet = SwXCellBaseClass::queryInterface(aType);
881 if(aRet.getValueType() == ::getCppuVoidType())
882 aRet = SwXText::queryInterface(aType);
883 return aRet;
885 /*-- 11.12.98 10:56:24---------------------------------------------------
887 -----------------------------------------------------------------------*/
888 const SwStartNode *SwXCell::GetStartNode() const
890 const SwStartNode *pSttNd = 0;
892 if( pStartNode || ((SwXCell *)this)->IsValid() )
893 pSttNd = pStartNode ? pStartNode : pBox->GetSttNd();
895 return pSttNd;
898 uno::Reference< text::XTextCursor > SwXCell::createCursor() throw (uno::RuntimeException)
900 return createTextCursor();
902 /*-- 11.12.98 10:56:24---------------------------------------------------
904 -----------------------------------------------------------------------*/
905 sal_Bool SwXCell::IsValid()
907 SwFrmFmt* pTblFmt = pBox ? GetFrmFmt() : 0;
908 if(!pTblFmt)
909 pBox = 0;
910 else
912 SwTable* pTable = SwTable::FindTable( pTblFmt );
913 const SwTableBox* pFoundBox ;
914 pFoundBox = FindBox(pTable, pBox);
915 if(!pFoundBox)
916 pBox = 0;
918 return 0 != pBox;
920 /*-- 11.12.98 10:56:25---------------------------------------------------
922 -----------------------------------------------------------------------*/
923 OUString SwXCell::getFormula(void) throw( uno::RuntimeException )
925 vos::OGuard aGuard(Application::GetSolarMutex());
926 OUString sRet;
927 if(IsValid())
929 SwTblBoxFormula aFormula( pBox->GetFrmFmt()->GetTblBoxFormula() );
930 SwTable* pTable = SwTable::FindTable( GetFrmFmt() );
931 aFormula.PtrToBoxNm( pTable );
932 sRet = aFormula.GetFormula();
934 return sRet;
936 /*-- 11.12.98 10:56:26---------------------------------------------------
938 -----------------------------------------------------------------------*/
939 void SwXCell::setFormula(const OUString& rFormula) throw( uno::RuntimeException )
941 vos::OGuard aGuard(Application::GetSolarMutex());
942 if(IsValid())
944 // Der Text mu? zunaechst (vielleicht) geloescht werden
945 sal_uInt32 nNdPos = pBox->IsValidNumTxtNd( sal_True );
946 if(USHRT_MAX == nNdPos)
947 lcl_setString( *this, OUString(), TRUE );
948 String sFml(rFormula);
949 if( sFml.EraseLeadingChars().Len() && '=' == sFml.GetChar( 0 ) )
950 sFml.Erase( 0, 1 );
951 SwTblBoxFormula aFml( sFml );
952 SwDoc* pMyDoc = GetDoc();
953 UnoActionContext aAction(pMyDoc);
954 SfxItemSet aSet(pMyDoc->GetAttrPool(), RES_BOXATR_FORMAT, RES_BOXATR_FORMULA);
955 const SfxPoolItem* pItem;
956 SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
957 if(SFX_ITEM_SET != pBoxFmt->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, sal_True, &pItem)
958 || pMyDoc->GetNumberFormatter()->IsTextFormat(((SwTblBoxNumFormat*)pItem)->GetValue()))
960 aSet.Put(SwTblBoxNumFormat(0));
962 aSet.Put(aFml);
963 GetDoc()->SetTblBoxFormulaAttrs( *pBox, aSet );
964 //Tabelle aktualisieren
965 SwTableFmlUpdate aTblUpdate( SwTable::FindTable( GetFrmFmt() ));
966 pMyDoc->UpdateTblFlds( &aTblUpdate );
969 /*-- 11.12.98 10:56:26---------------------------------------------------
971 -----------------------------------------------------------------------*/
972 double SwXCell::getValue(void) throw( uno::RuntimeException )
974 vos::OGuard aGuard(Application::GetSolarMutex());
975 double fRet = lcl_getValue( *this );
976 //lcl_getValue was changed thus it can return nan values,
977 //so I make this additional nan check here to not change the behaviour
978 //but maybe it would even be more correct to just return nan here? ... todo?
979 if( ::rtl::math::isNan( fRet ) )
980 fRet = 0.0;
981 return fRet;
983 /*-- 11.12.98 10:56:26---------------------------------------------------
985 -----------------------------------------------------------------------*/
986 void SwXCell::setValue(double rValue) throw( uno::RuntimeException )
988 vos::OGuard aGuard(Application::GetSolarMutex());
989 lcl_setValue( *this, rValue );
991 /*-- 11.12.98 10:56:26---------------------------------------------------
993 -----------------------------------------------------------------------*/
994 table::CellContentType SwXCell::getType(void) throw( uno::RuntimeException )
996 vos::OGuard aGuard(Application::GetSolarMutex());
998 table::CellContentType nRes = table::CellContentType_EMPTY;
999 sal_uInt32 nNdPos = pBox->IsFormulaOrValueBox();
1000 switch (nNdPos)
1002 case 0 : nRes = table::CellContentType_TEXT; break;
1003 case USHRT_MAX : nRes = table::CellContentType_EMPTY; break;
1004 case RES_BOXATR_VALUE : nRes = table::CellContentType_VALUE; break;
1005 case RES_BOXATR_FORMULA : nRes = table::CellContentType_FORMULA; break;
1006 default :
1007 DBG_ERROR( "unexpected case" );
1009 return nRes;
1011 /* -----------------27.04.99 12:06-------------------
1013 * --------------------------------------------------*/
1014 void SwXCell::setString(const OUString& aString) throw( uno::RuntimeException )
1016 vos::OGuard aGuard(Application::GetSolarMutex());
1017 lcl_setString( *this, aString );
1020 /*-- 11.12.98 10:56:27---------------------------------------------------
1022 -----------------------------------------------------------------------*/
1023 sal_Int32 SwXCell::getError(void) throw( uno::RuntimeException )
1025 vos::OGuard aGuard(Application::GetSolarMutex());
1026 OUString sContent = getString();
1027 return sContent.equals(ViewShell::GetShellRes()->aCalc_Error);
1029 /*-- 11.12.98 10:56:28---------------------------------------------------
1031 -----------------------------------------------------------------------*/
1032 uno::Reference< text::XTextCursor > SwXCell::createTextCursor(void) throw( uno::RuntimeException )
1034 vos::OGuard aGuard(Application::GetSolarMutex());
1035 uno::Reference< text::XTextCursor > aRef;
1036 if(pStartNode || IsValid())
1038 const SwStartNode* pSttNd = pStartNode ? pStartNode : pBox->GetSttNd();
1039 SwPosition aPos(*pSttNd);
1040 SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, CURSOR_TBLTEXT, GetDoc());
1041 SwUnoCrsr* pUnoCrsr = pCrsr->GetCrsr();
1042 pUnoCrsr->Move(fnMoveForward, fnGoNode);
1043 aRef = (text::XWordCursor*)pCrsr;
1044 // // no Cursor in protected sections
1045 // SwCrsrSaveState aSave( *pUnoCrsr );
1046 // if(pUnoCrsr->IsInProtectTable( sal_True ) ||
1047 // pUnoCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE | nsSwCursorSelOverFlags::SELOVER_CHANGEPOS ))
1048 // throw( uno::RuntimeException() );
1050 else
1051 throw uno::RuntimeException();
1052 return aRef;
1054 /*-- 11.12.98 10:56:28---------------------------------------------------
1056 -----------------------------------------------------------------------*/
1057 uno::Reference< text::XTextCursor > SwXCell::createTextCursorByRange(const uno::Reference< text::XTextRange > & xTextPosition)
1058 throw( uno::RuntimeException )
1060 vos::OGuard aGuard(Application::GetSolarMutex());
1061 uno::Reference< text::XTextCursor > aRef;
1062 SwUnoInternalPaM aPam(*GetDoc());
1063 if((pStartNode || IsValid()) && SwXTextRange::XTextRangeToSwPaM(aPam, xTextPosition))
1065 const SwStartNode* pSttNd = pStartNode ? pStartNode : pBox->GetSttNd();
1066 //skip sections
1067 SwStartNode* p1 = aPam.GetNode()->StartOfSectionNode();
1068 while(p1->IsSectionNode())
1069 p1 = p1->StartOfSectionNode();
1071 if( p1 == pSttNd )
1072 aRef = (text::XWordCursor*)new SwXTextCursor(this , *aPam.GetPoint(), CURSOR_TBLTEXT, GetDoc(), aPam.GetMark());
1074 else
1075 throw uno::RuntimeException();
1076 return aRef;
1078 /*-- 11.12.98 10:56:33---------------------------------------------------
1080 -----------------------------------------------------------------------*/
1081 uno::Reference< beans::XPropertySetInfo > SwXCell::getPropertySetInfo(void) throw( uno::RuntimeException )
1083 static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
1084 return xRef;
1086 /*-- 11.12.98 10:56:34---------------------------------------------------
1088 -----------------------------------------------------------------------*/
1089 void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
1090 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException )
1092 vos::OGuard aGuard(Application::GetSolarMutex());
1093 if(IsValid())
1095 const SfxItemPropertySimpleEntry* pEntry =
1096 m_pPropSet->getPropertyMap()->getByName(rPropertyName);
1097 if( !pEntry )
1099 beans::UnknownPropertyException aEx;
1100 aEx.Message = rPropertyName;
1101 throw( aEx );
1103 if( pEntry->nWID == FN_UNO_CELL_ROW_SPAN )
1105 sal_Int32 nRowSpan = 0;
1106 if( aValue >>= nRowSpan )
1107 pBox->setRowSpan( nRowSpan );
1109 else
1111 SwFrmFmt* pBoxFmt = pBox->ClaimFrmFmt();
1112 SwAttrSet aSet(pBoxFmt->GetAttrSet());
1113 m_pPropSet->setPropertyValue(rPropertyName, aValue, aSet);
1114 pBoxFmt->GetDoc()->SetAttr(aSet, *pBoxFmt);
1118 /*-- 11.12.98 10:56:34---------------------------------------------------
1120 -----------------------------------------------------------------------*/
1121 uno::Any SwXCell::getPropertyValue(const OUString& rPropertyName)
1122 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1124 vos::OGuard aGuard(Application::GetSolarMutex());
1125 uno::Any aRet;
1126 if(IsValid())
1128 const SfxItemPropertySimpleEntry* pEntry =
1129 m_pPropSet->getPropertyMap()->getByName(rPropertyName);
1130 if( !pEntry )
1132 beans::UnknownPropertyException aEx;
1133 aEx.Message = rPropertyName;
1134 throw( aEx );
1136 switch( pEntry->nWID )
1138 case FN_UNO_CELL_ROW_SPAN:
1139 aRet <<= pBox->getRowSpan();
1140 break;
1141 case FN_UNO_TEXT_SECTION:
1143 SwFrmFmt* pTblFmt = GetFrmFmt();
1144 SwTable* pTable = SwTable::FindTable( pTblFmt );
1145 SwTableNode* pTblNode = pTable->GetTableNode();
1146 SwSectionNode* pSectionNode = pTblNode->FindSectionNode();
1147 if(pSectionNode)
1149 const SwSection& rSect = pSectionNode->GetSection();
1150 uno::Reference< text::XTextSection > xSect =
1151 SwXTextSections::GetObject( *rSect.GetFmt() );
1152 aRet <<= xSect;
1155 break;
1156 case FN_UNO_CELL_NAME:
1157 aRet <<= OUString ( pBox->GetName() );
1158 break;
1159 case FN_UNO_REDLINE_NODE_START:
1160 case FN_UNO_REDLINE_NODE_END:
1162 //redline can only be returned if it's a living object
1163 aRet = SwXText::getPropertyValue(rPropertyName);
1165 break;
1166 default:
1168 const SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
1169 const SwAttrSet& rSet = pBoxFmt->GetAttrSet();
1170 m_pPropSet->getPropertyValue(rPropertyName, rSet, aRet);
1174 return aRet;
1176 /*-- 11.12.98 10:56:35---------------------------------------------------
1178 -----------------------------------------------------------------------*/
1179 void SwXCell::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1181 DBG_WARNING("not implemented");
1183 /*-- 11.12.98 10:56:35---------------------------------------------------
1185 -----------------------------------------------------------------------*/
1186 void SwXCell::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1188 DBG_WARNING("not implemented");
1190 /*-- 11.12.98 10:56:36---------------------------------------------------
1192 -----------------------------------------------------------------------*/
1193 void SwXCell::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1195 DBG_WARNING("not implemented");
1197 /*-- 11.12.98 10:56:36---------------------------------------------------
1199 -----------------------------------------------------------------------*/
1200 void SwXCell::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1202 DBG_WARNING("not implemented");
1204 /*-- 11.12.98 10:56:37---------------------------------------------------
1206 -----------------------------------------------------------------------*/
1207 uno::Reference< container::XEnumeration > SwXCell::createEnumeration(void) throw( uno::RuntimeException )
1209 vos::OGuard aGuard(Application::GetSolarMutex());
1210 uno::Reference< container::XEnumeration > aRef;
1211 if(IsValid())
1213 const SwStartNode* pSttNd = pBox->GetSttNd();
1214 SwPosition aPos(*pSttNd);
1215 SwUnoCrsr* pUnoCrsr = GetDoc()->CreateUnoCrsr(aPos, sal_False);
1216 pUnoCrsr->Move( fnMoveForward, fnGoNode );
1218 SwXParagraphEnumeration *pEnum = new SwXParagraphEnumeration(this, pUnoCrsr, CURSOR_TBLTEXT);
1219 const SwTableNode* pTblNode = pSttNd->FindTableNode();
1220 // remember table and start node for later travelling
1221 // (used in export of tables in tables)
1222 pEnum->SetOwnTable( &pTblNode->GetTable() );
1223 pEnum->SetOwnStartNode( pSttNd );
1225 aRef = pEnum;
1226 // // no Cursor in protected sections
1227 // SwCrsrSaveState aSave( *pUnoCrsr );
1228 // if(pUnoCrsr->IsInProtectTable( sal_True ) ||
1229 // pUnoCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE | nsSwCursorSelOverFlags::SELOVER_CHANGEPOS ))
1230 // throw( uno::RuntimeException() );
1232 return aRef;
1234 /*-- 11.12.98 10:56:38---------------------------------------------------
1236 -----------------------------------------------------------------------*/
1237 uno::Type SAL_CALL SwXCell::getElementType(void) throw( uno::RuntimeException )
1239 return ::getCppuType((const uno::Reference<text::XTextRange>*)0);
1242 /*-- 11.12.98 10:56:38---------------------------------------------------
1244 -----------------------------------------------------------------------*/
1245 sal_Bool SwXCell::hasElements(void) throw( uno::RuntimeException )
1247 return sal_True;
1249 /*-- 11.12.98 10:56:37---------------------------------------------------
1251 -----------------------------------------------------------------------*/
1252 void SwXCell::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
1254 ClientModify(this, pOld, pNew);
1256 /* -----------------12.06.98 07:54-------------------
1258 * --------------------------------------------------*/
1259 SwXCell* SwXCell::CreateXCell(SwFrmFmt* pTblFmt, SwTableBox* pBox, SwTable *pTable )
1261 SwXCell* pRet = 0;
1262 if(pTblFmt && pBox)
1264 if( !pTable )
1265 pTable = SwTable::FindTable( pTblFmt );
1266 sal_uInt16 nPos = USHRT_MAX;
1267 SwTableBox* pFoundBox =
1268 pTable->GetTabSortBoxes().Seek_Entry( pBox, &nPos ) ? pBox : NULL;
1270 //wenn es die Box gibt, dann wird auch eine Zelle zurueckgegeben
1271 if(pFoundBox)
1273 SwClientIter aIter( *pTblFmt );
1274 SwXCell* pXCell = (SwXCell*)aIter.
1275 First( TYPE( SwXCell ));
1276 while( pXCell )
1278 // gibt es eine passende Zelle bereits?
1279 if(pXCell->GetTblBox() == pBox)
1280 break;
1281 pXCell = (SwXCell*)aIter.Next();
1283 //sonst anlegen
1284 if(!pXCell)
1285 pXCell = new SwXCell(pTblFmt, pBox, nPos );
1286 pRet = pXCell;
1289 return pRet;
1291 /* -----------------12.06.98 07:37-------------------
1292 * exitstiert die Box in der angegebenen Tabelle?
1293 * --------------------------------------------------*/
1294 SwTableBox* SwXCell::FindBox(SwTable* pTable, SwTableBox* pBox2)
1296 // check if nFndPos happens to point to the right table box
1297 if( nFndPos < pTable->GetTabSortBoxes().Count() &&
1298 pBox2 == pTable->GetTabSortBoxes()[ nFndPos ] )
1299 return pBox2;
1301 // if not, seek the entry (and return, if successful)
1302 if( pTable->GetTabSortBoxes().Seek_Entry( pBox2, &nFndPos ))
1303 return pBox2;
1305 // box not found: reset nFndPos pointer
1306 nFndPos = USHRT_MAX;
1307 return 0;
1309 /* -----------------------------19.04.00 15:20--------------------------------
1311 ---------------------------------------------------------------------------*/
1312 OUString SwXCell::getImplementationName(void) throw( uno::RuntimeException )
1314 return C2U("SwXCell");
1316 /* -----------------------------19.04.00 15:20--------------------------------
1318 ---------------------------------------------------------------------------*/
1319 BOOL SwXCell::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
1321 String sServiceName(rServiceName);
1322 return sServiceName.EqualsAscii("com.sun.star.text.CellProperties");
1324 /* -----------------------------19.04.00 15:20--------------------------------
1326 ---------------------------------------------------------------------------*/
1327 uno::Sequence< OUString > SwXCell::getSupportedServiceNames(void) throw( uno::RuntimeException )
1329 uno::Sequence< OUString > aRet(1);
1330 OUString* pArray = aRet.getArray();
1331 pArray[0] = C2U("com.sun.star.text.CellProperties");
1332 return aRet;
1335 /******************************************************************
1336 * SwXTextTableRow
1337 ******************************************************************/
1338 /* -----------------------------19.04.00 15:20--------------------------------
1340 ---------------------------------------------------------------------------*/
1341 OUString SwXTextTableRow::getImplementationName(void) throw( uno::RuntimeException )
1343 return C2U("SwXTextTableRow");
1345 /* -----------------------------19.04.00 15:20--------------------------------
1347 ---------------------------------------------------------------------------*/
1348 BOOL SwXTextTableRow::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
1350 return C2U("com.sun.star.text.TextTableRow") == rServiceName;
1352 /* -----------------------------19.04.00 15:20--------------------------------
1354 ---------------------------------------------------------------------------*/
1355 uno::Sequence< OUString > SwXTextTableRow::getSupportedServiceNames(void) throw( uno::RuntimeException )
1357 uno::Sequence< OUString > aRet(1);
1358 OUString* pArray = aRet.getArray();
1359 pArray[0] = C2U("com.sun.star.text.TextTableRow");
1360 return aRet;
1362 TYPEINIT1(SwXTextTableRow, SwClient);
1363 /*-- 11.12.98 12:04:44---------------------------------------------------
1365 -----------------------------------------------------------------------*/
1366 SwXTextTableRow::SwXTextTableRow(SwFrmFmt* pFmt, SwTableLine* pLn) :
1367 SwClient(pFmt),
1368 m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_ROW)),
1369 pLine(pLn)
1373 /*-- 11.12.98 12:04:45---------------------------------------------------
1375 -----------------------------------------------------------------------*/
1376 SwXTextTableRow::~SwXTextTableRow()
1380 /*-- 11.12.98 12:04:46---------------------------------------------------
1382 -----------------------------------------------------------------------*/
1383 uno::Reference< beans::XPropertySetInfo > SwXTextTableRow::getPropertySetInfo(void) throw( uno::RuntimeException )
1385 static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
1386 return xRef;
1388 /*-- 11.12.98 12:04:46---------------------------------------------------
1390 -----------------------------------------------------------------------*/
1391 void SwXTextTableRow::setPropertyValue(const OUString& rPropertyName,
1392 const uno::Any& aValue)
1393 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException )
1395 vos::OGuard aGuard(Application::GetSolarMutex());
1396 SwFrmFmt* pFmt = GetFrmFmt();
1397 if(pFmt)
1399 SwTable* pTable = SwTable::FindTable( pFmt );
1400 SwTableLine* pLn = SwXTextTableRow::FindLine(pTable, pLine);
1401 if(pLn)
1403 const SfxItemPropertySimpleEntry* pEntry =
1404 m_pPropSet->getPropertyMap()->getByName(rPropertyName);
1405 SwDoc* pDoc = pFmt->GetDoc();
1406 if (!pEntry)
1407 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1408 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
1409 throw beans::PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1411 switch(pEntry->nWID)
1413 case FN_UNO_ROW_HEIGHT:
1414 case FN_UNO_ROW_AUTO_HEIGHT:
1416 SwFmtFrmSize aFrmSize(pLn->GetFrmFmt()->GetFrmSize());
1417 if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID)
1419 sal_Bool bSet = *(sal_Bool*)aValue.getValue();
1420 aFrmSize.SetHeightSizeType(bSet ? ATT_VAR_SIZE : ATT_FIX_SIZE);
1422 else
1424 sal_Int32 nHeight = 0;
1425 aValue >>= nHeight;
1426 Size aSz(aFrmSize.GetSize());
1427 aSz.Height() = MM100_TO_TWIP(nHeight);
1428 aFrmSize.SetSize(aSz);
1430 pDoc->SetAttr(aFrmSize, *pLn->ClaimFrmFmt());
1432 break;
1433 case FN_UNO_TABLE_COLUMN_SEPARATORS:
1435 UnoActionContext aContext(pDoc);
1436 SwTable* pTable2 = SwTable::FindTable( pFmt );
1437 lcl_SetTblSeparators(aValue, pTable2, pLine->GetTabBoxes()[0], sal_True, pDoc);
1439 break;
1440 default:
1442 SwFrmFmt* pLnFmt = pLn->ClaimFrmFmt();
1443 SwAttrSet aSet(pLnFmt->GetAttrSet());
1444 m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
1445 pDoc->SetAttr(aSet, *pLnFmt);
1451 /*-- 11.12.98 12:04:47---------------------------------------------------
1453 -----------------------------------------------------------------------*/
1454 uno::Any SwXTextTableRow::getPropertyValue(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1456 vos::OGuard aGuard(Application::GetSolarMutex());
1457 uno::Any aRet;
1458 SwFrmFmt* pFmt = GetFrmFmt();
1459 if(pFmt)
1461 SwTable* pTable = SwTable::FindTable( pFmt );
1462 SwTableLine* pLn = SwXTextTableRow::FindLine(pTable, pLine);
1463 if(pLn)
1465 const SfxItemPropertySimpleEntry* pEntry =
1466 m_pPropSet->getPropertyMap()->getByName(rPropertyName);
1467 if (!pEntry)
1468 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1470 switch(pEntry->nWID)
1472 case FN_UNO_ROW_HEIGHT:
1473 case FN_UNO_ROW_AUTO_HEIGHT:
1475 const SwFmtFrmSize& rSize = pLn->GetFrmFmt()->GetFrmSize();
1476 if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID)
1478 BOOL bTmp = ATT_VAR_SIZE == rSize.GetHeightSizeType();
1479 aRet.setValue(&bTmp, ::getCppuBooleanType());
1481 else
1482 aRet <<= (sal_Int32)(TWIP_TO_MM100(rSize.GetSize().Height()));
1484 break;
1485 case FN_UNO_TABLE_COLUMN_SEPARATORS:
1487 lcl_GetTblSeparators(aRet, pTable, pLine->GetTabBoxes()[0], sal_True);
1489 break;
1490 default:
1492 const SwAttrSet& rSet = pLn->GetFrmFmt()->GetAttrSet();
1493 m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
1498 return aRet;
1500 /*-- 11.12.98 12:04:47---------------------------------------------------
1502 -----------------------------------------------------------------------*/
1503 void SwXTextTableRow::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1505 DBG_WARNING("not implemented");
1507 /*-- 11.12.98 12:04:48---------------------------------------------------
1509 -----------------------------------------------------------------------*/
1510 void SwXTextTableRow::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1512 DBG_WARNING("not implemented");
1514 /*-- 11.12.98 12:04:48---------------------------------------------------
1516 -----------------------------------------------------------------------*/
1517 void SwXTextTableRow::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1519 DBG_WARNING("not implemented");
1521 /*-- 11.12.98 12:04:49---------------------------------------------------
1523 -----------------------------------------------------------------------*/
1524 void SwXTextTableRow::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1526 DBG_WARNING("not implemented");
1528 /*-- 11.12.98 12:04:49---------------------------------------------------
1530 -----------------------------------------------------------------------*/
1531 void SwXTextTableRow::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
1533 ClientModify(this, pOld, pNew);
1535 /*-- 11.12.98 12:04:50---------------------------------------------------
1537 -----------------------------------------------------------------------*/
1538 SwTableLine* SwXTextTableRow::FindLine(SwTable* pTable, SwTableLine* pLine)
1540 SwTableLine* pRet = 0;
1541 SwTableLines &rLines = pTable->GetTabLines();
1542 for(sal_uInt16 i = 0; i < rLines.Count(); i++)
1543 if(rLines.GetObject(i) == pLine)
1545 pRet = pLine;
1546 break;
1548 return pRet;
1551 /******************************************************************
1552 * SwXTextTableCursor
1553 ******************************************************************/
1554 /* -----------------------------19.04.00 15:21--------------------------------
1556 ---------------------------------------------------------------------------*/
1557 OUString SwXTextTableCursor::getImplementationName(void) throw( uno::RuntimeException )
1559 return C2U("SwXTextTableCursor");
1561 /* -----------------------------19.04.00 15:21--------------------------------
1563 ---------------------------------------------------------------------------*/
1564 BOOL SwXTextTableCursor::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
1566 return C2U("com.sun.star.text.TextTableCursor") == rServiceName;
1568 // -----------------------------------------------------------------------------
1569 IMPLEMENT_FORWARD_XINTERFACE2(SwXTextTableCursor,SwXTextTableCursor_Base,OTextCursorHelper)
1570 const SwPaM* SwXTextTableCursor::GetPaM() const { return GetCrsr(); }
1571 SwPaM* SwXTextTableCursor::GetPaM() { return GetCrsr(); }
1572 const SwDoc* SwXTextTableCursor::GetDoc() const { return GetFrmFmt()->GetDoc(); }
1573 SwDoc* SwXTextTableCursor::GetDoc() { return GetFrmFmt()->GetDoc(); }
1574 const SwUnoCrsr* SwXTextTableCursor::GetCrsr() const { return (SwUnoCrsr*)aCrsrDepend.GetRegisteredIn(); }
1575 SwUnoCrsr* SwXTextTableCursor::GetCrsr() { return (SwUnoCrsr*)aCrsrDepend.GetRegisteredIn(); }
1576 /* -----------------------------19.04.00 15:21--------------------------------
1578 ---------------------------------------------------------------------------*/
1579 uno::Sequence< OUString > SwXTextTableCursor::getSupportedServiceNames(void) throw( uno::RuntimeException )
1581 uno::Sequence< OUString > aRet(1);
1582 OUString* pArray = aRet.getArray();
1583 pArray[0] = C2U("com.sun.star.text.TextTableCursor");
1584 return aRet;
1587 /*-- 11.12.98 12:16:13---------------------------------------------------
1589 -----------------------------------------------------------------------*/
1590 SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt* pFmt, SwTableBox* pBox) :
1591 SwClient(pFmt),
1592 aCrsrDepend(this, 0),
1593 m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR))
1595 SwDoc* pDoc = pFmt->GetDoc();
1596 const SwStartNode* pSttNd = pBox->GetSttNd();
1597 SwPosition aPos(*pSttNd);
1598 SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(aPos, sal_True);
1599 pUnoCrsr->Move( fnMoveForward, fnGoNode );
1600 pUnoCrsr->Add(&aCrsrDepend);
1601 SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
1602 pTblCrsr->MakeBoxSels();
1604 /*-- 11.12.98 12:16:14---------------------------------------------------
1606 -----------------------------------------------------------------------*/
1607 SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt& rTableFmt, const SwTableCursor* pTableSelection) :
1608 SwClient(&rTableFmt),
1609 aCrsrDepend(this, 0),
1610 m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR))
1612 SwUnoCrsr* pUnoCrsr = pTableSelection->GetDoc()->CreateUnoCrsr(*pTableSelection->GetPoint(), sal_True);
1613 if(pTableSelection->HasMark())
1615 pUnoCrsr->SetMark();
1616 *pUnoCrsr->GetMark() = *pTableSelection->GetMark();
1618 const SwSelBoxes& rBoxes = pTableSelection->GetBoxes();
1619 SwTableCursor* pTableCrsr = dynamic_cast<SwTableCursor*>(pUnoCrsr);
1620 for(sal_uInt16 i = 0; i < rBoxes.Count(); i++)
1621 pTableCrsr->InsertBox( *rBoxes.GetObject(i) );
1623 pUnoCrsr->Add(&aCrsrDepend);
1624 SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
1625 pTblCrsr->MakeBoxSels();
1627 /*-- 11.12.98 12:16:14---------------------------------------------------
1629 -----------------------------------------------------------------------*/
1630 SwXTextTableCursor::~SwXTextTableCursor()
1632 vos::OGuard aGuard(Application::GetSolarMutex());
1633 SwUnoCrsr* pUnoCrsr = GetCrsr();
1634 if(pUnoCrsr)
1635 delete pUnoCrsr;
1637 /*-- 11.12.98 12:16:15---------------------------------------------------
1639 -----------------------------------------------------------------------*/
1640 OUString SwXTextTableCursor::getRangeName(void) throw( uno::RuntimeException )
1642 vos::OGuard aGuard(Application::GetSolarMutex());
1643 OUString aRet;
1644 SwUnoCrsr* pUnoCrsr = GetCrsr();
1646 //!! see also SwChartDataSequence::getSourceRangeRepresentation
1647 if(pUnoCrsr)
1649 SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
1650 pTblCrsr->MakeBoxSels();
1651 const SwStartNode* pNode = pTblCrsr->GetPoint()->nNode.GetNode().FindTableBoxStartNode();
1652 const SwTable* pTable = SwTable::FindTable( GetFrmFmt() );
1653 const SwTableBox* pEndBox = pTable->GetTblBox( pNode->GetIndex());
1654 String aTmp( pEndBox->GetName() );
1656 if(pTblCrsr->HasMark())
1658 pNode = pTblCrsr->GetMark()->nNode.GetNode().FindTableBoxStartNode();
1659 const SwTableBox* pStartBox = pTable->GetTblBox( pNode->GetIndex());
1660 if(pEndBox != pStartBox)
1662 // need to switch start and end?
1663 if (*pTblCrsr->GetPoint() < *pTblCrsr->GetMark())
1665 const SwTableBox* pTmpBox = pStartBox;
1666 pStartBox = pEndBox;
1667 pEndBox = pTmpBox;
1670 aTmp = pStartBox->GetName();
1671 aTmp += ':';
1672 aTmp += pEndBox->GetName();
1675 aRet = aTmp;
1677 return aRet;
1679 /*-- 11.12.98 12:16:15---------------------------------------------------
1681 -----------------------------------------------------------------------*/
1682 sal_Bool SwXTextTableCursor::gotoCellByName(const OUString& CellName, sal_Bool Expand)
1683 throw( uno::RuntimeException )
1685 vos::OGuard aGuard(Application::GetSolarMutex());
1686 sal_Bool bRet = sal_False;
1687 SwUnoCrsr* pUnoCrsr = GetCrsr();
1688 if(pUnoCrsr)
1690 SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
1691 lcl_CrsrSelect( pTblCrsr, Expand );
1692 String sCellName(CellName);
1693 bRet = pTblCrsr->GotoTblBox(sCellName);
1695 return bRet;
1697 /*-- 11.12.98 12:16:15---------------------------------------------------
1699 -----------------------------------------------------------------------*/
1700 sal_Bool SwXTextTableCursor::goLeft(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException )
1702 vos::OGuard aGuard(Application::GetSolarMutex());
1703 sal_Bool bRet = sal_False;
1704 SwUnoCrsr* pUnoCrsr = GetCrsr();
1705 if(pUnoCrsr)
1707 SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
1708 lcl_CrsrSelect( pTblCrsr, Expand );
1709 bRet = pTblCrsr->Left( Count,CRSR_SKIP_CHARS, FALSE, FALSE);
1711 return bRet;
1713 /*-- 11.12.98 12:16:15---------------------------------------------------
1715 -----------------------------------------------------------------------*/
1716 sal_Bool SwXTextTableCursor::goRight(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException )
1718 vos::OGuard aGuard(Application::GetSolarMutex());
1719 sal_Bool bRet = sal_False;
1720 SwUnoCrsr* pUnoCrsr = GetCrsr();
1721 if(pUnoCrsr)
1723 SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
1724 lcl_CrsrSelect( pTblCrsr, Expand );
1725 bRet = pTblCrsr->Right( Count, CRSR_SKIP_CHARS, FALSE, FALSE);
1727 return bRet;
1729 /*-- 11.12.98 12:16:16---------------------------------------------------
1731 -----------------------------------------------------------------------*/
1732 sal_Bool SwXTextTableCursor::goUp(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException )
1734 vos::OGuard aGuard(Application::GetSolarMutex());
1735 sal_Bool bRet = sal_False;
1736 SwUnoCrsr* pUnoCrsr = GetCrsr();
1737 if(pUnoCrsr)
1739 SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
1740 lcl_CrsrSelect( pTblCrsr, Expand );
1741 bRet = pTblCrsr->UpDown(sal_True, Count, 0, 0);
1743 return bRet;
1745 /*-- 11.12.98 12:16:16---------------------------------------------------
1747 -----------------------------------------------------------------------*/
1748 sal_Bool SwXTextTableCursor::goDown(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException )
1750 vos::OGuard aGuard(Application::GetSolarMutex());
1751 sal_Bool bRet = sal_False;
1752 SwUnoCrsr* pUnoCrsr = GetCrsr();
1753 if(pUnoCrsr)
1755 SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
1756 lcl_CrsrSelect( pTblCrsr, Expand );
1757 bRet = pTblCrsr->UpDown(sal_False, Count, 0, 0);
1759 return bRet;
1761 /*-- 11.12.98 12:16:16---------------------------------------------------
1763 -----------------------------------------------------------------------*/
1764 void SwXTextTableCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException )
1766 vos::OGuard aGuard(Application::GetSolarMutex());
1767 SwUnoCrsr* pUnoCrsr = GetCrsr();
1768 if(pUnoCrsr)
1770 SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
1771 lcl_CrsrSelect( pTblCrsr, Expand );
1772 pTblCrsr->MoveTable(fnTableCurr, fnTableStart);
1775 /*-- 11.12.98 12:16:16---------------------------------------------------
1777 -----------------------------------------------------------------------*/
1778 void SwXTextTableCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException )
1780 vos::OGuard aGuard(Application::GetSolarMutex());
1781 SwUnoCrsr* pUnoCrsr = GetCrsr();
1782 if(pUnoCrsr)
1784 SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
1785 lcl_CrsrSelect( pTblCrsr, Expand );
1786 pTblCrsr->MoveTable(fnTableCurr, fnTableEnd);
1789 /*-- 11.12.98 12:16:16---------------------------------------------------
1791 -----------------------------------------------------------------------*/
1792 sal_Bool SwXTextTableCursor::mergeRange(void) throw( uno::RuntimeException )
1794 vos::OGuard aGuard(Application::GetSolarMutex());
1795 sal_Bool bRet = sal_False;
1796 SwUnoCrsr* pUnoCrsr = GetCrsr();
1797 if(pUnoCrsr)
1800 // hier muessen die Actions aufgehoben werden
1801 UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
1803 SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
1804 pTblCrsr->MakeBoxSels();
1807 UnoActionContext aContext(pUnoCrsr->GetDoc());
1808 bRet = TBLMERGE_OK == pTblCrsr->GetDoc()->MergeTbl(*pTblCrsr);
1809 if(bRet)
1811 USHORT nCount = pTblCrsr->GetBoxesCount();
1812 while(nCount--)
1813 pTblCrsr->DeleteBox(nCount);
1816 pTblCrsr->MakeBoxSels();
1818 return bRet;
1820 /*-- 11.12.98 12:16:16---------------------------------------------------
1822 -----------------------------------------------------------------------*/
1823 sal_Bool SwXTextTableCursor::splitRange(sal_Int16 Count, sal_Bool Horizontal) throw( uno::RuntimeException )
1825 vos::OGuard aGuard(Application::GetSolarMutex());
1826 if (Count <= 0)
1827 throw uno::RuntimeException( OUString( RTL_CONSTASCII_USTRINGPARAM( "Illegal first argument: needs to be > 0" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1828 sal_Bool bRet = sal_False;
1829 SwUnoCrsr* pUnoCrsr = GetCrsr();
1830 if(pUnoCrsr)
1833 // hier muessen die Actions aufgehoben werden
1834 UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
1836 SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
1837 pTblCrsr->MakeBoxSels();
1839 UnoActionContext aContext(pUnoCrsr->GetDoc());
1840 bRet = pTblCrsr->GetDoc()->SplitTbl( pTblCrsr->GetBoxes(), !Horizontal, Count );
1842 pTblCrsr->MakeBoxSels();
1844 return bRet;
1846 /*-- 11.12.98 12:16:17---------------------------------------------------
1848 -----------------------------------------------------------------------*/
1849 uno::Reference< beans::XPropertySetInfo > SwXTextTableCursor::getPropertySetInfo(void) throw( uno::RuntimeException )
1851 static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
1852 return xRef;
1854 /*-- 11.12.98 12:16:17---------------------------------------------------
1856 -----------------------------------------------------------------------*/
1857 extern sal_Bool lcl_setCrsrPropertyValue(const SfxItemPropertySimpleEntry* pEntry,
1858 SwPaM& rPam,
1859 SfxItemSet& rSet,
1860 const uno::Any& aValue ) throw (lang::IllegalArgumentException);
1863 void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName,
1864 const uno::Any& aValue)
1865 throw( beans::UnknownPropertyException,
1866 beans::PropertyVetoException,
1867 lang::IllegalArgumentException,
1868 lang::WrappedTargetException,
1869 uno::RuntimeException)
1871 vos::OGuard aGuard(Application::GetSolarMutex());
1872 SwUnoCrsr* pUnoCrsr = GetCrsr();
1873 if(pUnoCrsr)
1875 SwStartNode* pSttNode = pUnoCrsr->GetNode()->StartOfSectionNode();
1876 const SwTableNode* pTblNode = pSttNode->FindTableNode();
1877 lcl_FormatTable((SwFrmFmt*)pTblNode->GetTable().GetFrmFmt());
1878 SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
1879 const SfxItemPropertySimpleEntry* pEntry =
1880 m_pPropSet->getPropertyMap()->getByName(rPropertyName);
1881 if(pEntry)
1883 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
1884 throw beans::PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1885 pTblCrsr->MakeBoxSels();
1886 SwDoc* pDoc = pUnoCrsr->GetDoc();
1887 switch(pEntry->nWID )
1889 case FN_UNO_TABLE_CELL_BACKGROUND:
1891 SvxBrushItem aBrush( RES_BACKGROUND );
1892 pDoc->GetBoxAttr( *pUnoCrsr, aBrush );
1893 aBrush.PutValue(aValue, pEntry->nMemberId);
1894 pDoc->SetBoxAttr( *pUnoCrsr, aBrush );
1897 break;
1898 case RES_BOXATR_FORMAT:
1900 SfxUInt32Item aNumberFormat(RES_BOXATR_FORMAT);
1901 aNumberFormat.PutValue(aValue, 0);
1902 pDoc->SetBoxAttr( *pUnoCrsr, aNumberFormat);
1904 break;
1905 case FN_UNO_PARA_STYLE:
1906 lcl_SetTxtFmtColl(aValue, *pUnoCrsr);
1907 break;
1908 default:
1910 SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID );
1911 SwXTextCursor::GetCrsrAttr( pTblCrsr->GetSelRing(), aItemSet );
1913 if(!lcl_setCrsrPropertyValue( pEntry, pTblCrsr->GetSelRing(), aItemSet, aValue ))
1914 m_pPropSet->setPropertyValue( *pEntry, aValue, aItemSet );
1915 SwXTextCursor::SetCrsrAttr( pTblCrsr->GetSelRing(), aItemSet, CRSR_ATTR_MODE_TABLE );
1919 else
1920 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1923 /*-- 11.12.98 12:16:17---------------------------------------------------
1925 -----------------------------------------------------------------------*/
1926 uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName)
1927 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1929 vos::OGuard aGuard(Application::GetSolarMutex());
1930 uno::Any aRet;
1931 SwUnoCrsr* pUnoCrsr = GetCrsr();
1932 if(pUnoCrsr)
1934 SwStartNode* pSttNode = pUnoCrsr->GetNode()->StartOfSectionNode();
1935 const SwTableNode* pTblNode = pSttNode->FindTableNode();
1936 lcl_FormatTable((SwFrmFmt*)pTblNode->GetTable().GetFrmFmt());
1937 SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
1938 const SfxItemPropertySimpleEntry* pEntry =
1939 m_pPropSet->getPropertyMap()->getByName(rPropertyName);
1940 if(pEntry)
1942 pTblCrsr->MakeBoxSels();
1943 switch(pEntry->nWID )
1945 case FN_UNO_TABLE_CELL_BACKGROUND:
1947 SvxBrushItem aBrush( RES_BACKGROUND );
1948 if(pTblCrsr->GetDoc()->GetBoxAttr( *pUnoCrsr, aBrush ))
1949 aBrush.QueryValue(aRet, pEntry->nMemberId);
1952 break;
1953 case RES_BOXATR_FORMAT:
1954 //GetAttr fuer Tabellenselektion am Doc fehlt noch
1955 DBG_WARNING("not implemented");
1956 break;
1957 case FN_UNO_PARA_STYLE:
1959 SwFmtColl* pFmt = SwXTextCursor::GetCurTxtFmtColl(*pUnoCrsr, FALSE);
1960 OUString sRet;
1961 if(pFmt)
1962 sRet = pFmt->GetName();
1963 aRet <<= sRet;
1965 break;
1966 default:
1968 SfxItemSet aSet(pTblCrsr->GetDoc()->GetAttrPool(),
1969 RES_CHRATR_BEGIN, RES_FRMATR_END -1,
1970 RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
1971 0L);
1972 // erstmal die Attribute des Cursors
1973 SwXTextCursor::GetCrsrAttr(pTblCrsr->GetSelRing(), aSet);
1974 m_pPropSet->getPropertyValue(*pEntry, aSet, aRet);
1978 else
1979 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1981 return aRet;
1983 /*-- 11.12.98 12:16:18---------------------------------------------------
1985 -----------------------------------------------------------------------*/
1986 void SwXTextTableCursor::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1988 DBG_WARNING("not implemented");
1990 /*-- 11.12.98 12:16:18---------------------------------------------------
1992 -----------------------------------------------------------------------*/
1993 void SwXTextTableCursor::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1995 DBG_WARNING("not implemented");
1997 /*-- 11.12.98 12:16:18---------------------------------------------------
1999 -----------------------------------------------------------------------*/
2000 void SwXTextTableCursor::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2002 DBG_WARNING("not implemented");
2004 /*-- 11.12.98 12:16:19---------------------------------------------------
2006 -----------------------------------------------------------------------*/
2007 void SwXTextTableCursor::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2009 DBG_WARNING("not implemented");
2011 /*-- 11.12.98 12:16:19---------------------------------------------------
2013 -----------------------------------------------------------------------*/
2014 void SwXTextTableCursor::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
2016 ClientModify(this, pOld, pNew);
2018 /******************************************************************
2019 * SwXTextTable
2020 ******************************************************************/
2021 /****************************************************************************
2022 Tabellenbeschreibung
2023 ****************************************************************************/
2025 class SwTableProperties_Impl
2027 SwUnoCursorHelper::SwAnyMapHelper aAnyMap;
2028 public:
2029 SwTableProperties_Impl();
2030 ~SwTableProperties_Impl();
2032 void SetProperty(USHORT nWhichId, USHORT nMemberId, const uno::Any& aVal);
2033 sal_Bool GetProperty(USHORT nWhichId, USHORT nMemberId, const uno::Any*& rpAny);
2035 void ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc);
2038 /* -----------------22.06.98 09:43-------------------
2040 * --------------------------------------------------*/
2041 SwTableProperties_Impl::SwTableProperties_Impl()
2044 /* -----------------22.06.98 09:51-------------------
2046 * --------------------------------------------------*/
2047 SwTableProperties_Impl::~SwTableProperties_Impl()
2050 /* -----------------22.06.98 09:51-------------------
2052 * --------------------------------------------------*/
2053 void SwTableProperties_Impl::SetProperty(USHORT nWhichId, USHORT nMemberId, const uno::Any& rVal)
2055 aAnyMap.SetValue( nWhichId, nMemberId, rVal );
2057 /* -----------------22.06.98 09:51-------------------
2059 * --------------------------------------------------*/
2061 sal_Bool SwTableProperties_Impl::GetProperty(USHORT nWhichId, USHORT nMemberId, const uno::Any*& rpAny )
2063 return aAnyMap.FillValue( nWhichId, nMemberId, rpAny );
2065 /* -----------------13.01.99 15:42-------------------
2067 * --------------------------------------------------*/
2068 void SwTableProperties_Impl::ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc)
2070 SfxItemSet aSet(rDoc.GetAttrPool(),
2071 RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT,
2072 RES_BACKGROUND, RES_BACKGROUND,
2073 RES_FRM_SIZE, RES_UL_SPACE,
2074 RES_HORI_ORIENT, RES_HORI_ORIENT,
2075 RES_BREAK, RES_BREAK,
2076 RES_KEEP, RES_KEEP,
2077 RES_SHADOW, RES_SHADOW,
2078 RES_PAGEDESC, RES_PAGEDESC,
2081 const uno::Any* pRepHead;
2082 const SwFrmFmt &rFrmFmt = *rTbl.GetFrmFmt();
2083 if(GetProperty(FN_TABLE_HEADLINE_REPEAT, 0xff, pRepHead ))
2085 sal_Bool bVal = *(sal_Bool*)pRepHead->getValue();
2086 ((SwTable&)rTbl).SetRowsToRepeat( bVal ? 1 : 0 ); // TODO MULTIHEADER
2089 const uno::Any* pBackColor = 0;
2090 GetProperty(RES_BACKGROUND, MID_BACK_COLOR, pBackColor );
2091 const uno::Any* pBackTrans = 0;
2092 GetProperty(RES_BACKGROUND, MID_GRAPHIC_TRANSPARENT, pBackTrans );
2093 const uno::Any* pGrLoc = 0;
2094 GetProperty(RES_BACKGROUND, MID_GRAPHIC_POSITION, pGrLoc );
2095 const uno::Any* pGrURL = 0;
2096 GetProperty(RES_BACKGROUND, MID_GRAPHIC_URL, pGrURL );
2097 const uno::Any* pGrFilter = 0;
2098 GetProperty(RES_BACKGROUND, MID_GRAPHIC_FILTER, pGrFilter );
2100 if(pBackColor||pBackTrans||pGrURL||pGrFilter||pGrLoc)
2102 SvxBrushItem aBrush ( rFrmFmt.GetBackground() );
2103 if(pBackColor)
2104 aBrush.PutValue(*pBackColor, MID_BACK_COLOR);
2105 if(pBackTrans)
2106 aBrush.PutValue(*pBackTrans, MID_GRAPHIC_TRANSPARENT);
2107 if(pGrURL)
2108 aBrush.PutValue(*pGrURL, MID_GRAPHIC_URL);
2109 if(pGrFilter)
2110 aBrush.PutValue(*pGrFilter, MID_GRAPHIC_FILTER);
2111 if(pGrLoc)
2112 aBrush.PutValue(*pGrLoc, MID_GRAPHIC_POSITION);
2113 aSet.Put(aBrush);
2116 sal_Bool bPutBreak = sal_True;
2117 const uno::Any* pPage;
2118 if(GetProperty(FN_UNO_PAGE_STYLE, 0, pPage) || GetProperty(RES_PAGEDESC, 0xff, pPage))
2120 OUString uTmp;
2121 (*pPage) >>= uTmp;
2122 String sPageStyle = uTmp;
2123 if(sPageStyle.Len())
2125 SwStyleNameMapper::FillUIName(sPageStyle, sPageStyle, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True );
2126 const SwPageDesc* pDesc = ::GetPageDescByName_Impl(rDoc, sPageStyle);
2127 if(pDesc)
2129 SwFmtPageDesc aDesc( pDesc );
2130 const uno::Any* pPgNo;
2131 if(GetProperty(RES_PAGEDESC, MID_PAGEDESC_PAGENUMOFFSET, pPgNo ))
2133 INT16 nTmp = 0;
2134 (*pPgNo) >>= nTmp;
2135 aDesc.SetNumOffset( nTmp );
2137 aSet.Put(aDesc);
2138 bPutBreak = sal_False;
2143 const uno::Any* pBreak;
2144 if(bPutBreak && GetProperty(RES_BREAK, 0, pBreak))
2146 SvxFmtBreakItem aBreak ( rFrmFmt.GetBreak() );
2147 aBreak.PutValue(*pBreak, 0);
2148 aSet.Put(aBreak);
2150 const uno::Any* pShadow;
2151 if(GetProperty(RES_SHADOW, 0, pShadow))
2153 SvxShadowItem aShd ( rFrmFmt.GetShadow() );
2154 aShd.PutValue(*pShadow, CONVERT_TWIPS);
2155 aSet.Put(aShd);
2157 const uno::Any* pKeep;
2158 if(GetProperty(RES_KEEP, 0, pKeep))
2160 SvxFmtKeepItem aKeep( rFrmFmt.GetKeep() );
2161 aKeep.PutValue(*pKeep, 0);
2162 aSet.Put(aKeep);
2165 sal_Bool bFullAlign = sal_True;
2166 const uno::Any* pHOrient;
2167 if(GetProperty(RES_HORI_ORIENT, MID_HORIORIENT_ORIENT, pHOrient))
2169 SwFmtHoriOrient aOrient ( rFrmFmt.GetHoriOrient() );
2170 ((SfxPoolItem&)aOrient).PutValue(*pHOrient, MID_HORIORIENT_ORIENT|CONVERT_TWIPS);
2171 bFullAlign = (aOrient.GetHoriOrient() == text::HoriOrientation::FULL);
2172 aSet.Put(aOrient);
2176 const uno::Any* pSzRel = 0;
2177 GetProperty(FN_TABLE_IS_RELATIVE_WIDTH, 0xff, pSzRel );
2178 const uno::Any* pRelWidth = 0;
2179 GetProperty(FN_TABLE_RELATIVE_WIDTH, 0xff, pRelWidth);
2180 const uno::Any* pWidth = 0;
2181 GetProperty(FN_TABLE_WIDTH, 0xff, pWidth );
2183 sal_Bool bPutSize = pWidth != 0;
2184 SwFmtFrmSize aSz( ATT_VAR_SIZE);
2185 if(pWidth)
2187 ((SfxPoolItem&)aSz).PutValue(*pWidth, MID_FRMSIZE_WIDTH);
2188 bPutSize = sal_True;
2190 sal_Bool bTemp = pSzRel ? *(sal_Bool*)pSzRel->getValue() : FALSE;
2191 if(pSzRel && bTemp && pRelWidth)
2193 ((SfxPoolItem&)aSz).PutValue(*pRelWidth, MID_FRMSIZE_REL_WIDTH|CONVERT_TWIPS);
2194 bPutSize = sal_True;
2196 if(bPutSize)
2198 if(!aSz.GetWidth())
2199 aSz.SetWidth(MINLAY);
2200 aSet.Put(aSz);
2202 const uno::Any* pL = 0;
2203 GetProperty(RES_LR_SPACE, MID_L_MARGIN|CONVERT_TWIPS, pL);
2204 const uno::Any* pR = 0;
2205 GetProperty(RES_LR_SPACE, MID_R_MARGIN|CONVERT_TWIPS, pR);
2206 if(pL||pR)
2208 SvxLRSpaceItem aLR ( rFrmFmt.GetLRSpace() );
2209 if(pL)
2210 ((SfxPoolItem&)aLR).PutValue(*pL, MID_L_MARGIN|CONVERT_TWIPS);
2211 if(pR)
2212 ((SfxPoolItem&)aLR).PutValue(*pR, MID_R_MARGIN|CONVERT_TWIPS);
2213 aSet.Put(aLR);
2215 const uno::Any* pU = 0;
2216 GetProperty(RES_UL_SPACE, MID_UP_MARGIN|CONVERT_TWIPS, pU);
2217 const uno::Any* pLo = 0;
2218 GetProperty(RES_UL_SPACE, MID_LO_MARGIN|CONVERT_TWIPS, pLo);
2219 if(pU||pLo)
2221 SvxULSpaceItem aUL ( rFrmFmt.GetULSpace() );
2222 if(pU)
2223 ((SfxPoolItem&)aUL).PutValue(*pU, MID_UP_MARGIN|CONVERT_TWIPS);
2224 if(pLo)
2225 ((SfxPoolItem&)aUL).PutValue(*pLo, MID_LO_MARGIN|CONVERT_TWIPS);
2226 aSet.Put(aUL);
2228 const::uno::Any* pSplit;
2229 if(GetProperty(RES_LAYOUT_SPLIT, 0, pSplit ))
2231 sal_Bool bTmp = *(sal_Bool*)pSplit->getValue();
2232 SwFmtLayoutSplit aSp(bTmp);
2233 aSet.Put(aSp);
2236 //TODO: folgende Propertiers noch impl.
2237 // FN_UNO_RANGE_ROW_LABEL
2238 // FN_UNO_RANGE_COL_LABEL
2239 // FN_UNO_TABLE_BORDER
2241 if(aSet.Count())
2243 rDoc.SetAttr( aSet, *rTbl.GetFrmFmt() );
2246 /* -----------------------------11.07.00 12:14--------------------------------
2248 ---------------------------------------------------------------------------*/
2249 SwXTextTable* SwXTextTable::GetImplementation(uno::Reference< XInterface> xRef )
2251 uno::Reference<lang::XUnoTunnel> xTunnel( xRef, uno::UNO_QUERY);
2252 if(xTunnel.is())
2253 return reinterpret_cast< SwXTextTable * >(
2254 sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXTextTable::getUnoTunnelId()) ));
2255 return 0;
2257 /* -----------------------------10.03.00 18:02--------------------------------
2259 ---------------------------------------------------------------------------*/
2260 const uno::Sequence< sal_Int8 > & SwXTextTable::getUnoTunnelId()
2262 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
2263 return aSeq;
2265 /* -----------------------------10.03.00 18:04--------------------------------
2267 ---------------------------------------------------------------------------*/
2268 sal_Int64 SAL_CALL SwXTextTable::getSomething( const uno::Sequence< sal_Int8 >& rId )
2269 throw(uno::RuntimeException)
2271 if( rId.getLength() == 16
2272 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
2273 rId.getConstArray(), 16 ) )
2275 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
2277 return 0;
2279 /*-- 11.12.98 12:42:43---------------------------------------------------
2281 -----------------------------------------------------------------------*/
2282 TYPEINIT1(SwXTextTable, SwClient)
2284 /*-- 11.12.98 12:42:43---------------------------------------------------
2286 -----------------------------------------------------------------------*/
2287 SwXTextTable::SwXTextTable() :
2288 aLstnrCntnr( (text::XTextTable*)this),
2289 aChartLstnrCntnr( (text::XTextTable*)this),
2290 m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)),
2291 pTableProps(new SwTableProperties_Impl),
2292 bIsDescriptor(sal_True),
2293 nRows(2),
2294 nColumns(2),
2295 bFirstRowAsLabel(sal_False),
2296 bFirstColumnAsLabel(sal_False)
2300 /*-- 11.12.98 12:42:44---------------------------------------------------
2302 -----------------------------------------------------------------------*/
2303 SwXTextTable::SwXTextTable(SwFrmFmt& rFrmFmt) :
2304 SwClient( &rFrmFmt ),
2305 aLstnrCntnr( (text::XTextTable*)this),
2306 aChartLstnrCntnr( (text::XTextTable*)this),
2307 m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)),
2308 pTableProps(0),
2309 bIsDescriptor(sal_False),
2310 nRows(0),
2311 nColumns(0),
2312 bFirstRowAsLabel(sal_False),
2313 bFirstColumnAsLabel(sal_False)
2317 /*-- 11.12.98 12:42:44---------------------------------------------------
2319 -----------------------------------------------------------------------*/
2320 SwXTextTable::~SwXTextTable()
2322 delete pTableProps;
2324 /*-- 11.12.98 12:42:44---------------------------------------------------
2326 -----------------------------------------------------------------------*/
2327 void SwXTextTable::initialize(sal_Int32 nR, sal_Int32 nC) throw( uno::RuntimeException )
2329 if(!bIsDescriptor || nR <= 0 || nC <= 0 || nR >= USHRT_MAX || nC >= USHRT_MAX )
2330 throw uno::RuntimeException();
2331 else
2333 nRows = (sal_uInt16)nR;
2334 nColumns = (sal_uInt16)nC;
2337 /*-- 11.12.98 12:42:45---------------------------------------------------
2339 -----------------------------------------------------------------------*/
2340 uno::Reference< table::XTableRows > SwXTextTable::getRows(void) throw( uno::RuntimeException )
2342 vos::OGuard aGuard(Application::GetSolarMutex());
2343 uno::Reference< table::XTableRows > xRet;
2344 if (SwFrmFmt* pFmt = GetFrmFmt())
2346 SwXTableRows* pRows = (SwXTableRows*)SwClientIter(*pFmt).
2347 First(TYPE(SwXTableRows));
2348 if (!pRows)
2349 pRows = new SwXTableRows(*pFmt);
2350 xRet = pRows;
2352 if (!xRet.is())
2353 throw uno::RuntimeException();
2354 return xRet;
2356 /*-- 11.12.98 12:42:45---------------------------------------------------
2358 -----------------------------------------------------------------------*/
2359 uno::Reference< table::XTableColumns > SwXTextTable::getColumns(void) throw( uno::RuntimeException )
2361 vos::OGuard aGuard(Application::GetSolarMutex());
2362 uno::Reference< table::XTableColumns > xRet;
2363 if (SwFrmFmt* pFmt = GetFrmFmt())
2365 SwXTableColumns* pCols = (SwXTableColumns*)SwClientIter(*pFmt).
2366 First(TYPE(SwXTableColumns));
2367 if (!pCols)
2368 pCols = new SwXTableColumns(*pFmt);
2369 xRet = pCols;
2371 if (!xRet.is())
2372 throw uno::RuntimeException();
2373 return xRet;
2375 /*-- 11.12.98 12:42:45---------------------------------------------------
2377 -----------------------------------------------------------------------*/
2378 uno::Reference< table::XCell > SwXTextTable::getCellByName(const OUString& CellName) throw( uno::RuntimeException )
2380 vos::OGuard aGuard(Application::GetSolarMutex());
2381 uno::Reference< table::XCell > xRet;
2382 SwFrmFmt* pFmt = GetFrmFmt();
2383 if(pFmt)
2385 SwTable* pTable = SwTable::FindTable( pFmt );
2386 String sCellName(CellName);
2387 SwTableBox* pBox = (SwTableBox*)pTable->GetTblBox( sCellName );
2388 if(pBox)
2390 xRet = SwXCell::CreateXCell(pFmt, pBox);
2393 else
2394 throw uno::RuntimeException();
2395 return xRet;
2397 /*-- 11.12.98 12:42:45---------------------------------------------------
2399 -----------------------------------------------------------------------*/
2400 uno::Sequence< OUString > SwXTextTable::getCellNames(void) throw( uno::RuntimeException )
2402 vos::OGuard aGuard(Application::GetSolarMutex());
2403 SwFrmFmt* pFmt = GetFrmFmt();
2404 if(pFmt)
2406 SwTable* pTable = SwTable::FindTable( pFmt );
2407 // gibts an der Tabelle und an allen Boxen
2408 SwTableLines& rTblLines = pTable->GetTabLines();
2409 SvStrings aAllNames;
2410 lcl_InspectLines(rTblLines, aAllNames);
2411 uno::Sequence< OUString > aRet(aAllNames.Count());
2412 OUString* pArray = aRet.getArray();
2413 for(sal_uInt16 i = aAllNames.Count(); i; i--)
2415 String* pObject = aAllNames.GetObject(i-1);
2416 pArray[i - 1] = *pObject;
2417 aAllNames.Remove(i - 1);
2418 delete pObject;
2420 return aRet;
2422 return uno::Sequence< OUString >();
2424 /*-- 11.12.98 12:42:45---------------------------------------------------
2426 -----------------------------------------------------------------------*/
2427 uno::Reference< text::XTextTableCursor > SwXTextTable::createCursorByCellName(const OUString& CellName)
2428 throw( uno::RuntimeException )
2430 vos::OGuard aGuard(Application::GetSolarMutex());
2431 uno::Reference< text::XTextTableCursor > xRet;
2432 SwFrmFmt* pFmt = GetFrmFmt();
2433 if(pFmt)
2435 SwTable* pTable = SwTable::FindTable( pFmt );
2436 String sCellName(CellName);
2437 SwTableBox* pBox = (SwTableBox*)pTable->GetTblBox( sCellName );
2438 if(pBox && pBox->getRowSpan() > 0 )
2440 xRet = new SwXTextTableCursor(pFmt, pBox);
2443 if(!xRet.is())
2444 throw uno::RuntimeException();
2445 return xRet;
2447 /* -----------------18.02.99 13:36-------------------
2449 * --------------------------------------------------*/
2450 void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTextRange)
2451 throw( lang::IllegalArgumentException, uno::RuntimeException )
2453 // attachToRange must only be called once
2454 if(!bIsDescriptor) /* already attached ? */
2455 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "SwXTextTable: already attached to range." ) ), static_cast < cppu::OWeakObject * > ( this ) );
2457 uno::Reference<XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
2458 SwXTextRange* pRange = 0;
2459 OTextCursorHelper* pCursor = 0;
2460 if(xRangeTunnel.is())
2462 pRange = reinterpret_cast< SwXTextRange * >(
2463 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
2464 pCursor = reinterpret_cast< OTextCursorHelper * >(
2465 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
2467 SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0;
2468 if(pDoc && nRows && nColumns)
2470 SwUnoInternalPaM aPam(*pDoc);
2471 //das muss jetzt sal_True liefern
2472 SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange);
2475 UnoActionContext aCont( pDoc );
2477 pDoc->StartUndo(UNDO_EMPTY, NULL);
2478 const SwTable *pTable = 0;
2479 if( 0 != aPam.Start()->nContent.GetIndex() )
2481 pDoc->SplitNode(*aPam.Start(), false );
2483 //TODO: wenn es der letzte Absatz ist, dann muss noch ein Absatz angehaengt werden!
2484 if( aPam.HasMark() )
2486 pDoc->DeleteAndJoin(aPam);
2487 aPam.DeleteMark();
2489 pTable = pDoc->InsertTable( SwInsertTableOptions( tabopts::HEADLINE | tabopts::DEFAULT_BORDER | tabopts::SPLIT_LAYOUT, 0 ),
2490 *aPam.GetPoint(),
2491 nRows,
2492 nColumns,
2493 text::HoriOrientation::FULL );
2494 if(pTable)
2496 // hier muessen die Properties des Descriptors ausgewertet werden
2497 pTableProps->ApplyTblAttr(*pTable, *pDoc);
2498 SwFrmFmt* pTblFmt = pTable->GetFrmFmt();
2499 SwClientIter aIter( *pTblFmt );
2500 for( SwClient* pC = aIter.First( TYPE( SwFrm ));
2501 pC; pC = aIter.Next() )
2503 if( ((SwFrm*)pC)->IsTabFrm() )
2505 if(((SwFrm*)pC)->IsValid())
2506 ((SwFrm*)pC)->InvalidatePos();
2507 ((SwTabFrm*)pC)->SetONECalcLowers();
2508 ((SwTabFrm*)pC)->Calc();
2512 pTblFmt->Add(this);
2513 if(m_sTableName.Len())
2515 sal_uInt16 nIndex = 1;
2516 const String sTmpName(m_sTableName);
2517 String sTmpNameIndex(sTmpName);
2518 while(pDoc->FindTblFmtByName( sTmpNameIndex, sal_True ) && nIndex < USHRT_MAX)
2520 sTmpNameIndex = sTmpName;
2521 sTmpNameIndex += nIndex++;
2523 pDoc->SetTableName( *pTblFmt, sTmpNameIndex);
2526 const::uno::Any* pName;
2527 if(pTableProps->GetProperty(FN_UNO_TABLE_NAME, 0, pName))
2529 OUString sTmp;
2530 (*pName) >>= sTmp;
2531 setName(sTmp);
2533 bIsDescriptor = sal_False;
2534 DELETEZ(pTableProps);
2536 pDoc->EndUndo( UNDO_END, NULL );
2540 else
2541 throw lang::IllegalArgumentException();
2543 /*-- 11.12.98 12:42:45---------------------------------------------------
2545 -----------------------------------------------------------------------*/
2546 void SwXTextTable::attach(const uno::Reference< text::XTextRange > & xTextRange)
2547 throw( lang::IllegalArgumentException, uno::RuntimeException )
2549 vos::OGuard aGuard(Application::GetSolarMutex());
2550 attachToRange( xTextRange );
2552 /*-- 11.12.98 12:42:46---------------------------------------------------
2554 -----------------------------------------------------------------------*/
2555 uno::Reference< text::XTextRange > SwXTextTable::getAnchor(void)
2556 throw( uno::RuntimeException )
2558 vos::OGuard aGuard(Application::GetSolarMutex());
2559 SwFrmFmt* pFmt = GetFrmFmt();
2560 if(!pFmt)
2561 throw uno::RuntimeException();
2562 uno::Reference< text::XTextRange > xRet = new SwXTextRange(*pFmt);
2563 return xRet;
2565 /*-- 11.12.98 12:42:46---------------------------------------------------
2567 -----------------------------------------------------------------------*/
2568 void SwXTextTable::dispose(void) throw( uno::RuntimeException )
2570 vos::OGuard aGuard(Application::GetSolarMutex());
2571 SwFrmFmt* pFmt = GetFrmFmt();
2572 if(pFmt)
2574 SwTable* pTable = SwTable::FindTable( pFmt );
2575 SwTableSortBoxes& rBoxes = pTable->GetTabSortBoxes();
2576 SwSelBoxes aSelBoxes;
2577 aSelBoxes.Insert(rBoxes.GetData(), rBoxes.Count());
2578 pFmt->GetDoc()->DeleteRowCol(aSelBoxes);
2580 else
2581 throw uno::RuntimeException();
2583 /*-- 11.12.98 12:42:46---------------------------------------------------
2585 -----------------------------------------------------------------------*/
2586 void SwXTextTable::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
2588 if(!GetRegisteredIn())
2589 throw uno::RuntimeException();
2590 aLstnrCntnr.AddListener(aListener);
2592 /*-- 11.12.98 12:42:46---------------------------------------------------
2594 -----------------------------------------------------------------------*/
2595 void SwXTextTable::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
2597 if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener))
2598 throw uno::RuntimeException();
2600 /*-- 11.12.98 12:42:46---------------------------------------------------
2602 -----------------------------------------------------------------------*/
2603 uno::Reference< table::XCell > SwXTextTable::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
2604 throw( uno::RuntimeException, lang::IndexOutOfBoundsException )
2606 vos::OGuard aGuard(Application::GetSolarMutex());
2607 uno::Reference< table::XCell > aRef;
2608 SwFrmFmt* pFmt = GetFrmFmt();
2609 // Sheet interessiert nicht
2610 if(nColumn >= 0 && nRow >= 0 && nColumn < USHRT_MAX && nRow < USHRT_MAX && pFmt)
2612 SwXCell* pXCell = lcl_CreateXCell(pFmt, nColumn, nRow);
2613 if(pXCell)
2614 aRef = pXCell;
2616 if(!aRef.is())
2617 throw lang::IndexOutOfBoundsException();
2618 return aRef;
2621 /* -----------------11.12.98 13:26-------------------
2623 * --------------------------------------------------*/
2624 uno::Reference< table::XCellRange > SwXTextTable::GetRangeByName(SwFrmFmt* pFmt, SwTable* pTable,
2625 const String& rTLName, const String& rBRName,
2626 SwRangeDescriptor& rDesc)
2628 vos::OGuard aGuard(Application::GetSolarMutex());
2629 uno::Reference< table::XCellRange > aRef;
2630 String sTLName(rTLName);
2631 String sBRName(rBRName);
2632 const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
2633 if(pTLBox)
2635 // hier muessen die Actions aufgehoben werden
2636 UnoActionRemoveContext aRemoveContext(pFmt->GetDoc());
2637 const SwStartNode* pSttNd = pTLBox->GetSttNd();
2638 SwPosition aPos(*pSttNd);
2639 // Cursor in die obere linke Zelle des Ranges setzen
2640 SwUnoCrsr* pUnoCrsr = pFmt->GetDoc()->CreateUnoCrsr(aPos, sal_True);
2641 pUnoCrsr->Move( fnMoveForward, fnGoNode );
2642 pUnoCrsr->SetRemainInSection( sal_False );
2643 const SwTableBox* pBRBox = pTable->GetTblBox( sBRName );
2644 if(pBRBox)
2646 pUnoCrsr->SetMark();
2647 pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd();
2648 pUnoCrsr->Move( fnMoveForward, fnGoNode );
2649 SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
2650 pCrsr->MakeBoxSels();
2651 // pUnoCrsr wird uebergeben und nicht geloescht
2652 SwXCellRange* pCellRange = new SwXCellRange(pUnoCrsr, *pFmt, rDesc);
2653 aRef = pCellRange;
2655 else
2656 delete pUnoCrsr;
2658 return aRef;
2660 /*-- 11.12.98 12:42:46---------------------------------------------------
2662 -----------------------------------------------------------------------*/
2663 uno::Reference< table::XCellRange > SwXTextTable::getCellRangeByPosition(sal_Int32 nLeft, sal_Int32 nTop,
2664 sal_Int32 nRight, sal_Int32 nBottom)
2665 throw( uno::RuntimeException, lang::IndexOutOfBoundsException )
2667 vos::OGuard aGuard(Application::GetSolarMutex());
2668 uno::Reference< table::XCellRange > aRef;
2669 SwFrmFmt* pFmt = GetFrmFmt();
2670 if(pFmt && nRight < USHRT_MAX && nBottom < USHRT_MAX &&
2671 nLeft <= nRight && nTop <= nBottom &&
2672 nLeft >= 0 && nRight >= 0 && nTop >= 0 && nBottom >= 0 )
2674 SwTable* pTable = SwTable::FindTable( pFmt );
2675 if(!pTable->IsTblComplex())
2677 SwRangeDescriptor aDesc;
2678 aDesc.nTop = nTop;
2679 aDesc.nBottom = nBottom;
2680 aDesc.nLeft = nLeft;
2681 aDesc.nRight = nRight;
2682 String sTLName = lcl_GetCellName(aDesc.nLeft, aDesc.nTop);
2683 String sBRName = lcl_GetCellName(aDesc.nRight, aDesc.nBottom);
2685 // please note that according to the 'if' statement at the begin
2686 // sTLName:sBRName already denotes the normalized range string
2688 aRef = GetRangeByName(pFmt, pTable, sTLName, sBRName, aDesc);
2691 if(!aRef.is())
2692 throw lang::IndexOutOfBoundsException();
2693 return aRef;
2695 /*-- 11.12.98 12:42:47---------------------------------------------------
2697 -----------------------------------------------------------------------*/
2698 uno::Reference< table::XCellRange > SwXTextTable::getCellRangeByName(const OUString& aRange)
2699 throw( uno::RuntimeException )
2701 vos::OGuard aGuard(Application::GetSolarMutex());
2702 uno::Reference< table::XCellRange > aRef;
2703 SwFrmFmt* pFmt = GetFrmFmt();
2704 if(pFmt)
2706 SwTable* pTable = SwTable::FindTable( pFmt );
2707 if(!pTable->IsTblComplex())
2709 String sRange(aRange);
2710 String sTLName(sRange.GetToken(0, ':'));
2711 String sBRName(sRange.GetToken(1, ':'));
2712 if(!sTLName.Len() || !sBRName.Len())
2713 throw uno::RuntimeException();
2714 SwRangeDescriptor aDesc;
2715 aDesc.nTop = aDesc.nLeft = aDesc.nBottom = aDesc.nRight = -1;
2716 lcl_GetCellPosition(sTLName, aDesc.nLeft, aDesc.nTop );
2717 lcl_GetCellPosition(sBRName, aDesc.nRight, aDesc.nBottom );
2719 // we should normalize the range now (e.g. A5:C1 will become A1:C5)
2720 // since (depending on what is done later) it will be troublesome
2721 // elsewhere when the cursor in the implementation does not
2722 // point to the top-left and bottom-right cells
2723 aDesc.Normalize();
2725 aRef = GetRangeByName(pFmt, pTable, sTLName, sBRName, aDesc);
2728 if(!aRef.is())
2729 throw uno::RuntimeException();
2730 return aRef;
2732 /*-- 29.04.02 11:42:47---------------------------------------------------
2734 -----------------------------------------------------------------------*/
2735 uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray()
2736 throw (uno::RuntimeException)
2738 // see SwXTextTable::getData(...) also
2740 vos::OGuard aGuard(Application::GetSolarMutex());
2741 sal_Int16 nRowCount = getRowCount();
2742 sal_Int16 nColCount = getColumnCount();
2743 if(!nRowCount || !nColCount)
2745 uno::RuntimeException aRuntime;
2746 aRuntime.Message = C2U("Table too complex");
2747 throw aRuntime;
2749 SwFrmFmt* pFmt = GetFrmFmt();
2750 uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount);
2751 if(pFmt)
2753 uno::Sequence< uno::Any > * pRowArray = aRowSeq.getArray();
2754 for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++)
2756 uno::Sequence< uno::Any > aColSeq(nColCount);
2757 uno::Any * pColArray = aColSeq.getArray();
2758 uno::Reference< table::XCell > xCellRef;
2759 for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++)
2761 SwXCell* pXCell = lcl_CreateXCell(pFmt, nCol, nRow);
2762 //! keep (additional) reference to object to prevent implicit destruction
2763 //! in following UNO calls (when object will get referenced)
2764 xCellRef = pXCell;
2765 SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0;
2766 if(!pBox)
2768 throw uno::RuntimeException();
2770 else
2772 // check if table box value item is set
2773 SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
2774 BOOL bIsNum = pBoxFmt->GetItemState( RES_BOXATR_VALUE, FALSE ) == SFX_ITEM_SET;
2775 //const SfxPoolItem* pItem;
2776 //SwDoc* pDoc = pXCell->GetDoc();
2777 //BOOL bIsText = (SFX_ITEM_SET != pBoxFmt->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, sal_True, &pItem)
2778 // || pDoc->GetNumberFormatter()->IsTextFormat(((SwTblBoxNumFormat*)pItem)->GetValue())
2779 // || ((SwTblBoxNumFormat*)pItem)->GetValue() == NUMBERFORMAT_TEXT);
2781 if(!bIsNum/*bIsText*/)
2782 pColArray[nCol] <<= lcl_getString(*pXCell);
2783 else
2784 pColArray[nCol] <<= lcl_getValue(*pXCell);
2787 pRowArray[nRow] = aColSeq;
2790 else
2791 throw uno::RuntimeException();
2792 return aRowSeq;
2794 /*-- 29.04.02 11:42:47---------------------------------------------------
2796 -----------------------------------------------------------------------*/
2797 void SAL_CALL SwXTextTable::setDataArray(
2798 const uno::Sequence< uno::Sequence< uno::Any > >& rArray )
2799 throw (uno::RuntimeException)
2801 // see SwXTextTable::setData(...) also
2803 vos::OGuard aGuard(Application::GetSolarMutex());
2804 sal_Int16 nRowCount = getRowCount();
2805 sal_Int16 nColCount = getColumnCount();
2807 SwFrmFmt* pFmt = GetFrmFmt();
2808 if(pFmt)
2810 SwTable* pTable = SwTable::FindTable( pFmt );
2811 if(pTable->IsTblComplex())
2813 uno::RuntimeException aRuntime;
2814 aRuntime.Message = C2U("Table too complex");
2815 throw aRuntime;
2818 if(rArray.getLength() != nRowCount)
2820 throw uno::RuntimeException();
2822 const uno::Sequence< uno::Any >* pRowArray = rArray.getConstArray();
2823 for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++)
2825 const uno::Sequence< uno::Any >& rColSeq = pRowArray[nRow];
2826 if(rColSeq.getLength() != nColCount)
2828 throw uno::RuntimeException();
2830 const uno::Any * pColArray = rColSeq.getConstArray();
2831 uno::Reference< table::XCell > xCellRef;
2832 for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++)
2834 SwXCell* pXCell = lcl_CreateXCell(pFmt, nCol, nRow);
2835 //! keep (additional) reference to object to prevent implicit destruction
2836 //! in following UNO calls (when object will get referenced)
2837 xCellRef = pXCell;
2838 SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0;
2839 if(!pBox)
2841 throw uno::RuntimeException();
2843 else
2845 const uno::Any &rAny = pColArray[nCol];
2846 if (uno::TypeClass_STRING == rAny.getValueTypeClass())
2847 lcl_setString( *pXCell, *(rtl::OUString *) rAny.getValue() );
2848 else
2850 double d = 0;
2851 // #i20067# don't throw exception just do nothing if
2852 // there is no value set
2853 if( (rAny >>= d) )
2854 lcl_setValue( *pXCell, d );
2855 else
2856 lcl_setString( *pXCell, OUString(), TRUE );
2864 /*-- 11.12.98 12:42:47---------------------------------------------------
2866 -----------------------------------------------------------------------*/
2867 uno::Sequence< uno::Sequence< double > > SwXTextTable::getData(void)
2868 throw( uno::RuntimeException )
2870 vos::OGuard aGuard(Application::GetSolarMutex());
2871 sal_Int16 nRowCount = getRowCount();
2872 sal_Int16 nColCount = getColumnCount();
2873 if(!nRowCount || !nColCount)
2875 uno::RuntimeException aRuntime;
2876 aRuntime.Message = C2U("Table too complex");
2877 throw aRuntime;
2880 SwFrmFmt* pFmt = GetFrmFmt();
2881 uno::Sequence< uno::Sequence< double > > aRowSeq(bFirstRowAsLabel ? nRowCount - 1 : nRowCount);
2882 if(pFmt)
2884 uno::Sequence< double >* pArray = aRowSeq.getArray();
2886 sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
2887 for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
2889 uno::Sequence< double > aColSeq(bFirstColumnAsLabel ? nColCount - 1 : nColCount);
2890 double* pColArray = aColSeq.getArray();
2891 sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
2892 for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
2894 uno::Reference< table::XCell > xCell = getCellByPosition(nCol, nRow);
2895 if(!xCell.is())
2897 throw uno::RuntimeException();
2899 pColArray[nCol - nColStart] = xCell->getValue();
2901 pArray[nRow - nRowStart] = aColSeq;
2904 else
2905 throw uno::RuntimeException();
2906 return aRowSeq;
2908 /*-- 11.12.98 12:42:47---------------------------------------------------
2910 -----------------------------------------------------------------------*/
2911 void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData)
2912 throw( uno::RuntimeException )
2914 vos::OGuard aGuard(Application::GetSolarMutex());
2915 sal_Int16 nRowCount = getRowCount();
2916 sal_Int16 nColCount = getColumnCount();
2917 sal_Bool bChanged = sal_False;
2919 if(!nRowCount || !nColCount)
2921 uno::RuntimeException aRuntime;
2922 aRuntime.Message = C2U("Table too complex");
2923 throw aRuntime;
2925 SwFrmFmt* pFmt = GetFrmFmt();
2926 if(pFmt )
2928 sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
2929 if(rData.getLength() < nRowCount - nRowStart)
2931 throw uno::RuntimeException();
2933 const uno::Sequence< double >* pRowArray = rData.getConstArray();
2934 for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
2936 const uno::Sequence< double >& rColSeq = pRowArray[nRow - nRowStart];
2937 sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
2938 if(rColSeq.getLength() < nColCount - nColStart)
2940 throw uno::RuntimeException();
2942 const double * pColArray = rColSeq.getConstArray();
2943 for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
2945 uno::Reference< table::XCell > xCell = getCellByPosition(nCol, nRow);
2946 if(!xCell.is())
2948 throw uno::RuntimeException();
2950 xCell->setValue(pColArray[nCol - nColStart]);
2951 bChanged=sal_True;
2954 if ( bChanged )
2955 aChartLstnrCntnr.ChartDataChanged();
2958 /*-- 11.12.98 12:42:47---------------------------------------------------
2960 -----------------------------------------------------------------------*/
2961 uno::Sequence< OUString > SwXTextTable::getRowDescriptions(void) throw( uno::RuntimeException )
2963 vos::OGuard aGuard(Application::GetSolarMutex());
2964 sal_Int16 nRowCount = getRowCount();
2965 if(!nRowCount)
2967 uno::RuntimeException aRuntime;
2968 aRuntime.Message = C2U("Table too complex");
2969 throw aRuntime;
2971 uno::Sequence< OUString > aRet(bFirstColumnAsLabel ? nRowCount - 1 : nRowCount);
2972 SwFrmFmt* pFmt = GetFrmFmt();
2973 if(pFmt)
2975 OUString* pArray = aRet.getArray();
2976 if(bFirstColumnAsLabel)
2978 sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
2979 for(sal_uInt16 i = nStart; i < nRowCount; i++)
2981 uno::Reference< table::XCell > xCell = getCellByPosition(0, i);
2982 if(!xCell.is())
2984 //exception ...
2985 break;
2987 uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
2988 pArray[i - nStart] = xText->getString();
2991 else
2993 DBG_ERROR("Wo kommen die Labels her?");
2996 else
2997 throw uno::RuntimeException();
2998 return aRet;
3000 /*-- 11.12.98 12:42:47---------------------------------------------------
3002 -----------------------------------------------------------------------*/
3003 void SwXTextTable::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc) throw( uno::RuntimeException )
3005 vos::OGuard aGuard(Application::GetSolarMutex());
3006 SwFrmFmt* pFmt = GetFrmFmt();
3007 if(pFmt)
3009 sal_Int16 nRowCount = getRowCount();
3010 if(!nRowCount || rRowDesc.getLength() < (bFirstRowAsLabel ? nRowCount - 1 : nRowCount))
3012 throw uno::RuntimeException();
3014 const OUString* pArray = rRowDesc.getConstArray();
3015 if(bFirstColumnAsLabel)
3017 sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
3018 for(sal_uInt16 i = nStart; i < nRowCount; i++)
3020 uno::Reference< table::XCell > xCell = getCellByPosition(0, i);
3021 if(!xCell.is())
3023 throw uno::RuntimeException();
3025 uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
3026 xText->setString(pArray[i - nStart]);
3029 else
3031 DBG_ERROR("Wohin mit den Labels?");
3034 else
3035 throw uno::RuntimeException();
3037 /*-- 11.12.98 12:42:48---------------------------------------------------
3039 -----------------------------------------------------------------------*/
3040 uno::Sequence< OUString > SwXTextTable::getColumnDescriptions(void)
3041 throw( uno::RuntimeException )
3043 vos::OGuard aGuard(Application::GetSolarMutex());
3044 sal_Int16 nColCount = getColumnCount();
3045 if(!nColCount)
3047 uno::RuntimeException aRuntime;
3048 aRuntime.Message = C2U("Table too complex");
3049 throw aRuntime;
3051 uno::Sequence< OUString > aRet(bFirstRowAsLabel ? nColCount - 1 : nColCount);
3052 SwFrmFmt* pFmt = GetFrmFmt();
3053 if(pFmt)
3055 OUString* pArray = aRet.getArray();
3056 if(bFirstRowAsLabel)
3058 sal_uInt16 nStart = bFirstColumnAsLabel ? 1 : 0;
3059 for(sal_uInt16 i = nStart; i < nColCount; i++)
3061 uno::Reference< table::XCell > xCell = getCellByPosition(i, 0);
3062 if(!xCell.is())
3064 throw uno::RuntimeException();
3066 uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
3068 pArray[i - nStart] = xText->getString();
3071 else
3073 DBG_ERROR("Wo kommen die Labels her?");
3076 else
3077 throw uno::RuntimeException();
3078 return aRet;
3080 /*-- 11.12.98 12:42:48---------------------------------------------------
3082 -----------------------------------------------------------------------*/
3083 void SwXTextTable::setColumnDescriptions(const uno::Sequence< OUString >& rColumnDesc) throw( uno::RuntimeException )
3085 vos::OGuard aGuard(Application::GetSolarMutex());
3086 sal_Int16 nColCount = getColumnCount();
3087 if(!nColCount)
3089 uno::RuntimeException aRuntime;
3090 aRuntime.Message = C2U("Table too complex");
3091 throw aRuntime;
3093 SwFrmFmt* pFmt = GetFrmFmt();
3094 if(pFmt)
3096 const OUString* pArray = rColumnDesc.getConstArray();
3097 if(bFirstRowAsLabel && rColumnDesc.getLength() >= nColCount - bFirstColumnAsLabel ? 1 : 0)
3099 sal_uInt16 nStart = bFirstColumnAsLabel ? 1 : 0;
3100 for(sal_uInt16 i = nStart; i < nColCount; i++)
3102 uno::Reference< table::XCell > xCell = getCellByPosition(i, 0);
3103 if(!xCell.is())
3105 throw uno::RuntimeException();
3107 uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
3108 xText->setString(pArray[i - nStart]);
3111 else
3113 DBG_ERROR("Wo kommen die Labels her?");
3116 else
3117 throw uno::RuntimeException();
3119 /*-- 11.12.98 12:42:48---------------------------------------------------
3121 -----------------------------------------------------------------------*/
3122 void SwXTextTable::addChartDataChangeEventListener(
3123 const uno::Reference< chart::XChartDataChangeEventListener > & aListener)
3124 throw( uno::RuntimeException )
3126 if(!GetRegisteredIn())
3127 throw uno::RuntimeException();
3128 aChartLstnrCntnr.AddListener(aListener.get());
3130 /*-- 11.12.98 12:42:48---------------------------------------------------
3132 -----------------------------------------------------------------------*/
3133 void SwXTextTable::removeChartDataChangeEventListener(
3134 const uno::Reference< chart::XChartDataChangeEventListener > & aListener)
3135 throw( uno::RuntimeException )
3137 if(!GetRegisteredIn() || !aChartLstnrCntnr.RemoveListener(aListener.get()))
3138 throw uno::RuntimeException();
3140 /* -----------------08.03.99 15:33-------------------
3142 * --------------------------------------------------*/
3143 sal_Bool SwXTextTable::isNotANumber(double nNumber) throw( uno::RuntimeException )
3145 // We use DBL_MIN because starcalc does (which uses it because chart
3146 // wants it that way!)
3147 return ( nNumber == DBL_MIN );
3149 /* -----------------08.03.99 15:34-------------------
3151 * --------------------------------------------------*/
3152 double SwXTextTable::getNotANumber(void) throw( uno::RuntimeException )
3154 // We use DBL_MIN because starcalc does (which uses it because chart
3155 // wants it that way!)
3156 return DBL_MIN;
3158 /*-- 11.12.98 12:42:48---------------------------------------------------
3160 -----------------------------------------------------------------------*/
3161 uno::Sequence< beans::PropertyValue > SwXTextTable::createSortDescriptor(void)
3162 throw( uno::RuntimeException )
3164 vos::OGuard aGuard(Application::GetSolarMutex());
3165 return SwXTextCursor::createSortDescriptor(sal_True);
3167 /*-- 11.12.98 12:42:49---------------------------------------------------
3169 -----------------------------------------------------------------------*/
3170 void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor)
3171 throw( uno::RuntimeException )
3173 vos::OGuard aGuard(Application::GetSolarMutex());
3174 SwSortOptions aSortOpt;
3175 SwFrmFmt* pFmt = GetFrmFmt();
3176 if(pFmt &&
3177 SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt))
3179 SwTable* pTable = SwTable::FindTable( pFmt );
3180 SwSelBoxes aBoxes;
3181 const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
3182 for( sal_uInt16 n = 0; n < rTBoxes.Count(); ++n )
3184 SwTableBox* pBox = rTBoxes[ n ];
3185 aBoxes.Insert( pBox );
3187 UnoActionContext aContext( pFmt->GetDoc() );
3188 pFmt->GetDoc()->SortTbl(aBoxes, aSortOpt);
3191 /*-- 11.12.98 12:42:49---------------------------------------------------
3193 -----------------------------------------------------------------------*/
3194 void SwXTextTable::autoFormat(const OUString& aName) throw( lang::IllegalArgumentException, uno::RuntimeException )
3196 vos::OGuard aGuard(Application::GetSolarMutex());
3197 SwFrmFmt* pFmt = GetFrmFmt();
3198 if(pFmt)
3200 SwTable* pTable = SwTable::FindTable( pFmt );
3201 if(!pTable->IsTblComplex())
3204 String sAutoFmtName(aName);
3205 SwTableAutoFmtTbl aAutoFmtTbl;
3206 aAutoFmtTbl.Load();
3207 for( sal_uInt16 i = aAutoFmtTbl.Count(); i; )
3208 if( sAutoFmtName == aAutoFmtTbl[ --i ]->GetName() )
3210 SwSelBoxes aBoxes;
3211 const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
3212 for( sal_uInt16 n = 0; n < rTBoxes.Count(); ++n )
3214 SwTableBox* pBox = rTBoxes[ n ];
3215 aBoxes.Insert( pBox );
3217 UnoActionContext aContext( pFmt->GetDoc() );
3218 pFmt->GetDoc()->SetTableAutoFmt( aBoxes, *aAutoFmtTbl[i] );
3219 break;
3223 else
3224 throw uno::RuntimeException();
3226 /*-- 11.12.98 12:42:49---------------------------------------------------
3228 -----------------------------------------------------------------------*/
3229 uno::Reference< beans::XPropertySetInfo > SwXTextTable::getPropertySetInfo(void) throw( uno::RuntimeException )
3231 static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
3232 return xRef;
3234 /*-- 11.12.98 12:42:50---------------------------------------------------
3236 -----------------------------------------------------------------------*/
3237 void SwXTextTable::setPropertyValue(const OUString& rPropertyName,
3238 const uno::Any& aValue)
3239 throw( beans::UnknownPropertyException, beans::PropertyVetoException,
3240 lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException )
3242 vos::OGuard aGuard(Application::GetSolarMutex());
3243 SwFrmFmt* pFmt = GetFrmFmt();
3244 if(!aValue.hasValue())
3245 throw lang::IllegalArgumentException();
3246 const SfxItemPropertySimpleEntry* pEntry =
3247 m_pPropSet->getPropertyMap()->getByName(rPropertyName);
3248 if( !pEntry )
3249 throw lang::IllegalArgumentException();
3250 if(pFmt)
3252 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
3253 throw beans::PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
3255 if(0xFF == pEntry->nMemberId)
3257 lcl_SetSpecialProperty(pFmt, pEntry, aValue);
3259 else
3261 switch(pEntry->nWID)
3263 case UNO_NAME_TABLE_NAME :
3265 ::rtl::OUString sName;
3266 aValue >>= sName;
3267 setName( sName );
3269 break;
3270 case FN_UNO_RANGE_ROW_LABEL:
3272 sal_Bool bTmp = *(sal_Bool*)aValue.getValue();
3273 if(bFirstRowAsLabel != bTmp)
3275 aChartLstnrCntnr.ChartDataChanged();
3276 bFirstRowAsLabel = bTmp;
3279 break;
3280 case FN_UNO_RANGE_COL_LABEL:
3282 sal_Bool bTmp = *(sal_Bool*)aValue.getValue();
3283 if(bFirstColumnAsLabel != bTmp)
3285 aChartLstnrCntnr.ChartDataChanged();
3286 bFirstColumnAsLabel = bTmp;
3289 break;
3290 case FN_UNO_TABLE_BORDER:
3292 const table::TableBorder* pBorder =
3293 (const table::TableBorder* )aValue.getValue();
3294 if(aValue.getValueType() == ::getCppuType((const table::TableBorder* )0)
3295 && pBorder)
3297 SwDoc* pDoc = pFmt->GetDoc();
3298 SwClientIter aIter( *pFmt );
3299 //Tabellen ohne Layout (unsichtbare Header/Footer )
3300 if(0 != aIter.First( TYPE( SwFrm )))
3302 lcl_FormatTable(pFmt);
3303 SwTable* pTable = SwTable::FindTable( pFmt );
3304 SwTableLines &rLines = pTable->GetTabLines();
3307 // hier muessen die Actions aufgehoben werden
3308 UnoActionRemoveContext aRemoveContext(pDoc);
3309 SwTableBox* pTLBox = rLines[0]->GetTabBoxes()[0];
3310 const SwStartNode* pSttNd = pTLBox->GetSttNd();
3311 SwPosition aPos(*pSttNd);
3312 // Cursor in die obere linke Zelle des Ranges setzen
3313 SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(aPos, sal_True);
3314 pUnoCrsr->Move( fnMoveForward, fnGoNode );
3315 pUnoCrsr->SetRemainInSection( sal_False );
3317 SwTableLine* pLastLine = rLines[rLines.Count() - 1];
3318 SwTableBoxes &rBoxes = pLastLine->GetTabBoxes();
3319 const SwTableBox* pBRBox = rBoxes[rBoxes.Count() -1];
3320 pUnoCrsr->SetMark();
3321 pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd();
3322 pUnoCrsr->Move( fnMoveForward, fnGoNode );
3323 SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
3324 pCrsr->MakeBoxSels();
3326 SfxItemSet aSet(pDoc->GetAttrPool(),
3327 RES_BOX, RES_BOX,
3328 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
3331 SvxBoxItem aBox( RES_BOX );
3332 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
3333 SvxBorderLine aLine;
3335 sal_Bool bSet = lcl_LineToSvxLine(pBorder->TopLine, aLine);
3336 aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_TOP);
3337 aBoxInfo.SetValid(VALID_TOP, pBorder->IsTopLineValid);
3339 bSet = lcl_LineToSvxLine(pBorder->BottomLine, aLine);
3340 aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_BOTTOM);
3341 aBoxInfo.SetValid(VALID_BOTTOM, pBorder->IsBottomLineValid);
3343 bSet = lcl_LineToSvxLine(pBorder->LeftLine, aLine);
3344 aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_LEFT);
3345 aBoxInfo.SetValid(VALID_LEFT, pBorder->IsLeftLineValid);
3347 bSet = lcl_LineToSvxLine(pBorder->RightLine, aLine);
3348 aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_RIGHT);
3349 aBoxInfo.SetValid(VALID_RIGHT, pBorder->IsRightLineValid);
3351 bSet = lcl_LineToSvxLine(pBorder->HorizontalLine, aLine);
3352 aBoxInfo.SetLine(bSet ? &aLine : 0, BOXINFO_LINE_HORI);
3353 aBoxInfo.SetValid(VALID_HORI, pBorder->IsHorizontalLineValid);
3355 bSet = lcl_LineToSvxLine(pBorder->VerticalLine, aLine);
3356 aBoxInfo.SetLine(bSet ? &aLine : 0, BOXINFO_LINE_VERT);
3357 aBoxInfo.SetValid(VALID_VERT, pBorder->IsVerticalLineValid);
3359 aBox.SetDistance((sal_uInt16)MM100_TO_TWIP(pBorder->Distance));
3360 aBoxInfo.SetValid(VALID_DISTANCE, pBorder->IsDistanceValid);
3362 aSet.Put(aBox);
3363 aSet.Put(aBoxInfo);
3365 pDoc->SetTabBorders(*pCrsr, aSet);
3366 delete pUnoCrsr;
3370 break;
3371 case FN_UNO_TABLE_BORDER_DISTANCES:
3373 table::TableBorderDistances aTableBorderDistances;
3374 if( !(aValue >>= aTableBorderDistances) ||
3375 (!aTableBorderDistances.IsLeftDistanceValid &&
3376 !aTableBorderDistances.IsRightDistanceValid &&
3377 !aTableBorderDistances.IsTopDistanceValid &&
3378 !aTableBorderDistances.IsBottomDistanceValid ))
3379 break;
3381 USHORT nLeftDistance = MM100_TO_TWIP_UNSIGNED( aTableBorderDistances.LeftDistance);
3382 USHORT nRightDistance = MM100_TO_TWIP_UNSIGNED( aTableBorderDistances.RightDistance);
3383 USHORT nTopDistance = MM100_TO_TWIP_UNSIGNED( aTableBorderDistances.TopDistance);
3384 USHORT nBottomDistance = MM100_TO_TWIP_UNSIGNED( aTableBorderDistances.BottomDistance);
3385 SwDoc* pDoc = pFmt->GetDoc();
3386 SwTable* pTable = SwTable::FindTable( pFmt );
3387 SwTableLines &rLines = pTable->GetTabLines();
3388 pDoc->StartUndo(UNDO_START, NULL);
3389 for(sal_uInt16 i = 0; i < rLines.Count(); i++)
3391 SwTableLine* pLine = rLines.GetObject(i);
3392 SwTableBoxes& rBoxes = pLine->GetTabBoxes();
3393 for(sal_uInt16 k = 0; k < rBoxes.Count(); k++)
3395 SwTableBox* pBox = rBoxes.GetObject(k);
3396 const SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
3397 const SvxBoxItem& rBox = pBoxFmt->GetBox();
3398 if(
3399 aTableBorderDistances.IsLeftDistanceValid && nLeftDistance != rBox.GetDistance( BOX_LINE_LEFT ) ||
3400 aTableBorderDistances.IsRightDistanceValid && nRightDistance != rBox.GetDistance( BOX_LINE_RIGHT ) ||
3401 aTableBorderDistances.IsTopDistanceValid && nTopDistance != rBox.GetDistance( BOX_LINE_TOP ) ||
3402 aTableBorderDistances.IsBottomDistanceValid && nBottomDistance != rBox.GetDistance( BOX_LINE_BOTTOM ))
3404 SvxBoxItem aSetBox( rBox );
3405 SwFrmFmt* pSetBoxFmt = pBox->ClaimFrmFmt();
3406 if( aTableBorderDistances.IsLeftDistanceValid )
3407 aSetBox.SetDistance( nLeftDistance, BOX_LINE_LEFT );
3408 if( aTableBorderDistances.IsRightDistanceValid )
3409 aSetBox.SetDistance( nRightDistance, BOX_LINE_RIGHT );
3410 if( aTableBorderDistances.IsTopDistanceValid )
3411 aSetBox.SetDistance( nTopDistance, BOX_LINE_TOP );
3412 if( aTableBorderDistances.IsBottomDistanceValid )
3413 aSetBox.SetDistance( nBottomDistance, BOX_LINE_BOTTOM );
3414 pDoc->SetAttr( aSetBox, *pSetBoxFmt );
3418 pDoc->EndUndo(UNDO_END, NULL);
3420 break;
3421 case FN_UNO_TABLE_COLUMN_SEPARATORS:
3423 UnoActionContext aContext(pFmt->GetDoc());
3424 SwTable* pTable = SwTable::FindTable( pFmt );
3425 lcl_SetTblSeparators(aValue, pTable, pTable->GetTabLines()[0]->GetTabBoxes()[0], sal_False, pFmt->GetDoc());
3427 break;
3428 case FN_UNO_TABLE_COLUMN_RELATIVE_SUM:/*_readonly_*/ break;
3429 default:
3431 SwAttrSet aSet(pFmt->GetAttrSet());
3432 m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
3433 pFmt->GetDoc()->SetAttr(aSet, *pFmt);
3438 else if(bIsDescriptor)
3440 String aPropertyName(rPropertyName);
3441 pTableProps->SetProperty( pEntry->nWID, pEntry->nMemberId, aValue);
3443 else
3444 throw uno::RuntimeException();
3446 /*-- 11.12.98 12:42:51---------------------------------------------------
3448 -----------------------------------------------------------------------*/
3449 uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3451 vos::OGuard aGuard(Application::GetSolarMutex());
3452 uno::Any aRet;
3453 SwFrmFmt* pFmt = GetFrmFmt();
3454 const SfxItemPropertySimpleEntry* pEntry =
3455 m_pPropSet->getPropertyMap()->getByName(rPropertyName);
3456 if(pFmt)
3458 if (!pEntry)
3459 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
3461 if(0xFF == pEntry->nMemberId)
3463 aRet = lcl_GetSpecialProperty(pFmt, pEntry );
3465 else
3467 switch(pEntry->nWID)
3469 case UNO_NAME_TABLE_NAME:
3471 aRet <<= getName();
3473 break;
3474 case FN_UNO_ANCHOR_TYPES:
3475 case FN_UNO_TEXT_WRAP:
3476 case FN_UNO_ANCHOR_TYPE:
3477 SwXParagraph::getDefaultTextContentValue(aRet, OUString(), pEntry->nWID);
3478 break;
3479 case FN_UNO_RANGE_ROW_LABEL:
3481 sal_Bool bTemp = bFirstRowAsLabel;
3482 aRet.setValue(&bTemp, ::getCppuBooleanType());
3484 break;
3485 case FN_UNO_RANGE_COL_LABEL:
3487 sal_Bool bTemp = bFirstColumnAsLabel;
3488 aRet.setValue(&bTemp, ::getCppuBooleanType());
3490 break;
3491 case FN_UNO_TABLE_BORDER:
3493 SwDoc* pDoc = pFmt->GetDoc();
3494 SwClientIter aIter( *pFmt );
3495 //Tabellen ohne Layout (unsichtbare Header/Footer )
3496 if(0 != aIter.First( TYPE( SwFrm )))
3498 lcl_FormatTable(pFmt);
3499 SwTable* pTable = SwTable::FindTable( pFmt );
3500 SwTableLines &rLines = pTable->GetTabLines();
3502 // hier muessen die Actions aufgehoben werden
3503 UnoActionRemoveContext aRemoveContext(pDoc);
3504 SwTableBox* pTLBox = rLines[0]->GetTabBoxes()[0];
3505 const SwStartNode* pSttNd = pTLBox->GetSttNd();
3506 SwPosition aPos(*pSttNd);
3507 // Cursor in die obere linke Zelle des Ranges setzen
3508 SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(aPos, sal_True);
3509 pUnoCrsr->Move( fnMoveForward, fnGoNode );
3510 pUnoCrsr->SetRemainInSection( sal_False );
3512 SwTableLine* pLastLine = rLines[rLines.Count() - 1];
3513 SwTableBoxes &rBoxes = pLastLine->GetTabBoxes();
3514 const SwTableBox* pBRBox = rBoxes[rBoxes.Count() -1];
3515 pUnoCrsr->SetMark();
3516 pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd();
3517 pUnoCrsr->Move( fnMoveForward, fnGoNode );
3518 SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
3519 pCrsr->MakeBoxSels();
3521 SfxItemSet aSet(pDoc->GetAttrPool(),
3522 RES_BOX, RES_BOX,
3523 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
3525 aSet.Put(SvxBoxInfoItem( SID_ATTR_BORDER_INNER ));
3526 pDoc->GetTabBorders(*pCrsr, aSet);
3527 const SvxBoxInfoItem& rBoxInfoItem = (const SvxBoxInfoItem&)aSet.Get(SID_ATTR_BORDER_INNER);
3528 const SvxBoxItem& rBox = (const SvxBoxItem&)aSet.Get(RES_BOX);
3530 table::TableBorder aTableBorder;
3531 aTableBorder.TopLine = lcl_SvxLineToLine(rBox.GetTop());
3532 aTableBorder.IsTopLineValid = rBoxInfoItem.IsValid(VALID_TOP);
3533 aTableBorder.BottomLine = lcl_SvxLineToLine(rBox.GetBottom());
3534 aTableBorder.IsBottomLineValid = rBoxInfoItem.IsValid(VALID_BOTTOM);
3535 aTableBorder.LeftLine = lcl_SvxLineToLine(rBox.GetLeft());
3536 aTableBorder.IsLeftLineValid = rBoxInfoItem.IsValid(VALID_LEFT);
3537 aTableBorder.RightLine = lcl_SvxLineToLine(rBox.GetRight());
3538 aTableBorder.IsRightLineValid = rBoxInfoItem.IsValid(VALID_RIGHT );
3539 aTableBorder.HorizontalLine = lcl_SvxLineToLine(rBoxInfoItem.GetHori());
3540 aTableBorder.IsHorizontalLineValid = rBoxInfoItem.IsValid(VALID_HORI);
3541 aTableBorder.VerticalLine = lcl_SvxLineToLine(rBoxInfoItem.GetVert());
3542 aTableBorder.IsVerticalLineValid = rBoxInfoItem.IsValid(VALID_VERT);
3543 aTableBorder.Distance = TWIP_TO_MM100_UNSIGNED( rBox.GetDistance() );
3544 aTableBorder.IsDistanceValid = rBoxInfoItem.IsValid(VALID_DISTANCE);
3545 aRet.setValue(&aTableBorder, ::getCppuType((const table::TableBorder*)0));
3546 delete pUnoCrsr;
3549 break;
3550 case FN_UNO_TABLE_BORDER_DISTANCES :
3552 table::TableBorderDistances aTableBorderDistances( 0, sal_True, 0, sal_True, 0, sal_True, 0, sal_True ) ;
3553 SwTable* pTable = SwTable::FindTable( pFmt );
3554 const SwTableLines &rLines = pTable->GetTabLines();
3555 bool bFirst = true;
3556 USHORT nLeftDistance = 0;
3557 USHORT nRightDistance = 0;
3558 USHORT nTopDistance = 0;
3559 USHORT nBottomDistance = 0;
3561 for(sal_uInt16 i = 0; i < rLines.Count(); i++)
3563 const SwTableLine* pLine = rLines.GetObject(i);
3564 const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
3565 for(sal_uInt16 k = 0; k < rBoxes.Count(); k++)
3567 const SwTableBox* pBox = rBoxes.GetObject(k);
3568 SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
3569 const SvxBoxItem& rBox = pBoxFmt->GetBox();
3570 if( bFirst )
3572 nLeftDistance = TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_LEFT ));
3573 nRightDistance = TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_RIGHT ));
3574 nTopDistance = TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_TOP ));
3575 nBottomDistance = TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_BOTTOM ));
3576 bFirst = false;
3578 else
3580 if( aTableBorderDistances.IsLeftDistanceValid &&
3581 nLeftDistance != TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_LEFT )))
3582 aTableBorderDistances.IsLeftDistanceValid = sal_False;
3583 if( aTableBorderDistances.IsRightDistanceValid &&
3584 nRightDistance != TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_RIGHT )))
3585 aTableBorderDistances.IsRightDistanceValid = sal_False;
3586 if( aTableBorderDistances.IsTopDistanceValid &&
3587 nTopDistance != TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_TOP )))
3588 aTableBorderDistances.IsTopDistanceValid = sal_False;
3589 if( aTableBorderDistances.IsBottomDistanceValid &&
3590 nBottomDistance != TWIP_TO_MM100_UNSIGNED( rBox.GetDistance( BOX_LINE_BOTTOM )))
3591 aTableBorderDistances.IsBottomDistanceValid = sal_False;
3595 if( !aTableBorderDistances.IsLeftDistanceValid &&
3596 !aTableBorderDistances.IsRightDistanceValid &&
3597 !aTableBorderDistances.IsTopDistanceValid &&
3598 !aTableBorderDistances.IsBottomDistanceValid )
3599 break;
3601 if( aTableBorderDistances.IsLeftDistanceValid)
3602 aTableBorderDistances.LeftDistance = nLeftDistance;
3603 if( aTableBorderDistances.IsRightDistanceValid)
3604 aTableBorderDistances.RightDistance = nRightDistance;
3605 if( aTableBorderDistances.IsTopDistanceValid)
3606 aTableBorderDistances.TopDistance = nTopDistance;
3607 if( aTableBorderDistances.IsBottomDistanceValid)
3608 aTableBorderDistances.BottomDistance = nBottomDistance;
3610 aRet <<= aTableBorderDistances;
3612 break;
3613 case FN_UNO_TABLE_COLUMN_SEPARATORS:
3615 SwTable* pTable = SwTable::FindTable( pFmt );
3616 lcl_GetTblSeparators(aRet, pTable, pTable->GetTabLines()[0]->GetTabBoxes()[0], sal_False);
3618 break;
3619 case FN_UNO_TABLE_COLUMN_RELATIVE_SUM:
3620 aRet <<= (INT16) UNO_TABLE_COLUMN_SUM;
3621 break;
3622 case RES_ANCHOR:
3623 //AnchorType ist readonly und maybevoid und wird nicht geliefert
3624 break;
3625 case FN_UNO_TEXT_SECTION:
3627 SwTable* pTable = SwTable::FindTable( pFmt );
3628 SwTableNode* pTblNode = pTable->GetTableNode();
3629 SwSectionNode* pSectionNode = pTblNode->FindSectionNode();
3630 if(pSectionNode)
3632 const SwSection& rSect = pSectionNode->GetSection();
3633 uno::Reference< text::XTextSection > xSect =
3634 SwXTextSections::GetObject( *rSect.GetFmt() );
3635 aRet <<= xSect;
3638 break;
3639 default:
3641 const SwAttrSet& rSet = pFmt->GetAttrSet();
3642 m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
3647 else if(bIsDescriptor)
3649 const uno::Any* pAny = 0;
3650 String aPropertyName(rPropertyName);
3651 if(!pTableProps->GetProperty(pEntry->nWID, pEntry->nMemberId, pAny))
3652 throw lang::IllegalArgumentException();
3653 else if(pAny)
3654 aRet = *pAny;
3656 else
3657 throw uno::RuntimeException();
3658 return aRet;
3660 /*-- 11.12.98 12:42:51---------------------------------------------------
3662 -----------------------------------------------------------------------*/
3663 void SwXTextTable::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3665 DBG_WARNING("not implemented");
3667 /*-- 11.12.98 12:42:52---------------------------------------------------
3669 -----------------------------------------------------------------------*/
3670 void SwXTextTable::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3672 DBG_WARNING("not implemented");
3674 /*-- 11.12.98 12:42:58---------------------------------------------------
3676 -----------------------------------------------------------------------*/
3677 void SwXTextTable::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3679 DBG_WARNING("not implemented");
3681 /*-- 11.12.98 12:42:58---------------------------------------------------
3683 -----------------------------------------------------------------------*/
3684 void SwXTextTable::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3686 DBG_WARNING("not implemented");
3688 /*-- 11.12.98 12:42:58---------------------------------------------------
3690 -----------------------------------------------------------------------*/
3691 OUString SwXTextTable::getName(void) throw( uno::RuntimeException )
3693 vos::OGuard aGuard(Application::GetSolarMutex());
3694 String sRet;
3695 SwFrmFmt* pFmt = GetFrmFmt();
3696 if(!pFmt && !bIsDescriptor)
3697 throw uno::RuntimeException();
3698 if(pFmt)
3700 sRet = pFmt->GetName();
3702 else
3703 sRet = m_sTableName;
3704 return sRet;
3706 /*-- 11.12.98 12:42:59---------------------------------------------------
3708 -----------------------------------------------------------------------*/
3709 void SwXTextTable::setName(const OUString& rName) throw( uno::RuntimeException )
3711 vos::OGuard aGuard(Application::GetSolarMutex());
3712 SwFrmFmt* pFmt = GetFrmFmt();
3713 String sNewTblName(rName);
3714 if(!pFmt && !bIsDescriptor ||
3715 !sNewTblName.Len() ||
3716 STRING_NOTFOUND != sNewTblName.Search('.') ||
3717 STRING_NOTFOUND != sNewTblName.Search(' ') )
3718 throw uno::RuntimeException();
3720 if(pFmt)
3722 const String aOldName( pFmt->GetName() );
3723 sal_Bool bNameFound = sal_False;
3724 SwFrmFmt* pTmpFmt;
3725 const SwFrmFmts* pTbl = pFmt->GetDoc()->GetTblFrmFmts();
3726 for( sal_uInt16 i = pTbl->Count(); i; )
3727 if( !( pTmpFmt = (*pTbl)[ --i ] )->IsDefault() &&
3728 pTmpFmt->GetName() == sNewTblName &&
3729 pFmt->GetDoc()->IsUsed( *pTmpFmt ))
3731 bNameFound = sal_True;
3732 break;
3735 if(bNameFound)
3737 throw uno::RuntimeException();
3739 pFmt->SetName( sNewTblName );
3742 SwStartNode *pStNd;
3743 SwNodeIndex aIdx( *pFmt->GetDoc()->GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
3744 while ( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
3746 aIdx++;
3747 SwNode *pNd = pFmt->GetDoc()->GetNodes()[aIdx];
3748 if ( pNd->IsOLENode() &&
3749 aOldName == ((SwOLENode*)pNd)->GetChartTblName() )
3751 ((SwOLENode*)pNd)->SetChartTblName( sNewTblName );
3753 ((SwOLENode*)pNd)->GetOLEObj();
3755 SwTable* pTable = SwTable::FindTable( pFmt );
3756 //TL_CHART2: chart needs to be notfied about name changes
3757 pFmt->GetDoc()->UpdateCharts( pTable->GetFrmFmt()->GetName() );
3759 aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
3761 pFmt->GetDoc()->SetModified();
3763 else
3764 m_sTableName = sNewTblName;
3766 /*-----------------11.02.98 09:58-------------------
3768 --------------------------------------------------*/
3769 sal_uInt16 SwXTextTable::getRowCount(void)
3771 vos::OGuard aGuard(Application::GetSolarMutex());
3772 sal_Int16 nRet = 0;
3773 SwFrmFmt* pFmt = GetFrmFmt();
3774 if(pFmt)
3776 SwTable* pTable = SwTable::FindTable( pFmt );
3777 if(!pTable->IsTblComplex())
3779 nRet = pTable->GetTabLines().Count();
3782 return nRet;
3784 /*-----------------11.02.98 09:58-------------------
3786 --------------------------------------------------*/
3787 sal_uInt16 SwXTextTable::getColumnCount(void)
3789 vos::OGuard aGuard(Application::GetSolarMutex());
3790 SwFrmFmt* pFmt = GetFrmFmt();
3791 sal_Int16 nRet = 0;
3792 if(pFmt)
3794 SwTable* pTable = SwTable::FindTable( pFmt );
3795 if(!pTable->IsTblComplex())
3797 SwTableLines& rLines = pTable->GetTabLines();
3798 SwTableLine* pLine = rLines.GetObject(0);
3799 nRet = pLine->GetTabBoxes().Count();
3802 return nRet;
3804 /*-- 11.12.98 12:42:59---------------------------------------------------
3806 -----------------------------------------------------------------------*/
3807 void SwXTextTable::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
3809 if(pOld && pOld->Which() == RES_REMOVE_UNO_OBJECT &&
3810 (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject )
3811 ((SwModify*)GetRegisteredIn())->Remove(this);
3812 else
3813 ClientModify(this, pOld, pNew);
3814 if(!GetRegisteredIn())
3816 aLstnrCntnr.Disposing();
3817 aChartLstnrCntnr.Disposing();
3819 else
3820 aChartLstnrCntnr.ChartDataChanged();
3822 /* -----------------25.10.99 15:12-------------------
3824 --------------------------------------------------*/
3825 OUString SAL_CALL SwXTextTable::getImplementationName(void) throw( uno::RuntimeException )
3827 return C2U("SwXTextTable");
3829 /* -----------------25.10.99 15:12-------------------
3831 --------------------------------------------------*/
3832 sal_Bool SwXTextTable::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
3834 String sServiceName(rServiceName);
3835 return (sServiceName.EqualsAscii("com.sun.star.document.LinkTarget") ||
3836 sServiceName.EqualsAscii("com.sun.star.text.TextTable") ||
3837 sServiceName.EqualsAscii("com.sun.star.text.TextContent") ||
3838 sServiceName.EqualsAscii("com.sun.star.text.TextSortable"));
3840 /* -----------------25.10.99 15:12-------------------
3842 --------------------------------------------------*/
3843 uno::Sequence< OUString > SwXTextTable::getSupportedServiceNames(void) throw( uno::RuntimeException )
3845 uno::Sequence< OUString > aRet(4);
3846 OUString* pArr = aRet.getArray();
3847 pArr[0] = C2U("com.sun.star.document.LinkTarget");
3848 pArr[1] = C2U("com.sun.star.text.TextTable");
3849 pArr[2] = C2U("com.sun.star.text.TextContent");
3850 pArr[2] = C2U("com.sun.star.text.TextSortable");
3851 return aRet;
3854 /******************************************************************
3856 ******************************************************************/
3857 /* -----------------------------10.03.00 18:02--------------------------------
3859 ---------------------------------------------------------------------------*/
3860 const uno::Sequence< sal_Int8 > & SwXCellRange::getUnoTunnelId()
3862 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
3863 return aSeq;
3865 /* -----------------------------10.03.00 18:04--------------------------------
3867 ---------------------------------------------------------------------------*/
3868 sal_Int64 SAL_CALL SwXCellRange::getSomething( const uno::Sequence< sal_Int8 >& rId )
3869 throw(uno::RuntimeException)
3871 if( rId.getLength() == 16
3872 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
3873 rId.getConstArray(), 16 ) )
3875 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
3877 return 0;
3879 /* -----------------28.04.98 10:29-------------------
3881 * --------------------------------------------------*/
3882 TYPEINIT1(SwXCellRange, SwClient);
3883 /* -----------------------------19.04.00 15:21--------------------------------
3885 ---------------------------------------------------------------------------*/
3886 OUString SwXCellRange::getImplementationName(void) throw( uno::RuntimeException )
3888 return C2U("SwXCellRange");
3890 /* -----------------------------19.04.00 15:21--------------------------------
3892 ---------------------------------------------------------------------------*/
3893 BOOL SwXCellRange::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
3895 return
3896 rServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.text.CellRange" ) ) ||
3897 rServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.style.CharacterProperties" ) ) ||
3898 rServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.style.CharacterPropertiesAsian" ) ) ||
3899 rServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.style.CharacterPropertiesComplex") ) ||
3900 rServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.style.ParagraphProperties" ) ) ||
3901 rServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.style.ParagraphPropertiesAsian" ) ) ||
3902 rServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.style.ParagraphPropertiesComplex" ) );
3904 /* -----------------------------19.04.00 15:21--------------------------------
3906 ---------------------------------------------------------------------------*/
3907 uno::Sequence< OUString > SwXCellRange::getSupportedServiceNames(void) throw( uno::RuntimeException )
3909 uno::Sequence< OUString > aRet(7);
3910 OUString* pArray = aRet.getArray();
3911 pArray[0] = C2U("com.sun.star.text.CellRange");
3912 pArray[1] = C2U("com.sun.star.style.CharacterProperties");
3913 pArray[2] = C2U("com.sun.star.style.CharacterPropertiesAsian");
3914 pArray[3] = C2U("com.sun.star.style.CharacterPropertiesComplex");
3915 pArray[4] = C2U("com.sun.star.style.ParagraphProperties");
3916 pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian");
3917 pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex");
3918 return aRet;
3921 /*-- 11.12.98 14:27:33---------------------------------------------------
3923 -----------------------------------------------------------------------*/
3924 SwXCellRange::SwXCellRange(SwUnoCrsr* pCrsr, SwFrmFmt& rFrmFmt,
3925 SwRangeDescriptor& rDesc)
3927 SwClient(&rFrmFmt),
3928 aCursorDepend(this, pCrsr),
3929 aChartLstnrCntnr((cppu::OWeakObject*)this),
3930 aRgDesc(rDesc),
3931 m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_RANGE)),
3932 pTblCrsr(pCrsr),
3933 bFirstRowAsLabel(sal_False),
3934 bFirstColumnAsLabel(sal_False)
3936 aRgDesc.Normalize();
3938 /*-- 11.12.98 14:27:33---------------------------------------------------
3940 -----------------------------------------------------------------------*/
3941 SwXCellRange::~SwXCellRange()
3943 vos::OGuard aGuard(Application::GetSolarMutex());
3944 delete pTblCrsr;
3946 /*-- 11.12.98 14:27:34---------------------------------------------------
3948 -----------------------------------------------------------------------*/
3949 uno::Reference< table::XCell > SwXCellRange::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
3950 throw( uno::RuntimeException, lang::IndexOutOfBoundsException )
3952 vos::OGuard aGuard(Application::GetSolarMutex());
3953 uno::Reference< table::XCell > aRet;
3954 SwFrmFmt* pFmt = GetFrmFmt();
3955 if(pFmt)
3957 if(nColumn >= 0 && nRow >= 0 &&
3958 getColumnCount() > nColumn && getRowCount() > nRow )
3960 SwXCell* pXCell = lcl_CreateXCell(pFmt,
3961 aRgDesc.nLeft + nColumn, aRgDesc.nTop + nRow);
3962 if(pXCell)
3963 aRet = pXCell;
3966 if(!aRet.is())
3967 throw lang::IndexOutOfBoundsException();
3968 return aRet;
3970 /*-- 11.12.98 14:27:34---------------------------------------------------
3972 -----------------------------------------------------------------------*/
3973 uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByPosition(
3974 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom)
3975 throw( uno::RuntimeException, lang::IndexOutOfBoundsException )
3977 vos::OGuard aGuard(Application::GetSolarMutex());
3978 uno::Reference< table::XCellRange > aRet;
3979 SwFrmFmt* pFmt = GetFrmFmt();
3980 if(pFmt && getColumnCount() > nRight && getRowCount() > nBottom &&
3981 nLeft <= nRight && nTop <= nBottom
3982 && nLeft >= 0 && nRight >= 0 && nTop >= 0 && nBottom >= 0 )
3984 SwTable* pTable = SwTable::FindTable( pFmt );
3985 if(!pTable->IsTblComplex())
3987 SwRangeDescriptor aNewDesc;
3988 aNewDesc.nTop = nTop + aRgDesc.nTop;
3989 aNewDesc.nBottom = nBottom + aRgDesc.nTop;
3990 aNewDesc.nLeft = nLeft + aRgDesc.nLeft;
3991 aNewDesc.nRight = nRight + aRgDesc.nLeft;
3992 aNewDesc.Normalize();
3993 String sTLName = lcl_GetCellName(aNewDesc.nLeft, aNewDesc.nTop);
3994 String sBRName = lcl_GetCellName(aNewDesc.nRight, aNewDesc.nBottom);
3995 const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
3996 if(pTLBox)
3998 // hier muessen die Actions aufgehoben
3999 UnoActionRemoveContext aRemoveContext(pFmt->GetDoc());
4000 const SwStartNode* pSttNd = pTLBox->GetSttNd();
4001 SwPosition aPos(*pSttNd);
4002 // Cursor in die obere linke Zelle des Ranges setzen
4003 SwUnoCrsr* pUnoCrsr = pFmt->GetDoc()->CreateUnoCrsr(aPos, sal_True);
4004 pUnoCrsr->Move( fnMoveForward, fnGoNode );
4005 pUnoCrsr->SetRemainInSection( sal_False );
4006 const SwTableBox* pBRBox = pTable->GetTblBox( sBRName );
4007 if(pBRBox)
4009 pUnoCrsr->SetMark();
4010 pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd();
4011 pUnoCrsr->Move( fnMoveForward, fnGoNode );
4012 SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
4013 pCrsr->MakeBoxSels();
4014 // pUnoCrsr wird uebergeben und nicht geloescht
4015 SwXCellRange* pCellRange = new SwXCellRange(pUnoCrsr, *pFmt, aNewDesc);
4016 aRet = pCellRange;
4018 else
4019 delete pUnoCrsr;
4023 if(!aRet.is())
4024 throw lang::IndexOutOfBoundsException();
4025 return aRet;
4028 /*-- 11.12.98 14:27:34---------------------------------------------------
4030 -----------------------------------------------------------------------*/
4031 uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByName(const OUString& rRange)
4032 throw( uno::RuntimeException )
4034 vos::OGuard aGuard(Application::GetSolarMutex());
4035 String sRange(rRange);
4036 String sTLName(sRange.GetToken(0, ':'));
4037 String sBRName(sRange.GetToken(1, ':'));
4038 if(!sTLName.Len() || !sBRName.Len())
4039 throw uno::RuntimeException();
4040 SwRangeDescriptor aDesc;
4041 aDesc.nTop = aDesc.nLeft = aDesc.nBottom = aDesc.nRight = -1;
4042 lcl_GetCellPosition( sTLName, aDesc.nLeft, aDesc.nTop );
4043 lcl_GetCellPosition( sBRName, aDesc.nRight, aDesc.nBottom );
4044 aDesc.Normalize();
4045 return getCellRangeByPosition(aDesc.nLeft - aRgDesc.nLeft, aDesc.nTop - aRgDesc.nTop,
4046 aDesc.nRight - aRgDesc.nLeft, aDesc.nBottom - aRgDesc.nTop);
4048 /*-- 11.12.98 14:27:35---------------------------------------------------
4050 -----------------------------------------------------------------------*/
4051 uno::Reference< beans::XPropertySetInfo > SwXCellRange::getPropertySetInfo(void) throw( uno::RuntimeException )
4053 static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
4054 return xRef;
4056 /*-- 11.12.98 14:27:35---------------------------------------------------
4058 -----------------------------------------------------------------------*/
4059 void SwXCellRange::setPropertyValue(const OUString& rPropertyName,
4060 const uno::Any& aValue) throw( beans::UnknownPropertyException,
4061 beans::PropertyVetoException, lang::IllegalArgumentException,
4062 lang::WrappedTargetException, uno::RuntimeException )
4064 vos::OGuard aGuard(Application::GetSolarMutex());
4065 SwFrmFmt* pFmt = GetFrmFmt();
4066 if(pFmt)
4068 /* ASK OLIVER
4069 lcl_FormatTable(pFmt);*/
4070 const SfxItemPropertySimpleEntry* pEntry =
4071 m_pPropSet->getPropertyMap()->getByName(rPropertyName);
4072 if(pEntry)
4074 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
4075 throw beans::PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
4077 SwDoc* pDoc = pTblCrsr->GetDoc();
4079 // remove actions to enable box selection
4080 UnoActionRemoveContext aRemoveContext(pDoc);
4082 SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr);
4083 pCrsr->MakeBoxSels();
4084 switch(pEntry->nWID )
4086 case FN_UNO_TABLE_CELL_BACKGROUND:
4088 SvxBrushItem aBrush( RES_BACKGROUND );
4089 pDoc->GetBoxAttr( *pTblCrsr, aBrush );
4090 ((SfxPoolItem&)aBrush).PutValue(aValue, pEntry->nMemberId);
4091 pDoc->SetBoxAttr( *pTblCrsr, aBrush );
4094 break;
4095 case RES_BOX :
4097 SfxItemSet aSet(pDoc->GetAttrPool(),
4098 RES_BOX, RES_BOX,
4099 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
4101 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
4102 aBoxInfo.SetValid(0xff, FALSE);
4103 BYTE nValid = 0;
4104 switch(pEntry->nMemberId & ~CONVERT_TWIPS)
4106 case LEFT_BORDER : nValid = VALID_LEFT; break;
4107 case RIGHT_BORDER: nValid = VALID_RIGHT; break;
4108 case TOP_BORDER : nValid = VALID_TOP; break;
4109 case BOTTOM_BORDER: nValid = VALID_BOTTOM; break;
4110 case LEFT_BORDER_DISTANCE :
4111 case RIGHT_BORDER_DISTANCE:
4112 case TOP_BORDER_DISTANCE :
4113 case BOTTOM_BORDER_DISTANCE:
4114 nValid = VALID_DISTANCE;
4115 break;
4117 aBoxInfo.SetValid(nValid, TRUE);
4120 aSet.Put(aBoxInfo);
4121 pDoc->GetTabBorders(*pCrsr, aSet);
4123 aSet.Put(aBoxInfo);
4124 SvxBoxItem aBoxItem((const SvxBoxItem&)aSet.Get(RES_BOX));
4125 ((SfxPoolItem&)aBoxItem).PutValue(aValue, pEntry->nMemberId);
4126 aSet.Put(aBoxItem);
4127 pDoc->SetTabBorders( *pTblCrsr, aSet );
4129 break;
4130 case RES_BOXATR_FORMAT:
4132 SfxUInt32Item aNumberFormat(RES_BOXATR_FORMAT);
4133 ((SfxPoolItem&)aNumberFormat).PutValue(aValue, 0);
4134 pDoc->SetBoxAttr( *pCrsr, aNumberFormat);
4136 break;
4137 case FN_UNO_RANGE_ROW_LABEL:
4139 sal_Bool bTmp = *(sal_Bool*)aValue.getValue();
4140 if(bFirstRowAsLabel != bTmp)
4142 aChartLstnrCntnr.ChartDataChanged();
4143 bFirstRowAsLabel = bTmp;
4146 break;
4147 case FN_UNO_RANGE_COL_LABEL:
4149 sal_Bool bTmp = *(sal_Bool*)aValue.getValue();
4150 if(bFirstColumnAsLabel != bTmp)
4152 aChartLstnrCntnr.ChartDataChanged();
4153 bFirstColumnAsLabel = bTmp;
4156 break;
4157 default:
4159 SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID );
4160 SwXTextCursor::GetCrsrAttr( pCrsr->GetSelRing(), aItemSet );
4162 if(!lcl_setCrsrPropertyValue( pEntry, pCrsr->GetSelRing(), aItemSet, aValue ))
4163 m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet );
4164 SwXTextCursor::SetCrsrAttr(pCrsr->GetSelRing(), aItemSet, CRSR_ATTR_MODE_TABLE );
4168 else
4169 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
4172 /*-- 11.12.98 14:27:35---------------------------------------------------
4174 -----------------------------------------------------------------------*/
4175 uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
4177 vos::OGuard aGuard(Application::GetSolarMutex());
4178 uno::Any aRet;
4179 SwFrmFmt* pFmt = GetFrmFmt();
4180 if(pFmt)
4182 /* ASK OLIVER
4183 lcl_FormatTable(pFmt);*/
4184 const SfxItemPropertySimpleEntry* pEntry =
4185 m_pPropSet->getPropertyMap()->getByName(rPropertyName);
4186 if(pEntry)
4188 switch(pEntry->nWID )
4190 case FN_UNO_TABLE_CELL_BACKGROUND:
4192 SvxBrushItem aBrush( RES_BACKGROUND );
4193 if(pTblCrsr->GetDoc()->GetBoxAttr( *pTblCrsr, aBrush ))
4194 aBrush.QueryValue(aRet, pEntry->nMemberId);
4197 break;
4198 case RES_BOX :
4200 SwDoc* pDoc = pTblCrsr->GetDoc();
4201 SfxItemSet aSet(pDoc->GetAttrPool(),
4202 RES_BOX, RES_BOX,
4203 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
4205 aSet.Put(SvxBoxInfoItem( SID_ATTR_BORDER_INNER ));
4206 pDoc->GetTabBorders(*pTblCrsr, aSet);
4207 const SvxBoxItem& rBoxItem = ((const SvxBoxItem&)aSet.Get(RES_BOX));
4208 rBoxItem.QueryValue(aRet, pEntry->nMemberId);
4210 break;
4211 case RES_BOXATR_FORMAT:
4212 //GetAttr fuer Tabellenselektion am Doc fehlt noch
4213 DBG_WARNING("not implemented");
4214 break;
4215 case FN_UNO_PARA_STYLE:
4217 SwFmtColl* pTmpFmt = SwXTextCursor::GetCurTxtFmtColl(*pTblCrsr, FALSE);
4218 OUString sRet;
4219 if(pFmt)
4220 sRet = pTmpFmt->GetName();
4221 aRet <<= sRet;
4223 break;
4224 case FN_UNO_RANGE_ROW_LABEL:
4226 sal_Bool bTemp = bFirstRowAsLabel;
4227 aRet.setValue(&bTemp, ::getCppuBooleanType());
4229 break;
4230 case FN_UNO_RANGE_COL_LABEL:
4232 sal_Bool bTemp = bFirstColumnAsLabel;
4233 aRet.setValue(&bTemp, ::getCppuBooleanType());
4235 break;
4236 default:
4238 SfxItemSet aSet(pTblCrsr->GetDoc()->GetAttrPool(),
4239 RES_CHRATR_BEGIN, RES_FRMATR_END -1,
4240 RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
4241 RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
4242 0L);
4243 // erstmal die Attribute des Cursors
4244 SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr);
4245 SwXTextCursor::GetCrsrAttr(pCrsr->GetSelRing(), aSet);
4246 m_pPropSet->getPropertyValue(*pEntry, aSet, aRet);
4250 else
4251 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
4253 return aRet;
4255 /*-- 11.12.98 14:27:35---------------------------------------------------
4257 -----------------------------------------------------------------------*/
4258 void SwXCellRange::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
4260 DBG_WARNING("not implemented");
4262 /*-- 11.12.98 14:27:35---------------------------------------------------
4264 -----------------------------------------------------------------------*/
4265 void SwXCellRange::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
4267 DBG_WARNING("not implemented");
4269 /*-- 11.12.98 14:27:36---------------------------------------------------
4271 -----------------------------------------------------------------------*/
4272 void SwXCellRange::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
4274 DBG_WARNING("not implemented");
4276 /*-- 11.12.98 14:27:36---------------------------------------------------
4278 -----------------------------------------------------------------------*/
4279 void SwXCellRange::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
4281 DBG_WARNING("not implemented");
4284 /*-----------------------------------------------------------------------
4286 -----------------------------------------------------------------------*/
4288 void SwXCellRange::GetDataSequence(
4289 uno::Sequence< uno::Any > *pAnySeq, //-> first pointer != 0 is used
4290 uno::Sequence< OUString > *pTxtSeq, //-> as output sequence
4291 uno::Sequence< double > *pDblSeq, //-> (previous data gets overwritten)
4292 sal_Bool bForceNumberResults ) //-> when 'true' requires to make an
4293 // extra effort to return a value different
4294 // from 0 even if the cell is formatted to text
4295 throw (uno::RuntimeException)
4297 vos::OGuard aGuard(Application::GetSolarMutex());
4299 // compare to SwXCellRange::getDataArray (note different return types though)
4301 sal_Int16 nRowCount = getRowCount();
4302 sal_Int16 nColCount = getColumnCount();
4304 if(!nRowCount || !nColCount)
4306 uno::RuntimeException aRuntime;
4307 aRuntime.Message = C2U("Table too complex");
4308 throw aRuntime;
4311 sal_Int32 nSize = nRowCount * nColCount;
4312 if (pAnySeq)
4313 pAnySeq->realloc( nSize );
4314 else if (pTxtSeq)
4315 pTxtSeq->realloc( nSize );
4316 else if (pDblSeq)
4317 pDblSeq->realloc( nSize );
4318 else
4320 DBG_ERROR( "argument missing" );
4321 return;
4323 uno::Any *pAnyData = pAnySeq ? pAnySeq->getArray() : 0;
4324 OUString *pTxtData = pTxtSeq ? pTxtSeq->getArray() : 0;
4325 double *pDblData = pDblSeq ? pDblSeq->getArray() : 0;
4327 sal_Int32 nDtaCnt = 0;
4328 SwFrmFmt* pFmt = GetFrmFmt();
4329 if(pFmt)
4331 double fNan;
4332 ::rtl::math::setNan( & fNan );
4334 uno::Reference< table::XCell > xCellRef;
4335 for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++)
4337 for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++)
4339 SwXCell * pXCell = lcl_CreateXCell(pFmt,
4340 aRgDesc.nLeft + nCol,
4341 aRgDesc.nTop + nRow);
4342 //! keep (additional) reference to object to prevent implicit destruction
4343 //! in following UNO calls (when object will get referenced)
4344 xCellRef = pXCell;
4345 SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0;
4346 if(!pBox)
4348 throw uno::RuntimeException();
4350 else
4352 if (pAnyData)
4354 // check if table box value item is set
4355 BOOL bIsNum = pBox->GetFrmFmt()->GetItemState( RES_BOXATR_VALUE, FALSE ) == SFX_ITEM_SET;
4356 //ULONG nNdPos = pBox->IsValidNumTxtNd( sal_True );
4357 if (!bIsNum/* && ULONG_MAX == nNdPos*/)
4358 pAnyData[nDtaCnt++] <<= lcl_getString(*pXCell);
4359 else
4360 pAnyData[nDtaCnt++] <<= lcl_getValue(*pXCell);
4362 else if (pTxtData)
4363 pTxtData[nDtaCnt++] = lcl_getString(*pXCell);
4364 else if (pDblData)
4366 double fVal = fNan;
4367 if (!bForceNumberResults || table::CellContentType_TEXT != pXCell->getType())
4368 fVal = lcl_getValue(*pXCell);
4369 else
4371 DBG_ASSERT( table::CellContentType_TEXT == pXCell->getType(),
4372 "this branch of 'if' is only for text formatted cells" );
4374 // now we'll try to get a useful numerical value
4375 // from the text in the cell...
4377 sal_uInt32 nFIndex;
4378 SvNumberFormatter* pNumFormatter = pTblCrsr->GetDoc()->GetNumberFormatter();
4380 // look for SwTblBoxNumFormat value in parents as well
4381 const SfxPoolItem* pItem;
4382 SwFrmFmt *pBoxFmt = pXCell->GetTblBox()->GetFrmFmt();
4383 SfxItemState eState = pBoxFmt->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, sal_True, &pItem);
4385 if (eState == SFX_ITEM_SET)
4387 // please note that the language of the numberformat
4388 // is implicitly coded into the below value as well
4389 nFIndex = ((SwTblBoxNumFormat*)pItem)->GetValue();
4391 // since the current value indicates a text format but the call
4392 // to 'IsNumberFormat' below won't work for text formats
4393 // we need to get rid of the part that indicates the text format.
4394 // According to ER this can be done like this:
4395 nFIndex -= (nFIndex % SV_COUNTRY_LANGUAGE_OFFSET);
4397 else
4399 // system language is probably not the best possible choice
4400 // but since we have to guess anyway (because the language of at
4401 // the text is NOT the one used for the number format!)
4402 // it is at least conform to to what is used in
4403 // SwTableShell::Execute when
4404 // SID_ATTR_NUMBERFORMAT_VALUE is set...
4405 LanguageType eLang = LANGUAGE_SYSTEM;
4406 nFIndex = pNumFormatter->GetStandardIndex( eLang );
4409 OUString aTxt( lcl_getString(*pXCell) );
4410 double fTmp;
4411 if (pNumFormatter->IsNumberFormat( aTxt, nFIndex, fTmp ))
4412 fVal = fTmp;
4414 pDblData[nDtaCnt++] = fVal;
4416 else {
4417 DBG_ERROR( "output sequence missing" );
4423 DBG_ASSERT( nDtaCnt == nSize, "size mismatch. Invalid cell range?" );
4424 if (pAnySeq)
4425 pAnySeq->realloc( nDtaCnt );
4426 else if (pTxtSeq)
4427 pTxtSeq->realloc( nDtaCnt );
4428 else if (pDblSeq)
4429 pDblSeq->realloc( nDtaCnt );
4432 /*-- 04.06.04 11:42:47---------------------------------------------------
4434 -----------------------------------------------------------------------*/
4436 SwUnoCrsr * lcl_CreateCursor( SwFrmFmt &rTblFmt,
4437 SwTableBox *pStartBox, // should be top-left cell of cell range
4438 SwTableBox *pEndBox ) // should be bottom right-cell cell range
4440 // create a *new* UNO cursor spanning the cell range defined by
4441 // the start and end box. Both boxes must be belong to the same table!
4443 SwUnoCrsr *pUnoCrsr = 0;
4444 if (pStartBox && pEndBox)
4446 // hier muessen die Actions aufgehoben werden um
4447 // (zB dem Layout zu ermöglichen die Tabelle zu formatieren, da
4448 // sonst kein Tabellen Cursor aufgespannt werden kann.)
4449 UnoActionRemoveContext aRemoveContext(rTblFmt.GetDoc());
4451 // set point of cursor to top left box of range
4452 const SwStartNode* pSttNd = pStartBox->GetSttNd();
4453 SwPosition aPos(*pSttNd);
4454 pUnoCrsr = rTblFmt.GetDoc()->CreateUnoCrsr(aPos, sal_True);
4455 pUnoCrsr->Move( fnMoveForward, fnGoNode );
4456 pUnoCrsr->SetRemainInSection( sal_False );
4457 pUnoCrsr->SetMark();
4458 pUnoCrsr->GetPoint()->nNode = *pEndBox->GetSttNd();
4459 pUnoCrsr->Move( fnMoveForward, fnGoNode );
4460 SwUnoTableCrsr *pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
4461 pCrsr->MakeBoxSels();
4463 return pUnoCrsr;
4467 /*-- 29.04.02 11:42:47---------------------------------------------------
4469 -----------------------------------------------------------------------*/
4470 uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray()
4471 throw (uno::RuntimeException)
4473 // see SwXCellRange::getData also
4474 // also see SwXCellRange::GetDataSequence
4476 vos::OGuard aGuard(Application::GetSolarMutex());
4477 sal_Int16 nRowCount = getRowCount();
4478 sal_Int16 nColCount = getColumnCount();
4480 if(!nRowCount || !nColCount)
4482 uno::RuntimeException aRuntime;
4483 aRuntime.Message = C2U("Table too complex");
4484 throw aRuntime;
4486 uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount);
4487 SwFrmFmt* pFmt = GetFrmFmt();
4488 if(pFmt)
4490 uno::Sequence< uno::Any >* pRowArray = aRowSeq.getArray();
4491 uno::Reference< table::XCell > xCellRef;
4492 for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++)
4494 uno::Sequence< uno::Any > aColSeq(nColCount);
4495 uno::Any * pColArray = aColSeq.getArray();
4496 for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++)
4498 SwXCell * pXCell = lcl_CreateXCell(pFmt,
4499 aRgDesc.nLeft + nCol,
4500 aRgDesc.nTop + nRow);
4501 //! keep (additional) reference to object to prevent implicit destruction
4502 //! in following UNO calls (when object will get referenced)
4503 xCellRef = pXCell;
4504 SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0;
4505 if(!pBox)
4507 throw uno::RuntimeException();
4509 else
4511 // check if table box value item is set
4512 SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
4513 BOOL bIsNum = pBoxFmt->GetItemState( RES_BOXATR_VALUE, FALSE ) == SFX_ITEM_SET;
4514 //const SfxPoolItem* pItem;
4515 //SwDoc* pDoc = pXCell->GetDoc();
4516 //BOOL bIsText = (SFX_ITEM_SET != pBoxFmt->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, sal_True, &pItem)
4517 // || pDoc->GetNumberFormatter()->IsTextFormat(((SwTblBoxNumFormat*)pItem)->GetValue())
4518 // || ((SwTblBoxNumFormat*)pItem)->GetValue() == NUMBERFORMAT_TEXT);
4520 if(!bIsNum/*bIsText*/)
4521 pColArray[nCol] <<= lcl_getString(*pXCell);
4522 else
4523 pColArray[nCol] <<= lcl_getValue(*pXCell);
4526 pRowArray[nRow] = aColSeq;
4529 return aRowSeq;
4531 /*-- 29.04.02 11:42:47---------------------------------------------------
4533 -----------------------------------------------------------------------*/
4534 void SAL_CALL SwXCellRange::setDataArray(
4535 const uno::Sequence< uno::Sequence< uno::Any > >& rArray )
4536 throw (uno::RuntimeException)
4538 // see SwXCellRange::setData also
4540 vos::OGuard aGuard(Application::GetSolarMutex());
4541 sal_Int16 nRowCount = getRowCount();
4542 sal_Int16 nColCount = getColumnCount();
4543 if(!nRowCount || !nColCount)
4545 uno::RuntimeException aRuntime;
4546 aRuntime.Message = C2U("Table too complex");
4547 throw aRuntime;
4549 SwFrmFmt* pFmt = GetFrmFmt();
4550 if(pFmt )
4552 if(rArray.getLength() != nRowCount)
4554 throw uno::RuntimeException();
4556 const uno::Sequence< uno::Any >* pRowArray = rArray.getConstArray();
4557 for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++)
4559 const uno::Sequence< uno::Any >& rColSeq = pRowArray[nRow];
4560 if(rColSeq.getLength() != nColCount)
4562 throw uno::RuntimeException();
4564 const uno::Any * pColArray = rColSeq.getConstArray();
4565 uno::Reference< table::XCell > xCellRef;
4566 for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++)
4568 SwXCell * pXCell = lcl_CreateXCell(pFmt,
4569 aRgDesc.nLeft + nCol,
4570 aRgDesc.nTop + nRow);
4571 //! keep (additional) reference to object to prevent implicit destruction
4572 //! in following UNO calls (when object will get referenced)
4573 xCellRef = pXCell;
4574 SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0;
4575 if(!pBox)
4577 throw uno::RuntimeException();
4579 else
4581 const uno::Any &rAny = pColArray[nCol];
4582 if (uno::TypeClass_STRING == rAny.getValueTypeClass())
4583 lcl_setString( *pXCell, *(rtl::OUString *) rAny.getValue() );
4584 else
4586 double d = 0;
4587 // #i20067# don't throw exception just do nothing if
4588 // there is no value set
4589 if( (rAny >>= d) )
4590 lcl_setValue( *pXCell, d );
4591 else
4592 lcl_setString( *pXCell, OUString(), TRUE );
4599 /*-- 11.12.98 14:27:36---------------------------------------------------
4601 -----------------------------------------------------------------------*/
4602 uno::Sequence< uno::Sequence< double > > SwXCellRange::getData(void) throw( uno::RuntimeException )
4604 vos::OGuard aGuard(Application::GetSolarMutex());
4605 sal_Int16 nRowCount = getRowCount();
4606 sal_Int16 nColCount = getColumnCount();
4608 if(!nRowCount || !nColCount)
4610 uno::RuntimeException aRuntime;
4611 aRuntime.Message = C2U("Table too complex");
4612 throw aRuntime;
4614 uno::Sequence< uno::Sequence< double > > aRowSeq(bFirstRowAsLabel ? nRowCount - 1 : nRowCount);
4615 SwFrmFmt* pFmt = GetFrmFmt();
4616 if(pFmt)
4618 uno::Sequence< double >* pRowArray = aRowSeq.getArray();
4620 sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
4621 for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
4623 uno::Sequence< double > aColSeq(bFirstColumnAsLabel ? nColCount - 1 : nColCount);
4624 double * pArray = aColSeq.getArray();
4625 sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
4626 for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
4628 uno::Reference< table::XCell > xCell = getCellByPosition(nCol, nRow);
4629 if(!xCell.is())
4631 throw uno::RuntimeException();
4633 pArray[nCol - nColStart] = xCell->getValue();
4635 pRowArray[nRow - nRowStart] = aColSeq;
4638 return aRowSeq;
4640 /*-- 11.12.98 14:27:37---------------------------------------------------
4642 -----------------------------------------------------------------------*/
4643 void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData)
4644 throw( uno::RuntimeException )
4646 vos::OGuard aGuard(Application::GetSolarMutex());
4647 sal_Int16 nRowCount = getRowCount();
4648 sal_Int16 nColCount = getColumnCount();
4649 if(!nRowCount || !nColCount)
4651 uno::RuntimeException aRuntime;
4652 aRuntime.Message = C2U("Table too complex");
4653 throw aRuntime;
4655 SwFrmFmt* pFmt = GetFrmFmt();
4656 if(pFmt )
4658 sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
4659 if(rData.getLength() < nRowCount - nRowStart)
4661 throw uno::RuntimeException();
4663 const uno::Sequence< double >* pRowArray = rData.getConstArray();
4664 for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
4666 const uno::Sequence< double >& rColSeq = pRowArray[nRow - nRowStart];
4667 sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
4668 if(rColSeq.getLength() < nColCount - nColStart)
4670 throw uno::RuntimeException();
4672 const double * pColArray = rColSeq.getConstArray();
4673 for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
4675 uno::Reference< table::XCell > xCell = getCellByPosition(nCol, nRow);
4676 if(!xCell.is())
4678 throw uno::RuntimeException();
4680 xCell->setValue(pColArray[nCol - nColStart]);
4685 /*-- 11.12.98 14:27:37---------------------------------------------------
4687 -----------------------------------------------------------------------*/
4688 uno::Sequence< OUString > SwXCellRange::getRowDescriptions(void)
4689 throw( uno::RuntimeException )
4691 vos::OGuard aGuard(Application::GetSolarMutex());
4692 sal_Int16 nRowCount = getRowCount();
4693 if(!nRowCount)
4695 uno::RuntimeException aRuntime;
4696 aRuntime.Message = C2U("Table too complex");
4697 throw aRuntime;
4699 uno::Sequence< OUString > aRet(bFirstColumnAsLabel ? nRowCount - 1 : nRowCount);
4700 SwFrmFmt* pFmt = GetFrmFmt();
4701 if(pFmt)
4703 OUString* pArray = aRet.getArray();
4704 if(bFirstColumnAsLabel)
4706 sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
4707 for(sal_uInt16 i = nStart; i < nRowCount; i++)
4709 uno::Reference< table::XCell > xCell = getCellByPosition(0, i);
4710 if(!xCell.is())
4712 throw uno::RuntimeException();
4714 uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
4715 pArray[i - nStart] = xText->getString();
4718 else
4720 DBG_ERROR("Wo kommen die Labels her?");
4723 else
4724 throw uno::RuntimeException();
4725 return aRet;
4727 /*-- 11.12.98 14:27:37---------------------------------------------------
4729 -----------------------------------------------------------------------*/
4730 void SwXCellRange::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc)
4731 throw( uno::RuntimeException )
4733 vos::OGuard aGuard(Application::GetSolarMutex());
4734 SwFrmFmt* pFmt = GetFrmFmt();
4735 if(pFmt)
4737 sal_Int16 nRowCount = getRowCount();
4738 if(!nRowCount || rRowDesc.getLength() < bFirstRowAsLabel ? nRowCount - 1 : nRowCount)
4740 throw uno::RuntimeException();
4742 const OUString* pArray = rRowDesc.getConstArray();
4743 if(bFirstColumnAsLabel)
4745 sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
4746 for(sal_uInt16 i = nStart; i < nRowCount; i++)
4748 uno::Reference< table::XCell > xCell = getCellByPosition(0, i);
4749 if(!xCell.is())
4751 throw uno::RuntimeException();
4753 uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
4754 xText->setString(pArray[i - nStart]);
4757 else
4759 DBG_ERROR("Wohin mit den Labels?");
4763 /*-- 11.12.98 14:27:37---------------------------------------------------
4765 -----------------------------------------------------------------------*/
4766 uno::Sequence< OUString > SwXCellRange::getColumnDescriptions(void)
4767 throw( uno::RuntimeException )
4769 vos::OGuard aGuard(Application::GetSolarMutex());
4770 sal_Int16 nColCount = getColumnCount();
4771 if(!nColCount)
4773 uno::RuntimeException aRuntime;
4774 aRuntime.Message = C2U("Table too complex");
4775 throw aRuntime;
4777 uno::Sequence< OUString > aRet(bFirstRowAsLabel ? nColCount - 1 : nColCount);
4778 SwFrmFmt* pFmt = GetFrmFmt();
4779 if(pFmt)
4781 OUString* pArray = aRet.getArray();
4782 if(bFirstRowAsLabel)
4784 sal_uInt16 nStart = bFirstColumnAsLabel ? 1 : 0;
4785 for(sal_uInt16 i = nStart; i < nColCount; i++)
4787 uno::Reference< table::XCell > xCell = getCellByPosition(i, 0);
4788 if(!xCell.is())
4790 throw uno::RuntimeException();
4792 uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
4793 pArray[i - nStart] = xText->getString();
4796 else
4798 DBG_ERROR("Wo kommen die Labels her?");
4801 else
4802 throw uno::RuntimeException();
4803 return aRet;
4805 /*-- 11.12.98 14:27:37---------------------------------------------------
4807 -----------------------------------------------------------------------*/
4808 void SwXCellRange::setColumnDescriptions(const uno::Sequence< OUString >& ColumnDesc)
4809 throw( uno::RuntimeException )
4811 vos::OGuard aGuard(Application::GetSolarMutex());
4812 sal_Int16 nColCount = getColumnCount();
4813 SwFrmFmt* pFmt = GetFrmFmt();
4814 if(pFmt)
4816 const OUString* pArray = ColumnDesc.getConstArray();
4817 if(bFirstRowAsLabel && ColumnDesc.getLength() >= nColCount - bFirstColumnAsLabel ? 1 : 0)
4819 sal_uInt16 nStart = bFirstColumnAsLabel ? 1 : 0;
4820 for(sal_uInt16 i = nStart; i < nColCount; i++)
4822 uno::Reference< table::XCell > xCell = getCellByPosition(i, 0);
4823 if(!xCell.is())
4825 throw uno::RuntimeException();
4827 uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
4829 xText->setString(pArray[i - nStart]);
4832 else
4834 DBG_ERROR("Wo kommen die Labels her?");
4838 /*-- 11.12.98 14:27:38---------------------------------------------------
4840 -----------------------------------------------------------------------*/
4841 void SwXCellRange::addChartDataChangeEventListener(const uno::Reference< chart::XChartDataChangeEventListener > & aListener) throw( uno::RuntimeException )
4843 if(!GetRegisteredIn())
4844 throw uno::RuntimeException();
4845 aChartLstnrCntnr.AddListener(aListener.get());
4847 /*-- 11.12.98 14:27:38---------------------------------------------------
4849 -----------------------------------------------------------------------*/
4850 void SwXCellRange::removeChartDataChangeEventListener(const uno::Reference< chart::XChartDataChangeEventListener > & aListener) throw( uno::RuntimeException )
4852 if(!GetRegisteredIn() || !aChartLstnrCntnr.RemoveListener(aListener.get()))
4853 throw uno::RuntimeException();
4855 /* -----------------08.03.99 15:36-------------------
4857 * --------------------------------------------------*/
4858 sal_Bool SwXCellRange::isNotANumber(double /*fNumber*/) throw( uno::RuntimeException )
4860 DBG_WARNING("not implemented");
4861 return sal_False;
4864 /* -----------------08.03.99 15:36-------------------
4866 * --------------------------------------------------*/
4867 double SwXCellRange::getNotANumber(void) throw( uno::RuntimeException )
4869 DBG_WARNING("not implemented");
4870 return 0.;
4872 /*-- 11.12.98 14:27:38---------------------------------------------------
4874 -----------------------------------------------------------------------*/
4875 uno::Sequence< beans::PropertyValue > SwXCellRange::createSortDescriptor(void) throw( uno::RuntimeException )
4877 vos::OGuard aGuard(Application::GetSolarMutex());
4878 return SwXTextCursor::createSortDescriptor(sal_True);
4880 /*-- 11.12.98 14:27:39---------------------------------------------------
4882 -----------------------------------------------------------------------*/
4883 void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor)
4884 throw( uno::RuntimeException )
4886 vos::OGuard aGuard(Application::GetSolarMutex());
4887 SwSortOptions aSortOpt;
4888 SwFrmFmt* pFmt = GetFrmFmt();
4889 if(pFmt &&
4890 SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt))
4892 SwUnoTableCrsr* pTableCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr);
4893 pTableCrsr->MakeBoxSels();
4894 UnoActionContext aContext( pFmt->GetDoc() );
4895 pFmt->GetDoc()->SortTbl(pTableCrsr->GetBoxes(), aSortOpt);
4898 /* -----------------27.04.98 16:54-------------------
4900 * --------------------------------------------------*/
4901 sal_uInt16 SwXCellRange::getColumnCount(void)
4903 return static_cast< sal_uInt16 >(aRgDesc.nRight - aRgDesc.nLeft + 1);
4905 /* -----------------27.04.98 16:54-------------------
4907 * --------------------------------------------------*/
4908 sal_uInt16 SwXCellRange::getRowCount(void)
4910 return static_cast< sal_uInt16 >(aRgDesc.nBottom - aRgDesc.nTop + 1);
4912 /* -----------------------------05.06.01 09:19--------------------------------
4914 ---------------------------------------------------------------------------*/
4915 const SwUnoCrsr* SwXCellRange::GetTblCrsr() const
4917 const SwUnoCrsr* pRet = 0;
4918 SwFrmFmt* pFmt = GetFrmFmt();
4919 if(pFmt)
4920 pRet = pTblCrsr;
4921 return pRet;
4924 /*-- 11.12.98 14:27:39---------------------------------------------------
4926 -----------------------------------------------------------------------*/
4927 void SwXCellRange::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
4929 ClientModify(this, pOld, pNew );
4930 if(!GetRegisteredIn() || !aCursorDepend.GetRegisteredIn())
4933 * Not sure if this will cause a memory leak - this pTblCrsr
4934 * is deleted in SwDoc and GPFs here when deleted again
4935 * if(!aCursorDepend.GetRegisteredIn())
4936 delete pTblCrsr;
4938 pTblCrsr = 0;
4939 aChartLstnrCntnr.Disposing();
4941 else
4942 aChartLstnrCntnr.ChartDataChanged();
4944 /******************************************************************
4945 * SwXTableRows
4946 ******************************************************************/
4947 /* -----------------------------19.04.00 15:22--------------------------------
4949 ---------------------------------------------------------------------------*/
4950 OUString SwXTableRows::getImplementationName(void) throw( uno::RuntimeException )
4952 return C2U("SwXTableRows");
4954 /* -----------------------------19.04.00 15:22--------------------------------
4956 ---------------------------------------------------------------------------*/
4957 BOOL SwXTableRows::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
4959 return C2U("com.sun.star.text.TableRows") == rServiceName;
4961 /* -----------------------------19.04.00 15:22--------------------------------
4963 ---------------------------------------------------------------------------*/
4964 uno::Sequence< OUString > SwXTableRows::getSupportedServiceNames(void) throw( uno::RuntimeException )
4966 uno::Sequence< OUString > aRet(1);
4967 OUString* pArray = aRet.getArray();
4968 pArray[0] = C2U("com.sun.star.text.TableRows");
4969 return aRet;
4971 TYPEINIT1(SwXTableRows, SwClient);
4972 /*-- 03.02.99 07:37:41---------------------------------------------------
4973 -----------------------------------------------------------------------*/
4974 SwXTableRows::SwXTableRows(SwFrmFmt& rFrmFmt) :
4975 SwClient(&rFrmFmt)
4978 /*-- 03.02.99 07:37:41---------------------------------------------------
4980 -----------------------------------------------------------------------*/
4981 SwXTableRows::~SwXTableRows()
4984 /*-- 03.02.99 07:37:41---------------------------------------------------
4986 -----------------------------------------------------------------------*/
4987 sal_Int32 SwXTableRows::getCount(void) throw( uno::RuntimeException )
4989 vos::OGuard aGuard(Application::GetSolarMutex());
4990 sal_Int32 nRet = 0;
4991 SwFrmFmt* pFrmFmt = GetFrmFmt();
4992 if(!pFrmFmt)
4993 throw uno::RuntimeException();
4994 else
4996 SwTable* pTable = SwTable::FindTable( pFrmFmt );
4997 nRet = pTable->GetTabLines().Count();
4999 return nRet;
5001 /*-- 03.02.99 07:37:41---------------------------------------------------
5003 -----------------------------------------------------------------------*/
5004 uno::Any SwXTableRows::getByIndex(sal_Int32 nIndex)
5005 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
5007 vos::OGuard aGuard(Application::GetSolarMutex());
5008 uno::Any aRet;
5009 SwFrmFmt* pFrmFmt = GetFrmFmt();
5010 if(!pFrmFmt || nIndex < 0 )
5011 throw lang::IndexOutOfBoundsException();
5012 else
5014 SwTable* pTable = SwTable::FindTable( pFrmFmt );
5015 if(pTable->GetTabLines().Count() > nIndex)
5017 SwTableLine* pLine = pTable->GetTabLines().GetObject((sal_uInt16)nIndex);
5018 SwClientIter aIter( *pFrmFmt );
5019 SwXTextTableRow* pXRow = (SwXTextTableRow*)aIter.
5020 First( TYPE( SwXTextTableRow ));
5021 while( pXRow )
5023 // gibt es eine passende Zelle bereits?
5024 if(pXRow->GetTblRow() == pLine)
5025 break;
5026 pXRow = (SwXTextTableRow*)aIter.Next();
5028 //sonst anlegen
5029 if(!pXRow)
5030 pXRow = new SwXTextTableRow(pFrmFmt, pLine);
5031 uno::Reference< beans::XPropertySet > xRet =
5032 (beans::XPropertySet*)pXRow;
5033 aRet.setValue(&xRet, ::getCppuType((const uno::Reference<beans::XPropertySet>*)0));
5035 else
5036 throw lang::IndexOutOfBoundsException();
5038 return aRet;
5040 /*-- 03.02.99 07:37:42---------------------------------------------------
5042 -----------------------------------------------------------------------*/
5043 uno::Type SAL_CALL SwXTableRows::getElementType(void) throw( uno::RuntimeException )
5045 return ::getCppuType((const uno::Reference<beans::XPropertySet>*)0);
5047 /*-- 03.02.99 07:37:42---------------------------------------------------
5049 -----------------------------------------------------------------------*/
5050 sal_Bool SwXTableRows::hasElements(void) throw( uno::RuntimeException )
5052 vos::OGuard aGuard(Application::GetSolarMutex());
5053 SwFrmFmt* pFrmFmt = GetFrmFmt();
5054 if(!pFrmFmt)
5055 throw uno::RuntimeException();
5056 //es gibt keine Tabelle ohne Zeilen
5057 return sal_True;
5059 /*-- 03.02.99 07:37:42---------------------------------------------------
5061 -----------------------------------------------------------------------*/
5062 void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount) throw( uno::RuntimeException )
5064 vos::OGuard aGuard(Application::GetSolarMutex());
5065 if (nCount == 0)
5066 return;
5067 SwFrmFmt* pFrmFmt = GetFrmFmt();
5068 if(!pFrmFmt)
5069 throw uno::RuntimeException();
5070 else
5072 SwTable* pTable = SwTable::FindTable( pFrmFmt );
5073 if(!pTable->IsTblComplex())
5075 sal_uInt16 nRowCount = pTable->GetTabLines().Count();
5076 if (nCount <= 0 || !(0 <= nIndex && nIndex <= nRowCount))
5078 uno::RuntimeException aExcept;
5079 aExcept.Message = C2U("Illegal arguments");
5080 throw aExcept;
5083 String sTLName = lcl_GetCellName(0, nIndex);
5084 const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
5085 sal_Bool bAppend = sal_False;
5086 if(!pTLBox)
5088 bAppend = sal_True;
5089 // am Ende anfuegen, dazu muss der Cursor in die letzte Zeile!
5090 SwTableLines& rLines = pTable->GetTabLines();
5091 SwTableLine* pLine = rLines.GetObject(rLines.Count() -1);
5092 SwTableBoxes& rBoxes = pLine->GetTabBoxes();
5093 pTLBox = rBoxes.GetObject(0);
5095 if(pTLBox)
5097 const SwStartNode* pSttNd = pTLBox->GetSttNd();
5098 SwPosition aPos(*pSttNd);
5099 // Cursor in die obere linke Zelle des Ranges setzen
5100 UnoActionContext aAction(pFrmFmt->GetDoc());
5101 SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, sal_True);
5102 pUnoCrsr->Move( fnMoveForward, fnGoNode );
5105 // remove actions
5106 UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
5109 pFrmFmt->GetDoc()->InsertRow(*pUnoCrsr, (sal_uInt16)nCount, bAppend);
5110 delete pUnoCrsr;
5115 /*-- 03.02.99 07:37:43---------------------------------------------------
5117 -----------------------------------------------------------------------*/
5118 void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount) throw( uno::RuntimeException )
5120 vos::OGuard aGuard(Application::GetSolarMutex());
5121 if (nCount == 0)
5122 return;
5123 SwFrmFmt* pFrmFmt = GetFrmFmt();
5124 if(!pFrmFmt || nIndex < 0 || nCount <=0 )
5125 throw uno::RuntimeException();
5126 else
5128 BOOL bSuccess = FALSE;
5129 SwTable* pTable = SwTable::FindTable( pFrmFmt );
5130 if(!pTable->IsTblComplex())
5132 String sTLName = lcl_GetCellName(0, nIndex);
5133 const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
5134 if(pTLBox)
5137 // hier muessen die Actions aufgehoben werden
5138 UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc());
5140 const SwStartNode* pSttNd = pTLBox->GetSttNd();
5141 SwPosition aPos(*pSttNd);
5142 // Cursor in die obere linke Zelle des Ranges setzen
5143 SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, sal_True);
5144 pUnoCrsr->Move( fnMoveForward, fnGoNode );
5145 pUnoCrsr->SetRemainInSection( sal_False );
5146 String sBLName = lcl_GetCellName(0, nIndex + nCount - 1);
5147 const SwTableBox* pBLBox = pTable->GetTblBox( sBLName );
5148 if(pBLBox)
5150 pUnoCrsr->SetMark();
5151 pUnoCrsr->GetPoint()->nNode = *pBLBox->GetSttNd();
5152 pUnoCrsr->Move( fnMoveForward, fnGoNode );
5153 SwUnoTableCrsr* pCrsr =
5154 dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
5155 pCrsr->MakeBoxSels();
5156 { // Die Klammer ist wichtig
5157 UnoActionContext aAction(pFrmFmt->GetDoc());
5158 pFrmFmt->GetDoc()->DeleteRow(*pUnoCrsr);
5159 delete pUnoCrsr;
5160 bSuccess = TRUE;
5163 // hier muessen die Actions aufgehoben werden
5164 UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc());
5169 if(!bSuccess)
5171 uno::RuntimeException aExcept;
5172 aExcept.Message = C2U("Illegal arguments");
5173 throw aExcept;
5177 /*-- 03.02.99 07:37:43---------------------------------------------------
5179 -----------------------------------------------------------------------*/
5180 void SwXTableRows::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
5182 ClientModify(this, pOld, pNew);
5185 /******************************************************************
5186 * SwXTableColumns
5187 ******************************************************************/
5188 /* -----------------------------19.04.00 15:23--------------------------------
5190 ---------------------------------------------------------------------------*/
5191 OUString SwXTableColumns::getImplementationName(void) throw( uno::RuntimeException )
5193 return C2U("SwXTableColumns");
5195 /* -----------------------------19.04.00 15:23--------------------------------
5197 ---------------------------------------------------------------------------*/
5198 BOOL SwXTableColumns::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
5200 return C2U("com.sun.star.text.TableColumns") == rServiceName;
5202 /* -----------------------------19.04.00 15:23--------------------------------
5204 ---------------------------------------------------------------------------*/
5205 uno::Sequence< OUString > SwXTableColumns::getSupportedServiceNames(void) throw( uno::RuntimeException )
5207 uno::Sequence< OUString > aRet(1);
5208 OUString* pArray = aRet.getArray();
5209 pArray[0] = C2U("com.sun.star.text.TableColumns");
5210 return aRet;
5212 TYPEINIT1(SwXTableColumns, SwClient);
5213 /*-- 03.02.99 07:37:41---------------------------------------------------
5214 -----------------------------------------------------------------------*/
5215 SwXTableColumns::SwXTableColumns(SwFrmFmt& rFrmFmt) :
5216 SwClient(&rFrmFmt)
5219 /*-- 03.02.99 07:37:41---------------------------------------------------
5221 -----------------------------------------------------------------------*/
5222 SwXTableColumns::~SwXTableColumns()
5225 /*-- 03.02.99 07:37:41---------------------------------------------------
5227 -----------------------------------------------------------------------*/
5228 sal_Int32 SwXTableColumns::getCount(void) throw( uno::RuntimeException )
5230 vos::OGuard aGuard(Application::GetSolarMutex());
5231 sal_Int32 nRet = 0;
5232 SwFrmFmt* pFrmFmt = GetFrmFmt();
5233 if(!pFrmFmt)
5234 throw uno::RuntimeException();
5235 else
5237 SwTable* pTable = SwTable::FindTable( pFrmFmt );
5238 if(!pTable->IsTblComplex())
5240 SwTableLines& rLines = pTable->GetTabLines();
5241 SwTableLine* pLine = rLines.GetObject(0);
5242 nRet = pLine->GetTabBoxes().Count();
5245 return nRet;
5247 /*-- 03.02.99 07:37:41---------------------------------------------------
5249 -----------------------------------------------------------------------*/
5250 uno::Any SwXTableColumns::getByIndex(sal_Int32 nIndex)
5251 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
5253 vos::OGuard aGuard(Application::GetSolarMutex());
5254 uno::Reference< uno::XInterface > xRet;
5255 SwFrmFmt* pFrmFmt = GetFrmFmt();
5256 if(!pFrmFmt)
5257 throw uno::RuntimeException();
5258 else
5260 USHORT nCount = 0;
5261 SwTable* pTable = SwTable::FindTable( pFrmFmt );
5262 if(!pTable->IsTblComplex())
5264 SwTableLines& rLines = pTable->GetTabLines();
5265 SwTableLine* pLine = rLines.GetObject(0);
5266 nCount = pLine->GetTabBoxes().Count();
5268 if(nCount <= nIndex || nIndex < 0)
5269 throw lang::IndexOutOfBoundsException();
5270 xRet = uno::Reference<uno::XInterface>(); //!! writer tables do not have columns !!
5272 return uno::Any(&xRet, ::getCppuType((const uno::Reference<uno::XInterface>*)0));
5274 /*-- 03.02.99 07:37:42---------------------------------------------------
5276 -----------------------------------------------------------------------*/
5278 uno::Type SAL_CALL SwXTableColumns::getElementType(void) throw( uno::RuntimeException )
5280 return ::getCppuType((uno::Reference<uno::XInterface>*)0);
5282 /*-- 03.02.99 07:37:42---------------------------------------------------
5284 -----------------------------------------------------------------------*/
5285 sal_Bool SwXTableColumns::hasElements(void) throw( uno::RuntimeException )
5287 vos::OGuard aGuard(Application::GetSolarMutex());
5288 SwFrmFmt* pFrmFmt = GetFrmFmt();
5289 if(!pFrmFmt)
5290 throw uno::RuntimeException();
5291 return sal_True;
5293 /*-- 03.02.99 07:37:42---------------------------------------------------
5295 -----------------------------------------------------------------------*/
5296 void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount) throw( uno::RuntimeException )
5298 vos::OGuard aGuard(Application::GetSolarMutex());
5299 if (nCount == 0)
5300 return;
5301 SwFrmFmt* pFrmFmt = GetFrmFmt();
5302 if(!pFrmFmt)
5303 throw uno::RuntimeException();
5304 else
5306 SwTable* pTable = SwTable::FindTable( pFrmFmt );
5307 if(!pTable->IsTblComplex())
5309 SwTableLines& rLines = pTable->GetTabLines();
5310 SwTableLine* pLine = rLines.GetObject(0);
5311 sal_uInt16 nColCount = pLine->GetTabBoxes().Count();
5312 if (nCount <= 0 || !(0 <= nIndex && nIndex <= nColCount))
5314 uno::RuntimeException aExcept;
5315 aExcept.Message = C2U("Illegal arguments");
5316 throw aExcept;
5319 String sTLName = lcl_GetCellName(nIndex, 0);
5320 const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
5321 sal_Bool bAppend = sal_False;
5322 if(!pTLBox)
5324 bAppend = sal_True;
5325 // am Ende anfuegen, dazu muss der Cursor in die letzte Spalte!
5326 SwTableBoxes& rBoxes = pLine->GetTabBoxes();
5327 pTLBox = rBoxes.GetObject(rBoxes.Count() - 1);
5329 if(pTLBox)
5331 const SwStartNode* pSttNd = pTLBox->GetSttNd();
5332 SwPosition aPos(*pSttNd);
5333 UnoActionContext aAction(pFrmFmt->GetDoc());
5334 SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, sal_True);
5335 pUnoCrsr->Move( fnMoveForward, fnGoNode );
5338 // remove actions
5339 UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
5342 pFrmFmt->GetDoc()->InsertCol(*pUnoCrsr, (sal_uInt16)nCount, bAppend);
5343 delete pUnoCrsr;
5348 /*-- 03.02.99 07:37:43---------------------------------------------------
5350 -----------------------------------------------------------------------*/
5351 void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount) throw( uno::RuntimeException )
5353 vos::OGuard aGuard(Application::GetSolarMutex());
5354 if (nCount == 0)
5355 return;
5356 SwFrmFmt* pFrmFmt = GetFrmFmt();
5357 if(!pFrmFmt|| nIndex < 0 || nCount <=0 )
5358 throw uno::RuntimeException();
5359 else
5361 BOOL bSuccess = FALSE;
5362 SwTable* pTable = SwTable::FindTable( pFrmFmt );
5363 if(!pTable->IsTblComplex())
5365 String sTLName = lcl_GetCellName(nIndex, 0);
5366 const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
5367 if(pTLBox)
5370 // hier muessen die Actions aufgehoben werden
5371 UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc());
5373 const SwStartNode* pSttNd = pTLBox->GetSttNd();
5374 SwPosition aPos(*pSttNd);
5375 // Cursor in die obere linke Zelle des Ranges setzen
5376 SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, sal_True);
5377 pUnoCrsr->Move( fnMoveForward, fnGoNode );
5378 pUnoCrsr->SetRemainInSection( sal_False );
5379 String sTRName = lcl_GetCellName(nIndex + nCount - 1, 0);
5380 const SwTableBox* pTRBox = pTable->GetTblBox( sTRName );
5381 if(pTRBox)
5383 pUnoCrsr->SetMark();
5384 pUnoCrsr->GetPoint()->nNode = *pTRBox->GetSttNd();
5385 pUnoCrsr->Move( fnMoveForward, fnGoNode );
5386 SwUnoTableCrsr* pCrsr =
5387 dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
5388 pCrsr->MakeBoxSels();
5389 { // Die Klammer ist wichtig
5390 UnoActionContext aAction(pFrmFmt->GetDoc());
5391 pFrmFmt->GetDoc()->DeleteCol(*pUnoCrsr);
5392 delete pUnoCrsr;
5393 bSuccess = TRUE;
5396 // hier muessen die Actions aufgehoben werden
5397 UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc());
5402 if(!bSuccess)
5404 uno::RuntimeException aExcept;
5405 aExcept.Message = C2U("Illegal arguments");
5406 throw aExcept;
5410 /*-- 03.02.99 07:37:43---------------------------------------------------
5412 -----------------------------------------------------------------------*/
5413 void SwXTableColumns::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
5415 ClientModify(this, pOld, pNew);
5417 /* -----------------------------22.09.00 11:11--------------------------------
5419 ---------------------------------------------------------------------------*/
5420 void SwChartEventListenerContainer::ChartDataChanged()
5422 if(pListenerArr)
5424 //TODO: find appropriate settings of the Event
5425 lang::EventObject aObj(pxParent);
5426 chart::ChartDataChangeEvent aEvent;
5427 aEvent.Type = chart::ChartDataChangeType_ALL;
5428 aEvent.StartColumn = 0;
5429 aEvent.EndColumn = 1;
5430 aEvent.StartRow = 0;
5431 aEvent.EndRow = 1;
5433 for(sal_uInt16 i = 0; i < pListenerArr->Count(); i++)
5437 XEventListenerPtr pElem = pListenerArr->GetObject(i);
5438 uno::Reference<lang::XEventListener> xEventListener = *pElem;
5439 uno::Reference<chart::XChartDataChangeEventListener> xChartEventListener = (chart::XChartDataChangeEventListener*)(*pElem).get();
5440 xChartEventListener->chartDataChanged( aEvent );
5442 catch(uno::Exception const &)
5449 ///////////////////////////////////////////////////////////////////////////