xref: /aoo41x/main/sw/source/ui/inc/dbinsdlg.hxx (revision 1d2dbeb0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _DBINSDLG_HXX
25 #define _DBINSDLG_HXX
26 
27 
28 #ifndef _BUTTON_HXX //autogen
29 #include <vcl/button.hxx>
30 #endif
31 #ifndef _GROUP_HXX //autogen
32 #include <vcl/group.hxx>
33 #endif
34 #ifndef _FIXED_HXX //autogen
35 #include <vcl/fixed.hxx>
36 #endif
37 #ifndef _EDIT_HXX //autogen
38 #include <vcl/edit.hxx>
39 #endif
40 #include <vcl/lstbox.hxx>
41 #include <svtools/svmedit.hxx>
42 #include <sfx2/basedlgs.hxx>
43 #include <svl/svarray.hxx>
44 #include <unotools/configitem.hxx>
45 #include <numfmtlb.hxx>
46 #include <swdbdata.hxx>
47 #include <com/sun/star/uno/Reference.h>
48 #include <com/sun/star/uno/Sequence.h>
49 namespace com{namespace sun{namespace star{
50 	namespace sdbcx{
51 	class XColumnsSupplier;
52 	}
53 	namespace sdbc{
54 	class XDataSource;
55 	class XConnection;
56 	class XResultSet;
57 	}
58 }}}
59 
60 class SwTableAutoFmt;
61 class SwView;
62 class SfxItemSet;
63 class SwTableRep;
64 class _DB_Columns;
65 
66 struct SwInsDBColumn
67 {
68 	rtl::OUString sColumn, sUsrNumFmt;
69 	sal_Int32 nDBNumFmt;
70 	sal_uInt32 nUsrNumFmt;
71 	LanguageType eUsrNumFmtLng;
72 	sal_uInt16 nCol;
73 	sal_Bool bHasFmt : 1;
74 	sal_Bool bIsDBFmt : 1;
75 
SwInsDBColumnSwInsDBColumn76 	SwInsDBColumn( const String& rStr, sal_uInt16 nColumn )
77         : sColumn( rStr ),
78         nDBNumFmt( 0 ),
79         nUsrNumFmt( 0 ),
80         eUsrNumFmtLng( LANGUAGE_SYSTEM ),
81         nCol( nColumn ),
82         bHasFmt(sal_False),
83         bIsDBFmt(sal_True)
84 	{}
85 
operator ==SwInsDBColumn86 	int operator==( const SwInsDBColumn& rCmp ) const
87 		{ return sColumn == rCmp.sColumn; }
88 	int operator<( const SwInsDBColumn& rCmp ) const;
89 };
90 
91 typedef SwInsDBColumn* SwInsDBColumnPtr;
92 SV_DECL_PTRARR_SORT_DEL( SwInsDBColumns, SwInsDBColumnPtr, 32, 32 )
93 
94 
95 class SwInsertDBColAutoPilot : public SfxModalDialog, public utl::ConfigItem
96 {
97 	FixedText 		aFtInsertData;
98 	RadioButton 	aRbAsTable;
99 	RadioButton 	aRbAsField;
100 	RadioButton 	aRbAsText;
101 
102     FixedLine       aFlHead;
103 	FixedText 		aFtDbColumn;
104 
105 	ListBox 		aLbTblDbColumn;
106 	ListBox 		aLbTxtDbColumn;
107 
108     FixedLine       aFlFormat;
109 	RadioButton 	aRbDbFmtFromDb;
110 	RadioButton 	aRbDbFmtFromUsr;
111 	NumFormatListBox aLbDbFmtFromUsr;
112 
113 	/* ----- Page Text/Field ------- */
114     ImageButton     aIbDbcolToEdit;
115 	MultiLineEdit 	aEdDbText;
116 	FixedText 		aFtDbParaColl;
117 	ListBox 		aLbDbParaColl;
118 
119 	/* ----- Page Table ------------ */
120     ImageButton     aIbDbcolAllTo;
121     ImageButton     aIbDbcolOneTo;
122     ImageButton     aIbDbcolOneFrom;
123     ImageButton     aIbDbcolAllFrom;
124 	FixedText 		aFtTableCol;
125 	ListBox 		aLbTableCol;
126 	CheckBox 		aCbTableHeadon;
127 	RadioButton 	aRbHeadlColnms;
128 	RadioButton 	aRbHeadlEmpty;
129 	PushButton 		aPbTblFormat;
130 	PushButton 		aPbTblAutofmt;
131 
132 	OKButton 		aBtOk;
133 	CancelButton 	aBtCancel;
134 	HelpButton 		aBtHelp;
135 
136     FixedLine       aFlBottom;
137 
138     SwInsDBColumns  aDBColumns;
139 	const SwDBData	aDBData;
140 
141 	Link			aOldNumFmtLnk;
142 	String			sNoTmpl;
143 
144 	SwView* 		pView;
145 	SwTableAutoFmt*	pTAutoFmt;
146 
147 	SfxItemSet*		pTblSet;
148 	SwTableRep* 	pRep;
149 	sal_uInt16			nGBFmtLen;
150 
151 	DECL_LINK( PageHdl, Button* );
152 	DECL_LINK( AutoFmtHdl, PushButton* );
153 	DECL_LINK( TblFmtHdl, PushButton* );
154 	DECL_LINK( DBFormatHdl, Button* );
155 	DECL_LINK( TblToFromHdl, Button* );
156 	DECL_LINK( SelectHdl, ListBox* );
157 	DECL_LINK( DblClickHdl, ListBox* );
158 	DECL_LINK( HeaderHdl, Button* );
159 
160 	sal_Bool SplitTextToColArr( const String& rTxt, _DB_Columns& rColArr, sal_Bool bInsField );
161         using SfxModalDialog::Notify;
162 	virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
163 	virtual void			Commit();
164 	void 					Load();
165 
166 	// setze die Tabellen - Eigenschaften
167 	void SetTabSet();
168 
169 public:
170 	SwInsertDBColAutoPilot( SwView& rView,
171 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> rxSource,
172 		com::sun::star::uno::Reference<com::sun::star::sdbcx::XColumnsSupplier>,
173 		const SwDBData& rData  );
174 
175 	virtual ~SwInsertDBColAutoPilot();
176 
177     void DataToDoc( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rSelection,
178 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> rxSource,
179 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> xConnection,
180 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > xResultSet);
181 
182 };
183 
184 #endif
185