[Libreoffice-commits] .: 3 commits - sw/source writerfilter/source

Lubos Lunak llunak at kemper.freedesktop.org
Thu Aug 11 07:03:20 PDT 2011


 sw/source/filter/ww8/docxattributeoutput.cxx          |    6 +-
 sw/source/filter/ww8/docxexport.cxx                   |   52 +++++++++++++++++
 sw/source/filter/ww8/docxexport.hxx                   |    2 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx     |   53 +++++++++++++++---
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |    4 +
 writerfilter/source/ooxml/OOXMLFastContextHandler.hxx |    2 
 6 files changed, 107 insertions(+), 12 deletions(-)

New commits:
commit f511fee19b9147253dc1c0873018429f3c0a1c91
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Aug 11 14:56:40 2011 +0200

    adjust for timezone when reading datetime

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 65f3481..1ded4ad 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -74,6 +74,7 @@
 #include <rtl/string.h>
 #include "FieldTypes.hxx"
 
+#include <tools/datetime.hxx>
 #include <tools/string.hxx>
 #ifdef DEBUG_DOMAINMAPPER
 #include <resourcemodel/QNameToString.hxx>
@@ -966,24 +967,60 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap )
 
 util::DateTime lcl_DateStringToDateTime( const ::rtl::OUString& rDateTime )
 {
-    util::DateTime aDateTime;
+    DateTime aDateTime;
     //xsd::DateTime in the format [-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm] example: 2008-01-21T10:42:00Z
     //OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const SAL_THROW(())
     sal_Int32 nIndex = 0;
     ::rtl::OUString sDate = rDateTime.getToken( 0, 'T', nIndex );
     ::rtl::OUString sTime = rDateTime.getToken( 0, 'Z', nIndex );
+    int timezonepos = nIndex;
     nIndex = 0;
-    aDateTime.Year = sal_uInt16( sDate.getToken( 0, '-', nIndex ).toInt32() );
-    aDateTime.Month = sal_uInt16( sDate.getToken( 0, '-', nIndex ).toInt32() );
-    aDateTime.Day = sal_uInt16( sDate.copy( nIndex ).toInt32() );
+    aDateTime.SetYear( sDate.getToken( 0, '-', nIndex ).toInt32() );
+    aDateTime.SetMonth( sDate.getToken( 0, '-', nIndex ).toInt32() );
+    aDateTime.SetDay( sDate.copy( nIndex ).toInt32() );
 
     nIndex = 0;
-    aDateTime.Hours = sal_uInt16( sTime.getToken( 0, ':', nIndex ).toInt32() );
-    aDateTime.Minutes = sal_uInt16( sTime.getToken( 0, ':', nIndex ).toInt32() );
-    aDateTime.Seconds = sal_uInt16( sTime.copy( nIndex ).toInt32() );
+    aDateTime.SetHour( sTime.getToken( 0, ':', nIndex ).toInt32() );
+    aDateTime.SetMin( sTime.getToken( 0, ':', nIndex ).toInt32() );
+    aDateTime.SetSec( sTime.copy( nIndex ).toInt32() );
 
-    return aDateTime;
+    if( timezonepos >= 0 ) // otherwise consider it local time
+    {
+        bool negative = false;
+        nIndex = timezonepos;
+        if( nIndex < rDateTime.getLength() && rDateTime[ nIndex ] == '-' )
+        {
+            negative = true;
+            ++nIndex;
+        }
+        else if ( nIndex < rDateTime.getLength() && rDateTime[ nIndex ] == '+' )
+        {
+            ++nIndex;
+        }
+        Time diff( 0, 0, 0 );
+        if( nIndex < rDateTime.getLength())
+        {
+            diff.SetHour( rDateTime.getToken( 0, ':', nIndex ).toInt32());
+            diff.SetMin( rDateTime.getToken( 0, ':', nIndex ).toInt32());
+        }
+        // convert to utc, then to local
+        if( negative )
+            aDateTime -= diff;
+        else
+            aDateTime += diff;
+        aDateTime.ConvertToLocalTime();
+    }
+    util::DateTime ret;
+    ret.Year = aDateTime.GetYear();
+    ret.Month = aDateTime.GetMonth();
+    ret.Day = aDateTime.GetDay();
+    ret.Hours = aDateTime.GetHour();
+    ret.Minutes = aDateTime.GetMin();
+    ret.Seconds = aDateTime.GetSec();
+    ret.HundredthSeconds = 0;
+    return ret;
 }
+
 void DomainMapper_Impl::appendTextPortion( const ::rtl::OUString& rString, PropertyMapPtr pPropertyMap )
 {
     uno::Reference< text::XTextAppend >  xTextAppend = m_aTextAppendStack.top().xTextAppend;
commit 593ae387ceda893b479dd25008403a0cd8b42543
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Aug 10 16:17:24 2011 +0200

    do not ignore attributes on <w:comment>

diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 3e1464d..6487415 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1666,7 +1666,7 @@ void OOXMLFastContextHandlerTable::newPropertySet
 
 OOXMLFastContextHandlerXNote::OOXMLFastContextHandlerXNote
 (OOXMLFastContextHandler * pContext)
-: OOXMLFastContextHandler(pContext), mbForwardEventsSaved(false)
+: OOXMLFastContextHandlerProperties(pContext), mbForwardEventsSaved(false)
 {
 }
 
@@ -1695,6 +1695,8 @@ void OOXMLFastContextHandlerXNote::lcl_endFastElement
 {
     endAction(Element);
 
+    OOXMLFastContextHandlerProperties::lcl_endFastElement(Element);
+
     setForwardEvents(mbForwardEventsSaved);
 }
 
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index 68a69bd..52c149c 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -426,7 +426,7 @@ protected:
     void addCurrentChild();
 };
 
