1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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>
39 namespace com
{namespace sun
{namespace star
{
41 class XColumnsSupplier
;
55 typedef boost::ptr_vector
<_DB_Column
> _DB_Columns
;
59 OUString sColumn
, sUsrNumFmt
;
61 sal_uInt32 nUsrNumFmt
;
62 LanguageType eUsrNumFmtLng
;
65 sal_Bool bIsDBFmt
: 1;
67 SwInsDBColumn( const String
& rStr
, sal_uInt16 nColumn
)
71 eUsrNumFmtLng( LANGUAGE_SYSTEM
),
77 int operator==( const SwInsDBColumn
& rCmp
) const
78 { return sColumn
== rCmp
.sColumn
; }
79 int operator<( const SwInsDBColumn
& rCmp
) const;
82 class SwInsDBColumns
: public o3tl::sorted_vector
<SwInsDBColumn
*, o3tl::less_ptr_to
<SwInsDBColumn
> >
85 ~SwInsDBColumns() { DeleteAndDestroyAll(); }
89 class SwInsertDBColAutoPilot
: public SfxModalDialog
, public utl::ConfigItem
91 FixedText aFtInsertData
;
92 RadioButton aRbAsTable
;
93 RadioButton aRbAsField
;
94 RadioButton aRbAsText
;
97 FixedText aFtDbColumn
;
99 ListBox aLbTblDbColumn
;
100 ListBox aLbTxtDbColumn
;
103 RadioButton aRbDbFmtFromDb
;
104 RadioButton aRbDbFmtFromUsr
;
105 NumFormatListBox aLbDbFmtFromUsr
;
107 /* ----- Page Text/Field ------- */
108 ImageButton aIbDbcolToEdit
;
109 MultiLineEdit aEdDbText
;
110 FixedText aFtDbParaColl
;
111 ListBox aLbDbParaColl
;
113 /* ----- Page Table ------------ */
114 ImageButton aIbDbcolAllTo
;
115 ImageButton aIbDbcolOneTo
;
116 ImageButton aIbDbcolOneFrom
;
117 ImageButton aIbDbcolAllFrom
;
118 FixedText aFtTableCol
;
120 CheckBox aCbTableHeadon
;
121 RadioButton aRbHeadlColnms
;
122 RadioButton aRbHeadlEmpty
;
123 PushButton aPbTblFormat
;
124 PushButton aPbTblAutofmt
;
127 CancelButton aBtCancel
;
132 SwInsDBColumns aDBColumns
;
133 const SwDBData aDBData
;
139 SwTableAutoFmt
* pTAutoFmt
;
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
* );
154 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
< OUString
>& aPropertyNames
);
157 virtual void Commit();
160 // set the tables - properties
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
);
169 virtual ~SwInsertDBColAutoPilot();
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
);
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */