diff options
Diffstat (limited to 'dbaccess/source')
22 files changed, 3846 insertions, 102 deletions
diff --git a/dbaccess/source/ui/browser/dataview.cxx b/dbaccess/source/ui/browser/dataview.cxx index fab769dcf27d..21af2c3bccc1 100644 --- a/dbaccess/source/ui/browser/dataview.cxx +++ b/dbaccess/source/ui/browser/dataview.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dataview.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2001-02-05 09:20:23 $ + * last change: $Author: oj $ $Date: 2001-02-14 14:29:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -85,8 +85,8 @@ using namespace ::com::sun::star::lang; // using namespace ::com::sun::star::container; // ------------------------------------------------------------------------- -ODataView::ODataView(Window* pParent, const Reference< XMultiServiceFactory >& _rFactory) - :Window(pParent) +ODataView::ODataView(Window* pParent, const Reference< XMultiServiceFactory >& _rFactory, WinBits nStyle) + :Window(pParent,nStyle) ,m_pToolBox(NULL) ,m_xServiceFactory(_rFactory) { diff --git a/dbaccess/source/ui/browser/dbloader.cxx b/dbaccess/source/ui/browser/dbloader.cxx index 272c26938b20..4d81472445ee 100644 --- a/dbaccess/source/ui/browser/dbloader.cxx +++ b/dbaccess/source/ui/browser/dbloader.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dbloader.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-01-09 15:52:33 $ + * last change: $Author: oj $ $Date: 2001-02-14 14:29:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -107,6 +107,9 @@ #ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ #include <com/sun/star/lang/XInitialization.hpp> #endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif using namespace ::com::sun::star::uno; using namespace ::com::sun::star::frame; @@ -114,6 +117,7 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::registry; +using namespace dbaui; class DBContentLoader : public ::cppu::WeakImplHelper2< XFrameLoader, XServiceInfo> { @@ -240,8 +244,10 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const :: xController = Reference< XController >(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.OFormGridView")),UNO_QUERY); else if(aParser.GetMainURL().EqualsAscii(".component:DB/DataSourceBrowser"))// construct the control xController = Reference< XController >(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.ODatasourceBrowser")),UNO_QUERY); - else if(aParser.GetMainURL().EqualsAscii(".component:DB/QueryDesign"))// construct the control + else if(aParser.GetMainURL() == String(URL_COMPONENT_QUERYDESIGN))// construct the control xController = Reference< XController >(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.OQueryDesign")),UNO_QUERY); + else if(aParser.GetMainURL() == String(URL_COMPONENT_TABLEDESIGN))// construct the control + xController = Reference< XController >(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.OTableDesign")),UNO_QUERY); else OSL_ENSHURE(0,"wrong dispatch url!"); diff --git a/dbaccess/source/ui/browser/sbabrw.src b/dbaccess/source/ui/browser/sbabrw.src index 9727dc85c9d3..08ed85e6d4a2 100644 --- a/dbaccess/source/ui/browser/sbabrw.src +++ b/dbaccess/source/ui/browser/sbabrw.src @@ -2,9 +2,9 @@ * * $RCSfile: sbabrw.src,v $ * - * $Revision: 1.18 $ + * $Revision: 1.19 $ * - * last change: $Author: oj $ $Date: 2001-02-05 09:20:07 $ + * last change: $Author: oj $ $Date: 2001-02-14 14:29:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -605,17 +605,17 @@ Menu MENU_BROWSERTREE_CONTEXT { Identifier = ID_TREE_QUERY_CREATE_DESIGN ; HelpId = HID_BROWSER_QUERY_CREATE_DESIGN ; - Text = "~Abfrageentwurf" ; - Text [ english ] = "~querydesign" ; - Text [ english_us ] = "~querydesign" ; + Text = "neuer ~Abfrageentwurf" ; + Text [ english ] = "new ~querydesign" ; + Text [ english_us ] = "new ~querydesign" ; }; MenuItem { Identifier = ID_TREE_QUERY_CREATE_TEXT ; HelpId = HID_BROWSER_QUERY_CREATE_TEXT ; - Text = "~SQL Befehl eingeben" ; - Text [ english ] = "~SQL command" ; - Text [ english_us ] = "~SQL command" ; + Text = "neuen ~SQL Befehl eingeben" ; + Text [ english ] = "new ~SQL command" ; + Text [ english_us ] = "new ~SQL command" ; }; MenuItem { @@ -633,6 +633,34 @@ Menu MENU_BROWSERTREE_CONTEXT Text [ english ] = "de~lete query" ; Text [ english_us ] = "de~lete query" ; }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + Identifier = ID_TREE_TABLE_CREATE_DESIGN ; + HelpId = HID_BROWSER_TABLE_CREATE_DESIGN ; + Text = "neuer ~Tabellenentwurf" ; + Text [ english ] = "new ~tabledesign" ; + Text [ english_us ] = "new ~tabledesign" ; + }; + MenuItem + { + Identifier = ID_TREE_TABLE_EDIT ; + HelpId = HID_BROWSER_TABLE_EDIT ; + Text = "Tabelle ~bearbeiten" ; + Text [ english ] = "edit ta~ble" ; + Text [ english_us ] = "edit ta~ble" ; + }; + MenuItem + { + Identifier = ID_TREE_TABLE_DELETE ; + HelpId = HID_BROWSER_TABLE_DELETE ; + Text = "Tabelle ~lschen" ; + Text [ english ] = "de~lete table" ; + Text [ english_us ] = "de~lete table" ; + }; }; }; @@ -644,6 +672,14 @@ QueryBox QUERY_BRW_DELETE_QUERY Message [ english_us ] = "Do you want to delete the selected query?" ; }; +QueryBox QUERY_BRW_DELETE_TABLE +{ + Buttons = WB_YES_NO ; + Message = "Soll die Tabelle gelscht werden?" ; + Message [ English ] = "Delete selected table?" ; + Message [ english_us ] = "Do you want to delete the selected table?" ; +}; + QueryBox QUERY_BRW_DELETE_QUERY_CONFIRM { Buttons = WB_YES_NO ; diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx index 56cab2266e8b..4d93a66f047f 100644 --- a/dbaccess/source/ui/browser/sbagrid.cxx +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sbagrid.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: fs $ $Date: 2001-01-17 16:25:28 $ + * last change: $Author: oj $ $Date: 2001-02-14 14:29:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -744,7 +744,7 @@ void SAL_CALL SbaXGridPeer::selectionChanged(const EventObject& aEvent) Reference< XIndexContainer > xColumns = getColumns(); Reference< XSelectionSupplier > xSelSupplier(aEvent.Source, UNO_QUERY); Reference< XPropertySet > xSelection; - xSelSupplier->getSelection() >>= xSelection; + ::cppu::extractInterface(xSelection,xSelSupplier->getSelection()); sal_uInt16 nSelectedCol = (sal_uInt16)-1; if (xSelection.is()) @@ -752,7 +752,7 @@ void SAL_CALL SbaXGridPeer::selectionChanged(const EventObject& aEvent) Reference< XPropertySet > xCol; for (sal_Int32 i = 0; i < xColumns->getCount(); i++) { - xColumns->getByIndex(i) >>= xCol; + ::cppu::extractInterface(xCol,xColumns->getByIndex(i)); if (xCol == xSelection) { nSelectedCol = (sal_uInt16)i; @@ -867,7 +867,7 @@ void SbaGridHeader::ImplSelect(sal_uInt16 nId) if (nPos < xColumns->getCount()) { Reference< XPropertySet > xColumn; - xColumns->getByIndex(nPos) >>= xColumn; + ::cppu::extractInterface(xColumn,xColumns->getByIndex(nPos)); Reference< XSelectionSupplier > xSelSupplier(xColumns, UNO_QUERY); if (xSelSupplier.is()) xSelSupplier->select(makeAny(xColumn)); @@ -1067,7 +1067,7 @@ void SbaGridControl::SetColWidth(sal_uInt16 nColId) Reference< XIndexAccess > xCols(GetPeer()->getColumns(), UNO_QUERY); Reference< XPropertySet > xAffectedCol; if (xCols.is() && (nModelPos != (sal_uInt16)-1)) - xCols->getByIndex(nModelPos) >>= xAffectedCol; + ::cppu::extractInterface(xAffectedCol,xCols->getByIndex(nModelPos)); if (xAffectedCol.is()) { @@ -1148,7 +1148,7 @@ void SbaGridControl::SetColAttrs(sal_uInt16 nColId) Reference< XIndexAccess > xCols(GetPeer()->getColumns(), UNO_QUERY); Reference< XPropertySet > xAffectedCol; if (xCols.is() && (nModelPos != (sal_uInt16)-1)) - xCols->getByIndex(nModelPos) >>= xAffectedCol; + ::cppu::extractInterface(xAffectedCol,xCols->getByIndex(nModelPos)); // get the field the column is bound to Reference< XPropertySet > xField = getField(nModelPos); @@ -1413,7 +1413,7 @@ void SbaGridControl::Select() if (nSelectedColumn != -1) { Reference< XPropertySet > xColumn; - xColumns->getByIndex(nSelectedColumn) >>= xColumn; + ::cppu::extractInterface(xColumn,xColumns->getByIndex(nSelectedColumn)); xSelSupplier->select(makeAny(xColumn)); } else @@ -1507,9 +1507,9 @@ Reference< XPropertySet > SbaGridControl::getField(sal_uInt16 nModelPos) if (xCols.is()) { Reference< XPropertySet > xCol; - xCols->getByIndex(nModelPos) >>= xCol; + ::cppu::extractInterface(xCol,xCols->getByIndex(nModelPos)); if (xCol.is()) - xCol->getPropertyValue(PROPERTY_BOUNDFIELD) >>= xEmptyReturn; + ::cppu::extractInterface(xEmptyReturn,xCol->getPropertyValue(PROPERTY_BOUNDFIELD)); } } catch(Exception&) @@ -1731,7 +1731,7 @@ void SbaGridControl::DoColumnDrag(sal_uInt16 nColumnPos) sal_uInt16 nModelPos = GetModelColumnPos(GetColumnIdFromViewPos(nColumnPos)); Reference< XIndexContainer > xCols(GetPeer()->getColumns(), UNO_QUERY); Reference< XPropertySet > xAffectedCol; - xCols->getByIndex(nModelPos) >>= xAffectedCol; + ::cppu::extractInterface(xAffectedCol,xCols->getByIndex(nModelPos)); sField = (const sal_Unicode*)::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_CONTROLSOURCE)); } catch(Exception&) @@ -1898,7 +1898,7 @@ void SbaGridControl::DoFieldDrag(sal_uInt16 nColumnPos, sal_uInt16 nRowPos) { sal_uInt16 nModelPos = GetModelColumnPos(GetColumnIdFromViewPos(nColumnPos)); Reference< XIndexContainer > xCols(GetPeer()->getColumns(), UNO_QUERY); - xCols->getByIndex(nModelPos) >>= xAffectedCol; + ::cppu::extractInterface(xAffectedCol,xCols->getByIndex(nModelPos)); sField = (const sal_Unicode*)::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_CONTROLSOURCE)); } catch(Exception&) @@ -2094,7 +2094,7 @@ sal_Bool SbaGridControl::QueryDrop(const BrowserDropEvent& rEvt) if (xColumnControls.is()) { Reference< ::com::sun::star::awt::XTextComponent > xColControl; - xColumnControls->getByIndex(GetViewColumnPos(nCol)) >>= xColControl; + ::cppu::extractInterface(xColControl,xColumnControls->getByIndex(GetViewColumnPos(nCol))); if (xColControl.is()) { m_bActivatingForDrop = sal_True; diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index 21a3ea4767a6..0cca01b9c247 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unodatbr.cxx,v $ * - * $Revision: 1.29 $ + * $Revision: 1.30 $ * - * last change: $Author: oj $ $Date: 2001-02-06 09:43:00 $ + * last change: $Author: oj $ $Date: 2001-02-14 14:29:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -141,6 +141,12 @@ #ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XViewsSupplier.hpp> #endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_ +#include <com/sun/star/sdbcx/XDrop.hpp> +#endif #ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_ #include <com/sun/star/sdb/XCompletedConnection.hpp> #endif @@ -530,7 +536,7 @@ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun:: Reference<XConnection> xConnection; Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY); - xProp->getPropertyValue(PROPERTY_ACTIVECONNECTION) >>= xConnection; + ::cppu::extractInterface(xConnection,xProp->getPropertyValue(PROPERTY_ACTIVECONNECTION)); OSL_ENSHURE(xConnection.is(),"A ActiveConnection should normaly exists!"); Reference<XChild> xChild(xConnection,UNO_QUERY); @@ -550,7 +556,7 @@ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun:: { // Typ // first get type to determine wich control we need - xColumns->getByName(*pBegin) >>= xColumn; + ::cppu::extractInterface(xColumn,xColumns->getByName(*pBegin)); // ignore the column when it is a rowversion one if(bSupress && xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISROWVERSION) @@ -612,7 +618,9 @@ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun:: xCurrentCol->setPropertyValue(PROPERTY_WIDTH, xColumn->getPropertyValue(PROPERTY_WIDTH)); // ... horizontal justify - xCurrentCol->setPropertyValue(PROPERTY_ALIGN, xColumn->getPropertyValue(PROPERTY_ALIGN)); + sal_Int32 nAlign; + xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign; + xCurrentCol->setPropertyValue(PROPERTY_ALIGN, makeAny(sal_Int16(nAlign))); // ... the 'comment' property as helptext (will usually be shown as header-tooltip) @@ -671,7 +679,7 @@ Reference<XPropertySet> getColumnHelper(SvLBoxEntry* _pCurrentlyDisplayed,const ::rtl::OUString aName; _rxSource->getPropertyValue(PROPERTY_NAME) >>= aName; if(xNames.is() && xNames->hasByName(aName)) - xNames->getByName(aName) >>= xRet; + ::cppu::extractInterface(xRet,xNames->getByName(aName)); } return xRet; } @@ -713,12 +721,19 @@ void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt) else if (evt.PropertyName.equals(PROPERTY_ALIGN)) { Reference<XPropertySet> xProp = getColumnHelper(m_pCurrentlyDisplayed,xSource); - if(xProp.is()) + try { - if(evt.NewValue.hasValue()) - xProp->setPropertyValue(PROPERTY_ALIGN,evt.NewValue); - else - xProp->setPropertyValue(PROPERTY_ALIGN,makeAny((sal_Int16)0)); + if(xProp.is()) + { + if(evt.NewValue.hasValue()) + xProp->setPropertyValue(PROPERTY_ALIGN,evt.NewValue); + else + xProp->setPropertyValue(PROPERTY_ALIGN,makeAny((sal_Int32)0)); + } + } + catch(Exception&) + { + OSL_ASSERT(0); } } @@ -1409,6 +1424,14 @@ IMPL_LINK(SbaTableQueryBrowser, OnListContextMenu, const CommandEvent*, _pEvent) if(pEntry) { SvLBoxEntry* pTemp = m_pTreeView->getListBox()->GetParent(pEntry); + + // 1. for tables + SvLBoxEntry* pTables = m_pTreeView->getListBox()->GetEntry(pDSEntry,1); + aContextMenu.EnableItem(ID_TREE_TABLE_CREATE_DESIGN, (pTables == pEntry || pTables == pTemp)); + aContextMenu.EnableItem(ID_TREE_TABLE_EDIT, (pTables != pEntry && pTables == pTemp)); + aContextMenu.EnableItem(ID_TREE_TABLE_DELETE, (pTables != pEntry && pTables == pTemp)); + + // 2. for queries SvLBoxEntry* pQueries = m_pTreeView->getListBox()->GetEntry(pDSEntry,0); aContextMenu.EnableItem(ID_TREE_QUERY_CREATE_DESIGN, (pQueries == pEntry || pQueries == pTemp)); aContextMenu.EnableItem(ID_TREE_QUERY_CREATE_TEXT, (pQueries == pEntry || pQueries == pTemp)); @@ -1471,13 +1494,15 @@ IMPL_LINK(SbaTableQueryBrowser, OnListContextMenu, const CommandEvent*, _pEvent) closeConnection(pDSEntry); } break; + case ID_TREE_TABLE_CREATE_DESIGN: case ID_TREE_QUERY_CREATE_DESIGN: case ID_TREE_QUERY_CREATE_TEXT: case ID_TREE_QUERY_EDIT: + case ID_TREE_TABLE_EDIT: { ::osl::MutexGuard aGuard(m_aEntryMutex); - // get all needed properties for querydesign + // get all needed properties for design ::rtl::OUString aDSName; SvLBoxItem* pTextItem = pDSEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING); if (pTextItem) @@ -1494,13 +1519,13 @@ IMPL_LINK(SbaTableQueryBrowser, OnListContextMenu, const CommandEvent*, _pEvent) if(!xConnection.is()) break; - ::rtl::OUString sCurrentQuery; - if ((ID_TREE_QUERY_EDIT == nPos) && pEntry) + ::rtl::OUString sCurrentObject; + if ((ID_TREE_QUERY_EDIT == nPos || ID_TREE_TABLE_EDIT == nPos) && pEntry) { // get the name of the query SvLBoxItem* pQueryTextItem = pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING); if (pQueryTextItem) - sCurrentQuery = static_cast<SvLBoxString*>(pQueryTextItem)->GetText(); + sCurrentObject = static_cast<SvLBoxString*>(pQueryTextItem)->GetText(); DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pEntry->GetUserData()); if(!pData) @@ -1510,15 +1535,25 @@ IMPL_LINK(SbaTableQueryBrowser, OnListContextMenu, const CommandEvent*, _pEvent) pData->bTable = sal_False; Reference<XNameAccess> xNameAccess; - Reference<XQueriesSupplier> xSup(xConnection,UNO_QUERY); - if(xSup.is()) - xNameAccess = xSup->getQueries(); + if(ID_TREE_TABLE_EDIT == nPos) + { + Reference<XTablesSupplier> xSup(xConnection,UNO_QUERY); + if(xSup.is()) + xNameAccess = xSup->getTables(); + } + else + { + Reference<XQueriesSupplier> xSup(xConnection,UNO_QUERY); + if(xSup.is()) + xNameAccess = xSup->getQueries(); + } SvLBoxItem* pTextItem = pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING); if (pTextItem) - sCurrentQuery = static_cast<SvLBoxString*>(pTextItem)->GetText(); + sCurrentObject = static_cast<SvLBoxString*>(pTextItem)->GetText(); - if(xNameAccess.is() && xNameAccess->hasByName(sCurrentQuery) && (xNameAccess->getByName(sCurrentQuery) >>= pData->xObject)) // remember the table or query object + if(xNameAccess.is() && xNameAccess->hasByName(sCurrentObject) && + ::cppu::extractInterface(pData->xObject,xNameAccess->getByName(sCurrentObject))) // remember the table or query object pEntry->SetUserData(pData); else { @@ -1528,11 +1563,27 @@ IMPL_LINK(SbaTableQueryBrowser, OnListContextMenu, const CommandEvent*, _pEvent) } } - OQueryDesignAccess aDispatcher(m_xMultiServiceFacatory); - if (ID_TREE_QUERY_EDIT == nPos) - aDispatcher.editQuery(aDSName, sCurrentQuery, xConnection); + ODesignAccess* pDispatcher = NULL; + sal_Bool bEdit = sal_False; + switch(nPos) + { + case ID_TREE_TABLE_EDIT: + bEdit = sal_True; // run through + case ID_TREE_TABLE_CREATE_DESIGN: + pDispatcher = new OTableDesignAccess(m_xMultiServiceFacatory) ; + break; + case ID_TREE_QUERY_EDIT: + bEdit = sal_True; // run through + case ID_TREE_QUERY_CREATE_DESIGN: + case ID_TREE_QUERY_CREATE_TEXT: + pDispatcher = new OQueryDesignAccess(m_xMultiServiceFacatory) ; + break; + } + + if (bEdit) + pDispatcher->edit(aDSName, sCurrentObject, xConnection); else - aDispatcher.createQuery(aDSName, xConnection,nPos == ID_TREE_QUERY_CREATE_DESIGN); + pDispatcher->create(aDSName, xConnection,nPos == ID_TREE_QUERY_CREATE_DESIGN); } break; case ID_TREE_QUERY_DELETE: @@ -1547,7 +1598,7 @@ IMPL_LINK(SbaTableQueryBrowser, OnListContextMenu, const CommandEvent*, _pEvent) SvLBoxItem* pTextItem = pDSEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING); if (pTextItem) aName = static_cast<SvLBoxString*>(pTextItem)->GetText(); - m_xDatabaseContext->getByName(aName) >>= xSet; + ::cppu::extractInterface(xSet,m_xDatabaseContext->getByName(aName)); } catch(Exception&) { } @@ -1570,6 +1621,51 @@ IMPL_LINK(SbaTableQueryBrowser, OnListContextMenu, const CommandEvent*, _pEvent) } } break; + case ID_TREE_TABLE_DELETE: + if(pDSEntry) + { + ::osl::MutexGuard aGuard(m_aEntryMutex); + + // get all needed properties for design + ::rtl::OUString aDSName; + SvLBoxItem* pTextItem = pDSEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING); + if (pTextItem) + aDSName = static_cast<SvLBoxString*>(pTextItem)->GetText(); + Reference<XConnection> xConnection; // supports the service sdb::connection + if (pDSData) + xConnection = Reference<XConnection>(pDSData->xObject,UNO_QUERY); + if(!xConnection.is() && pDSData) + { + xConnection = connect(aDSName); + pDSData->xObject = xConnection; // share the conenction with the querydesign + } + + if(!xConnection.is()) + break; + Reference<XTablesSupplier> xSup(xConnection,UNO_QUERY); + OSL_ENSURE(xSup.is(),"NO XTablesSuppier!"); + Reference<XDrop> xDrop(xSup,UNO_QUERY); + if(xDrop.is() && QueryBox(getBrowserView()->getVclControl(),ModuleRes(QUERY_BRW_DELETE_TABLE)).Execute() == RET_YES) + { + try + { + ::rtl::OUString aName; + SvLBoxItem* pTextItem = pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING); + if (pTextItem) + aName = static_cast<SvLBoxString*>(pTextItem)->GetText(); + if(aName.getLength()) + xDrop->dropByName(aName); + } + catch(SQLException& e) + { + showError(SQLExceptionInfo(e)); + } + catch(Exception&) + { + } + } + } + break; } return 1L; // handled @@ -1609,6 +1705,10 @@ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvLBoxEntry*, _pParent) { Image aImage(ModuleRes(TABLE_TREE_ICON)); populateTree(xTabSup->getTables(),_pParent,aImage); + Reference<XContainer> xCont(xTabSup->getTables(),UNO_QUERY); + if(xCont.is()) + // add as listener to know when elements are inserted or removed + xCont->addContainerListener(this); } Reference<XViewsSupplier> xViewSup(xConnection,UNO_QUERY); @@ -1616,6 +1716,10 @@ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvLBoxEntry*, _pParent) { Image aImage(ModuleRes(VIEW_TREE_ICON)); populateTree(xViewSup->getViews(),_pParent,aImage); + Reference<XContainer> xCont(xViewSup->getViews(),UNO_QUERY); + if(xCont.is()) + // add as listener to know when elements are inserted or removed + xCont->addContainerListener(this); } } else @@ -1632,7 +1736,7 @@ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvLBoxEntry*, _pParent) catch(Exception&) { } Reference<XQueryDefinitionsSupplier> xQuerySup; - if(aValue >>= xQuerySup) + if(::cppu::extractInterface(xQuerySup,aValue) && xQuerySup.is()) { Image aImage(ModuleRes(QUERY_TREE_ICON)); Reference<XNameAccess> xNames = xQuerySup->getQueryDefinitions(); @@ -1697,7 +1801,7 @@ IMPL_LINK(SbaTableQueryBrowser, OnSelectEntry, SvLBoxEntry*, _pEntry) sal_Int32 nOldType; xProp->getPropertyValue(PROPERTY_COMMANDTYPE) >>= nOldType; Reference<XConnection> xOldConnection; - xProp->getPropertyValue(PROPERTY_ACTIVECONNECTION) >>= xOldConnection; + ::cppu::extractInterface(xOldConnection,xProp->getPropertyValue(PROPERTY_ACTIVECONNECTION)); // the name of the table or query SvLBoxString* pString = (SvLBoxString*)_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING); OSL_ENSURE(pString,"There must be a string item!"); @@ -1886,7 +1990,7 @@ void SAL_CALL SbaTableQueryBrowser::elementInserted( const ContainerEvent& _rEve { // only insert userdata when we have a table because the query is only a commanddefinition object and not a query DBTreeListModel::DBTreeListUserData* pNewData = new DBTreeListModel::DBTreeListUserData; pNewData->bTable = pData->bTable; - _rEvent.Element >>= pNewData->xObject; // remember the new element + ::cppu::extractInterface(pNewData->xObject,_rEvent.Element);// remember the new element pNewEntry->SetUserData(pNewData); } } @@ -2016,7 +2120,7 @@ void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEve OSL_ENSURE(pData,"elementReplaced: There must be user data!"); if(pData->bTable) { // only insert userdata when we have a table because the query is only a commanddefinition object and not a query - _rEvent.Element >>= pData->xObject; // remember the new element + ::cppu::extractInterface(pData->xObject,_rEvent.Element);// remember the new element } else { @@ -2036,7 +2140,7 @@ void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEve OSL_ENSURE(pData,"elementReplaced: There must be user data!"); if(pData->bTable) { // only insert userdata when we have a table because the query is only a commanddefinition object and not a query - _rEvent.Element >>= pData->xObject; // remember the new element + ::cppu::extractInterface(pData->xObject,_rEvent.Element);// remember the new element } else { @@ -2117,12 +2221,14 @@ void SbaTableQueryBrowser::unloadForm(sal_Bool _bDisposeConnection, sal_Bool _bF if (_bFlushData) { DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData()); - OSL_ENSURE(pData,"SbaTableQueryBrowser::unloadForm: no userdata!"); try { - Reference<XFlushable> xFlush(pData->xObject, UNO_QUERY); - if(xFlush.is()) - xFlush->flush(); + if(pData) + { + Reference<XFlushable> xFlush(pData->xObject, UNO_QUERY); + if(xFlush.is()) + xFlush->flush(); + } } catch (RuntimeException&) { @@ -2209,7 +2315,7 @@ void SAL_CALL SbaTableQueryBrowser::initialize( const Sequence< Any >& aArgument else if(aValue.Name == PROPERTY_COMMAND) aValue.Value >>= m_sDefaultCommand; else if(aValue.Name == PROPERTY_ACTIVECONNECTION) - aValue.Value >>= xConnection; + ::cppu::extractInterface(xConnection,aValue.Value); else if(aValue.Name == PROPERTY_UPDATE_CATALOGNAME) aValue.Value >>= aCatalogName; else if(aValue.Name == PROPERTY_UPDATE_SCHEMANAME) diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx new file mode 100644 index 000000000000..6f995ed9c788 --- /dev/null +++ b/dbaccess/source/ui/control/FieldDescControl.cxx @@ -0,0 +1,2106 @@ +/************************************************************************* + * + * $RCSfile: FieldDescControl.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-02-14 14:35:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#define ITEMID_HORJUSTIFY SID_ATTR_ALIGN_HOR_JUSTIFY +#define ITEMID_VERJUSTIFY SID_ATTR_ALIGN_VER_JUSTIFY +#define ITEMID_ORIENTATION SID_ATTR_ALIGN_ORIENTATION +#define ITEMID_LINEBREAK SID_ATTR_ALIGN_LINEBREAK +#define ITEMID_MARGIN SID_ATTR_ALIGN_MARGIN + +#ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX +#include "FieldDescControl.hxx" +#endif +#ifndef DBAUI_FIELDCONTROLS_HXX +#include "FieldControls.hxx" +#endif +#ifndef _ZFORLIST_HXX //autogen +#define _ZFORLIST_DECLARE_TABLE // ohne das bekomme ich einen Compiler-Fehler in <svtools/zforlist.hxx> +#include <svtools/zforlist.hxx> +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef DBAUI_TABLEDESIGNHELPBAR_HXX +#include "TableDesignHelpBar.hxx" +#endif +#ifndef _SV_SCRBAR_HXX +#include <vcl/scrbar.hxx> +#endif +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +#ifndef _SVX_NUMFMTSH_HXX +#include <svx/numfmtsh.hxx> +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif +#ifndef _SV_FIXED_HXX +#include <vcl/fixed.hxx> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _VECTOR_ +#include <vector> +#endif +#ifndef DBAUI_FIELDDESCRIPTIONS_HXX +#include "FieldDescriptions.hxx" +#endif +#ifndef _SFXITEMPOOL_HXX +#include <svtools/itempool.hxx> +#endif +#ifndef DBAUI_SBATTRDLG_HXX +#include "dlgattr.hxx" +#endif +#ifndef _SVX_SVXIDS_HRC +#include <svx/svxids.hrc> +#endif +#ifndef _SVX_ALGITEM_HXX +#include <svx/algitem.hxx> +#endif +#ifndef _SFXRNGITEM_HXX +#include <svtools/rngitem.hxx> +#endif +#ifndef _SFXINTITEM_HXX +#include <svtools/intitem.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_ +#include <com/sun/star/util/NumberFormat.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATPREVIEWER_HPP_ +#include <com/sun/star/util/XNumberFormatPreviewer.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_ +#include <com/sun/star/util/XNumberFormatTypes.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef DBAUI_ENUMTYPES_HXX +#include "QEnumTypes.hxx" +#endif +#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include "dbaccess_helpid.hrc" +#endif +#ifndef _NUMUNO_HXX +#include <svtools/numuno.hxx> +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif + +using namespace dbaui; +// using namespace comphelper; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::sdbc; +// using namespace ::com::sun::star::sdb; + +//================================================================== + +// fuer die Controls auf der OFieldDescGenPage +#define CONTROL_SPACING_X 18 // 6 +#define CONTROL_SPACING_Y 5 +#define CONTROL_HEIGHT 20 +#define CONTROL_WIDTH_1 140 // 100 +#define CONTROL_WIDTH_2 100 // 60 +#define CONTROL_WIDTH_3 250 +#define CONTROL_WIDTH_4 (CONTROL_WIDTH_3 - CONTROL_HEIGHT - 5) + +#define SBA_DEF_RANGEFORMAT (100 + 143) // RangeItem +#define SBA_DEF_FMTVALUE (100 + 144) // SfxULONG, Format +#define SBA_ATTR_ALIGN_HOR_JUSTIFY (100 + 145) // SvxHorJustifyItem + +#define HSCROLL_STEP 20 + +//================================================================== +// class OFieldDescControl +//================================================================== + +DBG_NAME(OFieldDescControl); + +//================================================================== +OFieldDescControl::OFieldDescControl( Window* pParent, const ResId& rResId, OTableDesignHelpBar* pHelpBar) + :TabPage( pParent, rResId ) + ,m_pPreviousType( NULL ) + ,pHelp( pHelpBar ) + ,nCurChildId(1) + ,pDefault(NULL) + ,pDefaultText(NULL) + ,pRequired(NULL) + ,pRequiredText(NULL) + ,pAutoIncrement(NULL) + ,pAutoIncrementText(NULL) + ,pTextLen(NULL) + ,pTextLenText(NULL) + ,pNumType(NULL) + ,pNumTypeText(NULL) + ,pLastFocusWindow(NULL) + ,pFormatSample(NULL) + ,pFormatText(NULL) + ,pFormat(NULL) + ,pLength(NULL) + ,pLengthText(NULL) + ,pScale(NULL) + ,pScaleText(NULL) + ,pBoolDefault(NULL) + ,pBoolDefaultText(NULL) + ,m_pColumnName(NULL) + ,m_pColumnNameText(NULL) + ,m_pType(NULL) + ,m_pTypeText(NULL) + ,nPos(-1) + ,aYes(ModuleRes(STR_VALUE_YES)) + ,aNo(ModuleRes(STR_VALUE_NO)) + ,nDelayedGrabFocusEvent(0) + ,pActFieldDescr(NULL) +{ + DBG_CTOR(OFieldDescControl,NULL); + + m_pVertScroll = new ScrollBar(this, WB_VSCROLL | WB_REPEAT | WB_DRAG); + m_pHorzScroll = new ScrollBar(this, WB_HSCROLL | WB_REPEAT | WB_DRAG); + m_pVertScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll)); + m_pHorzScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll)); + m_pVertScroll->Show(); + m_pHorzScroll->Show(); + + m_pVertScroll->EnableClipSiblings(); + m_pHorzScroll->EnableClipSiblings(); + + m_pVertScroll->SetLineSize(1); + m_pVertScroll->SetPageSize(1); + m_pHorzScroll->SetLineSize(1); + m_pHorzScroll->SetPageSize(1); + + m_nOldVThumb = m_nOldHThumb = 0; +} +//------------------------------------------------------------------------------ +OFieldDescControl::OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHelpBar ) + :TabPage( pParent, WB_3DLOOK | WB_DIALOGCONTROL ) + ,m_pPreviousType( NULL ) + ,pHelp( pHelpBar ) + ,nCurChildId(1) + ,pDefault(NULL) + ,pDefaultText(NULL) + ,pRequired(NULL) + ,pRequiredText(NULL) + ,pAutoIncrement(NULL) + ,pAutoIncrementText(NULL) + ,pTextLen(NULL) + ,pTextLenText(NULL) + ,pNumType(NULL) + ,pNumTypeText(NULL) + ,pLastFocusWindow(NULL) + ,pFormatSample(NULL) + ,pFormatText(NULL) + ,pFormat(NULL) + ,pLength(NULL) + ,pLengthText(NULL) + ,pScale(NULL) + ,pScaleText(NULL) + ,pBoolDefault(NULL) + ,pBoolDefaultText(NULL) + ,m_pColumnName(NULL) + ,m_pColumnNameText(NULL) + ,m_pType(NULL) + ,m_pTypeText(NULL) + ,nPos(-1) + ,aYes(ModuleRes(STR_VALUE_YES)) + ,aNo(ModuleRes(STR_VALUE_NO)) + ,nDelayedGrabFocusEvent(0) + ,pActFieldDescr(0) +{ + DBG_CTOR(OFieldDescControl,NULL); + + m_pVertScroll = new ScrollBar(this, WB_VSCROLL | WB_REPEAT | WB_DRAG); + m_pHorzScroll = new ScrollBar(this, WB_HSCROLL | WB_REPEAT | WB_DRAG); + m_pVertScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll)); + m_pHorzScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll)); + m_pVertScroll->Show(); + m_pHorzScroll->Show(); + + m_pVertScroll->EnableClipSiblings(); + m_pHorzScroll->EnableClipSiblings(); + + m_pVertScroll->SetLineSize(1); + m_pVertScroll->SetPageSize(1); + m_pHorzScroll->SetLineSize(1); + m_pHorzScroll->SetPageSize(1); + + m_nOldVThumb = m_nOldHThumb = 0; +} + +//------------------------------------------------------------------------------ +OFieldDescControl::~OFieldDescControl() +{ + DBG_DTOR(OFieldDescControl,NULL); + + delete m_pVertScroll; + delete m_pHorzScroll; + + ////////////////////////////////////////////////////////////////////// + // Childs zerstoeren + DeactivateAggregate( tpDefault ); + DeactivateAggregate( tpRequired ); + DeactivateAggregate( tpTextLen ); + DeactivateAggregate( tpNumType ); + DeactivateAggregate( tpScale ); + DeactivateAggregate( tpLength ); + DeactivateAggregate( tpFormat ); + DeactivateAggregate( tpAutoIncrement ); + DeactivateAggregate( tpBoolDefault ); + DeactivateAggregate( tpColumnName ); + DeactivateAggregate( tpType ); + + if(nDelayedGrabFocusEvent) + Application::RemoveUserEvent(nDelayedGrabFocusEvent); +} + +//------------------------------------------------------------------------------ +String OFieldDescControl::BoolStringPersistent(const String& rUIString) const +{ + static String aZero('0'); + static String aOne('1'); + static String aNo(ModuleRes(STR_VALUE_NO)); + static String aYes(ModuleRes(STR_VALUE_YES)); + + if (rUIString == aNo) + return aZero; + if (rUIString == aYes) + return aOne; + return String(); +} + +//------------------------------------------------------------------------------ +String OFieldDescControl::BoolStringUI(const String& rPersistentString) const +{ + static String aZero('0'); + static String aOne('1'); + static String aYes(ModuleRes(STR_VALUE_YES)); + static String aNo(ModuleRes(STR_VALUE_NO)); + static String aNone(ModuleRes(STR_VALUE_NONE)); + + // FS - 66161 - 14.05.1999 - aeltere Versionen haben eventuell einen sprachabhaengigen String als Default gespeichert + if (rPersistentString.Equals(aYes) || rPersistentString.Equals(aNo)) + return rPersistentString; + + if (rPersistentString == aZero) + return aNo; + if (rPersistentString == aOne) + return aYes; + + return aNone; +} + +//------------------------------------------------------------------------------ +void OFieldDescControl::Init() +{ +} + +//------------------------------------------------------------------------------ +IMPL_LINK(OFieldDescControl, OnScroll, ScrollBar*, pBar) +{ + ScrollAllAggregates(); + return 0; +} + +//------------------------------------------------------------------------------ +void OFieldDescControl::CheckScrollBars() +{ + // ein paar Berechnungen zur neuen Position der ScrollBars + Size szOverallSize = GetSizePixel(); + long nHScrollHeight = m_pHorzScroll->GetSizePixel().Height(); + long nVScrollWidth = m_pVertScroll->GetSizePixel().Width(); + + long nNewHWidth = szOverallSize.Width() - nVScrollWidth; + long nNewVHeight = szOverallSize.Height() - nHScrollHeight; + + sal_Bool bNeedHScrollBar(sal_False), bNeedVScrollBar(sal_False); + + // die Bereiche anpassen + // brauche ich ScrollBars eigentlich ? + // horizontal : + long lMaxXPosition = 0; + if (pRequired) + lMaxXPosition = ::std::max(lMaxXPosition, pRequired->GetSizePixel().Width() + pRequired->GetPosPixel().X()); + if (pNumType) + lMaxXPosition = ::std::max(lMaxXPosition, pNumType->GetSizePixel().Width() + pNumType->GetPosPixel().X()); + if (pAutoIncrement) + lMaxXPosition = ::std::max(lMaxXPosition, pAutoIncrement->GetSizePixel().Width() + pAutoIncrement->GetPosPixel().X()); + if (pDefault) + lMaxXPosition = ::std::max(lMaxXPosition, pDefault->GetSizePixel().Width() + pDefault->GetPosPixel().X()); + if (pTextLen) + lMaxXPosition = ::std::max(lMaxXPosition, pTextLen->GetSizePixel().Width() + pTextLen->GetPosPixel().X()); + if (pLength) + lMaxXPosition = ::std::max(lMaxXPosition, pLength->GetSizePixel().Width() + pLength->GetPosPixel().X()); + if (pScale) + lMaxXPosition = ::std::max(lMaxXPosition, pScale->GetSizePixel().Width() + pScale->GetPosPixel().X()); + if (pFormat) + lMaxXPosition = ::std::max(lMaxXPosition, pFormat->GetSizePixel().Width() + pFormat->GetPosPixel().X()); + if (m_pColumnName) + lMaxXPosition = ::std::max(lMaxXPosition, m_pColumnName->GetSizePixel().Width() + m_pColumnName->GetPosPixel().X()); + if (m_pType) + lMaxXPosition = ::std::max(lMaxXPosition, m_pType->GetSizePixel().Width() + m_pType->GetPosPixel().X()); + + if (m_pHorzScroll) + lMaxXPosition += m_pHorzScroll->GetThumbPos() * HSCROLL_STEP; + + long lMaxXAvailable = szOverallSize.Width(); + bNeedHScrollBar = lMaxXPosition > lMaxXAvailable; + // aendert sich vielleicht noch + + // vertikal + // wieviel Controls habe ich + sal_uInt16 nActive = CountActiveAggregates(); + // welches ist das letzte, was ganz drauf passt ? + sal_uInt16 nLastVisible; + if (bNeedHScrollBar) + nLastVisible = (szOverallSize.Height() - CONTROL_SPACING_Y - nHScrollHeight) / (CONTROL_SPACING_Y + CONTROL_HEIGHT); + else + nLastVisible = (szOverallSize.Height() - CONTROL_SPACING_Y) / (CONTROL_SPACING_Y + CONTROL_HEIGHT); + bNeedVScrollBar = nActive>nLastVisible; + + if (bNeedVScrollBar) + { + // in die urspruengliche Berechnung von lMaxXAvailable ist nicht mit eingegangen, dass ich eine VScrollBar habe, also muss ich + // das nachholen + lMaxXAvailable -= nVScrollWidth; + if (!bNeedHScrollBar && (lMaxXPosition > lMaxXAvailable)) + { + // durch die vertikale brauche ich jetzt ploetzlich doch eine horizontale + bNeedHScrollBar = sal_True; + // nLastVisible anpassen + nLastVisible = (szOverallSize.Height() - CONTROL_SPACING_Y - nHScrollHeight) / (CONTROL_SPACING_Y + CONTROL_HEIGHT); + // bNeedVScrollBar aendert sich nicht : es ist schon auf sal_True und nLastVisible wird hoechstens kleiner + } + } + + // jetzt kann ich sie wirklich positionieren und ihre Parameter setzen + if (bNeedVScrollBar) + { + m_pVertScroll->Show(); + m_pVertScroll->SetRangeMax(nActive - nLastVisible); +// m_pVertScroll->SetThumbPos(0); + + m_pVertScroll->SetPosSizePixel( Point(nNewHWidth, 0), Size(nVScrollWidth, szOverallSize.Height()) ); + } + else + { + m_pVertScroll->Hide(); + m_pVertScroll->SetRangeMax(0); + m_pVertScroll->SetThumbPos(0); + } + + if (bNeedHScrollBar) + { + m_pHorzScroll->Show(); + m_pHorzScroll->SetRangeMax((lMaxXPosition - lMaxXAvailable + HSCROLL_STEP - 1 )/HSCROLL_STEP); +// m_pHorzScroll->SetThumbPos(0); + + m_pHorzScroll->SetPosSizePixel( Point(0, nNewVHeight), Size(bNeedVScrollBar ? nNewHWidth : szOverallSize.Width(), nHScrollHeight) ); + } + else + { + m_pHorzScroll->Hide(); + m_pHorzScroll->SetRangeMax(0); + m_pHorzScroll->SetThumbPos(0); + } +} + +//------------------------------------------------------------------------------ +void OFieldDescControl::Resize() +{ + CheckScrollBars(); + ScrollAllAggregates(); +} + +//------------------------------------------------------------------------------ +inline void OFieldDescControl::ScrollAggregate(Control* pText, Control* pInput, Control* pButton, long nDeltaX, long nDeltaY) +{ + if (!pText) + return; + pText->SetPosPixel(pText->GetPosPixel() + Point(nDeltaX, nDeltaY)); + pInput->SetPosPixel(pInput->GetPosPixel() + Point(nDeltaX, nDeltaY)); + if (pButton) + pButton->SetPosPixel(pButton->GetPosPixel() + Point(nDeltaX, nDeltaY)); +} + +//------------------------------------------------------------------------------ +void OFieldDescControl::ScrollAllAggregates() +{ + long nDeltaX = 0, nDeltaY = 0; + if (m_nOldHThumb != m_pHorzScroll->GetThumbPos()) + { + nDeltaX = (m_nOldHThumb - m_pHorzScroll->GetThumbPos()) * HSCROLL_STEP; + m_nOldHThumb = m_pHorzScroll->GetThumbPos(); + } + + if (m_nOldVThumb != m_pVertScroll->GetThumbPos()) + { + nDeltaY = (m_nOldVThumb - m_pVertScroll->GetThumbPos()) * (CONTROL_SPACING_Y + CONTROL_HEIGHT); + m_nOldVThumb = m_pVertScroll->GetThumbPos(); + } + + if (nDeltaX || nDeltaY) + { + ScrollAggregate(pRequiredText, pRequired, NULL, nDeltaX, nDeltaY); + ScrollAggregate(pNumTypeText, pNumType, NULL, nDeltaX, nDeltaY); + ScrollAggregate(pAutoIncrementText, pAutoIncrement, NULL, nDeltaX, nDeltaY); + ScrollAggregate(pDefaultText, pDefault, NULL, nDeltaX, nDeltaY); + ScrollAggregate(pTextLenText, pTextLen, NULL, nDeltaX, nDeltaY); + ScrollAggregate(pLengthText, pLength, NULL, nDeltaX, nDeltaY); + ScrollAggregate(pScaleText, pScale, NULL, nDeltaX, nDeltaY); + ScrollAggregate(pFormatText, pFormatSample, pFormat, nDeltaX, nDeltaY); + ScrollAggregate(m_pColumnNameText, m_pColumnName, NULL, nDeltaX, nDeltaY); + ScrollAggregate(m_pTypeText, m_pType, NULL, nDeltaX, nDeltaY); + } +} + +//------------------------------------------------------------------------------ +sal_uInt16 OFieldDescControl::CountActiveAggregates() const +{ + Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType}; + sal_uInt16 nVisibleAggregates = 0; + for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i) + if (ppAggregates[i]) + ++nVisibleAggregates; + return nVisibleAggregates; +} + +//------------------------------------------------------------------------------ +void OFieldDescControl::SetReadOnly( sal_Bool bReadOnly ) +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + ////////////////////////////////////////////////////////////////////// + // Controls enablen/disablen + if (pDefault) + { + pDefaultText->Enable( !bReadOnly ); + pDefault->Enable( !bReadOnly ); + } + if (pBoolDefault) + { + pBoolDefaultText->Enable( !bReadOnly ); + pBoolDefault->Enable( !bReadOnly ); + } + if( pRequired ) + { + pRequiredText->Enable( !bReadOnly ); + pRequired->Enable( !bReadOnly ); + } + if( pTextLen ) + { + pTextLenText->Enable( !bReadOnly ); + pTextLen->Enable( !bReadOnly ); + } + if( pNumType ) + { + pNumTypeText->Enable( !bReadOnly ); + pNumType->Enable( !bReadOnly ); + } + if( pFormat ) + { + pFormatText->Enable( !bReadOnly ); + pFormat->Enable( !bReadOnly ); + } + if( pLength ) + { + pLengthText->Enable( !bReadOnly ); + pLength->Enable( !bReadOnly ); + } + if( pScale ) + { + pScaleText->Enable( !bReadOnly ); + pScale->Enable( !bReadOnly ); + } + if( pAutoIncrement ) + { + pAutoIncrementText->Enable( !bReadOnly ); + pAutoIncrement->Enable( !bReadOnly ); + } + + if( m_pColumnName ) + { + m_pColumnNameText->Enable( !bReadOnly ); + m_pColumnName->Enable( !bReadOnly ); + } + if( m_pType ) + { + m_pTypeText->Enable( !bReadOnly ); + m_pType->Enable( !bReadOnly ); + } +} + +//------------------------------------------------------------------------------ +String OFieldDescControl::GetControlText( sal_uInt16 nControlId ) +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + ////////////////////////////////////////////////////////////////////// + // Texte der Controls auslesen + switch( nControlId ) + { + case FIELD_PROPERTY_BOOL_DEFAULT: + if (pBoolDefault) + return pBoolDefault->GetSelectEntry(); + break; + case FIELD_PROPERTY_DEFAULT: + if (pDefault) + return pDefault->GetText(); + break; + case FIELD_PROPERTY_REQUIRED: + if (pRequired) + return pRequired->GetSelectEntry(); + break; + case FIELD_PROPERTY_TEXTLEN: + if (pTextLen) + return String::CreateFromInt32(pTextLen->GetValue()); + case FIELD_PROPERTY_NUMTYPE: + if (pNumType) + return pNumType->GetSelectEntry(); + break; + case FIELD_PROPERTY_AUTOINC: + if (pAutoIncrement) + return pAutoIncrement->GetSelectEntry(); + break; + case FIELD_PROPERTY_LENGTH: + if (pLength) + return pLength->GetText(); + break; + case FIELD_PROPERTY_SCALE: + if (pScale) + return pScale->GetText(); + break; + case FIELD_PROPERTY_FORMAT: + if (pFormatSample) + return pFormatSample->GetText(); + break; + case FIELD_PRPOERTY_COLUMNNAME: + if(m_pColumnName) + return m_pColumnName->GetText(); + case FIELD_PRPOERTY_TYPE: + if(m_pType) + return m_pType->GetSelectEntry(); + break; + } + + return String(); +} + +//------------------------------------------------------------------------------ +void OFieldDescControl::SetControlText( sal_uInt16 nControlId, const String& rText ) +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + ////////////////////////////////////////////////////////////////////// + // Texte der Controls setzen + switch( nControlId ) + { + case FIELD_PROPERTY_BOOL_DEFAULT: + if (pBoolDefault) + { + String sOld = pBoolDefault->GetSelectEntry(); + pBoolDefault->SelectEntry(rText); + if (!sOld.Equals(rText)) + LINK(this, OFieldDescControl, ChangeHdl).Call(pBoolDefault); + } + break; + case FIELD_PROPERTY_DEFAULT: + if (pDefault) + { + pDefault->SetText(rText); + UpdateFormatSample(pActFieldDescr); + } + break; + + case FIELD_PROPERTY_REQUIRED: + if (pRequired) + pRequired->SelectEntry(rText); + break; + + + case FIELD_PROPERTY_TEXTLEN: + if (pTextLen) + pTextLen->SetText(rText); + break; + + case FIELD_PROPERTY_NUMTYPE: + if (pNumType) + pNumType->SelectEntry(rText); + break; + + case FIELD_PROPERTY_AUTOINC: + if (pAutoIncrement) + { + String sOld = pAutoIncrement->GetSelectEntry(); + pAutoIncrement->SelectEntry(rText); + if (!sOld.Equals(rText)) + LINK(this, OFieldDescControl, ChangeHdl).Call(pAutoIncrement); + } + break; + + case FIELD_PROPERTY_LENGTH: + if (pLength) + pLength->SetText(rText); + break; + + case FIELD_PROPERTY_SCALE: + if (pScale) + pScale->SetText(rText); + break; + + case FIELD_PROPERTY_FORMAT: + if (pActFieldDescr) + UpdateFormatSample(pActFieldDescr); + break; + case FIELD_PRPOERTY_COLUMNNAME: + if(m_pColumnName) + m_pColumnName->SetText(rText); + break; + case FIELD_PRPOERTY_TYPE: + if(m_pType) + m_pType->SelectEntry(rText); + break; + + } +} + +//------------------------------------------------------------------------ +IMPL_LINK( OFieldDescControl, FormatClickHdl, Button *, pButton ) +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + ////////////////////////////////////////////////////////////////////// + // Temporaere Column erzeugen, mit der Datenaustausch mit Dialog erfolgt + if( !pActFieldDescr ) + return 0; + + sal_uInt32 nOldFormatKey(pActFieldDescr->GetFormatKey()); + SvxCellHorJustify rOldJustify = pActFieldDescr->GetHorJustify(); + + // ------------ + // UNO->ItemSet + static SfxItemInfo aItemInfos[] = + { + { 0, 0 }, + { SID_ATTR_NUMBERFORMAT_VALUE, SFX_ITEM_POOLABLE }, + { SID_ATTR_ALIGN_HOR_JUSTIFY, SFX_ITEM_POOLABLE }, + { SID_ATTR_NUMBERFORMAT_ONE_AREA, SFX_ITEM_POOLABLE } + }; + static sal_uInt16 aAttrMap[] = + { + SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY, + SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA, + 0 + }; + + SfxPoolItem* pDefaults[] = + { + new SfxRangeItem(SBA_DEF_RANGEFORMAT, SBA_DEF_FMTVALUE, SBA_ATTR_ALIGN_HOR_JUSTIFY), + new SfxUInt32Item(SBA_DEF_FMTVALUE), + new SvxHorJustifyItem(SVX_HOR_JUSTIFY_STANDARD, SBA_ATTR_ALIGN_HOR_JUSTIFY), + new SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, sal_False) + }; + + SfxItemPool* pPool = new SfxItemPool(String::CreateFromAscii("GridBrowserProperties"), SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY, aItemInfos, pDefaults); + pPool->SetDefaultMetric( SFX_MAPUNIT_TWIP ); // ripped, don't understand why + pPool->FreezeIdRanges(); // the same + + SfxItemSet* pFormatDescriptor = new SfxItemSet(*pPool, aAttrMap); + // fill it + pFormatDescriptor->Put(SvxHorJustifyItem(rOldJustify, SBA_ATTR_ALIGN_HOR_JUSTIFY)); + pFormatDescriptor->Put(SfxUInt32Item(SBA_DEF_FMTVALUE, nOldFormatKey)); + + { // want the dialog to be destroyed before our set + Reference< XNumberFormatsSupplier > xSupplier = GetFormatter()->getNumberFormatsSupplier(); + + Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY); + SvNumberFormatsSupplierObj* pSupplierImpl = (SvNumberFormatsSupplierObj*)xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()); + + SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter(); + + SbaSbAttrDlg aDlg(this, pFormatDescriptor, pFormatter, TP_ATTR_ALIGN | TP_ATTR_NUMBER); + if( aDlg.Execute() == RET_OK ) + { + const SfxItemSet* pSet = aDlg.GetExampleSet(); + // GetExampleSet statt GetOutputItemSet, denn letzteres enthaelt nur die modifizierten Items + + sal_Bool bModified = sal_False; + // den Formatkey + SfxUInt32Item& rFormatItem = (SfxUInt32Item&)pSet->Get(SBA_DEF_FMTVALUE); + sal_uInt32 nNewFormatKey(rFormatItem.GetValue()); + if (nNewFormatKey != nOldFormatKey) + { + SetModified(sal_True); + bModified = sal_True; + } + +// if (m_pFormatterShell->GetListPos4Entry(nNewFormatKey) == -1) +// // Das neue Format ist meiner Formatter-Shell nicht bekannt, wurde also gerade neu angelegt +// // (oder ist in einer anderen Sprache als die aktuell eingestellte gehalten) +// // Das bedeutet, das ich die Shell updaten muss, sonst laeuft UpdateFormatSample in's Leere. +// InitFormatterShell(nNewFormatKey); + + // die horizontale Ausrichtung + SvxHorJustifyItem& rHorJustifyItem = (SvxHorJustifyItem&)pSet->Get(SBA_ATTR_ALIGN_HOR_JUSTIFY); + SvxCellHorJustify rNewJustify = (SvxCellHorJustify)rHorJustifyItem.GetValue(); + if (rNewJustify != rOldJustify) + { + SetModified(sal_True); + bModified = sal_True; + } + + if (bModified) + CellModified(-1, FIELD_PROPERTY_FORMAT); + + // das Setzen an der FieldDecription NACH den CellModified, da das ein Undo-::com::sun::star::chaos::Action erzeugt und die auf die Description + // zurueckgreift + pActFieldDescr->SetFormatKey( nNewFormatKey ); + pActFieldDescr->SetHorJustify(rNewJustify); + + UpdateFormatSample(pActFieldDescr); + + // SFX_BINDINGS().Invalidate(SID_SAVEDOC); + } + } + + return 0; +} + +//------------------------------------------------------------------------ +IMPL_LINK( OFieldDescControl, ChangeHdl, ListBox *, pAutoInc ) +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + if(pAutoInc->GetSavedValue() == pAutoInc->GetSelectEntryPos() || !pActFieldDescr) + return 0; + + SetModified(sal_True); + + // Sonderbehandlund f"ur Bool Felder + if(pAutoInc == pRequired && pBoolDefault ) + { + // wenn pRequired auf sal_True gesetzt ist, dann darf das sal_Bool Feld nicht den Eintrag <<keiner>> besitzen + String sDef = BoolStringUI((pActFieldDescr->GetDefaultValue())); + + if(pRequired->GetSelectEntryPos() == 0) // JA + { + pBoolDefault->RemoveEntry(String(ModuleRes(STR_VALUE_NONE))); + if (!sDef.Equals(aYes) && !sDef.Equals(aNo)) + pBoolDefault->SelectEntryPos(1); // nein als Default + else + pBoolDefault->SelectEntry(sDef); + } + else if(pBoolDefault->GetEntryCount() < 3) + { + pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE))); + pBoolDefault->SelectEntry(sDef); + } + } + + // nur fuer AutoIncrement eine Sonderbehandlung + if (pAutoInc == pAutoIncrement) + { + if(pAutoInc->GetSelectEntryPos() == 1) + { // no + if(pActFieldDescr->IsPrimaryKey()) + DeactivateAggregate( tpRequired ); + else if( pActFieldDescr->getTypeInfo()->bNullable ) + { + ActivateAggregate( tpRequired ); + if(pRequired) + { + if( pActFieldDescr->IsNullable() ) + pRequired->SelectEntryPos( 1 ); // no + else + pRequired->SelectEntryPos( 0 ); // yes + } + } + ActivateAggregate( tpDefault ); + } + else + { + DeactivateAggregate( tpRequired ); + DeactivateAggregate( tpDefault ); + } + // und jetzt alle nach oben schieben + ArrangeAggregates(); + } + + if(pAutoInc == m_pType) + { + pAutoInc->SaveValue(); + const OTypeInfo* pTypeInfo = getTypeInfo(m_pType->GetSelectEntryPos()); + pActFieldDescr->SetType(pTypeInfo); + +// OFieldDescription *pFieldDescr = new OFieldDescription(); +// pFieldDescr->SetType(pTypeInfo); +// +// pFieldDescr->SetName(pActFieldDescr->GetName()); +// pFieldDescr->SetFormatKey(pActFieldDescr->GetFormatKey()); +// pFieldDescr->SetPrimaryKey(pActFieldDescr->IsPrimaryKey()); +// pFieldDescr->SetDescription(pActFieldDescr->GetDescription()); +// pFieldDescr->SetAutoIncrement(pActFieldDescr->IsAutoIncrement()); +// pFieldDescr->SetHorJustify(pActFieldDescr->GetHorJustify()); +// +// ////////////////////////////////////////////////////////////////////// +// // Spezielle Daten +// if(pTypeInfo->bNullable && pActFieldDescr->getTypeInfo()->bNullable) +// pFieldDescr->SetIsNullable(pActFieldDescr->IsNullable()); +// +// pFieldDescr->SetDefaultValue(pActFieldDescr->GetDefaultValue()); +// delete pActFieldDescr; +// pActFieldDescr = pFieldDescr; + DisplayData(pActFieldDescr); + CellModified(-1, m_pType->GetPos()); + } + + return 0; +} +//------------------------------------------------------------------------------ +// alle Control neu anordnen, so dass sie in fester Reihenfolge und wirklich +// OBEN auf der DescriptionPage stehen +void OFieldDescControl::ArrangeAggregates() +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + // die Beschreibung eines Controls + struct AGGREGATE_DESCRIPTION + { + Control* pctrlInputControl; // das eigentliche Control zur Eingabe + Control* pctrlTextControl; // das Label dazu + int nPosSizeArgument; // das zweite Argument fuer SetPosSize + }; + AGGREGATE_DESCRIPTION adAggregates[] = { + { m_pColumnName, m_pColumnNameText, 1}, + { m_pType, m_pTypeText, 1}, + { pAutoIncrement, pAutoIncrementText, 1 }, + { pNumType, pNumTypeText, 1 }, + { pRequired, pRequiredText, 1 }, + { pTextLen, pTextLenText, 1 }, + { pLength, pLengthText, 1 }, + { pScale, pScaleText, 1 }, + { pDefault, pDefaultText, 3 }, + { pFormatSample, pFormatText, 4 }, + { pBoolDefault, pBoolDefaultText, 1 } + }; + + // und los ... + int nCurrentControlPos = 0; + Control* pZOrderPredecessor = NULL; + for (int i=0; i<sizeof(adAggregates)/sizeof(adAggregates[0]); i++) + { + if (adAggregates[i].pctrlInputControl) + { + SetPosSize(&adAggregates[i].pctrlTextControl, nCurrentControlPos, 0); + SetPosSize(&adAggregates[i].pctrlInputControl, nCurrentControlPos, adAggregates[i].nPosSizeArgument); + + // die Z-Order so, dass die Controls auch wirklich in derselben Reihenfolge durchwandert werden koennen, in der sie + // hier angeordnet wurden + adAggregates[i].pctrlInputControl->SetZOrder(pZOrderPredecessor, pZOrderPredecessor ? WINDOW_ZORDER_BEHIND : WINDOW_ZORDER_FIRST); + pZOrderPredecessor = adAggregates[i].pctrlInputControl; + + if (adAggregates[i].pctrlInputControl == pFormatSample) + { + pFormat->SetZOrder(pZOrderPredecessor, WINDOW_ZORDER_BEHIND); + pZOrderPredecessor = pFormat; + } + + ++nCurrentControlPos; + } + } + + // eine Sonderbehandlung fuer die Format-Controls + if (pFormat) + { + Point ptSamplePos(pFormatSample->GetPosPixel()); + Size szSampleSize(pFormatSample->GetSizePixel()); + pFormat->SetPosPixel(Point(ptSamplePos.X() + szSampleSize.Width() + 5, ptSamplePos.Y())); + } + + // als letztes noch die ScrollBars in der ZOrder ganz nach oben + m_pVertScroll->SetZOrder(NULL, WINDOW_ZORDER_FIRST); + m_pHorzScroll->SetZOrder(NULL, WINDOW_ZORDER_FIRST); +} + +//------------------------------------------------------------------------------ +void OFieldDescControl::ActivateAggregate( EControlType eType ) +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + ////////////////////////////////////////////////////////////////////// + // Controls erzeugen + switch( eType ) + { + case tpDefault: + if( pDefault ) + return; + nPos++; + pDefaultText = new FixedText( this ); + pDefaultText->SetText( ModuleRes(STR_DEFAULT_VALUE) ); + pDefault = new OPropEditCtrl( this, STR_HELP_DEFAULT_VALUE, FIELD_PROPERTY_DEFAULT, WB_BORDER ); + pDefault->SetHelpId(HID_TAB_ENT_DEFAULT); + SetPosSize( (Control**)&pDefaultText, nPos, 0 ); + SetPosSize( (Control**)&pDefault, nPos, 3 ); + + pDefault->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); + pDefault->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); + + pDefaultText->EnableClipSiblings(); + pDefault->EnableClipSiblings(); + break; + + case tpRequired: + { + if( pRequired ) + return; + Reference< XDatabaseMetaData> xMetaData = getMetaData(); + + if(xMetaData->supportsNonNullableColumns()) + { + nPos++; + pRequiredText = new FixedText( this ); + pRequiredText->SetText( ModuleRes(STR_FIELD_REQUIRED) ); + pRequired = new OPropListBoxCtrl( this, STR_HELP_FIELD_REQUIRED, FIELD_PROPERTY_REQUIRED, WB_DROPDOWN); + pRequired->SetHelpId(HID_TAB_ENT_REQUIRED); + + pRequired->InsertEntry( aYes ); + pRequired->InsertEntry( aNo ); + pRequired->SelectEntryPos(1); + pRequired->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl)); + + SetPosSize( (Control**)&pRequiredText, nPos, 0 ); + SetPosSize( (Control**)&pRequired, nPos, 2 ); + + pRequired->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); + pRequired->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); + + pRequiredText->EnableClipSiblings(); + pRequired->EnableClipSiblings(); + } + } + break; + case tpAutoIncrement: + { + if( pAutoIncrement ) + return; + nPos++; + pAutoIncrementText = new FixedText( this ); + pAutoIncrementText->SetText( ModuleRes(STR_FIELD_AUTOINCREMENT) ); + pAutoIncrement = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PROPERTY_AUTOINC, WB_DROPDOWN ); + pAutoIncrement->SetHelpId(HID_TAB_ENT_AUTOINCREMENT); + + pAutoIncrement->InsertEntry( aYes ); + pAutoIncrement->InsertEntry( aNo ); + pAutoIncrement->SelectEntryPos(0); + pAutoIncrement->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl)); + + SetPosSize( (Control**)&pAutoIncrementText, nPos, 0 ); + SetPosSize( (Control**)&pAutoIncrement, nPos, 2 ); + + pAutoIncrement->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); + pAutoIncrement->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); + + pAutoIncrementText->EnableClipSiblings(); + pAutoIncrement->EnableClipSiblings(); + } + break; + case tpTextLen: + if( pTextLen ) + return; + nPos++; + pTextLenText = new FixedText( this ); + pTextLenText->SetText( ModuleRes(STR_TEXT_LENGTH) ); + + pTextLen = new OPropNumericEditCtrl( this, STR_HELP_TEXT_LENGTH, FIELD_PROPERTY_TEXTLEN, WB_BORDER ); + pTextLen->SetDecimalDigits(0); + pTextLen->SetMin(0); + pTextLen->SetMax(0x7FFFFFFF); // soll draussen geaendert werden, wenn noetig + + pTextLen->SetHelpId(HID_TAB_ENT_TEXT_LEN); + SetPosSize( (Control**)&pTextLenText, nPos, 0 ); + SetPosSize( (Control**)&pTextLen, nPos, 1 ); + + pTextLen->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); + pTextLen->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); + + pTextLenText->EnableClipSiblings(); + pTextLen->EnableClipSiblings(); + break; + + case tpType: + if( m_pType) + return; + nPos++; + m_pTypeText = new FixedText( this ); + m_pTypeText->SetText( ModuleRes(STR_TAB_FIELD_DATATYPE) ); + m_pType = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PRPOERTY_TYPE, WB_DROPDOWN ); + m_pType->SetHelpId(HID_TAB_ENT_TYPE); + m_pType->SetDropDownLineCount(5); + { + const OTypeInfoMap* pTypeInfo = getTypeInfo(); + OTypeInfoMap::const_iterator aIter = pTypeInfo->begin(); + for(;aIter != pTypeInfo->end();++aIter) + m_pType->InsertEntry( aIter->second->aUIName ); + } + m_pType->SelectEntryPos(0); + m_pType->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl)); + + SetPosSize( (Control**)&m_pTypeText, nPos, 0 ); + SetPosSize( (Control**)&m_pType, nPos, 2 ); + + m_pType->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); + m_pType->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); + + m_pTypeText->EnableClipSiblings(); + m_pType->EnableClipSiblings(); + break; + case tpColumnName: + if( m_pColumnName ) + return; + nPos++; + m_pColumnNameText = new FixedText( this ); + m_pColumnNameText->SetText( ModuleRes(STR_TAB_FIELD_NAME) ); + m_pColumnName = new OPropEditCtrl( this, STR_HELP_DEFAULT_VALUE, FIELD_PRPOERTY_COLUMNNAME, WB_BORDER ); + m_pColumnName->SetHelpId(HID_TAB_ENT_COLUMNNAME); + { + Reference< XDatabaseMetaData> xMetaData = getMetaData(); + sal_uInt32 nMax = xMetaData->getMaxColumnNameLength(); + m_pColumnName->SetMaxTextLen( nMax ? nMax : EDIT_NOLIMIT); + } + + SetPosSize( (Control**)&m_pColumnNameText, nPos, 0 ); + SetPosSize( (Control**)&m_pColumnName, nPos, 1 ); + + m_pColumnName->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); + m_pColumnName->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); + + m_pColumnNameText->EnableClipSiblings(); + m_pColumnName->EnableClipSiblings(); + break; + case tpNumType: + if( pNumType ) + return; + nPos++; + pNumTypeText = new FixedText( this ); + pNumTypeText->SetText( ModuleRes(STR_NUMERIC_TYPE) ); + + pNumType = new OPropListBoxCtrl( this, STR_HELP_NUMERIC_TYPE, FIELD_PROPERTY_NUMTYPE, WB_DROPDOWN ); + pNumType->SetDropDownLineCount(5); + pNumType->SetHelpId(HID_TAB_ENT_NUMTYP); + + pNumType->InsertEntry( String::CreateFromAscii("Byte") ); + pNumType->InsertEntry( String::CreateFromAscii("SmallInt") ); + pNumType->InsertEntry( String::CreateFromAscii("Integer") ); + pNumType->InsertEntry( String::CreateFromAscii("Single") ); + pNumType->InsertEntry( String::CreateFromAscii("Double") ); + pNumType->SelectEntryPos(2); + pNumType->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl)); + + SetPosSize( (Control**)&pNumTypeText, nPos, 0 ); + SetPosSize( (Control**)&pNumType, nPos, 1 ); + + pNumType->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); + pNumType->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); + + pNumTypeText->EnableClipSiblings(); + pNumType->EnableClipSiblings(); + break; + + case tpLength: + if( pLength ) + return; + nPos++; + pLengthText = new FixedText( this ); + pLengthText->SetText( ModuleRes(STR_LENGTH) ); + + pLength = new OPropNumericEditCtrl( this, STR_HELP_LENGTH, FIELD_PROPERTY_LENGTH, WB_BORDER ); + pLength->SetDecimalDigits(0); + pLength->SetMin(0); + pLength->SetMax(0x7FFFFFFF); // soll draussen geaendert werden, wenn noetig + + pLength->SetHelpId(HID_TAB_ENT_LEN); + SetPosSize( (Control**)&pLengthText, nPos, 0 ); + SetPosSize( (Control**)&pLength, nPos, 1 ); + + pLength->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); + pLength->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); + + pLengthText->EnableClipSiblings(); + pLength->EnableClipSiblings(); + break; + + case tpScale: + if( pScale ) + return; + nPos++; + pScaleText = new FixedText( this ); + pScaleText->SetText( ModuleRes(STR_SCALE) ); + pScale = new OPropNumericEditCtrl( this, STR_HELP_SCALE, FIELD_PROPERTY_SCALE, WB_BORDER ); + pScale->SetDecimalDigits(0); + pScale->SetMin(0); + pScale->SetMax(0x7FFFFFFF); // soll draussen geaendert werden, wenn noetig + + pScale->SetHelpId(HID_TAB_ENT_SCALE); + + SetPosSize( (Control**)&pScaleText, nPos, 0 ); + SetPosSize( (Control**)&pScale, nPos, 1 ); + + pScale->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); + pScale->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); + + pScaleText->EnableClipSiblings(); + pScale->EnableClipSiblings(); + break; + + case tpFormat: + if (!pFormat) + { + nPos++; + pFormatText = new FixedText( this ); + pFormatText->SetText( ModuleRes(STR_FORMAT) ); + + pFormatSample = new OPropEditCtrl( this, STR_HELP_FORMAT_CODE, -1, WB_BORDER ); + pFormatSample->SetHelpId(HID_TAB_ENT_FORMAT_SAMPLE); + pFormatSample->SetReadOnly(sal_True); + pFormatSample->Enable(sal_False); + + pFormat = new PushButton( this, ModuleRes(PB_FORMAT) ); + pFormat->SetHelpId(HID_TAB_ENT_FORMAT); + pFormat->SetSizePixel(Size(CONTROL_HEIGHT, CONTROL_HEIGHT)); + pFormat->SetClickHdl( LINK( this, OFieldDescControl, FormatClickHdl ) ); + + pFormatSample->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); + pFormatSample->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); + pFormat->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); + pFormat->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); + + pFormatText->EnableClipSiblings(); + pFormatSample->EnableClipSiblings(); + pFormat->EnableClipSiblings(); + } + + UpdateFormatSample(pActFieldDescr); + break; + case tpBoolDefault: + if (pBoolDefault) + return; + + nPos++; + pBoolDefaultText = new FixedText(this); + pBoolDefaultText->SetText(ModuleRes(STR_DEFAULT_VALUE)); + pBoolDefault = new OPropListBoxCtrl( this, STR_HELP_BOOL_DEFAULT, FIELD_PROPERTY_BOOL_DEFAULT, WB_DROPDOWN ); + pBoolDefault->SetDropDownLineCount(3); + pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE))); + pBoolDefault->InsertEntry(aYes); + pBoolDefault->InsertEntry(aNo); + pBoolDefault->SetHelpId(HID_TAB_ENT_BOOL_DEFAULT); + SetPosSize( (Control**)&pBoolDefaultText, nPos, 0 ); + SetPosSize( (Control**)&pBoolDefault, nPos, 3 ); + + pBoolDefault->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); + pBoolDefault->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); + + pBoolDefaultText->EnableClipSiblings(); + pBoolDefault->EnableClipSiblings(); + break; + + } +} + +//------------------------------------------------------------------------------ +void OFieldDescControl::DeactivateAggregate( EControlType eType ) +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + ////////////////////////////////////////////////////////////////////// + // Controls zerstoeren + switch( eType ) + { + case tpDefault: + if( !pDefault ) + return; + nPos--; + pDefault->Hide(); + pDefaultText->Hide(); + delete pDefault; + delete pDefaultText; + pDefault = NULL; + pDefaultText = NULL; + break; + + case tpColumnName: + if( !m_pColumnName ) + return; + nPos--; + m_pColumnName->Hide(); + m_pColumnNameText->Hide(); + delete m_pColumnName; + delete m_pColumnNameText; + m_pColumnName = NULL; + m_pColumnNameText = NULL; + break; + + case tpType: + if( !m_pType ) + return; + nPos--; + m_pType->Hide(); + m_pTypeText->Hide(); + delete m_pType; + delete m_pTypeText; + m_pType = NULL; + m_pTypeText = NULL; + break; + + case tpAutoIncrement: + if( !pAutoIncrement ) + return; + nPos--; + pAutoIncrement->Hide(); + pAutoIncrementText->Hide(); + delete pAutoIncrement; + delete pAutoIncrementText; + pAutoIncrement = NULL; + pAutoIncrementText = NULL; + break; + + case tpRequired: + if( !pRequired ) + return; + nPos--; + pRequired->Hide(); + pRequiredText->Hide(); + delete pRequired; + delete pRequiredText; + pRequired = NULL; + pRequiredText = NULL; + break; + + case tpTextLen: + if( !pTextLen ) + return; + nPos--; + pTextLen->Hide(); + pTextLenText->Hide(); + delete pTextLen; + delete pTextLenText; + pTextLen = NULL; + pTextLenText = NULL; + break; + + case tpNumType: + if( !pNumType ) + return; + nPos--; + pNumType->Hide(); + pNumTypeText->Hide(); + delete pNumType; + delete pNumTypeText; + pNumType = NULL; + pNumTypeText = NULL; + break; + + case tpLength: + if( !pLength ) + return; + nPos--; + pLength->Hide(); + pLengthText->Hide(); + delete pLength; + delete pLengthText; + pLength = NULL; + pLengthText = NULL; + break; + + case tpScale: + if( !pScale ) + return; + nPos--; + pScale->Hide(); + pScaleText->Hide(); + delete pScale; + delete pScaleText; + pScale = NULL; + pScaleText = NULL; + break; + + case tpFormat: + if( !pFormat ) + return; + pFormatText->Hide(); + pFormatSample->Hide(); + pFormat->Hide(); + delete pFormatText; + delete pFormatSample; + delete pFormat; + pFormatText = NULL; + pFormatSample = NULL; + pFormat = NULL; + break; + case tpBoolDefault: + if (!pBoolDefault) + return; + nPos--; + pBoolDefault->Hide(); + pBoolDefaultText->Hide(); + delete pBoolDefault; + delete pBoolDefaultText; + pBoolDefault = NULL; + pBoolDefaultText = NULL; + break; + + } +} + +//------------------------------------------------------------------------------ +void OFieldDescControl::SetPosSize( Control** ppControl, long nRow, sal_uInt16 nCol ) +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + ////////////////////////////////////////////////////////////////////// + // Position ermitteln + Point aPosition; + switch( nCol ) + { + case 0: + aPosition.X() = 0; + break; + case 1: + case 2: + case 3: + case 4: + aPosition.X() = CONTROL_WIDTH_1 + CONTROL_SPACING_X; + break; + default: + aPosition.X() = 0; + } + + aPosition.Y() = ((nRow+1)*CONTROL_SPACING_Y) + + (nRow*CONTROL_HEIGHT); + + ////////////////////////////////////////////////////////////////////// + // Groesse ermitteln + Size aSize; + switch( nCol ) + { + case 0: + aSize.Width() = CONTROL_WIDTH_1; + aSize.Height() = CONTROL_HEIGHT; + break; + case 1: + aSize.Width() = CONTROL_WIDTH_2; + aSize.Height() = CONTROL_HEIGHT; + break; + case 2: + aSize.Width() = CONTROL_WIDTH_2; + aSize.Height() = long(1.5*CONTROL_HEIGHT); + break; + case 3: + aSize.Width() = CONTROL_WIDTH_3; + aSize.Height() = CONTROL_HEIGHT; + break; + case 4: + aSize.Width() = CONTROL_WIDTH_4; + aSize.Height() = CONTROL_HEIGHT; + break; + default: + aSize.Width() = CONTROL_WIDTH_1; + aSize.Height() = CONTROL_HEIGHT; + } + + + ////////////////////////////////////////////////////////////////////// + // Control anzeigen + (*ppControl)->SetPosSizePixel( aPosition, aSize ); + (*ppControl)->Show(); +} +//------------------------------------------------------------------------------ +//void OFieldDescControl::DisplayData(const OColumn* pColumn) +//{ +// if(pActFieldDescr) +// delete pActFieldDescr; +// +// SFX_ITEMSET_GET(*pColumn, pName, ONameItem, SBA_DEF_FLTNAME, sal_True); +// SFX_ITEMSET_GET(*pColumn, pType, ODataFieldTypeItem, SBA_DEF_FLTTYPE, sal_True); +// SFX_ITEMSET_GET(*pColumn, pLength, SfxUInt32Item, SBA_DEF_FLTLENGTH, sal_True); +// SFX_ITEMSET_GET(*pColumn, pRequired, SfxBoolItem, SBA_DEF_FLTREQUIRED, sal_True); +// SFX_ITEMSET_GET(*pColumn, pPrimary, SfxBoolItem, SBA_DEF_FLTPRIMARY, sal_True); +// SFX_ITEMSET_GET(*pColumn, pComment, SfxStringItem, SBA_DEF_FLTCOMMENT, sal_True); +// SFX_ITEMSET_GET(*pColumn, pFormat, SfxUInt32Item, SBA_DEF_FMTVALUE, sal_True); +// SFX_ITEMSET_GET(*pColumn, pScale, SfxUInt16Item, SBA_DEF_FLTSCALE, sal_True); +// SFX_ITEMSET_GET(*pColumn, pDefault, SfxStringItem, SBA_DEF_FLTDEFAULT, sal_True); +// SFX_ITEMSET_GET(*pColumn, pAutoIncrement, SfxBoolItem, SBA_DEF_FLTAUTOINCREMENT, sal_True); +// SFX_ITEMSET_GET(*pColumn, pHorJustify, SvxHorJustifyItem, SBA_ATTR_ALIGN_HOR_JUSTIFY, sal_True); +// +// sal_Int32 aFieldType = pType->GetType(); +// OFieldDescription* pFieldDescr; +// switch(aFieldType) +// { +// case dbNone: // undefiniert: unbekannt +// pFieldDescr = new OUnknownFieldDescr(); break; +// case dbText: // var. Text: +// pFieldDescr = new OTextFieldDescr(); break; +// case dbNumeric: // Zahlen von Byte bis double: +// pFieldDescr = new ONumericFieldDescr(); break; +// case dbDateTime: // Datumzeit: +// pFieldDescr = new ODateTimeFieldDescr(); break; +// case dbDate: // Datum: +// pFieldDescr = new ODateFieldDescr(); break; +// case dbTime: // Zeit: +// pFieldDescr = new OTimeFieldDescr(); break; +// case dbBool: // Logical: +// pFieldDescr = new OBoolFieldDescr(); break; +// case dbCurrency: // Whrung: +// pFieldDescr = new OCurrencyFieldDescr(); break; +// case dbMemo: // Langer Text: +// pFieldDescr = new OMemoFieldDescr(); break; +// case dbCounter: // Zaehler: +// pFieldDescr = new OCounterFieldDescr(); break; +// case dbImage: // Bilder: +// pFieldDescr = new OImageFieldDescr(); break; +// case dbChar: // fixt. Text: +// pFieldDescr = new OCharFieldDescr(); break; +// case dbDecimal: // decimal Werte: mit Vor und Nachkommastellen: +// pFieldDescr = new ODecimalFieldDescr(); break; +// case dbBinary: // Binary Feld bis 255: +// pFieldDescr = new OBinaryFieldDescr(); break; +// case dbVarBinary: // VarBinary Feld bis 255: +// pFieldDescr = new OVarBinaryFieldDescr(); break; +// case dbBigInt: // Big integer: +// pFieldDescr = new OBigIntFieldDescr(); break; +// +// } +// +// +// pFieldDescr->SetName(pName->GetValue()); +// pFieldDescr->SetFormatKey(pFormat->GetValue()); +// pFieldDescr->SetPrimaryKey(pPrimary->GetValue()); +// pFieldDescr->SetDescription(pComment->GetValue()); +// pFieldDescr->SetAutoIncrement(pAutoIncrement->GetValue()); +// pFieldDescr->SetHorJustify((SvxCellHorJustify)pHorJustify->GetValue()); +// +// ////////////////////////////////////////////////////////////////////// +// // Spezielle Daten +// if( pFieldDescr->ISA(OExtFieldDescription) ) +// { +// ((OExtFieldDescription*)pFieldDescr)->SetRequired(pRequired->GetValue()); +// ((OExtFieldDescription*)pFieldDescr)->SetDefaultValue(pDefault->GetValue()); +// } +// +// switch( pFieldDescr->GetFieldType() ) +// { +// case dbText: +// ((OTextFieldDescr*)pFieldDescr )->SetTextLen( (xub_StrLen)(pLength->GetValue()) ); +// break; +// +// case dbNumeric: +// ( (ONumericFieldDescr*)pFieldDescr )->SetNumType(GetDataDef()->SizeString((ONumericSize)pLength->GetValue()) ); +// break; +// +// case dbChar: +// ((OCharFieldDescr*)pFieldDescr )->SetTextLen( (xub_StrLen)(pLength->GetValue()) ); +// break; +// +// case dbDecimal: +// { +// ODecimalFieldDescr* pDecFieldDescr = (ODecimalFieldDescr*)pFieldDescr; +// pDecFieldDescr->SetLength( (xub_StrLen)(pLength->GetValue()) ); +// pDecFieldDescr->SetScale( String::CreateFromInt32(pScale->GetValue()) ); +// } +// break; +// case dbBinary: +// ((OBinaryFieldDescr*)pFieldDescr )->SetLength( (xub_StrLen)(pLength->GetValue()) ); +// break; +// +// case dbVarBinary: +// ((OVarBinaryFieldDescr*)pFieldDescr )->SetLength( (xub_StrLen)(pLength->GetValue()) ); +// break; +// } +// +// DisplayData(pFieldDescr); +//} +//------------------------------------------------------------------------------ +void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr ) +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + pActFieldDescr = pFieldDescr; + if(!pFieldDescr) + { + DeactivateAggregate( tpDefault ); + DeactivateAggregate( tpRequired ); + DeactivateAggregate( tpTextLen ); + DeactivateAggregate( tpNumType ); + DeactivateAggregate( tpScale ); + DeactivateAggregate( tpLength ); + DeactivateAggregate( tpFormat ); + DeactivateAggregate( tpAutoIncrement ); + DeactivateAggregate( tpBoolDefault ); + DeactivateAggregate( tpColumnName ); + DeactivateAggregate( tpType ); + m_pPreviousType = NULL; + return; + } + + const OTypeInfo* pFieldType = NULL; + if( pFieldDescr ) + pFieldType = pFieldDescr->getTypeInfo(); + + ActivateAggregate( tpColumnName ); + ActivateAggregate( tpType ); + + OSL_ENSURE(pFieldType,"We need a type information here!"); + ////////////////////////////////////////////////////////////////////// + // Wenn sich der Typ geaendert hat, Controls austauschen + if( m_pPreviousType != pFieldType ) + { + ////////////////////////////////////////////////////////////////////// + // Zeiger des gespeicherten Focus zuruecksetzen + pLastFocusWindow = NULL; + + ////////////////////////////////////////////////////////////////////// + // Controls, die nicht mehr angezeigt werden duerfen + DeactivateAggregate( tpNumType ); + + ////////////////////////////////////////////////////////////////////// + // determine which controls we should show and which not + + // 1. the required control + if(pFieldType->bNullable) + ActivateAggregate( tpRequired ); + else + DeactivateAggregate( tpRequired ); + + // 2. the autoincrement + if(pFieldType->bAutoIncrement) + { + DeactivateAggregate( tpRequired ); + DeactivateAggregate( tpDefault ); + ActivateAggregate( tpAutoIncrement ); + } + else + { + DeactivateAggregate( tpAutoIncrement ); + if(pFieldType->bNullable) + ActivateAggregate( tpRequired ); + else + DeactivateAggregate( tpRequired ); + ActivateAggregate( tpDefault ); + } + // 3. the scale and precision + if (pFieldType->nPrecision) + { + ActivateAggregate( tpLength ); + pLength->SetMax(pFieldType->nPrecision); + pLength->SetSpecialReadOnly(pFieldType->aCreateParams.getLength()==0); + } + else + DeactivateAggregate( tpLength ); + + if (pFieldType->nMaximumScale) + { + ActivateAggregate( tpScale ); + pScale->SetMax(pFieldType->nMaximumScale); + pScale->SetMin(pFieldType->nMinimumScale); + pScale->SetSpecialReadOnly(pFieldType->aCreateParams.getLength()==0); + } + else + DeactivateAggregate( tpScale ); + + // and now look for type specific things + switch( pFieldType->nType ) + { + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + DeactivateAggregate( tpLength ); + DeactivateAggregate( tpBoolDefault ); + + ActivateAggregate( tpDefault ); + ActivateAggregate( tpFormat ); + if (pFieldType->nPrecision) + { + ActivateAggregate( tpTextLen ); + pTextLen->SetMax(pFieldType->nPrecision); + pTextLen->SetSpecialReadOnly(pFieldType->aCreateParams.getLength()==0); + } + else + DeactivateAggregate( tpTextLen ); + break; + case DataType::DATE: + case DataType::TIME: + case DataType::TIMESTAMP: + DeactivateAggregate( tpLength ); // we don't need a length for date types + DeactivateAggregate( tpTextLen ); + DeactivateAggregate( tpBoolDefault ); + + ActivateAggregate( tpDefault ); + ActivateAggregate( tpFormat ); + break; + case DataType::BIT: + DeactivateAggregate( tpTextLen ); + DeactivateAggregate( tpFormat ); + DeactivateAggregate( tpDefault ); + + ActivateAggregate( tpBoolDefault ); + break; + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::BIGINT: + case DataType::FLOAT: + case DataType::DOUBLE: + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::INTEGER: + case DataType::REAL: + DeactivateAggregate( tpTextLen ); + DeactivateAggregate( tpBoolDefault ); + + ActivateAggregate( tpFormat ); + break; + case DataType::BINARY: + case DataType::VARBINARY: + DeactivateAggregate( tpDefault ); + DeactivateAggregate( tpRequired ); + DeactivateAggregate( tpTextLen ); + DeactivateAggregate( tpBoolDefault ); + + ActivateAggregate( tpFormat ); + break; + case DataType::LONGVARBINARY: + case DataType::SQLNULL: + case DataType::OBJECT: + case DataType::DISTINCT: + case DataType::STRUCT: + case DataType::ARRAY: + case DataType::BLOB: + case DataType::CLOB: + case DataType::REF: + DeactivateAggregate( tpFormat ); + DeactivateAggregate( tpTextLen ); + DeactivateAggregate( tpBoolDefault ); + + break; + default: + OSL_ENSURE(0,"Unknown type"); + } + m_pPreviousType = pFieldType; + } + if(pFieldDescr) + { + if(pFieldDescr->IsPrimaryKey()) + { + DeactivateAggregate( tpRequired ); + } + else if(!pAutoIncrement && pFieldType) + { + if(pFieldType->bNullable) + ActivateAggregate( tpRequired ); + else + DeactivateAggregate( tpRequired ); + } + } + ////////////////////////////////////////////////////////////////////// + // Controls initialisieren + if( pAutoIncrement ) + { + if(pFieldDescr->IsAutoIncrement()) + { + pAutoIncrement->SelectEntryPos( 0 ); // yes + DeactivateAggregate( tpRequired ); + DeactivateAggregate( tpDefault ); + } + else + { + // hat Auswirkungen auf pRequired + pAutoIncrement->SelectEntryPos( 1 ); // no + ActivateAggregate( tpDefault ); + if(!pFieldDescr->IsPrimaryKey()) + ActivateAggregate( tpRequired ); + } + } + + if( pDefault ) + { + pDefault->SetText( pFieldDescr->GetDefaultValue() ); + pDefault->ClearModifyFlag(); + } + + if( pBoolDefault ) + { + // wenn pRequired auf sal_True gesetzt ist, dann darf das sal_Bool Feld nicht den Eintrag <<keiner>> besitzen + String sDef = BoolStringUI(pFieldDescr->GetDefaultValue()); + + // sicher stellen das <<keiner>> nur vorhanden ist, wenn das Feld NULL sein darf + if(pFieldType && !pFieldType->bNullable || !pFieldDescr->IsNullable() ) + { + pFieldDescr->SetIsNullable(ColumnValue::NO_NULLS); // der Typ sagt das + + pBoolDefault->RemoveEntry(String(ModuleRes(STR_VALUE_NONE))); + if (!sDef.Equals(aYes) && !sDef.Equals(aNo)) + pBoolDefault->SelectEntryPos(1); // nein als Default + else + pBoolDefault->SelectEntry(sDef); + + pFieldDescr->SetDefaultValue(BoolStringPersistent(pBoolDefault->GetSelectEntry())); + } + else if(pBoolDefault->GetEntryCount() < 3) + { + pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE))); + pBoolDefault->SelectEntry(sDef); + } + else + pBoolDefault->SelectEntry(sDef); + } + + if( pRequired ) + { + if( pFieldDescr->IsNullable() ) + pRequired->SelectEntryPos( 1 ); // no + else + pRequired->SelectEntryPos( 0 ); // yes + } + + if( pTextLen ) + { + pTextLen->SetText( String::CreateFromInt32(pFieldDescr->GetPrecision()) ); + pTextLen->ClearModifyFlag(); + } + + if( pNumType ) + { + OSL_ASSERT(0); + } + + if( pLength ) + pLength->SetText( String::CreateFromInt32(pFieldDescr->GetPrecision()) ); + + if( pScale ) + pScale->SetText( String::CreateFromInt32(pFieldDescr->GetScale()) ); + + if( pFormat ) + UpdateFormatSample(pFieldDescr); + + if(m_pColumnName) + m_pColumnName->SetText(pFieldDescr->GetName()); + + if(m_pType) + m_pType->SelectEntryPos(pFieldDescr->GetType()); + + + ////////////////////////////////////////////////////////////////////// + // Controls Enablen/Disablen + sal_Bool bRead(IsReadOnly()); + + + ArrangeAggregates(); + CheckScrollBars(); + ScrollAllAggregates(); + + SetReadOnly( bRead ); +} +//------------------------------------------------------------------------ +IMPL_LINK(OFieldDescControl, DelayedGrabFocus, Control**, ppControl) +{ + nDelayedGrabFocusEvent = 0; + if (*ppControl) + (*ppControl)->GrabFocus(); + + return 0L; +} + +//------------------------------------------------------------------------------ +IMPL_LINK(OFieldDescControl, OnControlFocusGot, Control*, pControl ) +{ + String strHelpText; + if ((pControl == pLength) || (pControl == pScale) || (pControl == pTextLen)) + { + ((OPropNumericEditCtrl*)pControl)->SaveValue(); + strHelpText = ((OPropNumericEditCtrl*)pControl)->GetHelp(); + } + if ((pControl == pDefault) || (pControl == pFormatSample) || (pControl == m_pColumnName)) + { + ((OPropEditCtrl*)pControl)->SaveValue(); + strHelpText = ((OPropEditCtrl*)pControl)->GetHelp(); + } + else if ((pControl == pRequired) || (pControl == pNumType) || (pControl == pAutoIncrement) || (pControl == pBoolDefault) || (pControl == m_pType)) + { + ((OPropListBoxCtrl*)pControl)->SaveValue(); + strHelpText = ((OPropListBoxCtrl*)pControl)->GetHelp(); + } + else if (pControl == pFormat) + strHelpText = String(ModuleRes(STR_HELP_FORMAT_BUTTON)); + + if (strHelpText.Len() && (pHelp != NULL)) + pHelp->SetHelpText(strHelpText); + + return 0L; +} + +//------------------------------------------------------------------------------ +IMPL_LINK(OFieldDescControl, OnControlFocusLost, Control*, pControl ) +{ + if ((pControl == pLength) || (pControl == pTextLen) || (pControl == pScale)) + { + OPropNumericEditCtrl* pConverted = (OPropNumericEditCtrl*)pControl; + if (pConverted->IsModified()) + CellModified(-1, pConverted->GetPos()); + } + if ((pControl == pDefault) || (pControl == pFormatSample) || (pControl == m_pColumnName)) + { + OPropEditCtrl* pConverted = (OPropEditCtrl*)pControl; + if (pConverted->IsModified()) + CellModified(-1, pConverted->GetPos()); + } + else if ((pControl == pRequired) || (pControl == pNumType) || (pControl == pAutoIncrement) || (pControl == pBoolDefault) || (pControl == m_pType)) + { + OPropListBoxCtrl* pConverted = (OPropListBoxCtrl*)pControl; + if (pConverted->IsModified()) + CellModified(-1, pConverted->GetPos()); + } + + if (pControl == pDefault) + UpdateFormatSample(pActFieldDescr); + + implFocusLost(pControl); + + return 0L; +} +//------------------------------------------------------------------------------ +void OFieldDescControl::ActivatePropertyField(sal_uInt16 nVirtualField) +{ + Control** ppToActivate = NULL; + switch (nVirtualField) + { + case FIELD_PROPERTY_REQUIRED : ppToActivate = (Control**)&pRequired; break; + case FIELD_PROPERTY_NUMTYPE : ppToActivate = (Control**)&pNumType; break; + case FIELD_PROPERTY_AUTOINC : ppToActivate = (Control**)&pAutoIncrement; break; + case FIELD_PROPERTY_DEFAULT : ppToActivate = (Control**)&pDefault; if (!*ppToActivate) ppToActivate = (Control**)&pBoolDefault; break; + // da es immer nur eines der beiden Controls gibt, ist das hier eindeutig + case FIELD_PROPERTY_TEXTLEN : ppToActivate = (Control**)&pTextLen; break; + case FIELD_PROPERTY_LENGTH : ppToActivate = (Control**)&pLength; break; + case FIELD_PROPERTY_SCALE : ppToActivate = (Control**)&pScale; break; + case FIELD_PROPERTY_FORMAT : ppToActivate = (Control**)&pFormatSample; break; + case FIELD_PRPOERTY_COLUMNNAME : ppToActivate = (Control**)&m_pColumnName; break; + case FIELD_PRPOERTY_TYPE : ppToActivate = (Control**)&m_pType; break; + + default: + DBG_ERROR("OFieldDescControl::ActivatePropertyField : ungueltiger Parameter !"); + } + + if (*ppToActivate) + nDelayedGrabFocusEvent = Application::PostUserEvent(LINK(this, OFieldDescControl, DelayedGrabFocus), ppToActivate); +} +//------------------------------------------------------------------------------ +void OFieldDescControl::SaveData( OFieldDescription* pFieldDescr ) +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + if( !pFieldDescr ) + return; + + ////////////////////////////////////////////////////////////////////// + // Controls auslesen + String sDefault; + if (pDefault) + sDefault = pDefault->GetText(); + else if (pBoolDefault) + sDefault = BoolStringPersistent(pBoolDefault->GetSelectEntry()); + + pFieldDescr->SetDefaultValue(sDefault); + if((pRequired && pRequired->GetSelectEntryPos() == 0) || pFieldDescr->IsPrimaryKey() || (pBoolDefault && pBoolDefault->GetEntryCount() == 2)) // yes + pFieldDescr->SetIsNullable( ColumnValue::NO_NULLS ); + else + pFieldDescr->SetIsNullable( ColumnValue::NULLABLE ); + + if(pAutoIncrement && pAutoIncrement->GetSelectEntryPos() == 0 ) + pFieldDescr->SetAutoIncrement( sal_True ); + else + pFieldDescr->SetAutoIncrement( sal_False ); + + if( pTextLen ) + pFieldDescr->SetPrecision( pTextLen->GetValue() ); + else if( pLength ) + pFieldDescr->SetPrecision( pLength->GetValue() ); + if( pScale ) + pFieldDescr->SetScale( pScale->GetValue() ); + + if(m_pColumnName) + pFieldDescr->SetName(m_pColumnName->GetText()); +} + +//------------------------------------------------------------------------------ +void OFieldDescControl::UpdateFormatSample(OFieldDescription* pFieldDescr) +{ + if(!pFieldDescr) + return; + if(!pFormatSample) + return; + sal_uInt32 nFormatKey = pFieldDescr->GetFormatKey(); + + try + { + Reference< XNumberFormatTypes> xNumberTypes(GetFormatter()->getNumberFormatsSupplier()->getNumberFormats(),UNO_QUERY); + OSL_ENSURE(xNumberTypes.is(),"XNumberFormatTypes is null!"); + + + if (!nFormatKey) + { + nFormatKey = ::dbtools::getDefaultNumberFormat( pFieldDescr->GetType(), + pFieldDescr->GetScale(), + pFieldDescr->IsCurrency(), + xNumberTypes, + GetLocale()); + } + + String sDefault = pFieldDescr->GetDefaultValue(); + sal_Int32 nNumberFormat = xNumberTypes->getFormatIndex(nFormatKey,GetLocale()); + if(nNumberFormat == NumberFormat::TEXT) + pFormatSample->SetText(sDefault); + else if(sDefault.Len()) + { + Reference<XNumberFormatPreviewer> xPreViewer(GetFormatter(),UNO_QUERY); + OSL_ENSURE(xPreViewer.is(),"XNumberFormatPreviewer is null!"); + + double nValue = GetFormatter()->convertStringToNumber(nFormatKey,sDefault); + Reference<XPropertySet> xFormSet = GetFormatter()->getNumberFormatsSupplier()->getNumberFormats()->getByKey(nFormatKey); + OSL_ENSURE(xFormSet.is(),"XPropertySet is null!"); + + ::rtl::OUString sFormat; + xFormSet->getPropertyValue(::rtl::OUString::createFromAscii("FormatString")) >>= sFormat; + + sDefault = xPreViewer->convertNumberToPreviewString(sFormat,nValue,GetLocale(),sal_True); + } + pFormatSample->SetText(sDefault); + } + catch(Exception&) + { + OSL_ENSURE(0,"Format Exception!"); + } +} + +//------------------------------------------------------------------------------ +sal_Bool OFieldDescControl::ChildHasFocus() +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + ////////////////////////////////////////////////////////////////////// + // Hat eines der Childs den Focus? + Window* pChild; + for( sal_uInt16 nChildId=0; nChildId<GetChildCount(); nChildId++ ) + { + pChild = GetChild( nChildId ); + if( pChild->HasFocus() ) + return sal_True; + } + + return sal_False; +} + +//------------------------------------------------------------------------------ +void OFieldDescControl::GetFocus() +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + ////////////////////////////////////////////////////////////////////// + // Setzt den Focus auf das zuletzt aktive Control + TabPage::GetFocus(); + if( pLastFocusWindow ) + { + pLastFocusWindow->GrabFocus(); + pLastFocusWindow = NULL; + } +} + +//------------------------------------------------------------------------------ +void OFieldDescControl::implFocusLost(Window* _pWhich) +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + DBG_ASSERT(!_pWhich || IsChild(_pWhich), "OFieldDescControl::implFocusLost : invalid window !"); + + ////////////////////////////////////////////////////////////////////// + // Das aktive Control merken + if (!pLastFocusWindow) + pLastFocusWindow = _pWhich; + + ////////////////////////////////////////////////////////////////////// + // HelpText zuruecksetzen + if (pHelp && !pHelp->HasChildPathFocus()) + pHelp->SetHelpText( String() ); +} + +//------------------------------------------------------------------------------ +void OFieldDescControl::LoseFocus() +{ + DBG_CHKTHIS(OFieldDescControl,NULL); + + implFocusLost(NULL); + + TabPage::LoseFocus(); +} +// ----------------------------------------------------------------------------- + + + + + + diff --git a/dbaccess/source/ui/control/makefile.mk b/dbaccess/source/ui/control/makefile.mk index 53df5ab0715d..05c7195e7c51 100644 --- a/dbaccess/source/ui/control/makefile.mk +++ b/dbaccess/source/ui/control/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.3 $ +# $Revision: 1.4 $ # -# last change: $Author: fs $ $Date: 2001-01-30 08:30:21 $ +# last change: $Author: oj $ $Date: 2001-02-14 14:34:43 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -83,11 +83,12 @@ SRCFILES = \ # ... object files ............................ SLOFILES= \ - $(SLO)$/listviewitems.obj \ - $(SLO)$/undosqledit.obj \ - $(SLO)$/sqledit.obj \ - $(SLO)$/tabletree.obj \ - $(SLO)$/marktree.obj \ + $(SLO)$/FieldDescControl.obj \ + $(SLO)$/listviewitems.obj \ + $(SLO)$/undosqledit.obj \ + $(SLO)$/sqledit.obj \ + $(SLO)$/tabletree.obj \ + $(SLO)$/marktree.obj \ $(SLO)$/curledit.obj # --- Targets ---------------------------------- diff --git a/dbaccess/source/ui/dlg/dlgsave.cxx b/dbaccess/source/ui/dlg/dlgsave.cxx index 709c40bede19..8919853c3df8 100644 --- a/dbaccess/source/ui/dlg/dlgsave.cxx +++ b/dbaccess/source/ui/dlg/dlgsave.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dlgsave.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: fs $ $Date: 2001-02-05 09:47:47 $ + * last change: $Author: oj $ $Date: 2001-02-14 14:34:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -80,62 +80,154 @@ #ifndef _DBAUI_SQLMESSAGE_HXX_ #include "sqlmessage.hxx" #endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif using namespace dbaui; +using namespace dbtools; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::container; using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbc; //================================================================== OSaveAsDlg::OSaveAsDlg( Window * pParent, const sal_Int32& _rType, const Reference<XNameAccess>& _rxNames, + const Reference< XDatabaseMetaData>& _rxMetaData, const String& rDefault) :ModalDialog( pParent, ModuleRes(DLG_SAVE_AS)) + ,m_aCatalogLbl(this, ResId (FT_CATALOG)) + ,m_aCatalog(this, ResId (ET_CATALOG)) + ,m_aSchemaLbl(this, ResId (FT_SCHEMA)) + ,m_aSchema(this, ResId (ET_SCHEMA)) ,m_aLabel(this, ResId (FT_TITLE)) ,m_aTitle(this, ResId (ET_TITLE)) ,m_aPB_OK(this, ResId( PB_OK ) ) ,m_aPB_CANCEL(this, ResId( PB_CANCEL )) ,m_aPB_HELP(this, ResId( PB_HELP)) ,m_aQryLabel(ResId(STR_QRY_LABEL)) + ,m_sTblLabel(ResId(STR_TBL_LABEL)) ,m_aExists(ResId(STR_OBJECT_EXISTS_ALREADY)) ,m_aName(rDefault) ,m_xNames(_rxNames) + ,m_xMetaData(_rxMetaData) + ,m_nType(_rType) { switch (_rType) { case CommandType::QUERY: - m_aLabel.SetText(m_aQryLabel); + { + m_aLabel.SetText(m_aQryLabel); + m_aCatalogLbl.Hide(); + m_aCatalog.Hide(); + m_aSchemaLbl.Hide(); + m_aSchema.Hide(); + + Point aPos(m_aSchemaLbl.GetPosPixel()); + m_aLabel.SetPosPixel(m_aCatalogLbl.GetPosPixel()); + m_aTitle.SetPosPixel(m_aCatalog.GetPosPixel()); + + m_aPB_OK.SetPosPixel(Point(m_aPB_OK.GetPosPixel().X(),aPos.Y())); + m_aPB_CANCEL.SetPosPixel(Point(m_aPB_CANCEL.GetPosPixel().X(),aPos.Y())); + m_aPB_HELP.SetPosPixel(Point(m_aPB_HELP.GetPosPixel().X(),aPos.Y())); + + SetSizePixel(Size(GetSizePixel().Width(),aPos.Y()+m_aPB_OK.GetSizePixel().Height()+m_aTitle.GetSizePixel().Height()*0.5)); + m_aTitle.SetText(m_aName); + } + break; + case CommandType::TABLE: + { + if(m_aName.Search('.') != STRING_NOTFOUND) + { + ::rtl::OUString sCatalog,sSchema,sTable; + ::dbtools::qualifiedNameComponents(_rxMetaData, + m_aName, + sCatalog, + sSchema, + sTable); + + m_aCatalog.SetText(sCatalog); + m_aSchema.SetText(sSchema); + m_aTitle.SetText(sTable); + } + else + m_aTitle.SetText(m_aName); + + + m_aLabel.SetText(m_sTblLabel); + Point aPos(m_aPB_OK.GetPosPixel()); + if(!_rxMetaData->supportsCatalogsInTableDefinitions()) + { + m_aCatalogLbl.Hide(); + m_aCatalog.Hide(); + + aPos = m_aLabel.GetPosPixel(); + + m_aLabel.SetPosPixel(m_aSchemaLbl.GetPosPixel()); + m_aTitle.SetPosPixel(m_aSchema.GetPosPixel()); + + m_aSchemaLbl.SetPosPixel(m_aCatalogLbl.GetPosPixel()); + m_aSchema.SetPosPixel(m_aCatalog.GetPosPixel()); + } + + if(!_rxMetaData->supportsSchemasInTableDefinitions()) + { + m_aSchemaLbl.Hide(); + m_aSchema.Hide(); + + aPos = m_aLabel.GetPosPixel(); + + m_aLabel.SetPosPixel(m_aSchemaLbl.GetPosPixel()); + m_aTitle.SetPosPixel(m_aSchema.GetPosPixel()); + } + m_aPB_OK.SetPosPixel(Point(m_aPB_OK.GetPosPixel().X(),aPos.Y())); + m_aPB_CANCEL.SetPosPixel(Point(m_aPB_CANCEL.GetPosPixel().X(),aPos.Y())); + m_aPB_HELP.SetPosPixel(Point(m_aPB_HELP.GetPosPixel().X(),aPos.Y())); + + SetSizePixel(Size(GetSizePixel().Width(),aPos.Y()+m_aPB_OK.GetSizePixel().Height()+m_aTitle.GetSizePixel().Height()*0.5)); + } break; default: OSL_ENSURE(0,"Type not supported yet!"); } - m_aTitle.SetText(m_aName); + m_aPB_OK.SetClickHdl(LINK(this,OSaveAsDlg,ButtonClickHdl)); m_aTitle.SetModifyHdl(LINK(this,OSaveAsDlg,EditModifyHdl)); + m_aTitle.GrabFocus(); FreeResource(); } +// ----------------------------------------------------------------------------- IMPL_LINK(OSaveAsDlg, ButtonClickHdl, Button *, pButton) { if (pButton == &m_aPB_OK) { m_aName = m_aTitle.GetText(); - - if(m_xNames->hasByName(m_aName)) + sal_Bool bError = m_xNames->hasByName(m_aName); + if(m_nType == CommandType::TABLE) + { + ::rtl::OUString sComposedName; + ::dbtools::composeTableName(m_xMetaData,getCatalog(),getSchema(),m_aName,sComposedName,sal_False); + bError = m_xNames->hasByName(sComposedName); + } + if(bError) { m_aTitle.GrabFocus(); String aText(m_aExists); aText.SearchAndReplace(String::CreateFromAscii("'$Name: not supported by cvs2svn $'"),m_aName); OSQLMessageBox aDlg(this, String(ModuleRes(STR_OBJECT_ALREADY_EXSISTS)), aText, WB_OK, OSQLMessageBox::Query); + aDlg.Execute(); } else EndDialog(RET_OK); } return 0; } +// ----------------------------------------------------------------------------- IMPL_LINK(OSaveAsDlg, EditModifyHdl, Edit *, pEdit ) { @@ -143,4 +235,6 @@ IMPL_LINK(OSaveAsDlg, EditModifyHdl, Edit *, pEdit ) m_aPB_OK.Enable(m_aTitle.GetText().Len()); return 0; } +// ----------------------------------------------------------------------------- + diff --git a/dbaccess/source/ui/dlg/dlgsave.hrc b/dbaccess/source/ui/dlg/dlgsave.hrc index 451dc06cd915..4238504b3aef 100644 --- a/dbaccess/source/ui/dlg/dlgsave.hrc +++ b/dbaccess/source/ui/dlg/dlgsave.hrc @@ -2,9 +2,9 @@ * * $RCSfile: dlgsave.hrc,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: oj $ $Date: 2001-01-09 16:05:30 $ + * last change: $Author: oj $ $Date: 2001-02-14 14:34:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,8 +67,14 @@ #define PB_OK 1 #define PB_CANCEL 1 #define PB_HELP 1 -#define ET_TITLE 1 -#define FT_TITLE 1 + +#define ET_CATALOG 1 +#define ET_SCHEMA 2 +#define ET_TITLE 3 +#define FT_CATALOG 1 +#define FT_SCHEMA 2 +#define FT_TITLE 3 + #define STR_TBL_LABEL 1 #define STR_VW_LABEL 2 #define STR_QRY_LABEL 3 diff --git a/dbaccess/source/ui/dlg/dlgsave.src b/dbaccess/source/ui/dlg/dlgsave.src index 88431eb64a64..ff8fa8fe00c5 100644 --- a/dbaccess/source/ui/dlg/dlgsave.src +++ b/dbaccess/source/ui/dlg/dlgsave.src @@ -2,9 +2,9 @@ * * $RCSfile: dlgsave.src,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: oj $ $Date: 2001-01-09 16:05:38 $ + * last change: $Author: oj $ $Date: 2001-02-14 14:34:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,42 +74,73 @@ ModalDialog DLG_SAVE_AS OutputSize = TRUE ; SVLook = TRUE ; HelpId = HID_DLG_SAVE_AS ; - Size = MAP_APPFONT ( 174 , 45 ) ; + Size = MAP_APPFONT ( 174 , 56 ) ; Moveable = TRUE ; Closeable = TRUE ; Text = "Speichern unter" ; Text [ ENGLISH ] = "Save as" ; Text [ english_us ] = "Save As" ; - FixedText FT_TITLE + + FixedText FT_CATALOG { Pos = MAP_APPFONT ( 6 , 7 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; + Text = "~Catalog" ; + Text[ENGLISH] = "~Catalog" ; + }; + Edit ET_CATALOG + { + Border = TRUE ; + Pos = MAP_APPFONT ( 77 , 6 ) ; + Size = MAP_APPFONT ( 89 , 12 ) ; + Text = "" ; + TabStop = TRUE ; + }; + FixedText FT_SCHEMA + { + Pos = MAP_APPFONT ( 6 , 24 ) ; + Size = MAP_APPFONT ( 70 , 10 ) ; + Text = "~Schema" ; + Text[ENGLISH] = "~Schema" ; + }; + Edit ET_SCHEMA + { + Border = TRUE ; + Pos = MAP_APPFONT ( 77 , 23 ) ; + Size = MAP_APPFONT ( 89 , 12 ) ; + Text = "" ; + TabStop = TRUE ; + }; + FixedText FT_TITLE + { + Pos = MAP_APPFONT ( 6 , 41 ) ; + Size = MAP_APPFONT ( 70 , 10 ) ; Text = "" ; }; Edit ET_TITLE { Border = TRUE ; - Pos = MAP_APPFONT ( 77 , 6 ) ; + Pos = MAP_APPFONT ( 77 , 40 ) ; Size = MAP_APPFONT ( 89 , 12 ) ; Text = "" ; TabStop = TRUE ; }; OKButton PB_OK { - Pos = MAP_APPFONT ( 6 , 25 ) ; + Pos = MAP_APPFONT ( 6 , 58 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; DefButton = TRUE ; }; CancelButton PB_CANCEL { - Pos = MAP_APPFONT ( 62 , 25 ) ; + Pos = MAP_APPFONT ( 62 , 58 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; }; HelpButton PB_HELP { - Pos = MAP_APPFONT ( 118 , 25 ) ; + Pos = MAP_APPFONT ( 118 , 58 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; }; diff --git a/dbaccess/source/ui/dlg/paramdialog.cxx b/dbaccess/source/ui/dlg/paramdialog.cxx index 79a06c7c7b6f..cdabb5927ae2 100644 --- a/dbaccess/source/ui/dlg/paramdialog.cxx +++ b/dbaccess/source/ui/dlg/paramdialog.cxx @@ -2,9 +2,9 @@ * * $RCSfile: paramdialog.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: fs $ $Date: 2000-10-27 08:07:57 $ + * last change: $Author: oj $ $Date: 2001-02-14 14:34:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -542,6 +542,9 @@ namespace dbaui /************************************************************************* * history: * $Log: not supported by cvs2svn $ + * Revision 1.2 2000/10/27 08:07:57 fs + * OSQLParser interface was changed - adjustments + * * Revision 1.1 2000/10/26 18:06:51 fs * initial checkin - parameter dialog * diff --git a/dbaccess/source/ui/dlg/queryfilter.cxx b/dbaccess/source/ui/dlg/queryfilter.cxx index 4b5bc855025b..f67431658469 100644 --- a/dbaccess/source/ui/dlg/queryfilter.cxx +++ b/dbaccess/source/ui/dlg/queryfilter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: queryfilter.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-01-25 08:26:08 $ + * last change: $Author: oj $ $Date: 2001-02-14 14:34:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -101,6 +101,10 @@ #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" #endif +#ifndef _CPPUHELPER_EXTRACT_HXX_ +#include <cppuhelper/extract.hxx> +#endif + using namespace dbaui; using namespace connectivity; @@ -178,7 +182,7 @@ DlgFilterCrit::DlgFilterCrit(Window * pParent, { if (m_xColumns->hasByName(*pBegin)) { - m_xColumns->getByName(*pBegin) >>= xColumn; + ::cppu::extractInterface(xColumn,m_xColumns->getByName(*pBegin)); OSL_ENSHURE(xColumn.is(),"DlgFilterCrit::DlgFilterCrit: Column is null!"); } else @@ -201,7 +205,7 @@ DlgFilterCrit::DlgFilterCrit(Window * pParent, aLB_WHEREFIELD3.SelectEntryPos(0); // Jetzt die Felder mit den Kriterien des SQL-Strings fuellen - m_xColumns->getByName(rFieldName) >>= xColumn; + ::cppu::extractInterface(xColumn,m_xColumns->getByName(rFieldName)); m_xQueryComposer->appendFilterByColumn(xColumn); // insert the criteria into the dialog @@ -209,7 +213,7 @@ DlgFilterCrit::DlgFilterCrit(Window * pParent, const Sequence<PropertyValue >* pOrBegin = aValues.getConstArray(); const Sequence<PropertyValue >* pOrEnd = pOrBegin + aValues.getLength(); sal_Bool bOr = sal_True; - for(sal_uInt32 i=0;pOrBegin != pOrEnd; ++pOrBegin) + for(sal_uInt16 i=0;pOrBegin != pOrEnd; ++pOrBegin) { bOr = sal_True; const PropertyValue* pAndBegin = pOrBegin->getConstArray(); @@ -707,7 +711,7 @@ IMPL_LINK( DlgFilterCrit, ListSelectHdl, ListBox *, pListBox ) Reference<XPropertySet> xColumn; if (m_xColumns->hasByName(aName)) - m_xColumns->getByName(aName) >>= xColumn; + ::cppu::extractInterface(xColumn,m_xColumns->getByName(aName)); if(xColumn.is()) { sal_Int32 nDataType; diff --git a/dbaccess/source/ui/dlg/queryorder.cxx b/dbaccess/source/ui/dlg/queryorder.cxx index 4273eb864489..4aabc8f65fc0 100644 --- a/dbaccess/source/ui/dlg/queryorder.cxx +++ b/dbaccess/source/ui/dlg/queryorder.cxx @@ -2,9 +2,9 @@ * * $RCSfile: queryorder.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-01-25 07:16:20 $ + * last change: $Author: oj $ $Date: 2001-02-14 14:34:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,6 +93,10 @@ #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" #endif +#ifndef _CPPUHELPER_EXTRACT_HXX_ +#include <cppuhelper/extract.hxx> +#endif + using namespace dbaui; using namespace connectivity; @@ -159,8 +163,8 @@ DlgOrderCrit::DlgOrderCrit( Window * pParent, Reference<XPropertySet> xColumn; for(;pBegin != pEnd;++pBegin) { - m_xColumns->getByName(*pBegin) >>= xColumn; - OSL_ENSHURE(xColumn.is(),"Column is null!"); + ::cppu::extractInterface(xColumn,m_xColumns->getByName(*pBegin)); + OSL_ENSURE(xColumn.is(),"Column is null!"); sal_Int32 nDataType; xColumn->getPropertyValue(PROPERTY_TYPE) >>= nDataType; sal_Int32 eColumnSearch = dbtools::getSearchColumnFlag(m_xConnection,nDataType); diff --git a/dbaccess/source/ui/inc/FieldControls.hxx b/dbaccess/source/ui/inc/FieldControls.hxx new file mode 100644 index 000000000000..70ceb79ee972 --- /dev/null +++ b/dbaccess/source/ui/inc/FieldControls.hxx @@ -0,0 +1,185 @@ +/************************************************************************* + * + * $RCSfile: FieldControls.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-02-14 14:36:47 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef DBAUI_FIELDCONTROLS_HXX +#define DBAUI_FIELDCONTROLS_HXX + +#ifndef _SV_EDIT_HXX +#include <vcl/edit.hxx> +#endif +#ifndef _SV_FIELD_HXX +#include <vcl/field.hxx> +#endif +#ifndef _SV_LSTBOX_HXX +#include <vcl/lstbox.hxx> +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif + +namespace dbaui +{ + class OSpecialReadOnly + { + protected: + void SetSpecialReadOnly(BOOL _bReadOnly,Window *pWin) + { + StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings(); + const Color& rNewColor = _bReadOnly ? aSystemStyle.GetDialogColor() : aSystemStyle.GetFieldColor(); + pWin->SetBackground(Wallpaper(rNewColor)); + pWin->SetControlBackground(rNewColor); + } + public: + virtual void SetSpecialReadOnly(BOOL _bReadOnly) = 0; + }; + //================================================================== + class OPropEditCtrl : public Edit + ,public OSpecialReadOnly + { + short m_nPos; + String m_strHelpText; + + public: + inline OPropEditCtrl(Window* pParent, INT32 nHelpId, short nPosition = -1, WinBits nWinStyle = 0); + + inline BOOL IsModified() { return GetText() != GetSavedValue(); } + + short GetPos() const { return m_nPos; } + String GetHelp() const { return m_strHelpText; } + + virtual void SetSpecialReadOnly(BOOL _bReadOnly) + { + SetReadOnly(_bReadOnly); + OSpecialReadOnly::SetSpecialReadOnly(_bReadOnly,this); + } + }; + + inline OPropEditCtrl::OPropEditCtrl(Window* pParent, INT32 nHelpId, short nPosition, WinBits nWinStyle) + :Edit(pParent, nWinStyle) + ,m_nPos(nPosition) + { + m_strHelpText = String(ModuleRes(nHelpId)); + } + + //================================================================== + class OPropNumericEditCtrl : public NumericField + ,public OSpecialReadOnly + { + short m_nPos; + String m_strHelpText; + + public: + inline OPropNumericEditCtrl(Window* pParent, INT32 nHelpId, short nPosition = -1, WinBits nWinStyle = 0); + + inline BOOL IsModified() { return GetText() != GetSavedValue(); } + + short GetPos() const { return m_nPos; } + String GetHelp() const { return m_strHelpText; } + + virtual void SetSpecialReadOnly(BOOL _bReadOnly) + { + SetReadOnly(_bReadOnly); + OSpecialReadOnly::SetSpecialReadOnly(_bReadOnly,this); + } + }; + + inline OPropNumericEditCtrl::OPropNumericEditCtrl(Window* pParent, INT32 nHelpId, short nPosition, WinBits nWinStyle) + :NumericField(pParent, nWinStyle) + ,m_nPos(nPosition) + { + m_strHelpText = String(ModuleRes(nHelpId)); + } + + //================================================================== + class OPropListBoxCtrl : public ListBox + ,public OSpecialReadOnly + { + short m_nPos; + String m_strHelpText; + + public: + inline OPropListBoxCtrl(Window* pParent, INT32 nHelpId, short nPosition = -1, WinBits nWinStyle = 0); + + inline BOOL IsModified() { return GetSelectEntryPos() != GetSavedValue(); } + + short GetPos() const { return m_nPos; } + String GetHelp() const { return m_strHelpText; } + + virtual void SetSpecialReadOnly(BOOL _bReadOnly) + { + SetReadOnly(_bReadOnly); + OSpecialReadOnly::SetSpecialReadOnly(_bReadOnly,this); + } + }; + + inline OPropListBoxCtrl::OPropListBoxCtrl(Window* pParent, INT32 nHelpId, short nPosition, WinBits nWinStyle) + :ListBox(pParent, nWinStyle) + ,m_nPos(nPosition) + { + m_strHelpText = String(ModuleRes(nHelpId)); + } +} +#endif // DBAUI_FIELDCONTROLS_HXX + + + diff --git a/dbaccess/source/ui/inc/FieldDescControl.hxx b/dbaccess/source/ui/inc/FieldDescControl.hxx new file mode 100644 index 000000000000..b98314a44ea7 --- /dev/null +++ b/dbaccess/source/ui/inc/FieldDescControl.hxx @@ -0,0 +1,242 @@ +/************************************************************************* + * + * $RCSfile: FieldDescControl.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-02-14 14:37:14 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX +#define DBAUI_FIELDDESCRIPTIONCONTROL_HXX + +#ifndef _SV_TABPAGE_HXX +#include <vcl/tabpage.hxx> +#endif +#ifndef DBAUI_ENUMTYPES_HXX +#include "QEnumTypes.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_ +#include <com/sun/star/util/XNumberFormatter.hpp> +#endif +#ifndef DBAUI_TYPEINFO_HXX +#include "TypeInfo.hxx" +#endif + +//------------------------------------------------------------------ +// die Spalten einer Feld-Beschreibung einer Tabelle +#define FIELD_NAME 1 +#define FIELD_TYPE 2 +#define FIELD_DESCR 3 + +#define FIELD_FIRST_VIRTUAL_COLUMN 4 + +#define FIELD_PROPERTY_REQUIRED 4 +#define FIELD_PROPERTY_NUMTYPE 5 +#define FIELD_PROPERTY_AUTOINC 6 +#define FIELD_PROPERTY_DEFAULT 7 +#define FIELD_PROPERTY_TEXTLEN 8 +#define FIELD_PROPERTY_LENGTH 9 +#define FIELD_PROPERTY_SCALE 10 +#define FIELD_PROPERTY_BOOL_DEFAULT 11 +#define FIELD_PROPERTY_FORMAT 12 +#define FIELD_PRPOERTY_COLUMNNAME 13 +#define FIELD_PRPOERTY_TYPE 14 + +class FixedText; +class PushButton; +class SvxNumberFormatShell; +class ScrollBar; +class Button; +class ListBox; +class Control; +class SvNumberFormatter; + +namespace dbaui +{ + + class OTableDesignHelpBar; + class OPropListBoxCtrl; + class OPropEditCtrl; + class OPropNumericEditCtrl; + class OFieldDescription; + class OTypeInfo; + //================================================================== + class OFieldDescControl : public TabPage + { + private: + OTableDesignHelpBar* pHelp; + Window* pLastFocusWindow; + + FixedText* pDefaultText; + FixedText* pRequiredText; + FixedText* pAutoIncrementText; + FixedText* pTextLenText; + FixedText* pNumTypeText; + FixedText* pLengthText; + FixedText* pScaleText; + FixedText* pFormatText; + FixedText* pBoolDefaultText; + FixedText* m_pColumnNameText; + FixedText* m_pTypeText; + + OPropListBoxCtrl* pRequired; + OPropListBoxCtrl* pNumType; + OPropListBoxCtrl* pAutoIncrement; + OPropEditCtrl* pDefault; + OPropNumericEditCtrl* pTextLen; + OPropNumericEditCtrl* pLength; + OPropNumericEditCtrl* pScale; + OPropEditCtrl* pFormatSample; + OPropListBoxCtrl* pBoolDefault; + OPropEditCtrl* m_pColumnName; + OPropListBoxCtrl* m_pType; + + PushButton* pFormat; + + ScrollBar* m_pVertScroll; + ScrollBar* m_pHorzScroll; + + const OTypeInfo* m_pPreviousType; + USHORT nCurChildId; + short nPos; + short nOldDefaultPos; + XubString aYes; + XubString aNo; + + long m_nOldVThumb; + long m_nOldHThumb; + + ULONG nDelayedGrabFocusEvent; + + DECL_LINK( OnScroll, ScrollBar*); + + DECL_LINK( FormatClickHdl, Button * ); + DECL_LINK( ChangeHdl, ListBox * ); + + DECL_LINK( DelayedGrabFocus, Control** ); + // von ActivatePropertyField benutzt + DECL_LINK( OnControlFocusLost, Control* ); + DECL_LINK( OnControlFocusGot, Control* ); + + void UpdateFormatSample(OFieldDescription* pFieldDescr); + void ArrangeAggregates(); + + void SetPosSize( Control** ppControl, long nRow, USHORT nCol ); + + void ScrollAggregate(Control* pText, Control* pInput, Control* pButton, long nDeltaX, long nDeltaY); + void ScrollAllAggregates(); + + protected: + OFieldDescription* pActFieldDescr; // falls geloescht werden soll + + USHORT CountActiveAggregates() const; + + virtual void ActivateAggregate( EControlType eType ); + virtual void DeactivateAggregate( EControlType eType ); + virtual BOOL IsReadOnly() { return FALSE; }; + + // Sind von den abgeleiteten Klassen zu impl. + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > GetFormatter() = 0; + + virtual ::com::sun::star::lang::Locale GetLocale() const = 0; + + virtual void CellModified(long nRow, USHORT nColId ) = 0; + virtual void SetModified(BOOL bModified) = 0; + + virtual const OTypeInfo* getTypeInfo(sal_Int32 _nPos) = 0; + virtual const OTypeInfoMap* getTypeInfo() const = 0; + + String BoolStringPersistent(const String& rUIString) const; + String BoolStringUI(const String& rPersistentString) const; + + public: + OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHelpBar); + OFieldDescControl( Window* pParent, const ResId& rResId, OTableDesignHelpBar* pHelpBar); + virtual ~OFieldDescControl(); + + void DisplayData(OFieldDescription* pFieldDescr ); + // void DisplayData(const OColumn* pColumn); + + void SaveData( OFieldDescription* pFieldDescr ); + // void SaveData( OColumn* pColumn); + + BOOL ChildHasFocus(); + + void SetControlText( USHORT nControlId, const String& rText ); + String GetControlText( USHORT nControlId ); + void SetReadOnly( BOOL bReadOnly ); + + void ActivatePropertyField(USHORT nVirtualField); + // Parameter ist einer der FIELD_PROPERTY_xxx-Werte, das entsprechende Control wird aktiviert, wenn vorhanden + + // Resize aufegrufen + void CheckScrollBars(); + + virtual void Init(); + virtual void GetFocus(); + virtual void LoseFocus(); + virtual void Resize(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() = 0; + protected: + void implFocusLost(Window* _pWhich); + }; +} +#endif // DBAUI_FIELDDESCRIPTIONCONTROL_HXX + + diff --git a/dbaccess/source/ui/inc/FieldDescriptions.hxx b/dbaccess/source/ui/inc/FieldDescriptions.hxx new file mode 100644 index 000000000000..25e7d5b37f4f --- /dev/null +++ b/dbaccess/source/ui/inc/FieldDescriptions.hxx @@ -0,0 +1,160 @@ +/************************************************************************* + * + * $RCSfile: FieldDescriptions.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-02-14 14:37:35 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef DBAUI_FIELDDESCRIPTIONS_HXX +#define DBAUI_FIELDDESCRIPTIONS_HXX + +#ifndef DBAUI_ENUMTYPES_HXX +#include "QEnumTypes.hxx" +#endif +#ifndef _SVX_SVXENUM_HXX +#include <svx/svxenum.hxx> +#endif +#ifndef DBAUI_TYPEINFO_HXX +#include "TypeInfo.hxx" +#endif + +namespace dbaui +{ + class OFieldDescription + { + private: + const OTypeInfo* m_pType; + + ::rtl::OUString m_sName; + ::rtl::OUString m_sTypeName; + ::rtl::OUString m_sDescription; + ::rtl::OUString m_sDefaultValue; + sal_Int32 m_nPrecision; + sal_Int32 m_nScale; + sal_Int32 m_nIsNullable; + sal_Int32 m_nFormatKey; + SvxCellHorJustify m_eHorJustify; + sal_Bool m_bIsAutoIncrement; + sal_Bool m_bIsPrimaryKey; + sal_Bool m_bIsCurrency; + + public: + OFieldDescription(); + OFieldDescription( const ::rtl::OUString& _sName, + const ::rtl::OUString& _sTypeName, + const ::rtl::OUString& _sDescription, + const ::rtl::OUString& _sDefaultValue, + const OTypeInfo* _pType, + sal_Int32 _nPrecision, + sal_Int32 _nScale, + sal_Int32 _nIsNullable, + sal_Int32 _nFormatKey, + SvxCellHorJustify _eHorJustify, + sal_Bool _bIsAutoIncrement, + sal_Bool _bIsPrimaryKey, + sal_Bool _bIsCurrency) : + m_sName(_sName) + ,m_sTypeName(_sTypeName) + ,m_sDescription(_sDescription) + ,m_sDefaultValue(_sDefaultValue) + ,m_pType(_pType) + ,m_nPrecision(_nPrecision) + ,m_nScale(_nScale) + ,m_nIsNullable(_nIsNullable) + ,m_nFormatKey(_nFormatKey) + ,m_eHorJustify(_eHorJustify) + ,m_bIsAutoIncrement(_bIsAutoIncrement) + ,m_bIsPrimaryKey(_bIsPrimaryKey) + ,m_bIsCurrency(_bIsCurrency) + { + } + OFieldDescription( const OFieldDescription& rDescr ); + virtual ~OFieldDescription(); + + void SetName(const ::rtl::OUString& _rName) { m_sName = _rName; } + // void SetTypeName(const ::rtl::OUString& _rTypeName) { m_sTypeName = _rTypeName; } + void SetDescription(const ::rtl::OUString& _rDescription) { m_sDescription = _rDescription; } + void SetDefaultValue(const ::rtl::OUString& _rDefaultValue) { m_sDefaultValue = _rDefaultValue; } + void SetType(const OTypeInfo* _pType) { m_pType = _pType; } + void SetPrecision(const sal_Int32& _rPrecision) { m_nPrecision = _rPrecision; } + void SetScale(const sal_Int32& _rScale) { m_nScale = _rScale; } + void SetIsNullable(const sal_Int32& _rIsNullable) { m_nIsNullable = _rIsNullable; } + void SetFormatKey(const sal_Int32& _rFormatKey) { m_nFormatKey = _rFormatKey; } + void SetHorJustify(const SvxCellHorJustify& _rHorJustify) { m_eHorJustify = _rHorJustify; } + void SetAutoIncrement(sal_Bool _bAuto) { m_bIsAutoIncrement = _bAuto; } + void SetPrimaryKey(sal_Bool _bPKey) { m_bIsPrimaryKey = _bPKey; } + void SetCurrency(sal_Bool _bIsCurrency) { m_bIsCurrency = _bIsCurrency; } + + ::rtl::OUString GetName() const { return m_sName; } + // ::rtl::OUString GetTypeName() const { return m_sTypeName; } + ::rtl::OUString GetDescription() const { return m_sDescription; } + ::rtl::OUString GetDefaultValue() const { return m_sDefaultValue; } + sal_Int32 GetType() const { return m_pType ? m_pType->nType : ::com::sun::star::sdbc::DataType::VARCHAR; } + sal_Int32 GetPrecision() const { return m_nPrecision; } + sal_Int32 GetScale() const { return m_nScale; } + sal_Int32 GetIsNullable() const { return m_nIsNullable; } + sal_Int32 GetFormatKey() const { return m_nFormatKey; } + SvxCellHorJustify GetHorJustify() const { return m_eHorJustify; } + const OTypeInfo* getTypeInfo() const { return m_pType; } + sal_Bool IsAutoIncrement() const { return m_bIsAutoIncrement; } + sal_Bool IsPrimaryKey() const { return m_bIsPrimaryKey; } + sal_Bool IsCurrency() const { return m_bIsCurrency; } + sal_Bool IsNullable() const { return m_nIsNullable == ::com::sun::star::sdbc::ColumnValue::NULLABLE; } + }; +} +#endif // DBAUI_FIELDDESCRIPTIONS_HXX + + diff --git a/dbaccess/source/ui/inc/TableController.hxx b/dbaccess/source/ui/inc/TableController.hxx new file mode 100644 index 000000000000..f2d217e32793 --- /dev/null +++ b/dbaccess/source/ui/inc/TableController.hxx @@ -0,0 +1,204 @@ +/************************************************************************* + * + * $RCSfile: TableController.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-02-14 14:36:53 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef DBUI_TABLECONTROLLER_HXX +#define DBUI_TABLECONTROLLER_HXX + +#ifndef DBAUI_GENERICCONTROLLER_HXX +#include "genericcontroller.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_ +#include <com/sun/star/util/XNumberFormatter.hpp> +#endif +#ifndef _UNDO_HXX +#include <svtools/undo.hxx> +#endif +#ifndef _COM_SUN_STAR_IO_XOBJECTOUTPUTSTREAM_HPP_ +#include <com/sun/star/io/XObjectOutputStream.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_ +#include <com/sun/star/io/XObjectInputStream.hpp> +#endif +#ifndef DBAUI_TYPEINFO_HXX +#include "TypeInfo.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XKeysSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif + + +namespace dbaui +{ + class OTableRow; + class OFieldDescription; + class OTableController : public OGenericUnoController + { + private: + SfxUndoManager m_aUndoManager; + ::std::vector<OTableRow*> m_vRowList; + OTypeInfoMap m_aTypeInfo; + ::std::vector<OTypeInfoMap::iterator> m_aTypeInfoIndex; + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTable; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier + + ::rtl::OUString m_sDataSourceName; // is set in initialze + ::rtl::OUString m_sCatalogName; // catalog for update data + ::rtl::OUString m_sSchemaName; // schema for update data + ::rtl::OUString m_sName; // table for update data + String m_sTypeNames; // these type names are the ones out of the resource file + + sal_Bool m_bEditable; // is the control readonly or not + sal_Bool m_bModified; // is the data modified + sal_Bool m_bOwnConnection; // is true when we created our own connection + + void loadData(); + void fillTypeInfo(); // fills a vector with type info + void checkColumns() throw(::com::sun::star::sdbc::SQLException);; // check if we have double column names + String createUniqueName(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _rxTables,const String& _rDefault); + void appendColumns(::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier>& _rxColSup,sal_Bool _bKeyColumns=sal_False); + void appendKey(::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XKeysSupplier>& _rxSup); + void alterColumns(); + void dropKey(); + void setColumnProperties(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn,const OFieldDescription* _pFieldDesc); + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> getKeyColumns() const; + protected: + // all the features which should be handled by this class + virtual void AddSupportedFeatures(); + // state of a feature. 'feature' may be the handle of a ::com::sun::star::util::URL somebody requested a dispatch interface for OR a toolbar slot. + virtual FeatureState GetState(sal_uInt16 nId); + // execute a feature + virtual void Execute(sal_uInt16 nId); + virtual ToolBox* CreateToolBox(Window* pParent); + + void createNewConnection(sal_Bool _bUI = sal_False); + + public: + OTableController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM); + + ~OTableController(); + // removes the connection from the vector and delete it + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > getConnection() { return m_xConnection; } + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getTable() { return m_xTable;} + ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > getNumberFormatter() const { return m_xFormatter; } + + // should the statement be parsed by our own sql parser + sal_Bool isReadOnly() const { return !m_bEditable; } + sal_Bool isModified() const { return m_bModified; } + + void setModified(sal_Bool _bModified=sal_True); + + // const ::connectivity::OSQLParseNode* getParseTree() const { return m_aSqlIterator.getParseTree();} + // need for undo's and redo's + SfxUndoManager* getUndoMgr(); + ::std::vector<OTableRow*>* getRows() { return &m_vRowList; } + const OTypeInfoMap* getTypeInfo() const { return &m_aTypeInfo; } + + const OTypeInfo* getTypeInfo(sal_Int32 _nPos) const { return m_aTypeInfoIndex[_nPos]->second; } + const OTypeInfo* getTypeInfoByType(sal_Int32 _nDataType) const; + + virtual sal_Bool Construct(Window* pParent); + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::beans::XPropertyChangeListener + virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt); + // ::com::sun::star::container::XContainerListener + virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& Event) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& Event) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& Event) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::frame::XController + virtual sal_Bool SAL_CALL suspend(sal_Bool bSuspend) throw( ::com::sun::star::uno::RuntimeException ); + // ::com::sun::star::lang::XComponent + virtual void SAL_CALL dispose(); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + // need by registration + static ::rtl::OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&); + // lang::XInitialization + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + // + virtual void Load(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxIn); + virtual void Save(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOut); + + }; +} +#endif // DBUI_TABLECONTROLLER_HXX + + diff --git a/dbaccess/source/ui/inc/TableDesignControl.hxx b/dbaccess/source/ui/inc/TableDesignControl.hxx new file mode 100644 index 000000000000..4e7d1f26f38c --- /dev/null +++ b/dbaccess/source/ui/inc/TableDesignControl.hxx @@ -0,0 +1,134 @@ +/************************************************************************* + * + * $RCSfile: TableDesignControl.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-02-14 14:37:00 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef DBAUI_TABLEDESIGNCONTROL_HXX +#define DBAUI_TABLEDESIGNCONTROL_HXX + +#ifndef _TABBAR_HXX //autogen +#include <svtools/tabbar.hxx> +#endif +#ifndef _SVX_DBBROWSE_HXX +#include <svx/dbbrowse.hxx> +#endif // _SVX_DBBROWSE_HXX + +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif + +#define TABPAGESIZE 70 +namespace dbaui +{ + class OTableDesignView; + class OTypeInfo; + //================================================================== + class OTableRowView : public DbBrowseBox + { + friend class OTableDesignUndoAct; + + protected: + long m_nDataPos; // derzeit benoetigte Zeile + long m_nCurrentPos; // Aktuelle Position der ausgewaehlten Column + ULONG m_nClipboardFormat; + private: + USHORT m_nCurUndoActId; + protected: + BOOL m_bCurrentModified; + BOOL m_bUpdatable; + BOOL m_bClipboardFilled; + + public: + OTableRowView(Window* pParent); + virtual ~OTableRowView(); + + virtual void SetData( long nRow, USHORT nColId, const OTypeInfo* _pTypeInfo ) = 0; + virtual void SetData( long nRow, USHORT nColId, const String& _rNewData ) = 0; + virtual String GetData( long nRow, USHORT nColId ) = 0; + virtual void SetControlText( long nRow, USHORT nColId, const String& rText ) = 0; + virtual String GetControlText( long nRow, USHORT nColId ) = 0; + + virtual OTableDesignView* GetView() const = 0; + + USHORT GetCurUndoActId(){ return m_nCurUndoActId; } + + virtual void Cut(); + virtual void Copy(); + virtual void Paste(); + + protected: + void Paste( long nRow ); + + virtual void CopyRows() = 0; + virtual void DeleteRows() = 0; + virtual void InsertRows( long nRow ) = 0; + virtual void InsertNewRows( long nRow ) = 0; + + virtual BOOL IsUpdatable() const {return m_bUpdatable;} + virtual void SetUpdatable( BOOL bUpdate=TRUE ); + + virtual RowStatus GetRowStatus(long nRow) const; + virtual void KeyInput(const KeyEvent& rEvt); + virtual void Command( const CommandEvent& rEvt ); + + virtual void Init(); + }; +} +#endif // DBAUI_TABLEDESIGNCONTROL_HXX + + diff --git a/dbaccess/source/ui/inc/TableDesignHelpBar.hxx b/dbaccess/source/ui/inc/TableDesignHelpBar.hxx new file mode 100644 index 000000000000..6dd4269dd51e --- /dev/null +++ b/dbaccess/source/ui/inc/TableDesignHelpBar.hxx @@ -0,0 +1,111 @@ +/************************************************************************* + * + * $RCSfile: TableDesignHelpBar.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-02-14 14:36:40 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef DBAUI_TABLEDESIGNHELPBAR_HXX +#define DBAUI_TABLEDESIGNHELPBAR_HXX + +#ifndef _STRING_HXX +#include <tools/string.hxx> +#endif +#ifndef _SV_TABCTRL_HXX +#include <vcl/tabctrl.hxx> +#endif +#ifndef _SV_TABPAGE_HXX +#include <vcl/tabpage.hxx> +#endif + +class MultiLineEdit; +namespace dbaui +{ + //================================================================== + // Ableitung von TabPage ist ein Trick von TH, + // um Aenderungen der Systemfarben zu bemerken (Bug #53905) + class OTableDesignHelpBar : public TabPage + { + private: + String m_sHelpText; + MultiLineEdit* m_pTextWin; + USHORT m_nDummy; + + protected: + virtual void Resize(); + + public: + OTableDesignHelpBar( Window* pParent ); + virtual ~OTableDesignHelpBar(); + + void SetHelpText( const String& rText ); + String GetHelpText() const { return m_sHelpText; } + + virtual long PreNotify( NotifyEvent& rNEvt ); + }; + + //================================================================== + class OFieldPropTabCtrl : public TabControl + { + public: + OFieldPropTabCtrl( Window* pParent, WinBits nWinStyle = WB_STDTABCONTROL ); + virtual ~OFieldPropTabCtrl(); + + }; + +} +#endif // DBAUI_TABLEDESIGNHELPBAR_HXX + diff --git a/dbaccess/source/ui/inc/TableDesignView.hxx b/dbaccess/source/ui/inc/TableDesignView.hxx new file mode 100644 index 000000000000..0ac3fbd91db7 --- /dev/null +++ b/dbaccess/source/ui/inc/TableDesignView.hxx @@ -0,0 +1,142 @@ +/************************************************************************* + * + * $RCSfile: TableDesignView.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-02-14 14:37:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef DBAUI_TABLEDESIGNVIEW_HXX +#define DBAUI_TABLEDESIGNVIEW_HXX + +#ifndef DBAUI_DATAVIEW_HXX +#include "dataview.hxx" +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _SV_SPLIT_HXX +#include <vcl/split.hxx> +#endif + +namespace dbaui +{ + class OTableController; + class OTableFieldDescWin; + class OTableDescWin; + class OTableEditorCtrl; + //================================================================== + class OTableBorderWindow : public Window + { + Splitter m_aHorzSplitter; + OTableController* m_pController; + OTableFieldDescWin* m_pFieldDescWin; + OTableEditorCtrl* m_pEditorCtrl; + + void ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground ); + void ArrangeChilds( long nSplitPos ,Rectangle& rRect); + DECL_LINK( SplitHdl, Splitter* ); + protected: + virtual void DataChanged(const DataChangedEvent& rDCEvt); + public: + OTableBorderWindow(Window* pParent); + ~OTableBorderWindow(); + // window overloads + virtual void Resize(); + virtual void GetFocus(); + + OTableEditorCtrl* GetEditorCtrl() const { return m_pEditorCtrl; } + OTableFieldDescWin* GetDescWin() const { return m_pFieldDescWin; } + }; + //================================================================== + class OTableDesignView : public ODataView + { + private: + ::com::sun::star::lang::Locale m_aLocale; + OTableBorderWindow* m_pWin; + OTableController* m_pController; + + protected: + + + // return the Rectangle where I can paint myself + virtual void resizeControl(Rectangle& rRect); + + public: + OTableDesignView( Window* pParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&, + OTableController* _pController); + virtual ~OTableDesignView(); + + OTableEditorCtrl* GetEditorCtrl() const { return m_pWin->GetEditorCtrl(); } + OTableFieldDescWin* GetDescWin() const { return m_pWin->GetDescWin(); } + OTableController* getController() const { return m_pController; } + + ::com::sun::star::lang::Locale getLocale() const { return m_aLocale;} + + virtual sal_Bool isCutAllowed(); + virtual void copy(); + virtual void cut(); + virtual void paste(); + // set the view readonly or not + virtual void setReadOnly(sal_Bool _bReadOnly); + + virtual void initialize(); + + DECL_LINK( SwitchHdl, Accelerator* ); + }; +} +#endif // DBAUI_TABLEDESIGNVIEW_HXX + diff --git a/dbaccess/source/ui/inc/TypeInfo.hxx b/dbaccess/source/ui/inc/TypeInfo.hxx new file mode 100644 index 000000000000..8b79eb96a068 --- /dev/null +++ b/dbaccess/source/ui/inc/TypeInfo.hxx @@ -0,0 +1,167 @@ +/************************************************************************* + * + * $RCSfile: TypeInfo.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-02-14 14:37:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef DBAUI_TYPEINFO_HXX +#define DBAUI_TYPEINFO_HXX + + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNSEARCH_HPP_ +#include <com/sun/star/sdbc/ColumnSearch.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _MAP_ +#include <map> +#endif + + +namespace dbaui +{ +//======================================================================== +// Anhand dieser Ids werden die sprachabhaengigen ::rtl::OUString aus der Resource geholt +const sal_uInt16 TYPE_UNKNOWN = 0; +const sal_uInt16 TYPE_TEXT = 1; +const sal_uInt16 TYPE_NUMERIC = 2; +const sal_uInt16 TYPE_DATETIME = 3; +const sal_uInt16 TYPE_DATE = 4; +const sal_uInt16 TYPE_TIME = 5; +const sal_uInt16 TYPE_BOOL = 6; +const sal_uInt16 TYPE_CURRENCY = 7; +const sal_uInt16 TYPE_MEMO = 8; +const sal_uInt16 TYPE_COUNTER = 9; +const sal_uInt16 TYPE_IMAGE = 10; +const sal_uInt16 TYPE_CHAR = 11; +const sal_uInt16 TYPE_DECIMAL = 12; +const sal_uInt16 TYPE_BINARY = 13; +const sal_uInt16 TYPE_VARBINARY = 14; +const sal_uInt16 TYPE_BIGINT = 15; +const sal_uInt16 TYPE_DOUBLE = 16; +const sal_uInt16 TYPE_FLOAT = 17; +const sal_uInt16 TYPE_REAL = 18; +const sal_uInt16 TYPE_INTEGER = 19; +const sal_uInt16 TYPE_SMALLINT = 20; +const sal_uInt16 TYPE_TINYINT = 21; +const sal_uInt16 TYPE_SQLNULL = 22; +const sal_uInt16 TYPE_OBJECT = 23; +const sal_uInt16 TYPE_DISTINCT = 24; +const sal_uInt16 TYPE_STRUCT = 25; +const sal_uInt16 TYPE_ARRAY = 26; +const sal_uInt16 TYPE_BLOB = 27; +const sal_uInt16 TYPE_CLOB = 28; +const sal_uInt16 TYPE_REF = 29; + + class OTypeInfo + { + public: + ::rtl::OUString aUIName; // the name which is the user see (a combination of resource text and aTypeName) + ::rtl::OUString aTypeName; // Name des Types in der Datenbank + ::rtl::OUString aLiteralPrefix; // Prefix zum Quoten + ::rtl::OUString aLiteralSuffix; // Suffix zum Quoten + ::rtl::OUString aCreateParams; // Parameter zum Erstellen + ::rtl::OUString aLocalTypeName; + + sal_Int32 nPrecision; // Laenge des Types + sal_Int32 nNumPrecRadix; // indicating the radix, which is usually 2 or 10 + + sal_Int16 nMaximumScale; // Nachkommastellen + sal_Int16 nMinimumScale; // Min Nachkommastellen + + sal_Int16 nType; // Datenbanktyp + sal_Int16 nSearchType; // kann nach dem Typen gesucht werden + + + sal_Bool bCurrency : 1, // Waehrung + bAutoIncrement : 1, // Ist es ein automatisch incrementierendes Feld + bNullable : 1, // Kann das Feld NULL annehmen + bCaseSensitive : 1, // Ist der Type Casesensitive + bUnsigned : 1, // Ist der Type Unsigned + bEmpty_1 : 1, // for later use + bEmpty_2 : 1; + + OTypeInfo() + :bCurrency(sal_False) + ,bAutoIncrement(sal_False) + ,bNullable(sal_True) + ,bCaseSensitive(sal_False) + ,bUnsigned(sal_False) + ,nMaximumScale(0) + ,nMinimumScale(0) + ,nType(::com::sun::star::sdbc::DataType::OTHER) + ,nPrecision(0) + ,nSearchType(::com::sun::star::sdbc::ColumnSearch::FULL) + {} + sal_Bool operator == (const OTypeInfo& lh) const { return lh.nType == nType; } + sal_Bool operator != (const OTypeInfo& lh) const { return lh.nType != nType; } + }; + + + typedef ::std::multimap<sal_Int32,OTypeInfo*> OTypeInfoMap; +} + +#endif // DBAUI_TYPEINFO_HXX + + diff --git a/dbaccess/source/ui/misc/uiservices.cxx b/dbaccess/source/ui/misc/uiservices.cxx index 5f82459a0896..d16c830b2c01 100644 --- a/dbaccess/source/ui/misc/uiservices.cxx +++ b/dbaccess/source/ui/misc/uiservices.cxx @@ -2,9 +2,9 @@ * * $RCSfile: uiservices.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-01-09 16:11:54 $ + * last change: $Author: oj $ $Date: 2001-02-14 14:34:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,6 +89,7 @@ extern "C" void SAL_CALL writeDBLoaderInfo(void* pRegistryKey); extern "C" void SAL_CALL createRegistryInfo_OInteractionHandler(); extern "C" void SAL_CALL createRegistryInfo_SbaXGridControl(); extern "C" void SAL_CALL createRegistryInfo_OQueryControl(); +extern "C" void SAL_CALL createRegistryInfo_OTableControl(); //*************************************************************************************** extern "C" void SAL_CALL createRegistryInfo_DBU() @@ -104,6 +105,7 @@ extern "C" void SAL_CALL createRegistryInfo_DBU() createRegistryInfo_OInteractionHandler(); createRegistryInfo_SbaXGridControl(); createRegistryInfo_OQueryControl(); + createRegistryInfo_OTableControl(); bInit = sal_True; } } |