[Libreoffice-commits] .: 4 commits - sw/source tools/inc writerfilter/source

Lubos Lunak llunak at kemper.freedesktop.org
Thu Aug 18 06:16:26 PDT 2011


 sw/source/filter/ww8/docxattributeoutput.cxx      |   40 ++++++++++++++--
 sw/source/filter/ww8/docxattributeoutput.hxx      |    4 +
 tools/inc/tools/time.hxx                          |    6 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   55 ++++------------------
 4 files changed, 55 insertions(+), 50 deletions(-)

New commits:
commit 5513570bf9b58392659c33aea37abc4807f59cb2
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Fri Aug 12 20:37:20 2011 +0200

    add a warning to Time class that it is broken API

diff --git a/tools/inc/tools/time.hxx b/tools/inc/tools/time.hxx
index 9b25340..ff6a7c9 100644
--- a/tools/inc/tools/time.hxx
+++ b/tools/inc/tools/time.hxx
@@ -37,6 +37,12 @@ class ResId;
 // - Time -
 // --------
 
+/**
+ WARNING: This class can serve both as call clock time and time duration, and the mixing
+          of these concepts leads to problems such as there being 25 hours
+          or 10 minus 20 seconds being (non-negative) 10 seconds.
+*/
+
 class TOOLS_DLLPUBLIC Time
 {
 private:
commit 28d84e1b04a1936901695d9ecb8c5c8ee8f3c874
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Fri Aug 12 20:34:14 2011 +0200

    placeholder for writing math to .docx

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 7c5a399..b2c4391 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -113,6 +113,7 @@
 #include <htmltbl.hxx>
 #include <lineinfo.hxx>
 #include <ndgrf.hxx>
+#include <ndole.hxx>
 #include <ndtxt.hxx>
 #include <node.hxx>
 #include <pagedesc.hxx>
@@ -2207,7 +2208,15 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
     m_pSerializer->endElementNS( XML_w, XML_drawing );
 }
 
-void DocxAttributeOutput::WriteOLE2Obj( const SdrObject* pSdrObj, const Size& rSize )
+void DocxAttributeOutput::WriteOLE2Obj( const SdrObject* pSdrObj, const SwOLENode& rOLENode, const Size& rSize )
+{
+    if( WriteOLEChart( pSdrObj, rSize ))
+        return;
+    if( WriteOLEMath( pSdrObj, rOLENode, rSize ))
+        return;
+}
+
+bool DocxAttributeOutput::WriteOLEChart( const SdrObject* pSdrObj, const Size& rSize )
 {
     uno::Reference< chart2::XChartDocument > xChartDoc;
     uno::Reference< drawing::XShape > xShape( ((SdrObject*)pSdrObj)->getUnoShape(), uno::UNO_QUERY );
@@ -2277,7 +2286,23 @@ void DocxAttributeOutput::WriteOLE2Obj( const SdrObject* pSdrObj, const Size& rS
         m_pSerializer->endElementNS( XML_a, XML_graphic );
         m_pSerializer->endElementNS( XML_wp, XML_inline );
         m_pSerializer->endElementNS( XML_w, XML_drawing );
+
+        return true;
     }
+    return false;
+}
+
+bool DocxAttributeOutput::WriteOLEMath( const SdrObject*, const SwOLENode& rOLENode, const Size& )
+{
+    uno::Reference < embed::XEmbeddedObject > xObj(const_cast<SwOLENode&>(rOLENode).GetOLEObj().GetOleRef());
+    sal_Int64 nAspect = rOLENode.GetAspect();
+    svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
+    SvGlobalName aObjName(aObjRef->getClassID());
+
+    if( !SotExchange::IsMath(aObjName) )
+        return false;
+    // TODO
+    return true;
 }
 
 void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Point& /*rNdTopLeft*/ )
