connectivity/source/parse/sqlnode.cxx                  |    5 ++++-
 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, 38 insertions(+), 7 deletions(-)

New commits:
commit 8f705a714b57ef3a8086fd8750cf271616e051a8
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Wed Aug 30 10:23:31 2023 -0400
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Oct 25 11:08:18 2023 +0200

    connectivity: add neutral context parser
    
    Signed-off-by: Henry Castro <hcas...@collabora.com>
    Change-Id: I12b0fe811d141873aaa64af5b6c457051c3356b0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156297
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156424
    Tested-by: Jenkins
    (cherry picked from commit ae951137fae8afca65f695a5ca789ee1b9811629)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158274
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/connectivity/source/parse/sqlnode.cxx 
b/connectivity/source/parse/sqlnode.cxx
index 052b6b15cb05..b523e370a7a1 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 4e37188e7231..895657475f25 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 c3314c470c6b..1bcfd272ad86 100644
--- a/include/connectivity/sqlparse.hxx
+++ b/include/connectivity/sqlparse.hxx
@@ -123,7 +123,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;
@@ -155,7 +156,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
@@ -172,7 +175,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 bd53cbe6546a143809aea395d277f33bffe0154c
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Wed Aug 30 10:16:37 2023 -0400
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Oct 25 11:08:09 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 <hcas...@collabora.com>
    Change-Id: I191b9591ad796d0dd9509c0fb10b11c16f72e1ce
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156296
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156423
    Tested-by: Jenkins
    (cherry picked from commit 47d77c822fb58f9617379969b078c8a6230767d6)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158273
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

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
 {

Reply via email to