Tag: cws_src680_dba24d
User: oj      
Date: 2007-11-26 15:14:19+0000
Modified:
   dba/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
   dba/dbaccess/source/ui/misc/WCopyTable.cxx
   dba/dbaccess/source/ui/inc/WCopyTable.hxx

Log:
 #i49703# copy table settings

File Changes:

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

File [changed]: FieldDescriptions.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx?r1=1.26.70.2&r2=1.26.70.3
Delta lines:  +8 -3
-------------------
--- FieldDescriptions.cxx       2007-11-15 15:17:33+0000        1.26.70.2
+++ FieldDescriptions.cxx       2007-11-26 15:14:16+0000        1.26.70.3
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: FieldDescriptions.cxx,v $
  *
- *  $Revision: 1.26.70.2 $
+ *  $Revision: 1.26.70.3 $
  *
- *  last change: $Author: fs $ $Date: 2007/11/15 15:17:33 $
+ *  last change: $Author: oj $ $Date: 2007/11/26 15:14:16 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -99,7 +99,11 @@
 OFieldDescription::OFieldDescription( const OFieldDescription& rDescr )
     :m_aDefaultValue(rDescr.m_aDefaultValue)
     ,m_aControlDefault(rDescr.m_aControlDefault)
+    ,m_aWidth(rDescr.m_aWidth)
+    ,m_aRelativePosition(rDescr.m_aRelativePosition)
     ,m_pType(rDescr.m_pType)
+    ,m_xDest(rDescr.m_xDest)
+    ,m_xDestInfo(rDescr.m_xDestInfo)
     ,m_sName(rDescr.m_sName)
     ,m_sTypeName(rDescr.m_sTypeName)
     ,m_sDescription(rDescr.m_sDescription)
@@ -112,6 +116,7 @@
     ,m_eHorJustify(rDescr.m_eHorJustify)
     ,m_bIsAutoIncrement(rDescr.m_bIsAutoIncrement)
     ,m_bIsPrimaryKey(rDescr.m_bIsPrimaryKey)
+    ,m_bIsCurrency(rDescr.m_bIsCurrency)
     ,m_bHidden(rDescr.m_bHidden)
 {
     DBG_CTOR(OFieldDescription,NULL);
@@ -181,7 +186,7 @@
                                
if(xPropSetInfo->hasPropertyByName(PROPERTY_HIDDEN))
                                        
xAffectedCol->getPropertyValue(PROPERTY_HIDDEN) >>= m_bHidden;
                                
if(xPropSetInfo->hasPropertyByName(PROPERTY_ALIGN))
-                                       SetHorJustify( 
::dbaui::mapTextJustify(::comphelper::getINT16(xAffectedCol->getPropertyValue(PROPERTY_ALIGN))));
+                                       SetHorJustify( 
::dbaui::mapTextJustify(::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_ALIGN))));
                                
if(xPropSetInfo->hasPropertyByName(PROPERTY_ISAUTOINCREMENT))
                                        
SetAutoIncrement(::cppu::any2bool(xAffectedCol->getPropertyValue(PROPERTY_ISAUTOINCREMENT)));
                        }

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

File [changed]: WCopyTable.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/WCopyTable.cxx?r1=1.53.28.7&r2=1.53.28.8
Delta lines:  +64 -36
---------------------
--- WCopyTable.cxx      2007-11-26 12:05:07+0000        1.53.28.7
+++ WCopyTable.cxx      2007-11-26 15:14:16+0000        1.53.28.8
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: WCopyTable.cxx,v $
  *
- *  $Revision: 1.53.28.7 $
+ *  $Revision: 1.53.28.8 $
  *
- *  last change: $Author: fs $ $Date: 2007/11/26 12:05:07 $
+ *  last change: $Author: oj $ $Date: 2007/11/26 15:14:16 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -165,7 +165,7 @@
 void ObjectCopySource::copyUISettingsTo( const Reference< XPropertySet >& 
_rxObject ) const
 {
     const ::rtl::OUString aCopyProperties[] = {
-        PROPERTY_FONT, PROPERTY_ROW_HEIGHT, PROPERTY_TEXTCOLOR
+        PROPERTY_FONT, PROPERTY_ROW_HEIGHT, 
PROPERTY_TEXTCOLOR,PROPERTY_TEXTLINECOLOR,PROPERTY_TEXTEMPHASIS,PROPERTY_TEXTRELIEF
     };
     for ( size_t i=0; i < sizeof( aCopyProperties ) / sizeof( 
aCopyProperties[0] ); ++i )
     {
@@ -173,7 +173,54 @@
                        _rxObject->setPropertyValue( aCopyProperties[i], 
m_xObject->getPropertyValue( aCopyProperties[i] ) );
     }
 }
