summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-06-15 17:48:17 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-06-15 18:03:20 +0200
commit42e41ea6d6ec40977cc339af529b2306840d31cb (patch)
tree6cc0d842d20e96ea37c39a4d7ff40472467f8935 /sw
parent6c14d15dbbdc8920e1695b5fdc32b6519508815d (diff)
move DTTM2DateTime and DateTimeToOString to msfilter to avoid copy&paste
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/inc/msfilter.hxx9
-rw-r--r--sw/source/filter/rtf/swparrtf.cxx4
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx53
-rw-r--r--sw/source/filter/ww8/writerwordglue.cxx33
-rw-r--r--sw/source/filter/ww8/ww8par.cxx4
-rw-r--r--sw/source/filter/ww8/ww8par4.cxx2
6 files changed, 8 insertions, 97 deletions
diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx
index 3958f7407efb..45fd8830ec2a 100644
--- a/sw/source/filter/inc/msfilter.hxx
+++ b/sw/source/filter/inc/msfilter.hxx
@@ -37,7 +37,7 @@
#include "wwstyles.hxx" //ww::sti
#include <rtl/textenc.h> //rtl_TextEncoding
#include <tools/gen.hxx> //Size
-#include <tools/datetime.hxx>
+#include <filter/msfilter/util.hxx>
#include <fltshell.hxx> // fuer den Attribut Stack
#include <redline.hxx>
#include <shellio.hxx>
@@ -107,13 +107,6 @@ namespace sw
@author
<a href="mailto:mmaher@openoffice.org">Martin Maher</a
*/
- DateTime DTTM2DateTime( long lDTTM );
-
- /** Convert from DTTM to Writer's DateTime
-
- @author
- <a href="mailto:mmaher@openoffice.org">Martin Maher</a
- */
long DateTime2DTTM( const DateTime& rDT );
/** Convert from Word Date/Time field str to Writer's Date Time str
diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx
index 5a73aa1bf4d7..2e8553a011fb 100644
--- a/sw/source/filter/rtf/swparrtf.cxx
+++ b/sw/source/filter/rtf/swparrtf.cxx
@@ -1847,12 +1847,12 @@ void SwRTFParser::NextToken( int nToken )
case RTF_REVDTTM:
if (pRedlineInsert != NULL)
- pRedlineInsert->aStamp = sw::ms::DTTM2DateTime(nTokenValue);
+ pRedlineInsert->aStamp = msfilter::util::DTTM2DateTime(nTokenValue);
break;
case RTF_REVDTTMDEL:
- pRedlineDelete->aStamp = sw::ms::DTTM2DateTime(nTokenValue);
+ pRedlineDelete->aStamp = msfilter::util::DTTM2DateTime(nTokenValue);
break;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index db118a8b8bfb..ba5046354318 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1240,55 +1240,6 @@ void DocxAttributeOutput::Redline( const SwRedlineData* /*pRedline*/ )
OSL_TRACE( "TODO DocxAttributeOutput::Redline( const SwRedlineData* pRedline )" );
}
-/// Append the number as 2-digit when less than 10.
-static void impl_AppendTwoDigits( OStringBuffer &rBuffer, sal_Int32 nNum )
-{
- if ( nNum < 0 || nNum > 99 )
- {
- rBuffer.append( "00" );
- return;
- }
-
- if ( nNum < 10 )
- rBuffer.append( '0' );
-
- rBuffer.append( nNum );
-}
-
-/** Convert DateTime to xsd::dateTime string.
-
-I guess there must be an implementation of this somewhere in OOo, but I failed
-to find it, unfortunately :-(
-*/
-static OString impl_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( '-' );
-
- impl_AppendTwoDigits( aBuffer, aInUTC.GetMonth() );
- aBuffer.append( '-' );
-
- impl_AppendTwoDigits( aBuffer, aInUTC.GetDay() );
- aBuffer.append( 'T' );
-
- impl_AppendTwoDigits( aBuffer, aInUTC.GetHour() );
- aBuffer.append( ':' );
-
- impl_AppendTwoDigits( aBuffer, aInUTC.GetMin() );
- aBuffer.append( ':' );
-
- impl_AppendTwoDigits( aBuffer, aInUTC.GetSec() );
- aBuffer.append( 'Z' ); // we are in UTC
-
- return aBuffer.makeStringAndClear();
-}
-
void DocxAttributeOutput::StartRedline( const SwRedlineData* pRedlineData )
{
m_pRedlineData = pRedlineData;
@@ -1303,7 +1254,7 @@ void DocxAttributeOutput::StartRedline( const SwRedlineData* pRedlineData )
const String &rAuthor( SW_MOD()->GetRedlineAuthor( pRedlineData->GetAuthor() ) );
OString aAuthor( OUStringToOString( rAuthor, RTL_TEXTENCODING_UTF8 ) );
- OString aDate( impl_DateTimeToOString( pRedlineData->GetTimeStamp() ) );
+ OString aDate( msfilter::util::DateTimeToOString( pRedlineData->GetTimeStamp() ) );
switch ( pRedlineData->GetType() )
{
@@ -3380,7 +3331,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 ), rtl::OUStringToOString( f->GetPar1(), RTL_TEXTENCODING_UTF8 ).getStr(),
- FSNS( XML_w, XML_date ), impl_DateTimeToOString(f->GetDateTime()).getStr(), FSEND );
+ FSNS( XML_w, XML_date ), msfilter::util::DateTimeToOString(f->GetDateTime()).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,
// that is probably a bug in the Writer core.
diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx
index 2c1bd5426ebd..7dbed5657b28 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -728,39 +728,6 @@ namespace sw
return nDT;
}
- DateTime DTTM2DateTime( long lDTTM )
- {
- /*
- mint short :6 0000003F minutes (0-59)
- hr short :5 000007C0 hours (0-23)
- dom short :5 0000F800 days of month (1-31)
- mon short :4 000F0000 months (1-12)
- yr short :9 1FF00000 years (1900-2411)-1900
- wdy short :3 E0000000 weekday(Sunday=0
- Monday=1
- ( wdy can be ignored ) Tuesday=2
- Wednesday=3
- Thursday=4
- Friday=5
- Saturday=6)
- */
- DateTime aDateTime(Date( 0 ), Time( 0 ));
- if( lDTTM )
- {
- sal_uInt16 lMin = (sal_uInt16)(lDTTM & 0x0000003F);
- lDTTM >>= 6;
- sal_uInt16 lHour= (sal_uInt16)(lDTTM & 0x0000001F);
- lDTTM >>= 5;
- sal_uInt16 lDay = (sal_uInt16)(lDTTM & 0x0000001F);
- lDTTM >>= 5;
- sal_uInt16 lMon = (sal_uInt16)(lDTTM & 0x0000000F);
- lDTTM >>= 4;
- sal_uInt16 lYear= (sal_uInt16)(lDTTM & 0x000001FF) + 1900;
- aDateTime = DateTime(Date(lDay, lMon, lYear), Time(lHour, lMin));
- }
- return aDateTime;
- }
-
sal_uLong MSDateTimeFormatToSwFormat(String& rParams,
SvNumberFormatter *pFormatter, sal_uInt16 &rLang, bool bHijri,
sal_uInt16 nDocLang)
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 82f4312c605d..c49760289055 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1509,7 +1509,7 @@ void SwWW8ImplReader::ImportDop()
if (xDocuProps.is())
{
DateTime aLastPrinted(
- sw::ms::DTTM2DateTime(pWDop->dttmLastPrint));
+ msfilter::util::DTTM2DateTime(pWDop->dttmLastPrint));
::util::DateTime uDT(aLastPrinted.Get100Sec(),
aLastPrinted.GetSec(), aLastPrinted.GetMin(),
aLastPrinted.GetHour(), aLastPrinted.GetDay(),
@@ -1828,7 +1828,7 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
nDateTime = SVBT32ToUInt32(*(SVBT32*)(pExtended+(nIndex*18)));
}
- DateTime aDate = sw::ms::DTTM2DateTime(nDateTime);
+ DateTime aDate = msfilter::util::DTTM2DateTime(nDateTime);
String sTxt;
OutlinerParaObject *pOutliner = ImportAsOutliner( sTxt, pRes->nCp2OrIdx,
diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx
index 083fbd276456..2765d2ce3c34 100644
--- a/sw/source/filter/ww8/ww8par4.cxx
+++ b/sw/source/filter/ww8/ww8par4.cxx
@@ -522,7 +522,7 @@ void SwWW8ImplReader::Read_CRevisionMark(RedlineType_t eType,
// start of new revision mark, if not there default to first entry
sal_uInt16 nWWAutNo = pSprmCIbstRMark ? SVBT16ToShort(pSprmCIbstRMark) : 0;
sal_uInt32 nWWDate = pSprmCDttmRMark ? SVBT32ToUInt32(pSprmCDttmRMark): 0;
- DateTime aStamp(sw::ms::DTTM2DateTime(nWWDate));
+ DateTime aStamp(msfilter::util::DTTM2DateTime(nWWDate));
sal_uInt16 nAuthorNo = m_aAuthorInfos[nWWAutNo];
SwFltRedline aNewAttr(eType, nAuthorNo, aStamp);
NewAttr(aNewAttr);