[Libreoffice-commits] core.git: Branch 'feature/unitver' - sc/source

Markus Mohrhard markus.mohrhard at googlemail.com
Mon Jun 29 09:30:52 PDT 2015


 sc/source/core/units/unitsimpl.cxx |   22 ++++++++++++---------
 sc/source/core/units/util.cxx      |   38 +++++++++++++++++++------------------
 sc/source/core/units/utunit.cxx    |   18 +++++++++++------
 3 files changed, 45 insertions(+), 33 deletions(-)

New commits:
commit fb06017d212e10bc142977f6a8b8445fd9629423
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Jun 29 18:29:52 2015 +0200

    fix build and adapt a few places to calc coding style
    
    Change-Id: I9759b96f7ba53c6737ea1576f16d6b46ad5f472b

diff --git a/sc/source/core/units/unitsimpl.cxx b/sc/source/core/units/unitsimpl.cxx
index 66f5019..7d16ae3 100644
--- a/sc/source/core/units/unitsimpl.cxx
+++ b/sc/source/core/units/unitsimpl.cxx
@@ -281,7 +281,8 @@ UnitsResult UnitsImpl::getOutputUnitsForOpCode(stack< RAUSItem >& rStack, const
     return { FormulaStatus::VALID, pOut };
 }
 
-OUString UnitsImpl::extractUnitStringFromFormat(const OUString& rFormatString) {
+OUString UnitsImpl::extractUnitStringFromFormat(const OUString& rFormatString)
+{
     // TODO: decide what we do for different subformats? Simplest solution
     // would be to not allow unit storage for multiple subformats.
     // TODO: we should check the number of subformats here in future?
@@ -291,16 +292,19 @@ OUString UnitsImpl::extractUnitStringFromFormat(const OUString& rFormatString) {
     sal_Int32 nPos = rFormatString.getLength() - 1;
 
     // Only iterate if we have a string item at the end of our format string
-    if (rFormatString[nPos] == '\"') {
+    if (rFormatString[nPos] == '\"')
+    {
        // TODO: deal with escaped strings? (Does that exist in these?)
         while (rFormatString[--nPos] != '\"') {
             if (nPos == 0) {
                 // TODO: plug into our error reporting here to return bad escaping?
-                return "";
+                return OUString("");
             }
         }
-    } else { // otherwise we have no units for this cell
-        return "";
+    }
+    else
+    { // otherwise we have no units for this cell
+        return OUString("");
     }
 
     // Ensure that the parentheses are NOT included in our unit string.
@@ -364,7 +368,7 @@ HeaderUnitDescriptor UnitsImpl::findUnitInStandardHeader(const OUString& rsHeade
         }
     }
 
-    return { false, UtUnit(), boost::optional< ScAddress >(), "", -1 };
+    return { false, UtUnit(), boost::optional< ScAddress >(), OUString(""), -1 };
 }
 
 HeaderUnitDescriptor UnitsImpl::findFreestandingUnitInHeader(const OUString& rsHeader) {
@@ -427,7 +431,7 @@ HeaderUnitDescriptor UnitsImpl::findFreestandingUnitInHeader(const OUString& rsH
         return { true, aUnit, boost::optional< ScAddress >(), sUnitString, nStartPos };
     }
 
-    return { false, UtUnit(), boost::optional< ScAddress >(), "", -1 };
+    return { false, UtUnit(), boost::optional< ScAddress >(), OUString(""), -1 };
 }
 
 HeaderUnitDescriptor UnitsImpl::extractUnitFromHeaderString(const OUString& rsHeader) {
@@ -519,7 +523,7 @@ HeaderUnitDescriptor UnitsImpl::findHeaderUnitForCell(const ScAddress& rCellAddr
         }
     }
 
-    return { false, UtUnit(), boost::optional< ScAddress >(), "", -1 };
+    return { false, UtUnit(), boost::optional< ScAddress >(), OUString(""), -1 };
 }
 
 FormulaStatus UnitsImpl::verifyFormula(ScTokenArray* pArray, const ScAddress& rFormulaAddress, ScDocument* pDoc) {
@@ -732,7 +736,7 @@ bool UnitsImpl::convertCellUnitsForColumnRange(const ScRange& rRange,
     assert(rRange.aStart.Tab() == rRange.aEnd.Tab());
     assert(rOutputUnit.getInputString());
 
-    HeaderUnitDescriptor aHeader = { false, UtUnit(), boost::optional< ScAddress >(), "", -1 };
+    HeaderUnitDescriptor aHeader = { false, UtUnit(), boost::optional< ScAddress >(), OUString(""), -1 };
 
     SCCOL nCol = rRange.aStart.Col();
     SCROW nStartRow = rRange.aStart.Row();
diff --git a/sc/source/core/units/util.cxx b/sc/source/core/units/util.cxx
index b536e99..a9f01ec 100644
--- a/sc/source/core/units/util.cxx
+++ b/sc/source/core/units/util.cxx
@@ -14,40 +14,42 @@
 namespace sc {
 namespace units {
 
-OUString getUTStatus() {
-    switch(ut_get_status()) {
+OUString getUTStatus()
+{
+    switch(ut_get_status())
+    {
     case UT_SUCCESS:
-        return "UT_SUCCESS: successful!";
+        return OUString("UT_SUCCESS: successful!");
     case UT_BAD_ARG:
-        return "UT_BAD_ARG: invalid argument";
+        return OUString("UT_BAD_ARG: invalid argument");
     case UT_EXISTS:
-        return "UT_EXISTS: unit/prefix/identifier already exists";
+        return OUString("UT_EXISTS: unit/prefix/identifier already exists");
     case UT_NO_UNIT:
-        return "UT_NO_UNIT: no such unit exists";
+        return OUString("UT_NO_UNIT: no such unit exists");
     case UT_OS:
-        return "UT_OS: operating system error (check errno?)";
+        return OUString("UT_OS: operating system error (check errno?)");
     case UT_NOT_SAME_SYSTEM:
-        return "UT_NOT_SAME_SYSTEM: units not in same unit system";
+        return OUString("UT_NOT_SAME_SYSTEM: units not in same unit system");
     case UT_MEANINGLESS:
-        return "UT_MEANINGLESS: operation is meaningless";
+        return OUString("UT_MEANINGLESS: operation is meaningless");
     case UT_NO_SECOND:
-        return "UT_NO_SECOND: no unit named second";
+        return OUString("UT_NO_SECOND: no unit named second");
     case UT_VISIT_ERROR:
-        return "UT_VISIT_ERROR";
+        return OUString("UT_VISIT_ERROR");
     case UT_CANT_FORMAT:
-        return "UT_CANT_FORMAT";
+        return OUString("UT_CANT_FORMAT");
     case UT_SYNTAX:
-        return "UT_SYNTAX: syntax error in unit string";
+        return OUString("UT_SYNTAX: syntax error in unit string");
     case UT_UNKNOWN:
-        return "UT_UNKNOWN: unknown unit encountered";
+        return OUString("UT_UNKNOWN: unknown unit encountered");
     case UT_OPEN_ARG:
-        return "UT_OPEN_ARG: can't open specified unit database (arg)";
+        return OUString("UT_OPEN_ARG: can't open specified unit database (arg)");
     case UT_OPEN_ENV:
-        return "UT_OPEN_ENV: can't open specified unit databse (env)";
+        return OUString("UT_OPEN_ENV: can't open specified unit databse (env)");
     case UT_OPEN_DEFAULT:
-        return "UT_OPEN_DEFAULT: can't open default unit database";
+        return OUString("UT_OPEN_DEFAULT: can't open default unit database");
     default:
-        return "other (unspecified) error encountered";
+        return OUString("other (unspecified) error encountered");
     }
 }
 
diff --git a/sc/source/core/units/utunit.cxx b/sc/source/core/units/utunit.cxx
index 63e7e73..93c9c56 100644
--- a/sc/source/core/units/utunit.cxx
+++ b/sc/source/core/units/utunit.cxx
@@ -13,7 +13,8 @@
 
 using namespace sc::units;
 
-bool UtUnit::createUnit(const OUString& rUnitString, UtUnit& rUnitOut, const boost::shared_ptr< ut_system >& pUTSystem) {
+bool UtUnit::createUnit(const OUString& rUnitString, UtUnit& rUnitOut, const boost::shared_ptr< ut_system >& pUTSystem)
+{
     // ut_parse requires the string to be trimmed of whitespace, it's
     // simplest just to do this during conversion:
     OString sUnitStringUTF8 = OUStringToOString(rUnitString.trim(), RTL_TEXTENCODING_UTF8);
@@ -21,23 +22,28 @@ bool UtUnit::createUnit(const OUString& rUnitString, UtUnit& rUnitOut, const boo
     UtUnit pParsedUnit(ut_parse(pUTSystem.get(), sUnitStringUTF8.getStr(), UT_UTF8),
                        rUnitString);
 
-    if (pParsedUnit.isValid()) {
+    if (pParsedUnit.isValid())
+    {
         rUnitOut = pParsedUnit;
         return true;
-    } else {
+    }
+    else
+    {
         SAL_INFO("sc.units", "error encountered parsing unit \"" << rUnitString << "\": " << getUTStatus());
         return false;
     }
 }
 
 
-OUString UtUnit::getString() const {
+OUString UtUnit::getString() const
+{
     char aBuf[200];
     int nChars = ut_format(mpUnit.get(), aBuf, 200, UT_UTF8);
-    if (nChars == -1) {
+    if (nChars == -1)
+    {
         SAL_INFO("sc.units", "couldn't format unit: " << getUTStatus());
         // Placeholder for unformattable strings.
-        return "?";
+        return OUString("?");
     }
 
     // If the output doesn't fit in the buffer, ut_format doesn't write


More information about the Libreoffice-commits mailing list