Line data Source code
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 :
20 : #ifndef _DBINSDLG_HXX
21 : #define _DBINSDLG_HXX
22 :
23 :
24 : #include <vcl/button.hxx>
25 : #include <vcl/group.hxx>
26 : #include <vcl/fixed.hxx>
27 : #include <vcl/edit.hxx>
28 : #include <vcl/lstbox.hxx>
29 : #include <svtools/svmedit.hxx>
30 : #include <sfx2/basedlgs.hxx>
31 : #include <unotools/configitem.hxx>
32 : #include <numfmtlb.hxx>
33 : #include <swdbdata.hxx>
34 : #include <com/sun/star/uno/Reference.h>
35 : #include <com/sun/star/uno/Sequence.h>
36 : #include <boost/ptr_container/ptr_vector.hpp>
37 : #include <o3tl/sorted_vector.hxx>
38 :
39 : namespace com{namespace sun{namespace star{
40 : namespace sdbcx{
41 : class XColumnsSupplier;
42 : }
43 : namespace sdbc{
44 : class XDataSource;
45 : class XConnection;
46 : class XResultSet;
47 : }
48 : }}}
49 :
50 : class SwTableAutoFmt;
51 : class SwView;
52 : class SfxItemSet;
53 : class SwTableRep;
54 : struct _DB_Column;
55 : typedef boost::ptr_vector<_DB_Column> _DB_Columns;
56 :
57 0 : struct SwInsDBColumn
58 : {
59 : rtl::OUString sColumn, sUsrNumFmt;
60 : sal_Int32 nDBNumFmt;
61 : sal_uInt32 nUsrNumFmt;
62 : LanguageType eUsrNumFmtLng;
63 : sal_uInt16 nCol;
64 : sal_Bool bHasFmt : 1;
65 : sal_Bool bIsDBFmt : 1;
66 :
67 0 : SwInsDBColumn( const String& rStr, sal_uInt16 nColumn )
68 : : sColumn( rStr ),
69 : nDBNumFmt( 0 ),
70 : nUsrNumFmt( 0 ),
71 : eUsrNumFmtLng( LANGUAGE_SYSTEM ),
72 : nCol( nColumn ),
73 : bHasFmt(sal_False),
74 0 : bIsDBFmt(sal_True)
75 0 : {}
76 :
77 : int operator==( const SwInsDBColumn& rCmp ) const
78 : { return sColumn == rCmp.sColumn; }
79 : int operator<( const SwInsDBColumn& rCmp ) const;
80 : };
81 :
82 0 : class SwInsDBColumns : public o3tl::sorted_vector<SwInsDBColumn*, o3tl::less_ptr_to<SwInsDBColumn> >
83 : {
84 : public:
85 0 : ~SwInsDBColumns() { DeleteAndDestroyAll(); }
86 : };
87 :
88 :
89 : class SwInsertDBColAutoPilot : public SfxModalDialog, public utl::ConfigItem
90 : {
91 : FixedText aFtInsertData;
92 : RadioButton aRbAsTable;
93 : RadioButton aRbAsField;
94 : RadioButton aRbAsText;
95 :
96 : FixedLine aFlHead;
97 : FixedText aFtDbColumn;
98 :
99 : ListBox aLbTblDbColumn;
100 : ListBox aLbTxtDbColumn;
101 :
102 : FixedLine aFlFormat;
103 : RadioButton aRbDbFmtFromDb;
104 : RadioButton aRbDbFmtFromUsr;
105 : NumFormatListBox aLbDbFmtFromUsr;
106 :
107 : /* ----- Page Text/Field ------- */
108 : ImageButton aIbDbcolToEdit;
109 : MultiLineEdit aEdDbText;
110 : FixedText aFtDbParaColl;
111 : ListBox aLbDbParaColl;
112 :
113 : /* ----- Page Table ------------ */
114 : ImageButton aIbDbcolAllTo;
115 : ImageButton aIbDbcolOneTo;
116 : ImageButton aIbDbcolOneFrom;
117 : ImageButton aIbDbcolAllFrom;
118 : FixedText aFtTableCol;
119 : ListBox aLbTableCol;
120 : CheckBox aCbTableHeadon;
121 : RadioButton aRbHeadlColnms;
122 : RadioButton aRbHeadlEmpty;
123 : PushButton aPbTblFormat;
124 : PushButton aPbTblAutofmt;
125 :
126 : OKButton aBtOk;
127 : CancelButton aBtCancel;
128 : HelpButton aBtHelp;
129 :
130 : FixedLine aFlBottom;
131 :
132 : SwInsDBColumns aDBColumns;
133 : const SwDBData aDBData;
134 :
135 : Link aOldNumFmtLnk;
136 : String sNoTmpl;
137 :
138 : SwView* pView;
139 : SwTableAutoFmt* pTAutoFmt;
140 :
141 : SfxItemSet* pTblSet;
142 : SwTableRep* pRep;
143 : sal_uInt16 nGBFmtLen;
144 :
145 : DECL_LINK( PageHdl, Button* );
146 : DECL_LINK( AutoFmtHdl, PushButton* );
147 : DECL_LINK( TblFmtHdl, PushButton* );
148 : DECL_LINK( DBFormatHdl, Button* );
149 : DECL_LINK( TblToFromHdl, Button* );
150 : DECL_LINK( SelectHdl, ListBox* );
151 : DECL_LINK( DblClickHdl, ListBox* );
152 : DECL_LINK( HeaderHdl, Button* );
153 :
154 : sal_Bool SplitTextToColArr( const String& rTxt, _DB_Columns& rColArr, sal_Bool bInsField );
155 : using SfxModalDialog::Notify;
156 : virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
157 : virtual void Commit();
158 : void Load();
159 :
160 : // set the tables - properties
161 : void SetTabSet();
162 :
163 : public:
164 : SwInsertDBColAutoPilot( SwView& rView,
165 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> rxSource,
166 : com::sun::star::uno::Reference<com::sun::star::sdbcx::XColumnsSupplier>,
167 : const SwDBData& rData );
168 :
169 : virtual ~SwInsertDBColAutoPilot();
170 :
171 : void DataToDoc( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rSelection,
172 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> rxSource,
173 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> xConnection,
174 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > xResultSet);
175 :
176 : };
177 :
178 : #endif
179 :
180 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|