diff options
author | Vladimir Glazunov <vg@openoffice.org> | 2011-03-21 17:02:20 +0100 |
---|---|---|
committer | Vladimir Glazunov <vg@openoffice.org> | 2011-03-21 17:02:20 +0100 |
commit | d5b15e5ef07dbf653eb3e4509ed562a74f4712ad (patch) | |
tree | b1c143270ee33b099ecdd90b818441e4df107d27 | |
parent | c290b52a7aa1cd705ccbcf1faeecf9f03f0f70b0 (diff) | |
parent | 8807dc42d693a0068d6eb79aa1b9371b64837e14 (diff) |
CWS-TOOLING: integrate CWS dba34cooo/DEV300_m104
35 files changed, 716 insertions, 338 deletions
diff --git a/dbaccess/qa/complex/dbaccess/Query.java b/dbaccess/qa/complex/dbaccess/Query.java index c7f4674ee..d89cfcf07 100644 --- a/dbaccess/qa/complex/dbaccess/Query.java +++ b/dbaccess/qa/complex/dbaccess/Query.java @@ -40,7 +40,8 @@ import org.junit.Test; import static org.junit.Assert.*; // ------------------------------------------ -public class Query extends TestCase { +public class Query extends TestCase +{ connectivity.tools.HsqlDatabase m_database; @@ -49,17 +50,17 @@ public class Query extends TestCase { { try { - if ( m_database == null ) + if (m_database == null) { - final CRMDatabase database = new CRMDatabase( getMSF(), false ); + final CRMDatabase database = new CRMDatabase(getMSF(), false); m_database = database.getDatabase(); } } - catch( Exception e ) + catch (Exception e) { - System.out.println( "could not create the test case, error message:\n" + e.getMessage() ); - e.printStackTrace( System.err ); - fail( "failed to created the test case"); + System.out.println("could not create the test case, error message:\n" + e.getMessage()); + e.printStackTrace(System.err); + fail("failed to created the test case"); } } @@ -68,7 +69,6 @@ public class Query extends TestCase { // { // return (XMultiServiceFactory)param.getMSF(); // } - // -------------------------------------------------------------------------------------------------------- @Test public void testQueryColumns() @@ -90,23 +90,26 @@ public class Query extends TestCase { for ( int i = 0; i < queryNames.length; ++i ) { - final XPropertySet query = UnoRuntime.queryInterface( - XPropertySet.class, queries.getByName( queryNames[i] ) ); + if (queries.hasByName(queryNames[i])) + { + final XPropertySet query = UnoRuntime.queryInterface( + XPropertySet.class, queries.getByName( queryNames[i] ) ); - final XColumnsSupplier suppCols = UnoRuntime.queryInterface( - XColumnsSupplier.class, query); - final XIndexAccess columns = UnoRuntime.queryInterface( - XIndexAccess.class, suppCols.getColumns()); + final XColumnsSupplier suppCols = UnoRuntime.queryInterface( + XColumnsSupplier.class, query); + final XIndexAccess columns = UnoRuntime.queryInterface( + XIndexAccess.class, suppCols.getColumns()); - // check whether the columns supplied by the query match what we expected - assertTrue( "invalid column count (found " + columns.getCount() + ", expected: " + expectedColumnNames[i].length + ") for query \"" + queryNames[i] + "\"", - columns.getCount() == expectedColumnNames[i].length ); - for ( int col = 0; col < columns.getCount(); ++col ) - { - final XNamed columnName = UnoRuntime.queryInterface( - XNamed.class, columns.getByIndex(col) ); - assertTrue( "column no. " + col + " of query \"" + queryNames[i] + "\" not matching", - columnName.getName().equals( expectedColumnNames[i][col] ) ); + // check whether the columns supplied by the query match what we expected + assertTrue( "invalid column count (found " + columns.getCount() + ", expected: " + expectedColumnNames[i].length + ") for query \"" + queryNames[i] + "\"", + columns.getCount() == expectedColumnNames[i].length ); + for ( int col = 0; col < columns.getCount(); ++col ) + { + final XNamed columnName = UnoRuntime.queryInterface( + XNamed.class, columns.getByIndex(col) ); + assertTrue( "column no. " + col + " of query \"" + queryNames[i] + "\" not matching", + columnName.getName().equals( expectedColumnNames[i][col] ) ); + } } } } diff --git a/dbaccess/qa/complex/dbaccess/RowSet.java b/dbaccess/qa/complex/dbaccess/RowSet.java index a85fb01ac..57c82c7d7 100644 --- a/dbaccess/qa/complex/dbaccess/RowSet.java +++ b/dbaccess/qa/complex/dbaccess/RowSet.java @@ -435,6 +435,10 @@ public class RowSet extends TestCase testCursorMove(m_resultSet, cResSet.getMethod(NEXT, (Class[]) null), pRow, moves, null); moves[RowSetEventListener.IS_MODIFIED] = false; + updRow.updateString(2, m_row.getString(2)); + testCursorMove(m_resultSet, cResSet.getMethod(NEXT, (Class[]) null), pRow, moves, null); + + moves[RowSetEventListener.IS_MODIFIED] = false; final Class cupd = Class.forName("com.sun.star.sdbc.XResultSetUpdate"); final XResultSetUpdate upd = UnoRuntime.queryInterface( XResultSetUpdate.class, m_resultSet ); testCursorMove(upd, cupd.getMethod("moveToInsertRow", (Class[]) null), pRow, moves, null); diff --git a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java index 09a597576..a0e1c3cac 100755 --- a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java +++ b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java @@ -55,11 +55,12 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase { private XSingleSelectQueryComposer m_composer = null; - private final static String COMPLEXFILTER = "( \"ID\" = 1 AND \"Postal\" = '4' )" + - " OR ( \"ID\" = 2 AND \"Postal\" = '5' )" + - " OR ( \"ID\" = '3' AND \"Postal\" = '6' AND \"Address\" = '7' )" + - " OR ( \"Address\" = '8' )" + - " OR ( \"Postal\" = '9' )"; + private final static String COMPLEXFILTER = "( \"ID\" = 1 AND \"Postal\" = '4' )" + + " OR ( \"ID\" = 2 AND \"Postal\" = '5' )" + + " OR ( \"ID\" = 3 AND \"Postal\" = '6' AND \"Address\" = '7' )" + + " OR ( \"Address\" = '8' )" + + " OR ( \"Postal\" = '9' )" + + " OR ( NOW( ) = {D '2010-01-01' } )"; private final static String INNERPRODUCTSQUERY = "products (inner)"; // -------------------------------------------------------------------------------------------------------- @@ -124,7 +125,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase realValue.equals(_attributeValue)); System.out.println(" (results in " + m_composer.getQuery() + ")"); } - + /** tests setCommand of the composer */ @Test @@ -135,15 +136,15 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase try { final String table = "SELECT * FROM \"customers\""; - m_composer.setCommand("customers",CommandType.TABLE); + m_composer.setCommand("customers", CommandType.TABLE); assertTrue("setCommand/getQuery TABLE inconsistent", m_composer.getQuery().equals(table)); - + m_database.getDatabase().getDataSource().createQuery("set command test", "SELECT * FROM \"orders for customer\" \"a\", \"customers\" \"b\" WHERE \"a\".\"Product Name\" = \"b\".\"Name\""); - m_composer.setCommand("set command test",CommandType.QUERY); + m_composer.setCommand("set command test", CommandType.QUERY); assertTrue("setCommand/getQuery QUERY inconsistent", m_composer.getQuery().equals(m_database.getDatabase().getDataSource().getQueryDefinition("set command test").getCommand())); - + final String sql = "SELECT * FROM \"orders for customer\" WHERE \"Product Name\" = 'test'"; - m_composer.setCommand(sql,CommandType.COMMAND); + m_composer.setCommand(sql, CommandType.COMMAND); assertTrue("setCommand/getQuery COMMAND inconsistent", m_composer.getQuery().equals(sql)); } catch (Exception e) @@ -151,6 +152,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase fail("Exception caught: " + e); } } + /** tests accessing attributes of the composer (order, filter, group by, having) */ @Test @@ -161,6 +163,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase try { System.out.println("check setElementaryQuery"); + final String simpleQuery2 = "SELECT * FROM \"customers\" WHERE \"Name\" = 'oranges'"; m_composer.setElementaryQuery(simpleQuery2); assertTrue("setElementaryQuery/getQuery inconsistent", m_composer.getQuery().equals(simpleQuery2)); @@ -169,24 +172,24 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase final String simpleQuery = "SELECT * FROM \"customers\""; m_composer.setQuery(simpleQuery); assertTrue("set/getQuery inconsistent", m_composer.getQuery().equals(simpleQuery)); - + checkAttributeAccess("Filter", "\"Name\" = 'oranges'"); checkAttributeAccess("Group", "\"City\""); checkAttributeAccess("Order", "\"Address\""); checkAttributeAccess("HavingClause", "\"ID\" <> 4"); - + final XIndexAccess orderColumns = m_composer.getOrderColumns(); assertTrue("Order columns doesn't exist: \"Address\"", - orderColumns != null && orderColumns.getCount() == 1 && orderColumns.getByIndex(0) != null); - + orderColumns != null && orderColumns.getCount() == 1 && orderColumns.getByIndex(0) != null); + final XIndexAccess groupColumns = m_composer.getGroupColumns(); assertTrue("Group columns doesn't exist: \"City\"", - groupColumns != null && groupColumns.getCount() == 1 && groupColumns.getByIndex(0) != null); - + groupColumns != null && groupColumns.getCount() == 1 && groupColumns.getByIndex(0) != null); + // XColumnsSupplier final XColumnsSupplier xSelectColumns = UnoRuntime.queryInterface(XColumnsSupplier.class, m_composer); assertTrue("no select columns, or wrong number of select columns", - xSelectColumns != null && xSelectColumns.getColumns() != null && xSelectColumns.getColumns().getElementNames().length == 6); + xSelectColumns != null && xSelectColumns.getColumns() != null && xSelectColumns.getColumns().getElementNames().length == 6); // structured filter m_composer.setQuery("SELECT \"ID\", \"Postal\", \"Address\" FROM \"customers\""); @@ -194,6 +197,11 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase final PropertyValue[][] aStructuredFilter = m_composer.getStructuredFilter(); m_composer.setFilter(""); m_composer.setStructuredFilter(aStructuredFilter); + if (!m_composer.getFilter().equals(COMPLEXFILTER)) + { + System.out.println(COMPLEXFILTER); + System.out.println(m_composer.getFilter()); + } assertTrue("Structured Filter not identical", m_composer.getFilter().equals(COMPLEXFILTER)); // structured having clause @@ -244,6 +252,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase final XIndexAccess parameters = suppParams.getParameters(); final String expectedParamNames[] = + { "cname", "Product Name" @@ -276,6 +285,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase m_composer.setQuery("SELECT * FROM \"customers\""); final Object initArgs[] = + { new NamedValue("AutomaticAddition", Boolean.valueOf(true)) }; @@ -288,8 +298,8 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase filter.addProperty("Type", PropertyAttribute.MAYBEVOID, Integer.valueOf(DataType.LONGVARCHAR)); final XPropertySet column = UnoRuntime.queryInterface(XPropertySet.class, filter); - m_composer.appendFilterByColumn(column, true,SQLFilterOperator.LIKE); - assertTrue("At least one row should exist",m_database.getConnection().createStatement().executeQuery(m_composer.getQuery()).next()); + m_composer.appendFilterByColumn(column, true, SQLFilterOperator.LIKE); + assertTrue("At least one row should exist", m_database.getConnection().createStatement().executeQuery(m_composer.getQuery()).next()); } catch (Exception e) @@ -333,16 +343,16 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase { // a simple case: WHERE clause simply is a combination of predicates knitted with AND String query = - "SELECT \"customers\".\"Name\", " + - "\"customers\".\"Address\", " + - "\"customers\".\"City\", " + - "\"customers\".\"Postal\", " + - "\"products\".\"Name\" " + - "FROM \"orders\", \"customers\", \"orders_details\", \"products\" " + - "WHERE ( \"orders\".\"CustomerID\" = \"customers\".\"ID\" " + - "AND \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " + - "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " + - ") "; + "SELECT \"customers\".\"Name\", " + + "\"customers\".\"Address\", " + + "\"customers\".\"City\", " + + "\"customers\".\"Postal\", " + + "\"products\".\"Name\" " + + "FROM \"orders\", \"customers\", \"orders_details\", \"products\" " + + "WHERE ( \"orders\".\"CustomerID\" = \"customers\".\"ID\" " + + "AND \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " + + "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " + + ") "; impl_testDisjunctiveNormalForm(query, new PropertyValue[][] { @@ -356,20 +366,20 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase // somewhat more challenging: One of the conjunction terms is a disjunction itself query = - "SELECT \"customers\".\"Name\", " + - "\"customers\".\"Address\", " + - "\"customers\".\"City\", " + - "\"customers\".\"Postal\", " + - "\"products\".\"Name\" " + - "FROM \"orders\", \"customers\", \"orders_details\", \"products\" " + - "WHERE ( \"orders\".\"CustomerID\" = \"customers\".\"ID\" " + - "AND \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " + - "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " + - ") " + - "AND " + - "( \"products\".\"Name\" = 'Apples' " + - "OR \"products\".\"ID\" = 2 " + - ")"; + "SELECT \"customers\".\"Name\", " + + "\"customers\".\"Address\", " + + "\"customers\".\"City\", " + + "\"customers\".\"Postal\", " + + "\"products\".\"Name\" " + + "FROM \"orders\", \"customers\", \"orders_details\", \"products\" " + + "WHERE ( \"orders\".\"CustomerID\" = \"customers\".\"ID\" " + + "AND \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " + + "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " + + ") " + + "AND " + + "( \"products\".\"Name\" = 'Apples' " + + "OR \"products\".\"ID\" = 2 " + + ")"; impl_testDisjunctiveNormalForm(query, new PropertyValue[][] { diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx index 634927a8b..19a3bdd29 100644 --- a/dbaccess/source/core/api/CacheSet.cxx +++ b/dbaccess/source/core/api/CacheSet.cxx @@ -691,6 +691,20 @@ sal_Bool SAL_CALL OCacheSet::previous( ) throw(SQLException, RuntimeException) m_bInserted = m_bUpdated = m_bDeleted = sal_False; return m_xDriverSet->previous(); } +sal_Bool OCacheSet::last_checked( sal_Bool /*i_bFetchRow*/) +{ + return last(); +} +// ------------------------------------------------------------------------- +sal_Bool OCacheSet::previous_checked( sal_Bool /*i_bFetchRow*/ ) +{ + return previous(); +} +// ------------------------------------------------------------------------- +sal_Bool OCacheSet::absolute_checked( sal_Int32 row,sal_Bool /*i_bFetchRow*/ ) +{ + return absolute(row); +} // ------------------------------------------------------------------------- void SAL_CALL OCacheSet::refreshRow( ) throw(SQLException, RuntimeException) { diff --git a/dbaccess/source/core/api/CacheSet.hxx b/dbaccess/source/core/api/CacheSet.hxx index 729ccf263..4c4a37578 100644 --- a/dbaccess/source/core/api/CacheSet.hxx +++ b/dbaccess/source/core/api/CacheSet.hxx @@ -174,6 +174,9 @@ namespace dbaccess virtual bool columnValuesUpdated(ORowSetValueVector::Vector& o_aCachedRow,const ORowSetValueVector::Vector& i_aRow); virtual bool updateColumnValues(const ORowSetValueVector::Vector& io_aCachedRow,ORowSetValueVector::Vector& io_aRow,const ::std::vector<sal_Int32>& i_aChangedColumns); virtual void fillMissingValues(ORowSetValueVector::Vector& io_aRow) const; + virtual sal_Bool previous_checked( sal_Bool i_bFetchRow ); + virtual sal_Bool absolute_checked( sal_Int32 row,sal_Bool i_bFetchRow ); + virtual sal_Bool last_checked( sal_Bool i_bFetchRow); }; } #endif //DBACCESS_CORE_API_CACHESET_HXX diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 34fa1b2ca..8420c5e22 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -154,7 +154,8 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable, const ::rtl::OUString& _rUpdateTableName, // this can be the alias or the full qualified name const Reference< XSingleSelectQueryAnalyzer >& _xComposer, const ORowSetValueVector& _aParameterValueForCache, - sal_Int32 i_nMaxRows) + sal_Int32 i_nMaxRows, + sal_Int32& o_nRowCount) :OCacheSet(i_nMaxRows) ,m_aParameterValueForCache(_aParameterValueForCache) ,m_pKeyColumnNames(NULL) @@ -165,6 +166,7 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable, ,m_xTableKeys(_xTableKeys) ,m_xComposer(_xComposer) ,m_sUpdateTableName(_rUpdateTableName) + ,m_rRowCount(o_nRowCount) ,m_bRowCountFinal(sal_False) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::OKeySet" ); @@ -1167,6 +1169,12 @@ sal_Bool SAL_CALL OKeySet::next( ) throw(SQLException, RuntimeException) ++m_aKeyIter; // this is possible because we stand on begin() and this is the "beforefirst" row if(m_aKeyIter == m_aKeyMap.end() && !fetchRow()) m_aKeyIter = m_aKeyMap.end(); + else + { + //m_aKeyIter->second.second.second = new OPrivateRow(_rInsertRow->get()); + m_xRow.set(m_xDriverRow,UNO_QUERY_THROW); + return !isAfterLast(); + } } else if(!isAfterLast()) ++m_aKeyIter; @@ -1233,20 +1241,26 @@ sal_Bool SAL_CALL OKeySet::first( ) throw(SQLException, RuntimeException) ++m_aKeyIter; if(m_aKeyIter == m_aKeyMap.end() && !fetchRow()) m_aKeyIter = m_aKeyMap.end(); - - refreshRow(); + else + refreshRow(); return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); } // ----------------------------------------------------------------------------- sal_Bool SAL_CALL OKeySet::last( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::last" ); + return last_checked(sal_True); +} + +sal_Bool OKeySet::last_checked( sal_Bool i_bFetchRow) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::last_checked" ); m_bInserted = m_bUpdated = m_bDeleted = sal_False; fillAllRows(); m_aKeyIter = m_aKeyMap.end(); --m_aKeyIter; - refreshRow(); + if ( i_bFetchRow ) + refreshRow(); return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); } // ----------------------------------------------------------------------------- @@ -1261,6 +1275,10 @@ sal_Int32 SAL_CALL OKeySet::getRow( ) throw(SQLException, RuntimeException) // ----------------------------------------------------------------------------- sal_Bool SAL_CALL OKeySet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) { + return absolute_checked(row,sal_True); +} +sal_Bool OKeySet::absolute_checked( sal_Int32 row,sal_Bool i_bFetchRow ) +{ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::absolute" ); m_bInserted = m_bUpdated = m_bDeleted = sal_False; OSL_ENSURE(row,"absolute(0) isn't allowed!"); @@ -1281,6 +1299,11 @@ sal_Bool SAL_CALL OKeySet::absolute( sal_Int32 row ) throw(SQLException, Runtime sal_Bool bNext = sal_True; for(sal_Int32 i=m_aKeyMap.size()-1;i < row && bNext;++i) bNext = fetchRow(); + if ( bNext ) + { + m_xRow.set(m_xDriverRow,UNO_QUERY_THROW); + return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); + } } else m_aKeyIter = m_aKeyMap.end(); @@ -1292,7 +1315,8 @@ sal_Bool SAL_CALL OKeySet::absolute( sal_Int32 row ) throw(SQLException, Runtime ++m_aKeyIter; } } - refreshRow(); + if ( i_bFetchRow ) + refreshRow(); return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); } @@ -1308,18 +1332,25 @@ sal_Bool SAL_CALL OKeySet::relative( sal_Int32 rows ) throw(SQLException, Runtim return absolute(getRow()+rows); } // ----------------------------------------------------------------------------- -sal_Bool SAL_CALL OKeySet::previous( ) throw(SQLException, RuntimeException) +sal_Bool OKeySet::previous_checked( sal_Bool i_bFetchRow ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::previous" ); m_bInserted = m_bUpdated = m_bDeleted = sal_False; if(m_aKeyIter != m_aKeyMap.begin()) { --m_aKeyIter; - refreshRow(); + if ( i_bFetchRow ) + refreshRow(); } return m_aKeyIter != m_aKeyMap.begin(); } // ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OKeySet::previous( ) throw(SQLException, RuntimeException) +{ + return previous_checked(sal_True); +} + +// ----------------------------------------------------------------------------- void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::refreshRow" ); @@ -1374,9 +1405,18 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException) OSL_ENSURE(m_xSet.is(),"No resultset form statement!"); sal_Bool bOK = m_xSet->next(); if ( !bOK ) - m_aKeyIter = m_aKeyMap.end(); - m_xRow.set(m_xSet,UNO_QUERY); - OSL_ENSURE(m_xRow.is(),"No row form statement!"); + { + OKeySetMatrix::iterator aTemp = m_aKeyIter; + ++m_aKeyIter; + m_aKeyMap.erase(aTemp); + --m_rRowCount; + refreshRow(); + } + else + { + m_xRow.set(m_xSet,UNO_QUERY); + OSL_ENSURE(m_xRow.is(),"No row form statement!"); + } } // ----------------------------------------------------------------------------- sal_Bool OKeySet::fetchRow() diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx index 5a94d1d10..3ce26fcae 100644 --- a/dbaccess/source/core/api/KeySet.hxx +++ b/dbaccess/source/core/api/KeySet.hxx @@ -113,6 +113,7 @@ namespace dbaccess ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer > m_xComposer; ::rtl::OUString m_sUpdateTableName; ::std::vector< ::rtl::OUString > m_aFilterColumns; + sal_Int32& m_rRowCount; sal_Bool m_bRowCountFinal; @@ -160,7 +161,8 @@ namespace dbaccess const ::rtl::OUString& _rUpdateTableName, const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer, const ORowSetValueVector& _aParameterValueForCache, - sal_Int32 i_nMaxRows); + sal_Int32 i_nMaxRows, + sal_Int32& o_nRowCount); // late ctor which can throw exceptions virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter); @@ -228,6 +230,11 @@ namespace dbaccess virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + + virtual sal_Bool previous_checked( sal_Bool i_bFetchRow ); + virtual sal_Bool absolute_checked( sal_Int32 row,sal_Bool i_bFetchRow ); + virtual sal_Bool last_checked( sal_Bool i_bFetchRow); }; } #endif // DBACCESS_CORE_API_KEYSET_HXX diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx index ecde8d20e..ed522c1aa 100644 --- a/dbaccess/source/core/api/OptimisticSet.cxx +++ b/dbaccess/source/core/api/OptimisticSet.cxx @@ -103,8 +103,9 @@ OptimisticSet::OptimisticSet(const ::comphelper::ComponentContext& _rContext, const Reference< XConnection>& i_xConnection, const Reference< XSingleSelectQueryAnalyzer >& _xComposer, const ORowSetValueVector& _aParameterValueForCache, - sal_Int32 i_nMaxRows) - :OKeySet(NULL,NULL,::rtl::OUString(),_xComposer,_aParameterValueForCache,i_nMaxRows) + sal_Int32 i_nMaxRows, + sal_Int32& o_nRowCount) + :OKeySet(NULL,NULL,::rtl::OUString(),_xComposer,_aParameterValueForCache,i_nMaxRows,o_nRowCount) ,m_aSqlParser( _rContext.getLegacyServiceFactory() ) ,m_aSqlIterator( i_xConnection, Reference<XTablesSupplier>(_xComposer,UNO_QUERY)->getTables(), m_aSqlParser, NULL ) ,m_bResultSetChanged(false) diff --git a/dbaccess/source/core/api/OptimisticSet.hxx b/dbaccess/source/core/api/OptimisticSet.hxx index cf703da5e..c2b985760 100644 --- a/dbaccess/source/core/api/OptimisticSet.hxx +++ b/dbaccess/source/core/api/OptimisticSet.hxx @@ -80,7 +80,8 @@ namespace dbaccess const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_xConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer, const ORowSetValueVector& _aParameterValueForCache, - sal_Int32 i_nMaxRows); + sal_Int32 i_nMaxRows, + sal_Int32& o_nRowCount); // late ctor which can throw exceptions virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter); diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 84a09390a..dd0643b01 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -595,6 +595,7 @@ void ORowSet::freeResources( bool _bComplete ) m_bAfterLast = sal_False; m_bNew = sal_False; m_bModified = sal_False; + m_bIsInsertRow = sal_False; m_bLastKnownRowCountFinal = sal_False; m_nLastKnownRowCount = 0; if ( m_aOldRow.isValid() ) @@ -707,6 +708,7 @@ void ORowSet::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); ORowSetNotifier aNotify(this,rRow); m_pCache->updateValue(columnIndex,x,rRow,aNotify.getChangedColumns()); + m_bModified = m_bModified || !aNotify.getChangedColumns().empty(); aNotify.firePropertyChange(); } // ------------------------------------------------------------------------- @@ -722,6 +724,7 @@ void SAL_CALL ORowSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, R ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); ORowSetNotifier aNotify(this,rRow); m_pCache->updateNull(columnIndex,rRow,aNotify.getChangedColumns()); + m_bModified = m_bModified || !aNotify.getChangedColumns().empty(); aNotify.firePropertyChange(); } // ------------------------------------------------------------------------- @@ -819,6 +822,7 @@ void SAL_CALL ORowSet::updateCharacterStream( sal_Int32 columnIndex, const Refer ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); ORowSetNotifier aNotify(this,rRow); m_pCache->updateCharacterStream(columnIndex,x,length,rRow,aNotify.getChangedColumns()); + m_bModified = m_bModified || !aNotify.getChangedColumns().empty(); aNotify.firePropertyChange(); } // ------------------------------------------------------------------------- @@ -862,6 +866,7 @@ void SAL_CALL ORowSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); ORowSetNotifier aNotify(this,rRow); m_pCache->updateObject(columnIndex,aNewValue,rRow,aNotify.getChangedColumns()); + m_bModified = m_bModified || !aNotify.getChangedColumns().empty(); aNotify.firePropertyChange(); } } @@ -875,6 +880,7 @@ void SAL_CALL ORowSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); ORowSetNotifier aNotify(this,rRow); m_pCache->updateNumericObject(columnIndex,x,scale,rRow,aNotify.getChangedColumns()); + m_bModified = m_bModified || !aNotify.getChangedColumns().empty(); aNotify.firePropertyChange(); } // ------------------------------------------------------------------------- @@ -892,52 +898,49 @@ void SAL_CALL ORowSet::insertRow( ) throw(SQLException, RuntimeException) if(!m_pCache || !m_bNew || !m_bModified || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY) throwFunctionSequenceException(*this); - if(m_bModified) - { - // remember old value for fire - sal_Bool bOld = m_bNew; + // remember old value for fire + sal_Bool bOld = m_bNew; - ORowSetRow aOldValues; - if ( !m_aCurrentRow.isNull() ) - aOldValues = new ORowSetValueVector( m_aCurrentRow->getBody() ); - Sequence<Any> aChangedBookmarks; - RowsChangeEvent aEvt(*this,RowChangeAction::INSERT,1,aChangedBookmarks); - notifyAllListenersRowBeforeChange(aGuard,aEvt); + ORowSetRow aOldValues; + if ( !m_aCurrentRow.isNull() ) + aOldValues = new ORowSetValueVector( m_aCurrentRow->getBody() ); + Sequence<Any> aChangedBookmarks; + RowsChangeEvent aEvt(*this,RowChangeAction::INSERT,1,aChangedBookmarks); + notifyAllListenersRowBeforeChange(aGuard,aEvt); - ::std::vector< Any > aBookmarks; - sal_Bool bInserted = m_pCache->insertRow(aBookmarks); + ::std::vector< Any > aBookmarks; + sal_Bool bInserted = m_pCache->insertRow(aBookmarks); - // make sure that our row is set to the new inserted row before clearing the insert flags in the cache - m_pCache->resetInsertRow(bInserted); + // make sure that our row is set to the new inserted row before clearing the insert flags in the cache + m_pCache->resetInsertRow(bInserted); - // notification order - // - column values - setCurrentRow( sal_False, sal_True, aOldValues, aGuard ); // we don't move here + // notification order + // - column values + setCurrentRow( sal_False, sal_True, aOldValues, aGuard ); // we don't move here - // read-only flag restored - impl_restoreDataColumnsWriteable_throw(); + // read-only flag restored + impl_restoreDataColumnsWriteable_throw(); - // - rowChanged - notifyAllListenersRowChanged(aGuard,aEvt); + // - rowChanged + notifyAllListenersRowChanged(aGuard,aEvt); - if ( !aBookmarks.empty() ) - { - RowsChangeEvent aUpEvt(*this,RowChangeAction::UPDATE,aBookmarks.size(),Sequence<Any>(&(*aBookmarks.begin()),aBookmarks.size())); - notifyAllListenersRowChanged(aGuard,aUpEvt); - } + if ( !aBookmarks.empty() ) + { + RowsChangeEvent aUpEvt(*this,RowChangeAction::UPDATE,aBookmarks.size(),Sequence<Any>(&(*aBookmarks.begin()),aBookmarks.size())); + notifyAllListenersRowChanged(aGuard,aUpEvt); + } - // - IsModified - if(!m_bModified) - fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True); - OSL_ENSURE( !m_bModified, "ORowSet::insertRow: just updated, but _still_ modified?" ); + // - IsModified + if(!m_bModified) + fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True); + OSL_ENSURE( !m_bModified, "ORowSet::insertRow: just updated, but _still_ modified?" ); - // - IsNew - if(m_bNew != bOld) - fireProperty(PROPERTY_ID_ISNEW,m_bNew,bOld); + // - IsNew + if(m_bNew != bOld) + fireProperty(PROPERTY_ID_ISNEW,m_bNew,bOld); - // - RowCount/IsRowCountFinal - fireRowcount(); - } + // - RowCount/IsRowCountFinal + fireRowcount(); } // ------------------------------------------------------------------------- sal_Int32 SAL_CALL ORowSet::getRow( ) throw(SQLException, RuntimeException) @@ -946,7 +949,7 @@ sal_Int32 SAL_CALL ORowSet::getRow( ) throw(SQLException, RuntimeException) checkCache(); // check if we are inserting a row - return (m_pCache && ( m_pCache->m_bNew || m_bModified )) ? 0 : ORowSetBase::getRow(); + return (m_pCache && isInsertRow()) ? 0 : ORowSetBase::getRow(); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateRow( ) throw(SQLException, RuntimeException) @@ -975,6 +978,7 @@ void SAL_CALL ORowSet::updateRow( ) throw(SQLException, RuntimeException) aEvt.Rows += aBookmarks.size(); m_aBookmark = m_pCache->getBookmark(); m_aCurrentRow = m_pCache->m_aMatrixIter; + m_bIsInsertRow = sal_False; if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() && (*m_pCache->m_aMatrixIter).isValid() ) { if ( m_pCache->isResultSetChanged() ) @@ -1085,6 +1089,7 @@ void ORowSet::implCancelRowUpdates( sal_Bool _bNotifyModified ) SAL_THROW( ( SQL m_aBookmark = m_pCache->getBookmark(); m_aCurrentRow = m_pCache->m_aMatrixIter; + m_bIsInsertRow = sal_False; m_aCurrentRow.setBookmark(m_aBookmark); // notification order @@ -1219,6 +1224,7 @@ void SAL_CALL ORowSet::moveToInsertRow( ) throw(SQLException, RuntimeException) m_pCache->moveToInsertRow(); m_aCurrentRow = m_pCache->m_aInsertRow; + m_bIsInsertRow = sal_True; // set read-only flag to false impl_setDataColumnsWriteable_throw(); @@ -1829,6 +1835,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi } m_pCache->setFetchSize(m_nFetchSize); m_aCurrentRow = m_pCache->createIterator(this); + m_bIsInsertRow = sal_False; m_aOldRow = m_pCache->registerOldRow(); } @@ -2716,6 +2723,7 @@ void ORowSet::doCancelModification( ) m_pCache->cancelRowModification(); } m_bModified = sal_False; + m_bIsInsertRow = sal_False; } // ----------------------------------------------------------------------------- @@ -2739,14 +2747,12 @@ sal_Bool ORowSet::isNew( ) // ----------------------------------------------------------------------------- void ORowSet::checkUpdateIterator() { - if(!m_bModified && !m_bNew) + if(!m_bIsInsertRow) { m_pCache->setUpdateIterator(m_aCurrentRow); m_aCurrentRow = m_pCache->m_aInsertRow; - m_bModified = sal_True; - } // if(!m_bModified && !m_bNew) - else if ( m_bNew ) // here we are modifing a value - m_bModified = sal_True; + m_bIsInsertRow = sal_True; + } } // ----------------------------------------------------------------------------- void ORowSet::checkUpdateConditions(sal_Int32 columnIndex) diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx index 5afc502c0..97719fc36 100644 --- a/dbaccess/source/core/api/RowSetBase.cxx +++ b/dbaccess/source/core/api/RowSetBase.cxx @@ -112,6 +112,7 @@ ORowSetBase::ORowSetBase( const ::comphelper::ComponentContext& _rContext, ::cpp ,m_bIgnoreResult(sal_False) ,m_bBeforeFirst(sal_True) // changed from sal_False ,m_bAfterLast(sal_False) + ,m_bIsInsertRow(sal_False) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::ORowSetBase" ); DBG_CTOR(ORowSetBase,NULL); @@ -257,6 +258,7 @@ const ORowSetValue& ORowSetBase::impl_getValue(sal_Int32 columnIndex) // currentrow is null when the clone moves the window positionCache( MOVE_NONE_REFRESH_ONLY ); m_aCurrentRow = m_pCache->m_aMatrixIter; + m_bIsInsertRow = sal_False; OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getValue: we don't stand on a valid row! Row is null."); bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->isValid() ); @@ -398,6 +400,7 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSetBase::getBinaryS { positionCache( MOVE_NONE_REFRESH_ONLY ); m_aCurrentRow = m_pCache->m_aMatrixIter; + m_bIsInsertRow = sal_False; OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getBinaryStream: we don't stand on a valid row! Row is null."); bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->isValid() ); @@ -1121,6 +1124,7 @@ void ORowSetBase::setCurrentRow( sal_Bool _bMoved, sal_Bool _bDoNotify, const OR m_aBookmark = m_pCache->getBookmark(); OSL_ENSURE(m_aBookmark.hasValue(),"Bookmark has no value!"); m_aCurrentRow = m_pCache->m_aMatrixIter; + m_bIsInsertRow = sal_False; OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is null!"); m_aCurrentRow.setBookmark(m_aBookmark); OSL_ENSURE(!m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd(),"Position of matrix iterator isn't valid!"); @@ -1136,6 +1140,7 @@ void ORowSetBase::setCurrentRow( sal_Bool _bMoved, sal_Bool _bDoNotify, const OR #endif OSL_ENSURE(nOldRow == nNewRow,"Old position is not equal to new postion"); m_aCurrentRow = m_pCache->m_aMatrixIter; + m_bIsInsertRow = sal_False; OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is nul after positionCache!"); #if OSL_DEBUG_LEVEL > 0 ORowSetRow rRow = (*m_aCurrentRow); @@ -1147,6 +1152,7 @@ void ORowSetBase::setCurrentRow( sal_Bool _bMoved, sal_Bool _bDoNotify, const OR { positionCache( MOVE_NONE_REFRESH_ONLY ); m_aCurrentRow = m_pCache->m_aMatrixIter; + m_bIsInsertRow = sal_False; OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is nul after positionCache!"); } } @@ -1574,7 +1580,8 @@ void ORowSetNotifier::firePropertyChange() { m_pRowSet->firePropertyChange((*aIter)-1 ,m_pImpl->aRow[(*aIter)-1], ORowSetBase::GrantNotifierAccess()); } - m_pRowSet->fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False, ORowSetBase::GrantNotifierAccess()); + if ( !m_pImpl->aChangedColumns.empty() ) + m_pRowSet->fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False, ORowSetBase::GrantNotifierAccess()); } } } // namespace dbaccess diff --git a/dbaccess/source/core/api/RowSetBase.hxx b/dbaccess/source/core/api/RowSetBase.hxx index 4140c2175..62d778a56 100644 --- a/dbaccess/source/core/api/RowSetBase.hxx +++ b/dbaccess/source/core/api/RowSetBase.hxx @@ -158,6 +158,7 @@ namespace dbaccess sal_Bool m_bIgnoreResult ; sal_Bool m_bBeforeFirst : 1; sal_Bool m_bAfterLast : 1; + sal_Bool m_bIsInsertRow : 1; protected: ORowSetBase( @@ -383,7 +384,7 @@ namespace dbaccess inline sal_Bool isModification( const GrantNotifierAccess& ) { return isModification(); } inline sal_Bool isModified( const GrantNotifierAccess& ) { return isModified(); } inline sal_Bool isNew( const GrantNotifierAccess& ) { return isNew(); } - inline sal_Bool isInsertRow() { return isNew() || isModified(); } + inline sal_Bool isInsertRow() { return m_bIsInsertRow; } // isNew() || isModified(); } inline void fireProperty( sal_Int32 _nProperty, sal_Bool _bNew, sal_Bool _bOld, const GrantNotifierAccess& ) { fireProperty( _nProperty, _bNew, _bOld ); diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index e27e76d6f..c17801939 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -176,7 +176,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, if ( aTableNames.getLength() > 1 && !_rUpdateTableName.getLength() && bNeedKeySet ) {// here we have a join or union and nobody told us which table to update, so we update them all m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE; - OptimisticSet* pCursor = new OptimisticSet(m_aContext,xConnection,_xAnalyzer,_aParameterValueForCache,i_nMaxRows); + OptimisticSet* pCursor = new OptimisticSet(m_aContext,xConnection,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount); m_pCacheSet = pCursor; m_xCacheSet = m_pCacheSet; try @@ -309,7 +309,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, } } - OKeySet* pKeySet = new OKeySet(m_aUpdateTable,xUpdateTableKeys,aUpdateTableName ,_xAnalyzer,_aParameterValueForCache,i_nMaxRows); + OKeySet* pKeySet = new OKeySet(m_aUpdateTable,xUpdateTableKeys,aUpdateTableName ,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount); try { m_pCacheSet = pKeySet; @@ -441,6 +441,13 @@ void ORowSetCache::setFetchSize(sal_Int32 _nSize) m_nStartPos = 0; m_nEndPos = _nSize; } + else if (m_nStartPos < m_nPosition && m_nPosition < m_nEndPos) + { + sal_Int32 nNewSt = -1; + fillMatrix(nNewSt,_nSize+1); + m_nStartPos = 0; + m_nEndPos = _nSize; + } } // ------------------------------------------------------------------------- @@ -548,13 +555,16 @@ void ORowSetCache::updateNull(sal_Int32 columnIndex,ORowSetValueVector::Vector& checkUpdateConditions(columnIndex); ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get()); - rInsert[columnIndex].setBound(sal_True); - rInsert[columnIndex].setNull(); - rInsert[columnIndex].setModified(); - io_aRow[columnIndex].setNull(); + if ( !rInsert[columnIndex].isNull() ) + { + rInsert[columnIndex].setBound(sal_True); + rInsert[columnIndex].setNull(); + rInsert[columnIndex].setModified(); + io_aRow[columnIndex].setNull(); - m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); - impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); + impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + } } // ----------------------------------------------------------------------------- void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x @@ -565,13 +575,16 @@ void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x checkUpdateConditions(columnIndex); ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get()); - rInsert[columnIndex].setBound(sal_True); - rInsert[columnIndex] = x; - rInsert[columnIndex].setModified(); - io_aRow[columnIndex] = rInsert[columnIndex]; + if ( rInsert[columnIndex] != x ) + { + rInsert[columnIndex].setBound(sal_True); + rInsert[columnIndex] = x; + rInsert[columnIndex].setModified(); + io_aRow[columnIndex] = rInsert[columnIndex]; - m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); - impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); + impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + } } // ------------------------------------------------------------------------- void ORowSetCache::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x @@ -603,13 +616,18 @@ void ORowSetCache::updateObject( sal_Int32 columnIndex, const Any& x checkUpdateConditions(columnIndex); ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get()); - rInsert[columnIndex].setBound(sal_True); - rInsert[columnIndex] = x; - rInsert[columnIndex].setModified(); - io_aRow[columnIndex] = rInsert[columnIndex]; + ORowSetValue aTemp; + aTemp.fill(x); + if ( rInsert[columnIndex] != aTemp ) + { + rInsert[columnIndex].setBound(sal_True); + rInsert[columnIndex] = aTemp; + rInsert[columnIndex].setModified(); + io_aRow[columnIndex] = rInsert[columnIndex]; - m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); - impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); + impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + } } // ------------------------------------------------------------------------- void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ @@ -620,13 +638,18 @@ void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal checkUpdateConditions(columnIndex); ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get()); - rInsert[columnIndex].setBound(sal_True); - rInsert[columnIndex] = x; - rInsert[columnIndex].setModified(); - io_aRow[columnIndex] = rInsert[columnIndex]; + ORowSetValue aTemp; + aTemp.fill(x); + if ( rInsert[columnIndex] != aTemp ) + { + rInsert[columnIndex].setBound(sal_True); + rInsert[columnIndex] = aTemp; + rInsert[columnIndex].setModified(); + io_aRow[columnIndex] = rInsert[columnIndex]; - m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); - impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); + impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + } } // ------------------------------------------------------------------------- // XResultSet @@ -654,34 +677,26 @@ sal_Bool ORowSetCache::next( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isBeforeFirst( ) { - // return !m_nPosition; - return m_bBeforeFirst; } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isAfterLast( ) { - return m_bAfterLast; } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isFirst( ) { - return m_nPosition == 1; // ask resultset for } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isLast( ) { - // return m_bRowCountFinal ? (m_nPosition==m_nRowCount) : m_pCacheSet->isLast(); - return m_nPosition == m_nRowCount; } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::beforeFirst( ) { - - if(!m_bBeforeFirst) { m_bAfterLast = sal_False; @@ -696,8 +711,6 @@ sal_Bool ORowSetCache::beforeFirst( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::afterLast( ) { - - if(!m_bAfterLast) { m_bBeforeFirst = sal_False; @@ -705,7 +718,7 @@ sal_Bool ORowSetCache::afterLast( ) if(!m_bRowCountFinal) { - m_pCacheSet->last(); + m_pCacheSet->last_checked(sal_False); m_bRowCountFinal = sal_True; m_nRowCount = m_pCacheSet->getRow();// + 1 removed } @@ -721,10 +734,22 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos { OSL_ENSURE(_nNewStartPos != _nNewEndPos,"ORowSetCache::fillMatrix: StartPos and EndPos can not be equal!"); // fill the whole window with new data - ORowSetMatrix::iterator aIter = m_pMatrix->begin(); - sal_Bool bCheck = m_pCacheSet->absolute(_nNewStartPos); // -1 no need to + ORowSetMatrix::iterator aIter; + sal_Int32 i; + sal_Bool bCheck; + if ( _nNewStartPos == -1 ) + { + aIter = m_pMatrix->begin() + m_nEndPos; + i = m_nEndPos+1; + } + else + { + aIter = m_pMatrix->begin(); + i = _nNewStartPos; + } + bCheck = m_pCacheSet->absolute(i); // -1 no need to - sal_Int32 i=_nNewStartPos; + for(;i<_nNewEndPos;++i,++aIter) { if(bCheck) @@ -732,13 +757,15 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos if(!aIter->isValid()) *aIter = new ORowSetValueVector(m_xMetaData->getColumnCount()); m_pCacheSet->fillValueRow(*aIter,i); + if(!m_bRowCountFinal) + ++m_nRowCount; } else { // there are no more rows found so we can fetch some before start if(!m_bRowCountFinal) { - if(m_pCacheSet->previous()) // because we stand after the last row + if(m_pCacheSet->previous_checked(sal_False)) // because we stand after the last row m_nRowCount = m_pCacheSet->getRow(); // here we have the row count if(!m_nRowCount) m_nRowCount = i-1; // it can be that getRow return zero @@ -767,16 +794,18 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos } break; } - bCheck = m_pCacheSet->next(); + if ( i < (_nNewEndPos-1) ) + bCheck = m_pCacheSet->next(); } // m_nStartPos = _nNewStartPos; - // we have to read one row forward to enshure that we know when we are on last row + // we have to read one row forward to ensure that we know when we are on last row // but only when we don't know it already + /* if(!m_bRowCountFinal) { if(!m_pCacheSet->next()) { - if(m_pCacheSet->previous()) // because we stand after the last row + if(m_pCacheSet->previous_checked(sal_False)) // because we stand after the last row m_nRowCount = m_pCacheSet->getRow(); // here we have the row count m_bRowCountFinal = sal_True; } @@ -784,6 +813,7 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos m_nRowCount = std::max(i,m_nRowCount); } + */ return bCheck; } // ------------------------------------------------------------------------- @@ -813,7 +843,6 @@ sal_Bool ORowSetCache::moveWindow() if ( nNewStartPos < 1 ) { bCheck = m_pCacheSet->first(); - // aEnd = m_pMatrix->begin() + (sal_Int32)(m_nFetchSize*0.5); OSL_ENSURE((nNewEndPos - m_nStartPos - nNewStartPos) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!"); aEnd = m_pMatrix->begin() + (nNewEndPos - m_nStartPos - nNewStartPos); aIter = aEnd; @@ -921,19 +950,16 @@ sal_Bool ORowSetCache::moveWindow() // but only when we don't know it already if ( !m_bRowCountFinal ) { - bOk = m_pCacheSet->absolute( m_nPosition + 1 ); + bOk = m_pCacheSet->absolute_checked( m_nPosition + 1,sal_False ); if ( bOk ) m_nRowCount = std::max(sal_Int32(m_nPosition+1),m_nRowCount); } } - if(!bOk) + if(!bOk && !m_bRowCountFinal) { - if(!m_bRowCountFinal) - { - // because we stand after the last row - m_nRowCount = m_pCacheSet->previous() ? m_pCacheSet->getRow() : 0;// + 1 removed - m_bRowCountFinal = sal_True; - } + // because we stand after the last row + m_nRowCount = m_pCacheSet->previous_checked(sal_False) ? m_pCacheSet->getRow() : 0;// + 1 removed + m_bRowCountFinal = sal_True; } } } @@ -949,9 +975,6 @@ sal_Bool ORowSetCache::moveWindow() sal_Bool bCheck = m_pCacheSet->absolute(nPos); bCheck = fill(aIter,aEnd,nPos,bCheck); // refill the region wew don't need anymore -// // we know that this is the current maximal rowcount here -// if ( !m_bRowCountFinal && bCheck ) -// m_nRowCount = std::max(nPos,m_nRowCount); // we have to read one row forward to enshure that we know when we are on last row // but only when we don't know it already sal_Bool bOk = sal_True; @@ -967,7 +990,7 @@ sal_Bool ORowSetCache::moveWindow() // now I can say how many rows we have if(!bOk) { - m_pCacheSet->previous(); // because we stand after the last row + m_pCacheSet->previous_checked(sal_False); // because we stand after the last row m_nRowCount = nPos; // here we have the row count m_bRowCountFinal = sal_True; } @@ -985,7 +1008,7 @@ sal_Bool ORowSetCache::moveWindow() if ( !m_bRowCountFinal ) { - m_pCacheSet->previous(); // because we stand after the last row + m_pCacheSet->previous_checked(sal_False); // because we stand after the last row m_nRowCount = std::max(m_nRowCount,--nPos); // here we have the row count OSL_ENSURE(nPos == m_pCacheSet->getRow(),"nPos isn't valid!"); m_bRowCountFinal = sal_True; @@ -1001,7 +1024,7 @@ sal_Bool ORowSetCache::moveWindow() aIter = m_pMatrix->begin(); nPos = m_nStartPos; - bCheck = m_pCacheSet->absolute(m_nStartPos); + bCheck = m_pCacheSet->absolute_checked(m_nStartPos,sal_False); for(; !aIter->isValid() && bCheck;++aIter) { OSL_ENSURE(aIter != m_pMatrix->end(),"Invalid iterator"); diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index fbcd332f2..7587e29fe 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -58,6 +58,7 @@ #include <comphelper/sequence.hxx> #include <comphelper/types.hxx> #include <cppuhelper/typeprovider.hxx> +#include <connectivity/predicateinput.hxx> #include <rtl/logfile.hxx> #include <unotools/syslocale.hxx> #include <tools/debug.hxx> @@ -1243,16 +1244,12 @@ sal_Bool OSingleSelectQueryComposer::setComparsionPredicate(OSQLParseNode * pCon ::rtl::OUString aValue; ::rtl::OUString aColumnName; - pCondition->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) ); + pCondition->getChild(2)->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) ); pCondition->getChild(0)->parseNodeToPredicateStr( aColumnName, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep .toChar() ) ); - // don't display the column name - aValue = aValue.copy(aColumnName.getLength()); - aValue.trim(); - aItem.Name = getColumnName(pCondition->getChild(0),_rIterator); aItem.Value <<= aValue; - aItem.Handle = pCondition->getNodeType(); + aItem.Handle = getPredicateType(pCondition->getChild(1)); rFilter.push_back(aItem); } else // kann sich nur um einen Expr. Ausdruck handeln @@ -1269,7 +1266,7 @@ sal_Bool OSingleSelectQueryComposer::setComparsionPredicate(OSQLParseNode * pCon pLhs->getChild(i)->parseNodeToPredicateStr( aName, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) ); // Kriterium - aItem.Handle = pCondition->getChild(1)->getNodeType(); + aItem.Handle = getPredicateType(pCondition->getChild(1)); aValue = pCondition->getChild(1)->getTokenValue(); for(i=0;i< pRhs->count();i++) pRhs->getChild(i)->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) ); @@ -1514,7 +1511,7 @@ Reference< XIndexAccess > SAL_CALL OSingleSelectQueryComposer::getOrderColumns( // ----------------------------------------------------------------------------- namespace { - ::rtl::OUString lcl_getCondition(const Sequence< Sequence< PropertyValue > >& filter ) + ::rtl::OUString lcl_getCondition(const Sequence< Sequence< PropertyValue > >& filter,const OPredicateInputController& i_aPredicateInputController,const Reference< XNameAccess >& i_xSelectColumns) { ::rtl::OUStringBuffer sRet; const Sequence< PropertyValue >* pOrIter = filter.getConstArray(); @@ -1531,6 +1528,15 @@ namespace sRet.append(pAndIter->Name); ::rtl::OUString sValue; pAndIter->Value >>= sValue; + if ( i_xSelectColumns.is() && i_xSelectColumns->hasByName(pAndIter->Name) ) + { + Reference<XPropertySet> xColumn(i_xSelectColumns->getByName(pAndIter->Name),UNO_QUERY); + sValue = i_aPredicateInputController.getPredicateValue(sValue,xColumn,sal_True); + } + else + { + sValue = i_aPredicateInputController.getPredicateValue(pAndIter->Name,sValue,sal_True); + } lcl_addFilterCriteria_throw(pAndIter->Handle,sValue,sRet); ++pAndIter; if ( pAndIter != pAndEnd ) @@ -1549,13 +1555,15 @@ namespace void SAL_CALL OSingleSelectQueryComposer::setStructuredFilter( const Sequence< Sequence< PropertyValue > >& filter ) throw (SQLException, ::com::sun::star::lang::IllegalArgumentException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setStructuredFilter" ); - setFilter(lcl_getCondition(filter)); + OPredicateInputController aPredicateInput(m_aContext.getLegacyServiceFactory(),m_xConnection); + setFilter(lcl_getCondition(filter,aPredicateInput,getColumns())); } // ----------------------------------------------------------------------------- void SAL_CALL OSingleSelectQueryComposer::setStructuredHavingClause( const Sequence< Sequence< PropertyValue > >& filter ) throw (SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setStructuredHavingClause" ); - setHavingClause(lcl_getCondition(filter)); + OPredicateInputController aPredicateInput(m_aContext.getLegacyServiceFactory(),m_xConnection); + setHavingClause(lcl_getCondition(filter,aPredicateInput,getColumns())); } // ----------------------------------------------------------------------------- void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria ,::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString>& _aSetFunctor,sal_Int32 filterOperator) diff --git a/dbaccess/source/core/dataaccess/SharedConnection.cxx b/dbaccess/source/core/dataaccess/SharedConnection.cxx index 48f80ada2..e29377636 100644 --- a/dbaccess/source/core/dataaccess/SharedConnection.cxx +++ b/dbaccess/source/core/dataaccess/SharedConnection.cxx @@ -129,6 +129,8 @@ void SAL_CALL OSharedConnection::rollback( ) throw(SQLException, RuntimeExcepti sal_Bool SAL_CALL OSharedConnection::isClosed( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); + if ( !m_xConnection.is() ) + return sal_True; return m_xConnection->isClosed(); } diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx index 6a1151580..ee4e187ae 100755..100644 --- a/dbaccess/source/core/dataaccess/datasource.cxx +++ b/dbaccess/source/core/dataaccess/datasource.cxx @@ -204,7 +204,7 @@ void SAL_CALL FlushNotificationAdapter::disposing( const EventObject& Source ) t if ( xListener.is() ) xListener->disposing( Source ); - impl_dispose( false ); + impl_dispose( true ); } //-------------------------------------------------------------------------- diff --git a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx index 5ba9a6329..21dfa7e5e 100644 --- a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx +++ b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx @@ -27,51 +27,21 @@ #ifndef DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX #define DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX -#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_ #include <com/sun/star/sdb/XParametersSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XTablesSupplier.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 -#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> -#endif -#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_ #include <com/sun/star/script/XTypeConverter.hpp> -#endif -#ifndef _CPPUHELPER_IMPLBASE5_HXX_ #include <cppuhelper/implbase5.hxx> -#endif -#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_ #include <connectivity/sqliterator.hxx> -#endif -#ifndef _CONNECTIVITY_SQLPARSE_HXX #include <connectivity/sqlparse.hxx> -#endif -#ifndef _DBASHARED_APITOOLS_HXX_ #include "apitools.hxx" -#endif -#ifndef _COMPHELPER_BROADCASTHELPER_HXX_ #include <comphelper/broadcasthelper.hxx> -#endif -#ifndef _COMPHELPER_UNO3_HXX_ #include <comphelper/uno3.hxx> -#endif -#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_ #include <comphelper/proparrhlp.hxx> -#endif -#ifndef _COMPHELPER_PROPERTYCONTAINER_HXX_ #include <comphelper/propertycontainer.hxx> -#endif -#ifndef COMPHELPER_COMPONENTCONTEXT_HXX #include <comphelper/componentcontext.hxx> -#endif #include <memory> diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index ee6e35532..71196e5b0 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -32,6 +32,7 @@ #include "dbustrings.hrc" #include "advancedsettingsdlg.hxx" #include "subcomponentmanager.hxx" +#include "closeveto.hxx" /** === begin UNO includes === **/ #include <com/sun/star/beans/NamedValue.hpp> @@ -1300,8 +1301,8 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa ::comphelper::NamedValueCollection aCreationArgs; aCreationArgs.put( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, ID_NEW_VIEW_DESIGN == _nId ); - Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY ); - Reference< XComponent > xComponent( aDesigner.createNew( xDataSource, aCreationArgs ), UNO_QUERY ); + const Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY ); + const Reference< XComponent > xComponent( aDesigner.createNew( xDataSource, aCreationArgs ), UNO_QUERY ); onDocumentOpened( ::rtl::OUString(), E_QUERY, E_OPEN_DESIGN, xComponent, NULL ); } } @@ -1352,8 +1353,8 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa { RelationDesigner aDesigner( getORB(), this, m_aCurrentFrame.getFrame() ); - Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY ); - Reference< XComponent > xComponent( aDesigner.createNew( xDataSource ), UNO_QUERY ); + const Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY ); + const Reference< XComponent > xComponent( aDesigner.createNew( xDataSource ), UNO_QUERY ); onDocumentOpened( ::rtl::OUString(), SID_DB_APP_DSRELDESIGN, E_OPEN_DESIGN, xComponent, NULL ); } } @@ -1949,6 +1950,9 @@ IMPL_LINK( OApplicationController, OnCreateWithPilot, void*, _pType ) // ----------------------------------------------------------------------------- void OApplicationController::newElementWithPilot( ElementType _eType ) { + CloseVeto aKeepDoc( getFrame() ); + // prevent the document being closed while the wizard is open + OSL_ENSURE( getContainer(), "OApplicationController::newElementWithPilot: without a view?" ); switch ( _eType ) @@ -2710,61 +2714,83 @@ void SAL_CALL OApplicationController::attachFrame( const Reference< XFrame > & i sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel > & _rxModel) throw( RuntimeException ) { ::osl::MutexGuard aGuard( getMutex() ); - Reference< XOfficeDatabaseDocument > xOfficeDoc( _rxModel, UNO_QUERY ); - if ( !xOfficeDoc.is() && _rxModel.is() ) + const Reference< XOfficeDatabaseDocument > xOfficeDoc( _rxModel, UNO_QUERY ); + const Reference< XModifiable > xDocModify( _rxModel, UNO_QUERY ); + if ( ( !xOfficeDoc.is() || !xDocModify.is() ) && _rxModel.is() ) { DBG_ERROR( "OApplicationController::attachModel: invalid model!" ); return sal_False; } - DBG_ASSERT( !( m_xModel.is() && ( m_xModel != _rxModel ) ), - "OApplicationController::attachModel: missing implementation: setting a new model while we have another one!" ); - // at least: remove as property change listener from the old model/data source + if ( m_xModel.is() && ( m_xModel != _rxModel ) && ( _rxModel.is() ) ) + { + OSL_ENSURE( false, "OApplicationController::attachModel: missing implementation: setting a new model while we have another one!" ); + // we'd need to completely update our view here, close sub components, and the like + return sal_False; + } + + const ::rtl::OUString aPropertyNames[] = + { + PROPERTY_URL, PROPERTY_USER + }; + + // disconnect from old model + try + { + if ( m_xDataSource.is() ) + { + for ( size_t i=0; i < sizeof( aPropertyNames ) / sizeof( aPropertyNames[0] ); ++i ) + { + m_xDataSource->removePropertyChangeListener( aPropertyNames[i], this ); + } + } + + Reference< XModifyBroadcaster > xBroadcaster( m_xModel, UNO_QUERY ); + if ( xBroadcaster.is() ) + xBroadcaster->removeModifyListener( this ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } m_xModel = _rxModel; - if ( m_xModel.is() ) + m_xDocumentModify = xDocModify; + m_xDataSource.set( xOfficeDoc.is() ? xOfficeDoc->getDataSource() : Reference< XDataSource >(), UNO_QUERY ); + + // connect to new model + try { - m_xDocumentModify.set( m_xModel, UNO_QUERY_THROW ); + if ( m_xDataSource.is() ) + { + for ( size_t i=0; i < sizeof( aPropertyNames ) / sizeof( aPropertyNames[0] ); ++i ) + { + m_xDataSource->addPropertyChangeListener( aPropertyNames[i], this ); + } + } + + Reference< XModifyBroadcaster > xBroadcaster( m_xModel, UNO_QUERY_THROW ); + xBroadcaster->addModifyListener( this ); + } - else + catch( const Exception& ) { - m_xDocumentModify.clear(); + DBG_UNHANDLED_EXCEPTION(); } - m_xDataSource.set(xOfficeDoc.is() ? xOfficeDoc->getDataSource() : Reference<XDataSource>(),UNO_QUERY); + // initial preview mode if ( m_xDataSource.is() ) { try { - m_xDataSource->addPropertyChangeListener(PROPERTY_INFO, this); - m_xDataSource->addPropertyChangeListener(PROPERTY_URL, this); - m_xDataSource->addPropertyChangeListener(PROPERTY_ISPASSWORDREQUIRED, this); - m_xDataSource->addPropertyChangeListener(PROPERTY_LAYOUTINFORMATION, this); - m_xDataSource->addPropertyChangeListener(PROPERTY_SUPPRESSVERSIONCL, this); - m_xDataSource->addPropertyChangeListener(PROPERTY_TABLEFILTER, this); - m_xDataSource->addPropertyChangeListener(PROPERTY_TABLETYPEFILTER, this); - m_xDataSource->addPropertyChangeListener(PROPERTY_USER, this); // to get the 'modified' for the data source - Reference< XModifyBroadcaster > xBroadcaster(m_xModel, UNO_QUERY); - if ( xBroadcaster.is() ) - xBroadcaster->addModifyListener(static_cast<XModifyListener*>(this)); - - Sequence<PropertyValue> aFields; - m_xDataSource->getPropertyValue(PROPERTY_LAYOUTINFORMATION) >>= aFields; - PropertyValue *pIter = aFields.getArray(); - PropertyValue *pEnd = pIter + aFields.getLength(); - for (; pIter != pEnd && pIter->Name != INFO_PREVIEW; ++pIter) - ; - - if ( pIter != pEnd ) + ::comphelper::NamedValueCollection aLayoutInfo( m_xDataSource->getPropertyValue( PROPERTY_LAYOUTINFORMATION ) ); + if ( aLayoutInfo.has( (rtl::OUString)INFO_PREVIEW ) ) { - sal_Int32 nValue = 0; - pIter->Value >>= nValue; - m_ePreviewMode = static_cast<PreviewMode>(nValue); + const sal_Int32 nPreviewMode( aLayoutInfo.getOrDefault( (rtl::OUString)INFO_PREVIEW, (sal_Int32)0 ) ); + m_ePreviewMode = static_cast< PreviewMode >( nPreviewMode ); if ( getView() ) - { - getContainer()->switchPreview(m_ePreviewMode); - } + getContainer()->switchPreview( m_ePreviewMode ); } } catch( const Exception& ) diff --git a/dbaccess/source/ui/app/AppControllerGen.cxx b/dbaccess/source/ui/app/AppControllerGen.cxx index a26ac0be5..45f38a6d5 100644 --- a/dbaccess/source/ui/app/AppControllerGen.cxx +++ b/dbaccess/source/ui/app/AppControllerGen.cxx @@ -670,7 +670,6 @@ void OApplicationController::askToReconnect() void OApplicationController::onDocumentOpened( const ::rtl::OUString& _rName, const sal_Int32 _nType, const ElementOpenMode _eMode, const Reference< XComponent >& _xDocument, const Reference< XComponent >& _rxDefinition ) { - OSL_PRECOND( _xDocument.is(), "OApplicationController::onDocumentOpened: illegal document!" ); if ( !_xDocument.is() ) return; diff --git a/dbaccess/source/ui/app/app.src b/dbaccess/source/ui/app/app.src index 7cae30e49..39cd441f1 100644 --- a/dbaccess/source/ui/app/app.src +++ b/dbaccess/source/ui/app/app.src @@ -261,19 +261,19 @@ Menu RID_MENU_APP_EDIT MenuItem { Identifier = SID_DB_APP_DSPROPS; - Text[ en-US ] = "Properties"; + Text[ en-US ] = "Properties..."; Command = ".uno:DBDSProperties"; }; MenuItem { Identifier = SID_DB_APP_DSCONNECTION_TYPE; - Text[ en-US ] = "Connection Type"; + Text[ en-US ] = "Connection Type..."; Command = ".uno:DBDSConnectionType"; }; MenuItem { Identifier = SID_DB_APP_DSADVANCED_SETTINGS; - Text[ en-US ] = "Advanced Settings"; + Text[ en-US ] = "Advanced Settings..."; Command = ".uno:DBDSAdvancedSettings"; }; }; diff --git a/dbaccess/source/ui/app/closeveto.cxx b/dbaccess/source/ui/app/closeveto.cxx new file mode 100644 index 000000000..936c76942 --- /dev/null +++ b/dbaccess/source/ui/app/closeveto.cxx @@ -0,0 +1,180 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_dbaccess.hxx" + +#include "closeveto.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/util/XCloseable.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/implbase1.hxx> +#include <rtl/ref.hxx> +#include <tools/diagnose_ex.h> + +//...................................................................................................................... +namespace dbaui +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::util::XCloseable; + using ::com::sun::star::util::XCloseListener; + using ::com::sun::star::util::CloseVetoException; + using ::com::sun::star::lang::EventObject; + /** === end UNO using === **/ + + //================================================================================================================== + //= CloseListener_Impl + //================================================================================================================== + typedef ::cppu::WeakImplHelper1 < XCloseListener + > CloseListener_Base; + class DBACCESS_DLLPRIVATE CloseListener_Impl : public CloseListener_Base + { + public: + CloseListener_Impl() + :m_bHasOwnership( false ) + { + } + + // XCloseListener + virtual void SAL_CALL queryClosing( const EventObject& Source, ::sal_Bool GetsOwnership ) throw (CloseVetoException, RuntimeException); + virtual void SAL_CALL notifyClosing( const EventObject& Source ) throw (RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const EventObject& Source) throw (RuntimeException); + + bool hasOwnership() const { return m_bHasOwnership; } + + protected: + ~CloseListener_Impl() + { + } + + private: + bool m_bHasOwnership; + }; + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL CloseListener_Impl::queryClosing( const EventObject& i_source, ::sal_Bool i_deliverOwnership ) throw (CloseVetoException, RuntimeException) + { + (void)i_source; + + if ( !m_bHasOwnership ) + m_bHasOwnership = i_deliverOwnership; + + throw CloseVetoException(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL CloseListener_Impl::notifyClosing( const EventObject& i_source ) throw (RuntimeException) + { + (void)i_source; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL CloseListener_Impl::disposing( const EventObject& i_source ) throw (RuntimeException) + { + (void)i_source; + } + + //================================================================================================================== + //= CloseVeto_Data + //================================================================================================================== + struct DBACCESS_DLLPRIVATE CloseVeto_Data + { + Reference< XCloseable > xCloseable; + ::rtl::Reference< CloseListener_Impl > pListener; + }; + + //================================================================================================================== + //= operations + //================================================================================================================== + namespace + { + //-------------------------------------------------------------------------------------------------------------- + void lcl_init( CloseVeto_Data& i_data, const Reference< XInterface >& i_closeable ) + { + i_data.xCloseable.set( i_closeable, UNO_QUERY ); + ENSURE_OR_RETURN_VOID( i_data.xCloseable.is(), "CloseVeto: the component is not closeable!" ); + + i_data.pListener = new CloseListener_Impl; + i_data.xCloseable->addCloseListener( i_data.pListener.get() ); + } + + //-------------------------------------------------------------------------------------------------------------- + void lcl_deinit( CloseVeto_Data& i_data ) + { + if ( !i_data.xCloseable.is() ) + return; + + i_data.xCloseable->removeCloseListener( i_data.pListener.get() ); + if ( i_data.pListener->hasOwnership() ) + { + try + { + i_data.xCloseable->close( sal_True ); + } + catch( const CloseVetoException& ) { } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + } + + //================================================================================================================== + //= CloseVeto + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + CloseVeto::CloseVeto( const Reference< XInterface >& i_closeable ) + :m_pData( new CloseVeto_Data ) + { + lcl_init( *m_pData, i_closeable ); + } + + //------------------------------------------------------------------------------------------------------------------ + CloseVeto::~CloseVeto() + { + lcl_deinit( *m_pData ); + } + +//...................................................................................................................... +} // namespace dbaui +//...................................................................................................................... diff --git a/dbaccess/source/ui/app/closeveto.hxx b/dbaccess/source/ui/app/closeveto.hxx new file mode 100644 index 000000000..f7e1c8364 --- /dev/null +++ b/dbaccess/source/ui/app/closeveto.hxx @@ -0,0 +1,67 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBACCESS_CLOSEVETO_HXX +#define DBACCESS_CLOSEVETO_HXX + +#include "dbaccessdllapi.h" + +/** === begin UNO includes === **/ +#include <com/sun/star/uno/XInterface.hpp> +/** === end UNO includes === **/ + +#include <boost/scoped_ptr.hpp> + +//...................................................................................................................... +namespace dbaui +{ +//...................................................................................................................... + + //================================================================================================================== + //= CloseVeto + //================================================================================================================== + struct CloseVeto_Data; + /** will add a XCloseListener to a given component, and veto its closing as long as the <code>CloseVeto</code> + instance is alive. + + If closing has been requested and vetoed while the <code>CloseVeto</code> instance is alive, and the ownership + went to the <code>CloseVeto</code> instance, then it will close the component in its dtor. + */ + class DBACCESS_DLLPRIVATE CloseVeto + { + public: + CloseVeto( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_closeable ); + ~CloseVeto(); + + private: + ::boost::scoped_ptr< CloseVeto_Data > m_pData; + }; + +//...................................................................................................................... +} // namespace dbaui +//...................................................................................................................... + +#endif // DBACCESS_CLOSEVETO_HXX diff --git a/dbaccess/source/ui/app/makefile.mk b/dbaccess/source/ui/app/makefile.mk index a7097b433..e26927d99 100644 --- a/dbaccess/source/ui/app/makefile.mk +++ b/dbaccess/source/ui/app/makefile.mk @@ -48,7 +48,8 @@ EXCEPTIONSFILES=\ $(SLO)$/AppSwapWindow.obj \ $(SLO)$/AppTitleWindow.obj \ $(SLO)$/AppView.obj \ - $(SLO)$/subcomponentmanager.obj + $(SLO)$/subcomponentmanager.obj \ + $(SLO)$/closeveto.obj SLOFILES =\ diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx index 100a63649..3acc08df9 100644 --- a/dbaccess/source/ui/browser/genericcontroller.cxx +++ b/dbaccess/source/ui/browser/genericcontroller.cxx @@ -965,6 +965,9 @@ void OGenericUnoController::disposing() m_xMasterDispatcher = NULL; m_xSlaveDispatcher = NULL; m_xServiceFactory = NULL; + m_xTitleHelper.clear(); + m_xUrlTransformer.clear(); + m_aInitParameters.clear(); } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index b8f965435..4dcb6928e 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -469,7 +469,7 @@ void SbaTableQueryBrowser::impl_sanitizeRowSetClauses_nothrow() // check if the order columns apply to tables which really exist in the statement const Reference< XIndexAccess > xOrderColumns( xComposer->getOrderColumns(), UNO_SET_THROW ); const sal_Int32 nOrderColumns( xOrderColumns->getCount() ); - bool invalidColumn = false; + bool invalidColumn = nOrderColumns == 0; for ( sal_Int32 c=0; ( c < nOrderColumns ) && !invalidColumn; ++c ) { const Reference< XPropertySet > xOrderColumn( xOrderColumns->getByIndex(c), UNO_QUERY_THROW ); @@ -2701,6 +2701,8 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry ) sStatus.SearchAndReplaceAscii("$name$", aName); BrowserViewStatusDisplay aShowStatus(static_cast<UnoDataBrowserView*>(getView()), sStatus); + + sal_Bool bEscapeProcessing = sal_True; if(xNameAccess.is() && xNameAccess->hasByName(sSimpleName)) { DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData()); @@ -2711,38 +2713,42 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry ) { pData->xObjectProperties = pData->xObjectProperties.query( xObject ); // if the query contains a parameterized statement and preview is enabled we won't get any data. - if ( m_bPreview && nCommandType == CommandType::QUERY && xObject.is() ) + if ( nCommandType == CommandType::QUERY && xObject.is() ) { - ::rtl::OUString sSql; Reference<XPropertySet> xObjectProps(xObject,UNO_QUERY); - xObjectProps->getPropertyValue(PROPERTY_COMMAND) >>= sSql; - Reference< XMultiServiceFactory > xFactory( pConData->xConnection, UNO_QUERY ); - if (xFactory.is()) + xObjectProps->getPropertyValue(PROPERTY_ESCAPE_PROCESSING) >>= bEscapeProcessing; + if ( m_bPreview ) { - try + ::rtl::OUString sSql; + xObjectProps->getPropertyValue(PROPERTY_COMMAND) >>= sSql; + Reference< XMultiServiceFactory > xFactory( pConData->xConnection, UNO_QUERY ); + if (xFactory.is()) { - Reference<XSingleSelectQueryAnalyzer> xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY); - if ( xAnalyzer.is() ) + try { - xAnalyzer->setQuery(sSql); - Reference<XParametersSupplier> xParSup(xAnalyzer,UNO_QUERY); - if ( xParSup->getParameters()->getCount() > 0 ) + Reference<XSingleSelectQueryAnalyzer> xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY); + if ( xAnalyzer.is() ) { - String sFilter = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE ")); - sFilter = sFilter + xAnalyzer->getFilter(); - String sReplace(sSql); - sReplace.SearchAndReplace(sFilter,String()); - xAnalyzer->setQuery(sReplace); - Reference<XSingleSelectQueryComposer> xComposer(xAnalyzer,UNO_QUERY); - xComposer->setFilter(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0=1"))); - aName = xAnalyzer->getQuery(); - nCommandType = CommandType::COMMAND; + xAnalyzer->setQuery(sSql); + Reference<XParametersSupplier> xParSup(xAnalyzer,UNO_QUERY); + if ( xParSup->getParameters()->getCount() > 0 ) + { + String sFilter = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE ")); + sFilter = sFilter + xAnalyzer->getFilter(); + String sReplace(sSql); + sReplace.SearchAndReplace(sFilter,String()); + xAnalyzer->setQuery(sReplace); + Reference<XSingleSelectQueryComposer> xComposer(xAnalyzer,UNO_QUERY); + xComposer->setFilter(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0=1"))); + aName = xAnalyzer->getQuery(); + nCommandType = CommandType::COMMAND; + } } } - } - catch (Exception&) - { - DBG_UNHANDLED_EXCEPTION(); + catch (Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } } } } @@ -2751,7 +2757,7 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry ) } String sDataSourceName( getDataSourceAcessor( pConnection ) ); - bSuccess = implLoadAnything( sDataSourceName, aName, nCommandType, sal_True, pConData->xConnection ); + bSuccess = implLoadAnything( sDataSourceName, aName, nCommandType, bEscapeProcessing, pConData->xConnection ); if ( !bSuccess ) { // clean up criticalFail(); diff --git a/dbaccess/source/ui/dlg/advancedsettings.src b/dbaccess/source/ui/dlg/advancedsettings.src index afff07fc7..7e7d73e97 100644 --- a/dbaccess/source/ui/dlg/advancedsettings.src +++ b/dbaccess/source/ui/dlg/advancedsettings.src @@ -382,5 +382,5 @@ TabDialog DLG_DATABASE_ADVANCED Text [ en-US ] = "Special Settings"; }; - Text [ en-US ] = "Advanced Properties" ; + Text [ en-US ] = "Advanced Settings" ; }; diff --git a/dbaccess/source/ui/inc/dbu_qry.hrc b/dbaccess/source/ui/inc/dbu_qry.hrc index 04b2daa5d..e64a360dd 100644 --- a/dbaccess/source/ui/inc/dbu_qry.hrc +++ b/dbaccess/source/ui/inc/dbu_qry.hrc @@ -56,8 +56,8 @@ #define STR_QUERY_NOTABLE RID_STR_QRY_START + 21 #define STR_QRY_ORDERBY_UNRELATED RID_STR_QRY_START + 22 #define STR_QUERY_HANDLETEXT RID_STR_QRY_START + 23 -#define STR_QUERY_FALSE RID_STR_QRY_START + 24 -#define STR_QUERY_TRUE RID_STR_QRY_START + 25 +// free +// free #define STR_QRY_TOO_MANY_COLUMNS RID_STR_QRY_START + 26 #define STR_SVT_SQL_SYNTAX_ERROR RID_STR_QRY_START + 27 #define STR_QUERYDESIGN_NO_VIEW_SUPPORT RID_STR_QRY_START + 28 diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx index ab9d6d845..061c2c4a5 100644 --- a/dbaccess/source/ui/misc/DExport.cxx +++ b/dbaccess/source/ui/misc/DExport.cxx @@ -447,7 +447,8 @@ sal_Int16 ODatabaseExport::CheckString(const String& aCheckToken, sal_Int16 _nOl if ( eNumLang != LANGUAGE_NONE ) { nFormatKey = m_pFormatter->GetFormatForLanguageIfBuiltIn( nFormatKey, eNumLang ); - m_pFormatter->IsNumberFormat( m_sTextToken, nFormatKey, fOutNumber ); + if ( !m_pFormatter->IsNumberFormat( m_sTextToken, nFormatKey, fOutNumber ) ) + return NumberFormat::TEXT; } Reference<XPropertySet> xProp = xFormats->getByKey(nFormatKey); xProp->getPropertyValue(PROPERTY_TYPE) >>= nNumberFormat; diff --git a/dbaccess/source/ui/misc/databaseobjectview.cxx b/dbaccess/source/ui/misc/databaseobjectview.cxx index 469a477d3..97ed40b6a 100644 --- a/dbaccess/source/ui/misc/databaseobjectview.cxx +++ b/dbaccess/source/ui/misc/databaseobjectview.cxx @@ -162,9 +162,6 @@ namespace dbaui 0, i_rDispatchArgs.getPropertyValues() ); - - if ( !xReturn.is() ) - xReturn.set( m_xFrameLoader, UNO_QUERY ); } catch( const Exception& ) { diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index f166bbed4..7ee6721d2 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -2061,6 +2061,13 @@ namespace break; } + const OSQLParseNode* pTableExp = pParseTree->getChild(3); + if ( pTableExp->getChild(6)->count() > 0 || pTableExp->getChild(7)->count() > 0 || pTableExp->getChild(8)->count() > 0) + { + eErrorCode = eStatementTooComplex; + break; + } + Reference< XConnection> xConnection = rController.getConnection(); if ( !xConnection.is() ) { @@ -2142,7 +2149,7 @@ namespace pTableView->RemoveTabWin(aIterTableMap->second); } - if ( eOk == (eErrorCode = FillOuterJoins(_pView,pParseTree->getChild(3)->getChild(0)->getChild(1))) ) + if ( eOk == (eErrorCode = FillOuterJoins(_pView,pTableExp->getChild(0)->getChild(1))) ) { // check if we have a distinct statement if(SQL_ISTOKEN(pParseTree->getChild(1),DISTINCT)) diff --git a/dbaccess/source/ui/querydesign/query.src b/dbaccess/source/ui/querydesign/query.src index 3dd1180d8..eb1ad4121 100644 --- a/dbaccess/source/ui/querydesign/query.src +++ b/dbaccess/source/ui/querydesign/query.src @@ -281,14 +281,6 @@ ErrorBox ERR_QRY_ORDERBY_ON_ASTERISK { Message [ en-US ] = "[*] cannot be used as a sort criterion."; }; -String STR_QUERY_TRUE -{ - Text [ en-US ] = "TRUE" ; -}; -String STR_QUERY_FALSE -{ - Text [ en-US ] = "FALSE" ; -}; String STR_QRY_TOO_MANY_TABLES { Text [ en-US ] = "There are too many tables."; diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx index 77d7ccf43..68c356bc6 100644 --- a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx +++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx @@ -629,6 +629,7 @@ TOTypeInfoSP OFieldDescription::getSpecialTypeInfo() const *pSpecialType = *m_pType; pSpecialType->nPrecision = GetPrecision(); pSpecialType->nMaximumScale = static_cast<sal_Int16>(GetScale()); + pSpecialType->bAutoIncrement = IsAutoIncrement(); // http://dba.openoffice.org/issues/show_bug.cgi?id=115398 fixed by ludob return pSpecialType; } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx index 050f86c98..f4f728c7e 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.cxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx @@ -443,20 +443,14 @@ void OTableEditorCtrl::PaintCell(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const { DBG_CHKTHIS(OTableEditorCtrl,NULL); - String aText( GetCellText( m_nCurrentPos, nColumnId )); - Point aPos(rRect.TopLeft()); - Size TxtSize(GetDataWindow().GetTextWidth(aText), GetDataWindow().GetTextHeight()); - - if (aPos.X() < rRect.Right() || aPos.X() + TxtSize.Width() > rRect.Right() || - aPos.Y() < rRect.Top() || aPos.Y() + TxtSize.Height() > rRect.Bottom()) - rDev.SetClipRegion( rRect ); - - rDev.DrawText(aPos, aText); - - if (rDev.IsClipRegion()) - rDev.SetClipRegion(); -// rDev.DrawText(rRect.TopLeft(), aText); -// rDev.SetClipRegion( ); + const String aText( GetCellText( m_nCurrentPos, nColumnId )); + const Point aPos(rRect.TopLeft()); + const Size TxtSize(GetDataWindow().GetTextWidth(aText), GetDataWindow().GetTextHeight()); + + rDev.Push( PUSH_CLIPREGION ); + rDev.SetClipRegion( rRect ); + rDev.DrawText( rRect, aText, TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER ); + rDev.Pop(); } //------------------------------------------------------------------------------ diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx index d977c9542..4f5b88af0 100644 --- a/reportdesign/source/ui/report/ReportSection.cxx +++ b/reportdesign/source/ui/report/ReportSection.cxx @@ -544,22 +544,22 @@ void OReportSection::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) else { uno::Reference<report::XReportDefinition> xReportDefinition = m_xSection->getReportDefinition(); + const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN); + const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN); + const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width; + if ( _rEvent.PropertyName == PROPERTY_LEFTMARGIN ) { - const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN); m_pPage->SetLftBorder(nLeftMargin); } else if ( _rEvent.PropertyName == PROPERTY_RIGHTMARGIN ) { - const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN); m_pPage->SetRgtBorder(nRightMargin); } try { - const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN); - const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN); - const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width; + sal_Int32 nRightBorder = nPaperWidth - nRightMargin; const sal_Int32 nCount = m_xSection->getCount(); for (sal_Int32 i = 0; i < nCount; ++i) { @@ -578,9 +578,9 @@ void OReportSection::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) aPos.X = nLeftMargin; bChanged = true; } - if ( (aPos.X + aSize.Width) > (nPaperWidth - nRightMargin) ) + if ( (aPos.X + aSize.Width) > nRightBorder ) { - aPos.X = nPaperWidth - nRightMargin - aSize.Width; + aPos.X = nRightBorder - aSize.Width; if ( aPos.X < nLeftMargin ) { aSize.Width += aPos.X - nLeftMargin; @@ -603,6 +603,8 @@ void OReportSection::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) aRet.setWidth(aRet.getWidth() + 1); if ( m_xSection.is() && (static_cast<sal_uInt32>(aRet.getHeight() + aRet.Top()) > m_xSection->getHeight()) ) m_xSection->setHeight(aRet.getHeight() + aRet.Top()); + + pObject->RecalcBoundRect(); } pBase->StartListening(); } diff --git a/reportdesign/source/ui/report/dlgedfunc.cxx b/reportdesign/source/ui/report/dlgedfunc.cxx index a4c7b78ac..8f3cdd43e 100644 --- a/reportdesign/source/ui/report/dlgedfunc.cxx +++ b/reportdesign/source/ui/report/dlgedfunc.cxx @@ -451,6 +451,7 @@ void DlgEdFunc::activateOle(SdrObject* _pObj) void DlgEdFunc::deactivateOle(bool _bSelect) { OLEObjCache& rObjCache = GetSdrGlobalData().GetOLEObjCache(); + OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController(); const sal_uLong nCount = rObjCache.Count(); for(sal_uLong i = 0 ; i< nCount;++i) { @@ -463,8 +464,7 @@ void DlgEdFunc::deactivateOle(bool _bSelect) xObj->changeState( embed::EmbedStates::RUNNING ); m_bUiActive = false; if ( m_bShowPropertyBrowser ) - { - OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController(); + { rController.executeChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue >()); } @@ -639,15 +639,17 @@ bool DlgEdFunc::isRectangleHit(const MouseEvent& rMEvt) if (pObjOverlapped && !m_bSelectionMode) { colorizeOverlappedObject(pObjOverlapped); + } } } } } - } - else if ( aVEvt.pObj && !m_bSelectionMode) + else if ( aVEvt.pObj && (aVEvt.pObj->GetObjIdentifier() != OBJ_CUSTOMSHAPE) && !m_bSelectionMode) { colorizeOverlappedObject(aVEvt.pObj); } + else + bIsSetPoint = false; return bIsSetPoint; } // ----------------------------------------------------------------------------- |