summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/tabledesign
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/tabledesign')
-rw-r--r--dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx203
-rw-r--r--dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx88
-rw-r--r--dbaccess/source/ui/tabledesign/FieldDescriptions.cxx670
-rw-r--r--dbaccess/source/ui/tabledesign/TEditControl.cxx1950
-rw-r--r--dbaccess/source/ui/tabledesign/TEditControl.hxx230
-rw-r--r--dbaccess/source/ui/tabledesign/TableController.cxx1629
-rw-r--r--dbaccess/source/ui/tabledesign/TableDesignControl.cxx241
-rw-r--r--dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx130
-rw-r--r--dbaccess/source/ui/tabledesign/TableDesignView.cxx400
-rw-r--r--dbaccess/source/ui/tabledesign/TableFieldControl.cxx177
-rw-r--r--dbaccess/source/ui/tabledesign/TableFieldControl.hxx72
-rw-r--r--dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx337
-rw-r--r--dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx115
-rw-r--r--dbaccess/source/ui/tabledesign/TableRow.cxx232
-rw-r--r--dbaccess/source/ui/tabledesign/TableRowExchange.cxx97
-rw-r--r--dbaccess/source/ui/tabledesign/TableUndo.cxx495
-rw-r--r--dbaccess/source/ui/tabledesign/TableUndo.hxx178
-rw-r--r--dbaccess/source/ui/tabledesign/makefile.mk65
-rw-r--r--dbaccess/source/ui/tabledesign/table.src409
19 files changed, 7718 insertions, 0 deletions
diff --git a/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx b/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx
new file mode 100644
index 000000000000..727de7fe60ea
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx
@@ -0,0 +1,203 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_TABLEFIELDDESCGENPAGE_HXX
+#include "FieldDescGenWin.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef DBAUI_TABLEDESIGNHELPBAR_HXX
+#include "TableDesignHelpBar.hxx"
+#endif
+#ifndef DBAUI_TABLEFIELDCONTROL_HXX
+#include "TableFieldControl.hxx"
+#endif
+#ifndef DBAUI_TABLEDESIGNVIEW_HXX
+#include "TableDesignView.hxx"
+#endif
+#ifndef DBAUI_TABLEEDITORCONTROL_HXX
+#include "TEditControl.hxx"
+#endif
+using namespace dbaui;
+
+//==================================================================
+// class OFieldDescGenWin
+//==================================================================
+
+DBG_NAME(OFieldDescGenWin)
+//==================================================================
+//------------------------------------------------------------------------------
+OFieldDescGenWin::OFieldDescGenWin( Window* pParent, OTableDesignHelpBar* pHelp ) :
+ TabPage( pParent, WB_3DLOOK | WB_DIALOGCONTROL )
+{
+ DBG_CTOR(OFieldDescGenWin,NULL);
+ m_pFieldControl = new OTableFieldControl(this,pHelp);
+ m_pFieldControl->SetHelpId(HID_TAB_DESIGN_FIELDCONTROL);
+ m_pFieldControl->Show();
+}
+//------------------------------------------------------------------------------
+OFieldDescGenWin::~OFieldDescGenWin()
+{
+ DBG_DTOR(OFieldDescGenWin,NULL);
+ ::std::auto_ptr<Window> aTemp(m_pFieldControl);
+ m_pFieldControl = NULL;
+}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::Init()
+{
+ DBG_ASSERT(GetEditorCtrl() != NULL, "OFieldDescGenWin::Init : have no editor control !");
+
+ m_pFieldControl->Init();
+}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::Resize()
+{
+ m_pFieldControl->SetPosSizePixel(Point(0,0),GetSizePixel());
+ m_pFieldControl->Resize();
+}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::SetReadOnly( sal_Bool bReadOnly )
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+
+ m_pFieldControl->SetReadOnly(bReadOnly);
+}
+//------------------------------------------------------------------------------
+String OFieldDescGenWin::GetControlText( sal_uInt16 nControlId )
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+ return m_pFieldControl->GetControlText(nControlId);
+}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::SetControlText( sal_uInt16 nControlId, const String& rText )
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Texte der Controls setzen
+ m_pFieldControl->SetControlText(nControlId,rText);
+}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::DisplayData( OFieldDescription* pFieldDescr )
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+
+ m_pFieldControl->DisplayData(pFieldDescr);
+}
+//------------------------------------------------------------------------------
+#if OSL_DEBUG_LEVEL > 0
+OTableEditorCtrl* OFieldDescGenWin::GetEditorCtrl()
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+ OTableDesignView* pDesignWin = static_cast<OTableDesignView*>(GetParent()->GetParent()->GetParent());
+ return pDesignWin->GetEditorCtrl();
+}
+#endif
+//------------------------------------------------------------------------------
+//short OFieldDescGenWin::GetFormatCategory(OFieldDescription* pFieldDescr)
+//{
+// return m_pFieldControl->GetFormatCategory(pFieldDescr);
+//}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::SaveData( OFieldDescription* pFieldDescr )
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+ m_pFieldControl->SaveData(pFieldDescr);
+}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::GetFocus()
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Setzt den Focus auf das zuletzt aktive Control
+ TabPage::GetFocus();
+ if(m_pFieldControl)
+ m_pFieldControl->GetFocus();
+
+}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::LoseFocus()
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+ m_pFieldControl->LoseFocus();
+ TabPage::LoseFocus();
+}
+//------------------------------------------------------------------
+String OFieldDescGenWin::BoolStringPersistent(const String& rUIString) const
+{
+ return m_pFieldControl->BoolStringPersistent(rUIString);
+}
+
+//------------------------------------------------------------------
+String OFieldDescGenWin::BoolStringUI(const String& rPersistentString) const
+{
+ return m_pFieldControl->BoolStringUI(rPersistentString);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescGenWin::isCopyAllowed()
+{
+ return (m_pFieldControl && m_pFieldControl->isCutAllowed());
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescGenWin::isCutAllowed()
+{
+ return (m_pFieldControl && m_pFieldControl->isCutAllowed());
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescGenWin::isPasteAllowed()
+{
+ return (m_pFieldControl && m_pFieldControl->isPasteAllowed());
+}
+// -----------------------------------------------------------------------------
+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
new file mode 100644
index 000000000000..de6ea4b0ff49
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEFIELDDESCGENPAGE_HXX
+#define DBAUI_TABLEFIELDDESCGENPAGE_HXX
+
+#ifndef _SV_TABPAGE_HXX
+#include <vcl/tabpage.hxx>
+#endif
+#ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+#include "IClipBoardTest.hxx"
+#endif
+
+namespace dbaui
+{
+ class OTableDesignHelpBar;
+ class OFieldDescription;
+ class OTableFieldControl;
+ class OTableEditorCtrl;
+ //==================================================================
+ class OFieldDescGenWin : public TabPage
+ ,public IClipboardTest
+ {
+
+ OTableFieldControl *m_pFieldControl;
+ protected:
+ virtual void Resize();
+
+ public:
+ OFieldDescGenWin( Window* pParent, OTableDesignHelpBar* pHelpBar );
+ virtual ~OFieldDescGenWin();
+
+ virtual void GetFocus();
+ virtual void LoseFocus();
+ virtual void Init();
+
+ void DisplayData( OFieldDescription* pFieldDescr );
+ void SaveData( OFieldDescription* pFieldDescr );
+ void SetControlText( USHORT nControlId, const String& rText );
+ String GetControlText( USHORT nControlId );
+ void SetReadOnly( BOOL bReadOnly );
+#if OSL_DEBUG_LEVEL > 0
+ OTableEditorCtrl* GetEditorCtrl();
+#endif
+ // short GetFormatCategory(OFieldDescription* pFieldDescr);
+ // liefert zum am Feld eingestellten Format einen der CAT_xxx-Werte (CAT_NUMBER, CAT_DATE ...)
+
+ String BoolStringPersistent(const String& rUIString) const;
+ String BoolStringUI(const String& rPersistentString) const;
+
+ // IClipboardTest
+ virtual sal_Bool isCutAllowed();
+ virtual sal_Bool isCopyAllowed();
+ virtual sal_Bool isPasteAllowed();
+ virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
+
+ virtual void copy();
+ virtual void cut();
+ virtual void paste();
+
+ inline OTableFieldControl* getFieldControl() const { return m_pFieldControl; }
+ };
+}
+#endif // DBAUI_TABLEFIELDDESCGENPAGE_HXX
+
diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
new file mode 100644
index 000000000000..bd2a83d87364
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
@@ -0,0 +1,670 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _DBU_TBL_HRC_
+#include "dbu_tbl.hrc"
+#endif
+#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
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
+#include <com/sun/star/util/NumberFormat.hpp>
+#endif
+
+#define DEFAULT_VARCHAR_PRECSION 50
+#define DEFAULT_OTHER_PRECSION 16
+#define DEFAULT_NUMERIC_PRECSION 5
+#define DEFAULT_NUMERIC_SCALE 0
+
+
+using namespace dbaui;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+
+//========================================================================
+// class OFieldDescription
+//========================================================================
+DBG_NAME(OFieldDescription)
+//------------------------------------------------------------------------------
+OFieldDescription::OFieldDescription()
+ :m_pType()
+ ,m_nType(DataType::VARCHAR)
+ ,m_nPrecision(0)
+ ,m_nScale(0)
+ ,m_nIsNullable(ColumnValue::NULLABLE)
+ ,m_nFormatKey(0)
+ ,m_eHorJustify(SVX_HOR_JUSTIFY_STANDARD)
+ ,m_bIsAutoIncrement(sal_False)
+ ,m_bIsPrimaryKey(sal_False)
+ ,m_bIsCurrency(sal_False)
+ ,m_bHidden(sal_False)
+{
+ DBG_CTOR(OFieldDescription,NULL);
+}
+//------------------------------------------------------------------------------
+OFieldDescription::OFieldDescription( const OFieldDescription& rDescr )
+ :m_aDefaultValue(rDescr.m_aDefaultValue)
+ ,m_aControlDefault(rDescr.m_aControlDefault)
+ ,m_aWidth(rDescr.m_aWidth)
+ ,m_aRelativePosition(rDescr.m_aRelativePosition)
+ ,m_pType(rDescr.m_pType)
+ ,m_xDest(rDescr.m_xDest)
+ ,m_xDestInfo(rDescr.m_xDestInfo)
+ ,m_sName(rDescr.m_sName)
+ ,m_sTypeName(rDescr.m_sTypeName)
+ ,m_sDescription(rDescr.m_sDescription)
+ ,m_sAutoIncrementValue(rDescr.m_sAutoIncrementValue)
+ ,m_nType(rDescr.m_nType)
+ ,m_nPrecision(rDescr.m_nPrecision)
+ ,m_nScale(rDescr.m_nScale)
+ ,m_nIsNullable(rDescr.m_nIsNullable)
+ ,m_nFormatKey(rDescr.m_nFormatKey)
+ ,m_eHorJustify(rDescr.m_eHorJustify)
+ ,m_bIsAutoIncrement(rDescr.m_bIsAutoIncrement)
+ ,m_bIsPrimaryKey(rDescr.m_bIsPrimaryKey)
+ ,m_bIsCurrency(rDescr.m_bIsCurrency)
+ ,m_bHidden(rDescr.m_bHidden)
+{
+ DBG_CTOR(OFieldDescription,NULL);
+}
+
+//------------------------------------------------------------------------------
+OFieldDescription::~OFieldDescription()
+{
+ DBG_DTOR(OFieldDescription,NULL);
+}
+//------------------------------------------------------------------------------
+OFieldDescription::OFieldDescription(const Reference< XPropertySet >& xAffectedCol,sal_Bool _bUseAsDest)
+ :m_pType()
+ ,m_nType(DataType::VARCHAR)
+ ,m_nPrecision(0)
+ ,m_nScale(0)
+ ,m_nIsNullable(ColumnValue::NULLABLE)
+ ,m_nFormatKey(0)
+ ,m_eHorJustify(SVX_HOR_JUSTIFY_STANDARD)
+ ,m_bIsAutoIncrement(sal_False)
+ ,m_bIsPrimaryKey(sal_False)
+ ,m_bIsCurrency(sal_False)
+ ,m_bHidden(sal_False)
+{
+ DBG_CTOR(OFieldDescription,NULL);
+ OSL_ENSURE(xAffectedCol.is(),"PropetySet can notbe null!");
+ if ( xAffectedCol.is() )
+ {
+ if ( _bUseAsDest )
+ {
+ m_xDest = xAffectedCol;
+ m_xDestInfo = xAffectedCol->getPropertySetInfo();;
+ }
+ else
+ {
+ try
+ {
+ 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( xAffectedCol->getPropertyValue(PROPERTY_DEFAULTVALUE) );
+
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT))
+ SetControlDefault( xAffectedCol->getPropertyValue(PROPERTY_CONTROLDEFAULT) );
+
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION))
+ SetAutoIncrementValue(::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_AUTOINCREMENTCREATION)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_TYPE))
+ SetTypeValue(::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_TYPE)));
+ if (xPropSetInfo->hasPropertyByName(PROPERTY_TYPENAME))
+ SetTypeName(::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_TYPENAME)));
+ 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))
+ {
+ const Any aValue = xAffectedCol->getPropertyValue(PROPERTY_FORMATKEY);
+ if ( aValue.hasValue() )
+ SetFormatKey(::comphelper::getINT32(aValue));
+ }
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_RELATIVEPOSITION))
+ m_aRelativePosition = xAffectedCol->getPropertyValue(PROPERTY_RELATIVEPOSITION);
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_WIDTH))
+ m_aWidth = xAffectedCol->getPropertyValue(PROPERTY_WIDTH);
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_HIDDEN))
+ xAffectedCol->getPropertyValue(PROPERTY_HIDDEN) >>= m_bHidden;
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_ALIGN))
+ {
+ const Any aValue = xAffectedCol->getPropertyValue(PROPERTY_ALIGN);
+ if ( aValue.hasValue() )
+ SetHorJustify( ::dbaui::mapTextJustify(::comphelper::getINT32(aValue)));
+ }
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_ISAUTOINCREMENT))
+ SetAutoIncrement(::cppu::any2bool(xAffectedCol->getPropertyValue(PROPERTY_ISAUTOINCREMENT)));
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::FillFromTypeInfo(const TOTypeInfoSP& _pType,sal_Bool _bForce,sal_Bool _bReset)
+{
+ TOTypeInfoSP pOldType = getTypeInfo();
+ if ( _pType != pOldType )
+ {
+ // reset type depending information
+ if ( _bReset )
+ {
+ SetFormatKey(0);
+ SetControlDefault(Any());
+ }
+
+ sal_Bool bForce = _bForce || pOldType.get() == NULL || pOldType->nType != _pType->nType;
+ switch ( _pType->nType )
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ if ( bForce )
+ {
+ sal_Int32 nPrec = DEFAULT_VARCHAR_PRECSION;
+ if ( GetPrecision() )
+ nPrec = GetPrecision();
+ SetPrecision(::std::min<sal_Int32>(nPrec,_pType->nPrecision));
+ }
+ break;
+ case DataType::TIMESTAMP:
+ if ( bForce && _pType->nMaximumScale)
+ {
+ SetScale(::std::min<sal_Int32>(GetScale() ? GetScale() : DEFAULT_NUMERIC_SCALE,_pType->nMaximumScale));
+ }
+ break;
+ default:
+ if ( bForce )
+ {
+ sal_Int32 nPrec = DEFAULT_OTHER_PRECSION;
+ switch ( _pType->nType )
+ {
+ case DataType::BIT:
+ case DataType::BLOB:
+ case DataType::CLOB:
+ nPrec = _pType->nPrecision;
+ break;
+ default:
+ if ( GetPrecision() )
+ nPrec = GetPrecision();
+ break;
+ }
+
+ if ( _pType->nPrecision )
+ SetPrecision(::std::min<sal_Int32>(nPrec ? nPrec : DEFAULT_NUMERIC_PRECSION,_pType->nPrecision));
+ if ( _pType->nMaximumScale )
+ SetScale(::std::min<sal_Int32>(GetScale() ? GetScale() : DEFAULT_NUMERIC_SCALE,_pType->nMaximumScale));
+ }
+ }
+ if ( !_pType->aCreateParams.getLength() )
+ {
+ SetPrecision(_pType->nPrecision);
+ SetScale(_pType->nMinimumScale);
+ }
+ if ( !_pType->bNullable && IsNullable() )
+ SetIsNullable(ColumnValue::NO_NULLS);
+ if ( !_pType->bAutoIncrement && IsAutoIncrement() )
+ SetAutoIncrement(sal_False);
+ SetCurrency( _pType->bCurrency );
+ SetType(_pType);
+ SetTypeName(_pType->aTypeName);
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetName(const ::rtl::OUString& _rName)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_NAME) )
+ m_xDest->setPropertyValue(PROPERTY_NAME,makeAny(_rName));
+ else
+ m_sName = _rName;
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetDescription(const ::rtl::OUString& _rDescription)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_DESCRIPTION) )
+ m_xDest->setPropertyValue(PROPERTY_DESCRIPTION,makeAny(_rDescription));
+ else
+ m_sDescription = _rDescription;
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetDefaultValue(const Any& _rDefaultValue)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_DEFAULTVALUE) )
+ m_xDest->setPropertyValue(PROPERTY_DEFAULTVALUE,makeAny(_rDefaultValue));
+ else
+ m_aDefaultValue = _rDefaultValue;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetControlDefault(const Any& _rControlDefault)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT) )
+ m_xDest->setPropertyValue(PROPERTY_CONTROLDEFAULT,makeAny(_rControlDefault));
+ else
+ m_aControlDefault = _rControlDefault;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetAutoIncrementValue(const ::rtl::OUString& _sAutoIncValue)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION) )
+ m_xDest->setPropertyValue(PROPERTY_AUTOINCREMENTCREATION,makeAny(_sAutoIncValue));
+ else
+ m_sAutoIncrementValue = _sAutoIncValue;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetType(TOTypeInfoSP _pType)
+{
+ m_pType = _pType;
+ if ( m_pType.get() )
+ {
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_TYPE) )
+ m_xDest->setPropertyValue(PROPERTY_TYPE,makeAny(m_pType->nType));
+ else
+ m_nType = m_pType->nType;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetTypeValue(sal_Int32 _nType)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_TYPE) )
+ m_xDest->setPropertyValue(PROPERTY_TYPE,makeAny(_nType));
+ else
+ {
+ m_nType = _nType;
+ OSL_ENSURE(!m_pType.get(),"Invalid call here!");
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetPrecision(const sal_Int32& _rPrecision)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_PRECISION) )
+ m_xDest->setPropertyValue(PROPERTY_PRECISION,makeAny(_rPrecision));
+ else
+ m_nPrecision = _rPrecision;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetScale(const sal_Int32& _rScale)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_SCALE) )
+ m_xDest->setPropertyValue(PROPERTY_SCALE,makeAny(_rScale));
+ else
+ m_nScale = _rScale;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetIsNullable(const sal_Int32& _rIsNullable)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ISNULLABLE) )
+ m_xDest->setPropertyValue(PROPERTY_ISNULLABLE,makeAny(_rIsNullable));
+ else
+ m_nIsNullable = _rIsNullable;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetFormatKey(const sal_Int32& _rFormatKey)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_FORMATKEY) )
+ m_xDest->setPropertyValue(PROPERTY_FORMATKEY,makeAny(_rFormatKey));
+ else
+ m_nFormatKey = _rFormatKey;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetHorJustify(const SvxCellHorJustify& _rHorJustify)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ALIGN) )
+ m_xDest->setPropertyValue(PROPERTY_ALIGN,makeAny( dbaui::mapTextAllign(_rHorJustify)));
+ else
+ m_eHorJustify = _rHorJustify;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetAutoIncrement(sal_Bool _bAuto)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ISAUTOINCREMENT) )
+ m_xDest->setPropertyValue(PROPERTY_ISAUTOINCREMENT,makeAny(_bAuto));
+ else
+ m_bIsAutoIncrement = _bAuto;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetPrimaryKey(sal_Bool _bPKey)
+{
+ m_bIsPrimaryKey = _bPKey;
+ if ( _bPKey )
+ SetIsNullable(::com::sun::star::sdbc::ColumnValue::NO_NULLS);
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetCurrency(sal_Bool _bIsCurrency)
+{
+ m_bIsCurrency = _bIsCurrency;
+}
+// -----------------------------------------------------------------------------
+
+::rtl::OUString OFieldDescription::GetName() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_NAME) )
+ return ::comphelper::getString(m_xDest->getPropertyValue(PROPERTY_NAME));
+ else
+ return m_sName;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OFieldDescription::GetDescription() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_DESCRIPTION) )
+ return ::comphelper::getString(m_xDest->getPropertyValue(PROPERTY_DESCRIPTION));
+ else
+ return m_sDescription;
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Any OFieldDescription::GetControlDefault() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT) )
+ return m_xDest->getPropertyValue(PROPERTY_CONTROLDEFAULT);
+ else
+ return m_aControlDefault;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OFieldDescription::GetAutoIncrementValue() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION) )
+ return ::comphelper::getString(m_xDest->getPropertyValue(PROPERTY_AUTOINCREMENTCREATION));
+ else
+ return m_sAutoIncrementValue;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OFieldDescription::GetType() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_TYPE) )
+ return ::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_TYPE));
+ else
+ return m_pType.get() ? m_pType->nType : m_nType;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OFieldDescription::GetTypeName() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_TYPENAME) )
+ return ::comphelper::getString(m_xDest->getPropertyValue(PROPERTY_TYPENAME));
+ else
+ return m_pType.get() ? m_pType->aTypeName : m_sTypeName;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OFieldDescription::GetPrecision() const
+{
+ sal_Int32 nPrec = m_nPrecision;
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_PRECISION) )
+ nPrec = ::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_PRECISION));
+
+ TOTypeInfoSP pTypeInfo = getTypeInfo();
+ if ( pTypeInfo )
+ {
+ switch ( pTypeInfo->nType )
+ {
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::BIGINT:
+ if ( !nPrec )
+ nPrec = pTypeInfo->nPrecision;
+ break;
+ } // switch ( pTypeInfo->nType )
+ }
+
+ return nPrec;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OFieldDescription::GetScale() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_SCALE) )
+ return ::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_SCALE));
+ else
+ return m_nScale;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OFieldDescription::GetIsNullable() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ISNULLABLE) )
+ return ::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_ISNULLABLE));
+ else
+ return m_nIsNullable;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OFieldDescription::GetFormatKey() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_FORMATKEY) )
+ return ::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_FORMATKEY));
+ else
+ return m_nFormatKey;
+}
+// -----------------------------------------------------------------------------
+SvxCellHorJustify OFieldDescription::GetHorJustify() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ALIGN) )
+ return ::dbaui::mapTextJustify(::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_ALIGN)));
+ else
+ return m_eHorJustify;
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OFieldDescription::getTypeInfo() const
+{
+ return m_pType;
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OFieldDescription::getSpecialTypeInfo() const
+{
+ TOTypeInfoSP pSpecialType( new OTypeInfo() );
+ *pSpecialType = *m_pType;
+ pSpecialType->nPrecision = GetPrecision();
+ pSpecialType->nMaximumScale = static_cast<sal_Int16>(GetScale());
+ return pSpecialType;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescription::IsAutoIncrement() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ISAUTOINCREMENT) )
+ return ::cppu::any2bool(m_xDest->getPropertyValue(PROPERTY_ISAUTOINCREMENT));
+ else
+ return m_bIsAutoIncrement;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescription::IsPrimaryKey() const
+{
+ return m_bIsPrimaryKey;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescription::IsCurrency() const
+{
+ return m_bIsCurrency;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescription::IsNullable() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ISNULLABLE) )
+ return ::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_ISNULLABLE)) == ::com::sun::star::sdbc::ColumnValue::NULLABLE;
+ else
+ return m_nIsNullable == ::com::sun::star::sdbc::ColumnValue::NULLABLE;
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetTypeName(const ::rtl::OUString& _sTypeName)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_TYPENAME) )
+ m_xDest->setPropertyValue(PROPERTY_TYPENAME,makeAny(_sTypeName));
+ else
+ m_sTypeName = _sTypeName;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::copyColumnSettingsTo(const Reference< XPropertySet >& _rxColumn)
+{
+ if ( _rxColumn.is() )
+ {
+ Reference<XPropertySetInfo> xInfo = _rxColumn->getPropertySetInfo();
+
+ if ( GetFormatKey() != NumberFormat::ALL && xInfo->hasPropertyByName(PROPERTY_FORMATKEY) )
+ _rxColumn->setPropertyValue(PROPERTY_FORMATKEY,makeAny(GetFormatKey()));
+ if ( GetHorJustify() != SVX_HOR_JUSTIFY_STANDARD && xInfo->hasPropertyByName(PROPERTY_ALIGN) )
+ _rxColumn->setPropertyValue(PROPERTY_ALIGN,makeAny(dbaui::mapTextAllign(GetHorJustify())));
+ if ( GetDescription().getLength() && xInfo->hasPropertyByName(PROPERTY_HELPTEXT) )
+ _rxColumn->setPropertyValue(PROPERTY_HELPTEXT,makeAny(GetDescription()));
+ if ( GetControlDefault().hasValue() && xInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT) )
+ _rxColumn->setPropertyValue(PROPERTY_CONTROLDEFAULT,GetControlDefault());
+
+ if(xInfo->hasPropertyByName(PROPERTY_RELATIVEPOSITION))
+ _rxColumn->setPropertyValue(PROPERTY_RELATIVEPOSITION,m_aRelativePosition);
+ if(xInfo->hasPropertyByName(PROPERTY_WIDTH))
+ _rxColumn->setPropertyValue(PROPERTY_WIDTH,m_aWidth);
+ if(xInfo->hasPropertyByName(PROPERTY_HIDDEN))
+ _rxColumn->setPropertyValue(PROPERTY_HIDDEN,makeAny(m_bHidden));
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx
new file mode 100644
index 000000000000..40741ac02bb7
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx
@@ -0,0 +1,1950 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_TABLEEDITORCONTROL_HXX
+#include "TEditControl.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#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_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#endif
+#ifndef _DBU_TBL_HRC_
+#include "dbu_tbl.hrc"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX
+#include "FieldDescControl.hxx"
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef DBAUI_TABLEUNDO_HXX
+#include "TableUndo.hxx"
+#endif
+#ifndef DBUI_TABLECONTROLLER_HXX
+#include "TableController.hxx"
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#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
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX
+#include "FieldDescControl.hxx"
+#endif
+#ifndef DBAUI_TABLEFIELDCONTROL_HXX
+#include "TableFieldControl.hxx"
+#endif
+
+using namespace ::dbaui;
+using namespace ::comphelper;
+using namespace ::svt;
+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
+{
+ extern String GetTypeString( sal_uInt16 nType );
+}
+//==============================================================================
+
+// TYPEINIT1(OTableEditorCtrl, DBView);
+DBG_NAME(OTableEditorCtrl)
+
+//==============================================================================
+
+#define HANDLE_ID 0
+
+// Anzahl Spalten beim Neuanlegen
+#define NEWCOLS 128
+
+// default Spaltenbreiten
+#define FIELDNAME_WIDTH 100
+#define FIELDTYPE_WIDTH 150
+#define FIELDDESCR_WIDTH 300
+
+// Maximale Eingabelaenge im Beschreibungsfeld
+#define MAX_DESCR_LEN 256
+
+
+#define CONTROL_SPACING_X 18 // 6
+#define CONTROL_SPACING_Y 5
+#define CONTROL_HEIGHT 20
+#define CONTROL_WIDTH_1 140 // 100
+#define CONTROL_WIDTH_2 100 // 60
+#define CONTROL_WIDTH_3 250
+#define CONTROL_WIDTH_4 (CONTROL_WIDTH_3 - CONTROL_HEIGHT - 5)
+
+
+//==================================================================
+DBG_NAME(ClipboardInvalidator)
+//------------------------------------------------------------------
+OTableEditorCtrl::ClipboardInvalidator::ClipboardInvalidator(ULONG nTimeout,OTableEditorCtrl* _pOwner)
+: m_pOwner(_pOwner)
+{
+ DBG_CTOR(ClipboardInvalidator,NULL);
+
+ m_aInvalidateTimer.SetTimeout(nTimeout);
+ m_aInvalidateTimer.SetTimeoutHdl(LINK(this, OTableEditorCtrl::ClipboardInvalidator, OnInvalidate));
+ m_aInvalidateTimer.Start();
+}
+
+//------------------------------------------------------------------
+OTableEditorCtrl::ClipboardInvalidator::~ClipboardInvalidator()
+{
+ m_aInvalidateTimer.Stop();
+
+ DBG_DTOR(ClipboardInvalidator,NULL);
+}
+
+//------------------------------------------------------------------
+IMPL_LINK(OTableEditorCtrl::ClipboardInvalidator, OnInvalidate, void*, EMPTYARG)
+{
+ m_pOwner->GetView()->getController().InvalidateFeature(SID_CUT);
+ m_pOwner->GetView()->getController().InvalidateFeature(SID_COPY);
+ m_pOwner->GetView()->getController().InvalidateFeature(SID_PASTE);
+ return 0L;
+}
+
+//==================================================================
+void OTableEditorCtrl::Init()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ OTableRowView::Init();
+
+ //////////////////////////////////////////////////////////////////////
+ // Soll der Entwurf ReadOnly geoeffnet werden ?
+ sal_Bool bRead(GetView()->getController().isReadOnly());
+
+ SetReadOnly( bRead );
+
+ //////////////////////////////////////////////////////////////////////
+ // Spalten einfuegen
+ String aColumnName( ModuleRes(STR_TAB_FIELD_COLUMN_NAME) );
+ InsertDataColumn( 1, aColumnName, FIELDNAME_WIDTH );
+
+ aColumnName = String( ModuleRes(STR_TAB_FIELD_COLUMN_DATATYPE) );
+ InsertDataColumn( 2, aColumnName, FIELDTYPE_WIDTH );
+
+ aColumnName = String( ModuleRes(STR_TAB_FIELD_DESCR) );
+ InsertDataColumn( 3, aColumnName, FIELDDESCR_WIDTH );
+
+ InitCellController();
+
+ //////////////////////////////////////////////////////////////////////
+ // Zeilen einfuegen
+ RowInserted(0, m_pRowList->size(), sal_True);
+}
+
+//==================================================================
+void OTableEditorCtrl::UpdateAll()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ RowRemoved(0, GetRowCount(), sal_False);
+ m_nDataPos = 0;
+
+ InvalidateFeatures();
+ Invalidate();
+}
+//==================================================================
+OTableEditorCtrl::OTableEditorCtrl(Window* pWindow)
+ :OTableRowView(pWindow)
+ ,pNameCell(NULL)
+ ,pTypeCell(NULL)
+ ,pDescrCell(NULL)
+ ,pDescrWin(NULL)
+ ,nIndexEvent(0)
+ ,nCutEvent(0)
+ ,nPasteEvent(0)
+ ,nDeleteEvent(0)
+ ,nInsNewRowsEvent(0)
+ ,nInvalidateTypeEvent(0)
+ ,nEntryNotFoundEvent(0)
+ ,m_eChildFocus(NONE)
+ ,nOldDataPos(-1)
+ ,bSaveOnMove(sal_True)
+ ,bReadOnly(sal_True)
+ ,m_aInvalidate(500,this)
+{
+ DBG_CTOR(OTableEditorCtrl,NULL);
+
+ SetHelpId(HID_TABDESIGN_BACKGROUND);
+ GetDataWindow().SetHelpId(HID_CTL_TABLEEDIT);
+
+ m_pRowList = GetView()->getController().getRows();
+ m_nDataPos = 0;
+}
+
+//------------------------------------------------------------------------------
+SfxUndoManager* OTableEditorCtrl::GetUndoManager() const
+{
+ return GetView()->getController().getUndoMgr();
+}
+
+//------------------------------------------------------------------------------
+BOOL OTableEditorCtrl::IsReadOnly()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ return bReadOnly;
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::SetReadOnly( sal_Bool bRead )
+{
+ // nix zu tun ?
+ if (bRead == IsReadOnly())
+ // diese Abfrage ist wichtig, da die zugrundeliegende Def sonst im folgenden gelockt oder ge-unlocked wird, obwohl es
+ // nicht notwendig waere (und was schlimmer ist, das wuerde dann auch nicht wieder rueckgaengig gemacht)
+ return;
+
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ bReadOnly = bRead;
+
+ //////////////////////////////////////////////////////////////////////
+ // Aktive Zelle disablen
+ long nRow(GetCurRow());
+ sal_uInt16 nCol(GetCurColumnId());
+ DeactivateCell();
+
+ //////////////////////////////////////////////////////////////////////
+ // ::com::sun::star::beans::Property Controls disablen
+// if (pDescrWin)
+// pDescrWin->SetReadOnly(bReadOnly || !SetDataPtr(nRow) || GetActRow()->IsReadOnly());
+
+ //////////////////////////////////////////////////////////////////////
+ // Cursor des Browsers anpassen
+ BrowserMode nMode(BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | BROWSER_KEEPSELECTION |
+ BROWSER_HLINESFULL | BROWSER_VLINESFULL|BROWSER_AUTOSIZE_LASTCOL);
+ if( !bReadOnly )
+ nMode |= BROWSER_HIDECURSOR;
+ SetMode(nMode);
+
+ if( !bReadOnly )
+ ActivateCell( nRow, nCol );
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::InitCellController()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Zelle Feldname
+ xub_StrLen nMaxTextLen = EDIT_NOLIMIT;
+ ::rtl::OUString sExtraNameChars;
+ Reference<XConnection> xCon;
+ try
+ {
+ xCon = GetView()->getController().getConnection();
+ Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : Reference< XDatabaseMetaData>();
+
+ nMaxTextLen = ((xub_StrLen)xMetaData.is() ? static_cast<xub_StrLen>(xMetaData->getMaxColumnNameLength()) : 0);
+
+ if( nMaxTextLen == 0 )
+ nMaxTextLen = EDIT_NOLIMIT;
+ sExtraNameChars = xMetaData.is() ? xMetaData->getExtraNameCharacters() : ::rtl::OUString();
+
+ }
+ catch(SQLException&)
+ {
+ OSL_ASSERT(!"getMaxColumnNameLength");
+ }
+
+ pNameCell = new OSQLNameEdit( &GetDataWindow(), sExtraNameChars,WB_LEFT );
+ pNameCell->SetMaxTextLen( nMaxTextLen );
+ pNameCell->setCheck( isSQL92CheckEnabled(xCon) );
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Zelle Typ
+ pTypeCell = new ListBoxControl( &GetDataWindow() );
+ pTypeCell->SetDropDownLineCount( 15 );
+
+ //////////////////////////////////////////////////////////////////////
+ // Zelle Beschreibung
+ pDescrCell = new Edit( &GetDataWindow(), WB_LEFT );
+ pDescrCell->SetMaxTextLen( MAX_DESCR_LEN );
+
+ pNameCell->SetHelpId(HID_TABDESIGN_NAMECELL);
+ pTypeCell->SetHelpId(HID_TABDESIGN_TYPECELL);
+ pDescrCell->SetHelpId(HID_TABDESIGN_COMMENTCELL);
+
+ Size aHeight;
+ const Control* pControls[] = { pTypeCell,pDescrCell,pNameCell};
+ for(sal_Size i= 0; i < sizeof(pControls)/sizeof(pControls[0]);++i)
+ {
+ const Size aTemp( pControls[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) );
+ if ( aTemp.Height() > aHeight.Height() )
+ aHeight.Height() = aTemp.Height();
+ } // for(int i= 0; i < sizeof(pControls)/sizeof(pControls[0]);++i
+ SetDataRowHeight(aHeight.Height());
+
+ ClearModified();
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::ClearModified()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ pNameCell->ClearModifyFlag();
+ pDescrCell->ClearModifyFlag();
+ pTypeCell->SaveValue();
+}
+
+//------------------------------------------------------------------------------
+OTableEditorCtrl::~OTableEditorCtrl()
+{
+ DBG_DTOR(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Undo-Manager zuruecksetzen
+ GetUndoManager()->Clear();
+
+ //////////////////////////////////////////////////////////////////////
+ // Moegliche Events aus Queue entfernen
+ if( nCutEvent )
+ Application::RemoveUserEvent( nCutEvent );
+ if( nPasteEvent )
+ Application::RemoveUserEvent( nPasteEvent );
+ if( nDeleteEvent )
+ Application::RemoveUserEvent( nDeleteEvent );
+ if( nInsNewRowsEvent )
+ Application::RemoveUserEvent( nInsNewRowsEvent );
+ if( nInvalidateTypeEvent )
+ Application::RemoveUserEvent( nInvalidateTypeEvent );
+ if( nEntryNotFoundEvent )
+ Application::RemoveUserEvent( nEntryNotFoundEvent );
+
+ //////////////////////////////////////////////////////////////////////
+ // Controltypen zerstoeren
+ delete pNameCell;
+ delete pTypeCell;
+ delete pDescrCell;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::SetDataPtr( long nRow )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ if(nRow == -1)
+ return sal_False;
+
+ OSL_ENSURE((xub_StrLen)nRow < m_pRowList->size(),"Row is greater than size!");
+ if(nRow >= (long)m_pRowList->size())
+ return sal_False;
+ pActRow = (*m_pRowList)[nRow];
+ return pActRow != NULL;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::SeekRow(long _nRow)
+{
+ // die Basisklasse braucht den Aufruf, da sie sich dort merkt, welche Zeile gepainted wird
+ EditBrowseBox::SeekRow(_nRow);
+
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ m_nCurrentPos = _nRow;
+ return SetDataPtr(_nRow);
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::PaintCell(OutputDevice& rDev, const Rectangle& rRect,
+ sal_uInt16 nColumnId ) const
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ String aText( GetCellText( m_nCurrentPos, nColumnId ));
+ Point aPos(rRect.TopLeft());
+ Size TxtSize(GetDataWindow().GetTextWidth(aText), GetDataWindow().GetTextHeight());
+
+ if (aPos.X() < rRect.Right() || aPos.X() + TxtSize.Width() > rRect.Right() ||
+ aPos.Y() < rRect.Top() || aPos.Y() + TxtSize.Height() > rRect.Bottom())
+ rDev.SetClipRegion( rRect );
+
+ rDev.DrawText(aPos, aText);
+
+ if (rDev.IsClipRegion())
+ rDev.SetClipRegion();
+// rDev.DrawText(rRect.TopLeft(), aText);
+// rDev.SetClipRegion( );
+}
+
+//------------------------------------------------------------------------------
+CellController* OTableEditorCtrl::GetController(long nRow, sal_uInt16 nColumnId)
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Wenn EditorCtrl ReadOnly ist, darf nicht editiert werden
+ Reference<XPropertySet> xTable = GetView()->getController().getTable();
+ if (IsReadOnly() || ( xTable.is() &&
+ xTable->getPropertySetInfo()->hasPropertyByName(PROPERTY_TYPE) &&
+ ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW")))
+ return NULL;
+
+ //////////////////////////////////////////////////////////////////////
+ // Wenn Zeile ReadOnly ist, darf sie nicht editiert werden
+ SetDataPtr( nRow );
+ if( pActRow->IsReadOnly() )
+ return NULL;
+
+ OFieldDescription* pActFieldDescr = pActRow->GetActFieldDescr();
+ switch (nColumnId)
+ {
+ case FIELD_NAME:
+ return new EditCellController( pNameCell );
+ case FIELD_TYPE:
+ if (pActFieldDescr && (pActFieldDescr->GetName().getLength() != 0))
+ return new ListBoxCellController( pTypeCell );
+ else return NULL;
+ case FIELD_DESCR:
+ if (pActFieldDescr && (pActFieldDescr->GetName().getLength() != 0))
+ return new EditCellController( pDescrCell );
+ else return NULL;
+ default:
+ return NULL;
+ }
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::InitController(CellControllerRef&, long nRow, sal_uInt16 nColumnId)
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ SeekRow( nRow == -1 ? GetCurRow() : nRow);
+ OFieldDescription* pActFieldDescr = pActRow->GetActFieldDescr();
+ String aInitString;
+
+ switch (nColumnId)
+ {
+ case FIELD_NAME:
+ if( pActFieldDescr )
+ aInitString = pActFieldDescr->GetName();
+ pNameCell->SetText( aInitString );
+ pNameCell->SaveValue();
+ break;
+ case FIELD_TYPE:
+ {
+ if ( pActFieldDescr && pActFieldDescr->getTypeInfo() )
+ aInitString = pActFieldDescr->getTypeInfo()->aUIName;
+
+ //////////////////////////////////////////////////////////////
+ // Anpassen des ComboBoxInhalts
+ pTypeCell->Clear();
+ if( !pActFieldDescr )
+ break;
+
+ const OTypeInfoMap* pTypeInfo = GetView()->getController().getTypeInfo();
+ OTypeInfoMap::const_iterator aIter = pTypeInfo->begin();
+ OTypeInfoMap::const_iterator aEnd = pTypeInfo->end();
+ for(;aIter != aEnd;++aIter)
+ pTypeCell->InsertEntry( aIter->second->aUIName );
+ pTypeCell->SelectEntry( aInitString );
+ }
+
+ break;
+ case FIELD_DESCR:
+ if( pActFieldDescr )
+ aInitString = pActFieldDescr->GetDescription();
+ pDescrCell->SetText( aInitString );
+ pDescrCell->SaveValue();
+ break;
+
+ }
+}
+
+//------------------------------------------------------------------------------
+EditBrowseBox::RowStatus OTableEditorCtrl::GetRowStatus(long nRow) const
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ ( (OTableEditorCtrl*)this )->SetDataPtr( nRow );
+ if( !pActRow )
+ return EditBrowseBox::CLEAN;
+ if (nRow >= 0 && nRow == m_nDataPos)
+ {
+ if( pActRow->IsPrimaryKey() )
+ return EditBrowseBox::CURRENT_PRIMARYKEY;
+ return EditBrowseBox::CURRENT;
+ }
+ else
+ {
+ if( pActRow->IsPrimaryKey() )
+ return EditBrowseBox::PRIMARYKEY;
+ return EditBrowseBox::CLEAN;
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::SaveCurRow()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ if (GetFieldDescr(GetCurRow()) == NULL)
+ // in der Zeile, in der ich mich i.A. befinde, stehen keine Daten
+ return sal_True;
+ if (!SaveModified())
+ return sal_False;
+
+ SetDataPtr(GetCurRow());
+ pDescrWin->SaveData( pActRow->GetActFieldDescr() );
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::DisplayData(long nRow, sal_Bool bGrabFocus)
+{
+ // zur richtigen Zelle fahren
+ SetDataPtr(nRow);
+
+ // Editier-Modus temporaer aus
+ sal_Bool bWasEditing = IsEditing();
+ if (bWasEditing)
+ DeactivateCell();
+
+ CellControllerRef aTemp;
+ InitController(aTemp, nRow, FIELD_NAME);
+ InitController(aTemp, nRow, FIELD_TYPE);
+ InitController(aTemp, nRow, FIELD_DESCR);
+
+ GoToRow(nRow);
+ // das Description-Window aktualisieren
+ GetView()->GetDescWin()->DisplayData(GetFieldDescr(nRow));
+ // neu zeichnen
+ RowModified(nRow);
+
+ // wieder an
+ if (bWasEditing || bGrabFocus)
+ ActivateCell(nRow, GetCurColumnId(), bGrabFocus);
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::CursorMoved()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Zeilenwechsel ?
+ m_nDataPos = GetCurRow();
+ if( m_nDataPos != nOldDataPos && m_nDataPos != -1)
+ {
+ CellControllerRef aTemp;
+ InitController(aTemp,m_nDataPos,FIELD_NAME);
+ InitController(aTemp,m_nDataPos,FIELD_TYPE);
+ InitController(aTemp,m_nDataPos,FIELD_DESCR);
+ }
+
+ OTableRowView::CursorMoved();
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 OTableEditorCtrl::HasFieldName( const String& rFieldName )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+
+ Reference<XConnection> xCon = GetView()->getController().getConnection();
+ Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : Reference< XDatabaseMetaData>();
+
+ ::comphelper::UStringMixEqual bCase(xMetaData.is() ? xMetaData->supportsMixedCaseQuotedIdentifiers() : sal_True);
+
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_pRowList->begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_pRowList->end();
+ OFieldDescription* pFieldDescr;
+ sal_Int32 nCount(0);
+ for(;aIter != aEnd;++aIter)
+ {
+ pFieldDescr = (*aIter)->GetActFieldDescr();
+ if( pFieldDescr && bCase(rFieldName,pFieldDescr->GetName()))
+ nCount++;
+ }
+ return nCount;
+}
+// --------------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::SaveData(long nRow, sal_uInt16 nColId)
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////
+ // Zellinhalte in Datenstruktur speichern
+ SetDataPtr( nRow == -1 ? GetCurRow() : nRow);
+ OFieldDescription* pActFieldDescr = pActRow->GetActFieldDescr();
+
+ switch( nColId)
+ {
+ //////////////////////////////////////////////////////////////
+ // Speichern Inhalt NameCell
+ case FIELD_NAME:
+ {
+ //////////////////////////////////////////////////////////////
+ // Wenn kein Name, nichts machen
+ String aName(pNameCell->GetText());
+
+ if( !aName.Len() )
+ {
+ //////////////////////////////////////////////////////////////
+ // Wenn FieldDescr existiert, wurde Feld geloescht und alter Inhalt wird wiederhergestellt
+ if (pActFieldDescr)
+ {
+ GetUndoManager()->AddUndoAction(new OTableEditorTypeSelUndoAct(this, nRow, FIELD_TYPE, pActFieldDescr->getTypeInfo()));
+ SwitchType(TOTypeInfoSP());
+ pActFieldDescr = pActRow->GetActFieldDescr();
+ }
+ else
+ return sal_True;
+ }
+ if(pActFieldDescr)
+ pActFieldDescr->SetName( aName );
+ pNameCell->ClearModifyFlag();
+
+ break;
+ }
+
+ //////////////////////////////////////////////////////////////
+ // Speichern Inhalt TypeCell
+ case FIELD_TYPE:
+ break;
+
+ //////////////////////////////////////////////////////////////
+ // Speichern Inhalt DescrCell
+ case FIELD_DESCR:
+ {
+ //////////////////////////////////////////////////////////////
+ // Wenn aktuelle Feldbeschreibung NULL, Default setzen
+ if( !pActFieldDescr )
+ {
+ pDescrCell->SetText(String());
+ pDescrCell->ClearModifyFlag();
+ }
+ else
+ pActFieldDescr->SetDescription( pDescrCell->GetText() );
+ break;
+ }
+ case FIELD_PROPERTY_DEFAULT:
+ case FIELD_PROPERTY_REQUIRED:
+ case FIELD_PROPERTY_TEXTLEN:
+ case FIELD_PROPERTY_NUMTYPE:
+ case FIELD_PROPERTY_AUTOINC:
+ case FIELD_PROPERTY_LENGTH:
+ case FIELD_PROPERTY_SCALE:
+ case FIELD_PROPERTY_BOOL_DEFAULT:
+ pDescrWin->SaveData(pActFieldDescr);
+
+ if ( FIELD_PROPERTY_AUTOINC == nColId && pActFieldDescr->IsAutoIncrement() )
+ {
+ OTableController& rController = GetView()->getController();
+ if ( rController.isAutoIncrementPrimaryKey() )
+ {
+ pActFieldDescr->SetPrimaryKey( true );
+ InvalidateHandleColumn();
+ Invalidate();
+ }
+ }
+ break;
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::SaveModified()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ sal_uInt16 nColId = GetCurColumnId();
+
+ switch( nColId )
+ {
+ //////////////////////////////////////////////////////////////
+ // NameCell
+ case FIELD_NAME:
+ {
+ // removed the former duplicate-check. this is done in OTableDocShell::CheckDefConsistency now.
+ // FS - 07.12.99 - 69575
+
+ } break;
+
+ //////////////////////////////////////////////////////////////
+ // TypeCell
+ case FIELD_TYPE:
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Type umstellen
+ resetType();
+ } break;
+ }
+
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::CursorMoving(long nNewRow, sal_uInt16 nNewCol)
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+
+ if (!EditBrowseBox::CursorMoving(nNewRow, nNewCol))
+ return sal_False;
+
+ //////////////////////////////////////////////////////////////////////
+ // Wird nach SaveModified() gerufen, aktuelle Zeile ist noch die alte
+ m_nDataPos = nNewRow;
+ nOldDataPos = GetCurRow();
+
+ //////////////////////////////////////////////////////////////////////
+ // Marker umsetzen
+ InvalidateStatusCell( nOldDataPos );
+ InvalidateStatusCell( m_nDataPos );
+
+ //////////////////////////////////////////////////////////////////////
+ // Daten des Propertyfensters speichern
+ if( SetDataPtr(nOldDataPos) && pDescrWin)
+ pDescrWin->SaveData( pActRow->GetActFieldDescr() );
+
+ //////////////////////////////////////////////////////////////////////
+ // Neue Daten im Propertyfenster anzeigen
+ if( SetDataPtr(m_nDataPos) && pDescrWin)
+ pDescrWin->DisplayData( pActRow->GetActFieldDescr() );
+
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableEditorCtrl, InvalidateFieldType, void*, /*EMPTYTAG*/ )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ nInvalidateTypeEvent = 0;
+ Invalidate( GetFieldRectPixel(nOldDataPos, FIELD_TYPE) );
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableEditorCtrl, EntryNotFound, void*, /*EMPTYTAG*/ )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ nEntryNotFoundEvent = 0;
+ ErrorBox( this, ModuleRes(ERR_INVALID_LISTBOX_ENTRY) ).Execute();
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::CellModified( long nRow, sal_uInt16 nColId )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+
+ //////////////////////////////////////////////////////////////
+ // Wenn aktuelle Feldbeschreibung NULL, Default setzen
+ if(nRow == -1)
+ nRow = GetCurRow();
+ SetDataPtr( nRow );
+ OFieldDescription* pActFieldDescr = pActRow->GetActFieldDescr();
+
+ String sActionDescription;
+ switch ( 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;
+ default: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_ATTRIBUTE ) ); break;
+ }
+
+ GetUndoManager()->EnterListAction( sActionDescription, String() );
+ if (!pActFieldDescr)
+ {
+ const OTypeInfoMap* pTypeInfoMap = GetView()->getController().getTypeInfo();
+ if ( !pTypeInfoMap->empty() )
+ {
+ OTypeInfoMap::const_iterator aTypeIter = pTypeInfoMap->find(DataType::VARCHAR);
+ if ( aTypeIter == pTypeInfoMap->end() )
+ aTypeIter = pTypeInfoMap->begin();
+ pActRow->SetFieldType( aTypeIter->second );
+ }
+ else
+ pActRow->SetFieldType( GetView()->getController().getTypeInfoFallBack() );
+
+ nInvalidateTypeEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, InvalidateFieldType) );
+ pActFieldDescr = pActRow->GetActFieldDescr();
+ pDescrWin->DisplayData( pActFieldDescr );
+ GetUndoManager()->AddUndoAction( new OTableEditorTypeSelUndoAct(this, nRow, nColId+1, TOTypeInfoSP()) );
+ }
+
+ if( nColId != FIELD_TYPE )
+ GetUndoManager()->AddUndoAction( new OTableDesignCellUndoAct(this, nRow, nColId) );
+ else
+ {
+ GetUndoManager()->AddUndoAction(new OTableEditorTypeSelUndoAct(this, GetCurRow(), nColId, GetFieldDescr(GetCurRow())->getTypeInfo()));
+ resetType();
+ }
+
+ SaveData(nRow,nColId);
+ // SaveData could create a undo action as well
+ GetUndoManager()->LeaveListAction();
+ RowModified(nRow);
+ CellControllerRef xController(Controller());
+ if(xController.Is())
+ xController->SetModified();
+
+ //////////////////////////////////////////////////////////////////////
+ // Das ModifyFlag setzen
+ GetView()->getController().setModified( sal_True );
+ InvalidateFeatures();
+}
+// -----------------------------------------------------------------------------
+void OTableEditorCtrl::resetType()
+{
+ USHORT nPos = pTypeCell->GetSelectEntryPos();
+ if(nPos != LISTBOX_ENTRY_NOTFOUND)
+ SwitchType( GetView()->getController().getTypeInfo(nPos) );
+ else
+ SwitchType(TOTypeInfoSP());
+}
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::CellModified()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ CellModified( GetCurRow(), GetCurColumnId() );
+}
+// -----------------------------------------------------------------------------
+void OTableEditorCtrl::InvalidateFeatures()
+{
+ GetView()->getController().InvalidateFeature(SID_UNDO);
+ GetView()->getController().InvalidateFeature(SID_REDO);
+ GetView()->getController().InvalidateFeature(SID_SAVEDOC);
+}
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::Undo()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+
+ InvalidateFeatures();
+}
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::Redo()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ InvalidateFeatures();
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::CopyRows()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // set to the right row and save it
+ if( SetDataPtr(m_nDataPos) )
+ pDescrWin->SaveData( pActRow->GetActFieldDescr() );
+
+ //////////////////////////////////////////////////////////////////////
+ // Selektierte Zeilen in die ClipboardListe kopieren
+ ::boost::shared_ptr<OTableRow> pClipboardRow;
+ ::boost::shared_ptr<OTableRow> pRow;
+ ::std::vector< ::boost::shared_ptr<OTableRow> > vClipboardList;
+ vClipboardList.reserve(GetSelectRowCount());
+
+ for( long nIndex=FirstSelectedRow(); nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()); nIndex=NextSelectedRow() )
+ {
+ pRow = (*m_pRowList)[nIndex];
+ OSL_ENSURE(pRow,"OTableEditorCtrl::CopyRows: Row is NULL!");
+ if ( pRow && pRow->GetActFieldDescr() )
+ {
+ pClipboardRow.reset(new OTableRow( *pRow ));
+ vClipboardList.push_back( pClipboardRow);
+ }
+ }
+ if(!vClipboardList.empty())
+ {
+ OTableRowExchange* pData = new OTableRowExchange(vClipboardList);
+ Reference< ::com::sun::star::datatransfer::XTransferable> xRef = pData;
+ pData->CopyToClipboard(GetParent());
+ }
+}
+
+//------------------------------------------------------------------------------
+String OTableEditorCtrl::GenerateName( const String& rName )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Basisnamen zum Anhaengen einer Numerierung erstellen
+ String aBaseName;
+ Reference<XConnection> xCon = GetView()->getController().getConnection();
+ Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : Reference< XDatabaseMetaData>();
+
+ xub_StrLen nMaxTextLen((xub_StrLen)( xMetaData.is() ? xMetaData->getMaxColumnNameLength() : 0));
+
+ if( (rName.Len()+2) >nMaxTextLen )
+ aBaseName = rName.Copy( 0, nMaxTextLen-2 );
+ else
+ aBaseName = rName;
+
+ //////////////////////////////////////////////////////////////////////
+ // Namen durchnumerieren (bis 99)
+ String aFieldName( rName);
+ sal_Int32 i=1;
+ while( HasFieldName(aFieldName) )
+ {
+ aFieldName = aBaseName;
+ aFieldName += String::CreateFromInt32(i);
+ i++;
+ }
+
+ return aFieldName;
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::InsertRows( long nRow )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+
+ ::std::vector< ::boost::shared_ptr<OTableRow> > vInsertedUndoRedoRows; // need for undo/redo handling
+ //////////////////////////////////////////////////////////////////////
+ // get rows from clipboard
+ TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
+ if(aTransferData.HasFormat(SOT_FORMATSTR_ID_SBA_TABED))
+ {
+ 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;
+ ::boost::shared_ptr<OTableRow> pRow;
+ sal_Int32 nSize = 0;
+ (*aStreamRef) >> nSize;
+ vInsertedUndoRedoRows.reserve(nSize);
+ for(sal_Int32 i=0;i < nSize;++i)
+ {
+ pRow.reset(new OTableRow());
+ (*aStreamRef) >> *pRow;
+ pRow->SetReadOnly( sal_False );
+ sal_Int32 nType = pRow->GetActFieldDescr()->GetType();
+ if ( pRow->GetActFieldDescr() )
+ pRow->GetActFieldDescr()->SetType(GetView()->getController().getTypeInfoByType(nType));
+ //////////////////////////////////////////////////////////////////////
+ // Anpassen des Feldnamens
+ aFieldName = GenerateName( pRow->GetActFieldDescr()->GetName() );
+ pRow->GetActFieldDescr()->SetName( aFieldName );
+ pRow->SetPos(nInsertRow);
+ m_pRowList->insert( m_pRowList->begin()+nInsertRow,pRow );
+ vInsertedUndoRedoRows.push_back(::boost::shared_ptr<OTableRow>(new OTableRow(*pRow)));
+ nInsertRow++;
+ }
+ }
+ }
+ //////////////////////////////////////////////////////////////////////
+ // Beim RowInserted wird CursorMoved gerufen.
+ // Die UI-Daten duerfen hier beim CursorMoved nicht gespeichert werden.
+ bSaveOnMove = sal_False;
+ RowInserted( nRow,vInsertedUndoRedoRows.size(),sal_True );
+ bSaveOnMove = sal_True;
+
+ //////////////////////////////////////////////////////////////////////
+ // Undo-Action erzeugen
+ GetUndoManager()->AddUndoAction( new OTableEditorInsUndoAct(this, nRow,vInsertedUndoRedoRows) );
+ GetView()->getController().setModified( sal_True );
+ InvalidateFeatures();
+}
+
+//------------------------------------------------------------------------------
+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) );
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Alle markierten Zeilen loeschen
+ long nIndex = FirstSelectedRow();
+ nOldDataPos = nIndex;
+ bSaveOnMove = sal_False;
+
+ while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Zeile entfernen
+ m_pRowList->erase( m_pRowList->begin()+nIndex );
+ RowRemoved( nIndex, 1, sal_True );
+
+ //////////////////////////////////////////////////////////////////////
+ // Leerzeile am Ende wieder einfuegen
+ m_pRowList->push_back( ::boost::shared_ptr<OTableRow>(new OTableRow()));
+ RowInserted( GetRowCount()-1, 1, sal_True );
+
+ nIndex = FirstSelectedRow();
+ }
+
+ bSaveOnMove = sal_True;
+
+ //////////////////////////////////////////////////////////////////////
+ // Erzwingen, dass der aktuelle Datensatz angezeigt wird
+ m_nDataPos = GetCurRow();
+ InvalidateStatusCell( nOldDataPos );
+ InvalidateStatusCell( m_nDataPos );
+ SetDataPtr( m_nDataPos );
+ ActivateCell();
+ pDescrWin->DisplayData( pActRow->GetActFieldDescr() );
+ GetView()->getController().setModified( sal_True );
+ InvalidateFeatures();
+}
+
+//------------------------------------------------------------------------------
+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();
+ if( !nInsertRows )
+ nInsertRows = 1;
+ GetUndoManager()->AddUndoAction( new OTableEditorInsNewUndoAct(this, nRow, nInsertRows) );
+ //////////////////////////////////////////////////////////////////////
+ // Zahl der selektierten Zeilen werden neu eingefuegt
+ for( long i=nRow; i<(nRow+nInsertRows); i++ )
+ m_pRowList->insert( m_pRowList->begin()+i ,::boost::shared_ptr<OTableRow>(new OTableRow()));
+ RowInserted( nRow, nInsertRows, sal_True );
+
+ GetView()->getController().setModified( sal_True );
+ InvalidateFeatures();
+}
+
+//------------------------------------------------------------------------------
+String OTableEditorCtrl::GetControlText( long nRow, sal_uInt16 nColId )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Controls des Browsers auslesen
+ if( nColId < FIELD_FIRST_VIRTUAL_COLUMN )
+ {
+ GoToRow( nRow );
+ GoToColumnId( nColId );
+ CellControllerRef xController = Controller();
+ if(xController.Is())
+ return xController->GetWindow().GetText();
+ else
+ return GetCellText(nRow,nColId);
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Controls der Tabpage Auslesen
+ else
+ return pDescrWin->GetControlText( nColId );
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::SetControlText( long nRow, sal_uInt16 nColId, const String& rText )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Controls des Browsers setzen
+ if( nColId < FIELD_FIRST_VIRTUAL_COLUMN )
+ {
+ GoToRow( nRow );
+ GoToColumnId( nColId );
+ CellControllerRef xController = Controller();
+ if(xController.Is())
+ xController->GetWindow().SetText( rText );
+ else
+ RowModified(nRow,nColId);
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Controls der Tabpage setzen
+ else
+ {
+ pDescrWin->SetControlText( nColId, rText );
+ }
+}
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::SetCellData( long nRow, sal_uInt16 nColId, const TOTypeInfoSP& _pTypeInfo )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Aktuellen Datenzeiger umsetzen
+ if( nRow == -1 )
+ nRow = GetCurRow();
+ OFieldDescription* pFieldDescr = GetFieldDescr( nRow );
+ if( !pFieldDescr && nColId != FIELD_TYPE)
+ return;
+
+ //////////////////////////////////////////////////////////////////////
+ // Einzelne Felder setzen
+ switch( nColId )
+ {
+ case FIELD_TYPE:
+ SwitchType( _pTypeInfo );
+ break;
+ default:
+ OSL_ENSURE(sal_False, "OTableEditorCtrl::SetCellData: invalid column!");
+ }
+ SetControlText(nRow,nColId,_pTypeInfo.get() ? _pTypeInfo->aUIName : ::rtl::OUString());
+}
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::SetCellData( long nRow, sal_uInt16 nColId, const ::com::sun::star::uno::Any& _rNewData )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Aktuellen Datenzeiger umsetzen
+ if( nRow == -1 )
+ nRow = GetCurRow();
+ OFieldDescription* pFieldDescr = GetFieldDescr( nRow );
+ if( !pFieldDescr && nColId != FIELD_TYPE)
+ return;
+
+ String sValue;
+ //////////////////////////////////////////////////////////////////////
+ // Einzelne Felder setzen
+ switch( nColId )
+ {
+ case FIELD_NAME:
+ sValue = ::comphelper::getString(_rNewData);
+ pFieldDescr->SetName( sValue );
+ break;
+
+ case FIELD_TYPE:
+ OSL_ENSURE(sal_False, "OTableEditorCtrl::SetCellData: invalid column!");
+ break;
+
+ case FIELD_DESCR:
+ pFieldDescr->SetDescription( sValue = ::comphelper::getString(_rNewData) );
+ break;
+
+ case FIELD_PROPERTY_DEFAULT:
+ pFieldDescr->SetControlDefault( _rNewData );
+ sValue = GetView()->GetDescWin()->getGenPage()->getFieldControl()->getControlDefault(pFieldDescr);
+ break;
+
+ case FIELD_PROPERTY_REQUIRED:
+ {
+ sValue = ::comphelper::getString(_rNewData);
+ pFieldDescr->SetIsNullable( sValue.ToInt32() );
+ }
+ break;
+
+ case FIELD_PROPERTY_TEXTLEN:
+ case FIELD_PROPERTY_LENGTH:
+ {
+ sValue = ::comphelper::getString(_rNewData);
+ pFieldDescr->SetPrecision( sValue.ToInt32() );
+ }
+ break;
+
+ case FIELD_PROPERTY_NUMTYPE:
+ // pFieldDescr->SetNumType( _rNewData );
+ OSL_ENSURE(sal_False, "OTableEditorCtrl::SetCellData: invalid column!");
+ break;
+
+ case FIELD_PROPERTY_AUTOINC:
+ {
+ String strYes(ModuleRes(STR_VALUE_YES));
+ sValue = ::comphelper::getString(_rNewData);
+ pFieldDescr->SetAutoIncrement(sValue.Equals(strYes));
+ }
+ break;
+ case FIELD_PROPERTY_SCALE:
+ {
+ sValue = ::comphelper::getString(_rNewData);
+ pFieldDescr->SetScale(sValue.ToInt32());
+ }
+ break;
+
+ case FIELD_PROPERTY_BOOL_DEFAULT:
+ sValue = GetView()->GetDescWin()->BoolStringPersistent(::comphelper::getString(_rNewData));
+ pFieldDescr->SetControlDefault(makeAny(::rtl::OUString(sValue)));
+ break;
+
+ case FIELD_PROPERTY_FORMAT:
+ {
+ sValue = ::comphelper::getString(_rNewData);
+ pFieldDescr->SetFormatKey(sValue.ToInt32());
+ }
+ break;
+ }
+
+ SetControlText(nRow,nColId,sValue);
+}
+
+//------------------------------------------------------------------------------
+Any OTableEditorCtrl::GetCellData( long nRow, sal_uInt16 nColId )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ OFieldDescription* pFieldDescr = GetFieldDescr( nRow );
+ if( !pFieldDescr )
+ return Any();
+
+ //////////////////////////////////////////////////////////////////////
+ // Aktuellen Datenzeiger umsetzen
+ if( nRow==-1 )
+ nRow = GetCurRow();
+ SetDataPtr( nRow );
+
+ static const String strYes(ModuleRes(STR_VALUE_YES));
+ static const String strNo(ModuleRes(STR_VALUE_NO));
+ ::rtl::OUString sValue;
+ //////////////////////////////////////////////////////////////////////
+ // Einzelne Felder auslesen
+ switch( nColId )
+ {
+ case FIELD_NAME:
+ sValue = pFieldDescr->GetName();
+ break;
+
+ case FIELD_TYPE:
+ if ( pFieldDescr->getTypeInfo() )
+ sValue = pFieldDescr->getTypeInfo()->aUIName;
+ break;
+
+ case FIELD_DESCR:
+ sValue = pFieldDescr->GetDescription();
+ break;
+
+ case FIELD_PROPERTY_DEFAULT:
+ return pFieldDescr->GetControlDefault();
+
+ case FIELD_PROPERTY_REQUIRED:
+ sValue = pFieldDescr->GetIsNullable() == ColumnValue::NULLABLE ? strYes : strNo;
+ break;
+
+ case FIELD_PROPERTY_TEXTLEN:
+ case FIELD_PROPERTY_LENGTH:
+ sValue = String::CreateFromInt32(pFieldDescr->GetPrecision());
+ break;
+
+ case FIELD_PROPERTY_NUMTYPE:
+ OSL_ENSURE(sal_False, "OTableEditorCtrl::GetCellData: invalid column!");
+ // return pFieldDescr->GetNumType();
+
+ case FIELD_PROPERTY_AUTOINC:
+ sValue = pFieldDescr->IsAutoIncrement() ? strYes : strNo;
+ break;
+
+ case FIELD_PROPERTY_SCALE:
+ sValue = String::CreateFromInt32(pFieldDescr->GetScale());
+ break;
+
+ case FIELD_PROPERTY_BOOL_DEFAULT:
+ sValue = GetView()->GetDescWin()->BoolStringUI(::comphelper::getString(pFieldDescr->GetControlDefault()));
+ break;
+
+ case FIELD_PROPERTY_FORMAT:
+ sValue = String::CreateFromInt32(pFieldDescr->GetFormatKey());
+ break;
+ }
+
+ return makeAny(sValue);
+}
+
+//------------------------------------------------------------------------------
+String OTableEditorCtrl::GetCellText( long nRow, sal_uInt16 nColId ) const
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ ::rtl::OUString sCellText;
+ const_cast< OTableEditorCtrl* >( this )->GetCellData( nRow, nColId ) >>= sCellText;
+ return sCellText;
+}
+
+//------------------------------------------------------------------------------
+sal_uInt32 OTableEditorCtrl::GetTotalCellWidth(long nRow, sal_uInt16 nColId)
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ return GetTextWidth(GetCellText(nRow, nColId)) + 2 * GetTextWidth('0');
+}
+
+//------------------------------------------------------------------------------
+OFieldDescription* OTableEditorCtrl::GetFieldDescr( long nRow )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ std::vector< ::boost::shared_ptr<OTableRow> >::size_type nListCount(
+ m_pRowList->size());
+ if( (nRow<0) || (sal::static_int_cast< unsigned long >(nRow)>=nListCount) )
+ {
+ OSL_ENSURE(0,"(nRow<0) || (nRow>=nListCount)");
+ return NULL;
+ }
+ ::boost::shared_ptr<OTableRow> pRow = (*m_pRowList)[ nRow ];
+ if( !pRow )
+ return NULL;
+ return pRow->GetActFieldDescr();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::IsCutAllowed( long nRow )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ sal_Bool bIsCutAllowed = (GetView()->getController().isAddAllowed() && GetView()->getController().isDropAllowed()) ||
+ GetView()->getController().isAlterAllowed();
+
+ 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;
+ }
+
+// 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 bCutAllowed && IsDeleteAllowed( nRow );
+ return bIsCutAllowed;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::IsCopyAllowed( long /*nRow*/ )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ sal_Bool bIsCopyAllowed = sal_False;
+ if(m_eChildFocus == DESCRIPTION)
+ bIsCopyAllowed = pDescrCell->GetSelected().Len() != 0;
+ else if(m_eChildFocus == NAME)
+ bIsCopyAllowed = pNameCell->GetSelected().Len() != 0;
+ else if(m_eChildFocus == ROW)
+ {
+ Reference<XPropertySet> xTable = GetView()->getController().getTable();
+ if( !GetSelectRowCount() || (xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW")))
+ return sal_False;
+
+ //////////////////////////////////////////////////////////////////////
+ // Wenn eine der markierten Zeilen leer ist, kein Copy moeglich
+ ::boost::shared_ptr<OTableRow> pRow;
+ long nIndex = FirstSelectedRow();
+ while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
+ {
+ pRow = (*m_pRowList)[nIndex];
+ if( !pRow->GetActFieldDescr() )
+ return sal_False;
+
+ nIndex = NextSelectedRow();
+ }
+
+ bIsCopyAllowed = sal_True;
+ }
+
+ return bIsCopyAllowed;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::IsPasteAllowed( long /*nRow*/ )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ sal_Bool bAllowed = GetView()->getController().isAddAllowed();
+ if ( bAllowed )
+ {
+ TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
+ sal_Bool bRowFormat = aTransferData.HasFormat(SOT_FORMATSTR_ID_SBA_TABED);
+ if ( m_eChildFocus == ROW )
+ bAllowed = bRowFormat;
+ else
+ bAllowed = !bRowFormat && aTransferData.HasFormat(SOT_FORMAT_STRING);
+ }
+
+ return bAllowed;
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::cut()
+{
+ if(m_eChildFocus == NAME)
+ {
+ if(GetView()->getController().isAlterAllowed())
+ {
+ SaveData(-1,FIELD_NAME);
+ pNameCell->Cut();
+ CellModified(-1,FIELD_NAME);
+ }
+ }
+ else if(m_eChildFocus == DESCRIPTION)
+ {
+ if(GetView()->getController().isAlterAllowed())
+ {
+ SaveData(-1,FIELD_DESCR);
+ pDescrCell->Cut();
+ CellModified(-1,FIELD_DESCR);
+ }
+ }
+ else if(m_eChildFocus == ROW)
+ {
+ if (nCutEvent)
+ Application::RemoveUserEvent(nCutEvent);
+ nCutEvent = Application::PostUserEvent(LINK(this, OTableEditorCtrl, DelayedCut));
+ }
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::copy()
+{
+ if(GetSelectRowCount())
+ OTableRowView::copy();
+ else if(m_eChildFocus == NAME)
+ pNameCell->Copy();
+ else if(m_eChildFocus == DESCRIPTION)
+ pDescrCell->Copy();
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::paste()
+{
+ TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
+ if(aTransferData.HasFormat(SOT_FORMATSTR_ID_SBA_TABED))
+ {
+ if( nPasteEvent )
+ Application::RemoveUserEvent( nPasteEvent );
+ nPasteEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, DelayedPaste) );
+ }
+ else if(m_eChildFocus == NAME)
+ {
+ if(GetView()->getController().isAlterAllowed())
+ {
+ pNameCell->Paste();
+ CellModified();
+ }
+ }
+ else if(m_eChildFocus == DESCRIPTION)
+ {
+ if(GetView()->getController().isAlterAllowed())
+ {
+ pDescrCell->Paste();
+ CellModified();
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+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());
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::IsInsertNewAllowed( long nRow )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+
+ sal_Bool bInsertNewAllowed = GetView()->getController().isAddAllowed();
+ //////////////////////////////////////////////////////////////
+ // Wenn nur Felder hinzugefuegt werden duerfen, Paste nur in neue Felder
+ if (bInsertNewAllowed && !GetView()->getController().isDropAllowed())
+ {
+ SetDataPtr(nRow);
+ if( GetActRow()->IsReadOnly() )
+ return sal_False;
+ }
+
+ return bInsertNewAllowed;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::IsPrimaryKeyAllowed( long /*nRow*/ )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ if( !GetSelectRowCount() )
+ return sal_False;
+
+ OTableController& rController = GetView()->getController();
+ if ( !rController.getSdbMetaData().supportsPrimaryKeys() )
+ return sal_False;
+
+ Reference<XPropertySet> xTable = rController.getTable();
+ //////////////////////////////////////////////////////////////
+ // 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
+
+ if(xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW"))
+ return sal_False;
+ //////////////////////////////////////////////////////////////
+ // Wenn leeres Feld, kein PrimKey
+ // Eintrag wird nur erlaubt, wenn
+ // - kein leerer Eintrag in der Selection ist
+ // - kein Eintrag vom Typ Memo oder Image ist
+ // - kein DROP erlaubt ist (s.o.) und die Spalte noch kein Required (not null) gesetzt hatte.
+ long nIndex = FirstSelectedRow();
+ ::boost::shared_ptr<OTableRow> pRow;
+ while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
+ {
+ pRow = (*m_pRowList)[nIndex];
+ OFieldDescription* pFieldDescr = pRow->GetActFieldDescr();
+ if(!pFieldDescr)
+ return sal_False;
+ else
+ {
+ //////////////////////////////////////////////////////////////
+ // Wenn Feldtyp Memo oder Image, kein PrimKey
+ // oder wenn Spalten nicht gedroped werden können und das Required Flag ist nicht gesetzt
+ // oder wenn eine ::com::sun::star::sdbcx::View vorhanden ist und das Required Flag nicht gesetzt ist
+ TOTypeInfoSP pTypeInfo = pFieldDescr->getTypeInfo();
+ if( pTypeInfo->nSearchType == ColumnSearch::NONE
+ || (pFieldDescr->IsNullable() && pRow->IsReadOnly())
+ )
+ return sal_False;
+ }
+
+ nIndex = NextSelectedRow();
+ }
+
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::Command(const CommandEvent& rEvt)
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ switch (rEvt.GetCommand())
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ Point aMenuPos( rEvt.GetMousePosPixel() );
+ if (!rEvt.IsMouseEvent())
+ {
+ if ( 1 == GetSelectColumnCount() )
+ {
+ sal_uInt16 nSelId = GetColumnId(
+ sal::static_int_cast< USHORT >(
+ FirstSelectedColumn() ) );
+ ::Rectangle aColRect( GetFieldRectPixel( 0, nSelId, sal_False ) );
+
+ aMenuPos = aColRect.TopCenter();
+ }
+ else if ( GetSelectRowCount() > 0 )
+ {
+ ::Rectangle aColRect( GetFieldRectPixel( FirstSelectedRow(), HANDLE_ID, sal_True ) );
+
+ aMenuPos = aColRect.TopCenter();
+ }
+ else
+ {
+ OTableRowView::Command(rEvt);
+ return;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////
+ // Kontextmenu einblenden
+ if( !IsReadOnly() )
+ {
+ sal_uInt16 nColId = GetColumnAtXPosPixel(aMenuPos.X());
+ long nRow = GetRowAtYPosPixel(aMenuPos.Y());
+
+ if ( HANDLE_ID != nColId )
+ {
+ if ( nRow < 0 && nColId != BROWSER_INVALIDID )
+ { // hit the header
+ if ( 3 != nColId )
+ { // 3 would mean the last column, and this last column is auto-sized
+ if ( !IsColumnSelected( nColId ) )
+ SelectColumnId( nColId );
+
+ PopupMenu aContextMenu( ModuleRes( RID_QUERYCOLPOPUPMENU ) );
+ aContextMenu.EnableItem( SID_DELETE, sal_False );
+ aContextMenu.RemoveDisabledEntries(sal_True, sal_True);
+ switch ( aContextMenu.Execute( this, aMenuPos ) )
+ {
+ case ID_BROWSER_COLWIDTH:
+ adjustBrowseBoxColumnWidth( this, nColId );
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ PopupMenu aContextMenu(ModuleRes(RID_TABLEDESIGNROWPOPUPMENU));
+
+ aContextMenu.EnableItem( SID_CUT, IsCutAllowed(nRow) );
+ aContextMenu.EnableItem( SID_COPY, IsCopyAllowed(nRow) );
+ aContextMenu.EnableItem( SID_PASTE, IsPasteAllowed(nRow) );
+ aContextMenu.EnableItem( SID_DELETE, IsDeleteAllowed(nRow) );
+ aContextMenu.EnableItem( SID_TABLEDESIGN_TABED_PRIMARYKEY, IsPrimaryKeyAllowed(nRow) );
+ aContextMenu.EnableItem( SID_TABLEDESIGN_INSERTROWS, IsInsertNewAllowed(nRow) );
+ aContextMenu.CheckItem( SID_TABLEDESIGN_TABED_PRIMARYKEY, IsRowSelected(GetCurRow()) && IsPrimaryKey() );
+
+ // jetzt alles, was disabled wurde, wech
+ aContextMenu.RemoveDisabledEntries(sal_True, sal_True);
+
+ if( SetDataPtr(m_nDataPos) )
+ pDescrWin->SaveData( pActRow->GetActFieldDescr() );
+
+ //////////////////////////////////////////////////////////////
+ // Alle Aktionen, die die Zeilenzahl veraendern, muessen asynchron
+ // ausgefuehrt werden->sonst Probleme zwischen Kontextmenu u. Browser
+ m_nDataPos = GetCurRow();
+ switch (aContextMenu.Execute(this, aMenuPos))
+ {
+ case SID_CUT:
+ cut();
+ break;
+ case SID_COPY:
+ copy();
+ break;
+ case SID_PASTE:
+ paste();
+ break;
+ case SID_DELETE:
+ if( nDeleteEvent )
+ Application::RemoveUserEvent( nDeleteEvent );
+ nDeleteEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, DelayedDelete) );
+ break;
+ case SID_TABLEDESIGN_INSERTROWS:
+ if( nInsNewRowsEvent )
+ Application::RemoveUserEvent( nInsNewRowsEvent );
+ nInsNewRowsEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, DelayedInsNewRows) );
+ break;
+ case SID_TABLEDESIGN_TABED_PRIMARYKEY:
+ SetPrimaryKey( !IsPrimaryKey() );
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ break;
+ default:
+ OTableRowView::Command(rEvt);
+ }
+
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableEditorCtrl, DelayedCut, void*, /*EMPTYTAG*/ )
+{
+ nCutEvent = 0;
+ OTableRowView::cut();
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableEditorCtrl, DelayedPaste, void*, /*EMPTYTAG*/ )
+{
+ nPasteEvent = 0;
+
+ sal_Int32 nPastePosition = GetView()->getController().getFirstEmptyRowPosition();
+ if ( !GetView()->getController().getTable().is() )
+ nPastePosition = GetSelectRowCount() ? FirstSelectedRow() : GetCurRow();
+
+ if (!IsInsertNewAllowed(nPastePosition))
+ { // kein Einfuegen erlaubt, sondern nur anhaengen, also testen, ob hinter der PastePosition noch
+ // belegte Zeilen erscheinen
+
+ sal_Int32 nFreeFromPos; // ab da nur freie Zeilen
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::reverse_iterator aIter = m_pRowList->rbegin();
+ for(nFreeFromPos = m_pRowList->size();
+ aIter != m_pRowList->rend() && (!(*aIter) || !(*aIter)->GetActFieldDescr() || !(*aIter)->GetActFieldDescr()->GetName().getLength());
+ --nFreeFromPos, ++aIter)
+ ;
+ if (nPastePosition < nFreeFromPos) // es gibt mindestens eine belegte hinter PastePosition -> ganz nach hinten
+ nPastePosition = nFreeFromPos;
+ }
+
+ OTableRowView::Paste( nPastePosition );
+ SetNoSelection();
+ GoToRow( nPastePosition );
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableEditorCtrl, DelayedDelete, void*, /*EMPTYTAG*/ )
+{
+ nDeleteEvent = 0;
+ DeleteRows();
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableEditorCtrl, DelayedInsNewRows, void*, /*EMPTYTAG*/ )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ nInsNewRowsEvent = 0;
+ sal_Int32 nPastePosition = GetView()->getController().getFirstEmptyRowPosition();
+ if ( !GetView()->getController().getTable().is() )
+ nPastePosition = GetSelectRowCount() ? FirstSelectedRow() : m_nDataPos;
+
+ InsertNewRows( nPastePosition );
+ SetNoSelection();
+ GoToRow( nPastePosition );
+
+ return 0;
+}
+// -----------------------------------------------------------------------------
+void OTableEditorCtrl::AdjustFieldDescription(OFieldDescription* _pFieldDesc,
+ MultiSelection& _rMultiSel,
+ sal_Int32 _nPos,
+ sal_Bool _bSet,
+ sal_Bool _bPrimaryKey)
+{
+ _pFieldDesc->SetPrimaryKey( _bPrimaryKey );
+ if(!_bSet && _pFieldDesc->getTypeInfo()->bNullable)
+ {
+ _pFieldDesc->SetIsNullable(ColumnValue::NO_NULLS);
+ _pFieldDesc->SetControlDefault(Any());
+ } // if(!_bSet && _pFieldDesc->getTypeInfo()->bNullable)
+ if ( _pFieldDesc->IsAutoIncrement() && !_bPrimaryKey )
+ {
+ OTableController& rController = GetView()->getController();
+ if ( rController.isAutoIncrementPrimaryKey() )
+ {
+ _pFieldDesc->SetAutoIncrement(false);
+ }
+ }
+ //////////////////////////////////////////////////////////////////////
+ // update field description
+ pDescrWin->DisplayData(_pFieldDesc);
+
+ _rMultiSel.Insert( _nPos );
+ _rMultiSel.Select( _nPos );
+}
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::SetPrimaryKey( sal_Bool bSet )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Evtl. vorhandene Primary Keys loeschen
+ MultiSelection aDeletedPrimKeys;
+ aDeletedPrimKeys.SetTotalRange( Range(0,GetRowCount()) );
+ long nIndex = 0;
+
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_pRowList->begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_pRowList->end();
+ for(sal_Int32 nRow = 0;aIter != aEnd;++aIter,++nRow)
+ {
+ OFieldDescription* pFieldDescr = (*aIter)->GetActFieldDescr();
+ if( pFieldDescr && (*aIter)->IsPrimaryKey() && (!bSet || !IsRowSelected(nRow)) )
+ {
+ AdjustFieldDescription(pFieldDescr,aDeletedPrimKeys,nRow,bSet,sal_False);
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Die Primary Keys der markierten Zeilen setzen
+ MultiSelection aInsertedPrimKeys;
+ aInsertedPrimKeys.SetTotalRange( Range(0,GetRowCount()) );
+ if( bSet )
+ {
+ nIndex = FirstSelectedRow();
+ while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Key setzen
+ ::boost::shared_ptr<OTableRow> pRow = (*m_pRowList)[nIndex];
+ OFieldDescription* pFieldDescr = pRow->GetActFieldDescr();
+ if(pFieldDescr)
+ AdjustFieldDescription(pFieldDescr,aInsertedPrimKeys,nIndex,sal_False,sal_True);
+
+ nIndex = NextSelectedRow();
+ }
+ }
+
+ GetUndoManager()->AddUndoAction( new OPrimKeyUndoAct(this, aDeletedPrimKeys, aInsertedPrimKeys) );
+
+ //////////////////////////////////////////////////////////////////////
+ // Handle-Spalte invalidieren
+ InvalidateHandleColumn();
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Das ModifyFlag der TableDocSh setzen
+ GetView()->getController().setModified( sal_True );
+ InvalidateFeatures();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::IsPrimaryKey()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Gehoeren alle markierten Felder zu einem Primary Key ?
+ long nPrimaryKeys = 0;
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_pRowList->begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_pRowList->end();
+ for(sal_Int32 nRow=0;aIter != aEnd;++aIter,++nRow)
+ {
+ if( IsRowSelected(nRow) && !(*aIter)->IsPrimaryKey() )
+ return sal_False;
+ if( (*aIter)->IsPrimaryKey() )
+ ++nPrimaryKeys;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Gibt es unselektierte Felder, die noch zu dem Key gehoeren ?
+ return GetSelectRowCount() == nPrimaryKeys;
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::SwitchType( const TOTypeInfoSP& _pType )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Wenn noch kein Feldname vergeben wurde
+ long nRow(GetCurRow());
+ OFieldDescription* pActFieldDescr = GetFieldDescr( nRow );
+ if( pActFieldDescr )
+ //////////////////////////////////////////////////////////////////////
+ // Alte Beschreibung speichern
+ pDescrWin->SaveData( pActFieldDescr );
+
+ if ( nRow < 0 || nRow > static_cast<long>(m_pRowList->size()) )
+ return;
+ //////////////////////////////////////////////////////////////////////
+ // Neue Beschreibung darstellen
+ ::boost::shared_ptr<OTableRow> pRow = (*m_pRowList)[nRow];
+ pRow->SetFieldType( _pType, sal_True );
+ if ( _pType.get() )
+ {
+ const sal_uInt16 nCurrentlySelected = pTypeCell->GetSelectEntryPos();
+
+ if ( ( LISTBOX_ENTRY_NOTFOUND == nCurrentlySelected )
+ || ( GetView()->getController().getTypeInfo( nCurrentlySelected ) != _pType )
+ )
+ {
+ USHORT nEntryPos = 0;
+ const OTypeInfoMap* pTypeInfo = GetView()->getController().getTypeInfo();
+ OTypeInfoMap::const_iterator aIter = pTypeInfo->begin();
+ OTypeInfoMap::const_iterator aEnd = pTypeInfo->end();
+ for(;aIter != aEnd;++aIter,++nEntryPos)
+ {
+ if(aIter->second == _pType)
+ break;
+ }
+ if (nEntryPos < pTypeCell->GetEntryCount())
+ pTypeCell->SelectEntryPos( nEntryPos );
+ }
+ }
+
+ pActFieldDescr = pRow->GetActFieldDescr();
+ if (pActFieldDescr != NULL && !pActFieldDescr->GetFormatKey())
+ {
+ sal_Int32 nFormatKey = ::dbtools::getDefaultNumberFormat( pActFieldDescr->GetType(),
+ pActFieldDescr->GetScale(),
+ pActFieldDescr->IsCurrency(),
+ Reference< XNumberFormatTypes>(GetView()->getController().getNumberFormatter()->getNumberFormatsSupplier()->getNumberFormats(),UNO_QUERY),
+ GetView()->getLocale());
+
+ pActFieldDescr->SetFormatKey(nFormatKey);
+ }
+
+ pDescrWin->DisplayData( pActFieldDescr );
+}
+// -----------------------------------------------------------------------------
+OTableDesignView* OTableEditorCtrl::GetView() const
+{
+ return static_cast<OTableDesignView*>(GetParent()->GetParent());
+}
+// -----------------------------------------------------------------------------
+void OTableEditorCtrl::DeactivateCell(sal_Bool bUpdate)
+{
+ OTableRowView::DeactivateCell(bUpdate);
+ // now we have to deactivate the field description
+ long nRow(GetCurRow());
+ if (pDescrWin)
+ pDescrWin->SetReadOnly(bReadOnly || !SetDataPtr(nRow) || GetActRow()->IsReadOnly());
+}
+//------------------------------------------------------------------------------
+long OTableEditorCtrl::PreNotify( NotifyEvent& rNEvt )
+{
+ if (rNEvt.GetType() == EVENT_GETFOCUS)
+ {
+ if( pDescrCell && pDescrCell->HasChildPathFocus() )
+ m_eChildFocus = DESCRIPTION;
+ else if(pNameCell && pNameCell->HasChildPathFocus() )
+ m_eChildFocus = NAME;
+ else
+ m_eChildFocus = ROW;
+ }
+
+ return OTableRowView::PreNotify(rNEvt);
+}
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.hxx b/dbaccess/source/ui/tabledesign/TEditControl.hxx
new file mode 100644
index 000000000000..1b930af6aaba
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TEditControl.hxx
@@ -0,0 +1,230 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEEDITORCONTROL_HXX
+#define DBAUI_TABLEEDITORCONTROL_HXX
+
+#ifndef DBAUI_TABLEDESIGNCONTROL_HXX
+#include "TableDesignControl.hxx"
+#endif
+#ifndef DBAUI_TABLEDESIGNVIEW_HXX
+#include "TableDesignView.hxx"
+#endif
+#ifndef DBAUI_TABLEFIELDDESCRIPTION_HXX
+#include "TableFieldDescWin.hxx"
+#endif
+#ifndef DBAUI_TABLEROW_HXX
+#include "TableRow.hxx"
+#endif
+#ifndef DBAUI_ENUMTYPES_HXX
+#include "QEnumTypes.hxx"
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+
+class Edit;
+class SfxUndoManager;
+namespace dbaui
+{
+ class OSQLNameEdit;
+
+ class OTableEditorCtrl : public OTableRowView
+ {
+ enum ChildFocusState
+ {
+ DESCRIPTION,
+ NAME,
+ ROW,
+ NONE
+ };
+
+ ::std::vector< ::boost::shared_ptr<OTableRow> > m_aUndoList;
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* m_pRowList;
+
+ OSQLNameEdit* pNameCell;
+ ::svt::ListBoxControl* pTypeCell;
+ Edit* pDescrCell;
+ OTableFieldDescWin* pDescrWin; // properties of one column
+
+ ::boost::shared_ptr<OTableRow> pActRow;
+
+ ULONG nIndexEvent;
+ ULONG nCutEvent;
+ ULONG nPasteEvent;
+ ULONG nDeleteEvent;
+ ULONG nInsNewRowsEvent;
+ ULONG nInvalidateTypeEvent;
+ ULONG nEntryNotFoundEvent;
+ ChildFocusState m_eChildFocus;
+
+ long nOldDataPos;
+
+ BOOL bSaveOnMove;
+ BOOL bReadOnly;
+ //------------------------------------------------------------------
+ // Hilfsklasse
+ class ClipboardInvalidator
+ {
+ private:
+ AutoTimer m_aInvalidateTimer;
+ OTableEditorCtrl* m_pOwner;
+
+ public:
+ ClipboardInvalidator(ULONG nTimeout,OTableEditorCtrl*);
+ ~ClipboardInvalidator();
+
+ protected:
+ DECL_LINK(OnInvalidate, void*);
+ };
+ friend class OTableEditorCtrl::ClipboardInvalidator;
+
+ ClipboardInvalidator m_aInvalidate;
+
+ protected:
+ virtual void Command( const CommandEvent& rEvt );
+ virtual BOOL SeekRow(long nRow);
+ virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect,
+ USHORT nColumnId ) const;
+
+ virtual void CursorMoved();
+ virtual RowStatus GetRowStatus(long nRow) const;
+
+ virtual ::svt::CellController* GetController(long nRow, USHORT nCol);
+ virtual void InitController(::svt::CellControllerRef& rController, long nRow, USHORT nCol);
+
+ virtual void CellModified();
+ virtual BOOL SaveModified(); // wird aufgerufen vor einem Zellenwechsel
+ // return FALSE, verhindert Zellenwechsel
+ virtual void Undo();
+ virtual void Redo();
+ virtual String GetCellText(long nRow, sal_uInt16 nColId) const;
+ virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId);
+
+ virtual void CopyRows();
+ virtual void InsertRows( long nRow );
+ virtual void DeleteRows();
+ virtual void InsertNewRows( long nRow );
+
+ virtual sal_Bool IsPrimaryKeyAllowed( long nRow );
+ virtual sal_Bool IsInsertNewAllowed( long nRow );
+ virtual sal_Bool IsDeleteAllowed( long nRow );
+
+ void ClearModified();
+
+ void SetPrimaryKey( BOOL bSet );
+ BOOL IsPrimaryKey();
+
+ DECL_LINK(ControlPreNotifyHdl, NotifyEvent*);
+
+ public:
+ // TYPEINFO();
+ OTableEditorCtrl(Window* pParentWin);
+ virtual ~OTableEditorCtrl();
+ virtual BOOL CursorMoving(long nNewRow, USHORT nNewCol);
+ virtual void UpdateAll();
+ SfxUndoManager* GetUndoManager() const;
+
+ void SetDescrWin( OTableFieldDescWin* pWin ){ pDescrWin = pWin; if (pDescrWin && pActRow) pDescrWin->DisplayData(pActRow->GetActFieldDescr()); }
+ BOOL SaveCurRow();
+ void SwitchType( const TOTypeInfoSP& _pType );
+
+ void DisplayData( long nRow, BOOL bGrabFocus = TRUE );
+ // erzwingt das Anzeigen der genannten Zeile (selbst wenn es eigentlich schon die aktuelle ist)
+
+ virtual void SetCellData( long nRow, sal_uInt16 nColId, const TOTypeInfoSP& _pTypeInfo );
+ virtual void SetCellData( long nRow, sal_uInt16 nColId, const ::com::sun::star::uno::Any& _rSaveData );
+ virtual ::com::sun::star::uno::Any GetCellData( long nRow, sal_uInt16 nColId );
+ virtual void SetControlText( long nRow, sal_uInt16 nColId, const String& rText );
+ virtual String GetControlText( long nRow, sal_uInt16 nColId );
+
+ virtual OTableDesignView* GetView() const;
+
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* GetRowList(){ return m_pRowList; }
+
+ ::boost::shared_ptr<OTableRow> GetActRow(){ return pActRow; }
+ void CellModified( long nRow, sal_uInt16 nColId );
+ void SetReadOnly( BOOL bRead=TRUE );
+
+ virtual void Init();
+ virtual void DeactivateCell(sal_Bool bUpdate = sal_True);
+
+ BOOL IsCutAllowed( long nRow = -1 );
+ BOOL IsCopyAllowed( long nRow = -1 );
+ BOOL IsPasteAllowed( long nRow = -1 );
+ BOOL IsReadOnly();
+ OFieldDescription* GetFieldDescr( long nRow );
+
+ // window overloads
+ virtual long PreNotify( NotifyEvent& rNEvt );
+
+ // IClipboardTest
+ virtual sal_Bool isCutAllowed() { return IsCutAllowed(); }
+ virtual sal_Bool isCopyAllowed() { return IsCopyAllowed(); }
+ virtual sal_Bool isPasteAllowed() { return IsPasteAllowed(); }
+ virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
+
+ virtual void cut();
+ virtual void copy();
+ virtual void paste();
+ private:
+ DECL_LINK( StartIndexing, void* );
+ DECL_LINK( DelayedCut, void* );
+ DECL_LINK( DelayedPaste, void* );
+ DECL_LINK( DelayedDelete, void* );
+ DECL_LINK( DelayedInsNewRows, void* );
+ DECL_LINK( InvalidateFieldType, void* );
+ DECL_LINK( EntryNotFound, void* );
+
+ void InitCellController();
+ INT32 HasFieldName( const String& rFieldName );
+ String GenerateName( const String& rName );
+ BOOL SetDataPtr( long nRow );
+
+ BOOL SaveData(long nRow, USHORT nColumnId);
+ /** AdjustFieldDescription set the needed values for the description
+ @param _pFieldDesc the field description where to set the values
+ @param _rMultiSel contains the postions which changed for undo/redo
+ @param _nPos the current position
+ @param _bSet should a key be set
+ @param _bPrimaryKey which value should the pkey have
+ */
+ void AdjustFieldDescription( OFieldDescription* _pFieldDesc,
+ MultiSelection& _rMultiSel,
+ sal_Int32 _nPos,
+ sal_Bool _bSet,
+ sal_Bool _bPrimaryKey);
+ /** InvalidateFeatures invalidates the slots SID_UNDO | SID_REDO | SID_SAVEDOC
+ */
+ void InvalidateFeatures();
+
+ void resetType();
+ };
+}
+#endif // DBAUI_TABLEEDITORCONTROL_HXX
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
new file mode 100644
index 000000000000..b63a13e39aed
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -0,0 +1,1629 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "FieldDescriptions.hxx"
+#include "TEditControl.hxx"
+#include "TableController.hxx"
+#include "TableDesignView.hxx"
+#include "TableRow.hxx"
+#include "TypeInfo.hxx"
+#include "UITools.hxx"
+#include "browserids.hxx"
+#include "dbu_reghelper.hxx"
+#include "dbu_tbl.hrc"
+#include "dbustrings.hrc"
+#include "defaultobjectnamecheck.hxx"
+#include "dlgsave.hxx"
+#include "dsmeta.hxx"
+#include "indexdialog.hxx"
+#include "sqlmessage.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/XTitleChangeListener.hpp>
+#include <com/sun/star/frame/XUntitledNumbers.hpp>
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/XAlterTable.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
+#include <comphelper/streamsection.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbmetadata.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <tools/diagnose_ex.h>
+#include <tools/string.hxx>
+#include <vcl/msgbox.hxx>
+
+#include <boost/mem_fn.hpp>
+#include <boost/bind.hpp>
+
+#include <algorithm>
+#include <functional>
+
+extern "C" void SAL_CALL createRegistryInfo_OTableControl()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OTableController > aAutoRegistration;
+}
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+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::container;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::ui;
+using namespace ::com::sun::star::util;
+using namespace ::dbtools;
+using namespace ::dbaui;
+using namespace ::comphelper;
+
+namespace
+{
+ void dropTable(const Reference<XNameAccess>& _rxTable,const ::rtl::OUString& _sTableName)
+ {
+ if ( _rxTable->hasByName(_sTableName) )
+ {
+ Reference<XDrop> xNameCont(_rxTable,UNO_QUERY);
+ OSL_ENSURE(xNameCont.is(),"No drop interface for tables!");
+ if ( xNameCont.is() )
+ xNameCont->dropByName(_sTableName);
+ }
+ }
+ //------------------------------------------------------------------------------
+ struct OTableRowCompare : public ::std::binary_function< ::boost::shared_ptr<OTableRow> , ::rtl::OUString, bool>
+ {
+ bool operator() (const ::boost::shared_ptr<OTableRow> lhs, const ::rtl::OUString& rhs) const
+ {
+ OFieldDescription* pField = lhs->GetActFieldDescr();
+ return pField && pField->GetName() == rhs;
+ }
+ };
+
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OTableController::getImplementationName() throw( RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString OTableController::getImplementationName_Static() throw( RuntimeException )
+{
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.OTableDesign");
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString> OTableController::getSupportedServiceNames_Static(void) throw( RuntimeException )
+{
+ Sequence< ::rtl::OUString> aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.TableDesign");
+ return aSupported;
+}
+//-------------------------------------------------------------------------
+Sequence< ::rtl::OUString> SAL_CALL OTableController::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OTableController::Create(const Reference<XMultiServiceFactory >& _rxFactory)
+{
+ return *(new OTableController(_rxFactory));
+}
+
+DBG_NAME(OTableController)
+// -----------------------------------------------------------------------------
+OTableController::OTableController(const Reference< XMultiServiceFactory >& _rM) : OTableController_BASE(_rM)
+ ,m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES))
+ ,m_pTypeInfo()
+ ,m_bAllowAutoIncrementValue(sal_False)
+ ,m_bNew(sal_True)
+{
+ DBG_CTOR(OTableController,NULL);
+
+ InvalidateAll();
+ m_pTypeInfo = TOTypeInfoSP(new OTypeInfo());
+ m_pTypeInfo->aUIName = m_sTypeNames.GetToken(TYPE_OTHER);
+}
+// -----------------------------------------------------------------------------
+OTableController::~OTableController()
+{
+ m_aTypeInfoIndex.clear();
+ m_aTypeInfo.clear();
+
+ DBG_DTOR(OTableController,NULL);
+}
+
+// -----------------------------------------------------------------------------
+void OTableController::startTableListening()
+{
+ Reference< XComponent > xComponent(m_xTable, UNO_QUERY);
+ if (xComponent.is())
+ xComponent->addEventListener(static_cast<XModifyListener*>(this));
+}
+
+// -----------------------------------------------------------------------------
+void OTableController::stopTableListening()
+{
+ Reference< XComponent > xComponent(m_xTable, UNO_QUERY);
+ if (xComponent.is())
+ xComponent->removeEventListener(static_cast<XModifyListener*>(this));
+}
+
+// -----------------------------------------------------------------------------
+void OTableController::disposing()
+{
+ OTableController_BASE::disposing();
+ m_pView = NULL;
+
+ m_vRowList.clear();
+}
+// -----------------------------------------------------------------------------
+FeatureState OTableController::GetState(sal_uInt16 _nId) const
+{
+ FeatureState aReturn;
+ // (disabled automatically)
+
+ switch (_nId)
+ {
+ case ID_BROWSER_CLOSE:
+ aReturn.bEnabled = sal_True;
+ break;
+ case ID_BROWSER_EDITDOC:
+ aReturn.bChecked = isEditable();
+ aReturn.bEnabled = m_bNew || isEditable();// the editable flag is set through this one -> || isAddAllowed() || isDropAllowed() || isAlterAllowed();
+ break;
+ case ID_BROWSER_SAVEDOC:
+ aReturn.bEnabled = isModified();
+ if ( aReturn.bEnabled )
+ {
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(),
+ ::boost::mem_fn(&OTableRow::isValid));
+ aReturn.bEnabled = aIter != m_vRowList.end();
+ }
+ break;
+ case ID_BROWSER_SAVEASDOC:
+ aReturn.bEnabled = isConnected() && isEditable();
+ if ( aReturn.bEnabled )
+ {
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(),
+ ::boost::mem_fn(&OTableRow::isValid));
+ aReturn.bEnabled = aIter != m_vRowList.end();
+ }
+ break;
+
+ case ID_BROWSER_CUT:
+ aReturn.bEnabled = isEditable() && m_aCurrentFrame.isActive() && getView() && static_cast<OTableDesignView*>(getView())->isCutAllowed();
+ break;
+ case ID_BROWSER_COPY:
+ aReturn.bEnabled = m_aCurrentFrame.isActive() && getView() && static_cast<OTableDesignView*>(getView())->isCopyAllowed();
+ break;
+ case ID_BROWSER_PASTE:
+ aReturn.bEnabled = isEditable() && m_aCurrentFrame.isActive() && getView() && static_cast<OTableDesignView*>(getView())->isPasteAllowed();
+ break;
+ case SID_INDEXDESIGN:
+ aReturn.bEnabled =
+ ( ( ((!m_bNew && isModified()) || isModified())
+ || Reference< XIndexesSupplier >(m_xTable, UNO_QUERY).is()
+ )
+ && isConnected()
+ );
+ if ( aReturn.bEnabled )
+ {
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(),
+ ::boost::mem_fn(&OTableRow::isValid));
+ aReturn.bEnabled = aIter != m_vRowList.end();
+ }
+ break;
+ default:
+ aReturn = OTableController_BASE::GetState(_nId);
+ }
+ return aReturn;
+}
+// -----------------------------------------------------------------------------
+void OTableController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
+{
+ switch(_nId)
+ {
+ case ID_BROWSER_EDITDOC:
+ setEditable(!isEditable());
+ static_cast<OTableDesignView*>(getView())->setReadOnly(!isEditable());
+ InvalidateFeature(ID_BROWSER_PASTE);
+ InvalidateFeature(SID_BROWSER_CLEAR_QUERY);
+ break;
+ case ID_BROWSER_SAVEASDOC:
+ doSaveDoc(sal_True);
+ break;
+ case ID_BROWSER_SAVEDOC:
+ static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->SaveCurRow();
+ doSaveDoc(sal_False);
+ break;
+ case ID_BROWSER_CUT:
+ static_cast<OTableDesignView*>(getView())->cut();
+ break;
+ case ID_BROWSER_COPY:
+ static_cast<OTableDesignView*>(getView())->copy();
+ break;
+ case ID_BROWSER_PASTE:
+ static_cast<OTableDesignView*>(getView())->paste();
+ break;
+ case SID_INDEXDESIGN:
+ doEditIndexes();
+ break;
+ default:
+ OTableController_BASE::Execute(_nId,aArgs);
+ }
+ InvalidateFeature(_nId);
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OTableController::doSaveDoc(sal_Bool _bSaveAs)
+{
+ if (!isConnected())
+ reconnect(sal_True); // ask the user for a new connection
+ Reference<XTablesSupplier> xTablesSup(getConnection(),UNO_QUERY);
+
+ if (!xTablesSup.is())
+ {
+ String aMessage(ModuleRes(STR_TABLEDESIGN_CONNECTION_MISSING));
+ OSQLWarningBox( getView(), aMessage ).Execute();
+ return sal_False;
+ }
+
+ // check if a column exists
+ // TODO
+
+ Reference<XNameAccess> xTables;
+ ::rtl::OUString sCatalog, sSchema;
+
+ sal_Bool bNew = (0 == m_sName.getLength());
+ bNew = bNew || m_bNew || _bSaveAs;
+
+ try
+ {
+ xTables = xTablesSup->getTables();
+ OSL_ENSURE(xTables.is(),"The tables can't be null!");
+ bNew = bNew || (xTables.is() && !xTables->hasByName(m_sName));
+
+ // first we need a name for our query so ask the user
+ if(bNew)
+ {
+ String aDefaultName;
+ if (_bSaveAs && !bNew)
+ aDefaultName = String(m_sName);
+ else
+ {
+ String aName = String(ModuleRes(STR_TBL_TITLE));
+ aDefaultName = aName.GetToken(0,' ');
+ //aDefaultName = getPrivateTitle();
+ aDefaultName = ::dbtools::createUniqueName(xTables,aDefaultName);
+ }
+
+ DynamicTableOrQueryNameCheck aNameChecker( getConnection(), CommandType::TABLE );
+ OSaveAsDlg aDlg( getView(), CommandType::TABLE, getORB(), getConnection(), aDefaultName, aNameChecker );
+ if ( aDlg.Execute() != RET_OK )
+ return sal_False;
+
+ m_sName = aDlg.getName();
+ sCatalog = aDlg.getCatalog();
+ sSchema = aDlg.getSchema();
+ }
+
+ // did we get a name
+ if(!m_sName.getLength())
+ return sal_False;
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "OTableController::doSaveDoc: nothing is expected to happen here!");
+ }
+
+ sal_Bool bAlter = sal_False;
+ sal_Bool bError = sal_False;
+ SQLExceptionInfo aInfo;
+ try
+ {
+ // check the columns for double names
+ if(!checkColumns(bNew || !xTables->hasByName(m_sName)))
+ {
+ // #105323# OJ
+ return sal_False;
+ }
+
+ Reference<XPropertySet> xTable;
+ if(bNew || !xTables->hasByName(m_sName)) // just to make sure the table already exists
+ {
+ dropTable(xTables,m_sName);
+
+ Reference<XDataDescriptorFactory> xFact(xTables,UNO_QUERY);
+ OSL_ENSURE(xFact.is(),"OTableController::doSaveDoc: No XDataDescriptorFactory available!");
+ xTable = xFact->createDataDescriptor();
+ OSL_ENSURE(xTable.is(),"OTableController::doSaveDoc: Create query failed!");
+ // to set the name is only allowed when the wuery is new
+ xTable->setPropertyValue(PROPERTY_CATALOGNAME,makeAny(sCatalog));
+ xTable->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(sSchema));
+ xTable->setPropertyValue(PROPERTY_NAME,makeAny(m_sName));
+
+ // now append the columns
+ Reference<XColumnsSupplier> xColSup(xTable,UNO_QUERY);
+ appendColumns(xColSup,bNew);
+ // now append the primary key
+ Reference<XKeysSupplier> xKeySup(xTable,UNO_QUERY);
+ appendPrimaryKey(xKeySup,bNew);
+ }
+ // now set the properties
+ if(bNew)
+ {
+ Reference<XAppend> xAppend(xTables,UNO_QUERY);
+ OSL_ENSURE(xAppend.is(),"OTableController::doSaveDoc: No XAppend Interface!");
+ xAppend->appendByDescriptor(xTable);
+
+ assignTable();
+ if(!m_xTable.is()) // correct name and try again
+ {
+ // it can be that someone inserted new data for us
+ m_sName = ::dbtools::composeTableName( getConnection()->getMetaData(), xTable, ::dbtools::eInDataManipulation, false, false, false );
+ assignTable();
+ }
+ // now check if our datasource has set a tablefilter and if append the new table name to it
+ ::dbaui::appendToFilter(getConnection(),m_sName,getORB(),getView()); // we are not interessted in the return value
+ Reference< frame::XTitleChangeListener> xEventListener(impl_getTitleHelper_throw(),UNO_QUERY);
+ if ( xEventListener.is() )
+ {
+ frame::TitleChangedEvent aEvent;
+ xEventListener->titleChanged(aEvent);
+ }
+ releaseNumberForComponent();
+ }
+ else if(m_xTable.is())
+ {
+ bAlter = sal_True;
+ alterColumns();
+ }
+ reSyncRows();
+ }
+ catch(const SQLContext& e)
+ {
+ aInfo = SQLExceptionInfo(e);
+ }
+ catch(const SQLWarning& e)
+ {
+ aInfo = SQLExceptionInfo(e);
+ }
+ catch(const SQLException& e)
+ {
+ aInfo = SQLExceptionInfo(e);
+ }
+ catch(const ElementExistException& )
+ {
+ String sText( ModuleRes( STR_NAME_ALREADY_EXISTS ) );
+ sText.SearchAndReplaceAscii( "#" , m_sName);
+ OSQLMessageBox aDlg( getView(), String( ModuleRes( STR_ERROR_DURING_CREATION ) ), sText, WB_OK, OSQLMessageBox::Error );
+
+ aDlg.Execute();
+ bError = sal_True;
+ }
+ catch( const Exception& )
+ {
+ bError = sal_True;
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( aInfo.isValid() )
+ aInfo.prepend( String( ModuleRes( STR_TABLEDESIGN_SAVE_ERROR ) ) );
+ showError(aInfo);
+
+ if (aInfo.isValid() || bError)
+ {
+ if(!bAlter || bNew)
+ {
+ m_sName = ::rtl::OUString();
+ stopTableListening();
+ m_xTable = NULL;
+ }
+ // reload(); // a error occured so we have to reload
+ }
+ return ! (aInfo.isValid() || bError);
+}
+
+// -----------------------------------------------------------------------------
+void OTableController::doEditIndexes()
+{
+ // table needs to be saved before editing indexes
+ if (m_bNew || isModified())
+ {
+ QueryBox aAsk(getView(), ModuleRes(QUERY_SAVE_TABLE_EDIT_INDEXES));
+ if (RET_YES != aAsk.Execute())
+ return;
+
+ if (!doSaveDoc(sal_False))
+ return;
+
+ OSL_ENSURE(!m_bNew && !isModified(), "OTableController::doEditIndexes: what the hell did doSaveDoc do?");
+ }
+
+ Reference< XNameAccess > xIndexes; // will be the keys of the table
+ Sequence< ::rtl::OUString > aFieldNames; // will be the column names of the table
+ try
+ {
+ // get the keys
+ Reference< XIndexesSupplier > xIndexesSupp(m_xTable, UNO_QUERY);
+ if (xIndexesSupp.is())
+ {
+ xIndexes = xIndexesSupp->getIndexes();
+ OSL_ENSURE(xIndexes.is(), "OTableController::doEditIndexes: no keys got from the indexes supplier!");
+ }
+ else
+ OSL_ENSURE(sal_False, "OTableController::doEditIndexes: should never have reached this (no indexes supplier)!");
+
+ // get the field names
+ Reference< XColumnsSupplier > xColSupp(m_xTable, UNO_QUERY);
+ OSL_ENSURE(xColSupp.is(), "OTableController::doEditIndexes: no columns supplier!");
+ if (xColSupp.is())
+ {
+ Reference< XNameAccess > xCols = xColSupp->getColumns();
+ OSL_ENSURE(xCols.is(), "OTableController::doEditIndexes: no columns!");
+ if (xCols.is())
+ aFieldNames = xCols->getElementNames();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if (!xIndexes.is())
+ return;
+
+ DbaIndexDialog aDialog(getView(), aFieldNames, xIndexes, getConnection(),getORB(),isConnected() ? getConnection()->getMetaData().is() && getConnection()->getMetaData()->getMaxColumnsInIndex() : sal_Int32(0));
+ if (RET_OK != aDialog.Execute())
+ return;
+
+}
+
+// -----------------------------------------------------------------------------
+void OTableController::impl_initialize()
+{
+ try
+ {
+ OTableController_BASE::impl_initialize();
+
+ const NamedValueCollection& rArguments( getInitParams() );
+
+ rArguments.get_ensureType( (::rtl::OUString)PROPERTY_CURRENTTABLE, m_sName );
+
+ // read autoincrement value set in the datasource
+ ::dbaui::fillAutoIncrementValue(getDataSource(),m_bAllowAutoIncrementValue,m_sAutoIncrementValue);
+
+ assignTable();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ try
+ {
+ ::dbaui::fillTypeInfo(getConnection(),m_sTypeNames,m_aTypeInfo,m_aTypeInfoIndex); // fill the needed type information
+ }
+ catch(const SQLException&)
+ {
+ OSQLWarningBox( getView(), ModuleRes( STR_NO_TYPE_INFO_AVAILABLE ) ).Execute();
+ throw;
+ }
+ try
+ {
+ loadData(); // fill the column information form the table
+ getView()->initialize(); // show the windows and fill with our informations
+ getUndoMgr()->Clear(); // clear all undo redo things
+ setModified(sal_False); // and we are not modified yet
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableController::Construct(Window* pParent)
+{
+ m_pView = new OTableDesignView( pParent, getORB(), *this );
+ OTableController_BASE::Construct(pParent);
+// m_pView->Construct();
+// m_pView->Show();
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OTableController::suspend(sal_Bool /*_bSuspend*/) throw( RuntimeException )
+{
+ if ( getBroadcastHelper().bInDispose || getBroadcastHelper().bDisposed )
+ return sal_True;
+
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( getView() && getView()->IsInModalMode() )
+ return sal_False;
+ if ( getView() )
+ static_cast<OTableDesignView*>(getView())->GrabFocus();
+ sal_Bool bCheck = sal_True;
+ if ( isModified() )
+ {
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(),
+ ::boost::mem_fn(&OTableRow::isValid));
+ if ( aIter != m_vRowList.end() )
+ {
+ QueryBox aQry(getView(), ModuleRes(TABLE_DESIGN_SAVEMODIFIED));
+ switch (aQry.Execute())
+ {
+ case RET_YES:
+ Execute(ID_BROWSER_SAVEDOC,Sequence<PropertyValue>());
+ if ( isModified() )
+ bCheck = sal_False; // when we save the table this must be false else some press cancel
+ break;
+ case RET_CANCEL:
+ bCheck = sal_False;
+ default:
+ break;
+ }
+ }
+ else if ( !m_bNew )
+ {
+ QueryBox aQry(getView(), ModuleRes(TABLE_DESIGN_ALL_ROWS_DELETED));
+ switch (aQry.Execute())
+ {
+ case RET_YES:
+ {
+ try
+ {
+ Reference<XTablesSupplier> xTablesSup(getConnection(),UNO_QUERY);
+ Reference<XNameAccess> xTables = xTablesSup->getTables();
+ dropTable(xTables,m_sName);
+ }
+ catch(const Exception&)
+ {
+ OSL_ENSURE(sal_False, "OTableController::suspend: nothing is expected to happen here!");
+ }
+
+ }
+ break;
+ case RET_CANCEL:
+ bCheck = sal_False;
+ default:
+ break;
+ }
+ }
+ }
+/*
+ if ( bCheck )
+ OSingleDocumentController::suspend(_bSuspend);
+*/
+ return bCheck;
+}
+// -----------------------------------------------------------------------------
+void OTableController::describeSupportedFeatures()
+{
+ OSingleDocumentController::describeSupportedFeatures();
+
+ implDescribeSupportedFeature( ".uno:Redo", ID_BROWSER_REDO, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:Save", ID_BROWSER_SAVEDOC, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:Undo", ID_BROWSER_UNDO, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:HelpMenu", SID_HELPMENU, CommandGroup::APPLICATION );
+ implDescribeSupportedFeature( ".uno:NewDoc", SID_NEWDOC, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:SaveAs", ID_BROWSER_SAVEASDOC, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:DBIndexDesign", SID_INDEXDESIGN, CommandGroup::APPLICATION );
+ implDescribeSupportedFeature( ".uno:EditDoc", ID_BROWSER_EDITDOC, CommandGroup::EDIT );
+}
+// -----------------------------------------------------------------------------
+SfxUndoManager* OTableController::getUndoMgr()
+{
+ return &m_aUndoManager;
+}
+// -----------------------------------------------------------------------------
+void OTableController::setModified(sal_Bool _bModified)
+{
+ OSingleDocumentController::setModified(_bModified);
+ InvalidateFeature(SID_INDEXDESIGN);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OTableController::disposing( const EventObject& _rSource ) throw(RuntimeException)
+{
+ if ( _rSource.Source == m_xTable )
+ { // some deleted our table so we have a new one
+ stopTableListening();
+ m_xTable = NULL;
+ m_bNew = sal_True;
+ setModified(sal_True);
+ }
+ else
+ OTableController_BASE::disposing( _rSource );
+}
+// -----------------------------------------------------------------------------
+void OTableController::Save(const Reference< XObjectOutputStream>& _rxOut)
+{
+ OStreamSection aSection(_rxOut.get());
+
+}
+// -----------------------------------------------------------------------------
+void OTableController::Load(const Reference< XObjectInputStream>& _rxIn)
+{
+ OStreamSection aSection(_rxIn.get());
+}
+
+// -----------------------------------------------------------------------------
+void OTableController::losingConnection( )
+{
+ // let the base class do it's reconnect
+ OTableController_BASE::losingConnection( );
+
+ // remove from the table
+ Reference< XComponent > xComponent(m_xTable, UNO_QUERY);
+ if (xComponent.is())
+ {
+ Reference<XEventListener> xEvtL( static_cast< ::cppu::OWeakObject*>(this), UNO_QUERY);
+ xComponent->removeEventListener(xEvtL);
+ }
+ stopTableListening();
+ m_xTable = NULL;
+ assignTable();
+ if(!m_xTable.is())
+ {
+ m_bNew = sal_True;
+ setModified(sal_True);
+ }
+ InvalidateAll();
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OTableController::getTypeInfoByType(sal_Int32 _nDataType) const
+{
+ return queryTypeInfoByType(_nDataType,m_aTypeInfo);
+}
+// -----------------------------------------------------------------------------
+void OTableController::appendColumns(Reference<XColumnsSupplier>& _rxColSup,sal_Bool _bNew,sal_Bool _bKeyColumns)
+{
+ try
+ {
+ // now append the columns
+ OSL_ENSURE(_rxColSup.is(),"No columns supplier");
+ if(!_rxColSup.is())
+ return;
+ Reference<XNameAccess> xColumns = _rxColSup->getColumns();
+ OSL_ENSURE(xColumns.is(),"No columns");
+ Reference<XDataDescriptorFactory> xColumnFactory(xColumns,UNO_QUERY);
+
+ Reference<XAppend> xAppend(xColumns,UNO_QUERY);
+ OSL_ENSURE(xAppend.is(),"No XAppend Interface!");
+
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_vRowList.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_vRowList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OSL_ENSURE(*aIter,"OTableRow is null!");
+ OFieldDescription* pField = (*aIter)->GetActFieldDescr();
+ if ( !pField || (!_bNew && (*aIter)->IsReadOnly() && !_bKeyColumns) )
+ continue;
+
+ Reference<XPropertySet> xColumn;
+ if(pField->IsPrimaryKey() || !_bKeyColumns)
+ xColumn = xColumnFactory->createDataDescriptor();
+ if(xColumn.is())
+ {
+ if(!_bKeyColumns)
+ ::dbaui::setColumnProperties(xColumn,pField);
+ else
+ xColumn->setPropertyValue(PROPERTY_NAME,makeAny(pField->GetName()));
+
+ xAppend->appendByDescriptor(xColumn);
+ xColumn = NULL;
+ // now only the settings are missing
+ if(xColumns->hasByName(pField->GetName()))
+ {
+ xColumns->getByName(pField->GetName()) >>= xColumn;
+ if(xColumn.is())
+ pField->copyColumnSettingsTo(xColumn);
+ }
+ else
+ {
+ OSL_ENSURE(sal_False, "OTableController::appendColumns: invalid field name!");
+ }
+
+ }
+ }
+ }
+ catch(const SQLException& )
+ {
+ showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OTableController::appendPrimaryKey(Reference<XKeysSupplier>& _rxSup,sal_Bool _bNew)
+{
+ if(!_rxSup.is())
+ return; // the database doesn't support keys
+
+ OSL_ENSURE(_rxSup.is(),"No XKeysSupplier!");
+ Reference<XIndexAccess> xKeys(_rxSup->getKeys(),UNO_QUERY);
+ Reference<XPropertySet> xProp;
+ const sal_Int32 nCount = xKeys->getCount();
+ for(sal_Int32 i=0;i< nCount ;++i)
+ {
+ xKeys->getByIndex(i) >>= xProp;
+ sal_Int32 nKeyType = 0;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
+ if(KeyType::PRIMARY == nKeyType)
+ {
+ return; // primary key already exists after appending a column
+ }
+ }
+ Reference<XDataDescriptorFactory> xKeyFactory(xKeys,UNO_QUERY);
+ OSL_ENSURE(xKeyFactory.is(),"No XDataDescriptorFactory Interface!");
+ if ( !xKeyFactory.is() )
+ return;
+ Reference<XAppend> xAppend(xKeyFactory,UNO_QUERY);
+ OSL_ENSURE(xAppend.is(),"No XAppend Interface!");
+
+ Reference<XPropertySet> xKey = xKeyFactory->createDataDescriptor();
+ OSL_ENSURE(xKey.is(),"Key is null!");
+ xKey->setPropertyValue(PROPERTY_TYPE,makeAny(KeyType::PRIMARY));
+
+ Reference<XColumnsSupplier> xColSup(xKey,UNO_QUERY);
+ if(xColSup.is())
+ {
+ appendColumns(xColSup,_bNew,sal_True);
+ Reference<XNameAccess> xColumns = xColSup->getColumns();
+ if(xColumns->hasElements())
+ xAppend->appendByDescriptor(xKey);
+ }
+}
+// -----------------------------------------------------------------------------
+void OTableController::loadData()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Wenn Datenstruktur bereits vorhanden, Struktur leeren
+ m_vRowList.clear();
+
+ ::boost::shared_ptr<OTableRow> pTabEdRow;
+ Reference< XDatabaseMetaData> xMetaData = getMetaData( );
+ //////////////////////////////////////////////////////////////////////
+ // Datenstruktur mit Daten aus DatenDefinitionsObjekt fuellen
+ if(m_xTable.is() && xMetaData.is())
+ {
+ Reference<XColumnsSupplier> xColSup(m_xTable,UNO_QUERY);
+ OSL_ENSURE(xColSup.is(),"No XColumnsSupplier!");
+ Reference<XNameAccess> xColumns = xColSup->getColumns();
+ OFieldDescription* pActFieldDescr = NULL;
+ String aType;
+ //////////////////////////////////////////////////////////////////////
+ // ReadOnly-Flag
+ // 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 bIsAlterAllowed = isAlterAllowed();
+ Sequence< ::rtl::OUString> aColumns = xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aColumns.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aColumns.getLength();
+
+ for(;pIter != pEnd;++pIter)
+ {
+ Reference<XPropertySet> xColumn;
+ xColumns->getByName(*pIter) >>= xColumn;
+ sal_Int32 nType = 0;
+ sal_Int32 nScale = 0;
+ sal_Int32 nPrecision = 0;
+ sal_Int32 nNullable = 0;
+ sal_Int32 nFormatKey = 0;
+ sal_Int32 nAlign = 0;
+
+ sal_Bool bIsAutoIncrement = false, bIsCurrency = false;
+ ::rtl::OUString sName,sDescription,sTypeName;
+ Any aControlDefault;
+
+ // get the properties from the column
+ xColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
+ xColumn->getPropertyValue(PROPERTY_TYPENAME) >>= sTypeName;
+ xColumn->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullable;
+ xColumn->getPropertyValue(PROPERTY_ISAUTOINCREMENT) >>= bIsAutoIncrement;
+ xColumn->getPropertyValue(PROPERTY_ISCURRENCY) >>= bIsCurrency;
+ xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ xColumn->getPropertyValue(PROPERTY_SCALE) >>= nScale;
+ xColumn->getPropertyValue(PROPERTY_PRECISION) >>= nPrecision;
+
+
+ if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_HELPTEXT))
+ xColumn->getPropertyValue(PROPERTY_HELPTEXT) >>= sDescription;
+ if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_CONTROLDEFAULT))
+ aControlDefault = xColumn->getPropertyValue(PROPERTY_CONTROLDEFAULT);
+ if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_FORMATKEY))
+ xColumn->getPropertyValue(PROPERTY_FORMATKEY) >>= nFormatKey;
+ if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_ALIGN))
+ xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign;
+
+ pTabEdRow.reset(new OTableRow());
+ pTabEdRow->SetReadOnly(!bIsAlterAllowed);
+ // search for type
+ sal_Bool bForce;
+ ::rtl::OUString sCreate(RTL_CONSTASCII_USTRINGPARAM("x"));
+ TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(m_aTypeInfo,nType,sTypeName,sCreate,nPrecision,nScale,bIsAutoIncrement,bForce);
+ if ( !pTypeInfo.get() )
+ pTypeInfo = m_pTypeInfo;
+ pTabEdRow->SetFieldType( pTypeInfo, bForce );
+
+ pActFieldDescr = pTabEdRow->GetActFieldDescr();
+ OSL_ENSURE(pActFieldDescr, "OTableController::loadData: invalid field description generated by the table row!");
+ if ( pActFieldDescr )
+ {
+ pActFieldDescr->SetName(sName);
+ pActFieldDescr->SetFormatKey(nFormatKey);
+ // pActFieldDescr->SetPrimaryKey(pPrimary->GetValue());
+ pActFieldDescr->SetDescription(sDescription);
+ pActFieldDescr->SetAutoIncrement(bIsAutoIncrement);
+ pActFieldDescr->SetHorJustify(dbaui::mapTextJustify(nAlign));
+ pActFieldDescr->SetCurrency(bIsCurrency);
+
+ //////////////////////////////////////////////////////////////////////
+ // Spezielle Daten
+ pActFieldDescr->SetIsNullable(nNullable);
+ pActFieldDescr->SetControlDefault(aControlDefault);
+ pActFieldDescr->SetPrecision(nPrecision);
+ pActFieldDescr->SetScale(nScale);
+ }
+ m_vRowList.push_back( pTabEdRow);
+ }
+ // fill the primary key information
+ Reference<XNameAccess> xKeyColumns = getKeyColumns();
+ if(xKeyColumns.is())
+ {
+ Sequence< ::rtl::OUString> aKeyColumns = xKeyColumns->getElementNames();
+ const ::rtl::OUString* pKeyBegin = aKeyColumns.getConstArray();
+ const ::rtl::OUString* pKeyEnd = pKeyBegin + aKeyColumns.getLength();
+
+ for(;pKeyBegin != pKeyEnd;++pKeyBegin)
+ {
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator rowIter = m_vRowList.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator rowEnd = m_vRowList.end();
+ for(;rowIter != rowEnd;++rowIter)
+ {
+ if((*rowIter)->GetActFieldDescr()->GetName() == *pKeyBegin)
+ {
+ (*rowIter)->SetPrimaryKey(sal_True);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Leere Zeilen fuellen
+
+ OTypeInfoMap::iterator aTypeIter = m_aTypeInfo.find(DataType::VARCHAR);
+ if(aTypeIter == m_aTypeInfo.end())
+ aTypeIter = m_aTypeInfo.begin();
+
+ OSL_ENSURE(aTypeIter != m_aTypeInfo.end(),"We have no type infomation!");
+
+ bool bReadRow = !isAddAllowed();
+ for(sal_Int32 i=m_vRowList.size(); i<128; i++ )
+ {
+ pTabEdRow.reset(new OTableRow());
+ pTabEdRow->SetReadOnly(bReadRow);
+ m_vRowList.push_back( pTabEdRow);
+ }
+}
+// -----------------------------------------------------------------------------
+Reference<XNameAccess> OTableController::getKeyColumns() const
+{
+ // use keys and indexes for excat postioning
+ // first the keys
+ Reference<XKeysSupplier> xKeySup(m_xTable,UNO_QUERY);
+ Reference<XIndexAccess> xKeys;
+ if(xKeySup.is())
+ xKeys = xKeySup->getKeys();
+
+ Reference<XColumnsSupplier> xKeyColsSup;
+ Reference<XNameAccess> xKeyColumns;
+ if(xKeys.is())
+ {
+ Reference<XPropertySet> xProp;
+ sal_Int32 nCount = xKeys->getCount();
+ for(sal_Int32 i=0;i< nCount;++i)
+ {
+ xKeys->getByIndex(i) >>= xProp;
+ OSL_ENSURE(xProp.is(),"Key is invalid: NULL!");
+ if ( xProp.is() )
+ {
+ sal_Int32 nKeyType = 0;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
+ if(KeyType::PRIMARY == nKeyType)
+ {
+ xKeyColsSup.set(xProp,UNO_QUERY);
+ OSL_ENSURE(xKeyColsSup.is(),"Columnsupplier is null!");
+ xKeyColumns = xKeyColsSup->getColumns();
+ break;
+ }
+ }
+ }
+ }
+
+ return xKeyColumns;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableController::checkColumns(sal_Bool _bNew) throw(::com::sun::star::sdbc::SQLException)
+{
+ sal_Bool bOk = sal_True;
+ sal_Bool bFoundPKey = sal_False;
+ Reference< XDatabaseMetaData > xMetaData = getMetaData( );
+ DatabaseMetaData aMetaData( getConnection() );
+
+ ::comphelper::UStringMixEqual bCase(xMetaData.is() ? xMetaData->supportsMixedCaseQuotedIdentifiers() : sal_True);
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_vRowList.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_vRowList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OFieldDescription* pFieldDesc = (*aIter)->GetActFieldDescr();
+ if (pFieldDesc && pFieldDesc->GetName().getLength())
+ {
+ bFoundPKey |= (*aIter)->IsPrimaryKey();
+ // first check for duplicate names
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter2 = aIter+1;
+ for(;aIter2 != aEnd;++aIter2)
+ {
+ OFieldDescription* pCompareDesc = (*aIter2)->GetActFieldDescr();
+ if (pCompareDesc && bCase(pCompareDesc->GetName(),pFieldDesc->GetName()))
+ {
+ String strMessage = String(ModuleRes(STR_TABLEDESIGN_DUPLICATE_NAME));
+ strMessage.SearchAndReplaceAscii("$column$", pFieldDesc->GetName());
+ OSQLWarningBox( getView(), strMessage ).Execute();
+ return sal_False;
+ }
+ }
+ }
+ }
+ if ( _bNew && !bFoundPKey && aMetaData.supportsPrimaryKeys() )
+ {
+ String sTitle(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY_HEAD));
+ String sMsg(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY));
+ OSQLMessageBox aBox(getView(), sTitle,sMsg, WB_YES_NO_CANCEL | WB_DEF_YES);
+
+ switch ( aBox.Execute() )
+ {
+ case RET_YES:
+ {
+ ::boost::shared_ptr<OTableRow> pNewRow(new OTableRow());
+ TOTypeInfoSP pTypeInfo = ::dbaui::queryPrimaryKeyType(m_aTypeInfo);
+ if ( !pTypeInfo.get() )
+ break;
+
+ pNewRow->SetFieldType( pTypeInfo );
+ OFieldDescription* pActFieldDescr = pNewRow->GetActFieldDescr();
+
+ pActFieldDescr->SetAutoIncrement(sal_False); // #95927# pTypeInfo->bAutoIncrement
+ pActFieldDescr->SetIsNullable(ColumnValue::NO_NULLS);
+
+ pActFieldDescr->SetName( createUniqueName(::rtl::OUString::createFromAscii("ID") ));
+ pActFieldDescr->SetPrimaryKey( sal_True );
+ m_vRowList.insert(m_vRowList.begin(),pNewRow);
+
+ static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->Invalidate();
+ static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->RowInserted(0);
+ }
+ break;
+ case RET_CANCEL:
+ bOk = sal_False;
+ break;
+ }
+ }
+ return bOk;
+}
+// -----------------------------------------------------------------------------
+void OTableController::alterColumns()
+{
+ Reference<XColumnsSupplier> xColSup(m_xTable,UNO_QUERY_THROW);
+ OSL_ENSURE(xColSup.is(),"What happen here?!");
+
+ Reference<XNameAccess> xColumns = xColSup->getColumns();
+ Reference<XIndexAccess> xIdxColumns(xColumns,UNO_QUERY_THROW);
+ OSL_ENSURE(xColumns.is(),"No columns");
+ if ( !xColumns.is() )
+ return;
+ Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY); // can be null
+
+ sal_Int32 nColumnCount = xIdxColumns->getCount();
+ 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 = getMetaData( );
+
+ ::std::map< ::rtl::OUString,sal_Bool,::comphelper::UStringMixLess> aColumns(xMetaData.is() ? (xMetaData->supportsMixedCaseQuotedIdentifiers() ? true : false): sal_True);
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_vRowList.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_vRowList.end();
+ // first look for columns where something other than the name changed
+ sal_Int32 nPos = 0;
+ for(;aIter != aEnd;++aIter,++nPos)
+ {
+ OSL_ENSURE(*aIter,"OTableRow is null!");
+ OFieldDescription* pField = (*aIter)->GetActFieldDescr();
+ if ( !pField )
+ continue;
+ if ( (*aIter)->IsReadOnly() )
+ {
+ aColumns[pField->GetName()] = sal_True;
+ continue;
+ }
+
+ Reference<XPropertySet> xColumn;
+ if ( xColumns->hasByName(pField->GetName()) )
+ {
+ aColumns[pField->GetName()] = sal_True;
+ xColumns->getByName(pField->GetName()) >>= xColumn;
+ OSL_ENSURE(xColumn.is(),"Column is null!");
+
+ sal_Int32 nType=0,nPrecision=0,nScale=0,nNullable=0;
+ sal_Bool bAutoIncrement = false;
+ ::rtl::OUString sTypeName;
+
+ xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ xColumn->getPropertyValue(PROPERTY_PRECISION) >>= nPrecision;
+ xColumn->getPropertyValue(PROPERTY_SCALE) >>= nScale;
+ xColumn->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullable;
+ xColumn->getPropertyValue(PROPERTY_ISAUTOINCREMENT) >>= bAutoIncrement;
+
+ try { xColumn->getPropertyValue(PROPERTY_TYPENAME) >>= sTypeName; }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "no TypeName property?!" );
+ // since this is a last minute fix for #i41785#, I want to be on the safe side,
+ // and catch errors here as early as possible (instead of the whole process of altering
+ // the columns failing)
+ // Normally, sdbcx::Column objects are expected to have a TypeName property
+ }
+
+ // xColumn->getPropertyValue(PROPERTY_ISCURRENCY,::cppu::bool2any(pField->IsCurrency()));
+ // check if something changed
+ if((nType != pField->GetType() ||
+ sTypeName != pField->GetTypeName() ||
+ (nPrecision != pField->GetPrecision() && nPrecision ) ||
+ nScale != pField->GetScale() ||
+ nNullable != pField->GetIsNullable() ||
+ bAutoIncrement != pField->IsAutoIncrement())&&
+ xColumnFactory.is())
+ {
+ Reference<XPropertySet> xNewColumn;
+ xNewColumn = xColumnFactory->createDataDescriptor();
+ ::dbaui::setColumnProperties(xNewColumn,pField);
+ // first try to alter the column
+ sal_Bool bNotOk = sal_False;
+ try
+ {
+ // first try if we can alter the column
+ if(xAlter.is())
+ xAlter->alterColumnByName(pField->GetName(),xNewColumn);
+ }
+ catch(const SQLException&)
+ {
+ if(xDrop.is() && xAppend.is())
+ {
+ String aMessage( ModuleRes( STR_TABLEDESIGN_ALTER_ERROR ) );
+ aMessage.SearchAndReplaceAscii( "$column$", pField->GetName() );
+
+ SQLExceptionInfo aError( ::cppu::getCaughtException() );
+ OSQLWarningBox aMsg( getView(), aMessage, WB_YES_NO | WB_DEF_YES , &aError );
+ bNotOk = aMsg.Execute() == RET_YES;
+ }
+ else
+ throw;
+ }
+ // if something went wrong or we can't alter columns
+ // drop and append a new one
+ if((!xAlter.is() || bNotOk) && xDrop.is() && xAppend.is())
+ {
+ xDrop->dropByName(pField->GetName());
+ try
+ {
+ xAppend->appendByDescriptor(xNewColumn);
+ }
+ catch(const SQLException&)
+ { // an error occured so we try to reactivate the old one
+ xAppend->appendByDescriptor(xColumn);
+ throw;
+ }
+ }
+ // exceptions are caught outside
+ xNewColumn = NULL;
+ if(xColumns->hasByName(pField->GetName()))
+ xColumns->getByName(pField->GetName()) >>= xColumn;
+ bReload = sal_True;
+ }
+
+
+ }
+ else if(xColumnFactory.is() && xAlter.is() && nPos < nColumnCount)
+ { // we can't find the column so we could try it with the index before we drop and append a new column
+ try
+ {
+ Reference<XPropertySet> xNewColumn;
+ xNewColumn = xColumnFactory->createDataDescriptor();
+ ::dbaui::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())
+ pField->copyColumnSettingsTo(xColumn);
+ }
+ else
+ {
+ OSL_ENSURE(sal_False, "OTableController::alterColumns: invalid column (2)!");
+ }
+ }
+ catch(const SQLException&)
+ { // we couldn't alter the column so we have to add new columns
+ bReload = sal_True;
+ if(xDrop.is() && xAppend.is())
+ {
+ String aMessage(ModuleRes(STR_TABLEDESIGN_ALTER_ERROR));
+ aMessage.SearchAndReplaceAscii("$column$",pField->GetName());
+ OSQLWarningBox aMsg( getView(), aMessage, WB_YES_NO | WB_DEF_YES );
+ if ( aMsg.Execute() != RET_YES )
+ {
+ Reference<XPropertySet> xNewColumn(xIdxColumns->getByIndex(nPos),UNO_QUERY_THROW);
+ ::rtl::OUString sName;
+ xNewColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
+ aColumns[sName] = sal_True;
+ aColumns[pField->GetName()] = sal_True;
+ continue;
+ }
+ }
+ else
+ throw;
+ }
+ }
+ else
+ bReload = sal_True;
+ } // for(sal_Int32 nPos = 0;aIter != aEnd;++aIter,++nPos)
+ // alter column settings
+ aIter = m_vRowList.begin();
+
+ // first look for columns where something other than the name changed
+ for(nPos = 0;aIter != aEnd;++aIter,++nPos)
+ {
+ OSL_ENSURE(*aIter,"OTableRow is null!");
+ OFieldDescription* pField = (*aIter)->GetActFieldDescr();
+ if ( !pField )
+ continue;
+ if ( (*aIter)->IsReadOnly() )
+ {
+ aColumns[pField->GetName()] = sal_True;
+ continue;
+ }
+
+ Reference<XPropertySet> xColumn;
+ if ( xColumns->hasByName(pField->GetName()) )
+ {
+ xColumns->getByName(pField->GetName()) >>= xColumn;
+ Reference<XPropertySetInfo> xInfo = xColumn->getPropertySetInfo();
+ if ( xInfo->hasPropertyByName(PROPERTY_HELPTEXT) )
+ xColumn->setPropertyValue(PROPERTY_HELPTEXT,makeAny(pField->GetDescription()));
+ if(xInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT))
+ xColumn->setPropertyValue(PROPERTY_CONTROLDEFAULT,pField->GetControlDefault());
+ if(xInfo->hasPropertyByName(PROPERTY_FORMATKEY))
+ xColumn->setPropertyValue(PROPERTY_FORMATKEY,makeAny(pField->GetFormatKey()));
+ if(xInfo->hasPropertyByName(PROPERTY_ALIGN))
+ xColumn->setPropertyValue(PROPERTY_ALIGN,makeAny(dbaui::mapTextAllign(pField->GetHorJustify())));
+ } // if ( xColumns->hasByName(pField->GetName()) )
+ }
+ // second drop all columns which could be found by name
+ Reference<XNameAccess> xKeyColumns = getKeyColumns();
+ // now we have to look for the columns who could be deleted
+ if ( xDrop.is() )
+ {
+ Sequence< ::rtl::OUString> aColumnNames = xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aColumnNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aColumnNames.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if(aColumns.find(*pIter) == aColumns.end()) // found a column to delete
+ {
+ if(xKeyColumns.is() && xKeyColumns->hasByName(*pIter)) // check if this column is a member of the primary key
+ {
+ String aMsgT(ModuleRes(STR_TBL_COLUMN_IS_KEYCOLUMN));
+ aMsgT.SearchAndReplaceAscii("$column$",*pIter);
+ String aTitle(ModuleRes(STR_TBL_COLUMN_IS_KEYCOLUMN_TITLE));
+ OSQLMessageBox aMsg(getView(),aTitle,aMsgT,WB_YES_NO| WB_DEF_YES);
+ if(aMsg.Execute() == RET_YES)
+ {
+ xKeyColumns = NULL;
+ dropPrimaryKey();
+ }
+ else
+ {
+ bReload = sal_True;
+ continue;
+ }
+ }
+ try
+ {
+ xDrop->dropByName(*pIter);
+ }
+ catch (const SQLException&)
+ {
+ String sError( ModuleRes( STR_TABLEDESIGN_COULD_NOT_DROP_COL ) );
+ sError.SearchAndReplaceAscii( "$column$", *pIter );
+
+ SQLException aNewException;
+ aNewException.Message = sError;
+ aNewException.SQLState = ::rtl::OUString::createFromAscii( "S1000" );
+ aNewException.NextException = ::cppu::getCaughtException();
+
+ throw aNewException;
+ }
+ }
+ }
+ }
+
+ // third append the new columns
+ aIter = m_vRowList.begin();
+ for(;aIter != aEnd;++aIter)
+ {
+ OSL_ENSURE(*aIter,"OTableRow is null!");
+ OFieldDescription* pField = (*aIter)->GetActFieldDescr();
+ if ( !pField || (*aIter)->IsReadOnly() || aColumns.find(pField->GetName()) != aColumns.end() )
+ continue;
+
+ Reference<XPropertySet> xColumn;
+ if(!xColumns->hasByName(pField->GetName()))
+ {
+ if(xColumnFactory.is() && xAppend.is())
+ {// column not found by its name so we assume it is new
+ // Column is new
+ xColumn = xColumnFactory->createDataDescriptor();
+ ::dbaui::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())
+ pField->copyColumnSettingsTo(xColumn);
+ }
+ else
+ {
+ OSL_ENSURE(sal_False, "OTableController::alterColumns: invalid column!");
+ }
+ }
+ }
+ }
+
+
+ // check if we have to do something with the primary key
+ sal_Bool bNeedDropKey = sal_False;
+ sal_Bool bNeedAppendKey = sal_False;
+ if ( xKeyColumns.is() )
+ {
+ aIter = m_vRowList.begin();
+ for(;aIter != aEnd;++aIter)
+ {
+ OSL_ENSURE(*aIter,"OTableRow is null!");
+ OFieldDescription* pField = (*aIter)->GetActFieldDescr();
+ if ( !pField )
+ continue;
+
+ if ( pField->IsPrimaryKey()
+ && !xKeyColumns->hasByName( pField->GetName() )
+ )
+ { // new primary key column inserted which isn't already in the columns selection
+ bNeedDropKey = bNeedAppendKey = sal_True;
+ break;
+ }
+ else if ( !pField->IsPrimaryKey()
+ && xKeyColumns->hasByName( pField->GetName() )
+ )
+ { // found a column which currently is in the primary key, but is marked not to be anymore
+ bNeedDropKey = bNeedAppendKey = sal_True;
+ break;
+ }
+ }
+ }
+ else
+ { // no primary key available so we check if we should create one
+ bNeedAppendKey = sal_True;
+ }
+
+ if ( bNeedDropKey && xKeyColumns.is() && xKeyColumns->getElementNames().getLength() )
+ dropPrimaryKey();
+
+ if ( bNeedAppendKey )
+ {
+ Reference< XKeysSupplier > xKeySup( m_xTable, UNO_QUERY );
+ appendPrimaryKey( xKeySup ,sal_False);
+ }
+
+ reSyncRows();
+
+ if ( bReload )
+ reload();
+}
+// -----------------------------------------------------------------------------
+void OTableController::dropPrimaryKey()
+{
+ SQLExceptionInfo aInfo;
+ try
+ {
+ Reference<XKeysSupplier> xKeySup(m_xTable,UNO_QUERY);
+ Reference<XIndexAccess> xKeys;
+ if(xKeySup.is())
+ xKeys = xKeySup->getKeys();
+
+ if(xKeys.is())
+ {
+ Reference<XPropertySet> xProp;
+ for(sal_Int32 i=0;i< xKeys->getCount();++i)
+ {
+ xProp.set(xKeys->getByIndex(i),UNO_QUERY);
+ sal_Int32 nKeyType = 0;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
+ if(KeyType::PRIMARY == nKeyType)
+ {
+ Reference<XDrop> xDrop(xKeys,UNO_QUERY);
+ xDrop->dropByIndex(i); // delete the key
+ break;
+ }
+ }
+ }
+ }
+ catch(const SQLContext& e)
+ {
+ aInfo = SQLExceptionInfo(e);
+ }
+ catch(const SQLWarning& e)
+ {
+ aInfo = SQLExceptionInfo(e);
+ }
+ catch(const SQLException& e)
+ {
+ aInfo = SQLExceptionInfo(e);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ showError(aInfo);
+}
+// -----------------------------------------------------------------------------
+void OTableController::assignTable()
+{
+ ::rtl::OUString sComposedName;
+ // get the table
+ if(m_sName.getLength())
+ {
+ Reference<XNameAccess> xNameAccess;
+ Reference<XTablesSupplier> xSup(getConnection(),UNO_QUERY);
+ if(xSup.is())
+ {
+ xNameAccess = xSup->getTables();
+ OSL_ENSURE(xNameAccess.is(),"no nameaccess for the queries!");
+
+ Reference<XPropertySet> xProp;
+ if(xNameAccess->hasByName(m_sName) && ::cppu::extractInterface(xProp,xNameAccess->getByName(m_sName)) && xProp.is())
+ {
+ m_xTable = xProp;
+ startTableListening();
+
+ // check if we set the table editable
+ Reference<XDatabaseMetaData> xMeta = getConnection()->getMetaData();
+ setEditable( xMeta.is() && !xMeta->isReadOnly() && (isAlterAllowed() || isDropAllowed() || isAddAllowed()) );
+ if(!isEditable())
+ {
+ ::std::for_each(m_vRowList.begin(),m_vRowList.end(),boost::bind( &OTableRow::SetReadOnly, _1, boost::cref( sal_True )));
+ }
+ m_bNew = sal_False;
+ // be notified when the table is in disposing
+ InvalidateAll();
+ }
+ }
+ }
+ //updateTitle();
+}
+// -----------------------------------------------------------------------------
+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();
+
+ try
+ {
+ Reference< XDatabaseMetaData > xMetaData = getMetaData( );
+ bAddAllowed = bAddAllowed || ( xMetaData.is() && xMetaData->supportsAlterTableWithAddColumn());
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ bAddAllowed = sal_False;
+ }
+
+ return bAddAllowed;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableController::isDropAllowed() const
+{
+ Reference<XColumnsSupplier> xColsSup(m_xTable,UNO_QUERY);
+ sal_Bool bDropAllowed = !m_xTable.is();
+ if(xColsSup.is())
+ {
+ Reference<XNameAccess> xNameAccess = xColsSup->getColumns();
+ bDropAllowed = Reference<XDrop>(xNameAccess,UNO_QUERY).is() && xNameAccess->hasElements();
+ }
+
+ Reference< XDatabaseMetaData> xMetaData = getMetaData( );
+ 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< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_vRowList.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_vRowList.end();
+ for(;aIter != aEnd;++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
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTableController::createUniqueName(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString sName = _rName;
+ Reference< XDatabaseMetaData> xMetaData = getMetaData( );
+
+ ::comphelper::UStringMixEqual bCase(xMetaData.is() ? xMetaData->supportsMixedCaseQuotedIdentifiers() : sal_True);
+
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_vRowList.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_vRowList.end();
+ for(sal_Int32 i=0;aIter != aEnd;++aIter)
+ {
+ OFieldDescription* pFieldDesc = (*aIter)->GetActFieldDescr();
+ if (pFieldDesc && pFieldDesc->GetName().getLength() && bCase(sName,pFieldDesc->GetName()))
+ { // found a second name of _rName so we need another
+ sName = _rName + ::rtl::OUString::valueOf(++i);
+ aIter = m_vRowList.begin(); // and retry
+ }
+ }
+ return sName;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTableController::getPrivateTitle() const
+{
+ ::rtl::OUString sTitle;
+ try
+ {
+ // get the table
+ if ( m_sName.getLength() && getConnection().is() )
+ {
+ if ( m_xTable.is() )
+ sTitle = ::dbtools::composeTableName( getConnection()->getMetaData(), m_xTable, ::dbtools::eInDataManipulation, false, false, false );
+ else
+ sTitle = m_sName;
+ }
+ if ( !sTitle.getLength() )
+ {
+ String aName = String(ModuleRes(STR_TBL_TITLE));
+ sTitle = aName.GetToken(0,' ');
+ sTitle += ::rtl::OUString::valueOf(getCurrentStartNumber());
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sTitle;
+}
+// -----------------------------------------------------------------------------
+void OTableController::reload()
+{
+ loadData(); // fill the column information form the table
+ 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
+ static_cast<OTableDesignView*>(getView())->Invalidate();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OTableController::getFirstEmptyRowPosition() const
+{
+ sal_Int32 nRet = -1;
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_vRowList.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_vRowList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if ( !*aIter || !(*aIter)->GetActFieldDescr() || !(*aIter)->GetActFieldDescr()->GetName().getLength() )
+ {
+ nRet = aIter - m_vRowList.begin();
+ break;
+ }
+ }
+ return nRet;
+}
+// -----------------------------------------------------------------------------
+bool OTableController::isAutoIncrementPrimaryKey() const
+{
+ return getSdbMetaData().isAutoIncrementPrimaryKey();
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/tabledesign/TableDesignControl.cxx b/dbaccess/source/ui/tabledesign/TableDesignControl.cxx
new file mode 100644
index 000000000000..91fbcd27081f
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableDesignControl.cxx
@@ -0,0 +1,241 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBAUI_TABLEDESIGNCONTROL_HXX
+#include "TableDesignControl.hxx"
+#endif
+#ifndef _DBU_TBL_HRC_
+#include "dbu_tbl.hrc"
+#endif
+#ifndef DBAUI_TABLEDESIGNVIEW_HXX
+#include "TableDesignView.hxx"
+#endif
+#ifndef DBUI_TABLECONTROLLER_HXX
+#include "TableController.hxx"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UTIL_URL_HPP_
+#include <com/sun/star/util/URL.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+
+using namespace ::dbaui;
+using namespace ::svt;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+//--- Defines
+#define HANDLE_ID 0
+
+DBG_NAME(OTableRowView)
+//------------------------------------------------------------------------
+OTableRowView::OTableRowView(Window* pParent)
+ :EditBrowseBox(pParent, ModuleRes(RID_DB_TAB_EDITOR),EBBF_NONE,
+ BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | BROWSER_AUTOSIZE_LASTCOL |
+ BROWSER_KEEPSELECTION | BROWSER_HLINESFULL | BROWSER_VLINESFULL)
+ ,m_nDataPos(-1)
+ ,m_nCurrentPos(-1)
+ ,m_nCurUndoActId(0)
+ ,m_bCurrentModified(FALSE)
+ ,m_bUpdatable(FALSE)
+ ,m_bClipboardFilled(FALSE)
+{
+ DBG_CTOR(OTableRowView,NULL);
+
+}
+
+//------------------------------------------------------------------------
+OTableRowView::~OTableRowView()
+{
+
+ DBG_DTOR(OTableRowView,NULL);
+}
+
+//------------------------------------------------------------------------
+void OTableRowView::Init()
+{
+ EditBrowseBox::Init();
+
+// SetMapMode( MapMode(MAP_TWIP) );
+// GetDataWindow().SetMapMode( GetMapMode() );
+
+ Font aFont( GetDataWindow().GetFont() );
+ aFont.SetWeight( WEIGHT_NORMAL );
+ GetDataWindow().SetFont( aFont );
+
+ // Font fuer die Ueberschriften auf Light setzen
+ aFont = GetFont();
+ aFont.SetWeight( WEIGHT_LIGHT );
+ SetFont(aFont);
+
+ // HandleColumn, fuer maximal fuenf Ziffern einrichten
+ InsertHandleColumn(static_cast<USHORT>(GetTextWidth('0') * 4)/*, TRUE */);
+
+ BrowserMode nMode = BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | BROWSER_KEEPSELECTION |
+ BROWSER_HLINESFULL | BROWSER_VLINESFULL | BROWSER_AUTOSIZE_LASTCOL;
+ if (IsUpdatable())
+ nMode |= BROWSER_HIDECURSOR;
+
+ SetMode(nMode);
+}
+
+//------------------------------------------------------------------------
+void OTableRowView::KeyInput( const KeyEvent& rEvt )
+{
+ if (IsDeleteAllowed(0))
+ {
+ if (rEvt.GetKeyCode().GetCode() == KEY_DELETE && // Delete rows
+ !rEvt.GetKeyCode().IsShift() &&
+ !rEvt.GetKeyCode().IsMod1())
+ {
+ DeleteRows();
+ return;
+ }
+ if( rEvt.GetKeyCode().GetCode() == KEY_F2 )
+ {
+ ::com::sun::star::util::URL aUrl;
+ aUrl.Complete =::rtl::OUString::createFromAscii(".uno:DSBEditDoc");
+ GetView()->getController().dispatch( aUrl,Sequence< PropertyValue >() );
+ }
+ }
+ EditBrowseBox::KeyInput(rEvt);
+}
+
+//------------------------------------------------------------------------
+void OTableRowView::SetUpdatable( BOOL bUpdate )
+{
+ m_bUpdatable = bUpdate;
+
+}
+
+//------------------------------------------------------------------------
+void OTableRowView::Command(const CommandEvent& rEvt)
+{
+
+ switch (rEvt.GetCommand())
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ if (!rEvt.IsMouseEvent())
+ {
+ EditBrowseBox::Command(rEvt);
+ return;
+ }
+
+ USHORT nColId = GetColumnAtXPosPixel(rEvt.GetMousePosPixel().X());
+ long nRow = GetRowAtYPosPixel(rEvt.GetMousePosPixel().Y());
+
+ if ( nColId == HANDLE_ID )
+ {
+ PopupMenu aContextMenu(ModuleRes(RID_TABLEDESIGNROWPOPUPMENU));
+ long nSelectRowCount = GetSelectRowCount();
+ aContextMenu.EnableItem( SID_CUT, nSelectRowCount != 0);
+ aContextMenu.EnableItem( SID_COPY, nSelectRowCount != 0);
+ aContextMenu.EnableItem( SID_PASTE, m_bClipboardFilled );
+ aContextMenu.EnableItem( SID_DELETE, IsUpdatable() && nSelectRowCount != 0 );
+ switch (aContextMenu.Execute(this, rEvt.GetMousePosPixel()))
+ {
+ case SID_CUT:
+ cut();
+ break;
+ case SID_COPY:
+ copy();
+ break;
+ case SID_PASTE:
+ Paste( nRow );
+ SetNoSelection();
+ GoToRow( nRow );
+ SeekRow( nRow );
+ break;
+
+ case SID_DELETE:
+ DeleteRows();
+ break;
+ case SID_TABLEDESIGN_INSERTROWS:
+ InsertNewRows( nRow );
+ SetNoSelection();
+ GoToRow( nRow );
+ SeekRow( nRow );
+ break;
+ default:
+ break;
+ }
+ }
+
+ }
+ default:
+ EditBrowseBox::Command(rEvt);
+ }
+
+}
+
+//------------------------------------------------------------------------------
+void OTableRowView::cut()
+{
+ CopyRows();
+ DeleteRows();
+}
+
+//------------------------------------------------------------------------------
+void OTableRowView::copy()
+{
+ CopyRows();
+}
+
+//------------------------------------------------------------------------------
+void OTableRowView::paste()
+{
+ OSL_ENSURE(0,"OTableRowView::Paste : (pseudo-) abstract method called !");
+}
+
+//------------------------------------------------------------------------------
+void OTableRowView::Paste( long nRow )
+{
+ InsertRows( nRow );
+}
+
+//------------------------------------------------------------------------------
+EditBrowseBox::RowStatus OTableRowView::GetRowStatus(long nRow) const
+{
+ if (nRow >= 0 && m_nDataPos == nRow)
+ return CURRENT;
+ else
+ return CLEAN;
+}
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx b/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx
new file mode 100644
index 000000000000..c2326e441c95
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_TABLEDESIGNHELPBAR_HXX
+#include "TableDesignHelpBar.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _SVEDIT_HXX
+#include <svtools/svmedit.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#include <memory>
+using namespace dbaui;
+#define STANDARD_MARGIN 6
+//==================================================================
+// class OTableDesignHelpBar
+//==================================================================
+DBG_NAME(OTableDesignHelpBar)
+//------------------------------------------------------------------------------
+OTableDesignHelpBar::OTableDesignHelpBar( Window* pParent ) :
+ TabPage( pParent, WB_3DLOOK )
+{
+ DBG_CTOR(OTableDesignHelpBar,NULL);
+ m_pTextWin = new MultiLineEdit( this, WB_VSCROLL | WB_LEFT | WB_BORDER | WB_NOTABSTOP | WB_READONLY);
+ m_pTextWin->SetHelpId(HID_TABLE_DESIGN_HELP_WINDOW);
+ m_pTextWin->SetReadOnly();
+ m_pTextWin->SetControlBackground( GetSettings().GetStyleSettings().GetFaceColor() );
+ m_pTextWin->Show();
+}
+
+//------------------------------------------------------------------------------
+OTableDesignHelpBar::~OTableDesignHelpBar()
+{
+ DBG_DTOR(OTableDesignHelpBar,NULL);
+ ::std::auto_ptr<Window> aTemp(m_pTextWin);
+ m_pTextWin = NULL;
+}
+
+//------------------------------------------------------------------------------
+void OTableDesignHelpBar::SetHelpText( const String& rText )
+{
+ DBG_CHKTHIS(OTableDesignHelpBar,NULL);
+ if(m_pTextWin)
+ m_pTextWin->SetText( rText );
+ Invalidate();
+}
+
+//------------------------------------------------------------------------------
+void OTableDesignHelpBar::Resize()
+{
+ DBG_CHKTHIS(OTableDesignHelpBar,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Abmessungen parent window
+ Size aOutputSize( GetOutputSizePixel() );
+
+ //////////////////////////////////////////////////////////////////////
+ // TextWin anpassen
+ if(m_pTextWin)
+ m_pTextWin->SetPosSizePixel( Point(STANDARD_MARGIN+1, STANDARD_MARGIN+1),
+ Size(aOutputSize.Width()-(2*STANDARD_MARGIN)-2,
+ aOutputSize.Height()-(2*STANDARD_MARGIN)-2) );
+
+}
+
+//------------------------------------------------------------------------------
+long OTableDesignHelpBar::PreNotify( NotifyEvent& rNEvt )
+{
+ if (rNEvt.GetType() == EVENT_LOSEFOCUS)
+ SetHelpText(String());
+ return TabPage::PreNotify(rNEvt);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableDesignHelpBar::isCopyAllowed()
+{
+ return m_pTextWin && m_pTextWin->GetSelected().Len();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableDesignHelpBar::isCutAllowed()
+{
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableDesignHelpBar::isPasteAllowed()
+{
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+void OTableDesignHelpBar::cut()
+{
+}
+// -----------------------------------------------------------------------------
+void OTableDesignHelpBar::copy()
+{
+ if ( m_pTextWin )
+ m_pTextWin->Copy();
+}
+// -----------------------------------------------------------------------------
+void OTableDesignHelpBar::paste()
+{
+}
diff --git a/dbaccess/source/ui/tabledesign/TableDesignView.cxx b/dbaccess/source/ui/tabledesign/TableDesignView.cxx
new file mode 100644
index 000000000000..f16624dbdad2
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableDesignView.cxx
@@ -0,0 +1,400 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_TABLEDESIGNVIEW_HXX
+#include "TableDesignView.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBUI_TABLECONTROLLER_HXX
+#include "TableController.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef DBAUI_TABLEEDITORCONTROL_HXX
+#include "TEditControl.hxx"
+#endif
+#ifndef DBAUI_TABLEFIELDDESCRIPTION_HXX
+#include "TableFieldDescWin.hxx"
+#endif
+#ifndef DBAUI_TABLEROW_HXX
+#include "TableRow.hxx"
+#endif
+#ifndef _UTL_CONFIGMGR_HXX_
+#include <unotools/configmgr.hxx>
+#endif
+#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
+#ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX
+#include <unotools/syslocale.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#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;
+
+//==================================================================
+// class OTableBorderWindow
+DBG_NAME(OTableBorderWindow)
+//==================================================================
+OTableBorderWindow::OTableBorderWindow(Window* pParent) : Window(pParent,WB_BORDER)
+ ,m_aHorzSplitter( this )
+{
+ DBG_CTOR(OTableBorderWindow,NULL);
+
+ ImplInitSettings( sal_True, sal_True, sal_True );
+ //////////////////////////////////////////////////////////////////////
+ // Childs erzeugen
+ m_pEditorCtrl = new OTableEditorCtrl( this);
+ m_pFieldDescWin = new OTableFieldDescWin( this );
+
+ m_pFieldDescWin->SetHelpId(HID_TAB_DESIGN_DESCWIN);
+
+ // set depending windows and controls
+ m_pEditorCtrl->SetDescrWin(m_pFieldDescWin);
+
+ //////////////////////////////////////////////////////////////////////
+ // Splitter einrichten
+ m_aHorzSplitter.SetSplitHdl( LINK(this, OTableBorderWindow, SplitHdl) );
+ m_aHorzSplitter.Show();
+}
+// -----------------------------------------------------------------------------
+OTableBorderWindow::~OTableBorderWindow()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Childs zerstoeren
+ // ::dbaui::notifySystemWindow(this,m_pFieldDescWin,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
+ m_pEditorCtrl->Hide();
+ m_pFieldDescWin->Hide();
+
+ {
+ ::std::auto_ptr<Window> aTemp(m_pEditorCtrl);
+ m_pEditorCtrl = NULL;
+ }
+ {
+ ::std::auto_ptr<Window> aTemp(m_pFieldDescWin);
+ m_pFieldDescWin = NULL;
+ }
+
+ DBG_DTOR(OTableBorderWindow,NULL);
+}
+// -----------------------------------------------------------------------------
+void OTableBorderWindow::Resize()
+{
+ const long nSplitterHeight(3);
+
+ //////////////////////////////////////////////////////////////////////
+ // Abmessungen parent window
+ Size aOutputSize( GetOutputSize() );
+ long nOutputWidth = aOutputSize.Width();
+ long nOutputHeight = aOutputSize.Height();
+ long nSplitPos = m_aHorzSplitter.GetSplitPosPixel();
+
+ //////////////////////////////////////////////////////////////////////
+ // Verschiebebereich Splitter mittleres Drittel des Outputs
+ long nDragPosY = nOutputHeight/3;
+ long nDragSizeHeight = nOutputHeight/3;
+ m_aHorzSplitter.SetDragRectPixel( Rectangle(Point(0,nDragPosY), Size(nOutputWidth,nDragSizeHeight) ), this );
+ if( (nSplitPos < nDragPosY) || (nSplitPos > (nDragPosY+nDragSizeHeight)) )
+ nSplitPos = nDragPosY+nDragSizeHeight-5;
+
+ //////////////////////////////////////////////////////////////////////
+ // Splitter setzen
+ m_aHorzSplitter.SetPosSizePixel( Point( 0, nSplitPos ), Size(nOutputWidth, nSplitterHeight));
+ m_aHorzSplitter.SetSplitPosPixel( nSplitPos );
+
+ //////////////////////////////////////////////////////////////////////
+ // Fenster setzen
+ m_pEditorCtrl->SetPosSizePixel( Point(0, 0), Size(nOutputWidth , nSplitPos) );
+
+ m_pFieldDescWin->SetPosSizePixel( Point(0, nSplitPos+nSplitterHeight),
+ Size(nOutputWidth, nOutputHeight-nSplitPos-nSplitterHeight) );
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableBorderWindow, SplitHdl, Splitter*, pSplit )
+{
+ if(pSplit == &m_aHorzSplitter)
+ {
+ m_aHorzSplitter.SetPosPixel( Point( m_aHorzSplitter.GetPosPixel().X(),m_aHorzSplitter.GetSplitPosPixel() ) );
+ Resize();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+void OTableBorderWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ if ( bFont )
+ {
+ Font aFont = rStyleSettings.GetAppFont();
+ if ( IsControlFont() )
+ aFont.Merge( GetControlFont() );
+ SetPointFont( aFont );
+// Set/*Zoomed*/PointFont( aFont );
+ }
+
+ if ( bFont || bForeground )
+ {
+ Color aTextColor = rStyleSettings.GetButtonTextColor();
+ if ( IsControlForeground() )
+ aTextColor = GetControlForeground();
+ SetTextColor( aTextColor );
+ }
+
+ if ( bBackground )
+ {
+ if( IsControlBackground() )
+ SetBackground( GetControlBackground() );
+ else
+ SetBackground( rStyleSettings.GetFaceColor() );
+ }
+}
+// -----------------------------------------------------------------------
+void OTableBorderWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ ImplInitSettings( sal_True, sal_True, sal_True );
+ Invalidate();
+ }
+}
+// -----------------------------------------------------------------------------
+void OTableBorderWindow::GetFocus()
+{
+ Window::GetFocus();
+
+ // forward the focus to the current cell of the editor control
+ if (m_pEditorCtrl)
+ m_pEditorCtrl->GrabFocus();
+}
+
+//==================================================================
+// class OTableDesignView
+//==================================================================
+DBG_NAME(OTableDesignView);
+//------------------------------------------------------------------------------
+OTableDesignView::OTableDesignView( Window* pParent,
+ const Reference< XMultiServiceFactory >& _rxOrb,
+ OTableController& _rController
+ ) :
+ ODataView( pParent, _rController,_rxOrb )
+ ,m_rController( _rController )
+ ,m_eChildFocus(NONE)
+{
+ DBG_CTOR(OTableDesignView,NULL);
+
+ try
+ {
+ m_aLocale = SvtSysLocale().GetLocaleData().getLocale();
+ }
+ catch(Exception&)
+ {
+ }
+
+ m_pWin = new OTableBorderWindow(this);
+ m_pWin->Show();
+}
+
+//------------------------------------------------------------------------------
+OTableDesignView::~OTableDesignView()
+{
+ DBG_DTOR(OTableDesignView,NULL);
+ m_pWin->Hide();
+
+ {
+ ::std::auto_ptr<Window> aTemp(m_pWin);
+ m_pWin = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OTableDesignView::initialize()
+{
+ GetEditorCtrl()->Init();
+ GetDescWin()->Init();
+ // first call after the editctrl has been set
+
+ GetEditorCtrl()->Show();
+ GetDescWin()->Show();
+
+ GetEditorCtrl()->DisplayData(0);
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void OTableDesignView::resizeDocumentView(Rectangle& _rPlayground)
+{
+ m_pWin->SetPosSizePixel( _rPlayground.TopLeft(), _rPlayground.GetSize() );
+
+ // just for completeness: there is no space left, we occupied it all ...
+ _rPlayground.SetPos( _rPlayground.BottomRight() );
+ _rPlayground.SetSize( Size( 0, 0 ) );
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableDesignView, SwitchHdl, Accelerator*, /*pAcc*/ )
+{
+ if( getController().isReadOnly() )
+ return 0;
+
+ if( GetDescWin()->HasChildPathFocus() )
+ {
+ GetDescWin()->LoseFocus();
+ GetEditorCtrl()->GrabFocus();
+ }
+ else
+ {
+ ::boost::shared_ptr<OTableRow> pRow = (*GetEditorCtrl()->GetRowList())[GetEditorCtrl()->GetCurRow()];
+ OFieldDescription* pFieldDescr = pRow ? pRow->GetActFieldDescr() : NULL;
+ if ( pFieldDescr )
+ GetDescWin()->GrabFocus();
+ else
+ GetEditorCtrl()->GrabFocus();
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------
+long OTableDesignView::PreNotify( NotifyEvent& rNEvt )
+{
+ BOOL bHandled = FALSE;
+ switch(rNEvt.GetType())
+ {
+ case EVENT_GETFOCUS:
+ if( GetDescWin() && GetDescWin()->HasChildPathFocus() )
+ m_eChildFocus = DESCRIPTION;
+ else if ( GetEditorCtrl() && GetEditorCtrl()->HasChildPathFocus() )
+ m_eChildFocus = EDITOR;
+ else
+ m_eChildFocus = NONE;
+ break;
+ }
+
+ return bHandled ? 1L : ODataView::PreNotify(rNEvt);
+}
+// -----------------------------------------------------------------------------
+IClipboardTest* OTableDesignView::getActiveChild() const
+{
+ IClipboardTest* pTest = NULL;
+ switch(m_eChildFocus)
+ {
+ case DESCRIPTION:
+ pTest = GetDescWin();
+ break;
+ case EDITOR:
+ pTest = GetEditorCtrl();
+ break;
+ case NONE:
+ break;
+ }
+ return pTest;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableDesignView::isCopyAllowed()
+{
+ IClipboardTest* pTest = getActiveChild();
+ return pTest && pTest->isCopyAllowed();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableDesignView::isCutAllowed()
+{
+ IClipboardTest* pTest = getActiveChild();
+ return pTest && pTest->isCutAllowed();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableDesignView::isPasteAllowed()
+{
+ IClipboardTest* pTest = getActiveChild();
+ return pTest && pTest->isPasteAllowed();
+}
+// -----------------------------------------------------------------------------
+void OTableDesignView::copy()
+{
+ IClipboardTest* pTest = getActiveChild();
+ if ( pTest )
+ pTest->copy();
+}
+// -----------------------------------------------------------------------------
+void OTableDesignView::cut()
+{
+ IClipboardTest* pTest = getActiveChild();
+ if ( pTest )
+ pTest->cut();
+}
+// -----------------------------------------------------------------------------
+void OTableDesignView::paste()
+{
+ IClipboardTest* pTest = getActiveChild();
+ if ( pTest )
+ pTest->paste();
+}
+// -----------------------------------------------------------------------------
+// set the view readonly or not
+void OTableDesignView::setReadOnly(sal_Bool _bReadOnly)
+{
+ GetDescWin()->SetReadOnly(_bReadOnly);
+ GetEditorCtrl()->SetReadOnly(_bReadOnly);
+}
+// -----------------------------------------------------------------------------
+void OTableDesignView::reSync()
+{
+ GetEditorCtrl()->DeactivateCell();
+ ::boost::shared_ptr<OTableRow> pRow = (*GetEditorCtrl()->GetRowList())[GetEditorCtrl()->GetCurRow()];
+ OFieldDescription* pFieldDescr = pRow ? pRow->GetActFieldDescr() : NULL;
+ if ( pFieldDescr )
+ GetDescWin()->DisplayData(pFieldDescr);
+}
+// -----------------------------------------------------------------------------
+void OTableDesignView::GetFocus()
+{
+ if ( GetEditorCtrl() )
+ GetEditorCtrl()->GrabFocus();
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/tabledesign/TableFieldControl.cxx b/dbaccess/source/ui/tabledesign/TableFieldControl.cxx
new file mode 100644
index 000000000000..24bbb28411b1
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableFieldControl.cxx
@@ -0,0 +1,177 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_TABLEFIELDCONTROL_HXX
+#include "TableFieldControl.hxx"
+#endif
+#ifndef DBUI_TABLECONTROLLER_HXX
+#include "TableController.hxx"
+#endif
+#ifndef DBAUI_TABLEDESIGNVIEW_HXX
+#include "TableDesignView.hxx"
+#endif
+#ifndef DBAUI_TABLEEDITORCONTROL_HXX
+#include "TEditControl.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace dbaui;
+OTableFieldControl::OTableFieldControl( Window* pParent, OTableDesignHelpBar* pHelpBar) :OFieldDescControl(pParent,pHelpBar)
+{
+}
+//------------------------------------------------------------------
+void OTableFieldControl::CellModified(long nRow, sal_uInt16 nColId )
+{
+ GetCtrl()->CellModified(nRow,nColId);
+}
+//------------------------------------------------------------------
+OTableEditorCtrl* OTableFieldControl::GetCtrl() const
+{
+ OTableDesignView* pDesignWin = static_cast<OTableDesignView*>(GetParent()->GetParent()->GetParent()->GetParent());
+ OSL_ENSURE(pDesignWin,"no view!");
+ return pDesignWin->GetEditorCtrl();
+}
+//------------------------------------------------------------------
+sal_Bool OTableFieldControl::IsReadOnly()
+{
+ sal_Bool bRead(GetCtrl()->IsReadOnly());
+ if( !bRead )
+ {
+ // Die Spalten einer ::com::sun::star::sdbcx::View können nicht verändert werden
+ Reference<XPropertySet> xTable = GetCtrl()->GetView()->getController().getTable();
+ if(xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW"))
+ bRead = sal_True;
+ else
+ {
+ ::boost::shared_ptr<OTableRow> pCurRow = GetCtrl()->GetActRow();
+ if( pCurRow )
+ bRead = pCurRow->IsReadOnly();
+ }
+ }
+ return bRead;
+}
+//------------------------------------------------------------------
+void OTableFieldControl::ActivateAggregate( EControlType eType )
+{
+ switch(eType)
+ {
+ case tpColumnName:
+ case tpType:
+ break;
+ default:
+ OFieldDescControl::ActivateAggregate(eType);
+ }
+}
+//------------------------------------------------------------------
+void OTableFieldControl::DeactivateAggregate( EControlType eType )
+{
+ switch(eType)
+ {
+ case tpColumnName:
+ case tpType:
+ break;
+ default:
+ OFieldDescControl::DeactivateAggregate(eType);
+ }
+}
+// -----------------------------------------------------------------------------
+void OTableFieldControl::SetModified(BOOL bModified)
+{
+ GetCtrl()->GetView()->getController().setModified(bModified);
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> OTableFieldControl::getConnection()
+{
+ return GetCtrl()->GetView()->getController().getConnection();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> OTableFieldControl::getMetaData()
+{
+ Reference<XConnection> xCon = GetCtrl()->GetView()->getController().getConnection();
+ if(!xCon.is())
+ return NULL;
+ return xCon->getMetaData();
+}
+// -----------------------------------------------------------------------------
+Reference< XNumberFormatter > OTableFieldControl::GetFormatter() const
+{
+ return GetCtrl()->GetView()->getController().getNumberFormatter();
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OTableFieldControl::getTypeInfo(sal_Int32 _nPos)
+{
+ return GetCtrl()->GetView()->getController().getTypeInfo(_nPos);
+}
+// -----------------------------------------------------------------------------
+const OTypeInfoMap* OTableFieldControl::getTypeInfo() const
+{
+ return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().getTypeInfo();
+}
+// -----------------------------------------------------------------------------
+Locale OTableFieldControl::GetLocale() const
+{
+ return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getLocale();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableFieldControl::isAutoIncrementValueEnabled() const
+{
+ return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().isAutoIncrementValueEnabled();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTableFieldControl::getAutoIncrementValue() const
+{
+ return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().getAutoIncrementValue();
+}
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableFieldControl.hxx b/dbaccess/source/ui/tabledesign/TableFieldControl.hxx
new file mode 100644
index 000000000000..cc18065bc03d
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableFieldControl.hxx
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEFIELDCONTROL_HXX
+#define DBAUI_TABLEFIELDCONTROL_HXX
+
+#ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX
+#include "FieldDescControl.hxx"
+#endif
+
+namespace dbaui
+{
+ class OTableEditorCtrl;
+ class OTableDesignHelpBar;
+ //==================================================================
+ // OTableFieldControl
+ //==================================================================
+ class OTableFieldControl : public OFieldDescControl
+ {
+ OTableEditorCtrl* GetCtrl() const;
+ protected:
+ virtual void ActivateAggregate( EControlType eType );
+ virtual void DeactivateAggregate( EControlType eType );
+ // Sind von den abgeleiteten Klassen zu impl.
+ virtual void CellModified(long nRow, USHORT nColId );
+ virtual BOOL IsReadOnly();
+ virtual void SetModified(BOOL bModified);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > GetFormatter() const;
+
+ virtual ::com::sun::star::lang::Locale GetLocale() const;
+
+ virtual TOTypeInfoSP getTypeInfo(sal_Int32 _nPos);
+ virtual const OTypeInfoMap* getTypeInfo() const;
+ virtual sal_Bool isAutoIncrementValueEnabled() const;
+ virtual ::rtl::OUString getAutoIncrementValue() const;
+
+ public:
+ OTableFieldControl( Window* pParent, OTableDesignHelpBar* pHelpBar);
+
+ String BoolStringPersistent(const String& rUIString) const { return OFieldDescControl::BoolStringPersistent(rUIString); }
+ String BoolStringUI(const String& rPersistentString) const { return OFieldDescControl::BoolStringUI(rPersistentString); }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection();
+ };
+}
+#endif // DBAUI_TABLEFIELDCONTROL_HXX
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx
new file mode 100644
index 000000000000..6f136ab0b4e8
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx
@@ -0,0 +1,337 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBAUI_TABLEFIELDDESCRIPTION_HXX
+#include "TableFieldDescWin.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef _DBU_TBL_HRC_
+#include "dbu_tbl.hrc"
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef DBAUI_TABLEDESIGNHELPBAR_HXX
+#include "TableDesignHelpBar.hxx"
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#include <memory>
+
+#define STANDARD_MARGIN 6
+#define DETAILS_HEADER_HEIGHT 25
+#define CONTROL_SPACING_X 18 // 6
+#define CONTROL_SPACING_Y 5
+#define CONTROL_HEIGHT 20
+#define CONTROL_WIDTH_1 140 // 100
+#define CONTROL_WIDTH_2 100 // 60
+#define CONTROL_WIDTH_3 250
+#define CONTROL_WIDTH_4 (CONTROL_WIDTH_3 - CONTROL_HEIGHT - 5)
+#define DETAILS_OPT_PAGE_WIDTH (CONTROL_WIDTH_1 + CONTROL_SPACING_X + CONTROL_WIDTH_4 + 50)
+#define DETAILS_OPT_PAGE_HEIGHT ((CONTROL_HEIGHT + CONTROL_SPACING_Y) * 5)
+#define DETAILS_MIN_HELP_WIDTH 100
+#define DETAILS_OPT_HELP_WIDTH 200
+#define DETAILS_MIN_HELP_HEIGHT 50
+#define DETAILS_OPT_HELP_HEIGHT 100
+
+
+using namespace dbaui;
+//==================================================================
+// class OTableFieldDescWin
+//==================================================================
+DBG_NAME(OTableFieldDescWin)
+//------------------------------------------------------------------------------
+OTableFieldDescWin::OTableFieldDescWin( Window* pParent)
+ :TabPage(pParent, WB_3DLOOK)
+{
+ DBG_CTOR(OTableFieldDescWin,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Header
+ m_pHeader = new FixedText( this, WB_CENTER | WB_INFO ); // | WB_3DLOOK
+ m_pHeader->SetText( String(ModuleRes(STR_TAB_PROPERTIES)) );
+ m_pHeader->Show();
+
+ //////////////////////////////////////////////////////////////////////
+ // HelpBar
+ m_pHelpBar = new OTableDesignHelpBar( this );
+ m_pHelpBar->SetHelpId(HID_TAB_DESIGN_HELP_TEXT_FRAME);
+ m_pHelpBar->Show();
+
+ m_pGenPage = new OFieldDescGenWin( this, m_pHelpBar );
+ getGenPage()->SetHelpId( HID_TABLE_DESIGN_TABPAGE_GENERAL );
+ getGenPage()->Show();
+}
+
+//------------------------------------------------------------------------------
+OTableFieldDescWin::~OTableFieldDescWin()
+{
+ DBG_DTOR(OTableFieldDescWin,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Childs zerstoeren
+ m_pHelpBar->Hide();
+ getGenPage()->Hide();
+ m_pHeader->Hide();
+
+ {
+ ::std::auto_ptr<Window> aTemp(m_pGenPage);
+ m_pGenPage = NULL;
+ }
+ {
+ ::std::auto_ptr<Window> aTemp(m_pHeader);
+ m_pHeader = NULL;
+ }
+ {
+ ::std::auto_ptr<Window> aTemp(m_pHelpBar);
+ m_pHelpBar = NULL;
+ }
+}
+
+//------------------------------------------------------------------------------
+void OTableFieldDescWin::Init()
+{
+ DBG_ASSERT(getGenPage() != NULL, "OTableFieldDescWin::Init : ups ... no GenericPage ... this will crash ...");
+ getGenPage()->Init();
+}
+
+//------------------------------------------------------------------------------
+void OTableFieldDescWin::SetReadOnly( sal_Bool bRead )
+{
+ DBG_CHKTHIS(OTableFieldDescWin,NULL);
+ getGenPage()->SetReadOnly( bRead );
+}
+
+//------------------------------------------------------------------------------
+void OTableFieldDescWin::DisplayData( OFieldDescription* pFieldDescr )
+{
+ DBG_CHKTHIS(OTableFieldDescWin,NULL);
+ getGenPage()->DisplayData( pFieldDescr );
+}
+
+//------------------------------------------------------------------------------
+void OTableFieldDescWin::SaveData( OFieldDescription* pFieldDescr )
+{
+ DBG_CHKTHIS(OTableFieldDescWin,NULL);
+ getGenPage()->SaveData( pFieldDescr );
+}
+
+//------------------------------------------------------------------------------
+void OTableFieldDescWin::Paint( const Rectangle& /*rRect*/ )
+{
+ DBG_CHKTHIS(OTableFieldDescWin,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // 3D-Linie am oberen Fensterrand
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ SetLineColor( rStyleSettings.GetLightColor() );
+ DrawLine( Point(0,0), Point(GetSizePixel().Width(),0) );
+
+ //////////////////////////////////////////////////////////////////////
+ // 3D-Linie zum Abtrennen des Headers
+ DrawLine( Point(3, DETAILS_HEADER_HEIGHT), Point(GetSizePixel().Width()-6, DETAILS_HEADER_HEIGHT) );
+ SetLineColor( rStyleSettings.GetShadowColor() );
+ DrawLine( Point(3, DETAILS_HEADER_HEIGHT-1), Point(GetSizePixel().Width()-6, DETAILS_HEADER_HEIGHT-1) );
+}
+
+//------------------------------------------------------------------------------
+void OTableFieldDescWin::Resize()
+{
+ DBG_CHKTHIS(OTableFieldDescWin,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Abmessungen parent window
+ Size aOutputSize( GetOutputSizePixel() );
+ long nOutputWidth = aOutputSize.Width();
+ long nOutputHeight = aOutputSize.Height();
+
+ // da die GenPage scrollen kann, ich selber aber nicht, positioniere ich das HelpFenster, wenn ich zu schmal werde,
+ // _unter_ der Genpage, nicht rechts daneben. Zuvor versuche ich aber noch, es etwas schmaler zu machen
+
+ long nHelpX, nHelpY;
+ long nHelpWidth, nHelpHeight;
+ long nPageWidth, nPageHeight;
+
+ // passen beide nebeneinander (Rand + Page + Rand + Help) ?
+ if (STANDARD_MARGIN + DETAILS_OPT_PAGE_WIDTH + STANDARD_MARGIN + DETAILS_MIN_HELP_WIDTH <= nOutputWidth)
+ { // ja -> dann ist die Frage, ob man der Hilfe ihre Optimal-Breite geben kann
+ nHelpWidth = DETAILS_OPT_HELP_WIDTH;
+ nPageWidth = nOutputWidth - nHelpWidth - STANDARD_MARGIN - STANDARD_MARGIN;
+ if (nPageWidth < DETAILS_OPT_PAGE_WIDTH)
+ { // dann doch lieber die Hilfe von ihrer optimalen in Richtung auf die minimale Groesse
+ long nTransfer = DETAILS_OPT_PAGE_WIDTH - nPageWidth;
+ nPageWidth += nTransfer;
+ nHelpWidth -= nTransfer;
+ }
+ nHelpX = nOutputWidth - nHelpWidth;
+ // die Hoehen sind dann einfach ...
+ nHelpY = DETAILS_HEADER_HEIGHT + 1;
+ nHelpHeight = nOutputHeight - nHelpY;
+ nPageHeight = nOutputHeight - STANDARD_MARGIN - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN;
+ }
+ else
+ { // nebeneinander geht nicht, also untereinander (Rand + Header + Page + Help)
+ if (STANDARD_MARGIN + DETAILS_HEADER_HEIGHT + DETAILS_OPT_PAGE_HEIGHT + DETAILS_MIN_HELP_HEIGHT <= nOutputHeight)
+ { // es reicht zumindest, um beide untereinander (Page optimal, Help minimal) unterzubringen
+ nHelpHeight = DETAILS_OPT_HELP_HEIGHT;
+ nPageHeight = nOutputHeight - nHelpHeight - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN;
+ if (nPageHeight < DETAILS_OPT_PAGE_HEIGHT)
+ { // wie oben : Page optimal, Hilfe soviel wie eben bleibt (das ist groesser/gleich ihrem Minimum)
+ long nTransfer = DETAILS_OPT_PAGE_HEIGHT - nPageHeight;
+ nPageHeight += nTransfer;
+ nHelpHeight -= nTransfer;
+ }
+ nHelpY = nOutputHeight - nHelpHeight;
+ // und ueber die ganze Breite
+ nHelpX = 0; // ohne Margin, da das HelpCtrl einen eigenen hat
+ nHelpWidth = nOutputWidth; // dito
+ nPageWidth = nOutputWidth - STANDARD_MARGIN - STANDARD_MARGIN;
+ }
+ else
+ { // dummerweise reicht es nicht mal, um Page optimal und Help minimal zu zeigen
+ nHelpX = nHelpY = nHelpWidth = nHelpHeight = 0; // -> kein Help-Fenster
+ nPageWidth = nOutputWidth - STANDARD_MARGIN - STANDARD_MARGIN;
+ nPageHeight = nOutputHeight - STANDARD_MARGIN - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN;
+ }
+ }
+
+ m_pHeader->SetPosSizePixel( Point(0, STANDARD_MARGIN), Size(nOutputWidth, 15) );
+
+ getGenPage()->SetPosSizePixel(Point ( STANDARD_MARGIN,
+ STANDARD_MARGIN + DETAILS_HEADER_HEIGHT
+ ),
+ Size ( nPageWidth,
+ nPageHeight
+ )
+ );
+ if (nHelpHeight)
+ {
+ m_pHelpBar->Show();
+ m_pHelpBar->SetPosSizePixel(Point ( nHelpX,
+ nHelpY
+ ),
+ Size ( nHelpWidth,
+ nHelpHeight
+ )
+ );
+ }
+ else
+ {
+ m_pHelpBar->Hide();
+ }
+ Invalidate();
+}
+// -----------------------------------------------------------------------------
+IClipboardTest* OTableFieldDescWin::getActiveChild() const
+{
+ IClipboardTest* pTest = NULL;
+ switch(m_eChildFocus)
+ {
+ case DESCRIPTION:
+ pTest = getGenPage();
+ break;
+ default:
+ pTest = getHelpBar();
+ break;
+ }
+ return pTest;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableFieldDescWin::isCopyAllowed()
+{
+ return getActiveChild() && getActiveChild()->isCopyAllowed();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableFieldDescWin::isCutAllowed()
+{
+ return (getGenPage() && getGenPage()->HasChildPathFocus() && getGenPage()->isCutAllowed());
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableFieldDescWin::isPasteAllowed()
+{
+ return (getGenPage() && getGenPage()->HasChildPathFocus() && getGenPage()->isPasteAllowed());
+}
+// -----------------------------------------------------------------------------
+void OTableFieldDescWin::cut()
+{
+ if ( getGenPage() && getGenPage()->HasChildPathFocus() )
+ getGenPage()->cut();
+}
+// -----------------------------------------------------------------------------
+void OTableFieldDescWin::copy()
+{
+ if ( getActiveChild() )
+ getActiveChild()->copy();
+}
+// -----------------------------------------------------------------------------
+void OTableFieldDescWin::paste()
+{
+ if ( getGenPage() && getGenPage()->HasChildPathFocus() )
+ getGenPage()->paste();
+}
+// -----------------------------------------------------------------------------
+void OTableFieldDescWin::GetFocus()
+{
+ if ( getGenPage() )
+ getGenPage()->GetFocus();
+}
+// -----------------------------------------------------------------------------
+void OTableFieldDescWin::LoseFocus()
+{
+ if ( getGenPage() )
+ getGenPage()->LoseFocus();
+}
+// -----------------------------------------------------------------------------
+long OTableFieldDescWin::PreNotify( NotifyEvent& rNEvt )
+{
+ BOOL bHandled = FALSE;
+ switch(rNEvt.GetType())
+ {
+ case EVENT_GETFOCUS:
+ if( getGenPage() && getGenPage()->HasChildPathFocus() )
+ m_eChildFocus = DESCRIPTION;
+ else
+ m_eChildFocus = HELP;
+ break;
+ }
+
+ return bHandled ? 1L : TabPage::PreNotify(rNEvt);
+}
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx
new file mode 100644
index 000000000000..b2d5f09c99c4
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEFIELDDESCRIPTION_HXX
+#define DBAUI_TABLEFIELDDESCRIPTION_HXX
+
+#ifndef _SV_TABPAGE_HXX
+#include <vcl/tabpage.hxx>
+#endif
+#ifndef DBAUI_TABLEFIELDDESCGENPAGE_HXX
+#include "FieldDescGenWin.hxx"
+#endif
+#ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+#include "IClipBoardTest.hxx"
+#endif
+
+class FixedText;
+namespace dbaui
+{
+ class OFieldDescGenWin;
+ class OTableDesignHelpBar;
+ class OFieldDescription;
+ //==================================================================
+ // Ableitung von TabPage ist ein Trick von TH,
+ // um Aenderungen der Systemfarben zu bemerken (Bug #53905)
+ class OTableFieldDescWin : public TabPage
+ ,public IClipboardTest
+ {
+ enum ChildFocusState
+ {
+ DESCRIPTION,
+ HELP,
+ NONE
+ };
+ private:
+ OTableDesignHelpBar* m_pHelpBar;
+ OFieldDescGenWin* m_pGenPage;
+ FixedText* m_pHeader;
+ ChildFocusState m_eChildFocus;
+
+ IClipboardTest* getActiveChild() const;
+
+ protected:
+ virtual void Resize();
+ virtual void Paint( const Rectangle& rRect );
+
+ public:
+ OTableFieldDescWin( Window* pParent);
+ virtual ~OTableFieldDescWin();
+
+ virtual void Init();
+
+ void DisplayData( OFieldDescription* pFieldDescr );
+ void SaveData( OFieldDescription* pFieldDescr );
+ void SetReadOnly( BOOL bReadOnly );
+
+ // window overloads
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+ void SetControlText( USHORT nControlId, const String& rText )
+ { m_pGenPage->SetControlText(nControlId,rText); }
+ String GetControlText( USHORT nControlId )
+ { return m_pGenPage->GetControlText(nControlId); }
+
+ // short GetFormatCategory(OFieldDescription* pFieldDescr) { return m_pGenPage ? m_pGenPage->GetFormatCategory(pFieldDescr) : -1; }
+ // liefert zum am Feld eingestellten Format einen der CAT_xxx-Werte (CAT_NUMBER, CAT_DATE ...)
+
+ String BoolStringPersistent(const String& rUIString) const { return m_pGenPage->BoolStringPersistent(rUIString); }
+ String BoolStringUI(const String& rPersistentString) const { return m_pGenPage->BoolStringUI(rPersistentString); }
+
+ // IClipboardTest
+ virtual sal_Bool isCutAllowed();
+ virtual sal_Bool isCopyAllowed();
+ virtual sal_Bool isPasteAllowed();
+ virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
+
+ virtual void copy();
+ virtual void cut();
+ virtual void paste();
+
+ inline OFieldDescGenWin* getGenPage() const { return m_pGenPage; }
+ inline OTableDesignHelpBar* getHelpBar() const { return m_pHelpBar; }
+
+ };
+}
+#endif // DBAUI_TABLEFIELDDESCRIPTION_HXX
+
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableRow.cxx b/dbaccess/source/ui/tabledesign/TableRow.cxx
new file mode 100644
index 000000000000..7130c081f209
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableRow.cxx
@@ -0,0 +1,232 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_TABLEROW_HXX
+#include "TableRow.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#include <algorithm>
+#include <comphelper/types.hxx>
+
+using namespace dbaui;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+
+//========================================================================
+// class OTableRow
+//========================================================================
+DBG_NAME(OTableRow)
+//------------------------------------------------------------------------------
+OTableRow::OTableRow()
+ :m_pActFieldDescr( NULL )
+ ,m_nPos( -1 )
+ ,m_bReadOnly( false )
+ ,m_bOwnsDescriptions(false)
+{
+ DBG_CTOR(OTableRow,NULL);
+}
+//------------------------------------------------------------------------------
+OTableRow::OTableRow(const Reference< XPropertySet >& xAffectedCol)
+ :m_pActFieldDescr( NULL )
+ ,m_nPos( -1 )
+ ,m_bReadOnly( false )
+ ,m_bOwnsDescriptions(true)
+{
+ DBG_CTOR(OTableRow,NULL);
+ m_pActFieldDescr = new OFieldDescription(xAffectedCol);
+}
+//------------------------------------------------------------------------------
+OTableRow::OTableRow( const OTableRow& rRow, long nPosition )
+ :m_pActFieldDescr(NULL)
+ ,m_nPos( nPosition )
+ ,m_bReadOnly(rRow.IsReadOnly())
+ ,m_bOwnsDescriptions(false)
+{
+ DBG_CTOR(OTableRow,NULL);
+
+ OFieldDescription* pSrcField = rRow.GetActFieldDescr();
+ if(pSrcField)
+ {
+ m_pActFieldDescr = new OFieldDescription(*pSrcField);
+ m_bOwnsDescriptions = true;
+ }
+}
+
+//------------------------------------------------------------------------------
+OTableRow::~OTableRow()
+{
+ DBG_DTOR(OTableRow,NULL);
+ if(m_bOwnsDescriptions)
+ delete m_pActFieldDescr;
+}
+
+//------------------------------------------------------------------------------
+void OTableRow::SetPrimaryKey( sal_Bool bSet )
+{
+ DBG_CHKTHIS(OTableRow,NULL);
+ if(m_pActFieldDescr)
+ m_pActFieldDescr->SetPrimaryKey(bSet);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableRow::IsPrimaryKey() const
+{
+ DBG_CHKTHIS(OTableRow,NULL);
+ return m_pActFieldDescr && m_pActFieldDescr->IsPrimaryKey();
+}
+// -----------------------------------------------------------------------------
+void OTableRow::SetFieldType( const TOTypeInfoSP& _pType, sal_Bool _bForce )
+{
+ DBG_CHKTHIS(OTableRow,NULL);
+ if ( _pType.get() )
+ {
+ if( !m_pActFieldDescr )
+ {
+ m_pActFieldDescr = new OFieldDescription();
+ m_bOwnsDescriptions = true;
+ }
+ m_pActFieldDescr->FillFromTypeInfo(_pType,_bForce,sal_True);
+ }
+ else
+ {
+ delete m_pActFieldDescr;
+ m_pActFieldDescr = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+namespace dbaui
+{
+ // -----------------------------------------------------------------------------
+ SvStream& operator<<( SvStream& _rStr, const OTableRow& _rRow )
+ {
+ _rStr << _rRow.m_nPos;
+ OFieldDescription* pFieldDesc = _rRow.GetActFieldDescr();
+ if(pFieldDesc)
+ {
+ _rStr << (sal_Int32)1;
+ _rStr.WriteByteString(pFieldDesc->GetName());
+ _rStr.WriteByteString(pFieldDesc->GetDescription());
+ double nValue = 0.0;
+ Any aValue = pFieldDesc->GetControlDefault();
+ if ( aValue >>= nValue )
+ {
+ _rStr << sal_Int32(1);
+ _rStr << nValue;
+ }
+ else
+ {
+ _rStr << sal_Int32(2);
+ _rStr.WriteByteString(::comphelper::getString(aValue));
+ }
+
+ _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);
+ } // if(pFieldDesc)
+ else
+ _rStr << (sal_Int32)0;
+ return _rStr;
+ }
+ // -----------------------------------------------------------------------------
+ SvStream& operator>>( SvStream& _rStr, OTableRow& _rRow )
+ {
+ _rStr >> _rRow.m_nPos;
+ sal_Int32 nValue = 0;
+ _rStr >> nValue;
+ if ( nValue )
+ {
+ OFieldDescription* pFieldDesc = new OFieldDescription();
+ _rRow.m_pActFieldDescr = pFieldDesc;
+ String sValue;
+ _rStr.ReadByteString(sValue);
+ pFieldDesc->SetName(sValue);
+
+ _rStr.ReadByteString(sValue);
+ pFieldDesc->SetDescription(sValue);
+
+ _rStr >> nValue;
+ Any aControlDefault;
+ switch ( nValue )
+ {
+ case 1:
+ {
+ double nControlDefault;
+ _rStr >> nControlDefault;
+ aControlDefault <<= nControlDefault;
+ break;
+ }
+ case 2:
+ _rStr.ReadByteString(sValue);
+ aControlDefault <<= ::rtl::OUString(sValue);
+ break;
+ }
+
+ pFieldDesc->SetControlDefault(aControlDefault);
+
+
+ _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/TableRowExchange.cxx b/dbaccess/source/ui/tabledesign/TableRowExchange.cxx
new file mode 100644
index 000000000000..d9a462431bdc
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableRowExchange.cxx
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_TABLEROW_EXCHANGE_HXX
+#include "TableRowExchange.hxx"
+#endif
+#ifndef _SOT_FORMATS_HXX
+#include <sot/formats.hxx>
+#endif
+#ifndef _SOT_STORAGE_HXX
+#include <sot/storage.hxx>
+#endif
+#ifndef DBAUI_TABLEROW_HXX
+#include "TableRow.hxx"
+#endif
+
+namespace dbaui
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ OTableRowExchange::OTableRowExchange(const ::std::vector< ::boost::shared_ptr<OTableRow> >& _rvTableRow)
+ : m_vTableRow(_rvTableRow)
+ {
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool OTableRowExchange::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& /*rFlavor*/ )
+ {
+ if(nUserObjectId == SOT_FORMATSTR_ID_SBA_TABED)
+ {
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pRows = reinterpret_cast< ::std::vector< ::boost::shared_ptr<OTableRow> >* >(pUserObject);
+ if(pRows)
+ {
+ (*rxOStm) << (sal_Int32)pRows->size(); // first stream the size
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = pRows->begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = pRows->end();
+ for(;aIter != aEnd;++aIter)
+ (*rxOStm) << *(*aIter);
+ return sal_True;
+ }
+ }
+ return sal_False;
+ }
+ // -----------------------------------------------------------------------------
+ void OTableRowExchange::AddSupportedFormats()
+ {
+ if ( !m_vTableRow.empty() )
+ AddFormat(SOT_FORMATSTR_ID_SBA_TABED);
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool OTableRowExchange::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
+ {
+ ULONG nFormat = SotExchange::GetFormat(rFlavor);
+ if(nFormat == SOT_FORMATSTR_ID_SBA_TABED)
+ return SetObject(&m_vTableRow,SOT_FORMATSTR_ID_SBA_TABED,rFlavor);
+ return sal_False;
+ }
+ // -----------------------------------------------------------------------------
+ void OTableRowExchange::ObjectReleased()
+ {
+ m_vTableRow.clear();
+ }
+ // -----------------------------------------------------------------------------
+}
+
+
+
+
+
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableUndo.cxx b/dbaccess/source/ui/tabledesign/TableUndo.cxx
new file mode 100644
index 000000000000..39d7902a1b9d
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableUndo.cxx
@@ -0,0 +1,495 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_TABLEUNDO_HXX
+#include "TableUndo.hxx"
+#endif
+#ifndef _DBU_TBL_HRC_
+#include "dbu_tbl.hrc"
+#endif
+#ifndef DBAUI_TABLEEDITORCONTROL_HXX
+#include "TEditControl.hxx"
+#endif
+#ifndef DBAUI_TABLEROW_HXX
+#include "TableRow.hxx"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef DBUI_TABLECONTROLLER_HXX
+#include "TableController.hxx"
+#endif
+#ifndef DBAUI_TABLEDESIGNVIEW_HXX
+#include "TableDesignView.hxx"
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+using namespace dbaui;
+using namespace ::svt;
+
+TYPEINIT1( OCommentUndoAction, SfxUndoAction );
+TYPEINIT1( OTableDesignUndoAct, OCommentUndoAction );
+TYPEINIT1( OTableEditorUndoAct, OTableDesignUndoAct );
+TYPEINIT1( OTableDesignCellUndoAct, OTableDesignUndoAct );
+TYPEINIT1( OTableEditorTypeSelUndoAct, OTableEditorUndoAct );
+TYPEINIT1( OTableEditorDelUndoAct, OTableEditorUndoAct );
+TYPEINIT1( OTableEditorInsUndoAct, OTableEditorUndoAct );
+TYPEINIT1( OTableEditorInsNewUndoAct, OTableEditorUndoAct );
+TYPEINIT1( OPrimKeyUndoAct, OTableEditorUndoAct );
+
+//==============================================================================
+// class OTableDesignUndoAct
+//==============================================================================
+DBG_NAME(OTableDesignUndoAct);
+OTableDesignUndoAct::OTableDesignUndoAct( OTableRowView* pOwner,USHORT nCommentID ) : OCommentUndoAction(nCommentID)
+ ,m_pTabDgnCtrl( pOwner )
+{
+ DBG_CTOR(OTableDesignUndoAct,NULL);
+ m_pTabDgnCtrl->m_nCurUndoActId++;
+}
+
+//-------------------------------------------------------------------------
+OTableDesignUndoAct::~OTableDesignUndoAct()
+{
+ DBG_DTOR(OTableDesignUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+void OTableDesignUndoAct::Undo()
+{
+ m_pTabDgnCtrl->m_nCurUndoActId--;
+
+ //////////////////////////////////////////////////////////////////////
+ // Wenn erstes Undo zurueckgenommen wurde, ist Doc nicht modifiziert worden
+ if( m_pTabDgnCtrl->m_nCurUndoActId == 0 )
+ {
+ m_pTabDgnCtrl->GetView()->getController().setModified(sal_False);
+ m_pTabDgnCtrl->GetView()->getController().InvalidateFeature(SID_SAVEDOC);
+ }
+}
+
+//-------------------------------------------------------------------------
+void OTableDesignUndoAct::Redo()
+{
+ m_pTabDgnCtrl->m_nCurUndoActId++;
+
+ //////////////////////////////////////////////////////////////////////
+ // Wenn Redo fuer erste Undo-Action, muss Modified-Flag wieder gesetzt werden
+ if( m_pTabDgnCtrl->m_nCurUndoActId > 0 )
+ {
+ m_pTabDgnCtrl->GetView()->getController().setModified(sal_True);
+ m_pTabDgnCtrl->GetView()->getController().InvalidateFeature(SID_SAVEDOC);
+ }
+}
+//==============================================================================
+// class OTableDesignCellUndoAct
+//==============================================================================
+DBG_NAME(OTableDesignCellUndoAct);
+OTableDesignCellUndoAct::OTableDesignCellUndoAct( OTableRowView* pOwner, long nRowID, USHORT nColumn ) :
+ OTableDesignUndoAct( pOwner ,STR_TABED_UNDO_CELLMODIFIED)
+ ,m_nCol( nColumn )
+ ,m_nRow( nRowID )
+{
+ DBG_CTOR(OTableDesignCellUndoAct,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Text an der Position (m_nRow, m_nCol) auslesen
+ m_sOldText = m_pTabDgnCtrl->GetCellData( m_nRow, m_nCol );
+}
+
+//-------------------------------------------------------------------------
+OTableDesignCellUndoAct::~OTableDesignCellUndoAct()
+{
+ DBG_DTOR(OTableDesignCellUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+void OTableDesignCellUndoAct::Undo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Neuen Text der alten Zelle speichern und alten wieder einsetzen
+ m_pTabDgnCtrl->ActivateCell( m_nRow, m_nCol );
+ m_sNewText = m_pTabDgnCtrl->GetCellData( m_nRow, m_nCol );
+ m_pTabDgnCtrl->SetCellData( m_nRow, m_nCol, m_sOldText );
+ //////////////////////////////////////////////////////////////////////
+ // Wenn erstes Undo zurueckgenommen wurde, ist Zelle nicht mehr modifiziert
+ if (m_pTabDgnCtrl->GetCurUndoActId() == 1)
+ {
+ CellControllerRef xController = m_pTabDgnCtrl->Controller();
+ if ( xController.Is() )
+ xController->ClearModified();
+ m_pTabDgnCtrl->GetView()->getController().setModified(sal_False);
+
+ }
+
+ OTableDesignUndoAct::Undo();
+}
+
+//-------------------------------------------------------------------------
+void OTableDesignCellUndoAct::Redo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Neuen Text wieder einseten
+ m_pTabDgnCtrl->ActivateCell( m_nRow, m_nCol );
+ m_pTabDgnCtrl->SetCellData( m_nRow, m_nCol, m_sNewText );
+
+ OTableDesignUndoAct::Redo();
+}
+
+//==============================================================================
+// class OTableEditorUndoAct
+//==============================================================================
+DBG_NAME(OTableEditorUndoAct);
+OTableEditorUndoAct::OTableEditorUndoAct( OTableEditorCtrl* pOwner,USHORT _nCommentID ) :
+ OTableDesignUndoAct( pOwner ,_nCommentID)
+ ,pTabEdCtrl(pOwner)
+{
+ DBG_CTOR(OTableEditorUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+OTableEditorUndoAct::~OTableEditorUndoAct()
+{
+ DBG_DTOR(OTableEditorUndoAct,NULL);
+}
+
+//==============================================================================
+// class OTableEditorTypeSelUndoAct
+//==============================================================================
+DBG_NAME(OTableEditorTypeSelUndoAct);
+OTableEditorTypeSelUndoAct::OTableEditorTypeSelUndoAct( OTableEditorCtrl* pOwner, long nRowID, USHORT nColumn, const TOTypeInfoSP& _pOldType )
+ :OTableEditorUndoAct( pOwner ,STR_TABED_UNDO_TYPE_CHANGED)
+ ,m_nCol( nColumn )
+ ,m_nRow( nRowID )
+ ,m_pOldType( _pOldType )
+{
+ DBG_CTOR(OTableEditorTypeSelUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+OTableEditorTypeSelUndoAct::~OTableEditorTypeSelUndoAct()
+{
+ DBG_DTOR(OTableEditorTypeSelUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorTypeSelUndoAct::Undo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Typ zuruecksetzen
+ OFieldDescription* pFieldDesc = pTabEdCtrl->GetFieldDescr(m_nRow);
+ if(pFieldDesc)
+ m_pNewType = pFieldDesc->getTypeInfo();
+ else
+ m_pNewType = TOTypeInfoSP();
+ pTabEdCtrl->SetCellData(m_nRow,m_nCol,m_pOldType);
+ pTabEdCtrl->SwitchType( m_pOldType );
+
+ OTableEditorUndoAct::Undo();
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorTypeSelUndoAct::Redo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Neuen Typ
+ pTabEdCtrl->GoToRowColumnId( m_nRow ,m_nCol);
+ pTabEdCtrl->SetCellData(m_nRow,m_nCol,m_pNewType);
+
+ OTableEditorUndoAct::Redo();
+}
+
+//==============================================================================
+// class OTableEditorDelUndoAct
+//==============================================================================
+DBG_NAME(OTableEditorDelUndoAct);
+OTableEditorDelUndoAct::OTableEditorDelUndoAct( OTableEditorCtrl* pOwner) :
+ OTableEditorUndoAct( pOwner ,STR_TABED_UNDO_ROWDELETED)
+{
+ DBG_CTOR(OTableEditorDelUndoAct,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // DeletedRowList fuellen
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pOwner->GetRowList();
+ long nIndex = pOwner->FirstSelectedRow();
+ ::boost::shared_ptr<OTableRow> pOriginalRow;
+ ::boost::shared_ptr<OTableRow> pNewRow;
+
+ while( nIndex >= 0 )
+ {
+ pOriginalRow = (*pOriginalRows)[nIndex];
+ pNewRow.reset(new OTableRow( *pOriginalRow, nIndex ));
+ m_aDeletedRows.push_back( pNewRow);
+
+ nIndex = pOwner->NextSelectedRow();
+ }
+}
+
+//-------------------------------------------------------------------------
+OTableEditorDelUndoAct::~OTableEditorDelUndoAct()
+{
+ DBG_DTOR(OTableEditorDelUndoAct,NULL);
+ m_aDeletedRows.clear();
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorDelUndoAct::Undo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Geloeschte Zeilen wieder einfuegen
+ ULONG nPos;
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_aDeletedRows.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_aDeletedRows.end();
+
+ ::boost::shared_ptr<OTableRow> pNewOrigRow;
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pTabEdCtrl->GetRowList();
+
+ for(;aIter != aEnd;++aIter)
+ {
+ pNewOrigRow.reset(new OTableRow( **aIter ));
+ nPos = (*aIter)->GetPos();
+ pOriginalRows->insert( pOriginalRows->begin()+nPos,pNewOrigRow);
+ }
+
+ pTabEdCtrl->DisplayData(pTabEdCtrl->GetCurRow());
+ pTabEdCtrl->Invalidate();
+ OTableEditorUndoAct::Undo();
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorDelUndoAct::Redo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Zeilen wieder loeschen
+ ULONG nPos;
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_aDeletedRows.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_aDeletedRows.end();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pTabEdCtrl->GetRowList();
+
+ for(;aIter != aEnd;++aIter)
+ {
+ nPos = (*aIter)->GetPos();
+ pOriginalRows->erase( pOriginalRows->begin()+nPos );
+ }
+
+ pTabEdCtrl->DisplayData(pTabEdCtrl->GetCurRow());
+ pTabEdCtrl->Invalidate();
+ OTableEditorUndoAct::Redo();
+}
+
+//-------------------------------------------------------------------------
+//==============================================================================
+// class OTableEditorInsUndoAct
+//==============================================================================
+DBG_NAME(OTableEditorInsUndoAct);
+OTableEditorInsUndoAct::OTableEditorInsUndoAct( OTableEditorCtrl* pOwner,
+ long nInsertPosition ,
+ const ::std::vector< ::boost::shared_ptr<OTableRow> >& _vInsertedRows)
+ :OTableEditorUndoAct( pOwner,STR_TABED_UNDO_ROWINSERTED )
+ ,m_vInsertedRows(_vInsertedRows)
+ ,m_nInsPos( nInsertPosition )
+{
+ DBG_CTOR(OTableEditorInsUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+OTableEditorInsUndoAct::~OTableEditorInsUndoAct()
+{
+ DBG_DTOR(OTableEditorInsUndoAct,NULL);
+ m_vInsertedRows.clear();
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorInsUndoAct::Undo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Eingefuegte Zeilen wieder loeschen
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pTabEdCtrl->GetRowList();
+ for( long i=(m_nInsPos+m_vInsertedRows.size()-1); i>(m_nInsPos-1); i-- )
+ {
+ pOriginalRows->erase(pOriginalRows->begin()+i);
+ }
+
+ pTabEdCtrl->RowRemoved( m_nInsPos, m_vInsertedRows.size(), TRUE );
+ pTabEdCtrl->InvalidateHandleColumn();
+
+ OTableEditorUndoAct::Undo();
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorInsUndoAct::Redo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Zeilen wieder einfuegen
+ long nInsertRow = m_nInsPos;
+ ::boost::shared_ptr<OTableRow> pRow;
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_vInsertedRows.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_vInsertedRows.end();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pRowList = pTabEdCtrl->GetRowList();
+ for(;aIter != aEnd;++aIter)
+ {
+ pRow.reset(new OTableRow( **aIter ));
+ pRowList->insert( pRowList->begin()+nInsertRow ,pRow );
+ nInsertRow++;
+ }
+
+ pTabEdCtrl->RowInserted( m_nInsPos, m_vInsertedRows.size(), TRUE );
+ pTabEdCtrl->InvalidateHandleColumn();
+
+ OTableEditorUndoAct::Redo();
+}
+
+//==============================================================================
+// class OTableEditorInsNewUndoAct
+//==============================================================================
+DBG_NAME(OTableEditorInsNewUndoAct);
+OTableEditorInsNewUndoAct::OTableEditorInsNewUndoAct( OTableEditorCtrl* pOwner, long nInsertPosition, long nInsertedRows ) :
+ OTableEditorUndoAct( pOwner ,STR_TABED_UNDO_NEWROWINSERTED)
+ ,m_nInsPos( nInsertPosition )
+ ,m_nInsRows( nInsertedRows )
+{
+ DBG_CTOR(OTableEditorInsNewUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+OTableEditorInsNewUndoAct::~OTableEditorInsNewUndoAct()
+{
+ DBG_DTOR(OTableEditorInsNewUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorInsNewUndoAct::Undo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Eingefuegte Zeilen wieder loeschen
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pTabEdCtrl->GetRowList();
+
+ for( long i=(m_nInsPos+m_nInsRows-1); i>(m_nInsPos-1); i-- )
+ {
+ pOriginalRows->erase(pOriginalRows->begin()+i);
+ }
+
+ pTabEdCtrl->RowRemoved( m_nInsPos, m_nInsRows, TRUE );
+ pTabEdCtrl->InvalidateHandleColumn();
+
+ OTableEditorUndoAct::Undo();
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorInsNewUndoAct::Redo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Zeilen wieder einfuegen
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pRowList = pTabEdCtrl->GetRowList();
+
+ for( long i=m_nInsPos; i<(m_nInsPos+m_nInsRows); i++ )
+ pRowList->insert( pRowList->begin()+i,::boost::shared_ptr<OTableRow>(new OTableRow()) );
+
+ pTabEdCtrl->RowInserted( m_nInsPos, m_nInsRows, TRUE );
+ pTabEdCtrl->InvalidateHandleColumn();
+
+ OTableEditorUndoAct::Redo();
+}
+
+//-------------------------------------------------------------------------
+//========================================================================
+// class OPrimKeyUndoAct
+//========================================================================
+DBG_NAME(OPrimKeyUndoAct);
+//-------------------------------------------------------------------------
+OPrimKeyUndoAct::OPrimKeyUndoAct( OTableEditorCtrl* pOwner, MultiSelection aDeletedKeys, MultiSelection aInsertedKeys) :
+ OTableEditorUndoAct( pOwner ,STR_TABLEDESIGN_UNDO_PRIMKEY)
+ ,m_aDelKeys( aDeletedKeys )
+ ,m_aInsKeys( aInsertedKeys )
+ ,m_pEditorCtrl( pOwner )
+{
+ DBG_CTOR(OPrimKeyUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+OPrimKeyUndoAct::~OPrimKeyUndoAct()
+{
+ DBG_DTOR(OPrimKeyUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+void OPrimKeyUndoAct::Undo()
+{
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pRowList = pTabEdCtrl->GetRowList();
+ ::boost::shared_ptr<OTableRow> pRow;
+ long nIndex;
+
+ //////////////////////////////////////////////////////////////////////
+ // Die eingefuegten Keys loeschen
+ for( nIndex = m_aInsKeys.FirstSelected(); nIndex != (long)SFX_ENDOFSELECTION; nIndex=m_aInsKeys.NextSelected() )
+ {
+ OSL_ENSURE(nIndex <= static_cast<long>(pRowList->size()),"Index for undo isn't valid!");
+ pRow = (*pRowList)[nIndex];
+ pRow->SetPrimaryKey( FALSE );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Die geloeschten Keys herstellen
+ for( nIndex = m_aDelKeys.FirstSelected(); nIndex != (long)SFX_ENDOFSELECTION; nIndex=m_aDelKeys.NextSelected() )
+ {
+ OSL_ENSURE(nIndex <= static_cast<long>(pRowList->size()),"Index for undo isn't valid!");
+ pRow = (*pRowList)[nIndex];
+ pRow->SetPrimaryKey( TRUE );
+ }
+
+ m_pEditorCtrl->InvalidateHandleColumn();
+ OTableEditorUndoAct::Undo();
+}
+
+//-------------------------------------------------------------------------
+void OPrimKeyUndoAct::Redo()
+{
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pRowList = pTabEdCtrl->GetRowList();
+ long nIndex;
+
+ //////////////////////////////////////////////////////////////////////
+ // Die geloeschten Keys loeschen
+ for( nIndex = m_aDelKeys.FirstSelected(); nIndex != (long)SFX_ENDOFSELECTION; nIndex=m_aDelKeys.NextSelected() )
+ (*pRowList)[nIndex]->SetPrimaryKey( FALSE );
+
+ //////////////////////////////////////////////////////////////////////
+ // Die eingefuegten Keys herstellen
+ for( nIndex = m_aInsKeys.FirstSelected(); nIndex != (long)SFX_ENDOFSELECTION; nIndex=m_aInsKeys.NextSelected() )
+ (*pRowList)[nIndex]->SetPrimaryKey( TRUE );
+
+ m_pEditorCtrl->InvalidateHandleColumn();
+ OTableEditorUndoAct::Redo();
+}
+
+
+
+
diff --git a/dbaccess/source/ui/tabledesign/TableUndo.hxx b/dbaccess/source/ui/tabledesign/TableUndo.hxx
new file mode 100644
index 000000000000..a5e4af28b447
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableUndo.hxx
@@ -0,0 +1,178 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEUNDO_HXX
+#define DBAUI_TABLEUNDO_HXX
+
+#ifndef DBAUI_GENERALUNDO_HXX
+#include "GeneralUndo.hxx"
+#endif
+#ifndef _SV_MULTISEL_HXX
+#include <tools/multisel.hxx>
+#endif
+
+#include <vector>
+
+#ifndef _COM_SUN_STAR_UNO_ANY_H_
+#include <com/sun/star/uno/Any.h>
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+
+namespace dbaui
+{
+ //========================================================================
+ class OTableRowView;
+ class OTableRow;
+ class OTableDesignUndoAct : public OCommentUndoAction
+ {
+ protected:
+ OTableRowView* m_pTabDgnCtrl;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OTableDesignUndoAct( OTableRowView* pOwner ,USHORT nCommentID);
+ virtual ~OTableDesignUndoAct();
+ };
+
+ //========================================================================
+ class OTableEditorCtrl;
+ class OTableEditorUndoAct : public OTableDesignUndoAct
+ {
+ protected:
+ OTableEditorCtrl* pTabEdCtrl;
+
+ public:
+ TYPEINFO();
+ OTableEditorUndoAct( OTableEditorCtrl* pOwner,USHORT nCommentID );
+ virtual ~OTableEditorUndoAct();
+ };
+
+
+ //========================================================================
+ class OTableDesignCellUndoAct : public OTableDesignUndoAct
+ {
+ protected:
+ USHORT m_nCol;
+ long m_nRow;
+ ::com::sun::star::uno::Any m_sOldText;
+ ::com::sun::star::uno::Any m_sNewText;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OTableDesignCellUndoAct( OTableRowView* pOwner, long nRowID, USHORT nColumn );
+ virtual ~OTableDesignCellUndoAct();
+ };
+
+ class OTypeInfo;
+ //========================================================================
+ class OTableEditorTypeSelUndoAct : public OTableEditorUndoAct
+ {
+ protected:
+ USHORT m_nCol;
+ long m_nRow;
+ TOTypeInfoSP m_pOldType;
+ TOTypeInfoSP m_pNewType;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OTableEditorTypeSelUndoAct( OTableEditorCtrl* pOwner, long nRowID, USHORT nColumn, const TOTypeInfoSP& _pOldType );
+ virtual ~OTableEditorTypeSelUndoAct();
+ };
+
+ //========================================================================
+ class OTableEditorDelUndoAct : public OTableEditorUndoAct
+ {
+ protected:
+ ::std::vector< ::boost::shared_ptr<OTableRow> > m_aDeletedRows;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OTableEditorDelUndoAct( OTableEditorCtrl* pOwner );
+ virtual ~OTableEditorDelUndoAct();
+ };
+
+ //========================================================================
+ class OTableEditorInsUndoAct : public OTableEditorUndoAct
+ {
+ protected:
+ ::std::vector< ::boost::shared_ptr<OTableRow> > m_vInsertedRows;
+ long m_nInsPos;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OTableEditorInsUndoAct( OTableEditorCtrl* pOwner,
+ long nInsertPosition,
+ const ::std::vector< ::boost::shared_ptr<OTableRow> >& _vInsertedRows);
+ virtual ~OTableEditorInsUndoAct();
+ };
+
+ //========================================================================
+ class OTableEditorInsNewUndoAct : public OTableEditorUndoAct
+ {
+ protected:
+ long m_nInsPos;
+ long m_nInsRows;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OTableEditorInsNewUndoAct( OTableEditorCtrl* pOwner, long nInsertPosition, long nInsertedRows );
+ virtual ~OTableEditorInsNewUndoAct();
+ };
+
+ //========================================================================
+ class OPrimKeyUndoAct : public OTableEditorUndoAct
+ {
+ protected:
+ MultiSelection m_aDelKeys,
+ m_aInsKeys;
+ BOOL m_bActPrimKeySet;
+ OTableEditorCtrl* m_pEditorCtrl;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OPrimKeyUndoAct( OTableEditorCtrl* pOwner, MultiSelection aDeletedKeys, MultiSelection aInsertedKeys );
+ virtual ~OPrimKeyUndoAct();
+ };
+}
+#endif // DBAUI_TABLEUNDO_HXX
+
+
diff --git a/dbaccess/source/ui/tabledesign/makefile.mk b/dbaccess/source/ui/tabledesign/makefile.mk
new file mode 100644
index 000000000000..5e52041ecd29
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=tabledesign
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES =\
+ $(SLO)$/TableDesignControl.obj \
+ $(SLO)$/TableFieldDescWin.obj \
+ $(SLO)$/TableController.obj \
+ $(SLO)$/TableDesignView.obj \
+ $(SLO)$/TEditControl.obj \
+ $(SLO)$/TableFieldControl.obj \
+ $(SLO)$/TableDesignHelpBar.obj \
+ $(SLO)$/FieldDescGenWin.obj \
+ $(SLO)$/FieldDescriptions.obj \
+ $(SLO)$/TableRow.obj \
+ $(SLO)$/TableRowExchange.obj \
+ $(SLO)$/TableUndo.obj
+
+
+SRS1NAME=$(TARGET)
+SRC1FILES = table.src
+
+# --- Targets -------------------------------------------------------
+
+
+.INCLUDE : target.mk
+
+$(SRS)$/$(TARGET).srs: $(SOLARINCDIR)$/svx$/globlmn.hrc
diff --git a/dbaccess/source/ui/tabledesign/table.src b/dbaccess/source/ui/tabledesign/table.src
new file mode 100644
index 000000000000..d40da4e3c358
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/table.src
@@ -0,0 +1,409 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_TBL_HRC_
+#include "dbu_tbl.hrc"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBACCESS_SLOTID_HRC_
+#include "dbaccess_slotid.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _GLOBLMN_HRC
+#include <svx/globlmn.hrc>
+#endif
+#ifndef DBAUI_TOOLBOX_HXX
+#include "toolbox.hrc"
+#endif
+
+#define MN_EDIT 20
+#define MN_VIEW 21
+#define MN_EXTRA 22
+#define MN_INDEX 23
+#define MN_WIN 30
+#define MN_HELP 31
+
+String STR_TABLEDESIGN_DBFIELDTYPES
+{
+ Text [ en-US ] = "Unknown;Text;Number;Date/Time;Date;Time;Yes/No;Currency;Memo;Counter;Image;Text (fix);Decimal;Binary (fix);Binary;BigInt;Double;Float;Real;Integer;Small Integer;Tiny Integer;SQL Null;Object;Distinct;Structure;Field;BLOB;CLOB;REF;OTHER;Bit (fix)";
+};
+
+String STR_TABLEDESIGN_UNDO_PRIMKEY
+{
+ Text [ en-US ] = "Insert/remove primary key" ;
+};
+
+String STR_VALUE_YES
+{
+ Text [ en-US ] = "Yes" ;
+};
+String STR_VALUE_NO
+{
+ Text [ en-US ] = "No" ;
+};
+String STR_VALUE_ASC
+{
+ Text [ en-US ] = "Ascending" ;
+};
+String STR_VALUE_DESC
+{
+ Text [ en-US ] = "Descending" ;
+};
+String STR_VALUE_NONE
+{
+ // Bemerkung : sollte auch in anderen Sprachen irgendwie zum Wort 'Wert' passen : Wert - keiner ....
+ Text [ en-US ] = "<none>";
+};
+
+String STR_TAB_FIELD_NAME
+{
+ Text [ en-US ] = "Field name" ;
+};
+String STR_TAB_FIELD_COLUMN_NAME
+{
+ Text [ en-US ] = "Field Name" ;
+};
+String STR_TAB_FIELD_DATATYPE
+{
+ Text [ en-US ] = "Field ~type" ;
+};
+String STR_TAB_FIELD_COLUMN_DATATYPE
+{
+ Text [ en-US ] = "Field Type" ;
+};
+String STR_TAB_FIELD_LENGTH
+{
+ Text [ en-US ] = "Field length" ;
+};
+String STR_TAB_FIELD_DESCR
+{
+ Text [ en-US ] = "Description" ;
+};
+String STR_TAB_FIELD_NULLABLE
+{
+ Text [ en-US ] = "Input required" ;
+};
+String STR_FIELD_AUTOINCREMENT
+{
+ Text [ en-US ] = "~AutoValue";
+};
+String STR_TAB_PROPERTIES
+{
+ Text [ en-US ] = "Field Properties" ;
+};
+String STR_TABPAGE_GENERAL
+{
+ Text [ en-US ] = "General" ;
+};
+String STR_TAB_TABLE_DESCRIPTION
+{
+ Text [ en-US ] = "Description:";
+};
+
+String STR_TAB_TABLE_PROPERTIES
+{
+ Text [ en-US ] = "Table properties";
+};
+
+Control RID_DB_TAB_EDITOR
+{
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ TabStop = TRUE ;
+ SvLook = TRUE ;
+ Hide = TRUE ;
+ HelpId = HID_TABDESIGN_BACKGROUND ;
+};
+
+ErrorBox ERR_INVALID_LISTBOX_ENTRY
+{
+ Message [ en-US ] = "The text you entered is not a list element. " ;
+};
+
+Menu RID_TABLEDESIGNROWPOPUPMENU
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ ITEM_EDIT_CUT
+ };
+ MenuItem
+ {
+ ITEM_EDIT_COPY
+ };
+ MenuItem
+ {
+ ITEM_EDIT_PASTE
+ };
+ MenuItem
+ {
+ ITEM_EDIT_DELETE
+ };
+ MenuItem
+ {
+ Identifier = SID_TABLEDESIGN_INSERTROWS ;
+ HelpID = SID_TABLEDESIGN_INSERTROWS ;
+ Text [ en-US ] = "Insert Rows" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = SID_TABLEDESIGN_TABED_PRIMARYKEY ;
+ HelpID = SID_TABLEDESIGN_TABED_PRIMARYKEY ;
+ Checkable = TRUE ;
+ Text [ en-US ] = "Primary Key" ;
+ };
+ };
+};
+String STR_TABED_UNDO_CELLMODIFIED
+{
+ Text [ en-US ] = "Modify cell" ;
+};
+String STR_TABED_UNDO_ROWDELETED
+{
+ Text [ en-US ] = "Delete row" ;
+};
+String STR_TABED_UNDO_TYPE_CHANGED
+{
+ Text [ en-US ] = "Modify field type";
+};
+String STR_TABED_UNDO_ROWINSERTED
+{
+ Text [ en-US ] = "Insert row" ;
+};
+String STR_TABED_UNDO_NEWROWINSERTED
+{
+ Text [ en-US ] = "Insert new row" ;
+};
+String STR_TABED_UNDO_PRIMKEY
+{
+ Text [ en-US ] = "Insert/remove primary key" ;
+};
+
+String STR_DEFAULT_VALUE
+{
+ Text [ en-US ] = "~Default value" ;
+};
+String STR_FIELD_REQUIRED
+{
+ Text [ en-US ] = "~Entry required" ;
+};
+String STR_TEXT_LENGTH
+{
+ Text [ en-US ] = "~Length" ;
+};
+String STR_NUMERIC_TYPE
+{
+ Text [ en-US ] = "~Type" ;
+};
+String STR_LENGTH
+{
+ Text [ en-US ] = "~Length" ;
+};
+String STR_SCALE
+{
+ Text [ en-US ] = "Decimal ~places" ;
+};
+String STR_FORMAT
+{
+ Text [ en-US ] = "Format example";
+};
+String STR_HELP_BOOL_DEFAULT
+{
+ Text [ en-US ] = "Select a value that is to appear in all new records as default.\nIf the field is not to have a default value, select the empty string.";
+};
+String STR_HELP_DEFAULT_VALUE
+{
+ Text [ en-US ] = "Enter a default value for this field.\n\nWhen you later enter data in the table, this string will be used in each new record for the field selected. It should, therefore, correspond to the cell format that needs to be entered below." ;
+};
+String STR_HELP_FIELD_REQUIRED
+{
+ Text [ en-US ] = "Activate this option if this field cannot contain NULL values, i.e. the user must always enter data." ;
+};
+String STR_HELP_TEXT_LENGTH
+{
+ Text [ en-US ] = "Enter the maximum text length permitted." ;
+};
+String STR_HELP_NUMERIC_TYPE
+{
+ Text [ en-US ] = "Enter the number format." ;
+};
+String STR_HELP_LENGTH
+{
+ Text [ en-US ] = "Determine the length data can have in this field.\n\nIf decimal fields, then the maximum length of the number to be entered, if binary fields, then the length of the data block.\nThe value will be corrected accordingly when it exceeds the maximum for this database." ;
+};
+String STR_HELP_SCALE
+{
+ Text [ en-US ] = "Specify the number of decimal places permitted in this field." ;
+};
+String STR_HELP_FORMAT_CODE
+{
+ Text [ en-US ] = "This is where you see how the data would be displayed in the current format (use the button on the right to modify the format).";
+};
+String STR_HELP_FORMAT_BUTTON
+{
+ Text [ en-US ] = "This is where you determine the output format of the data.";
+};
+String STR_HELP_AUTOINCREMENT
+{
+ Text [ en-US ] = "Choose if this field should contain AutoIncrement values.\n\nYou can not enter data in fields of this type. An intrinsic value will be assigned to each new record automatically (resulting from the increment of the previous record)." ;
+};
+PushButton PB_FORMAT
+{
+ TabStop = TRUE ;
+ Text [ en-US ] = "~...";
+};
+String STR_TABLEDESIGN_DUPLICATE_NAME
+{
+ Text [ en-US ] = "The table cannot be saved because column name \"$column$\" was assigned twice.";
+};
+String STR_TBL_COLUMN_IS_KEYCOLUMN
+{
+ Text [ en-US ] = "The column \"$column$\" belongs to the primary key. If the column is deleted, the primary key will also be deleted. Do you really want to continue?";
+};
+String STR_TBL_COLUMN_IS_KEYCOLUMN_TITLE
+{
+ Text [ en-US ] = "Primary Key Affected";
+};
+String STR_COLUMN_NAME
+{
+ Text [ en-US ] = "Column";
+};
+String STR_QRY_CONTINUE
+{
+ Text [ en-US ] = "Continue anyway?" ;
+};
+String STR_STAT_WARNING
+{
+ Text [ en-US ] = "Warning!" ;
+};
+QueryBox TABLE_DESIGN_SAVEMODIFIED
+{
+ Buttons = WB_YES_NO_CANCEL ;
+ DefButton = WB_DEF_YES ;
+ Message [ en-US ] = "The table has been changed.\nDo you want to save the changes?" ;
+};
+QueryBox TABLE_QUERY_CONNECTION_LOST
+{
+ Buttons = WB_YES_NO ;
+ Message [ en-US ] = "The connection to the database was lost! The table design can only be used with limited functionality without a connection.\nReconnect?" ;
+};
+String STR_TABLEDESIGN_CONNECTION_MISSING
+{
+ Text [ en-US ] = "The table could not be saved due to problems connecting to the database.";
+};
+String STR_TABLEDESIGN_DATASOURCE_DELETED
+{
+ Text [ en-US ] = "The table filter could not be adjusted because the data source has been deleted.";
+};
+
+QueryBox QUERY_SAVE_TABLE_EDIT_INDEXES
+{
+ Message [ en-US ] = "Before you can edit the indexes of a table, you have to save it.\nDo you want to save the changes now?";
+
+ Buttons = WB_YES_NO ;
+};
+String STR_TABLEDESIGN_NO_PRIM_KEY_HEAD
+{
+ Text [ en-US ] = "No primary key" ;
+};
+String STR_TABLEDESIGN_NO_PRIM_KEY
+{
+ Text [ en-US ] = "A unique index or primary key is required for data record identification in this database.\nYou can only enter data into this table when one of these two structural conditions has been met.\n\nShould a primary key be created now?" ;
+};
+String STR_TABLEDESIGN_TITLE
+{
+ Text [ en-US ] = " - %PRODUCTNAME Base: Table Design";
+};
+
+/*
+ The menubar resource has become obsolete - you can now find the menubar definition at: <project>/uiconfig/dbtable/menubar/menubar.xml
+*/
+
+String STR_TABLEDESIGN_ALTER_ERROR
+{
+ Text [ en-US ] = "The column \"$column$\" could not be changed. Should the column instead be deleted and the new format appended?" ;
+};
+
+String STR_TABLEDESIGN_SAVE_ERROR
+{
+ Text [ en-US ] = "Error while saving the table design";
+};
+
+String STR_TABLEDESIGN_COULD_NOT_DROP_COL
+{
+ Text [ en-US ] = "The column $column$ could not be deleted.";
+};
+
+QueryBox TABLE_DESIGN_ALL_ROWS_DELETED
+{
+ Buttons = WB_YES_NO_CANCEL ;
+ DefButton = WB_DEF_YES ;
+ Message [ en-US ] = "You are trying to delete all the columns in the table. A table cannot exist without columns. Should the table be deleted from the database? If not, the table will remain unchanged.";
+};
+
+String STR_AUTOINCREMENT_VALUE
+{
+ Text [ en-US ] = "A~uto-increment statement";
+};
+String STR_HELP_AUTOINCREMENT_VALUE
+{
+ Text [ en-US ] = "Enter an SQL statement for the auto-increment field.\n\nThis statement will be directly transferred to the database when the table is created.";
+};
+
+String STR_NO_TYPE_INFO_AVAILABLE
+{
+ Text [ en-US ] = "No type information could be retrieved from the database.\nThe table design mode is not available for this data source.";
+};
+
+String STR_CHANGE_COLUMN_NAME
+{
+ Text [ en-US ] = "change field name";
+};
+
+String STR_CHANGE_COLUMN_TYPE
+{
+ Text [ en-US ] = "change field type";
+};
+
+String STR_CHANGE_COLUMN_DESCRIPTION
+{
+ Text [ en-US ] = "change field description";
+};
+
+String STR_CHANGE_COLUMN_ATTRIBUTE
+{
+ Text [ en-US ] = "change field attribute";
+};