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 "SchXMLImport.hxx" 28cdf0e10cSrcweir #include "SchXMLChartContext.hxx" 29cdf0e10cSrcweir #include "contexts.hxx" 30cdf0e10cSrcweir #include "XMLChartPropertySetMapper.hxx" 31cdf0e10cSrcweir #include "SchXMLTools.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <tools/debug.hxx> 34cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 35cdf0e10cSrcweir // header for class ByteString 36cdf0e10cSrcweir #include <tools/string.hxx> 37cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 38cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 39cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 40cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 41cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 42cdf0e10cSrcweir #include <xmloff/xmlictxt.hxx> 43cdf0e10cSrcweir #include <xmloff/xmlstyle.hxx> 44cdf0e10cSrcweir #include <com/sun/star/task/XStatusIndicatorSupplier.hpp> 45cdf0e10cSrcweir #include <com/sun/star/chart/XChartDocument.hpp> 46cdf0e10cSrcweir #include <com/sun/star/chart/ChartDataRowSource.hpp> 47cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 48cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 49cdf0e10cSrcweir #include <com/sun/star/chart2/data/XDataReceiver.hpp> 50cdf0e10cSrcweir #include <com/sun/star/chart2/data/XDataProvider.hpp> 51cdf0e10cSrcweir #include <com/sun/star/chart2/XChartDocument.hpp> 52cdf0e10cSrcweir #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> 53cdf0e10cSrcweir #include <com/sun/star/chart2/XChartTypeContainer.hpp> 54cdf0e10cSrcweir #include <com/sun/star/chart2/XDataSeriesContainer.hpp> 55cdf0e10cSrcweir 56cdf0e10cSrcweir #include <com/sun/star/document/XDocumentProperties.hpp> 57cdf0e10cSrcweir #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> 58cdf0e10cSrcweir 59cdf0e10cSrcweir #include <typeinfo> 60cdf0e10cSrcweir 61cdf0e10cSrcweir using namespace com::sun::star; 62cdf0e10cSrcweir using namespace ::xmloff::token; 63cdf0e10cSrcweir 64cdf0e10cSrcweir using ::rtl::OUString; 65cdf0e10cSrcweir using ::rtl::OUStringBuffer; 66cdf0e10cSrcweir using ::rtl::OUStringToOString; 67cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 68cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 69cdf0e10cSrcweir 70cdf0e10cSrcweir namespace 71cdf0e10cSrcweir { 72cdf0e10cSrcweir Reference< uno::XComponentContext > lcl_getComponentContext() 73cdf0e10cSrcweir { 74cdf0e10cSrcweir Reference< uno::XComponentContext > xContext; 75cdf0e10cSrcweir try 76cdf0e10cSrcweir { 77cdf0e10cSrcweir Reference< beans::XPropertySet > xFactProp( comphelper::getProcessServiceFactory(), uno::UNO_QUERY ); 78cdf0e10cSrcweir if( xFactProp.is()) 79cdf0e10cSrcweir xFactProp->getPropertyValue(OUString::createFromAscii("DefaultContext")) >>= xContext; 80cdf0e10cSrcweir } 81cdf0e10cSrcweir catch( uno::Exception& ) 82cdf0e10cSrcweir {} 83cdf0e10cSrcweir 84cdf0e10cSrcweir return xContext; 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir class lcl_MatchesChartType : public ::std::unary_function< Reference< chart2::XChartType >, bool > 88cdf0e10cSrcweir { 89cdf0e10cSrcweir public: 90cdf0e10cSrcweir explicit lcl_MatchesChartType( const OUString & aChartTypeName ) : 91cdf0e10cSrcweir m_aChartTypeName( aChartTypeName ) 92cdf0e10cSrcweir {} 93cdf0e10cSrcweir 94cdf0e10cSrcweir bool operator () ( const Reference< chart2::XChartType > & xChartType ) const 95cdf0e10cSrcweir { 96cdf0e10cSrcweir return (xChartType.is() && 97cdf0e10cSrcweir xChartType->getChartType().equals( m_aChartTypeName )); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir private: 101cdf0e10cSrcweir OUString m_aChartTypeName; 102cdf0e10cSrcweir }; 103cdf0e10cSrcweir } // anonymous namespace 104cdf0e10cSrcweir 105cdf0e10cSrcweir /* ---------------------------------------- 106cdf0e10cSrcweir TokenMaps for distinguishing different 107cdf0e10cSrcweir tokens in different contexts 108cdf0e10cSrcweir ----------------------------------------*/ 109cdf0e10cSrcweir 110cdf0e10cSrcweir // ---------------------------------------- 111cdf0e10cSrcweir // element maps 112cdf0e10cSrcweir // ---------------------------------------- 113cdf0e10cSrcweir 114cdf0e10cSrcweir 115cdf0e10cSrcweir 116cdf0e10cSrcweir 117cdf0e10cSrcweir 118cdf0e10cSrcweir 119cdf0e10cSrcweir 120cdf0e10cSrcweir // ---------------------------------------- 121cdf0e10cSrcweir // attribute maps 122cdf0e10cSrcweir // ---------------------------------------- 123cdf0e10cSrcweir 124cdf0e10cSrcweir 125cdf0e10cSrcweir 126cdf0e10cSrcweir 127cdf0e10cSrcweir 128cdf0e10cSrcweir 129cdf0e10cSrcweir 130cdf0e10cSrcweir 131cdf0e10cSrcweir 132cdf0e10cSrcweir // ======================================== 133cdf0e10cSrcweir 134cdf0e10cSrcweir SchXMLImportHelper::SchXMLImportHelper() : 135cdf0e10cSrcweir mpAutoStyles( 0 ), 136cdf0e10cSrcweir 137cdf0e10cSrcweir mpChartDocElemTokenMap( 0 ), 138cdf0e10cSrcweir mpTableElemTokenMap( 0 ), 139cdf0e10cSrcweir mpChartElemTokenMap( 0 ), 140cdf0e10cSrcweir mpPlotAreaElemTokenMap( 0 ), 141cdf0e10cSrcweir mpSeriesElemTokenMap( 0 ), 142cdf0e10cSrcweir 143cdf0e10cSrcweir mpChartAttrTokenMap( 0 ), 144cdf0e10cSrcweir mpPlotAreaAttrTokenMap( 0 ), 145cdf0e10cSrcweir mpAutoStyleAttrTokenMap( 0 ), 146cdf0e10cSrcweir mpCellAttrTokenMap( 0 ), 147cdf0e10cSrcweir mpSeriesAttrTokenMap( 0 ), 148cdf0e10cSrcweir mpRegEquationAttrTokenMap( 0 ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir SchXMLImportHelper::~SchXMLImportHelper() 153cdf0e10cSrcweir { 154cdf0e10cSrcweir // delete token maps 155cdf0e10cSrcweir if( mpChartDocElemTokenMap ) 156cdf0e10cSrcweir delete mpChartDocElemTokenMap; 157cdf0e10cSrcweir if( mpTableElemTokenMap ) 158cdf0e10cSrcweir delete mpTableElemTokenMap; 159cdf0e10cSrcweir if( mpChartElemTokenMap ) 160cdf0e10cSrcweir delete mpChartElemTokenMap; 161cdf0e10cSrcweir if( mpPlotAreaElemTokenMap ) 162cdf0e10cSrcweir delete mpPlotAreaElemTokenMap; 163cdf0e10cSrcweir if( mpSeriesElemTokenMap ) 164cdf0e10cSrcweir delete mpSeriesElemTokenMap; 165cdf0e10cSrcweir 166cdf0e10cSrcweir if( mpChartAttrTokenMap ) 167cdf0e10cSrcweir delete mpChartAttrTokenMap; 168cdf0e10cSrcweir if( mpPlotAreaAttrTokenMap ) 169cdf0e10cSrcweir delete mpPlotAreaAttrTokenMap; 170cdf0e10cSrcweir if( mpAutoStyleAttrTokenMap ) 171cdf0e10cSrcweir delete mpAutoStyleAttrTokenMap; 172cdf0e10cSrcweir if( mpCellAttrTokenMap ) 173cdf0e10cSrcweir delete mpCellAttrTokenMap; 174cdf0e10cSrcweir if( mpSeriesAttrTokenMap ) 175cdf0e10cSrcweir delete mpSeriesAttrTokenMap; 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir SvXMLImportContext* SchXMLImportHelper::CreateChartContext( 179cdf0e10cSrcweir SvXMLImport& rImport, 180cdf0e10cSrcweir sal_uInt16 nPrefix, const OUString& rLocalName, 181cdf0e10cSrcweir const Reference< frame::XModel > xChartModel, 182cdf0e10cSrcweir const Reference< xml::sax::XAttributeList >& ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir SvXMLImportContext* pContext = 0; 185cdf0e10cSrcweir 186cdf0e10cSrcweir Reference< chart::XChartDocument > xDoc( xChartModel, uno::UNO_QUERY ); 187cdf0e10cSrcweir if( xDoc.is()) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir mxChartDoc = xDoc; 190cdf0e10cSrcweir pContext = new SchXMLChartContext( *this, rImport, rLocalName ); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir else 193cdf0e10cSrcweir { 194cdf0e10cSrcweir DBG_ERROR( "No valid XChartDocument given as XModel" ); 195cdf0e10cSrcweir pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName ); 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir return pContext; 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201cdf0e10cSrcweir /* ---------------------------------------- 202cdf0e10cSrcweir get various token maps 203cdf0e10cSrcweir ----------------------------------------*/ 204cdf0e10cSrcweir 205cdf0e10cSrcweir const SvXMLTokenMap& SchXMLImportHelper::GetDocElemTokenMap() 206cdf0e10cSrcweir { 207cdf0e10cSrcweir if( ! mpChartDocElemTokenMap ) 208cdf0e10cSrcweir { 209cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aDocElemTokenMap[] = 210cdf0e10cSrcweir { 211cdf0e10cSrcweir { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES }, 212cdf0e10cSrcweir { XML_NAMESPACE_OFFICE, XML_STYLES, XML_TOK_DOC_STYLES }, 213cdf0e10cSrcweir { XML_NAMESPACE_OFFICE, XML_META, XML_TOK_DOC_META }, 214cdf0e10cSrcweir { XML_NAMESPACE_OFFICE, XML_BODY, XML_TOK_DOC_BODY }, 215cdf0e10cSrcweir XML_TOKEN_MAP_END 216cdf0e10cSrcweir }; 217cdf0e10cSrcweir 218cdf0e10cSrcweir mpChartDocElemTokenMap = new SvXMLTokenMap( aDocElemTokenMap ); 219cdf0e10cSrcweir } // if( ! mpChartDocElemTokenMap ) 220cdf0e10cSrcweir 221cdf0e10cSrcweir return *mpChartDocElemTokenMap; 222cdf0e10cSrcweir } 223cdf0e10cSrcweir 224cdf0e10cSrcweir const SvXMLTokenMap& SchXMLImportHelper::GetTableElemTokenMap() 225cdf0e10cSrcweir { 226cdf0e10cSrcweir if( ! mpTableElemTokenMap ) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aTableElemTokenMap[] = 229cdf0e10cSrcweir { 230cdf0e10cSrcweir { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, XML_TOK_TABLE_HEADER_COLS }, 231cdf0e10cSrcweir { XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, XML_TOK_TABLE_COLUMNS }, 232cdf0e10cSrcweir { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, XML_TOK_TABLE_COLUMN }, 233cdf0e10cSrcweir { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, XML_TOK_TABLE_HEADER_ROWS }, 234cdf0e10cSrcweir { XML_NAMESPACE_TABLE, XML_TABLE_ROWS, XML_TOK_TABLE_ROWS }, 235cdf0e10cSrcweir { XML_NAMESPACE_TABLE, XML_TABLE_ROW, XML_TOK_TABLE_ROW }, 236cdf0e10cSrcweir XML_TOKEN_MAP_END 237cdf0e10cSrcweir }; 238cdf0e10cSrcweir 239cdf0e10cSrcweir mpTableElemTokenMap = new SvXMLTokenMap( aTableElemTokenMap ); 240cdf0e10cSrcweir } // if( ! mpTableElemTokenMap ) 241cdf0e10cSrcweir 242cdf0e10cSrcweir return *mpTableElemTokenMap; 243cdf0e10cSrcweir } 244cdf0e10cSrcweir 245cdf0e10cSrcweir const SvXMLTokenMap& SchXMLImportHelper::GetChartElemTokenMap() 246cdf0e10cSrcweir { 247cdf0e10cSrcweir if( ! mpChartElemTokenMap ) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aChartElemTokenMap[] = 250cdf0e10cSrcweir { 251cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_PLOT_AREA, XML_TOK_CHART_PLOT_AREA }, 252cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_TITLE, XML_TOK_CHART_TITLE }, 253cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_SUBTITLE, XML_TOK_CHART_SUBTITLE }, 254cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_LEGEND, XML_TOK_CHART_LEGEND }, 255cdf0e10cSrcweir { XML_NAMESPACE_TABLE, XML_TABLE, XML_TOK_CHART_TABLE }, 256cdf0e10cSrcweir XML_TOKEN_MAP_END 257cdf0e10cSrcweir }; 258cdf0e10cSrcweir 259cdf0e10cSrcweir mpChartElemTokenMap = new SvXMLTokenMap( aChartElemTokenMap ); 260cdf0e10cSrcweir } // if( ! mpChartElemTokenMap ) 261cdf0e10cSrcweir 262cdf0e10cSrcweir return *mpChartElemTokenMap; 263cdf0e10cSrcweir } 264cdf0e10cSrcweir 265cdf0e10cSrcweir const SvXMLTokenMap& SchXMLImportHelper::GetPlotAreaElemTokenMap() 266cdf0e10cSrcweir { 267cdf0e10cSrcweir if( ! mpPlotAreaElemTokenMap ) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aPlotAreaElemTokenMap[] = 270cdf0e10cSrcweir { 271cdf0e10cSrcweir { XML_NAMESPACE_CHART_EXT, XML_COORDINATE_REGION, XML_TOK_PA_COORDINATE_REGION_EXT }, 272cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_COORDINATE_REGION, XML_TOK_PA_COORDINATE_REGION }, 273cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_AXIS, XML_TOK_PA_AXIS }, 274cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_SERIES, XML_TOK_PA_SERIES }, 275cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_WALL, XML_TOK_PA_WALL }, 276cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_FLOOR, XML_TOK_PA_FLOOR }, 277cdf0e10cSrcweir { XML_NAMESPACE_DR3D, XML_LIGHT, XML_TOK_PA_LIGHT_SOURCE }, 278cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_STOCK_GAIN_MARKER, XML_TOK_PA_STOCK_GAIN }, 279cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_STOCK_LOSS_MARKER, XML_TOK_PA_STOCK_LOSS }, 280cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_STOCK_RANGE_LINE, XML_TOK_PA_STOCK_RANGE }, 281cdf0e10cSrcweir XML_TOKEN_MAP_END 282cdf0e10cSrcweir }; 283cdf0e10cSrcweir 284cdf0e10cSrcweir mpPlotAreaElemTokenMap = new SvXMLTokenMap( aPlotAreaElemTokenMap ); 285cdf0e10cSrcweir } // if( ! mpPlotAreaElemTokenMap ) 286cdf0e10cSrcweir 287cdf0e10cSrcweir return *mpPlotAreaElemTokenMap; 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir const SvXMLTokenMap& SchXMLImportHelper::GetSeriesElemTokenMap() 291cdf0e10cSrcweir { 292cdf0e10cSrcweir if( ! mpSeriesElemTokenMap ) 293cdf0e10cSrcweir { 294cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aSeriesElemTokenMap[] = 295cdf0e10cSrcweir { 296cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_DATA_POINT, XML_TOK_SERIES_DATA_POINT }, 297cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_DOMAIN, XML_TOK_SERIES_DOMAIN }, 298cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_MEAN_VALUE, XML_TOK_SERIES_MEAN_VALUE_LINE }, 299cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_REGRESSION_CURVE, XML_TOK_SERIES_REGRESSION_CURVE }, 300cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_ERROR_INDICATOR, XML_TOK_SERIES_ERROR_INDICATOR }, 301cdf0e10cSrcweir XML_TOKEN_MAP_END 302cdf0e10cSrcweir }; 303cdf0e10cSrcweir 304cdf0e10cSrcweir mpSeriesElemTokenMap = new SvXMLTokenMap( aSeriesElemTokenMap ); 305cdf0e10cSrcweir } // if( ! mpSeriesElemTokenMap ) 306cdf0e10cSrcweir 307cdf0e10cSrcweir return *mpSeriesElemTokenMap; 308cdf0e10cSrcweir } 309cdf0e10cSrcweir 310cdf0e10cSrcweir // ---------------------------------------- 311cdf0e10cSrcweir 312cdf0e10cSrcweir const SvXMLTokenMap& SchXMLImportHelper::GetChartAttrTokenMap() 313cdf0e10cSrcweir { 314cdf0e10cSrcweir if( ! mpChartAttrTokenMap ) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aChartAttrTokenMap[] = 317cdf0e10cSrcweir { 318cdf0e10cSrcweir { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_CHART_HREF }, 319cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_CLASS, XML_TOK_CHART_CLASS }, 320cdf0e10cSrcweir { XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_CHART_WIDTH }, 321cdf0e10cSrcweir { XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_CHART_HEIGHT }, 322cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_CHART_STYLE_NAME }, 323cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_COLUMN_MAPPING, XML_TOK_CHART_COL_MAPPING }, 324cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_ROW_MAPPING, XML_TOK_CHART_ROW_MAPPING }, 325cdf0e10cSrcweir XML_TOKEN_MAP_END 326cdf0e10cSrcweir }; 327cdf0e10cSrcweir 328cdf0e10cSrcweir mpChartAttrTokenMap = new SvXMLTokenMap( aChartAttrTokenMap ); 329cdf0e10cSrcweir } // if( ! mpChartAttrTokenMap ) 330cdf0e10cSrcweir 331cdf0e10cSrcweir return *mpChartAttrTokenMap; 332cdf0e10cSrcweir } 333cdf0e10cSrcweir 334cdf0e10cSrcweir const SvXMLTokenMap& SchXMLImportHelper::GetPlotAreaAttrTokenMap() 335cdf0e10cSrcweir { 336cdf0e10cSrcweir if( ! mpPlotAreaAttrTokenMap ) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aPlotAreaAttrTokenMap[] = 339cdf0e10cSrcweir { 340cdf0e10cSrcweir { XML_NAMESPACE_SVG, XML_X, XML_TOK_PA_X }, 341cdf0e10cSrcweir { XML_NAMESPACE_SVG, XML_Y, XML_TOK_PA_Y }, 342cdf0e10cSrcweir { XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_PA_WIDTH }, 343cdf0e10cSrcweir { XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_PA_HEIGHT }, 344cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_PA_STYLE_NAME }, 345cdf0e10cSrcweir { XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, XML_TOK_PA_CHART_ADDRESS }, 346cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_DATA_SOURCE_HAS_LABELS, XML_TOK_PA_DS_HAS_LABELS }, 347cdf0e10cSrcweir { XML_NAMESPACE_DR3D, XML_TRANSFORM, XML_TOK_PA_TRANSFORM }, 348cdf0e10cSrcweir { XML_NAMESPACE_DR3D, XML_VRP, XML_TOK_PA_VRP }, 349cdf0e10cSrcweir { XML_NAMESPACE_DR3D, XML_VPN, XML_TOK_PA_VPN }, 350cdf0e10cSrcweir { XML_NAMESPACE_DR3D, XML_VUP, XML_TOK_PA_VUP }, 351cdf0e10cSrcweir { XML_NAMESPACE_DR3D, XML_PROJECTION, XML_TOK_PA_PROJECTION }, 352cdf0e10cSrcweir { XML_NAMESPACE_DR3D, XML_DISTANCE, XML_TOK_PA_DISTANCE }, 353cdf0e10cSrcweir { XML_NAMESPACE_DR3D, XML_FOCAL_LENGTH, XML_TOK_PA_FOCAL_LENGTH }, 354cdf0e10cSrcweir { XML_NAMESPACE_DR3D, XML_SHADOW_SLANT, XML_TOK_PA_SHADOW_SLANT }, 355cdf0e10cSrcweir { XML_NAMESPACE_DR3D, XML_SHADE_MODE, XML_TOK_PA_SHADE_MODE }, 356cdf0e10cSrcweir { XML_NAMESPACE_DR3D, XML_AMBIENT_COLOR, XML_TOK_PA_AMBIENT_COLOR }, 357cdf0e10cSrcweir { XML_NAMESPACE_DR3D, XML_LIGHTING_MODE, XML_TOK_PA_LIGHTING_MODE }, 358cdf0e10cSrcweir XML_TOKEN_MAP_END 359cdf0e10cSrcweir }; 360cdf0e10cSrcweir 361cdf0e10cSrcweir mpPlotAreaAttrTokenMap = new SvXMLTokenMap( aPlotAreaAttrTokenMap ); 362cdf0e10cSrcweir } // if( ! mpPlotAreaAttrTokenMap ) 363cdf0e10cSrcweir 364cdf0e10cSrcweir return *mpPlotAreaAttrTokenMap; 365cdf0e10cSrcweir } 366cdf0e10cSrcweir 367cdf0e10cSrcweir const SvXMLTokenMap& SchXMLImportHelper::GetAutoStyleAttrTokenMap() 368cdf0e10cSrcweir { 369cdf0e10cSrcweir if( ! mpAutoStyleAttrTokenMap ) 370cdf0e10cSrcweir { 371cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aAutoStyleAttrTokenMap[] = 372cdf0e10cSrcweir { 373cdf0e10cSrcweir { XML_NAMESPACE_STYLE, XML_FAMILY, XML_TOK_AS_FAMILY }, 374cdf0e10cSrcweir { XML_NAMESPACE_STYLE, XML_NAME, XML_TOK_AS_NAME }, 375cdf0e10cSrcweir XML_TOKEN_MAP_END 376cdf0e10cSrcweir }; 377cdf0e10cSrcweir 378cdf0e10cSrcweir mpAutoStyleAttrTokenMap = new SvXMLTokenMap( aAutoStyleAttrTokenMap ); 379cdf0e10cSrcweir } // if( ! mpAutoStyleAttrTokenMap ) 380cdf0e10cSrcweir 381cdf0e10cSrcweir return *mpAutoStyleAttrTokenMap; 382cdf0e10cSrcweir } 383cdf0e10cSrcweir 384cdf0e10cSrcweir const SvXMLTokenMap& SchXMLImportHelper::GetCellAttrTokenMap() 385cdf0e10cSrcweir { 386cdf0e10cSrcweir if( ! mpCellAttrTokenMap ) 387cdf0e10cSrcweir { 388cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aCellAttrTokenMap[] = 389cdf0e10cSrcweir { 390cdf0e10cSrcweir { XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_TOK_CELL_VAL_TYPE }, 391cdf0e10cSrcweir { XML_NAMESPACE_OFFICE, XML_VALUE, XML_TOK_CELL_VALUE }, 392cdf0e10cSrcweir XML_TOKEN_MAP_END 393cdf0e10cSrcweir }; 394cdf0e10cSrcweir 395cdf0e10cSrcweir mpCellAttrTokenMap = new SvXMLTokenMap( aCellAttrTokenMap ); 396cdf0e10cSrcweir } // if( ! mpCellAttrTokenMap ) 397cdf0e10cSrcweir 398cdf0e10cSrcweir return *mpCellAttrTokenMap; 399cdf0e10cSrcweir } 400cdf0e10cSrcweir 401cdf0e10cSrcweir const SvXMLTokenMap& SchXMLImportHelper::GetSeriesAttrTokenMap() 402cdf0e10cSrcweir { 403cdf0e10cSrcweir if( ! mpSeriesAttrTokenMap ) 404cdf0e10cSrcweir { 405cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aSeriesAttrTokenMap[] = 406cdf0e10cSrcweir { 407cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, XML_TOK_SERIES_CELL_RANGE }, 408cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, XML_TOK_SERIES_LABEL_ADDRESS }, 409cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_TOK_SERIES_ATTACHED_AXIS }, 410cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_SERIES_STYLE_NAME }, 411cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_CLASS, XML_TOK_SERIES_CHART_CLASS }, 412cdf0e10cSrcweir XML_TOKEN_MAP_END 413cdf0e10cSrcweir }; 414cdf0e10cSrcweir 415cdf0e10cSrcweir mpSeriesAttrTokenMap = new SvXMLTokenMap( aSeriesAttrTokenMap ); 416cdf0e10cSrcweir } // if( ! mpSeriesAttrTokenMap ) 417cdf0e10cSrcweir 418cdf0e10cSrcweir return *mpSeriesAttrTokenMap; 419cdf0e10cSrcweir } 420cdf0e10cSrcweir 421cdf0e10cSrcweir const SvXMLTokenMap& SchXMLImportHelper::GetRegEquationAttrTokenMap() 422cdf0e10cSrcweir { 423cdf0e10cSrcweir if( ! mpRegEquationAttrTokenMap ) 424cdf0e10cSrcweir { 425cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aRegressionEquationAttrTokenMap[] = 426cdf0e10cSrcweir { 427cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_REGEQ_STYLE_NAME }, 428cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_DISPLAY_EQUATION, XML_TOK_REGEQ_DISPLAY_EQUATION }, 429cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_DISPLAY_R_SQUARE, XML_TOK_REGEQ_DISPLAY_R_SQUARE }, 430cdf0e10cSrcweir { XML_NAMESPACE_SVG, XML_X, XML_TOK_REGEQ_POS_X }, 431cdf0e10cSrcweir { XML_NAMESPACE_SVG, XML_Y, XML_TOK_REGEQ_POS_Y }, 432cdf0e10cSrcweir XML_TOKEN_MAP_END 433cdf0e10cSrcweir }; 434cdf0e10cSrcweir 435cdf0e10cSrcweir mpRegEquationAttrTokenMap = new SvXMLTokenMap( aRegressionEquationAttrTokenMap ); 436cdf0e10cSrcweir } // if( ! mpRegEquationAttrTokenMap ) 437cdf0e10cSrcweir 438cdf0e10cSrcweir return *mpRegEquationAttrTokenMap; 439cdf0e10cSrcweir } 440cdf0e10cSrcweir 441cdf0e10cSrcweir // ---------------------------------------- 442cdf0e10cSrcweir 443cdf0e10cSrcweir //static 444cdf0e10cSrcweir void SchXMLImportHelper::DeleteDataSeries( 445cdf0e10cSrcweir const Reference< chart2::XDataSeries > & xSeries, 446cdf0e10cSrcweir const Reference< chart2::XChartDocument > & xDoc ) 447cdf0e10cSrcweir { 448cdf0e10cSrcweir if( xDoc.is() ) 449cdf0e10cSrcweir try 450cdf0e10cSrcweir { 451cdf0e10cSrcweir Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( 452cdf0e10cSrcweir xDoc->getFirstDiagram(), uno::UNO_QUERY_THROW ); 453cdf0e10cSrcweir Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( 454cdf0e10cSrcweir xCooSysCnt->getCoordinateSystems()); 455cdf0e10cSrcweir 456cdf0e10cSrcweir sal_Int32 nCooSysIndex = 0; 457cdf0e10cSrcweir for( nCooSysIndex=0; nCooSysIndex<aCooSysSeq.getLength(); nCooSysIndex++ ) 458cdf0e10cSrcweir { 459cdf0e10cSrcweir Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[ nCooSysIndex ], uno::UNO_QUERY_THROW ); 460cdf0e10cSrcweir Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); 461cdf0e10cSrcweir 462cdf0e10cSrcweir sal_Int32 nChartTypeIndex = 0; 463cdf0e10cSrcweir for( nChartTypeIndex=0; nChartTypeIndex<aChartTypes.getLength(); nChartTypeIndex++ ) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir Reference< chart2::XDataSeriesContainer > xSeriesCnt( aChartTypes[nChartTypeIndex], uno::UNO_QUERY_THROW ); 466cdf0e10cSrcweir Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries()); 467cdf0e10cSrcweir 468cdf0e10cSrcweir sal_Int32 nSeriesIndex = 0; 469cdf0e10cSrcweir for( nSeriesIndex=0; nSeriesIndex<aSeriesSeq.getLength(); nSeriesIndex++ ) 470cdf0e10cSrcweir { 471cdf0e10cSrcweir if( xSeries==aSeriesSeq[nSeriesIndex] ) 472cdf0e10cSrcweir { 473cdf0e10cSrcweir xSeriesCnt->removeDataSeries(xSeries); 474cdf0e10cSrcweir return; 475cdf0e10cSrcweir } 476cdf0e10cSrcweir } 477cdf0e10cSrcweir } 478cdf0e10cSrcweir } 479cdf0e10cSrcweir } 480cdf0e10cSrcweir catch( uno::Exception & ex ) 481cdf0e10cSrcweir { 482cdf0e10cSrcweir (void)ex; // avoid warning for pro build 483cdf0e10cSrcweir OSL_ENSURE( false, OUStringToOString( 484cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) + 485cdf0e10cSrcweir OUString::createFromAscii( typeid( ex ).name()) + 486cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) + 487cdf0e10cSrcweir ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); 488cdf0e10cSrcweir } 489cdf0e10cSrcweir } 490cdf0e10cSrcweir 491cdf0e10cSrcweir // static 492cdf0e10cSrcweir Reference< chart2::XDataSeries > SchXMLImportHelper::GetNewDataSeries( 493cdf0e10cSrcweir const Reference< chart2::XChartDocument > & xDoc, 494cdf0e10cSrcweir sal_Int32 nCoordinateSystemIndex, 495cdf0e10cSrcweir const OUString & rChartTypeName, 496cdf0e10cSrcweir bool bPushLastChartType /* = false */ ) 497cdf0e10cSrcweir { 498cdf0e10cSrcweir Reference< chart2::XDataSeries > xResult; 499cdf0e10cSrcweir if(!xDoc.is()) 500cdf0e10cSrcweir return xResult; 501cdf0e10cSrcweir 502cdf0e10cSrcweir try 503cdf0e10cSrcweir { 504cdf0e10cSrcweir Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( 505cdf0e10cSrcweir xDoc->getFirstDiagram(), uno::UNO_QUERY_THROW ); 506cdf0e10cSrcweir Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( 507cdf0e10cSrcweir xCooSysCnt->getCoordinateSystems()); 508cdf0e10cSrcweir Reference< uno::XComponentContext > xContext( lcl_getComponentContext()); 509cdf0e10cSrcweir 510cdf0e10cSrcweir if( nCoordinateSystemIndex < aCooSysSeq.getLength()) 511cdf0e10cSrcweir { 512cdf0e10cSrcweir Reference< chart2::XChartType > xCurrentType; 513cdf0e10cSrcweir { 514cdf0e10cSrcweir Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[ nCoordinateSystemIndex ], uno::UNO_QUERY_THROW ); 515cdf0e10cSrcweir Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); 516cdf0e10cSrcweir // find matching chart type group 517cdf0e10cSrcweir const Reference< chart2::XChartType > * pBegin = aChartTypes.getConstArray(); 518cdf0e10cSrcweir const Reference< chart2::XChartType > * pEnd = pBegin + aChartTypes.getLength(); 519cdf0e10cSrcweir const Reference< chart2::XChartType > * pIt = 520cdf0e10cSrcweir ::std::find_if( pBegin, pEnd, lcl_MatchesChartType( rChartTypeName )); 521cdf0e10cSrcweir if( pIt != pEnd ) 522cdf0e10cSrcweir xCurrentType.set( *pIt ); 523cdf0e10cSrcweir // if chart type is set at series and differs from current one, 524cdf0e10cSrcweir // create a new chart type 525cdf0e10cSrcweir if( !xCurrentType.is()) 526cdf0e10cSrcweir { 527cdf0e10cSrcweir xCurrentType.set( 528cdf0e10cSrcweir xContext->getServiceManager()->createInstanceWithContext( rChartTypeName, xContext ), 529cdf0e10cSrcweir uno::UNO_QUERY ); 530cdf0e10cSrcweir if( xCurrentType.is()) 531cdf0e10cSrcweir { 532cdf0e10cSrcweir if( bPushLastChartType && aChartTypes.getLength()) 533cdf0e10cSrcweir { 534cdf0e10cSrcweir sal_Int32 nIndex( aChartTypes.getLength() - 1 ); 535cdf0e10cSrcweir aChartTypes.realloc( aChartTypes.getLength() + 1 ); 536cdf0e10cSrcweir aChartTypes[ nIndex + 1 ] = aChartTypes[ nIndex ]; 537cdf0e10cSrcweir aChartTypes[ nIndex ] = xCurrentType; 538cdf0e10cSrcweir xCTCnt->setChartTypes( aChartTypes ); 539cdf0e10cSrcweir } 540cdf0e10cSrcweir else 541cdf0e10cSrcweir xCTCnt->addChartType( xCurrentType ); 542cdf0e10cSrcweir } 543cdf0e10cSrcweir } 544cdf0e10cSrcweir } 545cdf0e10cSrcweir 546cdf0e10cSrcweir if( xCurrentType.is()) 547cdf0e10cSrcweir { 548cdf0e10cSrcweir Reference< chart2::XDataSeriesContainer > xSeriesCnt( xCurrentType, uno::UNO_QUERY_THROW ); 549cdf0e10cSrcweir Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries()); 550cdf0e10cSrcweir 551cdf0e10cSrcweir if( xContext.is() ) 552cdf0e10cSrcweir { 553cdf0e10cSrcweir xResult.set( 554cdf0e10cSrcweir xContext->getServiceManager()->createInstanceWithContext( 555cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.chart2.DataSeries"), 556cdf0e10cSrcweir xContext ), uno::UNO_QUERY_THROW ); 557cdf0e10cSrcweir } 558cdf0e10cSrcweir if( xResult.is() ) 559cdf0e10cSrcweir xSeriesCnt->addDataSeries( xResult ); 560cdf0e10cSrcweir } 561cdf0e10cSrcweir } 562cdf0e10cSrcweir } 563cdf0e10cSrcweir catch( uno::Exception & ex ) 564cdf0e10cSrcweir { 565cdf0e10cSrcweir (void)ex; // avoid warning for pro build 566cdf0e10cSrcweir OSL_ENSURE( false, OUStringToOString( 567cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) + 568cdf0e10cSrcweir OUString::createFromAscii( typeid( ex ).name()) + 569cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) + 570cdf0e10cSrcweir ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); 571cdf0e10cSrcweir } 572cdf0e10cSrcweir return xResult; 573cdf0e10cSrcweir } 574cdf0e10cSrcweir 575cdf0e10cSrcweir // static 576cdf0e10cSrcweir Reference< chart2::data::XLabeledDataSequence > SchXMLImportHelper::GetNewLabeledDataSequence() 577cdf0e10cSrcweir { 578cdf0e10cSrcweir // @todo: remove this asap 579cdf0e10cSrcweir OSL_ENSURE( false, "Do not call this method" ); 580cdf0e10cSrcweir Reference< chart2::data::XLabeledDataSequence > xResult; 581cdf0e10cSrcweir // DO NOT USED -- DEPRECATED. Use SchXMLTools::GetNewLabeledDataSequence() instead 582cdf0e10cSrcweir return xResult; 583cdf0e10cSrcweir } 584cdf0e10cSrcweir 585cdf0e10cSrcweir // ======================================== 586cdf0e10cSrcweir 587cdf0e10cSrcweir // #110680# 588cdf0e10cSrcweir SchXMLImport::SchXMLImport( 589cdf0e10cSrcweir const Reference< lang::XMultiServiceFactory >& xServiceFactory, 590cdf0e10cSrcweir sal_uInt16 nImportFlags ) : 591cdf0e10cSrcweir SvXMLImport( xServiceFactory, nImportFlags ) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK ); 594cdf0e10cSrcweir GetNamespaceMap().Add( GetXMLToken(XML_NP_CHART_EXT), GetXMLToken(XML_N_CHART_EXT), XML_NAMESPACE_CHART_EXT); 595cdf0e10cSrcweir 596cdf0e10cSrcweir mbIsGraphicLoadOnDemandSupported = false; 597cdf0e10cSrcweir } 598cdf0e10cSrcweir 599cdf0e10cSrcweir // #110680# 600cdf0e10cSrcweir SchXMLImport::SchXMLImport( 601cdf0e10cSrcweir const Reference< lang::XMultiServiceFactory >& xServiceFactory, 602cdf0e10cSrcweir Reference< frame::XModel > xModel, 603cdf0e10cSrcweir Reference< document::XGraphicObjectResolver >& rGrfContainer, 604cdf0e10cSrcweir sal_Bool /*bLoadDoc*/, sal_Bool bShowProgress ) 605cdf0e10cSrcweir : SvXMLImport( xServiceFactory, xModel, rGrfContainer ) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK ); 608cdf0e10cSrcweir GetNamespaceMap().Add( GetXMLToken(XML_NP_CHART_EXT), GetXMLToken(XML_N_CHART_EXT), XML_NAMESPACE_CHART_EXT); 609cdf0e10cSrcweir 610cdf0e10cSrcweir // get status indicator (if requested) 611cdf0e10cSrcweir if( bShowProgress ) 612cdf0e10cSrcweir { 613cdf0e10cSrcweir Reference< frame::XController > xController( xModel->getCurrentController()); 614cdf0e10cSrcweir if( xController.is()) 615cdf0e10cSrcweir { 616cdf0e10cSrcweir Reference< frame::XFrame > xFrame( xController->getFrame()); 617cdf0e10cSrcweir if( xFrame.is()) 618cdf0e10cSrcweir { 619cdf0e10cSrcweir Reference< task::XStatusIndicatorSupplier > xFactory( xFrame, uno::UNO_QUERY ); 620cdf0e10cSrcweir if( xFactory.is()) 621cdf0e10cSrcweir { 622cdf0e10cSrcweir mxStatusIndicator = xFactory->getStatusIndicator(); 623cdf0e10cSrcweir } 624cdf0e10cSrcweir } 625cdf0e10cSrcweir } 626cdf0e10cSrcweir } 627cdf0e10cSrcweir 628cdf0e10cSrcweir // add progress view 629cdf0e10cSrcweir if( mxStatusIndicator.is()) 630cdf0e10cSrcweir { 631cdf0e10cSrcweir const OUString aText( RTL_CONSTASCII_USTRINGPARAM( "XML Import" )); 632cdf0e10cSrcweir mxStatusIndicator->start( aText, 100 ); // use percentage as values 633cdf0e10cSrcweir } 634cdf0e10cSrcweir } 635cdf0e10cSrcweir 636cdf0e10cSrcweir SchXMLImport::~SchXMLImport() throw () 637cdf0e10cSrcweir { 638cdf0e10cSrcweir // stop progress view 639cdf0e10cSrcweir if( mxStatusIndicator.is()) 640cdf0e10cSrcweir { 641cdf0e10cSrcweir mxStatusIndicator->end(); 642cdf0e10cSrcweir mxStatusIndicator->reset(); 643cdf0e10cSrcweir } 644cdf0e10cSrcweir 645cdf0e10cSrcweir uno::Reference< chart2::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY ); 646cdf0e10cSrcweir if( xChartDoc.is() && xChartDoc->hasControllersLocked() ) 647cdf0e10cSrcweir xChartDoc->unlockControllers(); 648cdf0e10cSrcweir } 649cdf0e10cSrcweir 650cdf0e10cSrcweir // create the main context (subcontexts are created 651cdf0e10cSrcweir // by the one created here) 652cdf0e10cSrcweir SvXMLImportContext *SchXMLImport::CreateContext( sal_uInt16 nPrefix, const OUString& rLocalName, 653cdf0e10cSrcweir const Reference< xml::sax::XAttributeList >& xAttrList ) 654cdf0e10cSrcweir { 655cdf0e10cSrcweir SvXMLImportContext* pContext = 0; 656cdf0e10cSrcweir 657cdf0e10cSrcweir // accept <office:document> 658cdf0e10cSrcweir if( XML_NAMESPACE_OFFICE == nPrefix && 659cdf0e10cSrcweir ( IsXMLToken( rLocalName, XML_DOCUMENT_STYLES) || 660cdf0e10cSrcweir IsXMLToken( rLocalName, XML_DOCUMENT_CONTENT) )) 661cdf0e10cSrcweir { 662cdf0e10cSrcweir pContext = new SchXMLDocContext( maImportHelper, *this, nPrefix, rLocalName ); 663cdf0e10cSrcweir } else if ( (XML_NAMESPACE_OFFICE == nPrefix) && 664cdf0e10cSrcweir ( IsXMLToken(rLocalName, XML_DOCUMENT) || 665cdf0e10cSrcweir (IsXMLToken(rLocalName, XML_DOCUMENT_META) 666cdf0e10cSrcweir && (getImportFlags() & IMPORT_META) )) ) 667cdf0e10cSrcweir { 668cdf0e10cSrcweir uno::Reference<document::XDocumentPropertiesSupplier> xDPS( 669cdf0e10cSrcweir GetModel(), uno::UNO_QUERY); 670cdf0e10cSrcweir // mst@: right now, this seems to be not supported, so it is untested 671cdf0e10cSrcweir if (xDPS.is()) { 672cdf0e10cSrcweir uno::Reference<xml::sax::XDocumentHandler> xDocBuilder( 673cdf0e10cSrcweir mxServiceFactory->createInstance( 674cdf0e10cSrcweir ::rtl::OUString::createFromAscii( 675cdf0e10cSrcweir "com.sun.star.xml.dom.SAXDocumentBuilder")), 676cdf0e10cSrcweir uno::UNO_QUERY_THROW); 677cdf0e10cSrcweir pContext = (IsXMLToken(rLocalName, XML_DOCUMENT_META)) 678cdf0e10cSrcweir ? new SvXMLMetaDocumentContext(*this, 679cdf0e10cSrcweir XML_NAMESPACE_OFFICE, rLocalName, 680cdf0e10cSrcweir xDPS->getDocumentProperties(), xDocBuilder) 681cdf0e10cSrcweir // flat OpenDocument file format 682cdf0e10cSrcweir : new SchXMLFlatDocContext_Impl( 683cdf0e10cSrcweir maImportHelper, *this, nPrefix, rLocalName, 684cdf0e10cSrcweir xDPS->getDocumentProperties(), xDocBuilder); 685cdf0e10cSrcweir } else { 686cdf0e10cSrcweir pContext = (IsXMLToken(rLocalName, XML_DOCUMENT_META)) 687cdf0e10cSrcweir ? SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList ) 688cdf0e10cSrcweir : new SchXMLDocContext( maImportHelper, *this, 689cdf0e10cSrcweir nPrefix, rLocalName ); 690cdf0e10cSrcweir } 691cdf0e10cSrcweir } else { 692cdf0e10cSrcweir pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList ); 693cdf0e10cSrcweir } 694cdf0e10cSrcweir 695cdf0e10cSrcweir return pContext; 696cdf0e10cSrcweir } 697cdf0e10cSrcweir 698cdf0e10cSrcweir SvXMLImportContext* SchXMLImport::CreateStylesContext( 699cdf0e10cSrcweir const OUString& rLocalName, 700cdf0e10cSrcweir const Reference<xml::sax::XAttributeList>& xAttrList ) 701cdf0e10cSrcweir { 702cdf0e10cSrcweir //#i103287# make sure that the version information is set before importing all the properties (especially stroke-opacity!) 703cdf0e10cSrcweir SchXMLTools::setBuildIDAtImportInfo( GetModel(), getImportInfo() ); 704cdf0e10cSrcweir 705cdf0e10cSrcweir SvXMLStylesContext* pStylesCtxt = 706cdf0e10cSrcweir new SvXMLStylesContext( *(this), XML_NAMESPACE_OFFICE, rLocalName, xAttrList ); 707cdf0e10cSrcweir 708cdf0e10cSrcweir // set context at base class, so that all auto-style classes are imported 709cdf0e10cSrcweir SetAutoStyles( pStylesCtxt ); 710cdf0e10cSrcweir maImportHelper.SetAutoStylesContext( pStylesCtxt ); 711cdf0e10cSrcweir 712cdf0e10cSrcweir return pStylesCtxt; 713cdf0e10cSrcweir } 714cdf0e10cSrcweir 715cdf0e10cSrcweir void SAL_CALL SchXMLImport::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc ) 716cdf0e10cSrcweir throw(lang::IllegalArgumentException, uno::RuntimeException) 717cdf0e10cSrcweir { 718cdf0e10cSrcweir uno::Reference< chart2::XChartDocument > xOldDoc( GetModel(), uno::UNO_QUERY ); 719cdf0e10cSrcweir if( xOldDoc.is() && xOldDoc->hasControllersLocked() ) 720cdf0e10cSrcweir xOldDoc->unlockControllers(); 721cdf0e10cSrcweir 722cdf0e10cSrcweir SvXMLImport::setTargetDocument( xDoc ); 723cdf0e10cSrcweir 724cdf0e10cSrcweir //set data provider and number formatter 725cdf0e10cSrcweir // try to get an XDataProvider and set it 726cdf0e10cSrcweir // @todo: if we have our own data, we must not use the parent as data provider 727cdf0e10cSrcweir uno::Reference< chart2::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY ); 728cdf0e10cSrcweir 729cdf0e10cSrcweir if( xChartDoc.is() ) 730cdf0e10cSrcweir try 731cdf0e10cSrcweir { 732cdf0e10cSrcweir //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 ) 733cdf0e10cSrcweir xChartDoc->lockControllers(); 734cdf0e10cSrcweir 735cdf0e10cSrcweir uno::Reference< container::XChild > xChild( xChartDoc, uno::UNO_QUERY ); 736cdf0e10cSrcweir uno::Reference< chart2::data::XDataReceiver > xDataReceiver( xChartDoc, uno::UNO_QUERY ); 737cdf0e10cSrcweir bool bHasOwnData = true; 738cdf0e10cSrcweir if( xChild.is() && xDataReceiver.is()) 739cdf0e10cSrcweir { 740cdf0e10cSrcweir Reference< lang::XMultiServiceFactory > xFact( xChild->getParent(), uno::UNO_QUERY ); 741cdf0e10cSrcweir if( xFact.is() ) 742cdf0e10cSrcweir { 743cdf0e10cSrcweir //if the parent has a number formatter we will use the numberformatter of the parent 744cdf0e10cSrcweir Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xFact, uno::UNO_QUERY ); 745cdf0e10cSrcweir xDataReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier ); 746cdf0e10cSrcweir 747cdf0e10cSrcweir if ( !xChartDoc->getDataProvider().is() ) 748cdf0e10cSrcweir { 749cdf0e10cSrcweir const OUString aDataProviderServiceName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DataProvider")); 750cdf0e10cSrcweir const uno::Sequence< OUString > aServiceNames( xFact->getAvailableServiceNames()); 751cdf0e10cSrcweir const OUString * pBegin = aServiceNames.getConstArray(); 752cdf0e10cSrcweir const OUString * pEnd = pBegin + aServiceNames.getLength(); 753cdf0e10cSrcweir if( ::std::find( pBegin, pEnd, aDataProviderServiceName ) != pEnd ) 754cdf0e10cSrcweir { 755cdf0e10cSrcweir Reference< chart2::data::XDataProvider > xProvider( 756cdf0e10cSrcweir xFact->createInstance( aDataProviderServiceName ), uno::UNO_QUERY ); 757cdf0e10cSrcweir if( xProvider.is()) 758cdf0e10cSrcweir { 759cdf0e10cSrcweir xDataReceiver->attachDataProvider( xProvider ); 760cdf0e10cSrcweir bHasOwnData = false; 761cdf0e10cSrcweir } 762cdf0e10cSrcweir } 763cdf0e10cSrcweir } 764cdf0e10cSrcweir else 765cdf0e10cSrcweir bHasOwnData = false; 766cdf0e10cSrcweir } 767cdf0e10cSrcweir // else we have no parent => we have our own data 768cdf0e10cSrcweir 769cdf0e10cSrcweir if( bHasOwnData && ! xChartDoc->hasInternalDataProvider() ) 770cdf0e10cSrcweir xChartDoc->createInternalDataProvider( sal_False ); 771cdf0e10cSrcweir } 772cdf0e10cSrcweir } 773cdf0e10cSrcweir catch( uno::Exception & rEx ) 774cdf0e10cSrcweir { 775cdf0e10cSrcweir #ifdef DBG_UTIL 776cdf0e10cSrcweir String aStr( rEx.Message ); 777cdf0e10cSrcweir ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US ); 778cdf0e10cSrcweir DBG_ERROR1( "SchXMLChartContext::StartElement(): Exception caught: %s", aBStr.GetBuffer()); 779cdf0e10cSrcweir #else 780cdf0e10cSrcweir (void)rEx; // avoid warning for pro build 781cdf0e10cSrcweir #endif 782cdf0e10cSrcweir } 783cdf0e10cSrcweir } 784cdf0e10cSrcweir 785cdf0e10cSrcweir // export components ======================================== 786cdf0e10cSrcweir 787cdf0e10cSrcweir // first version: everything comes from one storage 788cdf0e10cSrcweir 789cdf0e10cSrcweir Sequence< OUString > SAL_CALL SchXMLImport_getSupportedServiceNames() throw() 790cdf0e10cSrcweir { 791cdf0e10cSrcweir const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLOasisImporter" ) ); 792cdf0e10cSrcweir const Sequence< OUString > aSeq( &aServiceName, 1 ); 793cdf0e10cSrcweir return aSeq; 794cdf0e10cSrcweir } 795cdf0e10cSrcweir 796cdf0e10cSrcweir OUString SAL_CALL SchXMLImport_getImplementationName() throw() 797cdf0e10cSrcweir { 798cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLImport" ) ); 799cdf0e10cSrcweir } 800cdf0e10cSrcweir 801cdf0e10cSrcweir Reference< uno::XInterface > SAL_CALL SchXMLImport_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception ) 802cdf0e10cSrcweir { 803cdf0e10cSrcweir // #110680# 804cdf0e10cSrcweir // return (cppu::OWeakObject*)new SchXMLImport(); 805cdf0e10cSrcweir return (cppu::OWeakObject*)new SchXMLImport(rSMgr); 806cdf0e10cSrcweir } 807cdf0e10cSrcweir 808cdf0e10cSrcweir // ============================================================ 809cdf0e10cSrcweir 810cdf0e10cSrcweir // multiple storage version: one for content / styles / meta 811cdf0e10cSrcweir 812cdf0e10cSrcweir Sequence< OUString > SAL_CALL SchXMLImport_Styles_getSupportedServiceNames() throw() 813cdf0e10cSrcweir { 814cdf0e10cSrcweir const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLOasisStylesImporter" ) ); 815cdf0e10cSrcweir const Sequence< OUString > aSeq( &aServiceName, 1 ); 816cdf0e10cSrcweir return aSeq; 817cdf0e10cSrcweir } 818cdf0e10cSrcweir 819cdf0e10cSrcweir OUString SAL_CALL SchXMLImport_Styles_getImplementationName() throw() 820cdf0e10cSrcweir { 821cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLImport.Styles" ) ); 822cdf0e10cSrcweir } 823cdf0e10cSrcweir 824cdf0e10cSrcweir Reference< uno::XInterface > SAL_CALL SchXMLImport_Styles_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception ) 825cdf0e10cSrcweir { 826cdf0e10cSrcweir // #110680# 827cdf0e10cSrcweir // return (cppu::OWeakObject*)new SchXMLImport( IMPORT_STYLES ); 828cdf0e10cSrcweir return (cppu::OWeakObject*)new SchXMLImport( rSMgr, IMPORT_STYLES ); 829cdf0e10cSrcweir } 830cdf0e10cSrcweir 831cdf0e10cSrcweir // ------------------------------------------------------------ 832cdf0e10cSrcweir 833cdf0e10cSrcweir Sequence< OUString > SAL_CALL SchXMLImport_Content_getSupportedServiceNames() throw() 834cdf0e10cSrcweir { 835cdf0e10cSrcweir const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLOasisContentImporter" ) ); 836cdf0e10cSrcweir const Sequence< OUString > aSeq( &aServiceName, 1 ); 837cdf0e10cSrcweir return aSeq; 838cdf0e10cSrcweir } 839cdf0e10cSrcweir 840cdf0e10cSrcweir OUString SAL_CALL SchXMLImport_Content_getImplementationName() throw() 841cdf0e10cSrcweir { 842cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLImport.Content" ) ); 843cdf0e10cSrcweir } 844cdf0e10cSrcweir 845cdf0e10cSrcweir Reference< uno::XInterface > SAL_CALL SchXMLImport_Content_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception ) 846cdf0e10cSrcweir { 847cdf0e10cSrcweir // #110680# 848cdf0e10cSrcweir // return (cppu::OWeakObject*)new SchXMLImport( IMPORT_CONTENT | IMPORT_AUTOSTYLES | IMPORT_FONTDECLS ); 849cdf0e10cSrcweir return (cppu::OWeakObject*)new SchXMLImport( rSMgr, IMPORT_CONTENT | IMPORT_AUTOSTYLES | IMPORT_FONTDECLS ); 850cdf0e10cSrcweir } 851cdf0e10cSrcweir 852cdf0e10cSrcweir // ------------------------------------------------------------ 853cdf0e10cSrcweir 854cdf0e10cSrcweir Sequence< OUString > SAL_CALL SchXMLImport_Meta_getSupportedServiceNames() throw() 855cdf0e10cSrcweir { 856cdf0e10cSrcweir const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLOasisMetaImporter" ) ); 857cdf0e10cSrcweir const Sequence< OUString > aSeq( &aServiceName, 1 ); 858cdf0e10cSrcweir return aSeq; 859cdf0e10cSrcweir } 860cdf0e10cSrcweir 861cdf0e10cSrcweir OUString SAL_CALL SchXMLImport_Meta_getImplementationName() throw() 862cdf0e10cSrcweir { 863cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLImport.Meta" ) ); 864cdf0e10cSrcweir } 865cdf0e10cSrcweir 866cdf0e10cSrcweir Reference< uno::XInterface > SAL_CALL SchXMLImport_Meta_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception ) 867cdf0e10cSrcweir { 868cdf0e10cSrcweir // #110680# 869cdf0e10cSrcweir // return (cppu::OWeakObject*)new SchXMLImport( IMPORT_META ); 870cdf0e10cSrcweir return (cppu::OWeakObject*)new SchXMLImport( rSMgr, IMPORT_META ); 871cdf0e10cSrcweir } 872cdf0e10cSrcweir 873cdf0e10cSrcweir // XServiceInfo 874cdf0e10cSrcweir OUString SAL_CALL SchXMLImport::getImplementationName() throw( uno::RuntimeException ) 875cdf0e10cSrcweir { 876cdf0e10cSrcweir switch( getImportFlags()) 877cdf0e10cSrcweir { 878cdf0e10cSrcweir case IMPORT_ALL: 879cdf0e10cSrcweir return SchXMLImport_getImplementationName(); 880cdf0e10cSrcweir case IMPORT_STYLES: 881cdf0e10cSrcweir return SchXMLImport_Styles_getImplementationName(); 882cdf0e10cSrcweir case ( IMPORT_CONTENT | IMPORT_AUTOSTYLES | IMPORT_FONTDECLS ): 883cdf0e10cSrcweir return SchXMLImport_Content_getImplementationName(); 884cdf0e10cSrcweir case IMPORT_META: 885cdf0e10cSrcweir return SchXMLImport_Meta_getImplementationName(); 886cdf0e10cSrcweir 887cdf0e10cSrcweir case IMPORT_SETTINGS: 888cdf0e10cSrcweir // there is no settings component in chart 889cdf0e10cSrcweir default: 890cdf0e10cSrcweir return OUString::createFromAscii( "SchXMLImport" ); 891cdf0e10cSrcweir } 892cdf0e10cSrcweir } 893