xref: /AOO41X/main/xmloff/source/chart/PropertyMaps.cxx (revision 63bba73cc51e0afb45f8a8d578158724bb5afee8)
1*63bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*63bba73cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*63bba73cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*63bba73cSAndrew Rist  * distributed with this work for additional information
6*63bba73cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*63bba73cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*63bba73cSAndrew Rist  * "License"); you may not use this file except in compliance
9*63bba73cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*63bba73cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*63bba73cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*63bba73cSAndrew Rist  * software distributed under the License is distributed on an
15*63bba73cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63bba73cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*63bba73cSAndrew Rist  * specific language governing permissions and limitations
18*63bba73cSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*63bba73cSAndrew Rist  *************************************************************/
21*63bba73cSAndrew Rist 
22*63bba73cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // include PropertyMap.hxx with this define
28cdf0e10cSrcweir // to create the maps
29cdf0e10cSrcweir #ifndef _PROPERTYMAP_HXX_
30cdf0e10cSrcweir #define XML_SCH_CREATE_GLOBAL_MAPS
31cdf0e10cSrcweir #include "PropertyMap.hxx"
32cdf0e10cSrcweir #undef XML_SCH_CREATE_GLOBAL_MAPS
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include "XMLChartPropertySetMapper.hxx"
36cdf0e10cSrcweir #include "SchXMLTools.hxx"
37cdf0e10cSrcweir #include <xmloff/EnumPropertyHdl.hxx>
38cdf0e10cSrcweir #include <xmloff/XMLConstantsPropertyHandler.hxx>
39cdf0e10cSrcweir #include <xmloff/attrlist.hxx>
40cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
41cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
42cdf0e10cSrcweir #include <xmloff/shapeimport.hxx>
43cdf0e10cSrcweir #include <xmloff/NamedBoolPropertyHdl.hxx>
44cdf0e10cSrcweir #include <xmloff/xmlexp.hxx>
45cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
46cdf0e10cSrcweir #include "XMLErrorIndicatorPropertyHdl.hxx"
47cdf0e10cSrcweir #include "XMLErrorBarStylePropertyHdl.hxx"
48cdf0e10cSrcweir #include "XMLTextOrientationHdl.hxx"
49cdf0e10cSrcweir #include "XMLSymbolTypePropertyHdl.hxx"
50cdf0e10cSrcweir #include "XMLAxisPositionPropertyHdl.hxx"
51cdf0e10cSrcweir #include <com/sun/star/chart/ChartAxisMarks.hpp>
52cdf0e10cSrcweir #include <com/sun/star/chart/ChartDataCaption.hpp>
53cdf0e10cSrcweir #include <com/sun/star/chart/ChartSymbolType.hpp>
54cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp>
55cdf0e10cSrcweir #include <com/sun/star/drawing/FillStyle.hpp>
56cdf0e10cSrcweir #include <com/sun/star/drawing/LineJoint.hpp>
57cdf0e10cSrcweir #include <com/sun/star/chart/ChartDataRowSource.hpp>
58cdf0e10cSrcweir #include <com/sun/star/chart/ChartAxisPosition.hpp>
59cdf0e10cSrcweir 
60cdf0e10cSrcweir // header for any2enum
61cdf0e10cSrcweir #include <comphelper/extract.hxx>
62cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
63cdf0e10cSrcweir #include <rtl/math.hxx>
64cdf0e10cSrcweir 
65cdf0e10cSrcweir #define SCH_XML_SETFLAG( status, flag )   	(status)|= (flag)
66cdf0e10cSrcweir #define SCH_XML_UNSETFLAG( status, flag )   (status) = ((status) | (flag)) - (flag)
67cdf0e10cSrcweir 
68cdf0e10cSrcweir using namespace com::sun::star;
69cdf0e10cSrcweir using namespace ::xmloff::token;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir // the following class implementations are in this file:
72cdf0e10cSrcweir //
73cdf0e10cSrcweir // * XMLChartPropHdlFactory
74cdf0e10cSrcweir // * XMLChartPropertySetMapper
75cdf0e10cSrcweir // * XMLChartExportPropertyMapper
76cdf0e10cSrcweir // * XMLChartImportPropertyMapper
77cdf0e10cSrcweir // * SchXMLStyleExport
78cdf0e10cSrcweir 
79cdf0e10cSrcweir // ----------------------------------------
80cdf0e10cSrcweir 
~XMLChartPropHdlFactory()81cdf0e10cSrcweir XMLChartPropHdlFactory::~XMLChartPropHdlFactory()
82cdf0e10cSrcweir {
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
GetPropertyHandler(sal_Int32 nType) const85cdf0e10cSrcweir const XMLPropertyHandler* XMLChartPropHdlFactory::GetPropertyHandler( sal_Int32 nType ) const
86cdf0e10cSrcweir {
87cdf0e10cSrcweir 	const XMLPropertyHandler* pHdl = XMLPropertyHandlerFactory::GetPropertyHandler( nType );
88cdf0e10cSrcweir 	if( ! pHdl )
89cdf0e10cSrcweir 	{
90cdf0e10cSrcweir 		switch( nType )
91cdf0e10cSrcweir 		{
92cdf0e10cSrcweir             case XML_SCH_TYPE_AXIS_POSITION:
93cdf0e10cSrcweir                 pHdl = new XMLAxisPositionPropertyHdl( false );
94cdf0e10cSrcweir                 break;
95cdf0e10cSrcweir             case XML_SCH_TYPE_AXIS_POSITION_VALUE:
96cdf0e10cSrcweir                 pHdl = new XMLAxisPositionPropertyHdl( true );
97cdf0e10cSrcweir                 break;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir             case XML_SCH_TYPE_AXIS_LABEL_POSITION:
100cdf0e10cSrcweir                 pHdl = new XMLEnumPropertyHdl( aXMLChartAxisLabelPositionEnumMap,
101cdf0e10cSrcweir 											   ::getCppuType((const chart::ChartAxisLabelPosition*)0) );
102cdf0e10cSrcweir                 break;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir             case XML_SCH_TYPE_TICK_MARK_POSITION:
105cdf0e10cSrcweir                 pHdl = new XMLEnumPropertyHdl( aXMLChartAxisMarkPositionEnumMap,
106cdf0e10cSrcweir 											   ::getCppuType((const chart::ChartAxisMarkPosition*)0) );
107cdf0e10cSrcweir                 break;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 			case XML_SCH_TYPE_AXIS_ARRANGEMENT:
110cdf0e10cSrcweir 				pHdl = new XMLEnumPropertyHdl( aXMLChartAxisArrangementEnumMap,
111cdf0e10cSrcweir 											   ::getCppuType((const chart::ChartAxisArrangeOrderType*)0) );
112cdf0e10cSrcweir 				break;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 			case XML_SCH_TYPE_ERROR_BAR_STYLE:
115cdf0e10cSrcweir 				// here we have a constant rather than an enum
116cdf0e10cSrcweir 				pHdl = new XMLErrorBarStylePropertyHdl( aXMLChartErrorBarStyleEnumMap,
117cdf0e10cSrcweir                                                ::getCppuType((const sal_Int32*)0) );
118cdf0e10cSrcweir 				break;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 			case XML_SCH_TYPE_REGRESSION_TYPE:
121cdf0e10cSrcweir 				pHdl = new XMLEnumPropertyHdl( aXMLChartRegressionCurveTypeEnumMap,
122cdf0e10cSrcweir 											   ::getCppuType((const chart::ChartRegressionCurveType*)0) );
123cdf0e10cSrcweir 				break;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 			case XML_SCH_TYPE_ERROR_INDICATOR_LOWER:
126cdf0e10cSrcweir 				pHdl = new XMLErrorIndicatorPropertyHdl( sal_False );
127cdf0e10cSrcweir 				break;
128cdf0e10cSrcweir 			case XML_SCH_TYPE_ERROR_INDICATOR_UPPER:
129cdf0e10cSrcweir 				pHdl = new XMLErrorIndicatorPropertyHdl( sal_True );
130cdf0e10cSrcweir 				break;
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 			case XML_SCH_TYPE_SOLID_TYPE:
133cdf0e10cSrcweir 				// here we have a constant rather than an enum
134cdf0e10cSrcweir 				pHdl = new XMLEnumPropertyHdl( aXMLChartSolidTypeEnumMap,
135cdf0e10cSrcweir                                                ::getCppuType((const sal_Int32*)0) );
136cdf0e10cSrcweir 				break;
137cdf0e10cSrcweir             case XML_SCH_TYPE_LABEL_PLACEMENT_TYPE:
138cdf0e10cSrcweir                 // here we have a constant rather than an enum
139cdf0e10cSrcweir                 pHdl = new XMLEnumPropertyHdl( aXMLChartDataLabelPlacementEnumMap,
140cdf0e10cSrcweir                                                 ::getCppuType((const sal_Int32*)0) );
141cdf0e10cSrcweir                 break;
142cdf0e10cSrcweir             case XML_SCH_TYPE_DATAROWSOURCE:
143cdf0e10cSrcweir                 pHdl = new XMLEnumPropertyHdl( aXMLChartDataRowSourceTypeEnumMap,
144cdf0e10cSrcweir                                                ::getCppuType((const chart::ChartDataRowSource*)0) );
145cdf0e10cSrcweir                 break;
146cdf0e10cSrcweir             case XML_SCH_TYPE_TEXT_ORIENTATION:
147cdf0e10cSrcweir                 pHdl = new XMLTextOrientationHdl();
148cdf0e10cSrcweir                 break;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir             case XML_SCH_TYPE_INTERPOLATION:
151cdf0e10cSrcweir                 pHdl = new XMLEnumPropertyHdl( aXMLChartInterpolationTypeEnumMap,
152cdf0e10cSrcweir                                                ::getCppuType((const sal_Int32*)0) );
153cdf0e10cSrcweir                 break;
154cdf0e10cSrcweir             case XML_SCH_TYPE_SYMBOL_TYPE:
155cdf0e10cSrcweir                 pHdl = new XMLSymbolTypePropertyHdl( false );
156cdf0e10cSrcweir                 break;
157cdf0e10cSrcweir 
158cdf0e10cSrcweir             case XML_SCH_TYPE_NAMED_SYMBOL:
159cdf0e10cSrcweir                 pHdl = new XMLSymbolTypePropertyHdl( true );
160cdf0e10cSrcweir                 break;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir             case XML_SCH_TYPE_MISSING_VALUE_TREATMENT:
163cdf0e10cSrcweir                 pHdl = new XMLEnumPropertyHdl( aXMLChartMissingValueTreatmentEnumMap,
164cdf0e10cSrcweir                                                ::getCppuType((const sal_Int32*)0) );
165cdf0e10cSrcweir                 break;
166cdf0e10cSrcweir         }
167cdf0e10cSrcweir 		if( pHdl )
168cdf0e10cSrcweir 			PutHdlCache( nType, pHdl );
169cdf0e10cSrcweir 	}
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	return pHdl;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir // ----------------------------------------
175cdf0e10cSrcweir 
XMLChartPropertySetMapper()176cdf0e10cSrcweir XMLChartPropertySetMapper::XMLChartPropertySetMapper() :
177cdf0e10cSrcweir 		XMLPropertySetMapper( aXMLChartPropMap, new XMLChartPropHdlFactory )
178cdf0e10cSrcweir {
179cdf0e10cSrcweir }
180cdf0e10cSrcweir 
~XMLChartPropertySetMapper()181cdf0e10cSrcweir XMLChartPropertySetMapper::~XMLChartPropertySetMapper()
182cdf0e10cSrcweir {
183cdf0e10cSrcweir }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir // ----------------------------------------
186cdf0e10cSrcweir 
XMLChartExportPropertyMapper(const UniReference<XMLPropertySetMapper> & rMapper,SvXMLExport & rExport)187cdf0e10cSrcweir XMLChartExportPropertyMapper::XMLChartExportPropertyMapper( const UniReference< XMLPropertySetMapper >& rMapper,
188cdf0e10cSrcweir                                                             SvXMLExport& rExport) :
189cdf0e10cSrcweir 		SvXMLExportPropertyMapper( rMapper ),
190cdf0e10cSrcweir 		msTrue( GetXMLToken( XML_TRUE )),
191cdf0e10cSrcweir 		msFalse( GetXMLToken( XML_FALSE )),
192cdf0e10cSrcweir         mrExport( rExport )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir 	// chain draw properties
195cdf0e10cSrcweir 	ChainExportMapper( XMLShapeExport::CreateShapePropMapper( rExport ));
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 	// chain text properties
198cdf0e10cSrcweir 	ChainExportMapper( XMLTextParagraphExport::CreateParaExtPropMapper( rExport ));
199cdf0e10cSrcweir }
200cdf0e10cSrcweir 
~XMLChartExportPropertyMapper()201cdf0e10cSrcweir XMLChartExportPropertyMapper::~XMLChartExportPropertyMapper()
202cdf0e10cSrcweir {
203cdf0e10cSrcweir }
204cdf0e10cSrcweir 
ContextFilter(std::vector<XMLPropertyState> & rProperties,uno::Reference<beans::XPropertySet> rPropSet) const205cdf0e10cSrcweir void XMLChartExportPropertyMapper::ContextFilter(
206cdf0e10cSrcweir 	std::vector< XMLPropertyState >& rProperties,
207cdf0e10cSrcweir 	uno::Reference< beans::XPropertySet > rPropSet ) const
208cdf0e10cSrcweir {
209cdf0e10cSrcweir 	::rtl::OUString aAutoPropName;
210cdf0e10cSrcweir 	sal_Bool bCheckAuto = sal_False;
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 	// filter properties
213cdf0e10cSrcweir 	for( std::vector< XMLPropertyState >::iterator property = rProperties.begin();
214cdf0e10cSrcweir 		 property != rProperties.end();
215cdf0e10cSrcweir 		 property++ )
216cdf0e10cSrcweir 	{
217cdf0e10cSrcweir 		// find properties with context
218cdf0e10cSrcweir 		// to prevent writing this property set mnIndex member to -1
219cdf0e10cSrcweir 		switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ))
220cdf0e10cSrcweir 		{
221cdf0e10cSrcweir 			// if Auto... is set the corresponding properties mustn't be exported
222cdf0e10cSrcweir 			case XML_SCH_CONTEXT_MIN:
223cdf0e10cSrcweir 				bCheckAuto = sal_True;
224cdf0e10cSrcweir 				aAutoPropName = ::rtl::OUString::createFromAscii( "AutoMin" );
225cdf0e10cSrcweir 				break;
226cdf0e10cSrcweir 			case XML_SCH_CONTEXT_MAX:
227cdf0e10cSrcweir 				bCheckAuto = sal_True;
228cdf0e10cSrcweir 				aAutoPropName = ::rtl::OUString::createFromAscii( "AutoMax" );
229cdf0e10cSrcweir 				break;
230cdf0e10cSrcweir 			case XML_SCH_CONTEXT_STEP_MAIN:
231cdf0e10cSrcweir 				bCheckAuto = sal_True;
232cdf0e10cSrcweir 				aAutoPropName = ::rtl::OUString::createFromAscii( "AutoStepMain" );
233cdf0e10cSrcweir 				break;
234cdf0e10cSrcweir             case XML_SCH_CONTEXT_STEP_HELP_COUNT:
235cdf0e10cSrcweir                 bCheckAuto = sal_True;
236cdf0e10cSrcweir                 aAutoPropName = ::rtl::OUString::createFromAscii( "AutoStepHelp" );
237cdf0e10cSrcweir                 break;
238cdf0e10cSrcweir 
239cdf0e10cSrcweir             case XML_SCH_CONTEXT_ORIGIN:
240cdf0e10cSrcweir 				bCheckAuto = sal_True;
241cdf0e10cSrcweir 				aAutoPropName = ::rtl::OUString::createFromAscii( "AutoOrigin" );
242cdf0e10cSrcweir 				break;
243cdf0e10cSrcweir 
244cdf0e10cSrcweir             // the following property is deprecated
245cdf0e10cSrcweir             // elemet-item symbol-image is used now
246cdf0e10cSrcweir             case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME:
247cdf0e10cSrcweir                 property->mnIndex = -1;
248cdf0e10cSrcweir                 break;
249cdf0e10cSrcweir 
250cdf0e10cSrcweir             case XML_SCH_CONTEXT_STOCK_WITH_VOLUME:
251cdf0e10cSrcweir             case XML_SCH_CONTEXT_LINES_USED:
252cdf0e10cSrcweir                 // note this avoids export of the properties in OASIS format,
253cdf0e10cSrcweir                 // but also for the OOo XML Flat format (used by binfilter),
254cdf0e10cSrcweir                 // because there, the transformation to OOo is done after the
255cdf0e10cSrcweir                 // complete export of the chart in OASIS format.
256cdf0e10cSrcweir                 if( mrExport.getExportFlags() & EXPORT_OASIS )
257cdf0e10cSrcweir                     property->mnIndex = -1;
258cdf0e10cSrcweir                 break;
259cdf0e10cSrcweir 		}
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 		if( bCheckAuto )
262cdf0e10cSrcweir 		{
263cdf0e10cSrcweir 			if( rPropSet.is())
264cdf0e10cSrcweir 			{
265cdf0e10cSrcweir 				try
266cdf0e10cSrcweir 				{
267cdf0e10cSrcweir 					sal_Bool bAuto = false;
268cdf0e10cSrcweir 					uno::Any aAny = rPropSet->getPropertyValue( aAutoPropName );
269cdf0e10cSrcweir 					aAny >>= bAuto;
270cdf0e10cSrcweir 					if( bAuto )
271cdf0e10cSrcweir 						property->mnIndex = -1;
272cdf0e10cSrcweir 				}
273cdf0e10cSrcweir 				catch( beans::UnknownPropertyException )
274cdf0e10cSrcweir 				{
275cdf0e10cSrcweir 				}
276cdf0e10cSrcweir 			}
277cdf0e10cSrcweir 			bCheckAuto = sal_False;
278cdf0e10cSrcweir 		}
279cdf0e10cSrcweir 	}
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 	SvXMLExportPropertyMapper::ContextFilter(rProperties, rPropSet);
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
handleElementItem(SvXMLExport & rExport,const XMLPropertyState & rProperty,sal_uInt16 nFlags,const::std::vector<XMLPropertyState> * pProperties,sal_uInt32 nIdx) const284cdf0e10cSrcweir void XMLChartExportPropertyMapper::handleElementItem(
285cdf0e10cSrcweir     SvXMLExport& rExport,
286cdf0e10cSrcweir 	const XMLPropertyState& rProperty, sal_uInt16 nFlags,
287cdf0e10cSrcweir 	const ::std::vector< XMLPropertyState > *pProperties,
288cdf0e10cSrcweir 	sal_uInt32 nIdx ) const
289cdf0e10cSrcweir {
290cdf0e10cSrcweir     switch( getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex ))
291cdf0e10cSrcweir     {
292cdf0e10cSrcweir         case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE:
293cdf0e10cSrcweir             {
294cdf0e10cSrcweir                 ::rtl::OUString aURLStr;
295cdf0e10cSrcweir                 rProperty.maValue >>= aURLStr;
296cdf0e10cSrcweir 
297cdf0e10cSrcweir                 // export as XLink reference into the package
298cdf0e10cSrcweir                 // if embedding is off
299cdf0e10cSrcweir                 ::rtl::OUString sTempURL( mrExport.AddEmbeddedGraphicObject( aURLStr ));
300cdf0e10cSrcweir                 if( sTempURL.getLength() )
301cdf0e10cSrcweir                 {
302cdf0e10cSrcweir                     mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sTempURL );
303cdf0e10cSrcweir                     mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE,
304cdf0e10cSrcweir                                               XML_SIMPLE );
305cdf0e10cSrcweir                     mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE,
306cdf0e10cSrcweir                                               XML_ONLOAD );
307cdf0e10cSrcweir                 }
308cdf0e10cSrcweir 
309cdf0e10cSrcweir                 {
310cdf0e10cSrcweir                     sal_uInt32 nPropIndex = rProperty.mnIndex;
311cdf0e10cSrcweir                     // this is the element that has to live until the next statement
312cdf0e10cSrcweir                     SvXMLElementExport aElem( mrExport,
313cdf0e10cSrcweir                                               getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
314cdf0e10cSrcweir                                               getPropertySetMapper()->GetEntryXMLName( nPropIndex ),
315cdf0e10cSrcweir                                               sal_True, sal_True );
316cdf0e10cSrcweir 
317cdf0e10cSrcweir                     // export as Base64 embedded graphic
318cdf0e10cSrcweir                     // if embedding is on
319cdf0e10cSrcweir                     if( aURLStr.getLength())
320cdf0e10cSrcweir                         mrExport.AddEmbeddedGraphicObjectAsBase64( aURLStr );
321cdf0e10cSrcweir                 }
322cdf0e10cSrcweir             }
323cdf0e10cSrcweir             break;
324cdf0e10cSrcweir 
325cdf0e10cSrcweir         case XML_SCH_CONTEXT_SPECIAL_LABEL_SEPARATOR:
326cdf0e10cSrcweir             {
327cdf0e10cSrcweir                 ::rtl::OUString aSeparator;
328cdf0e10cSrcweir                 rProperty.maValue >>= aSeparator;
329cdf0e10cSrcweir 
330cdf0e10cSrcweir                 if( aSeparator.getLength() )
331cdf0e10cSrcweir                 {
332cdf0e10cSrcweir                     sal_uInt32 nPropIndex = rProperty.mnIndex;
333cdf0e10cSrcweir                     SvXMLElementExport aElem( mrExport,
334cdf0e10cSrcweir                                               getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
335cdf0e10cSrcweir                                               getPropertySetMapper()->GetEntryXMLName( nPropIndex ),
336cdf0e10cSrcweir                                               sal_True, sal_True );
337cdf0e10cSrcweir 
338cdf0e10cSrcweir                     SchXMLTools::exportText( mrExport, aSeparator, true );
339cdf0e10cSrcweir                 }
340cdf0e10cSrcweir             }
341cdf0e10cSrcweir             break;
342cdf0e10cSrcweir 
343cdf0e10cSrcweir         default:
344cdf0e10cSrcweir             // call parent
345cdf0e10cSrcweir             SvXMLExportPropertyMapper::handleElementItem( rExport, rProperty,
346cdf0e10cSrcweir                                                           nFlags, pProperties, nIdx );
347cdf0e10cSrcweir             break;
348cdf0e10cSrcweir     }
349cdf0e10cSrcweir }
350cdf0e10cSrcweir 
handleSpecialItem(SvXMLAttributeList & rAttrList,const XMLPropertyState & rProperty,const SvXMLUnitConverter & rUnitConverter,const SvXMLNamespaceMap & rNamespaceMap,const::std::vector<XMLPropertyState> * pProperties,sal_uInt32 nIdx) const351cdf0e10cSrcweir void XMLChartExportPropertyMapper::handleSpecialItem(
352cdf0e10cSrcweir 	SvXMLAttributeList& rAttrList, const XMLPropertyState& rProperty,
353cdf0e10cSrcweir 	const SvXMLUnitConverter& rUnitConverter,
354cdf0e10cSrcweir 	const SvXMLNamespaceMap& rNamespaceMap,
355cdf0e10cSrcweir 	const ::std::vector< XMLPropertyState > *pProperties,
356cdf0e10cSrcweir 	sal_uInt32 nIdx ) const
357cdf0e10cSrcweir {
358cdf0e10cSrcweir 	sal_Bool bHandled = sal_False;
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 	sal_Int32 nContextId = maPropMapper->GetEntryContextId( rProperty.mnIndex );
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 	if( nContextId )
363cdf0e10cSrcweir 	{
364cdf0e10cSrcweir 		bHandled = sal_True;
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 		rtl::OUString sAttrName = maPropMapper->GetEntryXMLName( rProperty.mnIndex );
367cdf0e10cSrcweir 		sal_uInt16 nNameSpace = maPropMapper->GetEntryNameSpace( rProperty.mnIndex );
368cdf0e10cSrcweir 		rtl::OUStringBuffer sValueBuffer;
369cdf0e10cSrcweir 		rtl::OUString sValue;
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 		sal_Int32 nValue = 0;
372cdf0e10cSrcweir 		sal_Bool bValue = sal_False;
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 		switch( nContextId )
375cdf0e10cSrcweir 		{
376cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER:
377cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER:
378cdf0e10cSrcweir 				rProperty.maValue >>= nValue;
379cdf0e10cSrcweir 				bValue = (( nValue & chart::ChartAxisMarks::INNER ) == chart::ChartAxisMarks::INNER );
380cdf0e10cSrcweir 				SvXMLUnitConverter::convertBool( sValueBuffer, bValue );
381cdf0e10cSrcweir 				break;
382cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER:
383cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER:
384cdf0e10cSrcweir 				rProperty.maValue >>= nValue;
385cdf0e10cSrcweir 				bValue = (( nValue & chart::ChartAxisMarks::OUTER ) == chart::ChartAxisMarks::OUTER );
386cdf0e10cSrcweir 				SvXMLUnitConverter::convertBool( sValueBuffer, bValue );
387cdf0e10cSrcweir 				break;
388cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION:
389cdf0e10cSrcweir 				{
390cdf0e10cSrcweir 					// convert from 100th degrees to degrees (double)
391cdf0e10cSrcweir 					rProperty.maValue >>= nValue;
392cdf0e10cSrcweir 					double fVal = (double)(nValue) / 100.0;
393cdf0e10cSrcweir 					SvXMLUnitConverter::convertDouble( sValueBuffer, fVal );
394cdf0e10cSrcweir 				}
395cdf0e10cSrcweir 				break;
396cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER:
397cdf0e10cSrcweir 				{
398cdf0e10cSrcweir 					rProperty.maValue >>= nValue;
399cdf0e10cSrcweir 					if((( nValue & chart::ChartDataCaption::VALUE ) == chart::ChartDataCaption::VALUE ))
400cdf0e10cSrcweir                     {
401cdf0e10cSrcweir                         if( ( nValue & chart::ChartDataCaption::PERCENT ) == chart::ChartDataCaption::PERCENT )
402cdf0e10cSrcweir                         {
403cdf0e10cSrcweir                             const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
404cdf0e10cSrcweir                             if( nCurrentVersion < SvtSaveOptions::ODFVER_012 )
405cdf0e10cSrcweir                                 sValueBuffer.append( GetXMLToken( XML_PERCENTAGE ));
406cdf0e10cSrcweir                             else
407cdf0e10cSrcweir 						        sValueBuffer.append( GetXMLToken( XML_VALUE_AND_PERCENTAGE ));
408cdf0e10cSrcweir                         }
409cdf0e10cSrcweir                         else
410cdf0e10cSrcweir 						    sValueBuffer.append( GetXMLToken( XML_VALUE ));
411cdf0e10cSrcweir                     }
412cdf0e10cSrcweir 					else if(( nValue & chart::ChartDataCaption::PERCENT ) == chart::ChartDataCaption::PERCENT )
413cdf0e10cSrcweir 						sValueBuffer.append( GetXMLToken( XML_PERCENTAGE ));
414cdf0e10cSrcweir 					else
415cdf0e10cSrcweir 						sValueBuffer.append( GetXMLToken( XML_NONE ));
416cdf0e10cSrcweir 				}
417cdf0e10cSrcweir 				break;
418cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT:
419cdf0e10cSrcweir 				rProperty.maValue >>= nValue;
420cdf0e10cSrcweir 				bValue = (( nValue & chart::ChartDataCaption::TEXT ) == chart::ChartDataCaption::TEXT );
421cdf0e10cSrcweir 				SvXMLUnitConverter::convertBool( sValueBuffer, bValue );
422cdf0e10cSrcweir 				break;
423cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL:
424cdf0e10cSrcweir 				rProperty.maValue >>= nValue;
425cdf0e10cSrcweir 				bValue = (( nValue & chart::ChartDataCaption::SYMBOL ) == chart::ChartDataCaption::SYMBOL );
426cdf0e10cSrcweir 				SvXMLUnitConverter::convertBool( sValueBuffer, bValue );
427cdf0e10cSrcweir 				break;
428cdf0e10cSrcweir 
429cdf0e10cSrcweir             case XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH:
430cdf0e10cSrcweir             case XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT:
431cdf0e10cSrcweir                 {
432cdf0e10cSrcweir                     awt::Size aSize;
433cdf0e10cSrcweir                     rProperty.maValue >>= aSize;
434cdf0e10cSrcweir                     rUnitConverter.convertMeasure( sValueBuffer,
435cdf0e10cSrcweir                                                    nContextId == XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH
436cdf0e10cSrcweir                                                    ? aSize.Width
437cdf0e10cSrcweir                                                    : aSize.Height );
438cdf0e10cSrcweir                 }
439cdf0e10cSrcweir                 break;
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT:
442cdf0e10cSrcweir 				{
443cdf0e10cSrcweir 					// just for import
444cdf0e10cSrcweir 					break;
445cdf0e10cSrcweir 				}
446cdf0e10cSrcweir 
447cdf0e10cSrcweir 			default:
448cdf0e10cSrcweir 				bHandled = sal_False;
449cdf0e10cSrcweir 				break;
450cdf0e10cSrcweir 		}
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 		if( sValueBuffer.getLength())
453cdf0e10cSrcweir 		{
454cdf0e10cSrcweir 			sValue = sValueBuffer.makeStringAndClear();
455cdf0e10cSrcweir 			sAttrName = rNamespaceMap.GetQNameByKey( nNameSpace, sAttrName );
456cdf0e10cSrcweir 			rAttrList.AddAttribute( sAttrName, sValue );
457cdf0e10cSrcweir 		}
458cdf0e10cSrcweir 	}
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 	if( !bHandled )
461cdf0e10cSrcweir 	{
462cdf0e10cSrcweir 		// call parent
463cdf0e10cSrcweir 		SvXMLExportPropertyMapper::handleSpecialItem( rAttrList, rProperty, rUnitConverter, rNamespaceMap, pProperties, nIdx );
464cdf0e10cSrcweir 	}
465cdf0e10cSrcweir }
466cdf0e10cSrcweir 
467cdf0e10cSrcweir // ----------------------------------------
468cdf0e10cSrcweir 
XMLChartImportPropertyMapper(const UniReference<XMLPropertySetMapper> & rMapper,const SvXMLImport & _rImport)469cdf0e10cSrcweir XMLChartImportPropertyMapper::XMLChartImportPropertyMapper( const UniReference< XMLPropertySetMapper >& rMapper,
470cdf0e10cSrcweir                                                             const SvXMLImport& _rImport ) :
471cdf0e10cSrcweir         SvXMLImportPropertyMapper( rMapper, const_cast< SvXMLImport & >( _rImport )),
472cdf0e10cSrcweir         mrImport( const_cast< SvXMLImport & > ( _rImport ))
473cdf0e10cSrcweir {
474cdf0e10cSrcweir 	// chain shape mapper for drawing properties
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 	// give an empty model. It is only used for numbering rules that don't exist in chart
477cdf0e10cSrcweir 	uno::Reference< frame::XModel > xEmptyModel;
478cdf0e10cSrcweir 	ChainImportMapper( XMLShapeImportHelper::CreateShapePropMapper( xEmptyModel, mrImport ));
479cdf0e10cSrcweir 
480cdf0e10cSrcweir     //#i14365# save and load writing-mode for chart elements
481cdf0e10cSrcweir     //The property TextWritingMode is mapped wrongly in the underlying draw mapper, but for draw it is necessary
482cdf0e10cSrcweir     //We remove that property here only for chart thus the chart can use the correct mapping from the writer paragraph settings (attribute 'writing-mode' <-> property 'WritingMode')
483cdf0e10cSrcweir     sal_Int32 nUnwantedWrongEntry = maPropMapper->FindEntryIndex( "TextWritingMode", XML_NAMESPACE_STYLE, GetXMLToken(XML_WRITING_MODE) );
484cdf0e10cSrcweir     maPropMapper->RemoveEntry(nUnwantedWrongEntry);
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 	// do not chain text properties: on import this is done by shape mapper
487cdf0e10cSrcweir     // to import old documents
488cdf0e10cSrcweir //  	ChainImportMapper( XMLTextImportHelper::CreateParaExtPropMapper());
489cdf0e10cSrcweir }
490cdf0e10cSrcweir 
~XMLChartImportPropertyMapper()491cdf0e10cSrcweir XMLChartImportPropertyMapper::~XMLChartImportPropertyMapper()
492cdf0e10cSrcweir {
493cdf0e10cSrcweir }
494cdf0e10cSrcweir 
handleSpecialItem(XMLPropertyState & rProperty,::std::vector<XMLPropertyState> & rProperties,const::rtl::OUString & rValue,const SvXMLUnitConverter & rUnitConverter,const SvXMLNamespaceMap & rNamespaceMap) const495cdf0e10cSrcweir sal_Bool XMLChartImportPropertyMapper::handleSpecialItem(
496cdf0e10cSrcweir 	XMLPropertyState& rProperty,
497cdf0e10cSrcweir 	::std::vector< XMLPropertyState >& rProperties,
498cdf0e10cSrcweir 	const ::rtl::OUString& rValue,
499cdf0e10cSrcweir 	const SvXMLUnitConverter& rUnitConverter,
500cdf0e10cSrcweir 	const SvXMLNamespaceMap& rNamespaceMap ) const
501cdf0e10cSrcweir {
502cdf0e10cSrcweir     static const ::rtl::OUString sPackageProtocol( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );
503cdf0e10cSrcweir 	sal_Int32 nContextId = maPropMapper->GetEntryContextId( rProperty.mnIndex );
504cdf0e10cSrcweir 	sal_Bool bRet = (nContextId != 0);
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 	if( nContextId )
507cdf0e10cSrcweir 	{
508cdf0e10cSrcweir 		sal_Int32 nValue = 0;
509cdf0e10cSrcweir 		sal_Bool bValue = sal_False;
510cdf0e10cSrcweir 
511cdf0e10cSrcweir 		switch( nContextId )
512cdf0e10cSrcweir 		{
513cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER:
514cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER:
515cdf0e10cSrcweir 				SvXMLUnitConverter::convertBool( bValue, rValue );
516cdf0e10cSrcweir 				// modify old value
517cdf0e10cSrcweir 				rProperty.maValue >>= nValue;
518cdf0e10cSrcweir 				if( bValue )
519cdf0e10cSrcweir 					SCH_XML_SETFLAG( nValue, chart::ChartAxisMarks::INNER );
520cdf0e10cSrcweir 				else
521cdf0e10cSrcweir 					SCH_XML_UNSETFLAG( nValue, chart::ChartAxisMarks::INNER );
522cdf0e10cSrcweir 				rProperty.maValue <<= nValue;
523cdf0e10cSrcweir 				break;
524cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER:
525cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER:
526cdf0e10cSrcweir 				SvXMLUnitConverter::convertBool( bValue, rValue );
527cdf0e10cSrcweir 				// modify old value
528cdf0e10cSrcweir 				rProperty.maValue >>= nValue;
529cdf0e10cSrcweir 				if( bValue )
530cdf0e10cSrcweir 					SCH_XML_SETFLAG( nValue, chart::ChartAxisMarks::OUTER );
531cdf0e10cSrcweir 				else
532cdf0e10cSrcweir 					SCH_XML_UNSETFLAG( nValue, chart::ChartAxisMarks::OUTER );
533cdf0e10cSrcweir 				rProperty.maValue <<= nValue;
534cdf0e10cSrcweir 				break;
535cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION:
536cdf0e10cSrcweir 				{
537cdf0e10cSrcweir 					// convert from degrees (double) to 100th degrees (integer)
538cdf0e10cSrcweir 					double fVal;
539cdf0e10cSrcweir 					SvXMLUnitConverter::convertDouble( fVal, rValue );
540cdf0e10cSrcweir 					nValue = (sal_Int32)( fVal * 100.0 );
541cdf0e10cSrcweir 					rProperty.maValue <<= nValue;
542cdf0e10cSrcweir 				}
543cdf0e10cSrcweir 				break;
544cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER:
545cdf0e10cSrcweir 				{
546cdf0e10cSrcweir 					// modify old value
547cdf0e10cSrcweir 					rProperty.maValue >>= nValue;
548cdf0e10cSrcweir 					if( IsXMLToken( rValue, XML_NONE ))
549cdf0e10cSrcweir 						SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::VALUE | chart::ChartDataCaption::PERCENT );
550cdf0e10cSrcweir                     else if( IsXMLToken( rValue, XML_VALUE_AND_PERCENTAGE ) )
551cdf0e10cSrcweir 						SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::VALUE | chart::ChartDataCaption::PERCENT );
552cdf0e10cSrcweir                     else if( IsXMLToken( rValue, XML_VALUE ) )
553cdf0e10cSrcweir 						SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::VALUE );
554cdf0e10cSrcweir 					else // must be XML_PERCENTAGE
555cdf0e10cSrcweir 						SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::PERCENT );
556cdf0e10cSrcweir 					rProperty.maValue <<= nValue;
557cdf0e10cSrcweir 				}
558cdf0e10cSrcweir 				break;
559cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT:
560cdf0e10cSrcweir 				rProperty.maValue >>= nValue;
561cdf0e10cSrcweir 				SvXMLUnitConverter::convertBool( bValue, rValue );
562cdf0e10cSrcweir 				if( bValue )
563cdf0e10cSrcweir 					SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::TEXT );
564cdf0e10cSrcweir 				else
565cdf0e10cSrcweir 					SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::TEXT );
566cdf0e10cSrcweir 				rProperty.maValue <<= nValue;
567cdf0e10cSrcweir 				break;
568cdf0e10cSrcweir 			case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL:
569cdf0e10cSrcweir 				rProperty.maValue >>= nValue;
570cdf0e10cSrcweir 				SvXMLUnitConverter::convertBool( bValue, rValue );
571cdf0e10cSrcweir 				if( bValue )
572cdf0e10cSrcweir 					SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::SYMBOL );
573cdf0e10cSrcweir 				else
574cdf0e10cSrcweir 					SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::SYMBOL );
575cdf0e10cSrcweir 				rProperty.maValue <<= nValue;
576cdf0e10cSrcweir 				break;
577cdf0e10cSrcweir             case XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH:
578cdf0e10cSrcweir             case XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT:
579cdf0e10cSrcweir                 {
580cdf0e10cSrcweir                     awt::Size aSize;
581cdf0e10cSrcweir                     rProperty.maValue >>= aSize;
582cdf0e10cSrcweir                     rUnitConverter.convertMeasure( nContextId == XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH
583cdf0e10cSrcweir                                                    ? aSize.Width
584cdf0e10cSrcweir                                                    : aSize.Height,
585cdf0e10cSrcweir                                                    rValue );
586cdf0e10cSrcweir                     rProperty.maValue <<= aSize;
587cdf0e10cSrcweir                 }
588cdf0e10cSrcweir                 break;
589cdf0e10cSrcweir 
590cdf0e10cSrcweir             // deprecated from 6.0 beta on
591cdf0e10cSrcweir             case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME:
592cdf0e10cSrcweir                 rProperty.maValue <<= mrImport.ResolveGraphicObjectURL( rValue, sal_False );
593cdf0e10cSrcweir                 break;
594cdf0e10cSrcweir 
595cdf0e10cSrcweir             default:
596cdf0e10cSrcweir 				bRet = sal_False;
597cdf0e10cSrcweir 				break;
598cdf0e10cSrcweir 		}
599cdf0e10cSrcweir 	}
600cdf0e10cSrcweir 
601cdf0e10cSrcweir 
602cdf0e10cSrcweir 	// if we didn't handle it, the parent should
603cdf0e10cSrcweir 	if( !bRet )
604cdf0e10cSrcweir 	{
605cdf0e10cSrcweir 		// call parent
606cdf0e10cSrcweir 		bRet = SvXMLImportPropertyMapper::handleSpecialItem( rProperty, rProperties, rValue, rUnitConverter, rNamespaceMap );
607cdf0e10cSrcweir 	}
608cdf0e10cSrcweir 
609cdf0e10cSrcweir 	return bRet;
610cdf0e10cSrcweir }
611cdf0e10cSrcweir 
finished(::std::vector<XMLPropertyState> &,sal_Int32,sal_Int32) const612cdf0e10cSrcweir void XMLChartImportPropertyMapper::finished( ::std::vector< XMLPropertyState >& /*rProperties*/, sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const
613cdf0e10cSrcweir {
614cdf0e10cSrcweir }
615