User: ihi     
Date: 2006/10/18 06:30:02

Modified:
   dba/dbaccess/source/ui/app/AppControllerDnD.cxx

Log:
 INTEGRATION: CWS dba205b (1.16.20); FILE MERGED
 2006/09/04 12:03:20 oj 1.16.20.4: RESYNC: (1.16-1.17); FILE MERGED
 2006/08/03 10:05:23 oj 1.16.20.3: ensure that a connection exists
 2006/07/31 12:00:34 oj 1.16.20.2: #i67016# copy column settings of a query
 2006/07/31 10:00:35 oj 1.16.20.1: #i67017# copy all properties

File Changes:

Directory: /dba/dbaccess/source/ui/app/
=======================================

File [changed]: AppControllerDnD.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppControllerDnD.cxx?r1=1.19&r2=1.20
Delta lines:  +50 -24
---------------------
--- AppControllerDnD.cxx        5 Oct 2006 12:59:33 -0000       1.19
+++ AppControllerDnD.cxx        18 Oct 2006 13:29:59 -0000      1.20
@@ -42,9 +42,21 @@
 #ifndef _COMPHELPER_SEQUENCE_HXX_
 #include <comphelper/sequence.hxx>
 #endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
 #include "dbustrings.hrc"
 #endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
 #ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
 #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
 #endif
@@ -745,11 +757,6 @@
                                        return sal_False;
                                }
 
-                               // three properties we can set only if we have 
a query object as source
-                               ::rtl::OUString sUpdateTableName;
-                               ::rtl::OUString sUpdateSchemaName;
-                               ::rtl::OUString sUpdateCatalogName;
-
                                // the target object name (as we'll suggest it 
to the user)
                                String sTargetName;
                                Reference< XNameAccess > xQueries;
@@ -766,6 +773,7 @@
                                        OSL_ENSURE(0,"could not create query 
default name!");
                                }
 
+                Reference< XPropertySet > xQuery;
                                if (CommandType::QUERY == nCommandType)
                                {
                                        // need to extract the statement and 
the escape processing flag from the query object
@@ -773,7 +781,6 @@
                                        try
                                        {
                                                // the concrete query
-                                               Reference< XPropertySet > 
xQuery;
                                                
Reference<XQueryDefinitionsSupplier> 
xSourceQuerySup(getDataSourceByName_displayError( m_xDatabaseContext, 
sDataSourceName, getView(), getORB(), true ),UNO_QUERY);
                                                if ( xSourceQuerySup.is() )
                                                        
xQueries.set(xSourceQuerySup->getQueryDefinitions(),UNO_QUERY);
@@ -781,18 +788,7 @@
                                                if ( xQueries.is() && 
xQueries->hasByName(sCommand) )
                                                {
                                                        
xQuery.set(xQueries->getByName(sCommand),UNO_QUERY);
-
-                                                       if (xQuery.is())
-                                                       {
-                                                               // extract all 
the properties we're interested in
-                                                               
xQuery->getPropertyValue(PROPERTY_COMMAND) >>= sCommand;
-                                                               
xQuery->getPropertyValue(PROPERTY_USE_ESCAPE_PROCESSING) >>= bEscapeProcessing;
-
-                                                               
xQuery->getPropertyValue(PROPERTY_UPDATE_TABLENAME) >>= sUpdateTableName;
-                                                               
xQuery->getPropertyValue(PROPERTY_UPDATE_SCHEMANAME) >>= sUpdateSchemaName;
-                                                               
xQuery->getPropertyValue(PROPERTY_UPDATE_CATALOGNAME) >>= sUpdateCatalogName;
-                                                               bSuccess = 
sal_True;
-                                                       }
+                                                       bSuccess = xQuery.is();
                                                        xQueries.clear();
                                                }
                                        }
@@ -818,6 +814,7 @@
 
                                // here we have everything needed to create a 
new query object ...
                                // ... ehm, except a new name
+                ensureConnection();
                 DynamicTableOrQueryNameCheck aNameChecker( getConnection(), 
CommandType::QUERY );
                                OSaveAsDlg aAskForName( getView(),
                                                                                
CommandType::QUERY,
@@ -838,13 +835,42 @@
                                if (xNewQuery.is())
                                {
                                        // initialize
-                                       xNewQuery->setPropertyValue( 
PROPERTY_COMMAND, makeAny(sCommand) );
-                                       xNewQuery->setPropertyValue( 
PROPERTY_USE_ESCAPE_PROCESSING, makeAny(bEscapeProcessing) );
-                                       xNewQuery->setPropertyValue( 
PROPERTY_UPDATE_TABLENAME, makeAny(sUpdateTableName) );
-                                       xNewQuery->setPropertyValue( 
PROPERTY_UPDATE_SCHEMANAME, makeAny(sUpdateSchemaName) );
-                                       xNewQuery->setPropertyValue( 
PROPERTY_UPDATE_CATALOGNAME, makeAny(sUpdateCatalogName) );
+                                       if ( xQuery.is() )
+                           ::comphelper::copyProperties(xQuery,xNewQuery);
+                                       else
+                                       {
+                        
xNewQuery->setPropertyValue(PROPERTY_COMMAND,makeAny(sCommand));
+                        
xNewQuery->setPropertyValue(PROPERTY_USE_ESCAPE_PROCESSING,makeAny(bEscapeProcessing));
+                    }
                                        // insert
                                        xDestQueries->insertByName( 
sTargetName, makeAny(xNewQuery) );
+                    xNewQuery.set(xDestQueries->getByName( 
sTargetName),UNO_QUERY);
+                    if ( xQuery.is() && xNewQuery.is() )
+                    {
+                        Reference<XColumnsSupplier> 
xSrcColSup(xQuery,UNO_QUERY);
+                        Reference<XColumnsSupplier> 
xDstColSup(xNewQuery,UNO_QUERY);
+                        if ( xSrcColSup.is() && xDstColSup.is() )
+                           {
+                                   Reference<XNameAccess> xSrcNameAccess = 
xSrcColSup->getColumns();
+                            Reference<XNameAccess> xDstNameAccess = 
xDstColSup->getColumns();
+                            Reference<XDataDescriptorFactory> 
xFac(xDstNameAccess,UNO_QUERY);
+                            Reference<XAppend> xAppend(xFac,UNO_QUERY);
+                                   if ( xSrcNameAccess.is() && 
xDstNameAccess.is() && xSrcNameAccess->hasElements() && xAppend.is() )
+                            {
+                                Reference<XPropertySet> 
xDstProp(xFac->createDataDescriptor());
+                                
+                                Sequence< ::rtl::OUString> aSeq = 
xSrcNameAccess->getElementNames();
+                                           const ::rtl::OUString* pIter = 
aSeq.getConstArray();
+                                           const ::rtl::OUString* pEnd   = 
pIter + aSeq.getLength();
+                                           for( ; pIter != pEnd ; ++pIter)
+                                           {
+                                                   Reference<XPropertySet> 
xSrcProp(xSrcNameAccess->getByName(*pIter),UNO_QUERY);
+                                    
::comphelper::copyProperties(xSrcProp,xDstProp);
+                                    xAppend->appendByDescriptor(xDstProp);
+                                }
+                            }
+                        }
+                                       }
                                }
                        }
                        else




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

Reply via email to