Kaydet (Commit) 4b5214f0 authored tarafından Ingrid Halama's avatar Ingrid Halama

chart50: #i113950# ODF: don't export text:id with bad value

üst 27d42b73
......@@ -1688,20 +1688,16 @@ void SchXMLExportHelper_Impl::exportTable()
{
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
exportText( *aIt );
if( nC < nComplexCount )
lcl_exportComplexLabel( rComplexColumnDescriptions[nC++], mrExport );
if( !bHasOwnData && aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd )
{
// remind the original range to allow a correct re-association when copying via clipboard
if ((*aColumnDescriptions_RangeIter).getLength())
{
mrExport.AddAttributeIdLegacy(XML_NAMESPACE_TEXT,
*aColumnDescriptions_RangeIter);
}
SchXMLTools::exportRangeToSomewhere( mrExport, *aColumnDescriptions_RangeIter );
++aColumnDescriptions_RangeIter;
}
exportText( *aIt );
if( nC < nComplexCount )
lcl_exportComplexLabel( rComplexColumnDescriptions[nC++], mrExport );
}
OSL_ASSERT( bHasOwnData || aColumnDescriptions_RangeIter == aColumnDescriptions_RangeEnd );
} // closing row and header-rows elements
......@@ -1725,17 +1721,15 @@ void SchXMLExportHelper_Impl::exportTable()
SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True );
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 && aRowDescriptions_RangeIter != aRowDescriptions_RangeEnd )
{
mrExport.AddAttributeIdLegacy(XML_NAMESPACE_TEXT,
*aRowDescriptions_RangeIter++);
}
exportText( *aRowDescriptionsIter );
++aRowDescriptionsIter;
if( nC < nComplexCount )
lcl_exportComplexLabel( rComplexRowDescriptions[nC++], mrExport );
if( !bHasOwnData && aRowDescriptions_RangeIter != aRowDescriptions_RangeEnd )
{
// remind the original range to allow a correct re-association when copying via clipboard
SchXMLTools::exportRangeToSomewhere( mrExport, *aRowDescriptions_RangeIter++ );
}
}
}
......@@ -1748,19 +1742,15 @@ void SchXMLExportHelper_Impl::exportTable()
mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT );
mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE, msString );
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
exportText( msString, false ); // do not convert tabs and lfs
if( ( !bHasOwnData && aDataRangeIter != aDataRangeEndIter ) &&
( mbRowSourceColumns || (aColIt == aRowIt->begin())) )
( mbRowSourceColumns || (aColIt == aRowIt->begin()) ) )
{
// remind the original range to allow a correct re-association when copying via clipboard
if ((*aDataRangeIter).getLength())
{
mrExport.AddAttributeIdLegacy(XML_NAMESPACE_TEXT,
*aDataRangeIter);
}
SchXMLTools::exportRangeToSomewhere( mrExport, *aDataRangeIter );
++aDataRangeIter;
}
exportText( msString, false ); // do not convert tabs and lfs
}
}
}
......
......@@ -34,6 +34,7 @@
#include "SchXMLImport.hxx"
#include "SchXMLTools.hxx"
#include "transporttypes.hxx"
#include "XMLStringBufferImportContext.hxx"
#include <tools/debug.hxx>
#include <rtl/math.hxx>
#include "xmlnmspe.hxx"
......@@ -687,6 +688,35 @@ SvXMLImportContext* SchXMLTableRowContext::CreateChildContext(
return pContext;
}
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
class SchXMLRangeSomewhereContext : public SvXMLImportContext
{
//#i113950# previously the range was exported to attribute text:id,
//but that attribute does not allow arbitrary strings anymore
//so we need to find an alternative to save that range info for copy/paste scenario ...
//-> use description at an empty group element for now
private:
::rtl::OUString& mrRangeString;
::rtl::OUStringBuffer maRangeStringBuffer;
public:
SchXMLRangeSomewhereContext( SvXMLImport& rImport,
const ::rtl::OUString& rLocalName,
::rtl::OUString& rRangeString );
virtual ~SchXMLRangeSomewhereContext();
virtual SvXMLImportContext* CreateChildContext(
USHORT nPrefix,
const ::rtl::OUString& rLocalName,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
virtual void EndElement();
};
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
// ========================================
// classes for cells and their content
......@@ -778,11 +808,18 @@ SvXMLImportContext* SchXMLTableCellContext::CreateChildContext(
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
// <text:p> element - read text (and range from text:id old version)
else if( nPrefix == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_P ) )
{
pContext = new SchXMLParagraphContext( GetImport(), rLocalName, maCellContent, &maRangeId );
}
// <draw:g> element - read range
else if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_G ) )
{
//#i113950# previously the range was exported to attribute text:id, but that attribute does not allow arbitrary strings anymore
//so we need to find an alternative to save that range info for copy/paste scenario ... -> use description at an empty group element for now
pContext = new SchXMLRangeSomewhereContext( GetImport(), rLocalName, maRangeId );
}
else
{
pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
......@@ -1148,3 +1185,34 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
}
}
//---------------------------------------------------------------------------------------------------
SchXMLRangeSomewhereContext::SchXMLRangeSomewhereContext( SvXMLImport& rImport,
const OUString& rLocalName,
OUString& rRangeString ) :
SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName ),
mrRangeString( rRangeString )
{
}
SchXMLRangeSomewhereContext::~SchXMLRangeSomewhereContext()
{
}
SvXMLImportContext* SchXMLRangeSomewhereContext::CreateChildContext(
USHORT nPrefix,
const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList >& )
{
if( XML_NAMESPACE_SVG == nPrefix && IsXMLToken( rLocalName, XML_DESC ) )
{
return new XMLStringBufferImportContext(
GetImport(), nPrefix, rLocalName, maRangeStringBuffer );
}
return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
}
void SchXMLRangeSomewhereContext::EndElement()
{
mrRangeString = maRangeStringBuffer.makeStringAndClear();
}
......@@ -600,6 +600,29 @@ void exportText( SvXMLExport& rExport, const OUString& rText, bool bConvertTabsL
}
}
void exportRangeToSomewhere( SvXMLExport& rExport, const ::rtl::OUString& rValue )
{
//with issue #i366# and CWS chart20 ranges for error bars were introduced
//to keep them during copy paste from calc to impress for example it
//was necessary to introduce a mapping between the used ranges within calc and the data written to the local table
//this is why we write this ranges here
//#i113950# first the range was exported to attribute text:id, but that attribute does not allow arbitrary strings anymore within ODF 1.2
//as an alternative the range info is now saved into the description at an empty group element (not very nice, but ODF conform)
const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
if( nCurrentODFVersion == SvtSaveOptions::ODFVER_010 || nCurrentODFVersion == SvtSaveOptions::ODFVER_011 )
return;//svg:desc is not allowed at draw:g in ODF1.0; but as the ranges for error bars are anyhow not allowed within ODF1.0 nor ODF1.1 we do not need the information
SvXMLElementExport aEmptyShapeGroup( rExport, XML_NAMESPACE_DRAW,
::xmloff::token::GetXMLToken( ::xmloff::token::XML_G ),
sal_True, sal_False );
SvXMLElementExport aDescription( rExport, XML_NAMESPACE_SVG,
::xmloff::token::GetXMLToken( ::xmloff::token::XML_DESC ),
sal_True, sal_False );
rExport.GetDocHandler()->characters( rValue );
}
Reference< chart2::XRegressionCurve > getRegressionCurve(
const Reference< chart2::XDataSeries > & xDataSeries )
{
......
......@@ -105,6 +105,8 @@ namespace SchXMLTools
void exportText( SvXMLExport& rExport, const ::rtl::OUString& rText, bool bConvertTabsLFs );
void exportRangeToSomewhere( SvXMLExport& rExport, const ::rtl::OUString& rValue );
/** returns the properties of the equation of the first regression curve
that is no mean-value line
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment