Tag: cws_src680_oj14
User: fs      
Date: 2007-06-04 20:29:23+0000
Log:
 some refactoring

File Changes:

Directory: /dba/connectivity/source/commontools/
================================================

File [changed]: paramwrapper.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/commontools/paramwrapper.cxx?r1=1.1.2.2&r2=1.1.2.3
Delta lines:  +42 -9
--------------------
--- paramwrapper.cxx    2007-06-04 13:19:34+0000        1.1.2.2
+++ paramwrapper.cxx    2007-06-04 20:29:20+0000        1.1.2.3
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: paramwrapper.cxx,v $
  *
- *  $Revision: 1.1.2.2 $
+ *  $Revision: 1.1.2.3 $
  *
- *  last change: $Author: fs $ $Date: 2007/06/04 13:19:34 $
+ *  last change: $Author: fs $ $Date: 2007/06/04 20:29:20 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -47,6 +47,9 @@
 #ifndef _COM_SUN_STAR_LANG_WRAPPEDTARGETEXCEPTION_HPP_
 #include <com/sun/star/lang/WrappedTargetException.hpp>
 #endif
+#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XParametersSupplier.hpp>
+#endif
 /** === end UNO includes === **/
 
 #include <tools/diagnose_ex.h>
@@ -57,6 +60,8 @@
 //........................................................................
 namespace dbtools
 {
+namespace param
+{
 //........................................................................
 
     /** === begin UNO using === **/
@@ -80,6 +85,8 @@
     using ::com::sun::star::lang::WrappedTargetException;
     using ::com::sun::star::lang::IndexOutOfBoundsException;
     using ::com::sun::star::container::XEnumeration;
+    using ::com::sun::star::sdb::XSingleSelectQueryAnalyzer;
+    using ::com::sun::star::sdb::XParametersSupplier;
     /** === end UNO using === **/
     namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
     namespace DataType = ::com::sun::star::sdbc::DataType;
@@ -88,6 +95,16 @@
     //= ParameterWrapper
     //====================================================================
     //--------------------------------------------------------------------
+    ParameterWrapper::ParameterWrapper( const Reference< XPropertySet >& 
_rxColumn )
+        :OPropertySetHelper( m_aBHelper )
+        ,m_xDelegator( _rxColumn )
+    {
+        if ( m_xDelegator.is() )
+            m_xDelegatorPSI = m_xDelegator->getPropertySetInfo();
+        if ( !m_xDelegatorPSI.is() )
+            throw RuntimeException();
+    }
+
     //--------------------------------------------------------------------
     ParameterWrapper::ParameterWrapper( const Reference< XPropertySet >& 
_rxColumn,
             const Reference< XParameters >& _rxAllParameters, const 
::std::vector< sal_Int32 >& _rIndexes )
@@ -183,7 +200,7 @@
         (void)nHandle;
 
         // we're lazy here ...
-        rOldValue = m_aValue;
+        rOldValue = m_aValue.makeAny();
         rConvertedValue = rValue;
         return sal_True;    // assume "modified" ...
     }
@@ -203,11 +220,14 @@
                 if ( m_xDelegatorPSI->hasPropertyByName( ::rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM( "Scale" ) ) ) )
                     OSL_VERIFY( m_xDelegator->getPropertyValue( 
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Scale" ) ) ) >>= nScale );
 
+                if ( m_xValueDestination.is() )
+                {
                 for ( ::std::vector< sal_Int32 >::iterator aIter = 
m_aIndexes.begin(); aIter != m_aIndexes.end(); ++aIter )
                 {
                     m_xValueDestination->setObjectWithInfo( *aIter + 1, 
rValue, nParamType, nScale );
                         // (the index of the parameters is one-based)
                 }
+                }
 
                 m_aValue = rValue;
             }
@@ -232,7 +252,7 @@
     {
         if ( nHandle == PROPERTY_ID_VALUE )
         {
-            rValue = m_aValue;
+            rValue = m_aValue.makeAny();
         }
         else
         {
@@ -250,6 +270,19 @@
     }
 
     //--------------------------------------------------------------------
+    ParameterWrapperContainer::ParameterWrapperContainer( const Reference< 
XSingleSelectQueryAnalyzer >& _rxComposer )
+    {
+        Reference< XParametersSupplier > xSuppParams( _rxComposer, 
UNO_QUERY_THROW );
+        Reference< XIndexAccess > xParameters( xSuppParams->getParameters(), 
UNO_QUERY_THROW );
+        sal_Int32 nParamCount( xParameters->getCount() );
+        m_aParameters.reserve( nParamCount );
+        for ( sal_Int32 i=0; i<nParamCount; ++i )
+        {
+            m_aParameters.push_back( new ParameterWrapper( Reference< 
XPropertySet >( xParameters->getByIndex( i ), UNO_QUERY_THROW ) ) );
+        }
+    }
+
+    //--------------------------------------------------------------------
     Type SAL_CALL ParameterWrapperContainer::getElementType() throw( 
RuntimeException )
     {
         return ::getCppuType( static_cast< Reference< XPropertySet >* >( NULL 
) );
@@ -273,7 +306,7 @@
         if ( ( _nIndex < 0 ) || ( _nIndex >= (sal_Int32)m_aParameters.size() ) 
)
             throw IndexOutOfBoundsException();
 
-        return makeAny( m_aParameters[ _nIndex ] );
+        return makeAny( Reference< XPropertySet >( m_aParameters[ _nIndex 
].get() ) );
     }
 
     //--------------------------------------------------------------------
@@ -288,5 +321,5 @@
     }
 
 //........................................................................
-} // namespace dbtools
+} } // namespace dbtools::param
 //........................................................................




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

Reply via email to