LibreOffice Module connectivity (master) 1
Keys.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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
10#include "Keys.hxx"
11#include "Table.hxx"
12
14
15using namespace ::connectivity;
16using namespace ::connectivity::firebird;
17
18using namespace ::dbtools;
19using namespace ::osl;
20
21using namespace ::com::sun::star;
22using namespace ::com::sun::star::beans;
23using namespace ::com::sun::star::sdbc;
24using namespace ::com::sun::star::uno;
25
26Keys::Keys(Table* pTable, Mutex& rMutex, const ::std::vector< OUString>& rNames):
27 OKeysHelper(pTable,
28 rMutex,
29 rNames),
30 m_pTable(pTable)
31{
32}
33
34//----- XDrop ----------------------------------------------------------------
35void Keys::dropObject(sal_Int32 nPosition, const OUString& sName)
36{
37 if (m_pTable->isNew())
38 return;
39
40 uno::Reference<XPropertySet> xKey(getObject(nPosition), UNO_QUERY);
41
42 if (xKey.is())
43 {
44 const OUString sQuote = m_pTable->getConnection()->getMetaData()
45 ->getIdentifierQuoteString();
46
47 OUString sSql("ALTER TABLE " + quoteName(sQuote, m_pTable->getName())
48 + " DROP CONSTRAINT " + quoteName(sQuote, sName));
49
50 m_pTable->getConnection()->createStatement()->execute(sSql);
51 }
52}
53
54/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
const char sQuote[]
OUString sName
OUString quoteName(std::u16string_view _rQuote, const OUString &_rName)
quote the given name with the given quote string.