[Libreoffice-commits] .: 3 commits - sc/source

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Thu Apr 19 17:38:06 PDT 2012


 sc/source/filter/excel/xecontent.cxx |   19 +++++++++++++++----
 sc/source/filter/excel/xeroot.cxx    |    6 ++++++
 sc/source/filter/excel/xestyle.cxx   |   26 ++++++++++++++++++++++----
 3 files changed, 43 insertions(+), 8 deletions(-)

New commits:
commit 503c8fdb1705f0b91e5181b250a6dc94e94e835d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Apr 20 02:28:55 2012 +0200

    export font information into dxf

diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index ca608ca..c73a08b 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -28,12 +28,14 @@
 
 #include "xestyle.hxx"
 
+#include <iostream>
 #include <algorithm>
 #include <iterator>
 #include <set>
 #include <com/sun/star/i18n/ScriptType.hpp>
 #include <vcl/font.hxx>
 #include <svl/zformat.hxx>
+#include <svl/itempool.hxx>
 #include <svl/languageoptions.hxx>
 #include <sfx2/printer.hxx>
 #include "scitems.hxx"
@@ -2878,9 +2880,16 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot )
                         delete pCellArea;
                         pCellArea = NULL;
                     }
-                    //XclExpFont* pFont = new XclExpFont( GetRoot(), XclFontData( rFont ), EXC_COLOR_CELLTEXT );
 
-                    maDxf.push_back(new XclExpDxf( rRoot, pAlign, pBorder, NULL, NULL, pCellProt, pCellArea ));
+                    XclExpFont* pFont = NULL;
+                    // check if non default font is set and only export then
+                    if (rSet.GetItemState(rSet.GetPool()->GetWhich( SID_ATTR_CHAR_FONT ))>SFX_ITEM_DEFAULT )
+                    {
+                        Font aFont = XclExpFontHelper::GetFontFromItemSet( GetRoot(), rSet, com::sun::star::i18n::ScriptType::WEAK );
+                        pFont = new XclExpFont( GetRoot(), XclFontData( aFont ), EXC_COLOR_CELLTEXT );
+                    }
+
+                    maDxf.push_back(new XclExpDxf( rRoot, pAlign, pBorder, pFont, NULL, pCellProt, pCellArea ));
                     ++nIndex;
                 }
 
commit e878c9bba31386cbdb9caca3cbc588a25dc1ae1e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Apr 20 00:12:20 2012 +0200

    allow more complex conditional formats being exported to xlsx

diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 3deb48a..8dfe1cb 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -783,7 +783,7 @@ void XclExpCFImpl::WriteBody( XclExpStream& rStrm )
 
 namespace {
 
-const char* GetOperatorString(ScConditionMode eMode)
+const char* GetOperatorString(ScConditionMode eMode, bool& bFrmla2)
 {
     switch(eMode)
     {
@@ -800,8 +800,10 @@ const char* GetOperatorString(ScConditionMode eMode)
         case SC_COND_NOTEQUAL:
             return "notEqual";
         case SC_COND_BETWEEN:
+            bFrmla2 = true;
             return "between";
         case SC_COND_NOTBETWEEN:
+            bFrmla2 = true;
             return "notBetween";
         case SC_COND_DUPLICATE:
         case SC_COND_NOTDUPLICATE:
@@ -814,8 +816,10 @@ const char* GetOperatorString(ScConditionMode eMode)
     return "";
 }
 
-const char* GetTypeString()
+const char* GetTypeString(ScConditionMode eMode)
 {
+    if (eMode == SC_COND_DIRECT)
+        return "expression";
     return "cellIs";
 }
 
@@ -823,15 +827,18 @@ const char* GetTypeString()
 
 void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
 {
+    bool bFmla2 = false;
     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
     rWorksheet->startElement( XML_cfRule,
-            XML_type, GetTypeString(),
+            XML_type, GetTypeString( mrFormatEntry.GetOperation() ),
             XML_priority, OString::valueOf( mnPriority + 1 ).getStr(),
-            XML_operator, GetOperatorString( mrFormatEntry.GetOperation() ),
+            XML_operator, GetOperatorString( mrFormatEntry.GetOperation(), bFmla2 ),
             XML_dxfId, OString::valueOf( GetDxfs().GetDxfId( mrFormatEntry.GetStyle() ) ).getStr(),
             FSEND );
     rWorksheet->startElement( XML_formula, FSEND );
     rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(), mrFormatEntry.CreateTokenArry( 0 ) ));
+    if (bFmla2)
+        rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(), mrFormatEntry.CreateTokenArry( 1 ) ));
     rWorksheet->endElement( XML_formula );
     // OOXTODO: XML_extLst
     rWorksheet->endElement( XML_cfRule );
commit f6a940ad1771016021a75c41a0e9be1e86843fb9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Apr 19 23:09:58 2012 +0200

    export conditional formatting to xlsx, fdo#48360
    
    This is not yet perfect but should export already the conditional
    formatting and a great deal of the styles to xlsx
    
    Still missing:
    
    font export
    number format export
    some advanced conditional formats features

diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 17bd7e3..3deb48a 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -828,7 +828,11 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
             XML_type, GetTypeString(),
             XML_priority, OString::valueOf( mnPriority + 1 ).getStr(),
             XML_operator, GetOperatorString( mrFormatEntry.GetOperation() ),
+            XML_dxfId, OString::valueOf( GetDxfs().GetDxfId( mrFormatEntry.GetStyle() ) ).getStr(),
             FSEND );
+    rWorksheet->startElement( XML_formula, FSEND );
+    rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(), mrFormatEntry.CreateTokenArry( 0 ) ));
+    rWorksheet->endElement( XML_formula );
     // OOXTODO: XML_extLst
     rWorksheet->endElement( XML_cfRule );
 }
diff --git a/sc/source/filter/excel/xeroot.cxx b/sc/source/filter/excel/xeroot.cxx
index bff5368..0516560 100644
--- a/sc/source/filter/excel/xeroot.cxx
+++ b/sc/source/filter/excel/xeroot.cxx
@@ -161,6 +161,12 @@ XclExpFilterManager& XclExpRoot::GetFilterManager() const
     return *mrExpData.mxFilterMgr;
 }
 
+XclExpDxfs& XclExpRoot::GetDxfs() const
+{
+    OSL_ENSURE( mrExpData.mxDxfs, "XclExpRoot::GetDxfs - missing object ( wrong BIFF?)" );
+    return *mrExpData.mxDxfs;
+}
+
 XclExpPivotTableManager& XclExpRoot::GetPivotTableManager() const
 {
     OSL_ENSURE( mrExpData.mxPTableMgr, "XclExpRoot::GetPivotTableManager - missing object (wrong BIFF?)" );
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 01beec6..ca608ca 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -2889,11 +2889,20 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot )
     }
 }
 
+sal_Int32 XclExpDxfs::GetDxfId( const rtl::OUString& rStyleName )
+{
+    std::map<rtl::OUString, sal_Int32>::iterator itr = maStyleNameToDxfId.find(rStyleName);
+    if(itr!= maStyleNameToDxfId.end())
+        return itr->second;
+    return -1;
+}
+
 void XclExpDxfs::SaveXml( XclExpXmlStream& rStrm )
 {
     sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
-    rStyleSheet->startElement( XML_dxfs, FSEND,
-            XML_count, rtl::OString::valueOf( static_cast<sal_Int32>(maDxf.size())).getStr() );
+    rStyleSheet->startElement( XML_dxfs,
+            XML_count, rtl::OString::valueOf( static_cast<sal_Int32>(maDxf.size())).getStr(),
+            FSEND );
 
     for ( DxfContainer::iterator itr = maDxf.begin(); itr != maDxf.end(); ++itr )
     {


More information about the Libreoffice-commits mailing list