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