summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorOcke Janssen <oj@openoffice.org>2001-03-22 06:54:07 +0000
committerOcke Janssen <oj@openoffice.org>2001-03-22 06:54:07 +0000
commit826e158cb0b1b1363012faffead56eb573208a10 (patch)
tree7fb85e5013bdcc3251610318e252f170d9dc2a9b /dbaccess
parent4af5ea4971233e508e8f8b3df8d89d9398179bd0 (diff)
eanble copy&paste for rows in tabledesign
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx37
-rw-r--r--dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx9
-rw-r--r--dbaccess/source/ui/tabledesign/FieldDescriptions.cxx54
-rw-r--r--dbaccess/source/ui/tabledesign/TEditControl.cxx258
-rw-r--r--dbaccess/source/ui/tabledesign/TEditControl.hxx16
-rw-r--r--dbaccess/source/ui/tabledesign/TableController.cxx126
-rw-r--r--dbaccess/source/ui/tabledesign/TableDesignView.cxx52
-rw-r--r--dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx31
-rw-r--r--dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx13
-rw-r--r--dbaccess/source/ui/tabledesign/TableRow.cxx95
-rw-r--r--dbaccess/source/ui/tabledesign/TableUndo.cxx38
-rw-r--r--dbaccess/source/ui/tabledesign/makefile.mk5
12 files changed, 551 insertions, 183 deletions
diff --git a/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx b/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx
index 59881c64008e..b404a80358b4 100644
--- a/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx
+++ b/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: FieldDescGenWin.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: oj $ $Date: 2001-02-14 14:28:01 $
+ * last change: $Author: oj $ $Date: 2001-03-22 07:54:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -167,13 +167,6 @@ void OFieldDescGenWin::SaveData( OFieldDescription* pFieldDescr )
m_pFieldControl->SaveData(pFieldDescr);
}
//------------------------------------------------------------------------------
-sal_Bool OFieldDescGenWin::ChildHasFocus()
-{
- DBG_CHKTHIS(OFieldDescGenWin,NULL);
-
- return m_pFieldControl->ChildHasFocus();
-}
-//------------------------------------------------------------------------------
void OFieldDescGenWin::GetFocus()
{
DBG_CHKTHIS(OFieldDescGenWin,NULL);
@@ -202,4 +195,30 @@ String OFieldDescGenWin::BoolStringUI(const String& rPersistentString) const
return m_pFieldControl->BoolStringUI(rPersistentString);
}
// -----------------------------------------------------------------------------
+sal_Bool OFieldDescGenWin::isCutAllowed()
+{
+ return (m_pFieldControl && m_pFieldControl->isCutAllowed());
+}
+// -----------------------------------------------------------------------------
+void OFieldDescGenWin::cut()
+{
+ if(m_pFieldControl)
+ m_pFieldControl->cut();
+}
+// -----------------------------------------------------------------------------
+void OFieldDescGenWin::copy()
+{
+ if(m_pFieldControl)
+ m_pFieldControl->copy();
+}
+// -----------------------------------------------------------------------------
+void OFieldDescGenWin::paste()
+{
+ if(m_pFieldControl)
+ m_pFieldControl->paste();
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx b/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx
index dd2384396f64..2c4f8a2156dd 100644
--- a/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx
+++ b/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: FieldDescGenWin.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: oj $ $Date: 2001-02-14 14:24:58 $
+ * last change: $Author: oj $ $Date: 2001-03-22 07:54:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -90,7 +90,6 @@ namespace dbaui
void DisplayData( OFieldDescription* pFieldDescr );
void SaveData( OFieldDescription* pFieldDescr );
- BOOL ChildHasFocus();
void SetControlText( USHORT nControlId, const String& rText );
String GetControlText( USHORT nControlId );
void SetReadOnly( BOOL bReadOnly );
@@ -103,6 +102,10 @@ namespace dbaui
String BoolStringPersistent(const String& rUIString) const;
String BoolStringUI(const String& rPersistentString) const;
+ sal_Bool isCutAllowed();
+ void cut();
+ void copy();
+ void paste();
};
}
#endif // DBAUI_TABLEFIELDDESCGENPAGE_HXX
diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
index 2eb3cce26225..eaca0124afc6 100644
--- a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
+++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: FieldDescriptions.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: oj $ $Date: 2001-02-14 14:26:09 $
+ * last change: $Author: oj $ $Date: 2001-03-22 07:54:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -74,9 +74,20 @@
#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
#include <com/sun/star/sdbc/ColumnValue.hpp>
#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
using namespace dbaui;
using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
//========================================================================
// class OFieldDescription
@@ -92,6 +103,7 @@ OFieldDescription::OFieldDescription() :
,m_nPrecision(0)
,m_pType(NULL)
,m_nIsNullable(ColumnValue::NULLABLE)
+ ,m_nType(DataType::VARCHAR)
{
DBG_CTOR(OFieldDescription,NULL);
}
@@ -110,6 +122,7 @@ OFieldDescription::OFieldDescription( const OFieldDescription& rDescr ) :
,m_eHorJustify(rDescr.m_eHorJustify)
,m_bIsAutoIncrement(rDescr.m_bIsAutoIncrement)
,m_bIsPrimaryKey(rDescr.m_bIsPrimaryKey)
+ ,m_nType(DataType::VARCHAR)
{
DBG_CTOR(OFieldDescription,NULL);
}
@@ -120,7 +133,42 @@ OFieldDescription::~OFieldDescription()
DBG_DTOR(OFieldDescription,NULL);
}
//------------------------------------------------------------------------------
-
+OFieldDescription::OFieldDescription(const Reference< XPropertySet >& xAffectedCol)
+ :m_bIsPrimaryKey(sal_False)
+ ,m_nFormatKey(0)
+ ,m_bIsAutoIncrement(sal_False)
+ ,m_eHorJustify(SVX_HOR_JUSTIFY_STANDARD)
+ ,m_nScale(0)
+ ,m_nPrecision(0)
+ ,m_pType(NULL)
+ ,m_nIsNullable(ColumnValue::NULLABLE)
+ ,m_nType(DataType::VARCHAR)
+{
+ DBG_CTOR(OFieldDescription,NULL);
+ OSL_ENSURE(xAffectedCol.is(),"PropetySet can notbe null!");
+ Reference<XPropertySetInfo> xPropSetInfo = xAffectedCol->getPropertySetInfo();
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_NAME))
+ SetName(::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_NAME)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_DESCRIPTION))
+ SetDescription(::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_DESCRIPTION)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_DEFAULTVALUE))
+ SetDefaultValue(::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_DEFAULTVALUE)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_TYPE))
+ SetTypeValue(::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_TYPE)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_PRECISION))
+ SetPrecision(::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_PRECISION)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_SCALE))
+ SetScale(::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_SCALE)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_ISNULLABLE))
+ SetIsNullable(::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_ISNULLABLE)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_FORMATKEY))
+ SetFormatKey(::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_FORMATKEY)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_ALIGN))
+ SetHorJustify((SvxCellHorJustify)::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_ALIGN)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_ISAUTOINCREMENT))
+ SetAutoIncrement(::cppu::any2bool(xAffectedCol->getPropertyValue(PROPERTY_ISAUTOINCREMENT)));
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx
index 6a5054b6214d..4df05a3c3ef3 100644
--- a/dbaccess/source/ui/tabledesign/TEditControl.cxx
+++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: TEditControl.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: fs $ $Date: 2001-03-21 13:30:42 $
+ * last change: $Author: oj $ $Date: 2001-03-22 07:54:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,6 +67,21 @@
#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XALTERTABLE_HPP_
+#include <com/sun/star/sdbcx/XAlterTable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
#include <com/sun/star/beans/PropertyAttribute.hpp>
#endif
@@ -115,16 +130,24 @@
#ifndef DBAUI_SQLNAMEEDIT_HXX
#include "SqlNameEdit.hxx"
#endif
+#ifndef DBAUI_TABLEROW_EXCHANGE_HXX
+#include "TableRowExchange.hxx"
+#endif
+#ifndef _SOT_STORAGE_HXX
+#include <sot/storage.hxx>
+#endif
using namespace dbaui;
using namespace comphelper;
using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
using namespace ::com::sun::star::io;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdb;
namespace dbaui
@@ -195,13 +218,6 @@ void OTableEditorCtrl::Init()
//////////////////////////////////////////////////////////////////////
// Soll der Entwurf ReadOnly geoeffnet werden ?
sal_Bool bRead(GetView()->getController()->isReadOnly());
- Reference<XPropertySet> xTable = GetView()->getController()->getTable();
- if(xTable.is() && !(xTable->getPropertySetInfo()->getPropertyByName(PROPERTY_NAME).Attributes & PropertyAttribute::READONLY))
- {
- Reference< XDatabaseMetaData> xMetaData = GetView()->getController()->getConnection()->getMetaData();
- bRead = xMetaData->supportsAlterTableWithAddColumn() && xMetaData->supportsAlterTableWithDropColumn();
- }
-
SetReadOnly( bRead );
@@ -260,10 +276,6 @@ OTableEditorCtrl::OTableEditorCtrl(Window* pWindow)
SetHelpId(HID_TABDESIGN_BACKGROUND);
GetDataWindow().SetHelpId(HID_CTL_TABLEEDIT);
- //////////////////////////////////////////////////////////////////////
- // Clipboard Format registrieren
- Clipboard::Clear();
- m_nClipboardFormat = Clipboard::RegisterFormatName( String::CreateFromAscii("Tabed") );
m_pRowList = GetView()->getController()->getRows();
m_nDataPos = 0;
}
@@ -386,11 +398,6 @@ OTableEditorCtrl::~OTableEditorCtrl()
delete pNameCell;
delete pTypeCell;
delete pDescrCell;
- ::std::vector<OTableRow*>::iterator aIter = m_aClipboardList.begin();
- for(;aIter != m_aClipboardList.end();++aIter)
- delete *aIter;
-
- m_aClipboardList.clear();
}
//------------------------------------------------------------------------------
@@ -401,6 +408,8 @@ sal_Bool OTableEditorCtrl::SetDataPtr( long nRow )
return sal_False;
OSL_ENSURE((xub_StrLen)nRow < m_pRowList->size(),"Row is greater than size!");
+ if(nRow >= m_pRowList->size())
+ return NULL;
pActRow = (*m_pRowList)[nRow];
return pActRow != NULL;
}
@@ -849,15 +858,7 @@ void OTableEditorCtrl::CopyRows()
{
DBG_CHKTHIS(OTableEditorCtrl,NULL);
//////////////////////////////////////////////////////////////////////
- // Alte ClipboardListe loeschen
- ::std::vector<OTableRow*>::iterator aIter = m_aClipboardList.begin();
- for(;aIter != m_aClipboardList.end();++aIter)
- delete *aIter;
-
- m_aClipboardList.clear();
-
- //////////////////////////////////////////////////////////////////////
- // Sichergehen, dass Daten aus dem PropertyWin schon gespeichert sind.
+ // set to the right row and save it
if( SetDataPtr(m_nDataPos) )
pDescrWin->SaveData( pActRow->GetActFieldDescr() );
@@ -865,16 +866,20 @@ void OTableEditorCtrl::CopyRows()
// Selektierte Zeilen in die ClipboardListe kopieren
OTableRow* pClipboardRow;
OTableRow* pRow;
+ ::std::vector<OTableRow*> vClipboardList;
for( long nIndex=FirstSelectedRow(); nIndex>=0; nIndex=NextSelectedRow() )
{
pRow = (*m_pRowList)[nIndex];
pClipboardRow = new OTableRow( *pRow );
- m_aClipboardList.push_back( pClipboardRow);
+ vClipboardList.push_back( pClipboardRow);
+ }
+ if(vClipboardList.size())
+ {
+ OTableRowExchange* pData = new OTableRowExchange(vClipboardList);
+ Reference< ::com::sun::star::datatransfer::XTransferable> xRef = pData;
+ pData->CopyToClipboard();
}
-
- if( m_aClipboardList.size() )
- m_bClipboardFilled = sal_True;
}
//------------------------------------------------------------------------------
@@ -912,36 +917,52 @@ String OTableEditorCtrl::GenerateName( const String& rName )
void OTableEditorCtrl::InsertRows( long nRow )
{
DBG_CHKTHIS(OTableEditorCtrl,NULL);
+
+ ::std::vector< OTableRow*> vInsertedUndoRedoRows; // need for undo/redo handling
//////////////////////////////////////////////////////////////////////
- // Zeilen aus der Clipboardliste in die Datenstruktur einf�gen
- long nInsertRow = nRow;
- String aFieldName;
- OTableRow* pRow;
- ::std::vector<OTableRow*>::const_iterator aIter = m_aClipboardList.begin();
- for(;aIter != m_aClipboardList.end();++aIter)
+ // get rows from clipboard
+ TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard());
+ if(aTransferData.HasFormat(SOT_FORMATSTR_ID_SBA_TABED))
{
- pRow = new OTableRow( **aIter );
- pRow->SetReadOnly( sal_False );
-
- //////////////////////////////////////////////////////////////////////
- // Anpassen des Feldnamens
- aFieldName = GenerateName( pRow->GetActFieldDescr()->GetName() );
- pRow->GetActFieldDescr()->SetName( aFieldName );
+ SotStorageStreamRef aStreamRef;
+ aTransferData.GetSotStorageStream(SOT_FORMATSTR_ID_SBA_TABED,aStreamRef);
+ if(aStreamRef.Is())
+ {
+ aStreamRef->Seek(STREAM_SEEK_TO_BEGIN);
+ aStreamRef->ResetError();
+ long nInsertRow = nRow;
+ String aFieldName;
+ OTableRow* pRow;
+ sal_Int32 nSize = 0;
+ (*aStreamRef) >> nSize;
+ for(sal_Int32 i=0;i < nSize;++i)
+ {
+ pRow = new OTableRow();
+ (*aStreamRef) >> *pRow;
+ pRow->SetReadOnly( sal_False );
+ sal_Int32 nType = pRow->GetActFieldDescr()->GetType();
+ pRow->GetActFieldDescr()->SetType(GetView()->getController()->getTypeInfoByType(nType));
+ //////////////////////////////////////////////////////////////////////
+ // Anpassen des Feldnamens
+ aFieldName = GenerateName( pRow->GetActFieldDescr()->GetName() );
+ pRow->GetActFieldDescr()->SetName( aFieldName );
- m_pRowList->insert( m_pRowList->begin()+nInsertRow,pRow );
- nInsertRow++;
+ m_pRowList->insert( m_pRowList->begin()+nInsertRow,pRow );
+ vInsertedUndoRedoRows.push_back(new OTableRow(*pRow));
+ nInsertRow++;
+ }
+ }
}
-
//////////////////////////////////////////////////////////////////////
// Beim RowInserted wird CursorMoved gerufen.
// Die UI-Daten duerfen hier beim CursorMoved nicht gespeichert werden.
bSaveOnMove = sal_False;
- RowInserted( nRow,m_aClipboardList.size() ,sal_True );
+ RowInserted( nRow,vInsertedUndoRedoRows.size(),sal_True );
bSaveOnMove = sal_True;
//////////////////////////////////////////////////////////////////////
// Undo-Action erzeugen
- GetUndoManager()->AddUndoAction( new OTableEditorInsUndoAct(this, nRow) );
+ GetUndoManager()->AddUndoAction( new OTableEditorInsUndoAct(this, nRow,vInsertedUndoRedoRows) );
GetView()->getController()->setModified( sal_True );
GetView()->getController()->InvalidateFeature(SID_UNDO);
GetView()->getController()->InvalidateFeature(SID_REDO);
@@ -951,6 +972,7 @@ void OTableEditorCtrl::InsertRows( long nRow )
void OTableEditorCtrl::DeleteRows()
{
DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ OSL_ENSURE(GetView()->getController()->isDropAllowed(),"Call of DeleteRows not valid here. Please check isDropAllowed!");
//////////////////////////////////////////////////////////////////////
// Undo-Action erzeugen
GetUndoManager()->AddUndoAction( new OTableEditorDelUndoAct(this) );
@@ -997,6 +1019,7 @@ void OTableEditorCtrl::DeleteRows()
void OTableEditorCtrl::InsertNewRows( long nRow )
{
DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ OSL_ENSURE(GetView()->getController()->isAddAllowed(),"Call of InsertNewRows not valid here. Please check isAppendAllowed!");
//////////////////////////////////////////////////////////////////////
// Undo-Action erzeugen
long nInsertRows = GetSelectRowCount();
@@ -1249,11 +1272,27 @@ OFieldDescription* OTableEditorCtrl::GetFieldDescr( long nRow )
sal_Bool OTableEditorCtrl::IsCutAllowed( long nRow )
{
DBG_CHKTHIS(OTableEditorCtrl,NULL);
- Reference<XPropertySet> xTable = GetView()->getController()->getTable();
- if( !IsCopyAllowed(nRow) || (xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW")))
- return sal_False;
+ sal_Bool bIsCutAllowed = (GetView()->getController()->isAddAllowed() && GetView()->getController()->isDropAllowed()) ||
+ GetView()->getController()->isAlterAllowed();
+
+ if(bIsCutAllowed)
+ {
+ if(pDescrCell->HasChildPathFocus())
+ bIsCutAllowed = pDescrCell->GetSelected().Len() != 0;
+ else if(pNameCell->HasChildPathFocus())
+ bIsCutAllowed = pNameCell->GetSelected().Len() != 0;
+ else
+ // only rows are slected for cutting so we look if all rows are valid
+ // wwe don't waant to copy empty rows here
+ bIsCutAllowed = IsCopyAllowed(nRow);
+ }
+
+// Reference<XPropertySet> xTable = GetView()->getController()->getTable();
+// if( !IsCopyAllowed(nRow) || (xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW")))
+// return sal_False;
- return IsDeleteAllowed( nRow );
+ // return bCutAllowed && IsDeleteAllowed( nRow );
+ return bIsCutAllowed;
}
//------------------------------------------------------------------------------
@@ -1284,82 +1323,97 @@ sal_Bool OTableEditorCtrl::IsCopyAllowed( long nRow )
sal_Bool OTableEditorCtrl::IsPasteAllowed( long nRow )
{
DBG_CHKTHIS(OTableEditorCtrl,NULL);
- Reference<XPropertySet> xTable = GetView()->getController()->getTable();
- if( !m_bClipboardFilled || (xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW")))
- return sal_False;
-
- return sal_True;
+ return GetView()->getController()->isAddAllowed();
}
//------------------------------------------------------------------------------
void OTableEditorCtrl::Cut()
{
- if (nCutEvent)
- Application::RemoveUserEvent(nCutEvent);
- nCutEvent = Application::PostUserEvent(LINK(this, OTableEditorCtrl, DelayedCut));
+ if(pNameCell->HasChildPathFocus())
+ {
+ if(GetView()->getController()->isAlterAllowed())
+ pNameCell->Cut();
+ }
+ else if(pDescrCell->HasChildPathFocus())
+ {
+ if(GetView()->getController()->isAlterAllowed())
+ pDescrCell->Cut();
+ }
+ else
+ {
+ if (nCutEvent)
+ Application::RemoveUserEvent(nCutEvent);
+ nCutEvent = Application::PostUserEvent(LINK(this, OTableEditorCtrl, DelayedCut));
+ }
}
//------------------------------------------------------------------------------
void OTableEditorCtrl::Copy()
{
- OTableRowView::Copy();
+ if(GetSelectRowCount())
+ OTableRowView::Copy();
+ else if(pNameCell->HasChildPathFocus())
+ pNameCell->Copy();
+ else if(pDescrCell->HasChildPathFocus())
+ pDescrCell->Copy();
}
//------------------------------------------------------------------------------
void OTableEditorCtrl::Paste()
{
- if( nPasteEvent )
- Application::RemoveUserEvent( nPasteEvent );
- nPasteEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, DelayedPaste) );
+ TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard());
+ if(aTransferData.HasFormat(SOT_FORMATSTR_ID_SBA_TABED))
+ {
+ if( nPasteEvent )
+ Application::RemoveUserEvent( nPasteEvent );
+ nPasteEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, DelayedPaste) );
+ }
+ else if(pNameCell->HasChildPathFocus())
+ {
+ if(GetView()->getController()->isAlterAllowed())
+ pNameCell->Paste();
+ }
+ else if(pDescrCell->HasChildPathFocus())
+ {
+ if(GetView()->getController()->isAlterAllowed())
+ pDescrCell->Paste();
+ }
}
//------------------------------------------------------------------------------
sal_Bool OTableEditorCtrl::IsDeleteAllowed( long nRow )
{
DBG_CHKTHIS(OTableEditorCtrl,NULL);
- Reference<XPropertySet> xTable = GetView()->getController()->getTable();
- if( !GetSelectRowCount() || (xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW")))
- return sal_False;
-
- // Wenn nur Felder hinzugefuegt werden duerfen, Delete nur auf neuen Feldern
- Reference<XConnection> xCon = GetView()->getController()->getConnection();
- Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : Reference< XDatabaseMetaData>();
- return !(xTable.is() && xTable->getPropertySetInfo()->getPropertyByName(PROPERTY_NAME).Attributes & PropertyAttribute::READONLY) ||
- ( xMetaData.is() && xMetaData->supportsAlterTableWithAddColumn() && xMetaData->supportsAlterTableWithDropColumn());
+ return GetSelectRowCount() != 0 && GetView()->getController()->isDropAllowed();
+// Reference<XPropertySet> xTable = GetView()->getController()->getTable();
+// if( !GetSelectRowCount() || (xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW")))
+// return sal_False;
+//
+// // Wenn nur Felder hinzugefuegt werden duerfen, Delete nur auf neuen Feldern
+// Reference<XConnection> xCon = GetView()->getController()->getConnection();
+// Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : NULL;
+//
+// return !(xTable.is() && xTable->getPropertySetInfo()->getPropertyByName(PROPERTY_NAME).Attributes & PropertyAttribute::READONLY) ||
+// ( xMetaData.is() && xMetaData->supportsAlterTableWithAddColumn() && xMetaData->supportsAlterTableWithDropColumn());
}
//------------------------------------------------------------------------------
sal_Bool OTableEditorCtrl::IsInsertNewAllowed( long nRow )
{
DBG_CHKTHIS(OTableEditorCtrl,NULL);
- Reference<XPropertySet> xTable = GetView()->getController()->getTable();
- if(xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW"))
- return sal_False;
- // table is new
- if(!(xTable.is() && xTable->getPropertySetInfo()->getPropertyByName(PROPERTY_NAME).Attributes & PropertyAttribute::READONLY))
- return sal_True;
-
- Reference<XConnection> xCon = GetView()->getController()->getConnection();
- Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : Reference< XDatabaseMetaData>();
- if(!xMetaData.is())
- return sal_False;
- //////////////////////////////////////////////////////////////
- // Wenn nur Felder geloescht werden duerfen, Paste disablen
-
- if ( !xMetaData->supportsAlterTableWithAddColumn() && xMetaData->supportsAlterTableWithDropColumn())
- return sal_False;
+ sal_Bool bInsertNewAllowed = GetView()->getController()->isAddAllowed();
//////////////////////////////////////////////////////////////
// Wenn nur Felder hinzugefuegt werden duerfen, Paste nur in neue Felder
- if (xMetaData->supportsAlterTableWithAddColumn() && !xMetaData->supportsAlterTableWithDropColumn())
+ if (bInsertNewAllowed && !GetView()->getController()->isDropAllowed())
{
SetDataPtr(nRow);
if( GetActRow()->IsReadOnly() )
return sal_False;
}
- return xMetaData->supportsAlterTableWithAddColumn() && xMetaData->supportsAlterTableWithDropColumn();
+ return bInsertNewAllowed;
}
//------------------------------------------------------------------------------
@@ -1369,22 +1423,26 @@ sal_Bool OTableEditorCtrl::IsPrimaryKeyAllowed( long nRow )
if( !GetSelectRowCount() )
return sal_False;
- //////////////////////////////////////////////////////////////
- // Datenbank kann keine PrimKeys verarbeiten oder keine Zeilenselektion
Reference<XConnection> xCon = GetView()->getController()->getConnection();
+
Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : Reference< XDatabaseMetaData>();
- if(!xMetaData.is() || !xMetaData->supportsCoreSQLGrammar())
- return sal_False;
+ Reference<XPropertySet> xTable = GetView()->getController()->getTable();
+ Reference<XKeysSupplier> xKeySup(xTable,UNO_QUERY);
+ Reference<XIndexAccess> xIndexAccess;
+ if(xKeySup.is())
+ xIndexAccess = xKeySup->getKeys();
+
+ if(!xIndexAccess.is() && (!xMetaData.is() || !xMetaData->supportsCoreSQLGrammar()))
+ return sal_False; // no primary keys allowed
//////////////////////////////////////////////////////////////
// Key darf nicht veraendert werden
// Dies gilt jedoch nur, wenn die Tabelle nicht neu ist und keine ::com::sun::star::sdbcx::View. Ansonsten wird kein DROP ausgef�hrt
- Reference<XPropertySet> xTable = GetView()->getController()->getTable();
sal_Bool bDropNotAllowed = sal_False;
- if (!( xMetaData->supportsAlterTableWithDropColumn() ||
+ if (!( GetView()->getController()->isDropAllowed() ||
!(xTable.is() && xTable->getPropertySetInfo()->getPropertyByName(PROPERTY_NAME).Attributes & PropertyAttribute::READONLY)) &&
- xMetaData->supportsAlterTableWithAddColumn() &&
+ GetView()->getController()->isAddAllowed() &&
(xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) != ::rtl::OUString::createFromAscii("VIEW")))
bDropNotAllowed = sal_True;
@@ -1725,3 +1783,5 @@ OTableDesignView* OTableEditorCtrl::GetView() const
+
+
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.hxx b/dbaccess/source/ui/tabledesign/TEditControl.hxx
index 1e30beb46590..0b7fb387aa8c 100644
--- a/dbaccess/source/ui/tabledesign/TEditControl.hxx
+++ b/dbaccess/source/ui/tabledesign/TEditControl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: TEditControl.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: fs $ $Date: 2001-03-19 06:04:38 $
+ * last change: $Author: oj $ $Date: 2001-03-22 07:54:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -85,7 +85,6 @@ namespace dbaui
class OTableEditorCtrl : public OTableRowView
{
- ::std::vector<OTableRow*> m_aClipboardList;
::std::vector<OTableRow*> m_aUndoList;
::std::vector<OTableRow*>* m_pRowList;
@@ -177,16 +176,15 @@ namespace dbaui
void DisplayData( long nRow, BOOL bGrabFocus = TRUE );
// erzwingt das Anzeigen der genannten Zeile (selbst wenn es eigentlich schon die aktuelle ist)
- virtual void SetData( long nRow, USHORT nColId, const OTypeInfo* _pTypeInfo );
- virtual void SetData( long nRow, USHORT nColId, const String& _rSaveData );
- virtual String GetData( long nRow, USHORT nColId );
- virtual void SetControlText( long nRow, USHORT nColId, const String& rText );
- virtual String GetControlText( long nRow, USHORT nColId );
+ virtual void SetData( long nRow, USHORT nColId, const OTypeInfo* _pTypeInfo );
+ virtual void SetData( long nRow, USHORT nColId, const String& _rSaveData );
+ virtual String GetData( long nRow, USHORT nColId );
+ virtual void SetControlText( long nRow, USHORT nColId, const String& rText );
+ virtual String GetControlText( long nRow, USHORT nColId );
virtual OTableDesignView* GetView() const;
::std::vector<OTableRow*>* GetRowList(){ return m_pRowList; }
- ::std::vector<OTableRow*>* GetClipboardRowList(){ return &m_aClipboardList; }
OTableRow* GetActRow(){ return pActRow; }
void CellModified( long nRow, USHORT nColId );
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
index 7e9c1dcca630..06de64096ee7 100644
--- a/dbaccess/source/ui/tabledesign/TableController.cxx
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: TableController.cxx,v $
*
- * $Revision: 1.18 $
+ * $Revision: 1.19 $
*
- * last change: $Author: fs $ $Date: 2001-03-21 13:34:42 $
+ * last change: $Author: oj $ $Date: 2001-03-22 07:54:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -502,7 +502,7 @@ sal_Bool OTableController::doSaveDoc(sal_Bool _bSaveAs)
{
alterColumns();
}
- setModified(sal_False);
+ reSyncRows();
}
catch(SQLContext& e)
{
@@ -1093,7 +1093,8 @@ void OTableController::loadData()
// Bei Drop darf keine Zeile editierbar sein.
// Bei Add duerfen nur die leeren Zeilen editierbar sein.
// Bei Add und Drop koennen alle Zeilen editiert werden.
- sal_Bool bReadOldRow = xMetaData->supportsAlterTableWithAddColumn() && xMetaData->supportsAlterTableWithDropColumn();
+ // sal_Bool bReadOldRow = xMetaData->supportsAlterTableWithAddColumn() && xMetaData->supportsAlterTableWithDropColumn();
+ sal_Bool bIsAlterAllowed = isAlterAllowed();
Sequence< ::rtl::OUString> aColumns = xColumns->getElementNames();
const ::rtl::OUString* pBegin = aColumns.getConstArray();
const ::rtl::OUString* pEnd = pBegin + aColumns.getLength();
@@ -1134,7 +1135,7 @@ void OTableController::loadData()
pTabEdRow = new OTableRow();
- pTabEdRow->SetReadOnly(bReadOldRow);
+ pTabEdRow->SetReadOnly(!bIsAlterAllowed);
// search for type
::std::pair<OTypeInfoMap::iterator, OTypeInfoMap::iterator> aPair = m_aTypeInfo.equal_range(nType);
OTypeInfoMap::iterator aIter = aPair.first;
@@ -1200,7 +1201,7 @@ void OTableController::loadData()
OSL_ENSURE(aTypeIter != m_aTypeInfo.end(),"We have no type infomation!");
- sal_Bool bReadRow = m_xTable.is() && xMetaData.is() && xMetaData->supportsAlterTableWithAddColumn();
+ sal_Bool bReadRow = !isAddAllowed();
for(sal_Int32 i=m_vRowList.size(); i<128; i++ )
{
pTabEdRow = new OTableRow();
@@ -1277,22 +1278,21 @@ void OTableController::alterColumns()
Reference<XNameAccess> xColumns = xColSup->getColumns();
OSL_ENSURE(xColumns.is(),"No columns");
- Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY);
- if(!xAlter.is())
- {
- OSL_ENSURE(0,"Normally we should never reach this state!");
- return;
- }
- Reference<XDrop> xDrop(xColumns,UNO_QUERY);
- Reference<XAppend> xAppend(xColumns,UNO_QUERY);
- Reference<XDataDescriptorFactory> xColumnFactory(xColumns,UNO_QUERY);
+ Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY); // can be null
+
+ sal_Int32 nColumnCount = xColumns->getElementNames().getLength();
+ Reference<XDrop> xDrop(xColumns,UNO_QUERY); // can be null
+ Reference<XAppend> xAppend(xColumns,UNO_QUERY); // can be null
+ Reference<XDataDescriptorFactory> xColumnFactory(xColumns,UNO_QUERY); // can be null
sal_Bool bReload = sal_False; // refresh the data
+ // contains all columns names which are already handled those which are not in the list will be deleted
Reference< XDatabaseMetaData> xMetaData = m_xConnection.is() ? m_xConnection->getMetaData() : Reference< XDatabaseMetaData>();
+
::std::map< ::rtl::OUString,sal_Bool,::comphelper::UStringMixLess> aColumns(xMetaData.is() ? xMetaData->storesMixedCaseQuotedIdentifiers() : sal_True);
::std::vector<OTableRow*>::iterator aIter = m_vRowList.begin();
- for(;aIter != m_vRowList.end();++aIter)
+ for(sal_Int32 nPos = 0;aIter != m_vRowList.end();++aIter,++nPos)
{
OSL_ENSURE(*aIter,"OTableRow is null!");
OFieldDescription* pField = (*aIter)->GetActFieldDescr();
@@ -1306,7 +1306,7 @@ void OTableController::alterColumns()
xColumns->getByName(pField->GetName()) >>= xColumn;
OSL_ENSURE(xColumn.is(),"Column is null!");
- sal_Int32 nType,nPrecision,nScale,nNullable,nFormatKey,nAlignment;
+ sal_Int32 nType,nPrecision,nScale,nNullable,nFormatKey=0,nAlignment=0;
sal_Bool bAutoIncrement;
::rtl::OUString sDescription,sDefaultValue;
@@ -1342,6 +1342,7 @@ void OTableController::alterColumns()
sal_Bool bNotOk = sal_False;
try
{
+ // first try if we can alter the column
if(xAlter.is())
xAlter->alterColumnByName(pField->GetName(),xNewColumn);
}
@@ -1349,11 +1350,14 @@ void OTableController::alterColumns()
{
bNotOk = sal_True;
}
+ // if something went wrong or the can't alter columns
+ // drop and append a new one
if((!xAlter.is() || bNotOk) && xDrop.is() && xAppend.is())
{
xDrop->dropByName(pField->GetName());
xAppend->appendByDescriptor(xNewColumn);
}
+ // exceptions are catched outside
xNewColumn = NULL;
xColumns->getByName(pField->GetName()) >>= xColumn;
bReload = sal_True;
@@ -1370,14 +1374,38 @@ void OTableController::alterColumns()
xColumn->setPropertyValue(PROPERTY_ALIGN,makeAny(nAlignment));
}
}
- else if(xColumnFactory.is())
- {
+ else if(xColumnFactory.is() && xAppend.is())
+ {// column not found by its name so we assume it is new
// Column is new
xColumn = xColumnFactory->createDataDescriptor();
setColumnProperties(xColumn,pField);
xAppend->appendByDescriptor(xColumn);
if(xColumns->hasByName(pField->GetName()))
+ { // ask for the append by name
+ aColumns[pField->GetName()] = sal_True;
+ xColumns->getByName(pField->GetName()) >>= xColumn;
+ if(xColumn.is())
+ {
+ if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_FORMATKEY))
+ xColumn->setPropertyValue(PROPERTY_FORMATKEY,makeAny(pField->GetFormatKey()));
+ if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_ALIGN))
+ xColumn->setPropertyValue(PROPERTY_ALIGN,makeAny((sal_Int32)pField->GetHorJustify()));
+ }
+ }
+ else
{
+ OSL_ASSERT(0);
+ }
+ }
+ else if(xColumnFactory.is() && xAlter.is() && nPos < nColumnCount)
+ { // we can't find the column nor can we append a new one so we alter it by index
+ Reference<XPropertySet> xNewColumn;
+ xNewColumn = xColumnFactory->createDataDescriptor();
+ setColumnProperties(xNewColumn,pField);
+ xAlter->alterColumnByIndex(nPos,xNewColumn);
+ if(xColumns->hasByName(pField->GetName()))
+ { // ask for the append by name
+ aColumns[pField->GetName()] = sal_True;
xColumns->getByName(pField->GetName()) >>= xColumn;
if(xColumn.is())
{
@@ -1392,6 +1420,8 @@ void OTableController::alterColumns()
OSL_ASSERT(0);
}
}
+ else
+ bReload = sal_True;
}
Reference<XNameAccess> xKeyColumns = getKeyColumns();
@@ -1452,10 +1482,12 @@ void OTableController::alterColumns()
appendKey(xKeySup);
}
+ reSyncRows();
+
if(bReload)
{
loadData(); // fill the column information form the table
- getView()->initialize(); // show the windows and fill with our informations
+ static_cast<OTableDesignView*>(getView())->reSync(); // show the windows and fill with our informations
getUndoMgr()->Clear(); // clear all undo redo things
setModified(sal_False); // and we are not modified yet
}
@@ -1520,8 +1552,9 @@ void OTableController::assignTable()
m_xTable = xProp;
startTableListening();
+ // check if we set the table editable
Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY);
- m_bEditable = xAlter.is();
+ m_bEditable = isAlterAllowed() || isDropAllowed() || isAddAllowed();
if(!m_bEditable)
{
::std::vector<OTableRow*>::iterator aIter = m_vRowList.begin();
@@ -1536,7 +1569,58 @@ void OTableController::assignTable()
}
}
// -----------------------------------------------------------------------------
+sal_Bool OTableController::isAddAllowed() const
+{
+ Reference<XColumnsSupplier> xColsSup(m_xTable,UNO_QUERY);
+ sal_Bool bAddAllowed = !m_xTable.is();
+ if(xColsSup.is())
+ bAddAllowed = Reference<XAppend>(xColsSup->getColumns(),UNO_QUERY).is();
+
+ Reference< XDatabaseMetaData> xMetaData = m_xConnection.is() ? m_xConnection->getMetaData() : NULL;
+ bAddAllowed = bAddAllowed || ( xMetaData.is() && xMetaData->supportsAlterTableWithAddColumn());
+
+ return bAddAllowed;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableController::isDropAllowed() const
+{
+ Reference<XColumnsSupplier> xColsSup(m_xTable,UNO_QUERY);
+ sal_Bool bDropAllowed = !m_xTable.is();
+ if(xColsSup.is())
+ bDropAllowed = Reference<XDrop>(xColsSup->getColumns(),UNO_QUERY).is();
+ Reference< XDatabaseMetaData> xMetaData = m_xConnection.is() ? m_xConnection->getMetaData() : NULL;
+ bDropAllowed = bDropAllowed || ( xMetaData.is() && xMetaData->supportsAlterTableWithDropColumn());
+
+ return bDropAllowed;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableController::isAlterAllowed() const
+{
+ sal_Bool bAllowed(!m_xTable.is() || Reference<XAlterTable>(m_xTable,UNO_QUERY).is());
+ return bAllowed;
+}
+// -----------------------------------------------------------------------------
+void OTableController::reSyncRows()
+{
+ sal_Bool bAlterAllowed = isAlterAllowed();
+ sal_Bool bAddAllowed = isAddAllowed();
+ ::std::vector<OTableRow*>::iterator aIter = m_vRowList.begin();
+ for(;aIter != m_vRowList.end();++aIter)
+ {
+ OSL_ENSURE(*aIter,"OTableRow is null!");
+ OFieldDescription* pField = (*aIter)->GetActFieldDescr();
+ if(pField)
+ (*aIter)->SetReadOnly(!bAlterAllowed);
+ else
+ (*aIter)->SetReadOnly(!bAddAllowed);
+
+ }
+ static_cast<OTableDesignView*>(getView())->reSync(); // show the windows and fill with our informations
+ getUndoMgr()->Clear(); // clear all undo redo things
+ setModified(sal_False); // and we are not modified yet
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/tabledesign/TableDesignView.cxx b/dbaccess/source/ui/tabledesign/TableDesignView.cxx
index 8174eae7d4d6..1d068f90b5de 100644
--- a/dbaccess/source/ui/tabledesign/TableDesignView.cxx
+++ b/dbaccess/source/ui/tabledesign/TableDesignView.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: TableDesignView.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: oj $ $Date: 2001-02-14 14:25:30 $
+ * last change: $Author: oj $ $Date: 2001-03-22 07:54:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -94,11 +94,15 @@
#ifndef _COMPHELPER_TYPES_HXX_
#include <comphelper/types.hxx>
#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARD_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#endif
using namespace ::dbaui;
using namespace ::utl;
using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::datatransfer::clipboard;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
@@ -323,24 +327,64 @@ IMPL_LINK( OTableDesignView, SwitchHdl, Accelerator*, pAcc )
// -----------------------------------------------------------------------------
sal_Bool OTableDesignView::isCutAllowed()
{
- return sal_True;
+ sal_Bool bAllowed = sal_False;
+ if( GetDescWin()->HasChildPathFocus() )
+ {
+ bAllowed = GetDescWin()->isCutAllowed();
+ }
+ else
+ {
+ bAllowed = GetEditorCtrl()->IsCutAllowed();
+ }
+ return bAllowed;
}
// -----------------------------------------------------------------------------
void OTableDesignView::copy()
{
+ if( GetDescWin()->HasChildPathFocus() )
+ {
+ GetDescWin()->copy();
+ }
+ else
+ {
+ GetEditorCtrl()->Copy();
+ }
}
// -----------------------------------------------------------------------------
void OTableDesignView::cut()
{
+ if( GetDescWin()->HasChildPathFocus() )
+ {
+ GetDescWin()->cut();
+ }
+ else
+ {
+ GetEditorCtrl()->Cut();
+ }
}
// -----------------------------------------------------------------------------
void OTableDesignView::paste()
{
+ if( GetDescWin()->HasChildPathFocus() )
+ {
+ GetDescWin()->paste();
+ }
+ else
+ {
+ GetEditorCtrl()->Paste();
+ }
}
+// -----------------------------------------------------------------------------
// set the view readonly or not
void OTableDesignView::setReadOnly(sal_Bool _bReadOnly)
{
GetDescWin()->SetReadOnly(_bReadOnly);
GetEditorCtrl()->SetReadOnly(_bReadOnly);
}
-// ----------------------------------------------------------------------------- \ No newline at end of file
+// -----------------------------------------------------------------------------
+void OTableDesignView::reSync()
+{
+ GetEditorCtrl()->DeactivateCell();
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx
index 8d36b1354d6b..98a3dedce82a 100644
--- a/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx
+++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: TableFieldDescWin.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: oj $ $Date: 2001-02-14 14:25:40 $
+ * last change: $Author: oj $ $Date: 2001-03-22 07:54:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -278,3 +278,30 @@ void OTableFieldDescWin::Resize()
}
Invalidate();
}
+// -----------------------------------------------------------------------------
+sal_Bool OTableFieldDescWin::isCutAllowed()
+{
+ return (m_pGenPage && m_pGenPage->HasChildPathFocus() && m_pGenPage->isCutAllowed());
+}
+// -----------------------------------------------------------------------------
+void OTableFieldDescWin::cut()
+{
+ if(m_pGenPage && m_pGenPage->HasChildPathFocus())
+ m_pGenPage->cut();
+}
+// -----------------------------------------------------------------------------
+void OTableFieldDescWin::copy()
+{
+ if(m_pGenPage && m_pGenPage->HasChildPathFocus())
+ m_pGenPage->copy();
+}
+// -----------------------------------------------------------------------------
+void OTableFieldDescWin::paste()
+{
+ if(m_pGenPage && m_pGenPage->HasChildPathFocus())
+ m_pGenPage->paste();
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx
index 03b8610b1f6d..3a93d29cb8dc 100644
--- a/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx
+++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: TableFieldDescWin.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: oj $ $Date: 2001-02-14 14:26:47 $
+ * last change: $Author: oj $ $Date: 2001-03-22 07:54:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,7 +73,6 @@ namespace dbaui
{
class OFieldDescGenWin;
class OTableDesignHelpBar;
- class OFieldPropTabCtrl;
class OFieldDescription;
//==================================================================
// Ableitung von TabPage ist ein Trick von TH,
@@ -83,7 +82,6 @@ namespace dbaui
private:
OTableDesignHelpBar* m_pHelpBar;
OFieldDescGenWin* m_pGenPage;
- OFieldPropTabCtrl* m_pTabControl;
FixedText* m_pHeader;
protected:
@@ -100,7 +98,6 @@ namespace dbaui
void SaveData( OFieldDescription* pFieldDescr );
void SetReadOnly( BOOL bReadOnly );
- BOOL ChildHasFocus(){ return m_pGenPage->HasChildPathFocus(); }
virtual void GetFocus(){ m_pGenPage->GetFocus(); }
virtual void LoseFocus(){ m_pGenPage->LoseFocus(); }
void SetControlText( USHORT nControlId, const String& rText )
@@ -115,6 +112,12 @@ namespace dbaui
String BoolStringPersistent(const String& rUIString) const { return m_pGenPage->BoolStringPersistent(rUIString); }
String BoolStringUI(const String& rPersistentString) const { return m_pGenPage->BoolStringUI(rPersistentString); }
+
+ sal_Bool isCutAllowed();
+ void cut();
+ void copy();
+ void paste();
+
};
}
#endif // DBAUI_TABLEFIELDDESCRIPTION_HXX
diff --git a/dbaccess/source/ui/tabledesign/TableRow.cxx b/dbaccess/source/ui/tabledesign/TableRow.cxx
index b5a82bf1dfae..08d8e5e4f362 100644
--- a/dbaccess/source/ui/tabledesign/TableRow.cxx
+++ b/dbaccess/source/ui/tabledesign/TableRow.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: TableRow.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: oj $ $Date: 2001-03-12 14:47:40 $
+ * last change: $Author: oj $ $Date: 2001-03-22 07:54:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,6 +71,8 @@
using namespace dbaui;
using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
//========================================================================
// class OTableRow
//========================================================================
@@ -82,10 +84,22 @@ OTableRow::OTableRow()
,m_bReadOnly( sal_False )
,m_bFirstNameModify( sal_True )
,m_bFirstDescrModify( sal_True )
+ ,m_bOwnsDescriptions(sal_False)
{
DBG_CTOR(OTableRow,NULL);
}
-
+//------------------------------------------------------------------------------
+OTableRow::OTableRow(const Reference< XPropertySet >& xAffectedCol)
+ :m_pActFieldDescr( NULL )
+ ,m_nPos( -1 )
+ ,m_bReadOnly( sal_False )
+ ,m_bFirstNameModify( sal_True )
+ ,m_bFirstDescrModify( sal_True )
+ ,m_bOwnsDescriptions(sal_True)
+{
+ DBG_CTOR(OTableRow,NULL);
+ m_pActFieldDescr = new OFieldDescription(xAffectedCol);
+}
//------------------------------------------------------------------------------
OTableRow::OTableRow( const OTableRow& rRow, long nPosition ) :
m_nPos( nPosition )
@@ -93,6 +107,7 @@ OTableRow::OTableRow( const OTableRow& rRow, long nPosition ) :
,m_bFirstNameModify(rRow.IsFirstNameModify())
,m_bFirstDescrModify(rRow.IsFirstDescrModify())
,m_pActFieldDescr(NULL)
+ ,m_bOwnsDescriptions(sal_False)
{
DBG_CTOR(OTableRow,NULL);
@@ -104,6 +119,8 @@ OTableRow::OTableRow( const OTableRow& rRow, long nPosition ) :
//------------------------------------------------------------------------------
OTableRow::~OTableRow()
{
+ if(m_bOwnsDescriptions)
+ delete m_pActFieldDescr;
DBG_DTOR(OTableRow,NULL);
}
@@ -165,5 +182,77 @@ void OTableRow::SetFieldType( const OTypeInfo* _pType )
}
}
// -----------------------------------------------------------------------------
+namespace dbaui
+{
+ // -----------------------------------------------------------------------------
+ SvStream& operator<<( SvStream& _rStr, const OTableRow& _rRow )
+ {
+ _rStr << _rRow.m_nPos;
+ OFieldDescription* pFieldDesc = _rRow.GetActFieldDescr();
+ if(pFieldDesc)
+ {
+ _rStr.WriteByteString(pFieldDesc->GetName());
+ _rStr.WriteByteString(pFieldDesc->GetDescription());
+ _rStr.WriteByteString(pFieldDesc->GetDefaultValue());
+
+ _rStr << pFieldDesc->GetType();
+
+ _rStr << pFieldDesc->GetPrecision();
+ _rStr << pFieldDesc->GetScale();
+ _rStr << pFieldDesc->GetIsNullable();
+ _rStr << pFieldDesc->GetFormatKey();
+ _rStr << (sal_Int32)pFieldDesc->GetHorJustify();
+ _rStr << sal_Int32(pFieldDesc->IsAutoIncrement() ? 1 : 0);
+ _rStr << sal_Int32(pFieldDesc->IsPrimaryKey() ? 1 : 0);
+ _rStr << sal_Int32(pFieldDesc->IsCurrency() ? 1 : 0);
+ }
+ return _rStr;
+ }
+ // -----------------------------------------------------------------------------
+ SvStream& operator>>( SvStream& _rStr, OTableRow& _rRow )
+ {
+ _rStr >> _rRow.m_nPos;
+
+ OFieldDescription* pFieldDesc = new OFieldDescription();
+ _rRow.m_pActFieldDescr = pFieldDesc;
+ if(pFieldDesc)
+ {
+ String sValue;
+ _rStr.ReadByteString(sValue);
+ pFieldDesc->SetName(sValue);
+
+ _rStr.ReadByteString(sValue);
+ pFieldDesc->SetDescription(sValue);
+
+ _rStr.ReadByteString(sValue);
+ pFieldDesc->SetDefaultValue(sValue);
+
+ sal_Int32 nValue;
+ _rStr >> nValue;
+ pFieldDesc->SetTypeValue(nValue);
+
+ _rStr >> nValue;
+ pFieldDesc->SetPrecision(nValue);
+ _rStr >> nValue;
+ pFieldDesc->SetScale(nValue);
+ _rStr >> nValue;
+ pFieldDesc->SetIsNullable(nValue);
+ _rStr >> nValue;
+ pFieldDesc->SetFormatKey(nValue);
+ _rStr >> nValue;
+ pFieldDesc->SetHorJustify((SvxCellHorJustify)nValue);
+
+ _rStr >> nValue;
+ pFieldDesc->SetAutoIncrement(nValue != 0);
+ _rStr >> nValue;
+ pFieldDesc->SetPrimaryKey(nValue != 0);
+ _rStr >> nValue;
+ pFieldDesc->SetCurrency(nValue != 0);
+ }
+ return _rStr;
+ }
+ // -----------------------------------------------------------------------------
+}
+
diff --git a/dbaccess/source/ui/tabledesign/TableUndo.cxx b/dbaccess/source/ui/tabledesign/TableUndo.cxx
index c1c82138c16f..887ab3919259 100644
--- a/dbaccess/source/ui/tabledesign/TableUndo.cxx
+++ b/dbaccess/source/ui/tabledesign/TableUndo.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: TableUndo.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: oj $ $Date: 2001-02-14 14:26:55 $
+ * last change: $Author: oj $ $Date: 2001-03-22 07:54:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -318,21 +318,13 @@ void OTableEditorDelUndoAct::Redo()
//==============================================================================
// class OTableEditorInsUndoAct
//==============================================================================
-OTableEditorInsUndoAct::OTableEditorInsUndoAct( OTableEditorCtrl* pOwner, long nInsertPosition ) :
- OTableEditorUndoAct( pOwner,STR_TABED_UNDO_ROWINSERTED )
+OTableEditorInsUndoAct::OTableEditorInsUndoAct( OTableEditorCtrl* pOwner,
+ long nInsertPosition ,
+ const ::std::vector< OTableRow*>& _vInsertedRows)
+ :OTableEditorUndoAct( pOwner,STR_TABED_UNDO_ROWINSERTED )
,m_nInsPos( nInsertPosition )
+ ,m_vInsertedRows(_vInsertedRows)
{
- //////////////////////////////////////////////////////////////////////
- // Clipboard-Inhalt in InsertedRowList kopieren
- ::std::vector<OTableRow*>* pClipboardList = pOwner->GetClipboardRowList();
- ::std::vector<OTableRow*>::iterator aIter = pClipboardList->begin();
-
- OTableRow* pNewRow;
- for(;aIter != pClipboardList->end();++aIter)
- {
- pNewRow = new OTableRow( **aIter );
- m_aInsertedRows.push_back( pNewRow);
- }
}
//-------------------------------------------------------------------------
@@ -340,11 +332,11 @@ OTableEditorInsUndoAct::~OTableEditorInsUndoAct()
{
//////////////////////////////////////////////////////////////////////
// InsertedRowList loeschen
- ::std::vector<OTableRow*>::iterator aIter = m_aInsertedRows.begin();
- for(;aIter != m_aInsertedRows.end();++aIter)
+ ::std::vector<OTableRow*>::iterator aIter = m_vInsertedRows.begin();
+ for(;aIter != m_vInsertedRows.end();++aIter)
delete *aIter;
- m_aInsertedRows.clear();
+ m_vInsertedRows.clear();
}
//-------------------------------------------------------------------------
@@ -353,13 +345,13 @@ void OTableEditorInsUndoAct::Undo()
//////////////////////////////////////////////////////////////////////
// Eingefuegte Zeilen wieder loeschen
::std::vector<OTableRow*>* pOriginalRows = pTabEdCtrl->GetRowList();
- for( long i=(m_nInsPos+m_aInsertedRows.size()-1); i>(m_nInsPos-1); i-- )
+ for( long i=(m_nInsPos+m_vInsertedRows.size()-1); i>(m_nInsPos-1); i-- )
{
delete (*pOriginalRows)[i];
pOriginalRows->erase(pOriginalRows->begin()+i);
}
- pTabEdCtrl->RowRemoved( m_nInsPos, m_aInsertedRows.size(), TRUE );
+ pTabEdCtrl->RowRemoved( m_nInsPos, m_vInsertedRows.size(), TRUE );
pTabEdCtrl->InvalidateHandleColumn();
OTableEditorUndoAct::Undo();
@@ -372,16 +364,16 @@ void OTableEditorInsUndoAct::Redo()
// Zeilen wieder einfuegen
long nInsertRow = m_nInsPos;
OTableRow* pRow;
- ::std::vector<OTableRow*>::iterator aIter = m_aInsertedRows.begin();
+ ::std::vector<OTableRow*>::iterator aIter = m_vInsertedRows.begin();
::std::vector<OTableRow*>* pRowList = pTabEdCtrl->GetRowList();
- for(;aIter != m_aInsertedRows.end();++aIter)
+ for(;aIter != m_vInsertedRows.end();++aIter)
{
pRow = new OTableRow( **aIter );
pRowList->insert( pRowList->begin()+nInsertRow ,pRow );
nInsertRow++;
}
- pTabEdCtrl->RowInserted( m_nInsPos, m_aInsertedRows.size(), TRUE );
+ pTabEdCtrl->RowInserted( m_nInsPos, m_vInsertedRows.size(), TRUE );
pTabEdCtrl->InvalidateHandleColumn();
OTableEditorUndoAct::Redo();
diff --git a/dbaccess/source/ui/tabledesign/makefile.mk b/dbaccess/source/ui/tabledesign/makefile.mk
index ab43118ea707..8ef089c28e0e 100644
--- a/dbaccess/source/ui/tabledesign/makefile.mk
+++ b/dbaccess/source/ui/tabledesign/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.1 $
+# $Revision: 1.2 $
#
-# last change: $Author: oj $ $Date: 2001-02-14 14:24:18 $
+# last change: $Author: oj $ $Date: 2001-03-22 07:54:07 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -84,6 +84,7 @@ SLOFILES =\
$(SLO)$/FieldDescGenWin.obj \
$(SLO)$/FieldDescriptions.obj \
$(SLO)$/TableRow.obj \
+ $(SLO)$/TableRowExchange.obj \
$(SLO)$/TableUndo.obj