/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "ChartColorWrapper.hxx" #include "ChartController.hxx" #include #include #include namespace chart { namespace sidebar { namespace { OUString getCID(css::uno::Reference xModel) { css::uno::Reference xController(xModel->getCurrentController()); css::uno::Reference xSelectionSupplier(xController, css::uno::UNO_QUERY); if (!xSelectionSupplier.is()) return OUString(); css::uno::Any aAny = xSelectionSupplier->getSelection(); if (!aAny.hasValue()) return OUString(); OUString aCID; aAny >>= aCID; return aCID; } css::uno::Reference getPropSet( css::uno::Reference xModel) { OUString aCID = getCID(xModel); css::uno::Reference xPropSet = ObjectIdentifier::getObjectPropertySet(aCID, xModel); ObjectType eType = ObjectIdentifier::getObjectType(aCID); if (eType == OBJECTTYPE_DIAGRAM) { css::uno::Reference xDiagram( xPropSet, css::uno::UNO_QUERY); if (!xDiagram.is()) return xPropSet; xPropSet.set(xDiagram->getWall()); } return xPropSet; } } ChartColorWrapper::ChartColorWrapper( css::uno::Reference xModel, SvxColorToolBoxControl* pControl): mxModel(xModel), mpControl(pControl), maPropertyName("FillColor") { } void ChartColorWrapper::operator()(const OUString& , const Color& rColor) { css::uno::Reference xPropSet = getPropSet(mxModel); assert(xPropSet.is()); xPropSet->setPropertyValue(maPropertyName, css::uno::makeAny(rColor.GetColor())); } void ChartColorWrapper::updateModel(css::uno::Reference xModel) { mxModel = xModel; } void ChartColorWrapper::updateData() { css::uno::Reference xPropSet = getPropSet(mxModel); if (!xPropSet.is()) return; css::uno::Any aAny = xPropSet->getPropertyValue(maPropertyName); sal_uInt32 nColor = 0; aAny >>= nColor; Color aColor(nColor); SvxColorItem aItem(aColor, SID_ATTR_FILL_COLOR); mpControl->StateChanged(SID_ATTR_FILL_COLOR, SfxItemState::SET, &aItem); } } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */