summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2015-07-31 22:14:41 +0200
committerAndras Timar <andras.timar@collabora.com>2015-10-07 09:07:48 +0000
commitd52d448e7b34cb8c2457948489e6691049f4a571 (patch)
tree81cd0bb8391d32a243229c87f97ba4fb2ffd92d3 /oox
parent6dd8193524a8a0208d7b424e396095f8e409cbc5 (diff)
tdf#88154 workaround and unit test
Fixed 45-degree layout for axis labels, too. Change-Id: I9764e281aeee0a439fa9eec1e3b0df840221b72f Reviewed-on: https://gerrit.libreoffice.org/18889 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/drawingml/chart/datasourcecontext.hxx5
-rw-r--r--oox/source/drawingml/chart/datasourcecontext.cxx62
2 files changed, 65 insertions, 2 deletions
diff --git a/oox/inc/drawingml/chart/datasourcecontext.hxx b/oox/inc/drawingml/chart/datasourcecontext.hxx
index 82aa38e2f2ac..ef3298c89fde 100644
--- a/oox/inc/drawingml/chart/datasourcecontext.hxx
+++ b/oox/inc/drawingml/chart/datasourcecontext.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_OOX_DRAWINGML_CHART_DATASOURCECONTEXT_HXX
#include <drawingml/chart/chartcontextbase.hxx>
+#include <svl/zforlist.hxx>
namespace oox {
namespace drawingml {
@@ -46,7 +47,11 @@ public:
virtual void onCharacters( const OUString& rChars ) SAL_OVERRIDE;
private:
+ SvNumberFormatter* getNumberFormatter();
+
+private:
sal_Int32 mnPtIndex; /// Current data point index.
+ SvNumberFormatter* mpNumberFormatter;
};
diff --git a/oox/source/drawingml/chart/datasourcecontext.cxx b/oox/source/drawingml/chart/datasourcecontext.cxx
index 946b5bdb00d1..10ac7c652015 100644
--- a/oox/source/drawingml/chart/datasourcecontext.cxx
+++ b/oox/source/drawingml/chart/datasourcecontext.cxx
@@ -21,6 +21,9 @@
#include "oox/drawingml/chart/datasourcemodel.hxx"
+#include <comphelper/processfactory.hxx>
+#include <oox/core/xmlfilterbase.hxx>
+#include <svl/zforlist.hxx>
#include <osl/diagnose.h>
namespace oox {
@@ -30,14 +33,21 @@ namespace chart {
using ::oox::core::ContextHandler2Helper;
using ::oox::core::ContextHandlerRef;
+using namespace ::com::sun::star;
+
DoubleSequenceContext::DoubleSequenceContext( ContextHandler2Helper& rParent, DataSequenceModel& rModel ) :
DataSequenceContextBase( rParent, rModel ),
- mnPtIndex( -1 )
+ mnPtIndex( -1 ),
+ mpNumberFormatter( NULL )
{
}
DoubleSequenceContext::~DoubleSequenceContext()
{
+ if( mpNumberFormatter != NULL )
+ {
+ delete mpNumberFormatter;
+ }
}
ContextHandlerRef DoubleSequenceContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
@@ -98,14 +108,62 @@ void DoubleSequenceContext::onCharacters( const OUString& rChars )
* TODO: NumberFormat conversion, remove the check then.
*/
if( isParentElement( C_TOKEN( cat ), 4 ) )
- mrModel.maData[ mnPtIndex ] <<= rChars;
+ {
+ // workaround for bug n#889755
+ SvNumberFormatter* pNumFrmt = getNumberFormatter();
+ if( pNumFrmt )
+ {
+ sal_uInt32 nKey = pNumFrmt->GetEntryKey( mrModel.maFormatCode );
+ bool bNoKey = ( nKey == NUMBERFORMAT_ENTRY_NOT_FOUND );
+ if( bNoKey )
+ {
+ OUString aFormatCode = mrModel.maFormatCode;
+ sal_Int32 nCheckPos = 0;
+ short nType;
+ pNumFrmt->PutEntry( aFormatCode, nCheckPos, nType, nKey );
+ bNoKey = (nCheckPos != 0);
+ }
+ if( bNoKey )
+ {
+ mrModel.maData[ mnPtIndex ] <<= rChars;
+ }
+ else
+ {
+ double fValue = rChars.toDouble();
+ Color* pColor = NULL;
+ OUString aFormattedValue;
+ pNumFrmt->GetOutputString( fValue, nKey, aFormattedValue, &pColor );
+ mrModel.maData[ mnPtIndex ] <<= aFormattedValue;
+ }
+ }
+ else
+ {
+ mrModel.maData[ mnPtIndex ] <<= rChars;
+ }
+ }
else
+ {
mrModel.maData[ mnPtIndex ] <<= rChars.toDouble();
+ }
}
break;
}
}
+
+SvNumberFormatter* DoubleSequenceContext::getNumberFormatter()
+{
+ if( mpNumberFormatter == NULL )
+ {
+ uno::Reference<uno::XComponentContext> rContext =
+ this->getFilter().getComponentContext();
+ mpNumberFormatter =
+ new SvNumberFormatter(rContext, LANGUAGE_DONTKNOW);
+ }
+ return mpNumberFormatter;
+}
+
+
StringSequenceContext::StringSequenceContext( ContextHandler2Helper& rParent, DataSequenceModel& rModel )
: DataSequenceContextBase( rParent, rModel )
, mnPtIndex(-1)