15900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
35900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
45900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file
55900e8ecSAndrew Rist * distributed with this work for additional information
65900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file
75900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the
85900e8ecSAndrew Rist * "License"); you may not use this file except in compliance
95900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at
105900e8ecSAndrew Rist *
115900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
125900e8ecSAndrew Rist *
135900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing,
145900e8ecSAndrew Rist * software distributed under the License is distributed on an
155900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165900e8ecSAndrew Rist * KIND, either express or implied. See the License for the
175900e8ecSAndrew Rist * specific language governing permissions and limitations
185900e8ecSAndrew Rist * under the License.
195900e8ecSAndrew Rist *
205900e8ecSAndrew Rist *************************************************************/
215900e8ecSAndrew Rist
225900e8ecSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <stdio.h>
28cdf0e10cSrcweir #include <svtools/addresstemplate.hxx>
29cdf0e10cSrcweir #include "addresstemplate.hrc"
30cdf0e10cSrcweir #include <svtools/svtools.hrc>
31cdf0e10cSrcweir #include <svtools/helpid.hrc>
32cdf0e10cSrcweir #include <svtools/svtdata.hxx>
33cdf0e10cSrcweir #include <tools/debug.hxx>
34cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
35cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
36cdf0e10cSrcweir #include <vcl/stdtext.hxx>
37cdf0e10cSrcweir #include <vcl/waitobj.hxx>
38cdf0e10cSrcweir #include <vcl/msgbox.hxx>
39cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
40cdf0e10cSrcweir #include <comphelper/extract.hxx>
41cdf0e10cSrcweir #include <comphelper/interaction.hxx>
42cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
43cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
44cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
45cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
46cdf0e10cSrcweir #include <com/sun/star/sdb/XCompletedConnection.hpp>
47cdf0e10cSrcweir #include <com/sun/star/sdb/SQLContext.hpp>
48cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLWarning.hpp>
49cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
50cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler.hpp>
51cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
52cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
53cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp>
54cdf0e10cSrcweir #include <svtools/localresaccess.hxx>
55cdf0e10cSrcweir #include "svl/filenotation.hxx"
56cdf0e10cSrcweir #include <tools/urlobj.hxx>
57cdf0e10cSrcweir #include <algorithm>
58cdf0e10cSrcweir
59cdf0e10cSrcweir // .......................................................................
60cdf0e10cSrcweir namespace svt
61cdf0e10cSrcweir {
62cdf0e10cSrcweir // .......................................................................
63cdf0e10cSrcweir
64cdf0e10cSrcweir using namespace ::com::sun::star::uno;
65cdf0e10cSrcweir using namespace ::com::sun::star::lang;
66cdf0e10cSrcweir using namespace ::com::sun::star::container;
67cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs;
68cdf0e10cSrcweir using namespace ::com::sun::star::util;
69cdf0e10cSrcweir using namespace ::com::sun::star::beans;
70cdf0e10cSrcweir using namespace ::com::sun::star::sdb;
71cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
72cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
73cdf0e10cSrcweir using namespace ::com::sun::star::task;
74cdf0e10cSrcweir using namespace ::comphelper;
75cdf0e10cSrcweir using namespace ::utl;
76cdf0e10cSrcweir
77cdf0e10cSrcweir DECLARE_STL_VECTOR( String, StringArray );
78cdf0e10cSrcweir DECLARE_STL_STDKEY_SET( ::rtl::OUString, StringBag );
79cdf0e10cSrcweir DECLARE_STL_USTRINGACCESS_MAP( ::rtl::OUString, MapString2String );
80cdf0e10cSrcweir
81cdf0e10cSrcweir namespace
82cdf0e10cSrcweir {
lcl_getSelectedDataSource(const ComboBox & _dataSourceCombo)83cdf0e10cSrcweir String lcl_getSelectedDataSource( const ComboBox& _dataSourceCombo )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir String selectedDataSource = _dataSourceCombo.GetText();
86cdf0e10cSrcweir if ( _dataSourceCombo.GetEntryPos( selectedDataSource ) == LISTBOX_ENTRY_NOTFOUND )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir // none of the pre-selected entries -> assume a path to a database document
89cdf0e10cSrcweir OFileNotation aFileNotation( selectedDataSource, OFileNotation::N_SYSTEM );
90cdf0e10cSrcweir selectedDataSource = aFileNotation.get( OFileNotation::N_URL );
91cdf0e10cSrcweir }
92cdf0e10cSrcweir return selectedDataSource;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir }
95cdf0e10cSrcweir
96cdf0e10cSrcweir // ===================================================================
97cdf0e10cSrcweir // = IAssigmentData
98cdf0e10cSrcweir // ===================================================================
99cdf0e10cSrcweir class IAssigmentData
100cdf0e10cSrcweir {
101cdf0e10cSrcweir public:
102cdf0e10cSrcweir virtual ~IAssigmentData();
103cdf0e10cSrcweir
104cdf0e10cSrcweir /// the data source to use for the address book
105cdf0e10cSrcweir virtual ::rtl::OUString getDatasourceName() const = 0;
106cdf0e10cSrcweir
107cdf0e10cSrcweir /// the command to use for the address book
108cdf0e10cSrcweir virtual ::rtl::OUString getCommand() const = 0;
109cdf0e10cSrcweir
110cdf0e10cSrcweir /** the command type to use for the address book
111cdf0e10cSrcweir @return
112cdf0e10cSrcweir a <type scope="com.sun.star.sdb">CommandType</type> value
113cdf0e10cSrcweir */
114cdf0e10cSrcweir virtual sal_Int32 getCommandType() const = 0;
115cdf0e10cSrcweir
116cdf0e10cSrcweir /// checks whether or not there is an assignment for a given logical field
117cdf0e10cSrcweir virtual sal_Bool hasFieldAssignment(const ::rtl::OUString& _rLogicalName) = 0;
118cdf0e10cSrcweir /// retrieves the assignment for a given logical field
119cdf0e10cSrcweir virtual ::rtl::OUString getFieldAssignment(const ::rtl::OUString& _rLogicalName) = 0;
120cdf0e10cSrcweir
121cdf0e10cSrcweir /// set the assignment for a given logical field
122cdf0e10cSrcweir virtual void setFieldAssignment(const ::rtl::OUString& _rLogicalName, const ::rtl::OUString& _rAssignment) = 0;
123cdf0e10cSrcweir /// clear the assignment for a given logical field
124cdf0e10cSrcweir virtual void clearFieldAssignment(const ::rtl::OUString& _rLogicalName) = 0;
125cdf0e10cSrcweir
126cdf0e10cSrcweir virtual void setDatasourceName(const ::rtl::OUString& _rName) = 0;
127cdf0e10cSrcweir virtual void setCommand(const ::rtl::OUString& _rCommand) = 0;
128cdf0e10cSrcweir };
129cdf0e10cSrcweir
130cdf0e10cSrcweir // -------------------------------------------------------------------
~IAssigmentData()131cdf0e10cSrcweir IAssigmentData::~IAssigmentData()
132cdf0e10cSrcweir {
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
135cdf0e10cSrcweir // ===================================================================
136cdf0e10cSrcweir // = AssigmentTransientData
137cdf0e10cSrcweir // ===================================================================
138cdf0e10cSrcweir class AssigmentTransientData : public IAssigmentData
139cdf0e10cSrcweir {
140cdf0e10cSrcweir protected:
141cdf0e10cSrcweir Reference< XDataSource > m_xDataSource;
142cdf0e10cSrcweir ::rtl::OUString m_sDSName;
143cdf0e10cSrcweir ::rtl::OUString m_sTableName;
144cdf0e10cSrcweir MapString2String m_aAliases;
145cdf0e10cSrcweir
146cdf0e10cSrcweir public:
147cdf0e10cSrcweir AssigmentTransientData(
148cdf0e10cSrcweir const Reference< XDataSource >& _rxDataSource,
149cdf0e10cSrcweir const ::rtl::OUString& _rDataSourceName,
150cdf0e10cSrcweir const ::rtl::OUString& _rTableName,
151cdf0e10cSrcweir const Sequence< AliasProgrammaticPair >& _rFields
152cdf0e10cSrcweir );
153cdf0e10cSrcweir
154cdf0e10cSrcweir // IAssigmentData overridables
155cdf0e10cSrcweir virtual ::rtl::OUString getDatasourceName() const;
156cdf0e10cSrcweir virtual ::rtl::OUString getCommand() const;
157cdf0e10cSrcweir virtual sal_Int32 getCommandType() const;
158cdf0e10cSrcweir
159cdf0e10cSrcweir virtual sal_Bool hasFieldAssignment(const ::rtl::OUString& _rLogicalName);
160cdf0e10cSrcweir virtual ::rtl::OUString getFieldAssignment(const ::rtl::OUString& _rLogicalName);
161cdf0e10cSrcweir virtual void setFieldAssignment(const ::rtl::OUString& _rLogicalName, const ::rtl::OUString& _rAssignment);
162cdf0e10cSrcweir virtual void clearFieldAssignment(const ::rtl::OUString& _rLogicalName);
163cdf0e10cSrcweir
164cdf0e10cSrcweir virtual void setDatasourceName(const ::rtl::OUString& _rName);
165cdf0e10cSrcweir virtual void setCommand(const ::rtl::OUString& _rCommand);
166cdf0e10cSrcweir };
167cdf0e10cSrcweir
168cdf0e10cSrcweir // -------------------------------------------------------------------
AssigmentTransientData(const Reference<XDataSource> & _rxDataSource,const::rtl::OUString & _rDataSourceName,const::rtl::OUString & _rTableName,const Sequence<AliasProgrammaticPair> & _rFields)169cdf0e10cSrcweir AssigmentTransientData::AssigmentTransientData( const Reference< XDataSource >& _rxDataSource,
170cdf0e10cSrcweir const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rTableName,
171cdf0e10cSrcweir const Sequence< AliasProgrammaticPair >& _rFields )
172cdf0e10cSrcweir :m_xDataSource( _rxDataSource )
173cdf0e10cSrcweir ,m_sDSName( _rDataSourceName )
174cdf0e10cSrcweir ,m_sTableName( _rTableName )
175cdf0e10cSrcweir {
176cdf0e10cSrcweir // fill our aliaes structure
177cdf0e10cSrcweir // first collect all known programmatic names
178cdf0e10cSrcweir StringBag aKnownNames;
179cdf0e10cSrcweir
180cdf0e10cSrcweir String sLogicalFieldNames( SvtResId( STR_LOCAGICAL_FIELD_NAMES ) );
181cdf0e10cSrcweir sal_Int32 nTokenCount = sLogicalFieldNames.GetTokenCount(';');
182cdf0e10cSrcweir for (sal_Int32 i = 0; i<nTokenCount; ++i)
183cdf0e10cSrcweir aKnownNames.insert(sLogicalFieldNames.GetToken((sal_uInt16)i, ';'));
184cdf0e10cSrcweir
185cdf0e10cSrcweir // loop throuzh the given names
186cdf0e10cSrcweir const AliasProgrammaticPair* pFields = _rFields.getConstArray();
187f1d3244eSDamjan Jovanovic const AliasProgrammaticPair* pEnd = pFields + _rFields.getLength();
188f1d3244eSDamjan Jovanovic for (;pFields != pEnd; ++pFields)
189cdf0e10cSrcweir {
190cdf0e10cSrcweir StringBagIterator aKnownPos = aKnownNames.find( pFields->ProgrammaticName );
191cdf0e10cSrcweir if ( aKnownNames.end() != aKnownPos )
192cdf0e10cSrcweir {
193cdf0e10cSrcweir m_aAliases[ pFields->ProgrammaticName ] = pFields->Alias;
194cdf0e10cSrcweir }
195cdf0e10cSrcweir else
196cdf0e10cSrcweir {
197cdf0e10cSrcweir DBG_ERROR ( ( ::rtl::OString("AssigmentTransientData::AssigmentTransientData: unknown programmatic name (")
198cdf0e10cSrcweir += ::rtl::OString(pFields->ProgrammaticName.getStr(), pFields->ProgrammaticName.getLength(), RTL_TEXTENCODING_ASCII_US)
199cdf0e10cSrcweir += ::rtl::OString(")!")
200cdf0e10cSrcweir ).getStr()
201cdf0e10cSrcweir );
202cdf0e10cSrcweir }
203cdf0e10cSrcweir }
204cdf0e10cSrcweir }
205cdf0e10cSrcweir
206cdf0e10cSrcweir // -------------------------------------------------------------------
getDatasourceName() const207cdf0e10cSrcweir ::rtl::OUString AssigmentTransientData::getDatasourceName() const
208cdf0e10cSrcweir {
209cdf0e10cSrcweir return m_sDSName;
210cdf0e10cSrcweir }
211cdf0e10cSrcweir
212cdf0e10cSrcweir // -------------------------------------------------------------------
getCommand() const213cdf0e10cSrcweir ::rtl::OUString AssigmentTransientData::getCommand() const
214cdf0e10cSrcweir {
215cdf0e10cSrcweir return m_sTableName;
216cdf0e10cSrcweir }
217cdf0e10cSrcweir
218cdf0e10cSrcweir // -------------------------------------------------------------------
getCommandType() const219cdf0e10cSrcweir sal_Int32 AssigmentTransientData::getCommandType() const
220cdf0e10cSrcweir {
221cdf0e10cSrcweir return CommandType::TABLE;
222cdf0e10cSrcweir }
223cdf0e10cSrcweir
224cdf0e10cSrcweir // -------------------------------------------------------------------
hasFieldAssignment(const::rtl::OUString & _rLogicalName)225cdf0e10cSrcweir sal_Bool AssigmentTransientData::hasFieldAssignment(const ::rtl::OUString& _rLogicalName)
226cdf0e10cSrcweir {
227cdf0e10cSrcweir ConstMapString2StringIterator aPos = m_aAliases.find( _rLogicalName );
228cdf0e10cSrcweir return ( m_aAliases.end() != aPos )
229cdf0e10cSrcweir && ( aPos->second.getLength() );
230cdf0e10cSrcweir }
231cdf0e10cSrcweir
232cdf0e10cSrcweir // -------------------------------------------------------------------
getFieldAssignment(const::rtl::OUString & _rLogicalName)233cdf0e10cSrcweir ::rtl::OUString AssigmentTransientData::getFieldAssignment(const ::rtl::OUString& _rLogicalName)
234cdf0e10cSrcweir {
235cdf0e10cSrcweir ::rtl::OUString sReturn;
236cdf0e10cSrcweir ConstMapString2StringIterator aPos = m_aAliases.find( _rLogicalName );
237cdf0e10cSrcweir if ( m_aAliases.end() != aPos )
238cdf0e10cSrcweir sReturn = aPos->second;
239cdf0e10cSrcweir
240cdf0e10cSrcweir return sReturn;
241cdf0e10cSrcweir }
242cdf0e10cSrcweir
243cdf0e10cSrcweir // -------------------------------------------------------------------
setFieldAssignment(const::rtl::OUString & _rLogicalName,const::rtl::OUString & _rAssignment)244cdf0e10cSrcweir void AssigmentTransientData::setFieldAssignment(const ::rtl::OUString& _rLogicalName, const ::rtl::OUString& _rAssignment)
245cdf0e10cSrcweir {
246cdf0e10cSrcweir m_aAliases[ _rLogicalName ] = _rAssignment;
247cdf0e10cSrcweir }
248cdf0e10cSrcweir
249cdf0e10cSrcweir // -------------------------------------------------------------------
clearFieldAssignment(const::rtl::OUString & _rLogicalName)250cdf0e10cSrcweir void AssigmentTransientData::clearFieldAssignment(const ::rtl::OUString& _rLogicalName)
251cdf0e10cSrcweir {
252cdf0e10cSrcweir MapString2StringIterator aPos = m_aAliases.find( _rLogicalName );
253cdf0e10cSrcweir if ( m_aAliases.end() != aPos )
254cdf0e10cSrcweir m_aAliases.erase( aPos );
255cdf0e10cSrcweir }
256cdf0e10cSrcweir
257cdf0e10cSrcweir // -------------------------------------------------------------------
setDatasourceName(const::rtl::OUString &)258cdf0e10cSrcweir void AssigmentTransientData::setDatasourceName(const ::rtl::OUString&)
259cdf0e10cSrcweir {
260cdf0e10cSrcweir DBG_ERROR( "AssigmentTransientData::setDatasourceName: cannot be implemented for transient data!" );
261cdf0e10cSrcweir }
262cdf0e10cSrcweir
263cdf0e10cSrcweir // -------------------------------------------------------------------
setCommand(const::rtl::OUString &)264cdf0e10cSrcweir void AssigmentTransientData::setCommand(const ::rtl::OUString&)
265cdf0e10cSrcweir {
266cdf0e10cSrcweir DBG_ERROR( "AssigmentTransientData::setCommand: cannot be implemented for transient data!" );
267cdf0e10cSrcweir }
268cdf0e10cSrcweir
269cdf0e10cSrcweir // ===================================================================
270cdf0e10cSrcweir // = AssignmentPersistentData
271cdf0e10cSrcweir // ===================================================================
272cdf0e10cSrcweir class AssignmentPersistentData
273cdf0e10cSrcweir :public ::utl::ConfigItem
274cdf0e10cSrcweir ,public IAssigmentData
275cdf0e10cSrcweir {
276cdf0e10cSrcweir protected:
277cdf0e10cSrcweir StringBag m_aStoredFields;
278cdf0e10cSrcweir
279cdf0e10cSrcweir protected:
280cdf0e10cSrcweir ::com::sun::star::uno::Any
281cdf0e10cSrcweir getProperty(const ::rtl::OUString& _rLocalName) const;
282cdf0e10cSrcweir ::com::sun::star::uno::Any
283cdf0e10cSrcweir getProperty(const sal_Char* _pLocalName) const;
284cdf0e10cSrcweir
285cdf0e10cSrcweir ::rtl::OUString getStringProperty(const sal_Char* _pLocalName) const;
286cdf0e10cSrcweir sal_Int32 getInt32Property(const sal_Char* _pLocalName) const;
287cdf0e10cSrcweir
288cdf0e10cSrcweir ::rtl::OUString getStringProperty(const ::rtl::OUString& _rLocalName) const;
289cdf0e10cSrcweir
290cdf0e10cSrcweir void setStringProperty(const sal_Char* _pLocalName, const ::rtl::OUString& _rValue);
291cdf0e10cSrcweir
292cdf0e10cSrcweir public:
293cdf0e10cSrcweir AssignmentPersistentData();
294cdf0e10cSrcweir ~AssignmentPersistentData();
295cdf0e10cSrcweir
296cdf0e10cSrcweir // IAssigmentData overridables
297cdf0e10cSrcweir virtual ::rtl::OUString getDatasourceName() const;
298cdf0e10cSrcweir virtual ::rtl::OUString getCommand() const;
299cdf0e10cSrcweir virtual sal_Int32 getCommandType() const;
300cdf0e10cSrcweir
301cdf0e10cSrcweir virtual sal_Bool hasFieldAssignment(const ::rtl::OUString& _rLogicalName);
302cdf0e10cSrcweir virtual ::rtl::OUString getFieldAssignment(const ::rtl::OUString& _rLogicalName);
303cdf0e10cSrcweir virtual void setFieldAssignment(const ::rtl::OUString& _rLogicalName, const ::rtl::OUString& _rAssignment);
304cdf0e10cSrcweir virtual void clearFieldAssignment(const ::rtl::OUString& _rLogicalName);
305cdf0e10cSrcweir
306cdf0e10cSrcweir virtual void setDatasourceName(const ::rtl::OUString& _rName);
307cdf0e10cSrcweir virtual void setCommand(const ::rtl::OUString& _rCommand);
308cdf0e10cSrcweir
309cdf0e10cSrcweir virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames);
310cdf0e10cSrcweir virtual void Commit();
311cdf0e10cSrcweir };
312cdf0e10cSrcweir
313cdf0e10cSrcweir
Notify(const com::sun::star::uno::Sequence<rtl::OUString> &)314cdf0e10cSrcweir void AssignmentPersistentData::Notify( const com::sun::star::uno::Sequence<rtl::OUString>& )
315cdf0e10cSrcweir {
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
Commit()318cdf0e10cSrcweir void AssignmentPersistentData::Commit()
319cdf0e10cSrcweir {
320cdf0e10cSrcweir }
321cdf0e10cSrcweir
322cdf0e10cSrcweir // -------------------------------------------------------------------
AssignmentPersistentData()323cdf0e10cSrcweir AssignmentPersistentData::AssignmentPersistentData()
324cdf0e10cSrcweir :ConfigItem( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Office.DataAccess/AddressBook" )))
325cdf0e10cSrcweir {
326cdf0e10cSrcweir Sequence< ::rtl::OUString > aStoredNames = GetNodeNames(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fields")));
327cdf0e10cSrcweir const ::rtl::OUString* pStoredNames = aStoredNames.getConstArray();
328cdf0e10cSrcweir for (sal_Int32 i=0; i<aStoredNames.getLength(); ++i, ++pStoredNames)
329cdf0e10cSrcweir m_aStoredFields.insert(*pStoredNames);
330cdf0e10cSrcweir }
331cdf0e10cSrcweir
332cdf0e10cSrcweir // -------------------------------------------------------------------
~AssignmentPersistentData()333cdf0e10cSrcweir AssignmentPersistentData::~AssignmentPersistentData()
334cdf0e10cSrcweir {
335cdf0e10cSrcweir }
336cdf0e10cSrcweir
337cdf0e10cSrcweir // -------------------------------------------------------------------
hasFieldAssignment(const::rtl::OUString & _rLogicalName)338cdf0e10cSrcweir sal_Bool AssignmentPersistentData::hasFieldAssignment(const ::rtl::OUString& _rLogicalName)
339cdf0e10cSrcweir {
340cdf0e10cSrcweir return (m_aStoredFields.end() != m_aStoredFields.find(_rLogicalName));
341cdf0e10cSrcweir }
342cdf0e10cSrcweir
343cdf0e10cSrcweir // -------------------------------------------------------------------
getFieldAssignment(const::rtl::OUString & _rLogicalName)344cdf0e10cSrcweir ::rtl::OUString AssignmentPersistentData::getFieldAssignment(const ::rtl::OUString& _rLogicalName)
345cdf0e10cSrcweir {
346cdf0e10cSrcweir ::rtl::OUString sAssignment;
347cdf0e10cSrcweir if (hasFieldAssignment(_rLogicalName))
348cdf0e10cSrcweir {
349cdf0e10cSrcweir ::rtl::OUString sFieldPath(RTL_CONSTASCII_USTRINGPARAM("Fields/"));
350cdf0e10cSrcweir sFieldPath += _rLogicalName;
351cdf0e10cSrcweir sFieldPath += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/AssignedFieldName"));
352cdf0e10cSrcweir sAssignment = getStringProperty(sFieldPath);
353cdf0e10cSrcweir }
354cdf0e10cSrcweir return sAssignment;
355cdf0e10cSrcweir }
356cdf0e10cSrcweir
357cdf0e10cSrcweir // -------------------------------------------------------------------
getProperty(const sal_Char * _pLocalName) const358cdf0e10cSrcweir Any AssignmentPersistentData::getProperty(const sal_Char* _pLocalName) const
359cdf0e10cSrcweir {
360cdf0e10cSrcweir return getProperty(::rtl::OUString::createFromAscii(_pLocalName));
361cdf0e10cSrcweir }
362cdf0e10cSrcweir
363cdf0e10cSrcweir // -------------------------------------------------------------------
getProperty(const::rtl::OUString & _rLocalName) const364cdf0e10cSrcweir Any AssignmentPersistentData::getProperty(const ::rtl::OUString& _rLocalName) const
365cdf0e10cSrcweir {
366cdf0e10cSrcweir Sequence< ::rtl::OUString > aProperties(&_rLocalName, 1);
367cdf0e10cSrcweir Sequence< Any > aValues = const_cast<AssignmentPersistentData*>(this)->GetProperties(aProperties);
368cdf0e10cSrcweir DBG_ASSERT(aValues.getLength() == 1, "AssignmentPersistentData::getProperty: invalid sequence length!");
369cdf0e10cSrcweir return aValues[0];
370cdf0e10cSrcweir }
371cdf0e10cSrcweir
372cdf0e10cSrcweir // -------------------------------------------------------------------
getStringProperty(const::rtl::OUString & _rLocalName) const373cdf0e10cSrcweir ::rtl::OUString AssignmentPersistentData::getStringProperty(const ::rtl::OUString& _rLocalName) const
374cdf0e10cSrcweir {
375cdf0e10cSrcweir ::rtl::OUString sReturn;
376cdf0e10cSrcweir getProperty( _rLocalName ) >>= sReturn;
377cdf0e10cSrcweir return sReturn;
378cdf0e10cSrcweir }
379cdf0e10cSrcweir
380cdf0e10cSrcweir // -------------------------------------------------------------------
getStringProperty(const sal_Char * _pLocalName) const381cdf0e10cSrcweir ::rtl::OUString AssignmentPersistentData::getStringProperty(const sal_Char* _pLocalName) const
382cdf0e10cSrcweir {
383cdf0e10cSrcweir ::rtl::OUString sReturn;
384cdf0e10cSrcweir getProperty( _pLocalName ) >>= sReturn;
385cdf0e10cSrcweir return sReturn;
386cdf0e10cSrcweir }
387cdf0e10cSrcweir
388cdf0e10cSrcweir // -------------------------------------------------------------------
getInt32Property(const sal_Char * _pLocalName) const389cdf0e10cSrcweir sal_Int32 AssignmentPersistentData::getInt32Property(const sal_Char* _pLocalName) const
390cdf0e10cSrcweir {
391cdf0e10cSrcweir sal_Int32 nReturn = 0;
392cdf0e10cSrcweir getProperty( _pLocalName ) >>= nReturn;
393cdf0e10cSrcweir return nReturn;
394cdf0e10cSrcweir }
395cdf0e10cSrcweir
396cdf0e10cSrcweir // -------------------------------------------------------------------
setStringProperty(const sal_Char * _pLocalName,const::rtl::OUString & _rValue)397cdf0e10cSrcweir void AssignmentPersistentData::setStringProperty(const sal_Char* _pLocalName, const ::rtl::OUString& _rValue)
398cdf0e10cSrcweir {
399cdf0e10cSrcweir Sequence< ::rtl::OUString > aNames(1);
400cdf0e10cSrcweir Sequence< Any > aValues(1);
401cdf0e10cSrcweir aNames[0] = ::rtl::OUString::createFromAscii(_pLocalName);
402cdf0e10cSrcweir aValues[0] <<= _rValue;
403cdf0e10cSrcweir PutProperties(aNames, aValues);
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
406cdf0e10cSrcweir // -------------------------------------------------------------------
setFieldAssignment(const::rtl::OUString & _rLogicalName,const::rtl::OUString & _rAssignment)407cdf0e10cSrcweir void AssignmentPersistentData::setFieldAssignment(const ::rtl::OUString& _rLogicalName, const ::rtl::OUString& _rAssignment)
408cdf0e10cSrcweir {
409cdf0e10cSrcweir if (!_rAssignment.getLength())
410cdf0e10cSrcweir {
411cdf0e10cSrcweir if (hasFieldAssignment(_rLogicalName))
412cdf0e10cSrcweir // the assignment exists but it should be reset
413cdf0e10cSrcweir clearFieldAssignment(_rLogicalName);
414cdf0e10cSrcweir return;
415cdf0e10cSrcweir }
416cdf0e10cSrcweir
417cdf0e10cSrcweir // Fields
418cdf0e10cSrcweir ::rtl::OUString sDescriptionNodePath(RTL_CONSTASCII_USTRINGPARAM("Fields"));
419cdf0e10cSrcweir
420cdf0e10cSrcweir // Fields/<field>
421cdf0e10cSrcweir ::rtl::OUString sFieldElementNodePath(sDescriptionNodePath);
422cdf0e10cSrcweir sFieldElementNodePath += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
423cdf0e10cSrcweir sFieldElementNodePath += _rLogicalName;
424cdf0e10cSrcweir
425cdf0e10cSrcweir Sequence< PropertyValue > aNewFieldDescription(2);
426cdf0e10cSrcweir // Fields/<field>/ProgrammaticFieldName
427cdf0e10cSrcweir aNewFieldDescription[0].Name = sFieldElementNodePath;
428cdf0e10cSrcweir aNewFieldDescription[0].Name += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/ProgrammaticFieldName"));
429cdf0e10cSrcweir aNewFieldDescription[0].Value <<= _rLogicalName;
430cdf0e10cSrcweir // Fields/<field>/AssignedFieldName
431cdf0e10cSrcweir aNewFieldDescription[1].Name = sFieldElementNodePath;
432cdf0e10cSrcweir aNewFieldDescription[1].Name += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/AssignedFieldName"));
433cdf0e10cSrcweir aNewFieldDescription[1].Value <<= _rAssignment;
434cdf0e10cSrcweir
435cdf0e10cSrcweir // just set the new value
436cdf0e10cSrcweir #ifdef DBG_UTIL
437cdf0e10cSrcweir sal_Bool bSuccess =
438cdf0e10cSrcweir #endif
439cdf0e10cSrcweir SetSetProperties(sDescriptionNodePath, aNewFieldDescription);
440cdf0e10cSrcweir DBG_ASSERT(bSuccess, "AssignmentPersistentData::setFieldAssignment: could not commit the changes a field!");
441cdf0e10cSrcweir }
442cdf0e10cSrcweir
443cdf0e10cSrcweir // -------------------------------------------------------------------
clearFieldAssignment(const::rtl::OUString & _rLogicalName)444cdf0e10cSrcweir void AssignmentPersistentData::clearFieldAssignment(const ::rtl::OUString& _rLogicalName)
445cdf0e10cSrcweir {
446cdf0e10cSrcweir if (!hasFieldAssignment(_rLogicalName))
447cdf0e10cSrcweir // nothing to do
448cdf0e10cSrcweir return;
449cdf0e10cSrcweir
450cdf0e10cSrcweir ::rtl::OUString sDescriptionNodePath(RTL_CONSTASCII_USTRINGPARAM("Fields"));
451cdf0e10cSrcweir Sequence< ::rtl::OUString > aNames(&_rLogicalName, 1);
452cdf0e10cSrcweir ClearNodeElements(sDescriptionNodePath, aNames);
453cdf0e10cSrcweir }
454cdf0e10cSrcweir
455cdf0e10cSrcweir // -------------------------------------------------------------------
getDatasourceName() const456cdf0e10cSrcweir ::rtl::OUString AssignmentPersistentData::getDatasourceName() const
457cdf0e10cSrcweir {
458cdf0e10cSrcweir return getStringProperty( "DataSourceName" );
459cdf0e10cSrcweir }
460cdf0e10cSrcweir
461cdf0e10cSrcweir // -------------------------------------------------------------------
getCommand() const462cdf0e10cSrcweir ::rtl::OUString AssignmentPersistentData::getCommand() const
463cdf0e10cSrcweir {
464cdf0e10cSrcweir return getStringProperty( "Command" );
465cdf0e10cSrcweir }
466cdf0e10cSrcweir
467cdf0e10cSrcweir // -------------------------------------------------------------------
setDatasourceName(const::rtl::OUString & _rName)468cdf0e10cSrcweir void AssignmentPersistentData::setDatasourceName(const ::rtl::OUString& _rName)
469cdf0e10cSrcweir {
470cdf0e10cSrcweir setStringProperty( "DataSourceName", _rName );
471cdf0e10cSrcweir }
472cdf0e10cSrcweir
473cdf0e10cSrcweir // -------------------------------------------------------------------
setCommand(const::rtl::OUString & _rCommand)474cdf0e10cSrcweir void AssignmentPersistentData::setCommand(const ::rtl::OUString& _rCommand)
475cdf0e10cSrcweir {
476cdf0e10cSrcweir setStringProperty( "Command", _rCommand );
477cdf0e10cSrcweir }
478cdf0e10cSrcweir
479cdf0e10cSrcweir // -------------------------------------------------------------------
getCommandType() const480cdf0e10cSrcweir sal_Int32 AssignmentPersistentData::getCommandType() const
481cdf0e10cSrcweir {
482cdf0e10cSrcweir return getInt32Property( "CommandType" );
483cdf0e10cSrcweir }
484cdf0e10cSrcweir
485cdf0e10cSrcweir // ===================================================================
486cdf0e10cSrcweir // = AddressBookSourceDialogData
487cdf0e10cSrcweir // ===================================================================
488cdf0e10cSrcweir struct AddressBookSourceDialogData
489cdf0e10cSrcweir {
490cdf0e10cSrcweir FixedText* pFieldLabels[FIELD_PAIRS_VISIBLE * 2];
491cdf0e10cSrcweir ListBox* pFields[FIELD_PAIRS_VISIBLE * 2];
492cdf0e10cSrcweir
493cdf0e10cSrcweir /// when working transient, we need the data source
494cdf0e10cSrcweir Reference< XDataSource >
495cdf0e10cSrcweir m_xTransientDataSource;
496cdf0e10cSrcweir /// current scroll pos in the field list
497cdf0e10cSrcweir sal_Int32 nFieldScrollPos;
498cdf0e10cSrcweir /// the index within m_pFields of the last visible list box. This is redundant, it could be extracted from other members
499cdf0e10cSrcweir sal_Int32 nLastVisibleListIndex;
500cdf0e10cSrcweir /// indicates that we've an odd field number. This member is for efficiency only, it's redundant.
501cdf0e10cSrcweir sal_Bool bOddFieldNumber : 1;
502cdf0e10cSrcweir /// indicates that we're working with the real persistent configuration
503cdf0e10cSrcweir sal_Bool bWorkingPersistent : 1;
504cdf0e10cSrcweir
505cdf0e10cSrcweir /// the strings to use as labels for the field selection listboxes
506cdf0e10cSrcweir StringArray aFieldLabels;
507cdf0e10cSrcweir // the current field assignment
508cdf0e10cSrcweir StringArray aFieldAssignments;
509cdf0e10cSrcweir /// the logical field names
510cdf0e10cSrcweir StringArray aLogicalFieldNames;
511cdf0e10cSrcweir
512cdf0e10cSrcweir IAssigmentData* pConfigData;
513cdf0e10cSrcweir
514cdf0e10cSrcweir // ................................................................
AddressBookSourceDialogDatasvt::AddressBookSourceDialogData515cdf0e10cSrcweir AddressBookSourceDialogData( )
516cdf0e10cSrcweir :nFieldScrollPos(0)
517cdf0e10cSrcweir ,nLastVisibleListIndex(0)
518cdf0e10cSrcweir ,bOddFieldNumber(sal_False)
519cdf0e10cSrcweir ,bWorkingPersistent( sal_True )
520cdf0e10cSrcweir ,pConfigData( new AssignmentPersistentData )
521cdf0e10cSrcweir {
522cdf0e10cSrcweir }
523cdf0e10cSrcweir
524cdf0e10cSrcweir // ................................................................
AddressBookSourceDialogDatasvt::AddressBookSourceDialogData525cdf0e10cSrcweir AddressBookSourceDialogData( const Reference< XDataSource >& _rxTransientDS, const ::rtl::OUString& _rDataSourceName,
526cdf0e10cSrcweir const ::rtl::OUString& _rTableName, const Sequence< AliasProgrammaticPair >& _rFields )
527cdf0e10cSrcweir :m_xTransientDataSource( _rxTransientDS )
528cdf0e10cSrcweir ,nFieldScrollPos(0)
529cdf0e10cSrcweir ,nLastVisibleListIndex(0)
530cdf0e10cSrcweir ,bOddFieldNumber(sal_False)
531cdf0e10cSrcweir ,bWorkingPersistent( sal_False )
532cdf0e10cSrcweir ,pConfigData( new AssigmentTransientData( m_xTransientDataSource, _rDataSourceName, _rTableName, _rFields ) )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir }
535cdf0e10cSrcweir
~AddressBookSourceDialogDatasvt::AddressBookSourceDialogData536cdf0e10cSrcweir ~AddressBookSourceDialogData()
537cdf0e10cSrcweir {
538cdf0e10cSrcweir delete pConfigData;
539cdf0e10cSrcweir }
540cdf0e10cSrcweir
541cdf0e10cSrcweir };
542cdf0e10cSrcweir
543cdf0e10cSrcweir // ===================================================================
544cdf0e10cSrcweir // = AddressBookSourceDialog
545cdf0e10cSrcweir // ===================================================================
546cdf0e10cSrcweir #define INIT_FIELDS() \
547cdf0e10cSrcweir ModalDialog(_pParent, SvtResId( DLG_ADDRESSBOOKSOURCE ))\
548cdf0e10cSrcweir ,m_aDatasourceFrame (this, SvtResId(FL_DATASOURCEFRAME))\
549cdf0e10cSrcweir ,m_aDatasourceLabel (this, SvtResId(FT_DATASOURCE))\
550cdf0e10cSrcweir ,m_aDatasource (this, SvtResId(CB_DATASOURCE))\
551cdf0e10cSrcweir ,m_aAdministrateDatasources (this, SvtResId(PB_ADMINISTATE_DATASOURCES))\
552cdf0e10cSrcweir ,m_aTableLabel (this, SvtResId(FT_TABLE))\
553cdf0e10cSrcweir ,m_aTable (this, SvtResId(CB_TABLE))\
554cdf0e10cSrcweir ,m_aFieldsTitle (this, SvtResId(FT_FIELDS))\
555cdf0e10cSrcweir ,m_aFieldsFrame (this, SvtResId(CT_BORDER))\
556cdf0e10cSrcweir ,m_aFieldScroller (&m_aFieldsFrame, SvtResId(SB_FIELDSCROLLER))\
557cdf0e10cSrcweir ,m_aOK (this, SvtResId(PB_OK))\
558cdf0e10cSrcweir ,m_aCancel (this, SvtResId(PB_CANCEL))\
559cdf0e10cSrcweir ,m_aHelp (this, SvtResId(PB_HELP))\
560cdf0e10cSrcweir ,m_sNoFieldSelection(SvtResId(STR_NO_FIELD_SELECTION))\
561cdf0e10cSrcweir ,m_xORB(_rxORB)
562cdf0e10cSrcweir
563cdf0e10cSrcweir // -------------------------------------------------------------------
AddressBookSourceDialog(Window * _pParent,const Reference<XMultiServiceFactory> & _rxORB)564cdf0e10cSrcweir AddressBookSourceDialog::AddressBookSourceDialog(Window* _pParent,
565cdf0e10cSrcweir const Reference< XMultiServiceFactory >& _rxORB )
566cdf0e10cSrcweir :INIT_FIELDS()
567cdf0e10cSrcweir ,m_pImpl( new AddressBookSourceDialogData )
568cdf0e10cSrcweir {
569cdf0e10cSrcweir implConstruct();
570cdf0e10cSrcweir }
571cdf0e10cSrcweir
572cdf0e10cSrcweir // -------------------------------------------------------------------
AddressBookSourceDialog(Window * _pParent,const Reference<XMultiServiceFactory> & _rxORB,const Reference<XDataSource> & _rxTransientDS,const::rtl::OUString & _rDataSourceName,const::rtl::OUString & _rTable,const Sequence<AliasProgrammaticPair> & _rMapping)573cdf0e10cSrcweir AddressBookSourceDialog::AddressBookSourceDialog( Window* _pParent, const Reference< XMultiServiceFactory >& _rxORB,
574cdf0e10cSrcweir const Reference< XDataSource >& _rxTransientDS, const ::rtl::OUString& _rDataSourceName,
575cdf0e10cSrcweir const ::rtl::OUString& _rTable, const Sequence< AliasProgrammaticPair >& _rMapping )
576cdf0e10cSrcweir :INIT_FIELDS()
577cdf0e10cSrcweir ,m_pImpl( new AddressBookSourceDialogData( _rxTransientDS, _rDataSourceName, _rTable, _rMapping ) )
578cdf0e10cSrcweir {
579cdf0e10cSrcweir implConstruct();
580cdf0e10cSrcweir }
581cdf0e10cSrcweir
582cdf0e10cSrcweir // -------------------------------------------------------------------
implConstruct()583cdf0e10cSrcweir void AddressBookSourceDialog::implConstruct()
584cdf0e10cSrcweir {
585cdf0e10cSrcweir for (sal_Int32 row=0; row<FIELD_PAIRS_VISIBLE; ++row)
586cdf0e10cSrcweir {
587cdf0e10cSrcweir for (sal_Int32 column=0; column<2; ++column)
588cdf0e10cSrcweir {
589cdf0e10cSrcweir // the label
590cdf0e10cSrcweir m_pImpl->pFieldLabels[row * 2 + column] = new FixedText(&m_aFieldsFrame, SvtResId((sal_uInt16)(FT_FIELD_BASE + row * 2 + column)));
591cdf0e10cSrcweir // the listbox
592cdf0e10cSrcweir m_pImpl->pFields[row * 2 + column] = new ListBox(&m_aFieldsFrame, SvtResId((sal_uInt16)(LB_FIELD_BASE + row * 2 + column)));
593cdf0e10cSrcweir m_pImpl->pFields[row * 2 + column]->SetDropDownLineCount(15);
594cdf0e10cSrcweir m_pImpl->pFields[row * 2 + column]->SetSelectHdl(LINK(this, AddressBookSourceDialog, OnFieldSelect));
595cdf0e10cSrcweir
596cdf0e10cSrcweir m_pImpl->pFields[row * 2 + column]->SetHelpId(HID_ADDRTEMPL_FIELD_ASSIGNMENT);
597cdf0e10cSrcweir }
598cdf0e10cSrcweir }
599cdf0e10cSrcweir
600cdf0e10cSrcweir m_aFieldsFrame.SetStyle((m_aFieldsFrame.GetStyle() | WB_TABSTOP | WB_DIALOGCONTROL) & ~WB_NODIALOGCONTROL);
601cdf0e10cSrcweir
602cdf0e10cSrcweir // correct the z-order
603cdf0e10cSrcweir m_aFieldScroller.SetZOrder(m_pImpl->pFields[FIELD_CONTROLS_VISIBLE - 1], WINDOW_ZORDER_BEHIND);
604cdf0e10cSrcweir m_aOK.SetZOrder(&m_aFieldsFrame, WINDOW_ZORDER_BEHIND);
605cdf0e10cSrcweir m_aCancel.SetZOrder(&m_aOK, WINDOW_ZORDER_BEHIND);
606cdf0e10cSrcweir
607cdf0e10cSrcweir initializeDatasources();
608cdf0e10cSrcweir
609cdf0e10cSrcweir // for the moment, we have a hard coded list of all known fields.
610cdf0e10cSrcweir // A better solution would be to store all known field translations in the configuration, which could be
611cdf0e10cSrcweir // extensible by the user in an arbitrary way.
612cdf0e10cSrcweir // But for the moment we need a quick solution ...
613cdf0e10cSrcweir // (the main thing would be to store the translations to use here in the user interface, besides that, the code
614cdf0e10cSrcweir // should be adjustable with a rather small effort.)
615cdf0e10cSrcweir
616cdf0e10cSrcweir // initialize the strings for the field labels
617cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_FIRSTNAME )) );
618cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_LASTNAME )) );
619cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_COMPANY)) );
620cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_DEPARTMENT )) );
621cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_STREET )) );
622cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_ZIPCODE )) );
623cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_CITY )) );
624cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_STATE)) );
625cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_COUNTRY )) );
626cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_HOMETEL )) );
627cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_WORKTEL )) );
628cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_OFFICETEL)) );
629cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_MOBILE)) );
630cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_TELOTHER)) );
631cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_PAGER)) );
632cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_FAX )) );
633cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_EMAIL )) );
634cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_URL )) );
635cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_TITLE )) );
636cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_POSITION )) );
637cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_INITIALS )) );
638cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_ADDRFORM )) );
639cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_SALUTATION )) );
640cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_ID)) );
641cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_CALENDAR)) );
642cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_INVITE)) );
643cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_NOTE)) );
644cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_USER1)) );
645cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_USER2)) );
646cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_USER3)) );
647cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_USER4)) );
648cdf0e10cSrcweir
649cdf0e10cSrcweir // force a even number of known fields
650cdf0e10cSrcweir m_pImpl->bOddFieldNumber = (m_pImpl->aFieldLabels.size() % 2) != 0;
651cdf0e10cSrcweir if (m_pImpl->bOddFieldNumber)
652cdf0e10cSrcweir m_pImpl->aFieldLabels.push_back( String() );
653cdf0e10cSrcweir
654cdf0e10cSrcweir // limit the scrollbar range accordingly
655cdf0e10cSrcweir sal_Int32 nOverallFieldPairs = m_pImpl->aFieldLabels.size() / 2;
656cdf0e10cSrcweir m_aFieldScroller.SetRange( Range(0, nOverallFieldPairs - FIELD_PAIRS_VISIBLE) );
657cdf0e10cSrcweir m_aFieldScroller.SetLineSize(1);
658cdf0e10cSrcweir m_aFieldScroller.SetPageSize(FIELD_PAIRS_VISIBLE);
659cdf0e10cSrcweir
660cdf0e10cSrcweir // reset the current field assignments
661cdf0e10cSrcweir m_pImpl->aFieldAssignments.resize(m_pImpl->aFieldLabels.size());
662cdf0e10cSrcweir // (empty strings mean "no assignment")
663cdf0e10cSrcweir
664cdf0e10cSrcweir // some knittings
665cdf0e10cSrcweir m_aFieldScroller.SetScrollHdl(LINK(this, AddressBookSourceDialog, OnFieldScroll));
666cdf0e10cSrcweir m_aAdministrateDatasources.SetClickHdl(LINK(this, AddressBookSourceDialog, OnAdministrateDatasources));
667cdf0e10cSrcweir m_aDatasource.EnableAutocomplete(sal_True);
668cdf0e10cSrcweir m_aTable.EnableAutocomplete(sal_True);
669cdf0e10cSrcweir m_aTable.SetGetFocusHdl(LINK(this, AddressBookSourceDialog, OnComboGetFocus));
670cdf0e10cSrcweir m_aDatasource.SetGetFocusHdl(LINK(this, AddressBookSourceDialog, OnComboGetFocus));
671cdf0e10cSrcweir m_aTable.SetLoseFocusHdl(LINK(this, AddressBookSourceDialog, OnComboLoseFocus));
672cdf0e10cSrcweir m_aDatasource.SetLoseFocusHdl(LINK(this, AddressBookSourceDialog, OnComboLoseFocus));
673cdf0e10cSrcweir m_aTable.SetSelectHdl(LINK(this, AddressBookSourceDialog, OnComboSelect));
674cdf0e10cSrcweir m_aDatasource.SetSelectHdl(LINK(this, AddressBookSourceDialog, OnComboSelect));
675cdf0e10cSrcweir m_aOK.SetClickHdl(LINK(this, AddressBookSourceDialog, OnOkClicked));
676cdf0e10cSrcweir
677cdf0e10cSrcweir m_aDatasource.SetDropDownLineCount(15);
678cdf0e10cSrcweir
679cdf0e10cSrcweir // initialize the field controls
680cdf0e10cSrcweir resetFields();
681cdf0e10cSrcweir m_aFieldScroller.SetThumbPos(0);
682cdf0e10cSrcweir m_pImpl->nFieldScrollPos = -1;
683cdf0e10cSrcweir implScrollFields(0, sal_False, sal_False);
684cdf0e10cSrcweir
685cdf0e10cSrcweir // the logical names
686cdf0e10cSrcweir String sLogicalFieldNames(SvtResId(STR_LOCAGICAL_FIELD_NAMES));
687cdf0e10cSrcweir sal_Int32 nAdjustedTokenCount = sLogicalFieldNames.GetTokenCount(';') + (m_pImpl->bOddFieldNumber ? 1 : 0);
688cdf0e10cSrcweir DBG_ASSERT(nAdjustedTokenCount == (sal_Int32)m_pImpl->aFieldLabels.size(),
689cdf0e10cSrcweir "AddressBookSourceDialog::AddressBookSourceDialog: inconsistence between logical and UI field names!");
690cdf0e10cSrcweir m_pImpl->aLogicalFieldNames.reserve(nAdjustedTokenCount);
691cdf0e10cSrcweir for (sal_Int32 i = 0; i<nAdjustedTokenCount; ++i)
692cdf0e10cSrcweir m_pImpl->aLogicalFieldNames.push_back(sLogicalFieldNames.GetToken((sal_uInt16)i, ';'));
693cdf0e10cSrcweir
694cdf0e10cSrcweir PostUserEvent(LINK(this, AddressBookSourceDialog, OnDelayedInitialize));
695cdf0e10cSrcweir // so the dialog will at least show up before we do the loading of the
696cdf0e10cSrcweir // configuration data and the (maybe time consuming) analysis of the data source/table to select
697cdf0e10cSrcweir
698cdf0e10cSrcweir FreeResource();
699cdf0e10cSrcweir
700cdf0e10cSrcweir if ( !m_pImpl->bWorkingPersistent )
701cdf0e10cSrcweir {
702cdf0e10cSrcweir StyleSettings aSystemStyle = GetSettings().GetStyleSettings();
703cdf0e10cSrcweir const Color& rNewColor = aSystemStyle.GetDialogColor();
704cdf0e10cSrcweir
705cdf0e10cSrcweir m_aDatasource.SetReadOnly( sal_True );
706cdf0e10cSrcweir m_aDatasource.SetBackground( Wallpaper( rNewColor ) );
707cdf0e10cSrcweir m_aDatasource.SetControlBackground( rNewColor );
708cdf0e10cSrcweir
709cdf0e10cSrcweir m_aTable.SetReadOnly( sal_True );
710cdf0e10cSrcweir m_aTable.SetBackground( Wallpaper( rNewColor ) );
711cdf0e10cSrcweir m_aTable.SetControlBackground( rNewColor );
712cdf0e10cSrcweir
713cdf0e10cSrcweir m_aAdministrateDatasources.Hide( );
714cdf0e10cSrcweir }
715cdf0e10cSrcweir }
716cdf0e10cSrcweir
717cdf0e10cSrcweir // -------------------------------------------------------------------
getFieldMapping(Sequence<AliasProgrammaticPair> & _rMapping) const718cdf0e10cSrcweir void AddressBookSourceDialog::getFieldMapping(Sequence< AliasProgrammaticPair >& _rMapping) const
719cdf0e10cSrcweir {
720cdf0e10cSrcweir _rMapping.realloc( m_pImpl->aLogicalFieldNames.size() );
721cdf0e10cSrcweir AliasProgrammaticPair* pPair = _rMapping.getArray();
722cdf0e10cSrcweir
723cdf0e10cSrcweir ::rtl::OUString sCurrent;
724cdf0e10cSrcweir for ( ConstStringArrayIterator aProgrammatic = m_pImpl->aLogicalFieldNames.begin();
725cdf0e10cSrcweir aProgrammatic != m_pImpl->aLogicalFieldNames.end();
726cdf0e10cSrcweir ++aProgrammatic
727cdf0e10cSrcweir )
728cdf0e10cSrcweir {
729cdf0e10cSrcweir sCurrent = *aProgrammatic;
730cdf0e10cSrcweir if ( m_pImpl->pConfigData->hasFieldAssignment( sCurrent ) )
731cdf0e10cSrcweir {
732cdf0e10cSrcweir // the user gave us an assignment for this field
733cdf0e10cSrcweir pPair->ProgrammaticName = *aProgrammatic;
734cdf0e10cSrcweir pPair->Alias = m_pImpl->pConfigData->getFieldAssignment( *aProgrammatic );
735cdf0e10cSrcweir ++pPair;
736cdf0e10cSrcweir }
737cdf0e10cSrcweir }
738cdf0e10cSrcweir
739cdf0e10cSrcweir _rMapping.realloc( pPair - _rMapping.getArray() );
740cdf0e10cSrcweir }
741cdf0e10cSrcweir
742cdf0e10cSrcweir // -------------------------------------------------------------------
loadConfiguration()743cdf0e10cSrcweir void AddressBookSourceDialog::loadConfiguration()
744cdf0e10cSrcweir {
745cdf0e10cSrcweir ::rtl::OUString sName = m_pImpl->pConfigData->getDatasourceName();
746cdf0e10cSrcweir INetURLObject aURL( sName );
747cdf0e10cSrcweir if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
748cdf0e10cSrcweir {
749cdf0e10cSrcweir OFileNotation aFileNotation( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
750cdf0e10cSrcweir sName = aFileNotation.get(OFileNotation::N_SYSTEM);
751cdf0e10cSrcweir }
752cdf0e10cSrcweir
753cdf0e10cSrcweir m_aDatasource.SetText(sName);
754cdf0e10cSrcweir m_aTable.SetText(m_pImpl->pConfigData->getCommand());
755cdf0e10cSrcweir // we ignore the CommandType: only tables are supported
756cdf0e10cSrcweir
757cdf0e10cSrcweir // the logical names for the fields
758cdf0e10cSrcweir DBG_ASSERT(m_pImpl->aLogicalFieldNames.size() == m_pImpl->aFieldAssignments.size(),
759cdf0e10cSrcweir "AddressBookSourceDialog::loadConfiguration: inconsistence between field names and field assignments!");
760cdf0e10cSrcweir
761cdf0e10cSrcweir ConstStringArrayIterator aLogical = m_pImpl->aLogicalFieldNames.begin();
762cdf0e10cSrcweir StringArrayIterator aAssignment = m_pImpl->aFieldAssignments.begin();
763cdf0e10cSrcweir for ( ;
764cdf0e10cSrcweir aLogical < m_pImpl->aLogicalFieldNames.end();
765cdf0e10cSrcweir ++aLogical, ++aAssignment
766cdf0e10cSrcweir )
767cdf0e10cSrcweir *aAssignment = m_pImpl->pConfigData->getFieldAssignment(*aLogical);
768cdf0e10cSrcweir }
769cdf0e10cSrcweir
770cdf0e10cSrcweir // -------------------------------------------------------------------
~AddressBookSourceDialog()771cdf0e10cSrcweir AddressBookSourceDialog::~AddressBookSourceDialog()
772cdf0e10cSrcweir {
773cdf0e10cSrcweir sal_Int32 i;
774cdf0e10cSrcweir for (i=0; i<FIELD_CONTROLS_VISIBLE; ++i)
775cdf0e10cSrcweir {
776cdf0e10cSrcweir delete m_pImpl->pFieldLabels[i];
777cdf0e10cSrcweir delete m_pImpl->pFields[i];
778cdf0e10cSrcweir }
779cdf0e10cSrcweir
780cdf0e10cSrcweir delete m_pImpl;
781cdf0e10cSrcweir }
782cdf0e10cSrcweir
783cdf0e10cSrcweir // -------------------------------------------------------------------
initializeDatasources()784cdf0e10cSrcweir void AddressBookSourceDialog::initializeDatasources()
785cdf0e10cSrcweir {
786cdf0e10cSrcweir if (!m_xDatabaseContext.is())
787cdf0e10cSrcweir {
788cdf0e10cSrcweir DBG_ASSERT(m_xORB.is(), "AddressBookSourceDialog::initializeDatasources: no service factory!");
789cdf0e10cSrcweir if (!m_xORB.is())
790cdf0e10cSrcweir return;
791cdf0e10cSrcweir
792cdf0e10cSrcweir const String sContextServiceName = String::CreateFromAscii("com.sun.star.sdb.DatabaseContext");
793cdf0e10cSrcweir try
794cdf0e10cSrcweir {
795cdf0e10cSrcweir m_xDatabaseContext = Reference< XNameAccess >(m_xORB->createInstance(sContextServiceName), UNO_QUERY);
796cdf0e10cSrcweir }
797cdf0e10cSrcweir catch(Exception&) { }
798cdf0e10cSrcweir if (!m_xDatabaseContext.is())
799cdf0e10cSrcweir {
800cdf0e10cSrcweir ShowServiceNotAvailableError( this, sContextServiceName, sal_False);
801cdf0e10cSrcweir return;
802cdf0e10cSrcweir }
803cdf0e10cSrcweir }
804cdf0e10cSrcweir m_aDatasource.Clear();
805cdf0e10cSrcweir
806cdf0e10cSrcweir // fill the datasources listbox
807cdf0e10cSrcweir Sequence< ::rtl::OUString > aDatasourceNames;
808cdf0e10cSrcweir try
809cdf0e10cSrcweir {
810cdf0e10cSrcweir aDatasourceNames = m_xDatabaseContext->getElementNames();
811cdf0e10cSrcweir }
812cdf0e10cSrcweir catch(Exception&)
813cdf0e10cSrcweir {
814cdf0e10cSrcweir DBG_ERROR("AddressBookSourceDialog::initializeDatasources: caught an exception while asking for the data source names!");
815cdf0e10cSrcweir }
816cdf0e10cSrcweir const ::rtl::OUString* pDatasourceNames = aDatasourceNames.getConstArray();
817cdf0e10cSrcweir const ::rtl::OUString* pEnd = pDatasourceNames + aDatasourceNames.getLength();
818cdf0e10cSrcweir for (; pDatasourceNames < pEnd; ++pDatasourceNames)
819cdf0e10cSrcweir m_aDatasource.InsertEntry(*pDatasourceNames);
820cdf0e10cSrcweir }
821cdf0e10cSrcweir
822cdf0e10cSrcweir // -------------------------------------------------------------------
IMPL_LINK(AddressBookSourceDialog,OnFieldScroll,ScrollBar *,_pScrollBar)823cdf0e10cSrcweir IMPL_LINK(AddressBookSourceDialog, OnFieldScroll, ScrollBar*, _pScrollBar)
824cdf0e10cSrcweir {
825cdf0e10cSrcweir implScrollFields( _pScrollBar->GetThumbPos(), sal_True, sal_True );
826cdf0e10cSrcweir return 0L;
827cdf0e10cSrcweir }
828cdf0e10cSrcweir
829cdf0e10cSrcweir // -------------------------------------------------------------------
resetTables()830cdf0e10cSrcweir void AddressBookSourceDialog::resetTables()
831cdf0e10cSrcweir {
832cdf0e10cSrcweir if (!m_xDatabaseContext.is())
833cdf0e10cSrcweir return;
834cdf0e10cSrcweir
835cdf0e10cSrcweir WaitObject aWaitCursor(this);
836cdf0e10cSrcweir
837*983f6de1SMatthias Seidel // no matter what we do here, we handled the currently selected data source (no matter if successful or not)
838cdf0e10cSrcweir m_aDatasource.SaveValue();
839cdf0e10cSrcweir
840cdf0e10cSrcweir // create an interaction handler (may be needed for connecting)
841cdf0e10cSrcweir const String sInteractionHandlerServiceName = String::CreateFromAscii("com.sun.star.task.InteractionHandler");
842cdf0e10cSrcweir Reference< XInteractionHandler > xHandler;
843cdf0e10cSrcweir try
844cdf0e10cSrcweir {
845cdf0e10cSrcweir xHandler = Reference< XInteractionHandler >(m_xORB->createInstance(sInteractionHandlerServiceName), UNO_QUERY);
846cdf0e10cSrcweir }
847cdf0e10cSrcweir catch(Exception&) { }
848cdf0e10cSrcweir if (!xHandler.is())
849cdf0e10cSrcweir {
850cdf0e10cSrcweir ShowServiceNotAvailableError(this, sInteractionHandlerServiceName, sal_True);
851cdf0e10cSrcweir return;
852cdf0e10cSrcweir }
853cdf0e10cSrcweir
854cdf0e10cSrcweir // the currently selected table
855cdf0e10cSrcweir ::rtl::OUString sOldTable = m_aTable.GetText();
856cdf0e10cSrcweir
857cdf0e10cSrcweir m_aTable.Clear();
858cdf0e10cSrcweir
859cdf0e10cSrcweir m_xCurrentDatasourceTables= NULL;
860cdf0e10cSrcweir
861cdf0e10cSrcweir // get the tables of the connection
862cdf0e10cSrcweir Sequence< ::rtl::OUString > aTableNames;
863cdf0e10cSrcweir Any aException;
864cdf0e10cSrcweir try
865cdf0e10cSrcweir {
866cdf0e10cSrcweir Reference< XCompletedConnection > xDS;
867cdf0e10cSrcweir if ( m_pImpl->bWorkingPersistent )
868cdf0e10cSrcweir {
869cdf0e10cSrcweir String sSelectedDS = lcl_getSelectedDataSource( m_aDatasource );
870cdf0e10cSrcweir
871cdf0e10cSrcweir // get the data source the user has chosen and let it build a connection
872cdf0e10cSrcweir INetURLObject aURL( sSelectedDS );
873cdf0e10cSrcweir if ( aURL.GetProtocol() != INET_PROT_NOT_VALID || m_xDatabaseContext->hasByName(sSelectedDS) )
874cdf0e10cSrcweir m_xDatabaseContext->getByName( sSelectedDS ) >>= xDS;
875cdf0e10cSrcweir }
876cdf0e10cSrcweir else
877cdf0e10cSrcweir {
878cdf0e10cSrcweir xDS = xDS.query( m_pImpl->m_xTransientDataSource );
879cdf0e10cSrcweir }
880cdf0e10cSrcweir
881cdf0e10cSrcweir // build the connection
882cdf0e10cSrcweir Reference< XConnection > xConn;
883cdf0e10cSrcweir if (xDS.is())
884cdf0e10cSrcweir xConn = xDS->connectWithCompletion(xHandler);
885cdf0e10cSrcweir
886cdf0e10cSrcweir // get the table names
887cdf0e10cSrcweir Reference< XTablesSupplier > xSupplTables(xConn, UNO_QUERY);
888cdf0e10cSrcweir if (xSupplTables.is())
889cdf0e10cSrcweir {
890cdf0e10cSrcweir m_xCurrentDatasourceTables = Reference< XNameAccess >(xSupplTables->getTables(), UNO_QUERY);
891cdf0e10cSrcweir if (m_xCurrentDatasourceTables.is())
892cdf0e10cSrcweir aTableNames = m_xCurrentDatasourceTables->getElementNames();
893cdf0e10cSrcweir }
894cdf0e10cSrcweir }
895cdf0e10cSrcweir catch(SQLContext& e) { aException <<= e; }
896cdf0e10cSrcweir catch(SQLWarning& e) { aException <<= e; }
897cdf0e10cSrcweir catch(SQLException& e) { aException <<= e; }
898cdf0e10cSrcweir catch(Exception&)
899cdf0e10cSrcweir {
900cdf0e10cSrcweir DBG_ERROR("AddressBookSourceDialog::resetTables: could not retrieve the table!");
901cdf0e10cSrcweir }
902cdf0e10cSrcweir
903cdf0e10cSrcweir if (aException.hasValue())
904cdf0e10cSrcweir {
905cdf0e10cSrcweir Reference< XInteractionRequest > xRequest = new OInteractionRequest(aException);
906cdf0e10cSrcweir try
907cdf0e10cSrcweir {
908cdf0e10cSrcweir xHandler->handle(xRequest);
909cdf0e10cSrcweir }
910cdf0e10cSrcweir catch(Exception&) { }
911cdf0e10cSrcweir return;
912cdf0e10cSrcweir }
913cdf0e10cSrcweir
914cdf0e10cSrcweir sal_Bool bKnowOldTable = sal_False;
915cdf0e10cSrcweir // fill the table list
916cdf0e10cSrcweir const ::rtl::OUString* pTableNames = aTableNames.getConstArray();
917cdf0e10cSrcweir const ::rtl::OUString* pEnd = pTableNames + aTableNames.getLength();
918cdf0e10cSrcweir for (;pTableNames != pEnd; ++pTableNames)
919cdf0e10cSrcweir {
920cdf0e10cSrcweir m_aTable.InsertEntry(*pTableNames);
921cdf0e10cSrcweir if (0 == pTableNames->compareTo(sOldTable))
922cdf0e10cSrcweir bKnowOldTable = sal_True;
923cdf0e10cSrcweir }
924cdf0e10cSrcweir
925cdf0e10cSrcweir // set the old table, if the new data source knows a table with this name, too. Else reset the tables edit field.
926cdf0e10cSrcweir if (!bKnowOldTable)
927cdf0e10cSrcweir sOldTable = ::rtl::OUString();
928cdf0e10cSrcweir m_aTable.SetText(sOldTable);
929cdf0e10cSrcweir
930cdf0e10cSrcweir resetFields();
931cdf0e10cSrcweir }
932cdf0e10cSrcweir
933cdf0e10cSrcweir // -------------------------------------------------------------------
resetFields()934cdf0e10cSrcweir void AddressBookSourceDialog::resetFields()
935cdf0e10cSrcweir {
936cdf0e10cSrcweir WaitObject aWaitCursor(this);
937cdf0e10cSrcweir
938cdf0e10cSrcweir // no matter what we do here, we handled the currently selected table (no matter if successfull or not)
939cdf0e10cSrcweir m_aDatasource.SaveValue();
940cdf0e10cSrcweir
941cdf0e10cSrcweir String sSelectedTable = m_aTable.GetText();
942cdf0e10cSrcweir Sequence< ::rtl::OUString > aColumnNames;
943cdf0e10cSrcweir try
944cdf0e10cSrcweir {
945cdf0e10cSrcweir if (m_xCurrentDatasourceTables.is())
946cdf0e10cSrcweir {
947cdf0e10cSrcweir // get the table and the columns
948cdf0e10cSrcweir Reference< XColumnsSupplier > xSuppTableCols;
949cdf0e10cSrcweir if (m_xCurrentDatasourceTables->hasByName(sSelectedTable))
950cdf0e10cSrcweir ::cppu::extractInterface(xSuppTableCols, m_xCurrentDatasourceTables->getByName(sSelectedTable));
951cdf0e10cSrcweir Reference< XNameAccess > xColumns;
952cdf0e10cSrcweir if (xSuppTableCols.is())
953cdf0e10cSrcweir xColumns = xSuppTableCols->getColumns();
954cdf0e10cSrcweir if (xColumns.is())
955cdf0e10cSrcweir aColumnNames = xColumns->getElementNames();
956cdf0e10cSrcweir }
957cdf0e10cSrcweir }
958cdf0e10cSrcweir catch(Exception&)
959cdf0e10cSrcweir {
960cdf0e10cSrcweir DBG_ERROR("AddressBookSourceDialog::resetFields: could not retrieve the table columns!");
961cdf0e10cSrcweir }
962cdf0e10cSrcweir
963cdf0e10cSrcweir
964cdf0e10cSrcweir const ::rtl::OUString* pColumnNames = aColumnNames.getConstArray();
965cdf0e10cSrcweir const ::rtl::OUString* pEnd = pColumnNames + aColumnNames.getLength();
966cdf0e10cSrcweir
967cdf0e10cSrcweir // for quicker access
968cdf0e10cSrcweir ::std::set< String > aColumnNameSet;
969cdf0e10cSrcweir for (pColumnNames = aColumnNames.getConstArray(); pColumnNames != pEnd; ++pColumnNames)
970cdf0e10cSrcweir aColumnNameSet.insert(*pColumnNames);
971cdf0e10cSrcweir
972cdf0e10cSrcweir std::vector<String>::iterator aInitialSelection = m_pImpl->aFieldAssignments.begin() + m_pImpl->nFieldScrollPos;
973cdf0e10cSrcweir
974cdf0e10cSrcweir ListBox** pListbox = m_pImpl->pFields;
975cdf0e10cSrcweir String sSaveSelection;
976cdf0e10cSrcweir for (sal_Int32 i=0; i<FIELD_CONTROLS_VISIBLE; ++i, ++pListbox, ++aInitialSelection)
977cdf0e10cSrcweir {
978cdf0e10cSrcweir sSaveSelection = (*pListbox)->GetSelectEntry();
979cdf0e10cSrcweir
980cdf0e10cSrcweir (*pListbox)->Clear();
981cdf0e10cSrcweir
982cdf0e10cSrcweir // the one entry for "no selection"
983cdf0e10cSrcweir (*pListbox)->InsertEntry(m_sNoFieldSelection, 0);
984cdf0e10cSrcweir // as it's entry data, set the index of the list box in our array
985cdf0e10cSrcweir (*pListbox)->SetEntryData(0, reinterpret_cast<void*>(i));
986cdf0e10cSrcweir
987cdf0e10cSrcweir // the field names
988cdf0e10cSrcweir for (pColumnNames = aColumnNames.getConstArray(); pColumnNames != pEnd; ++pColumnNames)
989cdf0e10cSrcweir (*pListbox)->InsertEntry(*pColumnNames);
990cdf0e10cSrcweir
991cdf0e10cSrcweir if (aInitialSelection->Len() && (aColumnNameSet.end() != aColumnNameSet.find(*aInitialSelection)))
992cdf0e10cSrcweir // we can select the entry as specified in our field assignment array
993cdf0e10cSrcweir (*pListbox)->SelectEntry(*aInitialSelection);
994cdf0e10cSrcweir else
995cdf0e10cSrcweir // try to restore the selection
996cdf0e10cSrcweir if (aColumnNameSet.end() != aColumnNameSet.find(sSaveSelection))
997cdf0e10cSrcweir // the old selection is a valid column name
998cdf0e10cSrcweir (*pListbox)->SelectEntry(sSaveSelection);
999cdf0e10cSrcweir else
1000cdf0e10cSrcweir // select the <none> entry
1001cdf0e10cSrcweir (*pListbox)->SelectEntryPos(0);
1002cdf0e10cSrcweir }
1003cdf0e10cSrcweir
1004cdf0e10cSrcweir // adjust m_pImpl->aFieldAssignments
1005cdf0e10cSrcweir for ( StringArrayIterator aAdjust = m_pImpl->aFieldAssignments.begin();
1006cdf0e10cSrcweir aAdjust != m_pImpl->aFieldAssignments.end();
1007cdf0e10cSrcweir ++aAdjust
1008cdf0e10cSrcweir )
1009cdf0e10cSrcweir if (aAdjust->Len())
1010cdf0e10cSrcweir if (aColumnNameSet.end() == aColumnNameSet.find(*aAdjust))
1011cdf0e10cSrcweir aAdjust->Erase();
1012cdf0e10cSrcweir }
1013cdf0e10cSrcweir
1014cdf0e10cSrcweir // -------------------------------------------------------------------
IMPL_LINK(AddressBookSourceDialog,OnFieldSelect,ListBox *,_pListbox)1015cdf0e10cSrcweir IMPL_LINK(AddressBookSourceDialog, OnFieldSelect, ListBox*, _pListbox)
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir // the index of the affected list box in our array
1018cdf0e10cSrcweir sal_IntPtr nListBoxIndex = reinterpret_cast<sal_IntPtr>(_pListbox->GetEntryData(0));
1019cdf0e10cSrcweir DBG_ASSERT(nListBoxIndex >= 0 && nListBoxIndex < FIELD_CONTROLS_VISIBLE,
1020cdf0e10cSrcweir "AddressBookSourceDialog::OnFieldScroll: invalid list box entry!");
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir // update the array where we remember the field selections
1023cdf0e10cSrcweir if (0 == _pListbox->GetSelectEntryPos())
1024cdf0e10cSrcweir // it's the "no field selection" entry
1025cdf0e10cSrcweir m_pImpl->aFieldAssignments[m_pImpl->nFieldScrollPos * 2 + nListBoxIndex] = String();
1026cdf0e10cSrcweir else
1027cdf0e10cSrcweir // it's a regular field entry
1028cdf0e10cSrcweir m_pImpl->aFieldAssignments[m_pImpl->nFieldScrollPos * 2 + nListBoxIndex] = _pListbox->GetSelectEntry();
1029cdf0e10cSrcweir
1030cdf0e10cSrcweir return 0L;
1031cdf0e10cSrcweir }
1032cdf0e10cSrcweir
1033cdf0e10cSrcweir // -------------------------------------------------------------------
implScrollFields(sal_Int32 _nPos,sal_Bool _bAdjustFocus,sal_Bool _bAdjustScrollbar)1034cdf0e10cSrcweir void AddressBookSourceDialog::implScrollFields(sal_Int32 _nPos, sal_Bool _bAdjustFocus, sal_Bool _bAdjustScrollbar)
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir if (_nPos == m_pImpl->nFieldScrollPos)
1037cdf0e10cSrcweir // nothing to do
1038cdf0e10cSrcweir return;
1039cdf0e10cSrcweir
1040cdf0e10cSrcweir // loop through our field control rows and do some adjustments
1041cdf0e10cSrcweir // for the new texts
1042cdf0e10cSrcweir FixedText** pLeftLabelControl = m_pImpl->pFieldLabels;
1043cdf0e10cSrcweir FixedText** pRightLabelControl = pLeftLabelControl + 1;
1044cdf0e10cSrcweir ConstStringArrayIterator pLeftColumnLabel = m_pImpl->aFieldLabels.begin() + 2 * _nPos;
1045cdf0e10cSrcweir ConstStringArrayIterator pRightColumnLabel = pLeftColumnLabel + 1;
1046cdf0e10cSrcweir
1047cdf0e10cSrcweir // for the focus movement and the selection scroll
1048cdf0e10cSrcweir ListBox** pLeftListControl = m_pImpl->pFields;
1049cdf0e10cSrcweir ListBox** pRightListControl = pLeftListControl + 1;
1050cdf0e10cSrcweir
1051cdf0e10cSrcweir // for the focus movement
1052cdf0e10cSrcweir sal_Int32 nOldFocusRow = -1;
1053cdf0e10cSrcweir sal_Int32 nOldFocusColumn = 0;
1054cdf0e10cSrcweir
1055cdf0e10cSrcweir // for the selection scroll
1056cdf0e10cSrcweir ConstStringArrayIterator pLeftAssignment = m_pImpl->aFieldAssignments.begin() + 2 * _nPos;
1057cdf0e10cSrcweir ConstStringArrayIterator pRightAssignment = pLeftAssignment + 1;
1058cdf0e10cSrcweir
1059cdf0e10cSrcweir m_pImpl->nLastVisibleListIndex = -1;
1060cdf0e10cSrcweir // loop
1061cdf0e10cSrcweir for (sal_Int32 i=0; i<FIELD_PAIRS_VISIBLE; ++i)
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir if ((*pLeftListControl)->HasChildPathFocus())
1064cdf0e10cSrcweir {
1065cdf0e10cSrcweir nOldFocusRow = i;
1066cdf0e10cSrcweir nOldFocusColumn = 0;
1067cdf0e10cSrcweir }
1068cdf0e10cSrcweir else if ((*pRightListControl)->HasChildPathFocus())
1069cdf0e10cSrcweir {
1070cdf0e10cSrcweir nOldFocusRow = i;
1071cdf0e10cSrcweir nOldFocusColumn = 1;
1072cdf0e10cSrcweir }
1073cdf0e10cSrcweir
1074cdf0e10cSrcweir // the new texts of the label controls
1075cdf0e10cSrcweir (*pLeftLabelControl)->SetText(*pLeftColumnLabel);
1076cdf0e10cSrcweir (*pRightLabelControl)->SetText(*pRightColumnLabel);
1077cdf0e10cSrcweir
1078cdf0e10cSrcweir // we may have to hide the controls in the right column, if we have no label text for it
1079cdf0e10cSrcweir // (which means we have an odd number of fields, though we forced our internal arrays to
1080cdf0e10cSrcweir // be even-sized for easier handling)
1081cdf0e10cSrcweir // (If sometimes we support an arbitrary number of field assignments, we would have to care for
1082cdf0e10cSrcweir // an invisible left hand side column, too. But right now, the left hand side controls are always
1083cdf0e10cSrcweir // visible)
1084cdf0e10cSrcweir sal_Bool bHideRightColumn = (0 == pRightColumnLabel->Len());
1085cdf0e10cSrcweir (*pRightLabelControl)->Show(!bHideRightColumn);
1086cdf0e10cSrcweir (*pRightListControl)->Show(!bHideRightColumn);
1087cdf0e10cSrcweir // the new selections of the listboxes
1088cdf0e10cSrcweir implSelectField(*pLeftListControl, *pLeftAssignment);
1089cdf0e10cSrcweir implSelectField(*pRightListControl, *pRightAssignment);
1090cdf0e10cSrcweir
1091cdf0e10cSrcweir // the index of the last visible list box
1092cdf0e10cSrcweir ++m_pImpl->nLastVisibleListIndex; // the left hand side box is always visible
1093cdf0e10cSrcweir if (!bHideRightColumn)
1094cdf0e10cSrcweir ++m_pImpl->nLastVisibleListIndex;
1095cdf0e10cSrcweir
1096cdf0e10cSrcweir // increment ...
1097cdf0e10cSrcweir if ( i < FIELD_PAIRS_VISIBLE - 1 )
1098cdf0e10cSrcweir { // (not in the very last round, here the +=2 could result in an invalid
1099cdf0e10cSrcweir // iterator position, which causes an abort in a non-product version
1100cdf0e10cSrcweir pLeftLabelControl += 2;
1101cdf0e10cSrcweir pRightLabelControl += 2;
1102cdf0e10cSrcweir pLeftColumnLabel += 2;
1103cdf0e10cSrcweir pRightColumnLabel += 2;
1104cdf0e10cSrcweir
1105cdf0e10cSrcweir pLeftListControl += 2;
1106cdf0e10cSrcweir pRightListControl += 2;
1107cdf0e10cSrcweir pLeftAssignment += 2;
1108cdf0e10cSrcweir pRightAssignment += 2;
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir }
1111cdf0e10cSrcweir
1112cdf0e10cSrcweir if (_bAdjustFocus && (nOldFocusRow >= 0))
1113cdf0e10cSrcweir { // we have to adjust the focus and one of the list boxes has the focus
1114cdf0e10cSrcweir sal_Int32 nDelta = m_pImpl->nFieldScrollPos - _nPos;
1115cdf0e10cSrcweir // the new row for the focus
1116cdf0e10cSrcweir sal_Int32 nNewFocusRow = nOldFocusRow + nDelta;
1117cdf0e10cSrcweir // normalize
1118cdf0e10cSrcweir nNewFocusRow = std::min(nNewFocusRow, (sal_Int32)(FIELD_PAIRS_VISIBLE - 1), ::std::less< sal_Int32 >());
1119cdf0e10cSrcweir nNewFocusRow = std::max(nNewFocusRow, (sal_Int32)0, ::std::less< sal_Int32 >());
1120cdf0e10cSrcweir // set the new focus (in the same column)
1121cdf0e10cSrcweir m_pImpl->pFields[nNewFocusRow * 2 + nOldFocusColumn]->GrabFocus();
1122cdf0e10cSrcweir }
1123cdf0e10cSrcweir
1124cdf0e10cSrcweir m_pImpl->nFieldScrollPos = _nPos;
1125cdf0e10cSrcweir
1126cdf0e10cSrcweir if (_bAdjustScrollbar)
1127cdf0e10cSrcweir m_aFieldScroller.SetThumbPos(m_pImpl->nFieldScrollPos);
1128cdf0e10cSrcweir }
1129cdf0e10cSrcweir
1130cdf0e10cSrcweir // -------------------------------------------------------------------
implSelectField(ListBox * _pBox,const String & _rText)1131cdf0e10cSrcweir void AddressBookSourceDialog::implSelectField(ListBox* _pBox, const String& _rText)
1132cdf0e10cSrcweir {
1133cdf0e10cSrcweir if (_rText.Len())
1134cdf0e10cSrcweir // a valid field name
1135cdf0e10cSrcweir _pBox->SelectEntry(_rText);
1136cdf0e10cSrcweir else
1137cdf0e10cSrcweir // no selection for this item
1138cdf0e10cSrcweir _pBox->SelectEntryPos(0);
1139cdf0e10cSrcweir }
1140cdf0e10cSrcweir
1141cdf0e10cSrcweir // -------------------------------------------------------------------
IMPL_LINK(AddressBookSourceDialog,OnDelayedInitialize,void *,EMPTYARG)1142cdf0e10cSrcweir IMPL_LINK(AddressBookSourceDialog, OnDelayedInitialize, void*, EMPTYARG)
1143cdf0e10cSrcweir {
1144cdf0e10cSrcweir // load the initial data from the configuration
1145cdf0e10cSrcweir loadConfiguration();
1146cdf0e10cSrcweir resetTables();
1147cdf0e10cSrcweir // will reset the tables/fields implicitly
1148cdf0e10cSrcweir
1149cdf0e10cSrcweir if ( !m_pImpl->bWorkingPersistent )
1150cdf0e10cSrcweir if ( m_pImpl->pFields[0] )
1151cdf0e10cSrcweir m_pImpl->pFields[0]->GrabFocus();
1152cdf0e10cSrcweir
1153cdf0e10cSrcweir return 0L;
1154cdf0e10cSrcweir }
1155cdf0e10cSrcweir
1156cdf0e10cSrcweir // -------------------------------------------------------------------
IMPL_LINK(AddressBookSourceDialog,OnComboSelect,ComboBox *,_pBox)1157cdf0e10cSrcweir IMPL_LINK(AddressBookSourceDialog, OnComboSelect, ComboBox*, _pBox)
1158cdf0e10cSrcweir {
1159cdf0e10cSrcweir if (_pBox == &m_aDatasource)
1160cdf0e10cSrcweir resetTables();
1161cdf0e10cSrcweir else
1162cdf0e10cSrcweir resetFields();
1163cdf0e10cSrcweir return 0;
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir
1166cdf0e10cSrcweir // -------------------------------------------------------------------
IMPL_LINK(AddressBookSourceDialog,OnComboGetFocus,ComboBox *,_pBox)1167cdf0e10cSrcweir IMPL_LINK(AddressBookSourceDialog, OnComboGetFocus, ComboBox*, _pBox)
1168cdf0e10cSrcweir {
1169cdf0e10cSrcweir _pBox->SaveValue();
1170cdf0e10cSrcweir return 0L;
1171cdf0e10cSrcweir }
1172cdf0e10cSrcweir
1173cdf0e10cSrcweir // -------------------------------------------------------------------
IMPL_LINK(AddressBookSourceDialog,OnComboLoseFocus,ComboBox *,_pBox)1174cdf0e10cSrcweir IMPL_LINK(AddressBookSourceDialog, OnComboLoseFocus, ComboBox*, _pBox)
1175cdf0e10cSrcweir {
1176cdf0e10cSrcweir if (_pBox->GetSavedValue() != _pBox->GetText())
1177cdf0e10cSrcweir {
1178cdf0e10cSrcweir if (_pBox == &m_aDatasource)
1179cdf0e10cSrcweir resetTables();
1180cdf0e10cSrcweir else
1181cdf0e10cSrcweir resetFields();
1182cdf0e10cSrcweir }
1183cdf0e10cSrcweir return 0L;
1184cdf0e10cSrcweir }
1185cdf0e10cSrcweir
1186cdf0e10cSrcweir // -------------------------------------------------------------------
IMPL_LINK(AddressBookSourceDialog,OnOkClicked,Button *,EMPTYARG)1187cdf0e10cSrcweir IMPL_LINK(AddressBookSourceDialog, OnOkClicked, Button*, EMPTYARG)
1188cdf0e10cSrcweir {
1189cdf0e10cSrcweir String sSelectedDS = lcl_getSelectedDataSource( m_aDatasource );
1190cdf0e10cSrcweir if ( m_pImpl->bWorkingPersistent )
1191cdf0e10cSrcweir {
1192cdf0e10cSrcweir m_pImpl->pConfigData->setDatasourceName(sSelectedDS);
1193cdf0e10cSrcweir m_pImpl->pConfigData->setCommand(m_aTable.GetText());
1194cdf0e10cSrcweir }
1195cdf0e10cSrcweir
1196cdf0e10cSrcweir // set the field assignments
1197cdf0e10cSrcweir ConstStringArrayIterator aLogical = m_pImpl->aLogicalFieldNames.begin();
1198cdf0e10cSrcweir ConstStringArrayIterator aAssignment = m_pImpl->aFieldAssignments.begin();
1199cdf0e10cSrcweir for ( ;
1200cdf0e10cSrcweir aLogical < m_pImpl->aLogicalFieldNames.end();
1201cdf0e10cSrcweir ++aLogical, ++aAssignment
1202cdf0e10cSrcweir )
1203cdf0e10cSrcweir m_pImpl->pConfigData->setFieldAssignment(*aLogical, *aAssignment);
1204cdf0e10cSrcweir
1205cdf0e10cSrcweir
1206cdf0e10cSrcweir EndDialog(RET_OK);
1207cdf0e10cSrcweir return 0L;
1208cdf0e10cSrcweir }
1209cdf0e10cSrcweir
1210cdf0e10cSrcweir // -------------------------------------------------------------------
IMPL_LINK(AddressBookSourceDialog,OnAdministrateDatasources,void *,EMPTYARG)1211cdf0e10cSrcweir IMPL_LINK(AddressBookSourceDialog, OnAdministrateDatasources, void*, EMPTYARG)
1212cdf0e10cSrcweir {
1213cdf0e10cSrcweir // collect some initial arguments for the dialog
1214cdf0e10cSrcweir Sequence< Any > aArgs(1);
1215cdf0e10cSrcweir aArgs[0] <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow")), 0, makeAny(VCLUnoHelper::GetInterface(this)), PropertyState_DIRECT_VALUE);
1216cdf0e10cSrcweir
1217cdf0e10cSrcweir // create the dialog object
1218cdf0e10cSrcweir const String sDialogServiceName = String::CreateFromAscii("com.sun.star.ui.dialogs.AddressBookSourcePilot");
1219cdf0e10cSrcweir Reference< XExecutableDialog > xAdminDialog;
1220cdf0e10cSrcweir try
1221cdf0e10cSrcweir {
1222cdf0e10cSrcweir xAdminDialog = Reference< XExecutableDialog >(m_xORB->createInstanceWithArguments(sDialogServiceName, aArgs), UNO_QUERY);
1223cdf0e10cSrcweir }
1224cdf0e10cSrcweir catch(Exception&) { }
1225cdf0e10cSrcweir if (!xAdminDialog.is())
1226cdf0e10cSrcweir {
1227cdf0e10cSrcweir ShowServiceNotAvailableError(this, sDialogServiceName, sal_True);
1228cdf0e10cSrcweir return 1L;
1229cdf0e10cSrcweir }
1230cdf0e10cSrcweir
1231cdf0e10cSrcweir // excute the dialog
1232cdf0e10cSrcweir try
1233cdf0e10cSrcweir {
1234cdf0e10cSrcweir if ( xAdminDialog->execute() == RET_OK )
1235cdf0e10cSrcweir {
1236cdf0e10cSrcweir Reference<XPropertySet> xProp(xAdminDialog,UNO_QUERY);
1237cdf0e10cSrcweir if ( xProp.is() )
1238cdf0e10cSrcweir {
1239cdf0e10cSrcweir ::rtl::OUString sName;
1240cdf0e10cSrcweir xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataSourceName"))) >>= sName;
1241cdf0e10cSrcweir
1242cdf0e10cSrcweir INetURLObject aURL( sName );
1243cdf0e10cSrcweir if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
1244cdf0e10cSrcweir {
1245cdf0e10cSrcweir OFileNotation aFileNotation( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
1246cdf0e10cSrcweir sName = aFileNotation.get(OFileNotation::N_SYSTEM);
1247cdf0e10cSrcweir }
1248cdf0e10cSrcweir m_aDatasource.InsertEntry(sName);
1249cdf0e10cSrcweir delete m_pImpl->pConfigData;
1250cdf0e10cSrcweir m_pImpl->pConfigData = new AssignmentPersistentData();
1251cdf0e10cSrcweir loadConfiguration();
1252cdf0e10cSrcweir resetTables();
1253cdf0e10cSrcweir // will reset the fields implicitly
1254cdf0e10cSrcweir }
1255cdf0e10cSrcweir }
1256cdf0e10cSrcweir }
1257cdf0e10cSrcweir catch(Exception&)
1258cdf0e10cSrcweir {
1259cdf0e10cSrcweir DBG_ERROR("AddressBookSourceDialog::OnAdministrateDatasources: an error occured while executing the administration dialog!");
1260cdf0e10cSrcweir }
1261cdf0e10cSrcweir
1262cdf0e10cSrcweir // re-fill the data source list
1263cdf0e10cSrcweir // try to preserve the current selection
1264cdf0e10cSrcweir
1265cdf0e10cSrcweir // initializeDatasources();
1266cdf0e10cSrcweir
1267cdf0e10cSrcweir return 0L;
1268cdf0e10cSrcweir }
1269cdf0e10cSrcweir
1270cdf0e10cSrcweir // -------------------------------------------------------------------
PreNotify(NotifyEvent & _rNEvt)1271cdf0e10cSrcweir long AddressBookSourceDialog::PreNotify( NotifyEvent& _rNEvt )
1272cdf0e10cSrcweir {
1273cdf0e10cSrcweir switch (_rNEvt.GetType())
1274cdf0e10cSrcweir {
1275cdf0e10cSrcweir case EVENT_KEYINPUT:
1276cdf0e10cSrcweir {
1277cdf0e10cSrcweir const KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent();
1278cdf0e10cSrcweir sal_uInt16 nCode = pKeyEvent->GetKeyCode().GetCode();
1279cdf0e10cSrcweir sal_Bool bShift = pKeyEvent->GetKeyCode().IsShift();
1280cdf0e10cSrcweir sal_Bool bCtrl = pKeyEvent->GetKeyCode().IsMod1();
1281cdf0e10cSrcweir sal_Bool bAlt = pKeyEvent->GetKeyCode().IsMod2();
1282cdf0e10cSrcweir
1283cdf0e10cSrcweir if (KEY_TAB == nCode)
1284cdf0e10cSrcweir { // somebody pressed the tab key
1285cdf0e10cSrcweir if (!bAlt && !bCtrl && !bShift)
1286cdf0e10cSrcweir { // it's really the only the key (no modifiers)
1287cdf0e10cSrcweir if (m_pImpl->pFields[m_pImpl->nLastVisibleListIndex]->HasChildPathFocus())
1288cdf0e10cSrcweir // the last of our visible list boxes has the focus
1289cdf0e10cSrcweir if (m_pImpl->nFieldScrollPos < m_aFieldScroller.GetRangeMax())
1290cdf0e10cSrcweir { // we can still scroll down
1291cdf0e10cSrcweir sal_Int32 nNextFocusList = m_pImpl->nLastVisibleListIndex + 1 - 2;
1292cdf0e10cSrcweir // -> scroll down
1293cdf0e10cSrcweir implScrollFields(m_pImpl->nFieldScrollPos + 1, sal_False, sal_True);
1294cdf0e10cSrcweir // give the left control in the "next" line the focus
1295cdf0e10cSrcweir m_pImpl->pFields[nNextFocusList]->GrabFocus();
1296cdf0e10cSrcweir // return saying "have handled this"
1297cdf0e10cSrcweir return 1;
1298cdf0e10cSrcweir }
1299cdf0e10cSrcweir }
1300cdf0e10cSrcweir else if (!bAlt && !bCtrl && bShift)
1301cdf0e10cSrcweir { // it's shift-tab
1302cdf0e10cSrcweir if (m_pImpl->pFields[0]->HasChildPathFocus())
1303cdf0e10cSrcweir // our first list box has the focus
1304cdf0e10cSrcweir if (m_pImpl->nFieldScrollPos > 0)
1305cdf0e10cSrcweir { // we can still scroll up
1306cdf0e10cSrcweir // -> scroll up
1307cdf0e10cSrcweir implScrollFields(m_pImpl->nFieldScrollPos - 1, sal_False, sal_True);
1308cdf0e10cSrcweir // give the right control in the "prebious" line the focus
1309cdf0e10cSrcweir m_pImpl->pFields[0 - 1 + 2]->GrabFocus();
1310cdf0e10cSrcweir // return saying "have handled this"
1311cdf0e10cSrcweir return 1;
1312cdf0e10cSrcweir }
1313cdf0e10cSrcweir }
1314cdf0e10cSrcweir }
1315cdf0e10cSrcweir }
1316cdf0e10cSrcweir break;
1317cdf0e10cSrcweir }
1318cdf0e10cSrcweir return ModalDialog::PreNotify(_rNEvt);
1319cdf0e10cSrcweir }
1320cdf0e10cSrcweir
1321cdf0e10cSrcweir // .......................................................................
1322cdf0e10cSrcweir } // namespace svt
1323cdf0e10cSrcweir // .......................................................................
1324cdf0e10cSrcweir
1325