summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dbaccess/source/ui/dlg/indexdialog.cxx763
-rw-r--r--dbaccess/source/ui/dlg/indexdialog.hrc96
-rw-r--r--dbaccess/source/ui/dlg/indexdialog.src360
-rw-r--r--dbaccess/source/ui/dlg/indexfieldscontrol.cxx511
4 files changed, 1730 insertions, 0 deletions
diff --git a/dbaccess/source/ui/dlg/indexdialog.cxx b/dbaccess/source/ui/dlg/indexdialog.cxx
new file mode 100644
index 000000000000..6c2534ea93ff
--- /dev/null
+++ b/dbaccess/source/ui/dlg/indexdialog.cxx
@@ -0,0 +1,763 @@
+/*************************************************************************
+ *
+ * $RCSfile: indexdialog.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: fs $ $Date: 2001-03-16 16:23:02 $
+ *
+ * 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 EXPRESS 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_INDEXDIALOG_HXX_
+#include "indexdialog.hxx"
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBAUI_INDEXDIALOG_HRC_
+#include "indexdialog.hrc"
+#endif
+#ifndef _DBAUI_INDEXFIELDSCONTROL_HXX_
+#include "indexfieldscontrol.hxx"
+#endif
+#ifndef _DBAUI_INDEXCOLLECTION_HXX_
+#include "indexcollection.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+
+//......................................................................
+namespace dbaui
+{
+//......................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::lang;
+ using namespace ::dbtools;
+
+ //==================================================================
+ //= helper
+ //==================================================================
+ //------------------------------------------------------------------
+ sal_Bool operator ==(const OIndexField& _rLHS, const OIndexField& _rRHS)
+ {
+ return (_rLHS.sFieldName == _rRHS.sFieldName)
+ && (_rLHS.bSortAscending == _rRHS.bSortAscending);
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool operator !=(const OIndexField& _rLHS, const OIndexField& _rRHS)
+ {
+ return !(_rLHS == _rRHS);
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool operator ==(const IndexFields& _rLHS, const IndexFields& _rRHS)
+ {
+ if (_rLHS.size() != _rRHS.size())
+ return sal_False;
+
+ ConstIndexFieldsIterator aLeft = _rLHS.begin();
+ ConstIndexFieldsIterator aRight = _rRHS.begin();
+ for (; aLeft != _rLHS.end(); ++aLeft, ++aRight)
+ {
+ if (*aLeft != *aRight)
+ return sal_False;
+ }
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool operator !=(const IndexFields& _rLHS, const IndexFields& _rRHS)
+ {
+ return !(_rLHS == _rRHS);
+ }
+
+ //==================================================================
+ //= DbaIndexList
+ //==================================================================
+ //------------------------------------------------------------------
+ DbaIndexList::DbaIndexList(Window* _pParent, const ResId& _rId)
+ :SvTreeListBox(_pParent, _rId)
+ ,m_bSuspendSelectHdl(sal_False)
+ {
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool DbaIndexList::EditedEntry( SvLBoxEntry* _pEntry, const String& _rNewText )
+ {
+ sal_Bool bReturn = SvTreeListBox::EditedEntry(_pEntry, _rNewText);
+ SvTreeListBox::SetEntryText(_pEntry, _rNewText);
+
+ if (m_aEndEditHdl.IsSet())
+ m_aEndEditHdl.Call(_pEntry);
+
+ return bReturn;
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexList::enableSelectHandler()
+ {
+ DBG_ASSERT(m_bSuspendSelectHdl, "DbaIndexList::enableSelectHandler: invalid call (this is not cumulative)!");
+ m_bSuspendSelectHdl = sal_False;
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexList::disableSelectHandler()
+ {
+ DBG_ASSERT(!m_bSuspendSelectHdl, "DbaIndexList::enableSelectHandler: invalid call (this is not cumulative)!");
+ m_bSuspendSelectHdl = sal_True;
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexList::SelectNoHandlerCall( SvLBoxEntry* _pEntry )
+ {
+ disableSelectHandler();
+ Select(_pEntry, sal_True);
+ enableSelectHandler();
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool DbaIndexList::Select( SvLBoxEntry* pEntry, sal_Bool _bSelect )
+ {
+ sal_Bool bReturn = SvTreeListBox::Select(pEntry, _bSelect);
+
+ if (m_aSelectHdl.IsSet() && !m_bSuspendSelectHdl && _bSelect)
+ m_aSelectHdl.Call(this);
+
+ return bReturn;
+ }
+
+ //==================================================================
+ //= DbaIndexDialog
+ //==================================================================
+ //------------------------------------------------------------------
+ DbaIndexDialog::DbaIndexDialog(Window* _pParent, const Sequence< ::rtl::OUString >& _rFieldNames,
+ const Reference< XNameAccess >& _rxIndexes, const Reference< XMultiServiceFactory >& _rxORB)
+ :ModalDialog( _pParent, ModuleRes(DLG_INDEXDESIGN))
+ ,m_aGeometrySettings(E_DIALOG, ::rtl::OUString::createFromAscii("dbaccess.tabledesign.indexdialog"))
+ ,m_aActions (this, ResId(TLB_ACTIONS))
+ ,m_aIndexes (this, ResId(CTR_INDEXLIST))
+ ,m_aIndexDetails (this, ResId(FL_INDEXDETAILS))
+ ,m_aDescriptionLabel (this, ResId(FT_DESC_LABEL))
+ ,m_aDescription (this, ResId(FT_DESCRIPTION))
+ ,m_aUnique (this, ResId(CB_UNIQUE))
+ ,m_aFieldsLabel (this, ResId(FT_FIELDS))
+ ,m_pFields(new IndexFieldsControl (this, ResId(CTR_FIELDS)))
+ ,m_aClose (this, ResId(PB_CLOSE))
+ ,m_pIndexes(NULL)
+ ,m_pPreviousSelection(NULL)
+ ,m_xORB(_rxORB)
+ {
+ FreeResource();
+
+ m_aActions.SetOutStyle(TOOLBOX_STYLE_FLAT);
+ // TODO: need the global application style for this ....
+ m_aActions.SetSelectHdl(LINK(this, DbaIndexDialog, OnIndexAction));
+
+ m_aIndexes.SetSelectHdl(LINK(this, DbaIndexDialog, OnIndexSelected));
+ m_aIndexes.SetEndEditHdl(LINK(this, DbaIndexDialog, OnEntryEdited));
+ m_aIndexes.SetSelectionMode(SINGLE_SELECTION);
+ m_aIndexes.SetHighlightRange();
+ m_pFields->Init(_rFieldNames);
+
+ m_pIndexes = new OIndexCollection(_rxIndexes);
+ fillIndexList();
+
+ m_aUnique.SetClickHdl(LINK(this, DbaIndexDialog, OnModified));
+ m_pFields->SetModifyHdl(LINK(this, DbaIndexDialog, OnModified));
+
+ m_aClose.SetClickHdl(LINK(this, DbaIndexDialog, OnCloseDialog));
+
+ // get our most recent geometry settings
+// if (m_aGeometrySettings.Exists())
+// {
+// Point aPos;
+// m_aGeometrySettings.GetPosition(aPos.X(), aPos.Y());
+// SetPosPixel(aPos);
+// }
+
+ // if all of the indexes have an empty description, we're not interested in displaying it
+ for ( OIndexCollection::const_iterator aCheck = m_pIndexes->begin();
+ aCheck != m_pIndexes->end();
+ ++aCheck
+ )
+ {
+ if (aCheck->sDescription.getLength())
+ break;
+ }
+
+ if (aCheck == m_pIndexes->end())
+ {
+ sal_Int32 nMoveUp = m_aUnique.GetPosPixel().Y() - m_aDescriptionLabel.GetPosPixel().Y();
+
+ // hide the controls which are necessary for the description
+ m_aDescription.Hide();
+ m_aDescriptionLabel.Hide();
+
+ // move other controls up
+ Point aPos = m_aUnique.GetPosPixel();
+ aPos.Y() -= nMoveUp;
+ m_aUnique.SetPosPixel(aPos);
+
+ aPos = m_aFieldsLabel.GetPosPixel();
+ aPos.Y() -= nMoveUp;
+ m_aFieldsLabel.SetPosPixel(aPos);
+
+ aPos = m_pFields->GetPosPixel();
+ aPos.Y() -= nMoveUp;
+ m_pFields->SetPosPixel(aPos);
+
+ // and enlarge the fields list
+ Size aSize = m_pFields->GetSizePixel();
+ aSize.Height() += nMoveUp;
+ m_pFields->SetSizePixel(aSize);
+ }
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::updateToolbox()
+ {
+ m_aActions.EnableItem(ID_INDEX_NEW, !m_aIndexes.IsEditingActive());
+
+ SvLBoxEntry* pSelected = m_aIndexes.FirstSelected();
+ sal_Bool bSelectedAnything = NULL != pSelected;
+ m_aActions.EnableItem(ID_INDEX_DROP, bSelectedAnything);
+ m_aActions.EnableItem(ID_INDEX_RENAME, bSelectedAnything);
+
+ if (pSelected)
+ {
+ // is the current entry modified?
+ OIndexCollection::const_iterator aSelectedPos = reinterpret_cast<OIndexCollection::const_iterator>(pSelected->GetUserData());
+ m_aActions.EnableItem(ID_INDEX_SAVE, aSelectedPos->isModified() || aSelectedPos->isNew());
+ m_aActions.EnableItem(ID_INDEX_RESET, aSelectedPos->isModified() && !aSelectedPos->isNew());
+ }
+ else
+ {
+ m_aActions.EnableItem(ID_INDEX_SAVE, sal_False);
+ m_aActions.EnableItem(ID_INDEX_RESET, sal_False);
+ }
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::fillIndexList()
+ {
+ Image aPKeyIcon(ModuleRes(IMG_PKEYICON));
+ // fill the list with the index names
+ m_aIndexes.Clear();
+ OIndexCollection::iterator aIndexLoop = m_pIndexes->begin();
+ OIndexCollection::iterator aEnd = m_pIndexes->end();
+ for (; aIndexLoop != aEnd; ++aIndexLoop)
+ {
+ SvLBoxEntry* pNewEntry = NULL;
+ if (aIndexLoop->bPrimaryKey)
+ pNewEntry = m_aIndexes.InsertEntry(aIndexLoop->sName, aPKeyIcon, aPKeyIcon);
+ else
+ pNewEntry = m_aIndexes.InsertEntry(aIndexLoop->sName);
+
+ pNewEntry->SetUserData(aIndexLoop);
+ }
+
+ OnIndexSelected(&m_aIndexes);
+ }
+
+ //------------------------------------------------------------------
+ DbaIndexDialog::~DbaIndexDialog( )
+ {
+ delete m_pIndexes;
+ delete m_pFields;
+
+ // save our geometry settings
+// Point aPos = GetPosPixel();
+// m_aGeometrySettings.SetPosition(aPos.X(), aPos.Y());
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool DbaIndexDialog::implCommit(SvLBoxEntry* _pEntry)
+ {
+ DBG_ASSERT(_pEntry, "DbaIndexDialog::implCommit: invalid entry!");
+
+ OIndexCollection::iterator aCommitPos = static_cast< OIndexCollection::iterator >(_pEntry->GetUserData());
+
+ // if it's not a new index, remove it
+ // (we can't modify indexes, only drop'n'insert)
+ if (!aCommitPos->isNew())
+ if (!implDropIndex(_pEntry, sal_False))
+ return sal_False;
+
+ // create the new index
+ SQLExceptionInfo aExceptionInfo;
+ try
+ {
+ m_pIndexes->commitNewIndex(aCommitPos);
+ }
+ catch(SQLContext& e) { aExceptionInfo = SQLExceptionInfo(e); }
+ catch(SQLWarning& e) { aExceptionInfo = SQLExceptionInfo(e); }
+ catch(SQLException& e) { aExceptionInfo = SQLExceptionInfo(e); }
+
+ // reflect the new selection in the toolbox
+ updateToolbox();
+
+ if (aExceptionInfo.isValid())
+ showError(aExceptionInfo, this, m_xORB);
+
+ return !aExceptionInfo.isValid();
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::OnNewIndex()
+ {
+ // commit the current entry, if necessary
+ if (!implCommitPreviouslySelected())
+ return;
+
+ // get a new unique name for the new index
+ String sNewIndexName;
+ const String sNewIndexNameBase(ModuleRes(STR_LOGICAL_INDEX_NAME));
+ for (sal_Int32 i=1; i<0x7FFFFFFF; ++i)
+ {
+ sNewIndexName = sNewIndexNameBase;
+ sNewIndexName += String::CreateFromInt32(i);
+ if (m_pIndexes->end() == m_pIndexes->find(sNewIndexName))
+ break;
+ }
+ if ((i>0x7FFFFFFF) || (i<0))
+ {
+ DBG_ERROR("DbaIndexDialog::OnNewIndex: no free index name found!");
+ // can't do anything ... of course we try another base, but this could end with the same result ...
+ return;
+ }
+
+ SvLBoxEntry* pNewEntry = m_aIndexes.InsertEntry(sNewIndexName);
+ OIndexCollection::iterator aIndexDescriptor = m_pIndexes->insert(sNewIndexName);
+ pNewEntry->SetUserData(aIndexDescriptor);
+
+ // select the entry and start in-place editing
+ m_aIndexes.SelectNoHandlerCall(pNewEntry);
+ OnIndexSelected(&m_aIndexes);
+ m_aIndexes.EditEntry(pNewEntry);
+ updateToolbox();
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::OnDropIndex()
+ {
+ // the selected index
+ SvLBoxEntry* pSelected = m_aIndexes.FirstSelected();
+ DBG_ASSERT(pSelected, "DbaIndexDialog::OnDropIndex: invalid call!");
+ if (pSelected)
+ {
+ // let the user confirm the drop
+ String sConfirm(ModuleRes(STR_CONFIRM_DROP_INDEX));
+ sConfirm.SearchAndReplaceAscii("$name$", m_aIndexes.GetEntryText(pSelected));
+ QueryBox aConfirm(this, WB_YES_NO, sConfirm);
+ if (RET_YES != aConfirm.Execute())
+ return;
+
+ // do the drop
+ implDropIndex(pSelected, sal_True);
+
+ // reflect the new selection in the toolbox
+ updateToolbox();
+ }
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool DbaIndexDialog::implDropIndex(SvLBoxEntry* _pEntry, sal_Bool _bRemoveFromCollection)
+ {
+ // do the drop
+ OIndexCollection::iterator aDropPos = static_cast< OIndexCollection::iterator >(_pEntry->GetUserData());
+ DBG_ASSERT(aDropPos != m_pIndexes->end(), "DbaIndexDialog::OnDropIndex: did not find the index in my collection!");
+
+ SQLExceptionInfo aExceptionInfo;
+ sal_Bool bNewIndex = aDropPos->isNew();
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ if (_bRemoveFromCollection)
+ bSuccess = m_pIndexes->drop(aDropPos);
+ else
+ bSuccess = m_pIndexes->dropNoRemove(aDropPos);
+ }
+ catch(SQLContext& e) { aExceptionInfo = SQLExceptionInfo(e); }
+ catch(SQLWarning& e) { aExceptionInfo = SQLExceptionInfo(e); }
+ catch(SQLException& e) { aExceptionInfo = SQLExceptionInfo(e); }
+
+ if (aExceptionInfo.isValid())
+ showError(aExceptionInfo, this, m_xORB);
+ else if (bSuccess && _bRemoveFromCollection)
+ {
+ SvLBoxTreeList* pModel = m_aIndexes.GetModel();
+
+ m_aIndexes.disableSelectHandler();
+ pModel->Remove(_pEntry);
+ m_aIndexes.enableSelectHandler();
+
+ // update the user data on the entries in the list box:
+ // they're iterators of the index collection, and thus they have changed when removing the index
+ for (SvLBoxEntry* pAdjust = m_aIndexes.First(); pAdjust; pAdjust = m_aIndexes.Next(pAdjust))
+ {
+ OIndexCollection::iterator aAfterDropPos = m_pIndexes->find(m_aIndexes.GetEntryText(pAdjust));
+ DBG_ASSERT(aAfterDropPos != m_pIndexes->end(), "DbaIndexDialog::OnDropIndex: problems with on of the remaining entries!");
+ pAdjust->SetUserData(aAfterDropPos);
+ }
+
+ // if the remvoved entry was the selected on ...
+ if (m_pPreviousSelection == _pEntry)
+ m_pPreviousSelection = NULL;
+
+ // the Remove automatically selected another entry (if possible), but we disabled the calling of the handler
+ // to prevent that we missed something ... call the handler directly
+ OnIndexSelected(&m_aIndexes);
+ }
+
+ return !aExceptionInfo.isValid();
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::OnRenameIndex()
+ {
+ // the selected index
+ SvLBoxEntry* pSelected = m_aIndexes.FirstSelected();
+ DBG_ASSERT(pSelected, "DbaIndexDialog::OnRenameIndex: invalid call!");
+
+ // save the changes made 'til here
+ // Upon leaving the edit mode, the control will be re-initialized with the
+ // settings from the current entry
+ implSaveModified();
+
+ m_aIndexes.EditEntry(pSelected);
+ updateToolbox();
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::OnSaveIndex()
+ {
+ // the selected index
+ SvLBoxEntry* pSelected = m_aIndexes.FirstSelected();
+ DBG_ASSERT(pSelected, "DbaIndexDialog::OnSaveIndex: invalid call!");
+
+ implCommitPreviouslySelected();
+ updateToolbox();
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::OnResetIndex()
+ {
+ // the selected index
+ SvLBoxEntry* pSelected = m_aIndexes.FirstSelected();
+ DBG_ASSERT(pSelected, "DbaIndexDialog::OnResetIndex: invalid call!");
+
+ OIndexCollection::iterator aResetPos = static_cast< OIndexCollection::iterator >(pSelected->GetUserData());
+
+ SQLExceptionInfo aExceptionInfo;
+ try
+ {
+ m_pIndexes->resetIndex(aResetPos);
+ }
+ catch(SQLContext& e) { aExceptionInfo = SQLExceptionInfo(e); }
+ catch(SQLWarning& e) { aExceptionInfo = SQLExceptionInfo(e); }
+ catch(SQLException& e) { aExceptionInfo = SQLExceptionInfo(e); }
+
+ if (aExceptionInfo.isValid())
+ showError(aExceptionInfo, this, m_xORB);
+ else
+ m_aIndexes.SetEntryText(pSelected, aResetPos->sName);
+
+ updateControls(pSelected);
+ updateToolbox();
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DbaIndexDialog, OnIndexAction, ToolBox*, NOTINTERESTEDIN )
+ {
+ sal_uInt16 nClicked = m_aActions.GetCurItemId();
+ switch (nClicked)
+ {
+ case ID_INDEX_NEW:
+ OnNewIndex();
+ break;
+ case ID_INDEX_DROP:
+ OnDropIndex();
+ break;
+ case ID_INDEX_RENAME:
+ OnRenameIndex();
+ break;
+ case ID_INDEX_SAVE:
+ OnSaveIndex();
+ break;
+ case ID_INDEX_RESET:
+ OnResetIndex();
+ break;
+ }
+ return 0L;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DbaIndexDialog, OnCloseDialog, void*, NOTINTERESTEDIN )
+ {
+ // the currently selected entry
+ const SvLBoxEntry* pSelected = m_aIndexes.FirstSelected();
+ DBG_ASSERT(pSelected, "DbaIndexDialog::OnCloseDialog: invalid call!");
+ DBG_ASSERT(pSelected == m_pPreviousSelection, "DbaIndexDialog::OnCloseDialog: inconsistence!");
+
+ // the descriptor
+ OIndexCollection::const_iterator aSelected = static_cast<OIndexCollection::const_iterator>(pSelected->GetUserData());
+ if (aSelected->isModified() || aSelected->isNew())
+ {
+ QueryBox aQuestion(this, ModuleRes(QUERY_SAVE_CURRENT_INDEX));
+ switch (aQuestion.Execute())
+ {
+ case RET_YES:
+ if (!implCommitPreviouslySelected())
+ return 1;
+ break;
+ case RET_NO:
+ break;
+ default:
+ return 1L;
+ }
+ }
+
+ EndDialog(RET_OK);
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DbaIndexDialog, OnEntryEdited, SvLBoxEntry*, _pEntry )
+ {
+ OIndexCollection::iterator aPosition = static_cast< OIndexCollection::iterator >(_pEntry->GetUserData());
+ DBG_ASSERT(aPosition >= m_pIndexes->begin() && aPosition < m_pIndexes->end(),
+ "DbaIndexDialog::OnEntryEdited: invalid entry!");
+
+ // rename can be done by a drop/insert combination only
+ if (aPosition->isNew())
+ {
+ updateToolbox();
+ // no commitment needed here ....
+ return 0L;
+ }
+
+ aPosition->sName = m_aIndexes.GetEntryText(_pEntry);
+ if (aPosition->sName != aPosition->getOriginalName())
+ {
+ aPosition->setModified(sal_True);
+ updateToolbox();
+ }
+
+ return 1L;
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool DbaIndexDialog::implSaveModified()
+ {
+ if (m_pPreviousSelection)
+ {
+ // try to commit the previously selected index
+ if (!m_pFields->SaveModified())
+ return sal_False;
+
+ OIndexCollection::iterator aPreviouslySelected = static_cast<OIndexCollection::iterator>(m_pPreviousSelection->GetUserData());
+
+ // the unique flag
+ if (m_aUnique.GetSavedValue() != m_aUnique.GetState())
+ {
+ aPreviouslySelected->setModified(sal_True);
+ aPreviouslySelected->bUnique = m_aUnique.IsChecked();
+ }
+
+ // the fields
+ m_pFields->commitTo(aPreviouslySelected->aFields);
+ if (m_pFields->GetSavedValue() != aPreviouslySelected->aFields)
+ aPreviouslySelected->setModified(sal_True);
+
+ // check for correctness
+ if (0 == aPreviouslySelected->aFields.size())
+ {
+ ErrorBox aError(this, ModuleRes(ERR_NEED_INDEX_FIELDS));
+ aError.Execute();
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool DbaIndexDialog::implCommitPreviouslySelected()
+ {
+ if (m_pPreviousSelection)
+ {
+ OIndexCollection::iterator aPreviouslySelected = static_cast<OIndexCollection::iterator>(m_pPreviousSelection->GetUserData());
+
+ if (!implSaveModified())
+ return sal_False;
+
+ // commit the index (if necessary)
+ if (aPreviouslySelected->isModified() && !implCommit(m_pPreviousSelection))
+ return sal_False;
+ }
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DbaIndexDialog, OnModified, void*, NOTINTERESTEDIN )
+ {
+ DBG_ASSERT(m_pPreviousSelection, "DbaIndexDialog, OnModified: invalid call!");
+ OIndexCollection::iterator aPosition = static_cast< OIndexCollection::iterator >(m_pPreviousSelection->GetUserData());
+
+ aPosition->setModified(sal_True);
+ updateToolbox();
+
+ return 1L;
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::updateControls(const SvLBoxEntry* _pEntry)
+ {
+ if (_pEntry)
+ {
+ // the descriptor of the selected index
+ OIndexCollection::const_iterator aSelectedIndex = static_cast<OIndexCollection::const_iterator>(_pEntry->GetUserData());
+
+ // fill the controls
+ m_aUnique.Check(aSelectedIndex->bUnique);
+ m_aUnique.Enable(!aSelectedIndex->bPrimaryKey);
+ m_aUnique.SaveValue();
+
+ m_pFields->initializeFrom(aSelectedIndex->aFields);
+ m_pFields->Enable(!aSelectedIndex->bPrimaryKey);
+ m_pFields->SaveValue();
+
+ m_aDescription.SetText(aSelectedIndex->sDescription);
+ m_aDescription.Enable(!aSelectedIndex->bPrimaryKey);
+
+ m_aDescriptionLabel.Enable(!aSelectedIndex->bPrimaryKey);
+ }
+ else
+ {
+ m_aUnique.Check(sal_False);
+ m_pFields->initializeFrom(IndexFields());
+ m_aDescription.SetText(String());
+ }
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DbaIndexDialog, OnIndexSelected, DbaIndexList*, NOTINTERESTEDIN )
+ {
+ m_aIndexes.EndSelection();
+
+ if (m_aIndexes.IsEditingActive())
+ m_aIndexes.EndEditing(sal_True);
+
+ // commit the old data
+ if (m_aIndexes.FirstSelected() != m_pPreviousSelection)
+ { // (this call may happen in case somebody ended an in-place edit with 'return', so we need to check this before committing)
+ if (!implCommitPreviouslySelected())
+ {
+ m_aIndexes.SelectNoHandlerCall(m_pPreviousSelection);
+ return 1L;
+ }
+ }
+
+ sal_Bool bHaveSelection = (NULL != m_aIndexes.FirstSelected());
+
+ // disable/enable the detail controls
+ m_aIndexDetails.Enable(bHaveSelection);
+ m_aUnique.Enable(bHaveSelection);
+ m_aDescriptionLabel.Enable(bHaveSelection);
+ m_aFieldsLabel.Enable(bHaveSelection);
+ m_pFields->Enable(bHaveSelection);
+
+ SvLBoxEntry* pNewSelection = m_aIndexes.FirstSelected();
+ updateControls(pNewSelection);
+ if (bHaveSelection)
+ m_aIndexes.GrabFocus();
+
+ m_pPreviousSelection = pNewSelection;
+
+ updateToolbox();
+ return 0L;
+ }
+
+//......................................................................
+} // namespace dbaui
+//......................................................................
+
+/*************************************************************************
+ * history:
+ * $Log: not supported by cvs2svn $
+ *
+ * Revision 1.0 07.03.01 12:16:06 fs
+ ************************************************************************/
+
diff --git a/dbaccess/source/ui/dlg/indexdialog.hrc b/dbaccess/source/ui/dlg/indexdialog.hrc
new file mode 100644
index 000000000000..28e5d1794d3a
--- /dev/null
+++ b/dbaccess/source/ui/dlg/indexdialog.hrc
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * $RCSfile: indexdialog.hrc,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: fs $ $Date: 2001-03-16 16:23: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 EXPRESS 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_INDEXDIALOG_HRC_
+#define _DBAUI_INDEXDIALOG_HRC_
+
+
+#define CTR_INDEXLIST 1
+#define CTR_FIELDS 2
+
+#define FL_INDEXDETAILS 1
+
+#define CB_UNIQUE 1
+
+#define FT_FIELDS 1
+#define FT_DESC_LABEL 2
+#define FT_DESCRIPTION 3
+
+#define TLB_ACTIONS 1
+
+#define PB_CLOSE 1
+
+
+#define ID_INDEX_NEW 1
+#define ID_INDEX_DROP 2
+#define ID_INDEX_RENAME 3
+#define ID_INDEX_SAVE 4
+#define ID_INDEX_RESET 5
+
+#endif // _DBAUI_INDEXDIALOG_HRC_
+
+/*************************************************************************
+ * history:
+ * $Log: not supported by cvs2svn $
+ *
+ * Revision 1.0 07.03.01 13:10:24 fs
+ ************************************************************************/
+
diff --git a/dbaccess/source/ui/dlg/indexdialog.src b/dbaccess/source/ui/dlg/indexdialog.src
new file mode 100644
index 000000000000..eee4f8a80938
--- /dev/null
+++ b/dbaccess/source/ui/dlg/indexdialog.src
@@ -0,0 +1,360 @@
+/*************************************************************************
+ *
+ * $RCSfile: indexdialog.src,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: fs $ $Date: 2001-03-16 16:23:18 $
+ *
+ * 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 EXPRESS 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 _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+#ifndef _DBAUI_INDEXDIALOG_HRC_
+#include "indexdialog.hrc"
+#endif
+
+#define DIALOG_SIZE_X 220
+#define DIALOG_SIZE_Y 140
+#define BUTTON_SIZE_X 50
+#define BUTTON_SIZE_Y 14
+
+#define LIST_WIDTH 70
+
+ModalDialog DLG_INDEXDESIGN
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( DIALOG_SIZE_X , DIALOG_SIZE_Y ) ;
+ Text = "Indizes" ;
+ Text [ english ] = "Indexes" ;
+ Text [ english_us ] = "Indexes" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ ToolBox TLB_ACTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( DIALOG_SIZE_X - 14 , 14 ) ;
+ ButtonType = BUTTON_SYMBOL;
+ Align = BOXALIGN_TOP;
+ Customize = FALSE;
+
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = ID_INDEX_NEW;
+ Command = ".index:createNew";
+ ItemBitmap = Bitmap { File = "indexnew_sc.bmp"; };
+ Text = "neuer Index" ;
+ Text [ english ] = "new index" ;
+ Text [ english_us ] = "new index" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = ID_INDEX_DROP;
+ Command = ".index:dropCurrent";
+ ItemBitmap = Bitmap { File = "indexdrop_sc.bmp"; };
+ Text = "aktuellen Index lschen" ;
+ Text [ english ] = "drop current index" ;
+ Text [ english_us ] = "drop current index" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = ID_INDEX_RENAME;
+ Command = ".index:renameCurrent";
+ ItemBitmap = Bitmap { File = "indexrename_sc.bmp"; };
+ Text = "aktuellen Index umbenennen" ;
+ Text [ english ] = "rename current index" ;
+ Text [ english_us ] = "rename current index" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = ID_INDEX_SAVE;
+ Command = ".index:saveCurrent";
+ ItemBitmap = Bitmap { File = "indexsave_sc.bmp"; };
+ Text = "aktuellen Index speichern" ;
+ Text [ english ] = "save current index" ;
+ Text [ english_us ] = "save current index" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = ID_INDEX_RESET;
+ Command = ".index:resetCurrent";
+ ItemBitmap = Bitmap { File = "indexreset_sc.bmp"; };
+ Text = "aktuellen Index zurcksetzen" ;
+ Text [ english ] = "reset current index" ;
+ Text [ english_us ] = "reset current index" ;
+ };
+ };
+ };
+ Control CTR_INDEXLIST
+ {
+ Pos = MAP_APPFONT ( 6 , 23 ) ;
+ Size = MAP_APPFONT ( LIST_WIDTH , DIALOG_SIZE_Y - (BUTTON_SIZE_Y + 4) - 29 ) ;
+ SVLook = TRUE;
+ Border = TRUE;
+ };
+ FixedLine FL_INDEXDETAILS
+ {
+ Pos = MAP_APPFONT ( LIST_WIDTH + 16 - 3, 9 ) ;
+ Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 22, 8 ) ;
+ Text = "Index-Details";
+ Text [ english ] = "Index details";
+ Text [ english_us ] = "Index details";
+ };
+ FixedText FT_DESC_LABEL
+ {
+ Pos = MAP_APPFONT ( LIST_WIDTH + 16, 23 ) ;
+ Size = MAP_APPFONT ( 50, 8 ) ;
+ Text = "Indexbezeichner:";
+ Text [ english ] = "Index identifier:";
+ Text [ english_us ] = "Index identifier:";
+ Text [ portuguese_brazilian ] = "Indexbezeichner:";
+ Text [ swedish ] = "Indexnamn:";
+ Text [ danish ] = "Indeksidentifikator:";
+ Text [ italian ] = "Identificatore indice:";
+ Text [ spanish ] = "Identificador de ndice:";
+ Text [ french ] = "Identificateur d'index:";
+ Text [ dutch ] = "Indexidentificator:";
+ Text [ portuguese ] = "Identificador de ndice:";
+ Text [ chinese_simplified ] = "־:";
+ Text [ russian ] = " :";
+ Text [ polish ] = "Identyfikator indeksu:";
+ Text [ japanese ] = "ޯ̊mF:";
+ Text [ chinese_traditional ] = "޼лx:";
+ Text [ arabic ] = " :";
+ Text [ dutch ] = "Indexidentificator:";
+ Text [ chinese_simplified ] = "־:";
+ Text [ greek ] = " :";
+ Text [ korean ] = "ε Ȯ:";
+ };
+ FixedText FT_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( LIST_WIDTH + 69, 23 ) ;
+ Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 75, 8 ) ;
+ };
+ CheckBox CB_UNIQUE
+ {
+ Pos = MAP_APPFONT ( LIST_WIDTH + 16, 34 ) ;
+ Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 22, 8 ) ;
+ SVLook = TRUE;
+ Text = "Eindeutig";
+ Text [ english ] = "Unique";
+ Text [ english_us ] = "Unique";
+ };
+ FixedText FT_FIELDS
+ {
+ Pos = MAP_APPFONT ( LIST_WIDTH + 16, 48 ) ;
+ Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 22, 8 ) ;
+ SVLook = TRUE;
+ Text = "Felder";
+ Text [ english ] = "Fields";
+ Text [ english_us ] = "Fields";
+ };
+ Control CTR_FIELDS
+ {
+ Pos = MAP_APPFONT ( LIST_WIDTH + 16, 59 ) ;
+ Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 22, DIALOG_SIZE_Y - (BUTTON_SIZE_Y + 4) - 65 ) ;
+ SVLook = TRUE;
+ Border = TRUE;
+ };
+ PushButton PB_CLOSE
+ {
+ Pos = MAP_APPFONT ( DIALOG_SIZE_X - BUTTON_SIZE_X - 6, DIALOG_SIZE_Y - BUTTON_SIZE_Y - 6 ) ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X, BUTTON_SIZE_Y );
+ SVLook = TRUE;
+ DefButton = TRUE;
+ Text = "S~chlieen";
+ Text [ english ] = "~Close";
+ Text [ english_us ] = "~Close";
+ };
+};
+
+String STR_TAB_INDEX_SORTORDER
+{
+ Text = "Sortierreihenfolge" ;
+ Text [ english ] = "Sort order" ;
+ Text [ english_us ] = "Sort order" ;
+ Text [ dutch ] = "Sorteervolgorde" ;
+ Text [ italian ] = "Sequenza di ordine" ;
+ Text [ spanish ] = "Orden de clasificacin" ;
+ Text [ french ] = "Ordre de tri" ;
+ Text [ swedish ] = "Sorteringsordning" ;
+ Text [ danish ] = "Sorteringsrkkeflge" ;
+ Text [ portuguese_brazilian ] = "Sortierreihenfolge" ;
+ Text [ portuguese ] = "Ordem de classificao" ;
+ Text [ chinese_simplified ] = "";
+ Text [ russian ] = " ";
+ Text [ polish ] = "Kolejno sortowania";
+ Text [ japanese ] = "בւ̏";
+ Text [ chinese_traditional ] = "ƧdzWh";
+ Text [ arabic ] = " ";
+ Text [ dutch ] = "Sorteervolgorde";
+ Text [ chinese_simplified ] = "";
+ Text [ greek ] = " ";
+ Text [ korean ] = "ļ";
+};
+String STR_TAB_INDEX_FIELD
+{
+ Text = "Indexfeld" ;
+ Text [ english ] = "Index field" ;
+ Text [ english_us ] = "Index field" ;
+};
+String STR_ORDER_ASCENDING
+{
+ Text = "Aufsteigend" ;
+ Text [ english ] = "Ascending" ;
+ Text [ dutch ] = "Oplopend" ;
+ Text [ english_us ] = "Ascending" ;
+ Text [ italian ] = "Crescente" ;
+ Text [ spanish ] = "Ascendente" ;
+ Text [ french ] = "Croissant" ;
+ Text [ swedish ] = "Stigande" ;
+ Text [ danish ] = "Stigende" ;
+ Text [ portuguese_brazilian ] = "Aufsteigend" ;
+ Text [ portuguese ] = "Ascendente" ;
+ Text [ chinese_simplified ] = "";
+ Text [ russian ] = " ";
+ Text [ polish ] = "Rosnco";
+ Text [ japanese ] = "";
+ Text [ chinese_traditional ] = "VW";
+ Text [ arabic ] = "";
+ Text [ dutch ] = "Oplopend";
+ Text [ chinese_simplified ] = "";
+ Text [ greek ] = "";
+ Text [ korean ] = " ";
+};
+String STR_ORDER_DESCENDING
+{
+ Text = "Absteigend" ;
+ Text [ english ] = "Descending" ;
+ Text [ english_us ] = "Descending" ;
+ Text [ italian ] = "Decrescente" ;
+ Text [ spanish ] = "Descendente" ;
+ Text [ french ] = "Dcroissant" ;
+ Text [ dutch ] = "Aflopend" ;
+ Text [ swedish ] = "Fallande" ;
+ Text [ danish ] = "Faldende" ;
+ Text [ portuguese_brazilian ] = "Absteigend" ;
+ Text [ portuguese ] = "Descendente" ;
+ Text [ chinese_simplified ] = "";
+ Text [ russian ] = " ";
+ Text [ polish ] = "Malejco";
+ Text [ japanese ] = "~";
+ Text [ chinese_traditional ] = "VU";
+ Text [ arabic ] = "";
+ Text [ dutch ] = "Aflopend";
+ Text [ chinese_simplified ] = "";
+ Text [ greek ] = "";
+ Text [ korean ] = "";
+};
+
+String STR_CONFIRM_DROP_INDEX
+{
+ Text = "Wollen Sie den Index '$name$' wirklich lschen?";
+ Text [ english ] = "Do you really want to drop the index '$name$'?";
+ Text [ english_us ] = "Do you really want to drop the index '$name$'?";
+};
+
+String STR_LOGICAL_INDEX_NAME
+{
+ Text = "index";
+ Text [ english ] = "index";
+ Text [ english_us ] = "index";
+ Text [ language_user1 ] = "This is a logical name only. It should be the word for 'Index' (in a database sense), but written in lower case (if appliable to your language :).";
+};
+
+Image IMG_PKEYICON
+{
+ ImageBitmap = Bitmap { File = "pkey.bmp"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+
+ErrorBox ERR_NEED_INDEX_FIELDS
+{
+ Title = "Index speichern";
+ Title [ english ] = "Save Index";
+ Title [ english_us ] = "Save Index";
+
+ Message = "Der Index mu mindestens ein Feld enthalten.";
+ Message [ english ] = "Der Index mu mindestens ein Feld enthalten.";
+ Message [ english_us ] = "Der Index mu mindestens ein Feld enthalten.";
+
+ Buttons = WB_OK;
+};
+
+QueryBox QUERY_SAVE_CURRENT_INDEX
+{
+ Title = "Index-Entwurf verlassen";
+ Title [ english ] = "close index design";
+ Title [ english_us ] = "close index design";
+
+ Message = "Wollen Sie die nderungen am aktuellen Index noch speichern?";
+ Message [ english ] = "Do you want to save the changes made on the current index?";
+ Message [ english_us ] = "Do you want to save the changes made on the current index?";
+
+ Buttons = WB_YES_NO_CANCEL;
+ DefButton = WB_DEF_YES;
+};
+
+/*************************************************************************
+ * history:
+ * $Log: not supported by cvs2svn $
+ *
+ * Revision 1.0 07.03.01 12:17:10 fs
+ ************************************************************************/
+
diff --git a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx
new file mode 100644
index 000000000000..3818103c5c1f
--- /dev/null
+++ b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx
@@ -0,0 +1,511 @@
+/*************************************************************************
+ *
+ * $RCSfile: indexfieldscontrol.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: fs $ $Date: 2001-03-16 16:23:31 $
+ *
+ * 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 EXPRESS 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_INDEXFIELDSCONTROL_HXX_
+#include "indexfieldscontrol.hxx"
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+//......................................................................
+namespace dbaui
+{
+//......................................................................
+
+#define BROWSER_STANDARD_FLAGS BROWSER_COLUMNSELECTION | BROWSER_HLINESFULL | BROWSER_VLINESFULL | \
+ BROWSER_HIDECURSOR | BROWSER_HIDESELECT | BROWSER_AUTO_HSCROLL | BROWSER_AUTO_VSCROLL
+
+#define COLUMN_ID_FIELDNAME 1
+#define COLUMN_ID_ORDER 2
+
+ using namespace ::com::sun::star::uno;
+
+ //==================================================================
+ //= DbaMouseDownListBoxController
+ //==================================================================
+ class DbaMouseDownListBoxController : public DbListBoxCellController
+ {
+ protected:
+ Link m_aOriginalModifyHdl;
+ Link m_aAdditionalModifyHdl;
+
+ public:
+ DbaMouseDownListBoxController(DbListBoxCtrl* _pParent)
+ :DbListBoxCellController(_pParent)
+ {
+ }
+
+ void SetAdditionalModifyHdl(const Link& _rHdl);
+
+ protected:
+ virtual sal_Bool WantMouseEvent() const { return sal_True; }
+ virtual void SetModifyHdl(const Link& _rHdl);
+
+ private:
+ void implCheckLinks();
+ DECL_LINK( OnMultiplexModify, void* );
+ };
+
+ //------------------------------------------------------------------
+ void DbaMouseDownListBoxController::SetAdditionalModifyHdl(const Link& _rHdl)
+ {
+ m_aAdditionalModifyHdl = _rHdl;
+ implCheckLinks();
+ }
+
+ //------------------------------------------------------------------
+ void DbaMouseDownListBoxController::SetModifyHdl(const Link& _rHdl)
+ {
+ m_aOriginalModifyHdl = _rHdl;
+ implCheckLinks();
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DbaMouseDownListBoxController, OnMultiplexModify, void*, _pArg )
+ {
+ if (m_aAdditionalModifyHdl.IsSet())
+ m_aAdditionalModifyHdl.Call(_pArg);
+ if (m_aOriginalModifyHdl.IsSet())
+ m_aOriginalModifyHdl.Call(_pArg);
+ return 0L;
+ }
+
+ //------------------------------------------------------------------
+ void DbaMouseDownListBoxController::implCheckLinks()
+ {
+ if (m_aAdditionalModifyHdl.IsSet() || m_aOriginalModifyHdl.IsSet())
+ DbListBoxCellController::SetModifyHdl(LINK(this, DbaMouseDownListBoxController, OnMultiplexModify));
+ else
+ DbListBoxCellController::SetModifyHdl(Link());
+ }
+
+ //==================================================================
+ //= IndexFieldsControl
+ //==================================================================
+ //------------------------------------------------------------------
+ IndexFieldsControl::IndexFieldsControl( Window* _pParent, const ResId& _rId )
+ :DbBrowseBox(_pParent, _rId, DBBF_ACTIVATE_ON_BUTTONDOWN, BROWSER_STANDARD_FLAGS)
+ ,m_aSeekRow(m_aFields.end())
+ ,m_pSortingCell(NULL)
+ ,m_pFieldNameCell(NULL)
+ {
+ }
+
+ //------------------------------------------------------------------
+ IndexFieldsControl::~IndexFieldsControl()
+ {
+ delete m_pSortingCell;
+ delete m_pFieldNameCell;
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool IndexFieldsControl::SeekRow(long nRow)
+ {
+ if (!DbBrowseBox::SeekRow(nRow))
+ return sal_False;
+
+ if (nRow < 0)
+ {
+ m_aSeekRow = m_aFields.end();
+ }
+ else
+ {
+ m_aSeekRow = m_aFields.begin() + nRow;
+ OSL_ENSURE(m_aSeekRow <= m_aFields.end(), "IndexFieldsControl::SeekRow: invalid row!");
+ }
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ void IndexFieldsControl::PaintCell( OutputDevice& _rDev, const Rectangle& _rRect, sal_uInt16 _nColumnId ) const
+ {
+ Point aPos(_rRect.TopLeft());
+ aPos.X() += 1;
+
+ String aText = GetCurrentRowCellText(_nColumnId);
+ Size TxtSize(GetDataWindow().GetTextWidth(aText), GetDataWindow().GetTextHeight());
+
+ // clipping
+ if (aPos.X() < _rRect.Right() || aPos.X() + TxtSize.Width() > _rRect.Right() ||
+ aPos.Y() < _rRect.Top() || aPos.Y() + TxtSize.Height() > _rRect.Bottom())
+ _rDev.SetClipRegion( _rRect );
+
+ // allow for a disabled control ...
+ sal_Bool bEnabled = IsEnabled();
+ Color aOriginalColor = _rDev.GetTextColor();
+ if (!bEnabled)
+ _rDev.SetTextColor(GetSettings().GetStyleSettings().GetDisableColor());
+
+ // draw the text
+ _rDev.DrawText(aPos, aText);
+
+ // reset the color (if necessary)
+ if (!bEnabled)
+ _rDev.SetTextColor(aOriginalColor);
+
+ if (_rDev.IsClipRegion())
+ _rDev.SetClipRegion();
+ }
+
+ //------------------------------------------------------------------
+ void IndexFieldsControl::initializeFrom(const IndexFields& _rFields)
+ {
+ // copy the field descriptions
+ m_aFields = _rFields;
+ m_aSeekRow = m_aFields.end();
+
+ SetUpdateMode(sal_False);
+ // remove all rows
+ RowRemoved(1, GetRowCount());
+ // insert rows for the the fields
+ RowInserted(GetRowCount(), m_aFields.size(), sal_False);
+ // insert an additional row for a new field for that index
+ RowInserted(GetRowCount(), 1, sal_False);
+ SetUpdateMode(sal_True);
+
+ GoToRowColumnId(0, COLUMN_ID_FIELDNAME);
+ }
+
+ //------------------------------------------------------------------
+ void IndexFieldsControl::commitTo(IndexFields& _rFields)
+ {
+ // do not just copy the array, we may have empty field names (which should not be copied)
+ _rFields.resize(m_aFields.size());
+ ConstIndexFieldsIterator aSource = m_aFields.begin();
+ ConstIndexFieldsIterator aSourceEnd = m_aFields.end();
+ IndexFieldsIterator aDest = _rFields.begin();
+ for (; aSource < aSourceEnd; ++aSource)
+ if (0 != aSource->sFieldName.Len())
+ {
+ *aDest = *aSource;
+ ++aDest;
+ }
+
+ _rFields.resize(aDest - _rFields.begin());
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt32 IndexFieldsControl::GetTotalCellWidth(long _nRow, sal_uInt16 _nColId)
+ {
+ if (COLUMN_ID_ORDER == _nColId)
+ {
+ sal_Int32 nWidthAsc = GetTextWidth(m_sAscendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
+ sal_Int32 nWidthDesc = GetTextWidth(m_sDescendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
+ // maximum plus some additional space
+ return (nWidthAsc > nWidthDesc ? nWidthAsc : nWidthDesc) + GetTextWidth('0') * 2;
+ }
+ return DbBrowseBox::GetTotalCellWidth(_nRow, _nColId);
+ }
+
+ //------------------------------------------------------------------
+ void IndexFieldsControl::Init(const Sequence< ::rtl::OUString >& _rAvailableFields)
+ {
+ RemoveColumns();
+
+ m_sAscendingText = String(ModuleRes(STR_ORDER_ASCENDING));
+ m_sDescendingText = String(ModuleRes(STR_ORDER_DESCENDING));
+
+ // the "sort order" column
+ String sColumnName = String(ModuleRes(STR_TAB_INDEX_SORTORDER));
+ // the width of the order column is the maximum widths of the texts used
+ // (the title of the column)
+ sal_Int32 nSortOrderColumnWidth = GetTextWidth(sColumnName);
+ // ("ascending" + scrollbar width)
+ sal_Int32 nOther = GetTextWidth(m_sAscendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
+ nSortOrderColumnWidth = nSortOrderColumnWidth > nOther ? nSortOrderColumnWidth : nOther;
+ // ("descending" + scrollbar width)
+ nOther = GetTextWidth(m_sDescendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
+ nSortOrderColumnWidth = nSortOrderColumnWidth > nOther ? nSortOrderColumnWidth : nOther;
+ // (plus some additional space)
+ nSortOrderColumnWidth += GetTextWidth('0') * 2;
+ InsertDataColumn(COLUMN_ID_ORDER, sColumnName, nSortOrderColumnWidth, HIB_STDSTYLE, 1);
+
+ // for the width: both columns together should be somewhat smaller than the whole window (without the scrollbar)
+ sal_Int32 nFieldNameWidth = GetSizePixel().Width();
+ nFieldNameWidth -= nSortOrderColumnWidth;
+
+ StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
+ nFieldNameWidth -= aSystemStyle.GetScrollBarSize();
+ nFieldNameWidth -= 8;
+
+ // the "field name" column
+ sColumnName = String(ModuleRes(STR_TAB_INDEX_FIELD));
+ InsertDataColumn(COLUMN_ID_FIELDNAME, sColumnName, nFieldNameWidth, HIB_STDSTYLE, 0);
+
+ // create the cell controllers
+ // for the field name cell
+ m_pFieldNameCell = new DbListBoxCtrl(&GetDataWindow());
+ m_pFieldNameCell->InsertEntry(String());
+ const ::rtl::OUString* pFields = _rAvailableFields.getConstArray();
+ const ::rtl::OUString* pFieldsEnd = pFields + _rAvailableFields.getLength();
+ for (;pFields < pFieldsEnd; ++pFields)
+ m_pFieldNameCell->InsertEntry(*pFields);
+ // for the sort cell
+ m_pSortingCell = new DbListBoxCtrl(&GetDataWindow());
+ m_pSortingCell->InsertEntry(m_sAscendingText);
+ m_pSortingCell->InsertEntry(m_sDescendingText);
+ }
+
+ //------------------------------------------------------------------
+ DbCellController* IndexFieldsControl::GetController(long _nRow, sal_uInt16 _nColumnId)
+ {
+ ConstIndexFieldsIterator aRow;
+ sal_Bool bNewField = !implGetFieldDesc(_nRow, aRow);
+
+ DbaMouseDownListBoxController* pReturn = NULL;
+ switch (_nColumnId)
+ {
+ case COLUMN_ID_ORDER:
+ if (!bNewField && m_pSortingCell && 0 != aRow->sFieldName.Len())
+ pReturn = new DbaMouseDownListBoxController(m_pSortingCell);
+ break;
+
+ case COLUMN_ID_FIELDNAME:
+ pReturn = new DbaMouseDownListBoxController(m_pFieldNameCell);
+ break;
+
+ default:
+ OSL_ENSURE(sal_False, "IndexFieldsControl::GetController: invalid column id!");
+ }
+
+ if (pReturn)
+ pReturn->SetAdditionalModifyHdl(LINK(this, IndexFieldsControl, OnListEntrySelected));
+
+ return pReturn;
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool IndexFieldsControl::implGetFieldDesc(long _nRow, ConstIndexFieldsIterator& _rPos)
+ {
+ _rPos = m_aFields.end();
+ if ((_nRow < 0) || (_nRow >= (sal_Int32)m_aFields.size()))
+ return sal_False;
+ _rPos = m_aFields.begin() + _nRow;
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool IndexFieldsControl::SaveModified()
+ {
+ switch (GetCurColumnId())
+ {
+ case COLUMN_ID_FIELDNAME:
+ {
+ String sFieldSelected = m_pFieldNameCell->GetSelectEntry();
+ sal_Bool bEmptySelected = 0 == sFieldSelected.Len();
+ if (isNewField())
+ {
+ if (!bEmptySelected)
+ {
+ // add a new field to the collection
+ OIndexField aNewField;
+ aNewField.sFieldName = sFieldSelected;
+ m_aFields.push_back(aNewField);
+ RowInserted(GetRowCount(), 1, sal_True);
+ }
+ }
+ else
+ {
+ sal_Int32 nRow = GetCurRow();
+ OSL_ENSURE(nRow < (sal_Int32)m_aFields.size(), "IndexFieldsControl::SaveModified: invalid current row!");
+ if (nRow >= 0) // may be -1 in case the control was empty
+ {
+ // remove the field from the selection
+ IndexFieldsIterator aPos = m_aFields.begin() + nRow;
+
+ if (bEmptySelected)
+ {
+ aPos->sFieldName = String();
+
+ // invalidate the row to force repaint
+ Invalidate(GetRowRectPixel(nRow));
+ return sal_True;
+ }
+
+ if (sFieldSelected == aPos->sFieldName)
+ // nothing changed
+ return sal_True;
+
+ aPos->sFieldName = sFieldSelected;
+ }
+ }
+
+ Invalidate(GetRowRectPixel(GetCurRow()));
+ }
+ break;
+ case COLUMN_ID_ORDER:
+ {
+ OSL_ENSURE(!isNewField(), "IndexFieldsControl::SaveModified: why the hell ...!!!");
+ // selected entry
+ sal_uInt16 nPos = m_pSortingCell->GetSelectEntryPos();
+ OSL_ENSURE(LISTBOX_ENTRY_NOTFOUND != nPos, "IndexFieldsControl::SaveModified: how did you get this selection??");
+ // adjust the sort flag in the index field description
+ OIndexField& rCurrentField = m_aFields[GetCurRow()];
+ rCurrentField.bSortAscending = (0 == nPos);
+
+ }
+ break;
+ default:
+ OSL_ENSURE(sal_False, "IndexFieldsControl::SaveModified: invalid column id!");
+ }
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ void IndexFieldsControl::InitController(DbCellControllerRef& _rController, long _nRow, sal_uInt16 _nColumnId)
+ {
+ ConstIndexFieldsIterator aFieldDescription;
+ sal_Bool bNewField = !implGetFieldDesc(_nRow, aFieldDescription);
+
+ switch (_nColumnId)
+ {
+ case COLUMN_ID_FIELDNAME:
+ m_pFieldNameCell->SelectEntry(bNewField ? String() : aFieldDescription->sFieldName);
+ m_pFieldNameCell->SaveValue();
+ break;
+
+ case COLUMN_ID_ORDER:
+ m_pSortingCell->SelectEntry(aFieldDescription->bSortAscending ? m_sAscendingText : m_sDescendingText);
+ m_pSortingCell->SaveValue();
+ break;
+
+ default:
+ OSL_ENSURE(sal_False, "IndexFieldsControl::InitController: invalid column id!");
+ }
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( IndexFieldsControl, OnListEntrySelected, ListBox*, _pBox )
+ {
+ if (!_pBox->IsTravelSelect() && m_aModifyHdl.IsSet())
+ m_aModifyHdl.Call(this);
+
+ if (_pBox == m_pFieldNameCell)
+ { // a field has been selected
+ if (GetCurRow() >= GetRowCount() - 2)
+ { // and we're in one of the last two rows
+ String sSelectedEntry = m_pFieldNameCell->GetSelectEntry();
+ sal_Int32 nCurrentRow = GetCurRow();
+ sal_Int32 nRowCount = GetRowCount();
+
+ OSL_ENSURE(((sal_Int32)(m_aFields.size() + 1)) == nRowCount, "IndexFieldsControl::OnListEntrySelected: inconsistence!");
+
+ if (sSelectedEntry.Len() && (nCurrentRow == nRowCount - 1))
+ { // in the last row, an non-empty string has been selected
+ // -> insert a bew row
+ m_aFields.push_back(OIndexField());
+ RowInserted(GetRowCount(), 1);
+ Invalidate(GetRowRectPixel(nCurrentRow));
+ }
+ else if (!sSelectedEntry.Len() && (nCurrentRow == nRowCount - 2))
+ { // in the (last-1)th row, an empty entry has been selected
+ // -> remove the last row
+ m_aFields.erase(m_aFields.end() - 1);
+ RowRemoved(GetRowCount() - 1, 1);
+ Invalidate(GetRowRectPixel(nCurrentRow));
+ }
+ }
+
+ SaveModified();
+ }
+ return 0L;
+ }
+
+ //------------------------------------------------------------------
+ String IndexFieldsControl::GetCurrentRowCellText(sal_uInt16 nColId) const
+ {
+ if (m_aSeekRow < m_aFields.end())
+ {
+ switch (nColId)
+ {
+ case COLUMN_ID_FIELDNAME:
+ return m_aSeekRow->sFieldName;
+ case COLUMN_ID_ORDER:
+ if (0 == m_aSeekRow->sFieldName.Len())
+ return String();
+ else
+ return m_aSeekRow->bSortAscending ? m_sAscendingText : m_sDescendingText;
+ default:
+ OSL_ENSURE(sal_False, "IndexFieldsControl::GetCurrentRowCellText: invalid column id!");
+ }
+ }
+ return String();
+ }
+
+//......................................................................
+} // namespace dbaui
+//......................................................................
+
+/*************************************************************************
+ * history:
+ * $Log: not supported by cvs2svn $
+ *
+ * Revision 1.0 07.03.01 14:26:26 fs
+ ************************************************************************/
+