LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/dbui - mmgreetingspage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 340 0.0 %
Date: 2013-07-09 Functions: 0 33 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 <mmgreetingspage.hxx>
      21             : #include <mailmergewizard.hxx>
      22             : #include <mmconfigitem.hxx>
      23             : #include <mmaddressblockpage.hxx>
      24             : #include <swtypes.hxx>
      25             : #include <vcl/msgbox.hxx>
      26             : #include <mmgreetingspage.hrc>
      27             : #include <dbui.hrc>
      28             : #include <com/sun/star/sdb/XColumn.hpp>
      29             : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      30             : #include <com/sun/star/container/XNameAccess.hpp>
      31             : #include <helpid.h>
      32             : 
      33             : using namespace svt;
      34             : using namespace ::com::sun::star;
      35             : using namespace ::com::sun::star::uno;
      36             : 
      37           0 : static void lcl_FillGreetingsBox(ListBox& rBox,
      38             :                         SwMailMergeConfigItem& rConfig,
      39             :                         SwMailMergeConfigItem::Gender eType)
      40             : {
      41           0 :     const Sequence< OUString> rEntries = rConfig.GetGreetings(eType);
      42           0 :     for(sal_Int32 nEntry = 0; nEntry < rEntries.getLength(); ++nEntry)
      43           0 :         rBox.InsertEntry(rEntries[nEntry]);
      44           0 :     rBox.SelectEntryPos((sal_uInt16)rConfig.GetCurrentGreeting(eType));
      45           0 : }
      46             : 
      47           0 : static void lcl_FillGreetingsBox(ComboBox& rBox,
      48             :                         SwMailMergeConfigItem& rConfig,
      49             :                         SwMailMergeConfigItem::Gender eType)
      50             : {
      51           0 :     const Sequence< OUString> rEntries = rConfig.GetGreetings(eType);
      52           0 :     for(sal_Int32 nEntry = 0; nEntry < rEntries.getLength(); ++nEntry)
      53           0 :         rBox.InsertEntry(rEntries[nEntry]);
      54           0 :     rBox.SelectEntryPos((sal_uInt16)rConfig.GetCurrentGreeting(eType));
      55           0 : }
      56             : 
      57           0 : static void lcl_StoreGreetingsBox(ListBox& rBox,
      58             :                         SwMailMergeConfigItem& rConfig,
      59             :                         SwMailMergeConfigItem::Gender eType)
      60             : {
      61           0 :     Sequence< OUString> aEntries(rBox.GetEntryCount());
      62           0 :     OUString* pEntries = aEntries.getArray();
      63           0 :     for(sal_uInt16 nEntry = 0; nEntry < rBox.GetEntryCount(); ++nEntry)
      64           0 :         pEntries[nEntry] = rBox.GetEntry(nEntry);
      65           0 :     rConfig.SetGreetings(eType, aEntries);
      66           0 :     rConfig.SetCurrentGreeting(eType, rBox.GetSelectEntryPos());
      67           0 : }
      68             : 
      69           0 : static void lcl_StoreGreetingsBox(ComboBox& rBox,
      70             :                         SwMailMergeConfigItem& rConfig,
      71             :                         SwMailMergeConfigItem::Gender eType)
      72             : {
      73           0 :     Sequence< OUString> aEntries(rBox.GetEntryCount());
      74           0 :     OUString* pEntries = aEntries.getArray();
      75           0 :     for(sal_uInt16 nEntry = 0; nEntry < rBox.GetEntryCount(); ++nEntry)
      76           0 :         pEntries[nEntry] = rBox.GetEntry(nEntry);
      77           0 :     rConfig.SetGreetings(eType, aEntries);
      78           0 :     rConfig.SetCurrentGreeting(eType, rBox.GetSelectEntryPos());
      79           0 : }
      80             : 
      81           0 : IMPL_LINK_NOARG(SwGreetingsHandler, IndividualHdl_Impl)
      82             : {
      83           0 :     sal_Bool bIndividual = m_pPersonalizedCB->IsEnabled() && m_pPersonalizedCB->IsChecked();
      84           0 :     m_pFemaleFT->Enable(bIndividual);
      85           0 :     m_pFemaleLB->Enable(bIndividual);
      86           0 :     m_pFemalePB->Enable(bIndividual);
      87           0 :     m_pMaleFT->Enable(bIndividual);
      88           0 :     m_pMaleLB->Enable(bIndividual);
      89           0 :     m_pMalePB->Enable(bIndividual);
      90           0 :     m_pFemaleFI->Enable(bIndividual);
      91           0 :     m_pFemaleColumnFT->Enable(bIndividual);
      92           0 :     m_pFemaleColumnLB->Enable(bIndividual);
      93           0 :     m_pFemaleFieldFT->Enable(bIndividual);
      94           0 :     m_pFemaleFieldCB->Enable(bIndividual);
      95             : 
      96           0 :     if( m_bIsTabPage )
      97             :     {
      98           0 :         m_pWizard->GetConfigItem().SetIndividualGreeting(bIndividual, sal_False);
      99           0 :         m_pWizard->UpdateRoadmap();
     100           0 :         m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
     101             :     }
     102           0 :     UpdatePreview();
     103           0 :     return 0;
     104             : }
     105             : 
     106           0 : IMPL_LINK(SwGreetingsHandler, GreetingHdl_Impl, PushButton*, pButton)
     107             : {
     108             :     SwCustomizeAddressBlockDialog* pDlg =
     109           0 :             new SwCustomizeAddressBlockDialog(pButton, m_pWizard->GetConfigItem(),
     110           0 :                         pButton == m_pMalePB ?
     111             :                         SwCustomizeAddressBlockDialog::GREETING_MALE :
     112           0 :                         SwCustomizeAddressBlockDialog::GREETING_FEMALE );
     113           0 :     if(RET_OK == pDlg->Execute())
     114             :     {
     115           0 :         ListBox* pToInsert = pButton == m_pMalePB ? m_pMaleLB : m_pFemaleLB;
     116           0 :         pToInsert->SelectEntryPos(pToInsert->InsertEntry(pDlg->GetAddress()));
     117           0 :         if(m_bIsTabPage)
     118             :         {
     119           0 :             m_pWizard->UpdateRoadmap();
     120           0 :             m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
     121             :         }
     122           0 :         UpdatePreview();
     123             :     }
     124           0 :     delete pDlg;
     125           0 :     return 0;
     126             : }
     127             : 
     128           0 : void    SwGreetingsHandler::UpdatePreview()
     129             : {
     130             :     //the base class does nothing
     131           0 : }
     132             : 
     133           0 : IMPL_LINK(SwMailMergeGreetingsPage, AssignHdl_Impl, PushButton*, pButton)
     134             : {
     135           0 :     String sPreview = m_aFemaleLB.GetSelectEntry();
     136           0 :     sPreview += '\n';
     137           0 :     sPreview += m_aMaleLB.GetSelectEntry();
     138             :     SwAssignFieldsDialog* pDlg =
     139           0 :             new SwAssignFieldsDialog(pButton, m_pWizard->GetConfigItem(), sPreview, false);
     140           0 :     if(RET_OK == pDlg->Execute())
     141             :     {
     142           0 :         UpdatePreview();
     143           0 :         m_pWizard->UpdateRoadmap();
     144           0 :         m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
     145             :     }
     146           0 :     delete pDlg;
     147           0 :     return 0;
     148             : }
     149             : 
     150           0 : IMPL_LINK_NOARG(SwMailMergeGreetingsPage, GreetingSelectHdl_Impl)
     151             : {
     152           0 :     UpdatePreview();
     153           0 :     return 0;
     154             : }
     155             : 
     156           0 : void SwMailMergeGreetingsPage::UpdatePreview()
     157             : {
     158             :     //find out which type of greeting should be selected:
     159           0 :     bool bFemale = false;
     160           0 :     bool bNoValue = !m_pFemaleColumnLB->IsEnabled();
     161           0 :     if( !bNoValue )
     162             :     {
     163           0 :         OUString sFemaleValue = m_aFemaleFieldCB.GetText();
     164           0 :         OUString sFemaleColumn = m_aFemaleColumnLB.GetSelectEntry();
     165           0 :         Reference< sdbcx::XColumnsSupplier > xColsSupp( m_pWizard->GetConfigItem().GetResultSet(), UNO_QUERY);
     166           0 :         Reference < container::XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0;
     167           0 :         if(!sFemaleValue.isEmpty() && !sFemaleColumn.isEmpty() &&
     168           0 :                 xColAccess.is() &&
     169           0 :                 xColAccess->hasByName(sFemaleColumn))
     170             :         {
     171             :             //get the content and exchange it in the address string
     172           0 :             Any aCol = xColAccess->getByName(sFemaleColumn);
     173           0 :             Reference< sdb::XColumn > xColumn;
     174           0 :             aCol >>= xColumn;
     175           0 :             if(xColumn.is())
     176             :             {
     177             :                 try
     178             :                 {
     179           0 :                     OUString sFemaleColumnValue = xColumn->getString();
     180           0 :                     bFemale = sFemaleColumnValue == sFemaleValue;
     181             :                     //bNoValue = !sFemaleColumnValue.getLength();
     182           0 :                     if( !bNoValue )
     183             :                     {
     184             :                         //no last name value marks the greeting also als neutral
     185           0 :                         SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     186           0 :                         OUString sLastNameColumn = rConfig.GetAssignedColumn(MM_PART_LASTNAME);
     187           0 :                         if ( xColAccess->hasByName(sLastNameColumn) )
     188             :                         {
     189           0 :                             aCol = xColAccess->getByName(sLastNameColumn);
     190           0 :                             aCol >>= xColumn;
     191           0 :                             OUString sLastNameColumnValue = xColumn->getString();
     192           0 :                             bNoValue = sLastNameColumnValue.isEmpty();
     193           0 :                         }
     194           0 :                     }
     195             :                 }
     196           0 :                 catch (const sdbc::SQLException&)
     197             :                 {
     198             :                     OSL_FAIL("SQLException caught");
     199             :                 }
     200           0 :             }
     201           0 :         }
     202             :     }
     203             : 
     204             :     String sPreview = bFemale ? OUString(m_aFemaleLB.GetSelectEntry()) :
     205           0 :         bNoValue ? m_aNeutralCB.GetText() : OUString(m_aMaleLB.GetSelectEntry());
     206             : 
     207           0 :     sPreview = SwAddressPreview::FillData(sPreview, m_pWizard->GetConfigItem());
     208           0 :     m_aPreviewWIN.SetAddress(sPreview);
     209           0 : }
     210             : 
     211           0 : void    SwGreetingsHandler::Contains(sal_Bool bContainsGreeting)
     212             : {
     213           0 :     m_pPersonalizedCB->Enable(bContainsGreeting);
     214           0 :     sal_Bool bEnablePersonal = bContainsGreeting && m_pPersonalizedCB->IsChecked();
     215           0 :     m_pFemaleFT->Enable(bEnablePersonal);
     216           0 :     m_pFemaleLB->Enable(bEnablePersonal);
     217           0 :     m_pFemalePB->Enable(bEnablePersonal);
     218           0 :     m_pMaleFT->Enable(bEnablePersonal);
     219           0 :     m_pMaleLB->Enable(bEnablePersonal);
     220           0 :     m_pMalePB->Enable(bEnablePersonal);
     221           0 :     m_pFemaleFI->Enable(bEnablePersonal);
     222           0 :     m_pFemaleColumnFT->Enable(bEnablePersonal);
     223           0 :     m_pFemaleColumnLB->Enable(bEnablePersonal);
     224           0 :     m_pFemaleFieldFT->Enable(bEnablePersonal);
     225           0 :     m_pFemaleFieldCB->Enable(bEnablePersonal);
     226             : 
     227           0 :     m_pNeutralFT->Enable(bContainsGreeting);
     228           0 :     m_pNeutralCB->Enable(bContainsGreeting);
     229           0 : }
     230             : 
     231           0 : SwMailMergeGreetingsPage::SwMailMergeGreetingsPage( SwMailMergeWizard* _pParent) :
     232             :     svt::OWizardPage(_pParent, SW_RES(DLG_MM_GREETINGS_PAGE)),
     233             : #ifdef _MSC_VER
     234             : #pragma warning (disable : 4355)
     235             : #endif
     236             :     m_aHeaderFI(this, SW_RES(          FI_HEADER     ) ),
     237             :     m_aGreetingLineCB(this, SW_RES(    CB_GREETINGLINE ) ),
     238             :     m_aPersonalizedCB(this, SW_RES(      CB_PERSONALIZED ) ),
     239             :     m_aFemaleFT(this, SW_RES(            FT_FEMALE   ) ),
     240             :     m_aFemaleLB(this, SW_RES(            LB_FEMALE   ) ),
     241             :     m_aFemalePB(this, SW_RES(            PB_FEMALE   ) ),
     242             :     m_aMaleFT(this, SW_RES(              FT_MALE     ) ),
     243             :     m_aMaleLB(this, SW_RES(              LB_MALE     ) ),
     244             :     m_aMalePB(this, SW_RES(              PB_MALE     ) ),
     245             :     m_aFemaleFI(this, SW_RES(            FI_FEMALE      ) ),
     246             :     m_aFemaleColumnFT(this, SW_RES(      FT_FEMALECOLUMN ) ),
     247             :     m_aFemaleColumnLB(this, SW_RES(      LB_FEMALECOLUMN ) ),
     248             :     m_aFemaleFieldFT(this, SW_RES(       FT_FEMALEFIELD  ) ),
     249             :     m_aFemaleFieldCB(this, SW_RES(       CB_FEMALEFIELD  ) ),
     250             :     m_aNeutralFT(this, SW_RES(           FT_NEUTRAL      ) ),
     251             :     m_aNeutralCB(this, SW_RES(         CB_NEUTRAL      ) ),
     252             :     m_aPreviewFI(       this, SW_RES( FI_PREVIEW     ) ),
     253             :     m_aPreviewWIN(      this, SW_RES( WIN_PREVIEW    ) ),
     254             :     m_aAssignPB(        this, SW_RES( PB_ASSIGN      ) ),
     255             :     m_aDocumentIndexFI( this, SW_RES( FI_DOCINDEX    ) ),
     256             :     m_aPrevSetIB(       this, SW_RES( IB_PREVSET     ) ),
     257             :     m_aNextSetIB(       this, SW_RES( IB_NEXTSET     ) ),
     258           0 :     m_sDocument(        SW_RES(       STR_DOCUMENT  ) )
     259             : #ifdef _MSC_VER
     260             : #pragma warning (default : 4355)
     261             : #endif
     262             : {
     263           0 :     m_pWizard = _pParent;
     264           0 :     m_pGreetingLineCB = &m_aGreetingLineCB;
     265           0 :     m_pPersonalizedCB = &m_aPersonalizedCB;
     266           0 :     m_pFemaleFT = &      m_aFemaleFT;
     267           0 :     m_pFemaleLB = &      m_aFemaleLB;
     268           0 :     m_pFemalePB = &      m_aFemalePB;
     269           0 :     m_pMaleFT = &        m_aMaleFT;
     270           0 :     m_pMaleLB = &        m_aMaleLB;
     271           0 :     m_pMalePB = &        m_aMalePB;
     272           0 :     m_pFemaleFI = &      m_aFemaleFI;
     273           0 :     m_pFemaleColumnFT = &m_aFemaleColumnFT;
     274           0 :     m_pFemaleColumnLB = &m_aFemaleColumnLB;
     275           0 :     m_pFemaleFieldFT = & m_aFemaleFieldFT;
     276           0 :     m_pFemaleFieldCB = & m_aFemaleFieldCB;
     277           0 :     m_pNeutralFT = &     m_aNeutralFT;
     278           0 :     m_pNeutralCB    = &m_aNeutralCB;
     279           0 :     m_bIsTabPage = true;
     280             : 
     281           0 :     m_pPersonalizedCB->SetHelpId(   HID_MM_GREETINGS_CB_PERSONALIZED);
     282           0 :     m_pFemaleLB->SetHelpId(         HID_MM_GREETINGS_LB_FEMALE      );
     283           0 :     m_pFemalePB->SetHelpId(         HID_MM_GREETINGS_PB_FEMALE      );
     284           0 :     m_pMaleLB->SetHelpId(           HID_MM_GREETINGS_LB_MALE        );
     285           0 :     m_pMalePB->SetHelpId(           HID_MM_GREETINGS_PB_MALE        );
     286           0 :     m_pFemaleColumnLB->SetHelpId(   HID_MM_GREETINGS_LB_FEMALECOLUMN);
     287           0 :     m_pFemaleFieldCB->SetHelpId(    HID_MM_GREETINGS_CB_FEMALEFIELD );
     288           0 :     m_pNeutralCB->SetHelpId(        HID_MM_GREETINGS_CB_NEUTRAL     );
     289             : 
     290           0 :     FreeResource();
     291           0 :     m_aGreetingLineCB.SetClickHdl(LINK(this, SwMailMergeGreetingsPage, ContainsHdl_Impl));
     292           0 :     Link aIndividualLink = LINK(this, SwGreetingsHandler, IndividualHdl_Impl);
     293           0 :     m_aPersonalizedCB.SetClickHdl(aIndividualLink);
     294           0 :     Link aGreetingLink = LINK(this, SwGreetingsHandler, GreetingHdl_Impl);
     295           0 :     m_aFemalePB.SetClickHdl(aGreetingLink);
     296           0 :     m_aMalePB.SetClickHdl(aGreetingLink);
     297           0 :     m_aAssignPB.SetClickHdl(LINK(this, SwMailMergeGreetingsPage, AssignHdl_Impl));
     298           0 :     Link aLBoxLink = LINK(this, SwMailMergeGreetingsPage, GreetingSelectHdl_Impl);
     299           0 :     m_aFemaleLB.SetSelectHdl(aLBoxLink);
     300           0 :     m_aMaleLB.SetSelectHdl(aLBoxLink);
     301           0 :     m_aFemaleColumnLB.SetSelectHdl(aLBoxLink);
     302           0 :     m_aFemaleFieldCB.SetSelectHdl(aLBoxLink);
     303           0 :     m_aFemaleFieldCB.SetModifyHdl(aLBoxLink);
     304           0 :     m_aNeutralCB.SetSelectHdl(aLBoxLink);
     305           0 :     m_aNeutralCB.SetModifyHdl(aLBoxLink);
     306             : 
     307           0 :     Link aDataLink = LINK(this, SwMailMergeGreetingsPage, InsertDataHdl_Impl);
     308           0 :     m_aPrevSetIB.SetClickHdl(aDataLink);
     309           0 :     m_aNextSetIB.SetClickHdl(aDataLink);
     310             : 
     311             : 
     312           0 :     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     313           0 :     m_aGreetingLineCB.Check(rConfig.IsGreetingLine(sal_False));
     314           0 :     m_aPersonalizedCB.Check(rConfig.IsIndividualGreeting(sal_False));
     315           0 :     ContainsHdl_Impl(&m_aGreetingLineCB);
     316           0 :     aIndividualLink.Call(0);
     317             : 
     318           0 :     lcl_FillGreetingsBox(m_aFemaleLB, rConfig, SwMailMergeConfigItem::FEMALE);
     319           0 :     lcl_FillGreetingsBox(m_aMaleLB, rConfig, SwMailMergeConfigItem::MALE);
     320           0 :     lcl_FillGreetingsBox(m_aNeutralCB, rConfig, SwMailMergeConfigItem::NEUTRAL);
     321             : 
     322           0 :     String sTemp(m_sDocument);
     323           0 :     sTemp.SearchAndReplaceAscii("%1", OUString::number(1));
     324           0 :     m_aDocumentIndexFI.SetText(sTemp);
     325           0 : }
     326             : 
     327           0 : SwMailMergeGreetingsPage::~SwMailMergeGreetingsPage()
     328             : {
     329           0 : }
     330             : 
     331           0 : void SwMailMergeGreetingsPage::ActivatePage()
     332             : {
     333           0 :     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     334             : 
     335             :     //try to find the gender setting
     336           0 :     m_aFemaleColumnLB.Clear();
     337           0 :     Reference< sdbcx::XColumnsSupplier > xColsSupp = rConfig.GetColumnsSupplier();
     338           0 :     if(xColsSupp.is())
     339             :     {
     340           0 :         Reference < container::XNameAccess> xColAccess = xColsSupp->getColumns();
     341           0 :         Sequence< OUString > aColumns = xColAccess->getElementNames();
     342           0 :         for(sal_Int32 nName = 0; nName < aColumns.getLength(); ++nName)
     343           0 :             m_aFemaleColumnLB.InsertEntry(aColumns[nName]);
     344             :     }
     345             : 
     346           0 :     OUString sGenderColumn = rConfig.GetAssignedColumn(MM_PART_GENDER);
     347           0 :     m_aFemaleColumnLB.SelectEntry(sGenderColumn);
     348           0 :     m_aFemaleColumnLB.SaveValue();
     349             : 
     350           0 :     m_aFemaleFieldCB.SetText(rConfig.GetFemaleGenderValue());
     351           0 :     m_aFemaleFieldCB.SaveValue();
     352             : 
     353           0 :     UpdatePreview();
     354           0 :     m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
     355           0 : }
     356             : 
     357           0 : sal_Bool    SwMailMergeGreetingsPage::commitPage( ::svt::WizardTypes::CommitPageReason )
     358             : {
     359           0 :     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     360             : 
     361           0 :     if(m_aFemaleColumnLB.GetSelectEntryPos() != m_aFemaleColumnLB.GetSavedValue())
     362             :     {
     363           0 :         const SwDBData& rDBData = rConfig.GetCurrentDBData();
     364           0 :         Sequence< OUString> aAssignment = rConfig.GetColumnAssignment( rDBData );
     365           0 :         if(aAssignment.getLength() <= MM_PART_GENDER)
     366           0 :             aAssignment.realloc(MM_PART_GENDER + 1);
     367           0 :         aAssignment[MM_PART_GENDER] = m_aFemaleColumnLB.GetSelectEntry();
     368           0 :         rConfig.SetColumnAssignment( rDBData, aAssignment );
     369             :     }
     370           0 :     if(m_aFemaleFieldCB.GetText() != m_aFemaleFieldCB.GetSavedValue())
     371           0 :         rConfig.SetFemaleGenderValue(m_aFemaleFieldCB.GetText());
     372             : 
     373           0 :     lcl_StoreGreetingsBox(m_aFemaleLB, rConfig, SwMailMergeConfigItem::FEMALE);
     374           0 :     lcl_StoreGreetingsBox(m_aMaleLB, rConfig, SwMailMergeConfigItem::MALE);
     375             : 
     376           0 :     sal_uInt16 nCurrentTextPos = m_aNeutralCB.GetEntryPos( m_aNeutralCB.GetText() );
     377           0 :     if(LISTBOX_ENTRY_NOTFOUND == nCurrentTextPos)
     378             :     {
     379           0 :         sal_uInt16 nCount = m_aNeutralCB.GetEntryCount();
     380           0 :         m_aNeutralCB.InsertEntry( m_aNeutralCB.GetText(), nCount );
     381           0 :         m_aNeutralCB.SelectEntryPos(nCount);
     382             :     }
     383           0 :     lcl_StoreGreetingsBox(m_aNeutralCB, rConfig, SwMailMergeConfigItem::NEUTRAL);
     384           0 :     rConfig.SetGreetingLine(m_aGreetingLineCB.IsChecked(), sal_False);
     385           0 :     rConfig.SetIndividualGreeting(m_aPersonalizedCB.IsChecked(), sal_False);
     386           0 :     return sal_True;
     387             : }
     388             : 
     389           0 : IMPL_LINK(SwMailMergeGreetingsPage, ContainsHdl_Impl, CheckBox*, pBox)
     390             : {
     391           0 :     sal_Bool bContainsGreeting = pBox->IsChecked();
     392           0 :     SwGreetingsHandler::Contains(bContainsGreeting);
     393           0 :     m_aPreviewFI. Enable(bContainsGreeting);
     394           0 :     m_aPreviewWIN.Enable(bContainsGreeting);
     395           0 :     m_aAssignPB.  Enable(bContainsGreeting);
     396           0 :     m_aDocumentIndexFI.  Enable(bContainsGreeting);
     397           0 :     m_aPrevSetIB.Enable(bContainsGreeting);
     398           0 :     m_aNextSetIB.Enable(bContainsGreeting);
     399           0 :     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     400           0 :     rConfig.SetGreetingLine(m_aGreetingLineCB.IsChecked(), sal_False);
     401           0 :     m_pWizard->UpdateRoadmap();
     402           0 :     return 0;
     403             : }
     404             : 
     405           0 : IMPL_LINK(SwMailMergeGreetingsPage, InsertDataHdl_Impl, ImageButton*, pButton)
     406             : {
     407             :     //if no pButton is given, the first set has to be pre-set
     408           0 :     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     409           0 :     if(!pButton)
     410             :     {
     411           0 :         rConfig.GetResultSet();
     412             :     }
     413             :     else
     414             :     {
     415           0 :         bool bNext = pButton == &m_aNextSetIB;
     416           0 :         sal_Int32 nPos = rConfig.GetResultSetPosition();
     417           0 :         rConfig.MoveResultSet( bNext ? ++nPos : --nPos);
     418             :     }
     419           0 :     sal_Int32 nPos = rConfig.GetResultSetPosition();
     420           0 :     sal_Bool bEnable = sal_True;
     421           0 :     if(nPos < 1)
     422             :     {
     423           0 :         bEnable = sal_False;
     424           0 :         nPos = 1;
     425             :     }
     426             :     else
     427           0 :         UpdatePreview();
     428           0 :     m_aPrevSetIB.Enable(bEnable);
     429           0 :     m_aNextSetIB.Enable(bEnable);
     430           0 :     m_aDocumentIndexFI.Enable(bEnable);
     431           0 :     String sTemp(m_sDocument);
     432           0 :     sTemp.SearchAndReplaceAscii("%1", OUString::number(nPos));
     433           0 :     m_aDocumentIndexFI.SetText(sTemp);
     434           0 :     return 0;
     435             : }
     436             : 
     437           0 : SwMailBodyDialog::SwMailBodyDialog(Window* pParent, SwMailMergeWizard* _pWizard) :
     438             :     SfxModalDialog(pParent, SW_RES(DLG_MM_MAILBODY)),
     439             : #ifdef _MSC_VER
     440             : #pragma warning (disable : 4355)
     441             : #endif
     442             :     m_aGreetingLineCB(this, SW_RES(    CB_GREETINGLINE ) ),
     443             :     m_aPersonalizedCB(this, SW_RES(      CB_PERSONALIZED ) ),
     444             :     m_aFemaleFT(this, SW_RES(            FT_FEMALE   ) ),
     445             :     m_aFemaleLB(this, SW_RES(            LB_FEMALE   ) ),
     446             :     m_aFemalePB(this, SW_RES(            PB_FEMALE   ) ),
     447             :     m_aMaleFT(this, SW_RES(              FT_MALE     ) ),
     448             :     m_aMaleLB(this, SW_RES(              LB_MALE     ) ),
     449             :     m_aMalePB(this, SW_RES(              PB_MALE     ) ),
     450             :     m_aFemaleFI(this, SW_RES(            FI_FEMALE      ) ),
     451             :     m_aFemaleColumnFT(this, SW_RES(      FT_FEMALECOLUMN ) ),
     452             :     m_aFemaleColumnLB(this, SW_RES(      LB_FEMALECOLUMN ) ),
     453             :     m_aFemaleFieldFT(this, SW_RES(       FT_FEMALEFIELD  ) ),
     454             :     m_aFemaleFieldCB(this, SW_RES(       CB_FEMALEFIELD  ) ),
     455             :     m_aNeutralFT(this, SW_RES(           FT_NEUTRAL      ) ),
     456             :     m_aNeutralCB(this, SW_RES(         CB_NEUTRAL      ) ),
     457             :     m_aBodyFT(   this, SW_RES(         FT_BODY         ) ),
     458             :     m_aBodyMLE(   this, SW_RES(        MLE_BODY        ) ),
     459             :     m_aSeparatorFL(   this, SW_RES(    FL_SEPARATOR    ) ),
     460             :     m_aOK(   this, SW_RES(             PB_OK           ) ),
     461             :     m_aCancel(   this, SW_RES(         PB_CANCEL       ) ),
     462           0 :     m_aHelp(   this, SW_RES(           PB_HELP         ) )
     463             : #ifdef _MSC_VER
     464             : #pragma warning (default : 4355)
     465             : #endif
     466             : {
     467           0 :     m_pWizard = _pWizard;
     468           0 :     m_pGreetingLineCB = &m_aGreetingLineCB;
     469           0 :     m_pPersonalizedCB = &m_aPersonalizedCB;
     470           0 :     m_pFemaleFT = &      m_aFemaleFT;
     471           0 :     m_pFemaleLB = &      m_aFemaleLB;
     472           0 :     m_pFemalePB = &      m_aFemalePB;
     473           0 :     m_pMaleFT = &        m_aMaleFT;
     474           0 :     m_pMaleLB = &        m_aMaleLB;
     475           0 :     m_pMalePB = &        m_aMalePB;
     476           0 :     m_pFemaleFI = &      m_aFemaleFI;
     477           0 :     m_pFemaleColumnFT = &m_aFemaleColumnFT;
     478           0 :     m_pFemaleColumnLB = &m_aFemaleColumnLB;
     479           0 :     m_pFemaleFieldFT = & m_aFemaleFieldFT;
     480           0 :     m_pFemaleFieldCB = & m_aFemaleFieldCB;
     481           0 :     m_pNeutralFT = &     m_aNeutralFT;
     482           0 :     m_pNeutralCB    = &m_aNeutralCB;
     483           0 :     m_bIsTabPage = false;
     484             : 
     485           0 :     m_pPersonalizedCB->SetHelpId(   HID_MM_BODY_CB_PERSONALIZED     );
     486           0 :     m_pFemaleLB->SetHelpId(         HID_MM_BODY_LB_FEMALE           );
     487           0 :     m_pFemalePB->SetHelpId(         HID_MM_BODY_PB_FEMALE           );
     488           0 :     m_pMaleLB->SetHelpId(           HID_MM_BODY_LB_MALE             );
     489           0 :     m_pMalePB->SetHelpId(           HID_MM_BODY_PB_MALE             );
     490           0 :     m_pFemaleColumnLB->SetHelpId(   HID_MM_BODY_LB_FEMALECOLUMN     );
     491           0 :     m_pFemaleFieldCB->SetHelpId(    HID_MM_BODY_CB_FEMALEFIELD      );
     492           0 :     m_pNeutralCB->SetHelpId(        HID_MM_BODY_CB_NEUTRAL          );
     493             : 
     494           0 :     FreeResource();
     495           0 :     m_aGreetingLineCB.SetClickHdl(LINK(this, SwMailBodyDialog, ContainsHdl_Impl));
     496           0 :     Link aIndividualLink = LINK(this, SwGreetingsHandler, IndividualHdl_Impl);
     497           0 :     m_aPersonalizedCB.SetClickHdl(aIndividualLink);
     498           0 :     Link aGreetingLink = LINK(this, SwGreetingsHandler, GreetingHdl_Impl);
     499           0 :     m_aFemalePB.SetClickHdl(aGreetingLink);
     500           0 :     m_aMalePB.SetClickHdl(aGreetingLink);
     501           0 :     m_aOK.SetClickHdl(LINK(this, SwMailBodyDialog, OKHdl));
     502             : 
     503           0 :     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     504           0 :     m_aGreetingLineCB.Check(rConfig.IsGreetingLine(sal_True));
     505           0 :     m_aPersonalizedCB.Check(rConfig.IsIndividualGreeting(sal_True));
     506           0 :     ContainsHdl_Impl(&m_aGreetingLineCB);
     507           0 :     aIndividualLink.Call(0);
     508             : 
     509           0 :     lcl_FillGreetingsBox(m_aFemaleLB, rConfig, SwMailMergeConfigItem::FEMALE);
     510           0 :     lcl_FillGreetingsBox(m_aMaleLB, rConfig, SwMailMergeConfigItem::MALE);
     511           0 :     lcl_FillGreetingsBox(m_aNeutralCB, rConfig, SwMailMergeConfigItem::NEUTRAL);
     512             : 
     513             :     //try to find the gender setting
     514           0 :     m_aFemaleColumnLB.Clear();
     515           0 :     Reference< sdbcx::XColumnsSupplier > xColsSupp = rConfig.GetColumnsSupplier();
     516           0 :     if(xColsSupp.is())
     517             :     {
     518           0 :         Reference < container::XNameAccess> xColAccess = xColsSupp->getColumns();
     519           0 :         Sequence< OUString > aColumns = xColAccess->getElementNames();
     520           0 :         for(sal_Int32 nName = 0; nName < aColumns.getLength(); ++nName)
     521           0 :             m_aFemaleColumnLB.InsertEntry(aColumns[nName]);
     522             :     }
     523             : 
     524           0 :     OUString sGenderColumn = rConfig.GetAssignedColumn(MM_PART_GENDER);
     525           0 :     m_aFemaleColumnLB.SelectEntry(sGenderColumn);
     526           0 :     m_aFemaleColumnLB.SaveValue();
     527             : 
     528           0 :     m_aFemaleFieldCB.SetText(rConfig.GetFemaleGenderValue());
     529           0 :     m_aFemaleFieldCB.SaveValue();
     530           0 : }
     531             : 
     532           0 : SwMailBodyDialog::~SwMailBodyDialog()
     533             : {
     534           0 : }
     535             : 
     536           0 : IMPL_LINK(SwMailBodyDialog, ContainsHdl_Impl, CheckBox*, pBox)
     537             : {
     538           0 :     SwGreetingsHandler::Contains(pBox->IsChecked());
     539           0 :     m_pWizard->GetConfigItem().SetGreetingLine(pBox->IsChecked(), sal_True);
     540           0 :     return 0;
     541             : }
     542             : 
     543           0 : IMPL_LINK_NOARG(SwMailBodyDialog, OKHdl)
     544             : {
     545           0 :     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
     546             :     rConfigItem.SetGreetingLine(
     547           0 :                 m_aGreetingLineCB.IsChecked(), sal_False);
     548             :     rConfigItem.SetIndividualGreeting(
     549           0 :                 m_aPersonalizedCB.IsChecked(), sal_False);
     550             : 
     551           0 :     if(m_aFemaleColumnLB.GetSelectEntryPos() != m_aFemaleColumnLB.GetSavedValue())
     552             :     {
     553           0 :         const SwDBData& rDBData = rConfigItem.GetCurrentDBData();
     554           0 :         Sequence< OUString> aAssignment = rConfigItem.GetColumnAssignment( rDBData );
     555           0 :         sal_Int32 nPos = m_aFemaleColumnLB.GetSelectEntryPos();
     556           0 :         if(aAssignment.getLength() < MM_PART_GENDER)
     557           0 :             aAssignment.realloc(MM_PART_GENDER);
     558           0 :         if( nPos > 0 )
     559           0 :             aAssignment[MM_PART_GENDER] = m_aFemaleColumnLB.GetSelectEntry();
     560             :         else
     561           0 :             aAssignment[MM_PART_GENDER] = OUString();
     562           0 :         rConfigItem.SetColumnAssignment( rDBData, aAssignment );
     563             :     }
     564           0 :     if(m_aFemaleFieldCB.GetText() != m_aFemaleFieldCB.GetSavedValue())
     565           0 :         rConfigItem.SetFemaleGenderValue(m_aFemaleFieldCB.GetText());
     566             : 
     567           0 :     EndDialog(RET_OK);
     568           0 :     return 0;
     569           0 : }
     570             : 
     571             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10