+//------------------------------------------------------------------------
+void ObjectCopySource::copyFilterAndSortingTo( const Reference< XConnection >& 
_xConnection,const Reference< XPropertySet >& _rxObject ) const
+{
+    ::std::pair< ::rtl::OUString, ::rtl::OUString > aProperties[] = {
+                 ::std::pair< ::rtl::OUString, ::rtl::OUString 
>(PROPERTY_FILTER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" AND ")))
+                ,::std::pair< ::rtl::OUString, ::rtl::OUString 
>(PROPERTY_ORDER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ORDER BY ")))
+    };
+
+    size_t i = 0;
+
+    try
+    {
+        const String sSourceName = 
(::dbtools::composeTableNameForSelect(m_xConnection,m_xObject) + 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")));
+        const ::rtl::OUString sTargetName = 
::dbtools::composeTableNameForSelect(_xConnection,_rxObject);
+        const String sTargetNameTemp = (sTargetName + 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")));
+
+        ::rtl::OUString sStatement(RTL_CONSTASCII_USTRINGPARAM("SELECT * FROM 
"));
+        sStatement += sTargetName;
+        sStatement += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE 
0=1"));
+        
+        
+        for ( i=0; i < sizeof( aProperties ) / sizeof( aProperties[0] ); ++i )
+        {
+                   if ( m_xObjectPSI->hasPropertyByName( aProperties[i].first 
) )
+            {
+                ::rtl::OUString sFilter;
+                m_xObject->getPropertyValue( aProperties[i].first ) >>= 
sFilter;
+                if ( sFilter.getLength() )
+                {
+                    sStatement += aProperties[i].second;
+                    String sReplace = sFilter;
+                    sReplace.SearchAndReplace(sSourceName,sTargetNameTemp);
+                    sFilter = sReplace;
+                    _rxObject->setPropertyValue( aProperties[i].first, 
makeAny(sFilter) );
+                    sStatement += sFilter;
+                }
+            }
+        }
+        
+        _xConnection->createStatement()->executeQuery(sStatement);
 
+               if ( m_xObjectPSI->hasPropertyByName( PROPERTY_APPLYFILTER ) )
+                       _rxObject->setPropertyValue( PROPERTY_APPLYFILTER, 
m_xObject->getPropertyValue( PROPERTY_APPLYFILTER ) );
+    }
+    catch(Exception&)
+    {
+    }
+}
 //------------------------------------------------------------------------
 Sequence< ::rtl::OUString > ObjectCopySource::getColumnNames() const
 {
@@ -203,7 +250,6 @@
     Reference< XPropertySet > xColumn( m_xObjectColumns->getByName( 
_rColumnName ), UNO_QUERY_THROW );
     return new OFieldDescription( xColumn );
 }
-
 //------------------------------------------------------------------------
 ::rtl::OUString ObjectCopySource::getSelectStatement() const
 {
@@ -297,7 +343,10 @@
 {
     // not supported: we do not have UI settings to copy
 }
-
+// 
-----------------------------------------------------------------------------
+void NamedTableCopySource::copyFilterAndSortingTo( const Reference< 
XConnection >& ,const Reference< XPropertySet >& /*_rxObject*/ ) const
+{
+}
 //------------------------------------------------------------------------
 void NamedTableCopySource::impl_ensureColumnInfo_nothrow()
 {
@@ -392,7 +441,6 @@
 
     return new OFieldDescription( pos->second );
 }
-
 //------------------------------------------------------------------------
 ::rtl::OUString NamedTableCopySource::getSelectStatement() const
 {
@@ -424,6 +472,7 @@
     virtual ::rtl::OUString     getQualifiedObjectName() const;
     virtual bool                isView() const;
     virtual void                copyUISettingsTo( const 
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& 
_rxObject ) const;
+    virtual void                copyFilterAndSortingTo(const 
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& 
_xConnection, const ::com::sun::star::uno::Reference< 
::com::sun::star::beans::XPropertySet >& _rxObject ) const;
     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
                                 getColumnNames() const;
     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
@@ -460,7 +509,10 @@
 {
     // no support
 }
-
+// 
-----------------------------------------------------------------------------
+void DummyCopySource::copyFilterAndSortingTo( const Reference< XConnection >& 
,const Reference< XPropertySet >& /*_rxObject*/ ) const
+{
+}
 //------------------------------------------------------------------------
 Sequence< ::rtl::OUString > DummyCopySource::getColumnNames() const
 {
@@ -480,7 +532,6 @@
     OSL_ENSURE( false, "DummyCopySource::createFieldDescription: not to be 
called!" );
     return NULL;
 }
-
 //------------------------------------------------------------------------
 ::rtl::OUString DummyCopySource::getSelectStatement() const
 {
@@ -1226,8 +1277,6 @@
                xTable->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(sSchema));
                xTable->setPropertyValue(PROPERTY_NAME,makeAny(sTable));
 
-        m_rSourceObject.copyUISettingsTo( xTable );
-
                Reference< XColumnsSupplier > xSuppDestinationColumns( xTable, 
UNO_QUERY );
                // now append the columns
                const ODatabaseExport::TColumnVector* pVec = getDestVector();
@@ -1261,6 +1310,11 @@
             xSuppDestinationColumns.set( xTable, UNO_QUERY_THROW );
                        // insert new table name into table filter
                        ::dbaui::appendToFilter( m_xDestConnection, m_sName, 
GetFactory(), this );
+
+            // copy ui settings
+            m_rSourceObject.copyUISettingsTo( xTable );
+            //copy filter and sorting
+            m_rSourceObject.copyFilterAndSortingTo(m_xDestConnection,xTable);
                        // set column mappings
                        Reference<XNameAccess> xNameAccess = 
xSuppDestinationColumns->getColumns();
                        Sequence< ::rtl::OUString> aSeq = 
xNameAccess->getElementNames();
@@ -1294,32 +1348,6 @@
                                                m_vColumnTypes[ aPosFind - 
m_vColumnPos.begin() ] = (*aFind)->second->GetType();
                                        }
                                }
-/*
-                               ODatabaseExport::TColumnVector::const_iterator 
aIter = pVec->begin();
-                               for(sal_Int32 nOldPos = 1;aIter != 
pVec->end();++aIter,++nOldPos)
-                               {
-                                       if((*aIter)->first == *pBegin)
-                                       {
-                                               if(nOldPos != nNewPos)
-                                               {
-                                                       
::std::vector<int>::iterator aFound = aAlreadyFound.begin();
-                                                       
ODatabaseExport::TPositions::iterator aColPos = m_vColumnPos.begin();
-                                                       for(; aColPos != 
m_vColumnPos.end() && nOldPos;++aColPos,++aFound)
-                                                       {
-                                                               
if(aColPos->second != COLUMN_POSITION_NOT_FOUND && !*aFound && nOldPos == 
aColPos->second)
-                                                                       break;
-                                                       }
-                                                       if(aColPos != 
m_vColumnPos.end())
-                                                       {
-                                                               *aFound = 1; 
-                                                               aColPos->second 
= nNewPos;
-                                                               
m_vColumnTypes[m_vColumnPos.end() - aColPos] = (*aIter)->second->GetType();
-                                                       }
-                                               }
-                                               break;
-                                       }
-                               }
-*/
                        }
                }
        }

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

File [changed]: WCopyTable.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/inc/WCopyTable.hxx?r1=1.22.28.5&r2=1.22.28.6
Delta lines:  +11 -2
--------------------
--- WCopyTable.hxx      2007-11-19 09:48:30+0000        1.22.28.5
+++ WCopyTable.hxx      2007-11-26 15:14:17+0000        1.22.28.6
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: WCopyTable.hxx,v $
  *
- *  $Revision: 1.22.28.5 $
+ *  $Revision: 1.22.28.6 $
  *
- *  last change: $Author: fs $ $Date: 2007/11/19 09:48:30 $
+ *  last change: $Author: oj $ $Date: 2007/11/26 15:14:17 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -162,6 +162,13 @@
         virtual OFieldDescription*  createFieldDescription( const 
::rtl::OUString& _rColumnName ) const = 0;
         /// returns the SELECT statement which can be used to retrieve the 
data of the to-be-copied object
         virtual ::rtl::OUString     getSelectStatement() const = 0;
+
+        /** copies the filter and sorting
+        *
+        * \return 
+        */
+        virtual void                copyFilterAndSortingTo(const 
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& 
_xConnection,const ::com::sun::star::uno::Reference< 
::com::sun::star::beans::XPropertySet >& _rxObject ) const = 0;
+
         /** returns the prepared statement which can be used to retrieve the 
data of the to-be-copied object
 
             The default implementation of this method will simply prepare a 
statement with the return value
@@ -195,6 +202,7 @@
         virtual ::rtl::OUString     getQualifiedObjectName() const;
         virtual bool                isView() const;
         virtual void                copyUISettingsTo( const 
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& 
_rxObject ) const;
+        virtual void                copyFilterAndSortingTo(const 
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& 
_xConnection, const ::com::sun::star::uno::Reference< 
::com::sun::star::beans::XPropertySet >& _rxObject ) const;
         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
                                     getColumnNames() const;
         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
@@ -230,6 +238,7 @@
         virtual ::rtl::OUString     getQualifiedObjectName() const;
         virtual bool                isView() const;
         virtual void                copyUISettingsTo( const 
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& 
_rxObject ) const;
+        virtual void                copyFilterAndSortingTo(const 
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& 
_xConnection,const ::com::sun::star::uno::Reference< 
::com::sun::star::beans::XPropertySet >& _rxObject ) const;
         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
                                     getColumnNames() const;
         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >




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

Reply via email to