Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / ado / AViews.cxx
blob155866c1ec30c23be3270ac0dbacba1833af8526
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "ado/AViews.hxx"
21 #include "ado/AView.hxx"
22 #include "ado/ATables.hxx"
23 #include "ado/ACatalog.hxx"
24 #include "ado/AConnection.hxx"
25 #include "ado/Awrapado.hxx"
26 #include "TConnection.hxx"
27 #include <comphelper/types.hxx>
28 #include <connectivity/dbexception.hxx>
29 #include "resource/ado_res.hrc"
31 using namespace ::comphelper;
33 using namespace connectivity;
34 using namespace connectivity::ado;
35 using namespace com::sun::star::uno;
36 using namespace com::sun::star::lang;
37 using namespace com::sun::star::beans;
38 using namespace com::sun::star::sdbc;
39 using namespace com::sun::star::container;
41 sdbcx::ObjectType OViews::createObject(const OUString& _rName)
43 OAdoView* pView = new OAdoView(isCaseSensitive(),m_aCollection.GetItem(_rName));
44 pView->setNew(sal_False);
45 return pView;
48 void OViews::impl_refresh( ) throw(RuntimeException)
50 m_aCollection.Refresh();
53 Reference< XPropertySet > OViews::createDescriptor()
55 return new OAdoView(isCaseSensitive());
59 // XAppend
60 sdbcx::ObjectType OViews::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
62 OAdoView* pView = NULL;
63 if ( !getImplementation( pView, descriptor ) || pView == NULL )
64 m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_VIEW_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
66 WpADOCommand aCommand;
67 aCommand.Create();
68 if ( !aCommand.IsValid() )
69 m_pCatalog->getConnection()->throwGenericSQLException( STR_VIEW_NO_COMMAND_ERROR,static_cast<XTypeProvider*>(this) );
71 OUString sName( _rForName );
72 aCommand.put_Name(sName);
73 aCommand.put_CommandText(getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND))));
74 ADOViews* pViews = (ADOViews*)m_aCollection;
75 if(FAILED(pViews->Append(OLEString(sName),aCommand)))
76 ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
78 OTables* pTables = static_cast<OTables*>(static_cast<OCatalog&>(m_rParent).getPrivateTables());
79 if ( pTables )
80 pTables->appendNew(sName);
82 return createObject( _rForName );
85 // XDrop
86 void OViews::dropObject(sal_Int32 /*_nPos*/,const OUString& _sElementName)
88 if(!m_aCollection.Delete(_sElementName))
89 ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */