LCOV - code coverage report
Current view: top level - sw/source/ui/fldui - flddok.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 331 0.0 %
Date: 2012-08-25 Functions: 0 16 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <vcl/svapp.hxx>
      30                 :            : #include <flddat.hxx>
      31                 :            : #include <docufld.hxx>
      32                 :            : #include <globals.hrc>
      33                 :            : #include <chpfld.hxx>
      34                 :            : #include <fldtdlg.hrc>
      35                 :            : #include <fldui.hrc>
      36                 :            : #include <flddok.hxx>
      37                 :            : #include <swmodule.hxx>
      38                 :            : #include <view.hxx>
      39                 :            : #include <wrtsh.hxx>
      40                 :            : #include <svl/zformat.hxx>
      41                 :            : 
      42                 :            : #include <index.hrc>
      43                 :            : 
      44                 :            : #define USER_DATA_VERSION_1 "1"
      45                 :            : #define USER_DATA_VERSION USER_DATA_VERSION_1
      46                 :            : 
      47                 :          0 : SwFldDokPage::SwFldDokPage(Window* pWindow, const SfxItemSet& rCoreSet ) :
      48                 :            :     SwFldPage( pWindow, SW_RES( TP_FLD_DOK ), rCoreSet ),
      49                 :            : 
      50                 :            :     aTypeFT         (this, SW_RES(FT_DOKTYPE)),
      51                 :            :     aTypeLB         (this, SW_RES(LB_DOKTYPE)),
      52                 :            :     aSelectionFT    (this, SW_RES(FT_DOKSELECTION)),
      53                 :            :     aSelectionLB    (this, SW_RES(LB_DOKSELECTION)),
      54                 :            :     aValueFT        (this, SW_RES(FT_DOKVALUE)),
      55                 :            :     aValueED        (this, SW_RES(ED_DOKVALUE)),
      56                 :            :     aLevelED        (this, SW_RES(ED_DOKLEVEL)),
      57                 :            :     aDateOffsetED   (this, SW_RES(ED_DOKDATEOFF)),
      58                 :            : 
      59                 :            :     aFormatFT       (this, SW_RES(FT_DOKFORMAT)),
      60                 :            :     aFormatLB       (this, SW_RES(LB_DOKFORMAT)),
      61                 :            :     aNumFormatLB    (this, SW_RES(LB_DOKNUMFORMAT)),
      62                 :            :     aFixedCB        (this, SW_RES(CB_DOKFIXEDCONTENT)),
      63                 :            : 
      64                 :            :     sDateOffset     (SW_RES(STR_DOKDATEOFF)),
      65                 :            :     sTimeOffset     (SW_RES(STR_DOKTIMEOFF)),
      66                 :            :     aRootOpened     (SW_RES(BMP_DOKROOT_OPENED)),
      67                 :          0 :     aRootClosed     (SW_RES(BMP_DOKROOT_CLOSED))
      68                 :            : {
      69                 :          0 :     FreeResource();
      70                 :            : 
      71                 :          0 :     aSelectionLB.SetDoubleClickHdl(LINK(this, SwFldDokPage, InsertHdl));
      72                 :          0 :     aFormatLB.SetDoubleClickHdl(LINK(this, SwFldDokPage, InsertHdl));
      73                 :          0 :     aNumFormatLB.SetDoubleClickHdl(LINK(this, SwFldDokPage, NumFormatHdl));
      74                 :            : 
      75                 :          0 :     aLevelED.SetMax(MAXLEVEL);
      76                 :          0 :     aDateOffsetED.SetMin(LONG_MIN);
      77                 :          0 :     aDateOffsetED.SetMax(LONG_MAX);
      78                 :            :     //enable 'active' language selection
      79                 :          0 :     aNumFormatLB.SetShowLanguageControl(sal_True);
      80                 :          0 : }
      81                 :            : 
      82                 :          0 : SwFldDokPage::~SwFldDokPage()
      83                 :            : {
      84                 :          0 : }
      85                 :            : 
      86                 :          0 : void SwFldDokPage::Reset(const SfxItemSet& )
      87                 :            : {
      88                 :          0 :     SavePos(&aTypeLB);
      89                 :          0 :     Init(); // general initialisation
      90                 :            : 
      91                 :            :     // initialise TypeListBox
      92                 :          0 :     const SwFldGroupRgn& rRg = GetFldMgr().GetGroupRange(IsFldDlgHtmlMode(), GetGroup());
      93                 :            : 
      94                 :          0 :     aTypeLB.SetUpdateMode(sal_False);
      95                 :          0 :     aTypeLB.Clear();
      96                 :            : 
      97                 :            :     sal_uInt16 nPos, nTypeId;
      98                 :          0 :     sal_Bool bPage = sal_False;
      99                 :            : 
     100                 :          0 :     if (!IsFldEdit())
     101                 :            :     {
     102                 :            :         // fill Type-Listbox
     103                 :          0 :         for(short i = rRg.nStart; i < rRg.nEnd; ++i)
     104                 :            :         {
     105                 :          0 :             nTypeId = GetFldMgr().GetTypeId(i);
     106                 :            : 
     107                 :          0 :             switch (nTypeId)
     108                 :            :             {
     109                 :            :                 case TYP_PREVPAGEFLD:
     110                 :            :                 case TYP_NEXTPAGEFLD:
     111                 :            :                 case TYP_PAGENUMBERFLD:
     112                 :          0 :                     if (!bPage)
     113                 :            :                     {
     114                 :          0 :                         nPos = aTypeLB.InsertEntry(SW_RESSTR(FMT_REF_PAGE));
     115                 :          0 :                         aTypeLB.SetEntryData(nPos, (void*)USHRT_MAX);
     116                 :          0 :                         bPage = sal_True;
     117                 :            :                     }
     118                 :          0 :                     break;
     119                 :            : 
     120                 :            :                 default:
     121                 :          0 :                     nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(i));
     122                 :          0 :                     aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
     123                 :          0 :                     break;
     124                 :            :             }
     125                 :            :         }
     126                 :            :     }
     127                 :            :     else
     128                 :            :     {
     129                 :          0 :         const SwField* pCurField = GetCurField();
     130                 :          0 :         nTypeId = pCurField->GetTypeId();
     131                 :          0 :         if (nTypeId == TYP_FIXDATEFLD)
     132                 :          0 :             nTypeId = TYP_DATEFLD;
     133                 :          0 :         if (nTypeId == TYP_FIXTIMEFLD)
     134                 :          0 :             nTypeId = TYP_TIMEFLD;
     135                 :          0 :         nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(GetFldMgr().GetPos(nTypeId)));
     136                 :          0 :         aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
     137                 :          0 :         aNumFormatLB.SetAutomaticLanguage(pCurField->IsAutomaticLanguage());
     138                 :          0 :         SwWrtShell *pSh = GetWrtShell();
     139                 :          0 :         if(!pSh)
     140                 :          0 :             pSh = ::GetActiveWrtShell();
     141                 :          0 :         if(pSh)
     142                 :            :         {
     143                 :          0 :             const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetFormat());
     144                 :          0 :             if(pFormat)
     145                 :          0 :                 aNumFormatLB.SetLanguage(pFormat->GetLanguage());
     146                 :            :         }
     147                 :            :     }
     148                 :            : 
     149                 :            :     // select old Pos
     150                 :          0 :     RestorePos(&aTypeLB);
     151                 :            : 
     152                 :          0 :     aTypeLB.SetUpdateMode(sal_True);
     153                 :          0 :     aTypeLB.SetDoubleClickHdl(LINK(this, SwFldDokPage, InsertHdl));
     154                 :          0 :     aTypeLB.SetSelectHdl(LINK(this, SwFldDokPage, TypeHdl));
     155                 :          0 :     aFormatLB.SetSelectHdl(LINK(this, SwFldDokPage, FormatHdl));
     156                 :            : 
     157                 :          0 :     if( !IsRefresh() )
     158                 :            :     {
     159                 :          0 :         String sUserData = GetUserData();
     160                 :          0 :         if( sUserData.GetToken(0, ';').EqualsIgnoreCaseAscii(USER_DATA_VERSION_1 ))
     161                 :            :         {
     162                 :          0 :             String sVal = sUserData.GetToken(1, ';');
     163                 :          0 :             sal_uInt16 nVal = static_cast< sal_uInt16 >(sVal.ToInt32());
     164                 :          0 :             if(nVal != USHRT_MAX)
     165                 :            :             {
     166                 :          0 :                 for(sal_uInt16 i = 0; i < aTypeLB.GetEntryCount(); i++)
     167                 :          0 :                     if(nVal == (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(i))
     168                 :            :                     {
     169                 :          0 :                         aTypeLB.SelectEntryPos(i);
     170                 :          0 :                         break;
     171                 :            :                     }
     172                 :          0 :             }
     173                 :          0 :         }
     174                 :            :     }
     175                 :          0 :     TypeHdl(0);
     176                 :            : 
     177                 :          0 :     if (IsFldEdit())
     178                 :            :     {
     179                 :          0 :         nOldSel = aSelectionLB.GetSelectEntryPos();
     180                 :          0 :         nOldFormat = GetCurField()->GetFormat();
     181                 :          0 :         aFixedCB.SaveValue();
     182                 :          0 :         aValueED.SaveValue();
     183                 :          0 :         aLevelED.SaveValue();
     184                 :          0 :         aDateOffsetED.SaveValue();
     185                 :            :     }
     186                 :          0 : }
     187                 :            : 
     188                 :          0 : IMPL_LINK_NOARG(SwFldDokPage, TypeHdl)
     189                 :            : {
     190                 :            :     // save old ListBoxPos
     191                 :          0 :     const sal_uInt16 nOld = GetTypeSel();
     192                 :            : 
     193                 :            :     // current ListBoxPos
     194                 :          0 :     SetTypeSel(aTypeLB.GetSelectEntryPos());
     195                 :            : 
     196                 :          0 :     if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND)
     197                 :            :     {
     198                 :          0 :         SetTypeSel(0);
     199                 :          0 :         aTypeLB.SelectEntryPos(0);
     200                 :            :     }
     201                 :            : 
     202                 :            :     sal_uInt16 nCount;
     203                 :            : 
     204                 :          0 :     if (nOld != GetTypeSel())
     205                 :            :     {
     206                 :          0 :         sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
     207                 :            : 
     208                 :            :         // fill Selection-Listbox
     209                 :          0 :         aSelectionLB.Clear();
     210                 :            : 
     211                 :          0 :         if (nTypeId != USHRT_MAX)
     212                 :            :         {
     213                 :          0 :             std::vector<rtl::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, sal_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 = aSelectionLB.InsertEntry(aLst[i]);
     229                 :            :                     else
     230                 :          0 :                         nPos = aSelectionLB.InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i));
     231                 :            : 
     232                 :          0 :                     aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i));
     233                 :            :                 }
     234                 :            :                 else
     235                 :            :                 {
     236                 :          0 :                     sal_Bool bInsert = sal_False;
     237                 :            : 
     238                 :          0 :                     switch (nTypeId)
     239                 :            :                     {
     240                 :            :                         case TYP_DATEFLD:
     241                 :            :                         case TYP_TIMEFLD:
     242                 :          0 :                             nPos = aSelectionLB.InsertEntry(aLst[i]);
     243                 :          0 :                             aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i));
     244                 :          0 :                             if (((SwDateTimeField*)GetCurField())->IsFixed() && !i)
     245                 :          0 :                                 aSelectionLB.SelectEntryPos(nPos);
     246                 :          0 :                             if (!((SwDateTimeField*)GetCurField())->IsFixed() && i)
     247                 :          0 :                                 aSelectionLB.SelectEntryPos(nPos);
     248                 :          0 :                             break;
     249                 :            : 
     250                 :            :                         case TYP_EXTUSERFLD:
     251                 :            :                         case TYP_DOCSTATFLD:
     252                 :          0 :                             nPos = aSelectionLB.InsertEntry(aLst[i]);
     253                 :          0 :                             aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i));
     254                 :          0 :                             if (GetCurField()->GetSubType() == i)
     255                 :          0 :                                 aSelectionLB.SelectEntryPos(nPos);
     256                 :          0 :                             break;
     257                 :            : 
     258                 :            :                         case TYP_AUTHORFLD:
     259                 :            :                         {
     260                 :          0 :                             String sFmt(GetFldMgr().GetFormatStr(nTypeId, i));
     261                 :          0 :                             nPos = aSelectionLB.InsertEntry(sFmt);
     262                 :          0 :                             aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i));
     263                 :          0 :                             aSelectionLB.SelectEntry(GetFldMgr().GetFormatStr(nTypeId, GetCurField()->GetFormat()));
     264                 :          0 :                             break;
     265                 :            :                         }
     266                 :            : 
     267                 :            :                         default:
     268                 :          0 :                             if (aLst[i] == GetCurField()->GetPar1())
     269                 :          0 :                                 bInsert = sal_True;
     270                 :          0 :                             break;
     271                 :            :                     }
     272                 :          0 :                     if (bInsert)
     273                 :            :                     {
     274                 :          0 :                         nPos = aSelectionLB.InsertEntry(aLst[i]);
     275                 :          0 :                         aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i));
     276                 :          0 :                         break;
     277                 :            :                     }
     278                 :            :                 }
     279                 :            :             }
     280                 :          0 :             aSelectionLB.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)aSelectionLB.GetEntryData(0);
     288                 :          0 :             nCount = 3;
     289                 :          0 :             aSelectionLB.SetSelectHdl(LINK(this, SwFldDokPage, SubTypeHdl));
     290                 :            :         }
     291                 :            : 
     292                 :          0 :         sal_Bool bEnable = nCount != 0;
     293                 :            : 
     294                 :          0 :         if (bEnable && !aSelectionLB.GetSelectEntryCount())
     295                 :          0 :             aSelectionLB.SelectEntryPos(0);
     296                 :            : 
     297                 :          0 :         aSelectionLB.Enable( bEnable );
     298                 :          0 :         aSelectionFT.Enable( bEnable );
     299                 :            : 
     300                 :            :         // fill Format-Listbox
     301                 :          0 :         sal_uInt16 nSize = FillFormatLB(nTypeId);
     302                 :            : 
     303                 :          0 :         sal_Bool bValue = sal_False, bLevel = sal_False, bNumFmt = sal_False, bOffset = sal_False;
     304                 :          0 :         sal_Bool bFormat = nSize != 0;
     305                 :          0 :         sal_Bool bOneArea = sal_False;
     306                 :          0 :         sal_Bool bFixed = sal_False;
     307                 :          0 :         sal_uInt16 nFmtType = 0;
     308                 :            : 
     309                 :          0 :         switch (nTypeId)
     310                 :            :         {
     311                 :            :             case TYP_DATEFLD:
     312                 :          0 :                 bFormat = bNumFmt = bOneArea = bOffset = sal_True;
     313                 :            : 
     314                 :          0 :                 nFmtType = NUMBERFORMAT_DATE;
     315                 :          0 :                 aValueFT.SetText(sDateOffset);
     316                 :          0 :                 aDateOffsetED.SetFirst(-31);    // one month
     317                 :          0 :                 aDateOffsetED.SetLast(31);
     318                 :            : 
     319                 :          0 :                 if (IsFldEdit())
     320                 :          0 :                     aDateOffsetED.SetValue( ((SwDateTimeField*)GetCurField())->GetOffset() / 24 / 60);
     321                 :          0 :                 break;
     322                 :            : 
     323                 :            :             case TYP_TIMEFLD:
     324                 :          0 :                 bFormat = bNumFmt = bOneArea = bOffset = sal_True;
     325                 :            : 
     326                 :          0 :                 nFmtType = NUMBERFORMAT_TIME;
     327                 :          0 :                 aValueFT.SetText(sTimeOffset);
     328                 :          0 :                 aDateOffsetED.SetFirst(-1440);  // one day
     329                 :          0 :                 aDateOffsetED.SetLast(1440);
     330                 :            : 
     331                 :          0 :                 if (IsFldEdit())
     332                 :          0 :                     aDateOffsetED.SetValue( ((SwDateTimeField*)GetCurField())->GetOffset() );
     333                 :          0 :                 break;
     334                 :            : 
     335                 :            :             case TYP_PREVPAGEFLD:
     336                 :            :             case TYP_NEXTPAGEFLD:
     337                 :          0 :                 if (IsFldEdit())
     338                 :            :                 {
     339                 :            :                     sal_uInt16 nTmp = (sal_uInt16)(sal_uLong)aFormatLB.GetEntryData(
     340                 :          0 :                                             aFormatLB.GetSelectEntryPos() );
     341                 :          0 :                     String sOldTxt(aValueFT.GetText());
     342                 :            : 
     343                 :          0 :                     if(SVX_NUM_CHAR_SPECIAL != nTmp)
     344                 :            :                     {
     345                 :          0 :                         sal_Int32 nOff = GetCurField()->GetPar2().toInt32();
     346                 :          0 :                         if( TYP_NEXTPAGEFLD == nTypeId && 1 != nOff )
     347                 :            :                             aValueED.SetText(
     348                 :          0 :                                 String::CreateFromInt32(nOff - 1) );
     349                 :          0 :                         else if( TYP_PREVPAGEFLD == nTypeId && -1 != nOff )
     350                 :            :                             aValueED.SetText(
     351                 :          0 :                                 String::CreateFromInt32(nOff + 1) );
     352                 :            :                         else
     353                 :          0 :                             aValueED.SetText(aEmptyStr);
     354                 :            :                     }
     355                 :            :                     else
     356                 :          0 :                         aValueED.SetText(((SwPageNumberField*)GetCurField())->GetUserString());
     357                 :            :                 }
     358                 :          0 :                 bValue = sal_True;
     359                 :          0 :                 break;
     360                 :            : 
     361                 :            :             case TYP_CHAPTERFLD:
     362                 :          0 :                 aValueFT.SetText(SW_RESSTR(STR_LEVEL));
     363                 :          0 :                 if (IsFldEdit())
     364                 :          0 :                     aLevelED.SetText(String::CreateFromInt32(((SwChapterField*)GetCurField())->GetLevel() + 1));
     365                 :          0 :                 bLevel = sal_True;
     366                 :          0 :                 break;
     367                 :            : 
     368                 :            :             case TYP_PAGENUMBERFLD:
     369                 :          0 :                 aValueFT.SetText( SW_RESSTR( STR_OFFSET ));
     370                 :          0 :                 if (IsFldEdit())
     371                 :          0 :                     aValueED.SetText(GetCurField()->GetPar2());
     372                 :          0 :                 bValue = sal_True;
     373                 :          0 :                 break;
     374                 :            : 
     375                 :            :             case TYP_EXTUSERFLD:
     376                 :            :             case TYP_AUTHORFLD:
     377                 :            :             case TYP_FILENAMEFLD:
     378                 :          0 :                 bFixed = sal_True;
     379                 :          0 :                 break;
     380                 :            : 
     381                 :            :             default:
     382                 :          0 :                 break;
     383                 :            :         }
     384                 :            : 
     385                 :          0 :         if (bNumFmt)
     386                 :            :         {
     387                 :          0 :             if (IsFldEdit())
     388                 :            :             {
     389                 :          0 :                 aNumFormatLB.SetDefFormat(GetCurField()->GetFormat());
     390                 :            : 
     391                 :          0 :                 if (aNumFormatLB.GetFormatType() == (NUMBERFORMAT_DATE|NUMBERFORMAT_TIME))
     392                 :            :                 {
     393                 :            :                     // always set Format-Type because otherwise when date/time formats are combined,
     394                 :            :                     // both formats would be displayed at the same time
     395                 :          0 :                     aNumFormatLB.SetFormatType(0);
     396                 :          0 :                     aNumFormatLB.SetFormatType(nFmtType);
     397                 :            :                     // set correct format once again
     398                 :          0 :                     aNumFormatLB.SetDefFormat(GetCurField()->GetFormat());
     399                 :            :                 }
     400                 :            :             }
     401                 :            :             else
     402                 :          0 :                 aNumFormatLB.SetFormatType(nFmtType);
     403                 :            : 
     404                 :          0 :             aNumFormatLB.SetOneArea(bOneArea);
     405                 :            :         }
     406                 :            : 
     407                 :          0 :         aFormatLB.Show(!bNumFmt);
     408                 :          0 :         aNumFormatLB.Show(bNumFmt);
     409                 :            : 
     410                 :          0 :         Size aSz(aFormatLB.GetSizePixel());
     411                 :            : 
     412                 :          0 :         if (bValue | bLevel | bOffset)
     413                 :          0 :             aSz.Height() = aFormatLB.LogicToPixel(Size(1, 137), MAP_APPFONT).Height();
     414                 :            :         else
     415                 :          0 :             aSz.Height() = aFormatLB.LogicToPixel(Size(1, 152), MAP_APPFONT).Height();
     416                 :            : 
     417                 :          0 :         aValueFT.Show(bValue | bLevel | bOffset);
     418                 :          0 :         aValueED.Show(bValue);
     419                 :          0 :         aLevelED.Show(bLevel);
     420                 :          0 :         aDateOffsetED.Show(bOffset);
     421                 :          0 :         aFixedCB.Show(!bValue && !bLevel && !bOffset);
     422                 :            : 
     423                 :          0 :         aFormatLB.SetSizePixel(aSz);
     424                 :          0 :         aNumFormatLB.SetSizePixel(aSz);
     425                 :            : 
     426                 :          0 :         aFormatLB.Enable(bFormat);
     427                 :          0 :         aFormatFT.Enable(bFormat);
     428                 :          0 :         aFixedCB.Enable(bFixed);
     429                 :            : 
     430                 :          0 :         if (IsFldEdit())
     431                 :          0 :             aFixedCB.Check( static_cast< sal_Bool >(((GetCurField()->GetFormat() & AF_FIXED) != 0) & bFixed));
     432                 :            : 
     433                 :          0 :         if (aNumFormatLB.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND)
     434                 :          0 :             aNumFormatLB.SelectEntryPos(0);
     435                 :          0 :         aValueFT.Enable(bValue | bLevel | bOffset);
     436                 :          0 :         aValueED.Enable(bValue);
     437                 :            :     }
     438                 :            : 
     439                 :          0 :     return 0;
     440                 :            : }
     441                 :            : 
     442                 :          0 : void SwFldDokPage::AddSubType(sal_uInt16 nTypeId)
     443                 :            : {
     444                 :          0 :     sal_uInt16 nPos = aSelectionLB.InsertEntry(SwFieldType::GetTypeStr(nTypeId));
     445                 :          0 :     aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
     446                 :          0 : }
     447                 :            : 
     448                 :          0 : IMPL_LINK_NOARG(SwFldDokPage, SubTypeHdl)
     449                 :            : {
     450                 :          0 :     sal_uInt16 nPos = aSelectionLB.GetSelectEntryPos();
     451                 :          0 :     if(nPos == LISTBOX_ENTRY_NOTFOUND)
     452                 :          0 :         nPos = 0;
     453                 :            : 
     454                 :          0 :     sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nPos);
     455                 :          0 :     FillFormatLB(nTypeId);
     456                 :            : 
     457                 :          0 :     sal_uInt16 nTextRes = 0;
     458                 :          0 :     switch (nTypeId)
     459                 :            :     {
     460                 :            :     case TYP_CHAPTERFLD:
     461                 :          0 :         nTextRes = STR_LEVEL;
     462                 :          0 :         break;
     463                 :            : 
     464                 :            :     case TYP_PREVPAGEFLD:
     465                 :            :     case TYP_NEXTPAGEFLD:
     466                 :            :         nTextRes = SVX_NUM_CHAR_SPECIAL == (sal_uInt16)(sal_uLong)aFormatLB.GetEntryData(
     467                 :          0 :                                         aFormatLB.GetSelectEntryPos() )
     468                 :          0 :                         ? STR_VALUE : STR_OFFSET;
     469                 :          0 :         break;
     470                 :            : 
     471                 :            :     case TYP_PAGENUMBERFLD:
     472                 :          0 :         nTextRes = STR_OFFSET;
     473                 :          0 :         break;
     474                 :            :     }
     475                 :            : 
     476                 :          0 :     if( nTextRes )
     477                 :          0 :         aValueFT.SetText( SW_RESSTR( nTextRes ));
     478                 :            : 
     479                 :          0 :     return 0;
     480                 :            : }
     481                 :            : 
     482                 :          0 : sal_uInt16 SwFldDokPage::FillFormatLB(sal_uInt16 nTypeId)
     483                 :            : {
     484                 :            :     // fill Format-Listbox
     485                 :          0 :     aFormatLB.Clear();
     486                 :            : 
     487                 :          0 :     if (nTypeId == TYP_AUTHORFLD)
     488                 :          0 :         return aFormatLB.GetEntryCount();
     489                 :            : 
     490                 :          0 :     sal_uInt16 nSize = GetFldMgr().GetFormatCount(nTypeId, sal_False, IsFldDlgHtmlMode());
     491                 :            : 
     492                 :          0 :     for( sal_uInt16 i = 0; i < nSize; ++i )
     493                 :            :     {
     494                 :          0 :         sal_uInt16 nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i));
     495                 :          0 :         sal_uInt16 nFmtId = GetFldMgr().GetFormatId( nTypeId, i );
     496                 :          0 :         aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>( nFmtId ));
     497                 :          0 :         if (IsFldEdit() && nFmtId == (GetCurField()->GetFormat() & ~AF_FIXED))
     498                 :          0 :             aFormatLB.SelectEntryPos( nPos );
     499                 :            :     }
     500                 :            : 
     501                 :          0 :     if( nSize && !aFormatLB.GetSelectEntryCount() )
     502                 :            :     {
     503                 :          0 :         aFormatLB.SelectEntry( SW_RESSTR(FMT_NUM_PAGEDESC) );
     504                 :          0 :         if( !aFormatLB.GetSelectEntryCount() )
     505                 :            :         {
     506                 :          0 :             aFormatLB.SelectEntry( SW_RESSTR(FMT_NUM_ARABIC) );
     507                 :          0 :             if( !aFormatLB.GetSelectEntryCount() )
     508                 :          0 :                 aFormatLB.SelectEntryPos( 0 );
     509                 :            :         }
     510                 :            :     }
     511                 :            : 
     512                 :          0 :     FormatHdl();
     513                 :            : 
     514                 :          0 :     return nSize;
     515                 :            : }
     516                 :            : 
     517                 :          0 : IMPL_LINK_NOARG(SwFldDokPage, FormatHdl)
     518                 :            : {
     519                 :          0 :     sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
     520                 :            : 
     521                 :          0 :     if (nTypeId == USHRT_MAX)
     522                 :            :     {
     523                 :          0 :         sal_uInt16 nPos = aSelectionLB.GetSelectEntryPos();
     524                 :          0 :         if(nPos == LISTBOX_ENTRY_NOTFOUND)
     525                 :          0 :             nPos = 0;
     526                 :            : 
     527                 :          0 :         nTypeId = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nPos);
     528                 :            :     }
     529                 :            : 
     530                 :          0 :     if (nTypeId == TYP_NEXTPAGEFLD || nTypeId == TYP_PREVPAGEFLD)
     531                 :            :     {
     532                 :            :         // Prev/Next - PageNumFields special treatment:
     533                 :            :         sal_uInt16 nTmp = (sal_uInt16)(sal_uLong)aFormatLB.GetEntryData(
     534                 :          0 :                                         aFormatLB.GetSelectEntryPos() );
     535                 :          0 :         String sOldTxt( aValueFT.GetText() );
     536                 :            :         String sNewTxt( SW_RES( SVX_NUM_CHAR_SPECIAL == nTmp  ? STR_VALUE
     537                 :          0 :                                                          : STR_OFFSET ));
     538                 :            : 
     539                 :          0 :         if( sOldTxt != sNewTxt )
     540                 :          0 :             aValueFT.SetText( sNewTxt );
     541                 :            : 
     542                 :          0 :         if (sOldTxt != aValueFT.GetText())
     543                 :          0 :             aValueED.SetText( aEmptyStr );
     544                 :            :     }
     545                 :            : 
     546                 :          0 :     return 0;
     547                 :            : }
     548                 :            : 
     549                 :          0 : sal_Bool SwFldDokPage::FillItemSet(SfxItemSet& )
     550                 :            : {
     551                 :          0 :     sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
     552                 :            : 
     553                 :          0 :     if (nTypeId == USHRT_MAX)
     554                 :            :     {
     555                 :          0 :         sal_uInt16 nPos = aSelectionLB.GetSelectEntryPos();
     556                 :          0 :         if(nPos == LISTBOX_ENTRY_NOTFOUND)
     557                 :          0 :             nPos = 0;
     558                 :          0 :         nTypeId = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nPos);
     559                 :            :     }
     560                 :            : 
     561                 :          0 :     String aVal(aValueED.GetText());
     562                 :          0 :     sal_uLong nFormat = 0;
     563                 :          0 :     sal_uInt16 nSubType = 0;
     564                 :            : 
     565                 :          0 :     if (aFormatLB.IsEnabled())
     566                 :            :     {
     567                 :          0 :         sal_uInt16 nPos = aFormatLB.GetSelectEntryPos();
     568                 :          0 :         if(nPos != LISTBOX_ENTRY_NOTFOUND)
     569                 :          0 :             nFormat = (sal_uInt16)(sal_uLong)aFormatLB.GetEntryData(nPos);
     570                 :            :     }
     571                 :            : 
     572                 :          0 :     if (aSelectionLB.IsEnabled())
     573                 :            :     {
     574                 :          0 :         sal_uInt16 nPos = aSelectionLB.GetSelectEntryPos();
     575                 :          0 :         if(nPos != LISTBOX_ENTRY_NOTFOUND)
     576                 :          0 :             nSubType = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nPos);
     577                 :            :     }
     578                 :            : 
     579                 :          0 :     switch (nTypeId)
     580                 :            :     {
     581                 :            :         case TYP_AUTHORFLD:
     582                 :          0 :             nFormat = nSubType;
     583                 :          0 :             nSubType = 0;
     584                 :            :             // no break!
     585                 :            :         case TYP_EXTUSERFLD:
     586                 :          0 :             nFormat |= aFixedCB.IsChecked() ? AF_FIXED : 0;
     587                 :          0 :             break;
     588                 :            : 
     589                 :            :         case TYP_FILENAMEFLD:
     590                 :          0 :             nFormat |= aFixedCB.IsChecked() ? FF_FIXED : 0;
     591                 :          0 :             break;
     592                 :            : 
     593                 :            :         case TYP_DATEFLD:
     594                 :            :         case TYP_TIMEFLD:
     595                 :            :         {
     596                 :          0 :             nFormat = aNumFormatLB.GetFormat();
     597                 :          0 :             long nVal = static_cast< long >(aDateOffsetED.GetValue());
     598                 :          0 :             if (nTypeId == TYP_DATEFLD)
     599                 :          0 :                 aVal = String::CreateFromInt32(nVal * 60 * 24);
     600                 :            :             else
     601                 :          0 :                 aVal = String::CreateFromInt32(nVal);
     602                 :          0 :             break;
     603                 :            :         }
     604                 :            : 
     605                 :            :         case TYP_NEXTPAGEFLD:
     606                 :            :         case TYP_PREVPAGEFLD:
     607                 :            :         case TYP_PAGENUMBERFLD:
     608                 :            :         case TYP_GETREFPAGEFLD:
     609                 :            :         {
     610                 :          0 :             if( SVX_NUM_CHAR_SPECIAL != nFormat &&
     611                 :            :                 (TYP_PREVPAGEFLD == nTypeId || TYP_NEXTPAGEFLD == nTypeId))
     612                 :            :             {
     613                 :          0 :                 sal_Int32 nVal = aValueED.GetText().ToInt32();
     614                 :          0 :                 aVal = String::CreateFromInt32(nVal);
     615                 :            :             }
     616                 :          0 :             break;
     617                 :            :         }
     618                 :            : 
     619                 :            :         case TYP_CHAPTERFLD:
     620                 :          0 :             aVal = aLevelED.GetText();
     621                 :          0 :             break;
     622                 :            : 
     623                 :            :         default:
     624                 :          0 :             break;
     625                 :            :     }
     626                 :            : 
     627                 :          0 :     if (!IsFldEdit() ||
     628                 :          0 :         nOldSel != aSelectionLB.GetSelectEntryPos() ||
     629                 :            :         nOldFormat != nFormat ||
     630                 :          0 :         aFixedCB.GetState() != aFixedCB.GetSavedValue() ||
     631                 :          0 :         aValueED.GetText() != aValueED.GetSavedValue() ||
     632                 :          0 :         aLevelED.GetText() != aLevelED.GetSavedValue() ||
     633                 :          0 :         aDateOffsetED.GetText() != aDateOffsetED.GetSavedValue())
     634                 :            :     {
     635                 :          0 :         InsertFld( nTypeId, nSubType, aEmptyStr, aVal, nFormat, ' ', aNumFormatLB.IsAutomaticLanguage() );
     636                 :            :     }
     637                 :            : 
     638                 :          0 :     return sal_False;
     639                 :            : }
     640                 :            : 
     641                 :          0 : SfxTabPage* SwFldDokPage::Create(   Window* pParent,
     642                 :            :                         const SfxItemSet& rAttrSet )
     643                 :            : {
     644                 :          0 :     return ( new SwFldDokPage( pParent, rAttrSet ) );
     645                 :            : }
     646                 :            : 
     647                 :          0 : sal_uInt16 SwFldDokPage::GetGroup()
     648                 :            : {
     649                 :          0 :     return GRP_DOC;
     650                 :            : }
     651                 :            : 
     652                 :          0 : void    SwFldDokPage::FillUserData()
     653                 :            : {
     654                 :          0 :     String sData(rtl::OUString(USER_DATA_VERSION));
     655                 :          0 :     sData += ';';
     656                 :          0 :     sal_uInt16 nTypeSel = aTypeLB.GetSelectEntryPos();
     657                 :          0 :     if( LISTBOX_ENTRY_NOTFOUND == nTypeSel )
     658                 :          0 :         nTypeSel = USHRT_MAX;
     659                 :            :     else
     660                 :          0 :         nTypeSel = sal::static_int_cast< sal_uInt16 >(reinterpret_cast< sal_uIntPtr >(aTypeLB.GetEntryData( nTypeSel )));
     661                 :          0 :     sData += String::CreateFromInt32( nTypeSel );
     662                 :          0 :     SetUserData(sData);
     663                 :          0 : }
     664                 :            : 
     665                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10