oox/source/core/xmlfilterbase.cxx          |    6 
 oox/source/token/namespaces.hxx.tail       |    1 
 oox/source/token/namespaces.txt            |    6 
 oox/source/token/tokens.txt                |    3 
 sc/Library_scfilt.mk                       |    1 
 sc/source/filter/inc/condformatbuffer.hxx  |    2 
 sc/source/filter/inc/extlstcontext.hxx     |  105 ++++++++++++++
 sc/source/filter/inc/worksheethelper.hxx   |    3 
 sc/source/filter/oox/condformatcontext.cxx |    3 
 sc/source/filter/oox/extlstcontext.cxx     |  208 +++++++++++++++++++++++++++++
 sc/source/filter/oox/worksheetfragment.cxx |    2 
 sc/source/filter/oox/worksheethelper.cxx   |    9 +
 12 files changed, 347 insertions(+), 2 deletions(-)

New commits:
commit 4f8af4aeacb34e3a99f49aeec66c3ada07d8a027
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Sun May 20 20:54:00 2012 +0200

    correctly import data bar information from Excel2010
    
    Change-Id: I7545dfd849f2cc9924a6bb7f6d1ca9d97c3cf079

diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt
index cec24b5..4c84cb0 100644
--- a/oox/source/token/tokens.txt
+++ b/oox/source/token/tokens.txt
@@ -714,6 +714,7 @@ axPos
 axis
 axisCol
 axisPage
+axisPosition
 axisRow
 axisValues
 azure
@@ -1296,6 +1297,7 @@ condense
 conditionalFormat
 conditionalFormats
 conditionalFormatting
+conditionalFormattings
 cone
 coneToMax
 confetti
@@ -3420,6 +3422,7 @@ nd
 ndxf
 neCell
 negativeInteger
+negativeFillColor
 neq
 never
 new
diff --git a/sc/Library_scfilt.mk b/sc/Library_scfilt.mk
index e5a4b2c..3d81d71 100644
--- a/sc/Library_scfilt.mk
+++ b/sc/Library_scfilt.mk
@@ -183,6 +183,7 @@ $(eval $(call gb_Library_add_exception_objects,scfilt,\
         sc/source/filter/oox/excelvbaproject \
         sc/source/filter/oox/externallinkbuffer \
         sc/source/filter/oox/externallinkfragment \
+       sc/source/filter/oox/extlstcontext \
         sc/source/filter/oox/formulabase \
         sc/source/filter/oox/formulaparser \
         sc/source/filter/oox/numberformatsbuffer \
diff --git a/sc/source/filter/inc/condformatbuffer.hxx 
b/sc/source/filter/inc/condformatbuffer.hxx
index de2c906..09b9a83 100644
--- a/sc/source/filter/inc/condformatbuffer.hxx
+++ b/sc/source/filter/inc/condformatbuffer.hxx
@@ -123,6 +123,8 @@ public:
 
     void SetData( ScDataBarFormat* pFormat, ScDocument* pDoc, const ScAddress& 
rAddr );
 
+    ScDataBarFormatData* getDataBarFormatData() { return mpFormat; }
+
 private:
     const CondFormat& mrCondFormat;
     ScDataBarFormatData* mpFormat;
diff --git a/sc/source/filter/inc/extlstcontext.hxx 
b/sc/source/filter/inc/extlstcontext.hxx
new file mode 100644
index 0000000..2ed742d
--- /dev/null
+++ b/sc/source/filter/inc/extlstcontext.hxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrh...@googlemail.com> 
(initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "excelhandlers.hxx"
+#include "worksheetfragment.hxx"
+
+namespace oox {
+namespace xls {
+
+class ExtCfRuleContext : public WorksheetContextBase
+{
+public:
+    explicit ExtCfRuleContext( WorksheetContextBase& rFragment, void* pDataBar 
);
+
+    virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 
nElement, const AttributeList& rAttribs );
+    virtual void        onStartElement( const AttributeList& rAttribs );
+
+private:
+    void importDataBar( const AttributeList& rAttribs );
+    void importNegativeFillColor( const AttributeList& rAttribs );
+    void* mpTarget;
+
+};
+
+/**
+ * Handle ExtLst entries in xlsx. These entries are a way to extend the 
standard
+ * without actually changing it
+ *
+ * Needed right now for data bars
+ *
+ * ExtLstLocalContext is for the entry in the datastructure that needs to be 
extended
+ */
+class ExtLstLocalContext : public WorksheetContextBase
+{
+public:
+    explicit ExtLstLocalContext( WorksheetContextBase& rFragment, void* 
pTarget ); // until now a ExtLst always extends an existing entry
+
+protected:
+    virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 
nElement, const AttributeList& rAttribs );
+    virtual void        onStartElement( const AttributeList& rAttribs );
+    virtual void        onCharacters( const ::rtl::OUString& rChars );
+
+private:
+    void* mpTarget;
+};
+
+/**
+ * A single ext entry. Will be skipped until the actual entry with the correct 
uri is found
+ */
+class ExtGlobalContext : public WorksheetContextBase
+{
+public:
+    explicit ExtGlobalContext( WorksheetContextBase& rFragment );
+
+protected:
+    virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 
nElement, const AttributeList& rAttribs );
+    virtual void        onStartElement( const AttributeList& rAttribs );
+
+private:
+};
+
+/**
+ * Used for the actual ExtLst containing the new extended definition.
+ * Uses the saved data from the ExtLstLocalContext
+ */
+class ExtLstGlobalContext : public WorksheetContextBase
+{
+public:
+    explicit ExtLstGlobalContext( WorksheetFragment& rFragment );
+
+protected:
+    virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 
nElement, const AttributeList& rAttribs );
+    virtual void        onStartElement( const AttributeList& rAttribs );
+    virtual void        onCharacters( const ::rtl::OUString& rChars );
+};
+
+} //namespace xls
+} //namespace oox
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/inc/worksheethelper.hxx 
b/sc/source/filter/inc/worksheethelper.hxx
index 93d8089..3a2de85 100644
--- a/sc/source/filter/inc/worksheethelper.hxx
+++ b/sc/source/filter/inc/worksheethelper.hxx
@@ -68,6 +68,7 @@ class SheetViewSettings;
 class VmlDrawing;
 class WorksheetSettings;
 
