diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-04-03 04:33:18 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-04-03 17:44:23 +0200 |
commit | eedf546acb878cb7c5856d33aad7496c1ad23269 (patch) | |
tree | 95942d461cb03e918e9ae2081939af4ca027509a /sc | |
parent | be8e63cdded81446810dce46c98518b0a6b52711 (diff) |
correct implementation
Change-Id: Ie195e46e1cb14b39875efd1c9689db0f13968e87
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/unoobj/condformatuno.cxx | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index ce46c429edc1..8efdc9475514 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -332,16 +332,35 @@ void ScCondFormatsObj::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint) } } -sal_Int32 ScCondFormatsObj::createByRange(const uno::Reference< sheet::XSheetCellRanges >& /*xRanges*/) +sal_Int32 ScCondFormatsObj::createByRange(const uno::Reference< sheet::XSheetCellRanges >& xRanges) throw(uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - /* - ScCondFormatObj* pFormatObj = ScCondFormatObj::getImplementation(xCondFormat); - ScConditionalFormat* pFormat = pFormatObj->getCoreObject(); - mpFormatList->InsertNew(pFormat); - */ - return 0; + if (!mpDocShell) + throw lang::IllegalArgumentException(); + + if (!xRanges.is()) + throw lang::IllegalArgumentException(); + + uno::Sequence<table::CellRangeAddress> aRanges = + xRanges->getRangeAddresses(); + + ScRangeList aCoreRange; + for (sal_Int32 i = 0, n = aRanges.getLength(); i < n; ++i) + { + ScRange aRange; + ScUnoConversion::FillScRange(aRange, aRanges[i]); + aCoreRange.Join(aRange); + } + + if (aCoreRange.empty()) + throw lang::IllegalArgumentException(); + + SCTAB nTab = aCoreRange[0]->aStart.Tab(); + + ScConditionalFormat* pNewFormat = new ScConditionalFormat(0, &mpDocShell->GetDocument()); + pNewFormat->SetRange(aCoreRange); + return mpDocShell->GetDocument().AddCondFormat(pNewFormat, nTab); } void ScCondFormatsObj::removeByID(const sal_Int32 nID) |