kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone
Blob Blame History Raw
From c76daf9b5f1efc44eaf6541314f122d641c791cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mat=C3=BA=C5=A1=20Kukan?= <matus.kukan@collabora.com>
Date: Tue, 29 Jul 2014 07:53:22 +0200
Subject: [PATCH 091/137] bnc#862510: PPTX import: Properly show data labels in
 percent format.

Usually, "General" is "0.00" number format, but in this case, when we
want to show percent value, MSO writes that instead of "0%".

Change-Id: I748719765f58e66f9f3fb43c2b527c6823ef6fa1
(cherry picked from commit 5f47e319428a703ea53ce49d166e7628aaa60789)
Reviewed-on: https://gerrit.libreoffice.org/10781
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
---
 oox/source/drawingml/chart/objectformatter.cxx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx
index b5b0a5b..8e91941 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -1113,9 +1113,12 @@ void ObjectFormatter::convertNumberFormat( PropertySet& rPropSet, const NumberFo
         sal_Int32 nPropId = bPercentFormat ? PROP_PercentageNumberFormat : PROP_NumberFormat;
         try
         {
-            sal_Int32 nIndex = rNumberFormat.maFormatCode.equalsIgnoreAsciiCase("general") ?
+            bool bGeneral = rNumberFormat.maFormatCode.equalsIgnoreAsciiCase("general");
+            sal_Int32 nIndex = bGeneral && !bPercentFormat ?
                 mxData->mxNumTypes->getStandardIndex( mxData->maFromLocale ) :
-                mxData->mxNumFmts->addNewConverted( rNumberFormat.maFormatCode, mxData->maEnUsLocale, mxData->maFromLocale );
+                mxData->mxNumFmts->addNewConverted(
+                        bGeneral ? OUString("0%") : rNumberFormat.maFormatCode,
+                        mxData->maEnUsLocale, mxData->maFromLocale );
             if( nIndex >= 0 )
                 rPropSet.setProperty( nPropId, nIndex );
         }
-- 
1.9.3