[Libreoffice-commits] core.git: 3 commits - include/xmloff sc/inc sc/source xmloff/source

Markus Mohrhard markus.mohrhard at googlemail.com
Tue Mar 24 08:09:57 PDT 2015


 include/xmloff/xmltoken.hxx               |    2 ++
 sc/inc/colorscale.hxx                     |   14 ++++++++++++++
 sc/source/core/data/colorscale.cxx        |    8 +++++---
 sc/source/filter/excel/xecontent.cxx      |    6 +++++-
 sc/source/filter/oox/condformatbuffer.cxx |    2 ++
 sc/source/filter/xml/xmlcondformat.cxx    |   22 ++++++++++++++++++++++
 sc/source/filter/xml/xmlexprt.cxx         |    6 ++++++
 sc/source/filter/xml/xmlimprt.cxx         |    2 ++
 sc/source/filter/xml/xmlimprt.hxx         |    4 +++-
 xmloff/source/core/xmltoken.cxx           |    2 ++
 10 files changed, 63 insertions(+), 5 deletions(-)

New commits:
commit 849c1b64de19ef42cbd8cd392b036b9f914f2522
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Mar 24 15:58:33 2015 +0100

    also import and export to ODF the new databar property
    
    Change-Id: Ib29a0d5c9fefe15fbd0f08a5cf9600eff58cd030

diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index d1d39a7..2527a8f 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -1176,6 +1176,7 @@ namespace xmloff { namespace token {
         XML_MAX,
         XML_MAX_EDGE,
         XML_MAX_HEIGHT,
+        XML_MAX_LENGTH,
         XML_MAX_WIDTH,
         XML_MAXIMUM,
         XML_MAXIMUM_DIFFERENCE,
@@ -1205,6 +1206,7 @@ namespace xmloff { namespace token {
         XML_MIN_INTEGER_DIGITS,
         XML_MIN_LABEL_DISTANCE,
         XML_MIN_LABEL_WIDTH,
+        XML_MIN_LENGTH,
         XML_MIN_LINE_HEIGHT,
         XML_MIN_NUMERATOR_DIGITS,
         XML_MIN_ROW_HEIGHT,
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index 911f5c0..4f067cb 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -180,6 +180,8 @@ ScXMLDataBarFormatContext::ScXMLDataBarFormatContext( ScXMLImport& rImport, sal_
     OUString sAxisPosition;
     OUString sShowValue;
     OUString sAxisColor;
+    OUString sMinLength;
+    OUString sMaxLength;
 
     sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataBarAttrMap();
@@ -211,6 +213,12 @@ ScXMLDataBarFormatContext::ScXMLDataBarFormatContext( ScXMLImport& rImport, sal_
             case XML_TOK_DATABAR_AXISCOLOR:
                 sAxisColor = sValue;
                 break;
+            case XML_TOK_DATABAR_MINLENGTH:
+                sMinLength = sValue;
+                break;
+            case XML_TOK_DATABAR_MAXLENGTH:
+                sMaxLength = sValue;
+                break;
             default:
                 break;
         }
@@ -265,6 +273,20 @@ ScXMLDataBarFormatContext::ScXMLDataBarFormatContext( ScXMLImport& rImport, sal_
         mpFormatData->mbOnlyBar = !bShowValue;
     }
 
+    if (!sMinLength.isEmpty())
+    {
+        double nVal = sMinLength.toDouble();
+        mpFormatData->mnMinLength = nVal;
+    }
+
+    if (!sMaxLength.isEmpty())
+    {
+        double nVal = sMaxLength.toDouble();
+        if (nVal == 0.0)
+            nVal = 100.0;
+        mpFormatData->mnMaxLength = nVal;
+    }
+
     pFormat->AddEntry(mpDataBarFormat);
 }
 
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index e6d7e3d..e1087dd 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -4454,6 +4454,12 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
                         if(pFormatData->mbOnlyBar)
                             AddAttribute(XML_NAMESPACE_CALC_EXT, XML_SHOW_VALUE, XML_FALSE);
 
+                        if (pFormatData->mnMinLength != 0.0)
+                            AddAttribute(XML_NAMESPACE_CALC_EXT, XML_MIN_LENGTH, OUString::number(pFormatData->mnMinLength));
+
+                        if (pFormatData->mnMaxLength != 0.0)
+                            AddAttribute(XML_NAMESPACE_CALC_EXT, XML_MAX_LENGTH, OUString::number(pFormatData->mnMaxLength));
+
                         if(pFormatData->mbNeg)
                         {
                             if(pFormatData->mpNegativeColor)
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 8930c36..25dd3db 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -720,6 +720,8 @@ const SvXMLTokenMap& ScXMLImport::GetDataBarAttrMap()
             { XML_NAMESPACE_CALC_EXT, XML_AXIS_POSITION, XML_TOK_DATABAR_AXISPOSITION },
             { XML_NAMESPACE_CALC_EXT, XML_SHOW_VALUE, XML_TOK_DATABAR_SHOWVALUE },
             { XML_NAMESPACE_CALC_EXT, XML_AXIS_COLOR, XML_TOK_DATABAR_AXISCOLOR },
+            { XML_NAMESPACE_CALC_EXT, XML_MIN_LENGTH, XML_TOK_DATABAR_MINLENGTH },
+            { XML_NAMESPACE_CALC_EXT, XML_MAX_LENGTH, XML_TOK_DATABAR_MAXLENGTH },
             XML_TOKEN_MAP_END
         };
 
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 09adfac..479bedf 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -211,7 +211,9 @@ enum ScXMLDataBarAttrTokens
     XML_TOK_DATABAR_GRADIENT,
     XML_TOK_DATABAR_AXISPOSITION,
     XML_TOK_DATABAR_SHOWVALUE,
-    XML_TOK_DATABAR_AXISCOLOR
+    XML_TOK_DATABAR_AXISCOLOR,
+    XML_TOK_DATABAR_MINLENGTH,
+    XML_TOK_DATABAR_MAXLENGTH
 };
 
 enum ScXMLDataBarEntryAttrTokens
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 0a1835b..faefa0e 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -1181,6 +1181,7 @@ namespace xmloff { namespace token {
         TOKEN( "max",                             XML_MAX ),
         TOKEN( "max-edge",                        XML_MAX_EDGE ),
         TOKEN( "max-height",                      XML_MAX_HEIGHT ),
+        TOKEN( "max-length",                      XML_MAX_LENGTH ),
         TOKEN( "max-width",                       XML_MAX_WIDTH ),
         TOKEN( "maximum",                         XML_MAXIMUM ),
         TOKEN( "maximum-difference",              XML_MAXIMUM_DIFFERENCE ),
@@ -1210,6 +1211,7 @@ namespace xmloff { namespace token {
         TOKEN( "min-integer-digits",              XML_MIN_INTEGER_DIGITS ),
         TOKEN( "min-label-distance",              XML_MIN_LABEL_DISTANCE ),
         TOKEN( "min-label-width",                 XML_MIN_LABEL_WIDTH ),
+        TOKEN( "min-length",                      XML_MIN_LENGTH ),
         TOKEN( "min-line-height",                 XML_MIN_LINE_HEIGHT ),
         TOKEN( "min-numerator-digits",            XML_MIN_NUMERATOR_DIGITS ),
         TOKEN( "min-row-height",                  XML_MIN_ROW_HEIGHT ),
commit 7d1fa5fb8ef2067c406eadbdfb0dbca37d4627bf
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Mar 24 14:42:36 2015 +0100

    add minLength and maxLength support to databars
    
    Change-Id: Idbbc4b64b616ead6ef880340064623b9a5c0ff51

diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 06c3c80..5b6f6e5 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -101,6 +101,8 @@ struct SC_DLLPUBLIC ScDataBarFormatData
         mbGradient(true),
         mbNeg(true),
         meAxisPosition(databar::AUTOMATIC),
+        mnMinLength(0),
+        mnMaxLength(100),
         mbOnlyBar(false){}
 
     ScDataBarFormatData(const ScDataBarFormatData& r):
@@ -109,6 +111,8 @@ struct SC_DLLPUBLIC ScDataBarFormatData
         mbGradient(r.mbGradient),
         mbNeg(r.mbNeg),
         meAxisPosition(r.meAxisPosition),
+        mnMinLength(r.mnMinLength),
+        mnMaxLength(r.mnMaxLength),
         mbOnlyBar(r.mbOnlyBar)
     {
         if(r.mpNegativeColor)
@@ -157,6 +161,16 @@ struct SC_DLLPUBLIC ScDataBarFormatData
      * Default is false
      */
     databar::ScAxisPosition meAxisPosition;
+    /**
+     * Minimal length of a databar in percent of cell length
+     * Value has to be in the range [0, 100)
+     */
+    double mnMinLength;
+    /**
+     * Maximal length of a databar in percent of cell length
+     * Value has to be in the range (0, 100]
+     */
+    double mnMaxLength;
 
     /**
      * If TRUE we only show the bar and not the value
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 9de8919..f567563 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -838,6 +838,8 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
     double nValMax = getMaxValue();
     double nMin = getMin(nValMin, nValMax);
     double nMax = getMax(nValMin, nValMax);
+    double nMinLength = mpFormatData->mnMinLength;
+    double nMaxLength = mpFormatData->mnMaxLength;
 
     double nValue = mpDoc->GetValue(rAddr);
 
@@ -846,16 +848,16 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
     {
         if(nValue <= nMin)
         {
-            pInfo->mnLength = 0;
+            pInfo->mnLength = nMinLength;
         }
         else if(nValue >= nMax)
         {
-            pInfo->mnLength = 100;
+            pInfo->mnLength = nMaxLength;
         }
         else
         {
             double nDiff = nMax - nMin;
-            pInfo->mnLength = (nValue - nMin)/nDiff*100.0;
+            pInfo->mnLength = nMinLength + (nValue - nMin)/nDiff * (nMaxLength-nMinLength);
         }
         pInfo->mnZero = 0;
     }
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 17140e0..ca71cf9 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1300,6 +1300,8 @@ void XclExpDataBar::SaveXml( XclExpXmlStream& rStrm )
 
     rWorksheet->startElement( XML_dataBar,
                                 XML_showValue, OString::number(!mrFormat.GetDataBarData()->mbOnlyBar),
+                                XML_minLength, OString::number(sal_uInt32(mrFormat.GetDataBarData()->mnMinLength)),
+                                XML_maxLength, OString::number(sal_uInt32(mrFormat.GetDataBarData()->mnMaxLength)),
             FSEND );
 
     mpCfvoLowerLimit->SaveXml(rStrm);
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 511e02e..9fa0b14 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -273,6 +273,8 @@ void DataBarRule::importCfvo( const AttributeList& rAttribs )
 void DataBarRule::importAttribs( const AttributeList& rAttribs )
 {
     mxFormat->mbOnlyBar = !rAttribs.getBool( XML_showValue, true );
+    mxFormat->mnMinLength = rAttribs.getUnsigned( XML_minLength, 10);
+    mxFormat->mnMaxLength = rAttribs.getUnsigned( XML_maxLength, 90);
 }
 
 void DataBarRule::SetData( ScDataBarFormat* pFormat, ScDocument* pDoc, const ScAddress& rAddr )
commit 0dc9317d52850b4271876ad18fa651b2f3c25bff
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Mar 23 00:59:17 2015 +0100

    export showValue databar property
    
    Change-Id: I4143b91b4d2edea9a9dab7ce1c06a59ca5d12857

diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 47de380..17140e0 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1298,7 +1298,9 @@ void XclExpDataBar::SaveXml( XclExpXmlStream& rStrm )
             XML_priority, OString::number( mnPriority + 1 ).getStr(),
             FSEND );
 
-    rWorksheet->startElement( XML_dataBar, FSEND );
+    rWorksheet->startElement( XML_dataBar,
+                                XML_showValue, OString::number(!mrFormat.GetDataBarData()->mbOnlyBar),
+            FSEND );
 
     mpCfvoLowerLimit->SaveXml(rStrm);
     mpCfvoUpperLimit->SaveXml(rStrm);


More information about the Libreoffice-commits mailing list