connectivity/source/parse/sqlnode.cxx | 7 +++++-- dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 2 +- dbaccess/source/core/inc/SingleSelectQueryComposer.hxx | 1 + include/connectivity/sqlparse.hxx | 10 +++++++--- include/svx/ParseContext.hxx | 11 +++++++++-- svx/source/form/ParseContext.cxx | 16 ++++++++++++++++ 6 files changed, 39 insertions(+), 8 deletions(-)
New commits: commit 57379b62950d5730cdd0ec2b14eaf55370a3298e Author: Henry Castro <[email protected]> AuthorDate: Wed Aug 30 10:23:31 2023 -0400 Commit: Caolán McNamara <[email protected]> CommitDate: Thu Aug 31 18:15:23 2023 +0200 connectivity: add neutral context parser Signed-off-by: Henry Castro <[email protected]> Change-Id: I12b0fe811d141873aaa64af5b6c457051c3356b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156297 Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 1cb631a80c78..e8e8b44f463b 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -1305,8 +1305,11 @@ std::unique_ptr<OSQLParseNode> OSQLParser::predicateTree(OUString& rErrorMessage } -OSQLParser::OSQLParser(css::uno::Reference< css::uno::XComponentContext > xContext, const IParseContext* _pContext) +OSQLParser::OSQLParser(css::uno::Reference< css::uno::XComponentContext > xContext, + const IParseContext* _pContext, + const IParseContext* _pNeutral) :m_pContext(_pContext) + ,m_pNeutral(_pNeutral) ,m_pData( new OSQLParser_Data ) ,m_nFormatKey(0) ,m_nDateFormatKey(0) diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 45d9a8ce6595..15667d7d170b 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -217,7 +217,7 @@ OSingleSelectQueryComposer::OSingleSelectQueryComposer(const Reference< XNameAcc const Reference<XComponentContext>& _rContext ) :OSubComponent(m_aMutex,_xConnection) ,OPropertyContainer(m_aBHelper) - ,m_aSqlParser( _rContext, &m_aParseContext ) + ,m_aSqlParser( _rContext, &m_aParseContext, &m_aNeutralContext ) ,m_aSqlIterator( _xConnection, _rxTables, m_aSqlParser ) ,m_aAdditiveIterator( _xConnection, _rxTables, m_aSqlParser ) ,m_aElementaryParts( size_t(SQLPartCount) ) diff --git a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx index a0edfd195a69..fdde2d451d17 100644 --- a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx +++ b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx @@ -76,6 +76,7 @@ namespace dbaccess typedef std::function<const ::connectivity::OSQLParseNode*(::connectivity::OSQLParseTreeIterator *)> TGetParseNode; ::svxform::OSystemParseContext m_aParseContext; + ::svxform::ONeutralParseContext m_aNeutralContext; ::connectivity::OSQLParser m_aSqlParser; ::connectivity::OSQLParseTreeIterator m_aSqlIterator; // the iterator for the complete statement ::connectivity::OSQLParseTreeIterator m_aAdditiveIterator; // the iterator for the "additive statement" (means without the clauses of the elementary statement) diff --git a/include/connectivity/sqlparse.hxx b/include/connectivity/sqlparse.hxx index 7e55d41e339f..50c72f6ebcdc 100644 --- a/include/connectivity/sqlparse.hxx +++ b/include/connectivity/sqlparse.hxx @@ -124,7 +124,8 @@ namespace connectivity static sal_Int32 s_nRefCount; // information on the current parse action - const IParseContext* m_pContext; + const IParseContext* m_pContext; + const IParseContext* m_pNeutral; std::unique_ptr<OSQLParseNode> m_pParseTree; // result from parsing ::std::unique_ptr< OSQLParser_Data > m_pData; @@ -156,7 +157,9 @@ namespace connectivity public: // if NULL, a default context will be used // the context must live as long as the parser - OSQLParser(css::uno::Reference< css::uno::XComponentContext > xContext, const IParseContext* _pContext = nullptr); + OSQLParser(css::uno::Reference< css::uno::XComponentContext > xContext, + const IParseContext* _pContext = nullptr, + const IParseContext* _pNeutral = nullptr); ~OSQLParser(); // Parsing an SQLStatement @@ -173,7 +176,8 @@ namespace connectivity bool bUseRealName = true); // Access to the context - const IParseContext& getContext() const {return *m_pContext;} + const IParseContext& getContext() const { return *m_pContext; } + const IParseContext* getNeutral() const { return m_pNeutral; } /// access to the SQLError instance owned by this parser const SQLError& getErrorHelper() const; commit 091d74c16e33a1c4cf3e456363965528392f7033 Author: Henry Castro <[email protected]> AuthorDate: Wed Aug 30 10:16:37 2023 -0400 Commit: Caolán McNamara <[email protected]> CommitDate: Thu Aug 31 18:15:16 2023 +0200 svx: add class "ONeutralParseContext" If Base SQL query: SELECT COUNT("test"."id") FROM Test Then changed to Spanish interface, it is required to have a neutral keyword localized, the "COUNT" will fail to detect column type, because the keyword in Spanish is "RECUENTO" Signed-off-by: Henry Castro <[email protected]> Change-Id: I191b9591ad796d0dd9509c0fb10b11c16f72e1ce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156296 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/include/svx/ParseContext.hxx b/include/svx/ParseContext.hxx index 4b8f451a8014..b5b8b7c84ea6 100644 --- a/include/svx/ParseContext.hxx +++ b/include/svx/ParseContext.hxx @@ -31,11 +31,12 @@ namespace svxform //= OSystemParseContext - class SAL_DLLPUBLIC_RTTI OSystemParseContext final : public ::connectivity::IParseContext + class SAL_DLLPUBLIC_RTTI OSystemParseContext : public ::connectivity::IParseContext { - private: + protected: ::std::vector< OUString > m_aLocalizedKeywords; + OSystemParseContext(bool bInit); public: SVXCORE_DLLPUBLIC OSystemParseContext(); @@ -57,6 +58,12 @@ namespace svxform }; + class SAL_DLLPUBLIC_RTTI ONeutralParseContext final : public OSystemParseContext + { + public: + SVXCORE_DLLPUBLIC ONeutralParseContext(); + SVXCORE_DLLPUBLIC virtual ~ONeutralParseContext(); + }; //= OParseContextClient diff --git a/svx/source/form/ParseContext.cxx b/svx/source/form/ParseContext.cxx index 63634179142e..d231bfb3cd52 100644 --- a/svx/source/form/ParseContext.cxx +++ b/svx/source/form/ParseContext.cxx @@ -41,6 +41,11 @@ OSystemParseContext::OSystemParseContext() m_aLocalizedKeywords.push_back(SvxResId(RID_RSC_SQL_INTERNATIONAL[i])); } +OSystemParseContext::OSystemParseContext(bool /*bInit*/) + : IParseContext() +{ +} + OSystemParseContext::~OSystemParseContext() { } @@ -140,6 +145,17 @@ IParseContext::InternationalKeyCode OSystemParseContext::getIntlKeyCode(const OS return InternationalKeyCode::None; } +ONeutralParseContext::ONeutralParseContext() + : OSystemParseContext(false) +{ + std::locale aLocale = Translate::Create("svx", LanguageTag("en-US")); + for (size_t i = 0; i < SAL_N_ELEMENTS(RID_RSC_SQL_INTERNATIONAL); ++i) + m_aLocalizedKeywords.push_back(Translate::get(RID_RSC_SQL_INTERNATIONAL[i], aLocale)); +} + +ONeutralParseContext::~ONeutralParseContext() +{ +} namespace { commit 985559a9d8e1e0bd0b6bddc1776c0c06fb029160 Author: Henry Castro <[email protected]> AuthorDate: Wed Aug 30 10:09:05 2023 -0400 Commit: Caolán McNamara <[email protected]> CommitDate: Thu Aug 31 18:15:09 2023 +0200 connectivity: fix return column type "DataType::SQLNULL" The Base SQL query: SELECT COUNT( "Test"."id" ) FROM "Test" And the UI language is set to Spanish, the function "getFunctionReturnType" returns misleading column type. Signed-off-by: Henry Castro <[email protected]> Change-Id: I2b57d1dfc005711374d7ae0de66b412f4f551d89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156295 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index d98e8cc80064..1cb631a80c78 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -2494,7 +2494,7 @@ void OSQLParseNode::parseLeaf(OUStringBuffer& rString, const SQLParseNodeParamet sal_Int32 OSQLParser::getFunctionReturnType(std::u16string_view _sFunctionName, const IParseContext* pContext) { - sal_Int32 nType = DataType::VARCHAR; + sal_Int32 nType = DataType::SQLNULL; OString sFunctionName(OUStringToOString(_sFunctionName,RTL_TEXTENCODING_UTF8)); if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_ASCII,pContext))) nType = DataType::INTEGER;
