LibreOffice Module connectivity (master) 1
AViews.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
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>
28#include <comphelper/types.hxx>
30#include <rtl/ref.hxx>
31#include <systools/win32/oleauto.hxx>
32
33#include <strings.hrc>
34
35using namespace ::comphelper;
36
37using namespace connectivity;
38using namespace connectivity::ado;
39using namespace com::sun::star::uno;
40using namespace com::sun::star::lang;
41using namespace com::sun::star::beans;
42using namespace com::sun::star::sdbc;
43using namespace com::sun::star::container;
44
45sdbcx::ObjectType OViews::createObject(const OUString& _rName)
46{
48 pView->setNew(false);
49 return pView;
50}
51
53{
55}
56
58{
59 return new OAdoView(isCaseSensitive());
60}
61
62
63// XAppend
64sdbcx::ObjectType OViews::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
65{
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) );
69
71 aCommand.Create();
72 if ( !aCommand.IsValid() )
73 m_pCatalog->getConnection()->throwGenericSQLException( STR_VIEW_NO_COMMAND_ERROR,static_cast<XTypeProvider*>(this) );
74
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));
81
82 OTables* pTables = static_cast<OTables*>(static_cast<OCatalog&>(m_rParent).getPrivateTables());
83 if ( pTables )
84 pTables->appendNew(sName);
85
86 return createObject( _rForName );
87}
88
89// XDrop
90void OViews::dropObject(sal_Int32 /*_nPos*/,const OUString& _sElementName)
91{
92 if(!m_aCollection.Delete(_sElementName))
93 ADOS::ThrowException(m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
94}
95
96
97/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::dbtools::OPropertyMap & getPropMap()
Definition: TConnection.cxx:68
void throwGenericSQLException(TranslateId pErrorResourceId, const css::uno::Reference< css::uno::XInterface > &_xContext)
Definition: TConnection.cxx:74
static void ThrowException(ADOConnection *_pAdoCon, const css::uno::Reference< css::uno::XInterface > &_xInterface)
Definition: ADriver.cxx:207
OConnection * getConnection() const
Definition: ACatalog.hxx:43
WpADOConnection & getConnection()
void appendNew(const OUString &_rsNewTable)
Definition: ATables.cxx:88
WpADOViews m_aCollection
Definition: AViews.hxx:32
virtual void dropObject(sal_Int32 _nPos, const OUString &_sElementName) override
Definition: AViews.cxx:90
virtual void impl_refresh() override
Definition: AViews.cxx:52
virtual sdbcx::ObjectType appendObject(const OUString &_rForName, const css::uno::Reference< css::beans::XPropertySet > &descriptor) override
appends an object described by a descriptor, under a given name
virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override
Definition: AViews.cxx:57
virtual sdbcx::ObjectType createObject(const OUString &_rName) override
Definition: AViews.cxx:45
bool Delete(const OUString &sName)
Definition: Aolewrap.hxx:165
WrapT GetItem(sal_Int32 index) const
Definition: Aolewrap.hxx:102
::cppu::OWeakObject & m_rParent
Definition: VCollection.hxx:97
const OUString & getNameByIndex(sal_Int32 _nIndex) const
Definition: propertyids.cxx:95
OUString sName
OUString getString(const Any &_rAny)
css::uno::Reference< css::beans::XPropertySet > ObjectType
Definition: VCollection.hxx:59
#define PROPERTY_ID_COMMAND
Definition: propertyids.hxx:72
OUString aCommand