-class OOXMLFastContextHandlerXNote : public OOXMLFastContextHandler
+class OOXMLFastContextHandlerXNote : public OOXMLFastContextHandlerProperties
 {
 public:
     OOXMLFastContextHandlerXNote(OOXMLFastContextHandler * pContext);
commit a36f220339b116f45247e4d232c4b8b826857630
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Aug 10 12:57:11 2011 +0200

    finish implementation of writing of comments to .docx

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 89cbd7c..da091ee 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3329,9 +3329,11 @@ void DocxAttributeOutput::WritePostitFields()
          ++i )
     {
         OString idstr = OString::valueOf( sal_Int32( i ));
-// TODO        const SwPostItField* f = m_postitFields[ i ];
+        const SwPostItField* f = m_postitFields[ i ];
         m_pSerializer->startElementNS( XML_w, XML_comment, FSNS( XML_w, XML_id ), idstr.getStr(),
-            /*TODO*/ FSEND );
+            FSNS( XML_w, XML_author ), rtl::OUStringToOString( f->GetPar1(), RTL_TEXTENCODING_UTF8 ).getStr(),
+            FSNS( XML_w, XML_date ), impl_DateTimeToOString(f->GetDateTime()).getStr(), FSEND );
+        GetExport().WriteOutliner( *f->GetTextObject(), TXT_ATN );
         m_pSerializer->endElementNS( XML_w, XML_comment );
     }
 }
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 9920350..bec163a 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -54,6 +54,9 @@
 #include <section.hxx>
 #include <ftninfo.hxx>
 
+#include <editeng/editobj.hxx>
+#include <editeng/outlobj.hxx>
+
 #include <docary.hxx>
 #include <numrule.hxx>
 #include <charfmt.hxx>
@@ -745,6 +748,55 @@ bool DocxExport::ignoreAttributeForStyles( sal_uInt16 nWhich ) const
     return MSWordExportBase::ignoreAttributeForStyles( nWhich );
 }
 
+void DocxExport::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt8 nTyp)
+{
+    const EditTextObject& rEditObj = rParaObj.GetTextObject();
+    MSWord_SdrAttrIter aAttrIter( *this, rEditObj, nTyp );
+
+    sal_uInt16 nPara = rEditObj.GetParagraphCount();
+    for( sal_uInt16 n = 0; n < nPara; ++n )
+    {
+        if( n )
+            aAttrIter.NextPara( n );
+
+        AttrOutput().StartParagraph( ww8::WW8TableNodeInfo::Pointer_t());
+        rtl_TextEncoding eChrSet = aAttrIter.GetNodeCharSet();
+        String aStr( rEditObj.GetText( n ));
+        xub_StrLen nAktPos = 0;
+        xub_StrLen nEnd = aStr.Len();
+        do {
+            AttrOutput().StartRun( NULL );
+            xub_StrLen nNextAttr = aAttrIter.WhereNext();
+            rtl_TextEncoding eNextChrSet = aAttrIter.GetNextCharSet();
+
+            if( nNextAttr > nEnd )
+                nNextAttr = nEnd;
+
+            bool bTxtAtr = aAttrIter.IsTxtAttr( nAktPos );
+            if( !bTxtAtr )
+            {
+                if( nAktPos == 0 && nNextAttr - nAktPos == aStr.Len())
+                    AttrOutput().RunText( aStr, eChrSet );
+                else
+                {
+                    String tmp( aStr.Copy( nAktPos, nNextAttr - nAktPos ));
+                    AttrOutput().RunText( tmp, eChrSet );
+                }
+            }
+            AttrOutput().StartRunProperties();
+            aAttrIter.OutAttr( nAktPos );
+            AttrOutput().EndRunProperties( NULL );
+
+            nAktPos = nNextAttr;
+            eChrSet = eNextChrSet;
+            aAttrIter.NextPos();
+            AttrOutput().EndRun();
+        } while( nAktPos < nEnd );
+//        aAttrIter.OutParaAttr(false);
+        AttrOutput().EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t());
+    }
+}
+
 DocxExport::DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam )
     : MSWordExportBase( pDocument, pCurrentPam, pOriginalPam ),
       m_pFilter( pFilter ),
diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx
index faed1e0..3eaec51 100644
--- a/sw/source/filter/ww8/docxexport.hxx
+++ b/sw/source/filter/ww8/docxexport.hxx
@@ -152,6 +152,8 @@ public:
     /// Returns the relationd id
     rtl::OString OutputChart( com::sun::star::uno::Reference< com::sun::star::frame::XModel >& xModel, sal_Int32 nCount );
 
+    void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp);
+
 protected:
     /// Format-dependant part of the actual export.
     virtual void ExportDocument_Impl();


More information about the Libreoffice-commits mailing list