Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / connectivity / source / drivers / ado / AViews.cxx
blob943422289627657dc35c87aac82fe6ec33e3d9aa
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/servicehelper.hxx>
28 #include <comphelper/types.hxx>
29 #include <connectivity/dbexception.hxx>
30 #include <rtl/ref.hxx>
31 #include <systools/win32/oleauto.hxx>
33 #include <strings.hrc>
35 using namespace ::comphelper;
37 using namespace connectivity;
38 using namespace connectivity::ado;
39 using namespace com::sun::star::uno;
40 using namespace com::sun::star::lang;
41 using namespace com::sun::star::beans;
42 using namespace com::sun::star::sdbc;
43 using namespace com::sun::star::container;
45 sdbcx::ObjectType OViews::createObject(const OUString& _rName)
47 rtl::Reference<OAdoView> pView = new OAdoView(isCaseSensitive(),m_aCollection.GetItem(_rName));
48 pView->setNew(false);
49 return pView;
52 void OViews::impl_refresh( )
54 m_aCollection.Refresh();
57 Reference< XPropertySet > OViews::createDescriptor()
59 return new OAdoView(isCaseSensitive());
63 // XAppend
64 sdbcx::ObjectType OViews::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
66 OAdoView* pView = dynamic_cast<OAdoView*>( descriptor.get() );
67 if ( pView == nullptr )
68 m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_VIEW_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
70 WpADOCommand aCommand;
71 aCommand.Create();
72 if ( !aCommand.IsValid() )
73 m_pCatalog->getConnection()->throwGenericSQLException( STR_VIEW_NO_COMMAND_ERROR,static_cast<XTypeProvider*>(this) );
75 OUString sName( _rForName );
76 aCommand.put_Name(sName);
77 aCommand.put_CommandText(getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND))));
78 ADOViews* pViews = m_aCollection;
79 if (FAILED(pViews->Append(sal::systools::BStr(sName), aCommand)))
80 ADOS::ThrowException(m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
82 OTables* pTables = static_cast<OTables*>(static_cast<OCatalog&>(m_rParent).getPrivateTables());
83 if ( pTables )
84 pTables->appendNew(sName);
86 return createObject( _rForName );
89 // XDrop
90 void OViews::dropObject(sal_Int32 /*_nPos*/,const OUString& _sElementName)
92 if(!m_aCollection.Delete(_sElementName))
93 ADOS::ThrowException(m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */