diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-04-30 12:02:01 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-04-30 12:02:01 +0000 |
commit | d779ea83508b3146c4d0ee37bf22b3a34a59a518 (patch) | |
tree | d44b8739cc0f12deb77d33aa215d0e17c6dc8251 /dbaccess/source/ui | |
parent | 0f1ce61d1626bb8853654a3a352ef8d6a0063122 (diff) |
#86515# check undo actions
Diffstat (limited to 'dbaccess/source/ui')
-rw-r--r-- | dbaccess/source/ui/querydesign/ConnectionLine.cxx | 12 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/JoinTableView.cxx | 48 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/QueryDesignView.cxx | 12 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/QueryTableView.cxx | 26 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx | 169 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx | 6 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/querycontroller.cxx | 17 |
7 files changed, 156 insertions, 134 deletions
diff --git a/dbaccess/source/ui/querydesign/ConnectionLine.cxx b/dbaccess/source/ui/querydesign/ConnectionLine.cxx index dd7656bd2744..71d386f96271 100644 --- a/dbaccess/source/ui/querydesign/ConnectionLine.cxx +++ b/dbaccess/source/ui/querydesign/ConnectionLine.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ConnectionLine.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2001-02-28 10:18:26 $ + * last change: $Author: oj $ $Date: 2001-04-30 13:02:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -107,10 +107,12 @@ OConnectionLine::OConnectionLine( OTableConnection* _pConn, const String& _rSour : m_pTabConn( _pConn ) ,m_pSourceEntry( NULL ) ,m_pDestEntry( NULL ) + ,m_pData(NULL) { DBG_CTOR(OConnectionLine,NULL); - m_pData->SetSourceFieldName( _rSourceFieldName ); - m_pData->SetDestFieldName( _rDestFieldName ); + m_pData = new OConnectionLineData( _rSourceFieldName,_rDestFieldName); +// m_pData->SetSourceFieldName( _rSourceFieldName ); +// m_pData->SetDestFieldName( _rDestFieldName ); } //------------------------------------------------------------------------ @@ -444,7 +446,7 @@ void OConnectionLine::Draw( OutputDevice* pOutDev ) //------------------------------------------------------------------------ BOOL OConnectionLine::IsValid() { - return m_pData->IsValid(); + return m_pData && m_pData->IsValid(); } //------------------------------------------------------------------------ double dist_Euklid(const Point &p1, const Point& p2,const Point& pM, Point& q) diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx index 38391dbd0066..20a22c86c0d1 100644 --- a/dbaccess/source/ui/querydesign/JoinTableView.cxx +++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx @@ -2,9 +2,9 @@ * * $RCSfile: JoinTableView.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2001-04-06 13:45:42 $ + * last change: $Author: oj $ $Date: 2001-04-30 13:02:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1109,35 +1109,21 @@ void OJoinTableView::ClearAll() { DBG_CHKTHIS(OJoinTableView,NULL); SetUpdateMode(FALSE); - OTableWindowMapIterator aTableIter = m_aTableMap.begin(); - for(;aTableIter != m_aTableMap.end();++aTableIter) - { - OTableWindow* pEntry = aTableIter->second; - ::std::vector< OTableWindowData*>::iterator aFind = ::std::find(m_pView->getController()->getTableWindowData()->begin(),m_pView->getController()->getTableWindowData()->end(),pEntry->GetData()); - if(aFind != m_pView->getController()->getTableWindowData()->end()) - { - delete *aFind; - m_pView->getController()->getTableWindowData()->erase(aFind); - } - delete pEntry; - } - m_aTableMap.clear(); + HideTabWins(); // und das selbe mit den Connections ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin(); for(;aIter != m_vTableConnection.end();++aIter) - { - ::std::auto_ptr<OTableConnectionData> pData((*aIter)->GetData()); - m_pView->getController()->removeConnectionData(pData); - delete (*aIter); - } + RemoveConnection(*aIter); m_vTableConnection.clear(); + m_pLastFocusTabWin = NULL; // scroll to the upper left Scroll(-GetScrollOffset().X(), TRUE, TRUE); Scroll(-GetScrollOffset().Y(), FALSE, TRUE); + Invalidate(); } //------------------------------------------------------------------------ @@ -1568,6 +1554,28 @@ void OJoinTableView::StateChanged( StateChangedType nType ) Resize(); } } +//------------------------------------------------------------------------------ +void OJoinTableView::HideTabWins() +{ + DBG_CHKTHIS(OJoinTableView,NULL); + SetUpdateMode(sal_False); + + OTableWindowMap* pTabWins = GetTabWinMap(); + if (pTabWins) + { + OTableWindowMap::const_iterator aIter = pTabWins->begin(); + for(;aIter != pTabWins->end();++aIter) + RemoveTabWin(aIter->second); + } + + m_pView->getController()->setModified(sal_True); + + SetUpdateMode(sal_True); + +} +// ----------------------------------------------------------------------------- + + diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index d03466b44650..94a53c2ba3ed 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -2,9 +2,9 @@ * * $RCSfile: QueryDesignView.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: oj $ $Date: 2001-04-18 13:16:33 $ + * last change: $Author: oj $ $Date: 2001-04-30 13:02:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -213,7 +213,7 @@ void OQueryDesignView::initialize() m_aSplitter.SetSplitPosPixel(static_cast<OQueryController*>(getController())->getSplitPos()); } m_pSelectionBox->initialize(); - m_pSelectionBox->ClearAll(); + m_pSelectionBox->PreFill(); m_pSelectionBox->SetReadOnly(static_cast<OQueryController*>(getController())->isReadOnly()); m_pSelectionBox->Fill(); } @@ -273,9 +273,9 @@ void OQueryDesignView::setReadOnly(sal_Bool _bReadOnly) // ----------------------------------------------------------------------------- void OQueryDesignView::clear() { - SfxUndoManager* pUndoMgr = static_cast<OQueryController*>(getController())->getUndoMgr(); + m_pSelectionBox->ClearAll(); // clear the whole selection - m_pSelectionBox->Fill(); // fill with empty the fields + // m_pSelectionBox->Fill(); // fill with empty the fields m_pTableView->ClearAll(); } // ----------------------------------------------------------------------------- @@ -1867,7 +1867,7 @@ sal_Bool OQueryDesignView::isSlotEnabled(sal_Int32 _nSlotId) // ----------------------------------------------------------------------------- void OQueryDesignView::InitFromParseNode() { - m_pSelectionBox->ClearAll(); + m_pSelectionBox->PreFill(); m_pSelectionBox->Fill(); ::connectivity::OSQLParseTreeIterator& aIterator = static_cast<OQueryController*>(getController())->getParseIterator(); diff --git a/dbaccess/source/ui/querydesign/QueryTableView.cxx b/dbaccess/source/ui/querydesign/QueryTableView.cxx index 9c5bb9c496a5..6bc0a8d88813 100644 --- a/dbaccess/source/ui/querydesign/QueryTableView.cxx +++ b/dbaccess/source/ui/querydesign/QueryTableView.cxx @@ -2,9 +2,9 @@ * * $RCSfile: QueryTableView.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: oj $ $Date: 2001-04-10 11:11:49 $ + * last change: $Author: oj $ $Date: 2001-04-30 13:02:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -849,7 +849,7 @@ void OQueryTableView::RemoveTabWin(OTableWindow* pTabWin) pUndoMgr->AddUndoAction( pUndoAction ); pUndoMgr->LeaveListAction(); - m_pView->getController()->InvalidateFeature(ID_BROWSER_UNDORECORD); + m_pView->getController()->InvalidateFeature(ID_BROWSER_UNDO); m_pView->getController()->InvalidateFeature(ID_BROWSER_REDO); // GetViewShell()->GetViewShell()->UIFeatureChanged(); @@ -860,26 +860,6 @@ void OQueryTableView::RemoveTabWin(OTableWindow* pTabWin) } } -//------------------------------------------------------------------------------ -void OQueryTableView::HideTabWins() -{ - DBG_CHKTHIS(OQueryTableView,NULL); - SetUpdateMode(sal_False); - - OTableWindowMap* pTabWins = GetTabWinMap(); - if (pTabWins) - { - OTableWindowMap::const_iterator aIter = GetTabWinMap()->begin(); - for(;aIter != GetTabWinMap()->end();++aIter) - RemoveTabWin(aIter->second); - } - - m_pView->getController()->setModified(sal_True); - - SetUpdateMode(sal_True); - -} - //------------------------------------------------------------------------ void OQueryTableView::EnsureVisible(const OTableWindow* pWin) { diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index a5b3b6edebd5..614bf518ab96 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -2,9 +2,9 @@ * * $RCSfile: SelectionBrowseBox.cxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: oj $ $Date: 2001-04-18 13:16:33 $ + * last change: $Author: oj $ $Date: 2001-04-30 13:02:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -298,7 +298,7 @@ void OSelectionBrowseBox::Init() } //------------------------------------------------------------------------------ -void OSelectionBrowseBox::ClearAll() +void OSelectionBrowseBox::PreFill() { DBG_CHKTHIS(OSelectionBrowseBox,NULL); SetUpdateMode(sal_False); @@ -306,12 +306,13 @@ void OSelectionBrowseBox::ClearAll() if (GetCurRow() != 0) GoToRow(0); + OQueryController* pController = static_cast<OQueryController*>(static_cast<OQueryController*>(getDesignView()->getController())); - ::std::vector<OTableFieldDesc*>::iterator aIter = pController->getTableFieldDesc()->begin(); - for(;aIter != pController->getTableFieldDesc()->end();++aIter) + ::std::vector<OTableFieldDesc*>::iterator aIter = getFields()->begin(); + for(;aIter != getFields()->end();++aIter) delete *aIter; - pController->getTableFieldDesc()->clear(); + getFields()->clear(); sal_uInt16 nCurCol = GetCurColumnId(); long nCurRow = GetCurRow(); @@ -327,7 +328,22 @@ void OSelectionBrowseBox::ClearAll() #endif } +//------------------------------------------------------------------------------ +void OSelectionBrowseBox::ClearAll() +{ + DBG_CHKTHIS(OSelectionBrowseBox,NULL); + SetUpdateMode(sal_False); + + OQueryController* pController = static_cast<OQueryController*>(static_cast<OQueryController*>(getDesignView()->getController())); + ::std::vector<OTableFieldDesc*>::reverse_iterator aIter = getFields()->rbegin(); + for(sal_uInt16 nId=getFields()->size();aIter != getFields()->rend();++aIter,--nId) + { + if(!(*aIter)->IsEmpty()) + RemoveField(nId); + } + SetUpdateMode(sal_True); +} //------------------------------------------------------------------------------ void OSelectionBrowseBox::SetReadOnly(sal_Bool bRO) { @@ -351,7 +367,7 @@ DbCellController* OSelectionBrowseBox::GetController(long nRow, sal_uInt16 nColI DBG_CHKTHIS(OSelectionBrowseBox,NULL); OQueryController* pController = static_cast<OQueryController*>(static_cast<OQueryController*>(getDesignView()->getController())); - OTableFieldDesc* pEntry = (*pController->getTableFieldDesc())[nColId-1]; + OTableFieldDesc* pEntry = (*getFields())[nColId-1]; DBG_ASSERT(pEntry, "OSelectionBrowseBox::GetController : keine FieldDescription !"); if (!pEntry) @@ -384,8 +400,8 @@ void OSelectionBrowseBox::InitController(DbCellControllerRef& rController, long DBG_CHKTHIS(OSelectionBrowseBox,NULL); OQueryController* pController = static_cast<OQueryController*>(static_cast<OQueryController*>(getDesignView()->getController())); - OSL_ENSURE(pController->getTableFieldDesc()->size() > sal_uInt16(nColId-1),"ColID is to great!"); - OTableFieldDesc* pEntry = (*pController->getTableFieldDesc())[nColId-1]; + OSL_ENSURE(getFields()->size() > sal_uInt16(nColId-1),"ColID is to great!"); + OTableFieldDesc* pEntry = (*getFields())[nColId-1]; DBG_ASSERT(pEntry, "OSelectionBrowseBox::InitController : keine FieldDescription !"); long nCellIndex = GetRealRow(nRow); @@ -583,8 +599,8 @@ sal_Bool OSelectionBrowseBox::SaveModified() DBG_CHKTHIS(OSelectionBrowseBox,NULL); OTableFieldDesc* pEntry = NULL; OQueryController* pController = static_cast<OQueryController*>(getDesignView()->getController()); - if(pController->getTableFieldDesc()->size() > sal_uInt16(GetCurColumnId() - 1)) - pEntry = (*pController->getTableFieldDesc())[GetCurColumnId() - 1]; + if(getFields()->size() > sal_uInt16(GetCurColumnId() - 1)) + pEntry = (*getFields())[GetCurColumnId() - 1]; sal_Bool bWasEmpty = pEntry ? pEntry->IsEmpty() : sal_False; sal_Bool bError = sal_False; @@ -839,7 +855,7 @@ sal_Bool OSelectionBrowseBox::SaveModified() if (!aFieldName.Len()) { - ::std::replace(pController->getTableFieldDesc()->begin(),static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->end(),pEntry,new OTableFieldDesc); + ::std::replace(getFields()->begin(),getFields()->end(),pEntry,new OTableFieldDesc); sal_uInt16 nCol = GetCurColumnId(); for (int i = 0; i < m_nVisibleCount; i++) // Spalte neu zeichnen RowModified(i,nCol); @@ -1089,8 +1105,8 @@ void OSelectionBrowseBox::PaintCell(OutputDevice& rDev, const Rectangle& rRect, rDev.SetClipRegion( rRect ); OTableFieldDesc* pEntry = NULL; - if(static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size() > sal_uInt16(nColumnId - 1)) - pEntry = (*static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc())[nColumnId - 1]; + if(getFields()->size() > sal_uInt16(nColumnId - 1)) + pEntry = (*getFields())[nColumnId - 1]; if (!pEntry) return; @@ -1123,9 +1139,10 @@ void OSelectionBrowseBox::PaintStatusCell(OutputDevice& rDev, const Rectangle& r void OSelectionBrowseBox::RemoveColumn(sal_uInt16 nColId) { DBG_CHKTHIS(OSelectionBrowseBox,NULL); - DBG_ASSERT(static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size() == sal_uInt16(ColCount() - 1), "OSelectionBrowseBox::RemoveColumn : inkonsistent state !"); + OQueryController* pController = static_cast<OQueryController*>(getDesignView()->getController()); + // das Control sollte immer genau eine Spalte mehr haben, naemlich die HandleColumn - DBG_ASSERT((nColId == 0) || (nColId <= static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size()), "OSelectionBrowseBox::RemoveColumn : invalid parameter nColId"); + DBG_ASSERT((nColId == 0) || (nColId <= getFields()->size()), "OSelectionBrowseBox::RemoveColumn : invalid parameter nColId"); // ColId ist bei mir gleichbedeutend mit Position, und da sollte die Bedingung natuerlich zutreffen sal_uInt16 nCurCol = GetCurColumnId(); @@ -1133,12 +1150,11 @@ void OSelectionBrowseBox::RemoveColumn(sal_uInt16 nColId) DeactivateCell(); // Spalteninfo rausnehmen und am Ende neues Info einfuegen - OTableFieldDesc* pOld = (*static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc())[((sal_uInt32)nColId - 1)]; - static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->erase( static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->begin() + ((sal_uInt32)nColId - 1) ); + getFields()->erase( getFields()->begin() + ((sal_uInt32)nColId - 1) ); // der Aufrufer ist dafuer verantwortlich, sich vorher die Description zu besorgen und die irgendwie aufzuraeumen // (im Normalfall wohl erst mal in ein Undo zu schieben) - OTableFieldDesc* pNew = new OTableFieldDesc; - static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->push_back(pNew); + OTableFieldDesc* pNew = new OTableFieldDesc(); + getFields()->push_back(pNew); // Nachfolgende Spalten optisch verschieben sal_uInt16 nCount = (sal_uInt16)ColCount(); @@ -1156,11 +1172,11 @@ void OSelectionBrowseBox::RemoveColumn(sal_uInt16 nColId) ActivateCell( nCurRow, nCurCol ); - static_cast<OQueryController*>(getDesignView()->getController())->setModified(); + pController->setModified(); - static_cast<OQueryController*>(getDesignView()->getController())->InvalidateFeature( ID_BROWSER_UNDO ); - static_cast<OQueryController*>(getDesignView()->getController())->InvalidateFeature( ID_BROWSER_REDO ); - static_cast<OQueryController*>(getDesignView()->getController())->InvalidateFeature( ID_BROWSER_QUERY_EXECUTE ); + pController->InvalidateFeature( ID_BROWSER_UNDO ); + pController->InvalidateFeature( ID_BROWSER_REDO ); + pController->InvalidateFeature( ID_BROWSER_QUERY_EXECUTE ); } @@ -1168,9 +1184,11 @@ void OSelectionBrowseBox::RemoveColumn(sal_uInt16 nColId) void OSelectionBrowseBox::RemoveField(sal_uInt16 nId, sal_Bool bActivate) { DBG_CHKTHIS(OSelectionBrowseBox,NULL); - OSL_ENSURE(static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size() > sal_uInt16(nId-1),"ID is to great!"); + OQueryController* pController = static_cast<OQueryController*>(getDesignView()->getController()); - OTableFieldDesc* pDesc = (*static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc())[(sal_uInt32)(nId - 1)] ; + OSL_ENSURE(getFields()->size() > sal_uInt16(nId-1),"ID is to great!"); + + OTableFieldDesc* pDesc = (*getFields())[(sal_uInt32)(nId - 1)] ; pDesc->SetColWidth( (sal_uInt16)GetColumnWidth(nId) ); // hat er sich vorher leider nicht gemerkt // UndoAction erzeugen @@ -1178,15 +1196,12 @@ void OSelectionBrowseBox::RemoveField(sal_uInt16 nId, sal_Bool bActivate) pUndoAction->SetTabFieldDescr(pDesc); pUndoAction->SetOwnership(sal_True); pUndoAction->SetColId( nId ); - static_cast<OQueryController*>(getDesignView()->getController())->getUndoMgr()->AddUndoAction( pUndoAction ); + pController->getUndoMgr()->AddUndoAction( pUndoAction ); RemoveColumn(nId); - // damit das Ganze potentiell unendlich ist, zieht ein Remove auch gleich ein Insert einer leeren Spalte nach sich -// AppendNewCol(1); - - static_cast<OQueryController*>(getDesignView()->getController())->InvalidateFeature(ID_BROWSER_UNDO); - static_cast<OQueryController*>(getDesignView()->getController())->InvalidateFeature(ID_BROWSER_REDO); + pController->InvalidateFeature(ID_BROWSER_UNDO); + pController->InvalidateFeature(ID_BROWSER_REDO); } //------------------------------------------------------------------------------ @@ -1292,24 +1307,24 @@ OTableFieldDesc* OSelectionBrowseBox::AppendNewCol( sal_uInt16 nCnt ) DBG_CHKTHIS(OSelectionBrowseBox,NULL); // es koennen mehrere angelegt werden, aber der Erste // wird returnt - sal_uInt32 nCount = static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size(); + sal_uInt32 nCount = getFields()->size(); OTableFieldDesc* pNewDesc; for (sal_uInt16 i=0 ; i<nCnt ; i++) { pNewDesc = new OTableFieldDesc; pNewDesc->SetColWidth(DEFAULT_SIZE); - static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->push_back(pNewDesc); - InsertDataColumn((sal_uInt16)static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size(), String(), DEFAULT_SIZE, HIB_STDSTYLE, HEADERBAR_APPEND); + getFields()->push_back(pNewDesc); + InsertDataColumn((sal_uInt16)getFields()->size(), String(), DEFAULT_SIZE, HIB_STDSTYLE, HEADERBAR_APPEND); } - return (*static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc())[nCount]; + return (*getFields())[nCount]; } //------------------------------------------------------------------------------ void OSelectionBrowseBox::DeleteFields(const String& rAliasName) { DBG_CHKTHIS(OSelectionBrowseBox,NULL); - if (static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size()) + if (getFields()->size()) { sal_uInt16 nColId = GetCurColumnId(); sal_uInt32 nRow = GetCurRow(); @@ -1318,9 +1333,9 @@ void OSelectionBrowseBox::DeleteFields(const String& rAliasName) if (bWasEditing) DeactivateCell(); - ::std::vector<OTableFieldDesc*>::reverse_iterator aIter = static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->rbegin(); + ::std::vector<OTableFieldDesc*>::reverse_iterator aIter = getFields()->rbegin(); OTableFieldDesc* pEntry = NULL; - for(sal_Int32 nPos=static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size();aIter != static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->rend();++aIter,--nPos) + for(sal_Int32 nPos=getFields()->size();aIter != getFields()->rend();++aIter,--nPos) { pEntry = *aIter; if (pEntry->GetAlias() == ::rtl::OUString(rAliasName) ) @@ -1362,7 +1377,7 @@ void OSelectionBrowseBox::SetColWidth(sal_uInt16 nColId, long nNewWidth) SetColumnWidth(nColId, nNewWidth); // der FieldDescription Bescheid sagen - OTableFieldDesc* pEntry = (*static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc())[nColId - 1]; + OTableFieldDesc* pEntry = (*getFields())[nColId - 1]; if (pEntry) pEntry->SetColWidth(sal_uInt16(GetColumnWidth(nColId))); @@ -1390,9 +1405,9 @@ Rectangle OSelectionBrowseBox::GetInvalidRect( sal_uInt16 nColId ) void OSelectionBrowseBox::InsertColumn(OTableFieldDesc* pEntry, long& nColId) { DBG_CHKTHIS(OSelectionBrowseBox,NULL); - DBG_ASSERT(static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size() == sal_uInt16(ColCount() - 1), "OSelectionBrowseBox::InsertColumn : inkonsistent state !"); + OQueryController* pController = static_cast<OQueryController*>(getDesignView()->getController()); // das Control sollte immer genau eine Spalte mehr haben, naemlich die HandleColumn - DBG_ASSERT(sal_uInt16(nColId == -1) || (nColId <= (long)static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size()), "OSelectionBrowseBox::InsertColumn : invalid parameter nColId."); + DBG_ASSERT(sal_uInt16(nColId == -1) || (nColId <= (long)getFields()->size()), "OSelectionBrowseBox::InsertColumn : invalid parameter nColId."); // -1 heisst ganz hinten, Count heisst ganz hinten, der Rest bezeichnet eine richtige Position sal_uInt16 nCurCol = GetCurColumnId(); @@ -1402,33 +1417,33 @@ void OSelectionBrowseBox::InsertColumn(OTableFieldDesc* pEntry, long& nColId) // Gueltigkeit von nColId pruefen (ColId von 1 bis ...) // Wenn zu klein oder zu gross, auf Ende der Liste setzen - if ((nColId == -1) || (sal_uInt16(nColId) >= static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size())) // Anhaengen des Feldes + if ((nColId == -1) || (sal_uInt16(nColId) >= getFields()->size())) // Anhaengen des Feldes { if (FindFirstFreeCol(nColId) == NULL) // keine freie Column mehr { AppendNewCol(1); - nColId = static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size(); + nColId = getFields()->size(); } else nColId++; // innerhalb der vorgegebenen Liste } // in Liste der Spaltenbeschreibungen neues Element - static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->insert( static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->begin()+(sal_uInt32)nColId-1 ,pEntry); + getFields()->insert( getFields()->begin()+(sal_uInt32)nColId-1 ,pEntry); // da ich meine Spaltenzahl immer auf dem selben Wert wie die Zahl der FieldDescriptions halten muss (plus 1, da es eine // HandleClumn gibt), muss ich fuer diese gerade eingefuegte Description auch eine loeschen long nFirstFreeCol = -1; CheckFreeColumns(nFirstFreeCol); // (es kann sein, dass es keine leere gab, dann erzwingt CheckFreeColumns das) - delete (*static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc())[(sal_uInt16)nFirstFreeCol]; - static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->erase(static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->begin()+(sal_uInt16)nFirstFreeCol); + delete (*getFields())[(sal_uInt16)nFirstFreeCol]; + getFields()->erase(getFields()->begin()+(sal_uInt16)nFirstFreeCol); // jetzt kann wieder keine leere Spalte vorhanden sein (falls naemlich die soeben geloeschte die einzige war) ... CheckFreeColumns(nFirstFreeCol); // Nachfolgende Spalten optisch verschieben - sal_uInt16 nCount = (sal_uInt16)static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size(); + sal_uInt16 nCount = (sal_uInt16)getFields()->size(); for (sal_uInt16 i = nCount-1; i > nColId; --i) SetColumnWidth(i, GetColumnWidth(i - 1)); @@ -1512,10 +1527,12 @@ OTableFieldDesc* OSelectionBrowseBox::InsertField(const OTableFieldDesc& rInfo, sal_uInt16 OSelectionBrowseBox::FieldsCount() { DBG_CHKTHIS(OSelectionBrowseBox,NULL); - ::std::vector<OTableFieldDesc*>::iterator aIter = static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->begin(); + OQueryController* pController = static_cast<OQueryController*>(getDesignView()->getController()); + + ::std::vector<OTableFieldDesc*>::iterator aIter = getFields()->begin(); sal_uInt16 nCount = 0; - while (aIter != static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->end()) + while (aIter != getFields()->end()) { if ((*aIter) && !(*aIter)->IsEmpty()) nCount++; @@ -1529,9 +1546,11 @@ sal_uInt16 OSelectionBrowseBox::FieldsCount() OTableFieldDesc* OSelectionBrowseBox::FindFirstFreeCol( long& rCol ) { DBG_CHKTHIS(OSelectionBrowseBox,NULL); - ::std::vector<OTableFieldDesc*>::iterator aIter = static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->begin(); + OQueryController* pController = static_cast<OQueryController*>(getDesignView()->getController()); + + ::std::vector<OTableFieldDesc*>::iterator aIter = getFields()->begin(); rCol = -1; - while (aIter != static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->end()) + while (aIter != getFields()->end()) { ++rCol; if ((*aIter) && (*aIter)->IsEmpty()) @@ -1563,8 +1582,8 @@ void OSelectionBrowseBox::AddGroupBy( const OTableFieldDesc& rInfo ) DBG_ASSERT(!rInfo.IsEmpty(),"AddGroupBy:: OTableFieldDesc sollte nicht Empty sein!"); OTableFieldDesc* pEntry; ::comphelper::UStringMixEqual bCase(xConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); - ::std::vector<OTableFieldDesc*>::iterator aIter = static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->begin(); - for(;aIter != static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->end();++aIter) + ::std::vector<OTableFieldDesc*>::iterator aIter = getFields()->begin(); + for(;aIter != getFields()->end();++aIter) { pEntry = *aIter; OSL_ENSURE(pEntry,"OTableFieldDesc was null!"); @@ -1588,7 +1607,7 @@ void OSelectionBrowseBox::AddGroupBy( const OTableFieldDesc& rInfo ) } } - if (aIter == static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->end()) + if (aIter == getFields()->end()) { OTableFieldDesc* pTmp = InsertField(rInfo, -1, sal_False, sal_False ); if((pTmp->GetFunctionType() == FKT_AGGREGATE && rInfo.IsGroupBy())) // das GroupBy wird bereits von rInfo "ubernommen @@ -1606,8 +1625,8 @@ void OSelectionBrowseBox::AddCondition( const OTableFieldDesc& rInfo, const Stri OTableFieldDesc* pEntry; ::comphelper::UStringMixEqual bCase(xConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); - ::std::vector<OTableFieldDesc*>::iterator aIter = static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->begin(); - for(;aIter != static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->end();++aIter) + ::std::vector<OTableFieldDesc*>::iterator aIter = getFields()->begin(); + for(;aIter != getFields()->end();++aIter) { pEntry = *aIter; ::rtl::OUString aField = pEntry->GetField(); @@ -1639,7 +1658,7 @@ void OSelectionBrowseBox::AddCondition( const OTableFieldDesc& rInfo, const Stri } } - if (aIter == static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->end()) + if (aIter == getFields()->end()) { OTableFieldDesc* pTmp = InsertField(rInfo, -1, sal_False, sal_False ); if((pTmp->GetFunctionType() == FKT_AGGREGATE && rInfo.IsGroupBy())) // das GroupBy wird bereits von rInfo "ubernommen @@ -1670,8 +1689,8 @@ void OSelectionBrowseBox::AddOrder( const OTableFieldDesc& rInfo, const EOrderDi OTableFieldDesc* pEntry; ::comphelper::UStringMixEqual bCase(xConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); - ::std::vector<OTableFieldDesc*>::iterator aIter = static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->begin(); - for(;aIter != static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->end();++aIter) + ::std::vector<OTableFieldDesc*>::iterator aIter = getFields()->begin(); + for(;aIter != getFields()->end();++aIter) { pEntry = *aIter; ::rtl::OUString aField = pEntry->GetField(); @@ -1683,12 +1702,12 @@ void OSelectionBrowseBox::AddOrder( const OTableFieldDesc& rInfo, const EOrderDi if(!m_bOrderByUnRelated) pEntry->SetVisible(sal_True); pEntry->SetOrderDir( eDir ); - nPos = static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->end() - aIter; + nPos = getFields()->end() - aIter; break; } } - if (aIter == static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->end()) + if (aIter == getFields()->end()) { OTableFieldDesc* pTmp = InsertField(rInfo, -1, sal_False, sal_False ); if(pTmp) @@ -1698,7 +1717,7 @@ void OSelectionBrowseBox::AddOrder( const OTableFieldDesc& rInfo, const EOrderDi pTmp->SetOrderDir( eDir ); } - nPos = (sal_uInt16)( static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size()-1 ); + nPos = (sal_uInt16)( getFields()->size()-1 ); } } @@ -1726,7 +1745,7 @@ void OSelectionBrowseBox::CellModified() { case BROW_VIS_ROW: { - OTableFieldDesc* pEntry = (*static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc())[GetCurColumnId() - 1]; + OTableFieldDesc* pEntry = (*getFields())[GetCurColumnId() - 1]; sal_Bool bOldValue = pEntry->IsVisible(); sal_uInt16 nIdx = m_pOrderCell->GetSelectEntryPos(); @@ -1948,7 +1967,7 @@ void OSelectionBrowseBox::SetNoneVisbleRow(long nRows) String OSelectionBrowseBox::GetCellText(long nRow, sal_uInt16 nColId) const { DBG_CHKTHIS(OSelectionBrowseBox,NULL); - OTableFieldDesc* pEntry = (*static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc())[nColId-1]; + OTableFieldDesc* pEntry = (*getFields())[nColId-1]; DBG_ASSERT(pEntry != NULL, "OSelectionBrowseBox::GetCellText : invalid column id, prepare for GPF ... "); if(pEntry->IsEmpty()) return String(); @@ -2033,7 +2052,7 @@ String OSelectionBrowseBox::GetCellContents(sal_uInt16 nCellIndex, long nColId) // DBG_ASSERT(nCellIndex < (GetRowCount()-1),"CellIndex ist zu gross"); SaveModified(); - OTableFieldDesc* pEntry = (*static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc())[nColId - 1]; + OTableFieldDesc* pEntry = (*getFields())[nColId - 1]; DBG_ASSERT(pEntry != NULL, "OSelectionBrowseBox::GetCellContents : invalid column id, prepare for GPF ... "); switch (nCellIndex) @@ -2060,7 +2079,7 @@ void OSelectionBrowseBox::SetCellContents(sal_uInt16 nRow, long nColId, const St if (bWasEditing) DeactivateCell(); - OTableFieldDesc* pEntry = (*static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc())[nColId - 1]; + OTableFieldDesc* pEntry = (*getFields())[nColId - 1]; DBG_ASSERT(pEntry != NULL, "OSelectionBrowseBox::SetCellContents : invalid column id, prepare for GPF ... "); @@ -2113,7 +2132,7 @@ void OSelectionBrowseBox::SetCellContents(sal_uInt16 nRow, long nColId, const St sal_uInt32 OSelectionBrowseBox::GetTotalCellWidth(long nRow, sal_uInt16 nColId) const { DBG_CHKTHIS(OSelectionBrowseBox,NULL); - OTableFieldDesc* pEntry = (*static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc())[nColId-1]; + OTableFieldDesc* pEntry = (*getFields())[nColId-1]; if (!pEntry) return DEFAULT_SIZE; @@ -2134,8 +2153,8 @@ void OSelectionBrowseBox::ColumnResized(sal_uInt16 nColId) // but the changes aren't permanent ... DBG_CHKTHIS(OSelectionBrowseBox,NULL); - DBG_ASSERT(nColId <= static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size(),"ColumnResized:: nColId sollte nicht groesser als List::count sein!"); - OTableFieldDesc* pEntry = (*static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc())[nColId-1]; + DBG_ASSERT(nColId <= getFields()->size(),"ColumnResized:: nColId sollte nicht groesser als List::count sein!"); + OTableFieldDesc* pEntry = (*getFields())[nColId-1]; DBG_ASSERT(pEntry, "OSelectionBrowseBox::ColumnResized : keine FieldDescription !"); static_cast<OQueryController*>(getDesignView()->getController())->setModified(); DbBrowseBox::ColumnResized(nColId); @@ -2154,9 +2173,9 @@ void OSelectionBrowseBox::ColumnResized(sal_uInt16 nColId) sal_uInt32 OSelectionBrowseBox::GetTotalCellWidth(long nRowId, sal_uInt16 nColId) { DBG_CHKTHIS(OSelectionBrowseBox,NULL); - DBG_ASSERT((nColId == 0) || (nColId <= static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc()->size()), "OSelectionBrowseBox::GetTotalCellWidth : invalid parameter nColId"); + DBG_ASSERT((nColId == 0) || (nColId <= getFields()->size()), "OSelectionBrowseBox::GetTotalCellWidth : invalid parameter nColId"); - OTableFieldDesc* pEntry = (*static_cast<OQueryController*>(getDesignView()->getController())->getTableFieldDesc())[nColId-1]; + OTableFieldDesc* pEntry = (*getFields())[nColId-1]; DBG_ASSERT(pEntry!=NULL, "OSelectionBrowseBox::GetTotalCellWidth : invalid FieldDescription !"); long nRow = GetRealRow(nRowId); @@ -2281,5 +2300,11 @@ void OSelectionBrowseBox::startTimer() m_timerInvalidate.Start(); } // ----------------------------------------------------------------------------- +::std::vector<OTableFieldDesc*>* OSelectionBrowseBox::getFields() const +{ + OQueryController* pController = static_cast<OQueryController*>(getDesignView()->getController()); + return getFields(); +} +// ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx index 8f538028a9a6..e6e649b97a35 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx @@ -2,9 +2,9 @@ * * $RCSfile: SelectionBrowseBox.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2001-04-18 13:16:33 $ + * last change: $Author: oj $ $Date: 2001-04-30 13:02:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -226,6 +226,8 @@ namespace dbaui long GetBrowseRow(long nRowId) const; sal_Bool GetFunktionName(String& rFkt); void appendUndoAction(const String& _rOldValue,const String& _rNewValue,sal_Int32 _nRow); + void PreFill(); + ::std::vector<OTableFieldDesc*>* getFields() const; }; } #endif // DBAUI_QUERYDESIGN_OSELECTIONBROWSEBOX_HXX diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index f155e45ff483..6290cb2ded8b 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -2,9 +2,9 @@ * * $RCSfile: querycontroller.cxx,v $ * - * $Revision: 1.34 $ + * $Revision: 1.35 $ * - * last change: $Author: oj $ $Date: 2001-04-26 13:34:47 $ + * last change: $Author: oj $ $Date: 2001-04-30 13:02:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -465,10 +465,15 @@ void OQueryController::Execute(sal_uInt16 _nId) } break; case ID_BROWSER_CLEAR_QUERY: - m_pWindow->getView()->clear(); - m_sStatement = ::rtl::OUString(); - if(m_bDesign) - InvalidateFeature(ID_BROWSER_ADDTABLE); + { + m_aUndoManager.EnterListAction( String( ModuleRes(STR_QUERY_UNDO_TABWINDELETE) ), String() ); + m_pWindow->getView()->clear(); + m_aUndoManager.LeaveListAction(); + + m_sStatement = ::rtl::OUString(); + if(m_bDesign) + InvalidateFeature(ID_BROWSER_ADDTABLE); + } // InvalidateFeature(ID_BROWSER_QUERY_EXECUTE); break; case ID_BROWSER_QUERY_VIEW_FUNCTIONS: |