xref: /trunk/main/svx/source/table/cell.cxx (revision 4b04c19b27cef8b0c77f01d2126079cba90dc7bd)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #include <com/sun/star/drawing/BitmapMode.hpp>
28 #include <com/sun/star/style/XStyle.hpp>
29 #include <com/sun/star/text/WritingMode.hpp>
30 #include <com/sun/star/table/TableBorder.hpp>
31 
32 #include <cppuhelper/typeprovider.hxx>
33 #include <svl/style.hxx>
34 #include <svl/itemset.hxx>
35 
36 #include <vos/mutex.hxx>
37 #include <vcl/svapp.hxx>
38 
39 #include "svx/sdr/properties/textproperties.hxx"
40 #include "editeng/outlobj.hxx"
41 #include "editeng/writingmodeitem.hxx"
42 #include "svx/svdotable.hxx"
43 #include "svx/svdoutl.hxx"
44 #include "svx/unoshtxt.hxx"
45 #include "svx/svdmodel.hxx"
46 
47 #include "tableundo.hxx"
48 #include "cell.hxx"
49 #include "svx/svdotable.hxx"
50 #include "svx/svdoutl.hxx"
51 #include "svx/unoshtxt.hxx"
52 #include "svx/unoshprp.hxx"
53 #include "svx/unoshape.hxx"
54 #include "editeng/editobj.hxx"
55 #include "editeng/boxitem.hxx"
56 #include "svx/xflbstit.hxx"
57 #include "svx/xflbmtit.hxx"
58 #include <svx/svdpool.hxx>
59 
60 // -----------------------------------------------------------------------------
61 
62 using ::rtl::OUString;
63 using ::vos::OGuard;
64 using namespace ::com::sun::star::uno;
65 using namespace ::com::sun::star::beans;
66 using namespace ::com::sun::star::lang;
67 using namespace ::com::sun::star::text;
68 using namespace ::com::sun::star::table;
69 using namespace ::com::sun::star::drawing;
70 using namespace ::com::sun::star::style;
71 using namespace ::com::sun::star::container;
72 
73 // -----------------------------------------------------------------------------
74 
ImplGetSvxCellPropertySet()75 static const SvxItemPropertySet* ImplGetSvxCellPropertySet()
76 {
77     // Propertymap fuer einen Outliner Text
78     static const SfxItemPropertyMapEntry aSvxCellPropertyMap[] =
79     {
80         FILL_PROPERTIES
81 //      { MAP_CHAR_LEN("HasLevels"),                    OWN_ATTR_HASLEVELS,             &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::READONLY,      0},
82         { MAP_CHAR_LEN("Style"),                        OWN_ATTR_STYLE,                 &::com::sun::star::style::XStyle::static_type(),                                    ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
83         { MAP_CHAR_LEN(UNO_NAME_TEXT_WRITINGMODE),      SDRATTR_TEXTDIRECTION,          &::getCppuType( (::com::sun::star::text::WritingMode*) 0 ),                         0,      0},
84         { MAP_CHAR_LEN(UNO_NAME_TEXT_HORZADJUST),       SDRATTR_TEXT_HORZADJUST,        &::getCppuType((const ::com::sun::star::drawing::TextHorizontalAdjust*)0),  0,      0}, \
85         { MAP_CHAR_LEN(UNO_NAME_TEXT_LEFTDIST),         SDRATTR_TEXT_LEFTDIST,          &::getCppuType((const sal_Int32*)0),        0,      SFX_METRIC_ITEM}, \
86         { MAP_CHAR_LEN(UNO_NAME_TEXT_LOWERDIST),        SDRATTR_TEXT_LOWERDIST,         &::getCppuType((const sal_Int32*)0),        0,      SFX_METRIC_ITEM}, \
87         { MAP_CHAR_LEN(UNO_NAME_TEXT_RIGHTDIST),        SDRATTR_TEXT_RIGHTDIST,         &::getCppuType((const sal_Int32*)0),        0,      SFX_METRIC_ITEM}, \
88         { MAP_CHAR_LEN(UNO_NAME_TEXT_UPPERDIST),        SDRATTR_TEXT_UPPERDIST,         &::getCppuType((const sal_Int32*)0),        0,      SFX_METRIC_ITEM}, \
89         { MAP_CHAR_LEN(UNO_NAME_TEXT_VERTADJUST),       SDRATTR_TEXT_VERTADJUST,        &::getCppuType((const ::com::sun::star::drawing::TextVerticalAdjust*)0),    0,      0},\
90         { MAP_CHAR_LEN(UNO_NAME_TEXT_WORDWRAP),         SDRATTR_TEXT_WORDWRAP,          &::getBooleanCppuType(),        0,      0}, \
91 
92         { MAP_CHAR_LEN("TableBorder"),                  OWN_ATTR_TABLEBORDER,           &::getCppuType((const TableBorder*)0), 0, 0 }, \
93         { MAP_CHAR_LEN("TopBorder"),                    SDRATTR_TABLE_BORDER,           &::getCppuType((const BorderLine*)0), 0, TOP_BORDER }, \
94         { MAP_CHAR_LEN("BottomBorder"),                 SDRATTR_TABLE_BORDER,           &::getCppuType((const BorderLine*)0), 0, BOTTOM_BORDER }, \
95         { MAP_CHAR_LEN("LeftBorder"),                   SDRATTR_TABLE_BORDER,           &::getCppuType((const BorderLine*)0), 0, LEFT_BORDER }, \
96         { MAP_CHAR_LEN("RightBorder"),                  SDRATTR_TABLE_BORDER,           &::getCppuType((const BorderLine*)0), 0, RIGHT_BORDER }, \
97 
98         SVX_UNOEDIT_OUTLINER_PROPERTIES,
99         SVX_UNOEDIT_CHAR_PROPERTIES,
100         SVX_UNOEDIT_PARA_PROPERTIES,
101         {0,0,0,0,0,0}
102     };
103 
104     static SvxItemPropertySet aSvxCellPropertySet( aSvxCellPropertyMap, SdrObject::GetGlobalDrawObjectItemPool() );
105     return &aSvxCellPropertySet;
106 }
107 
108 namespace sdr
109 {
110     namespace properties
111     {
112         class CellProperties : public TextProperties
113         {
114         protected:
115             // create a new itemset
116             SfxItemSet& CreateObjectSpecificItemSet(SfxItemPool& rPool);
117 
118         public:
119             // basic constructor
120             CellProperties(SdrObject& rObj, sdr::table::Cell* pCell );
121 
122             // constructor for copying, but using new object
123             CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell);
124 
125             // destructor
126             ~CellProperties();
127 
128             // Clone() operator, normally just calls the local copy constructor
129             BaseProperties& Clone(SdrObject& rObj) const;
130 
131             void ForceDefaultAttributes();
132 
133             void ItemSetChanged(const SfxItemSet& rSet);
134 
135             void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem);
136 
137             void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr);
138 
139             sdr::table::CellRef mxCell;
140         };
141 
142         // create a new itemset
CreateObjectSpecificItemSet(SfxItemPool & rPool)143         SfxItemSet& CellProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
144         {
145             return *(new SfxItemSet(rPool,
146 
147                 // range from SdrAttrObj
148                 SDRATTR_START, SDRATTR_SHADOW_LAST,
149                 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
150                 SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
151 
152                 // range for SdrTableObj
153                 SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
154 
155                 // range from SdrTextObj
156                 EE_ITEMS_START, EE_ITEMS_END,
157 
158                 // end
159                 0, 0));
160         }
161 
CellProperties(SdrObject & rObj,sdr::table::Cell * pCell)162         CellProperties::CellProperties(SdrObject& rObj, sdr::table::Cell* pCell)
163         :   TextProperties(rObj)
164         ,   mxCell(pCell)
165         {
166         }
167 
CellProperties(const CellProperties & rProps,SdrObject & rObj,sdr::table::Cell * pCell)168         CellProperties::CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell)
169         :   TextProperties(rProps, rObj)
170         ,   mxCell( pCell )
171         {
172         }
173 
~CellProperties()174         CellProperties::~CellProperties()
175         {
176         }
177 
Clone(SdrObject & rObj) const178         BaseProperties& CellProperties::Clone(SdrObject& rObj) const
179         {
180             DBG_ERROR("CellProperties::Clone(), does not work yet!");
181             return *(new CellProperties(*this, rObj,0));
182         }
183 
ForceDefaultAttributes()184         void CellProperties::ForceDefaultAttributes()
185         {
186         }
187 
ItemSetChanged(const SfxItemSet & rSet)188         void CellProperties::ItemSetChanged(const SfxItemSet& rSet )
189         {
190             SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
191 
192             if( mxCell.is() )
193             {
194                 OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject();
195 
196                 bool bOwnParaObj = pParaObj != 0;
197 
198                 if( pParaObj == 0 )
199                     pParaObj = mxCell->GetOutlinerParaObject();
200 
201                 if(pParaObj)
202                 {
203                     // handle outliner attributes
204                     Outliner* pOutliner = 0;
205 
206                     if(mxCell->IsTextEditActive())
207                     {
208                         pOutliner = rObj.GetTextEditOutliner();
209                     }
210                     else
211                     {
212                         pOutliner = &rObj.ImpGetDrawOutliner();
213                         pOutliner->SetText(*pParaObj);
214                     }
215 
216                     sal_uInt32 nParaCount(pOutliner->GetParagraphCount());
217 
218                     for(sal_uInt32 nPara = 0; nPara < nParaCount; nPara++)
219                     {
220                         SfxItemSet aSet(pOutliner->GetParaAttribs(nPara));
221                         aSet.Put(rSet);
222                         pOutliner->SetParaAttribs(nPara, aSet);
223                     }
224 
225                     if(!mxCell->IsTextEditActive())
226                     {
227                         if(nParaCount)
228                         {
229                             // force ItemSet
230                             GetObjectItemSet();
231 
232                             SfxItemSet aNewSet(pOutliner->GetParaAttribs(0L));
233                             mpItemSet->Put(aNewSet);
234                         }
235 
236                         OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount);
237                         pOutliner->Clear();
238 
239                         mxCell->SetOutlinerParaObject(pTemp);
240                     }
241 
242                     if( bOwnParaObj )
243                         delete pParaObj;
244                 }
245             }
246 
247             // call parent
248             AttributeProperties::ItemSetChanged(rSet);
249 
250             if( mxCell.is() )
251                 mxCell->notifyModified();
252         }
253 
ItemChange(const sal_uInt16 nWhich,const SfxPoolItem * pNewItem)254         void CellProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
255         {
256             if(pNewItem && (SDRATTR_TEXTDIRECTION == nWhich))
257             {
258                 sal_Bool bVertical(com::sun::star::text::WritingMode_TB_RL == ((SvxWritingModeItem*)pNewItem)->GetValue());
259 
260                 sdr::table::SdrTableObj& rObj = (sdr::table::SdrTableObj&)GetSdrObject();
261                 if( rObj.IsVerticalWriting() != bVertical )
262                     rObj.SetVerticalWriting(bVertical);
263 
264                 // Set a cell vertical property
265                 OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject();
266                 if( pParaObj == 0 )
267                     pParaObj = mxCell->GetOutlinerParaObject();
268                 if(pParaObj)
269                 {
270                     pParaObj->SetVertical(bVertical);
271                 }
272 
273             }
274 
275             // call parent
276             AttributeProperties::ItemChange( nWhich, pNewItem );
277         }
278 
SetStyleSheet(SfxStyleSheet * pNewStyleSheet,sal_Bool bDontRemoveHardAttr)279         void CellProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
280         {
281             TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr );
282         }
283     } // end of namespace properties
284 } // end of namespace sdr
285 
286 namespace sdr { namespace table {
287 
288 // -----------------------------------------------------------------------------
289 // Cell
290 // -----------------------------------------------------------------------------
291 
create(SdrTableObj & rTableObj,OutlinerParaObject * pOutlinerParaObject)292 rtl::Reference< Cell > Cell::create( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject )
293 {
294     rtl::Reference< Cell > xCell( new Cell( rTableObj, pOutlinerParaObject ) );
295     if( xCell->mxTable.is() )
296     {
297         Reference< XEventListener > xListener( xCell.get() );
298         xCell->mxTable->addEventListener( xListener );
299     }
300     return xCell;
301 }
302 
303 // -----------------------------------------------------------------------------
304 
Cell(SdrTableObj & rTableObj,OutlinerParaObject * pOutlinerParaObject)305 Cell::Cell( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject ) throw()
306 : SdrText( rTableObj, pOutlinerParaObject )
307 , SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
308 , mpPropSet( ImplGetSvxCellPropertySet() )
309 , mpProperties( new sdr::properties::CellProperties( rTableObj, this ) )
310 , mnCellContentType( CellContentType_EMPTY )
311 , mfValue( 0.0 )
312 , mnError( 0 )
313 , mbMerged( sal_False )
314 , mnRowSpan( 1 )
315 , mnColSpan( 1 )
316 , mxTable( rTableObj.getTable() )
317 {
318     if( rTableObj.GetModel() )
319         SetModel( rTableObj.GetModel() );
320 }
321 
322 // -----------------------------------------------------------------------------
323 
~Cell()324 Cell::~Cell() throw()
325 {
326     dispose();
327 }
328 
329 // -----------------------------------------------------------------------------
330 
dispose()331 void Cell::dispose()
332 {
333     if( mxTable.is() )
334     {
335         try
336         {
337             Reference< XEventListener > xThis( this );
338             mxTable->removeEventListener( xThis );
339         }
340         catch( Exception& )
341         {
342             DBG_ERROR("Cell::dispose(), exception caught!");
343         }
344         mxTable.clear();
345     }
346 
347     if( mpProperties )
348     {
349         delete mpProperties;
350         mpProperties = 0;
351     }
352     // the model can be gone when the last reference to the cell is released
353     SdrText::SetOutlinerParaObject( 0 );
354     SdrText::SetModel( 0 );
355 }
356 
357 // -----------------------------------------------------------------------------
358 
SetModel(SdrModel * pNewModel)359 void Cell::SetModel(SdrModel* pNewModel)
360 {
361     SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( GetEditSource() );
362     if( (GetModel() != pNewModel) || ( pNewModel && !pTextEditSource) )
363     {
364         if( mpProperties )
365         {
366             SfxItemPool* pItemPool = mpProperties->GetObjectItemSet().GetPool();
367 
368             // test for correct pool in ItemSet; move to new pool if necessary
369             if( pNewModel && pItemPool && pItemPool != &pNewModel->GetItemPool())
370                 mpProperties->MoveToItemPool(pItemPool, &pNewModel->GetItemPool(), pNewModel);
371         }
372 
373         if( pTextEditSource )
374         {
375             pTextEditSource->ChangeModel( pNewModel );
376         }
377         else
378         {
379             SetEditSource( new SvxTextEditSource( &GetObject(), this, static_cast< XWeak * >( this ) ) );
380         }
381 
382         SetStyleSheet( 0, sal_True );
383         SdrText::SetModel( pNewModel );
384         ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
385     }
386 }
387 
388 // -----------------------------------------------------------------------------
389 
merge(sal_Int32 nColumnSpan,sal_Int32 nRowSpan)390 void Cell::merge( sal_Int32 nColumnSpan, sal_Int32 nRowSpan )
391 {
392     if( (mnColSpan != nColumnSpan) || (mnRowSpan != nRowSpan) || (mbMerged != sal_False) )
393     {
394         mnColSpan = nColumnSpan;
395         mnRowSpan = nRowSpan;
396         mbMerged = sal_False;
397         notifyModified();
398     }
399 }
400 
401 // -----------------------------------------------------------------------------
402 
mergeContent(const CellRef & xSourceCell)403 void Cell::mergeContent( const CellRef& xSourceCell )
404 {
405     SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
406 
407     if( xSourceCell->hasText() )
408     {
409         SdrOutliner& rOutliner=rTableObj.ImpGetDrawOutliner();
410         rOutliner.SetUpdateMode(sal_True);
411 
412         if( hasText() )
413         {
414             rOutliner.SetText(*GetOutlinerParaObject());
415             rOutliner.AddText(*xSourceCell->GetOutlinerParaObject());
416         }
417         else
418         {
419             rOutliner.SetText(*xSourceCell->GetOutlinerParaObject());
420         }
421 
422         SetOutlinerParaObject( rOutliner.CreateParaObject() );
423         rOutliner.Clear();
424         xSourceCell->SetOutlinerParaObject(rOutliner.CreateParaObject());
425         rOutliner.Clear();
426         SetStyleSheet( GetStyleSheet(), sal_True );
427     }
428 }
429 
430 // -----------------------------------------------------------------------------
431 
cloneFrom(const CellRef & xCell)432 void Cell::cloneFrom( const CellRef& xCell )
433 {
434     if( xCell.is() )
435     {
436         replaceContentAndFormatting( xCell );
437 
438         mnCellContentType = xCell->mnCellContentType;
439 
440         msFormula = xCell->msFormula;
441         mfValue = xCell->mfValue;
442         mnError = xCell->mnError;
443 
444         mbMerged = xCell->mbMerged;
445         mnRowSpan = xCell->mnRowSpan;
446         mnColSpan = xCell->mnColSpan;
447 
448     }
449     notifyModified();
450 }
451 
replaceContentAndFormatting(const CellRef & xSourceCell)452 void Cell::replaceContentAndFormatting( const CellRef& xSourceCell )
453 {
454     if( xSourceCell.is() && mpProperties )
455     {
456         mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() );
457         SetOutlinerParaObject( new OutlinerParaObject(*xSourceCell->GetOutlinerParaObject()) );
458 
459         SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
460         SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() );
461 
462         if(rSourceTableObj.GetModel() != rTableObj.GetModel())
463         {
464             SetStyleSheet( 0, sal_True );
465         }
466     }
467 }
468 
469 // -----------------------------------------------------------------------------
470 
setMerged()471 void Cell::setMerged()
472 {
473     if( !mbMerged )
474     {
475         mbMerged = sal_True;
476         notifyModified();
477     }
478 }
479 
480 // -----------------------------------------------------------------------------
481 
notifyModified()482 void Cell::notifyModified()
483 {
484     if( mxTable.is() )
485         mxTable->setModified( sal_True );
486 }
487 
488 // -----------------------------------------------------------------------------
489 // SdrTextShape proxy
490 // -----------------------------------------------------------------------------
491 
IsTextEditActive()492 bool Cell::IsTextEditActive()
493 {
494     bool isActive = false;
495     SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
496     if(rTableObj.getActiveCell().get() == this )
497     {
498         OutlinerParaObject* pParaObj = rTableObj.GetEditOutlinerParaObject();
499         if( pParaObj != 0 )
500         {
501             isActive = true;
502             delete pParaObj;
503         }
504     }
505     return isActive;
506 }
507 
508 // -----------------------------------------------------------------------------
509 
hasText() const510 bool Cell::hasText() const
511 {
512     OutlinerParaObject* pParaObj = GetOutlinerParaObject();
513     if( pParaObj )
514     {
515         const EditTextObject& rTextObj = pParaObj->GetTextObject();
516         if( rTextObj.GetParagraphCount() >= 1 )
517         {
518             if( rTextObj.GetParagraphCount() == 1 )
519             {
520                 if( rTextObj.GetText(0).Len() == 0 )
521                     return false;
522             }
523             return true;
524         }
525     }
526 
527     return false;
528 }
529 
530 // -----------------------------------------------------------------------------
531 
GetEditOutlinerParaObject() const532 OutlinerParaObject* Cell::GetEditOutlinerParaObject() const
533 {
534     SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
535     if( rTableObj.getActiveCell().get() == this )
536         return rTableObj.GetEditOutlinerParaObject();
537     return 0;
538 }
539 
540 // -----------------------------------------------------------------------------
541 
SetStyleSheet(SfxStyleSheet * pStyleSheet,sal_Bool bDontRemoveHardAttr)542 void Cell::SetStyleSheet( SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr )
543 {
544     // only allow cell styles for cells
545     if( pStyleSheet && pStyleSheet->GetFamily() != SFX_STYLE_FAMILY_FRAME )
546         return;
547 
548     if( mpProperties && (mpProperties->GetStyleSheet() != pStyleSheet) )
549     {
550         mpProperties->SetStyleSheet( pStyleSheet, bDontRemoveHardAttr );
551     }
552 }
553 
554 // -----------------------------------------------------------------------------
555 
GetObjectItemSet()556 const SfxItemSet& Cell::GetObjectItemSet()
557 {
558     if( mpProperties )
559     {
560         return mpProperties->GetObjectItemSet();
561     }
562     else
563     {
564         DBG_ERROR("Cell::GetObjectItemSet(), called without properties!");
565         return GetObject().GetObjectItemSet();
566     }
567 }
568 
SetObjectItem(const SfxPoolItem & rItem)569 void Cell::SetObjectItem(const SfxPoolItem& rItem)
570 {
571     if( mpProperties )
572     {
573         mpProperties->SetObjectItem( rItem );
574         notifyModified();
575     }
576 }
577 
SetMergedItem(const SfxPoolItem & rItem)578 void Cell::SetMergedItem(const SfxPoolItem& rItem)
579 {
580     SetObjectItem(rItem);
581 }
582 
GetStyleSheet() const583 SfxStyleSheet* Cell::GetStyleSheet() const
584 {
585     if( mpProperties )
586         return mpProperties->GetStyleSheet();
587     else
588         return 0;
589 }
590 
591 // -----------------------------------------------------------------------------
592 
GetStyleSheetPool() const593 SfxStyleSheetPool* Cell::GetStyleSheetPool() const
594 {
595     if( mpProperties && mpProperties->GetStyleSheet() )
596         return dynamic_cast< SfxStyleSheetPool* >( &mpProperties->GetStyleSheet()->GetPool() );
597     else
598         return 0;
599 }
600 
601 // -----------------------------------------------------------------------------
602 
GetCurrentBoundRect() const603 const Rectangle& Cell::GetCurrentBoundRect() const
604 {
605     return maCellRect;
606 }
607 
608 // -----------------------------------------------------------------------------
609 
TakeTextAnchorRect(Rectangle & rAnchorRect) const610 void Cell::TakeTextAnchorRect(Rectangle& rAnchorRect) const
611 {
612     rAnchorRect.nLeft = maCellRect.nLeft + GetTextLeftDistance();
613     rAnchorRect.nRight = maCellRect.nRight - GetTextRightDistance();
614     rAnchorRect.nTop = maCellRect.nTop + GetTextUpperDistance();
615     rAnchorRect.nBottom = maCellRect.nBottom - GetTextLowerDistance();
616 }
617 
618 // -----------------------------------------------------------------------------
619 
GetItemSet() const620 const SfxItemSet& Cell::GetItemSet() const
621 {
622     return mpProperties->GetObjectItemSet();
623 }
624 
625 // -----------------------------------------------------------------------------
626 
SetMergedItemSetAndBroadcast(const SfxItemSet & rSet,sal_Bool bClearAllItems)627 void Cell::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems)
628 {
629     if( mpProperties )
630     {
631         mpProperties->SetMergedItemSetAndBroadcast(rSet, bClearAllItems);
632         notifyModified();
633     }
634 }
635 
636 // -----------------------------------------------------------------------------
637 
getMinimumWidth()638 sal_Int32 Cell::getMinimumWidth()
639 {
640     return GetTextLeftDistance() + GetTextRightDistance() + 100;
641 }
642 
643 // -----------------------------------------------------------------------------
644 
getMinimumHeight()645 sal_Int32 Cell::getMinimumHeight()
646 {
647     if( !mpProperties )
648         return 0;
649 
650     SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
651     sal_Int32 nMinimumHeight = 0;
652 
653     Rectangle aTextRect;
654     TakeTextAnchorRect( aTextRect );
655     Size aSize( aTextRect.GetSize() );
656     aSize.Height()=0x0FFFFFFF;
657 
658     SdrOutliner* pEditOutliner = rTableObj.GetCellTextEditOutliner( *this );
659     if(pEditOutliner)
660     {
661         pEditOutliner->SetMaxAutoPaperSize(aSize);
662         nMinimumHeight = pEditOutliner->GetTextHeight()+1;
663     }
664     else /*if ( hasText() )*/
665     {
666         Outliner& rOutliner=rTableObj.ImpGetDrawOutliner();
667         rOutliner.SetPaperSize(aSize);
668         rOutliner.SetUpdateMode(sal_True);
669         ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
670 
671         if( GetOutlinerParaObject() )
672         {
673             rOutliner.SetText(*GetOutlinerParaObject());
674         }
675         nMinimumHeight=rOutliner.GetTextHeight()+1;
676         rOutliner.Clear();
677     }
678 
679     nMinimumHeight += GetTextUpperDistance() + GetTextLowerDistance();
680     return nMinimumHeight;
681 }
682 
683 // -----------------------------------------------------------------------------
684 
GetTextLeftDistance() const685 long Cell::GetTextLeftDistance() const
686 {
687     return ((SdrTextLeftDistItem&)(GetItemSet().Get(SDRATTR_TEXT_LEFTDIST))).GetValue();
688 }
689 
690 // -----------------------------------------------------------------------------
691 
GetTextRightDistance() const692 long Cell::GetTextRightDistance() const
693 {
694     return ((SdrTextRightDistItem&)(GetItemSet().Get(SDRATTR_TEXT_RIGHTDIST))).GetValue();
695 }
696 
697 // -----------------------------------------------------------------------------
698 
GetTextUpperDistance() const699 long Cell::GetTextUpperDistance() const
700 {
701     return ((SdrTextUpperDistItem&)(GetItemSet().Get(SDRATTR_TEXT_UPPERDIST))).GetValue();
702 }
703 
704 // -----------------------------------------------------------------------------
705 
GetTextLowerDistance() const706 long Cell::GetTextLowerDistance() const
707 {
708     return ((SdrTextLowerDistItem&)(GetItemSet().Get(SDRATTR_TEXT_LOWERDIST))).GetValue();
709 }
710 
711 // -----------------------------------------------------------------------------
712 
GetTextVerticalAdjust() const713 SdrTextVertAdjust Cell::GetTextVerticalAdjust() const
714 {
715     return ((SdrTextVertAdjustItem&)(GetItemSet().Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
716 }
717 
718 // -----------------------------------------------------------------------------
719 
GetTextHorizontalAdjust() const720 SdrTextHorzAdjust Cell::GetTextHorizontalAdjust() const
721 {
722     return ((SdrTextHorzAdjustItem&)(GetItemSet().Get(SDRATTR_TEXT_HORZADJUST))).GetValue();
723 }
724 
725 // -----------------------------------------------------------------------------
726 
SetOutlinerParaObject(OutlinerParaObject * pTextObject)727 void Cell::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
728 {
729     SdrText::SetOutlinerParaObject( pTextObject );
730     maSelection.nStartPara = 0xffff;
731 
732     if( pTextObject == 0 )
733         ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
734 }
735 
736 // -----------------------------------------------------------------------------
737 
AddUndo()738 void Cell::AddUndo()
739 {
740     SdrObject& rObj = GetObject();
741     if( rObj.IsInserted() && GetModel() && GetModel()->IsUndoEnabled() )
742     {
743         CellRef xCell( this );
744         GetModel()->AddUndo( new CellUndo( &rObj, xCell ) );
745     }
746 }
747 
748 // -----------------------------------------------------------------------------
749 
CloneProperties(sdr::properties::TextProperties * pProperties,SdrObject & rNewObj,Cell & rNewCell)750 sdr::properties::TextProperties* Cell::CloneProperties( sdr::properties::TextProperties* pProperties, SdrObject& rNewObj, Cell& rNewCell )
751 {
752     if( pProperties )
753         return new sdr::properties::CellProperties( *static_cast<sdr::properties::CellProperties*>(pProperties), rNewObj, &rNewCell );
754     else
755         return 0;
756 }
757 
758 // -----------------------------------------------------------------------------
759 
CloneProperties(SdrObject & rNewObj,Cell & rNewCell)760 sdr::properties::TextProperties* Cell::CloneProperties( SdrObject& rNewObj, Cell& rNewCell )
761 {
762     return CloneProperties(mpProperties,rNewObj,rNewCell);
763 }
764 
765 // -----------------------------------------------------------------------------
766 // XInterface
767 // -----------------------------------------------------------------------------
768 
queryInterface(const Type & rType)769 Any SAL_CALL Cell::queryInterface( const Type & rType )
770 {
771     if( rType == XMergeableCell::static_type() )
772         return Any( Reference< XMergeableCell >( this ) );
773 
774     if( rType == XCell::static_type() )
775         return Any( Reference< XCell >( this ) );
776 
777     if( rType == XLayoutConstrains::static_type() )
778         return Any( Reference< XLayoutConstrains >( this ) );
779 
780     if( rType == XEventListener::static_type() )
781         return Any( Reference< XEventListener >( this ) );
782 
783     Any aRet( SvxUnoTextBase::queryAggregation( rType ) );
784     if( aRet.hasValue() )
785         return aRet;
786 
787     return ::cppu::OWeakObject::queryInterface( rType );
788 }
789 
790 // -----------------------------------------------------------------------------
791 
acquire()792 void SAL_CALL Cell::acquire() throw ()
793 {
794     ::cppu::OWeakObject::acquire();
795 }
796 
797 // -----------------------------------------------------------------------------
798 
release()799 void SAL_CALL Cell::release() throw ()
800 {
801     ::cppu::OWeakObject::release();
802 }
803 
804 // -----------------------------------------------------------------------------
805 // XTypeProvider
806 // -----------------------------------------------------------------------------
807 
getTypes()808 Sequence< Type > SAL_CALL Cell::getTypes(  )
809 {
810     Sequence< Type > aTypes( SvxUnoTextBase::getTypes() );
811 
812     sal_Int32 nLen = aTypes.getLength();
813     aTypes.realloc(nLen + 2);
814     aTypes[nLen++] = XMergeableCell::static_type();
815     aTypes[nLen++] = XLayoutConstrains::static_type();
816 
817     return aTypes;
818 }
819 
820 // -----------------------------------------------------------------------------
821 
getImplementationId()822 Sequence< sal_Int8 > SAL_CALL Cell::getImplementationId(  )
823 {
824     static ::cppu::OImplementationId* pId = 0;
825     if (! pId)
826     {
827         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
828         if (! pId)
829         {
830             static ::cppu::OImplementationId aId;
831             pId = &aId;
832         }
833     }
834     return pId->getImplementationId();
835 }
836 
837 // -----------------------------------------------------------------------------
838 // XServiceInfo
839 // -----------------------------------------------------------------------------
840 
getImplementationName()841 OUString SAL_CALL Cell::getImplementationName(  )
842 {
843     return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.table.Cell" ) );
844 }
845 
846 // -----------------------------------------------------------------------------
847 
supportsService(const OUString & ServiceName)848 sal_Bool SAL_CALL Cell::supportsService( const OUString& ServiceName )
849 {
850     if( ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.table.cell" ) ) == 0 )
851         return sal_True;
852 
853     if( ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.cell" ) ) == 0 )
854         return sal_True;
855 
856     return SvxUnoTextBase::supportsService( ServiceName );
857 }
858 
859 // -----------------------------------------------------------------------------
860 
getSupportedServiceNames()861 Sequence< OUString > SAL_CALL Cell::getSupportedServiceNames(  )
862 {
863     Sequence< OUString > aSeq( SvxUnoTextBase::getSupportedServiceNames() );
864     sal_Int32 nIndex = aSeq.getLength();
865     aSeq.realloc( nIndex + 2 );
866     aSeq[nIndex++] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.cell" ) );
867     aSeq[nIndex++] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.cell" ) );
868     return aSeq;
869 }
870 
871 // -----------------------------------------------------------------------------
872 // XLayoutConstrains
873 // -----------------------------------------------------------------------------
874 
getMinimumSize()875 ::com::sun::star::awt::Size SAL_CALL Cell::getMinimumSize(  )
876 {
877     return ::com::sun::star::awt::Size( getMinimumWidth(),  getMinimumHeight() );
878 }
879 
880 // -----------------------------------------------------------------------------
881 
getPreferredSize()882 ::com::sun::star::awt::Size SAL_CALL Cell::getPreferredSize(  )
883 {
884     return getMinimumSize();
885 }
886 
887 // -----------------------------------------------------------------------------
888 
calcAdjustedSize(const::com::sun::star::awt::Size & aNewSize)889 ::com::sun::star::awt::Size SAL_CALL Cell::calcAdjustedSize( const ::com::sun::star::awt::Size& aNewSize )
890 {
891     return aNewSize;
892 }
893 
894 // -----------------------------------------------------------------------------
895 // XMergeableCell
896 // -----------------------------------------------------------------------------
897 
getRowSpan()898 sal_Int32 SAL_CALL Cell::getRowSpan()
899 {
900     return mnRowSpan;
901 }
902 
903 // -----------------------------------------------------------------------------
904 
getColumnSpan()905 sal_Int32 SAL_CALL Cell::getColumnSpan()
906 {
907     return mnColSpan;
908 }
909 
910 // -----------------------------------------------------------------------------
911 
isMerged()912 sal_Bool SAL_CALL Cell::isMerged()
913 {
914     return mbMerged;
915 }
916 
917 // -----------------------------------------------------------------------------
918 // XCell
919 // -----------------------------------------------------------------------------
920 
getFormula()921 OUString SAL_CALL Cell::getFormula(  )
922 {
923     return msFormula;
924 }
925 
926 // -----------------------------------------------------------------------------
927 
setFormula(const OUString & aFormula)928 void SAL_CALL Cell::setFormula( const OUString& aFormula )
929 {
930     if( msFormula != aFormula )
931     {
932         msFormula = aFormula;
933     }
934 }
935 
936 // -----------------------------------------------------------------------------
937 
getValue()938 double SAL_CALL Cell::getValue(  )
939 {
940     return mfValue;
941 }
942 
943 // -----------------------------------------------------------------------------
944 
setValue(double nValue)945 void SAL_CALL Cell::setValue( double nValue )
946 {
947     if( mfValue == nValue )
948     {
949         mfValue = nValue;
950         mnCellContentType = CellContentType_VALUE;
951     }
952 }
953 
954 // -----------------------------------------------------------------------------
955 
getType()956 CellContentType SAL_CALL Cell::getType()
957 {
958     return mnCellContentType;
959 }
960 
961 // -----------------------------------------------------------------------------
962 
getError()963 sal_Int32 SAL_CALL Cell::getError(  )
964 {
965     return mnError;
966 }
967 
968 // -----------------------------------------------------------------------------
969 // XPropertySet
970 // -----------------------------------------------------------------------------
971 
GetAnyForItem(SfxItemSet & aSet,const SfxItemPropertySimpleEntry * pMap)972 Any Cell::GetAnyForItem( SfxItemSet& aSet, const SfxItemPropertySimpleEntry* pMap )
973 {
974     Any aAny( SvxItemPropertySet_getPropertyValue( *mpPropSet, pMap, aSet ) );
975 
976     if( *pMap->pType != aAny.getValueType() )
977     {
978         // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
979         if( ( *pMap->pType == ::getCppuType((const sal_Int16*)0)) && aAny.getValueType() == ::getCppuType((const sal_Int32*)0) )
980         {
981             sal_Int32 nValue = 0;
982             aAny >>= nValue;
983             aAny <<= (sal_Int16)nValue;
984         }
985         else
986         {
987             DBG_ERROR("GetAnyForItem() Returnvalue has wrong Type!" );
988         }
989     }
990 
991     return aAny;
992 }
993 
getPropertySetInfo()994 Reference< XPropertySetInfo > SAL_CALL Cell::getPropertySetInfo()
995 {
996     return mpPropSet->getPropertySetInfo();
997 }
998 
999 // -----------------------------------------------------------------------------
1000 
setPropertyValue(const OUString & rPropertyName,const Any & rValue)1001 void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
1002 {
1003     OGuard aGuard( Application::GetSolarMutex() );
1004 
1005     if( (mpProperties == 0) || (GetModel() == 0) )
1006         throw DisposedException();
1007 
1008     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName);
1009     if( pMap )
1010     {
1011         if( (pMap->nFlags & PropertyAttribute::READONLY ) != 0 )
1012             throw PropertyVetoException();
1013 
1014         switch( pMap->nWID )
1015         {
1016         case OWN_ATTR_STYLE:
1017         {
1018             Reference< XStyle > xStyle;
1019             if( !( rValue >>= xStyle ) )
1020                 throw IllegalArgumentException();
1021 
1022             SfxUnoStyleSheet* pStyle = SfxUnoStyleSheet::getUnoStyleSheet(xStyle);
1023             SetStyleSheet( pStyle, sal_True );
1024             return;
1025         }
1026         case OWN_ATTR_TABLEBORDER:
1027         {
1028             if(rValue.getValueType() != ::getCppuType((const TableBorder*)0) )
1029                 break;
1030 
1031             const TableBorder* pBorder = (const TableBorder* )rValue.getValue();
1032             if( pBorder == NULL )
1033                 break;
1034 
1035             SvxBoxItem aBox( SDRATTR_TABLE_BORDER );
1036             SvxBoxInfoItem aBoxInfo( SDRATTR_TABLE_BORDER_INNER );
1037             SvxBorderLine aLine;
1038 
1039             sal_Bool bSet = SvxBoxItem::LineToSvxLine(pBorder->TopLine, aLine, false);
1040             aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_TOP);
1041             aBoxInfo.SetValid(VALID_TOP, pBorder->IsTopLineValid);
1042 
1043             bSet = SvxBoxItem::LineToSvxLine(pBorder->BottomLine, aLine, false);
1044             aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_BOTTOM);
1045             aBoxInfo.SetValid(VALID_BOTTOM, pBorder->IsBottomLineValid);
1046 
1047             bSet = SvxBoxItem::LineToSvxLine(pBorder->LeftLine, aLine, false);
1048             aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_LEFT);
1049             aBoxInfo.SetValid(VALID_LEFT, pBorder->IsLeftLineValid);
1050 
1051             bSet = SvxBoxItem::LineToSvxLine(pBorder->RightLine, aLine, false);
1052             aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_RIGHT);
1053             aBoxInfo.SetValid(VALID_RIGHT, pBorder->IsRightLineValid);
1054 
1055             bSet = SvxBoxItem::LineToSvxLine(pBorder->HorizontalLine, aLine, false);
1056             aBoxInfo.SetLine(bSet ? &aLine : 0, BOXINFO_LINE_HORI);
1057             aBoxInfo.SetValid(VALID_HORI, pBorder->IsHorizontalLineValid);
1058 
1059             bSet = SvxBoxItem::LineToSvxLine(pBorder->VerticalLine, aLine, false);
1060             aBoxInfo.SetLine(bSet ? &aLine : 0, BOXINFO_LINE_VERT);
1061             aBoxInfo.SetValid(VALID_VERT, pBorder->IsVerticalLineValid);
1062 
1063             aBox.SetDistance(pBorder->Distance, false);
1064             aBoxInfo.SetValid(VALID_DISTANCE, pBorder->IsDistanceValid);
1065 
1066             mpProperties->SetObjectItem(aBox);
1067             mpProperties->SetObjectItem(aBoxInfo);
1068             return;
1069         }
1070         case OWN_ATTR_FILLBMP_MODE:
1071         {
1072             BitmapMode eMode;
1073             if(!(rValue >>= eMode) )
1074             {
1075                 sal_Int32 nMode = 0;
1076                 if(!(rValue >>= nMode))
1077                     throw IllegalArgumentException();
1078 
1079                     eMode = (BitmapMode)nMode;
1080             }
1081 
1082             mpProperties->SetObjectItem( XFillBmpStretchItem( eMode == BitmapMode_STRETCH ) );
1083             mpProperties->SetObjectItem( XFillBmpTileItem( eMode == BitmapMode_REPEAT ) );
1084             return;
1085         }
1086         default:
1087         {
1088             SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
1089             aSet.Put(mpProperties->GetItem(pMap->nWID));
1090 
1091             bool bSpecial = false;
1092 
1093             switch( pMap->nWID )
1094             {
1095                 case XATTR_FILLBITMAP:
1096                 case XATTR_FILLGRADIENT:
1097                 case XATTR_FILLHATCH:
1098                 case XATTR_FILLFLOATTRANSPARENCE:
1099                 case XATTR_LINEEND:
1100                 case XATTR_LINESTART:
1101                 case XATTR_LINEDASH:
1102                 {
1103                     if( pMap->nMemberId == MID_NAME )
1104                     {
1105                         OUString aApiName;
1106                         if( rValue >>= aApiName )
1107                         {
1108                             if( SvxShape::SetFillAttribute( pMap->nWID, aApiName, aSet, GetModel() ) )
1109                                 bSpecial = true;
1110                         }
1111                     }
1112                 }
1113                 break;
1114             }
1115 
1116             if( !bSpecial )
1117             {
1118 
1119                 if( !SvxUnoTextRangeBase::SetPropertyValueHelper( aSet, pMap, rValue, aSet ))
1120                 {
1121                     if( aSet.GetItemState( pMap->nWID ) != SFX_ITEM_SET )
1122                     {
1123                         // Default aus ItemPool holen
1124                         if(GetModel()->GetItemPool().IsWhich(pMap->nWID))
1125                             aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
1126                     }
1127 
1128                     if( aSet.GetItemState( pMap->nWID ) == SFX_ITEM_SET )
1129                     {
1130                         SvxItemPropertySet_setPropertyValue( *mpPropSet, pMap, rValue, aSet );
1131                     }
1132                 }
1133             }
1134 
1135             GetModel()->SetChanged();
1136             mpProperties->SetMergedItemSetAndBroadcast( aSet );
1137             return;
1138         }
1139         }
1140     }
1141     throw UnknownPropertyException();
1142 }
1143 
1144 // -----------------------------------------------------------------------------
1145 
getPropertyValue(const OUString & PropertyName)1146 Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName )
1147 {
1148     OGuard aGuard( Application::GetSolarMutex() );
1149 
1150     if( (mpProperties == 0) || (GetModel() == 0) )
1151         throw DisposedException();
1152 
1153     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
1154     if( pMap )
1155     {
1156         switch( pMap->nWID )
1157         {
1158 /*
1159         case OWN_ATTR_HASLEVELS:
1160         {
1161             return Any( hasLevels() );
1162         }
1163 */
1164         case OWN_ATTR_STYLE:
1165         {
1166             return Any( Reference< XStyle >( dynamic_cast< SfxUnoStyleSheet* >( GetStyleSheet() ) ) );
1167         }
1168         case OWN_ATTR_TABLEBORDER:
1169         {
1170             const SvxBoxInfoItem& rBoxInfoItem = static_cast<const SvxBoxInfoItem&>(mpProperties->GetItem(SDRATTR_TABLE_BORDER_INNER));
1171             const SvxBoxItem& rBox = static_cast<const SvxBoxItem&>(mpProperties->GetItem(SDRATTR_TABLE_BORDER));
1172 
1173             TableBorder aTableBorder;
1174             aTableBorder.TopLine                = SvxBoxItem::SvxLineToLine(rBox.GetTop(), false);
1175             aTableBorder.IsTopLineValid         = rBoxInfoItem.IsValid(VALID_TOP);
1176             aTableBorder.BottomLine             = SvxBoxItem::SvxLineToLine(rBox.GetBottom(), false);
1177             aTableBorder.IsBottomLineValid      = rBoxInfoItem.IsValid(VALID_BOTTOM);
1178             aTableBorder.LeftLine               = SvxBoxItem::SvxLineToLine(rBox.GetLeft(), false);
1179             aTableBorder.IsLeftLineValid        = rBoxInfoItem.IsValid(VALID_LEFT);
1180             aTableBorder.RightLine              = SvxBoxItem::SvxLineToLine(rBox.GetRight(), false);
1181             aTableBorder.IsRightLineValid       = rBoxInfoItem.IsValid(VALID_RIGHT );
1182             aTableBorder.HorizontalLine         = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetHori(), false);
1183             aTableBorder.IsHorizontalLineValid  = rBoxInfoItem.IsValid(VALID_HORI);
1184             aTableBorder.VerticalLine           = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetVert(), false);
1185             aTableBorder.IsVerticalLineValid    = rBoxInfoItem.IsValid(VALID_VERT);
1186             aTableBorder.Distance               = rBox.GetDistance();
1187             aTableBorder.IsDistanceValid        = rBoxInfoItem.IsValid(VALID_DISTANCE);
1188 
1189             return Any( aTableBorder );
1190         }
1191         case OWN_ATTR_FILLBMP_MODE:
1192         {
1193             const XFillBmpStretchItem& rStretchItem = static_cast<const XFillBmpStretchItem&>(mpProperties->GetItem(XATTR_FILLBMP_STRETCH));
1194             const XFillBmpTileItem& rTileItem = static_cast<const XFillBmpTileItem&>(mpProperties->GetItem(XATTR_FILLBMP_TILE));
1195             if( rTileItem.GetValue() )
1196             {
1197                 return Any( BitmapMode_REPEAT );
1198             }
1199             else if( rStretchItem.GetValue() )
1200             {
1201                 return Any(  BitmapMode_STRETCH );
1202             }
1203             else
1204             {
1205                 return Any(  BitmapMode_NO_REPEAT );
1206             }
1207         }
1208         default:
1209         {
1210             SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
1211             aSet.Put(mpProperties->GetItem(pMap->nWID));
1212 
1213             Any aAny;
1214             if(!SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pMap, aAny ))
1215             {
1216                 if(!aSet.Count())
1217                 {
1218                     // Default aus ItemPool holen
1219                     if(GetModel()->GetItemPool().IsWhich(pMap->nWID))
1220                         aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
1221                 }
1222 
1223                 if( aSet.Count() )
1224                     aAny = GetAnyForItem( aSet, pMap );
1225             }
1226 
1227             return aAny;
1228         }
1229         }
1230     }
1231     throw UnknownPropertyException();
1232 }
1233 
1234 // -----------------------------------------------------------------------------
1235 
addPropertyChangeListener(const OUString &,const Reference<XPropertyChangeListener> &)1236 void SAL_CALL Cell::addPropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*xListener*/ )
1237 {
1238 }
1239 
1240 // -----------------------------------------------------------------------------
1241 
removePropertyChangeListener(const OUString &,const Reference<XPropertyChangeListener> &)1242 void SAL_CALL Cell::removePropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*aListener*/ )
1243 {
1244 }
1245 
1246 // -----------------------------------------------------------------------------
1247 
addVetoableChangeListener(const OUString &,const Reference<XVetoableChangeListener> &)1248 void SAL_CALL Cell::addVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ )
1249 {
1250 }
1251 
1252 // -----------------------------------------------------------------------------
1253 
removeVetoableChangeListener(const OUString &,const Reference<XVetoableChangeListener> &)1254 void SAL_CALL Cell::removeVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ )
1255 {
1256 }
1257 
1258 // -----------------------------------------------------------------------------
1259 // XMultiPropertySet
1260 // -----------------------------------------------------------------------------
1261 
setPropertyValues(const Sequence<OUString> & aPropertyNames,const Sequence<Any> & aValues)1262 void SAL_CALL Cell::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues )
1263 {
1264     OGuard aSolarGuard( Application::GetSolarMutex() );
1265 
1266     if( (mpProperties == 0) || (GetModel() == 0) )
1267         throw DisposedException();
1268 
1269     const sal_Int32 nCount = aPropertyNames.getLength();
1270 
1271     const OUString* pNames = aPropertyNames.getConstArray();
1272     const Any* pValues = aValues.getConstArray();
1273 
1274     for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ )
1275     {
1276         try
1277         {
1278             setPropertyValue( *pNames, *pValues );
1279         }
1280         catch( UnknownPropertyException& )
1281         {
1282             DBG_ERROR("svx::Cell::setPropertyValues(), unknown property!" );
1283         }
1284         catch( Exception& )
1285         {
1286             DBG_ERROR("svx::Cell::setPropertyValues(), Exception caught!" );
1287         }
1288     }
1289 }
1290 
1291 // -----------------------------------------------------------------------------
1292 
getPropertyValues(const Sequence<OUString> & aPropertyNames)1293 Sequence< Any > SAL_CALL Cell::getPropertyValues( const Sequence< OUString >& aPropertyNames )
1294 {
1295     OGuard aSolarGuard( Application::GetSolarMutex() );
1296 
1297     if( (mpProperties == 0) || (GetModel() == 0) )
1298         throw DisposedException();
1299 
1300     const sal_Int32 nCount = aPropertyNames.getLength();
1301     const OUString* pNames = aPropertyNames.getConstArray();
1302 
1303     Sequence< Any > aRet( nCount );
1304     Any* pValue = aRet.getArray();
1305 
1306     for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ )
1307     {
1308         try
1309         {
1310             *pValue = getPropertyValue( *pNames );
1311         }
1312         catch( UnknownPropertyException& )
1313         {
1314             DBG_ERROR("svx::Cell::setPropertyValues(), unknown property!" );
1315         }
1316         catch( Exception& )
1317         {
1318             DBG_ERROR( "svx::Cell::getPropertyValues(), Exception caught!" );
1319         }
1320     }
1321 
1322     return aRet;
1323 }
1324 
1325 // -----------------------------------------------------------------------------
1326 
addPropertiesChangeListener(const Sequence<OUString> &,const Reference<XPropertiesChangeListener> &)1327 void SAL_CALL Cell::addPropertiesChangeListener( const Sequence< OUString >& /*aPropertyNames*/, const Reference< XPropertiesChangeListener >& /*xListener*/ )
1328 {
1329 }
1330 
1331 // -----------------------------------------------------------------------------
1332 
removePropertiesChangeListener(const Reference<XPropertiesChangeListener> &)1333 void SAL_CALL Cell::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& /*xListener*/ )
1334 {
1335 }
1336 
1337 // -----------------------------------------------------------------------------
1338 
firePropertiesChangeEvent(const Sequence<OUString> &,const Reference<XPropertiesChangeListener> &)1339 void SAL_CALL Cell::firePropertiesChangeEvent( const Sequence< OUString >& /*aPropertyNames*/, const Reference< XPropertiesChangeListener >& /*xListener*/ )
1340 {
1341 }
1342 
1343 // -----------------------------------------------------------------------------
1344 // XPropertyState
1345 // -----------------------------------------------------------------------------
1346 
getPropertyState(const OUString & PropertyName)1347 PropertyState SAL_CALL Cell::getPropertyState( const OUString& PropertyName )
1348 {
1349     OGuard aGuard( Application::GetSolarMutex() );
1350 
1351     if( (mpProperties == 0) || (GetModel() == 0) )
1352         throw DisposedException();
1353 
1354     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
1355 
1356     if( pMap )
1357     {
1358         PropertyState eState;
1359         switch( pMap->nWID )
1360         {
1361         case OWN_ATTR_FILLBMP_MODE:
1362         {
1363             const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
1364 
1365             const bool bStretch = rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET;
1366             const bool bTile = rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET;
1367             if( bStretch || bTile )
1368             {
1369                 eState = PropertyState_DIRECT_VALUE;
1370             }
1371             else
1372             {
1373                 eState = PropertyState_DEFAULT_VALUE;
1374             }
1375         }
1376 /*
1377         case OWN_ATTR_HASLEVELS:
1378         {
1379             return PropertyState_DIRECT_VALUE;
1380         }
1381 */
1382         case OWN_ATTR_STYLE:
1383         {
1384             return PropertyState_DIRECT_VALUE;
1385         }
1386         case OWN_ATTR_TABLEBORDER:
1387         {
1388             const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
1389             if( (rSet.GetItemState( SDRATTR_TABLE_BORDER_INNER, sal_False ) == SFX_ITEM_DEFAULT) && (rSet.GetItemState( SDRATTR_TABLE_BORDER, sal_False ) == SFX_ITEM_DEFAULT) )
1390                 return PropertyState_DEFAULT_VALUE;
1391 
1392             return PropertyState_DIRECT_VALUE;
1393         }
1394         default:
1395         {
1396             const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
1397 
1398             switch( rSet.GetItemState( pMap->nWID, sal_False ) )
1399             {
1400             case SFX_ITEM_READONLY:
1401             case SFX_ITEM_SET:
1402                 eState = PropertyState_DIRECT_VALUE;
1403                 break;
1404             case SFX_ITEM_DEFAULT:
1405                 eState = PropertyState_DEFAULT_VALUE;
1406                 break;
1407     //      case SFX_ITEM_UNKNOWN:
1408     //      case SFX_ITEM_DONTCARE:
1409     //      case SFX_ITEM_DISABLED:
1410             default:
1411                 eState = PropertyState_AMBIGUOUS_VALUE;
1412                 break;
1413             }
1414 
1415             // if a item is set, this doesn't mean we want it :)
1416             if( ( PropertyState_DIRECT_VALUE == eState ) )
1417             {
1418                 switch( pMap->nWID )
1419                 {
1420                 // the following items are disabled by changing the
1421                 // fill style or the line style. so there is no need
1422                 // to export items without names which should be empty
1423                 case XATTR_FILLBITMAP:
1424                 case XATTR_FILLGRADIENT:
1425                 case XATTR_FILLHATCH:
1426                 case XATTR_LINEDASH:
1427                     {
1428                         NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((sal_uInt16)pMap->nWID);
1429                         if( ( pItem == NULL ) || ( pItem->GetName().Len() == 0) )
1430                             eState = PropertyState_DEFAULT_VALUE;
1431                     }
1432                     break;
1433 
1434                 // #i36115#
1435                 // If e.g. the LineStart is on NONE and thus the string has length 0, it still
1436                 // may be a hard attribute covering the set LineStart of the parent (Style).
1437                 // #i37644#
1438                 // same is for fill float transparency
1439                 case XATTR_LINEEND:
1440                 case XATTR_LINESTART:
1441                 case XATTR_FILLFLOATTRANSPARENCE:
1442                     {
1443                         NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((sal_uInt16)pMap->nWID);
1444                         if( pItem == NULL )
1445                             eState = PropertyState_DEFAULT_VALUE;
1446                     }
1447                     break;
1448                 }
1449             }
1450         }
1451         }
1452         return eState;
1453     }
1454     throw UnknownPropertyException();
1455 }
1456 
1457 // -----------------------------------------------------------------------------
1458 
getPropertyStates(const Sequence<OUString> & aPropertyName)1459 Sequence< PropertyState > SAL_CALL Cell::getPropertyStates( const Sequence< OUString >& aPropertyName )
1460 {
1461     OGuard aGuard( Application::GetSolarMutex() );
1462 
1463     if( (mpProperties == 0) || (GetModel() == 0) )
1464         throw DisposedException();
1465 
1466     const sal_Int32 nCount = aPropertyName.getLength();
1467 
1468     Sequence< PropertyState > aRet( nCount );
1469 
1470     const OUString* pNames = aPropertyName.getConstArray();
1471     PropertyState* pState = aRet.getArray();
1472 
1473     for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pState++ )
1474     {
1475         try
1476         {
1477             *pState = getPropertyState( *pNames );
1478         }
1479         catch( Exception& )
1480         {
1481             *pState = PropertyState_AMBIGUOUS_VALUE;
1482         }
1483     }
1484 
1485     return aRet;
1486 }
1487 
1488 // -----------------------------------------------------------------------------
1489 
setPropertyToDefault(const OUString & PropertyName)1490 void SAL_CALL Cell::setPropertyToDefault( const OUString& PropertyName )
1491 {
1492     OGuard aGuard( Application::GetSolarMutex() );
1493 
1494     if( (mpProperties == 0) || (GetModel() == 0) )
1495         throw DisposedException();
1496 
1497     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
1498     if( pMap )
1499     {
1500         switch( pMap->nWID )
1501         {
1502         case OWN_ATTR_FILLBMP_MODE:
1503         {
1504             mpProperties->ClearObjectItem( XATTR_FILLBMP_STRETCH );
1505             mpProperties->ClearObjectItem( XATTR_FILLBMP_TILE );
1506             break;
1507         }
1508 //      case OWN_ATTR_HASLEVELS:
1509         case OWN_ATTR_STYLE:
1510             break;
1511 
1512         case OWN_ATTR_TABLEBORDER:
1513         {
1514             mpProperties->ClearObjectItem( SDRATTR_TABLE_BORDER_INNER );
1515             mpProperties->ClearObjectItem( SDRATTR_TABLE_BORDER );
1516             break;
1517         }
1518 
1519         default:
1520         {
1521             mpProperties->ClearObjectItem( pMap->nWID );
1522         }
1523         }
1524 
1525         GetModel()->SetChanged();
1526         return;
1527     }
1528     throw UnknownPropertyException();
1529 }
1530 
1531 // -----------------------------------------------------------------------------
1532 
getPropertyDefault(const OUString & aPropertyName)1533 Any SAL_CALL Cell::getPropertyDefault( const OUString& aPropertyName )
1534 {
1535     OGuard aGuard( Application::GetSolarMutex() );
1536 
1537     if( (mpProperties == 0) || (GetModel() == 0) )
1538         throw DisposedException();
1539 
1540     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName);
1541     if( pMap )
1542     {
1543         switch( pMap->nWID )
1544         {
1545         case OWN_ATTR_FILLBMP_MODE:
1546             return Any(  BitmapMode_NO_REPEAT );
1547 
1548 /*
1549         case OWN_ATTR_HASLEVELS:
1550             return Any( sal_False );
1551 */
1552         case OWN_ATTR_STYLE:
1553         {
1554             Reference< XStyle > xStyle;
1555             return Any( xStyle );
1556         }
1557 
1558         case OWN_ATTR_TABLEBORDER:
1559         {
1560             TableBorder aBorder;
1561             return Any( aBorder );
1562         }
1563 
1564         default:
1565         {
1566             if(  GetModel()->GetItemPool().IsWhich(pMap->nWID) )
1567             {
1568                 SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
1569                 aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
1570                 return GetAnyForItem( aSet, pMap );
1571             }
1572         }
1573         }
1574     }
1575     throw UnknownPropertyException();
1576 }
1577 
1578 // -----------------------------------------------------------------------------
1579 // XMultiPropertyStates
1580 // -----------------------------------------------------------------------------
1581 
setAllPropertiesToDefault()1582 void SAL_CALL Cell::setAllPropertiesToDefault(  )
1583 {
1584     if( mpProperties )
1585         delete mpProperties;
1586     mpProperties = new sdr::properties::CellProperties( static_cast< SdrTableObj& >( GetObject() ), this );
1587 
1588     SdrOutliner& rOutliner = GetObject().ImpGetDrawOutliner();
1589 
1590     OutlinerParaObject* pParaObj = GetOutlinerParaObject();
1591     if( pParaObj )
1592     {
1593         rOutliner.SetText(*pParaObj);
1594         sal_uInt32 nParaCount(rOutliner.GetParagraphCount());
1595 
1596         if(nParaCount)
1597         {
1598             ESelection aSelection( 0, 0, EE_PARA_ALL, EE_PARA_ALL);
1599             rOutliner.RemoveAttribs(aSelection, sal_True, 0);
1600 
1601             OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, nParaCount);
1602             rOutliner.Clear();
1603 
1604             SetOutlinerParaObject(pTemp);
1605         }
1606     }
1607 }
1608 
1609 // -----------------------------------------------------------------------------
1610 
setPropertiesToDefault(const Sequence<OUString> & aPropertyNames)1611 void SAL_CALL Cell::setPropertiesToDefault( const Sequence< OUString >& aPropertyNames )
1612 {
1613     sal_Int32 nCount = aPropertyNames.getLength();
1614     const OUString* pName = aPropertyNames.getConstArray();
1615 
1616     while(nCount--)
1617         setPropertyToDefault( *pName++ );
1618 }
1619 
1620 // -----------------------------------------------------------------------------
1621 
getPropertyDefaults(const Sequence<OUString> & aPropertyNames)1622 Sequence< Any > SAL_CALL Cell::getPropertyDefaults( const Sequence< OUString >& aPropertyNames )
1623 {
1624     sal_Int32 nCount = aPropertyNames.getLength();
1625     Sequence< Any > aDefaults( nCount );
1626     Any* pDefaults = aDefaults.getArray();
1627     const OUString* pName = aPropertyNames.getConstArray();
1628 
1629     while(nCount--)
1630         *pDefaults++ = getPropertyDefault( *pName++ );
1631 
1632     return aDefaults;
1633 }
1634 
1635 // -----------------------------------------------------------------------------
1636 // XFastPropertySet
1637 // -----------------------------------------------------------------------------
1638 
setFastPropertyValue(sal_Int32 nHandle,const Any & aValue)1639 void SAL_CALL Cell::setFastPropertyValue( sal_Int32 nHandle, const Any& aValue )
1640 {
1641     (void)aValue;
1642     (void)nHandle;
1643     throw UnknownPropertyException();
1644 }
1645 
1646 // -----------------------------------------------------------------------------
1647 // TODO: Refactor this method!
getFastPropertyValue(sal_Int32 nHandle)1648 Any SAL_CALL Cell::getFastPropertyValue( sal_Int32 nHandle )
1649 {
1650     (void)nHandle;
1651     throw UnknownPropertyException();
1652 }
1653 
1654 // -----------------------------------------------------------------------------
1655 // XText
1656 // -----------------------------------------------------------------------------
1657 
insertTextContent(const Reference<XTextRange> & xRange,const Reference<XTextContent> & xContent,sal_Bool bAbsorb)1658 void SAL_CALL Cell::insertTextContent( const Reference< XTextRange >& xRange, const Reference< XTextContent >& xContent, sal_Bool bAbsorb )
1659 {
1660     SvxUnoTextBase::insertTextContent( xRange, xContent, bAbsorb );
1661     notifyModified();
1662 }
1663 
1664 // -----------------------------------------------------------------------------
1665 
removeTextContent(const Reference<XTextContent> & xContent)1666 void SAL_CALL Cell::removeTextContent( const Reference< XTextContent >& xContent )
1667 {
1668     SvxUnoTextBase::removeTextContent( xContent );
1669     notifyModified();
1670 }
1671 
1672 // -----------------------------------------------------------------------------
1673 // XSimpleText
1674 // -----------------------------------------------------------------------------
1675 
createTextCursor()1676 Reference< XTextCursor > SAL_CALL Cell::createTextCursor(  )
1677 {
1678     return SvxUnoTextBase::createTextCursor();
1679 }
1680 
1681 // -----------------------------------------------------------------------------
1682 
createTextCursorByRange(const Reference<XTextRange> & aTextPosition)1683 Reference< XTextCursor > SAL_CALL Cell::createTextCursorByRange( const Reference< XTextRange >& aTextPosition )
1684 {
1685     return SvxUnoTextBase::createTextCursorByRange( aTextPosition );
1686 }
1687 
1688 // -----------------------------------------------------------------------------
1689 
insertString(const Reference<XTextRange> & xRange,const OUString & aString,sal_Bool bAbsorb)1690 void SAL_CALL Cell::insertString( const Reference< XTextRange >& xRange, const OUString& aString, sal_Bool bAbsorb )
1691 {
1692     SvxUnoTextBase::insertString( xRange, aString, bAbsorb );
1693     notifyModified();
1694 }
1695 
1696 // -----------------------------------------------------------------------------
1697 
insertControlCharacter(const Reference<XTextRange> & xRange,sal_Int16 nControlCharacter,sal_Bool bAbsorb)1698 void SAL_CALL Cell::insertControlCharacter( const Reference< XTextRange >& xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb )
1699 {
1700     SvxUnoTextBase::insertControlCharacter( xRange, nControlCharacter, bAbsorb );
1701     notifyModified();
1702 }
1703 
1704 // -----------------------------------------------------------------------------
1705 // XTextRange
1706 // -----------------------------------------------------------------------------
1707 
getText()1708 Reference< XText > SAL_CALL Cell::getText(  )
1709 {
1710     return SvxUnoTextBase::getText();
1711 }
1712 
1713 // -----------------------------------------------------------------------------
1714 
getStart()1715 Reference< XTextRange > SAL_CALL Cell::getStart(  )
1716 {
1717     return SvxUnoTextBase::getStart();
1718 }
1719 
1720 // -----------------------------------------------------------------------------
1721 
getEnd()1722 Reference< XTextRange > SAL_CALL Cell::getEnd(  )
1723 {
1724     return SvxUnoTextBase::getEnd();
1725 }
1726 
1727 // -----------------------------------------------------------------------------
1728 
getString()1729 OUString SAL_CALL Cell::getString(  )
1730 {
1731     maSelection.nStartPara = 0xffff;
1732     return SvxUnoTextBase::getString();
1733 }
1734 
1735 // -----------------------------------------------------------------------------
1736 
setString(const OUString & aString)1737 void SAL_CALL Cell::setString( const OUString& aString )
1738 {
1739     SvxUnoTextBase::setString( aString );
1740     notifyModified();
1741 }
1742 
1743 // XEventListener
disposing(const EventObject &)1744 void SAL_CALL Cell::disposing( const EventObject& /*Source*/ )
1745 {
1746     mxTable.clear();
1747     dispose();
1748 }
1749 
getCellName(sal_Int32 nCol,sal_Int32 nRow)1750 static OUString getCellName( sal_Int32 nCol, sal_Int32 nRow )
1751 {
1752     rtl::OUStringBuffer aBuf;
1753 
1754     if (nCol < 26*26)
1755     {
1756         if (nCol < 26)
1757             aBuf.append( static_cast<sal_Unicode>( 'A' +
1758                         static_cast<sal_uInt16>(nCol)));
1759         else
1760         {
1761             aBuf.append( static_cast<sal_Unicode>( 'A' +
1762                         (static_cast<sal_uInt16>(nCol) / 26) - 1));
1763             aBuf.append( static_cast<sal_Unicode>( 'A' +
1764                         (static_cast<sal_uInt16>(nCol) % 26)));
1765         }
1766     }
1767     else
1768     {
1769         String aStr;
1770         while (nCol >= 26)
1771         {
1772             sal_Int32 nC = nCol % 26;
1773             aStr += static_cast<sal_Unicode>( 'A' +
1774                     static_cast<sal_uInt16>(nC));
1775             nCol = nCol - nC;
1776             nCol = nCol / 26 - 1;
1777         }
1778         aStr += static_cast<sal_Unicode>( 'A' +
1779                 static_cast<sal_uInt16>(nCol));
1780         aStr.Reverse();
1781         aBuf.append( aStr);
1782     }
1783     aBuf.append( OUString::valueOf(nRow+1) );
1784     return aBuf.makeStringAndClear();
1785 }
1786 
getName()1787 OUString Cell::getName()
1788 {
1789     // todo: optimize!
1790     OUString sName;
1791     if( mxTable.is() ) try
1792     {
1793         Reference< XCell > xThis( static_cast< XCell* >( this ) );
1794 
1795         sal_Int32 nRowCount = mxTable->getRowCount();
1796         sal_Int32 nColCount = mxTable->getColumnCount();
1797         for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
1798         {
1799             for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ )
1800             {
1801                 Reference< XCell > xCell( mxTable->getCellByPosition( nCol, nRow ) );
1802                 if( xCell == xThis )
1803                 {
1804                     return getCellName( nCol, nRow );
1805                 }
1806             }
1807         }
1808     }
1809     catch( Exception& )
1810     {
1811     }
1812 
1813     return sName;
1814 }
1815 
1816 } }
1817