summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/tabledesign/TableController.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/tabledesign/TableController.cxx')
-rw-r--r--dbaccess/source/ui/tabledesign/TableController.cxx80
1 files changed, 36 insertions, 44 deletions
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
index 57af83b361f3..7b5b6d152cfc 100644
--- a/dbaccess/source/ui/tabledesign/TableController.cxx
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -46,17 +46,18 @@
#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
-#include <comphelper/processfactory.hxx>
#include <connectivity/dbexception.hxx>
#include <connectivity/dbtools.hxx>
#include <connectivity/dbmetadata.hxx>
#include <cppuhelper/exc_hlp.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
+#include <o3tl/string_view.hxx>
#include <algorithm>
#include <functional>
+#include <set>
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
org_openoffice_comp_dbu_OTableDesign_get_implementation(
@@ -67,7 +68,6 @@ org_openoffice_comp_dbu_OTableDesign_get_implementation(
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::lang;
@@ -75,7 +75,6 @@ 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;
@@ -100,17 +99,16 @@ namespace
OUString SAL_CALL OTableController::getImplementationName()
{
- return "org.openoffice.comp.dbu.OTableDesign";
+ return u"org.openoffice.comp.dbu.OTableDesign"_ustr;
}
Sequence< OUString> OTableController::getSupportedServiceNames()
{
- return { "com.sun.star.sdb.TableDesign" };
+ return { u"com.sun.star.sdb.TableDesign"_ustr };
}
OTableController::OTableController(const Reference< XComponentContext >& _rM) : OTableController_BASE(_rM)
,m_sTypeNames(DBA_RES(STR_TABLEDESIGN_DBFIELDTYPES))
- ,m_pTypeInfo()
,m_bAllowAutoIncrementValue(false)
,m_bNew(true)
{
@@ -315,9 +313,9 @@ bool OTableController::doSaveDoc(bool _bSaveAs)
xTable = xFact->createDataDescriptor();
OSL_ENSURE(xTable.is(),"OTableController::doSaveDoc: Create query failed!");
// to set the name is only allowed when the query is new
- xTable->setPropertyValue(PROPERTY_CATALOGNAME,makeAny(sCatalog));
- xTable->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(sSchema));
- xTable->setPropertyValue(PROPERTY_NAME,makeAny(m_sName));
+ xTable->setPropertyValue(PROPERTY_CATALOGNAME,Any(sCatalog));
+ xTable->setPropertyValue(PROPERTY_SCHEMANAME,Any(sSchema));
+ xTable->setPropertyValue(PROPERTY_NAME,Any(m_sName));
// now append the columns
Reference<XColumnsSupplier> xColSup(xTable,UNO_QUERY);
@@ -455,13 +453,11 @@ void OTableController::doEditIndexes()
}
-void OTableController::impl_initialize()
+void OTableController::impl_initialize(const ::comphelper::NamedValueCollection& rArguments)
{
try
{
- OTableController_BASE::impl_initialize();
-
- const NamedValueCollection& rArguments( getInitParams() );
+ OTableController_BASE::impl_initialize(rArguments);
rArguments.get_ensureType( PROPERTY_CURRENTTABLE, m_sName );
@@ -522,8 +518,8 @@ sal_Bool SAL_CALL OTableController::suspend(sal_Bool /*_bSuspend*/)
if ( std::any_of(m_vRowList.begin(),m_vRowList.end(),
std::mem_fn(&OTableRow::isValid)) )
{
- std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getFrameWeld(), "dbaccess/ui/tabledesignsavemodifieddialog.ui"));
- std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("TableDesignSaveModifiedDialog"));
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getFrameWeld(), u"dbaccess/ui/tabledesignsavemodifieddialog.ui"_ustr));
+ std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog(u"TableDesignSaveModifiedDialog"_ustr));
switch (xQuery->run())
{
case RET_YES:
@@ -540,8 +536,8 @@ sal_Bool SAL_CALL OTableController::suspend(sal_Bool /*_bSuspend*/)
}
else if ( !m_bNew )
{
- std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getFrameWeld(), "dbaccess/ui/deleteallrowsdialog.ui"));
- std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("DeleteAllRowsDialog"));
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getFrameWeld(), u"dbaccess/ui/deleteallrowsdialog.ui"_ustr));
+ std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog(u"DeleteAllRowsDialog"_ustr));
switch (xQuery->run())
{
case RET_YES:
@@ -575,15 +571,15 @@ 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: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 );
- implDescribeSupportedFeature( ".uno:GetUndoStrings", SID_GETUNDOSTRINGS );
- implDescribeSupportedFeature( ".uno:GetRedoStrings", SID_GETREDOSTRINGS );
+ implDescribeSupportedFeature( u".uno:Redo"_ustr, ID_BROWSER_REDO, CommandGroup::EDIT );
+ implDescribeSupportedFeature( u".uno:Save"_ustr, ID_BROWSER_SAVEDOC, CommandGroup::EDIT );
+ implDescribeSupportedFeature( u".uno:Undo"_ustr, ID_BROWSER_UNDO, CommandGroup::EDIT );
+ implDescribeSupportedFeature( u".uno:NewDoc"_ustr, SID_NEWDOC, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( u".uno:SaveAs"_ustr, ID_BROWSER_SAVEASDOC, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( u".uno:DBIndexDesign"_ustr, SID_INDEXDESIGN, CommandGroup::APPLICATION );
+ implDescribeSupportedFeature( u".uno:EditDoc"_ustr, ID_BROWSER_EDITDOC, CommandGroup::EDIT );
+ implDescribeSupportedFeature( u".uno:GetUndoStrings"_ustr, SID_GETUNDOSTRINGS );
+ implDescribeSupportedFeature( u".uno:GetRedoStrings"_ustr, SID_GETREDOSTRINGS );
}
void OTableController::impl_onModifyChanged()
@@ -663,7 +659,7 @@ void OTableController::appendColumns(Reference<XColumnsSupplier> const & _rxColS
if(!_bKeyColumns)
::dbaui::setColumnProperties(xColumn,pField);
else
- xColumn->setPropertyValue(PROPERTY_NAME,makeAny(pField->GetName()));
+ xColumn->setPropertyValue(PROPERTY_NAME,Any(pField->GetName()));
xAppend->appendByDescriptor(xColumn);
xColumn = nullptr;
@@ -722,7 +718,7 @@ void OTableController::appendPrimaryKey(Reference<XKeysSupplier> const & _rxSup,
Reference<XPropertySet> xKey = xKeyFactory->createDataDescriptor();
OSL_ENSURE(xKey.is(),"Key is null!");
- xKey->setPropertyValue(PROPERTY_TYPE,makeAny(KeyType::PRIMARY));
+ xKey->setPropertyValue(PROPERTY_TYPE,Any(KeyType::PRIMARY));
Reference<XColumnsSupplier> xColSup(xKey,UNO_QUERY);
if(xColSup.is())
@@ -795,7 +791,7 @@ void OTableController::loadData()
pTabEdRow->SetReadOnly(!bIsAlterAllowed);
// search for type
bool bForce;
- TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(m_aTypeInfo,nType,sTypeName,"x",nPrecision,nScale,bIsAutoIncrement,bForce);
+ TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(m_aTypeInfo,nType,sTypeName,u"x"_ustr,nPrecision,nScale,bIsAutoIncrement,bForce);
if ( !pTypeInfo )
pTypeInfo = m_pTypeInfo;
pTabEdRow->SetFieldType( pTypeInfo, bForce );
@@ -903,18 +899,18 @@ bool OTableController::checkColumns(bool _bNew)
{
case RET_YES:
{
- auto pNewRow = std::make_shared<OTableRow>();
TOTypeInfoSP pTypeInfo = ::dbaui::queryPrimaryKeyType(m_aTypeInfo);
if ( !pTypeInfo )
break;
+ auto pNewRow = std::make_shared<OTableRow>();
pNewRow->SetFieldType( pTypeInfo );
OFieldDescription* pActFieldDescr = pNewRow->GetActFieldDescr();
- pActFieldDescr->SetAutoIncrement(false);
+ pActFieldDescr->SetAutoIncrement(pTypeInfo->bAutoIncrement);
pActFieldDescr->SetIsNullable(ColumnValue::NO_NULLS);
- pActFieldDescr->SetName( createUniqueName("ID" ));
+ pActFieldDescr->SetName( createUniqueName(u"ID"_ustr ));
pActFieldDescr->SetPrimaryKey( true );
m_vRowList.insert(m_vRowList.begin(),pNewRow);
@@ -1121,14 +1117,14 @@ void OTableController::alterColumns()
xColumns->getByName(pField->GetName()) >>= xColumn;
Reference<XPropertySetInfo> xInfo = xColumn->getPropertySetInfo();
if ( xInfo->hasPropertyByName(PROPERTY_HELPTEXT) )
- xColumn->setPropertyValue(PROPERTY_HELPTEXT,makeAny(pField->GetHelpText()));
+ xColumn->setPropertyValue(PROPERTY_HELPTEXT,Any(pField->GetHelpText()));
if(xInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT))
xColumn->setPropertyValue(PROPERTY_CONTROLDEFAULT,pField->GetControlDefault());
if(xInfo->hasPropertyByName(PROPERTY_FORMATKEY))
- xColumn->setPropertyValue(PROPERTY_FORMATKEY,makeAny(pField->GetFormatKey()));
+ xColumn->setPropertyValue(PROPERTY_FORMATKEY,Any(pField->GetFormatKey()));
if(xInfo->hasPropertyByName(PROPERTY_ALIGN))
- xColumn->setPropertyValue(PROPERTY_ALIGN,makeAny(dbaui::mapTextAllign(pField->GetHorJustify())));
+ xColumn->setPropertyValue(PROPERTY_ALIGN,Any(dbaui::mapTextAlign(pField->GetHorJustify())));
}
}
// second drop all columns which could be found by name
@@ -1164,15 +1160,11 @@ void OTableController::alterColumns()
}
catch (const SQLException&)
{
+ const auto caughtException = ::cppu::getCaughtException();
OUString sError( DBA_RES( STR_TABLEDESIGN_COULD_NOT_DROP_COL ) );
sError = sError.replaceFirst( "$column$", rColumnName );
- SQLException aNewException;
- aNewException.Message = sError;
- aNewException.SQLState = "S1000";
- aNewException.NextException = ::cppu::getCaughtException();
-
- throw aNewException;
+ throw SQLException(sError, {}, u"S1000"_ustr, 0, caughtException);
}
}
}
@@ -1326,7 +1318,7 @@ void OTableController::assignTable()
if (!xProp.is())
return;
- m_xTable = xProp;
+ m_xTable = std::move(xProp);
startTableListening();
// check if we set the table editable
@@ -1444,7 +1436,7 @@ OUString OTableController::getPrivateTitle() const
if ( sTitle.isEmpty() )
{
OUString aName = DBA_RES(STR_TBL_TITLE);
- sTitle = aName.getToken(0,' ') + OUString::number(getCurrentStartNumber());
+ sTitle = o3tl::getToken(aName,0,' ') + OUString::number(getCurrentStartNumber());
}
}
catch( const Exception& )