+typedef ::std::map< rtl::OUString, void* >  ExtLst;
 // ============================================================================
 // ============================================================================
 
@@ -249,6 +250,8 @@ public:
     /** Returns the VML drawing page for this sheet (OOXML/BIFF12 only). */
     VmlDrawing&         getVmlDrawing() const;
 
+    ExtLst&             getExtLst() const;
+
     /** Sets a column or row page break described in the passed struct. */
     void                setPageBreak( const PageBreakModel& rModel, bool 
bRowBreak );
     /** Inserts the hyperlink URL into the spreadsheet. */
diff --git a/sc/source/filter/oox/condformatcontext.cxx 
b/sc/source/filter/oox/condformatcontext.cxx
index 01ad6a4..81d56fb 100644
--- a/sc/source/filter/oox/condformatcontext.cxx
+++ b/sc/source/filter/oox/condformatcontext.cxx
@@ -27,6 +27,7 @@
  ************************************************************************/
 
 #include "condformatcontext.hxx"
+#include "extlstcontext.hxx"
 
 namespace oox {
 namespace xls {
@@ -137,6 +138,8 @@ ContextHandlerRef CondFormatContext::onCreateContext( 
sal_Int32 nElement, const
                 return new ColorScaleContext( *this, mxRule );
             else if (nElement == XLS_TOKEN( dataBar ) )
                 return new DataBarContext( *this, mxRule );
+            else if (nElement == XLS_TOKEN( extLst ) )
+                return new ExtLstLocalContext( *this, 
mxRule->getDataBar()->getDataBarFormatData() );
             else
                 return 0;
     }
diff --git a/sc/source/filter/oox/extlstcontext.cxx 
b/sc/source/filter/oox/extlstcontext.cxx
new file mode 100644
index 0000000..4b7a79f
--- /dev/null
+++ b/sc/source/filter/oox/extlstcontext.cxx
@@ -0,0 +1,208 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrh...@googlemail.com> 
(initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "extlstcontext.hxx"
+#include "worksheethelper.hxx"
+#include <oox/core/contexthandler.hxx>
+#include "colorscale.hxx"
+
+using ::oox::core::ContextHandlerRef;
+
+namespace oox {
+namespace xls {
+
+ExtCfRuleContext::ExtCfRuleContext( WorksheetContextBase& rFragment, void* 
pTarget ):
+    WorksheetContextBase( rFragment ),
+    mpTarget( pTarget )
+{
+}
+
+ContextHandlerRef ExtCfRuleContext::onCreateContext( sal_Int32 , const 
AttributeList& )
+{
+    return this;
+}
+
+void ExtCfRuleContext::onStartElement( const AttributeList& rAttribs )
+{
+    switch( getCurrentElement() )
+    {
+        case XLS_EXT_TOKEN( dataBar ):
+            importDataBar( rAttribs );
+            break;
+        case XLS_EXT_TOKEN( negativeFillColor ):
+            importNegativeFillColor( rAttribs );
+
+        default:
+            break;
+    }
+}
+
+void ExtCfRuleContext::importDataBar( const AttributeList& rAttribs )
+{
+    ScDataBarFormatData* pDataBar = 
static_cast<ScDataBarFormatData*>(mpTarget);
+    pDataBar->mbGradient = rAttribs.getBool( XML_gradient, true );
+
+    if(rAttribs.hasAttribute(XML_axisPosition))
+    {
+        rtl::OUString aAxisPosition = rAttribs.getString( XML_axisPosition, 
rtl::OUString() );
+        if( aAxisPosition == "none" )
+        {
+            pDataBar->mbSameDirection = true;
+        }
+    }
+}
+
+namespace {
+
+::Color RgbToRgbComponents( sal_Int32& nRgb )
+{
+    sal_Int32 ornR = (nRgb >> 16) & 0xFF;
+    sal_Int32 ornG = (nRgb >> 8) & 0xFF;
+    sal_Int32 ornB = nRgb & 0xFF;
+
+    return ::Color(ornR, ornG, ornB);
+}
+
+}
+
+void ExtCfRuleContext::importNegativeFillColor( const AttributeList& rAttribs )
+{
+    sal_Int32 nColor = rAttribs.getIntegerHex( XML_rgb, API_RGB_TRANSPARENT );
+    ::Color aColor = RgbToRgbComponents(nColor);
+    ::Color* pColor = new Color(aColor.GetRed(), aColor.GetGreen(), 
aColor.GetBlue());
+    static_cast<ScDataBarFormatData*>(mpTarget)->mpNegativeColor.reset(pColor);
+}
+
+ExtLstLocalContext::ExtLstLocalContext( WorksheetContextBase& rFragment, void* 
pTarget ):
+    WorksheetContextBase(rFragment),
+    mpTarget(pTarget)
+{
+}
+
+ContextHandlerRef ExtLstLocalContext::onCreateContext( sal_Int32 nElement, 
const AttributeList& )
+{
+    switch( getCurrentElement() )
+    {
+        case XLS_TOKEN( extLst ):
+            if(nElement == XLS_TOKEN( ext ))
+                return this;
+            else
+                return 0;
+            break;
+        case XLS_TOKEN( ext ):
+            if (nElement == XLS_EXT_TOKEN( id ))
+                return this;
+            else
+                return 0;
+    }
+    return 0;
+}
+
+void ExtLstLocalContext::onStartElement( const AttributeList& )
+{
+    switch( getCurrentElement() )
+    {
+        case XLS_EXT_TOKEN( id ):
+        break;
+    }
+}
+
+void ExtLstLocalContext::onCharacters( const rtl::OUString& rChars )
+{
+    if (getCurrentElement() == XLS_EXT_TOKEN( id ))
+    {
+        getExtLst().insert( std::pair< rtl::OUString, void*>(rChars, mpTarget) 
);
+    }
+}
+
+ExtGlobalContext::ExtGlobalContext( WorksheetContextBase& rFragment ):
+    WorksheetContextBase(rFragment)
+{
+}
+
+ContextHandlerRef ExtGlobalContext::onCreateContext( sal_Int32 nElement, const 
AttributeList& rAttribs )
+{
+    if(!rAttribs.hasAttribute( XML_id))
+        return this;
+    else
+    {
+        if(nElement == XLS_EXT_TOKEN( cfRule ))
+        {
+            rtl::OUString aId = rAttribs.getString( XML_id, rtl::OUString() );
+            void* pInfo = getExtLst().find( aId )->second;
+            if (!pInfo)
+            {
+                return NULL;
+            }
+            return new ExtCfRuleContext( *this, pInfo );
+        }
+        else
+            return this;
+    }
+
+    return 0;
+}
+
+void ExtGlobalContext::onStartElement( const AttributeList& rAttribs )
+{
+    if(rAttribs.hasAttribute( XML_id ))
+    {
+        rtl::OUString aId = rAttribs.getString( XML_id, rtl::OUString() );
+    }
+
+    if(rAttribs.hasAttribute( XML_uri ))
+    {
+        rtl::OUString aUri = rAttribs.getString( XML_uri, rtl::OUString() );
+    }
+}
+
+ExtLstGlobalContext::ExtLstGlobalContext( WorksheetFragment& rFragment ):
+    WorksheetContextBase(rFragment)
+{
+}
+
+ContextHandlerRef ExtLstGlobalContext::onCreateContext( sal_Int32 nElement, 
const AttributeList& )
+{
+    if (nElement == XLS_TOKEN( ext ))
+        return new ExtGlobalContext( *this );
+
+    return this;
+}
+
+void ExtLstGlobalContext::onStartElement( const AttributeList& )
+{
+}
+
+void ExtLstGlobalContext::onCharacters( const rtl::OUString&)
+{
+}
+
+} //namespace oox
+} //namespace xls
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/oox/worksheetfragment.cxx 
b/sc/source/filter/oox/worksheetfragment.cxx
index 0b0c25f..be41a16 100644
--- a/sc/source/filter/oox/worksheetfragment.cxx
+++ b/sc/source/filter/oox/worksheetfragment.cxx
@@ -48,6 +48,7 @@
 #include "sheetdatabuffer.hxx"
 #include "sheetdatacontext.hxx"
 #include "tablefragment.hxx"
+#include "extlstcontext.hxx"
 #include "viewsettings.hxx"
 #include "workbooksettings.hxx"
 #include "worksheetsettings.hxx"
@@ -253,6 +254,7 @@ ContextHandlerRef WorksheetFragment::onCreateContext( 
sal_Int32 nElement, const
                 case XLS_TOKEN( dataValidations ):          return new 
DataValidationsContext( *this );
                 case XLS_TOKEN( autoFilter ):               return new 
AutoFilterContext( *this, getAutoFilters().createAutoFilter() );
                 case XLS_TOKEN( scenarios ):                return new 
ScenariosContext( *this );
+                case XLS_TOKEN( extLst ):                   return new 
ExtLstGlobalContext( *this );
 
                 case XLS_TOKEN( sheetViews ):
                 case XLS_TOKEN( cols ):
diff --git a/sc/source/filter/oox/worksheethelper.cxx 
b/sc/source/filter/oox/worksheethelper.cxx
index 84b1678..43c1b33 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -297,6 +297,9 @@ public:
     inline SheetViewSettings& getSheetViewSettings() { return maSheetViewSett; 
}
     /** Returns the VML drawing page for this sheet (OOXML/BIFF12 only). */
     inline VmlDrawing&  getVmlDrawing() { return *mxVmlDrawing; }
+    /** returns the ExtLst entries that need to be filled */
+    inline ExtLst&      getExtLst() { return maExtLst; }
+
     /** Returns the BIFF drawing page for this sheet (BIFF2-BIFF8 only). */
     inline BiffSheetDrawing& getBiffDrawing() const { return *mxBiffDrawing; }
 
@@ -408,6 +411,7 @@ private:
     PageSettings        maPageSett;         /// Page/print settings for this 
sheet.
     SheetViewSettings   maSheetViewSett;    /// View settings for this sheet.
     VmlDrawingPtr       mxVmlDrawing;       /// Collection of all VML shapes.
+    ExtLst              maExtLst;           /// List of extended elements
     BiffSheetDrawingPtr mxBiffDrawing;      /// Collection of all BIFF/DFF 
shapes.
     OUString            maDrawingPath;      /// Path to DrawingML fragment.
     OUString            maVmlDrawingPath;   /// Path to legacy VML drawing 
fragment.
@@ -1477,6 +1481,11 @@ VmlDrawing& WorksheetHelper::getVmlDrawing() const
     return mrSheetGlob.getVmlDrawing();
 }
 
+ExtLst& WorksheetHelper::getExtLst() const
+{
+    return mrSheetGlob.getExtLst();
+}
+
 void WorksheetHelper::setPageBreak( const PageBreakModel& rModel, bool 
bRowBreak )
 {
     mrSheetGlob.setPageBreak( rModel, bRowBreak );
commit b930234aade453d8a162f609779756594532d02b
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Sun May 20 02:37:16 2012 +0200

    add namespace for extensions from Excel2010
    
    Change-Id: I45144a08729b00c1e46784b430af7bc15244dfe7

diff --git a/oox/source/core/xmlfilterbase.cxx 
b/oox/source/core/xmlfilterbase.cxx
index 24a1391..762e2bd 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -150,7 +150,8 @@ namespace
                 "http://schemas.openxmlformats.org/presentationml/2006/main";,
                 "http://schemas.openxmlformats.org/markup-compatibility/2006";,
                 "http://schemas.openxmlformats.org/spreadsheetml/2006/main/v2";,
-                "http://schemas.microsoft.com/office/drawing/2008/diagram";
+                "http://schemas.microsoft.com/office/drawing/2008/diagram";,
+                "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
             };
 
             static const sal_Int32 namespaceIds[] = {
@@ -173,7 +174,8 @@ namespace
                 NMSP_xm,
                 NMSP_mce,
                 NMSP_mceTest,
-                NMSP_dsp
+                NMSP_dsp,
+                NMSP_xlsExtLst
             };
 
             Sequence< Pair< OUString, sal_Int32 > > 
aRet(STATIC_ARRAY_SIZE(namespaceIds));
diff --git a/oox/source/token/namespaces.hxx.tail 
b/oox/source/token/namespaces.hxx.tail
index 945ebbd..ce57879 100644
--- a/oox/source/token/namespaces.hxx.tail
+++ b/oox/source/token/namespaces.hxx.tail
@@ -29,6 +29,7 @@ inline sal_Int32 getNamespace( sal_Int32 nToken ) { return 
nToken & NMSP_MASK; }
 #define VMLX_TOKEN( token )     OOX_TOKEN( vmlExcel, token )
 #define XDR_TOKEN( token )      OOX_TOKEN( dmlSpreadDr, token )
 #define XLS_TOKEN( token )      OOX_TOKEN( xls, token )
+#define XLS_EXT_TOKEN( token )  OOX_TOKEN( xlsExtLst, token )
 #define XM_TOKEN( token )       OOX_TOKEN( xm, token )
 #define XML_TOKEN( token )      OOX_TOKEN( xml, token )
 #define VMLPPT_TOKEN( token )   OOX_TOKEN( vmlPowerpoint, token )
diff --git a/oox/source/token/namespaces.txt b/oox/source/token/namespaces.txt
index 57d5905..d37e296 100644
--- a/oox/source/token/namespaces.txt
+++ b/oox/source/token/namespaces.txt
@@ -53,3 +53,9 @@ xm                      
http://schemas.microsoft.com/office/excel/2006/main
 sprm                    http://sprm
 mce                     
http://schemas.openxmlformats.org/markup-compatibility/2006
 mceTest                 
http://schemas.openxmlformats.org/spreadsheetml/2006/main/v2
+
+# extlst namespaces
+
+# xlsExtLst for features introduced by excel 2010
+xlsExtLst               
http://schemas.microsoft.com/office/spreadsheetml/2009/9/main
+
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to