correct the creation of views

This commit is contained in:
Ocke Janssen 2001-03-30 07:47:18 +00:00
parent 14482ffc65
commit 21d596a931
4 changed files with 71 additions and 15 deletions

View file

@ -2,9 +2,9 @@
*
* $RCSfile: dsbrowserDnD.cxx,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: fs $ $Date: 2001-03-28 15:44:58 $
* last change: $Author: oj $ $Date: 2001-03-30 08:47:18 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -570,6 +570,9 @@ namespace dbaui
::comphelper::disposeComponent(xDestRsUpd);
}
break;
case OCopyTableWizard::WIZARD_DEF_VIEW:
xTable = aWizard.createView();
break;
default:
break;
}
@ -798,6 +801,9 @@ namespace dbaui
/*************************************************************************
* history:
* $Log: not supported by cvs2svn $
* Revision 1.3 2001/03/28 15:44:58 fs
* changed the ctor of ODataClipboard
*
* Revision 1.2 2001/03/27 07:09:19 oj
* use of new initialize
*

View file

@ -2,9 +2,9 @@
*
* $RCSfile: WCopyTable.hxx,v $
*
* $Revision: 1.1 $
* $Revision: 1.2 $
*
* last change: $Author: oj $ $Date: 2001-02-23 14:59:07 $
* last change: $Author: oj $ $Date: 2001-03-30 08:44:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -245,6 +245,7 @@ namespace dbaui
void clearDestColumns();
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createTable();
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createView();
};
}

View file

@ -2,9 +2,9 @@
*
* $RCSfile: WCPage.cxx,v $
*
* $Revision: 1.1 $
* $Revision: 1.2 $
*
* last change: $Author: oj $ $Date: 2001-02-23 15:07:07 $
* last change: $Author: oj $ $Date: 2001-03-30 08:44:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -135,7 +135,7 @@ OCopyTable::OCopyTable( Window * pParent, EImportMode atWhat, sal_Bool bIsQuery,
::rtl::OUString sValue = xRow->getString(1);
if(!xRow->wasNull() && sValue.equalsIgnoreCase(sVIEW))
{
m_bIsViewAllowed &= sal_True;
m_bIsViewAllowed = m_bIsViewAllowed || sal_True;
break;
}
}
@ -187,8 +187,7 @@ OCopyTable::OCopyTable( Window * pParent, EImportMode atWhat, sal_Bool bIsQuery,
m_edKeyName.Enable(sal_False);
m_edKeyName.SetText(String::CreateFromAscii("ID"));
sal_Int32 nMaxLen = xMetaData->getMaxColumnNameLength();
if(nMaxLen)
m_edKeyName.SetMaxTextLen(nMaxLen);
m_edKeyName.SetMaxTextLen(nMaxLen ? (xub_StrLen)nMaxLen : EDIT_NOLIMIT);
FreeResource();
@ -349,8 +348,7 @@ void OCopyTable::ActivatePage()
//////////////////////////////////////////////////////////////////////////
// Ist der Name zu lang?
sal_Int32 nLen = m_pParent->m_xConnection->getMetaData()->getMaxTableNameLength();
if(nLen)
m_edTableName.SetMaxTextLen(nLen);
m_edTableName.SetMaxTextLen(nLen ? (xub_StrLen)nLen : EDIT_NOLIMIT);
//m_pParent->EnableButton(OCopyTableWizard::WIZARD_FINISH,FALSE);
// if (m_pParent->m_xSourceDef.Is() && (m_pParent->m_xSourceDef->GetDatabase() == m_pParent->m_xDatabase))
@ -368,8 +366,7 @@ void OCopyTable::Reset()
sal_Int32 nLen = m_pParent->m_xConnection->getMetaData()->getMaxTableNameLength();
if(nLen)
m_edTableName.SetMaxTextLen(nLen);
m_edTableName.SetMaxTextLen(nLen ? (xub_StrLen)nLen : EDIT_NOLIMIT);
String aTableName = m_pParent->m_sName;
if(nLen && nLen < aTableName.Len())

View file

@ -2,9 +2,9 @@
*
* $RCSfile: WCopyTable.cxx,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: fs $ $Date: 2001-03-15 08:23:44 $
* last change: $Author: oj $ $Date: 2001-03-30 08:44:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -68,6 +68,9 @@
#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
#endif
@ -119,6 +122,9 @@
#ifndef _COMPHELPER_EXTRACT_HXX_
#include <comphelper/extract.hxx>
#endif
#ifndef DBAUI_TOOLS_HXX
#include "UITools.hxx"
#endif
using namespace ::dbaui;
using namespace ::com::sun::star::uno;
@ -889,6 +895,52 @@ void OCopyTableWizard::setColumnProperties(const Reference<XPropertySet>& _rxCol
_rxColumn->setPropertyValue(PROPERTY_DEFAULTVALUE,makeAny(_pFieldDesc->GetDefaultValue()));
}
// -----------------------------------------------------------------------------
Reference< XPropertySet > OCopyTableWizard::createView()
{
Reference<XViewsSupplier> xSup(m_xConnection,UNO_QUERY);
Reference< XNameAccess > xViews;
if(xSup.is())
xViews = xSup->getViews();
Reference<XDataDescriptorFactory> xFact(xViews,UNO_QUERY);
OSL_ENSURE(xFact.is(),"No XDataDescriptorFactory available!");
if(!xFact.is())
return NULL;
m_xDestObject = xFact->createDataDescriptor();
::rtl::OUString sCatalog,sSchema,sTable;
::dbtools::qualifiedNameComponents(m_xConnection->getMetaData(),
m_sName,
sCatalog,
sSchema,
sTable);
m_xDestObject->setPropertyValue(PROPERTY_CATALOGNAME,makeAny(sCatalog));
m_xDestObject->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(sSchema));
m_xDestObject->setPropertyValue(PROPERTY_NAME,makeAny(sTable));
::rtl::OUString sCommand = ::rtl::OUString::createFromAscii("SELECT * FROM ");
::rtl::OUString sComposedName;
::dbaui::composeTableName(m_xConnection->getMetaData(),m_xSourceObject,sComposedName,sal_True);
sCommand += sComposedName;
m_xDestObject->setPropertyValue(PROPERTY_COMMAND,makeAny(sCommand));
Reference<XAppend> xAppend(xViews,UNO_QUERY);
if(xAppend.is())
xAppend->appendByDescriptor(m_xDestObject);
m_xDestObject = NULL;
// we need to reget the view because after appending it it is no longer valid
// but this time it isn't a view object it is a table object with type "VIEW"
Reference<XTablesSupplier> xTabSup(m_xConnection,UNO_QUERY);
Reference< XNameAccess > xTables;
if(xSup.is())
xTables = xTabSup->getTables();
if(xTables.is() && xTables->hasByName(m_sName))
xTables->getByName(m_sName) >>= m_xDestObject;
return m_xDestObject;
}
// -----------------------------------------------------------------------------
Reference< XPropertySet > OCopyTableWizard::createTable()
{
Reference<XTablesSupplier> xSup(m_xConnection,UNO_QUERY);