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