[Libreoffice-commits] core.git: oox/source sc/source
Katarina Behrens
Katarina.Behrens at cib.de
Thu Jul 23 09:25:48 PDT 2015
oox/source/core/xmlfilterbase.cxx | 6 ++-
oox/source/token/namespaces-strict.txt | 3 +
oox/source/token/namespaces.hxx.tail | 1
oox/source/token/namespaces.txt | 3 +
oox/source/token/tokens.txt | 7 ++++
sc/source/filter/excel/excdoc.cxx | 5 ++
sc/source/filter/excel/xeextlst.cxx | 42 ++++++++++++++++++++++++
sc/source/filter/inc/extlstcontext.hxx | 22 ++++++++++++
sc/source/filter/inc/xeextlst.hxx | 17 +++++++++-
sc/source/filter/oox/extlstcontext.cxx | 51 ++++++++++++++++++++++++++++++
sc/source/filter/oox/workbookfragment.cxx | 3 +
11 files changed, 157 insertions(+), 3 deletions(-)
New commits:
commit c2e48be7e54efd33ad4dae0c24185597521efd46
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Mon Jul 20 11:50:54 2015 +0200
tdf#92256: OOXML save/load syntax for string reference
+ introduce a separate LibO namespace for that
Change-Id: Ie62da0746e81ea0d861680863beb03094649d41c
Reviewed-on: https://gerrit.libreoffice.org/17216
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index f1c80df..535c811 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -118,7 +118,8 @@ struct NamespaceIds: public rtl::StaticWithInit<
"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/spreadsheetml/2009/9/main"
+ "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",
+ "http://schemas.libreoffice.org/"
};
static const sal_Int32 namespaceIds[] = {
@@ -145,7 +146,8 @@ struct NamespaceIds: public rtl::StaticWithInit<
NMSP_mce,
NMSP_mceTest,
NMSP_dsp,
- NMSP_xls14Lst
+ NMSP_xls14Lst,
+ NMSP_loext
};
Sequence< beans::Pair< OUString, sal_Int32 > > aRet(SAL_N_ELEMENTS(namespaceIds));
diff --git a/oox/source/token/namespaces-strict.txt b/oox/source/token/namespaces-strict.txt
index 9359f8b..026fcfe 100644
--- a/oox/source/token/namespaces-strict.txt
+++ b/oox/source/token/namespaces-strict.txt
@@ -80,3 +80,6 @@ a14 http://schemas.microsoft.com/office/drawingml/2010/main
# xls14Lst for features introduced by excel 2010
xls14Lst http://schemas.microsoft.com/office/spreadsheetml/2009/9/main
+
+# LibreOffice's own extensions
+loext http://schemas.libreoffice.org/
diff --git a/oox/source/token/namespaces.hxx.tail b/oox/source/token/namespaces.hxx.tail
index de5cc21..24de645 100644
--- a/oox/source/token/namespaces.hxx.tail
+++ b/oox/source/token/namespaces.hxx.tail
@@ -55,6 +55,7 @@ inline sal_Int32 getNamespace( sal_Int32 nToken ) { return nToken & NMSP_MASK; }
#define WPS_TOKEN( token ) OOX_TOKEN( wps, token )
#define WPG_TOKEN( token ) OOX_TOKEN( wpg, token )
#define W_TOKEN( token ) OOX_TOKEN( doc, token )
+#define LOEXT_TOKEN( token ) OOX_TOKEN( loext, token )
diff --git a/oox/source/token/namespaces.txt b/oox/source/token/namespaces.txt
index face9d6..2c61d60 100644
--- a/oox/source/token/namespaces.txt
+++ b/oox/source/token/namespaces.txt
@@ -80,3 +80,6 @@ a14 http://schemas.microsoft.com/office/drawing/2010/main
# xls14Lst for features introduced by excel 2010
xls14Lst http://schemas.microsoft.com/office/spreadsheetml/2009/9/main
+
+# LibreOffice's own extensions
+loext http://schemas.libreoffice.org/
diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt
index c26e957..1ed1681 100644
--- a/oox/source/token/tokens.txt
+++ b/oox/source/token/tokens.txt
@@ -69,6 +69,7 @@ BroadcastTitle
Broadcaster
Button
CF
+CalcA1
Camera
Cancel
Caption
@@ -141,6 +142,8 @@ Editor
ElectronicSource
Embed
EnhancedMetaFile
+ExcelA1
+ExcelR1C1
Extend
Extension
External
@@ -392,6 +395,7 @@ True
Type
Types
UIObj
+Unspecified
URI
URL
UpdateMode
@@ -2137,6 +2141,7 @@ exp
explosion
expression
ext
+extCalcPr
extLst
extend
extendable
@@ -3165,6 +3170,7 @@ lockWindows
locked
lockedCanvas
lockrotationcenter
+loext
log
logBase
lon
@@ -4954,6 +4960,7 @@ strikeH
strikeTLBR
strikeV
string
+stringRefSyntax
stringValue1
stringValue2
stripedRightArrow
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index b9788d7..b56c9b1 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -445,6 +445,11 @@ void ExcTable::FillAsHeaderXml( ExcBoundsheetList& rBoundsheetList )
aRecList.AppendRecord( GetObjectManager().CreateDrawingGroup() );
// Shared string table: SST, EXTSST
aRecList.AppendRecord( CreateRecord( EXC_ID_SST ) );
+
+ XclExtLstRef xExtLst( new XclExtLst( GetRoot() ) );
+ const ScCalcConfig& rCalcConfig = rDoc.GetCalcConfig();
+ xExtLst->AddRecord( XclExpExtRef( new XclExpExtCalcPr( GetRoot(), rCalcConfig.meStringRefAddressSyntax )) );
+ aRecList.AppendRecord( xExtLst );
}
void ExcTable::FillAsTableBinary( SCTAB nCodeNameIdx )
diff --git a/sc/source/filter/excel/xeextlst.cxx b/sc/source/filter/excel/xeextlst.cxx
index 2639bec..ebfe2cd 100644
--- a/sc/source/filter/excel/xeextlst.cxx
+++ b/sc/source/filter/excel/xeextlst.cxx
@@ -361,6 +361,48 @@ void XclExpExtConditionalFormatting::SaveXml( XclExpXmlStream& rStrm )
rWorksheet->endElementNS( XML_x14, XML_conditionalFormatting );
}
+XclExpExtCalcPr::XclExpExtCalcPr( const XclExpRoot& rRoot, formula::FormulaGrammar::AddressConvention eConv ):
+ XclExpExt( rRoot ),
+ meConv( eConv )
+{
+ maURI = OString("{7626C862-2A13-11E5-B345-FEFF819CDC9F}");
+
+ switch (meConv)
+ {
+ case formula::FormulaGrammar::CONV_OOO:
+ maSyntax = OString("CalcA1");
+ break;
+ case formula::FormulaGrammar::CONV_XL_A1:
+ maSyntax = OString("ExcelA1");
+ break;
+ case formula::FormulaGrammar::CONV_XL_R1C1:
+ maSyntax = OString("ExcelR1C1");
+ break;
+ case formula::FormulaGrammar::CONV_UNSPECIFIED:
+ case formula::FormulaGrammar::CONV_ODF:
+ case formula::FormulaGrammar::CONV_XL_OOX:
+ case formula::FormulaGrammar::CONV_LOTUS_A1:
+ case formula::FormulaGrammar::CONV_LAST:
+ maSyntax = OString("Unspecified");
+ break;
+ }
+}
+
+void XclExpExtCalcPr::SaveXml( XclExpXmlStream& rStrm )
+{
+ sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
+ rWorksheet->startElement( XML_ext,
+ FSNS( XML_xmlns, XML_loext ), "http://schemas.libreoffice.org/",
+ XML_uri, maURI.getStr(),
+ FSEND );
+
+ rWorksheet->singleElementNS( XML_loext, XML_extCalcPr,
+ XML_stringRefSyntax, maSyntax.getStr(),
+ FSEND );
+
+ rWorksheet->endElement( XML_ext );
+}
+
XclExpExtCondFormat::XclExpExtCondFormat( const XclExpRoot& rRoot ):
XclExpExt( rRoot )
{
diff --git a/sc/source/filter/inc/extlstcontext.hxx b/sc/source/filter/inc/extlstcontext.hxx
index 598adbd..d77d51a 100644
--- a/sc/source/filter/inc/extlstcontext.hxx
+++ b/sc/source/filter/inc/extlstcontext.hxx
@@ -12,6 +12,7 @@
#include "excelhandlers.hxx"
#include "worksheetfragment.hxx"
+#include "workbookfragment.hxx"
#include <boost/ptr_container/ptr_vector.hpp>
@@ -103,6 +104,27 @@ protected:
virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
};
+class ExtGlobalWorkbookContext : public WorkbookContextBase
+{
+public:
+ explicit ExtGlobalWorkbookContext( WorkbookContextBase& rFragment );
+
+protected:
+ virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
+ virtual void onStartElement( const AttributeList& rAttribs ) SAL_OVERRIDE;
+
+private:
+};
+
+class ExtLstGlobalWorkbookContext : public WorkbookContextBase
+{
+public:
+ explicit ExtLstGlobalWorkbookContext( WorkbookFragment& rFragment );
+
+protected:
+ virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
+};
+
} //namespace xls
} //namespace oox
diff --git a/sc/source/filter/inc/xeextlst.hxx b/sc/source/filter/inc/xeextlst.hxx
index f148f83..d31fb4d 100644
--- a/sc/source/filter/inc/xeextlst.hxx
+++ b/sc/source/filter/inc/xeextlst.hxx
@@ -14,12 +14,14 @@
#include "xeroot.hxx"
#include "colorscale.hxx"
+#include "formulaopt.hxx"
#include <memory>
enum XclExpExtType
{
- XclExpExtDataBarType
+ XclExpExtDataBarType,
+ XclExpExtDataFooType
};
struct XclExpExtCondFormatData
@@ -167,6 +169,19 @@ private:
XclExpRecordList< XclExpExtConditionalFormatting > maCF;
};
+class XclExpExtCalcPr : public XclExpExt
+{
+public:
+ XclExpExtCalcPr( const XclExpRoot& rRoot, formula::FormulaGrammar::AddressConvention eConv );
+ virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
+
+ virtual XclExpExtType GetType() SAL_OVERRIDE { return XclExpExtDataFooType; }
+
+private:
+ formula::FormulaGrammar::AddressConvention meConv;
+ OString maSyntax;
+};
+
class XclExtLst : public XclExpRecordBase, public XclExpRoot
{
public:
diff --git a/sc/source/filter/oox/extlstcontext.cxx b/sc/source/filter/oox/extlstcontext.cxx
index 7371f99..81590b4 100644
--- a/sc/source/filter/oox/extlstcontext.cxx
+++ b/sc/source/filter/oox/extlstcontext.cxx
@@ -249,6 +249,57 @@ ContextHandlerRef ExtLstGlobalContext::onCreateContext( sal_Int32 nElement, cons
return this;
}
+ExtGlobalWorkbookContext::ExtGlobalWorkbookContext( WorkbookContextBase& rFragment ):
+ WorkbookContextBase(rFragment)
+{
+}
+
+ContextHandlerRef ExtGlobalWorkbookContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
+{
+ if (nElement == LOEXT_TOKEN(extCalcPr))
+ {
+ ScDocument* pDoc = &getScDocument();
+ sal_Int32 nToken = rAttribs.getToken( XML_stringRefSyntax, XML_CalcA1 );
+ ScCalcConfig aCalcConfig = pDoc->GetCalcConfig();
+
+ switch( nToken )
+ {
+ case XML_CalcA1:
+ aCalcConfig.meStringRefAddressSyntax = formula::FormulaGrammar::CONV_OOO;
+ break;
+ case XML_ExcelA1:
+ aCalcConfig.meStringRefAddressSyntax = formula::FormulaGrammar::CONV_XL_A1;
+ break;
+ case XML_ExcelR1C1:
+ aCalcConfig.meStringRefAddressSyntax = formula::FormulaGrammar::CONV_XL_R1C1;
+ break;
+ default:
+ aCalcConfig.meStringRefAddressSyntax = formula::FormulaGrammar::CONV_UNSPECIFIED;
+ break;
+ }
+ pDoc->SetCalcConfig(aCalcConfig);
+ }
+
+ return this;
+}
+
+void ExtGlobalWorkbookContext::onStartElement( const AttributeList& /*rAttribs*/ )
+{
+}
+
+ExtLstGlobalWorkbookContext::ExtLstGlobalWorkbookContext( WorkbookFragment& rFragment ):
+ WorkbookContextBase(rFragment)
+{
+}
+
+ContextHandlerRef ExtLstGlobalWorkbookContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
+{
+ if (nElement == XLS_TOKEN( ext ))
+ return new ExtGlobalWorkbookContext( *this );
+
+ return this;
+}
+
} //namespace oox
} //namespace xls
diff --git a/sc/source/filter/oox/workbookfragment.cxx b/sc/source/filter/oox/workbookfragment.cxx
index 4b37d0f..06881c0 100644
--- a/sc/source/filter/oox/workbookfragment.cxx
+++ b/sc/source/filter/oox/workbookfragment.cxx
@@ -46,6 +46,7 @@
#include "worksheethelper.hxx"
#include "worksheetfragment.hxx"
#include "sheetdatacontext.hxx"
+#include "extlstcontext.hxx"
#include "officecfg/Office/Common.hxx"
#include "document.hxx"
@@ -110,6 +111,8 @@ ContextHandlerRef WorkbookFragment::onCreateContext( sal_Int32 nElement, const A
case XLS_TOKEN( workbookPr ): getWorkbookSettings().importWorkbookPr( rAttribs ); break;
case XLS_TOKEN( calcPr ): getWorkbookSettings().importCalcPr( rAttribs ); break;
case XLS_TOKEN( oleSize ): getViewSettings().importOleSize( rAttribs ); break;
+
+ case XLS_TOKEN( extLst ): return new ExtLstGlobalWorkbookContext( *this );
}
break;
More information about the Libreoffice-commits
mailing list