LCOV - code coverage report
Current view: top level - sw/source/ui/envelp - label1.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 548 0.0 %
Date: 2014-04-11 Functions: 0 59 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 <vcl/waitobj.hxx>
      21             : #include <rtl/ustring.hxx>
      22             : #include "svtools/treelistentry.hxx"
      23             : #include <com/sun/star/uno/Sequence.h>
      24             : #include <swtypes.hxx>
      25             : #include <wrtsh.hxx>
      26             : #include <initui.hxx>
      27             : #include <../../core/uibase/envelp/labimp.hxx>
      28             : #include <labfmt.hxx>
      29             : #include <labprt.hxx>
      30             : #include <unotools.hxx>
      31             : #include <dbmgr.hxx>
      32             : #include "uitool.hxx"
      33             : #include <cmdid.h>
      34             : #include <helpid.h>
      35             : #include <globals.hrc>
      36             : #include <../../core/uibase/envelp/label.hrc>
      37             : 
      38             : //impl in envimg.cxx
      39             : extern SW_DLLPUBLIC OUString MakeSender();
      40             : 
      41           0 : void SwLabRec::SetFromItem( const SwLabItem& rItem )
      42             : {
      43           0 :     lHDist  = rItem.lHDist;
      44           0 :     lVDist  = rItem.lVDist;
      45           0 :     lWidth  = rItem.lWidth;
      46           0 :     lHeight = rItem.lHeight;
      47           0 :     lLeft   = rItem.lLeft;
      48           0 :     lUpper  = rItem.lUpper;
      49           0 :     nCols   = rItem.nCols;
      50           0 :     nRows   = rItem.nRows;
      51           0 :     lPWidth  = rItem.lPWidth;
      52           0 :     lPHeight = rItem.lPHeight;
      53           0 :     bCont   = rItem.bCont;
      54           0 : }
      55             : 
      56           0 : void SwLabRec::FillItem( SwLabItem& rItem ) const
      57             : {
      58           0 :     rItem.lHDist  = lHDist;
      59           0 :     rItem.lVDist  = lVDist;
      60           0 :     rItem.lWidth  = lWidth;
      61           0 :     rItem.lHeight = lHeight;
      62           0 :     rItem.lLeft   = lLeft;
      63           0 :     rItem.lUpper  = lUpper;
      64           0 :     rItem.nCols   = nCols;
      65           0 :     rItem.lPWidth  = lPWidth;
      66           0 :     rItem.lPHeight = lPHeight;
      67           0 :     rItem.nRows   = nRows;
      68           0 : }
      69             : 
      70           0 : void SwLabDlg::_ReplaceGroup( const OUString &rMake )
      71             : {
      72             :     // Remove old entries
      73           0 :     pRecs->erase(pRecs->begin() + 1, pRecs->end());
      74           0 :     aLabelsCfg.FillLabels(rMake, *pRecs);
      75           0 :     aLstGroup = rMake;
      76           0 : }
      77             : 
      78           0 : void SwLabDlg::PageCreated(sal_uInt16 nId, SfxTabPage &rPage)
      79             : {
      80           0 :     if (nId == m_nLabelId)
      81             :     {
      82           0 :         if(m_bLabel)
      83             :         {
      84           0 :             ((SwLabPage*)&rPage)->SetNewDBMgr(pNewDBMgr);
      85           0 :             ((SwLabPage*)&rPage)->InitDatabaseBox();
      86             :         }
      87             :         else
      88           0 :             ((SwLabPage*)&rPage)->SetToBusinessCard();
      89             :     }
      90           0 :     else if (nId == m_nOptionsId)
      91           0 :         pPrtPage = (SwLabPrtPage*)&rPage;
      92           0 : }
      93             : 
      94           0 : SwLabDlg::SwLabDlg(Window* pParent, const SfxItemSet& rSet,
      95             :                                 SwNewDBMgr* pDBMgr, sal_Bool bLabel)
      96             :     : SfxTabDialog(pParent, "LabelDialog",
      97             :         "modules/swriter/ui/labeldialog.ui", &rSet)
      98             :     , pNewDBMgr(pDBMgr)
      99             :     , pPrtPage(0)
     100             :     , aTypeIds(50, 10)
     101           0 :     , pRecs(new SwLabRecs())
     102             :     , m_bLabel(bLabel)
     103             :     , m_nFormatId(0)
     104             :     , m_nOptionsId(0)
     105             :     , m_nLabelId(0)
     106             :     , m_nCardsId(0)
     107             :     , m_nBusinessId(0)
     108           0 :     , m_nPrivateId(0)
     109             : {
     110           0 :     WaitObject aWait( pParent );
     111             : 
     112           0 :     m_nFormatId = AddTabPage("format", SwLabFmtPage::Create, 0);
     113           0 :     m_nOptionsId = AddTabPage("options", SwLabPrtPage::Create, 0);
     114           0 :     m_nCardsId = AddTabPage("cards", SwVisitingCardPage::Create, 0);
     115           0 :     m_sBusinessCardDlg = GetPageText(m_nCardsId);
     116             : 
     117           0 :     if (m_bLabel)
     118             :     {
     119           0 :         RemoveTabPage("business");
     120           0 :         RemoveTabPage("private");
     121           0 :         RemoveTabPage("cards");
     122           0 :         RemoveTabPage("medium");
     123           0 :         m_nLabelId = AddTabPage("labels", SwLabPage::Create, 0);
     124             :     }
     125             :     else
     126             :     {
     127           0 :         RemoveTabPage("labels");
     128           0 :         RemoveTabPage("cards");
     129           0 :         m_nLabelId = AddTabPage("medium", SwLabPage::Create, 0);
     130           0 :         m_nBusinessId = AddTabPage("business", SwBusinessDataPage::Create, 0 );
     131           0 :         m_nPrivateId = AddTabPage("private", SwPrivateDataPage::Create, 0);
     132           0 :         SetText(m_sBusinessCardDlg);
     133             :     }
     134             :     // Read user label from writer.cfg
     135           0 :     SwLabItem aItem((const SwLabItem&)rSet.Get( FN_LABEL ));
     136           0 :     SwLabRec* pRec = new SwLabRec;
     137           0 :     pRec->aMake = pRec->aType = SW_RESSTR( STR_CUSTOM );
     138           0 :     pRec->SetFromItem( aItem );
     139             : 
     140           0 :     bool bDouble = false;
     141             : 
     142           0 :     for (size_t nRecPos = 0; nRecPos < pRecs->size(); ++nRecPos)
     143             :     {
     144           0 :         if (pRec->aMake == (*pRecs)[nRecPos]->aMake &&
     145           0 :             pRec->aType == (*pRecs)[nRecPos]->aType)
     146             :         {
     147           0 :             bDouble = true;
     148           0 :             break;
     149             :         }
     150             :     }
     151             : 
     152           0 :     if (!bDouble)
     153           0 :         pRecs->insert( pRecs->begin(), pRec );
     154             :     else
     155           0 :         delete pRec;
     156             : 
     157           0 :     size_t nLstGroup = 0;
     158           0 :     const std::vector<OUString>& rMan = aLabelsCfg.GetManufacturers();
     159           0 :     for(size_t nMan = 0; nMan < rMan.size(); ++nMan)
     160             :     {
     161           0 :         aMakes.push_back(rMan[nMan]);
     162           0 :         if ( rMan[nMan] == aItem.aLstMake )
     163           0 :             nLstGroup = nMan;
     164             :     }
     165             : 
     166           0 :     if ( !aMakes.empty() )
     167           0 :         _ReplaceGroup( aMakes[nLstGroup] );
     168             : 
     169           0 :     if (pExampleSet)
     170           0 :         pExampleSet->Put(aItem);
     171           0 : }
     172             : 
     173           0 : SwLabDlg::~SwLabDlg()
     174             : {
     175           0 :     delete pRecs;
     176           0 : }
     177             : 
     178           0 : void SwLabDlg::GetLabItem(SwLabItem &rItem)
     179             : {
     180           0 :     const SwLabItem& rActItem = (const SwLabItem&)GetExampleSet()->Get(FN_LABEL);
     181           0 :     const SwLabItem& rOldItem = (const SwLabItem&)GetInputSetImpl()->Get(FN_LABEL);
     182             : 
     183           0 :     if (rActItem != rOldItem)
     184             :     {
     185             :         // Was already "put" with (hopefully) correct content
     186           0 :         rItem = rActItem;
     187             :     }
     188             :     else
     189             :     {
     190           0 :         rItem = rOldItem;
     191             : 
     192             :         // In rItem there are only settings defined by users.
     193             :         // Therefore get the real settings directly from Record
     194           0 :         SwLabRec* pRec = GetRecord(rItem.aType, rItem.bCont);
     195           0 :         pRec->FillItem( rItem );
     196             :     }
     197           0 : }
     198             : 
     199           0 : SwLabRec* SwLabDlg::GetRecord(const OUString &rRecName, sal_Bool bCont)
     200             : {
     201           0 :     SwLabRec* pRec = NULL;
     202           0 :     bool bFound = false;
     203           0 :     const OUString sCustom(SW_RES(STR_CUSTOM));
     204             : 
     205           0 :     const size_t nCount = Recs().size();
     206           0 :     for (size_t i = 0; i < nCount; ++i)
     207             :     {
     208           0 :         pRec = Recs()[i];
     209           0 :         if (pRec->aType != sCustom &&
     210           0 :             rRecName == pRec->aType && bCont == pRec->bCont)
     211             :         {
     212           0 :             bFound = true;
     213           0 :             break;
     214             :         }
     215             :     }
     216           0 :     if (!bFound)    // User defined
     217           0 :         pRec = Recs()[0];
     218             : 
     219           0 :     return(pRec);
     220             : }
     221             : 
     222           0 : Printer *SwLabDlg::GetPrt()
     223             : {
     224           0 :     if (pPrtPage)
     225           0 :         return (pPrtPage->GetPrt());
     226             :     else
     227           0 :         return (NULL);
     228             : }
     229             : 
     230           0 : SwLabPage::SwLabPage(Window* pParent, const SfxItemSet& rSet)
     231             :     : SfxTabPage(pParent, "CardMediumPage",
     232             :         "modules/swriter/ui/cardmediumpage.ui", rSet)
     233             :     , pNewDBMgr(NULL)
     234           0 :     , aItem((const SwLabItem&)rSet.Get(FN_LABEL))
     235             : {
     236           0 :     WaitObject aWait( pParent );
     237             : 
     238           0 :     get(m_pAddressFrame, "addressframe");
     239           0 :     get(m_pAddrBox, "address");
     240           0 :     get(m_pWritingEdit, "textview");
     241           0 :     m_pWritingEdit->set_height_request(m_pWritingEdit->GetTextHeight() * 10);
     242           0 :     m_pWritingEdit->set_width_request(m_pWritingEdit->approximate_char_width() * 25);
     243           0 :     get(m_pDatabaseLB, "database");
     244           0 :     get(m_pTableLB, "table");
     245           0 :     get(m_pInsertBT, "insert");
     246           0 :     get(m_pDBFieldLB, "field");
     247           0 :     get(m_pContButton, "continuous");
     248           0 :     get(m_pSheetButton, "sheet");
     249           0 :     get(m_pMakeBox, "brand");
     250           0 :     get(m_pTypeBox, "type");
     251           0 :     get(m_pFormatInfo, "formatinfo");
     252           0 :     get(m_pHiddenSortTypeBox, "hiddentype");
     253           0 :     m_pHiddenSortTypeBox->SetStyle(m_pHiddenSortTypeBox->GetStyle() | WB_SORT);
     254             : 
     255           0 :     long nListBoxWidth = approximate_char_width() * 30;
     256           0 :     m_pTableLB->set_width_request(nListBoxWidth);
     257           0 :     m_pDatabaseLB->set_width_request(nListBoxWidth);
     258           0 :     m_pDBFieldLB->set_width_request(nListBoxWidth);
     259             : 
     260           0 :     SetExchangeSupport();
     261             : 
     262             :     // Install handlers
     263           0 :     m_pAddrBox->SetClickHdl (LINK(this, SwLabPage, AddrHdl         ));
     264           0 :     m_pDatabaseLB->SetSelectHdl(LINK(this, SwLabPage, DatabaseHdl     ));
     265           0 :     m_pTableLB->SetSelectHdl(LINK(this, SwLabPage, DatabaseHdl     ));
     266           0 :     m_pInsertBT->SetClickHdl (LINK(this, SwLabPage, FieldHdl        ));
     267           0 :     m_pContButton->SetClickHdl (LINK(this, SwLabPage, PageHdl         ));
     268           0 :     m_pSheetButton->SetClickHdl (LINK(this, SwLabPage, PageHdl         ));
     269           0 :     m_pMakeBox->SetSelectHdl(LINK(this, SwLabPage, MakeHdl         ));
     270           0 :     m_pTypeBox->SetSelectHdl(LINK(this, SwLabPage, TypeHdl         ));
     271             : 
     272           0 :     InitDatabaseBox();
     273             : 
     274           0 :     size_t nLstGroup = 0;
     275             : 
     276           0 :     const size_t nCount = GetParentSwLabDlg()->Makes().size();
     277           0 :     for(size_t i = 0; i < nCount; ++i)
     278             :     {
     279           0 :         OUString& rStr = GetParentSwLabDlg()->Makes()[i];
     280           0 :         m_pMakeBox->InsertEntry( rStr );
     281             : 
     282           0 :         if ( rStr == aItem.aLstMake)
     283           0 :             nLstGroup = i;
     284             :     }
     285             : 
     286           0 :     m_pMakeBox->SelectEntryPos( nLstGroup );
     287           0 :     m_pMakeBox->GetSelectHdl().Call(m_pMakeBox);
     288           0 : }
     289             : 
     290           0 : void SwLabPage::SetToBusinessCard()
     291             : {
     292           0 :     SetHelpId(HID_BUSINESS_FMT_PAGE);
     293           0 :     m_pContButton->SetHelpId(HID_BUSINESS_FMT_PAGE_CONT);
     294           0 :     m_pSheetButton->SetHelpId(HID_BUSINESS_FMT_PAGE_SHEET);
     295           0 :     m_pMakeBox->SetHelpId(HID_BUSINESS_FMT_PAGE_BRAND);
     296           0 :     m_pTypeBox->SetHelpId(HID_BUSINESS_FMT_PAGE_TYPE);
     297           0 :     m_bLabel = sal_False;
     298           0 :     m_pAddressFrame->Hide();
     299           0 : };
     300             : 
     301           0 : IMPL_LINK_NOARG(SwLabPage, AddrHdl)
     302             : {
     303           0 :     OUString aWriting;
     304             : 
     305           0 :     if ( m_pAddrBox->IsChecked() )
     306           0 :         aWriting = convertLineEnd(MakeSender(), GetSystemLineEnd());
     307             : 
     308           0 :     m_pWritingEdit->SetText( aWriting );
     309           0 :     m_pWritingEdit->GrabFocus();
     310           0 :     return 0;
     311             : }
     312             : 
     313           0 : IMPL_LINK( SwLabPage, DatabaseHdl, ListBox *, pListBox )
     314             : {
     315           0 :     sActDBName = m_pDatabaseLB->GetSelectEntry();
     316             : 
     317           0 :     WaitObject aObj( GetParentSwLabDlg() );
     318             : 
     319           0 :     if (pListBox == m_pDatabaseLB)
     320           0 :         GetNewDBMgr()->GetTableNames(m_pTableLB, sActDBName);
     321             : 
     322           0 :     GetNewDBMgr()->GetColumnNames(m_pDBFieldLB, sActDBName, m_pTableLB->GetSelectEntry());
     323           0 :     return 0;
     324             : }
     325             : 
     326           0 : IMPL_LINK_NOARG(SwLabPage, FieldHdl)
     327             : {
     328           0 :     OUString aStr("<" + m_pDatabaseLB->GetSelectEntry() + "." +
     329           0 :                   m_pTableLB->GetSelectEntry() + "." +
     330           0 :                   (m_pTableLB->GetEntryData(m_pTableLB->GetSelectEntryPos()) == 0 ? OUString("0") : OUString("1")) + "." +
     331           0 :                   m_pDBFieldLB->GetSelectEntry() + ">");
     332           0 :     m_pWritingEdit->ReplaceSelected(aStr);
     333           0 :     Selection aSel = m_pWritingEdit->GetSelection();
     334           0 :     m_pWritingEdit->GrabFocus();
     335           0 :     m_pWritingEdit->SetSelection(aSel);
     336           0 :     return 0;
     337             : }
     338             : 
     339           0 : IMPL_LINK_NOARG_INLINE_START(SwLabPage, PageHdl)
     340             : {
     341           0 :     m_pMakeBox->GetSelectHdl().Call(m_pMakeBox);
     342           0 :     return 0;
     343             : }
     344           0 : IMPL_LINK_NOARG_INLINE_END(SwLabPage, PageHdl)
     345             : 
     346           0 : IMPL_LINK_NOARG(SwLabPage, MakeHdl)
     347             : {
     348           0 :     WaitObject aWait( GetParentSwLabDlg() );
     349             : 
     350           0 :     m_pTypeBox->Clear();
     351           0 :     m_pHiddenSortTypeBox->Clear();
     352           0 :     GetParentSwLabDlg()->TypeIds().clear();
     353             : 
     354           0 :     const OUString aMake = m_pMakeBox->GetSelectEntry();
     355           0 :     GetParentSwLabDlg()->ReplaceGroup( aMake );
     356           0 :     aItem.aLstMake = aMake;
     357             : 
     358           0 :     const sal_Bool   bCont    = m_pContButton->IsChecked();
     359           0 :     const size_t nCount   = GetParentSwLabDlg()->Recs().size();
     360           0 :     size_t nLstType = 0;
     361             : 
     362           0 :     const OUString sCustom(SW_RES(STR_CUSTOM));
     363             :     //insert the entries into the sorted list box
     364           0 :     for ( size_t i = 0; i < nCount; ++i )
     365             :     {
     366           0 :         const OUString aType ( GetParentSwLabDlg()->Recs()[i]->aType );
     367           0 :         bool bInsert = false;
     368           0 :         if ( GetParentSwLabDlg()->Recs()[i]->aType == sCustom )
     369             :         {
     370           0 :             bInsert = true;
     371           0 :             m_pTypeBox->InsertEntry(aType );
     372             :         }
     373           0 :         else if ( GetParentSwLabDlg()->Recs()[i]->bCont == bCont )
     374             :         {
     375           0 :             if ( m_pHiddenSortTypeBox->GetEntryPos(aType) == LISTBOX_ENTRY_NOTFOUND )
     376             :             {
     377           0 :                 bInsert = true;
     378           0 :                 m_pHiddenSortTypeBox->InsertEntry( aType );
     379             :             }
     380             :         }
     381           0 :         if(bInsert)
     382             :         {
     383           0 :             GetParentSwLabDlg()->TypeIds().push_back(i);
     384           0 :             if ( !nLstType && aType == aItem.aLstType )
     385           0 :                 nLstType = GetParentSwLabDlg()->TypeIds().size();
     386             :         }
     387           0 :     }
     388           0 :     for(sal_Int32 nEntry = 0; nEntry < m_pHiddenSortTypeBox->GetEntryCount(); ++nEntry)
     389             :     {
     390           0 :         m_pTypeBox->InsertEntry(m_pHiddenSortTypeBox->GetEntry(nEntry));
     391             :     }
     392           0 :     if (nLstType)
     393           0 :         m_pTypeBox->SelectEntry(aItem.aLstType);
     394             :     else
     395           0 :         m_pTypeBox->SelectEntryPos(0);
     396           0 :     m_pTypeBox->GetSelectHdl().Call(m_pTypeBox);
     397           0 :     return 0;
     398             : }
     399             : 
     400           0 : IMPL_LINK_NOARG_INLINE_START(SwLabPage, TypeHdl)
     401             : {
     402           0 :     DisplayFormat();
     403           0 :     aItem.aType = m_pTypeBox->GetSelectEntry();
     404           0 :     return 0;
     405             : }
     406           0 : IMPL_LINK_NOARG_INLINE_END(SwLabPage, TypeHdl)
     407             : 
     408           0 : void SwLabPage::DisplayFormat()
     409             : {
     410           0 :     MetricField aField(this, WinBits(0));
     411           0 :     FieldUnit aMetric = ::GetDfltMetric(sal_False);
     412           0 :     SetMetric(aField, aMetric);
     413           0 :     aField.SetDecimalDigits(2);
     414           0 :     aField.SetMin         (0);
     415           0 :     aField.SetMax         (LONG_MAX);
     416             : 
     417           0 :     SwLabRec* pRec = GetSelectedEntryPos();
     418           0 :     aItem.aLstType = pRec->aType;
     419           0 :     SETFLDVAL(aField, pRec->lWidth);
     420           0 :     aField.Reformat();
     421           0 :     const OUString aWString = aField.GetText();
     422             : 
     423           0 :     SETFLDVAL(aField, pRec->lHeight);
     424           0 :     aField.Reformat();
     425             : 
     426           0 :     OUString aText = pRec->aType + ": " + aWString +
     427           0 :            " x " + aField.GetText() +
     428           0 :            " (" + OUString::number( pRec->nCols ) +
     429           0 :            " x " + OUString::number( pRec->nRows ) + ")";
     430           0 :     m_pFormatInfo->SetText(aText);
     431           0 : }
     432             : 
     433           0 : SwLabRec* SwLabPage::GetSelectedEntryPos()
     434             : {
     435           0 :     OUString sSelEntry(m_pTypeBox->GetSelectEntry());
     436             : 
     437           0 :     return GetParentSwLabDlg()->GetRecord(sSelEntry, m_pContButton->IsChecked());
     438             : }
     439             : 
     440           0 : void SwLabPage::InitDatabaseBox()
     441             : {
     442           0 :     if( GetNewDBMgr() )
     443             :     {
     444           0 :         m_pDatabaseLB->Clear();
     445           0 :         ::com::sun::star::uno::Sequence<OUString> aDataNames = SwNewDBMgr::GetExistingDatabaseNames();
     446           0 :         const OUString* pDataNames = aDataNames.getConstArray();
     447           0 :         for (long i = 0; i < aDataNames.getLength(); i++)
     448           0 :             m_pDatabaseLB->InsertEntry(pDataNames[i]);
     449           0 :         OUString sDBName = sActDBName.getToken( 0, DB_DELIM );
     450           0 :         OUString sTableName = sActDBName.getToken( 1, DB_DELIM );
     451           0 :         m_pDatabaseLB->SelectEntry(sDBName);
     452           0 :         if( !sDBName.isEmpty() && GetNewDBMgr()->GetTableNames(m_pTableLB, sDBName))
     453             :         {
     454           0 :             m_pTableLB->SelectEntry(sTableName);
     455           0 :             GetNewDBMgr()->GetColumnNames(m_pDBFieldLB, sActDBName, sTableName);
     456             :         }
     457             :         else
     458           0 :             m_pDBFieldLB->Clear();
     459             :     }
     460           0 : }
     461             : 
     462           0 : SfxTabPage* SwLabPage::Create(Window* pParent, const SfxItemSet& rSet)
     463             : {
     464           0 :     return new SwLabPage(pParent, rSet);
     465             : }
     466             : 
     467           0 : void SwLabPage::ActivatePage(const SfxItemSet& rSet)
     468             : {
     469           0 :     Reset( rSet );
     470           0 : }
     471             : 
     472           0 : int SwLabPage::DeactivatePage(SfxItemSet* _pSet)
     473             : {
     474           0 :     if (_pSet)
     475           0 :         FillItemSet(*_pSet);
     476             : 
     477           0 :     return sal_True;
     478             : }
     479             : 
     480           0 : void SwLabPage::FillItem(SwLabItem& rItem)
     481             : {
     482           0 :     rItem.bAddr    = m_pAddrBox->IsChecked();
     483           0 :     rItem.aWriting = m_pWritingEdit->GetText();
     484           0 :     rItem.bCont    = m_pContButton->IsChecked();
     485           0 :     rItem.aMake    = m_pMakeBox->GetSelectEntry();
     486           0 :     rItem.aType    = m_pTypeBox->GetSelectEntry();
     487           0 :     rItem.sDBName  = sActDBName;
     488             : 
     489           0 :     SwLabRec* pRec = GetSelectedEntryPos();
     490           0 :     pRec->FillItem( rItem );
     491             : 
     492           0 :     rItem.aLstMake = m_pMakeBox->GetSelectEntry();
     493           0 :     rItem.aLstType = m_pTypeBox->GetSelectEntry();
     494           0 : }
     495             : 
     496           0 : bool SwLabPage::FillItemSet(SfxItemSet& rSet)
     497             : {
     498           0 :     FillItem( aItem );
     499           0 :     rSet.Put( aItem );
     500             : 
     501           0 :     return true;
     502             : }
     503             : 
     504           0 : void SwLabPage::Reset(const SfxItemSet& rSet)
     505             : {
     506           0 :     aItem = (const SwLabItem&) rSet.Get(FN_LABEL);
     507           0 :     OUString sDBName  = aItem.sDBName;
     508             : 
     509           0 :     OUString aWriting(convertLineEnd(aItem.aWriting, GetSystemLineEnd()));
     510             : 
     511           0 :     m_pAddrBox->Check( aItem.bAddr );
     512           0 :     m_pWritingEdit->SetText    ( aWriting );
     513             : 
     514           0 :     for(std::vector<OUString>::const_iterator i = GetParentSwLabDlg()->Makes().begin(); i != GetParentSwLabDlg()->Makes().end(); ++i)
     515             :     {
     516           0 :         if(m_pMakeBox->GetEntryPos(OUString(*i)) == LISTBOX_ENTRY_NOTFOUND)
     517           0 :             m_pMakeBox->InsertEntry(*i);
     518             :     }
     519             : 
     520           0 :     m_pMakeBox->SelectEntry( aItem.aMake );
     521             :     //save the current type
     522           0 :     OUString sType(aItem.aType);
     523           0 :     m_pMakeBox->GetSelectHdl().Call(m_pMakeBox);
     524           0 :     aItem.aType = sType;
     525             :     //#102806# a newly added make may not be in the type ListBox already
     526           0 :     if (m_pTypeBox->GetEntryPos(aItem.aType) == LISTBOX_ENTRY_NOTFOUND && !aItem.aMake.isEmpty())
     527           0 :         GetParentSwLabDlg()->UpdateGroup( aItem.aMake );
     528           0 :     if (m_pTypeBox->GetEntryPos(aItem.aType) != LISTBOX_ENTRY_NOTFOUND)
     529             :     {
     530           0 :         m_pTypeBox->SelectEntry(aItem.aType);
     531           0 :         m_pTypeBox->GetSelectHdl().Call(m_pTypeBox);
     532             :     }
     533           0 :     if (m_pDatabaseLB->GetEntryPos(sDBName) != LISTBOX_ENTRY_NOTFOUND)
     534             :     {
     535           0 :         m_pDatabaseLB->SelectEntry(sDBName);
     536           0 :         m_pDatabaseLB->GetSelectHdl().Call(m_pDatabaseLB);
     537             :     }
     538             : 
     539           0 :     if (aItem.bCont)
     540           0 :         m_pContButton->Check();
     541             :     else
     542           0 :         m_pSheetButton->Check();
     543           0 : }
     544             : 
     545           0 : void SwVisitingCardPage::ClearUserData()
     546             : {
     547           0 :     SvTreeListEntry* pEntry = m_pAutoTextLB->First();
     548           0 :     while(pEntry)
     549             :     {
     550           0 :         delete (OUString*)pEntry->GetUserData();
     551           0 :         pEntry = m_pAutoTextLB->Next(pEntry);
     552             :     }
     553           0 : }
     554             : 
     555           0 : void SwVisitingCardPage::SetUserData( sal_uInt32 nCnt,
     556             :                 const OUString* pNames, const OUString* pValues )
     557             : {
     558           0 :     for( sal_uInt32 i = 0; i < nCnt; ++i )
     559             :     {
     560           0 :         SvTreeListEntry* pEntry = m_pAutoTextLB->InsertEntry( pNames[ i ] );
     561           0 :         pEntry->SetUserData( new OUString( pValues[ i ] ));
     562             :     }
     563           0 : }
     564             : 
     565           0 : SwVisitingCardPage::SwVisitingCardPage(Window* pParent, const SfxItemSet& rSet)
     566             :     : SfxTabPage(pParent, "CardFormatPage",
     567             :         "modules/swriter/ui/cardformatpage.ui", rSet)
     568           0 :     , pExampleFrame(0)
     569             : {
     570           0 :     get(m_pAutoTextLB, "treeview");
     571           0 :     m_pAutoTextLB->set_height_request(m_pAutoTextLB->GetTextHeight() * 16);
     572           0 :     get(m_pAutoTextGroupLB, "autotext");
     573           0 :     get(m_pExampleWIN, "preview");
     574             : 
     575           0 :     m_pAutoTextLB->SetStyle( m_pAutoTextLB->GetStyle() | WB_HSCROLL );
     576           0 :     m_pAutoTextLB->SetSpaceBetweenEntries(0);
     577           0 :     m_pAutoTextLB->SetSelectionMode( SINGLE_SELECTION );
     578             : 
     579           0 :     SetExchangeSupport();
     580           0 :     m_pAutoTextLB->SetSelectHdl(LINK(this, SwVisitingCardPage, AutoTextSelectHdl));
     581           0 :     m_pAutoTextGroupLB->SetSelectHdl(LINK(this, SwVisitingCardPage, AutoTextSelectHdl));
     582             : 
     583           0 :     m_pExampleWIN->Hide();
     584             : 
     585           0 :     InitFrameControl();
     586           0 : }
     587             : 
     588           0 : SwVisitingCardPage::~SwVisitingCardPage()
     589             : {
     590           0 :     for(sal_Int32 i = 0; i < m_pAutoTextGroupLB->GetEntryCount(); ++i)
     591           0 :         delete (OUString*)m_pAutoTextGroupLB->GetEntryData( i );
     592           0 :     m_xAutoText = 0;
     593             : 
     594           0 :     ClearUserData();
     595           0 :     delete pExampleFrame;
     596           0 : }
     597             : 
     598           0 : SfxTabPage* SwVisitingCardPage::Create(Window* pParent, const SfxItemSet& rSet)
     599             : {
     600           0 :     return new SwVisitingCardPage(pParent, rSet);
     601             : }
     602             : 
     603           0 : void SwVisitingCardPage::ActivatePage(const SfxItemSet& rSet)
     604             : {
     605           0 :     Reset( rSet );
     606           0 :     UpdateFields();
     607           0 : }
     608             : 
     609           0 : int  SwVisitingCardPage::DeactivatePage(SfxItemSet* _pSet)
     610             : {
     611           0 :     if (_pSet)
     612           0 :         FillItemSet(*_pSet);
     613           0 :     return LEAVE_PAGE;
     614             : }
     615             : 
     616           0 : bool SwVisitingCardPage::FillItemSet(SfxItemSet& rSet)
     617             : {
     618             :     const OUString* pGroup = (const OUString*)m_pAutoTextGroupLB->GetEntryData(
     619           0 :                                     m_pAutoTextGroupLB->GetSelectEntryPos());
     620             :     OSL_ENSURE(pGroup, "no group selected?");
     621             : 
     622           0 :     if (pGroup)
     623           0 :         aLabItem.sGlossaryGroup = *pGroup;
     624             : 
     625           0 :     SvTreeListEntry* pSelEntry = m_pAutoTextLB->FirstSelected();
     626           0 :     if(pSelEntry)
     627           0 :         aLabItem.sGlossaryBlockName = *(OUString*)pSelEntry->GetUserData();
     628           0 :     rSet.Put(aLabItem);
     629           0 :     return true;
     630             : }
     631             : 
     632           0 : static void lcl_SelectBlock(SvTreeListBox& rAutoTextLB, const OUString& rBlockName)
     633             : {
     634           0 :     SvTreeListEntry* pEntry = rAutoTextLB.First();
     635           0 :     while(pEntry)
     636             :     {
     637           0 :         if(*(OUString*)pEntry->GetUserData() == rBlockName)
     638             :         {
     639           0 :             rAutoTextLB.Select(pEntry);
     640           0 :             rAutoTextLB.MakeVisible(pEntry);
     641           0 :             break;
     642             :         }
     643           0 :         pEntry = rAutoTextLB.Next(pEntry);
     644             :     }
     645           0 : }
     646             : 
     647           0 : static bool lcl_FindBlock(SvTreeListBox& rAutoTextLB, const OUString& rBlockName)
     648             : {
     649           0 :     SvTreeListEntry* pEntry = rAutoTextLB.First();
     650           0 :     while(pEntry)
     651             :     {
     652           0 :         if(*(OUString*)pEntry->GetUserData() == rBlockName)
     653             :         {
     654           0 :             rAutoTextLB.Select(pEntry);
     655           0 :             return true;
     656             :         }
     657           0 :         pEntry = rAutoTextLB.Next(pEntry);
     658             :     }
     659           0 :     return false;
     660             : }
     661             : 
     662           0 : void SwVisitingCardPage::Reset(const SfxItemSet& rSet)
     663             : {
     664           0 :     aLabItem = (const SwLabItem&) rSet.Get(FN_LABEL);
     665             : 
     666           0 :     bool bFound = false;
     667             :     sal_Int32 i;
     668           0 :     for(i = 0; i < m_pAutoTextGroupLB->GetEntryCount(); i++)
     669           0 :         if( aLabItem.sGlossaryGroup == *(const OUString*)m_pAutoTextGroupLB->GetEntryData( i ))
     670             :         {
     671           0 :             bFound = true;
     672           0 :             break;
     673             :         }
     674             : 
     675           0 :     if(!bFound)
     676             :     {
     677             :         // initially search for a group starting with "crd" which is the name of the
     678             :         // business card AutoTexts
     679           0 :         for(i = 0; i < m_pAutoTextGroupLB->GetEntryCount(); i++)
     680           0 :             if (((const OUString*)m_pAutoTextGroupLB->GetEntryData(i))->startsWith("crd"))
     681             :             {
     682           0 :                 bFound = true;
     683           0 :                 break;
     684             :             }
     685             :     }
     686           0 :     if(bFound)
     687             :     {
     688           0 :         if(m_pAutoTextGroupLB->GetSelectEntryPos() != i)
     689             :         {
     690           0 :             m_pAutoTextGroupLB->SelectEntryPos(i);
     691           0 :             AutoTextSelectHdl(m_pAutoTextGroupLB);
     692             :         }
     693           0 :         if(lcl_FindBlock(*m_pAutoTextLB, aLabItem.sGlossaryBlockName))
     694             :         {
     695           0 :             SvTreeListEntry* pSelEntry = m_pAutoTextLB->FirstSelected();
     696           0 :             if( pSelEntry &&
     697           0 :                 *(OUString*)pSelEntry->GetUserData() != aLabItem.sGlossaryBlockName)
     698             :             {
     699           0 :                 lcl_SelectBlock(*m_pAutoTextLB, aLabItem.sGlossaryBlockName);
     700           0 :                 AutoTextSelectHdl(m_pAutoTextLB);
     701             :             }
     702             :         }
     703             :     }
     704           0 : }
     705             : 
     706           0 : SwPrivateDataPage::SwPrivateDataPage(Window* pParent, const SfxItemSet& rSet)
     707             :     : SfxTabPage(pParent, "PrivateUserPage",
     708           0 :         "modules/swriter/ui/privateuserpage.ui", rSet)
     709             : {
     710           0 :     get(m_pFirstNameED, "firstname");
     711           0 :     get(m_pNameED, "lastname");
     712           0 :     get(m_pShortCutED, "shortname");
     713           0 :     get(m_pFirstName2ED, "firstname2");
     714           0 :     get(m_pName2ED, "lastname2");
     715           0 :     get(m_pShortCut2ED, "shortname2");
     716           0 :     get(m_pStreetED, "street");
     717           0 :     get(m_pZipED, "izip");
     718           0 :     get(m_pCityED, "icity");
     719           0 :     get(m_pCountryED, "country");
     720           0 :     get(m_pStateED, "state");
     721           0 :     get(m_pTitleED, "title");
     722           0 :     get(m_pProfessionED, "job");
     723           0 :     get(m_pPhoneED, "phone");
     724           0 :     get(m_pMobilePhoneED, "mobile");
     725           0 :     get(m_pFaxED, "fax");
     726           0 :     get(m_pHomePageED, "url");
     727           0 :     get(m_pMailED, "email");
     728             : 
     729           0 :     SetExchangeSupport();
     730           0 : }
     731             : 
     732           0 : SfxTabPage* SwPrivateDataPage::Create(Window* pParent, const SfxItemSet& rSet)
     733             : {
     734           0 :     return new SwPrivateDataPage(pParent, rSet);
     735             : }
     736             : 
     737           0 : void SwPrivateDataPage::ActivatePage(const SfxItemSet& rSet)
     738             : {
     739           0 :     Reset(rSet);
     740           0 : }
     741             : 
     742           0 : int  SwPrivateDataPage::DeactivatePage(SfxItemSet* _pSet)
     743             : {
     744           0 :     if (_pSet)
     745           0 :         FillItemSet(*_pSet);
     746           0 :     return LEAVE_PAGE;
     747             : }
     748             : 
     749           0 : bool SwPrivateDataPage::FillItemSet(SfxItemSet& rSet)
     750             : {
     751             : 
     752           0 :     SwLabItem aItem = (const SwLabItem&) GetTabDialog()->GetExampleSet()->Get(FN_LABEL);
     753           0 :     aItem.aPrivFirstName = m_pFirstNameED->GetText();
     754           0 :     aItem.aPrivName      = m_pNameED->GetText(  );
     755           0 :     aItem.aPrivShortCut  = m_pShortCutED->GetText(  );
     756           0 :     aItem.aPrivFirstName2 = m_pFirstName2ED->GetText();
     757           0 :     aItem.aPrivName2     = m_pName2ED->GetText(  );
     758           0 :     aItem.aPrivShortCut2 = m_pShortCut2ED->GetText(  );
     759           0 :     aItem.aPrivStreet    = m_pStreetED->GetText(  );
     760           0 :     aItem.aPrivZip       = m_pZipED->GetText(  );
     761           0 :     aItem.aPrivCity      = m_pCityED->GetText(  );
     762           0 :     aItem.aPrivCountry   = m_pCountryED->GetText(  );
     763           0 :     aItem.aPrivState     = m_pStateED->GetText(  );
     764           0 :     aItem.aPrivTitle     = m_pTitleED->GetText(  );
     765           0 :     aItem.aPrivProfession= m_pProfessionED->GetText(   );
     766           0 :     aItem.aPrivPhone     = m_pPhoneED->GetText(  );
     767           0 :     aItem.aPrivMobile    = m_pMobilePhoneED->GetText(  );
     768           0 :     aItem.aPrivFax       = m_pFaxED->GetText(  );
     769           0 :     aItem.aPrivWWW       = m_pHomePageED->GetText(  );
     770           0 :     aItem.aPrivMail      = m_pMailED->GetText(  );
     771             : 
     772           0 :     rSet.Put(aItem);
     773           0 :     return true;
     774             : }
     775             : 
     776           0 : void SwPrivateDataPage::Reset(const SfxItemSet& rSet)
     777             : {
     778           0 :     const SwLabItem& aItem = (const SwLabItem&) rSet.Get(FN_LABEL);
     779           0 :     m_pFirstNameED->SetText(aItem.aPrivFirstName);
     780           0 :     m_pNameED->SetText(aItem.aPrivName);
     781           0 :     m_pShortCutED->SetText(aItem.aPrivShortCut);
     782           0 :     m_pFirstName2ED->SetText(aItem.aPrivFirstName2);
     783           0 :     m_pName2ED->SetText(aItem.aPrivName2);
     784           0 :     m_pShortCut2ED->SetText(aItem.aPrivShortCut2);
     785           0 :     m_pStreetED->SetText(aItem.aPrivStreet);
     786           0 :     m_pZipED->SetText(aItem.aPrivZip);
     787           0 :     m_pCityED->SetText(aItem.aPrivCity);
     788           0 :     m_pCountryED->SetText(aItem.aPrivCountry);
     789           0 :     m_pStateED->SetText(aItem.aPrivState);
     790           0 :     m_pTitleED->SetText(aItem.aPrivTitle);
     791           0 :     m_pProfessionED->SetText(aItem.aPrivProfession);
     792           0 :     m_pPhoneED->SetText(aItem.aPrivPhone);
     793           0 :     m_pMobilePhoneED->SetText(aItem.aPrivMobile);
     794           0 :     m_pFaxED->SetText(aItem.aPrivFax);
     795           0 :     m_pHomePageED->SetText(aItem.aPrivWWW);
     796           0 :     m_pMailED->SetText(aItem.aPrivMail);
     797           0 : }
     798             : 
     799           0 : SwBusinessDataPage::SwBusinessDataPage(Window* pParent, const SfxItemSet& rSet)
     800             :     : SfxTabPage(pParent, "BusinessDataPage",
     801           0 :         "modules/swriter/ui/businessdatapage.ui", rSet)
     802             : {
     803           0 :     get(m_pCompanyED, "company");
     804           0 :     get(m_pCompanyExtED, "company2");
     805           0 :     get(m_pSloganED, "slogan");
     806           0 :     get(m_pStreetED, "street");
     807           0 :     get(m_pZipED, "izip");
     808           0 :     get(m_pCityED, "icity");
     809           0 :     get(m_pCountryED, "country");
     810           0 :     get(m_pStateED, "state");
     811           0 :     get(m_pPositionED, "position");
     812           0 :     get(m_pPhoneED, "phone");
     813           0 :     get(m_pMobilePhoneED, "mobile");
     814           0 :     get(m_pFaxED, "fax");
     815           0 :     get(m_pHomePageED, "url");
     816           0 :     get(m_pMailED, "email");
     817           0 :     SetExchangeSupport();
     818           0 : }
     819             : 
     820           0 : SfxTabPage* SwBusinessDataPage::Create(Window* pParent, const SfxItemSet& rSet)
     821             : {
     822           0 :     return new SwBusinessDataPage(pParent, rSet);
     823             : }
     824             : 
     825           0 : void SwBusinessDataPage::ActivatePage(const SfxItemSet& rSet)
     826             : {
     827           0 :     Reset(rSet);
     828           0 : }
     829             : 
     830           0 : int  SwBusinessDataPage::DeactivatePage(SfxItemSet* _pSet)
     831             : {
     832           0 :     if (_pSet)
     833           0 :         FillItemSet(*_pSet);
     834           0 :     return LEAVE_PAGE;
     835             : }
     836             : 
     837           0 : bool SwBusinessDataPage::FillItemSet(SfxItemSet& rSet)
     838             : {
     839           0 :     SwLabItem aItem = (const SwLabItem&) GetTabDialog()->GetExampleSet()->Get(FN_LABEL);
     840             : 
     841           0 :     aItem.aCompCompany   = m_pCompanyED->GetText();
     842           0 :     aItem.aCompCompanyExt= m_pCompanyExtED->GetText();
     843           0 :     aItem.aCompSlogan    = m_pSloganED->GetText();
     844           0 :     aItem.aCompStreet    = m_pStreetED->GetText();
     845           0 :     aItem.aCompZip       = m_pZipED->GetText();
     846           0 :     aItem.aCompCity      = m_pCityED->GetText();
     847           0 :     aItem.aCompCountry   = m_pCountryED->GetText();
     848           0 :     aItem.aCompState     = m_pStateED->GetText();
     849           0 :     aItem.aCompPosition  = m_pPositionED->GetText();
     850           0 :     aItem.aCompPhone     = m_pPhoneED->GetText();
     851           0 :     aItem.aCompMobile    = m_pMobilePhoneED->GetText();
     852           0 :     aItem.aCompFax       = m_pFaxED->GetText();
     853           0 :     aItem.aCompWWW       = m_pHomePageED->GetText();
     854           0 :     aItem.aCompMail      = m_pMailED->GetText();
     855             : 
     856           0 :     rSet.Put(aItem);
     857           0 :     return true;
     858             : }
     859             : 
     860           0 : void SwBusinessDataPage::Reset(const SfxItemSet& rSet)
     861             : {
     862           0 :     const SwLabItem& aItem = (const SwLabItem&) rSet.Get(FN_LABEL);
     863           0 :     m_pCompanyED->SetText(aItem.aCompCompany);
     864           0 :     m_pCompanyExtED->SetText(aItem.aCompCompanyExt);
     865           0 :     m_pSloganED->SetText(aItem.aCompSlogan);
     866           0 :     m_pStreetED->SetText(aItem.aCompStreet);
     867           0 :     m_pZipED->SetText(aItem.aCompZip);
     868           0 :     m_pCityED->SetText(aItem.aCompCity);
     869           0 :     m_pCountryED->SetText(aItem.aCompCountry);
     870           0 :     m_pStateED->SetText(aItem.aCompState);
     871           0 :     m_pPositionED->SetText(aItem.aCompPosition);
     872           0 :     m_pPhoneED->SetText(aItem.aCompPhone);
     873           0 :     m_pMobilePhoneED->SetText(aItem.aCompMobile);
     874           0 :     m_pFaxED->SetText(aItem.aCompFax);
     875           0 :     m_pHomePageED->SetText(aItem.aCompWWW);
     876           0 :     m_pMailED->SetText(aItem.aCompMail);
     877           0 : }
     878             : 
     879             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10