[Libreoffice-commits] core.git: 2 commits - xmloff/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Sat Jun 29 19:03:46 PDT 2013
xmloff/source/chart/SchXMLChartContext.cxx | 4
xmloff/source/chart/SchXMLTableContext.cxx | 150 +++++------------------------
xmloff/source/chart/SchXMLTableContext.hxx | 5
3 files changed, 36 insertions(+), 123 deletions(-)
New commits:
commit 1ca3beae12a7f222c987481e07a544845fc9fd46
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Jun 30 03:57:14 2013 +0200
remove all my debug code
This should never have been pushed.
Change-Id: Ida67b0716a916cb7c3b9af7430abc51800414f18
diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx
index 7ffce59..ffc0e3bb 100644
--- a/xmloff/source/chart/SchXMLTableContext.cxx
+++ b/xmloff/source/chart/SchXMLTableContext.cxx
@@ -55,90 +55,6 @@ using namespace ::xmloff::token;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Reference;
-#define DEBUG_CHART_FILTER 1
-
-#if DEBUG_CHART_FILTER
-#include <iostream>
-#endif
-
-namespace {
-
-std::ostream& operator<<(std::ostream& str, const uno::Any& aAny)
-{
- OUString aString;
- double aValue;
- bool bVal;
- if(aAny >>= aString)
- {
- str << aString;
- }
- else if(aAny >>= aValue)
- {
- str << aValue;
- }
- else if(aAny >>= bVal)
- {
- str << bVal;
- }
- else
- {
- str << "Unknown data in Any";
- }
-
- return str;
-}
-
-template<typename T>
-std::ostream& operator<<(std::ostream& str, const Sequence<T>& seq)
-{
- for(sal_Int32 i = 0; i < seq.getLength(); ++i)
- {
- str << seq[i] << " ";
- }
-
- return str;
-}
-
-std::ostream& operator<<(std::ostream& str, const SchXMLCell& rCell )
-{
- switch(rCell.eType)
- {
- case SCH_CELL_TYPE_FLOAT:
- str << rCell.fValue;
- break;
- case SCH_CELL_TYPE_STRING:
- str << rCell.aString;
- break;
- case SCH_CELL_TYPE_COMPLEX_STRING:
- str << "Complex String";
- break;
- default:
- str << "Unknown Type";
- break;
- }
-
- return str;
-}
-
-std::ostream& operator<<(std::ostream& str, const SchXMLTable& rTable )
-{
- for(size_t i = 0; i < rTable.aData.size(); ++i)
- {
- str << "Row " << i << std::endl;
- for(size_t j = 0; j < rTable.aData[i].size(); ++j)
- {
- str << rTable.aData[i][j] << " ";
- }
- str << std::endl;
- }
-
- return str;
-}
-
-}
-
-#endif
-
namespace
{
@@ -999,31 +915,11 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
Reference< chart2::data::XDataProvider > xDataProv( xChartDoc->getDataProvider());
-#if DEBUG_CHART_FILTER
-
- if( eDataRowSource == chart::ChartDataRowSource_COLUMNS )
- {
- std::cout << "data in Columns" << std::endl;
- }
- else
- {
- std::cout << "data in rows" << std::endl;
- }
-
-#endif
-
// create a mapping from original ranges to new ranges
lcl_tOriginalRangeToInternalRangeMap aRangeMap;
lcl_fillRangeMapping( rTable, aRangeMap, eDataRowSource );
-#if DEBUG_CHART_FILTER
- std::cout << "Start Table" << std::endl;
- std::cout << rTable << std::endl;
- std::cout << "EndTable" << std::endl;
-
-#endif
-
const OUString lcl_aCategoriesRange(aCategoriesRange);
bool bCategoriesApplied = false;
@@ -1039,13 +935,6 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
{
Reference< chart2::data::XDataSequence > xSeq( aLSeqIt->second->getValues());
-#if DEBUG_CHART_FILTER
- std::cout << "Old Data Sequence" << std::endl;
- std::cout << "Source Range Representation: " << xSeq->getSourceRangeRepresentation() <<std::endl;
- std::cout << "Data: " << xSeq->getData() << std::endl;
- std::cout << "Old Data Sequence End" << std::endl;
-#endif
-
OUString aRange;
if( xSeq.is() &&
SchXMLTools::getXMLRangePropertyFromDataSequence( xSeq, aRange, /* bClearProp = */ true ) &&
@@ -1058,13 +947,6 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
Reference< beans::XPropertySet >( xNewSeq, uno::UNO_QUERY ));
aLSeqIt->second->setValues( xNewSeq );
-
-#if DEBUG_CHART_FILTER
- std::cout << "Data Sequence" << std::endl;
- std::cout << "Source Range Representation: " << xNewSeq->getSourceRangeRepresentation() <<std::endl;
- std::cout << "Data: " << xNewSeq->getData() << std::endl;
- std::cout << "Data Sequence End" << std::endl;
-#endif
}
}
else
commit 14fa5488a829936275f79a7693b13da55114220e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Jun 30 03:44:05 2013 +0200
transpose "data in rows" ranges for internal data provider, fdo#62057
This is an ugly hack but it at least works. This regression has been
introduced by the merge from the AOO code. The order of calls during
import is totally screwed and I have no idea how to properly fix all
these problems without introducing new regressions.
The best solution would be to move the import/export code into chart2
where we could manipulate tese properties directly and would not need to
transform the same information N times until it is written into the
chart code.
Change-Id: Id53c49441c683b19a973a48884135a3f4e89de03
diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx
index 8c6aff2..f45b210 100644
--- a/xmloff/source/chart/SchXMLChartContext.cxx
+++ b/xmloff/source/chart/SchXMLChartContext.cxx
@@ -788,7 +788,7 @@ void SchXMLChartContext::EndElement()
//own data or only rectangular range available
if( xNewDoc->hasInternalDataProvider() )
- SchXMLTableHelper::applyTableToInternalDataProvider( maTable, xNewDoc );
+ SchXMLTableHelper::applyTableToInternalDataProvider( maTable, xNewDoc, meDataRowSource );
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.
@@ -825,7 +825,7 @@ void SchXMLChartContext::EndElement()
if( !xNewDoc->hasInternalDataProvider() )
{
xNewDoc->createInternalDataProvider( sal_False /* bCloneExistingData */ );
- SchXMLTableHelper::applyTableToInternalDataProvider( maTable, xNewDoc );
+ SchXMLTableHelper::applyTableToInternalDataProvider( maTable, xNewDoc, meDataRowSource );
try
{
lcl_ApplyDataFromRectangularRangeToDiagram( xNewDoc, msChartAddress, meDataRowSource, mbRowHasLabels, mbColHasLabels, bHasOwnData, msColTrans, msRowTrans );
diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx
index 4834767..7ffce59 100644
--- a/xmloff/source/chart/SchXMLTableContext.cxx
+++ b/xmloff/source/chart/SchXMLTableContext.cxx
@@ -59,6 +59,7 @@ using ::com::sun::star::uno::Reference;
#if DEBUG_CHART_FILTER
#include <iostream>
+#endif
namespace {
@@ -858,9 +859,35 @@ static void lcl_ApplyCellToComplexLabel( const SchXMLCell& rCell, Sequence< uno:
}
}
+namespace {
+
+void transposeTable(SchXMLTable& rTable)
+{
+ std::vector<std::vector<SchXMLCell> > aNewData;
+ sal_Int32 nRows = rTable.aData.size();
+ aNewData.resize(rTable.nMaxColumnIndex+1);
+ for(sal_Int32 i = 0; i < nRows; ++i)
+ {
+ sal_Int32 nCols = rTable.aData[i].size();
+ for(sal_Int32 j = 0; j < nCols; ++j)
+ {
+ SchXMLCell& rCell = rTable.aData[i][j];
+ aNewData[j].push_back(rCell);
+ }
+ }
+ bool bHasRowHeader = rTable.bHasHeaderRow;
+ bool bHasColHeader = rTable.bHasHeaderColumn;
+ rTable.bHasHeaderColumn = bHasRowHeader;
+ rTable.bHasHeaderRow = bHasColHeader;
+ rTable.nMaxColumnIndex = nRows;
+ rTable.aData = aNewData;
+}
+
+}
+
void SchXMLTableHelper::applyTableToInternalDataProvider(
- const SchXMLTable& rTable,
- uno::Reference< chart2::XChartDocument > xChartDoc )
+ SchXMLTable rTable,
+ uno::Reference< chart2::XChartDocument > xChartDoc, chart::ChartDataRowSource eDataRowSource )
{
// apply all data read from the local table to the internal data provider
if( !xChartDoc.is() || !xChartDoc->hasInternalDataProvider() )
@@ -869,6 +896,9 @@ void SchXMLTableHelper::applyTableToInternalDataProvider(
if( !xDataProv.is() )
return;
+ if(eDataRowSource == chart::ChartDataRowSource_ROWS)
+ transposeTable(rTable);
+
//prepare the read local table data
sal_Int32 nNumRows( static_cast< sal_Int32 >( rTable.aData.size()));
sal_Int32 nRowOffset = 0;
diff --git a/xmloff/source/chart/SchXMLTableContext.hxx b/xmloff/source/chart/SchXMLTableContext.hxx
index 20b87b5..864fa4e 100644
--- a/xmloff/source/chart/SchXMLTableContext.hxx
+++ b/xmloff/source/chart/SchXMLTableContext.hxx
@@ -77,8 +77,9 @@ private:
sal_Int32& nRows, sal_Int32& nColumns );
public:
- static void applyTableToInternalDataProvider( const SchXMLTable& rTable,
- com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc );
+ static void applyTableToInternalDataProvider( SchXMLTable rTable,
+ com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc,
+ com::sun::star::chart::ChartDataRowSource eDataRowSource );
/** This function reorders local data to fit the correct data structure.
Call it after the data series got their styles set.
More information about the Libreoffice-commits
mailing list