LibreOffice Module dbaccess (master) 1
TableController.hxx
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#pragma once
20
22#include <com/sun/star/beans/XPropertySet.hpp>
23#include "TypeInfo.hxx"
24#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
25#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
26#include <com/sun/star/container/XNameAccess.hpp>
27
28namespace dbaui
29{
30 class OTableRow;
33 {
34 private:
35 std::vector< std::shared_ptr<OTableRow> > m_vRowList;
37 std::vector<OTypeInfoMap::iterator> m_aTypeInfoIndex;
38
39 css::uno::Reference< css::beans::XPropertySet > m_xTable;
40
41 OUString m_sName; // table for update data
42 OUString m_sAutoIncrementValue; // the autoincrement value set in the datasource
43 OUString m_sTypeNames; // these type names are the ones out of the resource file
44 TOTypeInfoSP m_pTypeInfo; // fall back when type is unknown because database driver has a failure
45
46 bool m_bAllowAutoIncrementValue; // no : 1 NO BIT , is true when the datasource has an AutoIncrementValue property in their info property
47 bool m_bNew : 1; // is true when we create a new table
48
49
50 void reSyncRows();
51 void assignTable(); // set the table if a name is given
52 void loadData();
55 bool checkColumns(bool _bNew); // check if we have double column names
56 void appendColumns(css::uno::Reference< css::sdbcx::XColumnsSupplier> const & _rxColSup, bool _bNew, bool _bKeyColumns = false);
57 void appendPrimaryKey(css::uno::Reference< css::sdbcx::XKeysSupplier> const & _rxSup, bool _bNew);
58 void alterColumns();
59 void dropPrimaryKey();
60 css::uno::Reference< css::container::XNameAccess> getKeyColumns() const;
61 OUString createUniqueName(const OUString& _rName);
62
63 void reload();
64
65 // all the features which should be handled by this class
66 virtual void describeSupportedFeatures() override;
67 // state of a feature. 'feature' may be the handle of a css::util::URL somebody requested a dispatch interface for OR a toolbar slot.
68 virtual FeatureState GetState(sal_uInt16 nId) const override;
69 // execute a feature
70 virtual void Execute(sal_uInt16 nId, const css::uno::Sequence< css::beans::PropertyValue>& aArgs) override;
71
72 virtual void losingConnection( ) override;
73
74 virtual OUString getPrivateTitle( ) const override;
75
76 void doEditIndexes();
77 bool doSaveDoc(bool _bSaveAs);
78
79 virtual ~OTableController() override;
80 public:
81 OTableController(const css::uno::Reference< css::uno::XComponentContext >& _rM);
82
83 const css::uno::Reference< css::beans::XPropertySet >& getTable() const { return m_xTable;}
84
85 bool isAddAllowed() const;
86 bool isDropAllowed() const;
87 bool isAlterAllowed() const;
88 bool isAutoIncrementPrimaryKey() const;
89
91 const OUString& getAutoIncrementValue() const { return m_sAutoIncrementValue; }
92
93 virtual void impl_onModifyChanged() override;
94
95 std::vector< std::shared_ptr<OTableRow> >& getRows() { return m_vRowList; }
96
98 sal_Int32 getFirstEmptyRowPosition();
99
100 const OTypeInfoMap& getTypeInfo() const { return m_aTypeInfo; }
101
102 TOTypeInfoSP const & getTypeInfo(sal_Int32 _nPos) const { return m_aTypeInfoIndex[_nPos]->second; }
103 TOTypeInfoSP getTypeInfoByType(sal_Int32 _nDataType) const;
104
106
107 virtual bool Construct(vcl::Window* pParent) override;
108 // XEventListener
109 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
110
111 // css::frame::XController
112 virtual sal_Bool SAL_CALL suspend(sal_Bool bSuspend) override;
113
114 // css::lang::XComponent
115 virtual void SAL_CALL disposing() override;
116
117 // XServiceInfo
118 virtual OUString SAL_CALL getImplementationName() override;
119 virtual css::uno::Sequence< OUString> SAL_CALL getSupportedServiceNames() override;
120
121 private:
122 void startTableListening();
123 void stopTableListening();
124 virtual void impl_initialize() override;
125 };
126}
127
128
129/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString createUniqueName(const OUString &_rName)
bool isAutoIncrementPrimaryKey() const
sal_Int32 getFirstEmptyRowPosition()
returns the position of the first empty row
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual OUString SAL_CALL getImplementationName() override
virtual void describeSupportedFeatures() override
void appendColumns(css::uno::Reference< css::sdbcx::XColumnsSupplier > const &_rxColSup, bool _bNew, bool _bKeyColumns=false)
TOTypeInfoSP getTypeInfoByType(sal_Int32 _nDataType) const
const OTypeInfoMap & getTypeInfo() const
std::vector< std::shared_ptr< OTableRow > > & getRows()
TOTypeInfoSP const & getTypeInfo(sal_Int32 _nPos) const
bool checkColumns(bool _bNew)
virtual void Execute(sal_uInt16 nId, const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
virtual void impl_onModifyChanged() override
std::vector< OTypeInfoMap::iterator > m_aTypeInfoIndex
bool doSaveDoc(bool _bSaveAs)
void appendPrimaryKey(css::uno::Reference< css::sdbcx::XKeysSupplier > const &_rxSup, bool _bNew)
virtual FeatureState GetState(sal_uInt16 nId) const override
OTableController(const css::uno::Reference< css::uno::XComponentContext > &_rM)
css::uno::Reference< css::container::XNameAccess > getKeyColumns() const
virtual bool Construct(vcl::Window *pParent) override
std::vector< std::shared_ptr< OTableRow > > m_vRowList
css::uno::Reference< css::beans::XPropertySet > m_xTable
virtual void losingConnection() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString getPrivateTitle() const override
const TOTypeInfoSP & getTypeInfoFallBack() const
virtual void impl_initialize() override
virtual ~OTableController() override
const OUString & getAutoIncrementValue() const
bool isAutoIncrementValueEnabled() const
const css::uno::Reference< css::beans::XPropertySet > & getTable() const
virtual void SAL_CALL disposing() override
virtual sal_Bool SAL_CALL suspend(sal_Bool bSuspend) override
OSingleDocumentController OTableController_BASE
std::multimap< sal_Int32, TOTypeInfoSP > OTypeInfoMap
Definition: TypeInfo.hxx:100
std::shared_ptr< OTypeInfo > TOTypeInfoSP
Definition: TypeInfo.hxx:99
describes the state of a feature
unsigned char sal_Bool
sal_Int32 _nPos