Update ooo320-m1
[ooovba.git] / sw / source / ui / dbui / mmconfigitem.cxx
blob6605b2dbaf2dd8c6cd3394c81d516ad07b2e1047
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: mmconfigitem.cxx,v $
10 * $Revision: 1.18 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <mmconfigitem.hxx>
34 #include <swtypes.hxx>
35 #include <tools/debug.hxx>
36 #include <com/sun/star/uno/Any.hxx>
37 #include <com/sun/star/beans/PropertyValue.hpp>
38 #include <com/sun/star/sdb/XCompletedConnection.hpp>
39 #include <com/sun/star/sdbc/XDataSource.hpp>
40 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
41 #include "com/sun/star/mail/MailServiceType.hpp"
42 #include "com/sun/star/mail/XMailService.hpp"
43 #include "com/sun/star/mail/MailServiceProvider.hpp"
44 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
45 #include <com/sun/star/beans/XPropertySet.hpp>
46 #include <com/sun/star/sdbc/XRowSet.hpp>
47 #include <comphelper/processfactory.hxx>
48 #include <comphelper/types.hxx>
49 #include <com/sun/star/sdb/CommandType.hpp>
50 #include <unotools/configitem.hxx>
51 #include <mailmergehelper.hxx>
52 #include <swunohelper.hxx>
53 #ifndef _DBMGR_HXX
54 #include <dbmgr.hxx>
55 #endif
56 #ifndef _VIEW_HXX
57 #include <view.hxx>
58 #endif
59 #include <wrtsh.hxx>
60 #include <dbui.hrc>
61 #include <vector>
63 #include <unomid.h>
65 #define _SVSTDARR_STRINGSDTOR
66 #include <svtools/svstdarr.hxx>
68 using namespace utl;
69 using ::rtl::OUString;
70 using namespace ::com::sun::star;
71 using namespace ::com::sun::star::uno;
72 using namespace ::com::sun::star::lang;
73 using namespace ::com::sun::star::beans;
74 using namespace ::com::sun::star::sdb;
75 using namespace ::com::sun::star::sdbc;
76 using namespace ::com::sun::star::sdbcx;
78 const char* cAddressDataAssignments = "AddressDataAssignments";
79 const char* cDBColumnAssignments = "DBColumnAssignments";
80 const char* cDataSourceName = "DataSource/DataSourceName";
81 const char* cDataTableName = "DataSource/DataTableName" ;
82 const char* cDataCommandType = "DataSource/DataCommandType";
84 #define SECURE_PORT 465
85 #define DEFAULT_PORT 25
86 #define POP_PORT 110
88 /*-- 16.04.2004 09:41:36---------------------------------------------------
90 -----------------------------------------------------------------------*/
91 struct DBAddressDataAssignment
93 SwDBData aDBData;
94 Sequence< ::rtl::OUString> aDBColumnAssignments;
95 //if loaded the name of the node has to be saved
96 ::rtl::OUString sConfigNodeName;
97 //all created or changed assignments need to be stored
98 bool bColumnAssignmentsChanged;
100 DBAddressDataAssignment() :
101 bColumnAssignmentsChanged(false)
105 /*-- 16.04.2004 09:43:29---------------------------------------------------
107 -----------------------------------------------------------------------*/
108 class SwMailMergeConfigItem_Impl : public utl::ConfigItem
110 friend class SwMailMergeConfigItem;
111 Reference< XDataSource> xSource;
112 SharedConnection xConnection;
113 Reference< XColumnsSupplier> xColumnsSupplier;
114 Reference< XStatement> xStatement;
115 Reference< XResultSet> xResultSet;
116 SwDBData aDBData;
117 ::rtl::OUString sFilter;
118 sal_Int32 nResultSetCursorPos;
120 ::std::vector<DBAddressDataAssignment> aAddressDataAssignments;
121 ::std::vector< ::rtl::OUString> aAddressBlocks;
122 sal_Int32 nCurrentAddressBlock;
123 sal_Bool bIsAddressBlock;
124 sal_Bool bIsHideEmptyParagraphs;
126 sal_Bool bIsOutputToLetter;
127 sal_Bool bIncludeCountry;
128 ::rtl::OUString sExcludeCountry;
130 sal_Bool bIsGreetingLine;
131 sal_Bool bIsIndividualGreetingLine;
132 ::std::vector< ::rtl::OUString> aFemaleGreetingLines;
133 sal_Int32 nCurrentFemaleGreeting;
134 ::std::vector< ::rtl::OUString> aMaleGreetingLines;
135 sal_Int32 nCurrentMaleGreeting;
136 ::std::vector< ::rtl::OUString> aNeutralGreetingLines;
137 sal_Int32 nCurrentNeutralGreeting;
138 ::rtl::OUString sFemaleGenderValue;
139 uno::Sequence< ::rtl::OUString> aSavedDocuments;
141 sal_Bool bIsGreetingLineInMail;
142 sal_Bool bIsIndividualGreetingLineInMail;
144 //mail settings
145 ::rtl::OUString sMailDisplayName;
146 ::rtl::OUString sMailAddress;
147 ::rtl::OUString sMailReplyTo;
148 ::rtl::OUString sMailServer;
149 ::rtl::OUString sMailUserName;
150 ::rtl::OUString sMailPassword;
152 sal_Bool bIsSMPTAfterPOP;
153 ::rtl::OUString sInServerName;
154 sal_Int16 nInServerPort;
155 sal_Bool bInServerPOP;
156 ::rtl::OUString sInServerUserName;
157 ::rtl::OUString sInServerPassword;
159 sal_Int16 nMailPort;
160 sal_Bool bIsMailReplyTo;
161 sal_Bool bIsDefaultPort;
162 sal_Bool bIsSecureConnection;
163 sal_Bool bIsAuthentication;
165 sal_Bool bIsEMailSupported;
167 ResStringArray m_AddressHeaderSA;
169 //these addresses are not stored in the configuration
170 ::std::vector< SwDocMergeInfo > aMergeInfos;
172 //we do overwrite the usersettings in a special case
173 //than we do remind the usersettings here
174 sal_Bool bUserSettingWereOverwritten;
175 sal_Bool bIsAddressBlock_LastUserSetting;
176 sal_Bool bIsGreetingLineInMail_LastUserSetting;
177 sal_Bool bIsGreetingLine_LastUserSetting;
180 const Sequence< ::rtl::OUString>& GetPropertyNames();
182 public:
183 SwMailMergeConfigItem_Impl();
184 ~SwMailMergeConfigItem_Impl();
186 virtual void Commit();
188 const Sequence< ::rtl::OUString>
189 GetAddressBlocks(sal_Bool bConvertToConfig = sal_False) const;
190 void SetAddressBlocks(
191 const Sequence< ::rtl::OUString>& rBlocks,
192 sal_Bool bConvertFromConfig = sal_False);
193 const uno::Sequence< ::rtl::OUString>
194 GetGreetings(SwMailMergeConfigItem::Gender eType,
195 sal_Bool bConvertToConfig = sal_False) const;
196 void SetGreetings(SwMailMergeConfigItem::Gender eType,
197 const uno::Sequence< ::rtl::OUString>& rBlocks,
198 sal_Bool bConvertFromConfig = sal_False);
200 void SetCurrentAddressBlockIndex( sal_Int32 nSet );
201 sal_Int32 GetCurrentAddressBlockIndex() const
202 { return nCurrentAddressBlock; }
203 sal_Int32 GetCurrentGreeting(SwMailMergeConfigItem::Gender eType) const;
204 void SetCurrentGreeting(SwMailMergeConfigItem::Gender eType, sal_Int32 nIndex);
208 /*-- 06.05.2004 12:51:54---------------------------------------------------
210 -----------------------------------------------------------------------*/
211 SwMailMergeConfigItem_Impl::SwMailMergeConfigItem_Impl() :
212 ConfigItem(C2U("Office.Writer/MailMergeWizard"), 0),
213 nResultSetCursorPos(-1),
214 nCurrentAddressBlock(0),
215 bIsAddressBlock(sal_True),
216 bIsHideEmptyParagraphs(sal_False),
217 bIsOutputToLetter(sal_True),
218 bIncludeCountry(sal_False),
219 bIsGreetingLine(sal_True),
220 nCurrentFemaleGreeting(0),
221 nCurrentMaleGreeting(0),
222 nCurrentNeutralGreeting(0),
224 bIsSMPTAfterPOP(sal_False),
225 nInServerPort( POP_PORT ),
226 bInServerPOP( sal_True ),
227 nMailPort(0),
228 bIsMailReplyTo(sal_False),
229 bIsDefaultPort(sal_False),
230 bIsSecureConnection(sal_False),
231 bIsAuthentication(sal_False),
233 bIsEMailSupported(sal_False),
234 m_AddressHeaderSA( SW_RES( SA_ADDRESS_HEADER )),
235 bUserSettingWereOverwritten(sal_False),
236 bIsAddressBlock_LastUserSetting(sal_False),
237 bIsGreetingLineInMail_LastUserSetting(sal_False),
238 bIsGreetingLine_LastUserSetting(sal_False)
240 const Sequence<OUString>& rNames = GetPropertyNames();
241 Sequence<Any> aValues = GetProperties(rNames);
242 const Any* pValues = aValues.getConstArray();
243 DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed");
244 if(aValues.getLength() == rNames.getLength())
246 for(int nProp = 0; nProp < rNames.getLength(); nProp++)
248 switch(nProp)
250 case 0: pValues[nProp] >>= bIsOutputToLetter; break;
251 case 1: pValues[nProp] >>= bIncludeCountry; break;
252 case 2: pValues[nProp] >>= sExcludeCountry; break;
253 case 3:
255 Sequence< ::rtl::OUString> aBlocks;
256 pValues[nProp] >>= aBlocks;
257 SetAddressBlocks(aBlocks, sal_True);
259 break;
260 case 4: pValues[nProp] >>= bIsAddressBlock; break;
261 case 5: pValues[nProp] >>= bIsGreetingLine; break;
262 case 6: pValues[nProp] >>= bIsIndividualGreetingLine; break;
263 case 7 :
264 case 8 :
265 case 9 :
267 Sequence< ::rtl::OUString> aGreetings;
268 pValues[nProp] >>= aGreetings;
269 SetGreetings(SwMailMergeConfigItem::Gender(
270 SwMailMergeConfigItem::FEMALE + nProp - 7), aGreetings, sal_True);
272 break;
274 case 10: pValues[nProp] >>= nCurrentFemaleGreeting; break;
275 case 11: pValues[nProp] >>= nCurrentMaleGreeting; break;
276 case 12: pValues[nProp] >>= nCurrentNeutralGreeting; break;
277 case 13: pValues[nProp] >>= sFemaleGenderValue; break;
278 case 14: pValues[nProp] >>= sMailDisplayName; break;
279 case 15: pValues[nProp] >>= sMailAddress; break;
280 case 16: pValues[nProp] >>= bIsMailReplyTo; break;
281 case 17: pValues[nProp] >>= sMailReplyTo; break;
282 case 18: pValues[nProp] >>= sMailServer; break;
283 case 19:
284 bIsDefaultPort =
285 (pValues[nProp] >>= nMailPort) ?
286 sal_False : sal_True;
287 break;
288 case 20: pValues[nProp] >>= bIsSecureConnection; break;
289 case 21: pValues[nProp] >>= bIsAuthentication; break;
290 case 22: pValues[nProp] >>= sMailUserName; break;
291 case 23: pValues[nProp] >>= sMailPassword; break;
292 case 24 :pValues[nProp] >>= aDBData.sDataSource; break;
293 case 25 :pValues[nProp] >>= aDBData.sCommand; break;
294 case 26 :
296 short nTemp = 0;
297 if(pValues[nProp] >>= nTemp)
298 aDBData.nCommandType = nTemp;
300 break;
301 case 27: pValues[nProp] >>= sFilter; break;
302 case 28: pValues[nProp] >>= aSavedDocuments; break;
303 case 29:
304 pValues[nProp] >>= bIsEMailSupported;
305 break;
306 case 30: pValues[nProp] >>= bIsGreetingLineInMail; break;
307 case 31: pValues[nProp] >>= bIsIndividualGreetingLineInMail; break;
308 case 32: pValues[nProp] >>= bIsSMPTAfterPOP; break;
309 case 33: pValues[nProp] >>= sInServerName; break;
310 case 34: pValues[nProp] >>= nInServerPort; break;
311 case 35: pValues[nProp] >>= bInServerPOP; break;
312 case 36: pValues[nProp] >>= sInServerUserName; break;
313 case 37: pValues[nProp] >>= sInServerPassword; break;
314 case 38: pValues[nProp] >>= bIsHideEmptyParagraphs; break;
315 case 39: pValues[nProp] >>= nCurrentAddressBlock; break;
319 //read the list of data base assignments
320 Sequence<OUString> aAssignments = GetNodeNames(C2U(cAddressDataAssignments));
321 if(aAssignments.getLength())
323 //create a list of property names to load the URLs of all data bases
324 const OUString* pAssignments = aAssignments.getConstArray();
325 Sequence< ::rtl::OUString > aAssignProperties(4 * aAssignments.getLength());
326 ::rtl::OUString* pAssignProperties = aAssignProperties.getArray();
327 sal_Int32 nAssign;
328 OUString sSlash = C2U("/");
329 for(nAssign = 0; nAssign < aAssignProperties.getLength(); nAssign += 4)
331 String sAssignPath = C2U(cAddressDataAssignments);
332 sAssignPath += '/';
333 sAssignPath += String(pAssignments[nAssign / 4]);
334 sAssignPath += '/';
335 pAssignProperties[nAssign] = sAssignPath;
336 pAssignProperties[nAssign] += C2U(cDataSourceName);
337 pAssignProperties[nAssign + 1] = sAssignPath;
338 pAssignProperties[nAssign + 1] += C2U(cDataTableName);
339 pAssignProperties[nAssign + 2] = sAssignPath;
340 pAssignProperties[nAssign + 2] += C2U(cDataCommandType);
341 pAssignProperties[nAssign + 3] = sAssignPath;
342 pAssignProperties[nAssign + 3] += C2U(cDBColumnAssignments);
344 Sequence<Any> aAssignValues = GetProperties(aAssignProperties);
345 const Any* pAssignValues = aAssignValues.getConstArray();
346 for(nAssign = 0; nAssign < aAssignValues.getLength(); nAssign += 4 )
348 DBAddressDataAssignment aAssignment;
349 pAssignValues[nAssign] >>= aAssignment.aDBData.sDataSource;
350 pAssignValues[nAssign + 1] >>= aAssignment.aDBData.sCommand;
351 pAssignValues[nAssign + 2] >>= aAssignment.aDBData.nCommandType;
352 pAssignValues[nAssign + 3] >>= aAssignment.aDBColumnAssignments;
353 aAssignment.sConfigNodeName = pAssignments[nAssign / 4];
354 aAddressDataAssignments.push_back(aAssignment);
357 //check if the saved documents still exist
358 if(aSavedDocuments.getLength())
360 uno::Sequence< ::rtl::OUString > aTempDocuments(aSavedDocuments.getLength());
361 ::rtl::OUString* pTempDocuments = aTempDocuments.getArray();
362 sal_Int32 nIndex = 0;
363 for(sal_Int32 i = 0; i < aSavedDocuments.getLength(); ++i)
365 if(SWUnoHelper::UCB_IsFile( aSavedDocuments[i] ))
367 pTempDocuments[nIndex++] = aSavedDocuments[i];
370 if(nIndex < aSavedDocuments.getLength())
372 aSavedDocuments = aTempDocuments;
373 aSavedDocuments.realloc(nIndex);
378 /*-- 06.05.2004 12:51:54---------------------------------------------------
380 -----------------------------------------------------------------------*/
381 SwMailMergeConfigItem_Impl::~SwMailMergeConfigItem_Impl()
384 /*-- 13.03.2006 12:12:59---------------------------------------------------
386 -----------------------------------------------------------------------*/
387 void SwMailMergeConfigItem_Impl::SetCurrentAddressBlockIndex( sal_Int32 nSet )
389 if(aAddressBlocks.size() >= sal::static_int_cast<sal_uInt32, sal_Int32>(nSet))
391 nCurrentAddressBlock = nSet;
392 SetModified();
395 /*-- 16.04.2004 13:06:07---------------------------------------------------
397 -----------------------------------------------------------------------*/
398 OUString lcl_CreateNodeName(Sequence<OUString>& rAssignments )
400 const OUString* pNames = rAssignments.getConstArray();
401 sal_Int32 nStart = rAssignments.getLength();
402 OUString sNewName;
403 bool bFound;
406 bFound = false;
407 sNewName = C2U("_");
408 sNewName += OUString::valueOf(nStart);
409 //search if the name exists
410 for(sal_Int32 nAssign = 0; nAssign < rAssignments.getLength(); ++nAssign)
412 if(pNames[nAssign] == sNewName)
414 bFound = true;
415 ++nStart;
416 break;
420 while(bFound);
421 // add the new name to the array of existing names
422 rAssignments.realloc(rAssignments.getLength() + 1);
423 rAssignments.getArray()[rAssignments.getLength() - 1] = sNewName;
424 return sNewName;
426 // --------------------------------------------------------------------------------
427 void lcl_ConvertToNumbers(OUString& rBlock, const ResStringArray& rHeaders )
429 //convert the strings used for UI to numbers used for the configuration
430 String sBlock(rBlock);
431 sBlock.SearchAndReplaceAllAscii("\n", String::CreateFromAscii("\\n"));
432 for(USHORT i = 0; i < rHeaders.Count(); ++i)
434 String sHeader = rHeaders.GetString( i );
435 sHeader.Insert('<', 0);
436 sHeader += '>';
437 String sReplace(C2U("<>"));
438 sReplace.Insert('0' + i, 1);
439 sBlock.SearchAndReplaceAll(sHeader, sReplace);
441 rBlock = sBlock;
443 // --------------------------------------------------------------------------------
444 void lcl_ConvertFromNumbers(OUString& rBlock, const ResStringArray& rHeaders)
446 //convert the numbers used for the configuration to strings used for UI to numbers
447 //doesn't use ReplaceAll to prevent expansion of numbers inside of the headers
448 String sBlock(rBlock);
449 sBlock.SearchAndReplaceAllAscii("\\n", '\n');
450 SwAddressIterator aGreetingIter(sBlock);
451 sBlock.Erase();
452 while(aGreetingIter.HasMore())
454 SwMergeAddressItem aNext = aGreetingIter.Next();
455 if(aNext.bIsColumn)
457 //the text should be 1 characters long
458 sal_Unicode cChar = aNext.sText.GetChar(0);
459 if(cChar >= '0' && cChar <= 'c')
461 sBlock += '<';
462 sal_uInt16 nHeader = cChar - '0';
463 if(nHeader < rHeaders.Count())
464 sBlock += rHeaders.GetString( nHeader );
465 sBlock += '>';
467 else
469 DBG_ERROR("parse error in address block or greeting line");
472 else
473 sBlock += aNext.sText;
475 rBlock = sBlock;
478 /*--------------------------------------------------------------------
480 --------------------------------------------------------------------*/
481 const Sequence<OUString>& SwMailMergeConfigItem_Impl::GetPropertyNames()
483 static Sequence<OUString> aNames;
484 if(!aNames.getLength())
486 static const char* aPropNames[] =
488 "OutputToLetter", // 0
489 "IncludeCountry", // 1
490 "ExcludeCountry", // 2
491 "AddressBlockSettings", // 3
492 "IsAddressBlock", // 4
493 "IsGreetingLine", // 5
494 "IsIndividualGreetingLine", // 6
495 "FemaleGreetingLines", // 7
496 "MaleGreetingLines", // 8
497 "NeutralGreetingLines", // 9
498 "CurrentFemaleGreeting", // 10
499 "CurrentMaleGreeting", // 11
500 "CurrentNeutralGreeting", // 12
501 "FemaleGenderValue", // 13
502 "MailDisplayName", // 14
503 "MailAddress", // 15
504 "IsMailReplyTo", // 16
505 "MailReplyTo", // 17
506 "MailServer", // 18
507 "MailPort", // 19
508 "IsSecureConnection", // 20
509 "IsAuthentication", // 21
510 "MailUserName", // 22
511 "MailPassword", // 23
512 "DataSource/DataSourceName",// 24
513 "DataSource/DataTableName", // 25
514 "DataSource/DataCommandType",// 26
515 "Filter", // 27
516 "SavedDocuments", // 28
517 "EMailSupported", // 29
518 "IsEMailGreetingLine", //30
519 "IsEMailIndividualGreetingLine", //31
520 "IsSMPTAfterPOP", //32
521 "InServerName", //33
522 "InServerPort", //34
523 "InServerIsPOP", //35
524 "InServerUserName", //36
525 "InServerPassword", //37
526 "IsHideEmptyParagraphs", //38
527 "CurrentAddressBlock" //39
530 const int nCount = sizeof(aPropNames)/sizeof(const char*);
531 aNames.realloc(nCount);
532 OUString* pNames = aNames.getArray();
533 for(int i = 0; i < nCount; i++)
534 pNames[i] = OUString::createFromAscii(aPropNames[i]);
536 return aNames;
538 /*-- 15.04.2004 08:48:39---------------------------------------------------
540 -----------------------------------------------------------------------*/
541 void SwMailMergeConfigItem_Impl::Commit()
543 Sequence<OUString> aNames = GetPropertyNames();
544 Sequence<Any> aValues(aNames.getLength());
545 Any* pValues = aValues.getArray();
547 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
549 switch(nProp)
551 case 0: pValues[nProp] <<= bIsOutputToLetter; break;//
552 case 1: pValues[nProp] <<= bIncludeCountry; break;
553 case 2: pValues[nProp] <<= sExcludeCountry; break;
554 case 3: pValues[nProp] <<= GetAddressBlocks(sal_True); break;
555 case 4:
557 if( bUserSettingWereOverwritten == sal_True )
558 pValues[nProp] <<= bIsAddressBlock_LastUserSetting;
559 else
560 pValues[nProp] <<= bIsAddressBlock;
561 break;
563 case 5:
565 if( bUserSettingWereOverwritten == sal_True )
566 pValues[nProp] <<= bIsGreetingLine_LastUserSetting;
567 else
568 pValues[nProp] <<= bIsGreetingLine;
569 break;
571 case 6: pValues[nProp] <<= bIsIndividualGreetingLine; break;
572 case 7:
573 case 8:
574 case 9:
575 pValues[nProp] <<= GetGreetings(
576 SwMailMergeConfigItem::Gender(
577 SwMailMergeConfigItem::FEMALE + nProp - 7), sal_True);
578 break;
579 case 10: pValues[nProp] <<= nCurrentFemaleGreeting; break;
580 case 11: pValues[nProp] <<= nCurrentMaleGreeting; break;
581 case 12: pValues[nProp] <<= nCurrentNeutralGreeting; break;
582 case 13: pValues[nProp] <<= sFemaleGenderValue; break;
583 case 14: pValues[nProp] <<= sMailDisplayName; break;
584 case 15: pValues[nProp] <<= sMailAddress; break;
585 case 16: pValues[nProp] <<= bIsMailReplyTo; break;
586 case 17: pValues[nProp] <<= sMailReplyTo; break;
587 case 18: pValues[nProp] <<= sMailServer; break;
588 case 19: if(!bIsDefaultPort)
589 pValues[nProp] <<= nMailPort;
590 break;
591 case 20: pValues[nProp] <<= bIsSecureConnection; break;
592 case 21: pValues[nProp] <<= bIsAuthentication; break;
593 case 22: pValues[nProp] <<= sMailUserName; break;
594 case 23: pValues[nProp] <<= sMailPassword; break;
595 case 24 :pValues[nProp] <<= aDBData.sDataSource; break;
596 case 25 :pValues[nProp] <<= aDBData.sCommand; break;
597 case 26 :pValues[nProp] <<= (short)aDBData.nCommandType; break;
598 case 27 :pValues[nProp] <<= sFilter; break;
599 case 28 :pValues[nProp] <<= aSavedDocuments; break;
600 case 29: pValues[nProp] <<= bIsEMailSupported; break;
601 case 30:
603 if( bUserSettingWereOverwritten == sal_True )
604 pValues[nProp] <<= bIsGreetingLineInMail_LastUserSetting;
605 else
606 pValues[nProp] <<= bIsGreetingLineInMail;
607 break;
609 case 31: pValues[nProp] <<= bIsIndividualGreetingLineInMail; break;
610 case 32: pValues[nProp] <<= bIsSMPTAfterPOP; break;
611 case 33: pValues[nProp] <<= sInServerName; break;
612 case 34: pValues[nProp] <<= nInServerPort; break;
613 case 35: pValues[nProp] <<= bInServerPOP; break;
614 case 36: pValues[nProp] <<= sInServerUserName; break;
615 case 37: pValues[nProp] <<= sInServerPassword; break;
616 case 38: pValues[nProp] <<= bIsHideEmptyParagraphs; break;
617 case 39: pValues[nProp] <<= nCurrentAddressBlock; break;
620 PutProperties(aNames, aValues);
621 //store the changed / new assignments
623 //load the existing node names to find new names
624 Sequence<OUString> aAssignments = GetNodeNames(C2U(cAddressDataAssignments));
626 ::std::vector<DBAddressDataAssignment>::iterator aAssignIter;
627 for(aAssignIter = aAddressDataAssignments.begin();
628 aAssignIter != aAddressDataAssignments.end(); aAssignIter++)
630 if(aAssignIter->bColumnAssignmentsChanged)
632 //create a new node name
633 OUString sNewNode = aAssignIter->sConfigNodeName.getLength() ?
634 aAssignIter->sConfigNodeName :
635 lcl_CreateNodeName(aAssignments);
636 OUString sSlash = C2U("/");
637 OUString sNodePath = C2U(cAddressDataAssignments);
638 sNodePath += sSlash;
639 sNodePath += sNewNode;
640 sNodePath += sSlash;
641 //only one new entry is written
642 Sequence< PropertyValue > aNewValues(4);
643 PropertyValue* pNewValues = aNewValues.getArray();
644 pNewValues[0].Name = sNodePath;
645 pNewValues[0].Name += C2U(cDataSourceName);
646 pNewValues[0].Value <<= aAssignIter->aDBData.sDataSource;
647 pNewValues[1].Name = sNodePath;
648 pNewValues[1].Name += C2U(cDataTableName);
649 pNewValues[1].Value <<= aAssignIter->aDBData.sCommand;
650 pNewValues[2].Name = sNodePath;
651 pNewValues[2].Name += C2U(cDataCommandType);
652 pNewValues[2].Value <<= aAssignIter->aDBData.nCommandType;
653 pNewValues[3].Name = sNodePath;
654 pNewValues[3].Name += C2U(cDBColumnAssignments);
655 pNewValues[3].Value <<= aAssignIter->aDBColumnAssignments;
657 SetSetProperties(C2U(cAddressDataAssignments), aNewValues);
661 bUserSettingWereOverwritten = sal_False;
663 /*-- 06.05.2004 13:04:36---------------------------------------------------
665 -----------------------------------------------------------------------*/
666 const Sequence< ::rtl::OUString> SwMailMergeConfigItem_Impl::GetAddressBlocks(
667 sal_Bool bConvertToConfig) const
669 Sequence< ::rtl::OUString> aRet(aAddressBlocks.size());
670 ::rtl::OUString* pRet = aRet.getArray();
671 for(sal_uInt32 nBlock = 0; nBlock < aAddressBlocks.size(); nBlock++)
673 pRet[nBlock] = aAddressBlocks[nBlock];
674 if(bConvertToConfig)
675 lcl_ConvertToNumbers(pRet[nBlock], m_AddressHeaderSA);
677 return aRet;
679 /*-- 06.05.2004 13:04:36---------------------------------------------------
681 -----------------------------------------------------------------------*/
682 void SwMailMergeConfigItem_Impl::SetAddressBlocks(
683 const Sequence< ::rtl::OUString>& rBlocks,
684 sal_Bool bConvertFromConfig)
686 aAddressBlocks.clear();
687 for(sal_Int32 nBlock = 0; nBlock < rBlocks.getLength(); nBlock++)
689 OUString sBlock = rBlocks[nBlock];
690 if(bConvertFromConfig)
691 lcl_ConvertFromNumbers(sBlock, m_AddressHeaderSA);
692 aAddressBlocks.push_back(sBlock);
694 nCurrentAddressBlock = 0;
695 SetModified();
697 /*-- 30.04.2004 11:04:52---------------------------------------------------
699 -----------------------------------------------------------------------*/
700 const Sequence< ::rtl::OUString> SwMailMergeConfigItem_Impl::GetGreetings(
701 SwMailMergeConfigItem::Gender eType, sal_Bool bConvertToConfig) const
703 const ::std::vector< ::rtl::OUString>& rGreetings =
704 eType == SwMailMergeConfigItem::FEMALE ? aFemaleGreetingLines :
705 eType == SwMailMergeConfigItem::MALE ? aMaleGreetingLines :
706 aNeutralGreetingLines;
707 Sequence< ::rtl::OUString> aRet(rGreetings.size());
708 ::rtl::OUString* pRet = aRet.getArray();
709 for(sal_uInt32 nGreeting = 0; nGreeting < rGreetings.size(); nGreeting++)
711 pRet[nGreeting] = rGreetings[nGreeting];
712 if(bConvertToConfig)
713 lcl_ConvertToNumbers(pRet[nGreeting], m_AddressHeaderSA);
715 return aRet;
717 /*-- 30.04.2004 11:04:52---------------------------------------------------
719 -----------------------------------------------------------------------*/
720 void SwMailMergeConfigItem_Impl::SetGreetings(
721 SwMailMergeConfigItem::Gender eType,
722 const Sequence< ::rtl::OUString>& rSetGreetings,
723 sal_Bool bConvertFromConfig)
725 ::std::vector< ::rtl::OUString>& rGreetings =
726 eType == SwMailMergeConfigItem::FEMALE ? aFemaleGreetingLines :
727 eType == SwMailMergeConfigItem::MALE ? aMaleGreetingLines :
728 aNeutralGreetingLines;
730 rGreetings.clear();
731 for(sal_Int32 nGreeting = 0; nGreeting < rSetGreetings.getLength(); nGreeting++)
733 OUString sGreeting = rSetGreetings[nGreeting];
734 if(bConvertFromConfig)
735 lcl_ConvertFromNumbers(sGreeting, m_AddressHeaderSA);
736 rGreetings.push_back(sGreeting);
738 SetModified();
740 /*-- 11.05.2004 13:13:54---------------------------------------------------
742 -----------------------------------------------------------------------*/
743 sal_Int32 SwMailMergeConfigItem_Impl::GetCurrentGreeting(
744 SwMailMergeConfigItem::Gender eType) const
746 sal_Int32 nRet;
747 switch(eType)
749 case SwMailMergeConfigItem::FEMALE: nRet = nCurrentFemaleGreeting ; break;
750 case SwMailMergeConfigItem::MALE: nRet = nCurrentMaleGreeting ; break;
751 default: nRet = nCurrentNeutralGreeting; break;
753 return nRet;
755 /*-- 11.05.2004 13:13:54---------------------------------------------------
757 -----------------------------------------------------------------------*/
758 void SwMailMergeConfigItem_Impl::SetCurrentGreeting(
759 SwMailMergeConfigItem::Gender eType, sal_Int32 nIndex)
761 bool bChanged = false;
762 switch(eType)
764 case SwMailMergeConfigItem::FEMALE:
765 bChanged = nCurrentFemaleGreeting != nIndex;
766 nCurrentFemaleGreeting = nIndex;
767 break;
768 case SwMailMergeConfigItem::MALE:
769 bChanged = nCurrentMaleGreeting != nIndex;
770 nCurrentMaleGreeting = nIndex;
771 break;
772 default:
773 bChanged = nCurrentNeutralGreeting != nIndex;
774 nCurrentNeutralGreeting = nIndex;
776 if(bChanged)
777 SetModified();
780 static SwMailMergeConfigItem_Impl* pOptions = NULL;
781 static sal_Int32 nRefCount = 0;
782 static ::osl::Mutex aMutex;
783 /*-- 15.04.2004 08:42:43---------------------------------------------------
785 -----------------------------------------------------------------------*/
786 SwMailMergeConfigItem::SwMailMergeConfigItem() :
787 m_bAddressInserted(false),
788 m_bMergeDone(false),
789 m_bGreetingInserted(false),
790 m_nGreetingMoves(0),
791 m_nStartPrint(0),
792 m_nEndPrint(0),
793 m_pSourceView(0),
794 m_pTargetView(0)
796 // Global access, must be guarded (multithreading)
797 ::osl::MutexGuard aGuard( aMutex );
798 if ( !pOptions )
799 pOptions = new SwMailMergeConfigItem_Impl;
800 ++nRefCount;
801 m_pImpl = pOptions;
803 /*-- 15.04.2004 08:43:36---------------------------------------------------
805 -----------------------------------------------------------------------*/
806 SwMailMergeConfigItem::~SwMailMergeConfigItem()
808 // Global access, must be guarded (multithreading)
809 ::osl::MutexGuard aGuard( aMutex );
810 if ( !--nRefCount )
812 DELETEZ( pOptions );
815 /*-- 06.05.2004 14:18:10---------------------------------------------------
817 -----------------------------------------------------------------------*/
818 void SwMailMergeConfigItem::Commit()
820 if(m_pImpl->IsModified())
821 m_pImpl->Commit();
823 /*-- 06.05.2004 12:59:50---------------------------------------------------
825 -----------------------------------------------------------------------*/
826 const ResStringArray& SwMailMergeConfigItem::GetDefaultAddressHeaders() const
828 return m_pImpl->m_AddressHeaderSA;
830 /*-- 27.04.2004 14:34:16---------------------------------------------------
832 -----------------------------------------------------------------------*/
833 void SwMailMergeConfigItem::SetAddressBlocks(
834 const Sequence< ::rtl::OUString>& rBlocks)
836 m_pImpl->SetAddressBlocks(rBlocks);
838 /*-- 27.04.2004 14:34:16---------------------------------------------------
840 -----------------------------------------------------------------------*/
841 const Sequence< ::rtl::OUString> SwMailMergeConfigItem::GetAddressBlocks() const
843 return m_pImpl->GetAddressBlocks();
845 /*-- 11.05.2004 17:08:45---------------------------------------------------
847 -----------------------------------------------------------------------*/
848 sal_Bool SwMailMergeConfigItem::IsAddressBlock()const
850 return m_pImpl->bIsAddressBlock && IsOutputToLetter();
852 /*-- 11.05.2004 17:08:46---------------------------------------------------
854 -----------------------------------------------------------------------*/
855 void SwMailMergeConfigItem::SetAddressBlock(sal_Bool bSet)
857 m_pImpl->bUserSettingWereOverwritten = sal_False;
858 if(m_pImpl->bIsAddressBlock != bSet)
860 m_pImpl->bIsAddressBlock = bSet;
861 m_pImpl->SetModified();
865 /*-- 30.08.2005 15:09:46---------------------------------------------------
867 -----------------------------------------------------------------------*/
868 sal_Bool SwMailMergeConfigItem::IsHideEmptyParagraphs() const
870 return m_pImpl->bIsHideEmptyParagraphs;
872 /*-- 30.08.2005 15:09:47---------------------------------------------------
874 -----------------------------------------------------------------------*/
875 void SwMailMergeConfigItem::SetHideEmptyParagraphs(sal_Bool bSet)
877 if(m_pImpl->bIsHideEmptyParagraphs != bSet)
879 m_pImpl->bIsHideEmptyParagraphs = bSet;
880 m_pImpl->SetModified();
883 /*-- 28.04.2004 13:00:02---------------------------------------------------
885 -----------------------------------------------------------------------*/
886 sal_Bool SwMailMergeConfigItem::IsIncludeCountry() const
888 return m_pImpl->bIncludeCountry;
890 /*-- 28.04.2004 13:00:02---------------------------------------------------
892 -----------------------------------------------------------------------*/
893 rtl::OUString& SwMailMergeConfigItem::GetExcludeCountry() const
895 return m_pImpl->sExcludeCountry;
897 /*-- 28.04.2004 13:00:02---------------------------------------------------
899 -----------------------------------------------------------------------*/
900 void SwMailMergeConfigItem::SetCountrySettings(sal_Bool bSet, const rtl::OUString& rCountry)
902 if(m_pImpl->sExcludeCountry != rCountry ||
903 m_pImpl->bIncludeCountry != bSet)
905 m_pImpl->bIncludeCountry = bSet;
906 m_pImpl->sExcludeCountry = bSet ? rCountry : OUString();
907 m_pImpl->SetModified();
911 /*-- 28.04.2004 15:35:16---------------------------------------------------
913 -----------------------------------------------------------------------*/
914 void SwMailMergeConfigItem::SetCurrentConnection(
915 Reference< XDataSource> xSource,
916 SharedConnection xConnection,
917 Reference< XColumnsSupplier> xColumnsSupplier,
918 const SwDBData& rDBData)
920 m_pImpl->xSource = xSource ;
921 m_pImpl->xConnection = xConnection ;
922 m_pImpl->xColumnsSupplier = xColumnsSupplier;
923 m_pImpl->aDBData = rDBData;
924 m_pImpl->xResultSet = 0;
925 m_pImpl->nResultSetCursorPos = 0;
926 m_pImpl->SetModified();
928 /*-- 28.04.2004 15:38:11---------------------------------------------------
930 -----------------------------------------------------------------------*/
931 Reference< XDataSource> SwMailMergeConfigItem::GetSource()
933 return m_pImpl->xSource;
935 /*-- 28.04.2004 15:38:11---------------------------------------------------
937 -----------------------------------------------------------------------*/
938 SharedConnection SwMailMergeConfigItem::GetConnection()
940 return m_pImpl->xConnection;
942 /*-- 28.04.2004 15:38:11---------------------------------------------------
944 -----------------------------------------------------------------------*/
945 Reference< XColumnsSupplier> SwMailMergeConfigItem::GetColumnsSupplier()
947 if(!m_pImpl->xColumnsSupplier.is() && m_pImpl->xConnection.is())
949 m_pImpl->xColumnsSupplier = SwNewDBMgr::GetColumnSupplier(m_pImpl->xConnection,
950 m_pImpl->aDBData.sCommand,
951 m_pImpl->aDBData.nCommandType == CommandType::TABLE ?
952 SW_DB_SELECT_TABLE : SW_DB_SELECT_QUERY );
954 return m_pImpl->xColumnsSupplier;
956 /*-- 30.04.2004 14:30:55---------------------------------------------------
958 -----------------------------------------------------------------------*/
959 const SwDBData& SwMailMergeConfigItem::GetCurrentDBData() const
961 return m_pImpl->aDBData;
964 /*-- 17.06.2004 13:18:47---------------------------------------------------
966 -----------------------------------------------------------------------*/
967 void SwMailMergeConfigItem::SetCurrentDBData( const SwDBData& rDBData)
969 if(m_pImpl->aDBData != rDBData)
971 m_pImpl->aDBData = rDBData;
972 m_pImpl->xConnection.clear();
973 m_pImpl->xSource = 0;
974 m_pImpl->xColumnsSupplier = 0;
975 m_pImpl->SetModified();
978 /*-- 29.04.2004 11:34:36---------------------------------------------------
980 -----------------------------------------------------------------------*/
981 Reference< XResultSet> SwMailMergeConfigItem::GetResultSet() const
983 if(!m_pImpl->xConnection.is() && m_pImpl->aDBData.sDataSource.getLength())
985 m_pImpl->xConnection.reset(
986 SwNewDBMgr::GetConnection( m_pImpl->aDBData.sDataSource, m_pImpl->xSource ),
987 SharedConnection::TakeOwnership
990 if(!m_pImpl->xResultSet.is() && m_pImpl->xConnection.is())
994 Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
995 if( xMgr.is() )
997 Reference<XRowSet> xRowSet(
998 xMgr->createInstance(C2U("com.sun.star.sdb.RowSet")), UNO_QUERY);
999 Reference<XPropertySet> xRowProperties(xRowSet, UNO_QUERY);
1000 xRowProperties->setPropertyValue(C2U("DataSourceName"), makeAny(m_pImpl->aDBData.sDataSource));
1001 xRowProperties->setPropertyValue(C2U("Command"), makeAny(m_pImpl->aDBData.sCommand));
1002 xRowProperties->setPropertyValue(C2U("CommandType"), makeAny(m_pImpl->aDBData.nCommandType));
1003 xRowProperties->setPropertyValue(C2U("FetchSize"), makeAny((sal_Int32)10));
1004 xRowProperties->setPropertyValue(C2U("ActiveConnection"), makeAny(m_pImpl->xConnection.getTyped()));
1007 xRowProperties->setPropertyValue(C2U("ApplyFilter"), makeAny(m_pImpl->sFilter.getLength()>0));
1008 xRowProperties->setPropertyValue(C2U("Filter"), makeAny(m_pImpl->sFilter));
1010 catch(Exception&)
1012 DBG_ERROR("exception caught in xResultSet->SetFilter()");
1014 xRowSet->execute();
1015 m_pImpl->xResultSet = xRowSet.get();
1016 m_pImpl->xResultSet->first();
1017 m_pImpl->nResultSetCursorPos = 1;
1020 catch(Exception& )
1022 DBG_ERROR("exception caught in: SwMailMergeConfigItem::GetResultSet() ");
1025 return m_pImpl->xResultSet;
1027 /*-- 13.08.2004 11:49:46---------------------------------------------------
1029 -----------------------------------------------------------------------*/
1030 void SwMailMergeConfigItem::DisposeResultSet()
1032 m_pImpl->xConnection.clear();
1033 if(m_pImpl->xResultSet.is())
1035 ::comphelper::disposeComponent( m_pImpl->xResultSet );
1038 /*-- 14.05.2004 15:07:55---------------------------------------------------
1040 -----------------------------------------------------------------------*/
1041 ::rtl::OUString& SwMailMergeConfigItem::GetFilter() const
1043 return m_pImpl->sFilter;
1045 /*-- 14.05.2004 15:07:55---------------------------------------------------
1047 -----------------------------------------------------------------------*/
1048 void SwMailMergeConfigItem::SetFilter(::rtl::OUString& rFilter)
1050 if(m_pImpl->sFilter != rFilter)
1052 m_pImpl->sFilter = rFilter;
1053 m_pImpl->SetModified();
1054 Reference<XPropertySet> xRowProperties(m_pImpl->xResultSet, UNO_QUERY);
1055 if(xRowProperties.is())
1059 xRowProperties->setPropertyValue(C2U("ApplyFilter"), makeAny(m_pImpl->sFilter.getLength()>0));
1060 xRowProperties->setPropertyValue(C2U("Filter"), makeAny(m_pImpl->sFilter));
1061 uno::Reference<XRowSet> xRowSet( m_pImpl->xResultSet, UNO_QUERY_THROW );
1062 xRowSet->execute();
1064 catch(Exception&)
1066 DBG_ERROR("exception caught in SwMailMergeConfigItem::SetFilter()");
1071 /*-- 29.04.2004 11:55:38---------------------------------------------------
1073 -----------------------------------------------------------------------*/
1074 sal_Int32 SwMailMergeConfigItem::MoveResultSet(sal_Int32 nTarget)
1076 if(!m_pImpl->xResultSet.is())
1077 GetResultSet();
1078 if(m_pImpl->xResultSet.is())
1082 //no action if the resultset is already at the right position
1083 if(m_pImpl->xResultSet->getRow() != nTarget)
1085 if(nTarget > 0)
1087 BOOL bMoved = m_pImpl->xResultSet->absolute(nTarget);
1088 if(!bMoved)
1090 if(nTarget > 1)
1091 m_pImpl->xResultSet->last();
1092 else if(nTarget == 1)
1093 m_pImpl->xResultSet->first();
1096 else if(nTarget == -1)
1097 m_pImpl->xResultSet->last();
1098 m_pImpl->nResultSetCursorPos = m_pImpl->xResultSet->getRow();
1101 catch(Exception&)
1105 return m_pImpl->nResultSetCursorPos;
1108 /*-- 27.05.2004 13:56:18---------------------------------------------------
1110 -----------------------------------------------------------------------*/
1111 bool SwMailMergeConfigItem::IsResultSetFirstLast(bool& bIsFirst, bool& bIsLast)
1113 bool bRet = false;
1114 if(!m_pImpl->xResultSet.is())
1115 GetResultSet();
1116 if(m_pImpl->xResultSet.is())
1120 bIsFirst = m_pImpl->xResultSet->isFirst();
1121 bIsLast = m_pImpl->xResultSet->isLast();
1122 bRet = true;
1124 catch(Exception&)
1128 return bRet;
1130 /*-- 29.04.2004 11:55:38---------------------------------------------------
1132 -----------------------------------------------------------------------*/
1133 sal_Int32 SwMailMergeConfigItem::GetResultSetPosition() const
1135 return m_pImpl->nResultSetCursorPos;
1137 /*-- 27.05.2004 14:49:53---------------------------------------------------
1139 -----------------------------------------------------------------------*/
1140 bool SwMailMergeConfigItem::IsRecordExcluded(sal_Int32 nRecord)
1142 bool bRet = false;
1143 if(nRecord > 0 && nRecord < m_aSelection.getLength())
1145 sal_Int32 nTemp = 0;
1146 m_aSelection[nRecord - 1] >>= nTemp;
1147 bRet = nTemp < 1;
1149 return bRet;
1151 /*-- 27.05.2004 14:49:53---------------------------------------------------
1153 -----------------------------------------------------------------------*/
1154 void SwMailMergeConfigItem::ExcludeRecord(sal_Int32 nRecord, bool bExclude)
1156 //nRecord is based on 1
1157 //the selection array contains Anys for all records
1158 //excluded records contain a '-1'
1159 if(!m_aSelection.getLength() || nRecord > m_aSelection.getLength())
1161 if(bExclude)
1163 //if no selection array is available we need to create one containing the
1164 //entries for all available records
1165 if(!m_pImpl->xResultSet.is())
1166 GetResultSet();
1167 if(m_pImpl->xResultSet.is())
1169 m_pImpl->xResultSet->last();
1170 sal_Int32 nEnd = m_pImpl->xResultSet->getRow();
1171 sal_Int32 nStart = m_aSelection.getLength();
1172 m_aSelection.realloc(nEnd);
1173 Any* pSelection = m_aSelection.getArray();
1174 for(sal_Int32 nIndex = nStart; nIndex < nEnd; ++nIndex)
1176 if((nRecord - 1) != nIndex)
1177 pSelection[nIndex] <<= nIndex + 1;
1178 else
1179 pSelection[nIndex] <<= (sal_Int32) -1;
1184 else
1186 if(nRecord > 0 && m_aSelection.getLength() > nRecord)
1188 m_aSelection[nRecord - 1] <<= bExclude ? -1 : nRecord;
1192 /*-- 27.05.2004 15:08:35---------------------------------------------------
1194 -----------------------------------------------------------------------*/
1195 Sequence< Any > SwMailMergeConfigItem::GetSelection() const
1197 Sequence< Any > aRet(m_aSelection.getLength());
1198 sal_Int32 nRetIndex = 0;
1199 sal_Int32 nRet;
1200 for(sal_Int32 nIndex = 0; nIndex < m_aSelection.getLength(); ++nIndex)
1202 m_aSelection[nIndex] >>= nRet;
1203 if(nRet > 0)
1205 aRet[nRetIndex] <<= nRet;
1206 ++nRetIndex;
1209 aRet.realloc(nRetIndex);
1210 return aRet;
1212 /*-- 16.06.2004 15:15:56---------------------------------------------------
1214 -----------------------------------------------------------------------*/
1215 const uno::Sequence< ::rtl::OUString>&
1216 SwMailMergeConfigItem::GetSavedDocuments() const
1218 return m_pImpl->aSavedDocuments;
1220 /*-- 16.06.2004 15:15:56---------------------------------------------------
1222 -----------------------------------------------------------------------*/
1223 void SwMailMergeConfigItem::AddSavedDocument(::rtl::OUString rName)
1225 const ::rtl::OUString* pDocs = m_pImpl->aSavedDocuments.getConstArray();
1226 bool bFound = false;
1227 for(sal_Int32 nDoc = 0; nDoc < m_pImpl->aSavedDocuments.getLength(); ++nDoc)
1229 if(pDocs[nDoc] == rName)
1231 bFound = true;
1232 break;
1235 if(!bFound)
1237 m_pImpl->aSavedDocuments.realloc(m_pImpl->aSavedDocuments.getLength() + 1);
1238 m_pImpl->aSavedDocuments[m_pImpl->aSavedDocuments.getLength() - 1] = rName;
1241 /*-- 28.04.2004 16:15:16---------------------------------------------------
1243 -----------------------------------------------------------------------*/
1244 sal_Bool SwMailMergeConfigItem::IsOutputToLetter()const
1246 return m_pImpl->bIsOutputToLetter || !IsMailAvailable();
1248 /*-- 28.04.2004 16:15:16---------------------------------------------------
1250 -----------------------------------------------------------------------*/
1251 void SwMailMergeConfigItem::SetOutputToLetter(sal_Bool bSet)
1253 if(m_pImpl->bIsOutputToLetter != bSet)
1255 m_pImpl->bIsOutputToLetter = bSet;
1256 m_pImpl->SetModified();
1259 /*-- 30.04.2004 10:51:10---------------------------------------------------
1261 -----------------------------------------------------------------------*/
1262 sal_Bool SwMailMergeConfigItem::IsIndividualGreeting(sal_Bool bInEMail) const
1264 return bInEMail ?
1265 m_pImpl->bIsIndividualGreetingLineInMail :
1266 m_pImpl->bIsIndividualGreetingLine;
1268 /*-- 30.04.2004 10:51:10---------------------------------------------------
1270 -----------------------------------------------------------------------*/
1271 void SwMailMergeConfigItem::SetIndividualGreeting(
1272 sal_Bool bSet, sal_Bool bInEMail)
1274 if(bInEMail)
1276 if(m_pImpl->bIsIndividualGreetingLineInMail != bSet)
1278 m_pImpl->bIsIndividualGreetingLineInMail = bSet;
1279 m_pImpl->SetModified();
1282 else
1284 if(m_pImpl->bIsIndividualGreetingLine != bSet)
1286 m_pImpl->bIsIndividualGreetingLine = bSet;
1287 m_pImpl->SetModified();
1291 /*-- 30.04.2004 10:51:10---------------------------------------------------
1293 -----------------------------------------------------------------------*/
1294 sal_Bool SwMailMergeConfigItem::IsGreetingLine(sal_Bool bInEMail) const
1296 return bInEMail ? m_pImpl->bIsGreetingLineInMail : m_pImpl->bIsGreetingLine;
1298 /*-- 30.04.2004 10:51:10---------------------------------------------------
1300 -----------------------------------------------------------------------*/
1301 void SwMailMergeConfigItem::SetGreetingLine(sal_Bool bSet, sal_Bool bInEMail)
1303 m_pImpl->bUserSettingWereOverwritten = sal_False;
1304 if(bInEMail)
1306 if(m_pImpl->bIsGreetingLineInMail != bSet)
1308 m_pImpl->bIsGreetingLineInMail = bSet;
1309 m_pImpl->SetModified();
1312 else
1314 if(m_pImpl->bIsGreetingLine != bSet)
1316 m_pImpl->bIsGreetingLine = bSet;
1317 m_pImpl->SetModified();
1321 /*-- 30.04.2004 11:04:52---------------------------------------------------
1323 -----------------------------------------------------------------------*/
1324 const Sequence< ::rtl::OUString> SwMailMergeConfigItem::GetGreetings(
1325 Gender eType ) const
1327 return m_pImpl->GetGreetings(eType);
1329 /*-- 30.04.2004 11:04:52---------------------------------------------------
1331 -----------------------------------------------------------------------*/
1332 void SwMailMergeConfigItem::SetGreetings(
1333 Gender eType, const Sequence< ::rtl::OUString>& rSetGreetings)
1335 m_pImpl->SetGreetings( eType, rSetGreetings);
1338 /*-- 11.05.2004 13:10:54---------------------------------------------------
1340 -----------------------------------------------------------------------*/
1341 sal_Int32 SwMailMergeConfigItem::GetCurrentGreeting(
1342 SwMailMergeConfigItem::Gender eType) const
1344 return m_pImpl->GetCurrentGreeting(eType);
1346 /*-- 11.05.2004 13:10:55---------------------------------------------------
1348 -----------------------------------------------------------------------*/
1349 void SwMailMergeConfigItem::SetCurrentGreeting(Gender eType, sal_Int32 nIndex)
1351 m_pImpl->SetCurrentGreeting(eType, nIndex);
1353 /*-- 12.05.2004 12:29:59---------------------------------------------------
1355 -----------------------------------------------------------------------*/
1356 const ::rtl::OUString& SwMailMergeConfigItem::GetFemaleGenderValue() const
1358 return m_pImpl->sFemaleGenderValue;
1360 /*-- 12.05.2004 12:29:59---------------------------------------------------
1362 -----------------------------------------------------------------------*/
1363 void SwMailMergeConfigItem::SetFemaleGenderValue(const ::rtl::OUString rValue)
1365 if( m_pImpl->sFemaleGenderValue != rValue )
1367 m_pImpl->sFemaleGenderValue = rValue;
1368 m_pImpl->SetModified();
1372 /*-- 30.04.2004 13:25:41---------------------------------------------------
1374 -----------------------------------------------------------------------*/
1375 Sequence< ::rtl::OUString> SwMailMergeConfigItem::GetColumnAssignment(
1376 const SwDBData& rDBData ) const
1378 Sequence< ::rtl::OUString> aRet;
1379 ::std::vector<DBAddressDataAssignment>::iterator aAssignIter;
1380 for(aAssignIter = m_pImpl->aAddressDataAssignments.begin();
1381 aAssignIter != m_pImpl->aAddressDataAssignments.end(); aAssignIter++)
1383 if(aAssignIter->aDBData == rDBData)
1385 aRet = aAssignIter->aDBColumnAssignments;
1386 break;
1389 return aRet;
1391 /*-- 21.05.2004 12:31:31---------------------------------------------------
1392 returns the name that is assigned as e-mail column of the current data base
1393 -----------------------------------------------------------------------*/
1394 ::rtl::OUString SwMailMergeConfigItem::GetAssignedColumn(sal_uInt32 nColumn) const
1396 ::rtl::OUString sRet;
1397 Sequence< ::rtl::OUString> aAssignment = GetColumnAssignment( m_pImpl->aDBData );
1398 if(aAssignment.getLength() > sal::static_int_cast< sal_Int32, sal_uInt32>(nColumn) && aAssignment[nColumn].getLength())
1399 sRet = aAssignment[nColumn];
1400 else if(nColumn < m_pImpl->m_AddressHeaderSA.Count())
1401 sRet = m_pImpl->m_AddressHeaderSA.GetString(nColumn);
1402 return sRet;
1404 /*-- 30.04.2004 13:25:41---------------------------------------------------
1406 -----------------------------------------------------------------------*/
1407 void SwMailMergeConfigItem::SetColumnAssignment( const SwDBData& rDBData,
1408 const Sequence< ::rtl::OUString>& rList)
1410 ::std::vector<DBAddressDataAssignment>::iterator aAssignIter;
1411 sal_Bool bFound = sal_False;
1412 for(aAssignIter = m_pImpl->aAddressDataAssignments.begin();
1413 aAssignIter != m_pImpl->aAddressDataAssignments.end(); aAssignIter++)
1415 if(aAssignIter->aDBData == rDBData)
1417 if(aAssignIter->aDBColumnAssignments != rList)
1419 aAssignIter->aDBColumnAssignments = rList;
1420 aAssignIter->bColumnAssignmentsChanged = true;
1422 bFound = sal_True;
1423 break;
1426 if(!bFound)
1428 DBAddressDataAssignment aAssignment;
1429 aAssignment.aDBData = rDBData;
1430 aAssignment.aDBColumnAssignments = rList;
1431 aAssignment.bColumnAssignmentsChanged = true;
1432 m_pImpl->aAddressDataAssignments.push_back(aAssignment);
1434 m_pImpl->SetModified();
1437 /*-- 07.09.2005 11:50:27---------------------------------------------------
1439 -----------------------------------------------------------------------*/
1440 bool SwMailMergeConfigItem::IsAddressFieldsAssigned() const
1442 bool bResult = true;
1443 Reference< XResultSet> xResultSet = GetResultSet();
1444 uno::Reference< XColumnsSupplier > xColsSupp( xResultSet, UNO_QUERY );
1445 if(!xColsSupp.is())
1446 return false;
1447 uno::Reference<container::XNameAccess> xCols = xColsSupp->getColumns();
1449 const ResStringArray& rHeaders = GetDefaultAddressHeaders();
1450 Sequence< ::rtl::OUString> aAssignment =
1451 GetColumnAssignment( GetCurrentDBData() );
1452 const ::rtl::OUString* pAssignment = aAssignment.getConstArray();
1453 const Sequence< ::rtl::OUString> aBlocks = GetAddressBlocks();
1455 if(aBlocks.getLength() <= m_pImpl->GetCurrentAddressBlockIndex())
1456 return false;
1457 SwAddressIterator aIter(aBlocks[m_pImpl->GetCurrentAddressBlockIndex()]);
1458 while(aIter.HasMore())
1460 SwMergeAddressItem aItem = aIter.Next();
1461 if(aItem.bIsColumn)
1463 String sConvertedColumn = aItem.sText;
1464 for(USHORT nColumn = 0;
1465 nColumn < rHeaders.Count() && nColumn < aAssignment.getLength();
1466 ++nColumn)
1468 if(rHeaders.GetString(nColumn) == aItem.sText &&
1469 pAssignment[nColumn].getLength())
1471 sConvertedColumn = pAssignment[nColumn];
1472 break;
1475 //find out if the column exists in the data base
1476 if(!xCols->hasByName(sConvertedColumn))
1478 bResult = false;
1479 break;
1483 return bResult;
1485 /*-- 07.09.2005 11:50:27---------------------------------------------------
1487 -----------------------------------------------------------------------*/
1488 bool SwMailMergeConfigItem::IsGreetingFieldsAssigned() const
1490 bool bResult = true;
1492 if(!IsIndividualGreeting(sal_False))
1493 return true;
1495 Reference< XResultSet> xResultSet = GetResultSet();
1496 uno::Reference< XColumnsSupplier > xColsSupp( xResultSet, UNO_QUERY );
1497 if(!xColsSupp.is())
1498 return false;
1499 const ResStringArray& rHeaders = GetDefaultAddressHeaders();
1500 uno::Reference<container::XNameAccess> xCols = xColsSupp->getColumns();
1502 Sequence< ::rtl::OUString> aAssignment =
1503 GetColumnAssignment( GetCurrentDBData() );
1504 const ::rtl::OUString* pAssignment = aAssignment.getConstArray();
1506 const Sequence< ::rtl::OUString> rFemaleEntries = GetGreetings(SwMailMergeConfigItem::FEMALE);
1507 sal_Int32 nCurrentFemale = GetCurrentGreeting(SwMailMergeConfigItem::FEMALE);
1508 const Sequence< ::rtl::OUString> rMaleEntries = GetGreetings(SwMailMergeConfigItem::MALE);
1509 sal_Int32 nCurrentMale = GetCurrentGreeting(SwMailMergeConfigItem::MALE);
1510 ::rtl::OUString sMale, sFemale;
1511 if(rFemaleEntries.getLength() > nCurrentFemale)
1512 sFemale = rFemaleEntries[nCurrentFemale];
1513 if(rMaleEntries.getLength() > nCurrentMale)
1514 sMale = rMaleEntries[nCurrentMale];
1516 ::rtl::OUString sAddress( sFemale );
1517 sAddress += sMale;
1518 SwAddressIterator aIter(sAddress);
1519 while(aIter.HasMore())
1521 SwMergeAddressItem aItem = aIter.Next();
1522 if(aItem.bIsColumn)
1524 String sConvertedColumn = aItem.sText;
1525 for(USHORT nColumn = 0;
1526 nColumn < rHeaders.Count() && nColumn < aAssignment.getLength();
1527 ++nColumn)
1529 if(rHeaders.GetString(nColumn) == aItem.sText &&
1530 pAssignment[nColumn].getLength())
1532 sConvertedColumn = pAssignment[nColumn];
1533 break;
1536 //find out if the column exists in the data base
1537 if(!xCols->hasByName(sConvertedColumn))
1539 bResult = false;
1540 break;
1544 return bResult;
1546 /*-- 05.05.2004 16:10:07---------------------------------------------------
1548 -----------------------------------------------------------------------*/
1549 ::rtl::OUString SwMailMergeConfigItem::GetMailDisplayName() const
1551 return m_pImpl->sMailDisplayName;
1553 /*-- 05.05.2004 16:10:08---------------------------------------------------
1555 -----------------------------------------------------------------------*/
1556 void SwMailMergeConfigItem::SetMailDisplayName(const ::rtl::OUString& rName)
1558 if(m_pImpl->sMailDisplayName != rName)
1560 m_pImpl->sMailDisplayName = rName;
1561 m_pImpl->SetModified();
1564 /*-- 05.05.2004 16:10:09---------------------------------------------------
1566 -----------------------------------------------------------------------*/
1567 ::rtl::OUString SwMailMergeConfigItem::GetMailAddress() const
1569 return m_pImpl->sMailAddress;
1571 /*-- 05.05.2004 16:10:09---------------------------------------------------
1573 -----------------------------------------------------------------------*/
1574 void SwMailMergeConfigItem::SetMailAddress(const ::rtl::OUString& rAddress)
1576 if(m_pImpl->sMailAddress != rAddress )
1578 m_pImpl->sMailAddress = rAddress;
1579 m_pImpl->SetModified();
1583 /*-- 07.05.2004 12:40:59---------------------------------------------------
1585 -----------------------------------------------------------------------*/
1586 sal_Bool SwMailMergeConfigItem::IsMailReplyTo() const
1588 return m_pImpl->bIsMailReplyTo;
1590 /*-- 07.05.2004 12:40:59---------------------------------------------------
1592 -----------------------------------------------------------------------*/
1593 void SwMailMergeConfigItem::SetMailReplyTo(sal_Bool bSet)
1595 if(m_pImpl->bIsMailReplyTo != bSet)
1597 m_pImpl->bIsMailReplyTo = bSet;
1598 m_pImpl->SetModified();
1601 /*-- 05.05.2004 16:10:09---------------------------------------------------
1603 -----------------------------------------------------------------------*/
1604 ::rtl::OUString SwMailMergeConfigItem::GetMailReplyTo() const
1606 return m_pImpl->sMailReplyTo;
1608 /*-- 05.05.2004 16:10:09---------------------------------------------------
1610 -----------------------------------------------------------------------*/
1611 void SwMailMergeConfigItem::SetMailReplyTo(const ::rtl::OUString& rReplyTo)
1613 if(m_pImpl->sMailReplyTo != rReplyTo)
1615 m_pImpl->sMailReplyTo = rReplyTo;
1616 m_pImpl->SetModified();
1619 /*-- 05.05.2004 16:10:09---------------------------------------------------
1621 -----------------------------------------------------------------------*/
1622 ::rtl::OUString SwMailMergeConfigItem::GetMailServer() const
1624 return m_pImpl->sMailServer;
1626 /*-- 05.05.2004 16:10:10---------------------------------------------------
1628 -----------------------------------------------------------------------*/
1629 void SwMailMergeConfigItem::SetMailServer(const ::rtl::OUString& rAddress)
1631 if(m_pImpl->sMailServer != rAddress)
1633 m_pImpl->sMailServer = rAddress;
1634 m_pImpl->SetModified();
1637 /*-- 05.05.2004 16:10:10---------------------------------------------------
1639 -----------------------------------------------------------------------*/
1640 sal_Int16 SwMailMergeConfigItem::GetMailPort() const
1642 return m_pImpl->bIsDefaultPort ?
1643 (m_pImpl->bIsSecureConnection ? SECURE_PORT : DEFAULT_PORT) :
1644 m_pImpl->nMailPort;
1646 /*-- 05.05.2004 16:10:10---------------------------------------------------
1648 -----------------------------------------------------------------------*/
1649 void SwMailMergeConfigItem::SetMailPort(sal_Int16 nSet)
1651 if(m_pImpl->nMailPort != nSet || m_pImpl->bIsDefaultPort)
1653 m_pImpl->nMailPort = nSet;
1654 m_pImpl->bIsDefaultPort = sal_False;
1655 m_pImpl->SetModified();
1658 /*-- 05.05.2004 16:10:11---------------------------------------------------
1660 -----------------------------------------------------------------------*/
1661 sal_Bool SwMailMergeConfigItem::IsSecureConnection() const
1663 return m_pImpl->bIsSecureConnection;
1665 /*-- 05.05.2004 16:10:12---------------------------------------------------
1667 -----------------------------------------------------------------------*/
1668 void SwMailMergeConfigItem::SetSecureConnection(sal_Bool bSet)
1670 if(m_pImpl->bIsSecureConnection != bSet)
1672 m_pImpl->bIsSecureConnection = bSet;
1673 m_pImpl->SetModified();
1676 /*-- 05.05.2004 16:10:12---------------------------------------------------
1678 -----------------------------------------------------------------------*/
1679 sal_Bool SwMailMergeConfigItem::IsAuthentication() const
1681 return m_pImpl->bIsAuthentication;
1683 /*-- 05.05.2004 16:10:13---------------------------------------------------
1685 -----------------------------------------------------------------------*/
1686 void SwMailMergeConfigItem::SetAuthentication(sal_Bool bSet)
1688 if(m_pImpl->bIsAuthentication != bSet)
1690 m_pImpl->bIsAuthentication = bSet;
1691 m_pImpl->SetModified();
1694 /*-- 05.05.2004 16:10:13---------------------------------------------------
1696 -----------------------------------------------------------------------*/
1697 ::rtl::OUString SwMailMergeConfigItem::GetMailUserName() const
1699 return m_pImpl->sMailUserName;
1701 /*-- 05.05.2004 16:10:13---------------------------------------------------
1703 -----------------------------------------------------------------------*/
1704 void SwMailMergeConfigItem::SetMailUserName(const ::rtl::OUString& rName)
1706 if(m_pImpl->sMailUserName != rName)
1708 m_pImpl->sMailUserName = rName;
1709 m_pImpl->SetModified();
1712 /*-- 05.05.2004 16:10:14---------------------------------------------------
1714 -----------------------------------------------------------------------*/
1715 ::rtl::OUString SwMailMergeConfigItem::GetMailPassword() const
1717 return m_pImpl->sMailPassword;
1719 /*-- 05.05.2004 16:10:14---------------------------------------------------
1721 -----------------------------------------------------------------------*/
1722 void SwMailMergeConfigItem::SetMailPassword(const ::rtl::OUString& rPassword)
1724 if(m_pImpl->sMailPassword != rPassword)
1726 m_pImpl->sMailPassword = rPassword;
1727 m_pImpl->SetModified();
1730 /*-- 19.08.2004 14:44:57---------------------------------------------------
1732 -----------------------------------------------------------------------*/
1733 sal_Bool SwMailMergeConfigItem::IsSMTPAfterPOP() const
1735 return m_pImpl->bIsSMPTAfterPOP;
1737 /*-- 19.08.2004 14:44:57---------------------------------------------------
1739 -----------------------------------------------------------------------*/
1740 void SwMailMergeConfigItem::SetSMTPAfterPOP(sal_Bool bSet)
1742 if( m_pImpl->bIsSMPTAfterPOP != bSet)
1744 m_pImpl->bIsSMPTAfterPOP = bSet;
1745 m_pImpl->SetModified();
1748 /*-- 19.08.2004 14:44:57---------------------------------------------------
1750 -----------------------------------------------------------------------*/
1751 ::rtl::OUString SwMailMergeConfigItem::GetInServerName() const
1753 return m_pImpl->sInServerName;
1755 /*-- 19.08.2004 14:44:57---------------------------------------------------
1757 -----------------------------------------------------------------------*/
1758 void SwMailMergeConfigItem::SetInServerName(const ::rtl::OUString& rServer)
1760 if(m_pImpl->sInServerName != rServer)
1762 m_pImpl->sInServerName = rServer;
1763 m_pImpl->SetModified();
1766 /*-- 19.08.2004 14:44:58---------------------------------------------------
1768 -----------------------------------------------------------------------*/
1769 sal_Int16 SwMailMergeConfigItem::GetInServerPort() const
1771 return m_pImpl->nInServerPort;
1773 /*-- 19.08.2004 14:44:58---------------------------------------------------
1775 -----------------------------------------------------------------------*/
1776 void SwMailMergeConfigItem::SetInServerPort(sal_Int16 nSet)
1778 if( m_pImpl->nInServerPort != nSet)
1780 m_pImpl->nInServerPort = nSet;
1781 m_pImpl->SetModified();
1784 /*-- 20.08.2004 08:52:48---------------------------------------------------
1786 -----------------------------------------------------------------------*/
1787 sal_Bool SwMailMergeConfigItem::IsInServerPOP() const
1789 return m_pImpl->bInServerPOP;
1791 /*-- 20.08.2004 08:52:49---------------------------------------------------
1793 -----------------------------------------------------------------------*/
1794 void SwMailMergeConfigItem::SetInServerPOP(sal_Bool bSet)
1796 if( m_pImpl->bInServerPOP != bSet)
1798 m_pImpl->bInServerPOP = bSet;
1799 m_pImpl->SetModified();
1802 /*-- 19.08.2004 14:44:58---------------------------------------------------
1804 -----------------------------------------------------------------------*/
1805 ::rtl::OUString SwMailMergeConfigItem::GetInServerUserName() const
1807 return m_pImpl->sInServerUserName;
1809 /*-- 19.08.2004 14:44:58---------------------------------------------------
1811 -----------------------------------------------------------------------*/
1812 void SwMailMergeConfigItem::SetInServerUserName(const ::rtl::OUString& rName)
1814 if( m_pImpl->sInServerUserName != rName)
1816 m_pImpl->sInServerUserName = rName;
1817 m_pImpl->SetModified();
1820 /*-- 19.08.2004 14:44:59---------------------------------------------------
1822 -----------------------------------------------------------------------*/
1823 ::rtl::OUString SwMailMergeConfigItem::GetInServerPassword() const
1825 return m_pImpl->sInServerPassword;
1827 /*-- 19.08.2004 14:45:00---------------------------------------------------
1829 -----------------------------------------------------------------------*/
1830 void SwMailMergeConfigItem::SetInServerPassword(const ::rtl::OUString& rPassword)
1832 if(m_pImpl->sInServerPassword != rPassword)
1834 m_pImpl->sInServerPassword = rPassword;
1835 m_pImpl->SetModified();
1839 /*-- 02.09.2004 14:43:27---------------------------------------------------
1841 -----------------------------------------------------------------------*/
1842 void SwMailMergeConfigItem::DocumentReloaded()
1844 m_bMergeDone = false;
1845 m_bGreetingInserted = false;
1846 m_bAddressInserted = false;
1847 m_rAddressBlockFrame = ::rtl::OUString();
1849 /*-- 16.06.2004 12:24:18---------------------------------------------------
1851 -----------------------------------------------------------------------*/
1852 bool SwMailMergeConfigItem::IsMailAvailable() const
1854 return m_pImpl->bIsEMailSupported;
1856 /*-- 21.05.2004 12:20:05---------------------------------------------------
1858 -----------------------------------------------------------------------*/
1859 void SwMailMergeConfigItem::AddMergedDocument(SwDocMergeInfo& rInfo)
1861 m_pImpl->aMergeInfos.push_back(rInfo);
1863 /*-- 21.05.2004 12:20:05---------------------------------------------------
1865 -----------------------------------------------------------------------*/
1866 SwDocMergeInfo& SwMailMergeConfigItem::GetDocumentMergeInfo(sal_uInt32 nDocument)
1868 DBG_ASSERT(m_pImpl->aMergeInfos.size() > nDocument,"invalid document index");
1869 return m_pImpl->aMergeInfos[nDocument];
1871 /*-- 14.06.2004 11:46:26---------------------------------------------------
1873 -----------------------------------------------------------------------*/
1874 sal_uInt32 SwMailMergeConfigItem::GetMergedDocumentCount() const
1876 return m_pImpl->aMergeInfos.size();
1878 /*-- 11.06.2004 10:38:39---------------------------------------------------
1880 -----------------------------------------------------------------------*/
1881 SwView* lcl_ExistsView(SwView* pView)
1883 const TypeId aType(TYPE(SwView));
1884 SfxViewShell* pViewShell = SfxViewShell::GetFirst( &aType, FALSE );
1885 while(pViewShell)
1887 if(pViewShell == pView)
1888 return pView;
1890 pViewShell = SfxViewShell::GetNext( *pViewShell, &aType, FALSE );
1892 return 0;
1894 /*-- 16.06.2004 15:02:35---------------------------------------------------
1896 -----------------------------------------------------------------------*/
1897 SwView* SwMailMergeConfigItem::GetTargetView()
1899 //make sure that the pointer is really valid - the document may have been closed manually
1900 if(m_pTargetView)
1902 m_pTargetView = lcl_ExistsView(m_pTargetView);
1904 return m_pTargetView;
1906 /*-- 02.09.2004 17:04:11---------------------------------------------------
1908 -----------------------------------------------------------------------*/
1909 void SwMailMergeConfigItem::SetTargetView(SwView* pView)
1911 m_pTargetView = pView;
1912 //reset the document merge counter
1913 if(!m_pTargetView)
1915 m_pImpl->aMergeInfos.clear();
1918 /*-- 16.06.2004 15:02:35---------------------------------------------------
1920 -----------------------------------------------------------------------*/
1921 SwView* SwMailMergeConfigItem::GetSourceView()
1923 m_pSourceView = lcl_ExistsView(m_pSourceView);
1924 return m_pSourceView;
1927 /*-- 04.11.2004 19:53 ---------------------------------------------------
1928 -----------------------------------------------------------------------*/
1929 void SwMailMergeConfigItem::SetSourceView(SwView* pView)
1931 m_pSourceView = pView;
1933 if(pView)
1935 SvStringsDtor aDBNameList(5, 1);
1936 SvStringsDtor aAllDBNames(5, 5);
1937 pView->GetWrtShell().GetAllUsedDB( aDBNameList, &aAllDBNames );
1938 if(aDBNameList.Count())
1940 // if fields are available there is usually no need of an addressblock and greeting
1941 if(!m_pImpl->bUserSettingWereOverwritten)
1943 if( m_pImpl->bIsAddressBlock == sal_True
1944 || m_pImpl->bIsGreetingLineInMail == sal_True
1945 || m_pImpl->bIsGreetingLine == sal_True )
1947 //store user settings
1948 m_pImpl->bUserSettingWereOverwritten = sal_True;
1949 m_pImpl->bIsAddressBlock_LastUserSetting = m_pImpl->bIsAddressBlock;
1950 m_pImpl->bIsGreetingLineInMail_LastUserSetting = m_pImpl->bIsGreetingLineInMail;
1951 m_pImpl->bIsGreetingLine_LastUserSetting = m_pImpl->bIsGreetingLine;
1953 //set all to false
1954 m_pImpl->bIsAddressBlock = sal_False;
1955 m_pImpl->bIsGreetingLineInMail = sal_False;
1956 m_pImpl->bIsGreetingLine = sal_False;
1958 m_pImpl->SetModified();
1962 else if( m_pImpl->bUserSettingWereOverwritten )
1964 //restore last user settings:
1965 m_pImpl->bIsAddressBlock = m_pImpl->bIsAddressBlock_LastUserSetting;
1966 m_pImpl->bIsGreetingLineInMail = m_pImpl->bIsGreetingLineInMail_LastUserSetting;
1967 m_pImpl->bIsGreetingLine = m_pImpl->bIsGreetingLine_LastUserSetting;
1969 m_pImpl->bUserSettingWereOverwritten = sal_False;
1974 /*-- 13.03.2006 12:15:06---------------------------------------------------
1976 -----------------------------------------------------------------------*/
1977 void SwMailMergeConfigItem::SetCurrentAddressBlockIndex( sal_Int32 nSet )
1979 m_pImpl->SetCurrentAddressBlockIndex( nSet );
1981 /*-- 13.03.2006 12:15:07---------------------------------------------------
1983 -----------------------------------------------------------------------*/
1984 sal_Int32 SwMailMergeConfigItem::GetCurrentAddressBlockIndex() const
1986 return m_pImpl->GetCurrentAddressBlockIndex();