LCOV - code coverage report
Current view: top level - sw/source/ui/dbui - mmgreetingspage.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 334 0.0 %
Date: 2014-11-03 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 <dbui.hrc>
      27             : #include <com/sun/star/sdb/XColumn.hpp>
      28             : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      29             : #include <com/sun/star/container/XNameAccess.hpp>
      30             : #include <helpid.h>
      31             : 
      32             : #include <boost/scoped_ptr.hpp>
      33             : 
      34             : using namespace svt;
      35             : using namespace ::com::sun::star;
      36             : using namespace ::com::sun::star::uno;
      37             : 
      38           0 : static void lcl_FillGreetingsBox(ListBox& rBox,
      39             :                         SwMailMergeConfigItem& rConfig,
      40             :                         SwMailMergeConfigItem::Gender eType)
      41             : {
      42           0 :     const Sequence< OUString> rEntries = rConfig.GetGreetings(eType);
      43           0 :     for(sal_Int32 nEntry = 0; nEntry < rEntries.getLength(); ++nEntry)
      44           0 :         rBox.InsertEntry(rEntries[nEntry]);
      45           0 :     rBox.SelectEntryPos(rConfig.GetCurrentGreeting(eType));
      46           0 : }
      47             : 
      48           0 : static void lcl_FillGreetingsBox(ComboBox& rBox,
      49             :                         SwMailMergeConfigItem& rConfig,
      50             :                         SwMailMergeConfigItem::Gender eType)
      51             : {
      52           0 :     const Sequence< OUString> rEntries = rConfig.GetGreetings(eType);
      53           0 :     for(sal_Int32 nEntry = 0; nEntry < rEntries.getLength(); ++nEntry)
      54           0 :         rBox.InsertEntry(rEntries[nEntry]);
      55           0 :     rBox.SelectEntryPos(rConfig.GetCurrentGreeting(eType));
      56           0 : }
      57             : 
      58           0 : static void lcl_StoreGreetingsBox(ListBox& rBox,
      59             :                         SwMailMergeConfigItem& rConfig,
      60             :                         SwMailMergeConfigItem::Gender eType)
      61             : {
      62           0 :     Sequence< OUString> aEntries(rBox.GetEntryCount());
      63           0 :     OUString* pEntries = aEntries.getArray();
      64           0 :     for(sal_Int32 nEntry = 0; nEntry < rBox.GetEntryCount(); ++nEntry)
      65           0 :         pEntries[nEntry] = rBox.GetEntry(nEntry);
      66           0 :     rConfig.SetGreetings(eType, aEntries);
      67           0 :     rConfig.SetCurrentGreeting(eType, rBox.GetSelectEntryPos());
      68           0 : }
      69             : 
      70           0 : static void lcl_StoreGreetingsBox(ComboBox& rBox,
      71             :                         SwMailMergeConfigItem& rConfig,
      72             :                         SwMailMergeConfigItem::Gender eType)
      73             : {
      74           0 :     Sequence< OUString> aEntries(rBox.GetEntryCount());
      75           0 :     OUString* pEntries = aEntries.getArray();
      76           0 :     for(sal_Int32 nEntry = 0; nEntry < rBox.GetEntryCount(); ++nEntry)
      77           0 :         pEntries[nEntry] = rBox.GetEntry(nEntry);
      78           0 :     rConfig.SetGreetings(eType, aEntries);
      79           0 :     rConfig.SetCurrentGreeting(eType, rBox.GetSelectEntryPos());
      80           0 : }
      81             : 
      82           0 : IMPL_LINK_NOARG(SwGreetingsHandler, IndividualHdl_Impl)
      83             : {
      84           0 :     bool bIndividual = m_pPersonalizedCB->IsEnabled() && m_pPersonalizedCB->IsChecked();
      85           0 :     m_pFemaleFT->Enable(bIndividual);
      86           0 :     m_pFemaleLB->Enable(bIndividual);
      87           0 :     m_pFemalePB->Enable(bIndividual);
      88           0 :     m_pMaleFT->Enable(bIndividual);
      89           0 :     m_pMaleLB->Enable(bIndividual);
      90           0 :     m_pMalePB->Enable(bIndividual);
      91           0 :     m_pFemaleFI->Enable(bIndividual);
      92           0 :     m_pFemaleColumnFT->Enable(bIndividual);
      93           0 :     m_pFemaleColumnLB->Enable(bIndividual);
      94           0 :     m_pFemaleFieldFT->Enable(bIndividual);
      95           0 :     m_pFemaleFieldCB->Enable(bIndividual);
      96             : 
      97           0 :     if( m_bIsTabPage )
      98             :     {
      99           0 :         m_pWizard->GetConfigItem().SetIndividualGreeting(bIndividual, false);
     100           0 :         m_pWizard->UpdateRoadmap();
     101           0 :         m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
     102             :     }
     103           0 :     UpdatePreview();
     104           0 :     return 0;
     105             : }
     106             : 
     107           0 : IMPL_LINK(SwGreetingsHandler, GreetingHdl_Impl, PushButton*, pButton)
     108             : {
     109             :     boost::scoped_ptr<SwCustomizeAddressBlockDialog> pDlg(
     110           0 :             new SwCustomizeAddressBlockDialog(pButton, m_pWizard->GetConfigItem(),
     111           0 :                         pButton == m_pMalePB ?
     112             :                         SwCustomizeAddressBlockDialog::GREETING_MALE :
     113           0 :                         SwCustomizeAddressBlockDialog::GREETING_FEMALE ));
     114           0 :     if(RET_OK == pDlg->Execute())
     115             :     {
     116           0 :         ListBox* pToInsert = pButton == m_pMalePB ? m_pMaleLB : m_pFemaleLB;
     117           0 :         pToInsert->SelectEntryPos(pToInsert->InsertEntry(pDlg->GetAddress()));
     118           0 :         if(m_bIsTabPage)
     119             :         {
     120           0 :             m_pWizard->UpdateRoadmap();
     121           0 :             m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
     122             :         }
     123           0 :         UpdatePreview();
     124             :     }
     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 :     const OUString sPreview(m_pFemaleLB->GetSelectEntry() + "\n" + m_pMaleLB->GetSelectEntry());
     136             :     boost::scoped_ptr<SwAssignFieldsDialog> pDlg(
     137           0 :             new SwAssignFieldsDialog(pButton, m_pWizard->GetConfigItem(), sPreview, false));
     138           0 :     if(RET_OK == pDlg->Execute())
     139             :     {
     140           0 :         UpdatePreview();
     141           0 :         m_pWizard->UpdateRoadmap();
     142           0 :         m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
     143             :     }
     144           0 :     return 0;
     145             : }
     146             : 
     147           0 : IMPL_LINK_NOARG(SwMailMergeGreetingsPage, GreetingSelectHdl_Impl)
     148             : {
     149           0 :     UpdatePreview();
     150           0 :     return 0;
     151             : }
     152             : 
     153           0 : void SwMailMergeGreetingsPage::UpdatePreview()
     154             : {
     155             :     //find out which type of greeting should be selected:
     156           0 :     bool bFemale = false;
     157           0 :     bool bNoValue = !m_pFemaleColumnLB->IsEnabled();
     158           0 :     if( !bNoValue )
     159             :     {
     160           0 :         const OUString sFemaleValue = m_pFemaleFieldCB->GetText();
     161           0 :         const OUString sFemaleColumn = m_pFemaleColumnLB->GetSelectEntry();
     162           0 :         Reference< sdbcx::XColumnsSupplier > xColsSupp( m_pWizard->GetConfigItem().GetResultSet(), UNO_QUERY);
     163           0 :         Reference < container::XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0;
     164           0 :         if(!sFemaleValue.isEmpty() && !sFemaleColumn.isEmpty() &&
     165           0 :                 xColAccess.is() &&
     166           0 :                 xColAccess->hasByName(sFemaleColumn))
     167             :         {
     168             :             //get the content and exchange it in the address string
     169           0 :             Any aCol = xColAccess->getByName(sFemaleColumn);
     170           0 :             Reference< sdb::XColumn > xColumn;
     171           0 :             aCol >>= xColumn;
     172           0 :             if(xColumn.is())
     173             :             {
     174             :                 try
     175             :                 {
     176           0 :                     bFemale = xColumn->getString() == sFemaleValue;
     177           0 :                     if( !bNoValue )
     178             :                     {
     179             :                         //no last name value marks the greeting also als neutral
     180           0 :                         SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     181             :                         const OUString sLastNameColumn =
     182           0 :                             rConfig.GetAssignedColumn(MM_PART_LASTNAME);
     183           0 :                         if ( xColAccess->hasByName(sLastNameColumn) )
     184             :                         {
     185           0 :                             aCol = xColAccess->getByName(sLastNameColumn);
     186           0 :                             aCol >>= xColumn;
     187           0 :                             bNoValue = xColumn->getString().isEmpty();
     188           0 :                         }
     189             :                     }
     190             :                 }
     191           0 :                 catch (const sdbc::SQLException&)
     192             :                 {
     193             :                     OSL_FAIL("SQLException caught");
     194             :                 }
     195           0 :             }
     196           0 :         }
     197             :     }
     198             : 
     199             :     OUString sPreview = bFemale ? m_pFemaleLB->GetSelectEntry() :
     200           0 :         bNoValue ? m_pNeutralCB->GetText() : m_pMaleLB->GetSelectEntry();
     201             : 
     202           0 :     sPreview = SwAddressPreview::FillData(sPreview, m_pWizard->GetConfigItem());
     203           0 :     m_pPreviewWIN->SetAddress(sPreview);
     204           0 : }
     205             : 
     206           0 : void    SwGreetingsHandler::Contains(bool bContainsGreeting)
     207             : {
     208           0 :     m_pPersonalizedCB->Enable(bContainsGreeting);
     209           0 :     bool bEnablePersonal = bContainsGreeting && m_pPersonalizedCB->IsChecked();
     210           0 :     m_pFemaleFT->Enable(bEnablePersonal);
     211           0 :     m_pFemaleLB->Enable(bEnablePersonal);
     212           0 :     m_pFemalePB->Enable(bEnablePersonal);
     213           0 :     m_pMaleFT->Enable(bEnablePersonal);
     214           0 :     m_pMaleLB->Enable(bEnablePersonal);
     215           0 :     m_pMalePB->Enable(bEnablePersonal);
     216           0 :     m_pFemaleFI->Enable(bEnablePersonal);
     217           0 :     m_pFemaleColumnFT->Enable(bEnablePersonal);
     218           0 :     m_pFemaleColumnLB->Enable(bEnablePersonal);
     219           0 :     m_pFemaleFieldFT->Enable(bEnablePersonal);
     220           0 :     m_pFemaleFieldCB->Enable(bEnablePersonal);
     221             : 
     222           0 :     m_pNeutralFT->Enable(bContainsGreeting);
     223           0 :     m_pNeutralCB->Enable(bContainsGreeting);
     224           0 : }
     225             : 
     226           0 : SwMailMergeGreetingsPage::SwMailMergeGreetingsPage(SwMailMergeWizard* _pParent)
     227             :     : svt::OWizardPage(_pParent, "MMSalutationPage",
     228           0 :         "modules/swriter/ui/mmsalutationpage.ui")
     229             : {
     230           0 :     m_pWizard = _pParent;
     231             : 
     232           0 :     get(m_pGreetingLineCB, "greeting");
     233           0 :     get(m_pPersonalizedCB, "personalized");
     234           0 :     get(m_pFemaleFT, "femaleft");
     235           0 :     get(m_pFemaleLB, "female");
     236           0 :     get(m_pFemalePB, "newfemale");
     237           0 :     get(m_pMaleFT, "maleft");
     238           0 :     get(m_pMaleLB, "male");
     239           0 :     get(m_pMalePB, "newmale");
     240           0 :     get(m_pFemaleFI, "femalefi");
     241           0 :     get(m_pFemaleColumnFT, "femalecolft");
     242           0 :     get(m_pFemaleColumnLB, "femalecol");
     243           0 :     get(m_pFemaleFieldFT, "femalefieldft");
     244           0 :     get(m_pFemaleFieldCB, "femalefield");
     245           0 :     get(m_pNeutralFT, "generalft");
     246           0 :     get(m_pNeutralCB, "general");
     247           0 :     get(m_pPreviewFI, "previewft");
     248           0 :     get(m_pPreviewWIN, "preview");
     249           0 :     Size aSize(LogicToPixel(Size(186, 21), MapMode(MAP_APPFONT)));
     250           0 :     m_pPreviewWIN->set_width_request(aSize.Width());
     251           0 :     m_pPreviewWIN->set_height_request(aSize.Height());
     252           0 :     get(m_pAssignPB, "assign");
     253           0 :     get(m_pDocumentIndexFI, "documentindex");
     254           0 :     m_sDocument = m_pDocumentIndexFI->GetText();
     255           0 :     get(m_pPrevSetIB, "prev");
     256           0 :     get(m_pNextSetIB, "next");
     257             : 
     258           0 :     m_bIsTabPage = true;
     259             : 
     260           0 :     m_pGreetingLineCB->SetClickHdl(LINK(this, SwMailMergeGreetingsPage, ContainsHdl_Impl));
     261           0 :     Link aIndividualLink = LINK(this, SwGreetingsHandler, IndividualHdl_Impl);
     262           0 :     m_pPersonalizedCB->SetClickHdl(aIndividualLink);
     263           0 :     Link aGreetingLink = LINK(this, SwGreetingsHandler, GreetingHdl_Impl);
     264           0 :     m_pFemalePB->SetClickHdl(aGreetingLink);
     265           0 :     m_pMalePB->SetClickHdl(aGreetingLink);
     266           0 :     m_pAssignPB->SetClickHdl(LINK(this, SwMailMergeGreetingsPage, AssignHdl_Impl));
     267           0 :     Link aLBoxLink = LINK(this, SwMailMergeGreetingsPage, GreetingSelectHdl_Impl);
     268           0 :     m_pFemaleLB->SetSelectHdl(aLBoxLink);
     269           0 :     m_pMaleLB->SetSelectHdl(aLBoxLink);
     270           0 :     m_pFemaleColumnLB->SetSelectHdl(aLBoxLink);
     271           0 :     m_pFemaleFieldCB->SetSelectHdl(aLBoxLink);
     272           0 :     m_pFemaleFieldCB->SetModifyHdl(aLBoxLink);
     273           0 :     m_pNeutralCB->SetSelectHdl(aLBoxLink);
     274           0 :     m_pNeutralCB->SetModifyHdl(aLBoxLink);
     275             : 
     276           0 :     Link aDataLink = LINK(this, SwMailMergeGreetingsPage, InsertDataHdl_Impl);
     277           0 :     m_pPrevSetIB->SetClickHdl(aDataLink);
     278           0 :     m_pNextSetIB->SetClickHdl(aDataLink);
     279             : 
     280           0 :     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     281           0 :     m_pGreetingLineCB->Check(rConfig.IsGreetingLine(false));
     282           0 :     m_pPersonalizedCB->Check(rConfig.IsIndividualGreeting(false));
     283           0 :     ContainsHdl_Impl(m_pGreetingLineCB);
     284           0 :     aIndividualLink.Call(0);
     285             : 
     286           0 :     lcl_FillGreetingsBox(*m_pFemaleLB, rConfig, SwMailMergeConfigItem::FEMALE);
     287           0 :     lcl_FillGreetingsBox(*m_pMaleLB, rConfig, SwMailMergeConfigItem::MALE);
     288           0 :     lcl_FillGreetingsBox(*m_pNeutralCB, rConfig, SwMailMergeConfigItem::NEUTRAL);
     289             : 
     290           0 :     m_pDocumentIndexFI->SetText(m_sDocument.replaceFirst("%1", "1"));
     291           0 : }
     292             : 
     293           0 : SwMailMergeGreetingsPage::~SwMailMergeGreetingsPage()
     294             : {
     295           0 : }
     296             : 
     297           0 : void SwMailMergeGreetingsPage::ActivatePage()
     298             : {
     299           0 :     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     300             : 
     301             :     //try to find the gender setting
     302           0 :     m_pFemaleColumnLB->Clear();
     303           0 :     Reference< sdbcx::XColumnsSupplier > xColsSupp = rConfig.GetColumnsSupplier();
     304           0 :     if(xColsSupp.is())
     305             :     {
     306           0 :         Reference < container::XNameAccess> xColAccess = xColsSupp->getColumns();
     307           0 :         Sequence< OUString > aColumns = xColAccess->getElementNames();
     308           0 :         for(sal_Int32 nName = 0; nName < aColumns.getLength(); ++nName)
     309           0 :             m_pFemaleColumnLB->InsertEntry(aColumns[nName]);
     310             :     }
     311             : 
     312           0 :     m_pFemaleColumnLB->SelectEntry(rConfig.GetAssignedColumn(MM_PART_GENDER));
     313           0 :     m_pFemaleColumnLB->SaveValue();
     314             : 
     315           0 :     m_pFemaleFieldCB->SetText(rConfig.GetFemaleGenderValue());
     316           0 :     m_pFemaleFieldCB->SaveValue();
     317             : 
     318           0 :     UpdatePreview();
     319           0 :     m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
     320           0 : }
     321             : 
     322           0 : bool SwMailMergeGreetingsPage::commitPage( ::svt::WizardTypes::CommitPageReason )
     323             : {
     324           0 :     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     325             : 
     326           0 :     if (m_pFemaleColumnLB->IsValueChangedFromSaved())
     327             :     {
     328           0 :         const SwDBData& rDBData = rConfig.GetCurrentDBData();
     329           0 :         Sequence< OUString> aAssignment = rConfig.GetColumnAssignment( rDBData );
     330           0 :         if(aAssignment.getLength() <= MM_PART_GENDER)
     331           0 :             aAssignment.realloc(MM_PART_GENDER + 1);
     332           0 :         aAssignment[MM_PART_GENDER] = m_pFemaleColumnLB->GetSelectEntry();
     333           0 :         rConfig.SetColumnAssignment( rDBData, aAssignment );
     334             :     }
     335           0 :     if (m_pFemaleFieldCB->IsValueChangedFromSaved())
     336           0 :         rConfig.SetFemaleGenderValue(m_pFemaleFieldCB->GetText());
     337             : 
     338           0 :     lcl_StoreGreetingsBox(*m_pFemaleLB, rConfig, SwMailMergeConfigItem::FEMALE);
     339           0 :     lcl_StoreGreetingsBox(*m_pMaleLB, rConfig, SwMailMergeConfigItem::MALE);
     340             : 
     341           0 :     sal_Int32 nCurrentTextPos = m_pNeutralCB->GetEntryPos(m_pNeutralCB->GetText());
     342           0 :     if(COMBOBOX_ENTRY_NOTFOUND == nCurrentTextPos)
     343             :     {
     344           0 :         sal_Int32 nCount = m_pNeutralCB->GetEntryCount();
     345           0 :         m_pNeutralCB->InsertEntry(m_pNeutralCB->GetText(), nCount);
     346           0 :         m_pNeutralCB->SelectEntryPos(nCount);
     347             :     }
     348           0 :     lcl_StoreGreetingsBox(*m_pNeutralCB, rConfig, SwMailMergeConfigItem::NEUTRAL);
     349           0 :     rConfig.SetGreetingLine(m_pGreetingLineCB->IsChecked(), false);
     350           0 :     rConfig.SetIndividualGreeting(m_pPersonalizedCB->IsChecked(), false);
     351           0 :     return true;
     352             : }
     353             : 
     354           0 : IMPL_LINK(SwMailMergeGreetingsPage, ContainsHdl_Impl, CheckBox*, pBox)
     355             : {
     356           0 :     bool bContainsGreeting = pBox->IsChecked();
     357           0 :     SwGreetingsHandler::Contains(bContainsGreeting);
     358           0 :     m_pPreviewFI-> Enable(bContainsGreeting);
     359           0 :     m_pPreviewWIN->Enable(bContainsGreeting);
     360           0 :     m_pAssignPB->  Enable(bContainsGreeting);
     361           0 :     m_pDocumentIndexFI->  Enable(bContainsGreeting);
     362           0 :     m_pPrevSetIB->Enable(bContainsGreeting);
     363           0 :     m_pNextSetIB->Enable(bContainsGreeting);
     364           0 :     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     365           0 :     rConfig.SetGreetingLine(m_pGreetingLineCB->IsChecked(), false);
     366           0 :     m_pWizard->UpdateRoadmap();
     367           0 :     return 0;
     368             : }
     369             : 
     370           0 : IMPL_LINK(SwMailMergeGreetingsPage, InsertDataHdl_Impl, ImageButton*, pButton)
     371             : {
     372             :     //if no pButton is given, the first set has to be pre-set
     373           0 :     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     374           0 :     if(!pButton)
     375             :     {
     376           0 :         rConfig.GetResultSet();
     377             :     }
     378             :     else
     379             :     {
     380           0 :         bool bNext = pButton == m_pNextSetIB;
     381           0 :         sal_Int32 nPos = rConfig.GetResultSetPosition();
     382           0 :         rConfig.MoveResultSet( bNext ? ++nPos : --nPos);
     383             :     }
     384           0 :     sal_Int32 nPos = rConfig.GetResultSetPosition();
     385           0 :     bool bEnable = true;
     386           0 :     if(nPos < 1)
     387             :     {
     388           0 :         bEnable = false;
     389           0 :         nPos = 1;
     390             :     }
     391             :     else
     392           0 :         UpdatePreview();
     393           0 :     m_pPrevSetIB->Enable(bEnable);
     394           0 :     m_pNextSetIB->Enable(bEnable);
     395           0 :     m_pDocumentIndexFI->Enable(bEnable);
     396           0 :     m_pDocumentIndexFI->SetText(m_sDocument.replaceFirst("%1", OUString::number(nPos)));
     397           0 :     return 0;
     398             : }
     399             : 
     400           0 : SwMailBodyDialog::SwMailBodyDialog(vcl::Window* pParent, SwMailMergeWizard* _pWizard) :
     401           0 :     SfxModalDialog(pParent, "MailBodyDialog", "modules/swriter/ui/mmmailbody.ui")
     402             : {
     403           0 :     m_pWizard = _pWizard;
     404           0 :     get(m_pGreetingLineCB, "greeting");
     405           0 :     get(m_pPersonalizedCB, "personalized");
     406           0 :     get(m_pFemaleFT, "femaleft");
     407           0 :     get(m_pFemaleLB, "female");
     408           0 :     get(m_pFemalePB, "newfemale");
     409           0 :     get(m_pMaleFT, "maleft");
     410           0 :     get(m_pMaleLB, "male");
     411           0 :     get(m_pMalePB, "newmale");
     412           0 :     get(m_pFemaleFI, "femalefi");
     413           0 :     get(m_pFemaleColumnFT, "femalecolft");
     414           0 :     get(m_pFemaleColumnLB, "femalecol");
     415           0 :     get(m_pFemaleFieldFT, "femalefieldft");
     416           0 :     get(m_pFemaleFieldCB, "femalefield");
     417           0 :     get(m_pNeutralFT, "generalft");
     418           0 :     get(m_pNeutralCB, "general");
     419           0 :     get(m_pBodyFT, "bodyft");
     420           0 :     get(m_pBodyMLE, "bodymle");
     421           0 :     m_pBodyMLE->SetStyle(m_pBodyMLE->GetStyle() | WB_HSCROLL | WB_VSCROLL | WB_IGNORETAB);
     422           0 :     Size aSize(LogicToPixel(Size(180, 50), MAP_APPFONT));
     423           0 :     m_pBodyMLE->set_width_request(aSize.Width());
     424           0 :     m_pBodyMLE->set_height_request(aSize.Height());
     425           0 :     get(m_pOK, "ok");
     426           0 :     m_bIsTabPage = false;
     427             : 
     428           0 :     m_pPersonalizedCB->SetHelpId(   HID_MM_BODY_CB_PERSONALIZED     );
     429           0 :     m_pFemaleLB->SetHelpId(         HID_MM_BODY_LB_FEMALE           );
     430           0 :     m_pFemalePB->SetHelpId(         HID_MM_BODY_PB_FEMALE           );
     431           0 :     m_pMaleLB->SetHelpId(           HID_MM_BODY_LB_MALE             );
     432           0 :     m_pMalePB->SetHelpId(           HID_MM_BODY_PB_MALE             );
     433           0 :     m_pFemaleColumnLB->SetHelpId(   HID_MM_BODY_LB_FEMALECOLUMN     );
     434           0 :     m_pFemaleFieldCB->SetHelpId(    HID_MM_BODY_CB_FEMALEFIELD      );
     435           0 :     m_pNeutralCB->SetHelpId(        HID_MM_BODY_CB_NEUTRAL          );
     436             : 
     437           0 :     m_pGreetingLineCB->SetClickHdl(LINK(this, SwMailBodyDialog, ContainsHdl_Impl));
     438           0 :     Link aIndividualLink = LINK(this, SwGreetingsHandler, IndividualHdl_Impl);
     439           0 :     m_pPersonalizedCB->SetClickHdl(aIndividualLink);
     440           0 :     Link aGreetingLink = LINK(this, SwGreetingsHandler, GreetingHdl_Impl);
     441           0 :     m_pFemalePB->SetClickHdl(aGreetingLink);
     442           0 :     m_pMalePB->SetClickHdl(aGreetingLink);
     443           0 :     m_pOK->SetClickHdl(LINK(this, SwMailBodyDialog, OKHdl));
     444             : 
     445           0 :     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     446           0 :     m_pGreetingLineCB->Check(rConfig.IsGreetingLine(true));
     447           0 :     m_pPersonalizedCB->Check(rConfig.IsIndividualGreeting(true));
     448           0 :     ContainsHdl_Impl(m_pGreetingLineCB);
     449           0 :     aIndividualLink.Call(0);
     450             : 
     451           0 :     lcl_FillGreetingsBox(*m_pFemaleLB, rConfig, SwMailMergeConfigItem::FEMALE);
     452           0 :     lcl_FillGreetingsBox(*m_pMaleLB, rConfig, SwMailMergeConfigItem::MALE);
     453           0 :     lcl_FillGreetingsBox(*m_pNeutralCB, rConfig, SwMailMergeConfigItem::NEUTRAL);
     454             : 
     455             :     //try to find the gender setting
     456           0 :     m_pFemaleColumnLB->Clear();
     457           0 :     Reference< sdbcx::XColumnsSupplier > xColsSupp = rConfig.GetColumnsSupplier();
     458           0 :     if(xColsSupp.is())
     459             :     {
     460           0 :         Reference < container::XNameAccess> xColAccess = xColsSupp->getColumns();
     461           0 :         Sequence< OUString > aColumns = xColAccess->getElementNames();
     462           0 :         for(sal_Int32 nName = 0; nName < aColumns.getLength(); ++nName)
     463           0 :             m_pFemaleColumnLB->InsertEntry(aColumns[nName]);
     464             :     }
     465             : 
     466           0 :     m_pFemaleColumnLB->SelectEntry(rConfig.GetAssignedColumn(MM_PART_GENDER));
     467           0 :     m_pFemaleColumnLB->SaveValue();
     468             : 
     469           0 :     m_pFemaleFieldCB->SetText(rConfig.GetFemaleGenderValue());
     470           0 :     m_pFemaleFieldCB->SaveValue();
     471           0 : }
     472             : 
     473           0 : SwMailBodyDialog::~SwMailBodyDialog()
     474             : {
     475           0 : }
     476             : 
     477           0 : IMPL_LINK(SwMailBodyDialog, ContainsHdl_Impl, CheckBox*, pBox)
     478             : {
     479           0 :     SwGreetingsHandler::Contains(pBox->IsChecked());
     480           0 :     m_pWizard->GetConfigItem().SetGreetingLine(pBox->IsChecked(), true);
     481           0 :     return 0;
     482             : }
     483             : 
     484           0 : IMPL_LINK_NOARG(SwMailBodyDialog, OKHdl)
     485             : {
     486           0 :     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
     487             :     rConfigItem.SetGreetingLine(
     488           0 :                 m_pGreetingLineCB->IsChecked(), false);
     489             :     rConfigItem.SetIndividualGreeting(
     490           0 :                 m_pPersonalizedCB->IsChecked(), false);
     491             : 
     492           0 :     if(m_pFemaleColumnLB->IsValueChangedFromSaved())
     493             :     {
     494           0 :         const SwDBData& rDBData = rConfigItem.GetCurrentDBData();
     495           0 :         Sequence< OUString> aAssignment = rConfigItem.GetColumnAssignment( rDBData );
     496           0 :         sal_Int32 nPos = m_pFemaleColumnLB->GetSelectEntryPos();
     497           0 :         if(aAssignment.getLength() < MM_PART_GENDER)
     498           0 :             aAssignment.realloc(MM_PART_GENDER);
     499           0 :         if( nPos > 0 )
     500           0 :             aAssignment[MM_PART_GENDER] = m_pFemaleColumnLB->GetSelectEntry();
     501             :         else
     502           0 :             aAssignment[MM_PART_GENDER] = OUString();
     503           0 :         rConfigItem.SetColumnAssignment( rDBData, aAssignment );
     504             :     }
     505           0 :     if(m_pFemaleFieldCB->IsValueChangedFromSaved())
     506           0 :         rConfigItem.SetFemaleGenderValue(m_pFemaleFieldCB->GetText());
     507             : 
     508           0 :     EndDialog(RET_OK);
     509           0 :     return 0;
     510           0 : }
     511             : 
     512             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10