Tag: cws_src680_qiq
User: fs      
Date: 06/05/24 02:10:47

Modified:
 /dba/dbaccess/source/core/api/
  querycontainer.cxx

Log:
 #i51143# approveNewObject: use XObjectNames to determine whether the query 
name is allowed

File Changes:

Directory: /dba/dbaccess/source/core/api/
=========================================

File [changed]: querycontainer.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/querycontainer.cxx?r1=1.23.4.1&r2=1.23.4.2
Delta lines:  +54 -14
---------------------
--- querycontainer.cxx  10 May 2006 14:23:16 -0000      1.23.4.1
+++ querycontainer.cxx  24 May 2006 09:10:44 -0000      1.23.4.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: querycontainer.cxx,v $
  *
- *  $Revision: 1.23.4.1 $
+ *  $Revision: 1.23.4.2 $
  *
- *  last change: $Author: fs $ $Date: 2006/05/10 14:23:16 $
+ *  last change: $Author: fs $ $Date: 2006/05/24 09:10:44 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -43,6 +43,28 @@
 #include "query.hxx"
 #endif
 
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
+#include <com/sun/star/container/XContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_TOOLS_XCONNECTIONTOOLS_HPP_
+#include <com/sun/star/sdb/tools/XConnectionTools.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
+#include <com/sun/star/sdb/CommandType.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+
 #ifndef _TOOLS_DEBUG_HXX
 #include <tools/debug.hxx>
 #endif
@@ -61,18 +83,8 @@
 #ifndef _COMPHELPER_EXTRACT_HXX_
 #include <comphelper/extract.hxx>
 #endif
-
-#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
-#include <com/sun/star/beans/XPropertySet.hpp>
-#endif
-#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
-#include <com/sun/star/container/XContainer.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
-#include <com/sun/star/sdbc/XConnection.hpp>
-#endif
-#ifndef _DBHELPER_DBEXCEPTION_HXX_
-#include <connectivity/dbexception.hxx>
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
 #endif
 
 using namespace dbtools;
@@ -80,6 +92,8 @@
 using namespace ::com::sun::star::ucb;
 using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdb::tools;
+using namespace ::com::sun::star::sdb;
 using namespace ::com::sun::star::sdbc;
 using namespace ::com::sun::star::sdbcx;
 using namespace ::com::sun::star::container;
@@ -408,6 +422,32 @@
 
        return m_xCommandDefinitions->getElementNames();
 }
+
+// 
-----------------------------------------------------------------------------
+void OQueryContainer::approveNewObject( const ::rtl::OUString& _sName, const 
Reference< XContent >& _rxObject) const
+{
+    ODefinitionContainer::approveNewObject( _sName, _rxObject );
+
+    Reference< XConnectionTools > xConnectionTools( m_xConnection, 
UNO_QUERY_THROW );
+    Reference< XObjectNames > xObjectNames( 
xConnectionTools->createObjectNames(), UNO_QUERY_THROW );
+    try
+    {
+        xObjectNames->checkNameIsUsed( CommandType::QUERY, _sName );
+        // this is a little bit overkill, since it will also check whether the 
given name is already
+        // used as query name - which is what 
ODefinitionContainer::approveNewObject already did.
+        // However, the main functionality here is that checkNameIsUsed also 
checks for conflicts with
+        // table names, in case we belong to a connection where queries and 
tables share the
+        // same namespace
+    }
+    catch( const SQLException& )
+    {
+       WrappedTargetException aWrapped;
+        aWrapped.Context = *this;
+        aWrapped.TargetException = ::cppu::getCaughtException();
+        throw aWrapped;
+    }
+}
+
 //........................................................................
 }      // namespace dbaccess
 //........................................................................




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to