summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-07-24 13:37:15 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-07-26 00:27:00 +0200
commit8ab10c27be8ab33e5cf355ab91f6783175184784 (patch)
tree35f723cfd2c4325f61da56b1eab21ff691b01029 /chart2
parentb5c0f852b51dd8b0e9b8bf65fbaa18bc61558107 (diff)
update hatch in chart sidebar
There is a huge level of insanity in the hatch handling. Apparently different parts of the code use different case of the hatch id which makes it difficult to handle it. Change-Id: I5674e21a6c9a2d01d7b641473e00ab5e2bcaffd4
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/sidebar/ChartAreaPanel.cxx75
1 files changed, 62 insertions, 13 deletions
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 9e1b5e83f2c6..966a9fda0ffa 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -43,33 +43,76 @@ css::uno::Reference<css::beans::XPropertySet> getPropSet(
return ObjectIdentifier::getObjectPropertySet(aCID, xModel);
}
-XGradient getXGradientForName(css::uno::Reference<css::frame::XModel> xModel,
- const OUString& rName)
+ViewElementListProvider getViewElementListProvider( css::uno::Reference<css::frame::XModel> xModel)
{
css::uno::Reference<css::frame::XController>xController = xModel->getCurrentController();
if (!xController.is())
- return XGradient();
+ throw std::exception();
ChartController* pController = dynamic_cast<ChartController*>(xController.get());
if (!pController)
- return XGradient();
+ throw std::exception();
ViewElementListProvider aProvider = pController->getViewElementListProvider();
- XGradientListRef aRef = aProvider.GetGradientList();
- size_t n = aRef->Count();
- for (size_t i = 0; i < n; ++i)
- {
- XGradientEntry* pGradient = aRef->GetGradient(i);
- if (!pGradient)
- continue;
+ return aProvider;
+}
- if (pGradient->GetName() == rName)
- return XGradient(pGradient->GetGradient());
+XGradient getXGradientForName(css::uno::Reference<css::frame::XModel> xModel,
+ const OUString& rName)
+{
+ try
+ {
+ ViewElementListProvider aProvider = getViewElementListProvider(xModel);
+ XGradientListRef aRef = aProvider.GetGradientList();
+ size_t n = aRef->Count();
+ for (size_t i = 0; i < n; ++i)
+ {
+ XGradientEntry* pGradient = aRef->GetGradient(i);
+ if (!pGradient)
+ continue;
+
+ if (pGradient->GetName() == rName)
+ return XGradient(pGradient->GetGradient());
+ }
+ }
+ catch (...)
+ {
+ // ignore exception
}
return XGradient();
}
+XHatch getXHatchFromName(css::uno::Reference<css::frame::XModel> xModel,
+ OUString& rName)
+{
+ try
+ {
+ ViewElementListProvider aProvider = getViewElementListProvider(xModel);
+ XHatchListRef aRef = aProvider.GetHatchList();
+ size_t n = aRef->Count();
+ for (size_t i = 0; i < n; ++i)
+ {
+ XHatchEntry* pHatch = aRef->GetHatch(i);
+ if (!pHatch)
+ continue;
+
+ if (pHatch->GetName().equalsIgnoreAsciiCase(rName))
+ {
+ // we need to update the hatch name
+ rName = pHatch->GetName();
+ return XHatch(pHatch->GetHatch());
+ }
+ }
+ }
+ catch (...)
+ {
+ // ignore exception
+ }
+
+ return XHatch();
+}
+
class PreventUpdate
{
public:
@@ -249,6 +292,12 @@ void ChartAreaPanel::updateData()
XGradient xGradient = getXGradientForName(mxModel, aGradientName);
XFillGradientItem aGradientItem(aGradientName, xGradient);
updateFillGradient(false, true, &aGradientItem);
+
+ OUString aHatchName;
+ xPropSet->getPropertyValue("HatchName") >>= aHatchName;
+ XHatch xHatch = getXHatchFromName(mxModel, aHatchName);
+ XFillHatchItem aHatchItem(aHatchName, xHatch);
+ updateFillHatch(false, true, &aHatchItem);
}
void ChartAreaPanel::modelInvalid()