LCOV - code coverage report
Current view: top level - sw/source/ui/fldui - fldref.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 485 0.0 %
Date: 2012-08-25 Functions: 0 19 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 "swtypes.hxx"
      30                 :            : #include <view.hxx>
      31                 :            : #include <IMark.hxx>
      32                 :            : #include <expfld.hxx>
      33                 :            : #include <swmodule.hxx>
      34                 :            : #include <fldref.hxx>
      35                 :            : #include <reffld.hxx>
      36                 :            : #include <wrtsh.hxx>
      37                 :            : 
      38                 :            : #include <fldui.hrc>
      39                 :            : #include <fldtdlg.hrc>
      40                 :            : #include <globals.hrc>
      41                 :            : // #i83479#
      42                 :            : #include <SwNodeNum.hxx>
      43                 :            : #include <IDocumentMarkAccess.hxx>
      44                 :            : #include <ndtxt.hxx>
      45                 :            : 
      46                 :            : #define REFFLDFLAG          0x4000
      47                 :            : #define REFFLDFLAG_BOOKMARK 0x4800
      48                 :            : #define REFFLDFLAG_FOOTNOTE 0x5000
      49                 :            : #define REFFLDFLAG_ENDNOTE  0x6000
      50                 :            : // #i83479#
      51                 :            : #define REFFLDFLAG_HEADING  0x7100
      52                 :            : #define REFFLDFLAG_NUMITEM  0x7200
      53                 :            : 
      54                 :            : sal_uInt16  nFldDlgFmtSel       = 0;
      55                 :            : 
      56                 :            : #define USER_DATA_VERSION_1 "1"
      57                 :            : #define USER_DATA_VERSION USER_DATA_VERSION_1
      58                 :            : 
      59                 :          0 : SwFldRefPage::SwFldRefPage(Window* pParent, const SfxItemSet& rCoreSet ) :
      60                 :            :     SwFldPage( pParent, SW_RES( TP_FLD_REF ), rCoreSet ),
      61                 :            : 
      62                 :            :     aTypeFT         (this, SW_RES(FT_REFTYPE)),
      63                 :            :     aTypeLB         (this, SW_RES(LB_REFTYPE)),
      64                 :            :     aSelectionFT    (this, SW_RES(FT_REFSELECTION)),
      65                 :            :     aSelectionLB    (this, SW_RES(LB_REFSELECTION)),
      66                 :            :     // #i83479#
      67                 :            :     aSelectionToolTipLB( this, SW_RES(LB_REFSELECTION_TOOLTIP) ),
      68                 :            :     aFormatFT       (this, SW_RES(FT_REFFORMAT)),
      69                 :            :     aFormatLB       (this, SW_RES(LB_REFFORMAT)),
      70                 :            :     aNameFT         (this, SW_RES(FT_REFNAME)),
      71                 :            :     aNameED         (this, SW_RES(ED_REFNAME)),
      72                 :            :     aValueFT        (this, SW_RES(FT_REFVALUE)),
      73                 :            :     aValueED        (this, SW_RES(ED_REFVALUE)),
      74                 :            : 
      75                 :            :     sBookmarkTxt    (SW_RES(STR_REFBOOKMARK)),
      76                 :            :     sFootnoteTxt    (SW_RES(STR_REFFOOTNOTE)),
      77                 :            :     sEndnoteTxt     (SW_RES(STR_REFENDNOTE)),
      78                 :            :     // #i83479#
      79                 :            :     sHeadingTxt     (SW_RES(STR_REFHEADING)),
      80                 :            :     sNumItemTxt     (SW_RES(STR_REFNUMITEM)),
      81                 :            :     maOutlineNodes(),
      82                 :            :     maNumItems(),
      83                 :            :     mpSavedSelectedTxtNode( 0 ),
      84                 :          0 :     mnSavedSelectedPos( 0 )
      85                 :            : {
      86                 :          0 :     FreeResource();
      87                 :            : 
      88                 :          0 :     aNameED.SetModifyHdl(LINK(this, SwFldRefPage, ModifyHdl));
      89                 :            : 
      90                 :          0 :     aTypeLB.SetDoubleClickHdl       (LINK(this, SwFldRefPage, InsertHdl));
      91                 :          0 :     aTypeLB.SetSelectHdl            (LINK(this, SwFldRefPage, TypeHdl));
      92                 :          0 :     aSelectionLB.SetSelectHdl       (LINK(this, SwFldRefPage, SubTypeHdl));
      93                 :          0 :     aSelectionLB.SetDoubleClickHdl  (LINK(this, SwFldRefPage, InsertHdl));
      94                 :          0 :     aFormatLB.SetDoubleClickHdl     (LINK(this, SwFldRefPage, InsertHdl));
      95                 :            : 
      96                 :            :     // #i83479#
      97                 :          0 :     aSelectionToolTipLB.SetSelectHdl( LINK(this, SwFldRefPage, SubTypeHdl) );
      98                 :          0 :     aSelectionToolTipLB.SetDoubleClickHdl( LINK(this, SwFldRefPage, InsertHdl) );
      99                 :          0 :     aSelectionToolTipLB.SetStyle( aSelectionToolTipLB.GetStyle() | WB_HSCROLL );
     100                 :          0 :     aSelectionToolTipLB.SetSpaceBetweenEntries(1);
     101                 :          0 :     aSelectionToolTipLB.SetHighlightRange();
     102                 :          0 : }
     103                 :            : 
     104                 :          0 : SwFldRefPage::~SwFldRefPage()
     105                 :            : {
     106                 :          0 : }
     107                 :            : 
     108                 :            : // #i83479#
     109                 :          0 : void SwFldRefPage::SaveSelectedTxtNode()
     110                 :            : {
     111                 :          0 :     mpSavedSelectedTxtNode = 0;
     112                 :          0 :     mnSavedSelectedPos = 0;
     113                 :          0 :     if ( aSelectionToolTipLB.IsVisible() )
     114                 :            :     {
     115                 :          0 :         SvLBoxEntry* pEntry = aSelectionToolTipLB.GetCurEntry();
     116                 :          0 :         if ( pEntry )
     117                 :            :         {
     118                 :          0 :             const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
     119                 :          0 :             SwWrtShell *pSh = GetWrtShell();
     120                 :          0 :             if ( !pSh )
     121                 :            :             {
     122                 :          0 :                 pSh = ::GetActiveWrtShell();
     123                 :            :             }
     124                 :          0 :             if ( nTypeId == REFFLDFLAG_HEADING )
     125                 :            :             {
     126                 :          0 :                 mnSavedSelectedPos = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(pEntry->GetUserData()));
     127                 :          0 :                 if ( mnSavedSelectedPos < maOutlineNodes.size() )
     128                 :            :                 {
     129                 :          0 :                     mpSavedSelectedTxtNode = maOutlineNodes[mnSavedSelectedPos];
     130                 :            :                 }
     131                 :            :             }
     132                 :          0 :             else if ( nTypeId == REFFLDFLAG_NUMITEM )
     133                 :            :             {
     134                 :          0 :                 mnSavedSelectedPos = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(pEntry->GetUserData()));
     135                 :          0 :                 if ( mnSavedSelectedPos < maNumItems.size() )
     136                 :            :                 {
     137                 :          0 :                     mpSavedSelectedTxtNode = maNumItems[mnSavedSelectedPos]->GetTxtNode();
     138                 :            :                 }
     139                 :            :             }
     140                 :            :         }
     141                 :            :     }
     142                 :          0 : }
     143                 :            : 
     144                 :          0 : const SwTxtNode* SwFldRefPage::GetSavedSelectedTxtNode() const
     145                 :            : {
     146                 :          0 :     return mpSavedSelectedTxtNode;
     147                 :            : }
     148                 :            : 
     149                 :          0 : sal_uInt16 SwFldRefPage::GetSavedSelectedPos() const
     150                 :            : {
     151                 :          0 :     return mnSavedSelectedPos;
     152                 :            : }
     153                 :            : 
     154                 :            : 
     155                 :          0 : void SwFldRefPage::Reset(const SfxItemSet& )
     156                 :            : {
     157                 :          0 :     if (!IsFldEdit())
     158                 :            :     {
     159                 :          0 :         SavePos(&aTypeLB);
     160                 :            :         // #i83479#
     161                 :          0 :         SaveSelectedTxtNode();
     162                 :            :     }
     163                 :          0 :     SetSelectionSel(LISTBOX_ENTRY_NOTFOUND);
     164                 :          0 :     SetTypeSel(LISTBOX_ENTRY_NOTFOUND);
     165                 :          0 :     Init(); // general initialisation
     166                 :            : 
     167                 :            :     // initialise TypeListBox
     168                 :          0 :     aTypeLB.SetUpdateMode(sal_False);
     169                 :          0 :     aTypeLB.Clear();
     170                 :            : 
     171                 :            :     // fill Type-Listbox
     172                 :            : 
     173                 :            :     sal_uInt16 nPos;
     174                 :            :     // set/insert reference
     175                 :          0 :     const SwFldGroupRgn& rRg = GetFldMgr().GetGroupRange(IsFldDlgHtmlMode(), GetGroup());
     176                 :            : 
     177                 :          0 :     for (short i = rRg.nStart; i < rRg.nEnd; ++i)
     178                 :            :     {
     179                 :          0 :         const sal_uInt16 nTypeId = GetFldMgr().GetTypeId(i);
     180                 :            : 
     181                 :          0 :         if (!IsFldEdit() || nTypeId != TYP_SETREFFLD)
     182                 :            :         {
     183                 :          0 :             nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(i), i - rRg.nStart);
     184                 :          0 :             aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
     185                 :            :         }
     186                 :            :     }
     187                 :            : 
     188                 :            :     // #i83479#
     189                 :            :     // entries for headings and numbered items
     190                 :          0 :     nPos = aTypeLB.InsertEntry(sHeadingTxt);
     191                 :          0 :     aTypeLB.SetEntryData(nPos, (void*)REFFLDFLAG_HEADING);
     192                 :          0 :     nPos = aTypeLB.InsertEntry(sNumItemTxt);
     193                 :          0 :     aTypeLB.SetEntryData(nPos, (void*)REFFLDFLAG_NUMITEM);
     194                 :            : 
     195                 :            :     // fill up with the sequence types
     196                 :          0 :     SwWrtShell *pSh = GetWrtShell();
     197                 :          0 :     if(!pSh)
     198                 :          0 :         pSh = ::GetActiveWrtShell();
     199                 :            : 
     200                 :          0 :     sal_uInt16 nFldTypeCnt = pSh->GetFldTypeCount(RES_SETEXPFLD);
     201                 :            : 
     202                 :          0 :     for (sal_uInt16 n = 0; n < nFldTypeCnt; ++n)
     203                 :            :     {
     204                 :          0 :         SwSetExpFieldType* pType = (SwSetExpFieldType*)pSh->GetFldType(n, RES_SETEXPFLD);
     205                 :            : 
     206                 :          0 :         if ((nsSwGetSetExpType::GSE_SEQ & pType->GetType()) && pType->GetDepends() && pSh->IsUsed(*pType))
     207                 :            :         {
     208                 :          0 :             nPos = aTypeLB.InsertEntry(pType->GetName());
     209                 :          0 :             aTypeLB.SetEntryData(nPos, (void*)(sal_uIntPtr)(REFFLDFLAG | n));
     210                 :            :         }
     211                 :            :     }
     212                 :            : 
     213                 :            :     // text marks - now always (because of globaldocuments)
     214                 :          0 :     nPos = aTypeLB.InsertEntry(sBookmarkTxt);
     215                 :          0 :     aTypeLB.SetEntryData(nPos, (void*)REFFLDFLAG_BOOKMARK);
     216                 :            : 
     217                 :            :     // footnotes:
     218                 :          0 :     if( pSh->HasFtns() )
     219                 :            :     {
     220                 :          0 :         nPos = aTypeLB.InsertEntry(sFootnoteTxt);
     221                 :          0 :         aTypeLB.SetEntryData(nPos, (void*)REFFLDFLAG_FOOTNOTE);
     222                 :            :     }
     223                 :            : 
     224                 :            :     // endnotes:
     225                 :          0 :     if ( pSh->HasFtns(true) )
     226                 :            :     {
     227                 :          0 :         nPos = aTypeLB.InsertEntry(sEndnoteTxt);
     228                 :          0 :         aTypeLB.SetEntryData(nPos, (void*)REFFLDFLAG_ENDNOTE);
     229                 :            :     }
     230                 :            : 
     231                 :            :     // select old Pos
     232                 :          0 :     if (!IsFldEdit())
     233                 :          0 :         RestorePos(&aTypeLB);
     234                 :            : 
     235                 :          0 :     aTypeLB.SetUpdateMode(sal_True);
     236                 :            : 
     237                 :          0 :     nFldDlgFmtSel = 0;
     238                 :            : 
     239                 :          0 :     if( !IsRefresh() )
     240                 :            :     {
     241                 :          0 :         String sUserData = GetUserData();
     242                 :          0 :         if(!IsRefresh() && sUserData.GetToken(0, ';').
     243                 :          0 :                                 EqualsIgnoreCaseAscii(USER_DATA_VERSION_1))
     244                 :            :         {
     245                 :          0 :             String sVal = sUserData.GetToken(1, ';');
     246                 :          0 :             sal_uInt16 nVal = static_cast< sal_uInt16 >(sVal.ToInt32());
     247                 :          0 :             if(nVal != USHRT_MAX)
     248                 :            :             {
     249                 :          0 :                 for(sal_uInt16 i = 0; i < aTypeLB.GetEntryCount(); i++)
     250                 :          0 :                     if(nVal == (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(i))
     251                 :            :                     {
     252                 :          0 :                         aTypeLB.SelectEntryPos(i);
     253                 :          0 :                         break;
     254                 :            :                     }
     255                 :          0 :             }
     256                 :          0 :         }
     257                 :            :     }
     258                 :          0 :     TypeHdl(0);
     259                 :            : 
     260                 :          0 :     if (IsFldEdit())
     261                 :            :     {
     262                 :          0 :         aTypeLB.SaveValue();
     263                 :          0 :         aSelectionLB.SaveValue();
     264                 :          0 :         aFormatLB.SaveValue();
     265                 :          0 :         aNameED.SaveValue();
     266                 :          0 :         aValueED.SaveValue();
     267                 :            :     }
     268                 :          0 : }
     269                 :            : 
     270                 :          0 : IMPL_LINK_NOARG(SwFldRefPage, TypeHdl)
     271                 :            : {
     272                 :            :     // save old ListBoxPos
     273                 :          0 :     const sal_uInt16 nOld = GetTypeSel();
     274                 :            : 
     275                 :            :     // current ListBoxPos
     276                 :          0 :     SetTypeSel(aTypeLB.GetSelectEntryPos());
     277                 :            : 
     278                 :          0 :     if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND)
     279                 :            :     {
     280                 :          0 :         if (IsFldEdit())
     281                 :            :         {
     282                 :            :             // select positions
     283                 :          0 :             String sName;
     284                 :          0 :             sal_uInt16 nFlag = 0;
     285                 :            : 
     286                 :          0 :             switch( GetCurField()->GetSubType() )
     287                 :            :             {
     288                 :            :                 case REF_BOOKMARK:
     289                 :            :                 {
     290                 :            :                     // #i83479#
     291                 :          0 :                     SwGetRefField* pRefFld = dynamic_cast<SwGetRefField*>(GetCurField());
     292                 :          0 :                     if ( pRefFld &&
     293                 :          0 :                          pRefFld->IsRefToHeadingCrossRefBookmark() )
     294                 :            :                     {
     295                 :          0 :                         sName = sHeadingTxt;
     296                 :          0 :                         nFlag = REFFLDFLAG_HEADING;
     297                 :            :                     }
     298                 :          0 :                     else if ( pRefFld &&
     299                 :          0 :                               pRefFld->IsRefToNumItemCrossRefBookmark() )
     300                 :            :                     {
     301                 :          0 :                         sName = sNumItemTxt;
     302                 :          0 :                         nFlag = REFFLDFLAG_NUMITEM;
     303                 :            :                     }
     304                 :            :                     else
     305                 :            :                     {
     306                 :          0 :                         sName = sBookmarkTxt;
     307                 :          0 :                         nFlag = REFFLDFLAG_BOOKMARK;
     308                 :            :                     }
     309                 :            :                 }
     310                 :          0 :                 break;
     311                 :            : 
     312                 :            :                 case REF_FOOTNOTE:
     313                 :          0 :                     sName = sFootnoteTxt;
     314                 :          0 :                     nFlag = REFFLDFLAG_FOOTNOTE;
     315                 :          0 :                     break;
     316                 :            : 
     317                 :            :                 case REF_ENDNOTE:
     318                 :          0 :                     sName = sEndnoteTxt;
     319                 :          0 :                     nFlag = REFFLDFLAG_ENDNOTE;
     320                 :          0 :                     break;
     321                 :            : 
     322                 :            :                 case REF_SETREFATTR:
     323                 :          0 :                     sName = SW_RESSTR(STR_GETREFFLD);
     324                 :          0 :                     nFlag = REF_SETREFATTR;
     325                 :          0 :                     break;
     326                 :            : 
     327                 :            :                 case REF_SEQUENCEFLD:
     328                 :          0 :                     sName = ((SwGetRefField*)GetCurField())->GetSetRefName();
     329                 :          0 :                     nFlag = REFFLDFLAG;
     330                 :          0 :                     break;
     331                 :            :             }
     332                 :            : 
     333                 :          0 :             if (aTypeLB.GetEntryPos(sName) == LISTBOX_ENTRY_NOTFOUND)   // reference to deleted mark
     334                 :            :             {
     335                 :          0 :                 sal_uInt16 nPos = aTypeLB.InsertEntry(sName);
     336                 :          0 :                 aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nFlag));
     337                 :            :             }
     338                 :            : 
     339                 :          0 :             aTypeLB.SelectEntry(sName);
     340                 :          0 :             SetTypeSel(aTypeLB.GetSelectEntryPos());
     341                 :            :         }
     342                 :            :         else
     343                 :            :         {
     344                 :          0 :             SetTypeSel(0);
     345                 :          0 :             aTypeLB.SelectEntryPos(0);
     346                 :            :         }
     347                 :            :     }
     348                 :            : 
     349                 :          0 :     if (nOld != GetTypeSel())
     350                 :            :     {
     351                 :          0 :         sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
     352                 :            : 
     353                 :            :         // fill selection-ListBox
     354                 :          0 :         UpdateSubType();
     355                 :            : 
     356                 :          0 :         sal_Bool bName = sal_False;     nFldDlgFmtSel = 0;
     357                 :            : 
     358                 :          0 :         if ( ( !IsFldEdit() || aSelectionLB.GetEntryCount() ) &&
     359                 :            :              nOld != LISTBOX_ENTRY_NOTFOUND )
     360                 :            :         {
     361                 :          0 :             aNameED.SetText(aEmptyStr);
     362                 :          0 :             aValueED.SetText(aEmptyStr);
     363                 :            :         }
     364                 :            : 
     365                 :          0 :         switch (nTypeId)
     366                 :            :         {
     367                 :            :             case TYP_GETREFFLD:
     368                 :          0 :                 if (REFFLDFLAG & (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(nOld))
     369                 :            :                     // the the old one stays
     370                 :          0 :                     nFldDlgFmtSel = aFormatLB.GetSelectEntryPos();
     371                 :          0 :                 bName = sal_True;
     372                 :          0 :                 break;
     373                 :            : 
     374                 :            :             case TYP_SETREFFLD:
     375                 :          0 :                 bName = sal_True;
     376                 :          0 :                 break;
     377                 :            : 
     378                 :            :             case REFFLDFLAG_BOOKMARK:
     379                 :          0 :                 bName = sal_True;
     380                 :            :                 // no break!!!
     381                 :            :             default:
     382                 :          0 :                 if( REFFLDFLAG & nTypeId )
     383                 :            :                 {
     384                 :          0 :                     sal_uInt16 nOldId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(nOld);
     385                 :          0 :                     if( nOldId & REFFLDFLAG || nOldId == TYP_GETREFFLD )
     386                 :            :                         // then the old one stays
     387                 :          0 :                         nFldDlgFmtSel = aFormatLB.GetSelectEntryPos();
     388                 :            :                 }
     389                 :          0 :                 break;
     390                 :            :         }
     391                 :            : 
     392                 :          0 :         aNameED.Enable(bName);
     393                 :          0 :         aNameFT.Enable(bName);
     394                 :            : 
     395                 :            :         // fill Format-Listbox
     396                 :          0 :         sal_uInt16 nSize = FillFormatLB(nTypeId);
     397                 :          0 :         sal_Bool bFormat = nSize != 0;
     398                 :          0 :         aFormatLB.Enable(bFormat);
     399                 :          0 :         aFormatFT.Enable(bFormat);
     400                 :            : 
     401                 :          0 :         SubTypeHdl();
     402                 :          0 :         ModifyHdl();
     403                 :            :     }
     404                 :            : 
     405                 :          0 :     return 0;
     406                 :            : }
     407                 :            : 
     408                 :          0 : IMPL_LINK_NOARG(SwFldRefPage, SubTypeHdl)
     409                 :            : {
     410                 :          0 :     sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
     411                 :            : 
     412                 :          0 :     switch(nTypeId)
     413                 :            :     {
     414                 :            :         case TYP_GETREFFLD:
     415                 :          0 :             if (!IsFldEdit() || aSelectionLB.GetSelectEntryCount())
     416                 :            :             {
     417                 :          0 :                 aNameED.SetText(aSelectionLB.GetSelectEntry());
     418                 :          0 :                 ModifyHdl(&aNameED);
     419                 :            :             }
     420                 :          0 :             break;
     421                 :            : 
     422                 :            :         case TYP_SETREFFLD:
     423                 :            :         {
     424                 :          0 :             SwWrtShell *pSh = GetWrtShell();
     425                 :          0 :             if(!pSh)
     426                 :          0 :                 pSh = ::GetActiveWrtShell();
     427                 :          0 :             if(pSh)
     428                 :            :             {
     429                 :          0 :                 aValueED.SetText(pSh->GetSelTxt());
     430                 :            :             }
     431                 :            : 
     432                 :            :         }
     433                 :          0 :         break;
     434                 :            :         // #i83479#
     435                 :            :         case REFFLDFLAG_HEADING:
     436                 :            :         case REFFLDFLAG_NUMITEM:
     437                 :            :         {
     438                 :          0 :             if ( aSelectionToolTipLB.GetCurEntry() )
     439                 :            :             {
     440                 :            :                 aNameED.SetText( aSelectionToolTipLB.GetEntryText(
     441                 :          0 :                                         aSelectionToolTipLB.GetCurEntry() ) );
     442                 :            :             }
     443                 :            :         }
     444                 :          0 :         break;
     445                 :            : 
     446                 :            :         default:
     447                 :          0 :             if (!IsFldEdit() || aSelectionLB.GetSelectEntryCount())
     448                 :          0 :                 aNameED.SetText(aSelectionLB.GetSelectEntry());
     449                 :          0 :             break;
     450                 :            :     }
     451                 :            : 
     452                 :          0 :     return 0;
     453                 :            : }
     454                 :            : 
     455                 :            : /*--------------------------------------------------------------------
     456                 :            :      Description: renew types in SelectionLB
     457                 :            :  --------------------------------------------------------------------*/
     458                 :            : 
     459                 :          0 : void SwFldRefPage::UpdateSubType()
     460                 :            : {
     461                 :          0 :     SwWrtShell *pSh = GetWrtShell();
     462                 :          0 :     if(!pSh)
     463                 :          0 :         pSh = ::GetActiveWrtShell();
     464                 :          0 :     SwGetRefField* pRefFld = (SwGetRefField*)GetCurField();
     465                 :          0 :     const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
     466                 :            : 
     467                 :          0 :     String sOldSel;
     468                 :            :     // #i83479#
     469                 :          0 :     if ( aSelectionLB.IsVisible() )
     470                 :            :     {
     471                 :          0 :         const sal_uInt16 nSelectionSel = aSelectionLB.GetSelectEntryPos();
     472                 :          0 :         if (nSelectionSel != LISTBOX_ENTRY_NOTFOUND)
     473                 :            :         {
     474                 :          0 :             sOldSel = aSelectionLB.GetEntry(nSelectionSel);
     475                 :            :         }
     476                 :            :     }
     477                 :          0 :     if (IsFldEdit() && !sOldSel.Len())
     478                 :          0 :         sOldSel = String::CreateFromInt32( pRefFld->GetSeqNo() + 1 );
     479                 :            : 
     480                 :          0 :     aSelectionLB.SetUpdateMode(sal_False);
     481                 :          0 :     aSelectionLB.Clear();
     482                 :            :     // #i83479#
     483                 :          0 :     aSelectionToolTipLB.SetUpdateMode(sal_False);
     484                 :          0 :     aSelectionToolTipLB.Clear();
     485                 :          0 :     bool bShowSelectionToolTipLB( false );
     486                 :            : 
     487                 :          0 :     if( REFFLDFLAG & nTypeId )
     488                 :            :     {
     489                 :          0 :         if (nTypeId == REFFLDFLAG_BOOKMARK)     // text marks!
     490                 :            :         {
     491                 :          0 :             aSelectionLB.SetStyle(aSelectionLB.GetStyle()|WB_SORT);
     492                 :            :             // get all text marks
     493                 :          0 :             IDocumentMarkAccess* const pMarkAccess = pSh->getIDocumentMarkAccess();
     494                 :          0 :             for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin();
     495                 :          0 :                 ppMark != pMarkAccess->getBookmarksEnd();
     496                 :            :                 ppMark++)
     497                 :            :             {
     498                 :          0 :                 const ::sw::mark::IMark* pBkmk = ppMark->get();
     499                 :          0 :                 if(IDocumentMarkAccess::BOOKMARK == IDocumentMarkAccess::GetType(*pBkmk))
     500                 :          0 :                     aSelectionLB.InsertEntry( pBkmk->GetName() );
     501                 :            :             }
     502                 :          0 :             if (IsFldEdit())
     503                 :          0 :                 sOldSel = pRefFld->GetSetRefName();
     504                 :            :         }
     505                 :          0 :         else if (nTypeId == REFFLDFLAG_FOOTNOTE)
     506                 :            :         {
     507                 :          0 :             aSelectionLB.SetStyle(aSelectionLB.GetStyle() & ~WB_SORT);
     508                 :          0 :             SwSeqFldList aArr;
     509                 :          0 :             sal_uInt16 nCnt = pSh->GetSeqFtnList( aArr );
     510                 :            : 
     511                 :          0 :             for( sal_uInt16 n = 0; n < nCnt; ++n )
     512                 :            :             {
     513                 :          0 :                 aSelectionLB.InsertEntry( aArr[ n ]->sDlgEntry );
     514                 :          0 :                 if (IsFldEdit() && pRefFld->GetSeqNo() == aArr[ n ]->nSeqNo)
     515                 :          0 :                     sOldSel = aArr[n]->sDlgEntry;
     516                 :          0 :             }
     517                 :            :         }
     518                 :          0 :         else if (nTypeId == REFFLDFLAG_ENDNOTE)
     519                 :            :         {
     520                 :          0 :             aSelectionLB.SetStyle(aSelectionLB.GetStyle() & ~WB_SORT);
     521                 :          0 :             SwSeqFldList aArr;
     522                 :          0 :             sal_uInt16 nCnt = pSh->GetSeqFtnList( aArr, true );
     523                 :            : 
     524                 :          0 :             for( sal_uInt16 n = 0; n < nCnt; ++n )
     525                 :            :             {
     526                 :          0 :                 aSelectionLB.InsertEntry( aArr[ n ]->sDlgEntry );
     527                 :          0 :                 if (IsFldEdit() && pRefFld->GetSeqNo() == aArr[ n ]->nSeqNo)
     528                 :          0 :                     sOldSel = aArr[n]->sDlgEntry;
     529                 :          0 :             }
     530                 :            :         }
     531                 :            :         // #i83479#
     532                 :          0 :         else if ( nTypeId == REFFLDFLAG_HEADING )
     533                 :            :         {
     534                 :          0 :             bShowSelectionToolTipLB = true;
     535                 :            : 
     536                 :          0 :             const IDocumentOutlineNodes* pIDoc( pSh->getIDocumentOutlineNodesAccess() );
     537                 :          0 :             pIDoc->getOutlineNodes( maOutlineNodes );
     538                 :          0 :             bool bCertainTxtNodeSelected( false );
     539                 :          0 :             SvLBoxEntry* pEntry = 0;
     540                 :          0 :             sal_uInt16 nOutlIdx = 0;
     541                 :          0 :             for ( nOutlIdx = 0; nOutlIdx < maOutlineNodes.size(); ++nOutlIdx )
     542                 :            :             {
     543                 :            :                 pEntry = aSelectionToolTipLB.InsertEntry(
     544                 :          0 :                                 pIDoc->getOutlineText( nOutlIdx, true, true ) );
     545                 :          0 :                 pEntry->SetUserData( reinterpret_cast<void*>(nOutlIdx) );
     546                 :          0 :                 if ( ( IsFldEdit() &&
     547                 :          0 :                        pRefFld->GetReferencedTxtNode() == maOutlineNodes[nOutlIdx] ) ||
     548                 :          0 :                      GetSavedSelectedTxtNode() == maOutlineNodes[nOutlIdx] )
     549                 :            :                 {
     550                 :          0 :                     aSelectionToolTipLB.Select( pEntry );
     551                 :          0 :                     sOldSel.Erase();
     552                 :          0 :                     bCertainTxtNodeSelected = true;
     553                 :            :                 }
     554                 :          0 :                 else if ( !bCertainTxtNodeSelected &&
     555                 :          0 :                           GetSavedSelectedPos() == nOutlIdx )
     556                 :            :                 {
     557                 :          0 :                     aSelectionToolTipLB.Select( pEntry );
     558                 :          0 :                     sOldSel.Erase();
     559                 :            :                 }
     560                 :            :             }
     561                 :            :         }
     562                 :          0 :         else if ( nTypeId == REFFLDFLAG_NUMITEM )
     563                 :            :         {
     564                 :          0 :             bShowSelectionToolTipLB = true;
     565                 :            : 
     566                 :          0 :             const IDocumentListItems* pIDoc( pSh->getIDocumentListItemsAccess() );
     567                 :          0 :             pIDoc->getNumItems( maNumItems );
     568                 :          0 :             bool bCertainTxtNodeSelected( false );
     569                 :          0 :             SvLBoxEntry* pEntry = 0;
     570                 :          0 :             sal_uInt16 nNumItemIdx = 0;
     571                 :          0 :             for ( nNumItemIdx = 0; nNumItemIdx < maNumItems.size(); ++nNumItemIdx )
     572                 :            :             {
     573                 :            :                 pEntry = aSelectionToolTipLB.InsertEntry(
     574                 :          0 :                             pIDoc->getListItemText( *maNumItems[nNumItemIdx], true, true ) );
     575                 :          0 :                 pEntry->SetUserData( reinterpret_cast<void*>(nNumItemIdx) );
     576                 :          0 :                 if ( ( IsFldEdit() &&
     577                 :          0 :                        pRefFld->GetReferencedTxtNode() == maNumItems[nNumItemIdx]->GetTxtNode() ) ||
     578                 :          0 :                      GetSavedSelectedTxtNode() == maNumItems[nNumItemIdx]->GetTxtNode() )
     579                 :            :                 {
     580                 :          0 :                     aSelectionToolTipLB.Select( pEntry );
     581                 :          0 :                     sOldSel.Erase();
     582                 :          0 :                     bCertainTxtNodeSelected = true;
     583                 :            :                 }
     584                 :          0 :                 else if ( !bCertainTxtNodeSelected &&
     585                 :          0 :                           GetSavedSelectedPos() == nNumItemIdx )
     586                 :            :                 {
     587                 :          0 :                     aSelectionToolTipLB.Select( pEntry );
     588                 :          0 :                     sOldSel.Erase();
     589                 :            :                 }
     590                 :            :             }
     591                 :            :         }
     592                 :            :         else
     593                 :            :         {
     594                 :          0 :             aSelectionLB.SetStyle(aSelectionLB.GetStyle()|WB_SORT);
     595                 :            :             // get the fields to Seq-FieldType:
     596                 :            : 
     597                 :            :             SwSetExpFieldType* pType = (SwSetExpFieldType*)pSh->GetFldType(
     598                 :          0 :                                 nTypeId & ~REFFLDFLAG, RES_SETEXPFLD );
     599                 :          0 :             if( pType )
     600                 :            :             {
     601                 :          0 :                 SwSeqFldList aArr;
     602                 :            :                 // old selection should be kept in non-edit mode
     603                 :          0 :                 if(IsFldEdit())
     604                 :          0 :                     sOldSel.Erase();
     605                 :            : 
     606                 :          0 :                 sal_uInt16 nCnt = pType->GetSeqFldList( aArr );
     607                 :          0 :                 for( sal_uInt16 n = 0; n < nCnt; ++n )
     608                 :            :                 {
     609                 :          0 :                     aSelectionLB.InsertEntry( aArr[ n ]->sDlgEntry );
     610                 :          0 :                     if (IsFldEdit() && !sOldSel.Len() &&
     611                 :          0 :                         aArr[ n ]->nSeqNo == pRefFld->GetSeqNo())
     612                 :          0 :                         sOldSel = aArr[ n ]->sDlgEntry;
     613                 :            :                 }
     614                 :            : 
     615                 :          0 :                 if (IsFldEdit() && !sOldSel.Len())
     616                 :          0 :                     sOldSel = String::CreateFromInt32( pRefFld->GetSeqNo() + 1);
     617                 :            :             }
     618                 :            :         }
     619                 :            :     }
     620                 :            :     else
     621                 :            :     {
     622                 :          0 :         std::vector<rtl::OUString> aLst;
     623                 :          0 :         GetFldMgr().GetSubTypes(nTypeId, aLst);
     624                 :          0 :         for(size_t i = 0; i < aLst.size(); ++i)
     625                 :          0 :             aSelectionLB.InsertEntry(aLst[i]);
     626                 :            : 
     627                 :          0 :         if (IsFldEdit())
     628                 :          0 :             sOldSel = pRefFld->GetSetRefName();
     629                 :            :     }
     630                 :            : 
     631                 :            :     // #i83479#
     632                 :          0 :     aSelectionToolTipLB.Show( bShowSelectionToolTipLB );
     633                 :          0 :     aSelectionLB.Show( !bShowSelectionToolTipLB );
     634                 :          0 :     if ( bShowSelectionToolTipLB )
     635                 :            :     {
     636                 :          0 :         aSelectionToolTipLB.SetUpdateMode(sal_True);
     637                 :            : 
     638                 :          0 :         sal_Bool bEnable = aSelectionToolTipLB.GetEntryCount() != 0;
     639                 :          0 :         aSelectionToolTipLB.Enable( bEnable );
     640                 :          0 :         aSelectionFT.Enable( bEnable );
     641                 :            : 
     642                 :          0 :         if ( aSelectionToolTipLB.GetCurEntry() != 0 )
     643                 :            :         {
     644                 :          0 :             aSelectionToolTipLB.MakeVisible( aSelectionToolTipLB.GetCurEntry() );
     645                 :            :         }
     646                 :            : 
     647                 :          0 :         if ( IsFldEdit() && aSelectionToolTipLB.GetCurEntry() == 0 )
     648                 :            :         {
     649                 :          0 :             aNameED.SetText(sOldSel);
     650                 :            :         }
     651                 :            :     }
     652                 :            :     else
     653                 :            :     {
     654                 :          0 :         aSelectionLB.SetUpdateMode(sal_True);
     655                 :            : 
     656                 :            :         // enable or disable
     657                 :          0 :         sal_Bool bEnable = aSelectionLB.GetEntryCount() != 0;
     658                 :          0 :         aSelectionLB.Enable( bEnable );
     659                 :          0 :         aSelectionFT.Enable( bEnable );
     660                 :            : 
     661                 :          0 :         if ( bEnable )
     662                 :            :         {
     663                 :          0 :             aSelectionLB.SelectEntry(sOldSel);
     664                 :          0 :             if (!aSelectionLB.GetSelectEntryCount() && !IsFldEdit())
     665                 :          0 :                 aSelectionLB.SelectEntryPos(0);
     666                 :            :         }
     667                 :            : 
     668                 :          0 :         if (IsFldEdit() && !aSelectionLB.GetSelectEntryCount()) // in case the reference was already deleted...
     669                 :          0 :             aNameED.SetText(sOldSel);
     670                 :          0 :     }
     671                 :          0 : }
     672                 :            : 
     673                 :          0 : sal_uInt16 SwFldRefPage::FillFormatLB(sal_uInt16 nTypeId)
     674                 :            : {
     675                 :          0 :     String sOldSel;
     676                 :            : 
     677                 :          0 :     sal_uInt16 nFormatSel = aFormatLB.GetSelectEntryPos();
     678                 :          0 :     if (nFormatSel != LISTBOX_ENTRY_NOTFOUND)
     679                 :          0 :         sOldSel = aFormatLB.GetEntry(nFormatSel);
     680                 :            : 
     681                 :            :     // fill Format-Listbox
     682                 :          0 :     aFormatLB.Clear();
     683                 :            : 
     684                 :            :     // refernce has less that the annotation
     685                 :          0 :     sal_uInt16 nSize( 0 );
     686                 :          0 :     bool bAddCrossRefFormats( false );
     687                 :          0 :     switch (nTypeId)
     688                 :            :     {
     689                 :            :         // #i83479#
     690                 :            :         case REFFLDFLAG_HEADING:
     691                 :            :         case REFFLDFLAG_NUMITEM:
     692                 :          0 :             bAddCrossRefFormats = true;
     693                 :            :             // intentional no break here
     694                 :            : 
     695                 :            :         case TYP_GETREFFLD:
     696                 :            :         case REFFLDFLAG_BOOKMARK:
     697                 :            :         case REFFLDFLAG_FOOTNOTE:
     698                 :            :         case REFFLDFLAG_ENDNOTE:
     699                 :          0 :             nSize = FMT_REF_PAGE_PGDSC - FMT_REF_BEGIN + 1;
     700                 :          0 :             break;
     701                 :            : 
     702                 :            :         default:
     703                 :            :             // #i83479#
     704                 :            : 
     705                 :          0 :             if ( REFFLDFLAG & nTypeId )
     706                 :            :             {
     707                 :          0 :                 nSize = FMT_REF_ONLYSEQNO - FMT_REF_BEGIN + 1;
     708                 :            :             }
     709                 :            :             else
     710                 :            :             {
     711                 :          0 :                 nSize = GetFldMgr().GetFormatCount( nTypeId, sal_False, IsFldDlgHtmlMode() );
     712                 :            :             }
     713                 :          0 :             break;
     714                 :            :     }
     715                 :            : 
     716                 :          0 :     if (REFFLDFLAG & nTypeId)
     717                 :          0 :         nTypeId = TYP_GETREFFLD;
     718                 :            : 
     719                 :          0 :     for (sal_uInt16 i = 0; i < nSize; i++)
     720                 :            :     {
     721                 :          0 :         sal_uInt16 nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr( nTypeId, i ));
     722                 :          0 :         aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>(GetFldMgr().GetFormatId( nTypeId, i )));
     723                 :            :     }
     724                 :            :     // #i83479#
     725                 :          0 :     if ( bAddCrossRefFormats )
     726                 :            :     {
     727                 :          0 :         sal_uInt16 nFormat = FMT_REF_NUMBER - FMT_REF_BEGIN;
     728                 :          0 :         sal_uInt16 nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr( nTypeId, nFormat ));
     729                 :          0 :         aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>(GetFldMgr().GetFormatId( nTypeId, nFormat )));
     730                 :          0 :         nFormat = FMT_REF_NUMBER_NO_CONTEXT - FMT_REF_BEGIN;
     731                 :          0 :         nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr( nTypeId, nFormat ));
     732                 :          0 :         aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>(GetFldMgr().GetFormatId( nTypeId, nFormat )));
     733                 :          0 :         nFormat = FMT_REF_NUMBER_FULL_CONTEXT - FMT_REF_BEGIN;
     734                 :          0 :         nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr( nTypeId, nFormat ));
     735                 :          0 :         aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>(GetFldMgr().GetFormatId( nTypeId, nFormat )));
     736                 :          0 :         nSize += 3;
     737                 :            :     }
     738                 :            : 
     739                 :            :     // select a certain entry
     740                 :          0 :     if (nSize)
     741                 :            :     {
     742                 :          0 :         if (!IsFldEdit())
     743                 :          0 :             aFormatLB.SelectEntry(sOldSel);
     744                 :            :         else
     745                 :          0 :             aFormatLB.SelectEntry(SW_RESSTR(FMT_REF_BEGIN + (sal_uInt16)GetCurField()->GetFormat()));
     746                 :            : 
     747                 :          0 :         if (!aFormatLB.GetSelectEntryCount())
     748                 :            :         {
     749                 :          0 :             aFormatLB.SelectEntryPos(nFldDlgFmtSel);
     750                 :          0 :             if (!aFormatLB.GetSelectEntryCount())
     751                 :          0 :                 aFormatLB.SelectEntryPos(0);
     752                 :            :         }
     753                 :            :     }
     754                 :            : 
     755                 :          0 :     return nSize;
     756                 :            : }
     757                 :            : 
     758                 :            : /*--------------------------------------------------------------------
     759                 :            :     Description: Modify
     760                 :            :  --------------------------------------------------------------------*/
     761                 :            : 
     762                 :          0 : IMPL_LINK_NOARG(SwFldRefPage, ModifyHdl)
     763                 :            : {
     764                 :          0 :     String aName(aNameED.GetText());
     765                 :          0 :     const sal_uInt16 nLen = aName.Len();
     766                 :            : 
     767                 :          0 :     sal_Bool bEnable = sal_True;
     768                 :          0 :     sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
     769                 :            : 
     770                 :          0 :     if ((nTypeId == TYP_SETREFFLD && !GetFldMgr().CanInsertRefMark(aName)) ||
     771                 :            :         (nLen == 0 && (nTypeId == TYP_GETREFFLD || nTypeId == TYP_SETREFFLD ||
     772                 :            :                        nTypeId == REFFLDFLAG_BOOKMARK)))
     773                 :          0 :         bEnable = sal_False;
     774                 :            : 
     775                 :          0 :     EnableInsert(bEnable);
     776                 :            : 
     777                 :          0 :     aSelectionLB.SelectEntry(aName);
     778                 :            : 
     779                 :          0 :     return 0;
     780                 :            : }
     781                 :            : 
     782                 :          0 : sal_Bool SwFldRefPage::FillItemSet(SfxItemSet& )
     783                 :            : {
     784                 :          0 :     sal_Bool bModified = sal_False;
     785                 :          0 :     sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
     786                 :            : 
     787                 :          0 :     sal_uInt16 nSubType = 0;
     788                 :            :     sal_uLong nFormat;
     789                 :            : 
     790                 :          0 :     nFormat = aFormatLB.GetSelectEntryPos();
     791                 :            : 
     792                 :          0 :     if(nFormat == LISTBOX_ENTRY_NOTFOUND)
     793                 :          0 :         nFormat = 0;
     794                 :            :     else
     795                 :          0 :         nFormat = (sal_uLong)aFormatLB.GetEntryData((sal_uInt16)nFormat);
     796                 :            : 
     797                 :          0 :     String aVal(aValueED.GetText());
     798                 :          0 :     String aName(aNameED.GetText());
     799                 :            : 
     800                 :          0 :     switch(nTypeId)
     801                 :            :     {
     802                 :            :         case TYP_GETREFFLD:
     803                 :          0 :             nSubType = REF_SETREFATTR;
     804                 :          0 :             break;
     805                 :            : 
     806                 :            :         case TYP_SETREFFLD:
     807                 :            :         {
     808                 :          0 :             SwFieldType* pType = GetFldMgr().GetFldType(RES_SETEXPFLD, aName);
     809                 :            : 
     810                 :          0 :             if(!pType)  // Only insert when the name doesn't exist yet
     811                 :            :             {
     812                 :          0 :                 aSelectionLB.InsertEntry(aName);
     813                 :          0 :                 aSelectionLB.Enable();
     814                 :          0 :                 aSelectionFT.Enable();
     815                 :            :             }
     816                 :          0 :             break;
     817                 :            :         }
     818                 :            :     }
     819                 :            : 
     820                 :          0 :     SwGetRefField* pRefFld = (SwGetRefField*)GetCurField();
     821                 :            : 
     822                 :          0 :     if (REFFLDFLAG & nTypeId)
     823                 :            :     {
     824                 :          0 :         SwWrtShell *pSh = GetWrtShell();
     825                 :          0 :         if(!pSh)
     826                 :            :         {
     827                 :          0 :             pSh = ::GetActiveWrtShell();
     828                 :            :         }
     829                 :          0 :         if (nTypeId == REFFLDFLAG_BOOKMARK)     // text marks!
     830                 :            :         {
     831                 :          0 :             aName = aNameED.GetText();
     832                 :          0 :             nTypeId = TYP_GETREFFLD;
     833                 :          0 :             nSubType = REF_BOOKMARK;
     834                 :            :         }
     835                 :          0 :         else if (REFFLDFLAG_FOOTNOTE == nTypeId)        // footnotes
     836                 :            :         {
     837                 :          0 :             SwSeqFldList aArr;
     838                 :          0 :             _SeqFldLstElem aElem( aSelectionLB.GetSelectEntry(), 0 );
     839                 :            : 
     840                 :            :             sal_uInt16 nPos;
     841                 :            : 
     842                 :          0 :             nTypeId = TYP_GETREFFLD;
     843                 :          0 :             nSubType = REF_FOOTNOTE;
     844                 :          0 :             aName.Erase();
     845                 :            : 
     846                 :          0 :             if (pSh->GetSeqFtnList(aArr) && aArr.SeekEntry(aElem, &nPos))
     847                 :            :             {
     848                 :          0 :                 aVal = String::CreateFromInt32( aArr[nPos]->nSeqNo );
     849                 :            : 
     850                 :          0 :                 if (IsFldEdit() && aArr[nPos]->nSeqNo == pRefFld->GetSeqNo())
     851                 :          0 :                     bModified = sal_True; // can happen with fields of which the references were deleted
     852                 :            :             }
     853                 :          0 :             else if (IsFldEdit())
     854                 :          0 :                 aVal = String::CreateFromInt32( pRefFld->GetSeqNo() );
     855                 :            :         }
     856                 :          0 :         else if (REFFLDFLAG_ENDNOTE == nTypeId)         // endnotes
     857                 :            :         {
     858                 :          0 :             SwSeqFldList aArr;
     859                 :          0 :             _SeqFldLstElem aElem( aSelectionLB.GetSelectEntry(), 0 );
     860                 :            : 
     861                 :            :             sal_uInt16 nPos;
     862                 :            : 
     863                 :          0 :             nTypeId = TYP_GETREFFLD;
     864                 :          0 :             nSubType = REF_ENDNOTE;
     865                 :          0 :             aName.Erase();
     866                 :            : 
     867                 :          0 :             if (pSh->GetSeqFtnList(aArr, true) && aArr.SeekEntry(aElem, &nPos))
     868                 :            :             {
     869                 :          0 :                 aVal = String::CreateFromInt32( aArr[nPos]->nSeqNo );
     870                 :            : 
     871                 :          0 :                 if (IsFldEdit() && aArr[nPos]->nSeqNo == pRefFld->GetSeqNo())
     872                 :          0 :                     bModified = sal_True; // can happen with fields of which the reference was deleted
     873                 :            :             }
     874                 :          0 :             else if (IsFldEdit())
     875                 :          0 :                 aVal = String::CreateFromInt32( pRefFld->GetSeqNo() );
     876                 :            :         }
     877                 :            :         // #i83479#
     878                 :          0 :         else if ( nTypeId == REFFLDFLAG_HEADING )
     879                 :            :         {
     880                 :          0 :             SvLBoxEntry* pEntry = aSelectionToolTipLB.GetCurEntry();
     881                 :            :             OSL_ENSURE( pEntry,
     882                 :            :                     "<SwFldRefPage::FillItemSet(..)> - no entry selected in selection tool tip listbox!" );
     883                 :          0 :             if ( pEntry )
     884                 :            :             {
     885                 :          0 :                 const sal_uInt16 nOutlIdx( static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(pEntry->GetUserData())) );
     886                 :          0 :                 pSh->getIDocumentOutlineNodesAccess()->getOutlineNodes( maOutlineNodes );
     887                 :          0 :                 if ( nOutlIdx < maOutlineNodes.size() )
     888                 :            :                 {
     889                 :          0 :                     ::sw::mark::IMark const * const pMark = pSh->getIDocumentMarkAccess()->getMarkForTxtNode(
     890                 :          0 :                         *(maOutlineNodes[nOutlIdx]),
     891                 :          0 :                         IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK);
     892                 :          0 :                     aName = pMark->GetName();
     893                 :          0 :                     nTypeId = TYP_GETREFFLD;
     894                 :          0 :                     nSubType = REF_BOOKMARK;
     895                 :            :                 }
     896                 :            :             }
     897                 :            :         }
     898                 :          0 :         else if ( nTypeId == REFFLDFLAG_NUMITEM )
     899                 :            :         {
     900                 :          0 :             SvLBoxEntry* pEntry = aSelectionToolTipLB.GetCurEntry();
     901                 :            :             OSL_ENSURE( pEntry,
     902                 :            :                     "<SwFldRefPage::FillItemSet(..)> - no entry selected in selection tool tip listbox!" );
     903                 :          0 :             if ( pEntry )
     904                 :            :             {
     905                 :          0 :                 const sal_uInt16 nNumItemIdx( static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(pEntry->GetUserData())) );
     906                 :          0 :                 pSh->getIDocumentListItemsAccess()->getNumItems( maNumItems );
     907                 :          0 :                 if ( nNumItemIdx < maNumItems.size() )
     908                 :            :                 {
     909                 :          0 :                     ::sw::mark::IMark const * const pMark = pSh->getIDocumentMarkAccess()->getMarkForTxtNode(
     910                 :          0 :                         *(maNumItems[nNumItemIdx]->GetTxtNode()),
     911                 :          0 :                         IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK);
     912                 :          0 :                     aName = pMark->GetName();
     913                 :          0 :                     nTypeId = TYP_GETREFFLD;
     914                 :          0 :                     nSubType = REF_BOOKMARK;
     915                 :            :                 }
     916                 :            :             }
     917                 :            :         }
     918                 :            :         else                                // SeqenceFields
     919                 :            :         {
     920                 :            :             // get fields for Seq-FeldType:
     921                 :            :             SwSetExpFieldType* pType = (SwSetExpFieldType*)pSh->GetFldType(
     922                 :          0 :                                     nTypeId & ~REFFLDFLAG, RES_SETEXPFLD );
     923                 :          0 :             if( pType )
     924                 :            :             {
     925                 :          0 :                 SwSeqFldList aArr;
     926                 :          0 :                 _SeqFldLstElem aElem( aSelectionLB.GetSelectEntry(), 0 );
     927                 :            : 
     928                 :            :                 sal_uInt16 nPos;
     929                 :            : 
     930                 :          0 :                 nTypeId = TYP_GETREFFLD;
     931                 :          0 :                 nSubType = REF_SEQUENCEFLD;
     932                 :          0 :                 aName = pType->GetName();
     933                 :            : 
     934                 :          0 :                 if (pType->GetSeqFldList(aArr) && aArr.SeekEntry(aElem, &nPos))
     935                 :            :                 {
     936                 :          0 :                     aVal = String::CreateFromInt32( aArr[nPos]->nSeqNo );
     937                 :            : 
     938                 :          0 :                     if (IsFldEdit() && aArr[nPos]->nSeqNo == pRefFld->GetSeqNo())
     939                 :          0 :                         bModified = sal_True; // can happen with fields of which the reference was deleted
     940                 :            :                 }
     941                 :          0 :                 else if (IsFldEdit())
     942                 :          0 :                     aVal = String::CreateFromInt32( pRefFld->GetSeqNo() );
     943                 :            :             }
     944                 :            :         }
     945                 :            :     }
     946                 :            : 
     947                 :          0 :     if (IsFldEdit() && nTypeId == TYP_GETREFFLD)
     948                 :            :     {
     949                 :          0 :         aVal.Insert('|', 0);
     950                 :          0 :         aVal.Insert(String::CreateFromInt32(nSubType), 0);
     951                 :            :     }
     952                 :            : 
     953                 :          0 :     if (!IsFldEdit() || bModified ||
     954                 :          0 :         aNameED.GetSavedValue() != aNameED.GetText() ||
     955                 :          0 :         aValueED.GetSavedValue() != aValueED.GetText() ||
     956                 :          0 :         aTypeLB.GetSavedValue() != aTypeLB.GetSelectEntryPos() ||
     957                 :          0 :         aSelectionLB.GetSavedValue() != aSelectionLB.GetSelectEntryPos() ||
     958                 :          0 :         aFormatLB.GetSavedValue() != aFormatLB.GetSelectEntryPos())
     959                 :            :     {
     960                 :          0 :         InsertFld( nTypeId, nSubType, aName, aVal, nFormat );
     961                 :            :     }
     962                 :            : 
     963                 :          0 :     ModifyHdl();    // enable/disable insert if applicable
     964                 :            : 
     965                 :          0 :     return sal_False;
     966                 :            : }
     967                 :            : 
     968                 :          0 : SfxTabPage* SwFldRefPage::Create(   Window* pParent,
     969                 :            :                         const SfxItemSet& rAttrSet )
     970                 :            : {
     971                 :          0 :     return ( new SwFldRefPage( pParent, rAttrSet ) );
     972                 :            : }
     973                 :            : 
     974                 :          0 : sal_uInt16 SwFldRefPage::GetGroup()
     975                 :            : {
     976                 :          0 :     return GRP_REF;
     977                 :            : }
     978                 :            : 
     979                 :          0 : void    SwFldRefPage::FillUserData()
     980                 :            : {
     981                 :          0 :     String sData(rtl::OUString(USER_DATA_VERSION));
     982                 :          0 :     sData += ';';
     983                 :          0 :     sal_uInt16 nTypeSel = aTypeLB.GetSelectEntryPos();
     984                 :          0 :     if( LISTBOX_ENTRY_NOTFOUND == nTypeSel )
     985                 :          0 :         nTypeSel = USHRT_MAX;
     986                 :            :     else
     987                 :          0 :         nTypeSel = sal::static_int_cast< sal_uInt16 >(reinterpret_cast< sal_uIntPtr >(aTypeLB.GetEntryData( nTypeSel )));
     988                 :          0 :     sData += String::CreateFromInt32( nTypeSel );
     989                 :          0 :     SetUserData(sData);
     990                 :          0 : }
     991                 :            : 
     992                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10