1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cell.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include <com/sun/star/drawing/BitmapMode.hpp>
35 #include <com/sun/star/style/XStyle.hpp>
36 #include <com/sun/star/text/WritingMode.hpp>
37 #include <com/sun/star/table/TableBorder.hpp>
39 #include <cppuhelper/typeprovider.hxx>
40 #include <svtools/style.hxx>
41 #include <svtools/itemset.hxx>
43 #include <vos/mutex.hxx>
44 #include <vcl/svapp.hxx>
46 #include "svx/sdr/properties/textproperties.hxx"
47 #include "svx/outlobj.hxx"
48 #include "svx/writingmodeitem.hxx"
49 #include "svx/svdotable.hxx"
50 #include "svx/svdoutl.hxx"
51 #include "svx/unoshtxt.hxx"
52 #include "svx/svdmodel.hxx"
54 #include "tableundo.hxx"
56 #include "svx/svdotable.hxx"
57 #include "svx/svdoutl.hxx"
58 #include "svx/unoshtxt.hxx"
59 #include "svx/unoshprp.hxx"
60 #include "svx/unoshape.hxx"
61 #include "svx/editobj.hxx"
62 #include "svx/boxitem.hxx"
63 #include "svx/xflbstit.hxx"
64 #include "svx/xflbmtit.hxx"
66 // -----------------------------------------------------------------------------
68 using ::rtl::OUString
;
70 using namespace ::com::sun::star::uno
;
71 using namespace ::com::sun::star::beans
;
72 using namespace ::com::sun::star::lang
;
73 using namespace ::com::sun::star::text
;
74 using namespace ::com::sun::star::table
;
75 using namespace ::com::sun::star::drawing
;
76 using namespace ::com::sun::star::style
;
77 using namespace ::com::sun::star::container
;
79 extern sal_Bool
lcl_LineToSvxLine(const BorderLine
& rLine
, SvxBorderLine
& rSvxLine
, sal_Bool bConvert
);
80 extern BorderLine
lcl_SvxLineToLine(const SvxBorderLine
* pLine
, sal_Bool bConvert
);
82 // -----------------------------------------------------------------------------
84 static const SvxItemPropertySet
* ImplGetSvxCellPropertySet()
86 // Propertymap fuer einen Outliner Text
87 static const SfxItemPropertyMapEntry aSvxCellPropertyMap
[] =
90 // { MAP_CHAR_LEN("HasLevels"), OWN_ATTR_HASLEVELS, &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
91 { MAP_CHAR_LEN("Style"), OWN_ATTR_STYLE
, &::com::sun::star::style::XStyle::static_type(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID
, 0},
92 { MAP_CHAR_LEN(UNO_NAME_TEXT_WRITINGMODE
), SDRATTR_TEXTDIRECTION
, &::getCppuType( (::com::sun::star::text::WritingMode
*) 0 ), 0, 0},
93 { MAP_CHAR_LEN(UNO_NAME_TEXT_HORZADJUST
), SDRATTR_TEXT_HORZADJUST
, &::getCppuType((const ::com::sun::star::drawing::TextHorizontalAdjust
*)0), 0, 0}, \
94 { MAP_CHAR_LEN(UNO_NAME_TEXT_LEFTDIST
), SDRATTR_TEXT_LEFTDIST
, &::getCppuType((const sal_Int32
*)0), 0, SFX_METRIC_ITEM
}, \
95 { MAP_CHAR_LEN(UNO_NAME_TEXT_LOWERDIST
), SDRATTR_TEXT_LOWERDIST
, &::getCppuType((const sal_Int32
*)0), 0, SFX_METRIC_ITEM
}, \
96 { MAP_CHAR_LEN(UNO_NAME_TEXT_RIGHTDIST
), SDRATTR_TEXT_RIGHTDIST
, &::getCppuType((const sal_Int32
*)0), 0, SFX_METRIC_ITEM
}, \
97 { MAP_CHAR_LEN(UNO_NAME_TEXT_UPPERDIST
), SDRATTR_TEXT_UPPERDIST
, &::getCppuType((const sal_Int32
*)0), 0, SFX_METRIC_ITEM
}, \
98 { MAP_CHAR_LEN(UNO_NAME_TEXT_VERTADJUST
), SDRATTR_TEXT_VERTADJUST
, &::getCppuType((const ::com::sun::star::drawing::TextVerticalAdjust
*)0), 0, 0},\
99 { MAP_CHAR_LEN(UNO_NAME_TEXT_WORDWRAP
), SDRATTR_TEXT_WORDWRAP
, &::getBooleanCppuType(), 0, 0}, \
101 { MAP_CHAR_LEN("TableBorder"), OWN_ATTR_TABLEBORDER
, &::getCppuType((const TableBorder
*)0), 0, 0 }, \
102 { MAP_CHAR_LEN("TopBorder"), SDRATTR_TABLE_BORDER
, &::getCppuType((const BorderLine
*)0), 0, TOP_BORDER
}, \
103 { MAP_CHAR_LEN("BottomBorder"), SDRATTR_TABLE_BORDER
, &::getCppuType((const BorderLine
*)0), 0, BOTTOM_BORDER
}, \
104 { MAP_CHAR_LEN("LeftBorder"), SDRATTR_TABLE_BORDER
, &::getCppuType((const BorderLine
*)0), 0, LEFT_BORDER
}, \
105 { MAP_CHAR_LEN("RightBorder"), SDRATTR_TABLE_BORDER
, &::getCppuType((const BorderLine
*)0), 0, RIGHT_BORDER
}, \
107 SVX_UNOEDIT_OUTLINER_PROPERTIES
,
108 SVX_UNOEDIT_CHAR_PROPERTIES
,
109 SVX_UNOEDIT_PARA_PROPERTIES
,
113 static SvxItemPropertySet
aSvxCellPropertySet( aSvxCellPropertyMap
);
114 return &aSvxCellPropertySet
;
121 class CellProperties
: public TextProperties
124 // create a new itemset
125 SfxItemSet
& CreateObjectSpecificItemSet(SfxItemPool
& rPool
);
129 CellProperties(SdrObject
& rObj
, sdr::table::Cell
* pCell
);
131 // constructor for copying, but using new object
132 CellProperties(const CellProperties
& rProps
, SdrObject
& rObj
, sdr::table::Cell
* pCell
);
137 // Clone() operator, normally just calls the local copy constructor
138 BaseProperties
& Clone(SdrObject
& rObj
) const;
140 void ForceDefaultAttributes();
142 void ItemSetChanged(const SfxItemSet
& rSet
);
144 void ItemChange(const sal_uInt16 nWhich
, const SfxPoolItem
* pNewItem
);
146 void SetStyleSheet(SfxStyleSheet
* pNewStyleSheet
, sal_Bool bDontRemoveHardAttr
);
148 sdr::table::CellRef mxCell
;
151 // create a new itemset
152 SfxItemSet
& CellProperties::CreateObjectSpecificItemSet(SfxItemPool
& rPool
)
154 return *(new SfxItemSet(rPool
,
156 // range from SdrAttrObj
157 SDRATTR_START
, SDRATTR_SHADOW_LAST
,
158 SDRATTR_MISC_FIRST
, SDRATTR_MISC_LAST
,
159 SDRATTR_TEXTDIRECTION
, SDRATTR_TEXTDIRECTION
,
161 // range for SdrTableObj
162 SDRATTR_TABLE_FIRST
, SDRATTR_TABLE_LAST
,
164 // range from SdrTextObj
165 EE_ITEMS_START
, EE_ITEMS_END
,
171 CellProperties::CellProperties(SdrObject
& rObj
, sdr::table::Cell
* pCell
)
172 : TextProperties(rObj
)
177 CellProperties::CellProperties(const CellProperties
& rProps
, SdrObject
& rObj
, sdr::table::Cell
* pCell
)
178 : TextProperties(rProps
, rObj
)
183 CellProperties::~CellProperties()
187 BaseProperties
& CellProperties::Clone(SdrObject
& rObj
) const
189 DBG_ERROR("CellProperties::Clone(), does not work yet!");
190 return *(new CellProperties(*this, rObj
,0));
193 void CellProperties::ForceDefaultAttributes()
197 void CellProperties::ItemSetChanged(const SfxItemSet
& rSet
)
199 SdrTextObj
& rObj
= (SdrTextObj
&)GetSdrObject();
203 OutlinerParaObject
* pParaObj
= mxCell
->GetEditOutlinerParaObject();
205 bool bOwnParaObj
= pParaObj
!= 0;
208 pParaObj
= mxCell
->GetOutlinerParaObject();
212 // handle outliner attributes
213 Outliner
* pOutliner
= 0;
215 if(mxCell
->IsTextEditActive())
217 pOutliner
= rObj
.GetTextEditOutliner();
221 pOutliner
= &rObj
.ImpGetDrawOutliner();
222 pOutliner
->SetText(*pParaObj
);
225 sal_uInt32
nParaCount(pOutliner
->GetParagraphCount());
227 for(sal_uInt16 nPara
= 0; nPara
< nParaCount
; nPara
++)
229 SfxItemSet
aSet(pOutliner
->GetParaAttribs(nPara
));
231 pOutliner
->SetParaAttribs(nPara
, aSet
);
234 if(!mxCell
->IsTextEditActive())
241 SfxItemSet
aNewSet(pOutliner
->GetParaAttribs(0L));
242 mpItemSet
->Put(aNewSet
);
245 OutlinerParaObject
* pTemp
= pOutliner
->CreateParaObject(0, (sal_uInt16
)nParaCount
);
248 mxCell
->SetOutlinerParaObject(pTemp
);
257 AttributeProperties::ItemSetChanged(rSet
);
260 mxCell
->notifyModified();
263 void CellProperties::ItemChange(const sal_uInt16 nWhich
, const SfxPoolItem
* pNewItem
)
265 if(pNewItem
&& (SDRATTR_TEXTDIRECTION
== nWhich
))
267 sal_Bool
bVertical(com::sun::star::text::WritingMode_TB_RL
== ((SvxWritingModeItem
*)pNewItem
)->GetValue());
269 sdr::table::SdrTableObj
& rObj
= (sdr::table::SdrTableObj
&)GetSdrObject();
270 if( rObj
.IsVerticalWriting() != bVertical
)
271 rObj
.SetVerticalWriting(bVertical
);
275 AttributeProperties::ItemChange( nWhich
, pNewItem
);
278 void CellProperties::SetStyleSheet(SfxStyleSheet
* pNewStyleSheet
, sal_Bool bDontRemoveHardAttr
)
280 TextProperties::SetStyleSheet( pNewStyleSheet
, bDontRemoveHardAttr
);
282 } // end of namespace properties
283 } // end of namespace sdr
285 namespace sdr
{ namespace table
{
287 // -----------------------------------------------------------------------------
289 // -----------------------------------------------------------------------------
291 rtl::Reference
< Cell
> Cell::create( SdrTableObj
& rTableObj
, OutlinerParaObject
* pOutlinerParaObject
)
293 rtl::Reference
< Cell
> xCell( new Cell( rTableObj
, pOutlinerParaObject
) );
294 if( xCell
->mxTable
.is() )
296 Reference
< XEventListener
> xListener( xCell
.get() );
297 xCell
->mxTable
->addEventListener( xListener
);
302 // -----------------------------------------------------------------------------
304 Cell::Cell( SdrTableObj
& rTableObj
, OutlinerParaObject
* pOutlinerParaObject
) throw()
305 : SdrText( rTableObj
, pOutlinerParaObject
)
306 , SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
307 , mpPropSet( ImplGetSvxCellPropertySet() )
308 , mpProperties( new sdr::properties::CellProperties( rTableObj
, this ) )
309 , mnCellContentType( CellContentType_EMPTY
)
312 , mbMerged( sal_False
)
315 , mxTable( rTableObj
.getTable() )
317 if( rTableObj
.GetModel() )
318 SetModel( rTableObj
.GetModel() );
321 // -----------------------------------------------------------------------------
323 Cell::~Cell() throw()
328 // -----------------------------------------------------------------------------
336 Reference
< XEventListener
> xThis( this );
337 mxTable
->removeEventListener( xThis
);
341 DBG_ERROR("Cell::dispose(), exception caught!");
351 SetOutlinerParaObject( 0 );
354 // -----------------------------------------------------------------------------
356 void Cell::SetModel(SdrModel
* pNewModel
)
358 SvxTextEditSource
* pTextEditSource
= dynamic_cast< SvxTextEditSource
* >( GetEditSource() );
359 if( (GetModel() != pNewModel
) || ( pNewModel
&& !pTextEditSource
) )
363 SfxItemPool
* pItemPool
= mpProperties
->GetObjectItemSet().GetPool();
365 // test for correct pool in ItemSet; move to new pool if necessary
366 if( pNewModel
&& pItemPool
&& pItemPool
!= &pNewModel
->GetItemPool())
367 mpProperties
->MoveToItemPool(pItemPool
, &pNewModel
->GetItemPool(), pNewModel
);
370 if( pTextEditSource
)
372 pTextEditSource
->ChangeModel( pNewModel
);
376 SetEditSource( new SvxTextEditSource( &GetObject(), this, static_cast< XWeak
* >( this ) ) );
379 SetStyleSheet( 0, sal_True
);
380 SdrText::SetModel( pNewModel
);
381 ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT
);
385 // -----------------------------------------------------------------------------
387 void Cell::merge( sal_Int32 nColumnSpan
, sal_Int32 nRowSpan
)
389 if( (mnColSpan
!= nColumnSpan
) || (mnRowSpan
!= nRowSpan
) || (mbMerged
!= sal_False
) )
391 mnColSpan
= nColumnSpan
;
392 mnRowSpan
= nRowSpan
;
393 mbMerged
= sal_False
;
398 // -----------------------------------------------------------------------------
400 void Cell::mergeContent( const CellRef
& xSourceCell
)
402 SdrTableObj
& rTableObj
= dynamic_cast< SdrTableObj
& >( GetObject() );
404 if( xSourceCell
->hasText() )
406 SdrOutliner
& rOutliner
=rTableObj
.ImpGetDrawOutliner();
407 rOutliner
.SetUpdateMode(TRUE
);
411 rOutliner
.SetText(*GetOutlinerParaObject());
412 rOutliner
.AddText(*xSourceCell
->GetOutlinerParaObject());
416 rOutliner
.SetText(*xSourceCell
->GetOutlinerParaObject());
419 SetOutlinerParaObject( rOutliner
.CreateParaObject() );
421 xSourceCell
->SetOutlinerParaObject(rOutliner
.CreateParaObject());
423 SetStyleSheet( GetStyleSheet(), sal_True
);
427 // -----------------------------------------------------------------------------
429 void Cell::cloneFrom( const CellRef
& xCell
)
433 replaceContentAndFormating( xCell
);
435 mnCellContentType
= xCell
->mnCellContentType
;
437 msFormula
= xCell
->msFormula
;
438 mfValue
= xCell
->mfValue
;
439 mnError
= xCell
->mnError
;
441 mbMerged
= xCell
->mbMerged
;
442 mnRowSpan
= xCell
->mnRowSpan
;
443 mnColSpan
= xCell
->mnColSpan
;
449 void Cell::replaceContentAndFormating( const CellRef
& xSourceCell
)
451 if( xSourceCell
.is() && mpProperties
)
453 mpProperties
->SetMergedItemSet( xSourceCell
->GetObjectItemSet() );
454 SetOutlinerParaObject( new OutlinerParaObject(*xSourceCell
->GetOutlinerParaObject()) );
456 SdrTableObj
& rTableObj
= dynamic_cast< SdrTableObj
& >( GetObject() );
457 SdrTableObj
& rSourceTableObj
= dynamic_cast< SdrTableObj
& >( xSourceCell
->GetObject() );
459 if(rSourceTableObj
.GetModel() != rTableObj
.GetModel())
461 SetStyleSheet( 0, sal_True
);
466 // -----------------------------------------------------------------------------
468 void Cell::setMerged()
477 // -----------------------------------------------------------------------------
479 void Cell::notifyModified()
482 mxTable
->setModified( sal_True
);
485 // -----------------------------------------------------------------------------
486 // SdrTextShape proxy
487 // -----------------------------------------------------------------------------
489 bool Cell::IsTextEditActive()
491 bool isActive
= false;
492 SdrTableObj
& rTableObj
= dynamic_cast< SdrTableObj
& >( GetObject() );
493 if(rTableObj
.getActiveCell().get() == this )
495 OutlinerParaObject
* pParaObj
= rTableObj
.GetEditOutlinerParaObject();
505 // -----------------------------------------------------------------------------
507 bool Cell::hasText() const
509 OutlinerParaObject
* pParaObj
= GetOutlinerParaObject();
512 const EditTextObject
& rTextObj
= pParaObj
->GetTextObject();
513 if( rTextObj
.GetParagraphCount() >= 1 )
515 if( rTextObj
.GetParagraphCount() == 1 )
517 if( rTextObj
.GetText(0).Len() == 0 )
527 // -----------------------------------------------------------------------------
529 OutlinerParaObject
* Cell::GetEditOutlinerParaObject() const
531 SdrTableObj
& rTableObj
= dynamic_cast< SdrTableObj
& >( GetObject() );
532 if( rTableObj
.getActiveCell().get() == this )
533 return rTableObj
.GetEditOutlinerParaObject();
537 // -----------------------------------------------------------------------------
539 void Cell::SetStyleSheet( SfxStyleSheet
* pStyleSheet
, sal_Bool bDontRemoveHardAttr
)
541 // only allow cell styles for cells
542 if( pStyleSheet
&& pStyleSheet
->GetFamily() != SFX_STYLE_FAMILY_FRAME
)
545 if( mpProperties
&& (mpProperties
->GetStyleSheet() != pStyleSheet
) )
547 mpProperties
->SetStyleSheet( pStyleSheet
, bDontRemoveHardAttr
);
551 // -----------------------------------------------------------------------------
553 const SfxItemSet
& Cell::GetObjectItemSet()
557 return mpProperties
->GetObjectItemSet();
561 DBG_ERROR("Cell::GetObjectItemSet(), called without properties!");
562 return GetObject().GetObjectItemSet();
566 void Cell::SetObjectItem(const SfxPoolItem
& rItem
)
570 mpProperties
->SetObjectItem( rItem
);
575 void Cell::SetMergedItem(const SfxPoolItem
& rItem
)
577 SetObjectItem(rItem
);
580 SfxStyleSheet
* Cell::GetStyleSheet() const
583 return mpProperties
->GetStyleSheet();
588 // -----------------------------------------------------------------------------
590 SfxStyleSheetPool
* Cell::GetStyleSheetPool() const
592 if( mpProperties
&& mpProperties
->GetStyleSheet() )
593 return dynamic_cast< SfxStyleSheetPool
* >( &mpProperties
->GetStyleSheet()->GetPool() );
598 // -----------------------------------------------------------------------------
600 const Rectangle
& Cell::GetCurrentBoundRect() const
605 // -----------------------------------------------------------------------------
607 void Cell::TakeTextAnchorRect(Rectangle
& rAnchorRect
) const
609 rAnchorRect
.nLeft
= maCellRect
.nLeft
+ GetTextLeftDistance();
610 rAnchorRect
.nRight
= maCellRect
.nRight
- GetTextRightDistance();
611 rAnchorRect
.nTop
= maCellRect
.nTop
+ GetTextUpperDistance();
612 rAnchorRect
.nBottom
= maCellRect
.nBottom
- GetTextLowerDistance();
615 // -----------------------------------------------------------------------------
617 const SfxItemSet
& Cell::GetItemSet() const
619 return mpProperties
->GetObjectItemSet();
622 // -----------------------------------------------------------------------------
624 void Cell::SetMergedItemSetAndBroadcast(const SfxItemSet
& rSet
, sal_Bool bClearAllItems
)
628 mpProperties
->SetMergedItemSetAndBroadcast(rSet
, bClearAllItems
);
633 // -----------------------------------------------------------------------------
635 sal_Int32
Cell::getMinimumWidth()
637 return GetTextLeftDistance() + GetTextRightDistance() + 100;
640 // -----------------------------------------------------------------------------
642 sal_Int32
Cell::getMinimumHeight()
647 SdrTableObj
& rTableObj
= dynamic_cast< SdrTableObj
& >( GetObject() );
648 sal_Int32 nMinimumHeight
= 0;
651 TakeTextAnchorRect( aTextRect
);
652 Size
aSize( aTextRect
.GetSize() );
653 aSize
.Height()=0x0FFFFFFF;
655 SdrOutliner
* pEditOutliner
= rTableObj
.GetCellTextEditOutliner( *this );
658 pEditOutliner
->SetMaxAutoPaperSize(aSize
);
659 nMinimumHeight
= pEditOutliner
->GetTextHeight()+1;
663 Outliner
& rOutliner
=rTableObj
.ImpGetDrawOutliner();
664 rOutliner
.SetPaperSize(aSize
);
665 rOutliner
.SetUpdateMode(TRUE
);
666 ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT
);
668 if( GetOutlinerParaObject() )
670 rOutliner
.SetText(*GetOutlinerParaObject());
672 nMinimumHeight
=rOutliner
.GetTextHeight()+1;
676 nMinimumHeight
+= GetTextUpperDistance() + GetTextLowerDistance();
677 return nMinimumHeight
;
680 // -----------------------------------------------------------------------------
682 long Cell::GetTextLeftDistance() const
684 return ((SdrTextLeftDistItem
&)(GetItemSet().Get(SDRATTR_TEXT_LEFTDIST
))).GetValue();
687 // -----------------------------------------------------------------------------
689 long Cell::GetTextRightDistance() const
691 return ((SdrTextRightDistItem
&)(GetItemSet().Get(SDRATTR_TEXT_RIGHTDIST
))).GetValue();
694 // -----------------------------------------------------------------------------
696 long Cell::GetTextUpperDistance() const
698 return ((SdrTextUpperDistItem
&)(GetItemSet().Get(SDRATTR_TEXT_UPPERDIST
))).GetValue();
701 // -----------------------------------------------------------------------------
703 long Cell::GetTextLowerDistance() const
705 return ((SdrTextLowerDistItem
&)(GetItemSet().Get(SDRATTR_TEXT_LOWERDIST
))).GetValue();
708 // -----------------------------------------------------------------------------
710 SdrTextVertAdjust
Cell::GetTextVerticalAdjust() const
712 return ((SdrTextVertAdjustItem
&)(GetItemSet().Get(SDRATTR_TEXT_VERTADJUST
))).GetValue();
715 // -----------------------------------------------------------------------------
717 SdrTextHorzAdjust
Cell::GetTextHorizontalAdjust() const
719 return ((SdrTextHorzAdjustItem
&)(GetItemSet().Get(SDRATTR_TEXT_HORZADJUST
))).GetValue();
722 // -----------------------------------------------------------------------------
724 void Cell::SetOutlinerParaObject( OutlinerParaObject
* pTextObject
)
726 SdrText::SetOutlinerParaObject( pTextObject
);
727 maSelection
.nStartPara
= 0xffff;
729 if( pTextObject
== 0 )
730 ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT
);
733 // -----------------------------------------------------------------------------
737 SdrObject
& rObj
= GetObject();
738 if( rObj
.IsInserted() && GetModel() && GetModel()->IsUndoEnabled() )
740 CellRef
xCell( this );
741 GetModel()->AddUndo( new CellUndo( &rObj
, xCell
) );
745 // -----------------------------------------------------------------------------
747 sdr::properties::TextProperties
* Cell::CloneProperties( sdr::properties::TextProperties
* pProperties
, SdrObject
& rNewObj
, Cell
& rNewCell
)
750 return new sdr::properties::CellProperties( *static_cast<sdr::properties::CellProperties
*>(pProperties
), rNewObj
, &rNewCell
);
755 // -----------------------------------------------------------------------------
757 sdr::properties::TextProperties
* Cell::CloneProperties( SdrObject
& rNewObj
, Cell
& rNewCell
)
759 return CloneProperties(mpProperties
,rNewObj
,rNewCell
);
762 // -----------------------------------------------------------------------------
764 // -----------------------------------------------------------------------------
766 Any SAL_CALL
Cell::queryInterface( const Type
& rType
) throw(RuntimeException
)
768 if( rType
== XMergeableCell::static_type() )
769 return Any( Reference
< XMergeableCell
>( this ) );
771 if( rType
== XCell::static_type() )
772 return Any( Reference
< XCell
>( this ) );
774 if( rType
== XLayoutConstrains::static_type() )
775 return Any( Reference
< XLayoutConstrains
>( this ) );
777 if( rType
== XEventListener::static_type() )
778 return Any( Reference
< XEventListener
>( this ) );
780 Any
aRet( SvxUnoTextBase::queryAggregation( rType
) );
781 if( aRet
.hasValue() )
784 return ::cppu::OWeakObject::queryInterface( rType
);
787 // -----------------------------------------------------------------------------
789 void SAL_CALL
Cell::acquire() throw ()
791 ::cppu::OWeakObject::acquire();
794 // -----------------------------------------------------------------------------
796 void SAL_CALL
Cell::release() throw ()
798 ::cppu::OWeakObject::release();
801 // -----------------------------------------------------------------------------
803 // -----------------------------------------------------------------------------
805 Sequence
< Type
> SAL_CALL
Cell::getTypes( ) throw (RuntimeException
)
807 Sequence
< Type
> aTypes( SvxUnoTextBase::getTypes() );
809 sal_Int32 nLen
= aTypes
.getLength();
810 aTypes
.realloc(nLen
+ 2);
811 aTypes
[nLen
++] = XMergeableCell::static_type();
812 aTypes
[nLen
++] = XLayoutConstrains::static_type();
817 // -----------------------------------------------------------------------------
819 Sequence
< sal_Int8
> SAL_CALL
Cell::getImplementationId( ) throw (RuntimeException
)
821 static ::cppu::OImplementationId
* pId
= 0;
824 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
827 static ::cppu::OImplementationId aId
;
831 return pId
->getImplementationId();
834 // -----------------------------------------------------------------------------
836 // -----------------------------------------------------------------------------
838 OUString SAL_CALL
Cell::getImplementationName( ) throw (RuntimeException
)
840 return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.table.Cell" ) );
843 // -----------------------------------------------------------------------------
845 sal_Bool SAL_CALL
Cell::supportsService( const OUString
& ServiceName
) throw (RuntimeException
)
847 if( ServiceName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.table.cell" ) ) == 0 )
850 if( ServiceName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.cell" ) ) == 0 )
853 return SvxUnoTextBase::supportsService( ServiceName
);
856 // -----------------------------------------------------------------------------
858 Sequence
< OUString
> SAL_CALL
Cell::getSupportedServiceNames( ) throw (RuntimeException
)
860 Sequence
< OUString
> aSeq( SvxUnoTextBase::getSupportedServiceNames() );
861 sal_Int32 nIndex
= aSeq
.getLength();
862 aSeq
.realloc( nIndex
+ 2 );
863 aSeq
[nIndex
++] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.cell" ) );
864 aSeq
[nIndex
++] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.cell" ) );
868 // -----------------------------------------------------------------------------
870 // -----------------------------------------------------------------------------
872 ::com::sun::star::awt::Size SAL_CALL
Cell::getMinimumSize( ) throw (RuntimeException
)
874 return ::com::sun::star::awt::Size( getMinimumWidth(), getMinimumHeight() );
877 // -----------------------------------------------------------------------------
879 ::com::sun::star::awt::Size SAL_CALL
Cell::getPreferredSize( ) throw (RuntimeException
)
881 return getMinimumSize();
884 // -----------------------------------------------------------------------------
886 ::com::sun::star::awt::Size SAL_CALL
Cell::calcAdjustedSize( const ::com::sun::star::awt::Size
& aNewSize
) throw (RuntimeException
)
891 // -----------------------------------------------------------------------------
893 // -----------------------------------------------------------------------------
895 sal_Int32 SAL_CALL
Cell::getRowSpan() throw (RuntimeException
)
900 // -----------------------------------------------------------------------------
902 sal_Int32 SAL_CALL
Cell::getColumnSpan() throw (RuntimeException
)
907 // -----------------------------------------------------------------------------
909 sal_Bool SAL_CALL
Cell::isMerged() throw (RuntimeException
)
914 // -----------------------------------------------------------------------------
916 // -----------------------------------------------------------------------------
918 OUString SAL_CALL
Cell::getFormula( ) throw (RuntimeException
)
923 // -----------------------------------------------------------------------------
925 void SAL_CALL
Cell::setFormula( const OUString
& aFormula
) throw (RuntimeException
)
927 if( msFormula
!= aFormula
)
929 msFormula
= aFormula
;
933 // -----------------------------------------------------------------------------
935 double SAL_CALL
Cell::getValue( ) throw (RuntimeException
)
940 // -----------------------------------------------------------------------------
942 void SAL_CALL
Cell::setValue( double nValue
) throw (RuntimeException
)
944 if( mfValue
== nValue
)
947 mnCellContentType
= CellContentType_VALUE
;
951 // -----------------------------------------------------------------------------
953 CellContentType SAL_CALL
Cell::getType() throw (RuntimeException
)
955 return mnCellContentType
;
958 // -----------------------------------------------------------------------------
960 sal_Int32 SAL_CALL
Cell::getError( ) throw (RuntimeException
)
965 // -----------------------------------------------------------------------------
967 // -----------------------------------------------------------------------------
969 Any
Cell::GetAnyForItem( SfxItemSet
& aSet
, const SfxItemPropertySimpleEntry
* pMap
)
971 Any
aAny( mpPropSet
->getPropertyValue( pMap
, aSet
) );
973 if( *pMap
->pType
!= aAny
.getValueType() )
975 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
976 if( ( *pMap
->pType
== ::getCppuType((const sal_Int16
*)0)) && aAny
.getValueType() == ::getCppuType((const sal_Int32
*)0) )
978 sal_Int32 nValue
= 0;
980 aAny
<<= (sal_Int16
)nValue
;
984 DBG_ERROR("GetAnyForItem() Returnvalue has wrong Type!" );
991 Reference
< XPropertySetInfo
> SAL_CALL
Cell::getPropertySetInfo() throw(RuntimeException
)
993 return mpPropSet
->getPropertySetInfo();
996 // -----------------------------------------------------------------------------
998 void SAL_CALL
Cell::setPropertyValue( const OUString
& rPropertyName
, const Any
& rValue
) throw(UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
)
1000 OGuard
aGuard( Application::GetSolarMutex() );
1002 if( (mpProperties
== 0) || (GetModel() == 0) )
1003 throw DisposedException();
1005 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(rPropertyName
);
1008 if( (pMap
->nFlags
& PropertyAttribute::READONLY
) != 0 )
1009 throw PropertyVetoException();
1011 switch( pMap
->nWID
)
1013 case OWN_ATTR_STYLE
:
1015 Reference
< XStyle
> xStyle
;
1016 if( !( rValue
>>= xStyle
) )
1017 throw IllegalArgumentException();
1019 SfxUnoStyleSheet
* pStyle
= SfxUnoStyleSheet::getUnoStyleSheet(xStyle
);
1020 SetStyleSheet( pStyle
, sal_True
);
1023 case OWN_ATTR_TABLEBORDER
:
1025 if(rValue
.getValueType() != ::getCppuType((const TableBorder
*)0) )
1028 const TableBorder
* pBorder
= (const TableBorder
* )rValue
.getValue();
1029 if( pBorder
== NULL
)
1032 SvxBoxItem
aBox( SDRATTR_TABLE_BORDER
);
1033 SvxBoxInfoItem
aBoxInfo( SDRATTR_TABLE_BORDER_INNER
);
1034 SvxBorderLine aLine
;
1036 sal_Bool bSet
= lcl_LineToSvxLine(pBorder
->TopLine
, aLine
, false);
1037 aBox
.SetLine(bSet
? &aLine
: 0, BOX_LINE_TOP
);
1038 aBoxInfo
.SetValid(VALID_TOP
, pBorder
->IsTopLineValid
);
1040 bSet
= lcl_LineToSvxLine(pBorder
->BottomLine
, aLine
, false);
1041 aBox
.SetLine(bSet
? &aLine
: 0, BOX_LINE_BOTTOM
);
1042 aBoxInfo
.SetValid(VALID_BOTTOM
, pBorder
->IsBottomLineValid
);
1044 bSet
= lcl_LineToSvxLine(pBorder
->LeftLine
, aLine
, false);
1045 aBox
.SetLine(bSet
? &aLine
: 0, BOX_LINE_LEFT
);
1046 aBoxInfo
.SetValid(VALID_LEFT
, pBorder
->IsLeftLineValid
);
1048 bSet
= lcl_LineToSvxLine(pBorder
->RightLine
, aLine
, false);
1049 aBox
.SetLine(bSet
? &aLine
: 0, BOX_LINE_RIGHT
);
1050 aBoxInfo
.SetValid(VALID_RIGHT
, pBorder
->IsRightLineValid
);
1052 bSet
= lcl_LineToSvxLine(pBorder
->HorizontalLine
, aLine
, false);
1053 aBoxInfo
.SetLine(bSet
? &aLine
: 0, BOXINFO_LINE_HORI
);
1054 aBoxInfo
.SetValid(VALID_HORI
, pBorder
->IsHorizontalLineValid
);
1056 bSet
= lcl_LineToSvxLine(pBorder
->VerticalLine
, aLine
, false);
1057 aBoxInfo
.SetLine(bSet
? &aLine
: 0, BOXINFO_LINE_VERT
);
1058 aBoxInfo
.SetValid(VALID_VERT
, pBorder
->IsVerticalLineValid
);
1060 aBox
.SetDistance(pBorder
->Distance
, false);
1061 aBoxInfo
.SetValid(VALID_DISTANCE
, pBorder
->IsDistanceValid
);
1063 mpProperties
->SetObjectItem(aBox
);
1064 mpProperties
->SetObjectItem(aBoxInfo
);
1067 case OWN_ATTR_FILLBMP_MODE
:
1070 if(!(rValue
>>= eMode
) )
1072 sal_Int32 nMode
= 0;
1073 if(!(rValue
>>= nMode
))
1074 throw IllegalArgumentException();
1076 eMode
= (BitmapMode
)nMode
;
1079 mpProperties
->SetObjectItem( XFillBmpStretchItem( eMode
== BitmapMode_STRETCH
) );
1080 mpProperties
->SetObjectItem( XFillBmpTileItem( eMode
== BitmapMode_REPEAT
) );
1085 SfxItemSet
aSet( GetModel()->GetItemPool(), pMap
->nWID
, pMap
->nWID
);
1086 aSet
.Put(mpProperties
->GetItem(pMap
->nWID
));
1088 bool bSpecial
= false;
1090 switch( pMap
->nWID
)
1092 case XATTR_FILLBITMAP
:
1093 case XATTR_FILLGRADIENT
:
1094 case XATTR_FILLHATCH
:
1095 case XATTR_FILLFLOATTRANSPARENCE
:
1097 case XATTR_LINESTART
:
1098 case XATTR_LINEDASH
:
1100 if( pMap
->nMemberId
== MID_NAME
)
1103 if( rValue
>>= aApiName
)
1105 if( SvxShape::SetFillAttribute( pMap
->nWID
, aApiName
, aSet
, GetModel() ) )
1116 if( !SvxUnoTextRangeBase::SetPropertyValueHelper( aSet
, pMap
, rValue
, aSet
))
1118 if( aSet
.GetItemState( pMap
->nWID
) != SFX_ITEM_SET
)
1120 // Default aus ItemPool holen
1121 if(GetModel()->GetItemPool().IsWhich(pMap
->nWID
))
1122 aSet
.Put(GetModel()->GetItemPool().GetDefaultItem(pMap
->nWID
));
1125 if( aSet
.GetItemState( pMap
->nWID
) == SFX_ITEM_SET
)
1127 mpPropSet
->setPropertyValue( pMap
, rValue
, aSet
);
1132 GetModel()->SetChanged();
1133 mpProperties
->SetMergedItemSetAndBroadcast( aSet
);
1138 throw UnknownPropertyException();
1141 // -----------------------------------------------------------------------------
1143 Any SAL_CALL
Cell::getPropertyValue( const OUString
& PropertyName
) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
1145 OGuard
aGuard( Application::GetSolarMutex() );
1147 if( (mpProperties
== 0) || (GetModel() == 0) )
1148 throw DisposedException();
1150 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(PropertyName
);
1153 switch( pMap
->nWID
)
1156 case OWN_ATTR_HASLEVELS:
1158 return Any( hasLevels() );
1161 case OWN_ATTR_STYLE
:
1163 return Any( Reference
< XStyle
>( dynamic_cast< SfxUnoStyleSheet
* >( GetStyleSheet() ) ) );
1165 case OWN_ATTR_TABLEBORDER
:
1167 const SvxBoxInfoItem
& rBoxInfoItem
= static_cast<const SvxBoxInfoItem
&>(mpProperties
->GetItem(SDRATTR_TABLE_BORDER_INNER
));
1168 const SvxBoxItem
& rBox
= static_cast<const SvxBoxItem
&>(mpProperties
->GetItem(SDRATTR_TABLE_BORDER
));
1170 TableBorder aTableBorder
;
1171 aTableBorder
.TopLine
= lcl_SvxLineToLine(rBox
.GetTop(), false);
1172 aTableBorder
.IsTopLineValid
= rBoxInfoItem
.IsValid(VALID_TOP
);
1173 aTableBorder
.BottomLine
= lcl_SvxLineToLine(rBox
.GetBottom(), false);
1174 aTableBorder
.IsBottomLineValid
= rBoxInfoItem
.IsValid(VALID_BOTTOM
);
1175 aTableBorder
.LeftLine
= lcl_SvxLineToLine(rBox
.GetLeft(), false);
1176 aTableBorder
.IsLeftLineValid
= rBoxInfoItem
.IsValid(VALID_LEFT
);
1177 aTableBorder
.RightLine
= lcl_SvxLineToLine(rBox
.GetRight(), false);
1178 aTableBorder
.IsRightLineValid
= rBoxInfoItem
.IsValid(VALID_RIGHT
);
1179 aTableBorder
.HorizontalLine
= lcl_SvxLineToLine(rBoxInfoItem
.GetHori(), false);
1180 aTableBorder
.IsHorizontalLineValid
= rBoxInfoItem
.IsValid(VALID_HORI
);
1181 aTableBorder
.VerticalLine
= lcl_SvxLineToLine(rBoxInfoItem
.GetVert(), false);
1182 aTableBorder
.IsVerticalLineValid
= rBoxInfoItem
.IsValid(VALID_VERT
);
1183 aTableBorder
.Distance
= rBox
.GetDistance();
1184 aTableBorder
.IsDistanceValid
= rBoxInfoItem
.IsValid(VALID_DISTANCE
);
1186 return Any( aTableBorder
);
1188 case OWN_ATTR_FILLBMP_MODE
:
1190 const XFillBmpStretchItem
& rStretchItem
= static_cast<const XFillBmpStretchItem
&>(mpProperties
->GetItem(XATTR_FILLBMP_STRETCH
));
1191 const XFillBmpTileItem
& rTileItem
= static_cast<const XFillBmpTileItem
&>(mpProperties
->GetItem(XATTR_FILLBMP_TILE
));
1192 if( rTileItem
.GetValue() )
1194 return Any( BitmapMode_REPEAT
);
1196 else if( rStretchItem
.GetValue() )
1198 return Any( BitmapMode_STRETCH
);
1202 return Any( BitmapMode_NO_REPEAT
);
1207 SfxItemSet
aSet( GetModel()->GetItemPool(), pMap
->nWID
, pMap
->nWID
);
1208 aSet
.Put(mpProperties
->GetItem(pMap
->nWID
));
1211 if(!SvxUnoTextRangeBase::GetPropertyValueHelper( aSet
, pMap
, aAny
))
1215 // Default aus ItemPool holen
1216 if(GetModel()->GetItemPool().IsWhich(pMap
->nWID
))
1217 aSet
.Put(GetModel()->GetItemPool().GetDefaultItem(pMap
->nWID
));
1221 aAny
= GetAnyForItem( aSet
, pMap
);
1228 throw UnknownPropertyException();
1231 // -----------------------------------------------------------------------------
1233 void SAL_CALL
Cell::addPropertyChangeListener( const OUString
& /*aPropertyName*/, const Reference
< XPropertyChangeListener
>& /*xListener*/ ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
1237 // -----------------------------------------------------------------------------
1239 void SAL_CALL
Cell::removePropertyChangeListener( const OUString
& /*aPropertyName*/, const Reference
< XPropertyChangeListener
>& /*aListener*/ ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
1243 // -----------------------------------------------------------------------------
1245 void SAL_CALL
Cell::addVetoableChangeListener( const OUString
& /*PropertyName*/, const Reference
< XVetoableChangeListener
>& /*aListener*/ ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
1249 // -----------------------------------------------------------------------------
1251 void SAL_CALL
Cell::removeVetoableChangeListener( const OUString
& /*PropertyName*/, const Reference
< XVetoableChangeListener
>& /*aListener*/ ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
1255 // -----------------------------------------------------------------------------
1256 // XMultiPropertySet
1257 // -----------------------------------------------------------------------------
1259 void SAL_CALL
Cell::setPropertyValues( const Sequence
< OUString
>& aPropertyNames
, const Sequence
< Any
>& aValues
) throw (PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
)
1261 OGuard
aSolarGuard( Application::GetSolarMutex() );
1263 if( (mpProperties
== 0) || (GetModel() == 0) )
1264 throw DisposedException();
1266 const sal_Int32 nCount
= aPropertyNames
.getLength();
1268 const OUString
* pNames
= aPropertyNames
.getConstArray();
1269 const Any
* pValues
= aValues
.getConstArray();
1271 for( sal_Int32 nIdx
= 0; nIdx
< nCount
; nIdx
++, pNames
++, pValues
++ )
1275 setPropertyValue( *pNames
, *pValues
);
1277 catch( UnknownPropertyException
& )
1279 DBG_ERROR("svx::Cell::setPropertyValues(), unknown property!" );
1283 DBG_ERROR("svx::Cell::setPropertyValues(), Exception caught!" );
1288 // -----------------------------------------------------------------------------
1290 Sequence
< Any
> SAL_CALL
Cell::getPropertyValues( const Sequence
< OUString
>& aPropertyNames
) throw (RuntimeException
)
1292 OGuard
aSolarGuard( Application::GetSolarMutex() );
1294 if( (mpProperties
== 0) || (GetModel() == 0) )
1295 throw DisposedException();
1297 const sal_Int32 nCount
= aPropertyNames
.getLength();
1298 const OUString
* pNames
= aPropertyNames
.getConstArray();
1300 Sequence
< Any
> aRet( nCount
);
1301 Any
* pValue
= aRet
.getArray();
1303 for( sal_Int32 nIdx
= 0; nIdx
< nCount
; nIdx
++, pValue
++, pNames
++ )
1307 *pValue
= getPropertyValue( *pNames
);
1309 catch( UnknownPropertyException
& )
1311 DBG_ERROR("svx::Cell::setPropertyValues(), unknown property!" );
1315 DBG_ERROR( "svx::Cell::getPropertyValues(), Exception caught!" );
1322 // -----------------------------------------------------------------------------
1324 void SAL_CALL
Cell::addPropertiesChangeListener( const Sequence
< OUString
>& /*aPropertyNames*/, const Reference
< XPropertiesChangeListener
>& /*xListener*/ ) throw (RuntimeException
)
1328 // -----------------------------------------------------------------------------
1330 void SAL_CALL
Cell::removePropertiesChangeListener( const Reference
< XPropertiesChangeListener
>& /*xListener*/ ) throw (RuntimeException
)
1334 // -----------------------------------------------------------------------------
1336 void SAL_CALL
Cell::firePropertiesChangeEvent( const Sequence
< OUString
>& /*aPropertyNames*/, const Reference
< XPropertiesChangeListener
>& /*xListener*/ ) throw (RuntimeException
)
1340 // -----------------------------------------------------------------------------
1342 // -----------------------------------------------------------------------------
1344 PropertyState SAL_CALL
Cell::getPropertyState( const OUString
& PropertyName
) throw(UnknownPropertyException
, RuntimeException
)
1346 OGuard
aGuard( Application::GetSolarMutex() );
1348 if( (mpProperties
== 0) || (GetModel() == 0) )
1349 throw DisposedException();
1351 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(PropertyName
);
1355 PropertyState eState
;
1356 switch( pMap
->nWID
)
1358 case OWN_ATTR_FILLBMP_MODE
:
1360 const SfxItemSet
& rSet
= mpProperties
->GetMergedItemSet();
1362 const bool bStretch
= rSet
.GetItemState( XATTR_FILLBMP_STRETCH
, false ) == SFX_ITEM_SET
;
1363 const bool bTile
= rSet
.GetItemState( XATTR_FILLBMP_TILE
, false ) == SFX_ITEM_SET
;
1364 if( bStretch
|| bTile
)
1366 eState
= PropertyState_DIRECT_VALUE
;
1370 eState
= PropertyState_DEFAULT_VALUE
;
1374 case OWN_ATTR_HASLEVELS:
1376 return PropertyState_DIRECT_VALUE;
1379 case OWN_ATTR_STYLE
:
1381 return PropertyState_DIRECT_VALUE
;
1383 case OWN_ATTR_TABLEBORDER
:
1385 const SfxItemSet
& rSet
= mpProperties
->GetMergedItemSet();
1386 if( (rSet
.GetItemState( SDRATTR_TABLE_BORDER_INNER
, sal_False
) == SFX_ITEM_DEFAULT
) && (rSet
.GetItemState( SDRATTR_TABLE_BORDER
, sal_False
) == SFX_ITEM_DEFAULT
) )
1387 return PropertyState_DEFAULT_VALUE
;
1389 return PropertyState_DIRECT_VALUE
;
1393 const SfxItemSet
& rSet
= mpProperties
->GetMergedItemSet();
1395 switch( rSet
.GetItemState( pMap
->nWID
, sal_False
) )
1397 case SFX_ITEM_READONLY
:
1399 eState
= PropertyState_DIRECT_VALUE
;
1401 case SFX_ITEM_DEFAULT
:
1402 eState
= PropertyState_DEFAULT_VALUE
;
1404 // case SFX_ITEM_UNKNOWN:
1405 // case SFX_ITEM_DONTCARE:
1406 // case SFX_ITEM_DISABLED:
1408 eState
= PropertyState_AMBIGUOUS_VALUE
;
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((USHORT
)pMap
->nWID
);
1426 if( ( pItem
== NULL
) || ( pItem
->GetName().Len() == 0) )
1427 eState
= PropertyState_DEFAULT_VALUE
;
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).
1435 // same is for fill float transparency
1437 case XATTR_LINESTART
:
1438 case XATTR_FILLFLOATTRANSPARENCE
:
1440 NameOrIndex
* pItem
= (NameOrIndex
*)rSet
.GetItem((USHORT
)pMap
->nWID
);
1441 if( ( pItem
== NULL
) )
1442 eState
= PropertyState_DEFAULT_VALUE
;
1451 throw UnknownPropertyException();
1454 // -----------------------------------------------------------------------------
1456 Sequence
< PropertyState
> SAL_CALL
Cell::getPropertyStates( const Sequence
< OUString
>& aPropertyName
) throw(UnknownPropertyException
, RuntimeException
)
1458 OGuard
aGuard( Application::GetSolarMutex() );
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
);
1478 *pState
= PropertyState_AMBIGUOUS_VALUE
;
1485 // -----------------------------------------------------------------------------
1487 void SAL_CALL
Cell::setPropertyToDefault( const OUString
& PropertyName
) throw(UnknownPropertyException
, RuntimeException
)
1489 OGuard
aGuard( Application::GetSolarMutex() );
1491 if( (mpProperties
== 0) || (GetModel() == 0) )
1492 throw DisposedException();
1494 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(PropertyName
);
1497 switch( pMap
->nWID
)
1499 case OWN_ATTR_FILLBMP_MODE
:
1501 mpProperties
->ClearObjectItem( XATTR_FILLBMP_STRETCH
);
1502 mpProperties
->ClearObjectItem( XATTR_FILLBMP_TILE
);
1505 // case OWN_ATTR_HASLEVELS:
1506 case OWN_ATTR_STYLE
:
1509 case OWN_ATTR_TABLEBORDER
:
1511 mpProperties
->ClearObjectItem( SDRATTR_TABLE_BORDER_INNER
);
1512 mpProperties
->ClearObjectItem( SDRATTR_TABLE_BORDER
);
1518 mpProperties
->ClearObjectItem( pMap
->nWID
);
1522 GetModel()->SetChanged();
1525 throw UnknownPropertyException();
1528 // -----------------------------------------------------------------------------
1530 Any SAL_CALL
Cell::getPropertyDefault( const OUString
& aPropertyName
) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
1532 OGuard
aGuard( Application::GetSolarMutex() );
1534 if( (mpProperties
== 0) || (GetModel() == 0) )
1535 throw DisposedException();
1537 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(aPropertyName
);
1540 switch( pMap
->nWID
)
1542 case OWN_ATTR_FILLBMP_MODE
:
1543 return Any( BitmapMode_NO_REPEAT
);
1546 case OWN_ATTR_HASLEVELS:
1547 return Any( sal_False );
1549 case OWN_ATTR_STYLE
:
1551 Reference
< XStyle
> xStyle
;
1552 return Any( xStyle
);
1555 case OWN_ATTR_TABLEBORDER
:
1557 TableBorder aBorder
;
1558 return Any( aBorder
);
1563 if( GetModel()->GetItemPool().IsWhich(pMap
->nWID
) )
1565 SfxItemSet
aSet( GetModel()->GetItemPool(), pMap
->nWID
, pMap
->nWID
);
1566 aSet
.Put(GetModel()->GetItemPool().GetDefaultItem(pMap
->nWID
));
1567 return GetAnyForItem( aSet
, pMap
);
1572 throw UnknownPropertyException();
1575 // -----------------------------------------------------------------------------
1576 // XMultiPropertyStates
1577 // -----------------------------------------------------------------------------
1579 void SAL_CALL
Cell::setAllPropertiesToDefault( ) throw (RuntimeException
)
1582 delete mpProperties
;
1583 mpProperties
= new sdr::properties::CellProperties( static_cast< SdrTableObj
& >( GetObject() ), this );
1585 SdrOutliner
& rOutliner
= GetObject().ImpGetDrawOutliner();
1587 OutlinerParaObject
* pParaObj
= GetOutlinerParaObject();
1590 rOutliner
.SetText(*pParaObj
);
1591 sal_uInt32
nParaCount(rOutliner
.GetParagraphCount());
1595 ESelection
aSelection( 0, 0, EE_PARA_ALL
, EE_PARA_ALL
);
1596 rOutliner
.RemoveAttribs(aSelection
, sal_True
, 0);
1598 OutlinerParaObject
* pTemp
= rOutliner
.CreateParaObject(0, (sal_uInt16
)nParaCount
);
1601 SetOutlinerParaObject(pTemp
);
1606 // -----------------------------------------------------------------------------
1608 void SAL_CALL
Cell::setPropertiesToDefault( const Sequence
< OUString
>& aPropertyNames
) throw (UnknownPropertyException
, RuntimeException
)
1610 sal_Int32 nCount
= aPropertyNames
.getLength();
1611 const OUString
* pName
= aPropertyNames
.getConstArray();
1614 setPropertyToDefault( *pName
++ );
1617 // -----------------------------------------------------------------------------
1619 Sequence
< Any
> SAL_CALL
Cell::getPropertyDefaults( const Sequence
< OUString
>& aPropertyNames
) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
1621 sal_Int32 nCount
= aPropertyNames
.getLength();
1622 Sequence
< Any
> aDefaults( nCount
);
1623 Any
* pDefaults
= aDefaults
.getArray();
1624 const OUString
* pName
= aPropertyNames
.getConstArray();
1627 *pDefaults
++ = getPropertyDefault( *pName
++ );
1632 // -----------------------------------------------------------------------------
1634 // -----------------------------------------------------------------------------
1636 void SAL_CALL
Cell::setFastPropertyValue( sal_Int32 nHandle
, const Any
& aValue
) throw (UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
)
1640 throw UnknownPropertyException();
1643 // -----------------------------------------------------------------------------
1644 // TODO: Refactor this method!
1645 Any SAL_CALL
Cell::getFastPropertyValue( sal_Int32 nHandle
) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
1648 throw UnknownPropertyException();
1651 // -----------------------------------------------------------------------------
1653 // -----------------------------------------------------------------------------
1655 void SAL_CALL
Cell::insertTextContent( const Reference
< XTextRange
>& xRange
, const Reference
< XTextContent
>& xContent
, sal_Bool bAbsorb
) throw (IllegalArgumentException
, RuntimeException
)
1657 SvxUnoTextBase::insertTextContent( xRange
, xContent
, bAbsorb
);
1661 // -----------------------------------------------------------------------------
1663 void SAL_CALL
Cell::removeTextContent( const Reference
< XTextContent
>& xContent
) throw (NoSuchElementException
, RuntimeException
)
1665 SvxUnoTextBase::removeTextContent( xContent
);
1669 // -----------------------------------------------------------------------------
1671 // -----------------------------------------------------------------------------
1673 Reference
< XTextCursor
> SAL_CALL
Cell::createTextCursor( ) throw (RuntimeException
)
1675 return SvxUnoTextBase::createTextCursor();
1678 // -----------------------------------------------------------------------------
1680 Reference
< XTextCursor
> SAL_CALL
Cell::createTextCursorByRange( const Reference
< XTextRange
>& aTextPosition
) throw (RuntimeException
)
1682 return SvxUnoTextBase::createTextCursorByRange( aTextPosition
);
1685 // -----------------------------------------------------------------------------
1687 void SAL_CALL
Cell::insertString( const Reference
< XTextRange
>& xRange
, const OUString
& aString
, sal_Bool bAbsorb
) throw (RuntimeException
)
1689 SvxUnoTextBase::insertString( xRange
, aString
, bAbsorb
);
1693 // -----------------------------------------------------------------------------
1695 void SAL_CALL
Cell::insertControlCharacter( const Reference
< XTextRange
>& xRange
, sal_Int16 nControlCharacter
, sal_Bool bAbsorb
) throw (IllegalArgumentException
, RuntimeException
)
1697 SvxUnoTextBase::insertControlCharacter( xRange
, nControlCharacter
, bAbsorb
);
1701 // -----------------------------------------------------------------------------
1703 // -----------------------------------------------------------------------------
1705 Reference
< XText
> SAL_CALL
Cell::getText( ) throw (RuntimeException
)
1707 return SvxUnoTextBase::getText();
1710 // -----------------------------------------------------------------------------
1712 Reference
< XTextRange
> SAL_CALL
Cell::getStart( ) throw (RuntimeException
)
1714 return SvxUnoTextBase::getStart();
1717 // -----------------------------------------------------------------------------
1719 Reference
< XTextRange
> SAL_CALL
Cell::getEnd( ) throw (RuntimeException
)
1721 return SvxUnoTextBase::getEnd();
1724 // -----------------------------------------------------------------------------
1726 OUString SAL_CALL
Cell::getString( ) throw (RuntimeException
)
1728 maSelection
.nStartPara
= 0xffff;
1729 return SvxUnoTextBase::getString();
1732 // -----------------------------------------------------------------------------
1734 void SAL_CALL
Cell::setString( const OUString
& aString
) throw (RuntimeException
)
1736 SvxUnoTextBase::setString( aString
);
1741 void SAL_CALL
Cell::disposing( const EventObject
& /*Source*/ ) throw (RuntimeException
)
1747 static OUString
getCellName( sal_Int32 nCol
, sal_Int32 nRow
)
1749 rtl::OUStringBuffer aBuf
;
1754 aBuf
.append( static_cast<sal_Unicode
>( 'A' +
1755 static_cast<sal_uInt16
>(nCol
)));
1758 aBuf
.append( static_cast<sal_Unicode
>( 'A' +
1759 (static_cast<sal_uInt16
>(nCol
) / 26) - 1));
1760 aBuf
.append( static_cast<sal_Unicode
>( 'A' +
1761 (static_cast<sal_uInt16
>(nCol
) % 26)));
1769 sal_Int32 nC
= nCol
% 26;
1770 aStr
+= static_cast<sal_Unicode
>( 'A' +
1771 static_cast<sal_uInt16
>(nC
));
1773 nCol
= nCol
/ 26 - 1;
1775 aStr
+= static_cast<sal_Unicode
>( 'A' +
1776 static_cast<sal_uInt16
>(nCol
));
1780 aBuf
.append( OUString::valueOf(nRow
+1) );
1781 return aBuf
.makeStringAndClear();
1784 OUString
Cell::getName()
1788 if( mxTable
.is() ) try
1790 Reference
< XCell
> xThis( static_cast< XCell
* >( this ) );
1792 sal_Int32 nRowCount
= mxTable
->getRowCount();
1793 sal_Int32 nColCount
= mxTable
->getColumnCount();
1794 for( sal_Int32 nRow
= 0; nRow
< nRowCount
; nRow
++ )
1796 for( sal_Int32 nCol
= 0; nCol
< nColCount
; nCol
++ )
1798 Reference
< XCell
> xCell( mxTable
->getCellByPosition( nCol
, nRow
) );
1799 if( xCell
== xThis
)
1801 return getCellName( nCol
, nRow
);