1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <o3tl/any.hxx>
32 #include <o3tl/make_unique.hxx>
33 #include <svl/style.hxx>
34 #include <svl/itemset.hxx>
36 #include <vcl/svapp.hxx>
37 #include <libxml/xmlwriter.h>
39 #include <sdr/properties/textproperties.hxx>
40 #include <editeng/outlobj.hxx>
41 #include <editeng/writingmodeitem.hxx>
42 #include <svx/svdotable.hxx>
43 #include <svx/svdoutl.hxx>
44 #include <svx/unoshtxt.hxx>
45 #include <svx/svdmodel.hxx>
47 #include <getallcharpropids.hxx>
48 #include "tableundo.hxx"
50 #include <svx/unoshprp.hxx>
51 #include <svx/unoshape.hxx>
52 #include <editeng/editobj.hxx>
53 #include <editeng/boxitem.hxx>
54 #include <editeng/charrotateitem.hxx>
55 #include <svx/xflbstit.hxx>
56 #include <svx/xflbmtit.hxx>
57 #include <svx/svdpool.hxx>
60 using ::editeng::SvxBorderLine
;
61 using namespace ::com::sun::star::uno
;
62 using namespace ::com::sun::star::beans
;
63 using namespace ::com::sun::star::lang
;
64 using namespace ::com::sun::star::text
;
65 using namespace ::com::sun::star::table
;
66 using namespace ::com::sun::star::drawing
;
67 using namespace ::com::sun::star::style
;
68 using namespace ::com::sun::star::container
;
71 static const SvxItemPropertySet
* ImplGetSvxCellPropertySet()
73 // property map for an outliner text
74 static const SfxItemPropertyMapEntry aSvxCellPropertyMap
[] =
77 // { "HasLevels", OWN_ATTR_HASLEVELS, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY, 0},
78 { OUString("Style"), OWN_ATTR_STYLE
, cppu::UnoType
< css::style::XStyle
>::get(), css::beans::PropertyAttribute::MAYBEVOID
, 0},
79 { OUString(UNO_NAME_TEXT_WRITINGMODE
), SDRATTR_TEXTDIRECTION
, cppu::UnoType
<css::text::WritingMode
>::get(), 0, 0},
80 { OUString(UNO_NAME_TEXT_HORZADJUST
), SDRATTR_TEXT_HORZADJUST
, cppu::UnoType
<css::drawing::TextHorizontalAdjust
>::get(), 0, 0},
81 { OUString(UNO_NAME_TEXT_LEFTDIST
), SDRATTR_TEXT_LEFTDIST
, cppu::UnoType
<sal_Int32
>::get(), 0, SFX_METRIC_ITEM
},
82 { OUString(UNO_NAME_TEXT_LOWERDIST
), SDRATTR_TEXT_LOWERDIST
, cppu::UnoType
<sal_Int32
>::get(), 0, SFX_METRIC_ITEM
},
83 { OUString(UNO_NAME_TEXT_RIGHTDIST
), SDRATTR_TEXT_RIGHTDIST
, cppu::UnoType
<sal_Int32
>::get(), 0, SFX_METRIC_ITEM
},
84 { OUString(UNO_NAME_TEXT_UPPERDIST
), SDRATTR_TEXT_UPPERDIST
, cppu::UnoType
<sal_Int32
>::get(), 0, SFX_METRIC_ITEM
},
85 { OUString(UNO_NAME_TEXT_VERTADJUST
), SDRATTR_TEXT_VERTADJUST
, cppu::UnoType
<css::drawing::TextVerticalAdjust
>::get(), 0, 0},
86 { OUString(UNO_NAME_TEXT_WORDWRAP
), SDRATTR_TEXT_WORDWRAP
, cppu::UnoType
<bool>::get(), 0, 0},
88 { OUString("TableBorder"), OWN_ATTR_TABLEBORDER
, cppu::UnoType
<TableBorder
>::get(), 0, 0 },
89 { OUString("TopBorder"), SDRATTR_TABLE_BORDER
, cppu::UnoType
<BorderLine
>::get(), 0, TOP_BORDER
},
90 { OUString("BottomBorder"), SDRATTR_TABLE_BORDER
, cppu::UnoType
<BorderLine
>::get(), 0, BOTTOM_BORDER
},
91 { OUString("LeftBorder"), SDRATTR_TABLE_BORDER
, cppu::UnoType
<BorderLine
>::get(), 0, LEFT_BORDER
},
92 { OUString("RightBorder"), SDRATTR_TABLE_BORDER
, cppu::UnoType
<BorderLine
>::get(), 0, RIGHT_BORDER
},
93 { OUString("RotateAngle"), SDRATTR_TABLE_TEXT_ROTATION
, cppu::UnoType
<sal_Int32
>::get(), 0, 0 },
95 SVX_UNOEDIT_OUTLINER_PROPERTIES
,
96 SVX_UNOEDIT_CHAR_PROPERTIES
,
97 SVX_UNOEDIT_PARA_PROPERTIES
,
98 { OUString(), 0, css::uno::Type(), 0, 0 }
101 static SvxItemPropertySet
aSvxCellPropertySet( aSvxCellPropertyMap
, SdrObject::GetGlobalDrawObjectItemPool() );
102 return &aSvxCellPropertySet
;
108 class CellTextProvider
: public svx::ITextProvider
111 explicit CellTextProvider(const sdr::table::CellRef
& rCell
);
112 virtual ~CellTextProvider();
115 virtual sal_Int32
getTextCount() const override
;
116 virtual SdrText
* getText(sal_Int32 nIndex
) const override
;
119 const sdr::table::CellRef m_xCell
;
122 CellTextProvider::CellTextProvider(const sdr::table::CellRef
& rCell
)
127 CellTextProvider::~CellTextProvider()
131 sal_Int32
CellTextProvider::getTextCount() const
136 SdrText
* CellTextProvider::getText(sal_Int32 nIndex
) const
140 return m_xCell
.get();
149 class CellProperties
: public TextProperties
152 // create a new itemset
153 std::unique_ptr
<SfxItemSet
> CreateObjectSpecificItemSet(SfxItemPool
& rPool
) override
;
155 const svx::ITextProvider
& getTextProvider() const override
;
159 CellProperties(SdrObject
& rObj
, sdr::table::Cell
* pCell
);
161 // constructor for copying, but using new object
162 CellProperties(const CellProperties
& rProps
, SdrObject
& rObj
, sdr::table::Cell
* pCell
);
164 // Clone() operator, normally just calls the local copy constructor
165 BaseProperties
& Clone(SdrObject
& rObj
) const override
;
167 void ForceDefaultAttributes() override
;
169 void ItemSetChanged(const SfxItemSet
& rSet
) override
;
171 void ItemChange(const sal_uInt16 nWhich
, const SfxPoolItem
* pNewItem
= nullptr) override
;
173 sdr::table::CellRef mxCell
;
176 const CellTextProvider maTextProvider
;
179 // create a new itemset
180 std::unique_ptr
<SfxItemSet
> CellProperties::CreateObjectSpecificItemSet(SfxItemPool
& rPool
)
182 return o3tl::make_unique
<SfxItemSet
>(rPool
,
184 // range from SdrAttrObj
185 svl::Items
<SDRATTR_START
, SDRATTR_SHADOW_LAST
,
186 SDRATTR_MISC_FIRST
, SDRATTR_MISC_LAST
,
187 SDRATTR_TEXTDIRECTION
, SDRATTR_TEXTDIRECTION
,
189 // range for SdrTableObj
190 SDRATTR_TABLE_FIRST
, SDRATTR_TABLE_LAST
,
192 // range from SdrTextObj
193 EE_ITEMS_START
, EE_ITEMS_END
>{});
196 const svx::ITextProvider
& CellProperties::getTextProvider() const
198 return maTextProvider
;
201 CellProperties::CellProperties(SdrObject
& rObj
, sdr::table::Cell
* pCell
)
202 : TextProperties(rObj
)
204 , maTextProvider(mxCell
)
208 CellProperties::CellProperties(const CellProperties
& rProps
, SdrObject
& rObj
, sdr::table::Cell
* pCell
)
209 : TextProperties(rProps
, rObj
)
211 , maTextProvider(mxCell
)
215 BaseProperties
& CellProperties::Clone(SdrObject
& rObj
) const
217 OSL_FAIL("CellProperties::Clone(), does not work yet!");
218 return *(new CellProperties(*this, rObj
,nullptr));
221 void CellProperties::ForceDefaultAttributes()
225 void CellProperties::ItemSetChanged(const SfxItemSet
& rSet
)
227 SdrTextObj
& rObj
= static_cast<SdrTextObj
&>(GetSdrObject());
231 OutlinerParaObject
* pParaObj
= mxCell
->GetEditOutlinerParaObject();
233 const bool bOwnParaObj
= pParaObj
!= nullptr;
235 if( pParaObj
== nullptr )
236 pParaObj
= mxCell
->GetOutlinerParaObject();
240 // handle outliner attributes
241 Outliner
* pOutliner
= nullptr;
243 if(mxCell
->IsTextEditActive())
245 pOutliner
= rObj
.GetTextEditOutliner();
249 pOutliner
= &rObj
.ImpGetDrawOutliner();
250 pOutliner
->SetText(*pParaObj
);
253 sal_Int32
nParaCount(pOutliner
->GetParagraphCount());
255 // if the user sets character attributes to the complete
256 // cell we want to remove all hard set character attributes
257 // with same which ids from the text
258 std::vector
<sal_uInt16
> aCharWhichIds(GetAllCharPropIds(rSet
));
260 for(sal_Int32 nPara
= 0; nPara
< nParaCount
; nPara
++)
262 SfxItemSet
aSet(pOutliner
->GetParaAttribs(nPara
));
265 for (std::vector
<sal_uInt16
>::const_iterator aI
= aCharWhichIds
.begin(); aI
!= aCharWhichIds
.end(); ++aI
)
267 pOutliner
->RemoveCharAttribs(nPara
, *aI
);
270 pOutliner
->SetParaAttribs(nPara
, aSet
);
273 if(!mxCell
->IsTextEditActive())
280 SfxItemSet
aNewSet(pOutliner
->GetParaAttribs(0));
281 mpItemSet
->Put(aNewSet
);
284 OutlinerParaObject
* pTemp
= pOutliner
->CreateParaObject(0, nParaCount
);
286 mxCell
->SetOutlinerParaObject(pTemp
);
295 AttributeProperties::ItemSetChanged(rSet
);
298 mxCell
->notifyModified();
301 void CellProperties::ItemChange(const sal_uInt16 nWhich
, const SfxPoolItem
* pNewItem
)
303 if(pNewItem
&& (SDRATTR_TEXTDIRECTION
== nWhich
))
305 bool bVertical(css::text::WritingMode_TB_RL
== static_cast<const SvxWritingModeItem
*>(pNewItem
)->GetValue());
307 sdr::table::SdrTableObj
& rObj
= static_cast<sdr::table::SdrTableObj
&>(GetSdrObject());
308 rObj
.SetVerticalWriting(bVertical
);
310 // Set a cell vertical property
311 OutlinerParaObject
* pParaObj
= mxCell
->GetEditOutlinerParaObject();
313 const bool bOwnParaObj
= pParaObj
!= nullptr;
315 if( pParaObj
== nullptr )
316 pParaObj
= mxCell
->GetOutlinerParaObject();
320 pParaObj
->SetVertical(bVertical
);
327 if (pNewItem
&& (SDRATTR_TABLE_TEXT_ROTATION
== nWhich
))
329 const SvxTextRotateItem
* pRotateItem
= static_cast<const SvxTextRotateItem
*>(pNewItem
);
331 // Set a cell vertical property
332 OutlinerParaObject
* pParaObj
= mxCell
->GetEditOutlinerParaObject();
334 const bool bOwnParaObj
= pParaObj
!= nullptr;
336 if (pParaObj
== nullptr)
337 pParaObj
= mxCell
->GetOutlinerParaObject();
341 pParaObj
->SetVertical(pRotateItem
->IsVertical(), pRotateItem
->IsTopToBottom());
347 // Change autogrow direction
348 SdrTextObj
& rObj
= static_cast<SdrTextObj
&>(GetSdrObject());
350 // rescue object size
351 tools::Rectangle aObjectRect
= rObj
.GetSnapRect();
353 const SfxItemSet
& rSet
= rObj
.GetObjectItemSet();
354 bool bAutoGrowWidth
= rSet
.Get(SDRATTR_TEXT_AUTOGROWWIDTH
).GetValue();
355 bool bAutoGrowHeight
= rSet
.Get(SDRATTR_TEXT_AUTOGROWHEIGHT
).GetValue();
357 // prepare ItemSet to set exchanged width and height items
358 SfxItemSet
aNewSet(*rSet
.GetPool(),
359 svl::Items
<SDRATTR_TEXT_AUTOGROWHEIGHT
, SDRATTR_TEXT_AUTOGROWHEIGHT
>{});
362 aNewSet
.Put(makeSdrTextAutoGrowWidthItem(bAutoGrowHeight
));
363 aNewSet
.Put(makeSdrTextAutoGrowHeightItem(bAutoGrowWidth
));
364 rObj
.SetObjectItemSet(aNewSet
);
366 // restore object size
367 rObj
.SetSnapRect(aObjectRect
);
371 AttributeProperties::ItemChange( nWhich
, pNewItem
);
374 } // end of namespace properties
375 } // end of namespace sdr
377 namespace sdr
{ namespace table
{
383 rtl::Reference
< Cell
> Cell::create( SdrTableObj
& rTableObj
)
385 rtl::Reference
< Cell
> xCell( new Cell( rTableObj
, nullptr ) );
386 if( xCell
->mxTable
.is() )
388 Reference
< XEventListener
> xListener( xCell
.get() );
389 xCell
->mxTable
->addEventListener( xListener
);
395 Cell::Cell( SdrTableObj
& rTableObj
, OutlinerParaObject
* pOutlinerParaObject
)
396 : SdrText( rTableObj
, pOutlinerParaObject
)
397 , SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
398 , mpPropSet( ImplGetSvxCellPropertySet() )
399 , mpProperties( new sdr::properties::CellProperties( rTableObj
, this ) )
400 , mnCellContentType( CellContentType_EMPTY
)
406 , mxTable( rTableObj
.getTable() )
408 if( rTableObj
.GetModel() )
409 SetModel( rTableObj
.GetModel() );
413 Cell::~Cell() throw()
425 Reference
< XEventListener
> xThis( this );
426 mxTable
->removeEventListener( xThis
);
430 OSL_FAIL("Cell::dispose(), exception caught!");
438 mpProperties
= nullptr;
440 SetOutlinerParaObject( nullptr );
444 void Cell::SetModel(SdrModel
* pNewModel
)
446 SvxTextEditSource
* pTextEditSource
= dynamic_cast< SvxTextEditSource
* >( GetEditSource() );
447 if( (GetModel() != pNewModel
) || ( pNewModel
&& !pTextEditSource
) )
451 SfxItemPool
* pItemPool
= mpProperties
->GetObjectItemSet().GetPool();
453 // test for correct pool in ItemSet; move to new pool if necessary
454 if( pNewModel
&& pItemPool
&& pItemPool
!= &pNewModel
->GetItemPool())
455 mpProperties
->MoveToItemPool(pItemPool
, &pNewModel
->GetItemPool(), pNewModel
);
458 if( pTextEditSource
)
460 pTextEditSource
->ChangeModel( pNewModel
);
464 SetEditSource( new SvxTextEditSource( &GetObject(), this ) );
467 SetStyleSheet( nullptr, true );
468 SdrText::SetModel( pNewModel
);
469 ForceOutlinerParaObject( OutlinerMode::TextObject
);
474 void Cell::merge( sal_Int32 nColumnSpan
, sal_Int32 nRowSpan
)
476 if ((mnColSpan
!= nColumnSpan
) || (mnRowSpan
!= nRowSpan
) || mbMerged
)
478 mnColSpan
= nColumnSpan
;
479 mnRowSpan
= nRowSpan
;
486 void Cell::mergeContent( const CellRef
& xSourceCell
)
488 SdrTableObj
& rTableObj
= dynamic_cast< SdrTableObj
& >( GetObject() );
490 if( xSourceCell
->hasText() )
492 SdrOutliner
& rOutliner
=rTableObj
.ImpGetDrawOutliner();
493 rOutliner
.SetUpdateMode(true);
497 rOutliner
.SetText(*GetOutlinerParaObject());
498 rOutliner
.AddText(*xSourceCell
->GetOutlinerParaObject());
502 rOutliner
.SetText(*xSourceCell
->GetOutlinerParaObject());
505 SetOutlinerParaObject( rOutliner
.CreateParaObject() );
507 xSourceCell
->SetOutlinerParaObject(rOutliner
.CreateParaObject());
509 SetStyleSheet( GetStyleSheet(), true );
514 void Cell::cloneFrom( const CellRef
& xCell
)
518 replaceContentAndFormating( xCell
);
520 mnCellContentType
= xCell
->mnCellContentType
;
522 msFormula
= xCell
->msFormula
;
523 mfValue
= xCell
->mfValue
;
524 mnError
= xCell
->mnError
;
526 mbMerged
= xCell
->mbMerged
;
527 mnRowSpan
= xCell
->mnRowSpan
;
528 mnColSpan
= xCell
->mnColSpan
;
534 void Cell::replaceContentAndFormating( const CellRef
& xSourceCell
)
536 if( xSourceCell
.is() && mpProperties
)
538 mpProperties
->SetMergedItemSet( xSourceCell
->GetObjectItemSet() );
539 SetOutlinerParaObject( new OutlinerParaObject(*xSourceCell
->GetOutlinerParaObject()) );
541 SdrTableObj
& rTableObj
= dynamic_cast< SdrTableObj
& >( GetObject() );
542 SdrTableObj
& rSourceTableObj
= dynamic_cast< SdrTableObj
& >( xSourceCell
->GetObject() );
544 if(rSourceTableObj
.GetModel() != rTableObj
.GetModel())
546 SetStyleSheet( nullptr, true );
552 void Cell::setMerged()
562 void Cell::copyFormatFrom( const CellRef
& xSourceCell
)
564 if( xSourceCell
.is() && mpProperties
)
566 mpProperties
->SetMergedItemSet( xSourceCell
->GetObjectItemSet() );
568 SdrTableObj
& rTableObj
= dynamic_cast< SdrTableObj
& >( GetObject() );
569 SdrTableObj
& rSourceTableObj
= dynamic_cast< SdrTableObj
& >( xSourceCell
->GetObject() );
571 if(rSourceTableObj
.GetModel() != rTableObj
.GetModel())
573 SetStyleSheet( nullptr, true );
581 void Cell::notifyModified()
584 mxTable
->setModified( true );
588 // SdrTextShape proxy
591 bool Cell::IsActiveCell()
593 bool isActive
= false;
594 SdrTableObj
& rTableObj
= dynamic_cast< SdrTableObj
& >( GetObject() );
595 if( rTableObj
.getActiveCell().get() == this )
601 bool Cell::IsTextEditActive()
603 bool isActive
= false;
604 SdrTableObj
& rTableObj
= dynamic_cast< SdrTableObj
& >( GetObject() );
605 if(rTableObj
.getActiveCell().get() == this )
607 OutlinerParaObject
* pParaObj
= rTableObj
.GetEditOutlinerParaObject();
608 if( pParaObj
!= nullptr )
618 bool Cell::hasText() const
620 OutlinerParaObject
* pParaObj
= GetOutlinerParaObject();
623 const EditTextObject
& rTextObj
= pParaObj
->GetTextObject();
624 if( rTextObj
.GetParagraphCount() >= 1 )
626 if( rTextObj
.GetParagraphCount() == 1 )
628 if( rTextObj
.GetText(0).isEmpty() )
639 OutlinerParaObject
* Cell::GetEditOutlinerParaObject() const
641 SdrTableObj
& rTableObj
= dynamic_cast< SdrTableObj
& >( GetObject() );
642 if( rTableObj
.getActiveCell().get() == this )
643 return rTableObj
.GetEditOutlinerParaObject();
648 void Cell::SetStyleSheet( SfxStyleSheet
* pStyleSheet
, bool bDontRemoveHardAttr
)
650 // only allow cell styles for cells
651 if( pStyleSheet
&& pStyleSheet
->GetFamily() != SfxStyleFamily::Frame
)
654 if( mpProperties
&& (mpProperties
->GetStyleSheet() != pStyleSheet
) )
656 mpProperties
->SetStyleSheet( pStyleSheet
, bDontRemoveHardAttr
);
661 const SfxItemSet
& Cell::GetObjectItemSet()
665 return mpProperties
->GetObjectItemSet();
669 OSL_FAIL("Cell::GetObjectItemSet(), called without properties!");
670 return GetObject().GetObjectItemSet();
674 void Cell::SetObjectItem(const SfxPoolItem
& rItem
)
678 mpProperties
->SetObjectItem( rItem
);
683 void Cell::SetMergedItem(const SfxPoolItem
& rItem
)
685 SetObjectItem(rItem
);
688 SfxStyleSheet
* Cell::GetStyleSheet() const
691 return mpProperties
->GetStyleSheet();
696 void Cell::TakeTextAnchorRect(tools::Rectangle
& rAnchorRect
) const
698 rAnchorRect
.Left() = maCellRect
.Left() + GetTextLeftDistance();
699 rAnchorRect
.Right() = maCellRect
.Right() - GetTextRightDistance();
700 rAnchorRect
.Top() = maCellRect
.Top() + GetTextUpperDistance();
701 rAnchorRect
.Bottom() = maCellRect
.Bottom() - GetTextLowerDistance();
705 const SfxItemSet
& Cell::GetItemSet() const
707 return mpProperties
->GetObjectItemSet();
711 void Cell::SetMergedItemSetAndBroadcast(const SfxItemSet
& rSet
, bool bClearAllItems
)
715 mpProperties
->SetMergedItemSetAndBroadcast(rSet
, bClearAllItems
);
721 sal_Int32
Cell::getMinimumWidth()
723 return GetTextLeftDistance() + GetTextRightDistance() + 100;
727 sal_Int32
Cell::getMinimumHeight()
732 SdrTableObj
& rTableObj
= dynamic_cast< SdrTableObj
& >( GetObject() );
733 sal_Int32 nMinimumHeight
= 0;
735 tools::Rectangle aTextRect
;
736 TakeTextAnchorRect( aTextRect
);
737 Size
aSize( aTextRect
.GetSize() );
738 aSize
.Height()=0x0FFFFFFF;
740 SdrOutliner
* pEditOutliner
= rTableObj
.GetCellTextEditOutliner( *this );
743 pEditOutliner
->SetMaxAutoPaperSize(aSize
);
744 nMinimumHeight
= pEditOutliner
->GetTextHeight()+1;
748 Outliner
& rOutliner
=rTableObj
.ImpGetDrawOutliner();
749 rOutliner
.SetPaperSize(aSize
);
750 rOutliner
.SetUpdateMode(true);
751 ForceOutlinerParaObject( OutlinerMode::TextObject
);
753 if( GetOutlinerParaObject() )
755 rOutliner
.SetText(*GetOutlinerParaObject());
757 nMinimumHeight
=rOutliner
.GetTextHeight()+1;
761 nMinimumHeight
+= GetTextUpperDistance() + GetTextLowerDistance();
762 return nMinimumHeight
;
766 long Cell::GetTextLeftDistance() const
768 return GetItemSet().Get(SDRATTR_TEXT_LEFTDIST
).GetValue();
772 long Cell::GetTextRightDistance() const
774 return GetItemSet().Get(SDRATTR_TEXT_RIGHTDIST
).GetValue();
778 long Cell::GetTextUpperDistance() const
780 return GetItemSet().Get(SDRATTR_TEXT_UPPERDIST
).GetValue();
784 long Cell::GetTextLowerDistance() const
786 return GetItemSet().Get(SDRATTR_TEXT_LOWERDIST
).GetValue();
790 SdrTextVertAdjust
Cell::GetTextVerticalAdjust() const
792 return GetItemSet().Get(SDRATTR_TEXT_VERTADJUST
).GetValue();
796 SdrTextHorzAdjust
Cell::GetTextHorizontalAdjust() const
798 return GetItemSet().Get(SDRATTR_TEXT_HORZADJUST
).GetValue();
802 void Cell::SetOutlinerParaObject( OutlinerParaObject
* pTextObject
)
804 SdrText::SetOutlinerParaObject( pTextObject
);
805 maSelection
.nStartPara
= EE_PARA_MAX_COUNT
;
807 if( pTextObject
== nullptr )
808 ForceOutlinerParaObject( OutlinerMode::TextObject
);
814 SdrObject
& rObj
= GetObject();
815 if( rObj
.IsInserted() && GetModel() && GetModel()->IsUndoEnabled() )
817 CellRef
xCell( this );
818 GetModel()->AddUndo( new CellUndo( &rObj
, xCell
) );
820 // Undo action for the after-text-edit-ended stack.
821 SdrTableObj
* pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(&rObj
);
822 if (pTableObj
&& pTableObj
->IsTextEditActive())
823 pTableObj
->AddUndo(new CellUndo(pTableObj
, xCell
));
828 sdr::properties::TextProperties
* Cell::CloneProperties( sdr::properties::TextProperties
const * pProperties
, SdrObject
& rNewObj
, Cell
& rNewCell
)
831 return new sdr::properties::CellProperties( *static_cast<sdr::properties::CellProperties
const *>(pProperties
), rNewObj
, &rNewCell
);
837 sdr::properties::TextProperties
* Cell::CloneProperties( SdrObject
& rNewObj
, Cell
& rNewCell
)
839 return CloneProperties(mpProperties
,rNewObj
,rNewCell
);
846 Any SAL_CALL
Cell::queryInterface( const Type
& rType
)
848 if( rType
== cppu::UnoType
<XMergeableCell
>::get() )
849 return Any( Reference
< XMergeableCell
>( this ) );
851 if( rType
== cppu::UnoType
<XCell
>::get() )
852 return Any( Reference
< XCell
>( this ) );
854 if( rType
== cppu::UnoType
<XLayoutConstrains
>::get() )
855 return Any( Reference
< XLayoutConstrains
>( this ) );
857 if( rType
== cppu::UnoType
<XEventListener
>::get() )
858 return Any( Reference
< XEventListener
>( this ) );
860 Any
aRet( SvxUnoTextBase::queryAggregation( rType
) );
861 if( aRet
.hasValue() )
864 return ::cppu::OWeakObject::queryInterface( rType
);
868 void SAL_CALL
Cell::acquire() throw ()
870 ::cppu::OWeakObject::acquire();
874 void SAL_CALL
Cell::release() throw ()
876 ::cppu::OWeakObject::release();
883 Sequence
< Type
> SAL_CALL
Cell::getTypes( )
885 Sequence
< Type
> aTypes( SvxUnoTextBase::getTypes() );
887 sal_Int32 nLen
= aTypes
.getLength();
888 aTypes
.realloc(nLen
+ 2);
889 aTypes
[nLen
++] = cppu::UnoType
<XMergeableCell
>::get();
890 aTypes
[nLen
++] = cppu::UnoType
<XLayoutConstrains
>::get();
896 Sequence
< sal_Int8
> SAL_CALL
Cell::getImplementationId( )
898 return css::uno::Sequence
<sal_Int8
>();
902 css::awt::Size SAL_CALL
Cell::getMinimumSize()
904 return css::awt::Size( getMinimumWidth(), getMinimumHeight() );
908 css::awt::Size SAL_CALL
Cell::getPreferredSize()
910 return getMinimumSize();
914 css::awt::Size SAL_CALL
Cell::calcAdjustedSize( const css::awt::Size
& aNewSize
)
923 sal_Int32 SAL_CALL
Cell::getRowSpan()
929 sal_Int32 SAL_CALL
Cell::getColumnSpan()
935 sal_Bool SAL_CALL
Cell::isMerged()
944 OUString SAL_CALL
Cell::getFormula( )
950 void SAL_CALL
Cell::setFormula( const OUString
& aFormula
)
952 if( msFormula
!= aFormula
)
954 msFormula
= aFormula
;
959 double SAL_CALL
Cell::getValue( )
965 void SAL_CALL
Cell::setValue( double nValue
)
967 if( mfValue
!= nValue
)
970 mnCellContentType
= CellContentType_VALUE
;
975 CellContentType SAL_CALL
Cell::getType()
977 return mnCellContentType
;
981 sal_Int32 SAL_CALL
Cell::getError( )
990 Any
Cell::GetAnyForItem( SfxItemSet
const & aSet
, const SfxItemPropertySimpleEntry
* pMap
)
992 Any
aAny( SvxItemPropertySet_getPropertyValue( pMap
, aSet
) );
994 if( pMap
->aType
!= aAny
.getValueType() )
996 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
997 if( ( pMap
->aType
== ::cppu::UnoType
<sal_Int16
>::get()) && aAny
.getValueType() == ::cppu::UnoType
<sal_Int32
>::get() )
999 sal_Int32 nValue
= 0;
1001 aAny
<<= (sal_Int16
)nValue
;
1005 OSL_FAIL("GetAnyForItem() Returnvalue has wrong Type!" );
1012 Reference
< XPropertySetInfo
> SAL_CALL
Cell::getPropertySetInfo()
1014 return mpPropSet
->getPropertySetInfo();
1018 void SAL_CALL
Cell::setPropertyValue( const OUString
& rPropertyName
, const Any
& rValue
)
1020 ::SolarMutexGuard aGuard
;
1022 if( (mpProperties
== nullptr) || (GetModel() == nullptr) )
1023 throw DisposedException();
1025 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(rPropertyName
);
1028 if( (pMap
->nFlags
& PropertyAttribute::READONLY
) != 0 )
1029 throw PropertyVetoException();
1031 switch( pMap
->nWID
)
1033 case OWN_ATTR_STYLE
:
1035 Reference
< XStyle
> xStyle
;
1036 if( !( rValue
>>= xStyle
) )
1037 throw IllegalArgumentException();
1039 SfxUnoStyleSheet
* pStyle
= SfxUnoStyleSheet::getUnoStyleSheet(xStyle
);
1040 SetStyleSheet( pStyle
, true );
1043 case OWN_ATTR_TABLEBORDER
:
1045 auto pBorder
= o3tl::tryAccess
<TableBorder
>(rValue
);
1049 SvxBoxItem
aBox( SDRATTR_TABLE_BORDER
);
1050 SvxBoxInfoItem
aBoxInfo( SDRATTR_TABLE_BORDER_INNER
);
1051 SvxBorderLine aLine
;
1053 bool bSet
= SvxBoxItem::LineToSvxLine(pBorder
->TopLine
, aLine
, false);
1054 aBox
.SetLine(bSet
? &aLine
: nullptr, SvxBoxItemLine::TOP
);
1055 aBoxInfo
.SetValid(SvxBoxInfoItemValidFlags::TOP
, pBorder
->IsTopLineValid
);
1057 bSet
= SvxBoxItem::LineToSvxLine(pBorder
->BottomLine
, aLine
, false);
1058 aBox
.SetLine(bSet
? &aLine
: nullptr, SvxBoxItemLine::BOTTOM
);
1059 aBoxInfo
.SetValid(SvxBoxInfoItemValidFlags::BOTTOM
, pBorder
->IsBottomLineValid
);
1061 bSet
= SvxBoxItem::LineToSvxLine(pBorder
->LeftLine
, aLine
, false);
1062 aBox
.SetLine(bSet
? &aLine
: nullptr, SvxBoxItemLine::LEFT
);
1063 aBoxInfo
.SetValid(SvxBoxInfoItemValidFlags::LEFT
, pBorder
->IsLeftLineValid
);
1065 bSet
= SvxBoxItem::LineToSvxLine(pBorder
->RightLine
, aLine
, false);
1066 aBox
.SetLine(bSet
? &aLine
: nullptr, SvxBoxItemLine::RIGHT
);
1067 aBoxInfo
.SetValid(SvxBoxInfoItemValidFlags::RIGHT
, pBorder
->IsRightLineValid
);
1069 bSet
= SvxBoxItem::LineToSvxLine(pBorder
->HorizontalLine
, aLine
, false);
1070 aBoxInfo
.SetLine(bSet
? &aLine
: nullptr, SvxBoxInfoItemLine::HORI
);
1071 aBoxInfo
.SetValid(SvxBoxInfoItemValidFlags::HORI
, pBorder
->IsHorizontalLineValid
);
1073 bSet
= SvxBoxItem::LineToSvxLine(pBorder
->VerticalLine
, aLine
, false);
1074 aBoxInfo
.SetLine(bSet
? &aLine
: nullptr, SvxBoxInfoItemLine::VERT
);
1075 aBoxInfo
.SetValid(SvxBoxInfoItemValidFlags::VERT
, pBorder
->IsVerticalLineValid
);
1077 aBox
.SetAllDistances(pBorder
->Distance
); //TODO
1078 aBoxInfo
.SetValid(SvxBoxInfoItemValidFlags::DISTANCE
, pBorder
->IsDistanceValid
);
1080 mpProperties
->SetObjectItem(aBox
);
1081 mpProperties
->SetObjectItem(aBoxInfo
);
1084 case OWN_ATTR_FILLBMP_MODE
:
1087 if(!(rValue
>>= eMode
) )
1089 sal_Int32 nMode
= 0;
1090 if(!(rValue
>>= nMode
))
1091 throw IllegalArgumentException();
1093 eMode
= (BitmapMode
)nMode
;
1096 mpProperties
->SetObjectItem( XFillBmpStretchItem( eMode
== BitmapMode_STRETCH
) );
1097 mpProperties
->SetObjectItem( XFillBmpTileItem( eMode
== BitmapMode_REPEAT
) );
1100 case SDRATTR_TABLE_TEXT_ROTATION
:
1102 sal_Int32 nRotVal
= 0;
1103 if (!(rValue
>>= nRotVal
))
1104 throw IllegalArgumentException();
1106 if (nRotVal
!= 27000 && nRotVal
!= 9000 && nRotVal
!= 0)
1107 throw IllegalArgumentException();
1109 mpProperties
->SetObjectItem(SvxTextRotateItem(nRotVal
/10, SDRATTR_TABLE_TEXT_ROTATION
));
1114 SfxItemSet
aSet( GetModel()->GetItemPool(), {{pMap
->nWID
, pMap
->nWID
}});
1115 aSet
.Put(mpProperties
->GetItem(pMap
->nWID
));
1117 bool bSpecial
= false;
1119 switch( pMap
->nWID
)
1121 case XATTR_FILLBITMAP
:
1122 case XATTR_FILLGRADIENT
:
1123 case XATTR_FILLHATCH
:
1124 case XATTR_FILLFLOATTRANSPARENCE
:
1126 case XATTR_LINESTART
:
1127 case XATTR_LINEDASH
:
1129 if( pMap
->nMemberId
== MID_NAME
)
1132 if( rValue
>>= aApiName
)
1134 if( SvxShape::SetFillAttribute( pMap
->nWID
, aApiName
, aSet
, GetModel() ) )
1145 if( !SvxUnoTextRangeBase::SetPropertyValueHelper( pMap
, rValue
, aSet
))
1147 if( aSet
.GetItemState( pMap
->nWID
) != SfxItemState::SET
)
1149 // fetch the default from ItemPool
1150 if(SfxItemPool::IsWhich(pMap
->nWID
))
1151 aSet
.Put(GetModel()->GetItemPool().GetDefaultItem(pMap
->nWID
));
1154 if( aSet
.GetItemState( pMap
->nWID
) == SfxItemState::SET
)
1156 SvxItemPropertySet_setPropertyValue( pMap
, rValue
, aSet
);
1161 GetModel()->SetChanged();
1162 mpProperties
->SetMergedItemSetAndBroadcast( aSet
);
1167 throw UnknownPropertyException( rPropertyName
, static_cast<cppu::OWeakObject
*>(this));
1171 Any SAL_CALL
Cell::getPropertyValue( const OUString
& PropertyName
)
1173 ::SolarMutexGuard aGuard
;
1175 if( (mpProperties
== nullptr) || (GetModel() == nullptr) )
1176 throw DisposedException();
1178 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(PropertyName
);
1181 switch( pMap
->nWID
)
1183 case OWN_ATTR_STYLE
:
1185 return Any( Reference
< XStyle
>( dynamic_cast< SfxUnoStyleSheet
* >( GetStyleSheet() ) ) );
1187 case OWN_ATTR_TABLEBORDER
:
1189 const SvxBoxInfoItem
& rBoxInfoItem
= static_cast<const SvxBoxInfoItem
&>(mpProperties
->GetItem(SDRATTR_TABLE_BORDER_INNER
));
1190 const SvxBoxItem
& rBox
= static_cast<const SvxBoxItem
&>(mpProperties
->GetItem(SDRATTR_TABLE_BORDER
));
1192 TableBorder aTableBorder
;
1193 aTableBorder
.TopLine
= SvxBoxItem::SvxLineToLine(rBox
.GetTop(), false);
1194 aTableBorder
.IsTopLineValid
= rBoxInfoItem
.IsValid(SvxBoxInfoItemValidFlags::TOP
);
1195 aTableBorder
.BottomLine
= SvxBoxItem::SvxLineToLine(rBox
.GetBottom(), false);
1196 aTableBorder
.IsBottomLineValid
= rBoxInfoItem
.IsValid(SvxBoxInfoItemValidFlags::BOTTOM
);
1197 aTableBorder
.LeftLine
= SvxBoxItem::SvxLineToLine(rBox
.GetLeft(), false);
1198 aTableBorder
.IsLeftLineValid
= rBoxInfoItem
.IsValid(SvxBoxInfoItemValidFlags::LEFT
);
1199 aTableBorder
.RightLine
= SvxBoxItem::SvxLineToLine(rBox
.GetRight(), false);
1200 aTableBorder
.IsRightLineValid
= rBoxInfoItem
.IsValid(SvxBoxInfoItemValidFlags::RIGHT
);
1201 aTableBorder
.HorizontalLine
= SvxBoxItem::SvxLineToLine(rBoxInfoItem
.GetHori(), false);
1202 aTableBorder
.IsHorizontalLineValid
= rBoxInfoItem
.IsValid(SvxBoxInfoItemValidFlags::HORI
);
1203 aTableBorder
.VerticalLine
= SvxBoxItem::SvxLineToLine(rBoxInfoItem
.GetVert(), false);
1204 aTableBorder
.IsVerticalLineValid
= rBoxInfoItem
.IsValid(SvxBoxInfoItemValidFlags::VERT
);
1205 aTableBorder
.Distance
= rBox
.GetSmallestDistance();
1206 aTableBorder
.IsDistanceValid
= rBoxInfoItem
.IsValid(SvxBoxInfoItemValidFlags::DISTANCE
);
1208 return Any( aTableBorder
);
1210 case OWN_ATTR_FILLBMP_MODE
:
1212 const XFillBmpStretchItem
& rStretchItem
= static_cast<const XFillBmpStretchItem
&>(mpProperties
->GetItem(XATTR_FILLBMP_STRETCH
));
1213 const XFillBmpTileItem
& rTileItem
= static_cast<const XFillBmpTileItem
&>(mpProperties
->GetItem(XATTR_FILLBMP_TILE
));
1214 if( rTileItem
.GetValue() )
1216 return Any( BitmapMode_REPEAT
);
1218 else if( rStretchItem
.GetValue() )
1220 return Any( BitmapMode_STRETCH
);
1224 return Any( BitmapMode_NO_REPEAT
);
1227 case SDRATTR_TABLE_TEXT_ROTATION
:
1229 const SvxTextRotateItem
& rTextRotate
= static_cast<const SvxTextRotateItem
&>(mpProperties
->GetItem(SDRATTR_TABLE_TEXT_ROTATION
));
1230 return Any(sal_Int32(rTextRotate
.GetValue() * 10));
1234 SfxItemSet
aSet( GetModel()->GetItemPool(), {{pMap
->nWID
, pMap
->nWID
}});
1235 aSet
.Put(mpProperties
->GetItem(pMap
->nWID
));
1238 if(!SvxUnoTextRangeBase::GetPropertyValueHelper( aSet
, pMap
, aAny
))
1242 // fetch the default from ItemPool
1243 if(SfxItemPool::IsWhich(pMap
->nWID
))
1244 aSet
.Put(GetModel()->GetItemPool().GetDefaultItem(pMap
->nWID
));
1248 aAny
= GetAnyForItem( aSet
, pMap
);
1255 throw UnknownPropertyException( PropertyName
, static_cast<cppu::OWeakObject
*>(this));
1259 void SAL_CALL
Cell::addPropertyChangeListener( const OUString
& /*aPropertyName*/, const Reference
< XPropertyChangeListener
>& /*xListener*/ )
1264 void SAL_CALL
Cell::removePropertyChangeListener( const OUString
& /*aPropertyName*/, const Reference
< XPropertyChangeListener
>& /*aListener*/ )
1269 void SAL_CALL
Cell::addVetoableChangeListener( const OUString
& /*PropertyName*/, const Reference
< XVetoableChangeListener
>& /*aListener*/ )
1274 void SAL_CALL
Cell::removeVetoableChangeListener( const OUString
& /*PropertyName*/, const Reference
< XVetoableChangeListener
>& /*aListener*/ )
1279 // XMultiPropertySet
1282 void SAL_CALL
Cell::setPropertyValues( const Sequence
< OUString
>& aPropertyNames
, const Sequence
< Any
>& aValues
)
1284 ::SolarMutexGuard aSolarGuard
;
1286 if( (mpProperties
== nullptr) || (GetModel() == nullptr) )
1287 throw DisposedException();
1289 const sal_Int32 nCount
= aPropertyNames
.getLength();
1291 const OUString
* pNames
= aPropertyNames
.getConstArray();
1292 const Any
* pValues
= aValues
.getConstArray();
1294 for( sal_Int32 nIdx
= 0; nIdx
< nCount
; nIdx
++, pNames
++, pValues
++ )
1298 setPropertyValue( *pNames
, *pValues
);
1300 catch( UnknownPropertyException
& )
1302 OSL_FAIL("svx::Cell::setPropertyValues(), unknown property!" );
1306 OSL_FAIL("svx::Cell::setPropertyValues(), Exception caught!" );
1312 Sequence
< Any
> SAL_CALL
Cell::getPropertyValues( const Sequence
< OUString
>& aPropertyNames
)
1314 ::SolarMutexGuard aSolarGuard
;
1316 if( (mpProperties
== nullptr) || (GetModel() == nullptr) )
1317 throw DisposedException();
1319 const sal_Int32 nCount
= aPropertyNames
.getLength();
1320 const OUString
* pNames
= aPropertyNames
.getConstArray();
1322 Sequence
< Any
> aRet( nCount
);
1323 Any
* pValue
= aRet
.getArray();
1325 for( sal_Int32 nIdx
= 0; nIdx
< nCount
; nIdx
++, pValue
++, pNames
++ )
1329 *pValue
= getPropertyValue( *pNames
);
1331 catch( UnknownPropertyException
& )
1333 OSL_FAIL("svx::Cell::setPropertyValues(), unknown property!" );
1337 OSL_FAIL( "svx::Cell::getPropertyValues(), Exception caught!" );
1345 void SAL_CALL
Cell::addPropertiesChangeListener( const Sequence
< OUString
>& /*aPropertyNames*/, const Reference
< XPropertiesChangeListener
>& /*xListener*/ )
1350 void SAL_CALL
Cell::removePropertiesChangeListener( const Reference
< XPropertiesChangeListener
>& /*xListener*/ )
1355 void SAL_CALL
Cell::firePropertiesChangeEvent( const Sequence
< OUString
>& /*aPropertyNames*/, const Reference
< XPropertiesChangeListener
>& /*xListener*/ )
1363 PropertyState SAL_CALL
Cell::getPropertyState( const OUString
& PropertyName
)
1365 ::SolarMutexGuard aGuard
;
1367 if( (mpProperties
== nullptr) || (GetModel() == nullptr) )
1368 throw DisposedException();
1370 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(PropertyName
);
1374 PropertyState eState
;
1375 switch( pMap
->nWID
)
1377 case OWN_ATTR_FILLBMP_MODE
:
1379 const SfxItemSet
& rSet
= mpProperties
->GetMergedItemSet();
1381 const bool bStretch
= rSet
.GetItemState( XATTR_FILLBMP_STRETCH
, false ) == SfxItemState::SET
;
1382 const bool bTile
= rSet
.GetItemState( XATTR_FILLBMP_TILE
, false ) == SfxItemState::SET
;
1383 if( bStretch
|| bTile
)
1385 eState
= PropertyState_DIRECT_VALUE
;
1389 eState
= PropertyState_DEFAULT_VALUE
;
1393 case OWN_ATTR_STYLE
:
1395 return PropertyState_DIRECT_VALUE
;
1397 case OWN_ATTR_TABLEBORDER
:
1399 const SfxItemSet
& rSet
= mpProperties
->GetMergedItemSet();
1400 if( (rSet
.GetItemState( SDRATTR_TABLE_BORDER_INNER
, false ) == SfxItemState::DEFAULT
) && (rSet
.GetItemState( SDRATTR_TABLE_BORDER
, false ) == SfxItemState::DEFAULT
) )
1401 return PropertyState_DEFAULT_VALUE
;
1403 return PropertyState_DIRECT_VALUE
;
1407 const SfxItemSet
& rSet
= mpProperties
->GetMergedItemSet();
1409 switch( rSet
.GetItemState( pMap
->nWID
, false ) )
1411 case SfxItemState::READONLY
:
1412 case SfxItemState::SET
:
1413 eState
= PropertyState_DIRECT_VALUE
;
1415 case SfxItemState::DEFAULT
:
1416 eState
= PropertyState_DEFAULT_VALUE
;
1419 eState
= PropertyState_AMBIGUOUS_VALUE
;
1423 // if a item is set, this doesn't mean we want it :)
1424 if( PropertyState_DIRECT_VALUE
== eState
)
1426 switch( pMap
->nWID
)
1428 // the following items are disabled by changing the
1429 // fill style or the line style. so there is no need
1430 // to export items without names which should be empty
1431 case XATTR_FILLBITMAP
:
1432 case XATTR_FILLGRADIENT
:
1433 case XATTR_FILLHATCH
:
1434 case XATTR_LINEDASH
:
1436 const NameOrIndex
* pItem
= rSet
.GetItem
<NameOrIndex
>((sal_uInt16
)pMap
->nWID
);
1437 if( ( pItem
== nullptr ) || pItem
->GetName().isEmpty() )
1438 eState
= PropertyState_DEFAULT_VALUE
;
1443 // If e.g. the LineStart is on NONE and thus the string has length 0, it still
1444 // may be a hard attribute covering the set LineStart of the parent (Style).
1446 // same is for fill float transparency
1448 case XATTR_LINESTART
:
1449 case XATTR_FILLFLOATTRANSPARENCE
:
1451 const NameOrIndex
* pItem
= rSet
.GetItem
<NameOrIndex
>((sal_uInt16
)pMap
->nWID
);
1452 if( pItem
== nullptr )
1453 eState
= PropertyState_DEFAULT_VALUE
;
1462 throw UnknownPropertyException();
1466 Sequence
< PropertyState
> SAL_CALL
Cell::getPropertyStates( const Sequence
< OUString
>& aPropertyName
)
1468 ::SolarMutexGuard aGuard
;
1470 if( (mpProperties
== nullptr) || (GetModel() == nullptr) )
1471 throw DisposedException();
1473 const sal_Int32 nCount
= aPropertyName
.getLength();
1475 Sequence
< PropertyState
> aRet( nCount
);
1477 const OUString
* pNames
= aPropertyName
.getConstArray();
1478 PropertyState
* pState
= aRet
.getArray();
1480 for( sal_Int32 nIdx
= 0; nIdx
< nCount
; nIdx
++, pNames
++, pState
++ )
1484 *pState
= getPropertyState( *pNames
);
1488 *pState
= PropertyState_AMBIGUOUS_VALUE
;
1496 void SAL_CALL
Cell::setPropertyToDefault( const OUString
& PropertyName
)
1498 ::SolarMutexGuard aGuard
;
1500 if( (mpProperties
== nullptr) || (GetModel() == nullptr) )
1501 throw DisposedException();
1503 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(PropertyName
);
1506 switch( pMap
->nWID
)
1508 case OWN_ATTR_FILLBMP_MODE
:
1510 mpProperties
->ClearObjectItem( XATTR_FILLBMP_STRETCH
);
1511 mpProperties
->ClearObjectItem( XATTR_FILLBMP_TILE
);
1514 case OWN_ATTR_STYLE
:
1517 case OWN_ATTR_TABLEBORDER
:
1519 mpProperties
->ClearObjectItem( SDRATTR_TABLE_BORDER_INNER
);
1520 mpProperties
->ClearObjectItem( SDRATTR_TABLE_BORDER
);
1526 mpProperties
->ClearObjectItem( pMap
->nWID
);
1530 GetModel()->SetChanged();
1533 throw UnknownPropertyException( PropertyName
, static_cast<cppu::OWeakObject
*>(this));
1537 Any SAL_CALL
Cell::getPropertyDefault( const OUString
& aPropertyName
)
1539 ::SolarMutexGuard aGuard
;
1541 if( (mpProperties
== nullptr) || (GetModel() == nullptr) )
1542 throw DisposedException();
1544 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(aPropertyName
);
1547 switch( pMap
->nWID
)
1549 case OWN_ATTR_FILLBMP_MODE
:
1550 return Any( BitmapMode_NO_REPEAT
);
1552 case OWN_ATTR_STYLE
:
1554 Reference
< XStyle
> xStyle
;
1555 return Any( xStyle
);
1558 case OWN_ATTR_TABLEBORDER
:
1560 TableBorder aBorder
;
1561 return Any( aBorder
);
1566 if( SfxItemPool::IsWhich(pMap
->nWID
) )
1568 SfxItemSet
aSet( GetModel()->GetItemPool(), {{pMap
->nWID
, pMap
->nWID
}});
1569 aSet
.Put(GetModel()->GetItemPool().GetDefaultItem(pMap
->nWID
));
1570 return GetAnyForItem( aSet
, pMap
);
1575 throw UnknownPropertyException( aPropertyName
, static_cast<cppu::OWeakObject
*>(this));
1579 // XMultiPropertyStates
1582 void SAL_CALL
Cell::setAllPropertiesToDefault()
1584 delete mpProperties
;
1585 mpProperties
= new sdr::properties::CellProperties( static_cast< SdrTableObj
& >( GetObject() ), this );
1587 SdrOutliner
& rOutliner
= GetObject().ImpGetDrawOutliner();
1589 OutlinerParaObject
* pParaObj
= GetOutlinerParaObject();
1592 rOutliner
.SetText(*pParaObj
);
1593 sal_Int32
nParaCount(rOutliner
.GetParagraphCount());
1597 ESelection
aSelection( 0, 0, EE_PARA_ALL
, EE_TEXTPOS_ALL
);
1598 rOutliner
.RemoveAttribs(aSelection
, true, 0);
1600 OutlinerParaObject
* pTemp
= rOutliner
.CreateParaObject(0, nParaCount
);
1603 SetOutlinerParaObject(pTemp
);
1609 void SAL_CALL
Cell::setPropertiesToDefault( const Sequence
< OUString
>& aPropertyNames
)
1611 sal_Int32 nCount
= aPropertyNames
.getLength();
1612 const OUString
* pName
= aPropertyNames
.getConstArray();
1615 setPropertyToDefault( *pName
++ );
1619 Sequence
< Any
> SAL_CALL
Cell::getPropertyDefaults( const Sequence
< OUString
>& aPropertyNames
)
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
++ );
1636 void SAL_CALL
Cell::insertTextContent( const Reference
< XTextRange
>& xRange
, const Reference
< XTextContent
>& xContent
, sal_Bool bAbsorb
)
1638 SvxUnoTextBase::insertTextContent( xRange
, xContent
, bAbsorb
);
1643 void SAL_CALL
Cell::removeTextContent( const Reference
< XTextContent
>& xContent
)
1645 SvxUnoTextBase::removeTextContent( xContent
);
1653 void SAL_CALL
Cell::insertString( const Reference
< XTextRange
>& xRange
, const OUString
& aString
, sal_Bool bAbsorb
)
1655 SvxUnoTextBase::insertString( xRange
, aString
, bAbsorb
);
1660 void SAL_CALL
Cell::insertControlCharacter( const Reference
< XTextRange
>& xRange
, sal_Int16 nControlCharacter
, sal_Bool bAbsorb
)
1662 SvxUnoTextBase::insertControlCharacter( xRange
, nControlCharacter
, bAbsorb
);
1670 OUString SAL_CALL
Cell::getString( )
1672 maSelection
.nStartPara
= EE_PARA_MAX_COUNT
;
1673 return SvxUnoTextBase::getString();
1677 void SAL_CALL
Cell::setString( const OUString
& aString
)
1679 SvxUnoTextBase::setString( aString
);
1684 void SAL_CALL
Cell::disposing( const EventObject
& /*Source*/ )
1690 void Cell::dumpAsXml(struct _xmlTextWriter
* pWriter
, sal_Int32 nRow
, sal_Int32 nCol
) const
1692 xmlTextWriterStartElement(pWriter
, BAD_CAST("Cell"));
1693 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("row"), "%" SAL_PRIdINT32
, nRow
);
1694 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("col"), "%" SAL_PRIdINT32
, nCol
);
1695 SdrText::dumpAsXml(pWriter
);
1696 //SvxUnoTextBase::dumpAsXml(pWriter);
1697 //mpPropSet->dumpAsXml(pWriter);
1698 mpProperties
->dumpAsXml(pWriter
);
1699 xmlTextWriterEndElement(pWriter
);
1704 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */