diff options
author | Caolán McNamara <cmc@openoffice.org> | 2010-04-08 10:38:20 +0100 |
---|---|---|
committer | Caolán McNamara <cmc@openoffice.org> | 2010-04-08 10:38:20 +0100 |
commit | 20482125e8067d51b5205374b650b62e84eeb791 (patch) | |
tree | 4a3f718edd098ced50259f3f4dc2afcf108e7ce9 | |
parent | d9cc9a33542bee1e661f4b8edbc1a56175a01120 (diff) | |
parent | 6b9635f6b2d62537052bdc11ec84247d3bc72832 (diff) |
sdfindall: merge with DEV300 m75
30 files changed, 675 insertions, 602 deletions
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index ba54fabd3a3c..1e278bf583a7 100644..100755 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -103,6 +103,7 @@ TYPEINIT1(SbUnoObject,SbxObject) TYPEINIT1(SbUnoClass,SbxObject) TYPEINIT1(SbUnoService,SbxObject) TYPEINIT1(SbUnoServiceCtor,SbxMethod) +TYPEINIT1(SbUnoSingleton,SbxObject) typedef WeakImplHelper1< XAllListener > BasicAllListenerHelper; @@ -3299,6 +3300,18 @@ SbxVariable* SbUnoClass::Find( const XubString& rName, SbxClassType t ) pRes->PutObject( xWrapper ); } } + + // An UNO singleton? + if( !pRes ) + { + SbUnoSingleton* pUnoSingleton = findUnoSingleton( aNewName ); + if( pUnoSingleton ) + { + pRes = new SbxVariable( SbxVARIANT ); + SbxObjectRef xWrapper = (SbxObject*)pUnoSingleton; + pRes->PutObject( xWrapper ); + } + } } } @@ -3579,6 +3592,90 @@ SbxInfo* SbUnoServiceCtor::GetInfo() } +SbUnoSingleton* findUnoSingleton( const String& rName ) +{ + SbUnoSingleton* pSbUnoSingleton = NULL; + + Reference< XHierarchicalNameAccess > xTypeAccess = getTypeProvider_Impl(); + if( xTypeAccess->hasByHierarchicalName( rName ) ) + { + Any aRet = xTypeAccess->getByHierarchicalName( rName ); + Reference< XTypeDescription > xTypeDesc; + aRet >>= xTypeDesc; + + if( xTypeDesc.is() ) + { + TypeClass eTypeClass = xTypeDesc->getTypeClass(); + if( eTypeClass == TypeClass_SINGLETON ) + { + Reference< XSingletonTypeDescription > xSingletonTypeDesc( xTypeDesc, UNO_QUERY ); + if( xSingletonTypeDesc.is() ) + pSbUnoSingleton = new SbUnoSingleton( rName, xSingletonTypeDesc ); + } + } + } + return pSbUnoSingleton; +} + +SbUnoSingleton::SbUnoSingleton( const String& aName_, + const Reference< XSingletonTypeDescription >& xSingletonTypeDesc ) + : SbxObject( aName_ ) + , m_xSingletonTypeDesc( xSingletonTypeDesc ) +{ + SbxVariableRef xGetMethodRef = + new SbxMethod( String( RTL_CONSTASCII_USTRINGPARAM( "get" ) ), SbxOBJECT ); + QuickInsert( (SbxVariable*)xGetMethodRef ); +} + +void SbUnoSingleton::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ) +{ + const SbxHint* pHint = PTR_CAST(SbxHint,&rHint); + if( pHint ) + { + SbxVariable* pVar = pHint->GetVar(); + SbxArray* pParams = pVar->GetParameters(); + UINT32 nParamCount = pParams ? ((UINT32)pParams->Count() - 1) : 0; + UINT32 nAllowedParamCount = 1; + + Reference < XComponentContext > xContextToUse; + if( nParamCount > 0 ) + { + // Check if first parameter is a context and use it then + Reference < XComponentContext > xFirstParamContext; + Any aArg1 = sbxToUnoValue( pParams->Get( 1 ) ); + if( (aArg1 >>= xFirstParamContext) && xFirstParamContext.is() ) + xContextToUse = xFirstParamContext; + } + + if( !xContextToUse.is() ) + { + Reference < XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW ); + xContextToUse.set( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" )) ), UNO_QUERY_THROW ); + --nAllowedParamCount; + } + + if( nParamCount > nAllowedParamCount ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + return; + } + + Any aRetAny; + if( xContextToUse.is() ) + { + String aSingletonName( RTL_CONSTASCII_USTRINGPARAM("/singletons/") ); + aSingletonName += GetName(); + Reference < XInterface > xRet; + xContextToUse->getValueByName( aSingletonName ) >>= xRet; + aRetAny <<= xRet; + } + unoToSbxValue( pVar, aRetAny ); + } + else + SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType ); +} + //======================================================================== //======================================================================== diff --git a/basic/source/inc/sbunoobj.hxx b/basic/source/inc/sbunoobj.hxx index d96edd1bc298..2d9836e3530e 100644 --- a/basic/source/inc/sbunoobj.hxx +++ b/basic/source/inc/sbunoobj.hxx @@ -41,6 +41,7 @@ #include <com/sun/star/script/XInvocation.hpp> #include <com/sun/star/reflection/XIdlClass.hpp> #include <com/sun/star/reflection/XServiceTypeDescription2.hpp> +#include <com/sun/star/reflection/XSingletonTypeDescription.hpp> #include <rtl/ustring.hxx> class SbUnoObject: public SbxObject @@ -226,6 +227,23 @@ public: }; +// Wrapper for UNO Singleton +class SbUnoSingleton : public SbxObject +{ + const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XSingletonTypeDescription > m_xSingletonTypeDesc; + +public: + TYPEINFO(); + SbUnoSingleton( const String& aName_, + const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XSingletonTypeDescription >& xSingletonTypeDesc ); + + void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& ); +}; +SV_DECL_IMPL_REF(SbUnoSingleton); + +SbUnoSingleton* findUnoSingleton( const String& rName ); + + // #105565 Special Object to wrap a strongly typed Uno Any class SbUnoAnyObject: public SbxObject { diff --git a/configmgr/source/xcdparser.cxx b/configmgr/source/xcdparser.cxx index 2f860f805487..8306c692c30f 100644 --- a/configmgr/source/xcdparser.cxx +++ b/configmgr/source/xcdparser.cxx @@ -28,7 +28,7 @@ #include "precompiled_configmgr.hxx" #include "sal/config.h" -#include <cstddef> +#include <climits> #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/RuntimeException.hpp" diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index b0711f919a7b..a3c20411d1fc 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -1259,21 +1259,13 @@ sal_uInt16 SfxObjectShell::ImplCheckSignaturesInformation( const uno::Sequence< bool bCompleteSignature = true; if( nInfos ) { - //These errors of certificates are allowed - sal_Int32 nNonErrors = security::CertificateValidity::VALID | - security::CertificateValidity::UNKNOWN_REVOKATION; - //Build a mask to filter out the allowed errors - sal_Int32 nMask = ~nNonErrors; - nResult = SIGNATURESTATE_SIGNATURES_OK; for ( int n = 0; n < nInfos; n++ ) { if ( bCertValid ) { sal_Int32 nCertStat = aInfos[n].CertificateStatus; - // "subtract" the allowed error flags from the result - sal_Int32 nErrors = ( nCertStat & nMask ); - bCertValid = nErrors > 0 ? sal_False : sal_True; + bCertValid = nCertStat == security::CertificateValidity::VALID ? sal_True : sal_False; } if ( !aInfos[n].SignatureIsValid ) diff --git a/sysui/desktop/freedesktop/freedesktop-menus.spec b/sysui/desktop/freedesktop/freedesktop-menus.spec index 14a7c7795b24..501f8432d940 100644 --- a/sysui/desktop/freedesktop/freedesktop-menus.spec +++ b/sysui/desktop/freedesktop/freedesktop-menus.spec @@ -325,6 +325,7 @@ done /usr/share/applications/%unixfilename-printeradmin.desktop /usr/share/applications/%unixfilename-writer.desktop /usr/share/applications/%unixfilename-startcenter.desktop +/usr/share/applications/%unixfilename-javafilter.desktop /usr/share/icons/gnome/*/apps/*png /usr/share/icons/gnome/*/mimetypes/*png /usr/share/icons/hicolor/*/apps/*png diff --git a/sysui/desktop/menus/javafilter.desktop b/sysui/desktop/menus/javafilter.desktop new file mode 100644 index 000000000000..9d230f954a7b --- /dev/null +++ b/sysui/desktop/menus/javafilter.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Version=1.0 +Terminal=false +Type=Application +Exec=openoffice -writer %U +MimeType=application/x-aportisdoc;application/x-pocket-word;application/x-pocket-excel; +Name=%PRODUCTNAME Small Device Format Importer +GenericName=Small Device Format Importer +NoDisplay=true diff --git a/sysui/desktop/redhat/redhat-menus.spec b/sysui/desktop/redhat/redhat-menus.spec index 4ad74ad1b31f..e153b55c3fd4 100644 --- a/sysui/desktop/redhat/redhat-menus.spec +++ b/sysui/desktop/redhat/redhat-menus.spec @@ -279,6 +279,7 @@ done /usr/share/applications/%unixfilename-base.desktop /usr/share/applications/%unixfilename-printeradmin.desktop /usr/share/applications/%unixfilename-startcenter.desktop +/usr/share/applications/%unixfilename-javafilter.desktop /usr/share/applnk-redhat/Office/%unixfilename-writer.desktop /usr/share/applnk-redhat/Office/%unixfilename-calc.desktop /usr/share/applnk-redhat/Office/%unixfilename-draw.desktop @@ -287,6 +288,7 @@ done /usr/share/applnk-redhat/Office/%unixfilename-base.desktop /usr/share/applnk-redhat/Office/%unixfilename-printeradmin.desktop /usr/share/applnk-redhat/Office/%unixfilename-startcenter.desktop +/usr/share/applnk-redhat/Office/%unixfilename-javafilter.desktop /usr/share/mime-info/*.keys /usr/share/mime-info/*.mime /usr/share/mimelnk/application/*.desktop diff --git a/sysui/desktop/share/launcher_genericname.ulf b/sysui/desktop/share/launcher_genericname.ulf index ea11da04e03f..ff8041a155fc 100644 --- a/sysui/desktop/share/launcher_genericname.ulf +++ b/sysui/desktop/share/launcher_genericname.ulf @@ -18,3 +18,6 @@ en-US = "Drawing Program" [startcenter] en-US = "Office" + +[javafilter] +en-US = "Small Device Format Importer" diff --git a/sysui/desktop/share/makefile.mk b/sysui/desktop/share/makefile.mk index 9668272a5615..e1e47648b077 100644 --- a/sysui/desktop/share/makefile.mk +++ b/sysui/desktop/share/makefile.mk @@ -52,7 +52,7 @@ ULFFILES= \ launcher_genericname.ulf \ launcher_name.ulf -LAUNCHERLIST = writer calc draw impress math base printeradmin qstart startcenter +LAUNCHERLIST = writer calc draw impress math base printeradmin qstart startcenter javafilter LAUNCHERDEPN = ../menus/{$(LAUNCHERLIST)}.desktop LAUNCHERFLAGFILE = $(COMMONMISC)/$(TARGET)/xdg.flag @@ -126,9 +126,9 @@ MIMEICONLIST = \ extension ICONDEPN = \ - ../icons/hicolor/{16x16 32x32 48x48}/apps/{$(LAUNCHERLIST:s/qstart//)}.png \ + ../icons/hicolor/{16x16 32x32 48x48}/apps/{$(LAUNCHERLIST:s/qstart//:s/javafilter//)}.png \ ../icons/hicolor/{16x16 32x32 48x48}/mimetypes/{$(MIMEICONLIST)}.png \ - ../icons/locolor/{16x16 32x32}/apps/{$(LAUNCHERLIST:s/qstart//)}.png \ + ../icons/locolor/{16x16 32x32}/apps/{$(LAUNCHERLIST:s/qstart//:s/javafilter//)}.png \ ../icons/locolor/{16x16 32x32}/mimetypes/{$(MIMEICONLIST)}.png # --- Targets ------------------------------------------------------ diff --git a/sysui/desktop/suse/suse-menus.spec b/sysui/desktop/suse/suse-menus.spec index a1bd2b0359f1..7280d9dbae8b 100644 --- a/sysui/desktop/suse/suse-menus.spec +++ b/sysui/desktop/suse/suse-menus.spec @@ -291,6 +291,7 @@ done /usr/share/applications/%unixfilename-base.desktop /usr/share/applications/%unixfilename-printeradmin.desktop /usr/share/applications/%unixfilename-startcenter.desktop +/usr/share/applications/%unixfilename-javafilter.desktop /opt/gnome/share/mime-info/*.keys /opt/gnome/share/mime-info/*.mime /opt/kde3/share/mimelnk/application/*.desktop diff --git a/ucb/source/ucp/gio/gio_content.hxx b/ucb/source/ucp/gio/gio_content.hxx index 824fa6514379..1c00f8c79d6e 100644 --- a/ucb/source/ucp/gio/gio_content.hxx +++ b/ucb/source/ucp/gio/gio_content.hxx @@ -140,7 +140,7 @@ public: virtual ~Content(); - static com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > getPropertyValuesFromGFileInfo( + com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > getPropertyValuesFromGFileInfo( GFileInfo *pInfo, const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr, const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv, const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& rProperties); diff --git a/ucb/source/ucp/gio/gio_datasupplier.cxx b/ucb/source/ucp/gio/gio_datasupplier.cxx index e7d55039ed27..22cd4afa08fe 100644 --- a/ucb/source/ucp/gio/gio_datasupplier.cxx +++ b/ucb/source/ucp/gio/gio_datasupplier.cxx @@ -236,11 +236,31 @@ uno::Reference< sdbc::XRow > DataSupplier::queryPropertyValues( sal_uInt32 nInde if ( getResult( nIndex ) ) { - uno::Reference< sdbc::XRow > xRow = Content::getPropertyValuesFromGFileInfo( - maResults[ nIndex ]->pInfo, m_xSMgr, getResultSet()->getEnvironment(), getResultSet()->getProperties()); - - maResults[ nIndex ]->xRow = xRow; - return xRow; + uno::Reference< ucb::XContent > xContent( queryContent( nIndex ) ); + if ( xContent.is() ) + { + try + { + uno::Reference< ucb::XCommandProcessor > xCmdProc( + xContent, uno::UNO_QUERY_THROW ); + sal_Int32 nCmdId( xCmdProc->createCommandIdentifier() ); + ucb::Command aCmd; + aCmd.Name = rtl::OUString::createFromAscii( "getPropertyValues" ); + aCmd.Handle = -1; + aCmd.Argument <<= getResultSet()->getProperties(); + uno::Any aResult( xCmdProc->execute( + aCmd, nCmdId, getResultSet()->getEnvironment() ) ); + uno::Reference< sdbc::XRow > xRow; + if ( aResult >>= xRow ) + { + maResults[ nIndex ]->xRow = xRow; + return xRow; + } + } + catch ( uno::Exception const & ) + { + } + } } return uno::Reference< sdbc::XRow >(); } diff --git a/ucb/source/ucp/webdav/DAVResourceAccess.cxx b/ucb/source/ucp/webdav/DAVResourceAccess.cxx index ea1c09efaa3f..4ffc8dd88cf5 100644 --- a/ucb/source/ucp/webdav/DAVResourceAccess.cxx +++ b/ucb/source/ucp/webdav/DAVResourceAccess.cxx @@ -960,6 +960,7 @@ void DAVResourceAccess::LOCK( while ( bRetry ); } +#if 0 // currently not used, but please don't remove code //========================================================================= // refresh existing lock. sal_Int64 DAVResourceAccess::LOCK( @@ -1003,6 +1004,7 @@ sal_Int64 DAVResourceAccess::LOCK( return nNewTimeout; } +#endif //========================================================================= void DAVResourceAccess::UNLOCK( diff --git a/ucb/source/ucp/webdav/DAVResourceAccess.hxx b/ucb/source/ucp/webdav/DAVResourceAccess.hxx index 87e306d94e02..53a98847078b 100644 --- a/ucb/source/ucp/webdav/DAVResourceAccess.hxx +++ b/ucb/source/ucp/webdav/DAVResourceAccess.hxx @@ -209,12 +209,14 @@ public: com::sun::star::ucb::XCommandEnvironment > & xEnv ) throw( DAVException ); +#if 0 // currently not used, but please don't remove code // refresh existing lock. sal_Int64 LOCK( sal_Int64 nTimeout, const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv ) throw ( DAVException ); +#endif void UNLOCK( const com::sun::star::uno::Reference< diff --git a/ucb/source/ucp/webdav/NeonSession.cxx b/ucb/source/ucp/webdav/NeonSession.cxx index 0d979ae72ada..8fc1730ba018 100644 --- a/ucb/source/ucp/webdav/NeonSession.cxx +++ b/ucb/source/ucp/webdav/NeonSession.cxx @@ -435,7 +435,7 @@ extern "C" int NeonSession_CertificationNotify( void *userdata, char * dn = ne_ssl_readable_dname( ne_ssl_cert_subject( cert ) ); rtl::OUString cert_subject( dn, strlen( dn ), RTL_TEXTENCODING_UTF8, 0 ); - free( dn ); + ne_free( dn ); security::CertificateContainerStatus certificateContainer( xCertificateContainer->hasCertificate( diff --git a/ucb/source/ucp/webdav/NeonUri.cxx b/ucb/source/ucp/webdav/NeonUri.cxx index f71056ba83a9..774faa06b9dd 100644 --- a/ucb/source/ucp/webdav/NeonUri.cxx +++ b/ucb/source/ucp/webdav/NeonUri.cxx @@ -32,6 +32,7 @@ #include <rtl/uri.hxx> #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> +#include "ne_alloc.h" #include "NeonUri.hxx" #include "DAVException.hxx" @@ -127,7 +128,7 @@ NeonUri::NeonUri( const ne_uri * inUri ) throw DAVException( DAVException::DAV_INVALID_ARG ); init( rtl::OString( uri ), inUri ); - free( uri ); + ne_free( uri ); calculateURI(); } diff --git a/uui/source/lockfailed.src b/uui/source/lockfailed.src index 66d6a1d4bb7e..1a3e1534d0ff 100644 --- a/uui/source/lockfailed.src +++ b/uui/source/lockfailed.src @@ -37,7 +37,7 @@ String STR_LOCKFAILED_TITLE }; String STR_LOCKFAILED_MSG { - Text [ en-US ] = "The file could not be locked for exclusive access by %PRODUCTNAME, due to missing permission to created a lock file on that file location."; + Text [ en-US ] = "The file could not be locked for exclusive access by %PRODUCTNAME, due to missing permission to create a lock file on that file location."; }; String STR_LOCKFAILED_DONTSHOWAGAIN { diff --git a/xmloff/inc/SchXMLExport.hxx b/xmloff/inc/SchXMLExport.hxx index 2f943f100170..d6227754a5f2 100644 --- a/xmloff/inc/SchXMLExport.hxx +++ b/xmloff/inc/SchXMLExport.hxx @@ -38,7 +38,6 @@ namespace com { namespace sun { namespace star { namespace chart { class XDiagram; class XChartDocument; - class XChartDataArray; struct ChartSeriesAddress; } namespace drawing { diff --git a/xmloff/inc/xmloff/SchXMLExportHelper.hxx b/xmloff/inc/xmloff/SchXMLExportHelper.hxx index 5876ce989c30..64f579a7c252 100644 --- a/xmloff/inc/xmloff/SchXMLExportHelper.hxx +++ b/xmloff/inc/xmloff/SchXMLExportHelper.hxx @@ -44,7 +44,6 @@ namespace com { namespace sun { namespace star { namespace chart { class XDiagram; class XChartDocument; - class XChartDataArray; struct ChartSeriesAddress; } namespace chart2 { @@ -114,6 +113,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mxAdditionalShapes; tDataSequenceCont m_aDataSequencesToExport; + rtl::OUString maCategoriesRange; /** first parseDocument: collect autostyles and store names in this queue second parseDocument: export content and use names from this queue @@ -179,8 +179,6 @@ private: SAL_DLLPRIVATE void addSize( com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape ); /// fills the member msString with the appropriate String (i.e. "A3") SAL_DLLPRIVATE void getCellAddress( sal_Int32 nCol, sal_Int32 nRow ); - /// interchanges rows and columns of the sequence given - SAL_DLLPRIVATE void swapDataArray( com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< double > >& rSequence ); /// exports a string as a paragraph element SAL_DLLPRIVATE void exportText( const ::rtl::OUString& rText, bool bConvertTabsLFs = false ); SAL_DLLPRIVATE void exportErrorBarRanges(); diff --git a/xmloff/inc/xmloff/SchXMLImportHelper.hxx b/xmloff/inc/xmloff/SchXMLImportHelper.hxx index f3cb28a754e2..03fa8c8e16c0 100644 --- a/xmloff/inc/xmloff/SchXMLImportHelper.hxx +++ b/xmloff/inc/xmloff/SchXMLImportHelper.hxx @@ -136,10 +136,6 @@ public: static sal_uInt16 GetChartFamilyID() { return XML_STYLE_FAMILY_SCH_CHART_ID; } - sal_Int32 GetNumberOfSeries(); - sal_Int32 GetLengthOfSeries(); - void ResizeChartData( sal_Int32 nSeries, sal_Int32 nDataPoints = -1 ); - /** @param bPushLastChartType If </FALSE>, in case a new chart type has to be added (because it does not exist yet), it is appended at the end of the chart-type container. When </TRUE>, a new chart type diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index fa6481015e5c..e9e3771eb0d7 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -57,7 +57,6 @@ #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/drawing/XDrawPage.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> -#include <com/sun/star/chart/XChartDataArray.hpp> #include <com/sun/star/awt/PosSize.hpp> #include <com/sun/star/embed/Aspects.hpp> #include <com/sun/star/embed/XVisualObject.hpp> @@ -874,6 +873,9 @@ void SchXMLChartContext::EndElement() { //own data or only rectangular range available + if( xNewDoc->hasInternalDataProvider() ) + SchXMLTableHelper::applyTableToInternalDataProvider( maTable, xNewDoc ); + bool bOlderThan2_3 = SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( Reference< frame::XModel >( xNewDoc, uno::UNO_QUERY )); bool bOldFileWithOwnDataFromRows = (bOlderThan2_3 && bHasOwnData && (meDataRowSource==chart::ChartDataRowSource_ROWS)); // in this case there are range addresses that are simply wrong. @@ -882,21 +884,12 @@ void SchXMLChartContext::EndElement() { //bHasOwnData is true in this case! //e.g. for normal files with own data or also in case of copy paste scenario (e.g. calc to impress) - if( xNewDoc->hasInternalDataProvider() ) - SchXMLTableHelper::applyTableToInternalDataProvider( maTable, xNewDoc ); bSwitchRangesFromOuterToInternalIfNecessary = true; } else { //apply data from rectangular range - // apply data read from the table sub-element to the chart - // if the data provider supports the XChartDataArray interface like - // the internal data provider - uno::Reference< chart::XChartDataArray > xChartData( xNewDoc->getDataProvider(), uno::UNO_QUERY ); - if( xChartData.is()) - SchXMLTableHelper::applyTableSimple( maTable, xChartData ); - // create datasource from data provider with rectangular range // parameters and change the diagram via template mechanism try @@ -919,9 +912,7 @@ void SchXMLChartContext::EndElement() if( !xNewDoc->hasInternalDataProvider() ) { xNewDoc->createInternalDataProvider( sal_False /* bCloneExistingData */ ); - xChartData = uno::Reference< chart::XChartDataArray >( xNewDoc->getDataProvider(), uno::UNO_QUERY ); - if( xChartData.is()) - SchXMLTableHelper::applyTableSimple( maTable, xChartData ); + SchXMLTableHelper::applyTableToInternalDataProvider( maTable, xNewDoc ); try { lcl_ApplyDataFromRectangularRangeToDiagram( xNewDoc, msChartAddress, meDataRowSource, mbRowHasLabels, mbColHasLabels, bHasOwnData, msColTrans, msRowTrans ); diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 3dea947dcb8c..9940f99d9f7a 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -71,7 +71,7 @@ #include <com/sun/star/chart/XTwoAxisXSupplier.hpp> #include <com/sun/star/chart/XTwoAxisYSupplier.hpp> #include <com/sun/star/chart/XAxisZSupplier.hpp> -#include <com/sun/star/chart/XChartDataArray.hpp> +#include <com/sun/star/chart/XComplexDescriptionAccess.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart/ChartAxisAssign.hpp> #include <com/sun/star/chart/ChartSeriesAddress.hpp> @@ -116,6 +116,7 @@ using ::rtl::OUStringToOString; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; +using ::std::vector; namespace { @@ -166,6 +167,13 @@ template< typename T > ::std::back_inserter( rDestination )); } +template< typename T > + void lcl_SequenceToVector( const Sequence< T > & rSource, ::std::vector< T > & rDestination ) +{ + rDestination.clear(); + lcl_SequenceToVectorAppend( rSource, rDestination ); +} + Reference< chart2::data::XLabeledDataSequence > lcl_getCategories( const Reference< chart2::XDiagram > & xDiagram ) { Reference< chart2::data::XLabeledDataSequence > xResult; @@ -209,24 +217,6 @@ Reference< chart2::data::XLabeledDataSequence > lcl_getCategories( const Referen ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); } - /* - //unused ranges are very problematic as they bear the risk to damage the rectangular structure completly - if(!xResult.is()) - { - Sequence< Reference< chart2::data::XLabeledDataSequence > > aUnusedSequences( xDiagram->getUnusedData() ); - - lcl_MatchesRole aHasCategories( OUString::createFromAscii("categories" ) ); - for( sal_Int32 nN=0; nN<aUnusedSequences.getLength(); nN++ ) - { - if( aHasCategories( aUnusedSequences[nN] ) ) - { - xResult.set( aUnusedSequences[nN] ); - break; - } - } - } - */ - return xResult; } @@ -471,12 +461,6 @@ sal_Int32 lcl_getMaxSequenceLength( for( SchXMLExportHelper::tDataSequenceCont::const_iterator aIt( rContainer.begin()); aIt != rContainer.end(); ++aIt ) { - if( aIt->first.is()) - { - sal_Int32 nSeqLength = aIt->first->getData().getLength(); - if( nSeqLength > nResult ) - nResult = nSeqLength; - } if( aIt->second.is()) { sal_Int32 nSeqLength = aIt->second->getData().getLength(); @@ -487,30 +471,6 @@ sal_Int32 lcl_getMaxSequenceLength( return nResult; } -void lcl_fillCategoriesIntoStringVector( - const Reference< chart2::data::XDataSequence > & xCategories, - ::std::vector< OUString > & rOutCategories ) -{ - OSL_ASSERT( xCategories.is()); - if( !xCategories.is()) - return; - Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xCategories, uno::UNO_QUERY ); - if( xTextualDataSequence.is()) - { - rOutCategories.clear(); - Sequence< OUString > aTextData( xTextualDataSequence->getTextualData()); - ::std::copy( aTextData.getConstArray(), aTextData.getConstArray() + aTextData.getLength(), - ::std::back_inserter( rOutCategories )); - } - else - { - Sequence< uno::Any > aAnies( xCategories->getData()); - rOutCategories.resize( aAnies.getLength()); - for( sal_Int32 i=0; i<aAnies.getLength(); ++i ) - aAnies[i] >>= rOutCategories[i]; - } -} - double lcl_getValueFromSequence( const Reference< chart2::data::XDataSequence > & xSeq, sal_Int32 nIndex ) { double fResult = 0.0; @@ -579,17 +539,23 @@ bool lcl_SequenceHasUnhiddenData( const uno::Reference< chart2::data::XDataSeque return false; } +typedef vector< OUString > tStringVector; +typedef vector< vector< OUString > > t2DStringVector; +typedef vector< vector< double > > t2DNumberContainer; + struct lcl_TableData { - typedef ::std::vector< OUString > tStringContainer; - typedef ::std::vector< ::std::vector< double > > tTwoDimNumberContainer; + t2DNumberContainer aDataInRows; + tStringVector aDataRangeRepresentations; - tTwoDimNumberContainer aDataInRows; - tStringContainer aDataRangeRepresentations; - tStringContainer aFirstRowStrings; - tStringContainer aFirstRowRangeRepresentations; - tStringContainer aFirstColumnStrings; - tStringContainer aFirstColumnRangeRepresentations; + tStringVector aColumnDescriptions; + tStringVector aColumnDescriptions_Ranges; + + tStringVector aRowDescriptions; + tStringVector aRowDescriptions_Ranges; + + Sequence< Sequence< OUString > > aComplexColumnDescriptions;//outer index is columns - inner index is level + Sequence< Sequence< OUString > > aComplexRowDescriptions;//outer index is rows - inner index is level ::std::vector< sal_Int32 > aHiddenColumns; }; @@ -613,39 +579,29 @@ typedef ::std::map< sal_Int32, SchXMLExportHelper::tLabelValuesDataPair > struct lcl_SequenceToMapElement : public ::std::unary_function< lcl_DataSequenceMap::mapped_type, lcl_DataSequenceMap::value_type > { - lcl_SequenceToMapElement( sal_Int32 nOffset = 0 ) : - m_nOffset( nOffset ) + lcl_SequenceToMapElement() {} result_type operator() ( const argument_type & rContent ) { sal_Int32 nIndex = -1; - if( rContent.second.is()) + if( rContent.second.is()) //has values { OUString aRangeRep( rContent.second->getSourceRangeRepresentation()); - if( aRangeRep.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("categories"))) - { - OSL_ASSERT( m_nOffset > 0 ); - nIndex = 0; - } - else - nIndex = aRangeRep.toInt32() + m_nOffset; + nIndex = aRangeRep.toInt32(); } - else if( rContent.first.is()) - nIndex = rContent.first->getSourceRangeRepresentation().copy( sizeof("label ")).toInt32() + m_nOffset; + else if( rContent.first.is()) //has labels + nIndex = rContent.first->getSourceRangeRepresentation().copy( sizeof("label ")).toInt32(); return result_type( nIndex, rContent ); } -private: - sal_Int32 m_nOffset; }; -void lcl_PrepareInternalSequencesForTableExport( - SchXMLExportHelper::tDataSequenceCont & rInOutSequences, bool bHasCategories ) +void lcl_ReorderInternalSequencesAccordingToTheirRangeName( + SchXMLExportHelper::tDataSequenceCont & rInOutSequences ) { lcl_DataSequenceMap aIndexSequenceMap; - const sal_Int32 nOffset = bHasCategories ? 1 : 0; ::std::transform( rInOutSequences.begin(), rInOutSequences.end(), ::std::inserter( aIndexSequenceMap, aIndexSequenceMap.begin()), - lcl_SequenceToMapElement( nOffset )); + lcl_SequenceToMapElement()); rInOutSequences.clear(); sal_Int32 nIndex = 0; @@ -665,113 +621,113 @@ void lcl_PrepareInternalSequencesForTableExport( lcl_TableData lcl_getDataForLocalTable( - const SchXMLExportHelper::tDataSequenceCont & aPassedSequences, bool bHasCategoryLabels, - bool bSwap, - bool bHasOwnData, + const SchXMLExportHelper::tDataSequenceCont & aSequencesToExport, + const Reference< chart::XComplexDescriptionAccess >& xComplexDescriptionAccess, + const OUString& rCategoriesRange, + bool bSeriesFromColumns, const Reference< chart2::data::XRangeXMLConversion > & xRangeConversion ) { lcl_TableData aResult; - SchXMLExportHelper::tDataSequenceCont aSequencesToExport( aPassedSequences ); - if( bHasOwnData ) - lcl_PrepareInternalSequencesForTableExport( aSequencesToExport, bHasCategoryLabels ); + try + { + Sequence< OUString > aSimpleCategories; + if( xComplexDescriptionAccess.is() ) + { + if( bSeriesFromColumns ) + aSimpleCategories = xComplexDescriptionAccess->getRowDescriptions(); + else + aSimpleCategories = xComplexDescriptionAccess->getColumnDescriptions(); - SchXMLExportHelper::tDataSequenceCont::size_type nNumSequences = aSequencesToExport.size(); - SchXMLExportHelper::tDataSequenceCont::const_iterator aBegin( aSequencesToExport.begin()); - SchXMLExportHelper::tDataSequenceCont::const_iterator aEnd( aSequencesToExport.end()); - SchXMLExportHelper::tDataSequenceCont::const_iterator aIt( aBegin ); + aResult.aComplexColumnDescriptions = xComplexDescriptionAccess->getComplexColumnDescriptions(); + aResult.aComplexRowDescriptions = xComplexDescriptionAccess->getComplexRowDescriptions(); + } - if( bHasCategoryLabels ) - { - if( nNumSequences>=1 ) //#i83537# - --nNumSequences; - else - bHasCategoryLabels=false; - } - size_t nMaxSequenceLength( lcl_getMaxSequenceLength( aSequencesToExport )); - size_t nNumColumns( bSwap ? nMaxSequenceLength : nNumSequences ); - size_t nNumRows( bSwap ? nNumSequences : nMaxSequenceLength ); + SchXMLExportHelper::tDataSequenceCont::size_type nNumSequences = aSequencesToExport.size(); + SchXMLExportHelper::tDataSequenceCont::const_iterator aBegin( aSequencesToExport.begin()); + SchXMLExportHelper::tDataSequenceCont::const_iterator aEnd( aSequencesToExport.end()); + SchXMLExportHelper::tDataSequenceCont::const_iterator aIt( aBegin ); - // resize data - aResult.aDataInRows.resize( nNumRows ); - double fNan = 0.0; - ::rtl::math::setNan( &fNan ); - ::std::for_each( aResult.aDataInRows.begin(), aResult.aDataInRows.end(), - lcl_resize< lcl_TableData::tTwoDimNumberContainer::value_type >( nNumColumns, fNan )); - aResult.aFirstRowStrings.resize( nNumColumns ); - aResult.aFirstColumnStrings.resize( nNumRows ); + size_t nMaxSequenceLength( lcl_getMaxSequenceLength( aSequencesToExport )); + nMaxSequenceLength = std::max( nMaxSequenceLength, size_t( aSimpleCategories.getLength() ) ); + size_t nNumColumns( bSeriesFromColumns ? nNumSequences : nMaxSequenceLength ); + size_t nNumRows( bSeriesFromColumns ? nMaxSequenceLength : nNumSequences ); - lcl_TableData::tStringContainer & rCategories = - (bSwap ? aResult.aFirstRowStrings : aResult.aFirstColumnStrings ); - lcl_TableData::tStringContainer & rLabels = - (bSwap ? aResult.aFirstColumnStrings : aResult.aFirstRowStrings ); + // resize data + aResult.aDataInRows.resize( nNumRows ); + double fNan = 0.0; + ::rtl::math::setNan( &fNan ); + ::std::for_each( aResult.aDataInRows.begin(), aResult.aDataInRows.end(), + lcl_resize< t2DNumberContainer::value_type >( nNumColumns, fNan )); + aResult.aColumnDescriptions.resize( nNumColumns ); + aResult.aComplexColumnDescriptions.realloc( nNumColumns ); + aResult.aRowDescriptions.resize( nNumRows ); + aResult.aComplexRowDescriptions.realloc( nNumRows ); - if( aIt != aEnd ) - { - if( bHasCategoryLabels ) - { - lcl_fillCategoriesIntoStringVector( aIt->second, rCategories ); - if( aIt->second.is()) - { - OUString aRange( aIt->second->getSourceRangeRepresentation()); - if( xRangeConversion.is()) - aRange = xRangeConversion->convertRangeToXML( aRange ); - if( bSwap ) - aResult.aFirstRowRangeRepresentations.push_back( aRange ); - else - aResult.aFirstColumnRangeRepresentations.push_back( aRange ); - } - ++aIt; - } - else - { - // autogenerated categories - rCategories.clear(); - lcl_SequenceToVectorAppend( aIt->second->generateLabel( chart2::data::LabelOrigin_LONG_SIDE ), rCategories ); - } - } + tStringVector& rCategories = bSeriesFromColumns ? aResult.aRowDescriptions : aResult.aColumnDescriptions; + tStringVector& rLabels = bSeriesFromColumns ? aResult.aColumnDescriptions : aResult.aRowDescriptions; - // iterate over all sequences - size_t nSeqIdx = 0; - for( ; aIt != aEnd; ++aIt, ++nSeqIdx ) - { - OUString aRange; - if( aIt->first.is()) + //categories + lcl_SequenceToVector( aSimpleCategories, rCategories ); + if( rCategoriesRange.getLength() ) { - rLabels[nSeqIdx] = lcl_getLabelString( aIt->first ); - aRange = aIt->first->getSourceRangeRepresentation(); + OUString aRange(rCategoriesRange); if( xRangeConversion.is()) aRange = xRangeConversion->convertRangeToXML( aRange ); + if( bSeriesFromColumns ) + aResult.aRowDescriptions_Ranges.push_back( aRange ); + else + aResult.aColumnDescriptions_Ranges.push_back( aRange ); } - else if( aIt->second.is()) - rLabels[nSeqIdx] = lcl_flattenStringSequence( - aIt->second->generateLabel( chart2::data::LabelOrigin_SHORT_SIDE )); - if( bSwap ) - aResult.aFirstColumnRangeRepresentations.push_back( aRange ); - else - aResult.aFirstRowRangeRepresentations.push_back( aRange ); - ::std::vector< double > aNumbers( lcl_getAllValuesFromSequence( aIt->second )); - if( bSwap ) - aResult.aDataInRows[nSeqIdx] = aNumbers; - else + // iterate over all sequences + size_t nSeqIdx = 0; + for( ; aIt != aEnd; ++aIt, ++nSeqIdx ) { - const sal_Int32 nSize( static_cast< sal_Int32 >( aNumbers.size())); - for( sal_Int32 nIdx=0; nIdx<nSize; ++nIdx ) - aResult.aDataInRows[nIdx][nSeqIdx] = aNumbers[nIdx]; - } + OUString aRange; + if( aIt->first.is()) + { + rLabels[nSeqIdx] = lcl_getLabelString( aIt->first ); + aRange = aIt->first->getSourceRangeRepresentation(); + if( xRangeConversion.is()) + aRange = xRangeConversion->convertRangeToXML( aRange ); + } + else if( aIt->second.is()) + rLabels[nSeqIdx] = lcl_flattenStringSequence( + aIt->second->generateLabel( chart2::data::LabelOrigin_SHORT_SIDE )); + if( bSeriesFromColumns ) + aResult.aColumnDescriptions_Ranges.push_back( aRange ); + else + aResult.aRowDescriptions_Ranges.push_back( aRange ); - if( aIt->second.is()) - { - aRange = aIt->second->getSourceRangeRepresentation(); - if( xRangeConversion.is()) - aRange = xRangeConversion->convertRangeToXML( aRange ); - } - aResult.aDataRangeRepresentations.push_back( aRange ); + ::std::vector< double > aNumbers( lcl_getAllValuesFromSequence( aIt->second )); + if( bSeriesFromColumns ) + { + const sal_Int32 nSize( static_cast< sal_Int32 >( aNumbers.size())); + for( sal_Int32 nIdx=0; nIdx<nSize; ++nIdx ) + aResult.aDataInRows[nIdx][nSeqIdx] = aNumbers[nIdx]; + } + else + aResult.aDataInRows[nSeqIdx] = aNumbers; + + if( aIt->second.is()) + { + aRange = aIt->second->getSourceRangeRepresentation(); + if( xRangeConversion.is()) + aRange = xRangeConversion->convertRangeToXML( aRange ); + } + aResult.aDataRangeRepresentations.push_back( aRange ); - //is column hidden? - if( !lcl_SequenceHasUnhiddenData(aIt->first) && !lcl_SequenceHasUnhiddenData(aIt->second) ) - aResult.aHiddenColumns.push_back(nSeqIdx); + //is column hidden? + if( !lcl_SequenceHasUnhiddenData(aIt->first) && !lcl_SequenceHasUnhiddenData(aIt->second) ) + aResult.aHiddenColumns.push_back(nSeqIdx); + } + } + catch( uno::Exception & rEx ) + { + (void)rEx; // avoid warning for pro build + OSL_TRACE( OUStringToOString( OUString( RTL_CONSTASCII_USTRINGPARAM( + "something went wrong during table data collection: " )) + rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); } return aResult; @@ -1452,6 +1408,19 @@ void SchXMLExportHelper::parseDocument( Reference< chart::XChartDocument >& rCha delete pElChart; } +void lcl_exportComplexLabel( const Sequence< OUString >& rComplexLabel, SvXMLExport& rExport ) +{ + sal_Int32 nLength = rComplexLabel.getLength(); + if( nLength<=1 ) + return; + SvXMLElementExport aTextList( rExport, XML_NAMESPACE_TEXT, XML_LIST, sal_True, sal_True ); + for(sal_Int32 nN=0; nN<nLength; nN++) + { + SvXMLElementExport aListItem( rExport, XML_NAMESPACE_TEXT, XML_LIST_ITEM, sal_True, sal_True ); + SchXMLTools::exportText( rExport, rComplexLabel[nN], false /*bConvertTabsLFs*/ ); + } +} + void SchXMLExportHelper::exportTable() { // table element @@ -1468,13 +1437,24 @@ void SchXMLExportHelper::exportTable() xRangeConversion.set( xNewDoc->getDataProvider(), uno::UNO_QUERY ); } - lcl_TableData aData( lcl_getDataForLocalTable( - m_aDataSequencesToExport, mbHasCategoryLabels, !mbRowSourceColumns, bHasOwnData, xRangeConversion )); + Reference< chart::XComplexDescriptionAccess > xComplexDescriptionAccess; + { + Reference< chart::XChartDocument > xChartDoc( mrExport.GetModel(), uno::UNO_QUERY ); + if( xChartDoc.is() ) + xComplexDescriptionAccess = Reference< chart::XComplexDescriptionAccess >( xChartDoc->getData(), uno::UNO_QUERY ); + } - lcl_TableData::tStringContainer::const_iterator aDataRangeIter( aData.aDataRangeRepresentations.begin()); - const lcl_TableData::tStringContainer::const_iterator aDataRangeEndIter( aData.aDataRangeRepresentations.end()); - lcl_TableData::tStringContainer::const_iterator aFirstColumnRangeIter( aData.aFirstColumnRangeRepresentations.begin()); - const lcl_TableData::tStringContainer::const_iterator aFirstColumnRangeEndIter( aData.aFirstColumnRangeRepresentations.end()); + if( bHasOwnData ) + lcl_ReorderInternalSequencesAccordingToTheirRangeName( m_aDataSequencesToExport ); + lcl_TableData aData( lcl_getDataForLocalTable( m_aDataSequencesToExport + , xComplexDescriptionAccess, maCategoriesRange + , mbRowSourceColumns, xRangeConversion )); + + tStringVector::const_iterator aDataRangeIter( aData.aDataRangeRepresentations.begin()); + const tStringVector::const_iterator aDataRangeEndIter( aData.aDataRangeRepresentations.end()); + + tStringVector::const_iterator aRowDescriptions_RangeIter( aData.aRowDescriptions_Ranges.begin()); + const tStringVector::const_iterator aRowDescriptions_RangeEnd( aData.aRowDescriptions_Ranges.end()); // declare columns { @@ -1502,7 +1482,7 @@ void SchXMLExportHelper::exportTable() nNextIndex = nHiddenIndex+1; } - sal_Int32 nEndIndex = aData.aFirstRowStrings.size()-1; + sal_Int32 nEndIndex = aData.aColumnDescriptions.size()-1; if( nEndIndex >= nNextIndex ) { sal_Int64 nRepeat = static_cast< sal_Int64 >( nEndIndex - nNextIndex + 1 ); @@ -1514,59 +1494,78 @@ void SchXMLExportHelper::exportTable() } // export rows with content + //export header row { SvXMLElementExport aHeaderRows( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, sal_True, sal_True ); SvXMLElementExport aRow( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True ); + + //first one empty cell for the row descriptions { SvXMLElementExport aEmptyCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True ); SvXMLElementExport aEmptyParagraph( mrExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_True ); } - lcl_TableData::tStringContainer::const_iterator aFirstRowRangeIter( aData.aFirstRowRangeRepresentations.begin()); - const lcl_TableData::tStringContainer::const_iterator aFirstRowRangeEndIter( aData.aFirstRowRangeRepresentations.end()); - for( lcl_TableData::tStringContainer::const_iterator aIt( aData.aFirstRowStrings.begin()); - aIt != aData.aFirstRowStrings.end(); ++aIt ) + //export column descriptions + tStringVector::const_iterator aColumnDescriptions_RangeIter( aData.aColumnDescriptions_Ranges.begin()); + const tStringVector::const_iterator aColumnDescriptions_RangeEnd( aData.aColumnDescriptions_Ranges.end()); + const Sequence< Sequence< OUString > >& rComplexColumnDescriptions = aData.aComplexColumnDescriptions; + sal_Int32 nComplexCount = rComplexColumnDescriptions.getLength(); + sal_Int32 nC = 0; + for( tStringVector::const_iterator aIt( aData.aColumnDescriptions.begin()); + aIt != aData.aColumnDescriptions.end(); ++aIt ) { mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING ); SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True ); // write the original range name as id into the local table // to allow a correct re-association when copying via clipboard - if( !bHasOwnData && aFirstRowRangeIter != aFirstRowRangeEndIter ) + if( !bHasOwnData && aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd ) { - if( (*aFirstRowRangeIter).getLength()) - mrExport.AddAttribute( XML_NAMESPACE_TEXT, XML_ID, *aFirstRowRangeIter ); - ++aFirstRowRangeIter; + if( (*aColumnDescriptions_RangeIter).getLength()) + mrExport.AddAttribute( XML_NAMESPACE_TEXT, XML_ID, *aColumnDescriptions_RangeIter ); + ++aColumnDescriptions_RangeIter; } exportText( *aIt ); + if( nC < nComplexCount ) + lcl_exportComplexLabel( rComplexColumnDescriptions[nC++], mrExport ); } - OSL_ASSERT( bHasOwnData || aFirstRowRangeIter == aFirstRowRangeEndIter ); + OSL_ASSERT( bHasOwnData || aColumnDescriptions_RangeIter == aColumnDescriptions_RangeEnd ); } // closing row and header-rows elements - // value rows + // export value rows { SvXMLElementExport aRows( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROWS, sal_True, sal_True ); - lcl_TableData::tStringContainer::const_iterator aFirstColIt( aData.aFirstColumnStrings.begin()); - for( lcl_TableData::tTwoDimNumberContainer::const_iterator aColIt( aData.aDataInRows.begin()); - aColIt != aData.aDataInRows.end(); ++aColIt ) + tStringVector::const_iterator aRowDescriptionsIter( aData.aRowDescriptions.begin()); + const Sequence< Sequence< OUString > >& rComplexRowDescriptions = aData.aComplexRowDescriptions; + sal_Int32 nComplexCount = rComplexRowDescriptions.getLength(); + sal_Int32 nC = 0; + + for( t2DNumberContainer::const_iterator aRowIt( aData.aDataInRows.begin()); + aRowIt != aData.aDataInRows.end(); ++aRowIt ) { SvXMLElementExport aRow( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True ); + + //export row descriptions { mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING ); SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True ); - if( aFirstColIt != aData.aFirstColumnStrings.end()) + if( aRowDescriptionsIter != aData.aRowDescriptions.end()) { // write the original range name as id into the local table // to allow a correct re-association when copying via clipboard - if( !bHasOwnData && aFirstColumnRangeIter != aFirstColumnRangeEndIter ) - mrExport.AddAttribute( XML_NAMESPACE_TEXT, XML_ID, *aFirstColumnRangeIter++ ); - exportText( *aFirstColIt ); - ++aFirstColIt; + if( !bHasOwnData && aRowDescriptions_RangeIter != aRowDescriptions_RangeEnd ) + mrExport.AddAttribute( XML_NAMESPACE_TEXT, XML_ID, *aRowDescriptions_RangeIter++ ); + exportText( *aRowDescriptionsIter ); + ++aRowDescriptionsIter; + if( nC < nComplexCount ) + lcl_exportComplexLabel( rComplexRowDescriptions[nC++], mrExport ); } } - for( lcl_TableData::tTwoDimNumberContainer::value_type::const_iterator aInnerIt( aColIt->begin()); - aInnerIt != aColIt->end(); ++aInnerIt ) + + //export row values + for( t2DNumberContainer::value_type::const_iterator aColIt( aRowIt->begin()); + aColIt != aRowIt->end(); ++aColIt ) { - SvXMLUnitConverter::convertDouble( msStringBuffer, *aInnerIt ); + SvXMLUnitConverter::convertDouble( msStringBuffer, *aColIt ); msString = msStringBuffer.makeStringAndClear(); mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT ); mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE, msString ); @@ -1574,7 +1573,7 @@ void SchXMLExportHelper::exportTable() // write the original range name as id into the local table to // allow a correct re-association when copying via clipboard if( ( !bHasOwnData && aDataRangeIter != aDataRangeEndIter ) && - ( mbRowSourceColumns || (aInnerIt == aColIt->begin())) ) + ( mbRowSourceColumns || (aColIt == aRowIt->begin())) ) { if( (*aDataRangeIter).getLength()) mrExport.AddAttribute( XML_NAMESPACE_TEXT, XML_ID, *aDataRangeIter ); @@ -1587,7 +1586,7 @@ void SchXMLExportHelper::exportTable() // if range iterator was used it should have reached its end OSL_ASSERT( bHasOwnData || (aDataRangeIter == aDataRangeEndIter) ); - OSL_ASSERT( bHasOwnData || (aFirstColumnRangeIter == aFirstColumnRangeEndIter) ); + OSL_ASSERT( bHasOwnData || (aRowDescriptions_RangeIter == aRowDescriptions_RangeEnd) ); } void SchXMLExportHelper::exportPlotArea( @@ -2112,8 +2111,8 @@ void SchXMLExportHelper::exportAxes( if( xValues.is()) { Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY ); - aCategoriesRange = lcl_ConvertRange( xValues->getSourceRangeRepresentation(), xNewDoc ); - m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, xValues )); + maCategoriesRange = xValues->getSourceRangeRepresentation(); + aCategoriesRange = lcl_ConvertRange( maCategoriesRange, xNewDoc ); } } } @@ -3422,24 +3421,6 @@ awt::Size SchXMLExportHelper::getPageSize( const Reference< chart2::XChartDocume return aSize; } -void SchXMLExportHelper::swapDataArray( Sequence< Sequence< double > >& rSequence ) -{ - sal_Int32 nOuterSize = rSequence.getLength(); - sal_Int32 nInnerSize = rSequence[0].getLength(); // assume that all subsequences have same length - sal_Int32 i, o; - - Sequence< Sequence< double > > aResult( nInnerSize ); - Sequence< double >* pArray = aResult.getArray(); - for( i = 0; i < nInnerSize; i++ ) - { - pArray[ i ].realloc( nOuterSize ); - for( o = 0 ; o < nOuterSize ; o++ ) - aResult[ i ][ o ] = rSequence[ o ][ i ]; - } - - rSequence = aResult; -} - void SchXMLExportHelper::CollectAutoStyle( const std::vector< XMLPropertyState >& aStates ) { if( !aStates.empty() ) diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx index 4f32e90e861f..6afbaecb551c 100644 --- a/xmloff/source/chart/SchXMLImport.cxx +++ b/xmloff/source/chart/SchXMLImport.cxx @@ -47,7 +47,6 @@ #include <xmloff/xmlstyle.hxx> #include <com/sun/star/task/XStatusIndicatorSupplier.hpp> #include <com/sun/star/chart/XChartDocument.hpp> -#include <com/sun/star/chart/XChartDataArray.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/uno/XComponentContext.hpp> @@ -507,113 +506,6 @@ const SvXMLTokenMap& SchXMLImportHelper::GetRegEquationAttrTokenMap() // ---------------------------------------- -sal_Int32 SchXMLImportHelper::GetNumberOfSeries() -{ - if( mxChartDoc.is()) - { - Reference< chart::XChartDataArray > xData( mxChartDoc->getData(), uno::UNO_QUERY ); - if( xData.is()) - { - Sequence< Sequence< double > > xArray = xData->getData(); - - if( xArray.getLength()) - return xArray[ 0 ].getLength(); - } - } - - return 0; -} - -sal_Int32 SchXMLImportHelper::GetLengthOfSeries() -{ - if( mxChartDoc.is()) - { - Reference< chart::XChartDataArray > xData( mxChartDoc->getData(), uno::UNO_QUERY ); - if( xData.is()) - { - Sequence< Sequence< double > > xArray = xData->getData(); - - return xArray.getLength(); - } - } - - return 0; -} - -// -1 means don't change -void SchXMLImportHelper::ResizeChartData( sal_Int32 nSeries, sal_Int32 nDataPoints ) -{ - if( mxChartDoc.is()) - { - sal_Bool bWasChanged = sal_False; - - sal_Bool bDataInColumns = sal_True; - Reference< beans::XPropertySet > xDiaProp( mxChartDoc->getDiagram(), uno::UNO_QUERY ); - if( xDiaProp.is()) - { - chart::ChartDataRowSource eRowSource; - xDiaProp->getPropertyValue( OUString::createFromAscii( "DataRowSource" )) >>= eRowSource; - bDataInColumns = ( eRowSource == chart::ChartDataRowSource_COLUMNS ); - - // the chart core treats donut chart with interchanged rows/columns - Reference< chart::XDiagram > xDiagram( xDiaProp, uno::UNO_QUERY ); - if( xDiagram.is()) - { - OUString sChartType = xDiagram->getDiagramType(); - if( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.DonutDiagram" ))) - { - bDataInColumns = ! bDataInColumns; - } - } - } - sal_Int32 nColCount = bDataInColumns ? nSeries : nDataPoints; - sal_Int32 nRowCount = bDataInColumns ? nDataPoints : nSeries; - - Reference< chart::XChartDataArray > xData( mxChartDoc->getData(), uno::UNO_QUERY ); - if( xData.is()) - { - Sequence< Sequence< double > > xArray = xData->getData(); - - // increase number of rows - if( xArray.getLength() < nRowCount ) - { - sal_Int32 nOldLen = xArray.getLength(); - xArray.realloc( nRowCount ); - if( nColCount == -1 ) - { - sal_Int32 nSize = xArray[ 0 ].getLength(); - for( sal_Int32 i = nOldLen; i < nRowCount; i++ ) - xArray[ i ].realloc( nSize ); - } - bWasChanged = sal_True; - } - - if( nSeries == -1 && - nRowCount > 0 ) - nColCount = xArray[ 0 ].getLength(); - - // columns - if( nColCount > 0 && - xArray[ 0 ].getLength() < nColCount ) - { - if( nDataPoints == -1 ) - nRowCount = xArray.getLength(); - - for( sal_Int32 i = 0; i < nRowCount; i++ ) - xArray[ i ].realloc( nColCount ); - bWasChanged = sal_True; - } - - if( bWasChanged ) - { - xData->setData( xArray ); - mxChartDoc->attachData( - Reference< chart::XChartData >( xData, uno::UNO_QUERY )); - } - } - } -} - //static void SchXMLImportHelper::DeleteDataSeries( const Reference< chart2::XDataSeries > & xSeries, diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx index 742d42cb5f15..6ba9a49e4502 100644 --- a/xmloff/source/chart/SchXMLTableContext.cxx +++ b/xmloff/source/chart/SchXMLTableContext.cxx @@ -30,6 +30,7 @@ #include "SchXMLTableContext.hxx" #include "SchXMLParagraphContext.hxx" +#include "SchXMLTextListContext.hxx" #include "SchXMLImport.hxx" #include "SchXMLTools.hxx" #include "transporttypes.hxx" @@ -44,7 +45,7 @@ #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XChartTypeContainer.hpp> #include <com/sun/star/chart2/XInternalDataProvider.hpp> -#include <com/sun/star/chart/XChartDataArray.hpp> +#include <com/sun/star/chart/XComplexDescriptionAccess.hpp> #include <com/sun/star/chart/ChartSeriesAddress.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> @@ -138,26 +139,10 @@ std::vector< Reference< chart2::XAxis > > lcl_getAxesHoldingCategoriesFromDiagra return aRet; } -void lcl_ApplyColumnLabels( - const ::std::vector< SchXMLCell > & rFirstRow, - Sequence< OUString > & rOutColumnLabels, - sal_Int32 nOffset ) -{ - const sal_Int32 nColumnLabelsSize = rOutColumnLabels.getLength(); - const sal_Int32 nMax = ::std::min< sal_Int32 >( nColumnLabelsSize, - static_cast< sal_Int32 >( rFirstRow.size()) - nOffset ); - OSL_ASSERT( nMax == nColumnLabelsSize ); - for( sal_Int32 i=0; i<nMax; ++i ) - if( rFirstRow[i+nOffset].eType == SCH_CELL_TYPE_STRING ) - rOutColumnLabels[i] = rFirstRow[i+nOffset].aString; -} - struct lcl_ApplyCellToData : public ::std::unary_function< SchXMLCell, void > { - lcl_ApplyCellToData( Sequence< double > & rOutData, - Sequence< OUString > & rOutRowLabels ) : + lcl_ApplyCellToData( Sequence< double > & rOutData ) : m_rData( rOutData ), - m_rRowLabels( rOutRowLabels ), m_nIndex( 0 ), m_nSize( rOutData.getLength()) { @@ -178,49 +163,11 @@ struct lcl_ApplyCellToData : public ::std::unary_function< SchXMLCell, void > private: Sequence< double > & m_rData; - Sequence< OUString > & m_rRowLabels; sal_Int32 m_nIndex; sal_Int32 m_nSize; double m_fNaN; }; -struct lcl_ApplyRowsToData : public ::std::unary_function< ::std::vector< SchXMLCell >, void > -{ - lcl_ApplyRowsToData( Sequence< Sequence< double > > & rOutData, - Sequence< OUString > & rOutRowLabels, - sal_Int32 nOffset, - bool bHasHeader ) : - m_rData( rOutData ), - m_rRowLabels( rOutRowLabels ), - m_nIndex( 0 ), - m_nOuterSize( rOutData.getLength()), - m_nOffset( nOffset ), - m_bHasHeader( bHasHeader ) - {} - void operator() ( const ::std::vector< SchXMLCell > & rRow ) - { - if( ! rRow.empty()) - { - // label - if( m_bHasHeader && m_nIndex < m_rRowLabels.getLength() && rRow.front().eType == SCH_CELL_TYPE_STRING ) - m_rRowLabels[m_nIndex] = rRow.front().aString; - - // values - if( m_nIndex < m_nOuterSize ) - ::std::for_each( rRow.begin() + m_nOffset, rRow.end(), lcl_ApplyCellToData( m_rData[m_nIndex], m_rRowLabels )); - } - ++m_nIndex; - } - -private: - Sequence< Sequence< double > > & m_rData; - Sequence< OUString > & m_rRowLabels; - sal_Int32 m_nIndex; - sal_Int32 m_nOuterSize; - sal_Int32 m_nOffset; - bool m_bHasHeader; -}; - Sequence< Sequence< double > > lcl_getSwappedArray( const Sequence< Sequence< double > > & rData ) { sal_Int32 nOldOuterSize = rData.getLength(); @@ -237,47 +184,6 @@ Sequence< Sequence< double > > lcl_getSwappedArray( const Sequence< Sequence< do return aResult; } -void lcl_applyXMLTableToInternalDataprovider( - const SchXMLTable & rTable, - const Reference< chart::XChartDataArray > & xDataArray ) -{ - sal_Int32 nNumRows( static_cast< sal_Int32 >( rTable.aData.size())); - sal_Int32 nRowOffset = 0; - if( rTable.bHasHeaderRow ) - { - --nNumRows; - nRowOffset = 1; - } - sal_Int32 nNumColumns( rTable.nMaxColumnIndex + 1 ); - sal_Int32 nColOffset = 0; - if( rTable.bHasHeaderColumn ) - { - --nNumColumns; - nColOffset = 1; - } - - Sequence< Sequence< double > > aData( nNumRows ); - Sequence< OUString > aRowLabels( nNumRows ); - Sequence< OUString > aColumnLabels( nNumColumns ); - for( sal_Int32 i=0; i<nNumRows; ++i ) - aData[i].realloc( nNumColumns ); - - if( rTable.aData.begin() != rTable.aData.end()) - { - if( rTable.bHasHeaderRow ) - lcl_ApplyColumnLabels( rTable.aData.front(), aColumnLabels, nColOffset ); - ::std::for_each( rTable.aData.begin() + nRowOffset, rTable.aData.end(), - lcl_ApplyRowsToData( aData, aRowLabels, nColOffset, rTable.bHasHeaderColumn )); - } - - xDataArray->setData( aData ); - - if( rTable.bHasHeaderColumn ) - xDataArray->setRowDescriptions( aRowLabels ); - if( rTable.bHasHeaderRow ) - xDataArray->setColumnDescriptions( aColumnLabels ); -} - void lcl_fillRangeMapping( const SchXMLTable & rTable, lcl_tOriginalRangeToInternalRangeMap & rOutRangeMap, @@ -830,7 +736,7 @@ void SchXMLTableCellContext::StartElement( const uno::Reference< xml::sax::XAttr } } - mbReadPara = sal_True; + mbReadText = sal_True; SchXMLCell aCell; aCell.eType = eValueType; @@ -841,8 +747,8 @@ void SchXMLTableCellContext::StartElement( const uno::Reference< xml::sax::XAttr SvXMLUnitConverter::convertDouble( fData, aCellContent ); aCell.fValue = fData; - // dont read following <text:p> element - mbReadPara = sal_False; + // dont read text from following <text:p> or <text:list> element + mbReadText = sal_False; } mrTable.aData[ mrTable.nRowIndex ].push_back( aCell ); @@ -858,9 +764,17 @@ SvXMLImportContext* SchXMLTableCellContext::CreateChildContext( { SvXMLImportContext* pContext = 0; - // <text:p> element - if( nPrefix == XML_NAMESPACE_TEXT && - IsXMLToken( rLocalName, XML_P ) ) + // <text:list> element + if( nPrefix == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_LIST ) && mbReadText ) + { + SchXMLCell& rCell = mrTable.aData[ mrTable.nRowIndex ][ mrTable.nColumnIndex ]; + rCell.pComplexString = new Sequence< OUString >(); + rCell.eType = SCH_CELL_TYPE_COMPLEX_STRING; + pContext = new SchXMLTextListContext( GetImport(), rLocalName, *rCell.pComplexString ); + mbReadText = sal_False;//don't apply text from <text:p> + } + // <text:p> element - read text and range-id + else if( nPrefix == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_P ) ) { pContext = new SchXMLParagraphContext( GetImport(), rLocalName, maCellContent, &maRangeId ); } @@ -874,7 +788,7 @@ SvXMLImportContext* SchXMLTableCellContext::CreateChildContext( void SchXMLTableCellContext::EndElement() { - if( mbReadPara && maCellContent.getLength()) + if( mbReadText && maCellContent.getLength() ) //apply text from <text:p> element mrTable.aData[ mrTable.nRowIndex ][ mrTable.nColumnIndex ].aString = maCellContent; if( maRangeId.getLength()) mrTable.aData[ mrTable.nRowIndex ][ mrTable.nColumnIndex ].aRangeId = maRangeId; @@ -882,133 +796,90 @@ void SchXMLTableCellContext::EndElement() // ======================================== -// just interpret the table in a linear way with no references used -// (this is just a workaround for clipboard handling in EA2) -void SchXMLTableHelper::applyTableSimple( - const SchXMLTable& rTable, - const uno::Reference< chart::XChartDataArray > & xData ) +void lcl_ApplyCellToComplexLabel( const SchXMLCell& rCell, Sequence< OUString >& rComplexLabel ) { - // interpret table like this: - // - // series ----+---+ - // | | - // categories | | - // | | | - // V V V - // A B C ... - // 1 x x <--- labels - // 2 x 0 0 - // 3 x 0 0 - // ... - - // Standard Role-interpretation: - - // Column 1 contains the Categories - - // Chart Type/Class | Col 2 Col 3 Col 4 Col 5 Col 6 | Series | Domain - // -----------------+-----------------------------------+--------+------- - // Category Charts | Y 1 Y 2 Y 3 Y 4 ... | Y | - - // XY Chart | X all Y 1 Y 2 Y 3 ... | Y | X - // Stock Chart 1 | Min Max Close - - | Close | - - // Stock Chart 2 | Open Min Max Close - | Close | - - // Stock Chart 3 | Volume Min Max Close - | Close | - - // Stock Chart 4 | Volume Open Min Max Close | Close | - - - if( xData.is()) + if( rCell.eType == SCH_CELL_TYPE_STRING ) { - // get NaN - double fSolarNaN; - ::rtl::math::setNan( &fSolarNaN ); - double fNaN = fSolarNaN; - sal_Bool bConvertNaN = sal_False; - - uno::Reference< chart::XChartData > xChartData( xData, uno::UNO_QUERY ); - if( xChartData.is()) - { - fNaN = xChartData->getNotANumber(); - bConvertNaN = ( ! ::rtl::math::isNan( fNaN )); - } + rComplexLabel.realloc(1); + rComplexLabel[0] = rCell.aString; + } + else if( rCell.pComplexString && rCell.eType == SCH_CELL_TYPE_COMPLEX_STRING ) + rComplexLabel = *rCell.pComplexString; +} - sal_Int32 nRowCount = rTable.aData.size(); - sal_Int32 nColumnCount = 0; - sal_Int32 nCol = 0, nRow = 0; - if( nRowCount ) - { - nColumnCount = rTable.aData[ 0 ].size(); - ::std::vector< ::std::vector< SchXMLCell > >::const_iterator iRow = rTable.aData.begin(); - while( iRow != rTable.aData.end() ) - { - nColumnCount = ::std::max( nColumnCount, static_cast<sal_Int32>(iRow->size()) ); - iRow++; - } - } +void SchXMLTableHelper::applyTableToInternalDataProvider( + const SchXMLTable& rTable, + uno::Reference< chart2::XChartDocument > xChartDoc ) +{ + // apply all data read from the local table to the internal data provider + if( !xChartDoc.is() || !xChartDoc->hasInternalDataProvider() ) + return; + Reference< chart2::data::XDataProvider > xDataProv( xChartDoc->getDataProvider() ); + if( !xDataProv.is() ) + return; - // #i27909# avoid illegal index access for empty tables - if( nColumnCount == 0 || nRowCount == 0 ) - return; + //prepare the read local table data + sal_Int32 nNumRows( static_cast< sal_Int32 >( rTable.aData.size())); + sal_Int32 nRowOffset = 0; + if( rTable.bHasHeaderRow ) + { + --nNumRows; + nRowOffset = 1; + } + sal_Int32 nNumColumns( rTable.nMaxColumnIndex + 1 ); + sal_Int32 nColOffset = 0; + if( rTable.bHasHeaderColumn ) + { + --nNumColumns; + nColOffset = 1; + } - uno::Sequence< ::rtl::OUString > aCategories( nRowCount - 1 ); - uno::Sequence< ::rtl::OUString > aLabels( nColumnCount - 1 ); - uno::Sequence< uno::Sequence< double > > aData( nRowCount - 1 ); - for( nRow = 0; nRow < nRowCount - 1; nRow++ ) - aData[ nRow ].realloc( nColumnCount - 1 ); + Sequence< Sequence< double > > aDataInRows( nNumRows ); + Sequence< Sequence< OUString > > aComplexRowDescriptions( nNumRows ); + Sequence< Sequence< OUString > > aComplexColumnDescriptions( nNumColumns ); + for( sal_Int32 i=0; i<nNumRows; ++i ) + aDataInRows[i].realloc( nNumColumns ); - // set labels - ::std::vector< ::std::vector< SchXMLCell > >::const_iterator iRow = rTable.aData.begin(); - sal_Int32 nColumnCountOnFirstRow = iRow->size(); - for( nCol = 1; nCol < nColumnCountOnFirstRow; nCol++ ) + if( rTable.aData.begin() != rTable.aData.end()) + { + //apply column labels + if( rTable.bHasHeaderRow ) { - aLabels[ nCol - 1 ] = (*iRow)[ nCol ].aString; + const ::std::vector< SchXMLCell >& rFirstRow = rTable.aData.front(); + const sal_Int32 nColumnLabelsSize = aComplexColumnDescriptions.getLength(); + const sal_Int32 nMax = ::std::min< sal_Int32 >( nColumnLabelsSize, static_cast< sal_Int32 >( rFirstRow.size()) - nColOffset ); + OSL_ASSERT( nMax == nColumnLabelsSize ); + for( sal_Int32 i=0; i<nMax; ++i ) + lcl_ApplyCellToComplexLabel( rFirstRow[i+nColOffset], aComplexColumnDescriptions[i] ); } - xData->setColumnDescriptions( aLabels ); - double fVal; - const sal_Bool bConstConvertNan = bConvertNaN; - for( ++iRow, nRow = 0; iRow != rTable.aData.end(); iRow++, nRow++ ) + std::vector< ::std::vector< SchXMLCell > >::const_iterator aRowIter( rTable.aData.begin() + nRowOffset ); + std::vector< ::std::vector< SchXMLCell > >::const_iterator aEnd( rTable.aData.end() ); + for( sal_Int32 nRow = 0; aRowIter != aEnd && nRow < nNumRows; ++aRowIter, ++nRow ) { - aCategories[ nRow ] = (*iRow)[ 0 ].aString; - sal_Int32 nTableColCount( static_cast< sal_Int32 >((*iRow).size())); - for( nCol = 1; nCol < nTableColCount; nCol++ ) + const ::std::vector< SchXMLCell >& rRow = *aRowIter; + if( !rRow.empty() ) { - fVal = (*iRow)[ nCol ].fValue; - if( bConstConvertNan && - ::rtl::math::isNan( fVal )) - aData[ nRow ][ nCol - 1 ] = fNaN; - else - aData[ nRow ][ nCol - 1 ] = fVal; + // row label + if( rTable.bHasHeaderColumn ) + lcl_ApplyCellToComplexLabel( rRow.front(), aComplexRowDescriptions[nRow] ); + + // values + ::std::for_each( rRow.begin() + nColOffset, rRow.end(), lcl_ApplyCellToData( aDataInRows[nRow] )); } - // set remaining cells to NaN - for( ; nCol < nColumnCount; ++nCol ) - if( bConstConvertNan ) - aData[ nRow ][nCol - 1 ] = fNaN; - else - ::rtl::math::setNan( &(aData[ nRow ][nCol - 1 ])); } - xData->setRowDescriptions( aCategories ); - xData->setData( aData ); } -} -// ---------------------------------------- - -void SchXMLTableHelper::applyTableToInternalDataProvider( - const SchXMLTable& rTable, - uno::Reference< chart2::XChartDocument > xChartDoc ) -{ - if( ! (xChartDoc.is() && xChartDoc->hasInternalDataProvider())) - return; - Reference< chart2::data::XDataProvider > xDataProv( xChartDoc->getDataProvider()); - Reference< chart::XChartDataArray > xDataArray( xDataProv, uno::UNO_QUERY ); - if( ! xDataArray.is()) + //apply the collected data to the chart + Reference< chart::XComplexDescriptionAccess > xDataAccess( xDataProv, uno::UNO_QUERY ); + if( !xDataAccess.is() ) return; - OSL_ASSERT( xDataProv.is()); - // prerequisite for this method: all objects (data series, domains, etc.) - // need their own range string. - - // apply all data read in the table to the chart data-array of the internal - // data provider - lcl_applyXMLTableToInternalDataprovider( rTable, xDataArray ); + xDataAccess->setData( aDataInRows ); + if( rTable.bHasHeaderColumn ) + xDataAccess->setComplexRowDescriptions( aComplexRowDescriptions ); + if( rTable.bHasHeaderRow ) + xDataAccess->setComplexColumnDescriptions( aComplexColumnDescriptions ); } void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary( diff --git a/xmloff/source/chart/SchXMLTableContext.hxx b/xmloff/source/chart/SchXMLTableContext.hxx index e6c8ef61ac28..717628b18de0 100644 --- a/xmloff/source/chart/SchXMLTableContext.hxx +++ b/xmloff/source/chart/SchXMLTableContext.hxx @@ -45,7 +45,6 @@ namespace com { namespace sun { namespace star { }} namespace chart { class XChartDocument; - class XChartDataArray; struct ChartSeriesAddress; }}}} @@ -96,21 +95,11 @@ private: sal_Int32& nRows, sal_Int32& nColumns ); public: - /// The data for the ChartDocument is applied linearly - static void applyTableSimple( - const SchXMLTable& rTable, - const com::sun::star::uno::Reference< com::sun::star::chart::XChartDataArray > & xData ); - - /** The data for the ChartDocument is applied by reading the - table, the addresses of series, the addresses of labels, - the cell-range-address for the categories - */ static void applyTableToInternalDataProvider( const SchXMLTable& rTable, com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc ); - /** Second part of applyTableToInternalDataProvider that has to be called after the data series - got their styles set. This function reorders local data to fit the - correct data structure. + /** This function reorders local data to fit the correct data structure. + Call it after the data series got their styles set. */ static void switchRangesFromOuterToInternalIfNecessary( const SchXMLTable& rTable, const tSchXMLLSequencesPerIndex & rLSequencesPerIndex, @@ -220,7 +209,7 @@ private: SchXMLTable& mrTable; rtl::OUString maCellContent; rtl::OUString maRangeId; - sal_Bool mbReadPara; + sal_Bool mbReadText; public: SchXMLTableCellContext( SchXMLImportHelper& rImpHelper, diff --git a/xmloff/source/chart/SchXMLTextListContext.cxx b/xmloff/source/chart/SchXMLTextListContext.cxx new file mode 100755 index 000000000000..884acb473108 --- /dev/null +++ b/xmloff/source/chart/SchXMLTextListContext.cxx @@ -0,0 +1,136 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_xmloff.hxx" + +#include "SchXMLImport.hxx" +#include "SchXMLTextListContext.hxx" +#include "SchXMLParagraphContext.hxx" + +#include "xmlnmspe.hxx" +#include <xmloff/xmltoken.hxx> +#include <xmloff/nmspmap.hxx> + +using ::rtl::OUString; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Reference; +using namespace com::sun::star; +using namespace ::xmloff::token; + +//------------------------------------------------- +class SchXMLListItemContext : public SvXMLImportContext +{ +public: + SchXMLListItemContext( SvXMLImport& rImport, const OUString& rLocalName, OUString& rText ); + virtual ~SchXMLListItemContext(); + virtual void StartElement( const Reference< xml::sax::XAttributeList >& xAttrList ); + virtual void EndElement(); + + virtual SvXMLImportContext* CreateChildContext( + USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList ); + +private: + ::rtl::OUString& m_rText; +}; + +SchXMLListItemContext::SchXMLListItemContext( + SvXMLImport& rImport + , const OUString& rLocalName + , OUString& rText ) + : SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName ) + , m_rText( rText ) +{ +} + +SchXMLListItemContext::~SchXMLListItemContext() +{} + +void SchXMLListItemContext::StartElement( const Reference< xml::sax::XAttributeList >& /*xAttrList*/ ) +{ +} + +void SchXMLListItemContext::EndElement() +{ +} + +SvXMLImportContext* SchXMLListItemContext::CreateChildContext( + USHORT nPrefix, const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList >& ) +{ + SvXMLImportContext* pContext = 0; + if( nPrefix == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_P ) ) + pContext = new SchXMLParagraphContext( GetImport(), rLocalName, m_rText ); + else + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + return pContext; +} + +//------------------------------------------------- + +SchXMLTextListContext::SchXMLTextListContext( + SvXMLImport& rImport + , const OUString& rLocalName + , Sequence< OUString>& rTextList ) + : SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName ) + , m_rTextList( rTextList ) + , m_aTextVector() +{ +} + +SchXMLTextListContext::~SchXMLTextListContext() +{ +} + +void SchXMLTextListContext::StartElement( const Reference< xml::sax::XAttributeList >& /*xAttrList*/ ) +{ +} + +void SchXMLTextListContext::EndElement() +{ + sal_Int32 nCount = m_aTextVector.size(); + m_rTextList.realloc(nCount); + for( sal_Int32 nN=0; nN<nCount; nN++ ) + m_rTextList[nN]=m_aTextVector[nN]; +} + +SvXMLImportContext* SchXMLTextListContext::CreateChildContext( + USHORT nPrefix, const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList >& ) +{ + SvXMLImportContext* pContext = 0; + if( nPrefix == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_LIST_ITEM ) ) + { + m_aTextVector.push_back( OUString() ); + pContext = new SchXMLListItemContext( GetImport(), rLocalName, m_aTextVector.back() ); + } + else + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + return pContext; +} diff --git a/xmloff/source/chart/SchXMLTextListContext.hxx b/xmloff/source/chart/SchXMLTextListContext.hxx new file mode 100755 index 000000000000..736331d10e71 --- /dev/null +++ b/xmloff/source/chart/SchXMLTextListContext.hxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SCH_XMLTEXTLISTCONTEXT_HXX_ +#define _SCH_XMLTEXTLISTCONTEXT_HXX_ + +#include <xmloff/xmlictxt.hxx> +#include "rtl/ustring.hxx" +#include <vector> + +namespace com { namespace sun { namespace star { namespace xml { namespace sax { + class XAttributeList; +}}}}} + +class SchXMLTextListContext : public SvXMLImportContext +{ +public: + SchXMLTextListContext( SvXMLImport& rImport, + const ::rtl::OUString& rLocalName, + ::com::sun::star::uno::Sequence< ::rtl::OUString>& rTextList ); + virtual ~SchXMLTextListContext(); + virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); + virtual void EndElement(); + + virtual SvXMLImportContext* CreateChildContext( + USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList ); + +private: + ::com::sun::star::uno::Sequence< ::rtl::OUString>& m_rTextList; + std::vector< ::rtl::OUString> m_aTextVector; +}; + +#endif // _SCH_XMLTEXTLISTCONTEXT_HXX_ diff --git a/xmloff/source/chart/contexts.cxx b/xmloff/source/chart/contexts.cxx index 14928b697a1b..8d9ba3b7ff26 100644 --- a/xmloff/source/chart/contexts.cxx +++ b/xmloff/source/chart/contexts.cxx @@ -35,13 +35,6 @@ #include "SchXMLImport.hxx" #include "SchXMLCalculationSettingsContext.hxx" -// #ifndef _XMLOFF_XMLCHARTSTYLECONTEXT_HXX_ -// #include "XMLChartStyleContext.hxx" -// #endif -#include <com/sun/star/chart/XChartDocument.hpp> -#include <com/sun/star/chart/XChartDataArray.hpp> -#include <com/sun/star/chart/ChartDataRowSource.hpp> - #include "contexts.hxx" #include "SchXMLChartContext.hxx" diff --git a/xmloff/source/chart/makefile.mk b/xmloff/source/chart/makefile.mk index 33c217e51326..bfdc9aeb5e22 100644 --- a/xmloff/source/chart/makefile.mk +++ b/xmloff/source/chart/makefile.mk @@ -47,6 +47,7 @@ SLOFILES = $(SLO)$/ColorPropertySet.obj \ $(SLO)$/SchXMLChartContext.obj \ $(SLO)$/SchXMLPlotAreaContext.obj \ $(SLO)$/SchXMLParagraphContext.obj \ + $(SLO)$/SchXMLTextListContext.obj \ $(SLO)$/SchXMLSeriesHelper.obj \ $(SLO)$/SchXMLSeries2Context.obj \ $(SLO)$/PropertyMaps.obj \ diff --git a/xmloff/source/chart/transporttypes.hxx b/xmloff/source/chart/transporttypes.hxx index 213f97590c9d..27c8850e2b81 100644 --- a/xmloff/source/chart/transporttypes.hxx +++ b/xmloff/source/chart/transporttypes.hxx @@ -37,17 +37,37 @@ enum SchXMLCellType { SCH_CELL_TYPE_UNKNOWN, SCH_CELL_TYPE_FLOAT, - SCH_CELL_TYPE_STRING + SCH_CELL_TYPE_STRING, + SCH_CELL_TYPE_COMPLEX_STRING }; struct SchXMLCell { rtl::OUString aString; + ::com::sun::star::uno::Sequence< rtl::OUString >* pComplexString; double fValue; SchXMLCellType eType; rtl::OUString aRangeId; - SchXMLCell() : fValue( 0.0 ), eType( SCH_CELL_TYPE_UNKNOWN ) {} + SchXMLCell() : pComplexString(0), fValue( 0.0 ), eType( SCH_CELL_TYPE_UNKNOWN ) + {} + + SchXMLCell( const SchXMLCell& rOther ) + : aString( rOther.aString ) + , pComplexString( rOther.pComplexString ? new ::com::sun::star::uno::Sequence< rtl::OUString >( *rOther.pComplexString ) : 0 ) + , fValue( rOther.fValue ) + , eType( rOther.eType ) + , aRangeId( rOther.aRangeId ) + {} + + ~SchXMLCell() + { + if(pComplexString) + { + delete pComplexString; + pComplexString=0; + } + } }; struct SchXMLTable |