xref: /aoo41x/main/sw/source/ui/dbui/mmconfigitem.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include <mmconfigitem.hxx>
27cdf0e10cSrcweir #include <swtypes.hxx>
28cdf0e10cSrcweir #include <tools/debug.hxx>
29cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
30cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
31cdf0e10cSrcweir #include <com/sun/star/sdb/XCompletedConnection.hpp>
32cdf0e10cSrcweir #include <com/sun/star/sdbc/XDataSource.hpp>
33cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
34cdf0e10cSrcweir #include "com/sun/star/mail/MailServiceType.hpp"
35cdf0e10cSrcweir #include "com/sun/star/mail/XMailService.hpp"
36cdf0e10cSrcweir #include "com/sun/star/mail/MailServiceProvider.hpp"
37cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
39cdf0e10cSrcweir #include <com/sun/star/sdbc/XRowSet.hpp>
40cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
41cdf0e10cSrcweir #include <comphelper/types.hxx>
42cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp>
43cdf0e10cSrcweir #include <unotools/configitem.hxx>
44cdf0e10cSrcweir #include <mailmergehelper.hxx>
45cdf0e10cSrcweir #include <swunohelper.hxx>
46cdf0e10cSrcweir #ifndef _DBMGR_HXX
47cdf0e10cSrcweir #include <dbmgr.hxx>
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir #ifndef _VIEW_HXX
50cdf0e10cSrcweir #include <view.hxx>
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir #include <wrtsh.hxx>
53cdf0e10cSrcweir #include <dbui.hrc>
54cdf0e10cSrcweir #include <vector>
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #include <unomid.h>
57cdf0e10cSrcweir 
58cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
59cdf0e10cSrcweir #include <svl/svstdarr.hxx>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir using namespace utl;
62cdf0e10cSrcweir using ::rtl::OUString;
63cdf0e10cSrcweir using namespace ::com::sun::star;
64cdf0e10cSrcweir using namespace ::com::sun::star::uno;
65cdf0e10cSrcweir using namespace ::com::sun::star::lang;
66cdf0e10cSrcweir using namespace ::com::sun::star::beans;
67cdf0e10cSrcweir using namespace ::com::sun::star::sdb;
68cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
69cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir const char* cAddressDataAssignments     = "AddressDataAssignments";
72cdf0e10cSrcweir const char* cDBColumnAssignments        = "DBColumnAssignments";
73cdf0e10cSrcweir const char* cDataSourceName             = "DataSource/DataSourceName";
74cdf0e10cSrcweir const char* cDataTableName              = "DataSource/DataTableName" ;
75cdf0e10cSrcweir const char* cDataCommandType            = "DataSource/DataCommandType";
76cdf0e10cSrcweir 
77cdf0e10cSrcweir #define SECURE_PORT     465
78cdf0e10cSrcweir #define DEFAULT_PORT    25
79cdf0e10cSrcweir #define POP_PORT        110
80cdf0e10cSrcweir 
81cdf0e10cSrcweir /*-- 16.04.2004 09:41:36---------------------------------------------------
82cdf0e10cSrcweir 
83cdf0e10cSrcweir   -----------------------------------------------------------------------*/
84cdf0e10cSrcweir struct DBAddressDataAssignment
85cdf0e10cSrcweir {
86cdf0e10cSrcweir     SwDBData                            aDBData;
87cdf0e10cSrcweir     Sequence< ::rtl::OUString>           aDBColumnAssignments;
88cdf0e10cSrcweir     //if loaded the name of the node has to be saved
89cdf0e10cSrcweir     ::rtl::OUString                     sConfigNodeName;
90cdf0e10cSrcweir     //all created or changed assignments need to be stored
91cdf0e10cSrcweir     bool                                bColumnAssignmentsChanged;
92cdf0e10cSrcweir 
DBAddressDataAssignmentDBAddressDataAssignment93cdf0e10cSrcweir     DBAddressDataAssignment() :
94cdf0e10cSrcweir         bColumnAssignmentsChanged(false)
95cdf0e10cSrcweir         {}
96cdf0e10cSrcweir };
97cdf0e10cSrcweir 
98cdf0e10cSrcweir /*-- 16.04.2004 09:43:29---------------------------------------------------
99cdf0e10cSrcweir 
100cdf0e10cSrcweir   -----------------------------------------------------------------------*/
101cdf0e10cSrcweir class SwMailMergeConfigItem_Impl : public utl::ConfigItem
102cdf0e10cSrcweir {
103cdf0e10cSrcweir     friend class SwMailMergeConfigItem;
104cdf0e10cSrcweir     Reference< XDataSource>                 xSource;
105cdf0e10cSrcweir     SharedConnection                        xConnection;
106cdf0e10cSrcweir     Reference< XColumnsSupplier>            xColumnsSupplier;
107cdf0e10cSrcweir     Reference< XStatement>                  xStatement;
108cdf0e10cSrcweir     Reference< XResultSet>                  xResultSet;
109cdf0e10cSrcweir     SwDBData                                aDBData;
110cdf0e10cSrcweir     ::rtl::OUString                         sFilter;
111cdf0e10cSrcweir     sal_Int32                               nResultSetCursorPos;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     ::std::vector<DBAddressDataAssignment>  aAddressDataAssignments;
114cdf0e10cSrcweir     ::std::vector< ::rtl::OUString>         aAddressBlocks;
115cdf0e10cSrcweir     sal_Int32                               nCurrentAddressBlock;
116cdf0e10cSrcweir     sal_Bool                                bIsAddressBlock;
117cdf0e10cSrcweir     sal_Bool                                bIsHideEmptyParagraphs;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     sal_Bool                                bIsOutputToLetter;
120cdf0e10cSrcweir     sal_Bool                                bIncludeCountry;
121cdf0e10cSrcweir     ::rtl::OUString                         sExcludeCountry;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     sal_Bool                                bIsGreetingLine;
124cdf0e10cSrcweir     sal_Bool                                bIsIndividualGreetingLine;
125cdf0e10cSrcweir     ::std::vector< ::rtl::OUString>         aFemaleGreetingLines;
126cdf0e10cSrcweir     sal_Int32                               nCurrentFemaleGreeting;
127cdf0e10cSrcweir     ::std::vector< ::rtl::OUString>         aMaleGreetingLines;
128cdf0e10cSrcweir     sal_Int32                               nCurrentMaleGreeting;
129cdf0e10cSrcweir     ::std::vector< ::rtl::OUString>         aNeutralGreetingLines;
130cdf0e10cSrcweir     sal_Int32                               nCurrentNeutralGreeting;
131cdf0e10cSrcweir     ::rtl::OUString                         sFemaleGenderValue;
132cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString>         aSavedDocuments;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     sal_Bool                                bIsGreetingLineInMail;
135cdf0e10cSrcweir     sal_Bool                                bIsIndividualGreetingLineInMail;
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     //mail settings
138cdf0e10cSrcweir     ::rtl::OUString                         sMailDisplayName;
139cdf0e10cSrcweir     ::rtl::OUString                         sMailAddress;
140cdf0e10cSrcweir     ::rtl::OUString                         sMailReplyTo;
141cdf0e10cSrcweir     ::rtl::OUString                         sMailServer;
142cdf0e10cSrcweir     ::rtl::OUString                         sMailUserName;
143cdf0e10cSrcweir     ::rtl::OUString                         sMailPassword;
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     sal_Bool                                bIsSMPTAfterPOP;
146cdf0e10cSrcweir     ::rtl::OUString                         sInServerName;
147cdf0e10cSrcweir     sal_Int16                               nInServerPort;
148cdf0e10cSrcweir     sal_Bool                                bInServerPOP;
149cdf0e10cSrcweir     ::rtl::OUString                         sInServerUserName;
150cdf0e10cSrcweir     ::rtl::OUString                         sInServerPassword;
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     sal_Int16                               nMailPort;
153cdf0e10cSrcweir     sal_Bool                                bIsMailReplyTo;
154cdf0e10cSrcweir     sal_Bool                                bIsDefaultPort;
155cdf0e10cSrcweir     sal_Bool                                bIsSecureConnection;
156cdf0e10cSrcweir     sal_Bool                                bIsAuthentication;
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     sal_Bool                                bIsEMailSupported;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     ResStringArray                          m_AddressHeaderSA;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     //these addresses are not stored in the configuration
163cdf0e10cSrcweir     ::std::vector< SwDocMergeInfo >         aMergeInfos;
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     //we do overwrite the usersettings in a special case
166cdf0e10cSrcweir     //than we do remind the usersettings here
167cdf0e10cSrcweir     sal_Bool                                bUserSettingWereOverwritten;
168cdf0e10cSrcweir     sal_Bool                                bIsAddressBlock_LastUserSetting;
169cdf0e10cSrcweir     sal_Bool                                bIsGreetingLineInMail_LastUserSetting;
170cdf0e10cSrcweir     sal_Bool                                bIsGreetingLine_LastUserSetting;
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     const Sequence< ::rtl::OUString>&       GetPropertyNames();
174cdf0e10cSrcweir 
175cdf0e10cSrcweir public:
176cdf0e10cSrcweir     SwMailMergeConfigItem_Impl();
177cdf0e10cSrcweir     ~SwMailMergeConfigItem_Impl();
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	virtual void Commit();
180cdf0e10cSrcweir 	virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
181cdf0e10cSrcweir     const           Sequence< ::rtl::OUString>
182cdf0e10cSrcweir                         GetAddressBlocks(sal_Bool bConvertToConfig = sal_False) const;
183cdf0e10cSrcweir     void                SetAddressBlocks(
184cdf0e10cSrcweir                                 const Sequence< ::rtl::OUString>& rBlocks,
185cdf0e10cSrcweir                                 sal_Bool bConvertFromConfig = sal_False);
186cdf0e10cSrcweir     const uno::Sequence< ::rtl::OUString>
187cdf0e10cSrcweir                         GetGreetings(SwMailMergeConfigItem::Gender eType,
188cdf0e10cSrcweir                                         sal_Bool bConvertToConfig = sal_False) const;
189cdf0e10cSrcweir     void                SetGreetings(SwMailMergeConfigItem::Gender eType,
190cdf0e10cSrcweir                                     const uno::Sequence< ::rtl::OUString>& rBlocks,
191cdf0e10cSrcweir                                     sal_Bool bConvertFromConfig = sal_False);
192cdf0e10cSrcweir 
193cdf0e10cSrcweir     void                SetCurrentAddressBlockIndex( sal_Int32 nSet );
GetCurrentAddressBlockIndex() const194cdf0e10cSrcweir     sal_Int32           GetCurrentAddressBlockIndex() const
195cdf0e10cSrcweir                         {   return nCurrentAddressBlock; }
196cdf0e10cSrcweir     sal_Int32           GetCurrentGreeting(SwMailMergeConfigItem::Gender eType) const;
197cdf0e10cSrcweir     void                SetCurrentGreeting(SwMailMergeConfigItem::Gender eType, sal_Int32 nIndex);
198cdf0e10cSrcweir 
199cdf0e10cSrcweir };
200cdf0e10cSrcweir 
201cdf0e10cSrcweir /*-- 06.05.2004 12:51:54---------------------------------------------------
202cdf0e10cSrcweir 
203cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SwMailMergeConfigItem_Impl()204cdf0e10cSrcweir SwMailMergeConfigItem_Impl::SwMailMergeConfigItem_Impl() :
205cdf0e10cSrcweir     ConfigItem(C2U("Office.Writer/MailMergeWizard"), 0),
206cdf0e10cSrcweir         nResultSetCursorPos(-1),
207cdf0e10cSrcweir         nCurrentAddressBlock(0),
208cdf0e10cSrcweir         bIsAddressBlock(sal_True),
209cdf0e10cSrcweir         bIsHideEmptyParagraphs(sal_False),
210cdf0e10cSrcweir         bIsOutputToLetter(sal_True),
211cdf0e10cSrcweir         bIncludeCountry(sal_False),
212cdf0e10cSrcweir         bIsGreetingLine(sal_True),
213cdf0e10cSrcweir         nCurrentFemaleGreeting(0),
214cdf0e10cSrcweir         nCurrentMaleGreeting(0),
215cdf0e10cSrcweir         nCurrentNeutralGreeting(0),
216cdf0e10cSrcweir 
217cdf0e10cSrcweir         bIsSMPTAfterPOP(sal_False),
218cdf0e10cSrcweir         nInServerPort( POP_PORT ),
219cdf0e10cSrcweir         bInServerPOP( sal_True ),
220cdf0e10cSrcweir         nMailPort(0),
221cdf0e10cSrcweir         bIsMailReplyTo(sal_False),
222cdf0e10cSrcweir         bIsDefaultPort(sal_False),
223cdf0e10cSrcweir         bIsSecureConnection(sal_False),
224cdf0e10cSrcweir         bIsAuthentication(sal_False),
225cdf0e10cSrcweir 
226cdf0e10cSrcweir         bIsEMailSupported(sal_False),
227cdf0e10cSrcweir         m_AddressHeaderSA( SW_RES( SA_ADDRESS_HEADER )),
228cdf0e10cSrcweir         bUserSettingWereOverwritten(sal_False),
229cdf0e10cSrcweir         bIsAddressBlock_LastUserSetting(sal_False),
230cdf0e10cSrcweir         bIsGreetingLineInMail_LastUserSetting(sal_False),
231cdf0e10cSrcweir         bIsGreetingLine_LastUserSetting(sal_False)
232cdf0e10cSrcweir {
233cdf0e10cSrcweir     const Sequence<OUString>& rNames = GetPropertyNames();
234cdf0e10cSrcweir     Sequence<Any> aValues = GetProperties(rNames);
235cdf0e10cSrcweir     const Any* pValues = aValues.getConstArray();
236cdf0e10cSrcweir     DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed");
237cdf0e10cSrcweir     if(aValues.getLength() == rNames.getLength())
238cdf0e10cSrcweir     {
239cdf0e10cSrcweir         for(int nProp = 0; nProp < rNames.getLength(); nProp++)
240cdf0e10cSrcweir         {
241cdf0e10cSrcweir             switch(nProp)
242cdf0e10cSrcweir             {
243cdf0e10cSrcweir                 case 0: pValues[nProp] >>= bIsOutputToLetter;  break;
244cdf0e10cSrcweir                 case 1: pValues[nProp] >>= bIncludeCountry; break;
245cdf0e10cSrcweir                 case 2: pValues[nProp] >>= sExcludeCountry; break;
246cdf0e10cSrcweir                 case 3:
247cdf0e10cSrcweir                 {
248cdf0e10cSrcweir                     Sequence< ::rtl::OUString> aBlocks;
249cdf0e10cSrcweir                     pValues[nProp] >>= aBlocks;
250cdf0e10cSrcweir                     SetAddressBlocks(aBlocks, sal_True);
251cdf0e10cSrcweir                 }
252cdf0e10cSrcweir                 break;
253cdf0e10cSrcweir                 case 4: pValues[nProp] >>= bIsAddressBlock; break;
254cdf0e10cSrcweir                 case 5: pValues[nProp] >>= bIsGreetingLine;   break;
255cdf0e10cSrcweir                 case 6: pValues[nProp] >>= bIsIndividualGreetingLine; break;
256cdf0e10cSrcweir                 case 7 :
257cdf0e10cSrcweir                 case 8 :
258cdf0e10cSrcweir                 case 9 :
259cdf0e10cSrcweir                 {
260cdf0e10cSrcweir                     Sequence< ::rtl::OUString> aGreetings;
261cdf0e10cSrcweir                     pValues[nProp] >>= aGreetings;
262cdf0e10cSrcweir                     SetGreetings(SwMailMergeConfigItem::Gender(
263cdf0e10cSrcweir                             SwMailMergeConfigItem::FEMALE + nProp - 7), aGreetings, sal_True);
264cdf0e10cSrcweir                 }
265cdf0e10cSrcweir                 break;
266cdf0e10cSrcweir 
267cdf0e10cSrcweir                 case 10: pValues[nProp] >>= nCurrentFemaleGreeting;     break;
268cdf0e10cSrcweir                 case 11: pValues[nProp] >>= nCurrentMaleGreeting;       break;
269cdf0e10cSrcweir                 case 12: pValues[nProp] >>= nCurrentNeutralGreeting;    break;
270cdf0e10cSrcweir                 case 13: pValues[nProp] >>= sFemaleGenderValue;   break;
271cdf0e10cSrcweir                 case 14: pValues[nProp] >>= sMailDisplayName;     break;
272cdf0e10cSrcweir                 case 15: pValues[nProp] >>= sMailAddress;         break;
273cdf0e10cSrcweir                 case 16: pValues[nProp] >>= bIsMailReplyTo;       break;
274cdf0e10cSrcweir                 case 17: pValues[nProp] >>= sMailReplyTo;         break;
275cdf0e10cSrcweir                 case 18: pValues[nProp] >>= sMailServer;          break;
276cdf0e10cSrcweir                 case 19:
277cdf0e10cSrcweir                     bIsDefaultPort =
278cdf0e10cSrcweir                             (pValues[nProp] >>= nMailPort) ?
279cdf0e10cSrcweir                                                         sal_False : sal_True;
280cdf0e10cSrcweir                 break;
281cdf0e10cSrcweir                 case 20: pValues[nProp] >>= bIsSecureConnection;           break;
282cdf0e10cSrcweir                 case 21: pValues[nProp] >>= bIsAuthentication;             break;
283cdf0e10cSrcweir                 case 22: pValues[nProp] >>= sMailUserName;                 break;
284cdf0e10cSrcweir                 case 23: pValues[nProp] >>= sMailPassword;                 break;
285cdf0e10cSrcweir                 case 24 :pValues[nProp] >>= aDBData.sDataSource;           break;
286cdf0e10cSrcweir                 case 25 :pValues[nProp] >>= aDBData.sCommand;              break;
287cdf0e10cSrcweir                 case 26 :
288cdf0e10cSrcweir                 {
289cdf0e10cSrcweir                     short nTemp = 0;
290cdf0e10cSrcweir                     if(pValues[nProp] >>= nTemp)
291cdf0e10cSrcweir                         aDBData.nCommandType = nTemp;
292cdf0e10cSrcweir                 }
293cdf0e10cSrcweir                 break;
294cdf0e10cSrcweir                 case 27: pValues[nProp] >>= sFilter; break;
295cdf0e10cSrcweir                 case 28: pValues[nProp] >>= aSavedDocuments; break;
296cdf0e10cSrcweir                 case 29:
297cdf0e10cSrcweir                     pValues[nProp] >>= bIsEMailSupported;
298cdf0e10cSrcweir                 break;
299cdf0e10cSrcweir                 case 30: pValues[nProp] >>= bIsGreetingLineInMail; break;
300cdf0e10cSrcweir                 case 31: pValues[nProp] >>= bIsIndividualGreetingLineInMail; break;
301cdf0e10cSrcweir                 case 32: pValues[nProp] >>= bIsSMPTAfterPOP; break;
302cdf0e10cSrcweir                 case 33: pValues[nProp] >>= sInServerName;    break;
303cdf0e10cSrcweir                 case 34: pValues[nProp] >>= nInServerPort;    break;
304cdf0e10cSrcweir                 case 35: pValues[nProp] >>= bInServerPOP; break;
305cdf0e10cSrcweir                 case 36: pValues[nProp] >>= sInServerUserName; break;
306cdf0e10cSrcweir                 case 37: pValues[nProp] >>= sInServerPassword; break;
307cdf0e10cSrcweir                 case 38: pValues[nProp] >>= bIsHideEmptyParagraphs; break;
308cdf0e10cSrcweir                 case 39: pValues[nProp] >>= nCurrentAddressBlock; break;
309cdf0e10cSrcweir             }
310cdf0e10cSrcweir         }
311cdf0e10cSrcweir     }
312cdf0e10cSrcweir     //read the list of data base assignments
313cdf0e10cSrcweir     Sequence<OUString> aAssignments = GetNodeNames(C2U(cAddressDataAssignments));
314cdf0e10cSrcweir     if(aAssignments.getLength())
315cdf0e10cSrcweir     {
316cdf0e10cSrcweir         //create a list of property names to load the URLs of all data bases
317cdf0e10cSrcweir         const OUString* pAssignments = aAssignments.getConstArray();
318cdf0e10cSrcweir         Sequence< ::rtl::OUString > aAssignProperties(4 * aAssignments.getLength());
319cdf0e10cSrcweir         ::rtl::OUString* pAssignProperties = aAssignProperties.getArray();
320cdf0e10cSrcweir         sal_Int32 nAssign;
321cdf0e10cSrcweir         OUString sSlash = C2U("/");
322cdf0e10cSrcweir         for(nAssign = 0; nAssign < aAssignProperties.getLength(); nAssign += 4)
323cdf0e10cSrcweir         {
324cdf0e10cSrcweir             String sAssignPath = C2U(cAddressDataAssignments);
325cdf0e10cSrcweir             sAssignPath += '/';
326cdf0e10cSrcweir             sAssignPath += String(pAssignments[nAssign / 4]);
327cdf0e10cSrcweir             sAssignPath += '/';
328cdf0e10cSrcweir             pAssignProperties[nAssign] = sAssignPath;
329cdf0e10cSrcweir             pAssignProperties[nAssign] += C2U(cDataSourceName);
330cdf0e10cSrcweir             pAssignProperties[nAssign + 1] = sAssignPath;
331cdf0e10cSrcweir             pAssignProperties[nAssign + 1] += C2U(cDataTableName);
332cdf0e10cSrcweir             pAssignProperties[nAssign + 2] = sAssignPath;
333cdf0e10cSrcweir             pAssignProperties[nAssign + 2] += C2U(cDataCommandType);
334cdf0e10cSrcweir             pAssignProperties[nAssign + 3] = sAssignPath;
335cdf0e10cSrcweir             pAssignProperties[nAssign + 3] += C2U(cDBColumnAssignments);
336cdf0e10cSrcweir         }
337cdf0e10cSrcweir         Sequence<Any> aAssignValues = GetProperties(aAssignProperties);
338cdf0e10cSrcweir         const Any* pAssignValues = aAssignValues.getConstArray();
339cdf0e10cSrcweir         for(nAssign = 0; nAssign < aAssignValues.getLength(); nAssign += 4 )
340cdf0e10cSrcweir         {
341cdf0e10cSrcweir             DBAddressDataAssignment aAssignment;
342cdf0e10cSrcweir             pAssignValues[nAssign] >>=      aAssignment.aDBData.sDataSource;
343cdf0e10cSrcweir             pAssignValues[nAssign + 1] >>=  aAssignment.aDBData.sCommand;
344cdf0e10cSrcweir             pAssignValues[nAssign + 2] >>=  aAssignment.aDBData.nCommandType;
345cdf0e10cSrcweir             pAssignValues[nAssign + 3] >>=  aAssignment.aDBColumnAssignments;
346cdf0e10cSrcweir             aAssignment.sConfigNodeName = pAssignments[nAssign / 4];
347cdf0e10cSrcweir             aAddressDataAssignments.push_back(aAssignment);
348cdf0e10cSrcweir         }
349cdf0e10cSrcweir     }
350cdf0e10cSrcweir     //check if the saved documents still exist
351cdf0e10cSrcweir     if(aSavedDocuments.getLength())
352cdf0e10cSrcweir     {
353cdf0e10cSrcweir         uno::Sequence< ::rtl::OUString > aTempDocuments(aSavedDocuments.getLength());
354cdf0e10cSrcweir         ::rtl::OUString* pTempDocuments = aTempDocuments.getArray();
355cdf0e10cSrcweir         sal_Int32 nIndex = 0;
356cdf0e10cSrcweir         for(sal_Int32 i = 0; i < aSavedDocuments.getLength(); ++i)
357cdf0e10cSrcweir         {
358cdf0e10cSrcweir             if(SWUnoHelper::UCB_IsFile( aSavedDocuments[i] ))
359cdf0e10cSrcweir             {
360cdf0e10cSrcweir                 pTempDocuments[nIndex++] = aSavedDocuments[i];
361cdf0e10cSrcweir             }
362cdf0e10cSrcweir         }
363cdf0e10cSrcweir         if(nIndex < aSavedDocuments.getLength())
364cdf0e10cSrcweir         {
365cdf0e10cSrcweir             aSavedDocuments = aTempDocuments;
366cdf0e10cSrcweir             aSavedDocuments.realloc(nIndex);
367cdf0e10cSrcweir         }
368cdf0e10cSrcweir     }
369cdf0e10cSrcweir 
370cdf0e10cSrcweir }
371cdf0e10cSrcweir /*-- 06.05.2004 12:51:54---------------------------------------------------
372cdf0e10cSrcweir 
373cdf0e10cSrcweir   -----------------------------------------------------------------------*/
~SwMailMergeConfigItem_Impl()374cdf0e10cSrcweir SwMailMergeConfigItem_Impl::~SwMailMergeConfigItem_Impl()
375cdf0e10cSrcweir {
376cdf0e10cSrcweir }
377cdf0e10cSrcweir /*-- 13.03.2006 12:12:59---------------------------------------------------
378cdf0e10cSrcweir 
379cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetCurrentAddressBlockIndex(sal_Int32 nSet)380cdf0e10cSrcweir void SwMailMergeConfigItem_Impl::SetCurrentAddressBlockIndex( sal_Int32 nSet )
381cdf0e10cSrcweir {
382cdf0e10cSrcweir     if(aAddressBlocks.size() >= sal::static_int_cast<sal_uInt32, sal_Int32>(nSet))
383cdf0e10cSrcweir     {
384cdf0e10cSrcweir         nCurrentAddressBlock = nSet;
385cdf0e10cSrcweir         SetModified();
386cdf0e10cSrcweir     }
387cdf0e10cSrcweir }
388cdf0e10cSrcweir /*-- 16.04.2004 13:06:07---------------------------------------------------
389cdf0e10cSrcweir 
390cdf0e10cSrcweir   -----------------------------------------------------------------------*/
lcl_CreateNodeName(Sequence<OUString> & rAssignments)391cdf0e10cSrcweir OUString lcl_CreateNodeName(Sequence<OUString>& rAssignments )
392cdf0e10cSrcweir {
393cdf0e10cSrcweir     const OUString* pNames = rAssignments.getConstArray();
394cdf0e10cSrcweir     sal_Int32 nStart = rAssignments.getLength();
395cdf0e10cSrcweir     OUString sNewName;
396cdf0e10cSrcweir     bool bFound;
397cdf0e10cSrcweir     do
398cdf0e10cSrcweir     {
399cdf0e10cSrcweir         bFound = false;
400cdf0e10cSrcweir         sNewName = C2U("_");
401cdf0e10cSrcweir         sNewName += OUString::valueOf(nStart);
402cdf0e10cSrcweir         //search if the name exists
403cdf0e10cSrcweir         for(sal_Int32 nAssign = 0; nAssign < rAssignments.getLength(); ++nAssign)
404cdf0e10cSrcweir         {
405cdf0e10cSrcweir             if(pNames[nAssign] == sNewName)
406cdf0e10cSrcweir             {
407cdf0e10cSrcweir                 bFound = true;
408cdf0e10cSrcweir                 ++nStart;
409cdf0e10cSrcweir                 break;
410cdf0e10cSrcweir             }
411cdf0e10cSrcweir         }
412cdf0e10cSrcweir     }
413cdf0e10cSrcweir     while(bFound);
414cdf0e10cSrcweir     // add the new name to the array of existing names
415cdf0e10cSrcweir     rAssignments.realloc(rAssignments.getLength() + 1);
416cdf0e10cSrcweir     rAssignments.getArray()[rAssignments.getLength() - 1] = sNewName;
417cdf0e10cSrcweir     return sNewName;
418cdf0e10cSrcweir }
419cdf0e10cSrcweir // --------------------------------------------------------------------------------
lcl_ConvertToNumbers(OUString & rBlock,const ResStringArray & rHeaders)420cdf0e10cSrcweir void lcl_ConvertToNumbers(OUString& rBlock, const ResStringArray& rHeaders )
421cdf0e10cSrcweir {
422cdf0e10cSrcweir     //convert the strings used for UI to numbers used for the configuration
423cdf0e10cSrcweir     String sBlock(rBlock);
424cdf0e10cSrcweir     sBlock.SearchAndReplaceAllAscii("\n", String::CreateFromAscii("\\n"));
425cdf0e10cSrcweir     for(sal_uInt16 i = 0; i < rHeaders.Count(); ++i)
426cdf0e10cSrcweir     {
427cdf0e10cSrcweir         String sHeader = rHeaders.GetString( i );
428cdf0e10cSrcweir         sHeader.Insert('<', 0);
429cdf0e10cSrcweir         sHeader += '>';
430cdf0e10cSrcweir         String sReplace(C2U("<>"));
431cdf0e10cSrcweir         sReplace.Insert('0' + i, 1);
432cdf0e10cSrcweir         sBlock.SearchAndReplaceAll(sHeader, sReplace);
433cdf0e10cSrcweir     }
434cdf0e10cSrcweir     rBlock = sBlock;
435cdf0e10cSrcweir }
436cdf0e10cSrcweir // --------------------------------------------------------------------------------
lcl_ConvertFromNumbers(OUString & rBlock,const ResStringArray & rHeaders)437cdf0e10cSrcweir void lcl_ConvertFromNumbers(OUString& rBlock, const ResStringArray& rHeaders)
438cdf0e10cSrcweir {
439cdf0e10cSrcweir     //convert the numbers used for the configuration to strings used for UI to numbers
440cdf0e10cSrcweir     //doesn't use ReplaceAll to prevent expansion of numbers inside of the headers
441cdf0e10cSrcweir     String sBlock(rBlock);
442cdf0e10cSrcweir     sBlock.SearchAndReplaceAllAscii("\\n", '\n');
443cdf0e10cSrcweir     SwAddressIterator aGreetingIter(sBlock);
444cdf0e10cSrcweir     sBlock.Erase();
445cdf0e10cSrcweir     while(aGreetingIter.HasMore())
446cdf0e10cSrcweir     {
447cdf0e10cSrcweir         SwMergeAddressItem aNext = aGreetingIter.Next();
448cdf0e10cSrcweir         if(aNext.bIsColumn)
449cdf0e10cSrcweir         {
450cdf0e10cSrcweir             //the text should be 1 characters long
451cdf0e10cSrcweir             sal_Unicode cChar = aNext.sText.GetChar(0);
452cdf0e10cSrcweir             if(cChar >= '0' && cChar <= 'c')
453cdf0e10cSrcweir             {
454cdf0e10cSrcweir                 sBlock += '<';
455cdf0e10cSrcweir                 sal_uInt16 nHeader = cChar - '0';
456cdf0e10cSrcweir                 if(nHeader < rHeaders.Count())
457cdf0e10cSrcweir                     sBlock += rHeaders.GetString( nHeader );
458cdf0e10cSrcweir                 sBlock += '>';
459cdf0e10cSrcweir             }
460cdf0e10cSrcweir             else
461cdf0e10cSrcweir             {
462cdf0e10cSrcweir                 DBG_ERROR("parse error in address block or greeting line");
463cdf0e10cSrcweir             }
464cdf0e10cSrcweir         }
465cdf0e10cSrcweir         else
466cdf0e10cSrcweir             sBlock += aNext.sText;
467cdf0e10cSrcweir     }
468cdf0e10cSrcweir     rBlock = sBlock;
469cdf0e10cSrcweir }
470cdf0e10cSrcweir 
471cdf0e10cSrcweir /*--------------------------------------------------------------------
472cdf0e10cSrcweir 
473cdf0e10cSrcweir  --------------------------------------------------------------------*/
GetPropertyNames()474cdf0e10cSrcweir const Sequence<OUString>& SwMailMergeConfigItem_Impl::GetPropertyNames()
475cdf0e10cSrcweir {
476cdf0e10cSrcweir     static Sequence<OUString> aNames;
477cdf0e10cSrcweir     if(!aNames.getLength())
478cdf0e10cSrcweir     {
479cdf0e10cSrcweir         static const char* aPropNames[] =
480cdf0e10cSrcweir         {
481cdf0e10cSrcweir             "OutputToLetter",           // 0
482cdf0e10cSrcweir             "IncludeCountry",           // 1
483cdf0e10cSrcweir             "ExcludeCountry",           // 2
484cdf0e10cSrcweir             "AddressBlockSettings",     // 3
485cdf0e10cSrcweir             "IsAddressBlock",          // 4
486cdf0e10cSrcweir             "IsGreetingLine",           // 5
487cdf0e10cSrcweir             "IsIndividualGreetingLine", // 6
488cdf0e10cSrcweir             "FemaleGreetingLines",      // 7
489cdf0e10cSrcweir             "MaleGreetingLines",        // 8
490cdf0e10cSrcweir             "NeutralGreetingLines",     // 9
491cdf0e10cSrcweir             "CurrentFemaleGreeting",    // 10
492cdf0e10cSrcweir             "CurrentMaleGreeting",      // 11
493cdf0e10cSrcweir             "CurrentNeutralGreeting",   // 12
494cdf0e10cSrcweir             "FemaleGenderValue",        // 13
495cdf0e10cSrcweir             "MailDisplayName",          // 14
496cdf0e10cSrcweir             "MailAddress",              // 15
497cdf0e10cSrcweir             "IsMailReplyTo",            // 16
498cdf0e10cSrcweir             "MailReplyTo",              // 17
499cdf0e10cSrcweir             "MailServer",               // 18
500cdf0e10cSrcweir             "MailPort",                 // 19
501cdf0e10cSrcweir             "IsSecureConnection",       // 20
502cdf0e10cSrcweir             "IsAuthentication",         // 21
503cdf0e10cSrcweir             "MailUserName",             // 22
504cdf0e10cSrcweir             "MailPassword",             // 23
505cdf0e10cSrcweir             "DataSource/DataSourceName",// 24
506cdf0e10cSrcweir             "DataSource/DataTableName", // 25
507cdf0e10cSrcweir             "DataSource/DataCommandType",// 26
508cdf0e10cSrcweir             "Filter",                   // 27
509cdf0e10cSrcweir             "SavedDocuments",           // 28
510cdf0e10cSrcweir             "EMailSupported",            // 29
511cdf0e10cSrcweir             "IsEMailGreetingLine",              //30
512cdf0e10cSrcweir             "IsEMailIndividualGreetingLine",     //31
513cdf0e10cSrcweir             "IsSMPTAfterPOP",                    //32
514cdf0e10cSrcweir             "InServerName",                      //33
515cdf0e10cSrcweir             "InServerPort",                      //34
516cdf0e10cSrcweir             "InServerIsPOP",                     //35
517cdf0e10cSrcweir             "InServerUserName",                  //36
518cdf0e10cSrcweir             "InServerPassword",                   //37
519cdf0e10cSrcweir             "IsHideEmptyParagraphs",             //38
520cdf0e10cSrcweir             "CurrentAddressBlock"               //39
521cdf0e10cSrcweir 
522cdf0e10cSrcweir         };
523cdf0e10cSrcweir         const int nCount = sizeof(aPropNames)/sizeof(const char*);
524cdf0e10cSrcweir         aNames.realloc(nCount);
525cdf0e10cSrcweir         OUString* pNames = aNames.getArray();
526cdf0e10cSrcweir         for(int i = 0; i < nCount; i++)
527cdf0e10cSrcweir             pNames[i] = OUString::createFromAscii(aPropNames[i]);
528cdf0e10cSrcweir     }
529cdf0e10cSrcweir     return aNames;
530cdf0e10cSrcweir }
531cdf0e10cSrcweir /*-- 15.04.2004 08:48:39---------------------------------------------------
532cdf0e10cSrcweir 
533cdf0e10cSrcweir   -----------------------------------------------------------------------*/
Notify(const::com::sun::star::uno::Sequence<rtl::OUString> &)534cdf0e10cSrcweir void SwMailMergeConfigItem_Impl::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
535cdf0e10cSrcweir 
Commit()536cdf0e10cSrcweir void  SwMailMergeConfigItem_Impl::Commit()
537cdf0e10cSrcweir {
538cdf0e10cSrcweir     Sequence<OUString> aNames = GetPropertyNames();
539cdf0e10cSrcweir     Sequence<Any> aValues(aNames.getLength());
540cdf0e10cSrcweir     Any* pValues = aValues.getArray();
541cdf0e10cSrcweir 
542cdf0e10cSrcweir     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
543cdf0e10cSrcweir     {
544cdf0e10cSrcweir         switch(nProp)
545cdf0e10cSrcweir         {
546cdf0e10cSrcweir             case 0: pValues[nProp] <<= bIsOutputToLetter; break;//
547cdf0e10cSrcweir             case 1: pValues[nProp] <<= bIncludeCountry; break;
548cdf0e10cSrcweir             case 2: pValues[nProp] <<= sExcludeCountry; break;
549cdf0e10cSrcweir             case 3: pValues[nProp] <<= GetAddressBlocks(sal_True); break;
550cdf0e10cSrcweir             case 4:
551cdf0e10cSrcweir                 {
552cdf0e10cSrcweir                     if( bUserSettingWereOverwritten == sal_True )
553cdf0e10cSrcweir                         pValues[nProp] <<= bIsAddressBlock_LastUserSetting;
554cdf0e10cSrcweir                     else
555cdf0e10cSrcweir                         pValues[nProp] <<= bIsAddressBlock;
556cdf0e10cSrcweir                     break;
557cdf0e10cSrcweir                 }
558cdf0e10cSrcweir             case 5:
559cdf0e10cSrcweir                 {
560cdf0e10cSrcweir                     if( bUserSettingWereOverwritten == sal_True )
561cdf0e10cSrcweir                         pValues[nProp] <<= bIsGreetingLine_LastUserSetting;
562cdf0e10cSrcweir                     else
563cdf0e10cSrcweir                         pValues[nProp] <<= bIsGreetingLine;
564cdf0e10cSrcweir                     break;
565cdf0e10cSrcweir                 }
566cdf0e10cSrcweir             case 6: pValues[nProp] <<= bIsIndividualGreetingLine;  break;
567cdf0e10cSrcweir             case 7:
568cdf0e10cSrcweir             case 8:
569cdf0e10cSrcweir             case 9:
570cdf0e10cSrcweir                 pValues[nProp] <<= GetGreetings(
571cdf0e10cSrcweir                         SwMailMergeConfigItem::Gender(
572cdf0e10cSrcweir                             SwMailMergeConfigItem::FEMALE + nProp - 7), sal_True);
573cdf0e10cSrcweir             break;
574cdf0e10cSrcweir             case 10: pValues[nProp] <<= nCurrentFemaleGreeting;     break;
575cdf0e10cSrcweir             case 11: pValues[nProp] <<= nCurrentMaleGreeting;       break;
576cdf0e10cSrcweir             case 12: pValues[nProp] <<= nCurrentNeutralGreeting;    break;
577cdf0e10cSrcweir             case 13: pValues[nProp] <<= sFemaleGenderValue;     break;
578cdf0e10cSrcweir             case 14: pValues[nProp] <<= sMailDisplayName;     break;
579cdf0e10cSrcweir             case 15: pValues[nProp] <<= sMailAddress;         break;
580cdf0e10cSrcweir             case 16: pValues[nProp] <<= bIsMailReplyTo;        break;
581cdf0e10cSrcweir             case 17: pValues[nProp] <<= sMailReplyTo;         break;
582cdf0e10cSrcweir             case 18: pValues[nProp] <<= sMailServer;          break;
583cdf0e10cSrcweir             case 19: if(!bIsDefaultPort)
584cdf0e10cSrcweir                         pValues[nProp] <<= nMailPort;
585cdf0e10cSrcweir             break;
586cdf0e10cSrcweir             case 20: pValues[nProp] <<= bIsSecureConnection;  break;
587cdf0e10cSrcweir             case 21: pValues[nProp] <<= bIsAuthentication;    break;
588cdf0e10cSrcweir             case 22: pValues[nProp] <<= sMailUserName;        break;
589cdf0e10cSrcweir             case 23: pValues[nProp] <<= sMailPassword;        break;
590cdf0e10cSrcweir             case 24 :pValues[nProp] <<= aDBData.sDataSource;           break;
591cdf0e10cSrcweir             case 25 :pValues[nProp] <<= aDBData.sCommand;              break;
592cdf0e10cSrcweir             case 26 :pValues[nProp] <<= (short)aDBData.nCommandType;   break;
593cdf0e10cSrcweir             case 27 :pValues[nProp] <<= sFilter; break;
594cdf0e10cSrcweir             case 28 :pValues[nProp] <<= aSavedDocuments; break;
595cdf0e10cSrcweir             case 29: pValues[nProp] <<= bIsEMailSupported; break;
596cdf0e10cSrcweir             case 30:
597cdf0e10cSrcweir                 {
598cdf0e10cSrcweir                     if( bUserSettingWereOverwritten == sal_True )
599cdf0e10cSrcweir                         pValues[nProp] <<= bIsGreetingLineInMail_LastUserSetting;
600cdf0e10cSrcweir                     else
601cdf0e10cSrcweir                         pValues[nProp] <<= bIsGreetingLineInMail;
602cdf0e10cSrcweir                     break;
603cdf0e10cSrcweir                 }
604cdf0e10cSrcweir             case 31: pValues[nProp] <<= bIsIndividualGreetingLineInMail; break;
605cdf0e10cSrcweir             case 32: pValues[nProp] <<= bIsSMPTAfterPOP; break;
606cdf0e10cSrcweir             case 33: pValues[nProp] <<= sInServerName;    break;
607cdf0e10cSrcweir             case 34: pValues[nProp] <<= nInServerPort;    break;
608cdf0e10cSrcweir             case 35: pValues[nProp] <<= bInServerPOP; break;
609cdf0e10cSrcweir             case 36: pValues[nProp] <<= sInServerUserName; break;
610cdf0e10cSrcweir             case 37: pValues[nProp] <<= sInServerPassword; break;
611cdf0e10cSrcweir             case 38: pValues[nProp] <<= bIsHideEmptyParagraphs; break;
612cdf0e10cSrcweir             case 39: pValues[nProp] <<= nCurrentAddressBlock; break;
613cdf0e10cSrcweir         }
614cdf0e10cSrcweir     }
615cdf0e10cSrcweir     PutProperties(aNames, aValues);
616cdf0e10cSrcweir     //store the changed / new assignments
617cdf0e10cSrcweir 
618cdf0e10cSrcweir     //load the existing node names to find new names
619cdf0e10cSrcweir     Sequence<OUString> aAssignments = GetNodeNames(C2U(cAddressDataAssignments));
620cdf0e10cSrcweir 
621cdf0e10cSrcweir     ::std::vector<DBAddressDataAssignment>::iterator aAssignIter;
622cdf0e10cSrcweir     for(aAssignIter = aAddressDataAssignments.begin();
623cdf0e10cSrcweir                 aAssignIter != aAddressDataAssignments.end(); aAssignIter++)
624cdf0e10cSrcweir     {
625cdf0e10cSrcweir         if(aAssignIter->bColumnAssignmentsChanged)
626cdf0e10cSrcweir         {
627cdf0e10cSrcweir             //create a new node name
628cdf0e10cSrcweir             OUString sNewNode = aAssignIter->sConfigNodeName.getLength() ?
629cdf0e10cSrcweir                         aAssignIter->sConfigNodeName :
630cdf0e10cSrcweir                         lcl_CreateNodeName(aAssignments);
631cdf0e10cSrcweir             OUString sSlash = C2U("/");
632cdf0e10cSrcweir             OUString sNodePath = C2U(cAddressDataAssignments);
633cdf0e10cSrcweir             sNodePath += sSlash;
634cdf0e10cSrcweir             sNodePath += sNewNode;
635cdf0e10cSrcweir             sNodePath += sSlash;
636cdf0e10cSrcweir             //only one new entry is written
637cdf0e10cSrcweir             Sequence< PropertyValue > aNewValues(4);
638cdf0e10cSrcweir             PropertyValue* pNewValues = aNewValues.getArray();
639cdf0e10cSrcweir             pNewValues[0].Name = sNodePath;
640cdf0e10cSrcweir             pNewValues[0].Name += C2U(cDataSourceName);
641cdf0e10cSrcweir             pNewValues[0].Value <<= aAssignIter->aDBData.sDataSource;
642cdf0e10cSrcweir             pNewValues[1].Name = sNodePath;
643cdf0e10cSrcweir             pNewValues[1].Name += C2U(cDataTableName);
644cdf0e10cSrcweir             pNewValues[1].Value <<= aAssignIter->aDBData.sCommand;
645cdf0e10cSrcweir             pNewValues[2].Name = sNodePath;
646cdf0e10cSrcweir             pNewValues[2].Name += C2U(cDataCommandType);
647cdf0e10cSrcweir             pNewValues[2].Value <<= aAssignIter->aDBData.nCommandType;
648cdf0e10cSrcweir             pNewValues[3].Name = sNodePath;
649cdf0e10cSrcweir             pNewValues[3].Name += C2U(cDBColumnAssignments);
650cdf0e10cSrcweir             pNewValues[3].Value <<= aAssignIter->aDBColumnAssignments;
651cdf0e10cSrcweir 
652cdf0e10cSrcweir             SetSetProperties(C2U(cAddressDataAssignments), aNewValues);
653cdf0e10cSrcweir         }
654cdf0e10cSrcweir     }
655cdf0e10cSrcweir 
656cdf0e10cSrcweir     bUserSettingWereOverwritten = sal_False;
657cdf0e10cSrcweir }
658cdf0e10cSrcweir /*-- 06.05.2004 13:04:36---------------------------------------------------
659cdf0e10cSrcweir 
660cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetAddressBlocks(sal_Bool bConvertToConfig) const661cdf0e10cSrcweir const Sequence< ::rtl::OUString> SwMailMergeConfigItem_Impl::GetAddressBlocks(
662cdf0e10cSrcweir         sal_Bool bConvertToConfig) const
663cdf0e10cSrcweir {
664cdf0e10cSrcweir     Sequence< ::rtl::OUString> aRet(aAddressBlocks.size());
665cdf0e10cSrcweir     ::rtl::OUString* pRet = aRet.getArray();
666cdf0e10cSrcweir     for(sal_uInt32 nBlock = 0; nBlock < aAddressBlocks.size(); nBlock++)
667cdf0e10cSrcweir     {
668cdf0e10cSrcweir         pRet[nBlock] = aAddressBlocks[nBlock];
669cdf0e10cSrcweir         if(bConvertToConfig)
670cdf0e10cSrcweir             lcl_ConvertToNumbers(pRet[nBlock], m_AddressHeaderSA);
671cdf0e10cSrcweir     }
672cdf0e10cSrcweir     return aRet;
673cdf0e10cSrcweir }
674cdf0e10cSrcweir /*-- 06.05.2004 13:04:36---------------------------------------------------
675cdf0e10cSrcweir 
676cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetAddressBlocks(const Sequence<::rtl::OUString> & rBlocks,sal_Bool bConvertFromConfig)677cdf0e10cSrcweir void SwMailMergeConfigItem_Impl::SetAddressBlocks(
678cdf0e10cSrcweir         const Sequence< ::rtl::OUString>& rBlocks,
679cdf0e10cSrcweir         sal_Bool bConvertFromConfig)
680cdf0e10cSrcweir {
681cdf0e10cSrcweir     aAddressBlocks.clear();
682cdf0e10cSrcweir     for(sal_Int32 nBlock = 0; nBlock < rBlocks.getLength(); nBlock++)
683cdf0e10cSrcweir     {
684cdf0e10cSrcweir         OUString sBlock = rBlocks[nBlock];
685cdf0e10cSrcweir         if(bConvertFromConfig)
686cdf0e10cSrcweir             lcl_ConvertFromNumbers(sBlock, m_AddressHeaderSA);
687cdf0e10cSrcweir         aAddressBlocks.push_back(sBlock);
688cdf0e10cSrcweir     }
689cdf0e10cSrcweir     nCurrentAddressBlock = 0;
690cdf0e10cSrcweir     SetModified();
691cdf0e10cSrcweir }
692cdf0e10cSrcweir /*-- 30.04.2004 11:04:52---------------------------------------------------
693cdf0e10cSrcweir 
694cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetGreetings(SwMailMergeConfigItem::Gender eType,sal_Bool bConvertToConfig) const695cdf0e10cSrcweir const Sequence< ::rtl::OUString>   SwMailMergeConfigItem_Impl::GetGreetings(
696cdf0e10cSrcweir         SwMailMergeConfigItem::Gender eType, sal_Bool bConvertToConfig) const
697cdf0e10cSrcweir {
698cdf0e10cSrcweir     const ::std::vector< ::rtl::OUString>& rGreetings =
699cdf0e10cSrcweir             eType == SwMailMergeConfigItem::FEMALE ? aFemaleGreetingLines :
700cdf0e10cSrcweir             eType == SwMailMergeConfigItem::MALE ? aMaleGreetingLines :
701cdf0e10cSrcweir                                 aNeutralGreetingLines;
702cdf0e10cSrcweir     Sequence< ::rtl::OUString> aRet(rGreetings.size());
703cdf0e10cSrcweir     ::rtl::OUString* pRet = aRet.getArray();
704cdf0e10cSrcweir     for(sal_uInt32 nGreeting = 0; nGreeting < rGreetings.size(); nGreeting++)
705cdf0e10cSrcweir     {
706cdf0e10cSrcweir         pRet[nGreeting] = rGreetings[nGreeting];
707cdf0e10cSrcweir         if(bConvertToConfig)
708cdf0e10cSrcweir             lcl_ConvertToNumbers(pRet[nGreeting], m_AddressHeaderSA);
709cdf0e10cSrcweir     }
710cdf0e10cSrcweir     return aRet;
711cdf0e10cSrcweir }
712cdf0e10cSrcweir /*-- 30.04.2004 11:04:52---------------------------------------------------
713cdf0e10cSrcweir 
714cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetGreetings(SwMailMergeConfigItem::Gender eType,const Sequence<::rtl::OUString> & rSetGreetings,sal_Bool bConvertFromConfig)715cdf0e10cSrcweir void  SwMailMergeConfigItem_Impl::SetGreetings(
716cdf0e10cSrcweir         SwMailMergeConfigItem::Gender eType,
717cdf0e10cSrcweir         const Sequence< ::rtl::OUString>& rSetGreetings,
718cdf0e10cSrcweir         sal_Bool bConvertFromConfig)
719cdf0e10cSrcweir {
720cdf0e10cSrcweir     ::std::vector< ::rtl::OUString>& rGreetings =
721cdf0e10cSrcweir             eType == SwMailMergeConfigItem::FEMALE ? aFemaleGreetingLines :
722cdf0e10cSrcweir             eType == SwMailMergeConfigItem::MALE ? aMaleGreetingLines :
723cdf0e10cSrcweir                                 aNeutralGreetingLines;
724cdf0e10cSrcweir 
725cdf0e10cSrcweir     rGreetings.clear();
726cdf0e10cSrcweir     for(sal_Int32 nGreeting = 0; nGreeting < rSetGreetings.getLength(); nGreeting++)
727cdf0e10cSrcweir     {
728cdf0e10cSrcweir         OUString sGreeting = rSetGreetings[nGreeting];
729cdf0e10cSrcweir         if(bConvertFromConfig)
730cdf0e10cSrcweir             lcl_ConvertFromNumbers(sGreeting, m_AddressHeaderSA);
731cdf0e10cSrcweir         rGreetings.push_back(sGreeting);
732cdf0e10cSrcweir     }
733cdf0e10cSrcweir     SetModified();
734cdf0e10cSrcweir }
735cdf0e10cSrcweir /*-- 11.05.2004 13:13:54---------------------------------------------------
736cdf0e10cSrcweir 
737cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetCurrentGreeting(SwMailMergeConfigItem::Gender eType) const738cdf0e10cSrcweir sal_Int32 SwMailMergeConfigItem_Impl::GetCurrentGreeting(
739cdf0e10cSrcweir                             SwMailMergeConfigItem::Gender eType) const
740cdf0e10cSrcweir {
741cdf0e10cSrcweir     sal_Int32 nRet;
742cdf0e10cSrcweir     switch(eType)
743cdf0e10cSrcweir     {
744cdf0e10cSrcweir         case SwMailMergeConfigItem::FEMALE: nRet = nCurrentFemaleGreeting ; break;
745cdf0e10cSrcweir         case SwMailMergeConfigItem::MALE:   nRet = nCurrentMaleGreeting   ; break;
746cdf0e10cSrcweir         default:                       nRet = nCurrentNeutralGreeting; break;
747cdf0e10cSrcweir     }
748cdf0e10cSrcweir     return nRet;
749cdf0e10cSrcweir }
750cdf0e10cSrcweir /*-- 11.05.2004 13:13:54---------------------------------------------------
751cdf0e10cSrcweir 
752cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetCurrentGreeting(SwMailMergeConfigItem::Gender eType,sal_Int32 nIndex)753cdf0e10cSrcweir void SwMailMergeConfigItem_Impl::SetCurrentGreeting(
754cdf0e10cSrcweir         SwMailMergeConfigItem::Gender eType, sal_Int32 nIndex)
755cdf0e10cSrcweir {
756cdf0e10cSrcweir     bool bChanged = false;
757cdf0e10cSrcweir     switch(eType)
758cdf0e10cSrcweir     {
759cdf0e10cSrcweir         case SwMailMergeConfigItem::FEMALE:
760cdf0e10cSrcweir             bChanged = nCurrentFemaleGreeting != nIndex;
761cdf0e10cSrcweir             nCurrentFemaleGreeting = nIndex;
762cdf0e10cSrcweir         break;
763cdf0e10cSrcweir         case SwMailMergeConfigItem::MALE:
764cdf0e10cSrcweir             bChanged = nCurrentMaleGreeting != nIndex;
765cdf0e10cSrcweir             nCurrentMaleGreeting = nIndex;
766cdf0e10cSrcweir         break;
767cdf0e10cSrcweir         default:
768cdf0e10cSrcweir             bChanged = nCurrentNeutralGreeting != nIndex;
769cdf0e10cSrcweir             nCurrentNeutralGreeting = nIndex;
770cdf0e10cSrcweir     }
771cdf0e10cSrcweir     if(bChanged)
772cdf0e10cSrcweir         SetModified();
773cdf0e10cSrcweir }
774cdf0e10cSrcweir 
775cdf0e10cSrcweir static SwMailMergeConfigItem_Impl* pOptions = NULL;
776cdf0e10cSrcweir static sal_Int32            nRefCount = 0;
777cdf0e10cSrcweir static ::osl::Mutex aMutex;
778cdf0e10cSrcweir /*-- 15.04.2004 08:42:43---------------------------------------------------
779cdf0e10cSrcweir 
780cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SwMailMergeConfigItem()781cdf0e10cSrcweir SwMailMergeConfigItem::SwMailMergeConfigItem() :
782cdf0e10cSrcweir     m_bAddressInserted(false),
783cdf0e10cSrcweir     m_bMergeDone(false),
784cdf0e10cSrcweir     m_bGreetingInserted(false),
785cdf0e10cSrcweir     m_nGreetingMoves(0),
786cdf0e10cSrcweir     m_nStartPrint(0),
787cdf0e10cSrcweir     m_nEndPrint(0),
788cdf0e10cSrcweir     m_pSourceView(0),
789cdf0e10cSrcweir     m_pTargetView(0)
790cdf0e10cSrcweir {
791cdf0e10cSrcweir     // Global access, must be guarded (multithreading)
792cdf0e10cSrcweir     ::osl::MutexGuard aGuard( aMutex );
793cdf0e10cSrcweir     if ( !pOptions )
794cdf0e10cSrcweir         pOptions = new SwMailMergeConfigItem_Impl;
795cdf0e10cSrcweir     ++nRefCount;
796cdf0e10cSrcweir     m_pImpl = pOptions;
797cdf0e10cSrcweir }
798cdf0e10cSrcweir /*-- 15.04.2004 08:43:36---------------------------------------------------
799cdf0e10cSrcweir 
800cdf0e10cSrcweir   -----------------------------------------------------------------------*/
~SwMailMergeConfigItem()801cdf0e10cSrcweir SwMailMergeConfigItem::~SwMailMergeConfigItem()
802cdf0e10cSrcweir {
803cdf0e10cSrcweir     // Global access, must be guarded (multithreading)
804cdf0e10cSrcweir     ::osl::MutexGuard aGuard( aMutex );
805cdf0e10cSrcweir     if ( !--nRefCount )
806cdf0e10cSrcweir     {
807cdf0e10cSrcweir         DELETEZ( pOptions );
808cdf0e10cSrcweir     }
809cdf0e10cSrcweir }
810cdf0e10cSrcweir /*-- 06.05.2004 14:18:10---------------------------------------------------
811cdf0e10cSrcweir 
812cdf0e10cSrcweir   -----------------------------------------------------------------------*/
Commit()813cdf0e10cSrcweir void  SwMailMergeConfigItem::Commit()
814cdf0e10cSrcweir {
815cdf0e10cSrcweir     if(m_pImpl->IsModified())
816cdf0e10cSrcweir         m_pImpl->Commit();
817cdf0e10cSrcweir }
818cdf0e10cSrcweir /*-- 06.05.2004 12:59:50---------------------------------------------------
819cdf0e10cSrcweir 
820cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetDefaultAddressHeaders() const821cdf0e10cSrcweir const ResStringArray&   SwMailMergeConfigItem::GetDefaultAddressHeaders() const
822cdf0e10cSrcweir {
823cdf0e10cSrcweir     return m_pImpl->m_AddressHeaderSA;
824cdf0e10cSrcweir }
825cdf0e10cSrcweir /*-- 27.04.2004 14:34:16---------------------------------------------------
826cdf0e10cSrcweir 
827cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetAddressBlocks(const Sequence<::rtl::OUString> & rBlocks)828cdf0e10cSrcweir void SwMailMergeConfigItem::SetAddressBlocks(
829cdf0e10cSrcweir         const Sequence< ::rtl::OUString>& rBlocks)
830cdf0e10cSrcweir {
831cdf0e10cSrcweir     m_pImpl->SetAddressBlocks(rBlocks);
832cdf0e10cSrcweir }
833cdf0e10cSrcweir /*-- 27.04.2004 14:34:16---------------------------------------------------
834cdf0e10cSrcweir 
835cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetAddressBlocks() const836cdf0e10cSrcweir const Sequence< ::rtl::OUString> SwMailMergeConfigItem::GetAddressBlocks() const
837cdf0e10cSrcweir {
838cdf0e10cSrcweir     return m_pImpl->GetAddressBlocks();
839cdf0e10cSrcweir }
840cdf0e10cSrcweir /*-- 11.05.2004 17:08:45---------------------------------------------------
841cdf0e10cSrcweir 
842cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsAddressBlock() const843cdf0e10cSrcweir sal_Bool SwMailMergeConfigItem::IsAddressBlock()const
844cdf0e10cSrcweir {
845cdf0e10cSrcweir     return m_pImpl->bIsAddressBlock && IsOutputToLetter();
846cdf0e10cSrcweir }
847cdf0e10cSrcweir /*-- 11.05.2004 17:08:46---------------------------------------------------
848cdf0e10cSrcweir 
849cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetAddressBlock(sal_Bool bSet)850cdf0e10cSrcweir void     SwMailMergeConfigItem::SetAddressBlock(sal_Bool bSet)
851cdf0e10cSrcweir {
852cdf0e10cSrcweir     m_pImpl->bUserSettingWereOverwritten = sal_False;
853cdf0e10cSrcweir     if(m_pImpl->bIsAddressBlock != bSet)
854cdf0e10cSrcweir     {
855cdf0e10cSrcweir         m_pImpl->bIsAddressBlock = bSet;
856cdf0e10cSrcweir         m_pImpl->SetModified();
857cdf0e10cSrcweir     }
858cdf0e10cSrcweir }
859cdf0e10cSrcweir 
860cdf0e10cSrcweir /*-- 30.08.2005 15:09:46---------------------------------------------------
861cdf0e10cSrcweir 
862cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsHideEmptyParagraphs() const863cdf0e10cSrcweir sal_Bool SwMailMergeConfigItem::IsHideEmptyParagraphs() const
864cdf0e10cSrcweir {
865cdf0e10cSrcweir     return m_pImpl->bIsHideEmptyParagraphs;
866cdf0e10cSrcweir }
867cdf0e10cSrcweir /*-- 30.08.2005 15:09:47---------------------------------------------------
868cdf0e10cSrcweir 
869cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetHideEmptyParagraphs(sal_Bool bSet)870cdf0e10cSrcweir void SwMailMergeConfigItem::SetHideEmptyParagraphs(sal_Bool bSet)
871cdf0e10cSrcweir {
872cdf0e10cSrcweir     if(m_pImpl->bIsHideEmptyParagraphs != bSet)
873cdf0e10cSrcweir     {
874cdf0e10cSrcweir         m_pImpl->bIsHideEmptyParagraphs = bSet;
875cdf0e10cSrcweir         m_pImpl->SetModified();
876cdf0e10cSrcweir     }
877cdf0e10cSrcweir }
878cdf0e10cSrcweir /*-- 28.04.2004 13:00:02---------------------------------------------------
879cdf0e10cSrcweir 
880cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsIncludeCountry() const881cdf0e10cSrcweir sal_Bool SwMailMergeConfigItem::IsIncludeCountry() const
882cdf0e10cSrcweir {
883cdf0e10cSrcweir     return m_pImpl->bIncludeCountry;
884cdf0e10cSrcweir }
885cdf0e10cSrcweir /*-- 28.04.2004 13:00:02---------------------------------------------------
886cdf0e10cSrcweir 
887cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetExcludeCountry() const888cdf0e10cSrcweir rtl::OUString& SwMailMergeConfigItem::GetExcludeCountry() const
889cdf0e10cSrcweir {
890cdf0e10cSrcweir     return m_pImpl->sExcludeCountry;
891cdf0e10cSrcweir }
892cdf0e10cSrcweir /*-- 28.04.2004 13:00:02---------------------------------------------------
893cdf0e10cSrcweir 
894cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetCountrySettings(sal_Bool bSet,const rtl::OUString & rCountry)895cdf0e10cSrcweir void SwMailMergeConfigItem::SetCountrySettings(sal_Bool bSet, const rtl::OUString& rCountry)
896cdf0e10cSrcweir {
897cdf0e10cSrcweir     if(m_pImpl->sExcludeCountry != rCountry ||
898cdf0e10cSrcweir         m_pImpl->bIncludeCountry != bSet)
899cdf0e10cSrcweir     {
900cdf0e10cSrcweir         m_pImpl->bIncludeCountry = bSet;
901cdf0e10cSrcweir         m_pImpl->sExcludeCountry = bSet ? rCountry : OUString();
902cdf0e10cSrcweir         m_pImpl->SetModified();
903cdf0e10cSrcweir     }
904cdf0e10cSrcweir }
905cdf0e10cSrcweir 
906cdf0e10cSrcweir /*-- 28.04.2004 15:35:16---------------------------------------------------
907cdf0e10cSrcweir 
908cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetCurrentConnection(Reference<XDataSource> xSource,SharedConnection xConnection,Reference<XColumnsSupplier> xColumnsSupplier,const SwDBData & rDBData)909cdf0e10cSrcweir void SwMailMergeConfigItem::SetCurrentConnection(
910cdf0e10cSrcweir         Reference< XDataSource>       xSource,
911cdf0e10cSrcweir         SharedConnection              xConnection,
912cdf0e10cSrcweir         Reference< XColumnsSupplier>  xColumnsSupplier,
913cdf0e10cSrcweir         const SwDBData& rDBData)
914cdf0e10cSrcweir {
915cdf0e10cSrcweir         m_pImpl->xSource            = xSource         ;
916cdf0e10cSrcweir         m_pImpl->xConnection        = xConnection     ;
917cdf0e10cSrcweir         m_pImpl->xColumnsSupplier   = xColumnsSupplier;
918cdf0e10cSrcweir         m_pImpl->aDBData = rDBData;
919cdf0e10cSrcweir         m_pImpl->xResultSet         = 0;
920cdf0e10cSrcweir         m_pImpl->nResultSetCursorPos = 0;
921cdf0e10cSrcweir         m_pImpl->SetModified();
922cdf0e10cSrcweir }
923cdf0e10cSrcweir /*-- 28.04.2004 15:38:11---------------------------------------------------
924cdf0e10cSrcweir 
925cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetSource()926cdf0e10cSrcweir Reference< XDataSource>  SwMailMergeConfigItem::GetSource()
927cdf0e10cSrcweir {
928cdf0e10cSrcweir     return m_pImpl->xSource;
929cdf0e10cSrcweir }
930cdf0e10cSrcweir /*-- 28.04.2004 15:38:11---------------------------------------------------
931cdf0e10cSrcweir 
932cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetConnection()933cdf0e10cSrcweir SharedConnection SwMailMergeConfigItem::GetConnection()
934cdf0e10cSrcweir {
935cdf0e10cSrcweir     return m_pImpl->xConnection;
936cdf0e10cSrcweir }
937cdf0e10cSrcweir /*-- 28.04.2004 15:38:11---------------------------------------------------
938cdf0e10cSrcweir 
939cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetColumnsSupplier()940cdf0e10cSrcweir Reference< XColumnsSupplier> SwMailMergeConfigItem::GetColumnsSupplier()
941cdf0e10cSrcweir {
942cdf0e10cSrcweir     if(!m_pImpl->xColumnsSupplier.is() && m_pImpl->xConnection.is())
943cdf0e10cSrcweir     {
944cdf0e10cSrcweir         m_pImpl->xColumnsSupplier = SwNewDBMgr::GetColumnSupplier(m_pImpl->xConnection,
945cdf0e10cSrcweir                                 m_pImpl->aDBData.sCommand,
946cdf0e10cSrcweir                                 m_pImpl->aDBData.nCommandType == CommandType::TABLE ?
947cdf0e10cSrcweir                                         SW_DB_SELECT_TABLE : SW_DB_SELECT_QUERY );
948cdf0e10cSrcweir     }
949cdf0e10cSrcweir     return m_pImpl->xColumnsSupplier;
950cdf0e10cSrcweir }
951cdf0e10cSrcweir /*-- 30.04.2004 14:30:55---------------------------------------------------
952cdf0e10cSrcweir 
953cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetCurrentDBData() const954cdf0e10cSrcweir const SwDBData&    SwMailMergeConfigItem::GetCurrentDBData() const
955cdf0e10cSrcweir {
956cdf0e10cSrcweir     return m_pImpl->aDBData;
957cdf0e10cSrcweir }
958cdf0e10cSrcweir 
959cdf0e10cSrcweir /*-- 17.06.2004 13:18:47---------------------------------------------------
960cdf0e10cSrcweir 
961cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetCurrentDBData(const SwDBData & rDBData)962cdf0e10cSrcweir void SwMailMergeConfigItem::SetCurrentDBData( const SwDBData& rDBData)
963cdf0e10cSrcweir {
964cdf0e10cSrcweir     if(m_pImpl->aDBData != rDBData)
965cdf0e10cSrcweir     {
966cdf0e10cSrcweir         m_pImpl->aDBData = rDBData;
967cdf0e10cSrcweir         m_pImpl->xConnection.clear();
968cdf0e10cSrcweir         m_pImpl->xSource = 0;
969cdf0e10cSrcweir         m_pImpl->xColumnsSupplier = 0;
970cdf0e10cSrcweir         m_pImpl->SetModified();
971cdf0e10cSrcweir     }
972cdf0e10cSrcweir }
973cdf0e10cSrcweir /*-- 29.04.2004 11:34:36---------------------------------------------------
974cdf0e10cSrcweir 
975cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetResultSet() const976cdf0e10cSrcweir Reference< XResultSet>   SwMailMergeConfigItem::GetResultSet() const
977cdf0e10cSrcweir {
978cdf0e10cSrcweir     if(!m_pImpl->xConnection.is() && m_pImpl->aDBData.sDataSource.getLength())
979cdf0e10cSrcweir     {
980cdf0e10cSrcweir         m_pImpl->xConnection.reset(
981cdf0e10cSrcweir             SwNewDBMgr::GetConnection( m_pImpl->aDBData.sDataSource, m_pImpl->xSource ),
982cdf0e10cSrcweir             SharedConnection::TakeOwnership
983cdf0e10cSrcweir         );
984cdf0e10cSrcweir     }
985cdf0e10cSrcweir     if(!m_pImpl->xResultSet.is() && m_pImpl->xConnection.is())
986cdf0e10cSrcweir     {
987cdf0e10cSrcweir         try
988cdf0e10cSrcweir         {
989cdf0e10cSrcweir             Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
990cdf0e10cSrcweir             if( xMgr.is() )
991cdf0e10cSrcweir             {
992cdf0e10cSrcweir                 Reference<XRowSet> xRowSet(
993cdf0e10cSrcweir                         xMgr->createInstance(C2U("com.sun.star.sdb.RowSet")), UNO_QUERY);
994cdf0e10cSrcweir                 Reference<XPropertySet> xRowProperties(xRowSet, UNO_QUERY);
995cdf0e10cSrcweir                 xRowProperties->setPropertyValue(C2U("DataSourceName"), makeAny(m_pImpl->aDBData.sDataSource));
996cdf0e10cSrcweir                 xRowProperties->setPropertyValue(C2U("Command"), makeAny(m_pImpl->aDBData.sCommand));
997cdf0e10cSrcweir                 xRowProperties->setPropertyValue(C2U("CommandType"), makeAny(m_pImpl->aDBData.nCommandType));
998cdf0e10cSrcweir                 xRowProperties->setPropertyValue(C2U("FetchSize"), makeAny((sal_Int32)10));
999cdf0e10cSrcweir                 xRowProperties->setPropertyValue(C2U("ActiveConnection"), makeAny(m_pImpl->xConnection.getTyped()));
1000cdf0e10cSrcweir                 try
1001cdf0e10cSrcweir                 {
1002cdf0e10cSrcweir                     xRowProperties->setPropertyValue(C2U("ApplyFilter"), makeAny(m_pImpl->sFilter.getLength()>0));
1003cdf0e10cSrcweir                     xRowProperties->setPropertyValue(C2U("Filter"), makeAny(m_pImpl->sFilter));
1004cdf0e10cSrcweir                 }
1005cdf0e10cSrcweir                 catch(Exception&)
1006cdf0e10cSrcweir                 {
1007cdf0e10cSrcweir                     DBG_ERROR("exception caught in xResultSet->SetFilter()");
1008cdf0e10cSrcweir                 }
1009cdf0e10cSrcweir                 xRowSet->execute();
1010cdf0e10cSrcweir                 m_pImpl->xResultSet = xRowSet.get();
1011cdf0e10cSrcweir                 m_pImpl->xResultSet->first();
1012cdf0e10cSrcweir                 m_pImpl->nResultSetCursorPos = 1;
1013cdf0e10cSrcweir             }
1014cdf0e10cSrcweir         }
1015cdf0e10cSrcweir         catch(Exception& )
1016cdf0e10cSrcweir         {
1017cdf0e10cSrcweir             DBG_ERROR("exception caught in: SwMailMergeConfigItem::GetResultSet() ");
1018cdf0e10cSrcweir         }
1019cdf0e10cSrcweir     }
1020cdf0e10cSrcweir     return m_pImpl->xResultSet;
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir /*-- 13.08.2004 11:49:46---------------------------------------------------
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir   -----------------------------------------------------------------------*/
DisposeResultSet()1025cdf0e10cSrcweir void SwMailMergeConfigItem::DisposeResultSet()
1026cdf0e10cSrcweir {
1027cdf0e10cSrcweir     m_pImpl->xConnection.clear();
1028cdf0e10cSrcweir     if(m_pImpl->xResultSet.is())
1029cdf0e10cSrcweir     {
1030cdf0e10cSrcweir         ::comphelper::disposeComponent( m_pImpl->xResultSet );
1031cdf0e10cSrcweir     }
1032cdf0e10cSrcweir }
1033cdf0e10cSrcweir /*-- 14.05.2004 15:07:55---------------------------------------------------
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetFilter() const1036cdf0e10cSrcweir ::rtl::OUString&    SwMailMergeConfigItem::GetFilter() const
1037cdf0e10cSrcweir {
1038cdf0e10cSrcweir     return m_pImpl->sFilter;
1039cdf0e10cSrcweir }
1040cdf0e10cSrcweir /*-- 14.05.2004 15:07:55---------------------------------------------------
1041cdf0e10cSrcweir 
1042cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetFilter(::rtl::OUString & rFilter)1043cdf0e10cSrcweir void  SwMailMergeConfigItem::SetFilter(::rtl::OUString& rFilter)
1044cdf0e10cSrcweir {
1045cdf0e10cSrcweir     if(m_pImpl->sFilter != rFilter)
1046cdf0e10cSrcweir     {
1047cdf0e10cSrcweir         m_pImpl->sFilter = rFilter;
1048cdf0e10cSrcweir         m_pImpl->SetModified();
1049cdf0e10cSrcweir         Reference<XPropertySet> xRowProperties(m_pImpl->xResultSet, UNO_QUERY);
1050cdf0e10cSrcweir         if(xRowProperties.is())
1051cdf0e10cSrcweir         {
1052cdf0e10cSrcweir             try
1053cdf0e10cSrcweir             {
1054cdf0e10cSrcweir                 xRowProperties->setPropertyValue(C2U("ApplyFilter"), makeAny(m_pImpl->sFilter.getLength()>0));
1055cdf0e10cSrcweir                 xRowProperties->setPropertyValue(C2U("Filter"), makeAny(m_pImpl->sFilter));
1056cdf0e10cSrcweir                 uno::Reference<XRowSet> xRowSet( m_pImpl->xResultSet, UNO_QUERY_THROW );
1057cdf0e10cSrcweir                 xRowSet->execute();
1058cdf0e10cSrcweir             }
1059cdf0e10cSrcweir             catch(Exception&)
1060cdf0e10cSrcweir             {
1061cdf0e10cSrcweir                 DBG_ERROR("exception caught in SwMailMergeConfigItem::SetFilter()");
1062cdf0e10cSrcweir             }
1063cdf0e10cSrcweir         }
1064cdf0e10cSrcweir     }
1065cdf0e10cSrcweir }
1066cdf0e10cSrcweir /*-- 29.04.2004 11:55:38---------------------------------------------------
1067cdf0e10cSrcweir 
1068cdf0e10cSrcweir   -----------------------------------------------------------------------*/
MoveResultSet(sal_Int32 nTarget)1069cdf0e10cSrcweir sal_Int32 SwMailMergeConfigItem::MoveResultSet(sal_Int32 nTarget)
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir     if(!m_pImpl->xResultSet.is())
1072cdf0e10cSrcweir         GetResultSet();
1073cdf0e10cSrcweir     if(m_pImpl->xResultSet.is())
1074cdf0e10cSrcweir     {
1075cdf0e10cSrcweir         try
1076cdf0e10cSrcweir         {
1077cdf0e10cSrcweir             //no action if the resultset is already at the right position
1078cdf0e10cSrcweir             if(m_pImpl->xResultSet->getRow() != nTarget)
1079cdf0e10cSrcweir             {
1080cdf0e10cSrcweir                 if(nTarget > 0)
1081cdf0e10cSrcweir                 {
1082cdf0e10cSrcweir                     sal_Bool bMoved = m_pImpl->xResultSet->absolute(nTarget);
1083cdf0e10cSrcweir                     if(!bMoved)
1084cdf0e10cSrcweir                     {
1085cdf0e10cSrcweir                         if(nTarget > 1)
1086cdf0e10cSrcweir                             m_pImpl->xResultSet->last();
1087cdf0e10cSrcweir                         else if(nTarget == 1)
1088cdf0e10cSrcweir                             m_pImpl->xResultSet->first();
1089cdf0e10cSrcweir                     }
1090cdf0e10cSrcweir                 }
1091cdf0e10cSrcweir                 else if(nTarget == -1)
1092cdf0e10cSrcweir                     m_pImpl->xResultSet->last();
1093cdf0e10cSrcweir                 m_pImpl->nResultSetCursorPos = m_pImpl->xResultSet->getRow();
1094cdf0e10cSrcweir             }
1095cdf0e10cSrcweir         }
1096cdf0e10cSrcweir         catch(Exception&)
1097cdf0e10cSrcweir         {
1098cdf0e10cSrcweir         }
1099cdf0e10cSrcweir     }
1100cdf0e10cSrcweir     return m_pImpl->nResultSetCursorPos;
1101cdf0e10cSrcweir }
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir /*-- 27.05.2004 13:56:18---------------------------------------------------
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsResultSetFirstLast(bool & bIsFirst,bool & bIsLast)1106cdf0e10cSrcweir bool SwMailMergeConfigItem::IsResultSetFirstLast(bool& bIsFirst, bool& bIsLast)
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir     bool bRet = false;
1109cdf0e10cSrcweir     if(!m_pImpl->xResultSet.is())
1110cdf0e10cSrcweir         GetResultSet();
1111cdf0e10cSrcweir     if(m_pImpl->xResultSet.is())
1112cdf0e10cSrcweir     {
1113cdf0e10cSrcweir         try
1114cdf0e10cSrcweir         {
1115cdf0e10cSrcweir             bIsFirst = m_pImpl->xResultSet->isFirst();
1116cdf0e10cSrcweir             bIsLast = m_pImpl->xResultSet->isLast();
1117cdf0e10cSrcweir             bRet = true;
1118cdf0e10cSrcweir         }
1119cdf0e10cSrcweir         catch(Exception&)
1120cdf0e10cSrcweir         {
1121cdf0e10cSrcweir         }
1122cdf0e10cSrcweir     }
1123cdf0e10cSrcweir     return bRet;
1124cdf0e10cSrcweir }
1125cdf0e10cSrcweir /*-- 29.04.2004 11:55:38---------------------------------------------------
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetResultSetPosition() const1128cdf0e10cSrcweir sal_Int32 SwMailMergeConfigItem::GetResultSetPosition() const
1129cdf0e10cSrcweir {
1130cdf0e10cSrcweir     return m_pImpl->nResultSetCursorPos;
1131cdf0e10cSrcweir }
1132cdf0e10cSrcweir /*-- 27.05.2004 14:49:53---------------------------------------------------
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsRecordExcluded(sal_Int32 nRecord)1135cdf0e10cSrcweir bool SwMailMergeConfigItem::IsRecordExcluded(sal_Int32 nRecord)
1136cdf0e10cSrcweir {
1137cdf0e10cSrcweir     bool bRet = false;
1138cdf0e10cSrcweir     if(nRecord > 0 && nRecord < m_aSelection.getLength())
1139cdf0e10cSrcweir     {
1140cdf0e10cSrcweir         sal_Int32 nTemp = 0;
1141cdf0e10cSrcweir         m_aSelection[nRecord - 1] >>= nTemp;
1142cdf0e10cSrcweir         bRet = nTemp < 1;
1143cdf0e10cSrcweir     }
1144cdf0e10cSrcweir     return bRet;
1145cdf0e10cSrcweir }
1146cdf0e10cSrcweir /*-- 27.05.2004 14:49:53---------------------------------------------------
1147cdf0e10cSrcweir 
1148cdf0e10cSrcweir   -----------------------------------------------------------------------*/
ExcludeRecord(sal_Int32 nRecord,bool bExclude)1149cdf0e10cSrcweir void SwMailMergeConfigItem::ExcludeRecord(sal_Int32 nRecord, bool bExclude)
1150cdf0e10cSrcweir {
1151cdf0e10cSrcweir     //nRecord is based on 1
1152cdf0e10cSrcweir     //the selection array contains Anys for all records
1153cdf0e10cSrcweir     //excluded records  contain a '-1'
1154cdf0e10cSrcweir     if(!m_aSelection.getLength() || nRecord > m_aSelection.getLength())
1155cdf0e10cSrcweir     {
1156cdf0e10cSrcweir         if(bExclude)
1157cdf0e10cSrcweir         {
1158cdf0e10cSrcweir             //if no selection array is available we need to create one containing the
1159cdf0e10cSrcweir             //entries for all available records
1160cdf0e10cSrcweir             if(!m_pImpl->xResultSet.is())
1161cdf0e10cSrcweir                 GetResultSet();
1162cdf0e10cSrcweir             if(m_pImpl->xResultSet.is())
1163cdf0e10cSrcweir             {
1164cdf0e10cSrcweir                 m_pImpl->xResultSet->last();
1165cdf0e10cSrcweir                 sal_Int32 nEnd = m_pImpl->xResultSet->getRow();
1166cdf0e10cSrcweir                 sal_Int32 nStart = m_aSelection.getLength();
1167cdf0e10cSrcweir                 m_aSelection.realloc(nEnd);
1168cdf0e10cSrcweir                 Any* pSelection = m_aSelection.getArray();
1169cdf0e10cSrcweir                 for(sal_Int32 nIndex = nStart; nIndex < nEnd; ++nIndex)
1170cdf0e10cSrcweir                 {
1171cdf0e10cSrcweir                     if((nRecord - 1) != nIndex)
1172cdf0e10cSrcweir                         pSelection[nIndex] <<= nIndex + 1;
1173cdf0e10cSrcweir                     else
1174cdf0e10cSrcweir                         pSelection[nIndex] <<= (sal_Int32) -1;
1175cdf0e10cSrcweir                 }
1176cdf0e10cSrcweir             }
1177cdf0e10cSrcweir         }
1178cdf0e10cSrcweir     }
1179cdf0e10cSrcweir     else
1180cdf0e10cSrcweir     {
1181cdf0e10cSrcweir         if(nRecord > 0 && m_aSelection.getLength() > nRecord)
1182cdf0e10cSrcweir         {
1183cdf0e10cSrcweir             m_aSelection[nRecord - 1] <<= bExclude ? -1 : nRecord;
1184cdf0e10cSrcweir         }
1185cdf0e10cSrcweir     }
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir /*-- 27.05.2004 15:08:35---------------------------------------------------
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetSelection() const1190cdf0e10cSrcweir Sequence< Any > SwMailMergeConfigItem::GetSelection() const
1191cdf0e10cSrcweir {
1192cdf0e10cSrcweir     Sequence< Any > aRet(m_aSelection.getLength());
1193cdf0e10cSrcweir     sal_Int32 nRetIndex = 0;
1194cdf0e10cSrcweir     sal_Int32 nRet;
1195cdf0e10cSrcweir     for(sal_Int32 nIndex = 0; nIndex < m_aSelection.getLength(); ++nIndex)
1196cdf0e10cSrcweir     {
1197cdf0e10cSrcweir         m_aSelection[nIndex] >>= nRet;
1198cdf0e10cSrcweir         if(nRet > 0)
1199cdf0e10cSrcweir         {
1200cdf0e10cSrcweir             aRet[nRetIndex] <<= nRet;
1201cdf0e10cSrcweir             ++nRetIndex;
1202cdf0e10cSrcweir         }
1203cdf0e10cSrcweir     }
1204cdf0e10cSrcweir     aRet.realloc(nRetIndex);
1205cdf0e10cSrcweir     return aRet;
1206cdf0e10cSrcweir }
1207cdf0e10cSrcweir /*-- 16.06.2004 15:15:56---------------------------------------------------
1208cdf0e10cSrcweir 
1209cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1210cdf0e10cSrcweir const uno::Sequence< ::rtl::OUString>&
GetSavedDocuments() const1211cdf0e10cSrcweir                     SwMailMergeConfigItem::GetSavedDocuments() const
1212cdf0e10cSrcweir {
1213cdf0e10cSrcweir     return m_pImpl->aSavedDocuments;
1214cdf0e10cSrcweir }
1215cdf0e10cSrcweir /*-- 16.06.2004 15:15:56---------------------------------------------------
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir   -----------------------------------------------------------------------*/
AddSavedDocument(::rtl::OUString rName)1218cdf0e10cSrcweir void SwMailMergeConfigItem::AddSavedDocument(::rtl::OUString rName)
1219cdf0e10cSrcweir {
1220cdf0e10cSrcweir     const ::rtl::OUString* pDocs = m_pImpl->aSavedDocuments.getConstArray();
1221cdf0e10cSrcweir     bool bFound = false;
1222cdf0e10cSrcweir     for(sal_Int32 nDoc = 0; nDoc < m_pImpl->aSavedDocuments.getLength(); ++nDoc)
1223cdf0e10cSrcweir     {
1224cdf0e10cSrcweir         if(pDocs[nDoc] == rName)
1225cdf0e10cSrcweir         {
1226cdf0e10cSrcweir             bFound = true;
1227cdf0e10cSrcweir             break;
1228cdf0e10cSrcweir         }
1229cdf0e10cSrcweir     }
1230cdf0e10cSrcweir     if(!bFound)
1231cdf0e10cSrcweir     {
1232cdf0e10cSrcweir         m_pImpl->aSavedDocuments.realloc(m_pImpl->aSavedDocuments.getLength() + 1);
1233cdf0e10cSrcweir         m_pImpl->aSavedDocuments[m_pImpl->aSavedDocuments.getLength() - 1] = rName;
1234cdf0e10cSrcweir     }
1235cdf0e10cSrcweir }
1236cdf0e10cSrcweir /*-- 28.04.2004 16:15:16---------------------------------------------------
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsOutputToLetter() const1239cdf0e10cSrcweir sal_Bool SwMailMergeConfigItem::IsOutputToLetter()const
1240cdf0e10cSrcweir {
1241cdf0e10cSrcweir     return m_pImpl->bIsOutputToLetter || !IsMailAvailable();
1242cdf0e10cSrcweir }
1243cdf0e10cSrcweir /*-- 28.04.2004 16:15:16---------------------------------------------------
1244cdf0e10cSrcweir 
1245cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetOutputToLetter(sal_Bool bSet)1246cdf0e10cSrcweir void SwMailMergeConfigItem::SetOutputToLetter(sal_Bool bSet)
1247cdf0e10cSrcweir {
1248cdf0e10cSrcweir     if(m_pImpl->bIsOutputToLetter != bSet)
1249cdf0e10cSrcweir     {
1250cdf0e10cSrcweir         m_pImpl->bIsOutputToLetter = bSet;
1251cdf0e10cSrcweir         m_pImpl->SetModified();
1252cdf0e10cSrcweir     }
1253cdf0e10cSrcweir }
1254cdf0e10cSrcweir /*-- 30.04.2004 10:51:10---------------------------------------------------
1255cdf0e10cSrcweir 
1256cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsIndividualGreeting(sal_Bool bInEMail) const1257cdf0e10cSrcweir sal_Bool SwMailMergeConfigItem::IsIndividualGreeting(sal_Bool bInEMail) const
1258cdf0e10cSrcweir {
1259cdf0e10cSrcweir     return bInEMail ?
1260cdf0e10cSrcweir             m_pImpl->bIsIndividualGreetingLineInMail :
1261cdf0e10cSrcweir             m_pImpl->bIsIndividualGreetingLine;
1262cdf0e10cSrcweir }
1263cdf0e10cSrcweir /*-- 30.04.2004 10:51:10---------------------------------------------------
1264cdf0e10cSrcweir 
1265cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetIndividualGreeting(sal_Bool bSet,sal_Bool bInEMail)1266cdf0e10cSrcweir void     SwMailMergeConfigItem::SetIndividualGreeting(
1267cdf0e10cSrcweir                                         sal_Bool bSet, sal_Bool bInEMail)
1268cdf0e10cSrcweir {
1269cdf0e10cSrcweir     if(bInEMail)
1270cdf0e10cSrcweir     {
1271cdf0e10cSrcweir         if(m_pImpl->bIsIndividualGreetingLineInMail != bSet)
1272cdf0e10cSrcweir         {
1273cdf0e10cSrcweir             m_pImpl->bIsIndividualGreetingLineInMail = bSet;
1274cdf0e10cSrcweir             m_pImpl->SetModified();
1275cdf0e10cSrcweir         }
1276cdf0e10cSrcweir     }
1277cdf0e10cSrcweir     else
1278cdf0e10cSrcweir     {
1279cdf0e10cSrcweir         if(m_pImpl->bIsIndividualGreetingLine != bSet)
1280cdf0e10cSrcweir         {
1281cdf0e10cSrcweir             m_pImpl->bIsIndividualGreetingLine = bSet;
1282cdf0e10cSrcweir             m_pImpl->SetModified();
1283cdf0e10cSrcweir         }
1284cdf0e10cSrcweir     }
1285cdf0e10cSrcweir }
1286cdf0e10cSrcweir /*-- 30.04.2004 10:51:10---------------------------------------------------
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsGreetingLine(sal_Bool bInEMail) const1289cdf0e10cSrcweir sal_Bool SwMailMergeConfigItem::IsGreetingLine(sal_Bool bInEMail) const
1290cdf0e10cSrcweir {
1291cdf0e10cSrcweir     return bInEMail ? m_pImpl->bIsGreetingLineInMail : m_pImpl->bIsGreetingLine;
1292cdf0e10cSrcweir }
1293cdf0e10cSrcweir /*-- 30.04.2004 10:51:10---------------------------------------------------
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetGreetingLine(sal_Bool bSet,sal_Bool bInEMail)1296cdf0e10cSrcweir void     SwMailMergeConfigItem::SetGreetingLine(sal_Bool bSet, sal_Bool bInEMail)
1297cdf0e10cSrcweir {
1298cdf0e10cSrcweir     m_pImpl->bUserSettingWereOverwritten = sal_False;
1299cdf0e10cSrcweir     if(bInEMail)
1300cdf0e10cSrcweir     {
1301cdf0e10cSrcweir         if(m_pImpl->bIsGreetingLineInMail != bSet)
1302cdf0e10cSrcweir         {
1303cdf0e10cSrcweir             m_pImpl->bIsGreetingLineInMail = bSet;
1304cdf0e10cSrcweir             m_pImpl->SetModified();
1305cdf0e10cSrcweir         }
1306cdf0e10cSrcweir     }
1307cdf0e10cSrcweir     else
1308cdf0e10cSrcweir     {
1309cdf0e10cSrcweir         if(m_pImpl->bIsGreetingLine != bSet)
1310cdf0e10cSrcweir         {
1311cdf0e10cSrcweir             m_pImpl->bIsGreetingLine = bSet;
1312cdf0e10cSrcweir             m_pImpl->SetModified();
1313cdf0e10cSrcweir         }
1314cdf0e10cSrcweir     }
1315cdf0e10cSrcweir }
1316cdf0e10cSrcweir /*-- 30.04.2004 11:04:52---------------------------------------------------
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetGreetings(Gender eType) const1319cdf0e10cSrcweir const Sequence< ::rtl::OUString>   SwMailMergeConfigItem::GetGreetings(
1320cdf0e10cSrcweir         Gender eType ) const
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir     return m_pImpl->GetGreetings(eType);
1323cdf0e10cSrcweir }
1324cdf0e10cSrcweir /*-- 30.04.2004 11:04:52---------------------------------------------------
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetGreetings(Gender eType,const Sequence<::rtl::OUString> & rSetGreetings)1327cdf0e10cSrcweir void  SwMailMergeConfigItem::SetGreetings(
1328cdf0e10cSrcweir         Gender eType, const Sequence< ::rtl::OUString>& rSetGreetings)
1329cdf0e10cSrcweir {
1330cdf0e10cSrcweir     m_pImpl->SetGreetings( eType, rSetGreetings);
1331cdf0e10cSrcweir }
1332cdf0e10cSrcweir 
1333cdf0e10cSrcweir /*-- 11.05.2004 13:10:54---------------------------------------------------
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetCurrentGreeting(SwMailMergeConfigItem::Gender eType) const1336cdf0e10cSrcweir sal_Int32 SwMailMergeConfigItem::GetCurrentGreeting(
1337cdf0e10cSrcweir                         SwMailMergeConfigItem::Gender eType) const
1338cdf0e10cSrcweir {
1339cdf0e10cSrcweir     return m_pImpl->GetCurrentGreeting(eType);
1340cdf0e10cSrcweir }
1341cdf0e10cSrcweir /*-- 11.05.2004 13:10:55---------------------------------------------------
1342cdf0e10cSrcweir 
1343cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetCurrentGreeting(Gender eType,sal_Int32 nIndex)1344cdf0e10cSrcweir void SwMailMergeConfigItem::SetCurrentGreeting(Gender eType, sal_Int32 nIndex)
1345cdf0e10cSrcweir {
1346cdf0e10cSrcweir     m_pImpl->SetCurrentGreeting(eType, nIndex);
1347cdf0e10cSrcweir }
1348cdf0e10cSrcweir /*-- 12.05.2004 12:29:59---------------------------------------------------
1349cdf0e10cSrcweir 
1350cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetFemaleGenderValue() const1351cdf0e10cSrcweir const ::rtl::OUString& SwMailMergeConfigItem::GetFemaleGenderValue() const
1352cdf0e10cSrcweir {
1353cdf0e10cSrcweir     return m_pImpl->sFemaleGenderValue;
1354cdf0e10cSrcweir }
1355cdf0e10cSrcweir /*-- 12.05.2004 12:29:59---------------------------------------------------
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetFemaleGenderValue(const::rtl::OUString rValue)1358cdf0e10cSrcweir void SwMailMergeConfigItem::SetFemaleGenderValue(const ::rtl::OUString rValue)
1359cdf0e10cSrcweir {
1360cdf0e10cSrcweir     if( m_pImpl->sFemaleGenderValue != rValue )
1361cdf0e10cSrcweir     {
1362cdf0e10cSrcweir         m_pImpl->sFemaleGenderValue = rValue;
1363cdf0e10cSrcweir         m_pImpl->SetModified();
1364cdf0e10cSrcweir     }
1365cdf0e10cSrcweir }
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir /*-- 30.04.2004 13:25:41---------------------------------------------------
1368cdf0e10cSrcweir 
1369cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetColumnAssignment(const SwDBData & rDBData) const1370cdf0e10cSrcweir Sequence< ::rtl::OUString> SwMailMergeConfigItem::GetColumnAssignment(
1371cdf0e10cSrcweir                 const SwDBData& rDBData ) const
1372cdf0e10cSrcweir {
1373cdf0e10cSrcweir     Sequence< ::rtl::OUString> aRet;
1374cdf0e10cSrcweir     ::std::vector<DBAddressDataAssignment>::iterator aAssignIter;
1375cdf0e10cSrcweir     for(aAssignIter = m_pImpl->aAddressDataAssignments.begin();
1376cdf0e10cSrcweir                 aAssignIter != m_pImpl->aAddressDataAssignments.end(); aAssignIter++)
1377cdf0e10cSrcweir     {
1378cdf0e10cSrcweir         if(aAssignIter->aDBData == rDBData)
1379cdf0e10cSrcweir         {
1380cdf0e10cSrcweir             aRet = aAssignIter->aDBColumnAssignments;
1381cdf0e10cSrcweir             break;
1382cdf0e10cSrcweir         }
1383cdf0e10cSrcweir     }
1384cdf0e10cSrcweir     return aRet;
1385cdf0e10cSrcweir }
1386cdf0e10cSrcweir /*-- 21.05.2004 12:31:31---------------------------------------------------
1387cdf0e10cSrcweir     returns the name that is assigned as e-mail column of the current data base
1388cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetAssignedColumn(sal_uInt32 nColumn) const1389cdf0e10cSrcweir ::rtl::OUString     SwMailMergeConfigItem::GetAssignedColumn(sal_uInt32 nColumn) const
1390cdf0e10cSrcweir {
1391cdf0e10cSrcweir     ::rtl::OUString sRet;
1392cdf0e10cSrcweir     Sequence< ::rtl::OUString> aAssignment = GetColumnAssignment( m_pImpl->aDBData );
1393cdf0e10cSrcweir     if(aAssignment.getLength() > sal::static_int_cast< sal_Int32, sal_uInt32>(nColumn) && aAssignment[nColumn].getLength())
1394cdf0e10cSrcweir         sRet = aAssignment[nColumn];
1395cdf0e10cSrcweir     else if(nColumn < m_pImpl->m_AddressHeaderSA.Count())
1396cdf0e10cSrcweir         sRet = m_pImpl->m_AddressHeaderSA.GetString(nColumn);
1397cdf0e10cSrcweir     return sRet;
1398cdf0e10cSrcweir }
1399cdf0e10cSrcweir /*-- 30.04.2004 13:25:41---------------------------------------------------
1400cdf0e10cSrcweir 
1401cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetColumnAssignment(const SwDBData & rDBData,const Sequence<::rtl::OUString> & rList)1402cdf0e10cSrcweir void SwMailMergeConfigItem::SetColumnAssignment( const SwDBData& rDBData,
1403cdf0e10cSrcweir                             const Sequence< ::rtl::OUString>& rList)
1404cdf0e10cSrcweir {
1405cdf0e10cSrcweir     ::std::vector<DBAddressDataAssignment>::iterator aAssignIter;
1406cdf0e10cSrcweir     sal_Bool bFound = sal_False;
1407cdf0e10cSrcweir     for(aAssignIter = m_pImpl->aAddressDataAssignments.begin();
1408cdf0e10cSrcweir                 aAssignIter != m_pImpl->aAddressDataAssignments.end(); aAssignIter++)
1409cdf0e10cSrcweir     {
1410cdf0e10cSrcweir         if(aAssignIter->aDBData == rDBData)
1411cdf0e10cSrcweir         {
1412cdf0e10cSrcweir             if(aAssignIter->aDBColumnAssignments != rList)
1413cdf0e10cSrcweir             {
1414cdf0e10cSrcweir                 aAssignIter->aDBColumnAssignments = rList;
1415cdf0e10cSrcweir                 aAssignIter->bColumnAssignmentsChanged = true;
1416cdf0e10cSrcweir             }
1417cdf0e10cSrcweir             bFound = sal_True;
1418cdf0e10cSrcweir             break;
1419cdf0e10cSrcweir         }
1420cdf0e10cSrcweir     }
1421cdf0e10cSrcweir     if(!bFound)
1422cdf0e10cSrcweir     {
1423cdf0e10cSrcweir         DBAddressDataAssignment aAssignment;
1424cdf0e10cSrcweir         aAssignment.aDBData = rDBData;
1425cdf0e10cSrcweir         aAssignment.aDBColumnAssignments = rList;
1426cdf0e10cSrcweir         aAssignment.bColumnAssignmentsChanged = true;
1427cdf0e10cSrcweir         m_pImpl->aAddressDataAssignments.push_back(aAssignment);
1428cdf0e10cSrcweir     }
1429cdf0e10cSrcweir     m_pImpl->SetModified();
1430cdf0e10cSrcweir }
1431cdf0e10cSrcweir 
1432cdf0e10cSrcweir /*-- 07.09.2005 11:50:27---------------------------------------------------
1433cdf0e10cSrcweir 
1434cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsAddressFieldsAssigned() const1435cdf0e10cSrcweir bool SwMailMergeConfigItem::IsAddressFieldsAssigned() const
1436cdf0e10cSrcweir {
1437cdf0e10cSrcweir     bool bResult = true;
1438cdf0e10cSrcweir     Reference< XResultSet> xResultSet = GetResultSet();
1439cdf0e10cSrcweir     uno::Reference< XColumnsSupplier > xColsSupp( xResultSet, UNO_QUERY );
1440cdf0e10cSrcweir     if(!xColsSupp.is())
1441cdf0e10cSrcweir         return false;
1442cdf0e10cSrcweir     uno::Reference<container::XNameAccess> xCols = xColsSupp->getColumns();
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir     const ResStringArray& rHeaders = GetDefaultAddressHeaders();
1445cdf0e10cSrcweir     Sequence< ::rtl::OUString> aAssignment =
1446cdf0e10cSrcweir                         GetColumnAssignment( GetCurrentDBData() );
1447cdf0e10cSrcweir     const ::rtl::OUString* pAssignment = aAssignment.getConstArray();
1448cdf0e10cSrcweir     const Sequence< ::rtl::OUString> aBlocks = GetAddressBlocks();
1449cdf0e10cSrcweir 
1450cdf0e10cSrcweir     if(aBlocks.getLength() <= m_pImpl->GetCurrentAddressBlockIndex())
1451cdf0e10cSrcweir         return false;
1452cdf0e10cSrcweir     SwAddressIterator aIter(aBlocks[m_pImpl->GetCurrentAddressBlockIndex()]);
1453cdf0e10cSrcweir     while(aIter.HasMore())
1454cdf0e10cSrcweir     {
1455cdf0e10cSrcweir         SwMergeAddressItem aItem = aIter.Next();
1456cdf0e10cSrcweir         if(aItem.bIsColumn)
1457cdf0e10cSrcweir         {
1458cdf0e10cSrcweir             String sConvertedColumn = aItem.sText;
1459cdf0e10cSrcweir             for(sal_uInt16 nColumn = 0;
1460cdf0e10cSrcweir                     nColumn < rHeaders.Count() && nColumn < aAssignment.getLength();
1461cdf0e10cSrcweir                                                                                 ++nColumn)
1462cdf0e10cSrcweir             {
1463cdf0e10cSrcweir                 if(rHeaders.GetString(nColumn) == aItem.sText &&
1464cdf0e10cSrcweir                     pAssignment[nColumn].getLength())
1465cdf0e10cSrcweir                 {
1466cdf0e10cSrcweir                     sConvertedColumn = pAssignment[nColumn];
1467cdf0e10cSrcweir                     break;
1468cdf0e10cSrcweir                 }
1469cdf0e10cSrcweir             }
1470cdf0e10cSrcweir             //find out if the column exists in the data base
1471cdf0e10cSrcweir             if(!xCols->hasByName(sConvertedColumn))
1472cdf0e10cSrcweir             {
1473cdf0e10cSrcweir                 bResult = false;
1474cdf0e10cSrcweir                 break;
1475cdf0e10cSrcweir             }
1476cdf0e10cSrcweir         }
1477cdf0e10cSrcweir     }
1478cdf0e10cSrcweir     return bResult;
1479cdf0e10cSrcweir }
1480cdf0e10cSrcweir /*-- 07.09.2005 11:50:27---------------------------------------------------
1481cdf0e10cSrcweir 
1482cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsGreetingFieldsAssigned() const1483cdf0e10cSrcweir bool SwMailMergeConfigItem::IsGreetingFieldsAssigned() const
1484cdf0e10cSrcweir {
1485cdf0e10cSrcweir     bool bResult = true;
1486cdf0e10cSrcweir 
1487cdf0e10cSrcweir     if(!IsIndividualGreeting(sal_False))
1488cdf0e10cSrcweir         return true;
1489cdf0e10cSrcweir 
1490cdf0e10cSrcweir     Reference< XResultSet> xResultSet = GetResultSet();
1491cdf0e10cSrcweir     uno::Reference< XColumnsSupplier > xColsSupp( xResultSet, UNO_QUERY );
1492cdf0e10cSrcweir     if(!xColsSupp.is())
1493cdf0e10cSrcweir         return false;
1494cdf0e10cSrcweir     const ResStringArray& rHeaders = GetDefaultAddressHeaders();
1495cdf0e10cSrcweir     uno::Reference<container::XNameAccess> xCols = xColsSupp->getColumns();
1496cdf0e10cSrcweir 
1497cdf0e10cSrcweir     Sequence< ::rtl::OUString> aAssignment =
1498cdf0e10cSrcweir                         GetColumnAssignment( GetCurrentDBData() );
1499cdf0e10cSrcweir     const ::rtl::OUString* pAssignment = aAssignment.getConstArray();
1500cdf0e10cSrcweir 
1501cdf0e10cSrcweir     const Sequence< ::rtl::OUString> rFemaleEntries = GetGreetings(SwMailMergeConfigItem::FEMALE);
1502cdf0e10cSrcweir     sal_Int32 nCurrentFemale = GetCurrentGreeting(SwMailMergeConfigItem::FEMALE);
1503cdf0e10cSrcweir     const Sequence< ::rtl::OUString> rMaleEntries = GetGreetings(SwMailMergeConfigItem::MALE);
1504cdf0e10cSrcweir     sal_Int32 nCurrentMale = GetCurrentGreeting(SwMailMergeConfigItem::MALE);
1505cdf0e10cSrcweir     ::rtl::OUString sMale, sFemale;
1506cdf0e10cSrcweir     if(rFemaleEntries.getLength() > nCurrentFemale)
1507cdf0e10cSrcweir         sFemale = rFemaleEntries[nCurrentFemale];
1508cdf0e10cSrcweir     if(rMaleEntries.getLength() > nCurrentMale)
1509cdf0e10cSrcweir         sMale = rMaleEntries[nCurrentMale];
1510cdf0e10cSrcweir 
1511cdf0e10cSrcweir     ::rtl::OUString sAddress( sFemale );
1512cdf0e10cSrcweir     sAddress += sMale;
1513cdf0e10cSrcweir     SwAddressIterator aIter(sAddress);
1514cdf0e10cSrcweir     while(aIter.HasMore())
1515cdf0e10cSrcweir     {
1516cdf0e10cSrcweir         SwMergeAddressItem aItem = aIter.Next();
1517cdf0e10cSrcweir         if(aItem.bIsColumn)
1518cdf0e10cSrcweir         {
1519cdf0e10cSrcweir             String sConvertedColumn = aItem.sText;
1520cdf0e10cSrcweir             for(sal_uInt16 nColumn = 0;
1521cdf0e10cSrcweir                     nColumn < rHeaders.Count() && nColumn < aAssignment.getLength();
1522cdf0e10cSrcweir                                                                                 ++nColumn)
1523cdf0e10cSrcweir             {
1524cdf0e10cSrcweir                 if(rHeaders.GetString(nColumn) == aItem.sText &&
1525cdf0e10cSrcweir                     pAssignment[nColumn].getLength())
1526cdf0e10cSrcweir                 {
1527cdf0e10cSrcweir                     sConvertedColumn = pAssignment[nColumn];
1528cdf0e10cSrcweir                     break;
1529cdf0e10cSrcweir                 }
1530cdf0e10cSrcweir             }
1531cdf0e10cSrcweir             //find out if the column exists in the data base
1532cdf0e10cSrcweir             if(!xCols->hasByName(sConvertedColumn))
1533cdf0e10cSrcweir             {
1534cdf0e10cSrcweir                 bResult = false;
1535cdf0e10cSrcweir                 break;
1536cdf0e10cSrcweir             }
1537cdf0e10cSrcweir         }
1538cdf0e10cSrcweir     }
1539cdf0e10cSrcweir     return bResult;
1540cdf0e10cSrcweir }
1541cdf0e10cSrcweir /*-- 05.05.2004 16:10:07---------------------------------------------------
1542cdf0e10cSrcweir 
1543cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetMailDisplayName() const1544cdf0e10cSrcweir ::rtl::OUString     SwMailMergeConfigItem::GetMailDisplayName() const
1545cdf0e10cSrcweir {
1546cdf0e10cSrcweir     return m_pImpl->sMailDisplayName;
1547cdf0e10cSrcweir }
1548cdf0e10cSrcweir /*-- 05.05.2004 16:10:08---------------------------------------------------
1549cdf0e10cSrcweir 
1550cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetMailDisplayName(const::rtl::OUString & rName)1551cdf0e10cSrcweir void SwMailMergeConfigItem::SetMailDisplayName(const ::rtl::OUString& rName)
1552cdf0e10cSrcweir {
1553cdf0e10cSrcweir     if(m_pImpl->sMailDisplayName != rName)
1554cdf0e10cSrcweir     {
1555cdf0e10cSrcweir         m_pImpl->sMailDisplayName = rName;
1556cdf0e10cSrcweir         m_pImpl->SetModified();
1557cdf0e10cSrcweir     }
1558cdf0e10cSrcweir }
1559cdf0e10cSrcweir /*-- 05.05.2004 16:10:09---------------------------------------------------
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetMailAddress() const1562cdf0e10cSrcweir ::rtl::OUString     SwMailMergeConfigItem::GetMailAddress() const
1563cdf0e10cSrcweir {
1564cdf0e10cSrcweir     return m_pImpl->sMailAddress;
1565cdf0e10cSrcweir }
1566cdf0e10cSrcweir /*-- 05.05.2004 16:10:09---------------------------------------------------
1567cdf0e10cSrcweir 
1568cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetMailAddress(const::rtl::OUString & rAddress)1569cdf0e10cSrcweir void SwMailMergeConfigItem::SetMailAddress(const ::rtl::OUString& rAddress)
1570cdf0e10cSrcweir {
1571cdf0e10cSrcweir     if(m_pImpl->sMailAddress != rAddress )
1572cdf0e10cSrcweir     {
1573cdf0e10cSrcweir         m_pImpl->sMailAddress = rAddress;
1574cdf0e10cSrcweir         m_pImpl->SetModified();
1575cdf0e10cSrcweir     }
1576cdf0e10cSrcweir }
1577cdf0e10cSrcweir 
1578cdf0e10cSrcweir /*-- 07.05.2004 12:40:59---------------------------------------------------
1579cdf0e10cSrcweir 
1580cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsMailReplyTo() const1581cdf0e10cSrcweir sal_Bool SwMailMergeConfigItem::IsMailReplyTo() const
1582cdf0e10cSrcweir {
1583cdf0e10cSrcweir     return m_pImpl->bIsMailReplyTo;
1584cdf0e10cSrcweir }
1585cdf0e10cSrcweir /*-- 07.05.2004 12:40:59---------------------------------------------------
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetMailReplyTo(sal_Bool bSet)1588cdf0e10cSrcweir void  SwMailMergeConfigItem::SetMailReplyTo(sal_Bool bSet)
1589cdf0e10cSrcweir {
1590cdf0e10cSrcweir     if(m_pImpl->bIsMailReplyTo != bSet)
1591cdf0e10cSrcweir     {
1592cdf0e10cSrcweir         m_pImpl->bIsMailReplyTo = bSet;
1593cdf0e10cSrcweir         m_pImpl->SetModified();
1594cdf0e10cSrcweir     }
1595cdf0e10cSrcweir }
1596cdf0e10cSrcweir /*-- 05.05.2004 16:10:09---------------------------------------------------
1597cdf0e10cSrcweir 
1598cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetMailReplyTo() const1599cdf0e10cSrcweir ::rtl::OUString     SwMailMergeConfigItem::GetMailReplyTo() const
1600cdf0e10cSrcweir {
1601cdf0e10cSrcweir     return m_pImpl->sMailReplyTo;
1602cdf0e10cSrcweir }
1603cdf0e10cSrcweir /*-- 05.05.2004 16:10:09---------------------------------------------------
1604cdf0e10cSrcweir 
1605cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetMailReplyTo(const::rtl::OUString & rReplyTo)1606cdf0e10cSrcweir void SwMailMergeConfigItem::SetMailReplyTo(const ::rtl::OUString& rReplyTo)
1607cdf0e10cSrcweir {
1608cdf0e10cSrcweir     if(m_pImpl->sMailReplyTo != rReplyTo)
1609cdf0e10cSrcweir     {
1610cdf0e10cSrcweir         m_pImpl->sMailReplyTo = rReplyTo;
1611cdf0e10cSrcweir         m_pImpl->SetModified();
1612cdf0e10cSrcweir     }
1613cdf0e10cSrcweir }
1614cdf0e10cSrcweir /*-- 05.05.2004 16:10:09---------------------------------------------------
1615cdf0e10cSrcweir 
1616cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetMailServer() const1617cdf0e10cSrcweir ::rtl::OUString  SwMailMergeConfigItem::GetMailServer() const
1618cdf0e10cSrcweir {
1619cdf0e10cSrcweir     return m_pImpl->sMailServer;
1620cdf0e10cSrcweir }
1621cdf0e10cSrcweir /*-- 05.05.2004 16:10:10---------------------------------------------------
1622cdf0e10cSrcweir 
1623cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetMailServer(const::rtl::OUString & rAddress)1624cdf0e10cSrcweir void SwMailMergeConfigItem::SetMailServer(const ::rtl::OUString& rAddress)
1625cdf0e10cSrcweir {
1626cdf0e10cSrcweir     if(m_pImpl->sMailServer != rAddress)
1627cdf0e10cSrcweir     {
1628cdf0e10cSrcweir         m_pImpl->sMailServer = rAddress;
1629cdf0e10cSrcweir         m_pImpl->SetModified();
1630cdf0e10cSrcweir     }
1631cdf0e10cSrcweir }
1632cdf0e10cSrcweir /*-- 05.05.2004 16:10:10---------------------------------------------------
1633cdf0e10cSrcweir 
1634cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetMailPort() const1635cdf0e10cSrcweir sal_Int16 SwMailMergeConfigItem::GetMailPort() const
1636cdf0e10cSrcweir {
1637cdf0e10cSrcweir     return m_pImpl->bIsDefaultPort ?
1638cdf0e10cSrcweir              (m_pImpl->bIsSecureConnection ? SECURE_PORT : DEFAULT_PORT) :
1639cdf0e10cSrcweir              m_pImpl->nMailPort;
1640cdf0e10cSrcweir }
1641cdf0e10cSrcweir /*-- 05.05.2004 16:10:10---------------------------------------------------
1642cdf0e10cSrcweir 
1643cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetMailPort(sal_Int16 nSet)1644cdf0e10cSrcweir void     SwMailMergeConfigItem::SetMailPort(sal_Int16 nSet)
1645cdf0e10cSrcweir {
1646cdf0e10cSrcweir     if(m_pImpl->nMailPort != nSet || m_pImpl->bIsDefaultPort)
1647cdf0e10cSrcweir     {
1648cdf0e10cSrcweir         m_pImpl->nMailPort = nSet;
1649cdf0e10cSrcweir         m_pImpl->bIsDefaultPort = sal_False;
1650cdf0e10cSrcweir         m_pImpl->SetModified();
1651cdf0e10cSrcweir     }
1652cdf0e10cSrcweir }
1653cdf0e10cSrcweir /*-- 05.05.2004 16:10:11---------------------------------------------------
1654cdf0e10cSrcweir 
1655cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsSecureConnection() const1656cdf0e10cSrcweir sal_Bool SwMailMergeConfigItem::IsSecureConnection() const
1657cdf0e10cSrcweir {
1658cdf0e10cSrcweir     return m_pImpl->bIsSecureConnection;
1659cdf0e10cSrcweir }
1660cdf0e10cSrcweir /*-- 05.05.2004 16:10:12---------------------------------------------------
1661cdf0e10cSrcweir 
1662cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetSecureConnection(sal_Bool bSet)1663cdf0e10cSrcweir void     SwMailMergeConfigItem::SetSecureConnection(sal_Bool bSet)
1664cdf0e10cSrcweir {
1665cdf0e10cSrcweir     if(m_pImpl->bIsSecureConnection != bSet)
1666cdf0e10cSrcweir     {
1667cdf0e10cSrcweir         m_pImpl->bIsSecureConnection = bSet;
1668cdf0e10cSrcweir         m_pImpl->SetModified();
1669cdf0e10cSrcweir     }
1670cdf0e10cSrcweir }
1671cdf0e10cSrcweir /*-- 05.05.2004 16:10:12---------------------------------------------------
1672cdf0e10cSrcweir 
1673cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsAuthentication() const1674cdf0e10cSrcweir sal_Bool SwMailMergeConfigItem::IsAuthentication() const
1675cdf0e10cSrcweir {
1676cdf0e10cSrcweir     return m_pImpl->bIsAuthentication;
1677cdf0e10cSrcweir }
1678cdf0e10cSrcweir /*-- 05.05.2004 16:10:13---------------------------------------------------
1679cdf0e10cSrcweir 
1680cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetAuthentication(sal_Bool bSet)1681cdf0e10cSrcweir void SwMailMergeConfigItem::SetAuthentication(sal_Bool bSet)
1682cdf0e10cSrcweir {
1683cdf0e10cSrcweir     if(m_pImpl->bIsAuthentication != bSet)
1684cdf0e10cSrcweir     {
1685cdf0e10cSrcweir         m_pImpl->bIsAuthentication = bSet;
1686cdf0e10cSrcweir         m_pImpl->SetModified();
1687cdf0e10cSrcweir     }
1688cdf0e10cSrcweir }
1689cdf0e10cSrcweir /*-- 05.05.2004 16:10:13---------------------------------------------------
1690cdf0e10cSrcweir 
1691cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetMailUserName() const1692cdf0e10cSrcweir ::rtl::OUString     SwMailMergeConfigItem::GetMailUserName() const
1693cdf0e10cSrcweir {
1694cdf0e10cSrcweir     return m_pImpl->sMailUserName;
1695cdf0e10cSrcweir }
1696cdf0e10cSrcweir /*-- 05.05.2004 16:10:13---------------------------------------------------
1697cdf0e10cSrcweir 
1698cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetMailUserName(const::rtl::OUString & rName)1699cdf0e10cSrcweir void SwMailMergeConfigItem::SetMailUserName(const ::rtl::OUString& rName)
1700cdf0e10cSrcweir {
1701cdf0e10cSrcweir     if(m_pImpl->sMailUserName != rName)
1702cdf0e10cSrcweir     {
1703cdf0e10cSrcweir         m_pImpl->sMailUserName = rName;
1704cdf0e10cSrcweir         m_pImpl->SetModified();
1705cdf0e10cSrcweir     }
1706cdf0e10cSrcweir }
1707cdf0e10cSrcweir /*-- 05.05.2004 16:10:14---------------------------------------------------
1708cdf0e10cSrcweir 
1709cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetMailPassword() const1710cdf0e10cSrcweir ::rtl::OUString     SwMailMergeConfigItem::GetMailPassword() const
1711cdf0e10cSrcweir {
1712cdf0e10cSrcweir     return m_pImpl->sMailPassword;
1713cdf0e10cSrcweir }
1714cdf0e10cSrcweir /*-- 05.05.2004 16:10:14---------------------------------------------------
1715cdf0e10cSrcweir 
1716cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetMailPassword(const::rtl::OUString & rPassword)1717cdf0e10cSrcweir void SwMailMergeConfigItem::SetMailPassword(const ::rtl::OUString& rPassword)
1718cdf0e10cSrcweir {
1719cdf0e10cSrcweir     if(m_pImpl->sMailPassword != rPassword)
1720cdf0e10cSrcweir     {
1721cdf0e10cSrcweir         m_pImpl->sMailPassword = rPassword;
1722cdf0e10cSrcweir         m_pImpl->SetModified();
1723cdf0e10cSrcweir     }
1724cdf0e10cSrcweir }
1725cdf0e10cSrcweir /*-- 19.08.2004 14:44:57---------------------------------------------------
1726cdf0e10cSrcweir 
1727cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsSMTPAfterPOP() const1728cdf0e10cSrcweir sal_Bool SwMailMergeConfigItem::IsSMTPAfterPOP() const
1729cdf0e10cSrcweir {
1730cdf0e10cSrcweir     return m_pImpl->bIsSMPTAfterPOP;
1731cdf0e10cSrcweir }
1732cdf0e10cSrcweir /*-- 19.08.2004 14:44:57---------------------------------------------------
1733cdf0e10cSrcweir 
1734cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetSMTPAfterPOP(sal_Bool bSet)1735cdf0e10cSrcweir void SwMailMergeConfigItem::SetSMTPAfterPOP(sal_Bool bSet)
1736cdf0e10cSrcweir {
1737cdf0e10cSrcweir     if( m_pImpl->bIsSMPTAfterPOP != bSet)
1738cdf0e10cSrcweir     {
1739cdf0e10cSrcweir         m_pImpl->bIsSMPTAfterPOP = bSet;
1740cdf0e10cSrcweir         m_pImpl->SetModified();
1741cdf0e10cSrcweir     }
1742cdf0e10cSrcweir }
1743cdf0e10cSrcweir /*-- 19.08.2004 14:44:57---------------------------------------------------
1744cdf0e10cSrcweir 
1745cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetInServerName() const1746cdf0e10cSrcweir ::rtl::OUString     SwMailMergeConfigItem::GetInServerName() const
1747cdf0e10cSrcweir {
1748cdf0e10cSrcweir     return m_pImpl->sInServerName;
1749cdf0e10cSrcweir }
1750cdf0e10cSrcweir /*-- 19.08.2004 14:44:57---------------------------------------------------
1751cdf0e10cSrcweir 
1752cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetInServerName(const::rtl::OUString & rServer)1753cdf0e10cSrcweir void SwMailMergeConfigItem::SetInServerName(const ::rtl::OUString& rServer)
1754cdf0e10cSrcweir {
1755cdf0e10cSrcweir     if(m_pImpl->sInServerName != rServer)
1756cdf0e10cSrcweir     {
1757cdf0e10cSrcweir         m_pImpl->sInServerName = rServer;
1758cdf0e10cSrcweir         m_pImpl->SetModified();
1759cdf0e10cSrcweir     }
1760cdf0e10cSrcweir }
1761cdf0e10cSrcweir /*-- 19.08.2004 14:44:58---------------------------------------------------
1762cdf0e10cSrcweir 
1763cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetInServerPort() const1764cdf0e10cSrcweir sal_Int16           SwMailMergeConfigItem::GetInServerPort() const
1765cdf0e10cSrcweir {
1766cdf0e10cSrcweir     return m_pImpl->nInServerPort;
1767cdf0e10cSrcweir }
1768cdf0e10cSrcweir /*-- 19.08.2004 14:44:58---------------------------------------------------
1769cdf0e10cSrcweir 
1770cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetInServerPort(sal_Int16 nSet)1771cdf0e10cSrcweir void SwMailMergeConfigItem::SetInServerPort(sal_Int16 nSet)
1772cdf0e10cSrcweir {
1773cdf0e10cSrcweir     if( m_pImpl->nInServerPort != nSet)
1774cdf0e10cSrcweir     {
1775cdf0e10cSrcweir         m_pImpl->nInServerPort = nSet;
1776cdf0e10cSrcweir         m_pImpl->SetModified();
1777cdf0e10cSrcweir     }
1778cdf0e10cSrcweir }
1779cdf0e10cSrcweir /*-- 20.08.2004 08:52:48---------------------------------------------------
1780cdf0e10cSrcweir 
1781cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsInServerPOP() const1782cdf0e10cSrcweir sal_Bool SwMailMergeConfigItem::IsInServerPOP() const
1783cdf0e10cSrcweir {
1784cdf0e10cSrcweir     return m_pImpl->bInServerPOP;
1785cdf0e10cSrcweir }
1786cdf0e10cSrcweir /*-- 20.08.2004 08:52:49---------------------------------------------------
1787cdf0e10cSrcweir 
1788cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetInServerPOP(sal_Bool bSet)1789cdf0e10cSrcweir void SwMailMergeConfigItem::SetInServerPOP(sal_Bool bSet)
1790cdf0e10cSrcweir {
1791cdf0e10cSrcweir     if( m_pImpl->bInServerPOP != bSet)
1792cdf0e10cSrcweir     {
1793cdf0e10cSrcweir         m_pImpl->bInServerPOP = bSet;
1794cdf0e10cSrcweir         m_pImpl->SetModified();
1795cdf0e10cSrcweir     }
1796cdf0e10cSrcweir }
1797cdf0e10cSrcweir /*-- 19.08.2004 14:44:58---------------------------------------------------
1798cdf0e10cSrcweir 
1799cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetInServerUserName() const1800cdf0e10cSrcweir ::rtl::OUString     SwMailMergeConfigItem::GetInServerUserName() const
1801cdf0e10cSrcweir {
1802cdf0e10cSrcweir     return m_pImpl->sInServerUserName;
1803cdf0e10cSrcweir }
1804cdf0e10cSrcweir /*-- 19.08.2004 14:44:58---------------------------------------------------
1805cdf0e10cSrcweir 
1806cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetInServerUserName(const::rtl::OUString & rName)1807cdf0e10cSrcweir void SwMailMergeConfigItem::SetInServerUserName(const ::rtl::OUString& rName)
1808cdf0e10cSrcweir {
1809cdf0e10cSrcweir     if( m_pImpl->sInServerUserName != rName)
1810cdf0e10cSrcweir     {
1811cdf0e10cSrcweir         m_pImpl->sInServerUserName = rName;
1812cdf0e10cSrcweir         m_pImpl->SetModified();
1813cdf0e10cSrcweir     }
1814cdf0e10cSrcweir }
1815cdf0e10cSrcweir /*-- 19.08.2004 14:44:59---------------------------------------------------
1816cdf0e10cSrcweir 
1817cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetInServerPassword() const1818cdf0e10cSrcweir ::rtl::OUString     SwMailMergeConfigItem::GetInServerPassword() const
1819cdf0e10cSrcweir {
1820cdf0e10cSrcweir     return m_pImpl->sInServerPassword;
1821cdf0e10cSrcweir }
1822cdf0e10cSrcweir /*-- 19.08.2004 14:45:00---------------------------------------------------
1823cdf0e10cSrcweir 
1824cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetInServerPassword(const::rtl::OUString & rPassword)1825cdf0e10cSrcweir void SwMailMergeConfigItem::SetInServerPassword(const ::rtl::OUString& rPassword)
1826cdf0e10cSrcweir {
1827cdf0e10cSrcweir     if(m_pImpl->sInServerPassword != rPassword)
1828cdf0e10cSrcweir     {
1829cdf0e10cSrcweir         m_pImpl->sInServerPassword = rPassword;
1830cdf0e10cSrcweir         m_pImpl->SetModified();
1831cdf0e10cSrcweir     }
1832cdf0e10cSrcweir }
1833cdf0e10cSrcweir 
1834cdf0e10cSrcweir /*-- 02.09.2004 14:43:27---------------------------------------------------
1835cdf0e10cSrcweir 
1836cdf0e10cSrcweir   -----------------------------------------------------------------------*/
DocumentReloaded()1837cdf0e10cSrcweir void SwMailMergeConfigItem::DocumentReloaded()
1838cdf0e10cSrcweir {
1839cdf0e10cSrcweir     m_bMergeDone = false;
1840cdf0e10cSrcweir     m_bGreetingInserted = false;
1841cdf0e10cSrcweir     m_bAddressInserted = false;
1842cdf0e10cSrcweir     m_rAddressBlockFrame = ::rtl::OUString();
1843cdf0e10cSrcweir }
1844cdf0e10cSrcweir /*-- 16.06.2004 12:24:18---------------------------------------------------
1845cdf0e10cSrcweir 
1846cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsMailAvailable() const1847cdf0e10cSrcweir bool SwMailMergeConfigItem::IsMailAvailable() const
1848cdf0e10cSrcweir {
1849cdf0e10cSrcweir     return m_pImpl->bIsEMailSupported;
1850cdf0e10cSrcweir }
1851cdf0e10cSrcweir /*-- 21.05.2004 12:20:05---------------------------------------------------
1852cdf0e10cSrcweir 
1853cdf0e10cSrcweir   -----------------------------------------------------------------------*/
AddMergedDocument(SwDocMergeInfo & rInfo)1854cdf0e10cSrcweir void SwMailMergeConfigItem::AddMergedDocument(SwDocMergeInfo& rInfo)
1855cdf0e10cSrcweir {
1856cdf0e10cSrcweir     m_pImpl->aMergeInfos.push_back(rInfo);
1857cdf0e10cSrcweir }
1858cdf0e10cSrcweir /*-- 21.05.2004 12:20:05---------------------------------------------------
1859cdf0e10cSrcweir 
1860cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetDocumentMergeInfo(sal_uInt32 nDocument)1861cdf0e10cSrcweir SwDocMergeInfo& SwMailMergeConfigItem::GetDocumentMergeInfo(sal_uInt32 nDocument)
1862cdf0e10cSrcweir {
1863cdf0e10cSrcweir     DBG_ASSERT(m_pImpl->aMergeInfos.size() > nDocument,"invalid document index");
1864cdf0e10cSrcweir     return m_pImpl->aMergeInfos[nDocument];
1865cdf0e10cSrcweir }
1866cdf0e10cSrcweir /*-- 14.06.2004 11:46:26---------------------------------------------------
1867cdf0e10cSrcweir 
1868cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetMergedDocumentCount() const1869cdf0e10cSrcweir sal_uInt32 SwMailMergeConfigItem::GetMergedDocumentCount() const
1870cdf0e10cSrcweir {
1871cdf0e10cSrcweir     return m_pImpl->aMergeInfos.size();
1872cdf0e10cSrcweir }
1873cdf0e10cSrcweir /*-- 11.06.2004 10:38:39---------------------------------------------------
1874cdf0e10cSrcweir 
1875cdf0e10cSrcweir   -----------------------------------------------------------------------*/
lcl_ExistsView(SwView * pView)1876cdf0e10cSrcweir SwView* lcl_ExistsView(SwView* pView)
1877cdf0e10cSrcweir {
1878cdf0e10cSrcweir     const TypeId aType(TYPE(SwView));
1879cdf0e10cSrcweir     SfxViewShell* pViewShell = SfxViewShell::GetFirst( &aType, sal_False );
1880cdf0e10cSrcweir     while(pViewShell)
1881cdf0e10cSrcweir     {
1882cdf0e10cSrcweir         if(pViewShell == pView)
1883cdf0e10cSrcweir             return pView;
1884cdf0e10cSrcweir 
1885cdf0e10cSrcweir         pViewShell = SfxViewShell::GetNext( *pViewShell, &aType, sal_False );
1886cdf0e10cSrcweir     }
1887cdf0e10cSrcweir     return 0;
1888cdf0e10cSrcweir }
1889cdf0e10cSrcweir /*-- 16.06.2004 15:02:35---------------------------------------------------
1890cdf0e10cSrcweir 
1891cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetTargetView()1892cdf0e10cSrcweir SwView*  SwMailMergeConfigItem::GetTargetView()
1893cdf0e10cSrcweir {
1894cdf0e10cSrcweir     //make sure that the pointer is really valid - the document may have been closed manually
1895cdf0e10cSrcweir     if(m_pTargetView)
1896cdf0e10cSrcweir     {
1897cdf0e10cSrcweir         m_pTargetView = lcl_ExistsView(m_pTargetView);
1898cdf0e10cSrcweir     }
1899cdf0e10cSrcweir     return m_pTargetView;
1900cdf0e10cSrcweir }
1901cdf0e10cSrcweir /*-- 02.09.2004 17:04:11---------------------------------------------------
1902cdf0e10cSrcweir 
1903cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetTargetView(SwView * pView)1904cdf0e10cSrcweir void  SwMailMergeConfigItem::SetTargetView(SwView* pView)
1905cdf0e10cSrcweir {
1906cdf0e10cSrcweir     m_pTargetView = pView;
1907cdf0e10cSrcweir     //reset the document merge counter
1908cdf0e10cSrcweir     if(!m_pTargetView)
1909cdf0e10cSrcweir     {
1910cdf0e10cSrcweir         m_pImpl->aMergeInfos.clear();
1911cdf0e10cSrcweir     }
1912cdf0e10cSrcweir }
1913cdf0e10cSrcweir /*-- 16.06.2004 15:02:35---------------------------------------------------
1914cdf0e10cSrcweir 
1915cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetSourceView()1916cdf0e10cSrcweir SwView* SwMailMergeConfigItem::GetSourceView()
1917cdf0e10cSrcweir {
1918cdf0e10cSrcweir     m_pSourceView = lcl_ExistsView(m_pSourceView);
1919cdf0e10cSrcweir     return m_pSourceView;
1920cdf0e10cSrcweir }
1921cdf0e10cSrcweir 
1922cdf0e10cSrcweir /*-- 04.11.2004 19:53 ---------------------------------------------------
1923cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetSourceView(SwView * pView)1924cdf0e10cSrcweir void SwMailMergeConfigItem::SetSourceView(SwView* pView)
1925cdf0e10cSrcweir {
1926cdf0e10cSrcweir     m_pSourceView = pView;
1927cdf0e10cSrcweir 
1928cdf0e10cSrcweir     if(pView)
1929cdf0e10cSrcweir     {
1930cdf0e10cSrcweir         SvStringsDtor aDBNameList(5, 1);
1931cdf0e10cSrcweir         SvStringsDtor aAllDBNames(5, 5);
1932cdf0e10cSrcweir         pView->GetWrtShell().GetAllUsedDB( aDBNameList, &aAllDBNames );
1933cdf0e10cSrcweir         if(aDBNameList.Count())
1934cdf0e10cSrcweir         {
1935cdf0e10cSrcweir             // if fields are available there is usually no need of an addressblock and greeting
1936cdf0e10cSrcweir             if(!m_pImpl->bUserSettingWereOverwritten)
1937cdf0e10cSrcweir             {
1938cdf0e10cSrcweir                 if( m_pImpl->bIsAddressBlock == sal_True
1939cdf0e10cSrcweir                     || m_pImpl->bIsGreetingLineInMail == sal_True
1940cdf0e10cSrcweir                     || m_pImpl->bIsGreetingLine == sal_True )
1941cdf0e10cSrcweir                 {
1942cdf0e10cSrcweir                     //store user settings
1943cdf0e10cSrcweir                     m_pImpl->bUserSettingWereOverwritten = sal_True;
1944cdf0e10cSrcweir                     m_pImpl->bIsAddressBlock_LastUserSetting = m_pImpl->bIsAddressBlock;
1945cdf0e10cSrcweir                     m_pImpl->bIsGreetingLineInMail_LastUserSetting = m_pImpl->bIsGreetingLineInMail;
1946cdf0e10cSrcweir                     m_pImpl->bIsGreetingLine_LastUserSetting = m_pImpl->bIsGreetingLine;
1947cdf0e10cSrcweir 
1948cdf0e10cSrcweir                     //set all to false
1949cdf0e10cSrcweir                     m_pImpl->bIsAddressBlock = sal_False;
1950cdf0e10cSrcweir                     m_pImpl->bIsGreetingLineInMail = sal_False;
1951cdf0e10cSrcweir                     m_pImpl->bIsGreetingLine = sal_False;
1952cdf0e10cSrcweir 
1953cdf0e10cSrcweir                     m_pImpl->SetModified();
1954cdf0e10cSrcweir                 }
1955cdf0e10cSrcweir             }
1956cdf0e10cSrcweir         }
1957cdf0e10cSrcweir         else if( m_pImpl->bUserSettingWereOverwritten )
1958cdf0e10cSrcweir         {
1959cdf0e10cSrcweir             //restore last user settings:
1960cdf0e10cSrcweir             m_pImpl->bIsAddressBlock = m_pImpl->bIsAddressBlock_LastUserSetting;
1961cdf0e10cSrcweir             m_pImpl->bIsGreetingLineInMail = m_pImpl->bIsGreetingLineInMail_LastUserSetting;
1962cdf0e10cSrcweir             m_pImpl->bIsGreetingLine = m_pImpl->bIsGreetingLine_LastUserSetting;
1963cdf0e10cSrcweir 
1964cdf0e10cSrcweir             m_pImpl->bUserSettingWereOverwritten = sal_False;
1965cdf0e10cSrcweir         }
1966cdf0e10cSrcweir     }
1967cdf0e10cSrcweir }
1968cdf0e10cSrcweir 
1969cdf0e10cSrcweir /*-- 13.03.2006 12:15:06---------------------------------------------------
1970cdf0e10cSrcweir 
1971cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetCurrentAddressBlockIndex(sal_Int32 nSet)1972cdf0e10cSrcweir void SwMailMergeConfigItem::SetCurrentAddressBlockIndex( sal_Int32 nSet )
1973cdf0e10cSrcweir {
1974cdf0e10cSrcweir     m_pImpl->SetCurrentAddressBlockIndex( nSet );
1975cdf0e10cSrcweir }
1976cdf0e10cSrcweir /*-- 13.03.2006 12:15:07---------------------------------------------------
1977cdf0e10cSrcweir 
1978cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetCurrentAddressBlockIndex() const1979cdf0e10cSrcweir sal_Int32 SwMailMergeConfigItem::GetCurrentAddressBlockIndex() const
1980cdf0e10cSrcweir {
1981cdf0e10cSrcweir     return m_pImpl->GetCurrentAddressBlockIndex();
1982cdf0e10cSrcweir }
1983