summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/tabledesign/TEditControl.cxx
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-04-16 13:55:24 +0200
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-04-16 13:55:24 +0200
commitb6693080a17418cf79b55f77add3bf7a84f00060 (patch)
tree2f2609e3549481a37d47fbf869224be6e0642b34 /dbaccess/source/ui/tabledesign/TEditControl.cxx
parent52cc8fded55d1761c6913a3704a03a7c137a7f3d (diff)
parentfd8c2dd9780e8b3f4e9d26783f477452ff62a17c (diff)
dba33f: merge with m76-branch
Diffstat (limited to 'dbaccess/source/ui/tabledesign/TEditControl.cxx')
-rw-r--r--dbaccess/source/ui/tabledesign/TEditControl.cxx146
1 files changed, 107 insertions, 39 deletions
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx
index 40741ac02bb7..2910380070c5 100644
--- a/dbaccess/source/ui/tabledesign/TEditControl.cxx
+++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx
@@ -105,6 +105,7 @@
#ifndef DBAUI_TABLEFIELDCONTROL_HXX
#include "TableFieldControl.hxx"
#endif
+#include "dsntypes.hxx"
using namespace ::dbaui;
using namespace ::comphelper;
@@ -199,13 +200,21 @@ void OTableEditorCtrl::Init()
//////////////////////////////////////////////////////////////////////
// Spalten einfuegen
String aColumnName( ModuleRes(STR_TAB_FIELD_COLUMN_NAME) );
- InsertDataColumn( 1, aColumnName, FIELDNAME_WIDTH );
+ InsertDataColumn( FIELD_NAME, aColumnName, FIELDNAME_WIDTH );
aColumnName = String( ModuleRes(STR_TAB_FIELD_COLUMN_DATATYPE) );
- InsertDataColumn( 2, aColumnName, FIELDTYPE_WIDTH );
+ InsertDataColumn( FIELD_TYPE, aColumnName, FIELDTYPE_WIDTH );
- aColumnName = String( ModuleRes(STR_TAB_FIELD_DESCR) );
- InsertDataColumn( 3, aColumnName, FIELDDESCR_WIDTH );
+ ::dbaccess::ODsnTypeCollection aDsnTypes(GetView()->getController().getORB());
+ sal_Bool bShowColumnDescription = aDsnTypes.supportsColumnDescription(::comphelper::getString(GetView()->getController().getDataSource()->getPropertyValue(PROPERTY_URL)));
+ aColumnName = String( ModuleRes(STR_TAB_HELP_TEXT) );
+ InsertDataColumn( HELP_TEXT, aColumnName, bShowColumnDescription ? FIELDTYPE_WIDTH : FIELDDESCR_WIDTH );
+
+ if ( bShowColumnDescription )
+ {
+ aColumnName = String( ModuleRes(STR_COLUMN_DESCRIPTION) );
+ InsertDataColumn( COLUMN_DESCRIPTION, aColumnName, FIELDTYPE_WIDTH );
+ }
InitCellController();
@@ -229,6 +238,7 @@ OTableEditorCtrl::OTableEditorCtrl(Window* pWindow)
:OTableRowView(pWindow)
,pNameCell(NULL)
,pTypeCell(NULL)
+ ,pHelpTextCell(NULL)
,pDescrCell(NULL)
,pDescrWin(NULL)
,nIndexEvent(0)
@@ -342,12 +352,16 @@ void OTableEditorCtrl::InitCellController()
pDescrCell = new Edit( &GetDataWindow(), WB_LEFT );
pDescrCell->SetMaxTextLen( MAX_DESCR_LEN );
+ pHelpTextCell = new Edit( &GetDataWindow(), WB_LEFT );
+ pHelpTextCell->SetMaxTextLen( MAX_DESCR_LEN );
+
pNameCell->SetHelpId(HID_TABDESIGN_NAMECELL);
pTypeCell->SetHelpId(HID_TABDESIGN_TYPECELL);
pDescrCell->SetHelpId(HID_TABDESIGN_COMMENTCELL);
+ pHelpTextCell->SetHelpId(HID_TABDESIGN_HELPTEXT);
Size aHeight;
- const Control* pControls[] = { pTypeCell,pDescrCell,pNameCell};
+ const Control* pControls[] = { pTypeCell,pDescrCell,pNameCell,pHelpTextCell};
for(sal_Size i= 0; i < sizeof(pControls)/sizeof(pControls[0]);++i)
{
const Size aTemp( pControls[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) );
@@ -365,6 +379,7 @@ void OTableEditorCtrl::ClearModified()
DBG_CHKTHIS(OTableEditorCtrl,NULL);
pNameCell->ClearModifyFlag();
pDescrCell->ClearModifyFlag();
+ pHelpTextCell->ClearModifyFlag();
pTypeCell->SaveValue();
}
@@ -396,6 +411,7 @@ OTableEditorCtrl::~OTableEditorCtrl()
delete pNameCell;
delete pTypeCell;
delete pDescrCell;
+ delete pHelpTextCell;
}
//------------------------------------------------------------------------------
@@ -471,10 +487,16 @@ CellController* OTableEditorCtrl::GetController(long nRow, sal_uInt16 nColumnId)
if (pActFieldDescr && (pActFieldDescr->GetName().getLength() != 0))
return new ListBoxCellController( pTypeCell );
else return NULL;
- case FIELD_DESCR:
+ case HELP_TEXT:
+ if (pActFieldDescr && (pActFieldDescr->GetName().getLength() != 0))
+ return new EditCellController( pHelpTextCell );
+ else
+ return NULL;
+ case COLUMN_DESCRIPTION:
if (pActFieldDescr && (pActFieldDescr->GetName().getLength() != 0))
return new EditCellController( pDescrCell );
- else return NULL;
+ else
+ return NULL;
default:
return NULL;
}
@@ -516,7 +538,13 @@ void OTableEditorCtrl::InitController(CellControllerRef&, long nRow, sal_uInt16
}
break;
- case FIELD_DESCR:
+ case HELP_TEXT:
+ if( pActFieldDescr )
+ aInitString = pActFieldDescr->GetHelpText();
+ pHelpTextCell->SetText( aInitString );
+ pHelpTextCell->SaveValue();
+ break;
+ case COLUMN_DESCRIPTION:
if( pActFieldDescr )
aInitString = pActFieldDescr->GetDescription();
pDescrCell->SetText( aInitString );
@@ -576,7 +604,8 @@ void OTableEditorCtrl::DisplayData(long nRow, sal_Bool bGrabFocus)
CellControllerRef aTemp;
InitController(aTemp, nRow, FIELD_NAME);
InitController(aTemp, nRow, FIELD_TYPE);
- InitController(aTemp, nRow, FIELD_DESCR);
+ InitController(aTemp, nRow, COLUMN_DESCRIPTION);
+ InitController(aTemp, nRow, HELP_TEXT);
GoToRow(nRow);
// das Description-Window aktualisieren
@@ -601,7 +630,8 @@ void OTableEditorCtrl::CursorMoved()
CellControllerRef aTemp;
InitController(aTemp,m_nDataPos,FIELD_NAME);
InitController(aTemp,m_nDataPos,FIELD_TYPE);
- InitController(aTemp,m_nDataPos,FIELD_DESCR);
+ InitController(aTemp,m_nDataPos,COLUMN_DESCRIPTION);
+ InitController(aTemp,m_nDataPos,HELP_TEXT);
}
OTableRowView::CursorMoved();
@@ -675,7 +705,20 @@ sal_Bool OTableEditorCtrl::SaveData(long nRow, sal_uInt16 nColId)
//////////////////////////////////////////////////////////////
// Speichern Inhalt DescrCell
- case FIELD_DESCR:
+ case HELP_TEXT:
+ {
+ //////////////////////////////////////////////////////////////
+ // Wenn aktuelle Feldbeschreibung NULL, Default setzen
+ if( !pActFieldDescr )
+ {
+ pHelpTextCell->SetText(String());
+ pHelpTextCell->ClearModifyFlag();
+ }
+ else
+ pActFieldDescr->SetHelpText( pHelpTextCell->GetText() );
+ break;
+ }
+ case COLUMN_DESCRIPTION:
{
//////////////////////////////////////////////////////////////
// Wenn aktuelle Feldbeschreibung NULL, Default setzen
@@ -811,7 +854,8 @@ void OTableEditorCtrl::CellModified( long nRow, sal_uInt16 nColId )
{
case FIELD_NAME: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_NAME ) ); break;
case FIELD_TYPE: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_TYPE ) ); break;
- case FIELD_DESCR: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_DESCRIPTION ) ); break;
+ case HELP_TEXT:
+ case COLUMN_DESCRIPTION: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_DESCRIPTION ) ); break;
default: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_ATTRIBUTE ) ); break;
}
@@ -1176,7 +1220,7 @@ void OTableEditorCtrl::SetCellData( long nRow, sal_uInt16 nColId, const ::com::s
OSL_ENSURE(sal_False, "OTableEditorCtrl::SetCellData: invalid column!");
break;
- case FIELD_DESCR:
+ case COLUMN_DESCRIPTION:
pFieldDescr->SetDescription( sValue = ::comphelper::getString(_rNewData) );
break;
@@ -1265,9 +1309,12 @@ Any OTableEditorCtrl::GetCellData( long nRow, sal_uInt16 nColId )
sValue = pFieldDescr->getTypeInfo()->aUIName;
break;
- case FIELD_DESCR:
+ case COLUMN_DESCRIPTION:
sValue = pFieldDescr->GetDescription();
break;
+ case HELP_TEXT:
+ sValue = pFieldDescr->GetHelpText();
+ break;
case FIELD_PROPERTY_DEFAULT:
return pFieldDescr->GetControlDefault();
@@ -1347,16 +1394,24 @@ sal_Bool OTableEditorCtrl::IsCutAllowed( long nRow )
if(bIsCutAllowed)
{
- if(m_eChildFocus == DESCRIPTION)
- bIsCutAllowed = pDescrCell->GetSelected().Len() != 0;
- else if(m_eChildFocus == NAME)
- bIsCutAllowed = pNameCell->GetSelected().Len() != 0;
- else if(m_eChildFocus == ROW)
- // only rows are selected for cutting so we look if all rows are valid
- // wwe don't waant to copy empty rows here
- bIsCutAllowed = IsCopyAllowed(nRow);
- else
- bIsCutAllowed = sal_False;
+ switch(m_eChildFocus)
+ {
+ case DESCRIPTION:
+ bIsCutAllowed = pDescrCell->GetSelected().Len() != 0;
+ break;
+ case HELPTEXT:
+ bIsCutAllowed = pHelpTextCell->GetSelected().Len() != 0;
+ break;
+ case NAME:
+ bIsCutAllowed = pNameCell->GetSelected().Len() != 0;
+ break;
+ case ROW:
+ bIsCutAllowed = IsCopyAllowed(nRow);
+ break;
+ default:
+ bIsCutAllowed = sal_False;
+ break;
+ }
}
// Reference<XPropertySet> xTable = GetView()->getController().getTable();
@@ -1372,8 +1427,10 @@ sal_Bool OTableEditorCtrl::IsCopyAllowed( long /*nRow*/ )
{
DBG_CHKTHIS(OTableEditorCtrl,NULL);
sal_Bool bIsCopyAllowed = sal_False;
- if(m_eChildFocus == DESCRIPTION)
+ if(m_eChildFocus == DESCRIPTION )
bIsCopyAllowed = pDescrCell->GetSelected().Len() != 0;
+ else if(HELPTEXT == m_eChildFocus )
+ bIsCopyAllowed = pHelpTextCell->GetSelected().Len() != 0;
else if(m_eChildFocus == NAME)
bIsCopyAllowed = pNameCell->GetSelected().Len() != 0;
else if(m_eChildFocus == ROW)
@@ -1435,9 +1492,18 @@ void OTableEditorCtrl::cut()
{
if(GetView()->getController().isAlterAllowed())
{
- SaveData(-1,FIELD_DESCR);
+ SaveData(-1,COLUMN_DESCRIPTION);
pDescrCell->Cut();
- CellModified(-1,FIELD_DESCR);
+ CellModified(-1,COLUMN_DESCRIPTION);
+ }
+ }
+ else if(HELPTEXT == m_eChildFocus )
+ {
+ if(GetView()->getController().isAlterAllowed())
+ {
+ SaveData(-1,HELP_TEXT);
+ pHelpTextCell->Cut();
+ CellModified(-1,HELP_TEXT);
}
}
else if(m_eChildFocus == ROW)
@@ -1455,7 +1521,9 @@ void OTableEditorCtrl::copy()
OTableRowView::copy();
else if(m_eChildFocus == NAME)
pNameCell->Copy();
- else if(m_eChildFocus == DESCRIPTION)
+ else if(HELPTEXT == m_eChildFocus )
+ pHelpTextCell->Copy();
+ else if(m_eChildFocus == DESCRIPTION )
pDescrCell->Copy();
}
@@ -1477,6 +1545,14 @@ void OTableEditorCtrl::paste()
CellModified();
}
}
+ else if(HELPTEXT == m_eChildFocus )
+ {
+ if(GetView()->getController().isAlterAllowed())
+ {
+ pHelpTextCell->Paste();
+ CellModified();
+ }
+ }
else if(m_eChildFocus == DESCRIPTION)
{
if(GetView()->getController().isAlterAllowed())
@@ -1493,16 +1569,6 @@ sal_Bool OTableEditorCtrl::IsDeleteAllowed( long /*nRow*/ )
DBG_CHKTHIS(OTableEditorCtrl,NULL);
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());
}
//------------------------------------------------------------------------------
@@ -1933,7 +1999,9 @@ long OTableEditorCtrl::PreNotify( NotifyEvent& rNEvt )
{
if (rNEvt.GetType() == EVENT_GETFOCUS)
{
- if( pDescrCell && pDescrCell->HasChildPathFocus() )
+ if( pHelpTextCell && pHelpTextCell->HasChildPathFocus() )
+ m_eChildFocus = HELPTEXT;
+ else if( pDescrCell && pDescrCell->HasChildPathFocus() )
m_eChildFocus = DESCRIPTION;
else if(pNameCell && pNameCell->HasChildPathFocus() )
m_eChildFocus = NAME;