[Libreoffice-commits] core.git: filter/source include/filter include/tools sw/source tools/Library_tl.mk tools/source writerfilter/source

Adam Co rattles2013 at gmail.com
Tue Nov 26 05:02:27 PST 2013


 filter/source/msfilter/util.cxx                |   44 -------------------
 include/filter/msfilter/util.hxx               |    1 
 include/tools/datetimeutils.hxx                |   20 ++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx   |    7 +--
 tools/Library_tl.mk                            |    1 
 tools/source/datetime/datetimeutils.cxx        |   56 +++++++++++++++++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |    3 -
 7 files changed, 83 insertions(+), 49 deletions(-)

New commits:
commit 8d7cb7773dafda969c22bb9cca658bf1c677798d
Author: Adam Co <rattles2013 at gmail.com>
Date:   Tue Nov 26 13:56:46 2013 +0200

    Moved 'DateTimeToOString' from 'filter' package to 'tools' package
    
    After the move now other classes can convert DateTime to OString also
    
    Reviewed on:
    	https://gerrit.libreoffice.org/6816
    
    Change-Id: I0ceb9a5cc26103a6cb36d7765a717770ec3fbe7d

diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx
index 828d5de..0bd7cbe 100644
--- a/filter/source/msfilter/util.cxx
+++ b/filter/source/msfilter/util.cxx
@@ -79,50 +79,6 @@ DateTime DTTM2DateTime( long lDTTM )
     return aDateTime;
 }
 
