sax/source/tools/fastserializer.cxx | 28 ++++++--------------------- sax/source/tools/fastserializer.hxx | 5 ---- sax/source/tools/fshelper.cxx | 8 ------- sc/source/filter/excel/xecontent.cxx | 12 +++++------ sc/source/filter/excel/xeextlst.cxx | 2 - sc/source/filter/excel/xestream.cxx | 7 ++++-- sc/source/filter/excel/xetable.cxx | 2 - sc/source/filter/inc/xeroot.hxx | 3 ++ sc/source/filter/inc/xestream.hxx | 3 +- sc/source/filter/xcl97/XclExpChangeTrack.cxx | 2 - 10 files changed, 28 insertions(+), 44 deletions(-)
New commits: commit 5a87aae25b05818a961beb34021db67f17336ab8 Author: Matúš Kukan <matus.ku...@collabora.com> Date: Wed Oct 1 18:45:23 2014 +0200 FastSerializer: Simplify a bit Change-Id: I7dee908f5441ad34128d688e1008fd6ffad2ab3f diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index 8ea04d2..7afdc4d 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -19,7 +19,9 @@ #include "fastserializer.hxx" +#include <com/sun/star/xml/sax/FastTokenHandler.hpp> #include <rtl/ustrbuf.hxx> +#include <comphelper/processfactory.hxx> #include <comphelper/sequenceasvector.hxx> #include <string.h> @@ -52,11 +54,14 @@ static const char sSpace[] = " "; static const char sXmlHeader[] = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"; namespace sax_fastparser { - FastSaxSerializer::FastSaxSerializer( ) + FastSaxSerializer::FastSaxSerializer( const css::uno::Reference< css::io::XOutputStream >& xOutputStream ) : maCachedOutputStream() - , mxFastTokenHandler() , maMarkStack() { + mxFastTokenHandler = css::xml::sax::FastTokenHandler::create( + ::comphelper::getProcessComponentContext()); + assert(xOutputStream.is()); // cannot do anything without that + maCachedOutputStream.setOutputStream( xOutputStream ); } FastSaxSerializer::~FastSaxSerializer() {} @@ -189,21 +194,11 @@ namespace sax_fastparser { writeBytes(sSlashAndClosingBracket, N_CHARS(sSlashAndClosingBracket)); } - void FastSaxSerializer::setOutputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream ) - { - maCachedOutputStream.setOutputStream( xOutputStream ); - } - ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > FastSaxSerializer::getOutputStream() { return maCachedOutputStream.getOutputStream(); } - void FastSaxSerializer::setFastTokenHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >& xFastTokenHandler ) - { - mxFastTokenHandler = xFastTokenHandler; - } - void FastSaxSerializer::writeTokenValueList() { #ifdef DBG_UTIL diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx index 6e81c91..60ef71b 100644 --- a/sax/source/tools/fastserializer.hxx +++ b/sax/source/tools/fastserializer.hxx @@ -48,7 +48,7 @@ class FastSaxSerializer typedef ::com::sun::star::uno::Sequence< ::sal_Int32 > Int32Sequence; public: - FastSaxSerializer(); + FastSaxSerializer( const css::uno::Reference< css::io::XOutputStream >& xOutputStream ); ~FastSaxSerializer(); ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > getOutputStream(); @@ -106,9 +106,6 @@ public: */ void singleFastElement( ::sal_Int32 Element, FastAttributeList* pAttrList = NULL ); - void setOutputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream ); - void setFastTokenHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >& xFastTokenHandler ); - // C++ helpers void writeId( ::sal_Int32 Element ); OString getId( ::sal_Int32 Element ); diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx index 2227352..55be646 100644 --- a/sax/source/tools/fshelper.cxx +++ b/sax/source/tools/fshelper.cxx @@ -19,9 +19,7 @@ #include <sax/fshelper.hxx> #include "fastserializer.hxx" -#include <com/sun/star/xml/sax/FastTokenHandler.hpp> #include <com/sun/star/xml/sax/XFastTokenHandler.hpp> -#include <comphelper/processfactory.hxx> #include <rtl/ustrbuf.hxx> using namespace ::com::sun::star; @@ -30,12 +28,8 @@ using namespace ::com::sun::star::uno; namespace sax_fastparser { FastSerializerHelper::FastSerializerHelper(const Reference< io::XOutputStream >& xOutputStream, bool bWriteHeader ) : - mpSerializer(new FastSaxSerializer()) + mpSerializer(new FastSaxSerializer(xOutputStream)) { - Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext(), UNO_SET_THROW ); - mpSerializer->setFastTokenHandler( css::xml::sax::FastTokenHandler::create(xContext) ); - assert(xOutputStream.is()); // cannot do anything without that - mpSerializer->setOutputStream( xOutputStream ); if( bWriteHeader ) mpSerializer->startDocument(); } commit 2adbe33e211e8e694bf93f50320fd3be2253f8f3 Author: Matúš Kukan <matus.ku...@collabora.com> Date: Wed Oct 1 18:24:58 2014 +0200 Unused includes / using-declarations Change-Id: I8b43635ab1f77b61469f060c9a092f1494388955 diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index 6d46cda..8ea04d2 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -19,9 +19,6 @@ #include "fastserializer.hxx" -#include <com/sun/star/xml/Attribute.hpp> -#include <com/sun/star/xml/FastAttribute.hpp> - #include <rtl/ustrbuf.hxx> #include <comphelper/sequenceasvector.hxx> @@ -34,15 +31,9 @@ using ::comphelper::SequenceAsVector; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::uno::Sequence; -using ::com::sun::star::xml::FastAttribute; using ::com::sun::star::xml::Attribute; -using ::com::sun::star::xml::sax::SAXException; using ::com::sun::star::io::XOutputStream; -using ::com::sun::star::io::NotConnectedException; -using ::com::sun::star::io::IOException; -using ::com::sun::star::io::BufferSizeExceededException; #define HAS_NAMESPACE(x) ((x & 0xffff0000) != 0) #define NAMESPACE(x) (x >> 16) commit cd6765ca13a05cb6d72e7fc3c43d685368bf7680 Author: Matúš Kukan <matus.ku...@collabora.com> Date: Wed Oct 1 17:39:00 2014 +0200 Use sc::CompileFormulaContext for faster export It's a cache for maTabNames (sheet names mangled for the current grammar for output) which ScCompiler needs and is expensive to get. Change-Id: I7e2954104427a3c220f0f097be6cd45a66485b56 diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 168e45209..c368c14 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -937,13 +937,13 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm ) if(!IsTextRule(eOperation) && !IsTopBottomRule(eOperation)) { rWorksheet->startElement( XML_formula, FSEND ); - rWorksheet->writeEscaped(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(), + rWorksheet->writeEscaped(XclXmlUtils::ToOUString( GetCompileFormulaContext(), mrFormatEntry.GetValidSrcPos(), mrFormatEntry.CreateTokenArry(0))); rWorksheet->endElement( XML_formula ); if (bFmla2) { rWorksheet->startElement( XML_formula, FSEND ); - rWorksheet->writeEscaped(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(), + rWorksheet->writeEscaped(XclXmlUtils::ToOUString( GetCompileFormulaContext(), mrFormatEntry.GetValidSrcPos(), mrFormatEntry.CreateTokenArry(1))); rWorksheet->endElement( XML_formula ); } @@ -1082,7 +1082,7 @@ void XclExpCfvo::SaveXml( XclExpXmlStream& rStrm ) OString aValue; if(mrEntry.GetType() == COLORSCALE_FORMULA) { - OUString aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), maSrcPos, + OUString aFormula = XclXmlUtils::ToOUString( GetCompileFormulaContext(), maSrcPos, mrEntry.GetFormula()->Clone()); aValue = OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 ); } @@ -1583,7 +1583,7 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong nScHandle ) : Formula compiler supports this by offering two different functions CreateDataValFormula() and CreateListValFormula(). */ mxTokArr1 = rFmlaComp.CreateFormula( EXC_FMLATYPE_LISTVAL, *xScTokArr ); - msFormula1 = XclXmlUtils::ToOUString( GetDoc(), pValData->GetSrcPos(), + msFormula1 = XclXmlUtils::ToOUString( GetCompileFormulaContext(), pValData->GetSrcPos(), xScTokArr.get()); } } @@ -1591,7 +1591,7 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong nScHandle ) : { // no list validation -> convert the formula mxTokArr1 = rFmlaComp.CreateFormula( EXC_FMLATYPE_DATAVAL, *xScTokArr ); - msFormula1 = XclXmlUtils::ToOUString( GetDoc(), pValData->GetSrcPos(), + msFormula1 = XclXmlUtils::ToOUString( GetCompileFormulaContext(), pValData->GetSrcPos(), xScTokArr.get()); } } @@ -1601,7 +1601,7 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong nScHandle ) : if( xScTokArr.get() ) { mxTokArr2 = rFmlaComp.CreateFormula( EXC_FMLATYPE_DATAVAL, *xScTokArr ); - msFormula2 = XclXmlUtils::ToOUString( GetDoc(), pValData->GetSrcPos(), + msFormula2 = XclXmlUtils::ToOUString( GetCompileFormulaContext(), pValData->GetSrcPos(), xScTokArr.get()); } } diff --git a/sc/source/filter/excel/xeextlst.cxx b/sc/source/filter/excel/xeextlst.cxx index 852647c..bb96e27 100644 --- a/sc/source/filter/excel/xeextlst.cxx +++ b/sc/source/filter/excel/xeextlst.cxx @@ -62,7 +62,7 @@ XclExpExtCfvo::XclExpExtCfvo( const XclExpRoot& rRoot, const ScColorScaleEntry& OUString aFormula; if(pArr) { - aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), rSrcPos, + aFormula = XclXmlUtils::ToOUString( GetCompileFormulaContext(), rSrcPos, pArr->Clone()); } maValue = OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 ); diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index 31e39c7..9d1adb0 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -39,6 +39,7 @@ #include "compiler.hxx" #include "formulacell.hxx" #include "tokenarray.hxx" +#include "tokenstringcontext.hxx" #include "refreshtimerprotector.hxx" #include "globstr.hrc" @@ -810,9 +811,10 @@ OUString XclXmlUtils::ToOUString( const ScfUInt16Vec& rBuf, sal_Int32 nStart, sa } OUString XclXmlUtils::ToOUString( - ScDocument& rDocument, const ScAddress& rAddress, const ScTokenArray* pTokenArray ) + sc::CompileFormulaContext& rCtx, const ScAddress& rAddress, const ScTokenArray* pTokenArray ) { - ScCompiler aCompiler( &rDocument, rAddress, const_cast<ScTokenArray&>(*pTokenArray)); + ScCompiler aCompiler( rCtx, rAddress, const_cast<ScTokenArray&>(*pTokenArray)); + aCompiler.SetGrammar(FormulaGrammar::GRAM_OOXML); OUStringBuffer aBuffer( pTokenArray->GetLen() * 5 ); @@ -1077,6 +1079,7 @@ bool XclExpXmlStream::exportDocument() aData.maMaxPos.SetCol( ::std::min( aData.maScMaxPos.Col(), aData.maXclMaxPos.Col() ) ); aData.maMaxPos.SetRow( ::std::min( aData.maScMaxPos.Row(), aData.maXclMaxPos.Row() ) ); aData.maMaxPos.SetTab( ::std::min( aData.maScMaxPos.Tab(), aData.maXclMaxPos.Tab() ) ); + aData.mpCompileFormulaCxt.reset( new sc::CompileFormulaContext(&rDoc) ); XclExpRoot aRoot( aData ); diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index ed4b137..e0dcf70 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -946,7 +946,7 @@ void XclExpFormulaCell::SaveXml( XclExpXmlStream& rStrm ) // OOXTODO: XML_bx bool FSEND ); rWorksheet->writeEscaped( XclXmlUtils::ToOUString( - *mrScFmlaCell.GetDocument(), mrScFmlaCell.aPos, mrScFmlaCell.GetCode())); + rStrm.GetRoot().GetCompileFormulaContext(), mrScFmlaCell.aPos, mrScFmlaCell.GetCode())); rWorksheet->endElement( XML_f ); if( strcmp( sType, "inlineStr" ) == 0 ) { diff --git a/sc/source/filter/inc/xeroot.hxx b/sc/source/filter/inc/xeroot.hxx index 35de5c6..698b0e4 100644 --- a/sc/source/filter/inc/xeroot.hxx +++ b/sc/source/filter/inc/xeroot.hxx @@ -52,6 +52,7 @@ class XclExpFilterManager; class XclExpPivotTableManager; class XclExpDxfs; class XclExpXmlPivotTableManager; +namespace sc { class CompileFormulaContext; } /** Stores global buffers and data needed for Excel export filter. */ struct XclExpRootData : public XclRootData @@ -92,6 +93,7 @@ struct XclExpRootData : public XclRootData XclExpDxfsRef mxDxfs; /// All delta formatting entries boost::shared_ptr<XclExpXmlPivotTableManager> mxXmlPTableMgr; + boost::shared_ptr<sc::CompileFormulaContext> mpCompileFormulaCxt; ScCompiler::OpCodeMapPtr mxOpCodeMap; /// mapping between op-codes and names @@ -112,6 +114,7 @@ public: inline const XclExpRoot& GetRoot() const { return *this; } /** Returns true, if URLs should be stored relative to the document location. */ inline bool IsRelUrl() const { return mrExpData.mbRelUrl; } + sc::CompileFormulaContext& GetCompileFormulaContext() const { return *mrExpData.mpCompileFormulaCxt; } /** Returns the buffer for Calc->Excel sheet index conversion. */ XclExpTabInfo& GetTabInfo() const; diff --git a/sc/source/filter/inc/xestream.hxx b/sc/source/filter/inc/xestream.hxx index c705e45..df1f7a3 100644 --- a/sc/source/filter/inc/xestream.hxx +++ b/sc/source/filter/inc/xestream.hxx @@ -251,6 +251,7 @@ struct XclAddress; struct XclFontData; struct XclRange; class XclRangeList; +namespace sc { class CompileFormulaContext; } class XclXmlUtils { @@ -275,7 +276,7 @@ public: static OUString ToOUString( const char* s ); static OUString ToOUString( const ScfUInt16Vec& rBuffer, sal_Int32 nStart = 0, sal_Int32 nLength = -1 ); - static OUString ToOUString( ScDocument& rDocument, const ScAddress& rAddress, const ScTokenArray* pTokenArray ); + static OUString ToOUString( sc::CompileFormulaContext& rCtx, const ScAddress& rAddress, const ScTokenArray* pTokenArray ); static OUString ToOUString( const XclExpString& s ); /** diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx index 83cdd57..04a64eb 100644 --- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx +++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx @@ -1032,7 +1032,7 @@ static void lcl_WriteCell( XclExpXmlStream& rStrm, sal_Int32 nElement, const ScA // OOXTODO: other attributes? see XclExpFormulaCell::SaveXml() FSEND ); pStream->writeEscaped( XclXmlUtils::ToOUString( - *pData->mpFormulaCell->GetDocument(), + rStrm.GetRoot().GetCompileFormulaContext(), pData->mpFormulaCell->aPos, pData->mpFormulaCell->GetCode())); pStream->endElement( XML_f ); break;
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits