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/.
10 #include "condformatuno.hxx"
12 #include "document.hxx"
13 #include "conditio.hxx"
14 #include "colorscale.hxx"
16 #include "miscuno.hxx"
17 #include "compiler.hxx"
18 #include "tokenarray.hxx"
20 #include "cellsuno.hxx"
21 #include "convuno.hxx"
23 #include <vcl/svapp.hxx>
24 #include <rtl/ustring.hxx>
26 #include <com/sun/star/sheet/DataBarAxis.hpp>
27 #include <com/sun/star/sheet/IconSetType.hpp>
28 #include <com/sun/star/sheet/DataBarAxis.hpp>
29 #include <com/sun/star/sheet/ConditionFormatOperator.hpp>
30 #include <com/sun/star/sheet/DataBarEntryType.hpp>
31 #include <com/sun/star/sheet/ColorScaleEntryType.hpp>
32 #include <com/sun/star/sheet/IconSetFormatEntry.hpp>
33 #include <com/sun/star/sheet/ConditionEntryType.hpp>
34 #include <com/sun/star/sheet/DateType.hpp>
38 enum CondFormatProperties
44 const SfxItemPropertyMapEntry
* getCondFormatPropset()
46 static const SfxItemPropertyMapEntry aCondFormatPropertyMap_Impl
[] =
48 {OUString("ID"), ID
, cppu::UnoType
<sal_Int32
>::get(), 0, 0},
49 {OUString("Range"), CondFormat_Range
, cppu::UnoType
<sheet::XSheetCellRanges
>::get(), 0, 0},
50 {OUString(), 0, css::uno::Type(), 0, 0}
52 return aCondFormatPropertyMap_Impl
;
55 enum ConditionEntryProperties
63 const SfxItemPropertyMapEntry
* getConditionEntryrPropSet()
65 static const SfxItemPropertyMapEntry aConditionEntryPropertyMap_Impl
[] =
67 {OUString("StyleName"), StyleName
, cppu::UnoType
<OUString
>::get(), 0, 0},
68 {OUString("Formula1"), Formula1
, cppu::UnoType
<OUString
>::get(), 0, 0},
69 {OUString("Formula2"), Formula2
, cppu::UnoType
<OUString
>::get(), 0, 0},
70 {OUString("Operator"), Operator
, cppu::UnoType
<decltype(sheet::ConditionFormatOperator::EQUAL
)>::get(), 0, 0 },
71 {OUString(), 0, css::uno::Type(), 0, 0}
73 return aConditionEntryPropertyMap_Impl
;
76 struct ConditionEntryApiMap
78 ScConditionMode eMode
;
82 ConditionEntryApiMap aConditionEntryMap
[] =
84 {SC_COND_EQUAL
, sheet::ConditionFormatOperator::EQUAL
},
85 {SC_COND_LESS
, sheet::ConditionFormatOperator::LESS
},
86 {SC_COND_GREATER
, sheet::ConditionFormatOperator::GREATER
},
87 {SC_COND_EQLESS
, sheet::ConditionFormatOperator::LESS_EQUAL
},
88 {SC_COND_EQGREATER
, sheet::ConditionFormatOperator::GREATER_EQUAL
},
89 {SC_COND_NOTEQUAL
, sheet::ConditionFormatOperator::NOT_EQUAL
},
90 {SC_COND_BETWEEN
, sheet::ConditionFormatOperator::BETWEEN
},
91 {SC_COND_NOTBETWEEN
, sheet::ConditionFormatOperator::NOT_BETWEEN
},
92 {SC_COND_DUPLICATE
, sheet::ConditionFormatOperator::DUPLICATE
},
93 {SC_COND_NOTDUPLICATE
, sheet::ConditionFormatOperator::UNIQUE
},
94 {SC_COND_DIRECT
, sheet::ConditionFormatOperator::EXPRESSION
},
95 {SC_COND_TOP10
, sheet::ConditionFormatOperator::TOP_N_ELEMENTS
},
96 {SC_COND_BOTTOM10
, sheet::ConditionFormatOperator::BOTTOM_N_ELEMENTS
},
97 {SC_COND_TOP_PERCENT
, sheet::ConditionFormatOperator::TOP_N_PERCENT
},
98 {SC_COND_BOTTOM_PERCENT
, sheet::ConditionFormatOperator::BOTTOM_N_PERCENT
},
99 {SC_COND_ABOVE_AVERAGE
, sheet::ConditionFormatOperator::ABOVE_AVERAGE
},
100 {SC_COND_BELOW_AVERAGE
, sheet::ConditionFormatOperator::BELOW_AVERAGE
},
101 {SC_COND_ABOVE_EQUAL_AVERAGE
, sheet::ConditionFormatOperator::ABOVE_EQUAL_AVERAGE
},
102 {SC_COND_BELOW_EQUAL_AVERAGE
, sheet::ConditionFormatOperator::BELOW_EQUAL_AVERAGE
},
103 {SC_COND_ERROR
, sheet::ConditionFormatOperator::ERROR
},
104 {SC_COND_NOERROR
, sheet::ConditionFormatOperator::NO_ERROR
},
105 {SC_COND_BEGINS_WITH
, sheet::ConditionFormatOperator::BEGINS_WITH
},
106 {SC_COND_ENDS_WITH
, sheet::ConditionFormatOperator::ENDS_WITH
},
107 {SC_COND_CONTAINS_TEXT
, sheet::ConditionFormatOperator::CONTAINS
},
108 {SC_COND_NOT_CONTAINS_TEXT
, sheet::ConditionFormatOperator::NOT_CONTAINS
},
109 {SC_COND_NONE
, sheet::ConditionFormatOperator::EQUAL
},
112 enum ColorScaleProperties
117 const SfxItemPropertyMapEntry
* getColorScalePropSet()
119 static const SfxItemPropertyMapEntry aColorScalePropertyMap_Impl
[] =
121 {OUString("ColorScaleEntries"), ColorScaleEntries
, cppu::UnoType
<uno::Sequence
< sheet::XColorScaleEntry
>>::get(), 0, 0 },
122 {OUString(), 0, css::uno::Type(), 0, 0}
124 return aColorScalePropertyMap_Impl
;
127 struct ColorScaleEntryTypeApiMap
129 ScColorScaleEntryType eType
;
133 ColorScaleEntryTypeApiMap aColorScaleEntryTypeMap
[] =
135 { COLORSCALE_MIN
, sheet::ColorScaleEntryType::COLORSCALE_MIN
},
136 { COLORSCALE_MAX
, sheet::ColorScaleEntryType::COLORSCALE_MAX
},
137 { COLORSCALE_VALUE
, sheet::ColorScaleEntryType::COLORSCALE_VALUE
},
138 { COLORSCALE_FORMULA
, sheet::ColorScaleEntryType::COLORSCALE_FORMULA
},
139 { COLORSCALE_PERCENT
, sheet::ColorScaleEntryType::COLORSCALE_PERCENT
},
140 { COLORSCALE_PERCENTILE
, sheet::ColorScaleEntryType::COLORSCALE_PERCENTILE
}
143 enum DataBarProperties
157 const SfxItemPropertyMapEntry
* getDataBarPropSet()
159 static const SfxItemPropertyMapEntry aDataBarPropertyMap_Impl
[] =
161 {OUString("AxisPosition"), AxisPosition
, cppu::UnoType
<decltype(sheet::DataBarAxis::AXIS_AUTOMATIC
)>::get(), 0, 0 },
162 {OUString("UseGradient"), UseGradient
, cppu::UnoType
<bool>::get(), 0, 0 },
163 {OUString("UseNegativeColor"), UseNegativeColor
, cppu::UnoType
<bool>::get(), 0, 0 },
164 {OUString("ShowValue"), DataBar_ShowValue
, cppu::UnoType
<bool>::get(), 0, 0 },
165 {OUString("Color"), DataBar_Color
, cppu::UnoType
<sal_Int32
>::get(), 0, 0},
166 {OUString("AxisColor"), AxisColor
, cppu::UnoType
<sal_Int32
>::get(), 0, 0},
167 {OUString("NegativeColor"), NegativeColor
, cppu::UnoType
<sal_Int32
>::get(), 0, 0},
168 {OUString("DataBarEntries"), DataBarEntries
, cppu::UnoType
<uno::Sequence
< sheet::XDataBarEntry
>>::get(), 0, 0 },
169 {OUString("MinimumLength"), MinimumLength
, cppu::UnoType
<double>::get(), 0, 0 },
170 {OUString("MaximumLength"), MaximumLength
, cppu::UnoType
<double>::get(), 0, 0 },
171 {OUString(), 0, css::uno::Type(), 0, 0}
173 return aDataBarPropertyMap_Impl
;
176 struct DataBarAxisApiMap
178 databar::ScAxisPosition ePos
;
182 DataBarAxisApiMap aDataBarAxisMap
[] =
184 { databar::NONE
, sheet::DataBarAxis::AXIS_NONE
},
185 { databar::AUTOMATIC
, sheet::DataBarAxis::AXIS_AUTOMATIC
},
186 { databar::MIDDLE
, sheet::DataBarAxis::AXIS_MIDDLE
}
189 struct DataBarEntryTypeApiMap
191 ScColorScaleEntryType eType
;
195 DataBarEntryTypeApiMap aDataBarEntryTypeMap
[] =
197 { COLORSCALE_AUTO
, sheet::DataBarEntryType::DATABAR_AUTO
},
198 { COLORSCALE_MIN
, sheet::DataBarEntryType::DATABAR_MIN
},
199 { COLORSCALE_MAX
, sheet::DataBarEntryType::DATABAR_MAX
},
200 { COLORSCALE_VALUE
, sheet::DataBarEntryType::DATABAR_VALUE
},
201 { COLORSCALE_FORMULA
, sheet::DataBarEntryType::DATABAR_FORMULA
},
202 { COLORSCALE_PERCENT
, sheet::DataBarEntryType::DATABAR_PERCENT
},
203 { COLORSCALE_PERCENTILE
, sheet::DataBarEntryType::DATABAR_PERCENTILE
}
206 enum IconSetProperties
214 const SfxItemPropertyMapEntry
* getIconSetPropSet()
216 static const SfxItemPropertyMapEntry aIconSetPropertyMap_Impl
[] =
218 {OUString("Icons"), Icons
, cppu::UnoType
<decltype(sheet::IconSetType::ICONSET_3SYMBOLS
)>::get(), 0, 0 },
219 {OUString("Reverse"), Reverse
, cppu::UnoType
<bool>::get(), 0, 0 },
220 {OUString("ShowValue"), ShowValue
, cppu::UnoType
<bool>::get(), 0, 0 },
221 {OUString("IconSetEntries"), IconSetEntries
, cppu::UnoType
<uno::Sequence
< sheet::XIconSetEntry
>>::get(), 0, 0 },
222 {OUString(), 0, css::uno::Type(), 0, 0}
224 return aIconSetPropertyMap_Impl
;
227 struct IconSetTypeApiMap
233 const IconSetTypeApiMap aIconSetApiMap
[] =
235 { IconSet_3Arrows
, sheet::IconSetType::ICONSET_3ARROWS
},
236 { IconSet_3ArrowsGray
, sheet::IconSetType::ICONSET_3ARROWS_GRAY
},
237 { IconSet_3Flags
, sheet::IconSetType::ICONSET_3FLAGS
},
238 { IconSet_3TrafficLights1
, sheet::IconSetType::ICONSET_3TRAFFICLIGHTS1
},
239 { IconSet_3TrafficLights2
, sheet::IconSetType::ICONSET_3TRAFFICLIGHTS2
},
240 { IconSet_3Signs
, sheet::IconSetType::ICONSET_3SIGNS
},
241 { IconSet_3Symbols
, sheet::IconSetType::ICONSET_3SYMBOLS
},
242 { IconSet_3Symbols2
, sheet::IconSetType::ICONSET_3SYMBOLS2
},
243 { IconSet_3Smilies
, sheet::IconSetType::ICONSET_3SMILIES
},
244 { IconSet_3ColorSmilies
, sheet::IconSetType::ICONSET_3COLOR_SIMILIES
},
245 { IconSet_4Arrows
, sheet::IconSetType::ICONSET_4ARROWS
},
246 { IconSet_4ArrowsGray
, sheet::IconSetType::ICONSET_4ARROWS_GRAY
},
247 { IconSet_4Rating
, sheet::IconSetType::ICONSET_4RATING
},
248 { IconSet_4RedToBlack
, sheet::IconSetType::ICONSET_4RED_TO_BLACK
},
249 { IconSet_4TrafficLights
, sheet::IconSetType::ICONSET_4TRAFFICLIGHTS
},
250 { IconSet_5Arrows
, sheet::IconSetType::ICONSET_5ARROWS
},
251 { IconSet_5ArrowsGray
, sheet::IconSetType::ICONSET_4ARROWS_GRAY
},
252 { IconSet_5Ratings
, sheet::IconSetType::ICONSET_5RATINGS
},
253 { IconSet_5Quarters
, sheet::IconSetType::ICONSET_5QUARTERS
},
256 struct IconSetEntryTypeApiMap
258 ScColorScaleEntryType eType
;
262 IconSetEntryTypeApiMap aIconSetEntryTypeMap
[] =
264 { COLORSCALE_MIN
, sheet::IconSetFormatEntry::ICONSET_MIN
},
265 { COLORSCALE_VALUE
, sheet::IconSetFormatEntry::ICONSET_VALUE
},
266 { COLORSCALE_FORMULA
, sheet::IconSetFormatEntry::ICONSET_FORMULA
},
267 { COLORSCALE_PERCENT
, sheet::IconSetFormatEntry::ICONSET_PERCENT
},
268 { COLORSCALE_PERCENTILE
, sheet::IconSetFormatEntry::ICONSET_PERCENTILE
}
277 const SfxItemPropertyMapEntry
* getCondDatePropSet()
279 static const SfxItemPropertyMapEntry aCondDatePropertyMap_Impl
[] =
281 {OUString("StyleName"), StyleName
, cppu::UnoType
<OUString
>::get(), 0, 0},
282 {OUString("DateType"), Icons
, cppu::UnoType
<decltype(sheet::DateType::TODAY
)>::get(), 0, 0 },
283 {OUString(), 0, css::uno::Type(), 0, 0}
285 return aCondDatePropertyMap_Impl
;
288 struct DateTypeApiMap
290 condformat::ScCondFormatDateType eType
;
294 DateTypeApiMap aDateTypeApiMap
[] =
296 { condformat::TODAY
, sheet::DateType::TODAY
},
297 { condformat::YESTERDAY
, sheet::DateType::YESTERDAY
},
298 { condformat::TOMORROW
, sheet::DateType::TOMORROW
},
299 { condformat::LAST7DAYS
, sheet::DateType::LAST7DAYS
},
300 { condformat::THISWEEK
, sheet::DateType::THISWEEK
},
301 { condformat::LASTWEEK
, sheet::DateType::LASTWEEK
},
302 { condformat::NEXTWEEK
, sheet::DateType::NEXTWEEK
},
303 { condformat::THISMONTH
, sheet::DateType::THISMONTH
},
304 { condformat::LASTMONTH
, sheet::DateType::LASTMONTH
},
305 { condformat::NEXTMONTH
, sheet::DateType::NEXTMONTH
},
306 { condformat::THISYEAR
, sheet::DateType::THISYEAR
},
307 { condformat::LASTYEAR
, sheet::DateType::LASTYEAR
},
308 { condformat::NEXTYEAR
, sheet::DateType::NEXTYEAR
}
313 ScCondFormatsObj::ScCondFormatsObj(ScDocShell
* pDocShell
, SCTAB nTab
):
315 mpDocShell(pDocShell
)
317 pDocShell
->GetDocument().AddUnoObject(*this);
320 ScCondFormatsObj::~ScCondFormatsObj()
323 mpDocShell
->GetDocument().RemoveUnoObject(*this);
326 void ScCondFormatsObj::Notify(SfxBroadcaster
& /*rBC*/, const SfxHint
& rHint
)
328 if ( dynamic_cast<const SfxSimpleHint
*>(&rHint
) &&
329 static_cast<const SfxSimpleHint
&>(rHint
).GetId() == SFX_HINT_DYING
)
331 mpDocShell
= NULL
; // ungueltig geworden
335 sal_Int32
ScCondFormatsObj::createByRange(const uno::Reference
< sheet::XSheetCellRanges
>& xRanges
)
336 throw(uno::RuntimeException
, std::exception
)
338 SolarMutexGuard aGuard
;
340 throw lang::IllegalArgumentException();
343 throw lang::IllegalArgumentException();
345 uno::Sequence
<table::CellRangeAddress
> aRanges
=
346 xRanges
->getRangeAddresses();
348 ScRangeList aCoreRange
;
349 for (sal_Int32 i
= 0, n
= aRanges
.getLength(); i
< n
; ++i
)
352 ScUnoConversion::FillScRange(aRange
, aRanges
[i
]);
353 aCoreRange
.Join(aRange
);
356 if (aCoreRange
.empty())
357 throw lang::IllegalArgumentException();
359 SCTAB nTab
= aCoreRange
[0]->aStart
.Tab();
361 ScConditionalFormat
* pNewFormat
= new ScConditionalFormat(0, &mpDocShell
->GetDocument());
362 pNewFormat
->SetRange(aCoreRange
);
363 return mpDocShell
->GetDocument().AddCondFormat(pNewFormat
, nTab
);
366 void ScCondFormatsObj::removeByID(const sal_Int32 nID
)
367 throw(uno::RuntimeException
, std::exception
)
369 SolarMutexGuard aGuard
;
370 ScConditionalFormatList
* pFormatList
= getCoreObject();;
371 pFormatList
->erase(nID
);
374 uno::Sequence
<uno::Reference
<sheet::XConditionalFormat
> > ScCondFormatsObj::getConditionalFormats()
375 throw(uno::RuntimeException
, std::exception
)
377 SolarMutexGuard aGuard
;
378 ScConditionalFormatList
* pFormatList
= getCoreObject();;
379 size_t n
= pFormatList
->size();
380 uno::Sequence
<uno::Reference
<sheet::XConditionalFormat
> > aCondFormats(n
);
382 for (ScConditionalFormatList::const_iterator itr
= pFormatList
->begin(); itr
!= pFormatList
->end(); ++itr
, ++i
) {
383 uno::Reference
<sheet::XConditionalFormat
> xCondFormat(new ScCondFormatObj(mpDocShell
, this, itr
->GetKey()));
384 aCondFormats
[i
] = xCondFormat
;
390 sal_Int32
ScCondFormatsObj::getLength()
391 throw(uno::RuntimeException
, std::exception
)
393 SolarMutexGuard aGuard
;
394 ScConditionalFormatList
* pFormatList
= getCoreObject();;
395 return pFormatList
->size();;
398 ScConditionalFormatList
* ScCondFormatsObj::getCoreObject()
401 throw uno::RuntimeException();
403 ScConditionalFormatList
* pList
= mpDocShell
->GetDocument().GetCondFormList(mnTab
);
405 throw uno::RuntimeException();
412 uno::Reference
<beans::XPropertySet
> createConditionEntry(const ScFormatEntry
* pEntry
,
413 rtl::Reference
<ScCondFormatObj
> xParent
)
415 switch (pEntry
->GetType())
417 case condformat::CONDITION
:
418 return new ScConditionEntryObj(xParent
,
419 static_cast<const ScCondFormatEntry
*>(pEntry
));
421 case condformat::COLORSCALE
:
422 return new ScColorScaleFormatObj(xParent
,
423 static_cast<const ScColorScaleFormat
*>(pEntry
));
425 case condformat::DATABAR
:
426 return new ScDataBarFormatObj(xParent
,
427 static_cast<const ScDataBarFormat
*>(pEntry
));
429 case condformat::ICONSET
:
430 return new ScIconSetFormatObj(xParent
,
431 static_cast<const ScIconSetFormat
*>(pEntry
));
433 case condformat::DATE
:
434 return new ScCondDateFormatObj(xParent
,
435 static_cast<const ScCondDateFormatEntry
*>(pEntry
));
440 return uno::Reference
<beans::XPropertySet
>();
445 ScCondFormatObj::ScCondFormatObj(ScDocShell
* pDocShell
, rtl::Reference
<ScCondFormatsObj
> xCondFormats
,
447 mxCondFormatList(xCondFormats
),
448 mpDocShell(pDocShell
),
449 maPropSet(getCondFormatPropset()),
454 ScCondFormatObj::~ScCondFormatObj()
458 ScConditionalFormat
* ScCondFormatObj::getCoreObject()
460 ScConditionalFormatList
* pList
= mxCondFormatList
->getCoreObject();
461 ScConditionalFormat
* pFormat
= pList
->GetFormat(mnKey
);
463 throw uno::RuntimeException();
468 ScDocShell
* ScCondFormatObj::getDocShell()
473 void ScCondFormatObj::createEntry(const sal_Int32 nType
, const sal_Int32 nPos
)
474 throw(uno::RuntimeException
, std::exception
)
476 SolarMutexGuard aGuard
;
477 ScConditionalFormat
* pFormat
= getCoreObject();
478 if (nPos
> sal_Int32(pFormat
->size()))
479 throw lang::IllegalArgumentException();
481 ScFormatEntry
* pNewEntry
= NULL
;
482 ScDocument
* pDoc
= &mpDocShell
->GetDocument();
485 case sheet::ConditionEntryType::CONDITION
:
486 pNewEntry
= new ScCondFormatEntry(SC_COND_EQUAL
, "", "",
487 pDoc
, pFormat
->GetRange().GetTopLeftCorner(), "");
489 case sheet::ConditionEntryType::COLORSCALE
:
490 pNewEntry
= new ScColorScaleFormat(pDoc
);
491 static_cast<ScColorScaleFormat
*>(pNewEntry
)->EnsureSize();
493 case sheet::ConditionEntryType::DATABAR
:
494 pNewEntry
= new ScDataBarFormat(pDoc
);
495 static_cast<ScDataBarFormat
*>(pNewEntry
)->EnsureSize();
497 case sheet::ConditionEntryType::ICONSET
:
498 pNewEntry
= new ScIconSetFormat(pDoc
);
499 static_cast<ScIconSetFormat
*>(pNewEntry
)->EnsureSize();
501 case sheet::ConditionEntryType::DATE
:
502 pNewEntry
= new ScCondDateFormatEntry(pDoc
);
505 SAL_WARN("sc", "unknown conditional format type");
506 throw lang::IllegalArgumentException();
509 pFormat
->AddEntry(pNewEntry
);
512 void ScCondFormatObj::removeByIndex(const sal_Int32 nIndex
)
513 throw(uno::RuntimeException
, std::exception
)
515 SolarMutexGuard aGuard
;
516 if (getCoreObject()->size() >= size_t(nIndex
))
517 throw lang::IllegalArgumentException();
519 getCoreObject()->RemoveEntry(nIndex
);
522 uno::Type
ScCondFormatObj::getElementType()
523 throw(uno::RuntimeException
, std::exception
)
525 return cppu::UnoType
<beans::XPropertySet
>::get();
528 sal_Bool
ScCondFormatObj::hasElements()
529 throw(uno::RuntimeException
, std::exception
)
531 SolarMutexGuard aGuard
;
532 ScConditionalFormat
* pFormat
= getCoreObject();
533 return !pFormat
->IsEmpty();
536 sal_Int32
ScCondFormatObj::getCount()
537 throw(uno::RuntimeException
, std::exception
)
539 SolarMutexGuard aGuard
;
540 ScConditionalFormat
* pFormat
= getCoreObject();
542 return pFormat
->size();
545 uno::Any
ScCondFormatObj::getByIndex(sal_Int32 nIndex
)
546 throw(uno::RuntimeException
, std::exception
)
548 SolarMutexGuard aGuard
;
549 if (getCoreObject()->size() <= size_t(nIndex
))
550 throw lang::IllegalArgumentException();
552 const ScFormatEntry
* pEntry
= getCoreObject()->GetEntry(nIndex
);
553 uno::Reference
<beans::XPropertySet
> xCondEntry
=
554 createConditionEntry(pEntry
, this);
560 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScCondFormatObj::getPropertySetInfo()
561 throw(uno::RuntimeException
, std::exception
)
563 SolarMutexGuard aGuard
;
564 static uno::Reference
<beans::XPropertySetInfo
> aRef(
565 new SfxItemPropertySetInfo( maPropSet
.getPropertyMap()));
569 void SAL_CALL
ScCondFormatObj::setPropertyValue(
570 const OUString
& aPropertyName
, const uno::Any
& aValue
)
571 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
572 lang::IllegalArgumentException
, lang::WrappedTargetException
,
573 uno::RuntimeException
, std::exception
)
575 SolarMutexGuard aGuard
;
577 const SfxItemPropertyMap
& rPropertyMap
= maPropSet
.getPropertyMap(); // from derived class
578 const SfxItemPropertySimpleEntry
* pEntry
= rPropertyMap
.getByName( aPropertyName
);
580 throw beans::UnknownPropertyException();
585 throw lang::IllegalArgumentException();
587 case CondFormat_Range
:
589 uno::Reference
<sheet::XSheetCellRanges
> xRange
;
590 if (aValue
>>= xRange
)
592 ScConditionalFormat
* pFormat
= getCoreObject();
593 uno::Sequence
<table::CellRangeAddress
> aRanges
=
594 xRange
->getRangeAddresses();
595 ScRangeList aTargetRange
;
596 for (size_t i
= 0, n
= aRanges
.getLength(); i
< n
; ++i
)
599 ScUnoConversion::FillScRange(aRange
, aRanges
[i
]);
600 aTargetRange
.Join(aRange
);
602 pFormat
->SetRange(aTargetRange
);
607 SAL_WARN("sc", "unknown property");
611 uno::Any SAL_CALL
ScCondFormatObj::getPropertyValue( const OUString
& aPropertyName
)
612 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
613 uno::RuntimeException
, std::exception
)
615 SolarMutexGuard aGuard
;
617 const SfxItemPropertyMap
& rPropertyMap
= maPropSet
.getPropertyMap(); // from derived class
618 const SfxItemPropertySimpleEntry
* pEntry
= rPropertyMap
.getByName( aPropertyName
);
620 throw beans::UnknownPropertyException();
626 aAny
<<= sal_Int32(getCoreObject()->GetKey());
628 case CondFormat_Range
:
630 const ScRangeList
& rRange
= getCoreObject()->GetRange();
631 uno::Reference
<sheet::XSheetCellRanges
> xRange
;
632 xRange
.set(new ScCellRangesObj(mpDocShell
, rRange
));
637 SAL_WARN("sc", "unknown property");
642 void SAL_CALL
ScCondFormatObj::addPropertyChangeListener( const OUString
& /* aPropertyName */,
643 const uno::Reference
<beans::XPropertyChangeListener
>& /* aListener */)
644 throw(beans::UnknownPropertyException
,
645 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
647 SAL_WARN("sc", "not implemented");
650 void SAL_CALL
ScCondFormatObj::removePropertyChangeListener( const OUString
& /* aPropertyName */,
651 const uno::Reference
<beans::XPropertyChangeListener
>& /* aListener */)
652 throw(beans::UnknownPropertyException
,
653 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
655 SAL_WARN("sc", "not implemented");
658 void SAL_CALL
ScCondFormatObj::addVetoableChangeListener( const OUString
&,
659 const uno::Reference
<beans::XVetoableChangeListener
>&)
660 throw(beans::UnknownPropertyException
,
661 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
663 SAL_WARN("sc", "not implemented");
666 void SAL_CALL
ScCondFormatObj::removeVetoableChangeListener( const OUString
&,
667 const uno::Reference
<beans::XVetoableChangeListener
>&)
668 throw(beans::UnknownPropertyException
,
669 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
671 SAL_WARN("sc", "not implemented");
676 bool isObjectStillAlive(ScConditionalFormat
* pFormat
, const ScFormatEntry
* pEntry
)
678 for(size_t i
= 0, n
= pFormat
->size(); i
< n
; ++i
)
680 if (pFormat
->GetEntry(i
) == pEntry
)
688 ScConditionEntryObj::ScConditionEntryObj(rtl::Reference
<ScCondFormatObj
> xParent
,
689 const ScCondFormatEntry
* pFormat
):
690 mpDocShell(xParent
->getDocShell()),
692 maPropSet(getConditionEntryrPropSet()),
697 ScConditionEntryObj::~ScConditionEntryObj()
701 ScCondFormatEntry
* ScConditionEntryObj::getCoreObject()
703 ScConditionalFormat
* pFormat
= mxParent
->getCoreObject();
704 if (isObjectStillAlive(pFormat
, mpFormat
))
705 return const_cast<ScCondFormatEntry
*>(mpFormat
);
707 throw lang::IllegalArgumentException();
710 sal_Int32
ScConditionEntryObj::getType()
711 throw(uno::RuntimeException
, std::exception
)
713 return sheet::ConditionEntryType::CONDITION
;
716 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScConditionEntryObj::getPropertySetInfo()
717 throw(uno::RuntimeException
, std::exception
)
719 static uno::Reference
<beans::XPropertySetInfo
> aRef(
720 new SfxItemPropertySetInfo( maPropSet
.getPropertyMap() ));
724 void SAL_CALL
ScConditionEntryObj::setPropertyValue(
725 const OUString
& aPropertyName
, const uno::Any
& aValue
)
726 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
727 lang::IllegalArgumentException
, lang::WrappedTargetException
,
728 uno::RuntimeException
, std::exception
)
730 SolarMutexGuard aGuard
;
732 const SfxItemPropertyMap
& rPropertyMap
= maPropSet
.getPropertyMap(); // from derived class
733 const SfxItemPropertySimpleEntry
* pEntry
= rPropertyMap
.getByName( aPropertyName
);
735 throw beans::UnknownPropertyException();
742 if ((aValue
>>= aStyleName
) && !aStyleName
.isEmpty())
743 getCoreObject()->UpdateStyleName(aStyleName
);
749 if ((aValue
>>= aFormula
) && !aFormula
.isEmpty())
751 ScCompiler
aComp(&mpDocShell
->GetDocument(), getCoreObject()->GetSrcPos());
752 boost::scoped_ptr
<ScTokenArray
> pArr(aComp
.CompileString(aFormula
));
753 getCoreObject()->SetFormula1(*pArr
);
760 if ((aValue
>>= aFormula
) && !aFormula
.isEmpty())
762 ScCompiler
aComp(&mpDocShell
->GetDocument(), getCoreObject()->GetSrcPos());
763 boost::scoped_ptr
<ScTokenArray
> pArr(aComp
.CompileString(aFormula
));
764 getCoreObject()->SetFormula2(*pArr
);
773 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aConditionEntryMap
); ++i
)
775 if (aConditionEntryMap
[i
].nApiMode
== nVal
)
777 getCoreObject()->SetOperation(aConditionEntryMap
[i
].eMode
);
785 SAL_WARN("sc", "unsupported property");
789 uno::Any SAL_CALL
ScConditionEntryObj::getPropertyValue( const OUString
& aPropertyName
)
790 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
791 uno::RuntimeException
, std::exception
)
793 SolarMutexGuard aGuard
;
795 const SfxItemPropertyMap
& rPropertyMap
= maPropSet
.getPropertyMap(); // from derived class
796 const SfxItemPropertySimpleEntry
* pEntry
= rPropertyMap
.getByName( aPropertyName
);
798 throw beans::UnknownPropertyException();
804 aAny
<<= getCoreObject()->GetStyle();
808 ScAddress aCursor
= getCoreObject()->GetSrcPos();
809 OUString aFormula
= getCoreObject()->GetExpression(aCursor
, 0);
815 ScAddress aCursor
= getCoreObject()->GetSrcPos();
816 OUString aFormula
= getCoreObject()->GetExpression(aCursor
, 1);
822 ScConditionMode eMode
= getCoreObject()->GetOperation();
823 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aConditionEntryMap
); ++i
)
825 if (aConditionEntryMap
[i
].eMode
== eMode
)
827 aAny
<<= aConditionEntryMap
[i
].nApiMode
;
834 SAL_WARN("sc", "unsupported property");
839 void SAL_CALL
ScConditionEntryObj::addPropertyChangeListener( const OUString
& /* aPropertyName */,
840 const uno::Reference
<beans::XPropertyChangeListener
>& /* aListener */)
841 throw(beans::UnknownPropertyException
,
842 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
844 SAL_WARN("sc", "not implemented");
847 void SAL_CALL
ScConditionEntryObj::removePropertyChangeListener( const OUString
& /* aPropertyName */,
848 const uno::Reference
<beans::XPropertyChangeListener
>& /* aListener */)
849 throw(beans::UnknownPropertyException
,
850 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
852 SAL_WARN("sc", "not implemented");
855 void SAL_CALL
ScConditionEntryObj::addVetoableChangeListener( const OUString
&,
856 const uno::Reference
<beans::XVetoableChangeListener
>&)
857 throw(beans::UnknownPropertyException
,
858 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
860 SAL_WARN("sc", "not implemented");
863 void SAL_CALL
ScConditionEntryObj::removeVetoableChangeListener( const OUString
&,
864 const uno::Reference
<beans::XVetoableChangeListener
>&)
865 throw(beans::UnknownPropertyException
,
866 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
868 SAL_WARN("sc", "not implemented");
871 ScColorScaleFormatObj::ScColorScaleFormatObj(rtl::Reference
<ScCondFormatObj
> xParent
,
872 const ScColorScaleFormat
* pFormat
):
873 mpDocShell(xParent
->getDocShell()),
875 maPropSet(getColorScalePropSet()),
880 ScColorScaleFormatObj::~ScColorScaleFormatObj()
884 ScColorScaleFormat
* ScColorScaleFormatObj::getCoreObject()
886 ScConditionalFormat
* pFormat
= mxParent
->getCoreObject();
887 if (isObjectStillAlive(pFormat
, mpFormat
))
888 return const_cast<ScColorScaleFormat
*>(mpFormat
);
890 throw lang::IllegalArgumentException();
893 sal_Int32
ScColorScaleFormatObj::getType()
894 throw(uno::RuntimeException
, std::exception
)
896 return sheet::ConditionEntryType::COLORSCALE
;
899 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScColorScaleFormatObj::getPropertySetInfo()
900 throw(uno::RuntimeException
, std::exception
)
902 static uno::Reference
<beans::XPropertySetInfo
> aRef(
903 new SfxItemPropertySetInfo( maPropSet
.getPropertyMap() ));
909 void setColorScaleEntry(ScColorScaleEntry
* pEntry
, uno::Reference
<sheet::XColorScaleEntry
> xEntry
)
911 ScColorScaleEntryType eType
= ScColorScaleEntryType();
912 sal_Int32 nApiType
= xEntry
->getType();
914 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aColorScaleEntryTypeMap
); ++i
)
916 if (aColorScaleEntryTypeMap
[i
].nApiType
== nApiType
)
918 eType
= aColorScaleEntryTypeMap
[i
].eType
;
925 throw lang::IllegalArgumentException();
927 pEntry
->SetType(eType
);
928 pEntry
->SetColor(xEntry
->getColor());
931 case COLORSCALE_FORMULA
:
936 double nVal
= xEntry
->getFormula().toDouble();
937 pEntry
->SetValue(nVal
);
945 void SAL_CALL
ScColorScaleFormatObj::setPropertyValue(
946 const OUString
& aPropertyName
, const uno::Any
& aValue
)
947 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
948 lang::IllegalArgumentException
, lang::WrappedTargetException
,
949 uno::RuntimeException
, std::exception
)
951 SolarMutexGuard aGuard
;
953 const SfxItemPropertyMap
& rPropertyMap
= maPropSet
.getPropertyMap(); // from derived class
954 const SfxItemPropertySimpleEntry
* pEntry
= rPropertyMap
.getByName( aPropertyName
);
956 throw beans::UnknownPropertyException();
960 case ColorScaleEntries
:
962 uno::Sequence
<uno::Reference
<sheet::XColorScaleEntry
> > aEntries
;
963 if (aValue
>>= aEntries
)
965 if (aEntries
.getLength() < 2)
966 throw lang::IllegalArgumentException();
968 // TODO: we need to make sure that there are enough entries
969 size_t n
= size_t(aEntries
.getLength());
970 for (size_t i
= 0; i
< n
; ++i
)
972 setColorScaleEntry(getCoreObject()->GetEntry(i
), aEntries
[i
]);
976 throw lang::IllegalArgumentException();
980 SAL_WARN("sc", "unknown property");
984 uno::Any SAL_CALL
ScColorScaleFormatObj::getPropertyValue( const OUString
& aPropertyName
)
985 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
986 uno::RuntimeException
, std::exception
)
988 SolarMutexGuard aGuard
;
990 const SfxItemPropertyMap
& rPropertyMap
= maPropSet
.getPropertyMap(); // from derived class
991 const SfxItemPropertySimpleEntry
* pEntry
= rPropertyMap
.getByName( aPropertyName
);
993 throw beans::UnknownPropertyException();
999 case ColorScaleEntries
:
1001 uno::Sequence
<uno::Reference
<sheet::XColorScaleEntry
> > aEntries(getCoreObject()->size());
1002 for (size_t i
= 0; i
< getCoreObject()->size(); ++i
)
1004 aEntries
[i
] = new ScColorScaleEntryObj(this, i
);
1010 SAL_WARN("sc", "unknown property");
1016 void SAL_CALL
ScColorScaleFormatObj::addPropertyChangeListener( const OUString
& /* aPropertyName */,
1017 const uno::Reference
<beans::XPropertyChangeListener
>& /* aListener */)
1018 throw(beans::UnknownPropertyException
,
1019 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
1021 SAL_WARN("sc", "not implemented");
1024 void SAL_CALL
ScColorScaleFormatObj::removePropertyChangeListener( const OUString
& /* aPropertyName */,
1025 const uno::Reference
<beans::XPropertyChangeListener
>& /* aListener */)
1026 throw(beans::UnknownPropertyException
,
1027 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
1029 SAL_WARN("sc", "not implemented");
1032 void SAL_CALL
ScColorScaleFormatObj::addVetoableChangeListener( const OUString
&,
1033 const uno::Reference
<beans::XVetoableChangeListener
>&)
1034 throw(beans::UnknownPropertyException
,
1035 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
1037 SAL_WARN("sc", "not implemented");
1040 void SAL_CALL
ScColorScaleFormatObj::removeVetoableChangeListener( const OUString
&,
1041 const uno::Reference
<beans::XVetoableChangeListener
>&)
1042 throw(beans::UnknownPropertyException
,
1043 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
1045 SAL_WARN("sc", "not implemented");
1048 ScColorScaleEntryObj::ScColorScaleEntryObj(rtl::Reference
<ScColorScaleFormatObj
> xParent
,
1055 ScColorScaleEntryObj::~ScColorScaleEntryObj()
1059 ScColorScaleEntry
* ScColorScaleEntryObj::getCoreObject()
1061 ScColorScaleFormat
* pFormat
= mxParent
->getCoreObject();
1062 if (pFormat
->size() <= mnPos
)
1063 throw lang::IllegalArgumentException();
1065 return pFormat
->GetEntry(mnPos
);
1068 util::Color
ScColorScaleEntryObj::getColor()
1069 throw(uno::RuntimeException
, std::exception
)
1071 Color aColor
= getCoreObject()->GetColor();
1072 return aColor
.GetColor();
1075 void ScColorScaleEntryObj::setColor(util::Color aColor
)
1076 throw(uno::RuntimeException
, std::exception
)
1078 getCoreObject()->SetColor(Color(aColor
));
1081 sal_Int32
ScColorScaleEntryObj::getType()
1082 throw(uno::RuntimeException
, std::exception
)
1084 ScColorScaleEntry
* pEntry
= getCoreObject();
1085 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aColorScaleEntryTypeMap
); ++i
)
1087 if (aColorScaleEntryTypeMap
[i
].eType
== pEntry
->GetType())
1089 return aColorScaleEntryTypeMap
[i
].nApiType
;
1093 throw lang::IllegalArgumentException();
1096 void ScColorScaleEntryObj::setType(sal_Int32 nType
)
1097 throw(uno::RuntimeException
, std::exception
)
1099 ScColorScaleEntry
* pEntry
= getCoreObject();
1100 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aColorScaleEntryTypeMap
); ++i
)
1102 if (aColorScaleEntryTypeMap
[i
].nApiType
== nType
)
1104 pEntry
->SetType(aColorScaleEntryTypeMap
[i
].eType
);
1108 throw lang::IllegalArgumentException();
1111 OUString
ScColorScaleEntryObj::getFormula()
1112 throw(uno::RuntimeException
, std::exception
)
1114 ScColorScaleEntry
* pEntry
= getCoreObject();
1115 switch (pEntry
->GetType())
1117 case COLORSCALE_FORMULA
:
1121 return OUString::number(pEntry
->GetValue());
1127 void ScColorScaleEntryObj::setFormula(const OUString
& rFormula
)
1128 throw(uno::RuntimeException
, std::exception
)
1130 ScColorScaleEntry
* pEntry
= getCoreObject();
1131 switch (pEntry
->GetType())
1133 case COLORSCALE_FORMULA
:
1135 // pEntry->SetFormula(rFormula);
1138 pEntry
->SetValue(rFormula
.toDouble());
1144 ScDataBarFormatObj::ScDataBarFormatObj(rtl::Reference
<ScCondFormatObj
> xParent
,
1145 const ScDataBarFormat
* pFormat
):
1146 mpDocShell(xParent
->getDocShell()),
1148 maPropSet(getDataBarPropSet()),
1153 ScDataBarFormatObj::~ScDataBarFormatObj()
1157 ScDataBarFormat
* ScDataBarFormatObj::getCoreObject()
1159 ScConditionalFormat
* pFormat
= mxParent
->getCoreObject();
1160 if (isObjectStillAlive(pFormat
, mpFormat
))
1161 return const_cast<ScDataBarFormat
*>(mpFormat
);
1163 throw lang::IllegalArgumentException();
1166 sal_Int32
ScDataBarFormatObj::getType()
1167 throw(uno::RuntimeException
, std::exception
)
1169 return sheet::ConditionEntryType::DATABAR
;
1172 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScDataBarFormatObj::getPropertySetInfo()
1173 throw(uno::RuntimeException
, std::exception
)
1175 SolarMutexGuard aGuard
;
1176 static uno::Reference
<beans::XPropertySetInfo
> aRef(
1177 new SfxItemPropertySetInfo( maPropSet
.getPropertyMap() ));
1183 void setDataBarEntry(ScColorScaleEntry
* pEntry
, uno::Reference
<sheet::XDataBarEntry
> xEntry
)
1185 ScColorScaleEntryType eType
= ScColorScaleEntryType();
1186 sal_Int32 nApiType
= xEntry
->getType();
1187 bool bFound
= false;
1188 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aDataBarEntryTypeMap
); ++i
)
1190 if (aDataBarEntryTypeMap
[i
].nApiType
== nApiType
)
1192 eType
= aDataBarEntryTypeMap
[i
].eType
;
1199 throw lang::IllegalArgumentException();
1201 pEntry
->SetType(eType
);
1204 case COLORSCALE_FORMULA
:
1209 double nVal
= xEntry
->getFormula().toDouble();
1210 pEntry
->SetValue(nVal
);
1218 void SAL_CALL
ScDataBarFormatObj::setPropertyValue(
1219 const OUString
& aPropertyName
, const uno::Any
& aValue
)
1220 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
1221 lang::IllegalArgumentException
, lang::WrappedTargetException
,
1222 uno::RuntimeException
, std::exception
)
1224 SolarMutexGuard aGuard
;
1226 const SfxItemPropertyMap
& rPropertyMap
= maPropSet
.getPropertyMap(); // from derived class
1227 const SfxItemPropertySimpleEntry
* pEntry
= rPropertyMap
.getByName( aPropertyName
);
1229 throw beans::UnknownPropertyException();
1231 switch(pEntry
->nWID
)
1236 if (aValue
>>= nVal
)
1238 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aDataBarAxisMap
); ++i
)
1240 if (aDataBarAxisMap
[i
].nApiPos
== nVal
)
1242 getCoreObject()->GetDataBarData()->meAxisPosition
=
1243 aDataBarAxisMap
[i
].ePos
;
1252 bool bUseGradient
= true;
1253 if (aValue
>>= bUseGradient
)
1255 getCoreObject()->GetDataBarData()->mbGradient
= bUseGradient
;
1259 case UseNegativeColor
:
1261 bool bUseNegativeColor
= false;
1262 if (aValue
>>= bUseNegativeColor
)
1264 getCoreObject()->GetDataBarData()->mbNeg
= bUseNegativeColor
;
1265 if (bUseNegativeColor
&& !getCoreObject()->GetDataBarData()->mpNegativeColor
)
1267 getCoreObject()->GetDataBarData()->mpNegativeColor
.reset(new Color(COL_AUTO
));
1272 case DataBar_ShowValue
:
1274 bool bShowValue
= true;
1275 if (aValue
>>= bShowValue
)
1277 getCoreObject()->GetDataBarData()->mbOnlyBar
= !bShowValue
;
1283 sal_Int32 nColor
= COL_AUTO
;
1284 if (aValue
>>= nColor
)
1286 getCoreObject()->GetDataBarData()->maPositiveColor
.SetColor(nColor
);
1292 sal_Int32 nAxisColor
= COL_AUTO
;
1293 if (aValue
>>= nAxisColor
)
1295 getCoreObject()->GetDataBarData()->maAxisColor
.SetColor(nAxisColor
);
1301 sal_Int32 nNegativeColor
= COL_AUTO
;
1302 if ((aValue
>>= nNegativeColor
) && getCoreObject()->GetDataBarData()->mbNeg
)
1304 getCoreObject()->GetDataBarData()->mpNegativeColor
->SetColor(nNegativeColor
);
1307 throw lang::IllegalArgumentException();
1310 case DataBarEntries
:
1312 uno::Sequence
<uno::Reference
<sheet::XDataBarEntry
> > aEntries
;
1313 if (aValue
>>= aEntries
)
1315 if (aEntries
.getLength() != 2)
1316 throw lang::IllegalArgumentException();
1318 setDataBarEntry(getCoreObject()->GetDataBarData()->mpLowerLimit
.get(),
1320 setDataBarEntry(getCoreObject()->GetDataBarData()->mpUpperLimit
.get(),
1324 throw lang::IllegalArgumentException();
1330 if ((aValue
>>= nLength
) && nLength
< 100 && nLength
>= 0)
1332 getCoreObject()->GetDataBarData()->mnMinLength
= nLength
;
1334 else throw lang::IllegalArgumentException();
1340 if ((aValue
>>= nLength
) && nLength
<= 100 && nLength
> 0)
1342 getCoreObject()->GetDataBarData()->mnMaxLength
= nLength
;
1344 else throw lang::IllegalArgumentException();
1350 uno::Any SAL_CALL
ScDataBarFormatObj::getPropertyValue( const OUString
& aPropertyName
)
1351 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
1352 uno::RuntimeException
, std::exception
)
1354 SolarMutexGuard aGuard
;
1356 const SfxItemPropertyMap
& rPropertyMap
= maPropSet
.getPropertyMap(); // from derived class
1357 const SfxItemPropertySimpleEntry
* pEntry
= rPropertyMap
.getByName( aPropertyName
);
1359 throw beans::UnknownPropertyException();
1362 switch(pEntry
->nWID
)
1366 databar::ScAxisPosition ePos
= getCoreObject()->GetDataBarData()->meAxisPosition
;
1367 sal_Int32 nApiPos
= sheet::DataBarAxis::AXIS_NONE
;
1368 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aDataBarAxisMap
); ++i
)
1370 if (aDataBarAxisMap
[i
].ePos
== ePos
)
1372 nApiPos
= aDataBarAxisMap
[i
].nApiPos
;
1381 aAny
<<= getCoreObject()->GetDataBarData()->mbGradient
;
1384 case UseNegativeColor
:
1386 aAny
<<= getCoreObject()->GetDataBarData()->mbNeg
;
1389 case DataBar_ShowValue
:
1391 aAny
<<= !getCoreObject()->GetDataBarData()->mbOnlyBar
;
1396 sal_Int32 nColor
= getCoreObject()->GetDataBarData()->maPositiveColor
.GetColor();
1402 sal_Int32 nAxisColor
= getCoreObject()->GetDataBarData()->maAxisColor
.GetColor();
1403 aAny
<<= nAxisColor
;
1408 if (getCoreObject()->GetDataBarData()->mbNeg
&& getCoreObject()->GetDataBarData()->mpNegativeColor
)
1410 sal_Int32 nNegativeColor
= getCoreObject()->GetDataBarData()->mpNegativeColor
->GetColor();
1411 aAny
<<= nNegativeColor
;
1415 case DataBarEntries
:
1417 uno::Sequence
<uno::Reference
<sheet::XDataBarEntry
> > aEntries(2);
1418 aEntries
[0] = new ScDataBarEntryObj(this, 0);
1419 aEntries
[1] = new ScDataBarEntryObj(this, 1);
1427 void SAL_CALL
ScDataBarFormatObj::addPropertyChangeListener( const OUString
& /* aPropertyName */,
1428 const uno::Reference
<beans::XPropertyChangeListener
>& /* aListener */)
1429 throw(beans::UnknownPropertyException
,
1430 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
1432 SAL_WARN("sc", "not implemented");
1435 void SAL_CALL
ScDataBarFormatObj::removePropertyChangeListener( const OUString
& /* aPropertyName */,
1436 const uno::Reference
<beans::XPropertyChangeListener
>& /* aListener */)
1437 throw(beans::UnknownPropertyException
,
1438 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
1440 SAL_WARN("sc", "not implemented");
1443 void SAL_CALL
ScDataBarFormatObj::addVetoableChangeListener( const OUString
&,
1444 const uno::Reference
<beans::XVetoableChangeListener
>&)
1445 throw(beans::UnknownPropertyException
,
1446 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
1448 SAL_WARN("sc", "not implemented");
1451 void SAL_CALL
ScDataBarFormatObj::removeVetoableChangeListener( const OUString
&,
1452 const uno::Reference
<beans::XVetoableChangeListener
>&)
1453 throw(beans::UnknownPropertyException
,
1454 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
1456 SAL_WARN("sc", "not implemented");
1459 ScDataBarEntryObj::ScDataBarEntryObj(rtl::Reference
<ScDataBarFormatObj
> xParent
,
1466 ScDataBarEntryObj::~ScDataBarEntryObj()
1470 ScColorScaleEntry
* ScDataBarEntryObj::getCoreObject()
1472 ScDataBarFormat
* pFormat
= mxParent
->getCoreObject();
1473 ScColorScaleEntry
* pEntry
;
1475 pEntry
= pFormat
->GetDataBarData()->mpLowerLimit
.get();
1477 pEntry
= pFormat
->GetDataBarData()->mpUpperLimit
.get();
1482 sal_Int32
ScDataBarEntryObj::getType()
1483 throw(uno::RuntimeException
, std::exception
)
1485 ScColorScaleEntry
* pEntry
= getCoreObject();
1486 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aDataBarEntryTypeMap
); ++i
)
1488 if (aDataBarEntryTypeMap
[i
].eType
== pEntry
->GetType())
1490 return aDataBarEntryTypeMap
[i
].nApiType
;
1494 throw lang::IllegalArgumentException();
1497 void ScDataBarEntryObj::setType(sal_Int32 nType
)
1498 throw(uno::RuntimeException
, std::exception
)
1500 ScColorScaleEntry
* pEntry
= getCoreObject();
1501 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aDataBarEntryTypeMap
); ++i
)
1503 if (aDataBarEntryTypeMap
[i
].nApiType
== nType
)
1505 pEntry
->SetType(aDataBarEntryTypeMap
[i
].eType
);
1509 throw lang::IllegalArgumentException();
1512 OUString
ScDataBarEntryObj::getFormula()
1513 throw(uno::RuntimeException
, std::exception
)
1515 ScColorScaleEntry
* pEntry
= getCoreObject();
1516 switch (pEntry
->GetType())
1518 case COLORSCALE_FORMULA
:
1522 return OUString::number(pEntry
->GetValue());
1528 void ScDataBarEntryObj::setFormula(const OUString
& rFormula
)
1529 throw(uno::RuntimeException
, std::exception
)
1531 ScColorScaleEntry
* pEntry
= getCoreObject();
1532 switch (pEntry
->GetType())
1534 case COLORSCALE_FORMULA
:
1536 // pEntry->SetFormula(rFormula);
1539 pEntry
->SetValue(rFormula
.toDouble());
1545 ScIconSetFormatObj::ScIconSetFormatObj(rtl::Reference
<ScCondFormatObj
> xParent
,
1546 const ScIconSetFormat
* pFormat
):
1547 mpDocShell(xParent
->getDocShell()),
1549 maPropSet(getIconSetPropSet()),
1554 ScIconSetFormatObj::~ScIconSetFormatObj()
1558 ScIconSetFormat
* ScIconSetFormatObj::getCoreObject()
1560 ScConditionalFormat
* pFormat
= mxParent
->getCoreObject();
1561 if (isObjectStillAlive(pFormat
, mpFormat
))
1562 return const_cast<ScIconSetFormat
*>(mpFormat
);
1564 throw lang::IllegalArgumentException();
1567 sal_Int32
ScIconSetFormatObj::getType()
1568 throw(uno::RuntimeException
, std::exception
)
1570 return sheet::ConditionEntryType::ICONSET
;
1573 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScIconSetFormatObj::getPropertySetInfo()
1574 throw(uno::RuntimeException
, std::exception
)
1576 SolarMutexGuard aGuard
;
1577 static uno::Reference
<beans::XPropertySetInfo
> aRef(
1578 new SfxItemPropertySetInfo( maPropSet
.getPropertyMap() ));
1584 void setIconSetEntry(ScIconSetFormat
* pFormat
, uno::Reference
<sheet::XIconSetEntry
> xEntry
, size_t nPos
)
1586 ScIconSetFormatData
* pData
= pFormat
->GetIconSetData();
1587 ScColorScaleEntryType eType
= ScColorScaleEntryType();
1588 sal_Int32 nApiType
= xEntry
->getType();
1589 bool bFound
= false;
1590 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aIconSetEntryTypeMap
); ++i
)
1592 if (aIconSetEntryTypeMap
[i
].nApiType
== nApiType
)
1594 eType
= aIconSetEntryTypeMap
[i
].eType
;
1601 throw lang::IllegalArgumentException();
1603 pData
->maEntries
[nPos
].SetType(eType
);
1606 case COLORSCALE_FORMULA
:
1611 double nVal
= xEntry
->getFormula().toDouble();
1612 pData
->maEntries
[nPos
].SetValue(nVal
);
1620 void SAL_CALL
ScIconSetFormatObj::setPropertyValue(
1621 const OUString
& aPropertyName
, const uno::Any
& aValue
)
1622 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
1623 lang::IllegalArgumentException
, lang::WrappedTargetException
,
1624 uno::RuntimeException
, std::exception
)
1626 SolarMutexGuard aGuard
;
1628 const SfxItemPropertyMap
& rPropertyMap
= maPropSet
.getPropertyMap(); // from derived class
1629 const SfxItemPropertySimpleEntry
* pEntry
= rPropertyMap
.getByName( aPropertyName
);
1631 throw beans::UnknownPropertyException();
1633 switch(pEntry
->nWID
)
1637 bool bShowValue
= true;
1638 aValue
>>= bShowValue
;
1639 getCoreObject()->GetIconSetData()->mbShowValue
= bShowValue
;
1644 bool bReverse
= false;
1645 aValue
>>= bReverse
;
1646 getCoreObject()->GetIconSetData()->mbReverse
= bReverse
;
1651 sal_Int32 nApiType
= -1;
1652 aValue
>>= nApiType
;
1653 ScIconSetType eType
= IconSet_3Arrows
;
1654 bool bFound
= false;
1655 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aIconSetApiMap
); ++i
)
1657 if (aIconSetApiMap
[i
].nApiType
== nApiType
)
1659 eType
= aIconSetApiMap
[i
].eType
;
1667 throw lang::IllegalArgumentException();
1670 // TODO: we need to make sure that there are enough entries
1671 getCoreObject()->GetIconSetData()->eIconSetType
= eType
;
1674 case IconSetEntries
:
1676 uno::Sequence
<uno::Reference
<sheet::XIconSetEntry
> > aEntries
;
1677 if (aValue
>>= aEntries
)
1679 // TODO: we need to check that the number of entries
1680 // corresponds to the icon type
1681 sal_Int32 nLength
= aEntries
.getLength();
1682 for (size_t i
= 0; i
< size_t(nLength
); ++i
)
1684 setIconSetEntry(getCoreObject(), aEntries
[i
], i
);
1688 throw lang::IllegalArgumentException();
1696 uno::Any SAL_CALL
ScIconSetFormatObj::getPropertyValue( const OUString
& aPropertyName
)
1697 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
1698 uno::RuntimeException
, std::exception
)
1700 SolarMutexGuard aGuard
;
1702 const SfxItemPropertyMap
& rPropertyMap
= maPropSet
.getPropertyMap(); // from derived class
1703 const SfxItemPropertySimpleEntry
* pEntry
= rPropertyMap
.getByName( aPropertyName
);
1705 throw beans::UnknownPropertyException();
1709 switch(pEntry
->nWID
)
1712 aAny
<<= getCoreObject()->GetIconSetData()->mbShowValue
;
1715 aAny
<<= getCoreObject()->GetIconSetData()->mbReverse
;
1719 ScIconSetType eType
= getCoreObject()->GetIconSetData()->eIconSetType
;
1720 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aIconSetApiMap
); ++i
)
1722 if (aIconSetApiMap
[i
].eType
== eType
)
1724 aAny
<<= aIconSetApiMap
[i
].nApiType
;
1730 case IconSetEntries
:
1732 uno::Sequence
<uno::Reference
<sheet::XIconSetEntry
> > aEntries(getCoreObject()->size());
1734 for (auto it
= getCoreObject()->begin(), itEnd
= getCoreObject()->end(); it
!= itEnd
; ++it
, ++i
)
1736 aEntries
[i
] = new ScIconSetEntryObj(this, i
);
1742 SAL_WARN("sc", "unknown property");
1747 void SAL_CALL
ScIconSetFormatObj::addPropertyChangeListener( const OUString
& /* aPropertyName */,
1748 const uno::Reference
<beans::XPropertyChangeListener
>& /* aListener */)
1749 throw(beans::UnknownPropertyException
,
1750 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
1752 SAL_WARN("sc", "not implemented");
1755 void SAL_CALL
ScIconSetFormatObj::removePropertyChangeListener( const OUString
& /* aPropertyName */,
1756 const uno::Reference
<beans::XPropertyChangeListener
>& /* aListener */)
1757 throw(beans::UnknownPropertyException
,
1758 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
1760 SAL_WARN("sc", "not implemented");
1763 void SAL_CALL
ScIconSetFormatObj::addVetoableChangeListener( const OUString
&,
1764 const uno::Reference
<beans::XVetoableChangeListener
>&)
1765 throw(beans::UnknownPropertyException
,
1766 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
1768 SAL_WARN("sc", "not implemented");
1771 void SAL_CALL
ScIconSetFormatObj::removeVetoableChangeListener( const OUString
&,
1772 const uno::Reference
<beans::XVetoableChangeListener
>&)
1773 throw(beans::UnknownPropertyException
,
1774 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
1776 SAL_WARN("sc", "not implemented");
1779 ScIconSetEntryObj::ScIconSetEntryObj(rtl::Reference
<ScIconSetFormatObj
> xParent
,
1786 ScIconSetEntryObj::~ScIconSetEntryObj()
1790 ScColorScaleEntry
* ScIconSetEntryObj::getCoreObject()
1792 ScIconSetFormat
* pFormat
= mxParent
->getCoreObject();
1793 if (pFormat
->GetIconSetData()->maEntries
.size() <= mnPos
)
1794 throw lang::IllegalArgumentException();
1796 return &pFormat
->GetIconSetData()->maEntries
[mnPos
];
1799 sal_Int32
ScIconSetEntryObj::getType()
1800 throw(uno::RuntimeException
, std::exception
)
1802 ScColorScaleEntry
* pEntry
= getCoreObject();
1803 // the first entry always is minimum
1805 return sheet::IconSetFormatEntry::ICONSET_MIN
;
1807 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aIconSetEntryTypeMap
); ++i
)
1809 if (aIconSetEntryTypeMap
[i
].eType
== pEntry
->GetType())
1811 return aIconSetEntryTypeMap
[i
].nApiType
;
1815 throw lang::IllegalArgumentException();
1818 void ScIconSetEntryObj::setType(sal_Int32 nType
)
1819 throw(uno::RuntimeException
, std::exception
)
1821 // first entry is always MIN
1825 ScColorScaleEntry
* pEntry
= getCoreObject();
1826 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aIconSetEntryTypeMap
); ++i
)
1828 if (aIconSetEntryTypeMap
[i
].nApiType
== nType
)
1830 pEntry
->SetType(aIconSetEntryTypeMap
[i
].eType
);
1834 throw lang::IllegalArgumentException();
1837 OUString
ScIconSetEntryObj::getFormula()
1838 throw(uno::RuntimeException
, std::exception
)
1840 ScColorScaleEntry
* pEntry
= getCoreObject();
1841 switch (pEntry
->GetType())
1843 case COLORSCALE_FORMULA
:
1847 return OUString::number(pEntry
->GetValue());
1853 void ScIconSetEntryObj::setFormula(const OUString
& rFormula
)
1854 throw(uno::RuntimeException
, std::exception
)
1856 ScColorScaleEntry
* pEntry
= getCoreObject();
1857 switch (pEntry
->GetType())
1859 case COLORSCALE_FORMULA
:
1861 // pEntry->SetFormula(rFormula);
1864 pEntry
->SetValue(rFormula
.toDouble());
1869 ScCondDateFormatObj::ScCondDateFormatObj(rtl::Reference
<ScCondFormatObj
> xParent
,
1870 const ScCondDateFormatEntry
* pFormat
):
1872 maPropSet(getCondDatePropSet()),
1877 ScCondDateFormatObj::~ScCondDateFormatObj()
1881 ScCondDateFormatEntry
* ScCondDateFormatObj::getCoreObject()
1883 ScConditionalFormat
* pFormat
= mxParent
->getCoreObject();
1884 if (isObjectStillAlive(pFormat
, mpFormat
))
1885 return const_cast<ScCondDateFormatEntry
*>(mpFormat
);
1887 throw lang::IllegalArgumentException();
1890 sal_Int32
ScCondDateFormatObj::getType()
1891 throw(uno::RuntimeException
, std::exception
)
1893 return sheet::ConditionEntryType::DATE
;
1896 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScCondDateFormatObj::getPropertySetInfo()
1897 throw(uno::RuntimeException
, std::exception
)
1899 SolarMutexGuard aGuard
;
1900 static uno::Reference
<beans::XPropertySetInfo
> aRef(
1901 new SfxItemPropertySetInfo( maPropSet
.getPropertyMap() ));
1905 void SAL_CALL
ScCondDateFormatObj::setPropertyValue(
1906 const OUString
& aPropertyName
, const uno::Any
& aValue
)
1907 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
1908 lang::IllegalArgumentException
, lang::WrappedTargetException
,
1909 uno::RuntimeException
, std::exception
)
1911 SolarMutexGuard aGuard
;
1913 const SfxItemPropertyMap
& rPropertyMap
= maPropSet
.getPropertyMap(); // from derived class
1914 const SfxItemPropertySimpleEntry
* pEntry
= rPropertyMap
.getByName( aPropertyName
);
1916 throw beans::UnknownPropertyException();
1918 switch(pEntry
->nWID
)
1920 case Date_StyleName
:
1922 OUString aStyleName
;
1923 if (aValue
>>= aStyleName
)
1925 getCoreObject()->SetStyleName(aStyleName
);
1928 throw lang::IllegalArgumentException();
1933 sal_Int32 nApiType
= -1;
1934 if (!(aValue
>>= nApiType
))
1935 throw lang::IllegalArgumentException();
1937 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aDateTypeApiMap
); ++i
)
1939 if (aDateTypeApiMap
[i
].nApiType
== nApiType
)
1941 getCoreObject()->SetDateType(aDateTypeApiMap
[i
].eType
);
1952 uno::Any SAL_CALL
ScCondDateFormatObj::getPropertyValue( const OUString
& aPropertyName
)
1953 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
1954 uno::RuntimeException
, std::exception
)
1956 SolarMutexGuard aGuard
;
1958 const SfxItemPropertyMap
& rPropertyMap
= maPropSet
.getPropertyMap(); // from derived class
1959 const SfxItemPropertySimpleEntry
* pEntry
= rPropertyMap
.getByName( aPropertyName
);
1961 throw beans::UnknownPropertyException();
1965 switch(pEntry
->nWID
)
1967 case Date_StyleName
:
1969 OUString aStyleName
= getCoreObject()->GetStyleName();
1970 aAny
<<= aStyleName
;
1975 condformat::ScCondFormatDateType eType
= getCoreObject()->GetDateType();
1976 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aDateTypeApiMap
); ++i
)
1978 if (aDateTypeApiMap
[i
].eType
== eType
)
1980 aAny
<<= aDateTypeApiMap
[i
].nApiType
;
1987 SAL_WARN("sc", "unknown property");
1992 void SAL_CALL
ScCondDateFormatObj::addPropertyChangeListener( const OUString
& /* aPropertyName */,
1993 const uno::Reference
<beans::XPropertyChangeListener
>& /* aListener */)
1994 throw(beans::UnknownPropertyException
,
1995 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
1997 SAL_WARN("sc", "not implemented");
2000 void SAL_CALL
ScCondDateFormatObj::removePropertyChangeListener( const OUString
& /* aPropertyName */,
2001 const uno::Reference
<beans::XPropertyChangeListener
>& /* aListener */)
2002 throw(beans::UnknownPropertyException
,
2003 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
2005 SAL_WARN("sc", "not implemented");
2008 void SAL_CALL
ScCondDateFormatObj::addVetoableChangeListener( const OUString
&,
2009 const uno::Reference
<beans::XVetoableChangeListener
>&)
2010 throw(beans::UnknownPropertyException
,
2011 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
2013 SAL_WARN("sc", "not implemented");
2016 void SAL_CALL
ScCondDateFormatObj::removeVetoableChangeListener( const OUString
&,
2017 const uno::Reference
<beans::XVetoableChangeListener
>&)
2018 throw(beans::UnknownPropertyException
,
2019 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
2021 SAL_WARN("sc", "not implemented");
2024 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */