summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/tabledesign
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2004-08-02 15:18:21 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2004-08-02 15:18:21 +0000
commite56db79e03e7d559fa3cd333509ecbe68645d755 (patch)
tree6d905f91389c986a03662bee8a2bb8435434b595 /dbaccess/source/ui/tabledesign
parent8557140cbdd94df19ae3226dfda0a3c803ba58fd (diff)
INTEGRATION: CWS insight01 (1.88.64); FILE MERGED
2004/07/20 14:04:28 oj 1.88.64.16: check connection 2004/07/20 13:23:14 oj 1.88.64.15: #i20125# change title 2004/07/19 12:45:23 oj 1.88.64.14: new method updateTitle 2004/07/14 10:22:19 oj 1.88.64.13: #i30603# corret frame loading 2004/07/02 10:04:39 oj 1.88.64.12: #i30226# add controller, model behavior 2004/05/26 07:14:37 oj 1.88.64.11: #i18612# check the create params of the type info too 2004/04/21 13:48:10 oj 1.88.64.10: enable catalog and schema disabling 2004/04/16 07:11:46 oj 1.88.64.9: handle readonly connection 2004/04/02 13:46:01 oj 1.88.64.8: set title of ds 2004/03/11 15:08:40 oj 1.88.64.7: #111075# ongoing fixes 2004/03/11 09:03:57 oj 1.88.64.6: #111075# changes for closing 2004/03/08 07:27:03 oj 1.88.64.5: change to new menu layout 2004/01/02 14:00:26 oj 1.88.64.4: RESYNC: (1.89-1.90); FILE MERGED 2003/12/17 09:16:12 oj 1.88.64.3: #111075# ongoing work 2003/10/24 06:41:16 oj 1.88.64.2: #111075# further changes 2003/07/29 12:47:00 oj 1.88.64.1: #111075# insight changes
Diffstat (limited to 'dbaccess/source/ui/tabledesign')
-rw-r--r--dbaccess/source/ui/tabledesign/TableController.cxx106
1 files changed, 48 insertions, 58 deletions
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
index 84abc603c64f..698371d3fcdb 100644
--- a/dbaccess/source/ui/tabledesign/TableController.cxx
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: TableController.cxx,v $
*
- * $Revision: 1.90 $
+ * $Revision: 1.91 $
*
- * last change: $Author: rt $ $Date: 2003-12-01 10:39:30 $
+ * last change: $Author: hr $ $Date: 2004-08-02 16:18:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -182,9 +182,6 @@
#ifndef _DBAUI_INDEXDIALOG_HXX_
#include "indexdialog.hxx"
#endif
-#ifndef _COM_SUN_STAR_UTIL_XFLUSHABLE_HPP_
-#include <com/sun/star/util/XFlushable.hpp>
-#endif
#ifndef DBAUI_TOOLS_HXX
#include "UITools.hxx"
#endif
@@ -317,7 +314,7 @@ FeatureState OTableController::GetState(sal_uInt16 _nId) const
break;
case ID_BROWSER_EDITDOC:
aReturn.aState = ::cppu::bool2any(isEditable());
- aReturn.bEnabled = m_bNew || isEditable() || isAddAllowed() || isDropAllowed() || isAlterAllowed();
+ aReturn.bEnabled = m_bNew || isEditable();// the editable flag is set through this one -> || isAddAllowed() || isDropAllowed() || isAlterAllowed();
break;
case ID_BROWSER_SAVEDOC:
aReturn.bEnabled = isModified();
@@ -328,7 +325,7 @@ FeatureState OTableController::GetState(sal_uInt16 _nId) const
}
break;
case ID_BROWSER_SAVEASDOC:
- aReturn.bEnabled |= isConnected();
+ aReturn.bEnabled = isConnected() && isEditable();
if ( aReturn.bEnabled )
{
::std::vector<OTableRow*>::const_iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(),::std::mem_fun(&OTableRow::isValid));
@@ -511,9 +508,7 @@ sal_Bool OTableController::doSaveDoc(sal_Bool _bSaveAs)
if(!m_xTable.is()) // correct name and try again
{
// it can be that someone inserted new data for us
- ::rtl::OUString sComposedName;
- ::dbaui::composeTableName(getConnection()->getMetaData(),xTable,sComposedName,sal_False);
- m_sName = sComposedName;
+ m_sName = ::dbtools::composeTableName(getConnection()->getMetaData(),xTable,sal_False,::dbtools::eInDataManipulation);
assignTable();
}
// now check if our datasource has set a tablefilter and if append the new table name to it
@@ -524,9 +519,6 @@ sal_Bool OTableController::doSaveDoc(sal_Bool _bSaveAs)
bAlter = sal_True;
alterColumns();
}
- Reference<XFlushable> xFlush(m_xTable,UNO_QUERY);
- if(xFlush.is())
- xFlush->flush();
reSyncRows();
}
catch(const SQLContext& e)
@@ -626,11 +618,11 @@ void OTableController::doEditIndexes()
}
// -----------------------------------------------------------------------------
-void SAL_CALL OTableController::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException)
+void OTableController::impl_initialize( const Sequence< Any >& aArguments )
{
try
{
- OTableController_BASE::initialize(aArguments);
+ OTableController_BASE::impl_initialize(aArguments);
PropertyValue aValue;
const Any* pBegin = aArguments.getConstArray();
@@ -646,19 +638,13 @@ void SAL_CALL OTableController::initialize( const Sequence< Any >& aArguments )
if ( xConn.is() )
initializeConnection( xConn );
}
- else if (0 == aValue.Name.compareToAscii(PROPERTY_DATASOURCENAME))
- {
- ::rtl::OUString sName;
- aValue.Value >>= sName;
- initializeDataSourceName( sName );
- // read autoincrement value set in the datasource
- ::dbaui::fillAutoIncrementValue(getDataSource(),m_bAllowAutoIncrementValue,m_sAutoIncrementValue);
- }
else if (0 == aValue.Name.compareToAscii(PROPERTY_CURRENTTABLE))
{
aValue.Value >>= m_sName;
}
}
+ // read autoincrement value set in the datasource
+ ::dbaui::fillAutoIncrementValue(getDataSource(),m_bAllowAutoIncrementValue,m_sAutoIncrementValue);
sal_Bool bFirstTry = sal_False;
if (!isConnected())
@@ -680,21 +666,12 @@ void SAL_CALL OTableController::initialize( const Sequence< Any >& aArguments )
assignTable();
if(!m_xFormatter.is())
{
- Reference< XChild> xChild(getConnection(), UNO_QUERY);
- if(xChild.is())
+ Reference< XNumberFormatsSupplier> xSupplier = ::dbtools::getNumberFormats(getConnection());
+ if(xSupplier.is())
{
- Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY);
- if(xProp.is())
- {
- Reference< XNumberFormatsSupplier> xSupplier;
- xProp->getPropertyValue(PROPERTY_NUMBERFORMATSSUPPLIER) >>= xSupplier;
- if(xSupplier.is())
- {
- m_xFormatter = Reference< ::com::sun::star::util::XNumberFormatter >(getORB()
- ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY);
- m_xFormatter->attachNumberFormatsSupplier(xSupplier);
- }
- }
+ m_xFormatter = Reference< ::com::sun::star::util::XNumberFormatter >(getORB()
+ ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY);
+ m_xFormatter->attachNumberFormatsSupplier(xSupplier);
}
OSL_ENSURE(m_xFormatter.is(),"No NumberFormatter!");
}
@@ -738,6 +715,11 @@ sal_Bool OTableController::Construct(Window* pParent)
// -----------------------------------------------------------------------------
sal_Bool SAL_CALL OTableController::suspend(sal_Bool _bSuspend) throw( RuntimeException )
{
+ if ( getBroadcastHelper().bInDispose || getBroadcastHelper().bDisposed )
+ return sal_True;
+
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard(m_aMutex);
sal_Bool bCheck = sal_True;
if ( isModified() )
{
@@ -1061,7 +1043,8 @@ void OTableController::loadData()
pTabEdRow->SetReadOnly(!bIsAlterAllowed);
// search for type
sal_Bool bForce;
- TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(m_aTypeInfo,nType,sTypeName,nPrecision,nScale,bIsAutoIncrement,bForce);
+ ::rtl::OUString sCreate(RTL_CONSTASCII_USTRINGPARAM("x"));
+ TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(m_aTypeInfo,nType,sTypeName,sCreate,nPrecision,nScale,bIsAutoIncrement,bForce);
if ( !pTypeInfo.get() )
pTypeInfo = m_pTypeInfo;
pTabEdRow->SetFieldType( pTypeInfo, bForce );
@@ -1153,7 +1136,7 @@ Reference<XNameAccess> OTableController::getKeyColumns() const
xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
if(KeyType::PRIMARY == nKeyType)
{
- xKeyColsSup = Reference<XColumnsSupplier>(xProp,UNO_QUERY);
+ xKeyColsSup.set(xProp,UNO_QUERY);
OSL_ENSURE(xKeyColsSup.is(),"Columnsupplier is null!");
xKeyColumns = xKeyColsSup->getColumns();
break;
@@ -1567,7 +1550,8 @@ void OTableController::assignTable()
startTableListening();
// check if we set the table editable
- setEditable( isAlterAllowed() || isDropAllowed() || isAddAllowed() );
+ Reference<XDatabaseMetaData> xMeta = getConnection()->getMetaData();
+ setEditable( xMeta.is() && !xMeta->isReadOnly() && (isAlterAllowed() || isDropAllowed() || isAddAllowed()) );
if(!isEditable())
{
::std::vector<OTableRow*>::iterator aIter = m_vRowList.begin();
@@ -1579,12 +1563,8 @@ void OTableController::assignTable()
InvalidateAll();
}
}
- if(m_xTable.is())
- ::dbaui::composeTableName(getConnection()->getMetaData(),m_xTable,sComposedName,sal_False);
- else
- sComposedName = m_sName;
}
- setTitle(sComposedName);
+ updateTitle();
}
// -----------------------------------------------------------------------------
sal_Bool OTableController::isAddAllowed() const
@@ -1663,23 +1643,33 @@ void OTableController::reSyncRows()
return sName;
}
// -----------------------------------------------------------------------------
-String OTableController::getMenu() const
+void OTableController::updateTitle()
{
- return String::CreateFromInt32(RID_TABLE_DESIGN_MAIN_MENU);
-}
-// -----------------------------------------------------------------------------
-void OTableController::setTitle(const ::rtl::OUString & _rTitle)
-{
- Reference<XPropertySet> xProp(m_xCurrentFrame,UNO_QUERY);
- if(xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_TITLE))
+ try
{
+ ::rtl::OUString sTitle;
+ // get the table
+ if ( m_sName.getLength() && getConnection().is() )
+ {
+ if ( m_xTable.is() )
+ sTitle = ::dbtools::composeTableName(getConnection()->getMetaData(),m_xTable,sal_False,::dbtools::eInDataManipulation);
+ else
+ sTitle = m_sName;
+ }
::rtl::OUString sName = String(ModuleRes(STR_TABLEDESIGN_TITLE));
- sName += ::rtl::OUString::createFromAscii(": ");
- if(_rTitle.getLength())
- sName += _rTitle;
+ if(sTitle.getLength())
+ sName = sTitle + sName;
else
- sName += getDataSourceName();
- xProp->setPropertyValue(PROPERTY_TITLE,makeAny(sName));
+ {
+ ::rtl::OUString sTemp(getDataSourceName());
+ sName = ::dbaui::getStrippedDatabaseName(getDataSource(),sTemp) + sName;
+ }
+
+ OGenericUnoController::setTitle(sName);
+ }
+ catch(Exception)
+ {
+ OSL_ENSURE(0,"Exception catched while setting the title!");
}
}
// -----------------------------------------------------------------------------