-/// Append the number as 2-digit when less than 10.
-static void lcl_AppendTwoDigits( OStringBuffer &rBuffer, sal_Int32 nNum )
-{
-    if ( nNum < 0 || nNum > 99 )
-    {
-        rBuffer.append( "00" );
-        return;
-    }
-
-    if ( nNum < 10 )
-        rBuffer.append( '0' );
-
-    rBuffer.append( nNum );
-}
-
-OString DateTimeToOString( const DateTime& rDateTime )
-{
-    DateTime aInUTC( rDateTime );
-// HACK: this is correct according to the spec, but MSOffice believes everybody lives
-// in UTC+0 when reading it back
-//    aInUTC.ConvertToUTC();
-
-    OStringBuffer aBuffer( 25 );
-    aBuffer.append( sal_Int32( aInUTC.GetYear() ) );
-    aBuffer.append( '-' );
-
-    lcl_AppendTwoDigits( aBuffer, aInUTC.GetMonth() );
-    aBuffer.append( '-' );
-
-    lcl_AppendTwoDigits( aBuffer, aInUTC.GetDay() );
-    aBuffer.append( 'T' );
-
-    lcl_AppendTwoDigits( aBuffer, aInUTC.GetHour() );
-    aBuffer.append( ':' );
-
-    lcl_AppendTwoDigits( aBuffer, aInUTC.GetMin() );
-    aBuffer.append( ':' );
-
-    lcl_AppendTwoDigits( aBuffer, aInUTC.GetSec() );
-    aBuffer.append( 'Z' ); // we are in UTC
-
-    return aBuffer.makeStringAndClear();
-}
-
 sal_Unicode bestFitOpenSymbolToMSFont(sal_Unicode cChar,
     rtl_TextEncoding& rChrSet, OUString& rFontName, bool bDisableUnicodeSupport)
 {
diff --git a/include/filter/msfilter/util.hxx b/include/filter/msfilter/util.hxx
index d9ab87e..f857bf5 100644
--- a/include/filter/msfilter/util.hxx
+++ b/include/filter/msfilter/util.hxx
@@ -40,7 +40,6 @@ MSFILTER_DLLPUBLIC DateTime DTTM2DateTime( long lDTTM );
 I guess there must be an implementation of this somewhere in LO, but I failed
 to find it, unfortunately :-(
 */
-MSFILTER_DLLPUBLIC OString DateTimeToOString( const DateTime& rDateTime );
 
 /// Given a cBullet in encoding r_ioChrSet and fontname r_ioFontName return a
 /// suitable new Bullet and change r_ioChrSet and r_ioFontName to form the
diff --git a/include/tools/datetimeutils.hxx b/include/tools/datetimeutils.hxx
new file mode 100644
index 0000000..840403b
--- /dev/null
+++ b/include/tools/datetimeutils.hxx
@@ -0,0 +1,20 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_TOOLS_DATETIMEUTILS_HXX
+#define INCLUDED_TOOLS_DATETIMEUTILS_HXX
+
+#include <tools/datetime.hxx>
+
+// This function converts a 'DateTime' object to an 'OString' object
+TOOLS_DLLPUBLIC OString DateTimeToOString( const DateTime& rDateTime );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 5780aff..2a8205c 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -80,6 +80,7 @@
 #include <svx/xflgrit.hxx>
 #include <svl/grabbagitem.hxx>
 #include <sfx2/sfxbasemodel.hxx>
+#include <tools/datetimeutils.hxx>
 
 #include <anchoredobject.hxx>
 #include <docufld.hxx>
@@ -1461,7 +1462,7 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedline)
     OString aId( OString::number( pRedline->GetSeqNo() ) );
     const OUString &rAuthor( SW_MOD()->GetRedlineAuthor( pRedline->GetAuthor() ) );
     OString aAuthor( OUStringToOString( rAuthor, RTL_TEXTENCODING_UTF8 ) );
-    OString aDate( msfilter::util::DateTimeToOString( pRedline->GetTimeStamp() ) );
+    OString aDate( DateTimeToOString( pRedline->GetTimeStamp() ) );
 
     OUString sVal;
     OString sOVal;
@@ -1522,7 +1523,7 @@ void DocxAttributeOutput::StartRedline()
     const OUString &rAuthor( SW_MOD()->GetRedlineAuthor( pRedlineData->GetAuthor() ) );
     OString aAuthor( OUStringToOString( rAuthor, RTL_TEXTENCODING_UTF8 ) );
 
-    OString aDate( msfilter::util::DateTimeToOString( pRedlineData->GetTimeStamp() ) );
+    OString aDate( DateTimeToOString( pRedlineData->GetTimeStamp() ) );
 
     switch ( pRedlineData->GetType() )
     {
@@ -4944,7 +4945,7 @@ void DocxAttributeOutput::WritePostitFields()
         const SwPostItField* f = m_postitFields[ i ];
         m_pSerializer->startElementNS( XML_w, XML_comment, FSNS( XML_w, XML_id ), idstr.getStr(),
             FSNS( XML_w, XML_author ), OUStringToOString( f->GetPar1(), RTL_TEXTENCODING_UTF8 ).getStr(),
-            FSNS( XML_w, XML_date ), msfilter::util::DateTimeToOString(f->GetDateTime()).getStr(),
+            FSNS( XML_w, XML_date ), DateTimeToOString(f->GetDateTime()).getStr(),
             FSNS( XML_w, XML_initials ), OUStringToOString( f->GetInitials(), RTL_TEXTENCODING_UTF8 ).getStr(), FSEND );
         // Check for the text object existing, it seems that it can be NULL when saving a newly created
         // comment without giving focus back to the main document. As GetTxt() is empty in that case as well,
diff --git a/tools/Library_tl.mk b/tools/Library_tl.mk
index db2360b..93f32c7 100644
--- a/tools/Library_tl.mk
+++ b/tools/Library_tl.mk
@@ -44,6 +44,7 @@ $(eval $(call gb_Library_use_libraries,tl,\
 
 $(eval $(call gb_Library_add_exception_objects,tl,\
     tools/source/datetime/datetime \
+    tools/source/datetime/datetimeutils \
     tools/source/datetime/tdate \
     tools/source/datetime/ttime \
     tools/source/debug/debug \
diff --git a/tools/source/datetime/datetimeutils.cxx b/tools/source/datetime/datetimeutils.cxx
new file mode 100644
index 0000000..512ae82
--- /dev/null
+++ b/tools/source/datetime/datetimeutils.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/datetimeutils.hxx>
+#include <rtl/strbuf.hxx>
+
+
+/// Append the number as 2-digit when less than 10.
+static void lcl_AppendTwoDigits( OStringBuffer &rBuffer, sal_Int32 nNum )
+{
+    if ( nNum < 0 || nNum > 99 )
+    {
+        rBuffer.append( "00" );
+        return;
+    }
+
+    if ( nNum < 10 )
+        rBuffer.append( '0' );
+
+    rBuffer.append( nNum );
+}
+
+OString DateTimeToOString( const DateTime& rDateTime )
+{
+    DateTime aInUTC( rDateTime );
+// HACK: this is correct according to the spec, but MSOffice believes everybody lives
+// in UTC+0 when reading it back
+//    aInUTC.ConvertToUTC();
+
+    OStringBuffer aBuffer( 25 );
+    aBuffer.append( sal_Int32( aInUTC.GetYear() ) );
+    aBuffer.append( '-' );
+
+    lcl_AppendTwoDigits( aBuffer, aInUTC.GetMonth() );
+    aBuffer.append( '-' );
+
+    lcl_AppendTwoDigits( aBuffer, aInUTC.GetDay() );
+    aBuffer.append( 'T' );
+
+    lcl_AppendTwoDigits( aBuffer, aInUTC.GetHour() );
+    aBuffer.append( ':' );
+
+    lcl_AppendTwoDigits( aBuffer, aInUTC.GetMin() );
+    aBuffer.append( ':' );
+
+    lcl_AppendTwoDigits( aBuffer, aInUTC.GetSec() );
+    aBuffer.append( 'Z' ); // we are in UTC
+
+    return aBuffer.makeStringAndClear();
+}
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index b77cbbb..cd17d92 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -34,6 +34,7 @@
 #include <filter/msfilter/escherex.hxx>
 #include <comphelper/string.hxx>
 #include <tools/globname.hxx>
+#include <tools/datetimeutils.hxx>
 #include <comphelper/classids.hxx>
 #include <comphelper/embeddedobjectcontainer.hxx>
 #include <sfx2/sfxbasemodel.hxx>
@@ -162,7 +163,7 @@ static void lcl_putBorderProperty(std::stack<RTFParserState>& aStates, Id nId, R
 
 static OString lcl_DTTM22OString(long lDTTM)
 {
-    return msfilter::util::DateTimeToOString(msfilter::util::DTTM2DateTime(lDTTM));
+    return DateTimeToOString(msfilter::util::DTTM2DateTime(lDTTM));
 }
 
 static writerfilter::Reference<Properties>::Pointer_t lcl_getBookmarkProperties(int nPos, OUString& rString)


More information about the Libreoffice-commits mailing list