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