LCOV - code coverage report
Current view: top level - sw/source/ui/fldui - flddok.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 346 0.0 %
Date: 2014-04-11 Functions: 0 18 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/svapp.hxx>
      21             : #include <flddat.hxx>
      22             : #include <docufld.hxx>
      23             : #include <globals.hrc>
      24             : #include <chpfld.hxx>
      25             : #include <fldui.hrc>
      26             : #include <flddok.hxx>
      27             : #include <swmodule.hxx>
      28             : #include <view.hxx>
      29             : #include <wrtsh.hxx>
      30             : #include <svl/zformat.hxx>
      31             : 
      32             : #include <index.hrc>
      33             : 
      34             : #define USER_DATA_VERSION_1 "1"
      35             : #define USER_DATA_VERSION USER_DATA_VERSION_1
      36             : 
      37           0 : SwFldDokPage::SwFldDokPage(Window* pParent, const SfxItemSet& rCoreSet )
      38             :     : SwFldPage(pParent, "FldDocumentPage",
      39           0 :         "modules/swriter/ui/flddocumentpage.ui", rCoreSet)
      40             : {
      41           0 :     get(m_pSelection, "selectframe");
      42           0 :     get(m_pFormat, "formatframe");
      43           0 :     get(m_pTypeLB, "type");
      44           0 :     m_pTypeLB->SetStyle(m_pTypeLB->GetStyle() | WB_SORT);
      45           0 :     get(m_pSelectionLB, "select");
      46           0 :     get(m_pValueFT, "valueft");
      47           0 :     get(m_pValueED, "value");
      48           0 :     get(m_pLevelFT, "levelft");
      49           0 :     get(m_pLevelED, "level");
      50           0 :     get(m_pDateFT, "daysft");
      51           0 :     get(m_pTimeFT, "minutesft");
      52           0 :     get(m_pDateOffsetED, "offset");
      53           0 :     get(m_pFormatLB, "format");
      54           0 :     m_pFormatLB->SetStyle(m_pFormatLB->GetStyle() | WB_SORT);
      55           0 :     get(m_pNumFormatLB, "numformat");
      56           0 :     get(m_pFixedCB, "fixed");
      57             : 
      58           0 :     long nHeight = m_pTypeLB->GetTextHeight() * 20;
      59           0 :     m_pTypeLB->set_height_request(nHeight);
      60           0 :     m_pSelectionLB->set_height_request(nHeight);
      61           0 :     m_pFormatLB->set_height_request(nHeight);
      62             : 
      63           0 :     long nWidth = m_pTypeLB->LogicToPixel(Size(FIELD_COLUMN_WIDTH, 0), MapMode(MAP_APPFONT)).Width();
      64           0 :     m_pTypeLB->set_width_request(nWidth);
      65           0 :     m_pSelectionLB->set_width_request(nWidth);
      66           0 :     m_pFormatLB->set_width_request(nWidth);
      67             : 
      68           0 :     m_pSelectionLB->SetDoubleClickHdl(LINK(this, SwFldDokPage, InsertHdl));
      69           0 :     m_pFormatLB->SetDoubleClickHdl(LINK(this, SwFldDokPage, InsertHdl));
      70           0 :     m_pNumFormatLB->SetDoubleClickHdl(LINK(this, SwFldDokPage, NumFormatHdl));
      71             : 
      72           0 :     m_pLevelED->SetMax(MAXLEVEL);
      73           0 :     m_pDateOffsetED->SetMin(LONG_MIN);
      74           0 :     m_pDateOffsetED->SetMax(LONG_MAX);
      75             :     //enable 'active' language selection
      76           0 :     m_pNumFormatLB->SetShowLanguageControl(sal_True);
      77           0 : }
      78             : 
      79           0 : SwFldDokPage::~SwFldDokPage()
      80             : {
      81           0 : }
      82             : 
      83           0 : void SwFldDokPage::Reset(const SfxItemSet& )
      84             : {
      85           0 :     SavePos(m_pTypeLB);
      86           0 :     Init(); // general initialisation
      87             : 
      88             :     // initialise TypeListBox
      89           0 :     const SwFldGroupRgn& rRg = GetFldMgr().GetGroupRange(IsFldDlgHtmlMode(), GetGroup());
      90             : 
      91           0 :     m_pTypeLB->SetUpdateMode(false);
      92           0 :     m_pTypeLB->Clear();
      93             : 
      94             :     sal_Int32 nPos;
      95             : 
      96           0 :     if (!IsFldEdit())
      97             :     {
      98           0 :         bool bPage = false;
      99             :         // fill Type-Listbox
     100           0 :         for(sal_uInt16 i = rRg.nStart; i < rRg.nEnd; ++i)
     101             :         {
     102           0 :             const sal_uInt16 nTypeId = GetFldMgr().GetTypeId(i);
     103             : 
     104           0 :             switch (nTypeId)
     105             :             {
     106             :                 case TYP_PREVPAGEFLD:
     107             :                 case TYP_NEXTPAGEFLD:
     108             :                 case TYP_PAGENUMBERFLD:
     109           0 :                     if (!bPage)
     110             :                     {
     111           0 :                         nPos = m_pTypeLB->InsertEntry(SW_RESSTR(FMT_REF_PAGE));
     112           0 :                         m_pTypeLB->SetEntryData(nPos, (void*)USHRT_MAX);
     113           0 :                         bPage = true;
     114             :                     }
     115           0 :                     break;
     116             : 
     117             :                 default:
     118           0 :                     nPos = m_pTypeLB->InsertEntry(GetFldMgr().GetTypeStr(i));
     119           0 :                     m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
     120           0 :                     break;
     121             :             }
     122             :         }
     123             :     }
     124             :     else
     125             :     {
     126           0 :         const SwField* pCurField = GetCurField();
     127           0 :         sal_uInt16 nTypeId = pCurField->GetTypeId();
     128           0 :         if (nTypeId == TYP_FIXDATEFLD)
     129           0 :             nTypeId = TYP_DATEFLD;
     130           0 :         if (nTypeId == TYP_FIXTIMEFLD)
     131           0 :             nTypeId = TYP_TIMEFLD;
     132           0 :         nPos = m_pTypeLB->InsertEntry(GetFldMgr().GetTypeStr(GetFldMgr().GetPos(nTypeId)));
     133           0 :         m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
     134           0 :         m_pNumFormatLB->SetAutomaticLanguage(pCurField->IsAutomaticLanguage());
     135           0 :         SwWrtShell *pSh = GetWrtShell();
     136           0 :         if(!pSh)
     137           0 :             pSh = ::GetActiveWrtShell();
     138           0 :         if(pSh)
     139             :         {
     140           0 :             const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetFormat());
     141           0 :             if(pFormat)
     142           0 :                 m_pNumFormatLB->SetLanguage(pFormat->GetLanguage());
     143             :         }
     144             :     }
     145             : 
     146             :     // select old Pos
     147           0 :     RestorePos(m_pTypeLB);
     148             : 
     149           0 :     m_pTypeLB->SetUpdateMode(true);
     150           0 :     m_pTypeLB->SetDoubleClickHdl(LINK(this, SwFldDokPage, InsertHdl));
     151           0 :     m_pTypeLB->SetSelectHdl(LINK(this, SwFldDokPage, TypeHdl));
     152           0 :     m_pFormatLB->SetSelectHdl(LINK(this, SwFldDokPage, FormatHdl));
     153             : 
     154           0 :     if( !IsRefresh() )
     155             :     {
     156           0 :         const OUString sUserData = GetUserData();
     157           0 :         if (sUserData.getToken(0, ';').equalsIgnoreAsciiCase(USER_DATA_VERSION_1))
     158             :         {
     159           0 :             const OUString sVal = sUserData.getToken(1, ';');
     160           0 :             const sal_uInt16 nVal = static_cast< sal_uInt16 >(sVal.toInt32());
     161           0 :             if(nVal != USHRT_MAX)
     162             :             {
     163           0 :                 for(sal_Int32 i = 0; i < m_pTypeLB->GetEntryCount(); i++)
     164           0 :                     if(nVal == (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(i))
     165             :                     {
     166           0 :                         m_pTypeLB->SelectEntryPos(i);
     167           0 :                         break;
     168             :                     }
     169           0 :             }
     170           0 :         }
     171             :     }
     172           0 :     TypeHdl(0);
     173             : 
     174           0 :     if (IsFldEdit())
     175             :     {
     176           0 :         nOldSel = m_pSelectionLB->GetSelectEntryPos();
     177           0 :         nOldFormat = GetCurField()->GetFormat();
     178           0 :         m_pFixedCB->SaveValue();
     179           0 :         m_pValueED->SaveValue();
     180           0 :         m_pLevelED->SaveValue();
     181           0 :         m_pDateOffsetED->SaveValue();
     182             :     }
     183           0 : }
     184             : 
     185           0 : IMPL_LINK_NOARG(SwFldDokPage, TypeHdl)
     186             : {
     187             :     // save old ListBoxPos
     188           0 :     const sal_Int32 nOld = GetTypeSel();
     189             : 
     190             :     // current ListBoxPos
     191           0 :     SetTypeSel(m_pTypeLB->GetSelectEntryPos());
     192             : 
     193           0 :     if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND)
     194             :     {
     195           0 :         SetTypeSel(0);
     196           0 :         m_pTypeLB->SelectEntryPos(0);
     197             :     }
     198             : 
     199             :     size_t nCount;
     200             : 
     201           0 :     if (nOld != GetTypeSel())
     202             :     {
     203           0 :         m_pDateFT->Hide();
     204           0 :         m_pTimeFT->Hide();
     205             : 
     206           0 :         sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
     207             : 
     208             :         // fill Selection-Listbox
     209           0 :         m_pSelectionLB->Clear();
     210             : 
     211           0 :         if (nTypeId != USHRT_MAX)
     212             :         {
     213           0 :             std::vector<OUString> aLst;
     214           0 :             GetFldMgr().GetSubTypes(nTypeId, aLst);
     215             : 
     216           0 :             if (nTypeId != TYP_AUTHORFLD)
     217           0 :                 nCount = aLst.size();
     218             :             else
     219           0 :                 nCount = GetFldMgr().GetFormatCount(nTypeId, false, IsFldDlgHtmlMode());
     220             : 
     221             :             size_t nPos;
     222             : 
     223           0 :             for(size_t i = 0; i < nCount; ++i)
     224             :             {
     225           0 :                 if (!IsFldEdit())
     226             :                 {
     227           0 :                     if (nTypeId != TYP_AUTHORFLD)
     228           0 :                         nPos = m_pSelectionLB->InsertEntry(aLst[i]);
     229             :                     else
     230           0 :                         nPos = m_pSelectionLB->InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i));
     231             : 
     232           0 :                     m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i));
     233             :                 }
     234             :                 else
     235             :                 {
     236           0 :                     bool bInsert = false;
     237             : 
     238           0 :                     switch (nTypeId)
     239             :                     {
     240             :                         case TYP_DATEFLD:
     241             :                         case TYP_TIMEFLD:
     242           0 :                             nPos = m_pSelectionLB->InsertEntry(aLst[i]);
     243           0 :                             m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i));
     244           0 :                             if (((SwDateTimeField*)GetCurField())->IsFixed() && !i)
     245           0 :                                 m_pSelectionLB->SelectEntryPos(nPos);
     246           0 :                             if (!((SwDateTimeField*)GetCurField())->IsFixed() && i)
     247           0 :                                 m_pSelectionLB->SelectEntryPos(nPos);
     248           0 :                             break;
     249             : 
     250             :                         case TYP_EXTUSERFLD:
     251             :                         case TYP_DOCSTATFLD:
     252           0 :                             nPos = m_pSelectionLB->InsertEntry(aLst[i]);
     253           0 :                             m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i));
     254           0 :                             if (GetCurField()->GetSubType() == i)
     255           0 :                                 m_pSelectionLB->SelectEntryPos(nPos);
     256           0 :                             break;
     257             : 
     258             :                         case TYP_AUTHORFLD:
     259             :                         {
     260           0 :                             const OUString sFmt(GetFldMgr().GetFormatStr(nTypeId, i));
     261           0 :                             nPos = m_pSelectionLB->InsertEntry(sFmt);
     262           0 :                             m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i));
     263           0 :                             m_pSelectionLB->SelectEntry(GetFldMgr().GetFormatStr(nTypeId, GetCurField()->GetFormat()));
     264           0 :                             break;
     265             :                         }
     266             : 
     267             :                         default:
     268           0 :                             if (aLst[i] == GetCurField()->GetPar1())
     269           0 :                                 bInsert = true;
     270           0 :                             break;
     271             :                     }
     272           0 :                     if (bInsert)
     273             :                     {
     274           0 :                         nPos = m_pSelectionLB->InsertEntry(aLst[i]);
     275           0 :                         m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i));
     276           0 :                         break;
     277             :                     }
     278             :                 }
     279             :             }
     280           0 :             m_pSelectionLB->SetSelectHdl(Link());
     281             :         }
     282             :         else
     283             :         {
     284           0 :             AddSubType(TYP_PAGENUMBERFLD);
     285           0 :             AddSubType(TYP_PREVPAGEFLD);
     286           0 :             AddSubType(TYP_NEXTPAGEFLD);
     287           0 :             nTypeId = (sal_uInt16)(sal_uLong)m_pSelectionLB->GetEntryData(0);
     288           0 :             nCount = 3;
     289           0 :             m_pSelectionLB->SetSelectHdl(LINK(this, SwFldDokPage, SubTypeHdl));
     290             :         }
     291             : 
     292           0 :         sal_Bool bEnable = nCount != 0;
     293             : 
     294           0 :         if (bEnable && !m_pSelectionLB->GetSelectEntryCount())
     295           0 :             m_pSelectionLB->SelectEntryPos(0);
     296             : 
     297           0 :         m_pSelection->Enable( bEnable );
     298             : 
     299             :         // fill Format-Listbox
     300           0 :         sal_Int32 nSize = FillFormatLB(nTypeId);
     301             : 
     302           0 :         sal_Bool bValue = sal_False, bLevel = sal_False, bNumFmt = sal_False, bOffset = sal_False;
     303           0 :         sal_Bool bFormat = nSize != 0;
     304           0 :         sal_Bool bOneArea = sal_False;
     305           0 :         sal_Bool bFixed = sal_False;
     306           0 :         sal_uInt16 nFmtType = 0;
     307             : 
     308           0 :         switch (nTypeId)
     309             :         {
     310             :             case TYP_DATEFLD:
     311           0 :                 bFormat = bNumFmt = bOneArea = bOffset = sal_True;
     312             : 
     313           0 :                 nFmtType = NUMBERFORMAT_DATE;
     314             : 
     315           0 :                 m_pDateFT->Show();
     316             : 
     317           0 :                 m_pDateOffsetED->SetFirst(-31);    // one month
     318           0 :                 m_pDateOffsetED->SetLast(31);
     319             : 
     320           0 :                 if (IsFldEdit())
     321           0 :                     m_pDateOffsetED->SetValue( ((SwDateTimeField*)GetCurField())->GetOffset() / 24 / 60);
     322           0 :                 break;
     323             : 
     324             :             case TYP_TIMEFLD:
     325           0 :                 bFormat = bNumFmt = bOneArea = bOffset = sal_True;
     326             : 
     327           0 :                 nFmtType = NUMBERFORMAT_TIME;
     328             : 
     329           0 :                 m_pTimeFT->Show();
     330             : 
     331           0 :                 m_pDateOffsetED->SetFirst(-1440);  // one day
     332           0 :                 m_pDateOffsetED->SetLast(1440);
     333             : 
     334           0 :                 if (IsFldEdit())
     335           0 :                     m_pDateOffsetED->SetValue( ((SwDateTimeField*)GetCurField())->GetOffset() );
     336           0 :                 break;
     337             : 
     338             :             case TYP_PREVPAGEFLD:
     339             :             case TYP_NEXTPAGEFLD:
     340           0 :                 if (IsFldEdit())
     341             :                 {
     342             :                     const sal_uInt16 nTmp = (sal_uInt16)(sal_uLong)m_pFormatLB->GetEntryData(
     343           0 :                                             m_pFormatLB->GetSelectEntryPos() );
     344             : 
     345           0 :                     if(SVX_NUM_CHAR_SPECIAL != nTmp)
     346             :                     {
     347           0 :                         sal_Int32 nOff = GetCurField()->GetPar2().toInt32();
     348           0 :                         if( TYP_NEXTPAGEFLD == nTypeId && 1 != nOff )
     349             :                             m_pValueED->SetText(
     350           0 :                                 OUString::number(nOff - 1) );
     351           0 :                         else if( TYP_PREVPAGEFLD == nTypeId && -1 != nOff )
     352             :                             m_pValueED->SetText(
     353           0 :                                 OUString::number(nOff + 1) );
     354             :                         else
     355           0 :                             m_pValueED->SetText(aEmptyOUStr);
     356             :                     }
     357             :                     else
     358           0 :                         m_pValueED->SetText(((SwPageNumberField*)GetCurField())->GetUserString());
     359             :                 }
     360           0 :                 bValue = sal_True;
     361           0 :                 break;
     362             : 
     363             :             case TYP_CHAPTERFLD:
     364           0 :                 m_pValueFT->SetText(SW_RESSTR(STR_LEVEL));
     365           0 :                 if (IsFldEdit())
     366           0 :                     m_pLevelED->SetText(OUString::number(((SwChapterField*)GetCurField())->GetLevel() + 1));
     367           0 :                 bLevel = sal_True;
     368           0 :                 break;
     369             : 
     370             :             case TYP_PAGENUMBERFLD:
     371           0 :                 m_pValueFT->SetText( SW_RESSTR( STR_OFFSET ));
     372           0 :                 if (IsFldEdit())
     373           0 :                     m_pValueED->SetText(GetCurField()->GetPar2());
     374           0 :                 bValue = sal_True;
     375           0 :                 break;
     376             : 
     377             :             case TYP_EXTUSERFLD:
     378             :             case TYP_AUTHORFLD:
     379             :             case TYP_FILENAMEFLD:
     380           0 :                 bFixed = sal_True;
     381           0 :                 break;
     382             : 
     383             :             default:
     384           0 :                 break;
     385             :         }
     386             : 
     387           0 :         if (bNumFmt)
     388             :         {
     389           0 :             if (IsFldEdit())
     390             :             {
     391           0 :                 m_pNumFormatLB->SetDefFormat(GetCurField()->GetFormat());
     392             : 
     393           0 :                 if (m_pNumFormatLB->GetFormatType() == (NUMBERFORMAT_DATE|NUMBERFORMAT_TIME))
     394             :                 {
     395             :                     // always set Format-Type because otherwise when date/time formats are combined,
     396             :                     // both formats would be displayed at the same time
     397           0 :                     m_pNumFormatLB->SetFormatType(0);
     398           0 :                     m_pNumFormatLB->SetFormatType(nFmtType);
     399             :                     // set correct format once again
     400           0 :                     m_pNumFormatLB->SetDefFormat(GetCurField()->GetFormat());
     401             :                 }
     402             :             }
     403             :             else
     404           0 :                 m_pNumFormatLB->SetFormatType(nFmtType);
     405             : 
     406           0 :             m_pNumFormatLB->SetOneArea(bOneArea);
     407             :         }
     408             : 
     409           0 :         m_pFormatLB->Show(!bNumFmt);
     410           0 :         m_pNumFormatLB->Show(bNumFmt);
     411             : 
     412           0 :         m_pValueFT->Show(bValue);
     413           0 :         m_pValueED->Show(bValue);
     414           0 :         m_pLevelFT->Show(bLevel);
     415           0 :         m_pLevelED->Show(bLevel);
     416           0 :         m_pDateOffsetED->Show(bOffset);
     417           0 :         m_pFixedCB->Show(!bValue && !bLevel && !bOffset);
     418             : 
     419           0 :         m_pFormat->Enable(bFormat);
     420           0 :         m_pFixedCB->Enable(bFixed);
     421             : 
     422           0 :         if (IsFldEdit())
     423           0 :             m_pFixedCB->Check( (GetCurField()->GetFormat() & AF_FIXED) != 0 && bFixed );
     424             : 
     425           0 :         if (m_pNumFormatLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND)
     426           0 :             m_pNumFormatLB->SelectEntryPos(0);
     427           0 :         m_pValueFT->Enable(bValue | bLevel | bOffset);
     428           0 :         m_pValueED->Enable(bValue);
     429             :     }
     430             : 
     431           0 :     return 0;
     432             : }
     433             : 
     434           0 : void SwFldDokPage::AddSubType(sal_uInt16 nTypeId)
     435             : {
     436           0 :     const sal_Int32 nPos = m_pSelectionLB->InsertEntry(SwFieldType::GetTypeStr(nTypeId));
     437           0 :     m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
     438           0 : }
     439             : 
     440           0 : IMPL_LINK_NOARG(SwFldDokPage, SubTypeHdl)
     441             : {
     442           0 :     sal_Int32 nPos = m_pSelectionLB->GetSelectEntryPos();
     443           0 :     if(nPos == LISTBOX_ENTRY_NOTFOUND)
     444           0 :         nPos = 0;
     445             : 
     446           0 :     const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pSelectionLB->GetEntryData(nPos);
     447           0 :     FillFormatLB(nTypeId);
     448             : 
     449           0 :     sal_uInt32 nTextRes = 0;
     450           0 :     switch (nTypeId)
     451             :     {
     452             :     case TYP_CHAPTERFLD:
     453           0 :         nTextRes = STR_LEVEL;
     454           0 :         break;
     455             : 
     456             :     case TYP_PREVPAGEFLD:
     457             :     case TYP_NEXTPAGEFLD:
     458           0 :         nTextRes = SVX_NUM_CHAR_SPECIAL == (sal_uInt16)(sal_uLong)m_pFormatLB->GetEntryData(
     459           0 :                                         m_pFormatLB->GetSelectEntryPos() )
     460           0 :                         ? STR_VALUE : STR_OFFSET;
     461           0 :         break;
     462             : 
     463             :     case TYP_PAGENUMBERFLD:
     464           0 :         nTextRes = STR_OFFSET;
     465           0 :         break;
     466             :     }
     467             : 
     468           0 :     if( nTextRes )
     469           0 :         m_pValueFT->SetText( SW_RESSTR( nTextRes ));
     470             : 
     471           0 :     return 0;
     472             : }
     473             : 
     474           0 : sal_Int32 SwFldDokPage::FillFormatLB(sal_uInt16 nTypeId)
     475             : {
     476             :     // fill Format-Listbox
     477           0 :     m_pFormatLB->Clear();
     478             : 
     479           0 :     if (nTypeId == TYP_AUTHORFLD)
     480           0 :         return m_pFormatLB->GetEntryCount();
     481             : 
     482           0 :     const sal_uInt16 nSize = GetFldMgr().GetFormatCount(nTypeId, false, IsFldDlgHtmlMode());
     483             : 
     484           0 :     for( sal_uInt16 i = 0; i < nSize; ++i )
     485             :     {
     486           0 :         const sal_Int32 nPos = m_pFormatLB->InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i));
     487           0 :         const sal_uInt16 nFmtId = GetFldMgr().GetFormatId( nTypeId, i );
     488           0 :         m_pFormatLB->SetEntryData( nPos, reinterpret_cast<void*>( nFmtId ));
     489           0 :         if (IsFldEdit() && nFmtId == (GetCurField()->GetFormat() & ~AF_FIXED))
     490           0 :             m_pFormatLB->SelectEntryPos( nPos );
     491             :     }
     492             : 
     493           0 :     if( nSize && !m_pFormatLB->GetSelectEntryCount() )
     494             :     {
     495           0 :         m_pFormatLB->SelectEntry( SW_RESSTR(FMT_NUM_PAGEDESC) );
     496           0 :         if( !m_pFormatLB->GetSelectEntryCount() )
     497             :         {
     498           0 :             m_pFormatLB->SelectEntry( SW_RESSTR(FMT_NUM_ARABIC) );
     499           0 :             if( !m_pFormatLB->GetSelectEntryCount() )
     500           0 :                 m_pFormatLB->SelectEntryPos( 0 );
     501             :         }
     502             :     }
     503             : 
     504           0 :     FormatHdl();
     505             : 
     506           0 :     return nSize;
     507             : }
     508             : 
     509           0 : IMPL_LINK_NOARG(SwFldDokPage, FormatHdl)
     510             : {
     511           0 :     sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
     512             : 
     513           0 :     if (nTypeId == USHRT_MAX)
     514             :     {
     515           0 :         sal_Int32 nPos = m_pSelectionLB->GetSelectEntryPos();
     516           0 :         if(nPos == LISTBOX_ENTRY_NOTFOUND)
     517           0 :             nPos = 0;
     518             : 
     519           0 :         nTypeId = (sal_uInt16)(sal_uLong)m_pSelectionLB->GetEntryData(nPos);
     520             :     }
     521             : 
     522           0 :     if (nTypeId == TYP_NEXTPAGEFLD || nTypeId == TYP_PREVPAGEFLD)
     523             :     {
     524             :         // Prev/Next - PageNumFields special treatment:
     525             :         sal_uInt16 nTmp = (sal_uInt16)(sal_uLong)m_pFormatLB->GetEntryData(
     526           0 :                                         m_pFormatLB->GetSelectEntryPos() );
     527           0 :         const OUString sOldTxt( m_pValueFT->GetText() );
     528             :         const OUString sNewTxt( SW_RES( SVX_NUM_CHAR_SPECIAL == nTmp  ? STR_VALUE
     529           0 :                                                          : STR_OFFSET ));
     530             : 
     531           0 :         if( sOldTxt != sNewTxt )
     532           0 :             m_pValueFT->SetText( sNewTxt );
     533             : 
     534           0 :         if (sOldTxt != m_pValueFT->GetText())
     535           0 :             m_pValueED->SetText( aEmptyOUStr );
     536             :     }
     537             : 
     538           0 :     return 0;
     539             : }
     540             : 
     541           0 : bool SwFldDokPage::FillItemSet(SfxItemSet& )
     542             : {
     543           0 :     sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
     544             : 
     545           0 :     if (nTypeId == USHRT_MAX)
     546             :     {
     547           0 :         sal_Int32 nPos = m_pSelectionLB->GetSelectEntryPos();
     548           0 :         if(nPos == LISTBOX_ENTRY_NOTFOUND)
     549           0 :             nPos = 0;
     550           0 :         nTypeId = (sal_uInt16)(sal_uLong)m_pSelectionLB->GetEntryData(nPos);
     551             :     }
     552             : 
     553           0 :     OUString aVal(m_pValueED->GetText());
     554           0 :     sal_uLong nFormat = 0;
     555           0 :     sal_uInt16 nSubType = 0;
     556             : 
     557           0 :     if (m_pFormatLB->IsEnabled())
     558             :     {
     559           0 :         sal_Int32 nPos = m_pFormatLB->GetSelectEntryPos();
     560           0 :         if(nPos != LISTBOX_ENTRY_NOTFOUND)
     561           0 :             nFormat = (sal_uLong)m_pFormatLB->GetEntryData(nPos);
     562             :     }
     563             : 
     564           0 :     if (m_pSelectionLB->IsEnabled())
     565             :     {
     566           0 :         sal_Int32 nPos = m_pSelectionLB->GetSelectEntryPos();
     567           0 :         if(nPos != LISTBOX_ENTRY_NOTFOUND)
     568           0 :             nSubType = (sal_uInt16)(sal_uLong)m_pSelectionLB->GetEntryData(nPos);
     569             :     }
     570             : 
     571           0 :     switch (nTypeId)
     572             :     {
     573             :         case TYP_AUTHORFLD:
     574           0 :             nFormat = nSubType;
     575           0 :             nSubType = 0;
     576             :             // no break!
     577             :         case TYP_EXTUSERFLD:
     578           0 :             nFormat |= m_pFixedCB->IsChecked() ? AF_FIXED : 0;
     579           0 :             break;
     580             : 
     581             :         case TYP_FILENAMEFLD:
     582           0 :             nFormat |= m_pFixedCB->IsChecked() ? FF_FIXED : 0;
     583           0 :             break;
     584             : 
     585             :         case TYP_DATEFLD:
     586             :         case TYP_TIMEFLD:
     587             :         {
     588           0 :             nFormat = m_pNumFormatLB->GetFormat();
     589           0 :             long nVal = static_cast< long >(m_pDateOffsetED->GetValue());
     590           0 :             if (nTypeId == TYP_DATEFLD)
     591           0 :                 aVal = OUString::number(nVal * 60 * 24);
     592             :             else
     593           0 :                 aVal = OUString::number(nVal);
     594           0 :             break;
     595             :         }
     596             : 
     597             :         case TYP_NEXTPAGEFLD:
     598             :         case TYP_PREVPAGEFLD:
     599             :         case TYP_PAGENUMBERFLD:
     600             :         case TYP_GETREFPAGEFLD:
     601             :         {
     602           0 :             if( SVX_NUM_CHAR_SPECIAL != nFormat &&
     603           0 :                 (TYP_PREVPAGEFLD == nTypeId || TYP_NEXTPAGEFLD == nTypeId))
     604             :             {
     605           0 :                 sal_Int32 nVal = m_pValueED->GetText().toInt32();
     606           0 :                 aVal = OUString::number(nVal);
     607             :             }
     608           0 :             break;
     609             :         }
     610             : 
     611             :         case TYP_CHAPTERFLD:
     612           0 :             aVal = m_pLevelED->GetText();
     613           0 :             break;
     614             : 
     615             :         default:
     616           0 :             break;
     617             :     }
     618             : 
     619           0 :     if (!IsFldEdit() ||
     620           0 :         nOldSel != m_pSelectionLB->GetSelectEntryPos() ||
     621           0 :         nOldFormat != nFormat ||
     622           0 :         m_pFixedCB->GetState() != m_pFixedCB->GetSavedValue() ||
     623           0 :         m_pValueED->GetText() != m_pValueED->GetSavedValue() ||
     624           0 :         m_pLevelED->GetText() != m_pLevelED->GetSavedValue() ||
     625           0 :         m_pDateOffsetED->GetText() != m_pDateOffsetED->GetSavedValue())
     626             :     {
     627           0 :         InsertFld( nTypeId, nSubType, aEmptyOUStr, aVal, nFormat, ' ', m_pNumFormatLB->IsAutomaticLanguage() );
     628             :     }
     629             : 
     630           0 :     return false;
     631             : }
     632             : 
     633           0 : SfxTabPage* SwFldDokPage::Create(   Window* pParent,
     634             :                         const SfxItemSet& rAttrSet )
     635             : {
     636           0 :     return ( new SwFldDokPage( pParent, rAttrSet ) );
     637             : }
     638             : 
     639           0 : sal_uInt16 SwFldDokPage::GetGroup()
     640             : {
     641           0 :     return GRP_DOC;
     642             : }
     643             : 
     644           0 : void    SwFldDokPage::FillUserData()
     645             : {
     646           0 :     const sal_Int32 nEntryPos = m_pTypeLB->GetSelectEntryPos();
     647             :     const sal_uInt16 nTypeSel = ( LISTBOX_ENTRY_NOTFOUND == nEntryPos )
     648             :         ? USHRT_MAX : sal::static_int_cast< sal_uInt16 >
     649           0 :             (reinterpret_cast< sal_uIntPtr >(m_pTypeLB->GetEntryData( nEntryPos )));
     650           0 :     SetUserData(USER_DATA_VERSION ";" + OUString::number( nTypeSel ));
     651           0 : }
     652             : 
     653             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10