LCOV - code coverage report
Current view: top level - sw/source/core/uibase/dbui - mmconfigitem.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 844 0.0 %
Date: 2014-04-14 Functions: 0 112 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10