From 8570f88531e1b206f3fa63e10b308df9c57bb9c9 Mon Sep 17 00:00:00 2001 From: Kurt Zenker Date: Mon, 14 Sep 2009 10:57:16 +0000 Subject: CWS-TOOLING: integrate CWS chart41 2009-09-07 11:17:59 +0200 iha r275880 : #i104854# ODF: Fallback to bar chart for surface charts as long as surface charts are not implemented 2009-09-03 10:07:24 +0200 iha r275745 : #i104020# Y axis scaling problem with stock chart 2009-09-02 17:11:42 +0200 iha r275723 : #i103984# XChartDataArray / setDataArray broken 2009-09-02 17:05:16 +0200 iha r275721 : #i103984# XChartDataArray / setDataArray broken 2009-08-31 18:18:21 +0200 iha r275629 : #i103076# ODF, chart from MS-Office2007sp2 doesn't load caused be different xlink:href syntax 2009-08-28 18:35:52 +0200 iha r275548 : #i103460# ODF charts without svg:width and svg:height are not imported correctly 2009-08-28 18:35:25 +0200 iha r275547 : #i103460# ODF charts without svg:width and svg:height are not imported correctly 2009-08-28 18:25:45 +0200 iha r275546 : #i103460# ODF charts without svg:width and svg:height are not imported correctly 2009-08-28 18:23:21 +0200 iha r275544 : #i103460# ODF charts without svg:width and svg:height are not imported correctly 2009-08-28 18:18:34 +0200 iha r275543 : #i103460# ODF charts without svg:width and svg:height are not imported correctly 2009-08-27 15:57:20 +0200 iha r275490 : #i104160# report designer broken --- embeddedobj/source/commonembedding/embedobj.cxx | 6 +++++ embeddedobj/source/commonembedding/miscobj.cxx | 10 ++++++-- embeddedobj/source/commonembedding/persistence.cxx | 10 ++++++++ embeddedobj/source/inc/commonembobj.hxx | 7 ++++++ svx/source/svdraw/svdoole2.cxx | 8 +++++++ svx/source/xml/xmleohlp.cxx | 28 ++++++++++++++++++---- xmloff/inc/xmloff/xmltoken.hxx | 1 + xmloff/source/chart/SchXMLChartContext.cxx | 25 +++++++++---------- xmloff/source/chart/SchXMLChartContext.hxx | 7 ++---- xmloff/source/chart/SchXMLExport.cxx | 7 ++++++ xmloff/source/chart/SchXMLTools.cxx | 9 +++++++ xmloff/source/core/xmltoken.cxx | 1 + 12 files changed, 95 insertions(+), 24 deletions(-) diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx index 668c4a53508f..85f9b8b0b2c9 100644 --- a/embeddedobj/source/commonembedding/embedobj.cxx +++ b/embeddedobj/source/commonembedding/embedobj.cxx @@ -696,3 +696,9 @@ void SAL_CALL OCommonEmbeddedObject::setParent( const com::sun::star::uno::Refer } } +// XDefaultSizeTransmitter +void SAL_CALL OCommonEmbeddedObject::setDefaultSize( const ::com::sun::star::awt::Size& rSize_100TH_MM ) throw (::com::sun::star::uno::RuntimeException) +{ + //#i103460# charts do not necessaryly have an own size within ODF files, in this case they need to use the size settings from the surrounding frame, which is made available with this method + m_aDefaultSizeForChart_In_100TH_MM = rSize_100TH_MM; +} diff --git a/embeddedobj/source/commonembedding/miscobj.cxx b/embeddedobj/source/commonembedding/miscobj.cxx index 58a5e87fe418..e557437e336d 100644 --- a/embeddedobj/source/commonembedding/miscobj.cxx +++ b/embeddedobj/source/commonembedding/miscobj.cxx @@ -361,9 +361,14 @@ uno::Any SAL_CALL OCommonEmbeddedObject::queryInterface( const uno::Type& rType { uno::Any aReturn; - aReturn <<= ::cppu::queryInterface( + if ( rType == ::getCppuType( (uno::Reference< embed::XEmbeddedObject > const *)0 )) + { + void * p = static_cast< embed::XEmbeddedObject * >( this ); + return uno::Any( &p, rType ); + } + else + aReturn <<= ::cppu::queryInterface( rType, - static_cast< embed::XEmbeddedObject* >( this ), static_cast< embed::XInplaceObject* >( this ), static_cast< embed::XVisualObject* >( this ), static_cast< embed::XCommonEmbedPersist* >( static_cast< embed::XEmbedPersist* >( this ) ), @@ -374,6 +379,7 @@ uno::Any SAL_CALL OCommonEmbeddedObject::queryInterface( const uno::Type& rType static_cast< embed::XComponentSupplier* >( this ), static_cast< util::XCloseable* >( this ), static_cast< container::XChild* >( this ), + static_cast< chart2::XDefaultSizeTransmitter* >( this ), static_cast< document::XEventBroadcaster* >( this ) ); if ( aReturn.hasValue() ) diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx index 8d33935168b6..47b16bf961af 100644 --- a/embeddedobj/source/commonembedding/persistence.cxx +++ b/embeddedobj/source/commonembedding/persistence.cxx @@ -58,6 +58,7 @@ #include #include #include +#include #include #include @@ -463,6 +464,15 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadDocumentFromStorag uno::Reference< util::XCloseable > xDocument( CreateDocument( m_xFactory, GetDocumentServiceName(), m_bEmbeddedScriptSupport ) ); + //#i103460# ODF: take the size given from the parent frame as default + uno::Reference< chart2::XChartDocument > xChart( xDocument, uno::UNO_QUERY ); + if( xChart.is() ) + { + uno::Reference< embed::XVisualObject > xChartVisualObject( xChart, uno::UNO_QUERY ); + if( xChartVisualObject.is() ) + xChartVisualObject->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, m_aDefaultSizeForChart_In_100TH_MM ); + } + uno::Reference< frame::XLoadable > xLoadable( xDocument, uno::UNO_QUERY ); uno::Reference< document::XStorageBasedDocument > xDoc #ifdef USE_STORAGEBASED_DOCUMENT diff --git a/embeddedobj/source/inc/commonembobj.hxx b/embeddedobj/source/inc/commonembobj.hxx index afd199af9207..5a2827de3aa6 100644 --- a/embeddedobj/source/inc/commonembobj.hxx +++ b/embeddedobj/source/inc/commonembobj.hxx @@ -47,6 +47,7 @@ #include #include #include +#include #include namespace com { namespace sun { namespace star { @@ -85,6 +86,7 @@ class OCommonEmbeddedObject : public ::com::sun::star::embed::XEmbeddedObject , public ::com::sun::star::embed::XLinkageSupport , public ::com::sun::star::embed::XInplaceObject , public ::com::sun::star::container::XChild + , public ::com::sun::star::chart2::XDefaultSizeTransmitter , public ::cppu::OWeakObject { protected: @@ -159,6 +161,7 @@ protected: sal_Bool m_bHasClonedSize; // the object has cached size ::com::sun::star::awt::Size m_aClonedSize; sal_Int32 m_nClonedMapUnit; + ::com::sun::star::awt::Size m_aDefaultSizeForChart_In_100TH_MM;//#i103460# charts do not necessaryly have an own size within ODF files, in this case they need to use the size settings from the surrounding frame, which is made available with this member private: void CommonInit_Impl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& aObjectProps ); @@ -492,6 +495,10 @@ public: // XChild virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + + // XDefaultSizeTransmitter + //#i103460# charts do not necessaryly have an own size within ODF files, in this case they need to use the size settings from the surrounding frame, which is made available with this method + virtual void SAL_CALL setDefaultSize( const ::com::sun::star::awt::Size& rSize_100TH_MM ) throw (::com::sun::star::uno::RuntimeException); }; #endif diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index 8c30bfb88018..a2b6991773e1 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -1867,6 +1867,14 @@ void SdrOle2Obj::NbcSetSnapRect(const Rectangle& rRect) SdrRectObj::NbcSetSnapRect(rRect); if( pModel && !pModel->isLocked() ) ImpSetVisAreaSize(); + + if ( xObjRef.is() && IsChart() ) + { + //#i103460# charts do not necessaryly have an own size within ODF files, + //for this case they need to use the size settings from the surrounding frame, + //which is made available with this method as there is no other way + xObjRef.SetDefaultSizeForChart( Size( rRect.GetWidth(), rRect.GetHeight() ) ); + } } // ----------------------------------------------------------------------------- diff --git a/svx/source/xml/xmleohlp.cxx b/svx/source/xml/xmleohlp.cxx index e6f7221623fd..ab9eb5aeb36d 100644 --- a/svx/source/xml/xmleohlp.cxx +++ b/svx/source/xml/xmleohlp.cxx @@ -326,11 +326,29 @@ sal_Bool SvXMLEmbeddedObjectHelper::ImplGetStorageNames( } else { - sal_Int32 nPathStart = 0; - if( 0 == aURLNoPar.compareToAscii( "./", 2 ) ) - nPathStart = 2; - if( _nPos >= nPathStart ) - rContainerStorageName = aURLNoPar.copy( nPathStart, _nPos-nPathStart); + //eliminate 'superfluous' slashes at start and end + //#i103076# load objects with all allowed xlink:href syntaxes + { + //eliminate './' at start + sal_Int32 nStart = 0; + sal_Int32 nCount = aURLNoPar.getLength(); + if( 0 == aURLNoPar.compareToAscii( "./", 2 ) ) + { + nStart = 2; + nCount -= 2; + } + + //eliminate '/' at end + sal_Int32 nEnd = aURLNoPar.lastIndexOf( '/' ); + if( nEnd == aURLNoPar.getLength()-1 && nEnd != (nStart-1) ) + nCount--; + + aURLNoPar = aURLNoPar.copy( nStart, nCount ); + } + + _nPos = aURLNoPar.lastIndexOf( '/' ); + if( _nPos >= 0 ) + rContainerStorageName = aURLNoPar.copy( 0, _nPos ); rObjectStorageName = aURLNoPar.copy( _nPos+1 ); } } diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx index 66abd40a44f4..978f6e698cc8 100644 --- a/xmloff/inc/xmloff/xmltoken.hxx +++ b/xmloff/inc/xmloff/xmltoken.hxx @@ -3075,6 +3075,7 @@ namespace xmloff { namespace token { XML_AT_AXIS, XML_AT_LABELS_AND_AXIS, XML_FILLED_RADAR, + XML_SURFACE, // MathML only XML_MATHVARIANT, diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index d103876b9350..1f854469b4be 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -318,7 +318,12 @@ void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttribut // parse attributes sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetChartAttrTokenMap(); - awt::Size aChartSize; + + uno::Reference< embed::XVisualObject > xVisualObject( mrImportHelper.GetChartDocument(), uno::UNO_QUERY); + DBG_ASSERT(xVisualObject.is(),"need xVisualObject for page size"); + if( xVisualObject.is() ) + maChartSize = xVisualObject->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT ); //#i103460# take the size given from the parent frame as default + // this flag is necessarry for pie charts in the core sal_Bool bSetSwitchData = sal_False; @@ -377,11 +382,11 @@ void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttribut break; case XML_TOK_CHART_WIDTH: - GetImport().GetMM100UnitConverter().convertMeasure( aChartSize.Width, aValue ); + GetImport().GetMM100UnitConverter().convertMeasure( maChartSize.Width, aValue ); break; case XML_TOK_CHART_HEIGHT: - GetImport().GetMM100UnitConverter().convertMeasure( aChartSize.Height, aValue ); + GetImport().GetMM100UnitConverter().convertMeasure( maChartSize.Height, aValue ); break; case XML_TOK_CHART_STYLE_NAME: @@ -406,7 +411,11 @@ void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttribut maChartTypeServiceName = SchXMLTools::GetChartTypeByClassName( aChartClass_Bar, false /* bUseOldNames */ ); } - InitChart (aChartSize, aOldChartTypeName, bSetSwitchData); + // Set the size of the draw page. + if( xVisualObject.is() ) + xVisualObject->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, maChartSize ); + + InitChart( aOldChartTypeName, bSetSwitchData); if( bHasAddin ) { @@ -1198,11 +1207,9 @@ SvXMLImportContext* SchXMLChartContext::CreateChildContext( 4. Set the chart type. */ void SchXMLChartContext::InitChart( - awt::Size aChartSize, const OUString & rChartTypeServiceName, // currently the old service name sal_Bool /* bSetSwitchData */ ) { - maChartSize = aChartSize; uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument(); DBG_ASSERT( xDoc.is(), "No valid document!" ); uno::Reference< frame::XModel > xModel (xDoc, uno::UNO_QUERY ); @@ -1217,12 +1224,6 @@ void SchXMLChartContext::InitChart( xTitled->setTitleObject( 0 ); } - // Set the size of the draw page. - uno::Reference< embed::XVisualObject > xVisualObject(xModel,uno::UNO_QUERY); - DBG_ASSERT(xVisualObject.is(),"need xVisualObject for page size"); - if( xVisualObject.is() ) - xVisualObject->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, aChartSize ); - // Set the chart type via setting the diagram. if( rChartTypeServiceName.getLength() && xDoc.is()) diff --git a/xmloff/source/chart/SchXMLChartContext.hxx b/xmloff/source/chart/SchXMLChartContext.hxx index c02f623ebe10..e14f09f965ca 100644 --- a/xmloff/source/chart/SchXMLChartContext.hxx +++ b/xmloff/source/chart/SchXMLChartContext.hxx @@ -138,15 +138,12 @@ private: ::com::sun::star::awt::Size maChartSize; /** @descr This method bundles some settings to the chart model and executes them with - a locked controller. This includes setting the draw page size and setting - the chart type. - @param aChartSize The size the draw page will be set to. + a locked controller. This includes setting the chart type. @param aServiceName The name of the service the diagram is initialized with. @param bSetWitchData Indicates wether the data set takes it's data series from rows or from columns. */ - void InitChart (com::sun::star::awt::Size aChartSize, - const ::rtl::OUString & rChartTypeServiceName, + void InitChart (const ::rtl::OUString & rChartTypeServiceName, sal_Bool bSetSwitchData); void MergeSeriesForStockChart(); diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 3290cb31db96..f7cf82abe974 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -93,6 +93,7 @@ #include #include #include +#include #include #include #include @@ -1123,6 +1124,12 @@ void SchXMLExportHelper::parseDocument( Reference< chart::XChartDocument >& rCha OUString aDataProviderURL( RTL_CONSTASCII_USTRINGPARAM( ".." ) ); if( xNewDoc->hasInternalDataProvider() ) aDataProviderURL = OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) ); + else //special handling for data base data provider necessary + { + Reference< chart2::data::XDatabaseDataProvider > xDBDataProvider( xNewDoc->getDataProvider(), uno::UNO_QUERY ); + if( xDBDataProvider.is() ) + aDataProviderURL = OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) ); + } mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aDataProviderURL ); } diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx index a1700c65d316..ebc48c0d24c0 100644 --- a/xmloff/source/chart/SchXMLTools.cxx +++ b/xmloff/source/chart/SchXMLTools.cxx @@ -173,6 +173,7 @@ static __FAR_DATA SvXMLEnumMapEntry aXMLChartClassMap[] = { XML_BAR, XML_CHART_CLASS_BAR }, { XML_STOCK, XML_CHART_CLASS_STOCK }, { XML_BUBBLE, XML_CHART_CLASS_BUBBLE }, + { XML_SURFACE, XML_CHART_CLASS_BAR }, //@todo change this if a surface chart is available { XML_ADD_IN, XML_CHART_CLASS_ADDIN }, { XML_TOKEN_INVALID, XML_CHART_CLASS_UNKNOWN } }; @@ -293,6 +294,14 @@ OUString GetChartTypeByClassName( else aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("CandleStick")); } + else if( IsXMLToken( rClassName, XML_SURFACE )) + { + //@todo change this if a surface chart is available + if( bUseOldNames ) + aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Bar")); + else + aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Column")); + } else bInternalType = false; diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 35b0cc1ec741..d4f60e053b3c 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3077,6 +3077,7 @@ namespace xmloff { namespace token { TOKEN( "at-axis", XML_AT_AXIS ), TOKEN( "at-labels-and-axis", XML_AT_LABELS_AND_AXIS ), TOKEN( "filled-radar", XML_FILLED_RADAR ), + TOKEN( "surface", XML_SURFACE ), TOKEN( "mathvariant", XML_MATHVARIANT ), TOKEN( "mathsize", XML_MATHSIZE ), -- cgit