diff options
author | Björn Milcke <bm@openoffice.org> | 2001-10-23 09:02:41 +0000 |
---|---|---|
committer | Björn Milcke <bm@openoffice.org> | 2001-10-23 09:02:41 +0000 |
commit | 1ffe0d5c974fdae9d46587f40a69d28810a72b42 (patch) | |
tree | c50871543065226d2f6d4da3b4c71bc6740bfdc5 /xmloff/source | |
parent | f5d2e3a1ce722b838892b089d6a7f4234ffd3f61 (diff) |
#93509# series rearrangement: new attributes column-mapping / row-mapping for chart element
Diffstat (limited to 'xmloff/source')
-rw-r--r-- | xmloff/source/chart/SchXMLChartContext.cxx | 68 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLChartContext.hxx | 8 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLExport.cxx | 55 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLImport.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/core/xmltoken.cxx | 7 |
5 files changed, 130 insertions, 14 deletions
diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index 01c861e554db..112283cac2c4 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: SchXMLChartContext.cxx,v $ * - * $Revision: 1.25 $ + * $Revision: 1.26 $ * - * last change: $Author: bm $ $Date: 2001-10-22 10:38:33 $ + * last change: $Author: bm $ $Date: 2001-10-23 10:02:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -91,6 +91,8 @@ #include "prstylei.hxx" #endif +#include "vector" + #ifndef _COM_SUN_STAR_CHART_XCHARTDOCUMENT_HPP_ #include <com/sun/star/chart/XChartDocument.hpp> #endif @@ -275,6 +277,13 @@ void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttribut case XML_TOK_CHART_ADDIN_NAME: aServiceName = aValue; break; + + case XML_TOK_CHART_COL_MAPPING: + msColTrans = aValue; + break; + case XML_TOK_CHART_ROW_MAPPING: + msRowTrans = aValue; + break; } } @@ -471,6 +480,22 @@ void SchXMLChartContext::EndElement() xProp->setPropertyValue( rtl::OUString::createFromAscii( "SeriesAddresses" ), aAny ); } } + + // row / col translations + bool bHasColTrans = (msColTrans.getLength() > 0); + bool bHasRowTrans = (msRowTrans.getLength() > 0); + if( bHasColTrans ) + { + uno::Sequence< sal_Int32 > aSeq = GetNumberSequenceFromString( msColTrans ); + aAny <<= aSeq; + xProp->setPropertyValue( ::rtl::OUString::createFromAscii( "TranslatedColumns" ), aAny ); + } + else if( bHasRowTrans ) + { + uno::Sequence< sal_Int32 > aSeq = GetNumberSequenceFromString( msRowTrans ); + aAny <<= aSeq; + xProp->setPropertyValue( ::rtl::OUString::createFromAscii( "TranslatedRows" ), aAny ); + } } catch( beans::UnknownPropertyException ) { @@ -744,6 +769,41 @@ void SchXMLChartContext::InitChart (awt::Size aChartSize, xModel->unlockControllers(); } +uno::Sequence< sal_Int32 > SchXMLChartContext::GetNumberSequenceFromString( const ::rtl::OUString& rStr ) +{ + const sal_Unicode aSpace( ' ' ); + + // count number of entries + ::std::vector< sal_Int32 > aVec; + sal_Int32 nLastPos = 0; + sal_Int32 nPos = 0; + const sal_Int32 nSize = rStr.getLength(); + while( nPos != -1 ) + { + nPos = rStr.indexOf( aSpace, nLastPos ); + if( nPos > nLastPos ) + { + aVec.push_back( rStr.copy( nLastPos, (nPos - nLastPos) ).toInt32() ); + } + if( nPos != -1 ) + nLastPos = nPos + 1; + } + // last entry + if( nLastPos != 0 && + rStr.getLength() > nLastPos ) + { + aVec.push_back( rStr.copy( nLastPos, (rStr.getLength() - nLastPos) ).toInt32() ); + } + + const sal_Int32 nVecSize = aVec.size(); + uno::Sequence< sal_Int32 > aSeq( nVecSize ); + sal_Int32* pSeqArr = aSeq.getArray(); + for( nPos = 0; nPos < nVecSize; ++nPos ) + { + pSeqArr[ nPos ] = aVec[ nPos ]; + } + return aSeq; +} // ---------------------------------------- @@ -942,7 +1002,3 @@ void SchXMLLegendContext::StartElement( const uno::Reference< xml::sax::XAttribu SchXMLLegendContext::~SchXMLLegendContext() { } - - - - diff --git a/xmloff/source/chart/SchXMLChartContext.hxx b/xmloff/source/chart/SchXMLChartContext.hxx index 2ca6dabeb3f2..d9156f1f211c 100644 --- a/xmloff/source/chart/SchXMLChartContext.hxx +++ b/xmloff/source/chart/SchXMLChartContext.hxx @@ -2,9 +2,9 @@ * * $RCSfile: SchXMLChartContext.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: bm $ $Date: 2001-09-28 14:56:18 $ + * last change: $Author: bm $ $Date: 2001-10-23 10:02:41 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -112,6 +112,10 @@ private: ::rtl::OUString msTableNumberList; ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mxDrawPage; + ::rtl::OUString msColTrans; + ::rtl::OUString msRowTrans; + + ::com::sun::star::uno::Sequence< sal_Int32 > GetNumberSequenceFromString( const ::rtl::OUString& rStr ); public: SchXMLChartContext( SchXMLImportHelper& rImpHelper, diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index cf929a1fa6d0..94f493effde2 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -2,9 +2,9 @@ * * $RCSfile: SchXMLExport.cxx,v $ * - * $Revision: 1.58 $ + * $Revision: 1.59 $ * - * last change: $Author: bm $ $Date: 2001-09-28 14:56:18 $ + * last change: $Author: bm $ $Date: 2001-10-23 10:00:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -445,6 +445,57 @@ void SchXMLExportHelper::parseDocument( uno::Reference< chart::XChartDocument >& if( sAddInName.getLength()) mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ADD_IN_NAME, sAddInName ); + + // translated rows/columns + if( xDocPropSet.is()) + { + sal_Bool bTranslate = sal_False; + ::rtl::OUString aTransPropName; + enum XMLTokenEnum eTransToken; + + uno::Any aAny = xDocPropSet->getPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HasTranslatedColumns" ))); + aAny >>= bTranslate; + if( bTranslate ) + { + aTransPropName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TranslatedColumns" )); + eTransToken = ::xmloff::token::XML_COLUMN_MAPPING; + } + else + { + aAny = xDocPropSet->getPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HasTranslatedRows" ))); + aAny >>= bTranslate; + if( bTranslate ) + { + aTransPropName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TranslatedRows" )); + eTransToken = ::xmloff::token::XML_ROW_MAPPING; + } + } + + if( bTranslate ) + { + uno::Sequence< sal_Int32 > aSeq; + aAny = xDocPropSet->getPropertyValue( aTransPropName ); + if( aAny >>= aSeq ) + { + const sal_Int32* pArray = aSeq.getConstArray(); + const sal_Int32 nSize = aSeq.getLength(); + sal_Int32 i = 0; + ::rtl::OUStringBuffer aBuf; + for( i = 0; i < nSize; ++i ) + { + aBuf.append( pArray[ i ], 10 ); + if( i != (nSize - 1)) + aBuf.append( static_cast< sal_Unicode >( ' ' )); + } + + mrExport.AddAttribute( XML_NAMESPACE_CHART, + ::xmloff::token::GetXMLToken( eTransToken ), + aBuf.makeStringAndClear() ); + } + } + } } // write style name AddAutoStyleAttribute( aPropertyStates ); diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx index e4c23fbaa92c..eddaa1267646 100644 --- a/xmloff/source/chart/SchXMLImport.cxx +++ b/xmloff/source/chart/SchXMLImport.cxx @@ -2,9 +2,9 @@ * * $RCSfile: SchXMLImport.cxx,v $ * - * $Revision: 1.23 $ + * $Revision: 1.24 $ * - * last change: $Author: bm $ $Date: 2001-09-14 11:21:05 $ + * last change: $Author: bm $ $Date: 2001-10-23 09:58:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -175,6 +175,8 @@ static __FAR_DATA SvXMLTokenMapEntry aChartAttrTokenMap[] = { XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_CHART_HEIGHT }, { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_CHART_STYLE_NAME }, { XML_NAMESPACE_CHART, XML_ADD_IN_NAME, XML_TOK_CHART_ADDIN_NAME }, + { XML_NAMESPACE_CHART, XML_COLUMN_MAPPING, XML_TOK_CHART_COL_MAPPING }, + { XML_NAMESPACE_CHART, XML_ROW_MAPPING, XML_TOK_CHART_ROW_MAPPING }, XML_TOKEN_MAP_END }; diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 31ea5c6cf7d4..2862f6e7569f 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltoken.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: dvo $ $Date: 2001-09-21 16:27:53 $ + * last change: $Author: bm $ $Date: 2001-10-23 09:59:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -2074,6 +2074,9 @@ namespace xmloff { namespace token { TOKEN( "spline-resolution" ), // XML_SPLINE_RESOLUTION TOKEN( "paper-tray-name" ), // XML_PAPER_TRAY_NAME + TOKEN( "column-mapping" ), // XML_COLUMN_MAPPING + TOKEN( "row-mapping" ), // XML_ROW_MAPPING + { 0, NULL, NULL } // XML_TOKEN_END }; |