Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / sc / source / core / data / attrib.cxx
blob409f7aa0a6a0d3e1ceeb57fb6ef8f7f12e295f2a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/util/CellProtection.hpp>
22 #include <scitems.hxx>
24 #include <editeng/editeng.hxx>
25 #include <editeng/editobj.hxx>
26 #include <editeng/eerdll.hxx>
27 #include <editeng/borderline.hxx>
28 #include <editeng/itemtype.hxx>
29 #include <svl/itempool.hxx>
31 #include <libxml/xmlwriter.h>
33 #include <attrib.hxx>
34 #include <global.hxx>
35 #include <editutil.hxx>
36 #include <mid.h>
37 #include <globstr.hrc>
38 #include <scresid.hxx>
39 #include <textuno.hxx>
41 using namespace com::sun::star;
44 SfxPoolItem* ScProtectionAttr::CreateDefault() { return new ScProtectionAttr; }
46 /**
47 * General Help Function
49 bool ScHasPriority( const ::editeng::SvxBorderLine* pThis, const ::editeng::SvxBorderLine* pOther )
52 if (!pThis)
53 return false;
54 if (!pOther)
55 return true;
57 sal_uInt16 nThisSize = pThis->GetScaledWidth();
58 sal_uInt16 nOtherSize = pOther->GetScaledWidth();
60 if (nThisSize > nOtherSize)
61 return true;
62 else if (nThisSize < nOtherSize)
63 return false;
64 else
66 if ( pOther->GetInWidth() && !pThis->GetInWidth() )
67 return true;
68 else if ( pThis->GetInWidth() && !pOther->GetInWidth() )
69 return false;
70 else
72 return true; // FIXME: What is this?
77 /** Item - Implementations */
79 /**
80 * Merge
82 ScMergeAttr::ScMergeAttr():
83 SfxPoolItem(ATTR_MERGE, SfxItemType::ScMergeAttrType),
84 nColMerge(0),
85 nRowMerge(0)
88 ScMergeAttr::ScMergeAttr( SCCOL nCol, SCROW nRow):
89 SfxPoolItem(ATTR_MERGE, SfxItemType::ScMergeAttrType),
90 nColMerge(nCol),
91 nRowMerge(nRow)
94 ScMergeAttr::ScMergeAttr(const ScMergeAttr& rItem):
95 SfxPoolItem(ATTR_MERGE, SfxItemType::ScMergeAttrType)
97 nColMerge = rItem.nColMerge;
98 nRowMerge = rItem.nRowMerge;
101 ScMergeAttr::~ScMergeAttr()
105 bool ScMergeAttr::operator==( const SfxPoolItem& rItem ) const
107 return SfxPoolItem::operator==(rItem)
108 && (nColMerge == static_cast<const ScMergeAttr&>(rItem).nColMerge)
109 && (nRowMerge == static_cast<const ScMergeAttr&>(rItem).nRowMerge);
112 ScMergeAttr* ScMergeAttr::Clone( SfxItemPool * ) const
114 return new ScMergeAttr(*this);
117 void ScMergeAttr::dumpAsXml(xmlTextWriterPtr pWriter) const
119 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("ScMergeAttr"));
120 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("col-merge"), BAD_CAST(OString::number(GetColMerge()).getStr()));
121 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("row-merge"), BAD_CAST(OString::number(GetRowMerge()).getStr()));
122 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("merged"), BAD_CAST(OString::boolean(IsMerged()).getStr()));
123 (void)xmlTextWriterEndElement(pWriter);
127 * MergeFlag
129 ScMergeFlagAttr::ScMergeFlagAttr():
130 SfxInt16Item(ATTR_MERGE_FLAG, 0)
134 ScMergeFlagAttr::ScMergeFlagAttr(ScMF nFlags):
135 SfxInt16Item(ATTR_MERGE_FLAG, static_cast<sal_Int16>(nFlags))
139 ScMergeFlagAttr::~ScMergeFlagAttr()
143 ScMergeFlagAttr* ScMergeFlagAttr::Clone(SfxItemPool *) const
145 return new ScMergeFlagAttr(*this);
148 bool ScMergeFlagAttr::HasPivotButton() const
150 return bool(GetValue() & ScMF::Button);
153 bool ScMergeFlagAttr::HasPivotPopupButton() const
155 return bool(GetValue() & ScMF::ButtonPopup);
158 bool ScMergeFlagAttr::HasPivotToggle() const
160 auto nFlags = GetValue();
161 return (nFlags & ScMF::DpCollapse) || (nFlags & ScMF::DpExpand);
164 bool ScMergeFlagAttr::HasPivotMultiFieldPopupButton() const
166 return bool(GetValue() & ScMF::ButtonPopup2);
169 void ScMergeFlagAttr::dumpAsXml(xmlTextWriterPtr pWriter) const
171 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("ScMergeFlagAttr"));
172 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("overlapped"), BAD_CAST(OString::boolean(IsOverlapped()).getStr()));
173 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("hor_overlapped"), BAD_CAST(OString::boolean(IsHorOverlapped()).getStr()));
174 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("ver_overlapped"), BAD_CAST(OString::boolean(IsVerOverlapped()).getStr()));
175 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("autofilter"), BAD_CAST(OString::boolean(HasAutoFilter()).getStr()));
176 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("scenario"), BAD_CAST(OString::boolean(IsScenario()).getStr()));
177 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("pivot-button"), BAD_CAST(OString::boolean(HasPivotButton()).getStr()));
178 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("pivot-popup-button"), BAD_CAST(OString::boolean(HasPivotPopupButton()).getStr()));
179 (void)xmlTextWriterEndElement(pWriter);
183 * Protection
185 ScProtectionAttr::ScProtectionAttr():
186 SfxPoolItem(ATTR_PROTECTION, SfxItemType::ScProtectionAttrType),
187 bProtection(true),
188 bHideFormula(false),
189 bHideCell(false),
190 bHidePrint(false)
194 ScProtectionAttr::ScProtectionAttr( bool bProtect, bool bHFormula,
195 bool bHCell, bool bHPrint):
196 SfxPoolItem(ATTR_PROTECTION, SfxItemType::ScProtectionAttrType),
197 bProtection(bProtect),
198 bHideFormula(bHFormula),
199 bHideCell(bHCell),
200 bHidePrint(bHPrint)
204 ScProtectionAttr::ScProtectionAttr(const ScProtectionAttr& rItem):
205 SfxPoolItem(ATTR_PROTECTION, SfxItemType::ScProtectionAttrType)
207 bProtection = rItem.bProtection;
208 bHideFormula = rItem.bHideFormula;
209 bHideCell = rItem.bHideCell;
210 bHidePrint = rItem.bHidePrint;
213 ScProtectionAttr::~ScProtectionAttr()
217 bool ScProtectionAttr::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
219 nMemberId &= ~CONVERT_TWIPS;
220 switch ( nMemberId )
222 case 0 :
224 util::CellProtection aProtection;
225 aProtection.IsLocked = bProtection;
226 aProtection.IsFormulaHidden = bHideFormula;
227 aProtection.IsHidden = bHideCell;
228 aProtection.IsPrintHidden = bHidePrint;
229 rVal <<= aProtection;
230 break;
232 case MID_1 :
233 rVal <<= bProtection; break;
234 case MID_2 :
235 rVal <<= bHideFormula; break;
236 case MID_3 :
237 rVal <<= bHideCell; break;
238 case MID_4 :
239 rVal <<= bHidePrint; break;
240 default:
241 OSL_FAIL("Wrong MemberID!");
242 return false;
245 return true;
248 bool ScProtectionAttr::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
250 bool bRet = false;
251 bool bVal = false;
252 nMemberId &= ~CONVERT_TWIPS;
253 switch ( nMemberId )
255 case 0 :
257 util::CellProtection aProtection;
258 if ( rVal >>= aProtection )
260 bProtection = aProtection.IsLocked;
261 bHideFormula = aProtection.IsFormulaHidden;
262 bHideCell = aProtection.IsHidden;
263 bHidePrint = aProtection.IsPrintHidden;
264 bRet = true;
266 else
268 OSL_FAIL("exception - wrong argument");
270 break;
272 case MID_1 :
273 bRet = (rVal >>= bVal); if (bRet) bProtection=bVal; break;
274 case MID_2 :
275 bRet = (rVal >>= bVal); if (bRet) bHideFormula=bVal; break;
276 case MID_3 :
277 bRet = (rVal >>= bVal); if (bRet) bHideCell=bVal; break;
278 case MID_4 :
279 bRet = (rVal >>= bVal); if (bRet) bHidePrint=bVal; break;
280 default:
281 OSL_FAIL("Wrong MemberID!");
284 return bRet;
287 OUString ScProtectionAttr::GetValueText() const
289 const OUString aStrYes ( ScResId(STR_YES) );
290 const OUString aStrNo ( ScResId(STR_NO) );
292 const OUString aValue = "("
293 + (bProtection ? aStrYes : aStrNo)
294 + ","
295 + (bHideFormula ? aStrYes : aStrNo)
296 + ","
297 + (bHideCell ? aStrYes : aStrNo)
298 + ","
299 + (bHidePrint ? aStrYes : aStrNo)
300 + ")";
302 return aValue;
305 bool ScProtectionAttr::GetPresentation
307 SfxItemPresentation ePres,
308 MapUnit /* eCoreMetric */,
309 MapUnit /* ePresMetric */,
310 OUString& rText,
311 const IntlWrapper& /* rIntl */
312 ) const
314 const OUString aStrYes ( ScResId(STR_YES) );
315 const OUString aStrNo ( ScResId(STR_NO) );
317 switch ( ePres )
319 case SfxItemPresentation::Nameless:
320 rText = GetValueText();
321 break;
323 case SfxItemPresentation::Complete:
324 rText = ScResId(STR_PROTECTION)
325 + ": "
326 + (bProtection ? aStrYes : aStrNo)
327 + ", "
328 + ScResId(STR_FORMULAS)
329 + ": "
330 + (!bHideFormula ? aStrYes : aStrNo)
331 + ", "
332 + ScResId(STR_HIDE)
333 + ": "
334 + (bHideCell ? aStrYes : aStrNo)
335 + ", "
336 + ScResId(STR_PRINT)
337 + ": "
338 + (!bHidePrint ? aStrYes : aStrNo);
339 break;
341 default: break;
344 return true;
347 bool ScProtectionAttr::operator==( const SfxPoolItem& rItem ) const
349 return SfxPoolItem::operator==(rItem)
350 && (bProtection == static_cast<const ScProtectionAttr&>(rItem).bProtection)
351 && (bHideFormula == static_cast<const ScProtectionAttr&>(rItem).bHideFormula)
352 && (bHideCell == static_cast<const ScProtectionAttr&>(rItem).bHideCell)
353 && (bHidePrint == static_cast<const ScProtectionAttr&>(rItem).bHidePrint);
356 ScProtectionAttr* ScProtectionAttr::Clone( SfxItemPool * ) const
358 return new ScProtectionAttr(*this);
361 void ScProtectionAttr::SetProtection( bool bProtect)
363 bProtection = bProtect;
366 void ScProtectionAttr::SetHideFormula( bool bHFormula)
368 bHideFormula = bHFormula;
371 void ScProtectionAttr::SetHideCell( bool bHCell)
373 bHideCell = bHCell;
376 void ScProtectionAttr::SetHidePrint( bool bHPrint)
378 bHidePrint = bHPrint;
381 void ScProtectionAttr::dumpAsXml(xmlTextWriterPtr pWriter) const
383 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("ScProtectionAttr"));
384 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("protection"), BAD_CAST(OString::boolean(GetProtection()).getStr()));
385 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("hide-formula"), BAD_CAST(OString::boolean(GetHideFormula()).getStr()));
386 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("hide-cell"), BAD_CAST(OString::boolean(GetHideCell()).getStr()));
387 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("hide-print"), BAD_CAST(OString::boolean(GetHidePrint()).getStr()));
388 (void)xmlTextWriterEndElement(pWriter);
392 * ScPageHFItem - Dates from the Head and Foot lines
394 ScPageHFItem::ScPageHFItem( sal_uInt16 nWhichP )
395 : SfxPoolItem( nWhichP, SfxItemType::ScPageHFItemType )
399 ScPageHFItem::ScPageHFItem( const ScPageHFItem& rItem )
400 : SfxPoolItem ( rItem )
402 if ( rItem.pLeftArea )
403 pLeftArea = rItem.pLeftArea->Clone();
404 if ( rItem.pCenterArea )
405 pCenterArea = rItem.pCenterArea->Clone();
406 if ( rItem.pRightArea )
407 pRightArea = rItem.pRightArea->Clone();
410 ScPageHFItem::~ScPageHFItem()
414 bool ScPageHFItem::QueryValue( uno::Any& rVal, sal_uInt8 /* nMemberId */ ) const
416 rtl::Reference<ScHeaderFooterContentObj> xContent =
417 new ScHeaderFooterContentObj();
418 xContent->Init(pLeftArea.get(), pCenterArea.get(), pRightArea.get());
420 uno::Reference<sheet::XHeaderFooterContent> xCont(xContent);
422 rVal <<= xCont;
423 return true;
426 bool ScPageHFItem::PutValue( const uno::Any& rVal, sal_uInt8 /* nMemberId */ )
428 bool bRet = false;
429 uno::Reference<sheet::XHeaderFooterContent> xContent;
430 if ( rVal >>= xContent )
432 if ( xContent.is() )
434 rtl::Reference<ScHeaderFooterContentObj> pImp =
435 ScHeaderFooterContentObj::getImplementation( xContent );
436 if (pImp.is())
438 const EditTextObject* pImpLeft = pImp->GetLeftEditObject();
439 pLeftArea.reset();
440 if (pImpLeft)
441 pLeftArea = pImpLeft->Clone();
443 const EditTextObject* pImpCenter = pImp->GetCenterEditObject();
444 pCenterArea.reset();
445 if (pImpCenter)
446 pCenterArea = pImpCenter->Clone();
448 const EditTextObject* pImpRight = pImp->GetRightEditObject();
449 pRightArea.reset();
450 if (pImpRight)
451 pRightArea = pImpRight->Clone();
453 if ( !pLeftArea || !pCenterArea || !pRightArea )
455 // no Text with Null are left
456 ScEditEngineDefaulter aEngine( EditEngine::CreatePool().get(), true );
457 if (!pLeftArea)
458 pLeftArea = aEngine.CreateTextObject();
459 if (!pCenterArea)
460 pCenterArea = aEngine.CreateTextObject();
461 if (!pRightArea)
462 pRightArea = aEngine.CreateTextObject();
465 bRet = true;
470 if (!bRet)
472 OSL_FAIL("exception - wrong argument");
475 return true;
478 bool ScPageHFItem::operator==( const SfxPoolItem& rItem ) const
480 assert(SfxPoolItem::operator==(rItem));
482 const ScPageHFItem& r = static_cast<const ScPageHFItem&>(rItem);
484 return ScGlobal::EETextObjEqual(pLeftArea.get(), r.pLeftArea.get())
485 && ScGlobal::EETextObjEqual(pCenterArea.get(), r.pCenterArea.get())
486 && ScGlobal::EETextObjEqual(pRightArea.get(), r.pRightArea.get());
489 ScPageHFItem* ScPageHFItem::Clone( SfxItemPool* ) const
491 return new ScPageHFItem( *this );
494 void ScPageHFItem::SetLeftArea( const EditTextObject& rNew )
496 pLeftArea = rNew.Clone();
499 void ScPageHFItem::SetCenterArea( const EditTextObject& rNew )
501 pCenterArea = rNew.Clone();
504 void ScPageHFItem::SetRightArea( const EditTextObject& rNew )
506 pRightArea = rNew.Clone();
508 void ScPageHFItem::dumpAsXml(xmlTextWriterPtr pWriter) const
510 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("ScPageHFItem"));
511 GetLeftArea()->dumpAsXml(pWriter);
512 GetCenterArea()->dumpAsXml(pWriter);
513 GetRightArea()->dumpAsXml(pWriter);
514 (void)xmlTextWriterEndElement(pWriter);
518 * ScViewObjectModeItem - Display Mode of View Objects
520 ScViewObjectModeItem::ScViewObjectModeItem( sal_uInt16 nWhichP )
521 : SfxEnumItem( nWhichP, SfxItemType::ScViewObjectModeItemType, VOBJ_MODE_SHOW )
525 ScViewObjectModeItem::ScViewObjectModeItem( sal_uInt16 nWhichP, ScVObjMode eMode )
526 : SfxEnumItem( nWhichP, SfxItemType::ScViewObjectModeItemType, eMode )
530 ScViewObjectModeItem::~ScViewObjectModeItem()
534 bool ScViewObjectModeItem::GetPresentation
536 SfxItemPresentation ePres,
537 MapUnit /* eCoreUnit */,
538 MapUnit /* ePresUnit */,
539 OUString& rText,
540 const IntlWrapper& /* rIntl */
541 ) const
543 OUString aDel(u": "_ustr);
544 rText.clear();
546 switch ( ePres )
548 case SfxItemPresentation::Complete:
549 switch( Which() )
551 case SID_SCATTR_PAGE_CHARTS:
552 rText = ScResId(STR_VOBJ_CHART) + aDel;
553 break;
555 case SID_SCATTR_PAGE_OBJECTS:
556 rText = ScResId(STR_VOBJ_OBJECT) + aDel;
557 break;
559 case SID_SCATTR_PAGE_DRAWINGS:
560 rText = ScResId(STR_VOBJ_DRAWINGS) + aDel;
561 break;
563 default: break;
565 [[fallthrough]];
566 case SfxItemPresentation::Nameless:
567 if (GetValue() == VOBJ_MODE_SHOW)
568 rText += ScResId(STR_VOBJ_MODE_SHOW);
569 else
570 rText += ScResId(STR_VOBJ_MODE_HIDE);
571 return true;
573 default: break;
574 // added to avoid warnings
577 return false;
580 sal_uInt16 ScViewObjectModeItem::GetValueCount() const
582 return 2;
585 ScViewObjectModeItem* ScViewObjectModeItem::Clone( SfxItemPool* ) const
587 return new ScViewObjectModeItem( *this );
590 ScPageScaleToItem::ScPageScaleToItem() :
591 SfxPoolItem( ATTR_PAGE_SCALETO, SfxItemType::ScPageScaleToItemType ),
592 mnWidth( 0 ),
593 mnHeight( 0 )
597 ScPageScaleToItem::ScPageScaleToItem( sal_uInt16 nWidth, sal_uInt16 nHeight ) :
598 SfxPoolItem( ATTR_PAGE_SCALETO, SfxItemType::ScPageScaleToItemType ),
599 mnWidth( nWidth ),
600 mnHeight( nHeight )
604 ScPageScaleToItem::~ScPageScaleToItem()
608 ScPageScaleToItem* ScPageScaleToItem::Clone( SfxItemPool* ) const
610 return new ScPageScaleToItem( *this );
613 bool ScPageScaleToItem::operator==( const SfxPoolItem& rCmp ) const
615 assert(SfxPoolItem::operator==(rCmp));
616 const ScPageScaleToItem& rPageCmp = static_cast< const ScPageScaleToItem& >( rCmp );
617 return (mnWidth == rPageCmp.mnWidth) && (mnHeight == rPageCmp.mnHeight);
620 namespace {
621 void lclAppendScalePageCount( OUString& rText, sal_uInt16 nPages )
623 rText += ": ";
624 if( nPages )
626 OUString aPages(ScResId(STR_SCATTR_PAGE_SCALE_PAGES, nPages));
627 rText += aPages.replaceFirst( "%1", OUString::number( nPages ) );
629 else
630 rText += ScResId( STR_SCATTR_PAGE_SCALE_AUTO );
632 } // namespace
634 bool ScPageScaleToItem::GetPresentation(
635 SfxItemPresentation ePres, MapUnit, MapUnit, OUString& rText, const IntlWrapper& ) const
637 rText.clear();
638 if( !IsValid())
639 return false;
641 OUString aName( ScResId( STR_SCATTR_PAGE_SCALETO ) );
642 OUString aValue( ScResId( STR_SCATTR_PAGE_SCALE_WIDTH ) );
643 lclAppendScalePageCount( aValue, mnWidth );
644 aValue += ", " + ScResId( STR_SCATTR_PAGE_SCALE_HEIGHT );
645 lclAppendScalePageCount( aValue, mnHeight );
647 switch( ePres )
649 case SfxItemPresentation::Nameless:
650 rText = aValue;
651 return true;
653 case SfxItemPresentation::Complete:
654 rText = aName + " (" + aValue + ")";
655 return true;
657 default:
658 OSL_FAIL( "ScPageScaleToItem::GetPresentation - unknown presentation mode" );
660 return false;
663 bool ScPageScaleToItem::QueryValue( uno::Any& rAny, sal_uInt8 nMemberId ) const
665 bool bRet = true;
666 switch( nMemberId )
668 case SC_MID_PAGE_SCALETO_WIDTH: rAny <<= mnWidth; break;
669 case SC_MID_PAGE_SCALETO_HEIGHT: rAny <<= mnHeight; break;
670 default:
671 OSL_FAIL( "ScPageScaleToItem::QueryValue - unknown member ID" );
672 bRet = false;
674 return bRet;
677 bool ScPageScaleToItem::PutValue( const uno::Any& rAny, sal_uInt8 nMemberId )
679 bool bRet = false;
680 switch( nMemberId )
682 case SC_MID_PAGE_SCALETO_WIDTH: bRet = rAny >>= mnWidth; break;
683 case SC_MID_PAGE_SCALETO_HEIGHT: bRet = rAny >>= mnHeight; break;
684 default:
685 OSL_FAIL( "ScPageScaleToItem::PutValue - unknown member ID" );
687 return bRet;
689 void ScPageScaleToItem::dumpAsXml(xmlTextWriterPtr pWriter) const
691 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("ScPageScaleToItem"));
692 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("width"), BAD_CAST(OString::number(GetWidth()).getStr()));
693 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("height"), BAD_CAST(OString::number(GetHeight()).getStr()));
694 (void)xmlTextWriterEndElement(pWriter);
697 ScCondFormatItem::ScCondFormatItem():
698 SfxPoolItem( ATTR_CONDITIONAL, SfxItemType::ScCondFormatItemType )
702 ScCondFormatItem::ScCondFormatItem( sal_uInt32 nIndex ):
703 SfxPoolItem( ATTR_CONDITIONAL, SfxItemType::ScCondFormatItemType )
705 maIndex.insert(nIndex);
708 ScCondFormatItem::ScCondFormatItem( const ScCondFormatIndexes& rIndex ):
709 SfxPoolItem( ATTR_CONDITIONAL, SfxItemType::ScCondFormatItemType ),
710 maIndex( rIndex )
714 ScCondFormatItem::ScCondFormatItem( ScCondFormatIndexes&& aIndex ) noexcept:
715 SfxPoolItem( ATTR_CONDITIONAL, SfxItemType::ScCondFormatItemType ),
716 maIndex( std::move(aIndex) )
720 ScCondFormatItem::~ScCondFormatItem()
724 bool ScCondFormatItem::operator==( const SfxPoolItem& rCmp ) const
726 if (!SfxPoolItem::operator==(rCmp))
727 return false;
728 auto const & other = static_cast<const ScCondFormatItem&>(rCmp);
729 if (maIndex.empty() && other.maIndex.empty())
730 return true;
731 // memcmp is faster than operator== on std::vector
732 return maIndex.size() == other.maIndex.size()
733 && memcmp(&maIndex.front(), &other.maIndex.front(), maIndex.size() * sizeof(sal_uInt32)) == 0;
736 ScCondFormatItem* ScCondFormatItem::Clone(SfxItemPool*) const
738 return new ScCondFormatItem(maIndex);
741 void ScCondFormatItem::dumpAsXml(xmlTextWriterPtr pWriter) const
743 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("ScCondFormatItem"));
744 for (const auto& nItem : maIndex)
746 std::string aStrVal = std::to_string(nItem);
747 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(aStrVal.c_str()));
748 (void)xmlTextWriterEndElement(pWriter);
750 (void)xmlTextWriterEndElement(pWriter);
753 ScRotateValueItem::ScRotateValueItem(Degree100 nAngle)
754 : SdrAngleItem(ATTR_ROTATE_VALUE, nAngle, SfxItemType::ScRotateValueItemType)
758 ScRotateValueItem* ScRotateValueItem::Clone(SfxItemPool*) const
760 return new ScRotateValueItem(GetValue());
763 bool ScRotateValueItem::GetPresentation(SfxItemPresentation ePresentation,
764 MapUnit eCoreMetric, MapUnit ePresMetric,
765 OUString& rText,
766 const IntlWrapper& rWrapper) const
768 bool bRet = SdrAngleItem::GetPresentation(SfxItemPresentation::Nameless, eCoreMetric, ePresMetric, rText, rWrapper);
769 if (bRet && ePresentation == SfxItemPresentation::Complete)
770 rText = ScResId(STR_TEXTORIENTANGLE) + " " + rText;
771 return bRet;
774 ScShrinkToFitCell::ScShrinkToFitCell(bool bShrink)
775 : SfxBoolItem(ATTR_SHRINKTOFIT, bShrink, SfxItemType::ScShrinkToFitCellType)
779 ScShrinkToFitCell* ScShrinkToFitCell::Clone(SfxItemPool*) const
781 return new ScShrinkToFitCell(GetValue());
784 bool ScShrinkToFitCell::GetPresentation(SfxItemPresentation,
785 MapUnit, MapUnit,
786 OUString& rText,
787 const IntlWrapper&) const
789 TranslateId pId = GetValue() ? STR_SHRINKTOFITCELL_ON : STR_SHRINKTOFITCELL_OFF;
790 rText = ScResId(pId);
791 return true;
794 ScVerticalStackCell::ScVerticalStackCell(bool bStack)
795 : SfxBoolItem(ATTR_STACKED, bStack, SfxItemType::ScVerticalStackCellType)
799 ScVerticalStackCell* ScVerticalStackCell::Clone(SfxItemPool*) const
801 return new ScVerticalStackCell(GetValue());
804 bool ScVerticalStackCell::GetPresentation(SfxItemPresentation,
805 MapUnit, MapUnit,
806 OUString& rText,
807 const IntlWrapper&) const
809 TranslateId pId = GetValue() ? STR_VERTICALSTACKCELL_ON : STR_VERTICALSTACKCELL_OFF;
810 rText = ScResId(pId);
811 return true;
814 ScLineBreakCell::ScLineBreakCell(bool bStack)
815 : SfxBoolItem(ATTR_LINEBREAK, bStack, SfxItemType::ScLineBreakCellType)
819 ScLineBreakCell* ScLineBreakCell::Clone(SfxItemPool*) const
821 return new ScLineBreakCell(GetValue());
824 bool ScLineBreakCell::GetPresentation(SfxItemPresentation,
825 MapUnit, MapUnit,
826 OUString& rText,
827 const IntlWrapper&) const
829 TranslateId pId = GetValue() ? STR_LINEBREAKCELL_ON : STR_LINEBREAKCELL_OFF;
830 rText = ScResId(pId);
831 return true;
834 ScHyphenateCell::ScHyphenateCell(bool bHyphenate)
835 : SfxBoolItem(ATTR_HYPHENATE, bHyphenate, SfxItemType::ScHyphenateCellType)
839 ScHyphenateCell* ScHyphenateCell::Clone(SfxItemPool*) const
841 return new ScHyphenateCell(GetValue());
844 bool ScHyphenateCell::GetPresentation(SfxItemPresentation,
845 MapUnit, MapUnit,
846 OUString& rText,
847 const IntlWrapper&) const
849 TranslateId pId = GetValue() ? STR_HYPHENATECELL_ON : STR_HYPHENATECELL_OFF;
850 rText = ScResId(pId);
851 return true;
854 ScIndentItem::ScIndentItem(sal_uInt16 nIndent)
855 : SfxUInt16Item(ATTR_INDENT, nIndent, SfxItemType::ScIndentItemType)
859 ScIndentItem* ScIndentItem::Clone(SfxItemPool*) const
861 return new ScIndentItem(GetValue());
864 bool ScIndentItem::GetPresentation(SfxItemPresentation ePres,
865 MapUnit eCoreUnit, MapUnit,
866 OUString& rText,
867 const IntlWrapper& rIntl) const
869 auto nValue = GetValue();
871 switch (ePres)
873 case SfxItemPresentation::Complete:
874 rText = ScResId(STR_INDENTCELL);
875 [[fallthrough]];
876 case SfxItemPresentation::Nameless:
877 rText += GetMetricText( nValue, eCoreUnit, MapUnit::MapPoint, &rIntl ) +
878 " " + EditResId(GetMetricId(MapUnit::MapPoint));
879 return true;
880 default: ; //prevent warning
882 return false;
885 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */