Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / svx / source / table / cell.cxx
blob3ab9b683006f32e4ff3b11361ebf6adff79bee5d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <com/sun/star/drawing/BitmapMode.hpp>
22 #include <com/sun/star/style/XStyle.hpp>
23 #include <com/sun/star/text/WritingMode.hpp>
24 #include <com/sun/star/table/TableBorder.hpp>
25 #include <com/sun/star/table/BorderLine2.hpp>
27 #include <comphelper/string.hxx>
29 #include <cppuhelper/supportsservice.hxx>
30 #include <cppuhelper/typeprovider.hxx>
31 #include <svl/style.hxx>
32 #include <svl/itemset.hxx>
34 #include <osl/mutex.hxx>
35 #include <vcl/svapp.hxx>
37 #include "svx/sdr/properties/textproperties.hxx"
38 #include "editeng/outlobj.hxx"
39 #include "editeng/writingmodeitem.hxx"
40 #include "svx/svdotable.hxx"
41 #include "svx/svdoutl.hxx"
42 #include "svx/unoshtxt.hxx"
43 #include "svx/svdmodel.hxx"
45 #include "tableundo.hxx"
46 #include "cell.hxx"
47 #include "svx/unoshprp.hxx"
48 #include "svx/unoshape.hxx"
49 #include "editeng/editobj.hxx"
50 #include "editeng/boxitem.hxx"
51 #include "svx/xflbstit.hxx"
52 #include "svx/xflbmtit.hxx"
53 #include <svx/svdpool.hxx>
57 using ::editeng::SvxBorderLine;
58 using namespace ::com::sun::star::uno;
59 using namespace ::com::sun::star::beans;
60 using namespace ::com::sun::star::lang;
61 using namespace ::com::sun::star::text;
62 using namespace ::com::sun::star::table;
63 using namespace ::com::sun::star::drawing;
64 using namespace ::com::sun::star::style;
65 using namespace ::com::sun::star::container;
69 static const SvxItemPropertySet* ImplGetSvxCellPropertySet()
71 // Propertymap fuer einen Outliner Text
72 static const SfxItemPropertyMapEntry aSvxCellPropertyMap[] =
74 FILL_PROPERTIES
75 // { "HasLevels", OWN_ATTR_HASLEVELS, ::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
76 { OUString("Style"), OWN_ATTR_STYLE, cppu::UnoType< ::com::sun::star::style::XStyle >::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
77 { OUString(UNO_NAME_TEXT_WRITINGMODE), SDRATTR_TEXTDIRECTION, cppu::UnoType<com::sun::star::text::WritingMode>::get(), 0, 0},
78 { OUString(UNO_NAME_TEXT_HORZADJUST), SDRATTR_TEXT_HORZADJUST, cppu::UnoType<com::sun::star::drawing::TextHorizontalAdjust>::get(), 0, 0}, \
79 { OUString(UNO_NAME_TEXT_LEFTDIST), SDRATTR_TEXT_LEFTDIST, ::cppu::UnoType<sal_Int32>::get(), 0, SFX_METRIC_ITEM}, \
80 { OUString(UNO_NAME_TEXT_LOWERDIST), SDRATTR_TEXT_LOWERDIST, ::cppu::UnoType<sal_Int32>::get(), 0, SFX_METRIC_ITEM}, \
81 { OUString(UNO_NAME_TEXT_RIGHTDIST), SDRATTR_TEXT_RIGHTDIST, ::cppu::UnoType<sal_Int32>::get(), 0, SFX_METRIC_ITEM}, \
82 { OUString(UNO_NAME_TEXT_UPPERDIST), SDRATTR_TEXT_UPPERDIST, ::cppu::UnoType<sal_Int32>::get(), 0, SFX_METRIC_ITEM}, \
83 { OUString(UNO_NAME_TEXT_VERTADJUST), SDRATTR_TEXT_VERTADJUST, cppu::UnoType<com::sun::star::drawing::TextVerticalAdjust>::get(), 0, 0},\
84 { OUString(UNO_NAME_TEXT_WORDWRAP), SDRATTR_TEXT_WORDWRAP, ::getBooleanCppuType(), 0, 0}, \
86 { OUString("TableBorder"), OWN_ATTR_TABLEBORDER, cppu::UnoType<TableBorder>::get(), 0, 0 }, \
87 { OUString("TopBorder"), SDRATTR_TABLE_BORDER, cppu::UnoType<BorderLine>::get(), 0, TOP_BORDER }, \
88 { OUString("BottomBorder"), SDRATTR_TABLE_BORDER, cppu::UnoType<BorderLine>::get(), 0, BOTTOM_BORDER }, \
89 { OUString("LeftBorder"), SDRATTR_TABLE_BORDER, cppu::UnoType<BorderLine>::get(), 0, LEFT_BORDER }, \
90 { OUString("RightBorder"), SDRATTR_TABLE_BORDER, cppu::UnoType<BorderLine>::get(), 0, RIGHT_BORDER }, \
92 SVX_UNOEDIT_OUTLINER_PROPERTIES,
93 SVX_UNOEDIT_CHAR_PROPERTIES,
94 SVX_UNOEDIT_PARA_PROPERTIES,
95 { OUString(), 0, css::uno::Type(), 0, 0 }
98 static SvxItemPropertySet aSvxCellPropertySet( aSvxCellPropertyMap, SdrObject::GetGlobalDrawObjectItemPool() );
99 return &aSvxCellPropertySet;
102 namespace
105 class CellTextProvider : public svx::ITextProvider
107 public:
108 explicit CellTextProvider(const sdr::table::CellRef xCell);
109 virtual ~CellTextProvider();
111 private:
112 virtual sal_Int32 getTextCount() const SAL_OVERRIDE;
113 virtual SdrText* getText(sal_Int32 nIndex) const SAL_OVERRIDE;
115 private:
116 const sdr::table::CellRef m_xCell;
119 CellTextProvider::CellTextProvider(const sdr::table::CellRef xCell)
120 : m_xCell(xCell)
124 CellTextProvider::~CellTextProvider()
128 sal_Int32 CellTextProvider::getTextCount() const
130 return 1;
133 SdrText* CellTextProvider::getText(sal_Int32 nIndex) const
135 (void) nIndex;
136 assert(nIndex == 0);
137 return m_xCell.get();
142 namespace sdr
144 namespace properties
146 class CellProperties : public TextProperties
148 protected:
149 // create a new itemset
150 SfxItemSet& CreateObjectSpecificItemSet(SfxItemPool& rPool) SAL_OVERRIDE;
152 const svx::ITextProvider& getTextProvider() const SAL_OVERRIDE;
154 public:
155 // basic constructor
156 CellProperties(SdrObject& rObj, sdr::table::Cell* pCell );
158 // constructor for copying, but using new object
159 CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell);
161 // destructor
162 virtual ~CellProperties();
164 // Clone() operator, normally just calls the local copy constructor
165 BaseProperties& Clone(SdrObject& rObj) const SAL_OVERRIDE;
167 void ForceDefaultAttributes() SAL_OVERRIDE;
169 void ItemSetChanged(const SfxItemSet& rSet) SAL_OVERRIDE;
171 void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem) SAL_OVERRIDE;
173 void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) SAL_OVERRIDE;
175 sdr::table::CellRef mxCell;
177 private:
178 const CellTextProvider maTextProvider;
181 // create a new itemset
182 SfxItemSet& CellProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
184 return *(new SfxItemSet(rPool,
186 // range from SdrAttrObj
187 SDRATTR_START, SDRATTR_SHADOW_LAST,
188 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
189 SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
191 // range for SdrTableObj
192 SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
194 // range from SdrTextObj
195 EE_ITEMS_START, EE_ITEMS_END,
197 // end
198 0, 0));
201 const svx::ITextProvider& CellProperties::getTextProvider() const
203 return maTextProvider;
206 CellProperties::CellProperties(SdrObject& rObj, sdr::table::Cell* pCell)
207 : TextProperties(rObj)
208 , mxCell(pCell)
209 , maTextProvider(mxCell)
213 CellProperties::CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell)
214 : TextProperties(rProps, rObj)
215 , mxCell( pCell )
216 , maTextProvider(mxCell)
220 CellProperties::~CellProperties()
224 BaseProperties& CellProperties::Clone(SdrObject& rObj) const
226 OSL_FAIL("CellProperties::Clone(), does not work yet!");
227 return *(new CellProperties(*this, rObj,0));
230 void CellProperties::ForceDefaultAttributes()
234 void CellProperties::ItemSetChanged(const SfxItemSet& rSet )
236 SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
238 if( mxCell.is() )
240 OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject();
242 bool bOwnParaObj = pParaObj != 0;
244 if( pParaObj == 0 )
245 pParaObj = mxCell->GetOutlinerParaObject();
247 if(pParaObj)
249 // handle outliner attributes
250 Outliner* pOutliner = 0;
252 if(mxCell->IsTextEditActive())
254 pOutliner = rObj.GetTextEditOutliner();
256 else
258 pOutliner = &rObj.ImpGetDrawOutliner();
259 pOutliner->SetText(*pParaObj);
262 sal_Int32 nParaCount(pOutliner->GetParagraphCount());
264 for(sal_Int32 nPara = 0; nPara < nParaCount; nPara++)
266 SfxItemSet aSet(pOutliner->GetParaAttribs(nPara));
267 aSet.Put(rSet);
268 pOutliner->SetParaAttribs(nPara, aSet);
271 if(!mxCell->IsTextEditActive())
273 if(nParaCount)
275 // force ItemSet
276 GetObjectItemSet();
278 SfxItemSet aNewSet(pOutliner->GetParaAttribs(0L));
279 mpItemSet->Put(aNewSet);
282 OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, nParaCount);
283 pOutliner->Clear();
285 mxCell->SetOutlinerParaObject(pTemp);
288 if( bOwnParaObj )
289 delete pParaObj;
293 // call parent
294 AttributeProperties::ItemSetChanged(rSet);
296 if( mxCell.is() )
297 mxCell->notifyModified();
300 void CellProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
302 if(pNewItem && (SDRATTR_TEXTDIRECTION == nWhich))
304 bool bVertical(com::sun::star::text::WritingMode_TB_RL == ((SvxWritingModeItem*)pNewItem)->GetValue());
306 sdr::table::SdrTableObj& rObj = (sdr::table::SdrTableObj&)GetSdrObject();
307 if( rObj.IsVerticalWriting() != bVertical )
308 rObj.SetVerticalWriting(bVertical);
310 // Set a cell vertical property
311 OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject();
312 if( pParaObj == 0 )
313 pParaObj = mxCell->GetOutlinerParaObject();
314 if(pParaObj)
316 pParaObj->SetVertical(bVertical);
321 // call parent
322 AttributeProperties::ItemChange( nWhich, pNewItem );
325 void CellProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr)
327 TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr );
329 } // end of namespace properties
330 } // end of namespace sdr
332 namespace sdr { namespace table {
335 // Cell
338 rtl::Reference< Cell > Cell::create( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject )
340 rtl::Reference< Cell > xCell( new Cell( rTableObj, pOutlinerParaObject ) );
341 if( xCell->mxTable.is() )
343 Reference< XEventListener > xListener( xCell.get() );
344 xCell->mxTable->addEventListener( xListener );
346 return xCell;
351 Cell::Cell( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject ) throw()
352 : SdrText( rTableObj, pOutlinerParaObject )
353 , SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
354 , mpPropSet( ImplGetSvxCellPropertySet() )
355 , mpProperties( new sdr::properties::CellProperties( rTableObj, this ) )
356 , mnCellContentType( CellContentType_EMPTY )
357 , mfValue( 0.0 )
358 , mnError( 0 )
359 , mbMerged( false )
360 , mnRowSpan( 1 )
361 , mnColSpan( 1 )
362 , mxTable( rTableObj.getTable() )
364 if( rTableObj.GetModel() )
365 SetModel( rTableObj.GetModel() );
370 Cell::~Cell() throw()
372 dispose();
377 void Cell::dispose()
379 if( mxTable.is() )
383 Reference< XEventListener > xThis( this );
384 mxTable->removeEventListener( xThis );
386 catch( Exception& )
388 OSL_FAIL("Cell::dispose(), exception caught!");
390 mxTable.clear();
393 if( mpProperties )
395 delete mpProperties;
396 mpProperties = 0;
398 SetOutlinerParaObject( 0 );
403 void Cell::SetModel(SdrModel* pNewModel)
405 SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( GetEditSource() );
406 if( (GetModel() != pNewModel) || ( pNewModel && !pTextEditSource) )
408 if( mpProperties )
410 SfxItemPool* pItemPool = mpProperties->GetObjectItemSet().GetPool();
412 // test for correct pool in ItemSet; move to new pool if necessary
413 if( pNewModel && pItemPool && pItemPool != &pNewModel->GetItemPool())
414 mpProperties->MoveToItemPool(pItemPool, &pNewModel->GetItemPool(), pNewModel);
417 if( pTextEditSource )
419 pTextEditSource->ChangeModel( pNewModel );
421 else
423 SetEditSource( new SvxTextEditSource( &GetObject(), this, static_cast< XWeak * >( this ) ) );
426 SetStyleSheet( 0, true );
427 SdrText::SetModel( pNewModel );
428 ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
434 void Cell::merge( sal_Int32 nColumnSpan, sal_Int32 nRowSpan )
436 if ((mnColSpan != nColumnSpan) || (mnRowSpan != nRowSpan) || mbMerged)
438 mnColSpan = nColumnSpan;
439 mnRowSpan = nRowSpan;
440 mbMerged = false;
441 notifyModified();
447 void Cell::mergeContent( const CellRef& xSourceCell )
449 SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
451 if( xSourceCell->hasText() )
453 SdrOutliner& rOutliner=rTableObj.ImpGetDrawOutliner();
454 rOutliner.SetUpdateMode(true);
456 if( hasText() )
458 rOutliner.SetText(*GetOutlinerParaObject());
459 rOutliner.AddText(*xSourceCell->GetOutlinerParaObject());
461 else
463 rOutliner.SetText(*xSourceCell->GetOutlinerParaObject());
466 SetOutlinerParaObject( rOutliner.CreateParaObject() );
467 rOutliner.Clear();
468 xSourceCell->SetOutlinerParaObject(rOutliner.CreateParaObject());
469 rOutliner.Clear();
470 SetStyleSheet( GetStyleSheet(), true );
476 void Cell::cloneFrom( const CellRef& xCell )
478 if( xCell.is() )
480 replaceContentAndFormating( xCell );
482 mnCellContentType = xCell->mnCellContentType;
484 msFormula = xCell->msFormula;
485 mfValue = xCell->mfValue;
486 mnError = xCell->mnError;
488 mbMerged = xCell->mbMerged;
489 mnRowSpan = xCell->mnRowSpan;
490 mnColSpan = xCell->mnColSpan;
493 notifyModified();
496 void Cell::replaceContentAndFormating( const CellRef& xSourceCell )
498 if( xSourceCell.is() && mpProperties )
500 mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() );
501 SetOutlinerParaObject( new OutlinerParaObject(*xSourceCell->GetOutlinerParaObject()) );
503 SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
504 SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() );
506 if(rSourceTableObj.GetModel() != rTableObj.GetModel())
508 SetStyleSheet( 0, true );
515 void Cell::setMerged()
517 if( !mbMerged )
519 mbMerged = true;
520 notifyModified();
526 void Cell::notifyModified()
528 if( mxTable.is() )
529 mxTable->setModified( sal_True );
533 // SdrTextShape proxy
536 bool Cell::IsTextEditActive()
538 bool isActive = false;
539 SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
540 if(rTableObj.getActiveCell().get() == this )
542 OutlinerParaObject* pParaObj = rTableObj.GetEditOutlinerParaObject();
543 if( pParaObj != 0 )
545 isActive = true;
546 delete pParaObj;
549 return isActive;
554 bool Cell::hasText() const
556 OutlinerParaObject* pParaObj = GetOutlinerParaObject();
557 if( pParaObj )
559 const EditTextObject& rTextObj = pParaObj->GetTextObject();
560 if( rTextObj.GetParagraphCount() >= 1 )
562 if( rTextObj.GetParagraphCount() == 1 )
564 if( rTextObj.GetText(0).isEmpty() )
565 return false;
567 return true;
571 return false;
576 OutlinerParaObject* Cell::GetEditOutlinerParaObject() const
578 SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
579 if( rTableObj.getActiveCell().get() == this )
580 return rTableObj.GetEditOutlinerParaObject();
581 return 0;
586 void Cell::SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr )
588 // only allow cell styles for cells
589 if( pStyleSheet && pStyleSheet->GetFamily() != SFX_STYLE_FAMILY_FRAME )
590 return;
592 if( mpProperties && (mpProperties->GetStyleSheet() != pStyleSheet) )
594 mpProperties->SetStyleSheet( pStyleSheet, bDontRemoveHardAttr );
600 const SfxItemSet& Cell::GetObjectItemSet()
602 if( mpProperties )
604 return mpProperties->GetObjectItemSet();
606 else
608 OSL_FAIL("Cell::GetObjectItemSet(), called without properties!");
609 return GetObject().GetObjectItemSet();
613 void Cell::SetObjectItem(const SfxPoolItem& rItem)
615 if( mpProperties )
617 mpProperties->SetObjectItem( rItem );
618 notifyModified();
622 void Cell::SetMergedItem(const SfxPoolItem& rItem)
624 SetObjectItem(rItem);
627 SfxStyleSheet* Cell::GetStyleSheet() const
629 if( mpProperties )
630 return mpProperties->GetStyleSheet();
631 else
632 return 0;
637 const Rectangle& Cell::GetCurrentBoundRect() const
639 return maCellRect;
644 void Cell::TakeTextAnchorRect(Rectangle& rAnchorRect) const
646 rAnchorRect.Left() = maCellRect.Left() + GetTextLeftDistance();
647 rAnchorRect.Right() = maCellRect.Right() - GetTextRightDistance();
648 rAnchorRect.Top() = maCellRect.Top() + GetTextUpperDistance();
649 rAnchorRect.Bottom() = maCellRect.Bottom() - GetTextLowerDistance();
654 const SfxItemSet& Cell::GetItemSet() const
656 return mpProperties->GetObjectItemSet();
661 void Cell::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, bool bClearAllItems)
663 if( mpProperties )
665 mpProperties->SetMergedItemSetAndBroadcast(rSet, bClearAllItems);
666 notifyModified();
672 sal_Int32 Cell::getMinimumWidth()
674 return GetTextLeftDistance() + GetTextRightDistance() + 100;
679 sal_Int32 Cell::getMinimumHeight()
681 if( !mpProperties )
682 return 0;
684 SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
685 sal_Int32 nMinimumHeight = 0;
687 Rectangle aTextRect;
688 TakeTextAnchorRect( aTextRect );
689 Size aSize( aTextRect.GetSize() );
690 aSize.Height()=0x0FFFFFFF;
692 SdrOutliner* pEditOutliner = rTableObj.GetCellTextEditOutliner( *this );
693 if(pEditOutliner)
695 pEditOutliner->SetMaxAutoPaperSize(aSize);
696 nMinimumHeight = pEditOutliner->GetTextHeight()+1;
698 else /*if ( hasText() )*/
700 Outliner& rOutliner=rTableObj.ImpGetDrawOutliner();
701 rOutliner.SetPaperSize(aSize);
702 rOutliner.SetUpdateMode(true);
703 ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
705 if( GetOutlinerParaObject() )
707 rOutliner.SetText(*GetOutlinerParaObject());
709 nMinimumHeight=rOutliner.GetTextHeight()+1;
710 rOutliner.Clear();
713 nMinimumHeight += GetTextUpperDistance() + GetTextLowerDistance();
714 return nMinimumHeight;
719 long Cell::GetTextLeftDistance() const
721 return ((SdrTextLeftDistItem&)(GetItemSet().Get(SDRATTR_TEXT_LEFTDIST))).GetValue();
726 long Cell::GetTextRightDistance() const
728 return ((SdrTextRightDistItem&)(GetItemSet().Get(SDRATTR_TEXT_RIGHTDIST))).GetValue();
733 long Cell::GetTextUpperDistance() const
735 return ((SdrTextUpperDistItem&)(GetItemSet().Get(SDRATTR_TEXT_UPPERDIST))).GetValue();
740 long Cell::GetTextLowerDistance() const
742 return ((SdrTextLowerDistItem&)(GetItemSet().Get(SDRATTR_TEXT_LOWERDIST))).GetValue();
747 SdrTextVertAdjust Cell::GetTextVerticalAdjust() const
749 return ((SdrTextVertAdjustItem&)(GetItemSet().Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
754 SdrTextHorzAdjust Cell::GetTextHorizontalAdjust() const
756 return ((SdrTextHorzAdjustItem&)(GetItemSet().Get(SDRATTR_TEXT_HORZADJUST))).GetValue();
761 void Cell::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
763 SdrText::SetOutlinerParaObject( pTextObject );
764 maSelection.nStartPara = EE_PARA_MAX_COUNT;
766 if( pTextObject == 0 )
767 ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
772 void Cell::AddUndo()
774 SdrObject& rObj = GetObject();
775 if( rObj.IsInserted() && GetModel() && GetModel()->IsUndoEnabled() )
777 CellRef xCell( this );
778 GetModel()->AddUndo( new CellUndo( &rObj, xCell ) );
784 sdr::properties::TextProperties* Cell::CloneProperties( sdr::properties::TextProperties* pProperties, SdrObject& rNewObj, Cell& rNewCell )
786 if( pProperties )
787 return new sdr::properties::CellProperties( *static_cast<sdr::properties::CellProperties*>(pProperties), rNewObj, &rNewCell );
788 else
789 return 0;
794 sdr::properties::TextProperties* Cell::CloneProperties( SdrObject& rNewObj, Cell& rNewCell )
796 return CloneProperties(mpProperties,rNewObj,rNewCell);
800 // XInterface
803 Any SAL_CALL Cell::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
805 if( rType == cppu::UnoType<XMergeableCell>::get() )
806 return Any( Reference< XMergeableCell >( this ) );
808 if( rType == cppu::UnoType<XCell>::get() )
809 return Any( Reference< XCell >( this ) );
811 if( rType == cppu::UnoType<XLayoutConstrains>::get() )
812 return Any( Reference< XLayoutConstrains >( this ) );
814 if( rType == cppu::UnoType<XEventListener>::get() )
815 return Any( Reference< XEventListener >( this ) );
817 Any aRet( SvxUnoTextBase::queryAggregation( rType ) );
818 if( aRet.hasValue() )
819 return aRet;
821 return ::cppu::OWeakObject::queryInterface( rType );
826 void SAL_CALL Cell::acquire() throw ()
828 ::cppu::OWeakObject::acquire();
833 void SAL_CALL Cell::release() throw ()
835 ::cppu::OWeakObject::release();
839 // XTypeProvider
842 Sequence< Type > SAL_CALL Cell::getTypes( ) throw (RuntimeException, std::exception)
844 Sequence< Type > aTypes( SvxUnoTextBase::getTypes() );
846 sal_Int32 nLen = aTypes.getLength();
847 aTypes.realloc(nLen + 2);
848 aTypes[nLen++] = cppu::UnoType<XMergeableCell>::get();
849 aTypes[nLen++] = cppu::UnoType<XLayoutConstrains>::get();
851 return aTypes;
856 Sequence< sal_Int8 > SAL_CALL Cell::getImplementationId( ) throw (RuntimeException, std::exception)
858 return css::uno::Sequence<sal_Int8>();
861 // XServiceInfo
862 OUString SAL_CALL Cell::getImplementationName( ) throw (RuntimeException, std::exception)
864 return OUString( "com.sun.star.comp.svx.table.Cell" );
867 sal_Bool SAL_CALL Cell::supportsService( const OUString& ServiceName ) throw (RuntimeException, std::exception)
869 return cppu::supportsService( this, ServiceName );
872 Sequence< OUString > SAL_CALL Cell::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
874 Sequence< OUString > aSeq( SvxUnoTextBase::getSupportedServiceNames() );
875 sal_Int32 nIndex = aSeq.getLength();
876 aSeq.realloc( nIndex + 2 );
877 aSeq[nIndex++] = "com.sun.star.table.cell";
878 aSeq[nIndex++] = "com.sun.star.drawing.cell";
879 return aSeq;
882 // XLayoutConstrains
883 ::com::sun::star::awt::Size SAL_CALL Cell::getMinimumSize()
884 throw (RuntimeException,
885 std::exception)
887 return ::com::sun::star::awt::Size( getMinimumWidth(), getMinimumHeight() );
892 ::com::sun::star::awt::Size SAL_CALL Cell::getPreferredSize()
893 throw (RuntimeException,
894 std::exception)
896 return getMinimumSize();
901 ::com::sun::star::awt::Size SAL_CALL Cell::calcAdjustedSize( const ::com::sun::star::awt::Size& aNewSize ) throw (RuntimeException, std::exception)
903 return aNewSize;
907 // XMergeableCell
910 sal_Int32 SAL_CALL Cell::getRowSpan() throw (RuntimeException, std::exception)
912 return mnRowSpan;
917 sal_Int32 SAL_CALL Cell::getColumnSpan() throw (RuntimeException, std::exception)
919 return mnColSpan;
924 sal_Bool SAL_CALL Cell::isMerged() throw (RuntimeException, std::exception)
926 return mbMerged;
930 // XCell
933 OUString SAL_CALL Cell::getFormula( ) throw (RuntimeException, std::exception)
935 return msFormula;
940 void SAL_CALL Cell::setFormula( const OUString& aFormula ) throw (RuntimeException, std::exception)
942 if( msFormula != aFormula )
944 msFormula = aFormula;
950 double SAL_CALL Cell::getValue( ) throw (RuntimeException, std::exception)
952 return mfValue;
957 void SAL_CALL Cell::setValue( double nValue ) throw (RuntimeException, std::exception)
959 if( mfValue != nValue )
961 mfValue = nValue;
962 mnCellContentType = CellContentType_VALUE;
968 CellContentType SAL_CALL Cell::getType() throw (RuntimeException, std::exception)
970 return mnCellContentType;
975 sal_Int32 SAL_CALL Cell::getError( ) throw (RuntimeException, std::exception)
977 return mnError;
981 // XPropertySet
984 Any Cell::GetAnyForItem( SfxItemSet& aSet, const SfxItemPropertySimpleEntry* pMap )
986 Any aAny( SvxItemPropertySet_getPropertyValue( *mpPropSet, pMap, aSet ) );
988 if( pMap->aType != aAny.getValueType() )
990 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
991 if( ( pMap->aType == ::cppu::UnoType<sal_Int16>::get()) && aAny.getValueType() == ::cppu::UnoType<sal_Int32>::get() )
993 sal_Int32 nValue = 0;
994 aAny >>= nValue;
995 aAny <<= (sal_Int16)nValue;
997 else
999 OSL_FAIL("GetAnyForItem() Returnvalue has wrong Type!" );
1003 return aAny;
1006 Reference< XPropertySetInfo > SAL_CALL Cell::getPropertySetInfo() throw(RuntimeException, std::exception)
1008 return mpPropSet->getPropertySetInfo();
1013 void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any& rValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
1015 ::SolarMutexGuard aGuard;
1017 if( (mpProperties == 0) || (GetModel() == 0) )
1018 throw DisposedException();
1020 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName);
1021 if( pMap )
1023 if( (pMap->nFlags & PropertyAttribute::READONLY ) != 0 )
1024 throw PropertyVetoException();
1026 switch( pMap->nWID )
1028 case OWN_ATTR_STYLE:
1030 Reference< XStyle > xStyle;
1031 if( !( rValue >>= xStyle ) )
1032 throw IllegalArgumentException();
1034 SfxUnoStyleSheet* pStyle = SfxUnoStyleSheet::getUnoStyleSheet(xStyle);
1035 SetStyleSheet( pStyle, true );
1036 return;
1038 case OWN_ATTR_TABLEBORDER:
1040 if(rValue.getValueType() != cppu::UnoType<TableBorder>::get())
1041 break;
1043 const TableBorder* pBorder = (const TableBorder* )rValue.getValue();
1044 if( pBorder == NULL )
1045 break;
1047 SvxBoxItem aBox( SDRATTR_TABLE_BORDER );
1048 SvxBoxInfoItem aBoxInfo( SDRATTR_TABLE_BORDER_INNER );
1049 SvxBorderLine aLine;
1051 bool bSet = SvxBoxItem::LineToSvxLine(pBorder->TopLine, aLine, false);
1052 aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_TOP);
1053 aBoxInfo.SetValid(VALID_TOP, pBorder->IsTopLineValid);
1055 bSet = SvxBoxItem::LineToSvxLine(pBorder->BottomLine, aLine, false);
1056 aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_BOTTOM);
1057 aBoxInfo.SetValid(VALID_BOTTOM, pBorder->IsBottomLineValid);
1059 bSet = SvxBoxItem::LineToSvxLine(pBorder->LeftLine, aLine, false);
1060 aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_LEFT);
1061 aBoxInfo.SetValid(VALID_LEFT, pBorder->IsLeftLineValid);
1063 bSet = SvxBoxItem::LineToSvxLine(pBorder->RightLine, aLine, false);
1064 aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_RIGHT);
1065 aBoxInfo.SetValid(VALID_RIGHT, pBorder->IsRightLineValid);
1067 bSet = SvxBoxItem::LineToSvxLine(pBorder->HorizontalLine, aLine, false);
1068 aBoxInfo.SetLine(bSet ? &aLine : 0, BOXINFO_LINE_HORI);
1069 aBoxInfo.SetValid(VALID_HORI, pBorder->IsHorizontalLineValid);
1071 bSet = SvxBoxItem::LineToSvxLine(pBorder->VerticalLine, aLine, false);
1072 aBoxInfo.SetLine(bSet ? &aLine : 0, BOXINFO_LINE_VERT);
1073 aBoxInfo.SetValid(VALID_VERT, pBorder->IsVerticalLineValid);
1075 aBox.SetDistance(pBorder->Distance); //TODO
1076 aBoxInfo.SetValid(VALID_DISTANCE, pBorder->IsDistanceValid);
1078 mpProperties->SetObjectItem(aBox);
1079 mpProperties->SetObjectItem(aBoxInfo);
1080 return;
1082 case OWN_ATTR_FILLBMP_MODE:
1084 BitmapMode eMode;
1085 if(!(rValue >>= eMode) )
1087 sal_Int32 nMode = 0;
1088 if(!(rValue >>= nMode))
1089 throw IllegalArgumentException();
1091 eMode = (BitmapMode)nMode;
1094 mpProperties->SetObjectItem( XFillBmpStretchItem( eMode == BitmapMode_STRETCH ) );
1095 mpProperties->SetObjectItem( XFillBmpTileItem( eMode == BitmapMode_REPEAT ) );
1096 return;
1098 default:
1100 SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
1101 aSet.Put(mpProperties->GetItem(pMap->nWID));
1103 bool bSpecial = false;
1105 switch( pMap->nWID )
1107 case XATTR_FILLBITMAP:
1108 case XATTR_FILLGRADIENT:
1109 case XATTR_FILLHATCH:
1110 case XATTR_FILLFLOATTRANSPARENCE:
1111 case XATTR_LINEEND:
1112 case XATTR_LINESTART:
1113 case XATTR_LINEDASH:
1115 if( pMap->nMemberId == MID_NAME )
1117 OUString aApiName;
1118 if( rValue >>= aApiName )
1120 if( SvxShape::SetFillAttribute( pMap->nWID, aApiName, aSet, GetModel() ) )
1121 bSpecial = true;
1125 break;
1128 if( !bSpecial )
1131 if( !SvxUnoTextRangeBase::SetPropertyValueHelper( aSet, pMap, rValue, aSet ))
1133 if( aSet.GetItemState( pMap->nWID ) != SFX_ITEM_SET )
1135 // Default aus ItemPool holen
1136 if(GetModel()->GetItemPool().IsWhich(pMap->nWID))
1137 aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
1140 if( aSet.GetItemState( pMap->nWID ) == SFX_ITEM_SET )
1142 SvxItemPropertySet_setPropertyValue( *mpPropSet, pMap, rValue, aSet );
1147 GetModel()->SetChanged();
1148 mpProperties->SetMergedItemSetAndBroadcast( aSet );
1149 return;
1153 throw UnknownPropertyException();
1158 Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
1160 ::SolarMutexGuard aGuard;
1162 if( (mpProperties == 0) || (GetModel() == 0) )
1163 throw DisposedException();
1165 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
1166 if( pMap )
1168 switch( pMap->nWID )
1170 case OWN_ATTR_STYLE:
1172 return Any( Reference< XStyle >( dynamic_cast< SfxUnoStyleSheet* >( GetStyleSheet() ) ) );
1174 case OWN_ATTR_TABLEBORDER:
1176 const SvxBoxInfoItem& rBoxInfoItem = static_cast<const SvxBoxInfoItem&>(mpProperties->GetItem(SDRATTR_TABLE_BORDER_INNER));
1177 const SvxBoxItem& rBox = static_cast<const SvxBoxItem&>(mpProperties->GetItem(SDRATTR_TABLE_BORDER));
1179 TableBorder aTableBorder;
1180 aTableBorder.TopLine = SvxBoxItem::SvxLineToLine(rBox.GetTop(), false);
1181 aTableBorder.IsTopLineValid = rBoxInfoItem.IsValid(VALID_TOP);
1182 aTableBorder.BottomLine = SvxBoxItem::SvxLineToLine(rBox.GetBottom(), false);
1183 aTableBorder.IsBottomLineValid = rBoxInfoItem.IsValid(VALID_BOTTOM);
1184 aTableBorder.LeftLine = SvxBoxItem::SvxLineToLine(rBox.GetLeft(), false);
1185 aTableBorder.IsLeftLineValid = rBoxInfoItem.IsValid(VALID_LEFT);
1186 aTableBorder.RightLine = SvxBoxItem::SvxLineToLine(rBox.GetRight(), false);
1187 aTableBorder.IsRightLineValid = rBoxInfoItem.IsValid(VALID_RIGHT );
1188 aTableBorder.HorizontalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetHori(), false);
1189 aTableBorder.IsHorizontalLineValid = rBoxInfoItem.IsValid(VALID_HORI);
1190 aTableBorder.VerticalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetVert(), false);
1191 aTableBorder.IsVerticalLineValid = rBoxInfoItem.IsValid(VALID_VERT);
1192 aTableBorder.Distance = rBox.GetDistance();
1193 aTableBorder.IsDistanceValid = rBoxInfoItem.IsValid(VALID_DISTANCE);
1195 return Any( aTableBorder );
1197 case OWN_ATTR_FILLBMP_MODE:
1199 const XFillBmpStretchItem& rStretchItem = static_cast<const XFillBmpStretchItem&>(mpProperties->GetItem(XATTR_FILLBMP_STRETCH));
1200 const XFillBmpTileItem& rTileItem = static_cast<const XFillBmpTileItem&>(mpProperties->GetItem(XATTR_FILLBMP_TILE));
1201 if( rTileItem.GetValue() )
1203 return Any( BitmapMode_REPEAT );
1205 else if( rStretchItem.GetValue() )
1207 return Any( BitmapMode_STRETCH );
1209 else
1211 return Any( BitmapMode_NO_REPEAT );
1214 default:
1216 SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
1217 aSet.Put(mpProperties->GetItem(pMap->nWID));
1219 Any aAny;
1220 if(!SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pMap, aAny ))
1222 if(!aSet.Count())
1224 // Default aus ItemPool holen
1225 if(GetModel()->GetItemPool().IsWhich(pMap->nWID))
1226 aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
1229 if( aSet.Count() )
1230 aAny = GetAnyForItem( aSet, pMap );
1233 return aAny;
1237 throw UnknownPropertyException();
1242 void SAL_CALL Cell::addPropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*xListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
1248 void SAL_CALL Cell::removePropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
1254 void SAL_CALL Cell::addVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
1260 void SAL_CALL Cell::removeVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
1265 // XMultiPropertySet
1268 void SAL_CALL Cell::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues ) throw (PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
1270 ::SolarMutexGuard aSolarGuard;
1272 if( (mpProperties == 0) || (GetModel() == 0) )
1273 throw DisposedException();
1275 const sal_Int32 nCount = aPropertyNames.getLength();
1277 const OUString* pNames = aPropertyNames.getConstArray();
1278 const Any* pValues = aValues.getConstArray();
1280 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ )
1284 setPropertyValue( *pNames, *pValues );
1286 catch( UnknownPropertyException& )
1288 OSL_FAIL("svx::Cell::setPropertyValues(), unknown property!" );
1290 catch( Exception& )
1292 OSL_FAIL("svx::Cell::setPropertyValues(), Exception caught!" );
1299 Sequence< Any > SAL_CALL Cell::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw (RuntimeException, std::exception)
1301 ::SolarMutexGuard aSolarGuard;
1303 if( (mpProperties == 0) || (GetModel() == 0) )
1304 throw DisposedException();
1306 const sal_Int32 nCount = aPropertyNames.getLength();
1307 const OUString* pNames = aPropertyNames.getConstArray();
1309 Sequence< Any > aRet( nCount );
1310 Any* pValue = aRet.getArray();
1312 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ )
1316 *pValue = getPropertyValue( *pNames );
1318 catch( UnknownPropertyException& )
1320 OSL_FAIL("svx::Cell::setPropertyValues(), unknown property!" );
1322 catch( Exception& )
1324 OSL_FAIL( "svx::Cell::getPropertyValues(), Exception caught!" );
1328 return aRet;
1333 void SAL_CALL Cell::addPropertiesChangeListener( const Sequence< OUString >& /*aPropertyNames*/, const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException, std::exception)
1339 void SAL_CALL Cell::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException, std::exception)
1345 void SAL_CALL Cell::firePropertiesChangeEvent( const Sequence< OUString >& /*aPropertyNames*/, const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException, std::exception)
1350 // XPropertyState
1353 PropertyState SAL_CALL Cell::getPropertyState( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException, std::exception)
1355 ::SolarMutexGuard aGuard;
1357 if( (mpProperties == 0) || (GetModel() == 0) )
1358 throw DisposedException();
1360 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
1362 if( pMap )
1364 PropertyState eState;
1365 switch( pMap->nWID )
1367 case OWN_ATTR_FILLBMP_MODE:
1369 const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
1371 const bool bStretch = rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET;
1372 const bool bTile = rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET;
1373 if( bStretch || bTile )
1375 eState = PropertyState_DIRECT_VALUE;
1377 else
1379 eState = PropertyState_DEFAULT_VALUE;
1382 case OWN_ATTR_STYLE:
1384 return PropertyState_DIRECT_VALUE;
1386 case OWN_ATTR_TABLEBORDER:
1388 const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
1389 if( (rSet.GetItemState( SDRATTR_TABLE_BORDER_INNER, false ) == SFX_ITEM_DEFAULT) && (rSet.GetItemState( SDRATTR_TABLE_BORDER, false ) == SFX_ITEM_DEFAULT) )
1390 return PropertyState_DEFAULT_VALUE;
1392 return PropertyState_DIRECT_VALUE;
1394 default:
1396 const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
1398 switch( rSet.GetItemState( pMap->nWID, false ) )
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 default:
1408 eState = PropertyState_AMBIGUOUS_VALUE;
1409 break;
1412 // if a item is set, this doesn't mean we want it :)
1413 if( ( PropertyState_DIRECT_VALUE == eState ) )
1415 switch( pMap->nWID )
1417 // the following items are disabled by changing the
1418 // fill style or the line style. so there is no need
1419 // to export items without names which should be empty
1420 case XATTR_FILLBITMAP:
1421 case XATTR_FILLGRADIENT:
1422 case XATTR_FILLHATCH:
1423 case XATTR_LINEDASH:
1425 NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((sal_uInt16)pMap->nWID);
1426 if( ( pItem == NULL ) || pItem->GetName().isEmpty() )
1427 eState = PropertyState_DEFAULT_VALUE;
1429 break;
1431 // #i36115#
1432 // If e.g. the LineStart is on NONE and thus the string has length 0, it still
1433 // may be a hard attribute covering the set LineStart of the parent (Style).
1434 // #i37644#
1435 // same is for fill float transparency
1436 case XATTR_LINEEND:
1437 case XATTR_LINESTART:
1438 case XATTR_FILLFLOATTRANSPARENCE:
1440 NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((sal_uInt16)pMap->nWID);
1441 if( pItem == NULL )
1442 eState = PropertyState_DEFAULT_VALUE;
1444 break;
1449 return eState;
1451 throw UnknownPropertyException();
1456 Sequence< PropertyState > SAL_CALL Cell::getPropertyStates( const Sequence< OUString >& aPropertyName ) throw(UnknownPropertyException, RuntimeException, std::exception)
1458 ::SolarMutexGuard aGuard;
1460 if( (mpProperties == 0) || (GetModel() == 0) )
1461 throw DisposedException();
1463 const sal_Int32 nCount = aPropertyName.getLength();
1465 Sequence< PropertyState > aRet( nCount );
1467 const OUString* pNames = aPropertyName.getConstArray();
1468 PropertyState* pState = aRet.getArray();
1470 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pState++ )
1474 *pState = getPropertyState( *pNames );
1476 catch( Exception& )
1478 *pState = PropertyState_AMBIGUOUS_VALUE;
1482 return aRet;
1487 void SAL_CALL Cell::setPropertyToDefault( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException, std::exception)
1489 ::SolarMutexGuard aGuard;
1491 if( (mpProperties == 0) || (GetModel() == 0) )
1492 throw DisposedException();
1494 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
1495 if( pMap )
1497 switch( pMap->nWID )
1499 case OWN_ATTR_FILLBMP_MODE:
1501 mpProperties->ClearObjectItem( XATTR_FILLBMP_STRETCH );
1502 mpProperties->ClearObjectItem( XATTR_FILLBMP_TILE );
1503 break;
1505 case OWN_ATTR_STYLE:
1506 break;
1508 case OWN_ATTR_TABLEBORDER:
1510 mpProperties->ClearObjectItem( SDRATTR_TABLE_BORDER_INNER );
1511 mpProperties->ClearObjectItem( SDRATTR_TABLE_BORDER );
1512 break;
1515 default:
1517 mpProperties->ClearObjectItem( pMap->nWID );
1521 GetModel()->SetChanged();
1522 return;
1524 throw UnknownPropertyException();
1529 Any SAL_CALL Cell::getPropertyDefault( const OUString& aPropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
1531 ::SolarMutexGuard aGuard;
1533 if( (mpProperties == 0) || (GetModel() == 0) )
1534 throw DisposedException();
1536 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName);
1537 if( pMap )
1539 switch( pMap->nWID )
1541 case OWN_ATTR_FILLBMP_MODE:
1542 return Any( BitmapMode_NO_REPEAT );
1544 case OWN_ATTR_STYLE:
1546 Reference< XStyle > xStyle;
1547 return Any( xStyle );
1550 case OWN_ATTR_TABLEBORDER:
1552 TableBorder aBorder;
1553 return Any( aBorder );
1556 default:
1558 if( GetModel()->GetItemPool().IsWhich(pMap->nWID) )
1560 SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
1561 aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
1562 return GetAnyForItem( aSet, pMap );
1567 throw UnknownPropertyException();
1571 // XMultiPropertyStates
1574 void SAL_CALL Cell::setAllPropertiesToDefault()
1575 throw (RuntimeException, std::exception)
1577 delete mpProperties;
1578 mpProperties = new sdr::properties::CellProperties( static_cast< SdrTableObj& >( GetObject() ), this );
1580 SdrOutliner& rOutliner = GetObject().ImpGetDrawOutliner();
1582 OutlinerParaObject* pParaObj = GetOutlinerParaObject();
1583 if( pParaObj )
1585 rOutliner.SetText(*pParaObj);
1586 sal_Int32 nParaCount(rOutliner.GetParagraphCount());
1588 if(nParaCount)
1590 ESelection aSelection( 0, 0, EE_PARA_ALL, EE_TEXTPOS_ALL);
1591 rOutliner.RemoveAttribs(aSelection, true, 0);
1593 OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, nParaCount);
1594 rOutliner.Clear();
1596 SetOutlinerParaObject(pTemp);
1603 void SAL_CALL Cell::setPropertiesToDefault( const Sequence< OUString >& aPropertyNames ) throw (UnknownPropertyException, RuntimeException, std::exception)
1605 sal_Int32 nCount = aPropertyNames.getLength();
1606 const OUString* pName = aPropertyNames.getConstArray();
1608 while(nCount--)
1609 setPropertyToDefault( *pName++ );
1614 Sequence< Any > SAL_CALL Cell::getPropertyDefaults( const Sequence< OUString >& aPropertyNames ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
1616 sal_Int32 nCount = aPropertyNames.getLength();
1617 Sequence< Any > aDefaults( nCount );
1618 Any* pDefaults = aDefaults.getArray();
1619 const OUString* pName = aPropertyNames.getConstArray();
1621 while(nCount--)
1622 *pDefaults++ = getPropertyDefault( *pName++ );
1624 return aDefaults;
1628 // XFastPropertySet
1631 void SAL_CALL Cell::setFastPropertyValue( sal_Int32 nHandle, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
1633 (void)aValue;
1634 (void)nHandle;
1635 throw UnknownPropertyException();
1639 // TODO: Refactor this method!
1640 Any SAL_CALL Cell::getFastPropertyValue( sal_Int32 nHandle ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
1642 (void)nHandle;
1643 throw UnknownPropertyException();
1647 // XText
1650 void SAL_CALL Cell::insertTextContent( const Reference< XTextRange >& xRange, const Reference< XTextContent >& xContent, sal_Bool bAbsorb ) throw (IllegalArgumentException, RuntimeException, std::exception)
1652 SvxUnoTextBase::insertTextContent( xRange, xContent, bAbsorb );
1653 notifyModified();
1658 void SAL_CALL Cell::removeTextContent( const Reference< XTextContent >& xContent ) throw (NoSuchElementException, RuntimeException, std::exception)
1660 SvxUnoTextBase::removeTextContent( xContent );
1661 notifyModified();
1665 // XSimpleText
1668 Reference< XTextCursor > SAL_CALL Cell::createTextCursor( ) throw (RuntimeException, std::exception)
1670 return SvxUnoTextBase::createTextCursor();
1675 Reference< XTextCursor > SAL_CALL Cell::createTextCursorByRange( const Reference< XTextRange >& aTextPosition ) throw (RuntimeException, std::exception)
1677 return SvxUnoTextBase::createTextCursorByRange( aTextPosition );
1682 void SAL_CALL Cell::insertString( const Reference< XTextRange >& xRange, const OUString& aString, sal_Bool bAbsorb ) throw (RuntimeException, std::exception)
1684 SvxUnoTextBase::insertString( xRange, aString, bAbsorb );
1685 notifyModified();
1690 void SAL_CALL Cell::insertControlCharacter( const Reference< XTextRange >& xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb ) throw (IllegalArgumentException, RuntimeException, std::exception)
1692 SvxUnoTextBase::insertControlCharacter( xRange, nControlCharacter, bAbsorb );
1693 notifyModified();
1697 // XTextRange
1700 Reference< XText > SAL_CALL Cell::getText( ) throw (RuntimeException, std::exception)
1702 return SvxUnoTextBase::getText();
1707 Reference< XTextRange > SAL_CALL Cell::getStart( ) throw (RuntimeException, std::exception)
1709 return SvxUnoTextBase::getStart();
1714 Reference< XTextRange > SAL_CALL Cell::getEnd( ) throw (RuntimeException, std::exception)
1716 return SvxUnoTextBase::getEnd();
1721 OUString SAL_CALL Cell::getString( ) throw (RuntimeException, std::exception)
1723 maSelection.nStartPara = EE_PARA_MAX_COUNT;
1724 return SvxUnoTextBase::getString();
1729 void SAL_CALL Cell::setString( const OUString& aString ) throw (RuntimeException, std::exception)
1731 SvxUnoTextBase::setString( aString );
1732 notifyModified();
1735 // XEventListener
1736 void SAL_CALL Cell::disposing( const EventObject& /*Source*/ ) throw (RuntimeException, std::exception)
1738 mxTable.clear();
1739 dispose();
1744 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */