1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_connectivity.hxx" 30 #include "ado/AViews.hxx" 31 #include "ado/AView.hxx" 32 #include "ado/ATables.hxx" 33 #include "ado/ACatalog.hxx" 34 #include "ado/AConnection.hxx" 35 #include "ado/Awrapado.hxx" 36 #include "TConnection.hxx" 37 #include <comphelper/types.hxx> 38 #include <connectivity/dbexception.hxx> 39 #include "resource/ado_res.hrc" 40 41 using namespace ::comphelper; 42 43 using namespace connectivity; 44 using namespace connectivity::ado; 45 using namespace com::sun::star::uno; 46 using namespace com::sun::star::lang; 47 using namespace com::sun::star::beans; 48 using namespace com::sun::star::sdbc; 49 using namespace com::sun::star::container; 50 51 sdbcx::ObjectType OViews::createObject(const ::rtl::OUString& _rName) 52 { 53 OAdoView* pView = new OAdoView(isCaseSensitive(),m_aCollection.GetItem(_rName)); 54 pView->setNew(sal_False); 55 return pView; 56 } 57 // ------------------------------------------------------------------------- 58 void OViews::impl_refresh( ) throw(RuntimeException) 59 { 60 m_aCollection.Refresh(); 61 } 62 // ------------------------------------------------------------------------- 63 Reference< XPropertySet > OViews::createDescriptor() 64 { 65 return new OAdoView(isCaseSensitive()); 66 } 67 68 // ------------------------------------------------------------------------- 69 // XAppend 70 sdbcx::ObjectType OViews::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor ) 71 { 72 OAdoView* pView = NULL; 73 if ( !getImplementation( pView, descriptor ) || pView == NULL ) 74 m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_VIEW_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) ); 75 76 WpADOCommand aCommand; 77 aCommand.Create(); 78 if ( !aCommand.IsValid() ) 79 m_pCatalog->getConnection()->throwGenericSQLException( STR_VIEW_NO_COMMAND_ERROR,static_cast<XTypeProvider*>(this) ); 80 81 ::rtl::OUString sName( _rForName ); 82 aCommand.put_Name(sName); 83 aCommand.put_CommandText(getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND)))); 84 ADOViews* pViews = (ADOViews*)m_aCollection; 85 if(FAILED(pViews->Append(OLEString(sName),aCommand))) 86 ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this)); 87 88 OTables* pTables = static_cast<OTables*>(static_cast<OCatalog&>(m_rParent).getPrivateTables()); 89 if ( pTables ) 90 pTables->appendNew(sName); 91 92 return createObject( _rForName ); 93 } 94 // ------------------------------------------------------------------------- 95 // XDrop 96 void OViews::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName) 97 { 98 if(!m_aCollection.Delete(_sElementName)) 99 ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this)); 100 } 101 // ------------------------------------------------------------------------- 102 103 104 105