LCOV - code coverage report
Current view: top level - xmloff/source/chart - SchXMLImport.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 254 0.0 %
Date: 2014-04-14 Functions: 0 39 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "SchXMLImport.hxx"
      21             : #include "SchXMLChartContext.hxx"
      22             : #include "contexts.hxx"
      23             : #include "XMLChartPropertySetMapper.hxx"
      24             : #include "SchXMLTools.hxx"
      25             : #include "facreg.hxx"
      26             : 
      27             : #include <tools/debug.hxx>
      28             : #include <rtl/ustrbuf.hxx>
      29             : #include <comphelper/processfactory.hxx>
      30             : #include <xmloff/xmlnmspe.hxx>
      31             : #include <xmloff/xmltoken.hxx>
      32             : #include <xmloff/xmluconv.hxx>
      33             : #include <xmloff/nmspmap.hxx>
      34             : #include <xmloff/xmlictxt.hxx>
      35             : #include <xmloff/xmlstyle.hxx>
      36             : #include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
      37             : #include <com/sun/star/chart/XChartDocument.hpp>
      38             : #include <com/sun/star/chart/ChartDataRowSource.hpp>
      39             : #include <com/sun/star/container/XChild.hpp>
      40             : #include <com/sun/star/uno/XComponentContext.hpp>
      41             : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
      42             : #include <com/sun/star/chart2/data/XDataProvider.hpp>
      43             : #include <com/sun/star/chart2/XChartDocument.hpp>
      44             : #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
      45             : #include <com/sun/star/chart2/XChartTypeContainer.hpp>
      46             : #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
      47             : 
      48             : #include <com/sun/star/document/XDocumentProperties.hpp>
      49             : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      50             : 
      51             : #include <typeinfo>
      52             : 
      53             : using namespace com::sun::star;
      54             : using namespace ::xmloff::token;
      55             : 
      56             : using ::com::sun::star::uno::Reference;
      57             : using ::com::sun::star::uno::Sequence;
      58             : 
      59             : namespace
      60             : {
      61           0 : class lcl_MatchesChartType : public ::std::unary_function< Reference< chart2::XChartType >, bool >
      62             : {
      63             : public:
      64           0 :     explicit lcl_MatchesChartType( const OUString & aChartTypeName ) :
      65           0 :             m_aChartTypeName( aChartTypeName )
      66           0 :     {}
      67             : 
      68           0 :     bool operator () ( const Reference< chart2::XChartType > & xChartType ) const
      69             :     {
      70           0 :         return (xChartType.is() &&
      71           0 :                 xChartType->getChartType().equals( m_aChartTypeName ));
      72             :     }
      73             : 
      74             : private:
      75             :     OUString m_aChartTypeName;
      76             : };
      77             : } // anonymous namespace
      78             : 
      79             :    // TokenMaps for distinguishing different
      80             :    // tokens in different contexts
      81             : 
      82             : // element maps
      83             : 
      84             : // attribute maps
      85             : 
      86           0 : SchXMLImportHelper::SchXMLImportHelper() :
      87             :         mpAutoStyles( 0 ),
      88             : 
      89             :         mpChartDocElemTokenMap( 0 ),
      90             :         mpTableElemTokenMap( 0 ),
      91             :         mpChartElemTokenMap( 0 ),
      92             :         mpPlotAreaElemTokenMap( 0 ),
      93             :         mpSeriesElemTokenMap( 0 ),
      94             : 
      95             :         mpChartAttrTokenMap( 0 ),
      96             :         mpPlotAreaAttrTokenMap( 0 ),
      97             :         mpAutoStyleAttrTokenMap( 0 ),
      98             :         mpCellAttrTokenMap( 0 ),
      99             :         mpSeriesAttrTokenMap( 0 ),
     100             :         mpPropMappingAttrTokenMap( 0 ),
     101           0 :         mpRegEquationAttrTokenMap( 0 )
     102             : {
     103           0 : }
     104             : 
     105           0 : SchXMLImportHelper::~SchXMLImportHelper()
     106             : {
     107             :         // delete token maps
     108           0 :     if( mpChartDocElemTokenMap )
     109           0 :         delete mpChartDocElemTokenMap;
     110           0 :     if( mpTableElemTokenMap )
     111           0 :         delete mpTableElemTokenMap;
     112           0 :     if( mpChartElemTokenMap )
     113           0 :         delete mpChartElemTokenMap;
     114           0 :     if( mpPlotAreaElemTokenMap )
     115           0 :         delete mpPlotAreaElemTokenMap;
     116           0 :     if( mpSeriesElemTokenMap )
     117           0 :         delete mpSeriesElemTokenMap;
     118             : 
     119           0 :     if( mpChartAttrTokenMap )
     120           0 :         delete mpChartAttrTokenMap;
     121           0 :     if( mpPlotAreaAttrTokenMap )
     122           0 :         delete mpPlotAreaAttrTokenMap;
     123           0 :     if( mpAutoStyleAttrTokenMap )
     124           0 :         delete mpAutoStyleAttrTokenMap;
     125           0 :     if( mpCellAttrTokenMap )
     126           0 :         delete mpCellAttrTokenMap;
     127           0 :     if( mpSeriesAttrTokenMap )
     128           0 :         delete mpSeriesAttrTokenMap;
     129           0 :     delete mpPropMappingAttrTokenMap;
     130           0 : }
     131             : 
     132           0 : SvXMLImportContext* SchXMLImportHelper::CreateChartContext(
     133             :     SvXMLImport& rImport,
     134             :     sal_uInt16 nPrefix, const OUString& rLocalName,
     135             :     const Reference< frame::XModel > xChartModel,
     136             :     const Reference< xml::sax::XAttributeList >& )
     137             : {
     138           0 :     SvXMLImportContext* pContext = 0;
     139             : 
     140           0 :     Reference< chart::XChartDocument > xDoc( xChartModel, uno::UNO_QUERY );
     141           0 :     if( xDoc.is())
     142             :     {
     143           0 :         mxChartDoc = xDoc;
     144           0 :         pContext = new SchXMLChartContext( *this, rImport, rLocalName );
     145             :     }
     146             :     else
     147             :     {
     148             :         SAL_WARN("xmloff.chart", "No valid XChartDocument given as XModel" );
     149           0 :         pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName );
     150             :     }
     151             : 
     152           0 :     return pContext;
     153             : }
     154             : 
     155             : // get various token maps
     156             : 
     157           0 : const SvXMLTokenMap& SchXMLImportHelper::GetDocElemTokenMap()
     158             : {
     159           0 :     if( ! mpChartDocElemTokenMap )
     160             :     {
     161             :         static const SvXMLTokenMapEntry aDocElemTokenMap[] =
     162             :         {
     163             :             { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES,   XML_TOK_DOC_AUTOSTYLES  },
     164             :             { XML_NAMESPACE_OFFICE, XML_STYLES,             XML_TOK_DOC_STYLES  },
     165             :             { XML_NAMESPACE_OFFICE, XML_META,               XML_TOK_DOC_META    },
     166             :             { XML_NAMESPACE_OFFICE, XML_BODY,               XML_TOK_DOC_BODY    },
     167             :             XML_TOKEN_MAP_END
     168             :         };
     169             : 
     170           0 :         mpChartDocElemTokenMap = new SvXMLTokenMap( aDocElemTokenMap );
     171             :     } // if( ! mpChartDocElemTokenMap )
     172             : 
     173           0 :     return *mpChartDocElemTokenMap;
     174             : }
     175             : 
     176           0 : const SvXMLTokenMap& SchXMLImportHelper::GetTableElemTokenMap()
     177             : {
     178           0 :     if( ! mpTableElemTokenMap )
     179             :     {
     180             :         static const SvXMLTokenMapEntry aTableElemTokenMap[] =
     181             :     {
     182             :         { XML_NAMESPACE_TABLE,  XML_TABLE_HEADER_COLUMNS,   XML_TOK_TABLE_HEADER_COLS   },
     183             :         { XML_NAMESPACE_TABLE,  XML_TABLE_COLUMNS,          XML_TOK_TABLE_COLUMNS       },
     184             :         { XML_NAMESPACE_TABLE,  XML_TABLE_COLUMN,           XML_TOK_TABLE_COLUMN        },
     185             :         { XML_NAMESPACE_TABLE,  XML_TABLE_HEADER_ROWS,      XML_TOK_TABLE_HEADER_ROWS   },
     186             :         { XML_NAMESPACE_TABLE,  XML_TABLE_ROWS,             XML_TOK_TABLE_ROWS          },
     187             :         { XML_NAMESPACE_TABLE,  XML_TABLE_ROW,              XML_TOK_TABLE_ROW           },
     188             :         XML_TOKEN_MAP_END
     189             :     };
     190             : 
     191           0 :         mpTableElemTokenMap = new SvXMLTokenMap( aTableElemTokenMap );
     192             :     } // if( ! mpTableElemTokenMap )
     193             : 
     194           0 :     return *mpTableElemTokenMap;
     195             : }
     196             : 
     197           0 : const SvXMLTokenMap& SchXMLImportHelper::GetChartElemTokenMap()
     198             : {
     199           0 :     if( ! mpChartElemTokenMap )
     200             :     {
     201             :         static const SvXMLTokenMapEntry aChartElemTokenMap[] =
     202             :         {
     203             :             { XML_NAMESPACE_CHART,  XML_PLOT_AREA,              XML_TOK_CHART_PLOT_AREA     },
     204             :             { XML_NAMESPACE_CHART,  XML_TITLE,                  XML_TOK_CHART_TITLE         },
     205             :             { XML_NAMESPACE_CHART,  XML_SUBTITLE,               XML_TOK_CHART_SUBTITLE      },
     206             :             { XML_NAMESPACE_CHART,  XML_LEGEND,             XML_TOK_CHART_LEGEND        },
     207             :             { XML_NAMESPACE_TABLE,  XML_TABLE,                  XML_TOK_CHART_TABLE         },
     208             :             XML_TOKEN_MAP_END
     209             :         };
     210             : 
     211           0 :         mpChartElemTokenMap = new SvXMLTokenMap( aChartElemTokenMap );
     212             :     } // if( ! mpChartElemTokenMap )
     213             : 
     214           0 :     return *mpChartElemTokenMap;
     215             : }
     216             : 
     217           0 : const SvXMLTokenMap& SchXMLImportHelper::GetPlotAreaElemTokenMap()
     218             : {
     219           0 :     if( ! mpPlotAreaElemTokenMap )
     220             :     {
     221             :         static const SvXMLTokenMapEntry aPlotAreaElemTokenMap[] =
     222             : {
     223             :     { XML_NAMESPACE_CHART_EXT,  XML_COORDINATE_REGION,      XML_TOK_PA_COORDINATE_REGION_EXT },
     224             :     { XML_NAMESPACE_CHART,  XML_COORDINATE_REGION,      XML_TOK_PA_COORDINATE_REGION },
     225             :     { XML_NAMESPACE_CHART,  XML_AXIS,                   XML_TOK_PA_AXIS             },
     226             :     { XML_NAMESPACE_CHART,  XML_SERIES,                 XML_TOK_PA_SERIES           },
     227             :     { XML_NAMESPACE_CHART,  XML_WALL,                   XML_TOK_PA_WALL             },
     228             :     { XML_NAMESPACE_CHART,  XML_FLOOR,                  XML_TOK_PA_FLOOR            },
     229             :     { XML_NAMESPACE_DR3D,   XML_LIGHT,                  XML_TOK_PA_LIGHT_SOURCE     },
     230             :     { XML_NAMESPACE_CHART,  XML_STOCK_GAIN_MARKER,      XML_TOK_PA_STOCK_GAIN       },
     231             :     { XML_NAMESPACE_CHART,  XML_STOCK_LOSS_MARKER,      XML_TOK_PA_STOCK_LOSS       },
     232             :     { XML_NAMESPACE_CHART,  XML_STOCK_RANGE_LINE,       XML_TOK_PA_STOCK_RANGE      },
     233             :     XML_TOKEN_MAP_END
     234             : };
     235             : 
     236           0 :         mpPlotAreaElemTokenMap = new SvXMLTokenMap( aPlotAreaElemTokenMap );
     237             :     } // if( ! mpPlotAreaElemTokenMap )
     238             : 
     239           0 :     return *mpPlotAreaElemTokenMap;
     240             : }
     241             : 
     242           0 : const SvXMLTokenMap& SchXMLImportHelper::GetSeriesElemTokenMap()
     243             : {
     244           0 :     if( ! mpSeriesElemTokenMap )
     245             :     {
     246             :         static const SvXMLTokenMapEntry aSeriesElemTokenMap[] =
     247             : {
     248             :     { XML_NAMESPACE_CHART,  XML_DATA_POINT,       XML_TOK_SERIES_DATA_POINT       },
     249             :     { XML_NAMESPACE_CHART,  XML_DOMAIN,           XML_TOK_SERIES_DOMAIN           },
     250             :     { XML_NAMESPACE_CHART,  XML_MEAN_VALUE,       XML_TOK_SERIES_MEAN_VALUE_LINE  },
     251             :     { XML_NAMESPACE_CHART,  XML_REGRESSION_CURVE, XML_TOK_SERIES_REGRESSION_CURVE },
     252             :     { XML_NAMESPACE_CHART,  XML_ERROR_INDICATOR,  XML_TOK_SERIES_ERROR_INDICATOR  },
     253             :     { XML_NAMESPACE_LO_EXT, XML_PROPERTY_MAPPING, XML_TOK_SERIES_PROPERTY_MAPPING },
     254             :     XML_TOKEN_MAP_END
     255             : };
     256             : 
     257           0 :         mpSeriesElemTokenMap = new SvXMLTokenMap( aSeriesElemTokenMap );
     258             :     } // if( ! mpSeriesElemTokenMap )
     259             : 
     260           0 :     return *mpSeriesElemTokenMap;
     261             : }
     262             : 
     263           0 : const SvXMLTokenMap& SchXMLImportHelper::GetChartAttrTokenMap()
     264             : {
     265           0 :     if( ! mpChartAttrTokenMap )
     266             :     {
     267             :         static const SvXMLTokenMapEntry aChartAttrTokenMap[] =
     268             : {
     269             :     { XML_NAMESPACE_XLINK,  XML_HREF,                   XML_TOK_CHART_HREF          },
     270             :     { XML_NAMESPACE_CHART,  XML_CLASS,                  XML_TOK_CHART_CLASS         },
     271             :     { XML_NAMESPACE_SVG,    XML_WIDTH,                  XML_TOK_CHART_WIDTH         },
     272             :     { XML_NAMESPACE_SVG,    XML_HEIGHT,                 XML_TOK_CHART_HEIGHT        },
     273             :     { XML_NAMESPACE_CHART,  XML_STYLE_NAME,             XML_TOK_CHART_STYLE_NAME    },
     274             :     { XML_NAMESPACE_CHART,  XML_COLUMN_MAPPING,         XML_TOK_CHART_COL_MAPPING   },
     275             :     { XML_NAMESPACE_CHART,  XML_ROW_MAPPING,            XML_TOK_CHART_ROW_MAPPING   },
     276             :     XML_TOKEN_MAP_END
     277             : };
     278             : 
     279           0 :         mpChartAttrTokenMap = new SvXMLTokenMap( aChartAttrTokenMap );
     280             :     } // if( ! mpChartAttrTokenMap )
     281             : 
     282           0 :     return *mpChartAttrTokenMap;
     283             : }
     284             : 
     285           0 : const SvXMLTokenMap& SchXMLImportHelper::GetPlotAreaAttrTokenMap()
     286             : {
     287           0 :     if( ! mpPlotAreaAttrTokenMap )
     288             :     {
     289             :         static const SvXMLTokenMapEntry aPlotAreaAttrTokenMap[] =
     290             : {
     291             :     { XML_NAMESPACE_SVG,    XML_X,                      XML_TOK_PA_X                 },
     292             :     { XML_NAMESPACE_SVG,    XML_Y,                      XML_TOK_PA_Y                 },
     293             :     { XML_NAMESPACE_SVG,    XML_WIDTH,                  XML_TOK_PA_WIDTH             },
     294             :     { XML_NAMESPACE_SVG,    XML_HEIGHT,                 XML_TOK_PA_HEIGHT            },
     295             :     { XML_NAMESPACE_CHART,  XML_STYLE_NAME,             XML_TOK_PA_STYLE_NAME        },
     296             :     { XML_NAMESPACE_TABLE,  XML_CELL_RANGE_ADDRESS,     XML_TOK_PA_CHART_ADDRESS     },
     297             :     { XML_NAMESPACE_CHART,  XML_DATA_SOURCE_HAS_LABELS, XML_TOK_PA_DS_HAS_LABELS     },
     298             :     { XML_NAMESPACE_DR3D,   XML_TRANSFORM,              XML_TOK_PA_TRANSFORM         },
     299             :     { XML_NAMESPACE_DR3D,   XML_VRP,                    XML_TOK_PA_VRP               },
     300             :     { XML_NAMESPACE_DR3D,   XML_VPN,                    XML_TOK_PA_VPN               },
     301             :     { XML_NAMESPACE_DR3D,   XML_VUP,                    XML_TOK_PA_VUP               },
     302             :     { XML_NAMESPACE_DR3D,   XML_PROJECTION,             XML_TOK_PA_PROJECTION        },
     303             :     { XML_NAMESPACE_DR3D,   XML_DISTANCE,               XML_TOK_PA_DISTANCE          },
     304             :     { XML_NAMESPACE_DR3D,   XML_FOCAL_LENGTH,           XML_TOK_PA_FOCAL_LENGTH      },
     305             :     { XML_NAMESPACE_DR3D,   XML_SHADOW_SLANT,           XML_TOK_PA_SHADOW_SLANT      },
     306             :     { XML_NAMESPACE_DR3D,   XML_SHADE_MODE,             XML_TOK_PA_SHADE_MODE        },
     307             :     { XML_NAMESPACE_DR3D,   XML_AMBIENT_COLOR,          XML_TOK_PA_AMBIENT_COLOR     },
     308             :     { XML_NAMESPACE_DR3D,   XML_LIGHTING_MODE,          XML_TOK_PA_LIGHTING_MODE     },
     309             :     XML_TOKEN_MAP_END
     310             : };
     311             : 
     312           0 :         mpPlotAreaAttrTokenMap = new SvXMLTokenMap( aPlotAreaAttrTokenMap );
     313             :     } // if( ! mpPlotAreaAttrTokenMap )
     314             : 
     315           0 :     return *mpPlotAreaAttrTokenMap;
     316             : }
     317             : 
     318           0 : const SvXMLTokenMap& SchXMLImportHelper::GetCellAttrTokenMap()
     319             : {
     320           0 :     if( ! mpCellAttrTokenMap )
     321             :     {
     322             :         static const SvXMLTokenMapEntry aCellAttrTokenMap[] =
     323             : {
     324             :     { XML_NAMESPACE_OFFICE, XML_VALUE_TYPE,             XML_TOK_CELL_VAL_TYPE       },
     325             :     { XML_NAMESPACE_OFFICE, XML_VALUE,                  XML_TOK_CELL_VALUE          },
     326             :     XML_TOKEN_MAP_END
     327             : };
     328             : 
     329           0 :         mpCellAttrTokenMap = new SvXMLTokenMap( aCellAttrTokenMap );
     330             :     } // if( ! mpCellAttrTokenMap )
     331             : 
     332           0 :     return *mpCellAttrTokenMap;
     333             : }
     334             : 
     335           0 : const SvXMLTokenMap& SchXMLImportHelper::GetSeriesAttrTokenMap()
     336             : {
     337           0 :     if( ! mpSeriesAttrTokenMap )
     338             :     {
     339             :         static const SvXMLTokenMapEntry aSeriesAttrTokenMap[] =
     340             : {
     341             :     { XML_NAMESPACE_CHART,  XML_VALUES_CELL_RANGE_ADDRESS,  XML_TOK_SERIES_CELL_RANGE    },
     342             :     { XML_NAMESPACE_CHART,  XML_LABEL_CELL_ADDRESS,         XML_TOK_SERIES_LABEL_ADDRESS },
     343             :     { XML_NAMESPACE_LO_EXT,  XML_LABEL_STRING,         XML_TOK_SERIES_LABEL_STRING },
     344             :     { XML_NAMESPACE_CHART,  XML_ATTACHED_AXIS,              XML_TOK_SERIES_ATTACHED_AXIS },
     345             :     { XML_NAMESPACE_CHART,  XML_STYLE_NAME,                 XML_TOK_SERIES_STYLE_NAME    },
     346             :     { XML_NAMESPACE_CHART,  XML_CLASS,                      XML_TOK_SERIES_CHART_CLASS   },
     347             :     XML_TOKEN_MAP_END
     348             : };
     349             : 
     350           0 :         mpSeriesAttrTokenMap = new SvXMLTokenMap( aSeriesAttrTokenMap );
     351             :     } // if( ! mpSeriesAttrTokenMap )
     352             : 
     353           0 :     return *mpSeriesAttrTokenMap;
     354             : }
     355             : 
     356           0 : const SvXMLTokenMap& SchXMLImportHelper::GetPropMappingAttrTokenMap()
     357             : {
     358           0 :     if( !mpPropMappingAttrTokenMap )
     359             :     {
     360             :         static const SvXMLTokenMapEntry aPropMappingAttrTokenMap[] =
     361             :         {
     362             :             { XML_NAMESPACE_LO_EXT, XML_PROPERTY, XML_TOK_PROPERTY_MAPPING_PROPERTY },
     363             :             { XML_NAMESPACE_LO_EXT, XML_CELL_RANGE_ADDRESS, XML_TOK_PROPERTY_MAPPING_RANGE },
     364             :             XML_TOKEN_MAP_END
     365             :         };
     366             : 
     367           0 :         mpPropMappingAttrTokenMap = new SvXMLTokenMap( aPropMappingAttrTokenMap );
     368             :     }
     369             : 
     370           0 :     return *mpPropMappingAttrTokenMap;
     371             : }
     372             : 
     373           0 : const SvXMLTokenMap& SchXMLImportHelper::GetRegEquationAttrTokenMap()
     374             : {
     375           0 :     if( ! mpRegEquationAttrTokenMap )
     376             :     {
     377             :         static const SvXMLTokenMapEntry aRegressionEquationAttrTokenMap[] =
     378             : {
     379             :     { XML_NAMESPACE_CHART,  XML_STYLE_NAME,             XML_TOK_REGEQ_STYLE_NAME         },
     380             :     { XML_NAMESPACE_CHART,  XML_DISPLAY_EQUATION,       XML_TOK_REGEQ_DISPLAY_EQUATION   },
     381             :     { XML_NAMESPACE_CHART,  XML_DISPLAY_R_SQUARE,       XML_TOK_REGEQ_DISPLAY_R_SQUARE   },
     382             :     { XML_NAMESPACE_SVG,    XML_X,                      XML_TOK_REGEQ_POS_X              },
     383             :     { XML_NAMESPACE_SVG,    XML_Y,                      XML_TOK_REGEQ_POS_Y              },
     384             :     XML_TOKEN_MAP_END
     385             : };
     386             : 
     387           0 :         mpRegEquationAttrTokenMap = new SvXMLTokenMap( aRegressionEquationAttrTokenMap );
     388             :     } // if( ! mpRegEquationAttrTokenMap )
     389             : 
     390           0 :     return *mpRegEquationAttrTokenMap;
     391             : }
     392             : 
     393             : //static
     394           0 : void SchXMLImportHelper::DeleteDataSeries(
     395             :                     const Reference< chart2::XDataSeries > & xSeries,
     396             :                     const Reference< chart2::XChartDocument > & xDoc )
     397             : {
     398           0 :     if( xDoc.is() )
     399             :     try
     400             :     {
     401             :         Reference< chart2::XCoordinateSystemContainer > xCooSysCnt(
     402           0 :             xDoc->getFirstDiagram(), uno::UNO_QUERY_THROW );
     403             :         Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
     404           0 :             xCooSysCnt->getCoordinateSystems());
     405             : 
     406           0 :         sal_Int32 nCooSysIndex = 0;
     407           0 :         for( nCooSysIndex=0; nCooSysIndex<aCooSysSeq.getLength(); nCooSysIndex++ )
     408             :         {
     409           0 :             Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[ nCooSysIndex ], uno::UNO_QUERY_THROW );
     410           0 :             Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
     411             : 
     412           0 :             sal_Int32 nChartTypeIndex = 0;
     413           0 :             for( nChartTypeIndex=0; nChartTypeIndex<aChartTypes.getLength(); nChartTypeIndex++ )
     414             :             {
     415           0 :                 Reference< chart2::XDataSeriesContainer > xSeriesCnt( aChartTypes[nChartTypeIndex], uno::UNO_QUERY_THROW );
     416           0 :                 Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries());
     417             : 
     418           0 :                 sal_Int32 nSeriesIndex = 0;
     419           0 :                 for( nSeriesIndex=0; nSeriesIndex<aSeriesSeq.getLength(); nSeriesIndex++ )
     420             :                 {
     421           0 :                     if( xSeries==aSeriesSeq[nSeriesIndex] )
     422             :                     {
     423           0 :                         xSeriesCnt->removeDataSeries(xSeries);
     424           0 :                         return;
     425             :                     }
     426             :                 }
     427           0 :             }
     428           0 :         }
     429             :     }
     430           0 :     catch( const uno::Exception & ex )
     431             :     {
     432             :        SAL_WARN("xmloff.chart",  "Exception caught. Type: " << OUString::createFromAscii( typeid( ex ).name()) << ", Message: " << ex.Message);
     433             :     }
     434             : }
     435             : 
     436             : // static
     437           0 : Reference< chart2::XDataSeries > SchXMLImportHelper::GetNewDataSeries(
     438             :     const Reference< chart2::XChartDocument > & xDoc,
     439             :     sal_Int32 nCoordinateSystemIndex,
     440             :     const OUString & rChartTypeName,
     441             :     bool bPushLastChartType /* = false */ )
     442             : {
     443           0 :     Reference< chart2::XDataSeries > xResult;
     444           0 :     if(!xDoc.is())
     445           0 :         return xResult;
     446             : 
     447             :     try
     448             :     {
     449             :         Reference< chart2::XCoordinateSystemContainer > xCooSysCnt(
     450           0 :             xDoc->getFirstDiagram(), uno::UNO_QUERY_THROW );
     451             :         Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
     452           0 :             xCooSysCnt->getCoordinateSystems());
     453             :         Reference< uno::XComponentContext > xContext(
     454           0 :             comphelper::getProcessComponentContext() );
     455             : 
     456           0 :         if( nCoordinateSystemIndex < aCooSysSeq.getLength())
     457             :         {
     458           0 :             Reference< chart2::XChartType > xCurrentType;
     459             :             {
     460           0 :                 Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[ nCoordinateSystemIndex ], uno::UNO_QUERY_THROW );
     461           0 :                 Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
     462             :                 // find matching chart type group
     463           0 :                 const Reference< chart2::XChartType > * pBegin = aChartTypes.getConstArray();
     464           0 :                 const Reference< chart2::XChartType > * pEnd = pBegin + aChartTypes.getLength();
     465             :                 const Reference< chart2::XChartType > * pIt =
     466           0 :                     ::std::find_if( pBegin, pEnd, lcl_MatchesChartType( rChartTypeName ));
     467           0 :                 if( pIt != pEnd )
     468           0 :                     xCurrentType.set( *pIt );
     469             :                 // if chart type is set at series and differs from current one,
     470             :                 // create a new chart type
     471           0 :                 if( !xCurrentType.is())
     472             :                 {
     473             :                     xCurrentType.set(
     474           0 :                         xContext->getServiceManager()->createInstanceWithContext( rChartTypeName, xContext ),
     475           0 :                         uno::UNO_QUERY );
     476           0 :                     if( xCurrentType.is())
     477             :                     {
     478           0 :                         if( bPushLastChartType && aChartTypes.getLength())
     479             :                         {
     480           0 :                             sal_Int32 nIndex( aChartTypes.getLength() - 1 );
     481           0 :                             aChartTypes.realloc( aChartTypes.getLength() + 1 );
     482           0 :                             aChartTypes[ nIndex + 1 ] = aChartTypes[ nIndex ];
     483           0 :                             aChartTypes[ nIndex ] = xCurrentType;
     484           0 :                             xCTCnt->setChartTypes( aChartTypes );
     485             :                         }
     486             :                         else
     487           0 :                             xCTCnt->addChartType( xCurrentType );
     488             :                     }
     489           0 :                 }
     490             :             }
     491             : 
     492           0 :             if( xCurrentType.is())
     493             :             {
     494           0 :                 Reference< chart2::XDataSeriesContainer > xSeriesCnt( xCurrentType, uno::UNO_QUERY_THROW );
     495             : 
     496           0 :                 if( xContext.is() )
     497             :                 {
     498             :                     xResult.set(
     499           0 :                         xContext->getServiceManager()->createInstanceWithContext(
     500             :                             OUString( "com.sun.star.chart2.DataSeries" ),
     501           0 :                             xContext ), uno::UNO_QUERY_THROW );
     502             :                 }
     503           0 :                 if( xResult.is() )
     504           0 :                     xSeriesCnt->addDataSeries( xResult );
     505           0 :             }
     506           0 :         }
     507             :     }
     508           0 :     catch( const uno::Exception & ex )
     509             :     {
     510             :         SAL_WARN("xmloff.chart", "Exception caught. Type: " << OUString::createFromAscii( typeid( ex ).name()) << ", Message: " << ex.Message);
     511             :     }
     512           0 :     return xResult;
     513             : }
     514             : 
     515             : // #110680#
     516           0 : SchXMLImport::SchXMLImport(
     517             :     const Reference< uno::XComponentContext >& xContext,
     518             :     OUString const & implementationName, sal_uInt16 nImportFlags ) :
     519           0 :     SvXMLImport( xContext, implementationName, nImportFlags )
     520             : {
     521           0 :     GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
     522           0 :     GetNamespaceMap().Add( GetXMLToken(XML_NP_CHART_EXT), GetXMLToken(XML_N_CHART_EXT), XML_NAMESPACE_CHART_EXT);
     523             : 
     524           0 :     mbIsGraphicLoadOnDemandSupported = false;
     525           0 : }
     526             : 
     527           0 : SchXMLImport::~SchXMLImport() throw ()
     528             : {
     529             :     // stop progress view
     530           0 :     if( mxStatusIndicator.is())
     531             :     {
     532           0 :         mxStatusIndicator->end();
     533           0 :         mxStatusIndicator->reset();
     534             :     }
     535             : 
     536           0 :     uno::Reference< chart2::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY );
     537           0 :     if( xChartDoc.is() && xChartDoc->hasControllersLocked() )
     538           0 :         xChartDoc->unlockControllers();
     539           0 : }
     540             : 
     541             : // create the main context (subcontexts are created
     542             : // by the one created here)
     543           0 : SvXMLImportContext *SchXMLImport::CreateContext( sal_uInt16 nPrefix, const OUString& rLocalName,
     544             :     const Reference< xml::sax::XAttributeList >& xAttrList )
     545             : {
     546           0 :     SvXMLImportContext* pContext = 0;
     547             : 
     548             :     // accept <office:document>
     549           0 :     if( XML_NAMESPACE_OFFICE == nPrefix &&
     550           0 :         ( IsXMLToken( rLocalName, XML_DOCUMENT_STYLES) ||
     551           0 :           IsXMLToken( rLocalName, XML_DOCUMENT_CONTENT) ))
     552             :     {
     553           0 :         pContext = new SchXMLDocContext( maImportHelper, *this, nPrefix, rLocalName );
     554           0 :     } else if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
     555           0 :                 ( IsXMLToken(rLocalName, XML_DOCUMENT) ||
     556           0 :                   (IsXMLToken(rLocalName, XML_DOCUMENT_META)
     557           0 :                    && (getImportFlags() & IMPORT_META) )) )
     558             :     {
     559             :         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
     560           0 :             GetModel(), uno::UNO_QUERY);
     561             :         // mst@: right now, this seems to be not supported, so it is untested
     562           0 :         if (xDPS.is()) {
     563           0 :             pContext = (IsXMLToken(rLocalName, XML_DOCUMENT_META))
     564             :                 ? new SvXMLMetaDocumentContext(*this,
     565             :                             XML_NAMESPACE_OFFICE, rLocalName,
     566           0 :                             xDPS->getDocumentProperties())
     567             :                 // flat OpenDocument file format
     568             :                 : new SchXMLFlatDocContext_Impl(
     569             :                             maImportHelper, *this, nPrefix, rLocalName,
     570           0 :                             xDPS->getDocumentProperties());
     571             :         } else {
     572           0 :             pContext = (IsXMLToken(rLocalName, XML_DOCUMENT_META))
     573           0 :                 ? SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList )
     574             :                 : new SchXMLDocContext( maImportHelper, *this,
     575           0 :                                         nPrefix, rLocalName );
     576           0 :         }
     577             :     } else {
     578           0 :         pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
     579             :     }
     580             : 
     581           0 :     return pContext;
     582             : }
     583             : 
     584           0 : SvXMLImportContext* SchXMLImport::CreateStylesContext(
     585             :     const OUString& rLocalName,
     586             :     const Reference<xml::sax::XAttributeList>& xAttrList )
     587             : {
     588             :     //#i103287# make sure that the version information is set before importing all the properties (especially stroke-opacity!)
     589           0 :     SchXMLTools::setBuildIDAtImportInfo( GetModel(), getImportInfo() );
     590             : 
     591             :     SvXMLStylesContext* pStylesCtxt =
     592           0 :         new SvXMLStylesContext( *(this), XML_NAMESPACE_OFFICE, rLocalName, xAttrList );
     593             : 
     594             :     // set context at base class, so that all auto-style classes are imported
     595           0 :     SetAutoStyles( pStylesCtxt );
     596           0 :     maImportHelper.SetAutoStylesContext( pStylesCtxt );
     597             : 
     598           0 :     return pStylesCtxt;
     599             : }
     600             : 
     601           0 : void SAL_CALL SchXMLImport::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc )
     602             :     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
     603             : {
     604           0 :     uno::Reference< chart2::XChartDocument > xOldDoc( GetModel(), uno::UNO_QUERY );
     605           0 :     if( xOldDoc.is() && xOldDoc->hasControllersLocked() )
     606           0 :         xOldDoc->unlockControllers();
     607             : 
     608           0 :     SvXMLImport::setTargetDocument( xDoc );
     609             : 
     610             :     //set data provider and number formatter
     611             :     // try to get an XDataProvider and set it
     612             :     // @todo: if we have our own data, we must not use the parent as data provider
     613           0 :     uno::Reference< chart2::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY );
     614             : 
     615           0 :     if( xChartDoc.is() )
     616             :     try
     617             :     {
     618             :         //prevent rebuild of view during load ( necesarry especially if loaded not via load api, which is the case for example if binary files are loaded )
     619           0 :         xChartDoc->lockControllers();
     620             : 
     621           0 :         uno::Reference< container::XChild > xChild( xChartDoc, uno::UNO_QUERY );
     622           0 :         uno::Reference< chart2::data::XDataReceiver > xDataReceiver( xChartDoc, uno::UNO_QUERY );
     623           0 :         bool bHasOwnData = true;
     624           0 :         if( xChild.is() && xDataReceiver.is())
     625             :         {
     626           0 :             Reference< lang::XMultiServiceFactory > xFact( xChild->getParent(), uno::UNO_QUERY );
     627           0 :             if( xFact.is() )
     628             :             {
     629             :                 //if the parent has a number formatter we will use the numberformatter of the parent
     630           0 :                 Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xFact, uno::UNO_QUERY );
     631           0 :                 xDataReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier );
     632             : 
     633           0 :                 if ( !xChartDoc->getDataProvider().is() )
     634             :                 {
     635           0 :                     const OUString aDataProviderServiceName( "com.sun.star.chart2.data.DataProvider");
     636           0 :                     const uno::Sequence< OUString > aServiceNames( xFact->getAvailableServiceNames());
     637           0 :                     const OUString * pBegin = aServiceNames.getConstArray();
     638           0 :                     const OUString * pEnd = pBegin + aServiceNames.getLength();
     639           0 :                     if( ::std::find( pBegin, pEnd, aDataProviderServiceName ) != pEnd )
     640             :                     {
     641             :                         Reference< chart2::data::XDataProvider > xProvider(
     642           0 :                             xFact->createInstance( aDataProviderServiceName ), uno::UNO_QUERY );
     643           0 :                         if( xProvider.is())
     644             :                         {
     645           0 :                             xDataReceiver->attachDataProvider( xProvider );
     646           0 :                             bHasOwnData = false;
     647           0 :                         }
     648           0 :                     }
     649             :                 }
     650             :                 else
     651           0 :                     bHasOwnData = false;
     652             :             }
     653             : //             else we have no parent => we have our own data
     654             : 
     655           0 :             if( bHasOwnData && ! xChartDoc->hasInternalDataProvider() )
     656           0 :                 xChartDoc->createInternalDataProvider( sal_False );
     657           0 :         }
     658             :     }
     659           0 :     catch( const uno::Exception & rEx )
     660             :     {
     661           0 :         OString aBStr(OUStringToOString(rEx.Message, RTL_TEXTENCODING_ASCII_US));
     662           0 :         SAL_INFO("xmloff.chart", "SchXMLChartContext::StartElement(): Exception caught: " << aBStr);
     663           0 :     }
     664           0 : }
     665             : 
     666             : // first version: everything comes from one storage
     667             : 
     668           0 : Sequence< OUString > SAL_CALL SchXMLImport_getSupportedServiceNames() throw()
     669             : {
     670           0 :     const OUString aServiceName(  "com.sun.star.comp.Chart.XMLOasisImporter"  );
     671           0 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
     672           0 :     return aSeq;
     673             : }
     674             : 
     675           0 : OUString SAL_CALL SchXMLImport_getImplementationName() throw()
     676             : {
     677           0 :     return OUString(  "SchXMLImport"  );
     678             : }
     679             : 
     680           0 : Reference< uno::XInterface > SAL_CALL SchXMLImport_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
     681             : {
     682             :     // #110680#
     683           0 :     return (cppu::OWeakObject*)new SchXMLImport( comphelper::getComponentContext(rSMgr), SchXMLImport_getImplementationName(), IMPORT_ALL);
     684             : }
     685             : 
     686             : // multiple storage version: one for content / styles / meta
     687             : 
     688           0 : Sequence< OUString > SAL_CALL SchXMLImport_Styles_getSupportedServiceNames() throw()
     689             : {
     690           0 :     const OUString aServiceName(  "com.sun.star.comp.Chart.XMLOasisStylesImporter"  );
     691           0 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
     692           0 :     return aSeq;
     693             : }
     694             : 
     695           0 : OUString SAL_CALL SchXMLImport_Styles_getImplementationName() throw()
     696             : {
     697           0 :     return OUString(  "SchXMLImport.Styles"  );
     698             : }
     699             : 
     700           0 : Reference< uno::XInterface > SAL_CALL SchXMLImport_Styles_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
     701             : {
     702             :     // #110680#
     703           0 :     return (cppu::OWeakObject*)new SchXMLImport( comphelper::getComponentContext(rSMgr), SchXMLImport_Styles_getImplementationName(), IMPORT_STYLES );
     704             : }
     705             : 
     706           0 : Sequence< OUString > SAL_CALL SchXMLImport_Content_getSupportedServiceNames() throw()
     707             : {
     708           0 :     const OUString aServiceName(  "com.sun.star.comp.Chart.XMLOasisContentImporter"  );
     709           0 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
     710           0 :     return aSeq;
     711             : }
     712             : 
     713           0 : OUString SAL_CALL SchXMLImport_Content_getImplementationName() throw()
     714             : {
     715           0 :     return OUString(  "SchXMLImport.Content"  );
     716             : }
     717             : 
     718           0 : Reference< uno::XInterface > SAL_CALL SchXMLImport_Content_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
     719             : {
     720             :     // #110680#
     721           0 :     return (cppu::OWeakObject*)new SchXMLImport( comphelper::getComponentContext(rSMgr), SchXMLImport_Content_getImplementationName(), IMPORT_CONTENT | IMPORT_AUTOSTYLES | IMPORT_FONTDECLS );
     722             : }
     723             : 
     724           0 : Sequence< OUString > SAL_CALL SchXMLImport_Meta_getSupportedServiceNames() throw()
     725             : {
     726           0 :     const OUString aServiceName(  "com.sun.star.comp.Chart.XMLOasisMetaImporter"  );
     727           0 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
     728           0 :     return aSeq;
     729             : }
     730             : 
     731           0 : OUString SAL_CALL SchXMLImport_Meta_getImplementationName() throw()
     732             : {
     733           0 :     return OUString(  "SchXMLImport.Meta"  );
     734             : }
     735             : 
     736           0 : Reference< uno::XInterface > SAL_CALL SchXMLImport_Meta_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
     737             : {
     738             :     // #110680#
     739           0 :     return (cppu::OWeakObject*)new SchXMLImport( comphelper::getComponentContext(rSMgr), SchXMLImport_Meta_getImplementationName(), IMPORT_META );
     740             : }
     741             : 
     742             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10