Update ooo320-m1
[ooovba.git] / applied_patches / 0021-cws-koheichart02-xmloff.diff
blobf0d12f3f477e8b5f24e199e0450252eab5e7377c
1 diff --git xmloff/source/chart/SchXMLChartContext.cxx xmloff/source/chart/SchXMLChartContext.cxx
2 index 5125a37..04a5505 100644
3 --- xmloff/source/chart/SchXMLChartContext.cxx
4 +++ xmloff/source/chart/SchXMLChartContext.cxx
5 @@ -71,13 +71,17 @@
6 #include <com/sun/star/chart2/data/XDataSink.hpp>
7 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
8 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
9 +#include <com/sun/star/chart2/XCoordinateSystem.hpp>
10 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
11 +#include <com/sun/star/chart2/XChartType.hpp>
12 #include <com/sun/star/chart2/XTitled.hpp>
14 using namespace com::sun::star;
15 using namespace ::xmloff::token;
16 using ::rtl::OUString;
17 using com::sun::star::uno::Reference;
18 +using ::com::sun::star::uno::Sequence;
19 +using ::com::sun::star::uno::UNO_QUERY;
20 using namespace ::SchXMLTools;
22 namespace
23 @@ -767,6 +771,48 @@ void lcl_ApplyDataFromRectangularRangeToDiagram(
24 xTemplate->changeDiagramData( xNewDia, xDataSource, aArgs );
27 +static void lcl_setStackTypeToAllChartTypes(
28 + const Reference<chart2::XDiagram>& rDiagram, const uno::Any& rStacked, const uno::Any& rPercent)
30 + Reference<chart2::XCoordinateSystemContainer> xCoordContainer(rDiagram, uno::UNO_QUERY);
31 + if (!xCoordContainer.is())
32 + return;
34 + Sequence< Reference<chart2::XCoordinateSystem> > xCoords = xCoordContainer->getCoordinateSystems();
36 + sal_Int32 n = xCoords.getLength();
37 + if (!n)
38 + return;
40 + for (sal_Int32 i = 0; i < n; ++i)
41 + {
42 + Reference<chart2::XChartTypeContainer> xChartTypeContainer(xCoords[i], UNO_QUERY);
43 + if (!xChartTypeContainer.is())
44 + continue;
46 + Sequence< Reference<chart2::XChartType> > xChartTypes = xChartTypeContainer->getChartTypes();
47 + sal_Int32 nChartTypeCount = xChartTypes.getLength();
48 + for (sal_Int32 j = 0; j < nChartTypeCount; ++j)
49 + {
50 + Reference<beans::XPropertySet> xProp(xChartTypes[j], UNO_QUERY);
51 + if (!xProp.is())
52 + continue;
54 + try
55 + {
56 + if (rStacked.hasValue())
57 + xProp->setPropertyValue(OUString::createFromAscii("Stacked"), rStacked);
58 + if (rPercent.hasValue())
59 + xProp->setPropertyValue(OUString::createFromAscii("Percent"), rPercent);
60 + }
61 + catch (const beans::UnknownPropertyException&)
62 + {
63 + // fail silently.
64 + }
65 + }
66 + }
69 void SchXMLChartContext::EndElement()
71 uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument();
72 @@ -952,6 +998,11 @@ void SchXMLChartContext::EndElement()
73 , SchXMLSeriesHelper::getDataSeriesIndexMapFromDiagram(xNewDiagram) );
76 + // For now, set the diagram's stack-related properties to all included
77 + // chart types until we support chart types of mixed stack states.
78 + lcl_setStackTypeToAllChartTypes(
79 + xNewDoc->getFirstDiagram(), maSeriesDefaultsAndStyles.maStackedDefault, maSeriesDefaultsAndStyles.maPercentDefault);
81 SchXMLSeries2Context::initSeriesPropertySets( maSeriesDefaultsAndStyles, uno::Reference< frame::XModel >(xDoc, uno::UNO_QUERY ) );
83 //set defaults from diagram to the new series: