[Libreoffice-commits] .: svl/inc svl/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Wed Feb 23 10:40:10 PST 2011
svl/inc/svl/zformat.hxx | 18 +++++++++++++-
svl/source/numbers/zformat.cxx | 50 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 1 deletion(-)
New commits:
commit 0c6497cf4eebd0999f9e0f925d0bc0f25e68116c
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Wed Feb 23 13:38:21 2011 -0500
Updated method documentation to be more specific.
diff --git a/svl/inc/svl/zformat.hxx b/svl/inc/svl/zformat.hxx
index a75af10..25268de 100644
--- a/svl/inc/svl/zformat.hxx
+++ b/svl/inc/svl/zformat.hxx
@@ -489,7 +489,23 @@ private:
xub_StrLen& nPos,
String& sSymbol );
- // get xxx of "[$-xxx]" as LanguageType, starting at and advancing position nPos
+ /**
+ * Parse the content of '[$-xxx] or '[$-xxxxxxxx]' and extract the
+ * language type from it. Given the string, start parsing at position
+ * specified by nPos, and store the end position with nPos when the
+ * parsing is complete. The nPos should point to the '$' before the
+ * parsing, and to the closing bracket after the parsing. When the
+ * content is [$-xxx], the xxx part represents the language type (aka
+ * LCID) in hex numerals. When the content is [$-xxxxxxxx] the last 4
+ * digits is the LCID (again in hex).
+ *
+ * @param rString input string
+ * @param nPos position (see above).
+ *
+ * @return LCID that specifies language type. See i18npool/lang.h for a
+ * complete list of language types. These numbers also correspond
+ * with the numbers used by Microsoft Office.
+ */
SVL_DLLPRIVATE static LanguageType ImpGetLanguageType( const String& rString, xub_StrLen& nPos );
// standard number output
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 882c8a5..994c2c0 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -59,6 +59,48 @@
using namespace svt;
+#include <stdio.h>
+#include <string>
+#include <sys/time.h>
+
+namespace {
+
+class StackPrinter
+{
+public:
+ explicit StackPrinter(const char* msg) :
+ msMsg(msg)
+ {
+ fprintf(stdout, "%s: --begin\n", msMsg.c_str());
+ mfStartTime = getTime();
+ }
+
+ ~StackPrinter()
+ {
+ double fEndTime = getTime();
+ fprintf(stdout, "%s: --end (duration: %g sec)\n", msMsg.c_str(), (fEndTime-mfStartTime));
+ }
+
+ void printTime(int line) const
+ {
+ double fEndTime = getTime();
+ fprintf(stdout, "%s: --(%d) (duration: %g sec)\n", msMsg.c_str(), line, (fEndTime-mfStartTime));
+ }
+
+private:
+ double getTime() const
+ {
+ timeval tv;
+ gettimeofday(&tv, NULL);
+ return tv.tv_sec + tv.tv_usec / 1000000.0;
+ }
+
+ ::std::string msMsg;
+ double mfStartTime;
+};
+
+}
+
namespace {
struct Gregorian
: public rtl::StaticWithInit<const ::rtl::OUString, Gregorian> {
@@ -603,6 +645,8 @@ SvNumberformat::SvNumberformat(String& rString,
nNewStandardDefined(0),
bStarFlag( FALSE )
{
+ StackPrinter __stack_printer__("SvNumberformat::SvNumberformat");
+ fprintf(stdout, "SvNumberformat::SvNumberformat: string = '%s'\n", rtl::OUStringToOString(rString, RTL_TEXTENCODING_UTF8).getStr());
// If the group (AKA thousand) separator is a Non-Breaking Space (French)
// replace all occurrences by a simple space.
// The tokens will be changed to the LocaleData separator again later on.
@@ -1099,6 +1143,9 @@ xub_StrLen SvNumberformat::ImpGetNumber(String& rString,
LanguageType SvNumberformat::ImpGetLanguageType( const String& rString,
xub_StrLen& nPos )
{
+ StackPrinter __stack_printer__("SvNumberformat::ImpGetLanguageType");
+ fprintf(stdout, "SvNumberformat::ImpGetLanguageType: string = '%s'\n", rtl::OUStringToOString(rString, RTL_TEXTENCODING_UTF8).getStr());
+
sal_Int32 nNum = 0;
sal_Unicode cToken = 0;
xub_StrLen nLen = rString.Len();
@@ -1123,6 +1170,7 @@ LanguageType SvNumberformat::ImpGetLanguageType( const String& rString,
return LANGUAGE_DONTKNOW;
++nPos;
}
+ fprintf(stdout, "SvNumberformat::ImpGetLanguageType: number = %ld\n", nNum);
return (nNum && (cToken == ']' || nPos == nLen)) ? (LanguageType)nNum :
LANGUAGE_DONTKNOW;
}
@@ -1131,6 +1179,7 @@ short SvNumberformat::ImpNextSymbol(String& rString,
xub_StrLen& nPos,
String& sSymbol)
{
+ StackPrinter __stack_printer__("SvNumberformat::ImpNextSymbol");
short eSymbolType = BRACKET_SYMBOLTYPE_FORMAT;
sal_Unicode cToken;
sal_Unicode cLetter = ' '; // Zwischenergebnis
@@ -1396,6 +1445,7 @@ short SvNumberformat::ImpNextSymbol(String& rString,
} // of switch
} // of while
+ fprintf(stdout, "SvNumberformat::ImpNextSymbol: symbol = '%s'\n", rtl::OUStringToOString(sSymbol, RTL_TEXTENCODING_UTF8).getStr());
return eSymbolType;
}
More information about the Libreoffice-commits
mailing list