update dev300-m58
[ooovba.git] / dbaccess / source / ui / inc / TableController.hxx
blob6062cec1aa916ce5e74fc96a093c1f6acde8601f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TableController.hxx,v $
10 * $Revision: 1.40.68.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef DBUI_TABLECONTROLLER_HXX
31 #define DBUI_TABLECONTROLLER_HXX
33 #ifndef DBAUI_SINGLEDOCCONTROLLER_HXX
34 #include "singledoccontroller.hxx"
35 #endif
36 #ifndef _DBAUI_MODULE_DBU_HXX_
37 #include "moduledbu.hxx"
38 #endif
39 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
40 #include <com/sun/star/sdbc/XConnection.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #endif
45 #ifndef _COM_SUN_STAR_IO_XOBJECTOUTPUTSTREAM_HPP_
46 #include <com/sun/star/io/XObjectOutputStream.hpp>
47 #endif
48 #ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_
49 #include <com/sun/star/io/XObjectInputStream.hpp>
50 #endif
51 #ifndef DBAUI_TYPEINFO_HXX
52 #include "TypeInfo.hxx"
53 #endif
54 #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
55 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
56 #endif
57 #ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
58 #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
59 #endif
60 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
61 #include <com/sun/star/container/XNameAccess.hpp>
62 #endif
64 class FixedText;
65 namespace dbaui
67 class OTableRow;
68 class OFieldDescription;
69 typedef OSingleDocumentController OTableController_BASE;
70 class OTableController : public OTableController_BASE
72 private:
73 OModuleClient m_aModuleClient;
74 ::std::vector< ::boost::shared_ptr<OTableRow> > m_vRowList;
75 OTypeInfoMap m_aTypeInfo;
76 ::std::vector<OTypeInfoMap::iterator> m_aTypeInfoIndex;
78 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTable;
80 ::rtl::OUString m_sCatalogName; // catalog for update data
81 ::rtl::OUString m_sSchemaName; // schema for update data
82 ::rtl::OUString m_sName; // table for update data
83 ::rtl::OUString m_sAutoIncrementValue; // the autoincrement value set in the datasource
84 String m_sTypeNames; // these type names are the ones out of the resource file
85 TOTypeInfoSP m_pTypeInfo; // fall back when type is unkown because database driver has a failure
87 sal_Bool m_bAllowAutoIncrementValue; // no : 1 NO BIT , is true when the datasource has a AutoIncrementValue property in their info property
88 sal_Bool m_bNew : 1; // is true when we create a new table
91 void reSyncRows();
92 void assignTable(); // set the table if a name is given
93 void loadData();
94 sal_Bool checkColumns(sal_Bool _bNew) throw(::com::sun::star::sdbc::SQLException); // check if we have double column names
95 String createUniqueName(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _rxTables,const String& _rDefault);
96 void appendColumns(::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier>& _rxColSup,sal_Bool _bNew,sal_Bool _bKeyColumns = sal_False);
97 void appendPrimaryKey(::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XKeysSupplier>& _rxSup,sal_Bool _bNew);
98 void alterColumns();
99 void dropPrimaryKey();
100 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> getKeyColumns() const;
101 ::rtl::OUString createUniqueName(const ::rtl::OUString& _rName);
103 void reload();
105 // all the features which should be handled by this class
106 virtual void describeSupportedFeatures();
107 // state of a feature. 'feature' may be the handle of a ::com::sun::star::util::URL somebody requested a dispatch interface for OR a toolbar slot.
108 virtual FeatureState GetState(sal_uInt16 nId) const;
109 // execute a feature
110 virtual void Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
112 virtual void losingConnection( );
114 virtual ::rtl::OUString getPrivateTitle( ) const;
116 void doEditIndexes();
117 sal_Bool doSaveDoc(sal_Bool _bSaveAs);
119 virtual ~OTableController();
120 public:
121 OTableController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM);
123 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getTable() { return m_xTable;}
125 sal_Bool isAddAllowed() const;
126 sal_Bool isDropAllowed() const;
127 sal_Bool isAlterAllowed() const;
128 bool isAutoIncrementPrimaryKey() const;
130 inline sal_Bool isAutoIncrementValueEnabled() const { return m_bAllowAutoIncrementValue; }
131 inline const ::rtl::OUString& getAutoIncrementValue() const { return m_sAutoIncrementValue; }
133 virtual void setModified(sal_Bool _bModified=sal_True);
135 // const ::connectivity::OSQLParseNode* getParseTree() const { return m_aSqlIterator.getParseTree();}
136 // need for undo's and redo's
137 SfxUndoManager* getUndoMgr();
138 inline ::std::vector< ::boost::shared_ptr<OTableRow> >* getRows() { return &m_vRowList; }
140 /// returns the postion of the the first empty row
141 sal_Int32 getFirstEmptyRowPosition() const;
143 inline const OTypeInfoMap* getTypeInfo() const { return &m_aTypeInfo; }
145 inline TOTypeInfoSP getTypeInfo(sal_Int32 _nPos) const { return m_aTypeInfoIndex[_nPos]->second; }
146 TOTypeInfoSP getTypeInfoByType(sal_Int32 _nDataType) const;
148 inline TOTypeInfoSP getTypeInfoFallBack() const { return m_pTypeInfo; }
150 virtual sal_Bool Construct(Window* pParent);
151 // XEventListener
152 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
154 // ::com::sun::star::frame::XController
155 virtual sal_Bool SAL_CALL suspend(sal_Bool bSuspend) throw( ::com::sun::star::uno::RuntimeException );
157 // ::com::sun::star::lang::XComponent
158 virtual void SAL_CALL disposing();
160 // XServiceInfo
161 virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
162 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
163 // need by registration
164 static ::rtl::OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException );
165 static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
166 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
167 SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
170 virtual void Load(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxIn);
171 virtual void Save(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOut);
173 protected:
174 void startTableListening();
175 void stopTableListening();
176 virtual void impl_initialize();
179 #endif // DBUI_TABLECONTROLLER_HXX