@@ -2339,9 +2364,14 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Po
             break;
         case sw::Frame::eOle:
             {
-                const SdrObject* pSdrObj = rFrame.GetFrmFmt().FindRealSdrObject();
+                const SwFrmFmt &rFrmFmt = rFrame.GetFrmFmt();
+                const SdrObject *pSdrObj = rFrmFmt.FindRealSdrObject();
                 if ( pSdrObj )
-                    WriteOLE2Obj( pSdrObj, rFrame.GetLayoutSize() );
+                {
+                    SwNodeIndex aIdx(*rFrmFmt.GetCntnt().GetCntntIdx(), 1);
+                    SwOLENode& rOLENd = *aIdx.GetNode().GetOLENode();
+                    WriteOLE2Obj( pSdrObj, rOLENd, rFrame.GetLayoutSize() );
+                }
             }
             break;
         default:
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index f875dc9..550ba9f 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -301,7 +301,9 @@ private:
 
     /// Output graphic fly frames.
     void FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size& rSize );
-    void WriteOLE2Obj( const SdrObject* pSdrObj, const Size& rSize );
+    void WriteOLE2Obj( const SdrObject* pSdrObj, const SwOLENode& rNode, const Size& rSize );
+    bool WriteOLEChart( const SdrObject* pSdrObj, const Size& rSize );
+    bool WriteOLEMath( const SdrObject* pSdrObj, const SwOLENode& rNode, const Size& rSize );
 
     void InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
     void StartTable( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
commit ece27b6e1c7d924715cc8a75f9d4a85636d84fff
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Aug 11 16:29:13 2011 +0200

    hack, write .docx datetime as local but mark as utc
    
    since that's how MSOffice reads it :-/

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index c66bb9d..7c5a399 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1265,7 +1265,9 @@ to find it, unfortunately :-(
 static OString impl_DateTimeToOString( const DateTime& rDateTime )
 {
     DateTime aInUTC( rDateTime );
-    aInUTC.ConvertToUTC();
+// 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() ) );
commit eccb19aebbef1a11a38e7ffb6b51c1fa6eded7e8
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Aug 11 16:24:22 2011 +0200

    Revert "adjust for timezone when reading datetime"
    
    This reverts commit 7fcd99b3d261b0bd76bbf4a7f9bfcb93793be4e4.
    Apparently everybody lives in UTC+0 timezone according to MSOffice,
    wherever they live.

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 0d2e311..82d2b75 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -74,7 +74,6 @@
 #include <rtl/string.h>
 #include "FieldTypes.hxx"
 
-#include <tools/datetime.hxx>
 #include <tools/string.hxx>
 #ifdef DEBUG_DOMAINMAPPER
 #include <resourcemodel/QNameToString.hxx>
@@ -974,60 +973,26 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap )
 
 util::DateTime lcl_DateStringToDateTime( const ::rtl::OUString& rDateTime )
 {
-    DateTime aDateTime;
+    util::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 );
+    // HACK: this is broken according to the spec, but MSOffice always treats the time as local,
+    // and writes it as Z (=UTC+0)
     ::rtl::OUString sTime = rDateTime.getToken( 0, 'Z', nIndex );
-    int timezonepos = nIndex;
     nIndex = 0;
-    aDateTime.SetYear( sDate.getToken( 0, '-', nIndex ).toInt32() );
-    aDateTime.SetMonth( sDate.getToken( 0, '-', nIndex ).toInt32() );
-    aDateTime.SetDay( sDate.copy( nIndex ).toInt32() );
+    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() );
 
     nIndex = 0;
-    aDateTime.SetHour( sTime.getToken( 0, ':', nIndex ).toInt32() );
-    aDateTime.SetMin( sTime.getToken( 0, ':', nIndex ).toInt32() );
-    aDateTime.SetSec( sTime.copy( nIndex ).toInt32() );
+    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() );
 
-    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;
+    return aDateTime;
 }
-
 void DomainMapper_Impl::appendTextPortion( const ::rtl::OUString& rString, PropertyMapPtr pPropertyMap )
 {
     if (m_aTextAppendStack.empty())


More information about the Libreoffice-commits mailing list