calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / connectivity / source / sdbcx / VIndex.cxx
blobaf4977765b3c09b54adacd8fdc32c0c75bf40279
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 <sdbcx/VIndex.hxx>
21 #include <com/sun/star/beans/PropertyAttribute.hpp>
22 #include <connectivity/dbexception.hxx>
23 #include <comphelper/sequence.hxx>
24 #include <connectivity/sdbcx/VCollection.hxx>
25 #include <cppuhelper/supportsservice.hxx>
26 #include <TConnection.hxx>
27 #include <utility>
28 #include <comphelper/diagnose_ex.hxx>
30 using namespace ::connectivity;
31 using namespace ::dbtools;
32 using namespace ::connectivity::sdbcx;
33 using namespace ::cppu;
34 using namespace ::com::sun::star::beans;
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::sdbc;
37 using namespace ::com::sun::star::sdbcx;
38 using namespace ::com::sun::star::container;
39 using namespace ::com::sun::star::lang;
42 OUString SAL_CALL OIndex::getImplementationName( )
44 if(isNew())
45 return "com.sun.star.sdbcx.VIndexDescriptor";
46 return "com.sun.star.sdbcx.VIndex";
49 css::uno::Sequence< OUString > SAL_CALL OIndex::getSupportedServiceNames( )
51 return { isNew()?OUString("com.sun.star.sdbcx.IndexDescriptor"):OUString("com.sun.star.sdbcx.Index") };
54 sal_Bool SAL_CALL OIndex::supportsService( const OUString& _rServiceName )
56 return cppu::supportsService(this, _rServiceName);
59 OIndex::OIndex(bool _bCase) : ODescriptor_BASE(m_aMutex)
60 , ODescriptor(ODescriptor_BASE::rBHelper,_bCase,true)
61 ,m_IsUnique(false)
62 ,m_IsPrimaryKeyIndex(false)
63 ,m_IsClustered(false)
67 OIndex::OIndex( const OUString& Name,
68 OUString Catalog,
69 bool _isUnique,
70 bool _isPrimaryKeyIndex,
71 bool _isClustered,
72 bool _bCase) : ODescriptor_BASE(m_aMutex)
73 ,ODescriptor(ODescriptor_BASE::rBHelper, _bCase)
74 ,m_Catalog(std::move(Catalog))
75 ,m_IsUnique(_isUnique)
76 ,m_IsPrimaryKeyIndex(_isPrimaryKeyIndex)
77 ,m_IsClustered(_isClustered)
79 m_Name = Name;
82 OIndex::~OIndex( )
86 ::cppu::IPropertyArrayHelper* OIndex::createArrayHelper( sal_Int32 /*_nId*/ ) const
88 return doCreateArrayHelper();
91 ::cppu::IPropertyArrayHelper& SAL_CALL OIndex::getInfoHelper()
93 return *OIndex_PROP::getArrayHelper(isNew() ? 1 : 0);
96 Any SAL_CALL OIndex::queryInterface( const Type & rType )
98 Any aRet = ODescriptor::queryInterface( rType);
99 if(!aRet.hasValue())
101 if(!isNew())
102 aRet = OIndex_BASE::queryInterface(rType);
103 if(!aRet.hasValue())
104 aRet = ODescriptor_BASE::queryInterface( rType);
106 return aRet;
109 Sequence< Type > SAL_CALL OIndex::getTypes( )
111 if(isNew())
112 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes());
113 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes(),OIndex_BASE::getTypes());
116 void OIndex::construct()
118 ODescriptor::construct();
120 sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
122 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOG), PROPERTY_ID_CATALOG, nAttrib,&m_Catalog, ::cppu::UnoType<OUString>::get());
123 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE), PROPERTY_ID_ISUNIQUE, nAttrib,&m_IsUnique, cppu::UnoType<bool>::get());
124 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISPRIMARYKEYINDEX),PROPERTY_ID_ISPRIMARYKEYINDEX, nAttrib,&m_IsPrimaryKeyIndex, cppu::UnoType<bool>::get());
125 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCLUSTERED), PROPERTY_ID_ISCLUSTERED, nAttrib,&m_IsClustered, cppu::UnoType<bool>::get());
128 void OIndex::disposing()
130 OPropertySetHelper::disposing();
132 ::osl::MutexGuard aGuard(m_aMutex);
134 if(m_pColumns)
135 m_pColumns->disposing();
138 Reference< css::container::XNameAccess > SAL_CALL OIndex::getColumns( )
140 ::osl::MutexGuard aGuard(m_aMutex);
141 checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
145 if ( !m_pColumns )
146 refreshColumns();
148 catch( const RuntimeException& )
150 // allowed to leave this method
151 throw;
153 catch( const Exception& )
155 TOOLS_WARN_EXCEPTION( "connectivity.commontools", "OIndex::getColumns" );
158 return m_pColumns.get();
161 Reference< XPropertySet > SAL_CALL OIndex::createDataDescriptor( )
163 ::osl::MutexGuard aGuard(m_aMutex);
164 checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
167 return this;
170 css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OIndex::getPropertySetInfo( )
172 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
175 OUString SAL_CALL OIndex::getName( )
177 return m_Name;
180 void SAL_CALL OIndex::setName( const OUString& /*aName*/ )
184 // XInterface
185 void SAL_CALL OIndex::acquire() noexcept
187 ODescriptor_BASE::acquire();
190 void SAL_CALL OIndex::release() noexcept
192 ODescriptor_BASE::release();
195 void OIndex::refreshColumns()
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */