1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION 28cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir 31cdf0e10cSrcweir 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include "swtypes.hxx" 34cdf0e10cSrcweir #include <view.hxx> 35cdf0e10cSrcweir #include <IMark.hxx> 36cdf0e10cSrcweir #include <expfld.hxx> 37cdf0e10cSrcweir #include <swmodule.hxx> 38cdf0e10cSrcweir #ifndef _FLDREF_HXX 39cdf0e10cSrcweir #include <fldref.hxx> 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir #include <reffld.hxx> 42cdf0e10cSrcweir #include <wrtsh.hxx> 43cdf0e10cSrcweir 44cdf0e10cSrcweir #ifndef _FLDUI_HRC 45cdf0e10cSrcweir #include <fldui.hrc> 46cdf0e10cSrcweir #endif 47cdf0e10cSrcweir #ifndef _FLDTDLG_HRC 48cdf0e10cSrcweir #include <fldtdlg.hrc> 49cdf0e10cSrcweir #endif 50cdf0e10cSrcweir #ifndef _GLOBALS_HRC 51cdf0e10cSrcweir #include <globals.hrc> 52cdf0e10cSrcweir #endif 53cdf0e10cSrcweir // --> OD 2007-11-14 #i83479# 54cdf0e10cSrcweir #include <SwNodeNum.hxx> 55cdf0e10cSrcweir #include <IDocumentMarkAccess.hxx> 56cdf0e10cSrcweir #include <ndtxt.hxx> 57cdf0e10cSrcweir // <-- 58cdf0e10cSrcweir 59cdf0e10cSrcweir // sw/inc/expfld.hxx 60cdf0e10cSrcweir SV_IMPL_PTRARR( _SwSeqFldList, _SeqFldLstElem* ) 61cdf0e10cSrcweir 62cdf0e10cSrcweir #define REFFLDFLAG 0x4000 63cdf0e10cSrcweir #define REFFLDFLAG_BOOKMARK 0x4800 64cdf0e10cSrcweir #define REFFLDFLAG_FOOTNOTE 0x5000 65cdf0e10cSrcweir #define REFFLDFLAG_ENDNOTE 0x6000 66cdf0e10cSrcweir // --> OD 2007-11-09 #i83479# 67cdf0e10cSrcweir #define REFFLDFLAG_HEADING 0x7100 68cdf0e10cSrcweir #define REFFLDFLAG_NUMITEM 0x7200 69cdf0e10cSrcweir // <-- 70cdf0e10cSrcweir 71cdf0e10cSrcweir sal_uInt16 nFldDlgFmtSel = 0; 72cdf0e10cSrcweir 73cdf0e10cSrcweir #define USER_DATA_VERSION_1 "1" 74cdf0e10cSrcweir #define USER_DATA_VERSION USER_DATA_VERSION_1 75cdf0e10cSrcweir 76cdf0e10cSrcweir 77cdf0e10cSrcweir /*-------------------------------------------------------------------- 78cdf0e10cSrcweir Beschreibung: 79cdf0e10cSrcweir --------------------------------------------------------------------*/ 80cdf0e10cSrcweir 81cdf0e10cSrcweir SwFldRefPage::SwFldRefPage(Window* pParent, const SfxItemSet& rCoreSet ) : 82cdf0e10cSrcweir SwFldPage( pParent, SW_RES( TP_FLD_REF ), rCoreSet ), 83cdf0e10cSrcweir 84cdf0e10cSrcweir aTypeFT (this, SW_RES(FT_REFTYPE)), 85cdf0e10cSrcweir aTypeLB (this, SW_RES(LB_REFTYPE)), 86cdf0e10cSrcweir aSelectionFT (this, SW_RES(FT_REFSELECTION)), 87cdf0e10cSrcweir aSelectionLB (this, SW_RES(LB_REFSELECTION)), 88cdf0e10cSrcweir // --> OD 2007-11-21 #i83479# 89cdf0e10cSrcweir aSelectionToolTipLB( this, SW_RES(LB_REFSELECTION_TOOLTIP) ), 90cdf0e10cSrcweir // <-- 91cdf0e10cSrcweir aFormatFT (this, SW_RES(FT_REFFORMAT)), 92cdf0e10cSrcweir aFormatLB (this, SW_RES(LB_REFFORMAT)), 93cdf0e10cSrcweir aNameFT (this, SW_RES(FT_REFNAME)), 94cdf0e10cSrcweir aNameED (this, SW_RES(ED_REFNAME)), 95cdf0e10cSrcweir aValueFT (this, SW_RES(FT_REFVALUE)), 96cdf0e10cSrcweir aValueED (this, SW_RES(ED_REFVALUE)), 97cdf0e10cSrcweir 98cdf0e10cSrcweir sBookmarkTxt (SW_RES(STR_REFBOOKMARK)), 99cdf0e10cSrcweir sFootnoteTxt (SW_RES(STR_REFFOOTNOTE)), 100cdf0e10cSrcweir sEndnoteTxt (SW_RES(STR_REFENDNOTE)), 101cdf0e10cSrcweir // --> OD 2007-11-09 #i83479# 102cdf0e10cSrcweir sHeadingTxt (SW_RES(STR_REFHEADING)), 103cdf0e10cSrcweir sNumItemTxt (SW_RES(STR_REFNUMITEM)), 104cdf0e10cSrcweir maOutlineNodes(), 105cdf0e10cSrcweir maNumItems(), 106cdf0e10cSrcweir mpSavedSelectedTxtNode( 0 ), 107cdf0e10cSrcweir mnSavedSelectedPos( 0 ) 108cdf0e10cSrcweir // <-- 109cdf0e10cSrcweir { 110cdf0e10cSrcweir FreeResource(); 111cdf0e10cSrcweir 112cdf0e10cSrcweir aNameED.SetModifyHdl(LINK(this, SwFldRefPage, ModifyHdl)); 113cdf0e10cSrcweir 114cdf0e10cSrcweir aTypeLB.SetDoubleClickHdl (LINK(this, SwFldRefPage, InsertHdl)); 115cdf0e10cSrcweir aTypeLB.SetSelectHdl (LINK(this, SwFldRefPage, TypeHdl)); 116cdf0e10cSrcweir aSelectionLB.SetSelectHdl (LINK(this, SwFldRefPage, SubTypeHdl)); 117cdf0e10cSrcweir aSelectionLB.SetDoubleClickHdl (LINK(this, SwFldRefPage, InsertHdl)); 118cdf0e10cSrcweir aFormatLB.SetDoubleClickHdl (LINK(this, SwFldRefPage, InsertHdl)); 119cdf0e10cSrcweir 120cdf0e10cSrcweir // --> OD 2007-11-21 #i83479# 121cdf0e10cSrcweir aSelectionToolTipLB.SetSelectHdl( LINK(this, SwFldRefPage, SubTypeHdl) ); 122cdf0e10cSrcweir aSelectionToolTipLB.SetDoubleClickHdl( LINK(this, SwFldRefPage, InsertHdl) ); 123cdf0e10cSrcweir aSelectionToolTipLB.SetStyle( aSelectionToolTipLB.GetStyle() | WB_HSCROLL ); 124cdf0e10cSrcweir aSelectionToolTipLB.SetSpaceBetweenEntries(1); 125cdf0e10cSrcweir aSelectionToolTipLB.SetHighlightRange(); 126cdf0e10cSrcweir // <-- 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir /*-------------------------------------------------------------------- 130cdf0e10cSrcweir Beschreibung: 131cdf0e10cSrcweir --------------------------------------------------------------------*/ 132cdf0e10cSrcweir 133cdf0e10cSrcweir SwFldRefPage::~SwFldRefPage() 134cdf0e10cSrcweir { 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir // --> OD 2007-11-22 #i83479# 138cdf0e10cSrcweir void SwFldRefPage::SaveSelectedTxtNode() 139cdf0e10cSrcweir { 140cdf0e10cSrcweir mpSavedSelectedTxtNode = 0; 141cdf0e10cSrcweir mnSavedSelectedPos = 0; 142cdf0e10cSrcweir if ( aSelectionToolTipLB.IsVisible() ) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir SvLBoxEntry* pEntry = aSelectionToolTipLB.GetCurEntry(); 145cdf0e10cSrcweir if ( pEntry ) 146cdf0e10cSrcweir { 147cdf0e10cSrcweir const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 148cdf0e10cSrcweir SwWrtShell *pSh = GetWrtShell(); 149cdf0e10cSrcweir if ( !pSh ) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir pSh = ::GetActiveWrtShell(); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir if ( nTypeId == REFFLDFLAG_HEADING ) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir mnSavedSelectedPos = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(pEntry->GetUserData())); 156cdf0e10cSrcweir if ( mnSavedSelectedPos < maOutlineNodes.size() ) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir mpSavedSelectedTxtNode = maOutlineNodes[mnSavedSelectedPos]; 159cdf0e10cSrcweir } 160cdf0e10cSrcweir } 161cdf0e10cSrcweir else if ( nTypeId == REFFLDFLAG_NUMITEM ) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir mnSavedSelectedPos = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(pEntry->GetUserData())); 164cdf0e10cSrcweir if ( mnSavedSelectedPos < maNumItems.size() ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir mpSavedSelectedTxtNode = maNumItems[mnSavedSelectedPos]->GetTxtNode(); 167cdf0e10cSrcweir } 168cdf0e10cSrcweir } 169cdf0e10cSrcweir } 170cdf0e10cSrcweir } 171cdf0e10cSrcweir } 172cdf0e10cSrcweir 173cdf0e10cSrcweir const SwTxtNode* SwFldRefPage::GetSavedSelectedTxtNode() const 174cdf0e10cSrcweir { 175cdf0e10cSrcweir return mpSavedSelectedTxtNode; 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir sal_uInt16 SwFldRefPage::GetSavedSelectedPos() const 179cdf0e10cSrcweir { 180cdf0e10cSrcweir return mnSavedSelectedPos; 181cdf0e10cSrcweir } 182cdf0e10cSrcweir 183cdf0e10cSrcweir // <-- 184cdf0e10cSrcweir 185cdf0e10cSrcweir /*-------------------------------------------------------------------- 186cdf0e10cSrcweir Beschreibung: 187cdf0e10cSrcweir --------------------------------------------------------------------*/ 188cdf0e10cSrcweir 189cdf0e10cSrcweir void SwFldRefPage::Reset(const SfxItemSet& ) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir if (!IsFldEdit()) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir SavePos(&aTypeLB); 194cdf0e10cSrcweir // --> OD 2007-11-22 #i83479# 195cdf0e10cSrcweir SaveSelectedTxtNode(); 196cdf0e10cSrcweir // <-- 197cdf0e10cSrcweir } 198cdf0e10cSrcweir SetSelectionSel(LISTBOX_ENTRY_NOTFOUND); 199cdf0e10cSrcweir SetTypeSel(LISTBOX_ENTRY_NOTFOUND); 200cdf0e10cSrcweir Init(); // Allgemeine initialisierung 201cdf0e10cSrcweir 202cdf0e10cSrcweir // TypeListBox initialisieren 203cdf0e10cSrcweir aTypeLB.SetUpdateMode(sal_False); 204cdf0e10cSrcweir aTypeLB.Clear(); 205cdf0e10cSrcweir 206cdf0e10cSrcweir // Typ-Listbox fuellen 207cdf0e10cSrcweir 208cdf0e10cSrcweir sal_uInt16 nPos; 209cdf0e10cSrcweir // Referenz setzen / einfuegen 210cdf0e10cSrcweir const SwFldGroupRgn& rRg = GetFldMgr().GetGroupRange(IsFldDlgHtmlMode(), GetGroup()); 211cdf0e10cSrcweir 212cdf0e10cSrcweir for (short i = rRg.nStart; i < rRg.nEnd; ++i) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir const sal_uInt16 nTypeId = GetFldMgr().GetTypeId(i); 215cdf0e10cSrcweir 216cdf0e10cSrcweir if (!IsFldEdit() || nTypeId != TYP_SETREFFLD) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(i), i - rRg.nStart); 219cdf0e10cSrcweir aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId)); 220cdf0e10cSrcweir } 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir // --> OD 2007-11-09 #i83479# 224cdf0e10cSrcweir // entries for headings and numbered items 225cdf0e10cSrcweir nPos = aTypeLB.InsertEntry(sHeadingTxt); 226cdf0e10cSrcweir aTypeLB.SetEntryData(nPos, (void*)REFFLDFLAG_HEADING); 227cdf0e10cSrcweir nPos = aTypeLB.InsertEntry(sNumItemTxt); 228cdf0e10cSrcweir aTypeLB.SetEntryData(nPos, (void*)REFFLDFLAG_NUMITEM); 229cdf0e10cSrcweir // <-- 230cdf0e10cSrcweir 231cdf0e10cSrcweir // mit den Sequence-Typen auffuellen 232cdf0e10cSrcweir SwWrtShell *pSh = GetWrtShell(); 233cdf0e10cSrcweir if(!pSh) 234cdf0e10cSrcweir pSh = ::GetActiveWrtShell(); 235cdf0e10cSrcweir 236cdf0e10cSrcweir sal_uInt16 nFldTypeCnt = pSh->GetFldTypeCount(RES_SETEXPFLD); 237cdf0e10cSrcweir 238cdf0e10cSrcweir for (sal_uInt16 n = 0; n < nFldTypeCnt; ++n) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir SwSetExpFieldType* pType = (SwSetExpFieldType*)pSh->GetFldType(n, RES_SETEXPFLD); 241cdf0e10cSrcweir 242cdf0e10cSrcweir if ((nsSwGetSetExpType::GSE_SEQ & pType->GetType()) && pType->GetDepends() && pSh->IsUsed(*pType)) 243cdf0e10cSrcweir { 244cdf0e10cSrcweir nPos = aTypeLB.InsertEntry(pType->GetName()); 245cdf0e10cSrcweir aTypeLB.SetEntryData(nPos, (void*)(REFFLDFLAG | n)); 246cdf0e10cSrcweir } 247cdf0e10cSrcweir } 248cdf0e10cSrcweir 249cdf0e10cSrcweir // Textmarken - jetzt immer (wegen Globaldokumenten) 250cdf0e10cSrcweir nPos = aTypeLB.InsertEntry(sBookmarkTxt); 251cdf0e10cSrcweir aTypeLB.SetEntryData(nPos, (void*)REFFLDFLAG_BOOKMARK); 252cdf0e10cSrcweir 253cdf0e10cSrcweir // Fussnoten: 254cdf0e10cSrcweir if( pSh->HasFtns() ) 255cdf0e10cSrcweir { 256cdf0e10cSrcweir nPos = aTypeLB.InsertEntry(sFootnoteTxt); 257cdf0e10cSrcweir aTypeLB.SetEntryData(nPos, (void*)REFFLDFLAG_FOOTNOTE); 258cdf0e10cSrcweir } 259cdf0e10cSrcweir 260cdf0e10cSrcweir // Endnoten: 261cdf0e10cSrcweir if ( pSh->HasFtns(true) ) 262cdf0e10cSrcweir { 263cdf0e10cSrcweir nPos = aTypeLB.InsertEntry(sEndnoteTxt); 264cdf0e10cSrcweir aTypeLB.SetEntryData(nPos, (void*)REFFLDFLAG_ENDNOTE); 265cdf0e10cSrcweir } 266cdf0e10cSrcweir 267cdf0e10cSrcweir // alte Pos selektieren 268cdf0e10cSrcweir if (!IsFldEdit()) 269cdf0e10cSrcweir RestorePos(&aTypeLB); 270cdf0e10cSrcweir 271cdf0e10cSrcweir aTypeLB.SetUpdateMode(sal_True); 272cdf0e10cSrcweir 273cdf0e10cSrcweir nFldDlgFmtSel = 0; 274cdf0e10cSrcweir 275cdf0e10cSrcweir if( !IsRefresh() ) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir String sUserData = GetUserData(); 278cdf0e10cSrcweir if(!IsRefresh() && sUserData.GetToken(0, ';'). 279cdf0e10cSrcweir EqualsIgnoreCaseAscii(USER_DATA_VERSION_1)) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir String sVal = sUserData.GetToken(1, ';'); 282cdf0e10cSrcweir sal_uInt16 nVal = static_cast< sal_uInt16 >(sVal.ToInt32()); 283cdf0e10cSrcweir if(nVal != USHRT_MAX) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir for(sal_uInt16 i = 0; i < aTypeLB.GetEntryCount(); i++) 286cdf0e10cSrcweir if(nVal == (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(i)) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir aTypeLB.SelectEntryPos(i); 289cdf0e10cSrcweir break; 290cdf0e10cSrcweir } 291cdf0e10cSrcweir } 292cdf0e10cSrcweir } 293cdf0e10cSrcweir } 294cdf0e10cSrcweir TypeHdl(0); 295cdf0e10cSrcweir 296cdf0e10cSrcweir if (IsFldEdit()) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir aTypeLB.SaveValue(); 299cdf0e10cSrcweir aSelectionLB.SaveValue(); 300cdf0e10cSrcweir aFormatLB.SaveValue(); 301cdf0e10cSrcweir aNameED.SaveValue(); 302cdf0e10cSrcweir aValueED.SaveValue(); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir } 305cdf0e10cSrcweir 306cdf0e10cSrcweir /*-------------------------------------------------------------------- 307cdf0e10cSrcweir Beschreibung: 308cdf0e10cSrcweir --------------------------------------------------------------------*/ 309cdf0e10cSrcweir 310cdf0e10cSrcweir IMPL_LINK( SwFldRefPage, TypeHdl, ListBox *, EMPTYARG ) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir // Alte ListBoxPos sichern 313cdf0e10cSrcweir const sal_uInt16 nOld = GetTypeSel(); 314cdf0e10cSrcweir 315cdf0e10cSrcweir // Aktuelle ListBoxPos 316cdf0e10cSrcweir SetTypeSel(aTypeLB.GetSelectEntryPos()); 317cdf0e10cSrcweir 318cdf0e10cSrcweir if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND) 319cdf0e10cSrcweir { 320cdf0e10cSrcweir if (IsFldEdit()) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir // Positionen selektieren 323cdf0e10cSrcweir String sName; 324cdf0e10cSrcweir sal_uInt16 nFlag = 0; 325cdf0e10cSrcweir 326cdf0e10cSrcweir switch( GetCurField()->GetSubType() ) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir case REF_BOOKMARK: 329cdf0e10cSrcweir { 330cdf0e10cSrcweir // --> OD 2007-11-14 #i83479# 331cdf0e10cSrcweir // sName = sBookmarkTxt; 332cdf0e10cSrcweir // nFlag = REFFLDFLAG_BOOKMARK; 333cdf0e10cSrcweir SwGetRefField* pRefFld = dynamic_cast<SwGetRefField*>(GetCurField()); 334cdf0e10cSrcweir if ( pRefFld && 335cdf0e10cSrcweir pRefFld->IsRefToHeadingCrossRefBookmark() ) 336cdf0e10cSrcweir { 337cdf0e10cSrcweir sName = sHeadingTxt; 338cdf0e10cSrcweir nFlag = REFFLDFLAG_HEADING; 339cdf0e10cSrcweir } 340cdf0e10cSrcweir else if ( pRefFld && 341cdf0e10cSrcweir pRefFld->IsRefToNumItemCrossRefBookmark() ) 342cdf0e10cSrcweir { 343cdf0e10cSrcweir sName = sNumItemTxt; 344cdf0e10cSrcweir nFlag = REFFLDFLAG_NUMITEM; 345cdf0e10cSrcweir } 346cdf0e10cSrcweir else 347cdf0e10cSrcweir { 348cdf0e10cSrcweir sName = sBookmarkTxt; 349cdf0e10cSrcweir nFlag = REFFLDFLAG_BOOKMARK; 350cdf0e10cSrcweir } 351cdf0e10cSrcweir // <-- 352cdf0e10cSrcweir } 353cdf0e10cSrcweir break; 354cdf0e10cSrcweir 355cdf0e10cSrcweir case REF_FOOTNOTE: 356cdf0e10cSrcweir sName = sFootnoteTxt; 357cdf0e10cSrcweir nFlag = REFFLDFLAG_FOOTNOTE; 358cdf0e10cSrcweir break; 359cdf0e10cSrcweir 360cdf0e10cSrcweir case REF_ENDNOTE: 361cdf0e10cSrcweir sName = sEndnoteTxt; 362cdf0e10cSrcweir nFlag = REFFLDFLAG_ENDNOTE; 363cdf0e10cSrcweir break; 364cdf0e10cSrcweir 365cdf0e10cSrcweir case REF_SETREFATTR: 366cdf0e10cSrcweir sName = SW_RESSTR(STR_GETREFFLD); 367cdf0e10cSrcweir nFlag = REF_SETREFATTR; 368cdf0e10cSrcweir break; 369cdf0e10cSrcweir 370cdf0e10cSrcweir case REF_SEQUENCEFLD: 371cdf0e10cSrcweir sName = ((SwGetRefField*)GetCurField())->GetSetRefName(); 372cdf0e10cSrcweir nFlag = REFFLDFLAG; 373cdf0e10cSrcweir break; 374cdf0e10cSrcweir } 375cdf0e10cSrcweir 376cdf0e10cSrcweir if (aTypeLB.GetEntryPos(sName) == LISTBOX_ENTRY_NOTFOUND) // Referenz zu gel?schter Marke 377cdf0e10cSrcweir { 378cdf0e10cSrcweir sal_uInt16 nPos = aTypeLB.InsertEntry(sName); 379cdf0e10cSrcweir aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nFlag)); 380cdf0e10cSrcweir } 381cdf0e10cSrcweir 382cdf0e10cSrcweir aTypeLB.SelectEntry(sName); 383cdf0e10cSrcweir SetTypeSel(aTypeLB.GetSelectEntryPos()); 384cdf0e10cSrcweir } 385cdf0e10cSrcweir else 386cdf0e10cSrcweir { 387cdf0e10cSrcweir SetTypeSel(0); 388cdf0e10cSrcweir aTypeLB.SelectEntryPos(0); 389cdf0e10cSrcweir } 390cdf0e10cSrcweir } 391cdf0e10cSrcweir 392cdf0e10cSrcweir if (nOld != GetTypeSel()) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 395cdf0e10cSrcweir 396cdf0e10cSrcweir // Auswahl-Listbox fuellen 397cdf0e10cSrcweir UpdateSubType(); 398cdf0e10cSrcweir 399cdf0e10cSrcweir sal_Bool bName = sal_False; nFldDlgFmtSel = 0; 400cdf0e10cSrcweir 401cdf0e10cSrcweir if ( ( !IsFldEdit() || aSelectionLB.GetEntryCount() ) && 402cdf0e10cSrcweir nOld != LISTBOX_ENTRY_NOTFOUND ) 403cdf0e10cSrcweir { 404cdf0e10cSrcweir aNameED.SetText(aEmptyStr); 405cdf0e10cSrcweir aValueED.SetText(aEmptyStr); 406cdf0e10cSrcweir } 407cdf0e10cSrcweir 408cdf0e10cSrcweir switch (nTypeId) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir case TYP_GETREFFLD: 411cdf0e10cSrcweir if (REFFLDFLAG & (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(nOld)) 412cdf0e10cSrcweir // dann bleibt die alte bestehen 413cdf0e10cSrcweir nFldDlgFmtSel = aFormatLB.GetSelectEntryPos(); 414cdf0e10cSrcweir bName = sal_True; 415cdf0e10cSrcweir break; 416cdf0e10cSrcweir 417cdf0e10cSrcweir case TYP_SETREFFLD: 418cdf0e10cSrcweir bName = sal_True; 419cdf0e10cSrcweir break; 420cdf0e10cSrcweir 421cdf0e10cSrcweir case REFFLDFLAG_BOOKMARK: 422cdf0e10cSrcweir bName = sal_True; 423cdf0e10cSrcweir // kein break!!! 424cdf0e10cSrcweir default: 425cdf0e10cSrcweir if( REFFLDFLAG & nTypeId ) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir sal_uInt16 nOldId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(nOld); 428cdf0e10cSrcweir if( nOldId & REFFLDFLAG || nOldId == TYP_GETREFFLD ) 429cdf0e10cSrcweir // dann bleibt die alte bestehen 430cdf0e10cSrcweir nFldDlgFmtSel = aFormatLB.GetSelectEntryPos(); 431cdf0e10cSrcweir } 432cdf0e10cSrcweir break; 433cdf0e10cSrcweir } 434cdf0e10cSrcweir 435cdf0e10cSrcweir aNameED.Enable(bName); 436cdf0e10cSrcweir aNameFT.Enable(bName); 437cdf0e10cSrcweir 438cdf0e10cSrcweir // Format-Listbox fuellen 439cdf0e10cSrcweir sal_uInt16 nSize = FillFormatLB(nTypeId); 440cdf0e10cSrcweir sal_Bool bFormat = nSize != 0; 441cdf0e10cSrcweir aFormatLB.Enable(bFormat); 442cdf0e10cSrcweir aFormatFT.Enable(bFormat); 443cdf0e10cSrcweir 444cdf0e10cSrcweir SubTypeHdl(); 445cdf0e10cSrcweir ModifyHdl(); 446cdf0e10cSrcweir } 447cdf0e10cSrcweir 448cdf0e10cSrcweir return 0; 449cdf0e10cSrcweir } 450cdf0e10cSrcweir 451cdf0e10cSrcweir /*-------------------------------------------------------------------- 452cdf0e10cSrcweir Beschreibung: 453cdf0e10cSrcweir --------------------------------------------------------------------*/ 454cdf0e10cSrcweir 455cdf0e10cSrcweir IMPL_LINK( SwFldRefPage, SubTypeHdl, ListBox *, EMPTYARG ) 456cdf0e10cSrcweir { 457cdf0e10cSrcweir sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 458cdf0e10cSrcweir 459cdf0e10cSrcweir switch(nTypeId) 460cdf0e10cSrcweir { 461cdf0e10cSrcweir case TYP_GETREFFLD: 462cdf0e10cSrcweir if (!IsFldEdit() || aSelectionLB.GetSelectEntryCount()) 463cdf0e10cSrcweir { 464cdf0e10cSrcweir aNameED.SetText(aSelectionLB.GetSelectEntry()); 465cdf0e10cSrcweir ModifyHdl(&aNameED); 466cdf0e10cSrcweir } 467cdf0e10cSrcweir break; 468cdf0e10cSrcweir 469cdf0e10cSrcweir case TYP_SETREFFLD: 470cdf0e10cSrcweir { 471cdf0e10cSrcweir SwWrtShell *pSh = GetWrtShell(); 472cdf0e10cSrcweir if(!pSh) 473cdf0e10cSrcweir pSh = ::GetActiveWrtShell(); 474cdf0e10cSrcweir if(pSh) 475cdf0e10cSrcweir { 476cdf0e10cSrcweir aValueED.SetText(pSh->GetSelTxt()); 477cdf0e10cSrcweir } 478cdf0e10cSrcweir 479cdf0e10cSrcweir } 480cdf0e10cSrcweir break; 481cdf0e10cSrcweir // --> OD 2007-11-21 #i83479# 482cdf0e10cSrcweir case REFFLDFLAG_HEADING: 483cdf0e10cSrcweir case REFFLDFLAG_NUMITEM: 484cdf0e10cSrcweir { 485cdf0e10cSrcweir if ( aSelectionToolTipLB.GetCurEntry() ) 486cdf0e10cSrcweir { 487cdf0e10cSrcweir aNameED.SetText( aSelectionToolTipLB.GetEntryText( 488cdf0e10cSrcweir aSelectionToolTipLB.GetCurEntry() ) ); 489cdf0e10cSrcweir } 490cdf0e10cSrcweir } 491cdf0e10cSrcweir break; 492cdf0e10cSrcweir // <-- 493cdf0e10cSrcweir 494cdf0e10cSrcweir default: 495cdf0e10cSrcweir if (!IsFldEdit() || aSelectionLB.GetSelectEntryCount()) 496cdf0e10cSrcweir aNameED.SetText(aSelectionLB.GetSelectEntry()); 497cdf0e10cSrcweir break; 498cdf0e10cSrcweir } 499cdf0e10cSrcweir 500cdf0e10cSrcweir return 0; 501cdf0e10cSrcweir } 502cdf0e10cSrcweir 503cdf0e10cSrcweir /*-------------------------------------------------------------------- 504cdf0e10cSrcweir Beschreibung: Typen in SelectionLB erneuern 505cdf0e10cSrcweir --------------------------------------------------------------------*/ 506cdf0e10cSrcweir 507cdf0e10cSrcweir void SwFldRefPage::UpdateSubType() 508cdf0e10cSrcweir { 509cdf0e10cSrcweir SwWrtShell *pSh = GetWrtShell(); 510cdf0e10cSrcweir if(!pSh) 511cdf0e10cSrcweir pSh = ::GetActiveWrtShell(); 512cdf0e10cSrcweir SwGetRefField* pRefFld = (SwGetRefField*)GetCurField(); 513cdf0e10cSrcweir const sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 514cdf0e10cSrcweir 515cdf0e10cSrcweir String sOldSel; 516cdf0e10cSrcweir // --> OD 2007-11-22 #i83479# 517cdf0e10cSrcweir if ( aSelectionLB.IsVisible() ) 518cdf0e10cSrcweir { 519cdf0e10cSrcweir const sal_uInt16 nSelectionSel = aSelectionLB.GetSelectEntryPos(); 520cdf0e10cSrcweir if (nSelectionSel != LISTBOX_ENTRY_NOTFOUND) 521cdf0e10cSrcweir { 522cdf0e10cSrcweir sOldSel = aSelectionLB.GetEntry(nSelectionSel); 523cdf0e10cSrcweir } 524cdf0e10cSrcweir } 525cdf0e10cSrcweir // <-- 526cdf0e10cSrcweir if (IsFldEdit() && !sOldSel.Len()) 527cdf0e10cSrcweir sOldSel = String::CreateFromInt32( pRefFld->GetSeqNo() + 1 ); 528cdf0e10cSrcweir 529cdf0e10cSrcweir aSelectionLB.SetUpdateMode(sal_False); 530cdf0e10cSrcweir aSelectionLB.Clear(); 531cdf0e10cSrcweir // --> OD 2007-11-21 #i83479# 532cdf0e10cSrcweir aSelectionToolTipLB.SetUpdateMode(sal_False); 533cdf0e10cSrcweir aSelectionToolTipLB.Clear(); 534cdf0e10cSrcweir bool bShowSelectionToolTipLB( false ); 535cdf0e10cSrcweir // <-- 536cdf0e10cSrcweir 537cdf0e10cSrcweir if( REFFLDFLAG & nTypeId ) 538cdf0e10cSrcweir { 539cdf0e10cSrcweir if (nTypeId == REFFLDFLAG_BOOKMARK) // TextMarken! 540cdf0e10cSrcweir { 541cdf0e10cSrcweir aSelectionLB.SetStyle(aSelectionLB.GetStyle()|WB_SORT); 542cdf0e10cSrcweir // alle Textmarken besorgen 543cdf0e10cSrcweir IDocumentMarkAccess* const pMarkAccess = pSh->getIDocumentMarkAccess(); 544cdf0e10cSrcweir for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin(); 545cdf0e10cSrcweir ppMark != pMarkAccess->getBookmarksEnd(); 546cdf0e10cSrcweir ppMark++) 547cdf0e10cSrcweir { 548cdf0e10cSrcweir const ::sw::mark::IMark* pBkmk = ppMark->get(); 549cdf0e10cSrcweir if(IDocumentMarkAccess::BOOKMARK == IDocumentMarkAccess::GetType(*pBkmk)) 550cdf0e10cSrcweir aSelectionLB.InsertEntry( pBkmk->GetName() ); 551cdf0e10cSrcweir } 552cdf0e10cSrcweir if (IsFldEdit()) 553cdf0e10cSrcweir sOldSel = pRefFld->GetSetRefName(); 554cdf0e10cSrcweir } 555cdf0e10cSrcweir else if (nTypeId == REFFLDFLAG_FOOTNOTE) 556cdf0e10cSrcweir { 557cdf0e10cSrcweir aSelectionLB.SetStyle(aSelectionLB.GetStyle() & ~WB_SORT); 558cdf0e10cSrcweir SwSeqFldList aArr; 559cdf0e10cSrcweir sal_uInt16 nCnt = pSh->GetSeqFtnList( aArr ); 560cdf0e10cSrcweir 561cdf0e10cSrcweir for( sal_uInt16 n = 0; n < nCnt; ++n ) 562cdf0e10cSrcweir { 563cdf0e10cSrcweir aSelectionLB.InsertEntry( aArr[ n ]->sDlgEntry ); 564cdf0e10cSrcweir if (IsFldEdit() && pRefFld->GetSeqNo() == aArr[ n ]->nSeqNo) 565cdf0e10cSrcweir sOldSel = aArr[n]->sDlgEntry; 566cdf0e10cSrcweir } 567cdf0e10cSrcweir } 568cdf0e10cSrcweir else if (nTypeId == REFFLDFLAG_ENDNOTE) 569cdf0e10cSrcweir { 570cdf0e10cSrcweir aSelectionLB.SetStyle(aSelectionLB.GetStyle() & ~WB_SORT); 571cdf0e10cSrcweir SwSeqFldList aArr; 572cdf0e10cSrcweir sal_uInt16 nCnt = pSh->GetSeqFtnList( aArr, true ); 573cdf0e10cSrcweir 574cdf0e10cSrcweir for( sal_uInt16 n = 0; n < nCnt; ++n ) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir aSelectionLB.InsertEntry( aArr[ n ]->sDlgEntry ); 577cdf0e10cSrcweir if (IsFldEdit() && pRefFld->GetSeqNo() == aArr[ n ]->nSeqNo) 578cdf0e10cSrcweir sOldSel = aArr[n]->sDlgEntry; 579cdf0e10cSrcweir } 580cdf0e10cSrcweir } 581cdf0e10cSrcweir // --> OD 2007-11-14 #i83479# 582cdf0e10cSrcweir else if ( nTypeId == REFFLDFLAG_HEADING ) 583cdf0e10cSrcweir { 584cdf0e10cSrcweir bShowSelectionToolTipLB = true; 585cdf0e10cSrcweir 586cdf0e10cSrcweir const IDocumentOutlineNodes* pIDoc( pSh->getIDocumentOutlineNodesAccess() ); 587cdf0e10cSrcweir pIDoc->getOutlineNodes( maOutlineNodes ); 588cdf0e10cSrcweir bool bCertainTxtNodeSelected( false ); 589cdf0e10cSrcweir SvLBoxEntry* pEntry = 0; 590cdf0e10cSrcweir sal_uInt16 nOutlIdx = 0; 591cdf0e10cSrcweir for ( nOutlIdx = 0; nOutlIdx < maOutlineNodes.size(); ++nOutlIdx ) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir pEntry = aSelectionToolTipLB.InsertEntry( 594cdf0e10cSrcweir pIDoc->getOutlineText( nOutlIdx, true, true ) ); 595cdf0e10cSrcweir pEntry->SetUserData( reinterpret_cast<void*>(nOutlIdx) ); 596cdf0e10cSrcweir if ( ( IsFldEdit() && 597cdf0e10cSrcweir pRefFld->GetReferencedTxtNode() == maOutlineNodes[nOutlIdx] ) || 598cdf0e10cSrcweir GetSavedSelectedTxtNode() == maOutlineNodes[nOutlIdx] ) 599cdf0e10cSrcweir { 600cdf0e10cSrcweir aSelectionToolTipLB.Select( pEntry ); 601cdf0e10cSrcweir sOldSel.Erase(); 602cdf0e10cSrcweir bCertainTxtNodeSelected = true; 603cdf0e10cSrcweir } 604cdf0e10cSrcweir else if ( !bCertainTxtNodeSelected && 605cdf0e10cSrcweir GetSavedSelectedPos() == nOutlIdx ) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir aSelectionToolTipLB.Select( pEntry ); 608cdf0e10cSrcweir sOldSel.Erase(); 609cdf0e10cSrcweir } 610cdf0e10cSrcweir } 611cdf0e10cSrcweir } 612cdf0e10cSrcweir else if ( nTypeId == REFFLDFLAG_NUMITEM ) 613cdf0e10cSrcweir { 614cdf0e10cSrcweir bShowSelectionToolTipLB = true; 615cdf0e10cSrcweir 616cdf0e10cSrcweir const IDocumentListItems* pIDoc( pSh->getIDocumentListItemsAccess() ); 617cdf0e10cSrcweir pIDoc->getNumItems( maNumItems ); 618cdf0e10cSrcweir bool bCertainTxtNodeSelected( false ); 619cdf0e10cSrcweir SvLBoxEntry* pEntry = 0; 620cdf0e10cSrcweir sal_uInt16 nNumItemIdx = 0; 621cdf0e10cSrcweir for ( nNumItemIdx = 0; nNumItemIdx < maNumItems.size(); ++nNumItemIdx ) 622cdf0e10cSrcweir { 623cdf0e10cSrcweir pEntry = aSelectionToolTipLB.InsertEntry( 624cdf0e10cSrcweir pIDoc->getListItemText( *maNumItems[nNumItemIdx], true, true ) ); 625cdf0e10cSrcweir pEntry->SetUserData( reinterpret_cast<void*>(nNumItemIdx) ); 626cdf0e10cSrcweir if ( ( IsFldEdit() && 627cdf0e10cSrcweir pRefFld->GetReferencedTxtNode() == maNumItems[nNumItemIdx]->GetTxtNode() ) || 628cdf0e10cSrcweir GetSavedSelectedTxtNode() == maNumItems[nNumItemIdx]->GetTxtNode() ) 629cdf0e10cSrcweir { 630cdf0e10cSrcweir aSelectionToolTipLB.Select( pEntry ); 631cdf0e10cSrcweir sOldSel.Erase(); 632cdf0e10cSrcweir bCertainTxtNodeSelected = true; 633cdf0e10cSrcweir } 634cdf0e10cSrcweir else if ( !bCertainTxtNodeSelected && 635cdf0e10cSrcweir GetSavedSelectedPos() == nNumItemIdx ) 636cdf0e10cSrcweir { 637cdf0e10cSrcweir aSelectionToolTipLB.Select( pEntry ); 638cdf0e10cSrcweir sOldSel.Erase(); 639cdf0e10cSrcweir } 640cdf0e10cSrcweir } 641cdf0e10cSrcweir } 642cdf0e10cSrcweir // <-- 643cdf0e10cSrcweir else 644cdf0e10cSrcweir { 645cdf0e10cSrcweir aSelectionLB.SetStyle(aSelectionLB.GetStyle()|WB_SORT); 646cdf0e10cSrcweir // zum Seq-FeldTyp die Felder besorgen: 647cdf0e10cSrcweir 648cdf0e10cSrcweir SwSetExpFieldType* pType = (SwSetExpFieldType*)pSh->GetFldType( 649cdf0e10cSrcweir nTypeId & ~REFFLDFLAG, RES_SETEXPFLD ); 650cdf0e10cSrcweir if( pType ) 651cdf0e10cSrcweir { 652cdf0e10cSrcweir SwSeqFldList aArr; 653cdf0e10cSrcweir // old selection should be kept in non-edit mode 654cdf0e10cSrcweir if(IsFldEdit()) 655cdf0e10cSrcweir sOldSel.Erase(); 656cdf0e10cSrcweir 657cdf0e10cSrcweir sal_uInt16 nCnt = pType->GetSeqFldList( aArr ); 658cdf0e10cSrcweir for( sal_uInt16 n = 0; n < nCnt; ++n ) 659cdf0e10cSrcweir { 660cdf0e10cSrcweir aSelectionLB.InsertEntry( aArr[ n ]->sDlgEntry ); 661cdf0e10cSrcweir if (IsFldEdit() && !sOldSel.Len() && 662cdf0e10cSrcweir aArr[ n ]->nSeqNo == pRefFld->GetSeqNo()) 663cdf0e10cSrcweir sOldSel = aArr[ n ]->sDlgEntry; 664cdf0e10cSrcweir } 665cdf0e10cSrcweir 666cdf0e10cSrcweir if (IsFldEdit() && !sOldSel.Len()) 667cdf0e10cSrcweir sOldSel = String::CreateFromInt32( pRefFld->GetSeqNo() + 1); 668cdf0e10cSrcweir } 669cdf0e10cSrcweir } 670cdf0e10cSrcweir } 671cdf0e10cSrcweir else 672cdf0e10cSrcweir { 673cdf0e10cSrcweir SvStringsDtor aLst; 674cdf0e10cSrcweir GetFldMgr().GetSubTypes(nTypeId, aLst); 675cdf0e10cSrcweir for (sal_uInt16 i = 0; i < aLst.Count(); ++i) 676cdf0e10cSrcweir aSelectionLB.InsertEntry(*aLst[i]); 677cdf0e10cSrcweir 678cdf0e10cSrcweir if (IsFldEdit()) 679cdf0e10cSrcweir sOldSel = pRefFld->GetSetRefName(); 680cdf0e10cSrcweir } 681cdf0e10cSrcweir 682cdf0e10cSrcweir // --> OD 2007-11-21 #i83479# 683cdf0e10cSrcweir aSelectionToolTipLB.Show( bShowSelectionToolTipLB ); 684cdf0e10cSrcweir aSelectionLB.Show( !bShowSelectionToolTipLB ); 685cdf0e10cSrcweir if ( bShowSelectionToolTipLB ) 686cdf0e10cSrcweir { 687cdf0e10cSrcweir aSelectionToolTipLB.SetUpdateMode(sal_True); 688cdf0e10cSrcweir 689cdf0e10cSrcweir sal_Bool bEnable = aSelectionToolTipLB.GetEntryCount() != 0; 690cdf0e10cSrcweir aSelectionToolTipLB.Enable( bEnable ); 691cdf0e10cSrcweir aSelectionFT.Enable( bEnable ); 692cdf0e10cSrcweir 693cdf0e10cSrcweir if ( aSelectionToolTipLB.GetCurEntry() != 0 ) 694cdf0e10cSrcweir { 695cdf0e10cSrcweir aSelectionToolTipLB.MakeVisible( aSelectionToolTipLB.GetCurEntry() ); 696cdf0e10cSrcweir } 697cdf0e10cSrcweir 698cdf0e10cSrcweir if ( IsFldEdit() && aSelectionToolTipLB.GetCurEntry() == 0 ) 699cdf0e10cSrcweir { 700cdf0e10cSrcweir aNameED.SetText(sOldSel); 701cdf0e10cSrcweir } 702cdf0e10cSrcweir } 703cdf0e10cSrcweir else 704cdf0e10cSrcweir { 705cdf0e10cSrcweir aSelectionLB.SetUpdateMode(sal_True); 706cdf0e10cSrcweir 707cdf0e10cSrcweir // Enable oder Disable 708cdf0e10cSrcweir sal_Bool bEnable = aSelectionLB.GetEntryCount() != 0; 709cdf0e10cSrcweir aSelectionLB.Enable( bEnable ); 710cdf0e10cSrcweir aSelectionFT.Enable( bEnable ); 711cdf0e10cSrcweir 712cdf0e10cSrcweir if ( bEnable ) 713cdf0e10cSrcweir { 714cdf0e10cSrcweir aSelectionLB.SelectEntry(sOldSel); 715cdf0e10cSrcweir if (!aSelectionLB.GetSelectEntryCount() && !IsFldEdit()) 716cdf0e10cSrcweir aSelectionLB.SelectEntryPos(0); 717cdf0e10cSrcweir } 718cdf0e10cSrcweir 719cdf0e10cSrcweir if (IsFldEdit() && !aSelectionLB.GetSelectEntryCount()) // Falls die Referenz schon geloescht wurde... 720cdf0e10cSrcweir aNameED.SetText(sOldSel); 721cdf0e10cSrcweir } 722cdf0e10cSrcweir // <-- 723cdf0e10cSrcweir } 724cdf0e10cSrcweir 725cdf0e10cSrcweir /*-------------------------------------------------------------------- 726cdf0e10cSrcweir Beschreibung: 727cdf0e10cSrcweir --------------------------------------------------------------------*/ 728cdf0e10cSrcweir 729cdf0e10cSrcweir sal_uInt16 SwFldRefPage::FillFormatLB(sal_uInt16 nTypeId) 730cdf0e10cSrcweir { 731cdf0e10cSrcweir String sOldSel; 732cdf0e10cSrcweir 733cdf0e10cSrcweir sal_uInt16 nFormatSel = aFormatLB.GetSelectEntryPos(); 734cdf0e10cSrcweir if (nFormatSel != LISTBOX_ENTRY_NOTFOUND) 735cdf0e10cSrcweir sOldSel = aFormatLB.GetEntry(nFormatSel); 736cdf0e10cSrcweir 737cdf0e10cSrcweir // Format-Listbox fuellen 738cdf0e10cSrcweir aFormatLB.Clear(); 739cdf0e10cSrcweir 740cdf0e10cSrcweir // Referenz hat weniger als die Beschriftung 741cdf0e10cSrcweir sal_uInt16 nSize( 0 ); 742cdf0e10cSrcweir bool bAddCrossRefFormats( false ); 743cdf0e10cSrcweir switch (nTypeId) 744cdf0e10cSrcweir { 745cdf0e10cSrcweir // --> OD 2007-11-16 #i83479# 746cdf0e10cSrcweir case REFFLDFLAG_HEADING: 747cdf0e10cSrcweir case REFFLDFLAG_NUMITEM: 748cdf0e10cSrcweir bAddCrossRefFormats = true; 749cdf0e10cSrcweir // intentional no break here 750cdf0e10cSrcweir // <-- 751cdf0e10cSrcweir 752cdf0e10cSrcweir case TYP_GETREFFLD: 753cdf0e10cSrcweir case REFFLDFLAG_BOOKMARK: 754cdf0e10cSrcweir case REFFLDFLAG_FOOTNOTE: 755cdf0e10cSrcweir case REFFLDFLAG_ENDNOTE: 756cdf0e10cSrcweir nSize = FMT_REF_PAGE_PGDSC - FMT_REF_BEGIN + 1; 757cdf0e10cSrcweir break; 758cdf0e10cSrcweir 759cdf0e10cSrcweir default: 760cdf0e10cSrcweir // --> OD 2007-11-16 #i83479# 761cdf0e10cSrcweir // nSize = GetFldMgr().GetFormatCount( (REFFLDFLAG & nTypeId) 762cdf0e10cSrcweir // ? (sal_uInt16)TYP_GETREFFLD : nTypeId, 763cdf0e10cSrcweir // sal_False, IsFldDlgHtmlMode() ); 764cdf0e10cSrcweir if ( REFFLDFLAG & nTypeId ) 765cdf0e10cSrcweir { 766cdf0e10cSrcweir nSize = FMT_REF_ONLYSEQNO - FMT_REF_BEGIN + 1; 767cdf0e10cSrcweir } 768cdf0e10cSrcweir else 769cdf0e10cSrcweir { 770cdf0e10cSrcweir nSize = GetFldMgr().GetFormatCount( nTypeId, sal_False, IsFldDlgHtmlMode() ); 771cdf0e10cSrcweir } 772cdf0e10cSrcweir break; 773cdf0e10cSrcweir } 774cdf0e10cSrcweir 775cdf0e10cSrcweir if (REFFLDFLAG & nTypeId) 776cdf0e10cSrcweir nTypeId = TYP_GETREFFLD; 777cdf0e10cSrcweir 778cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nSize; i++) 779cdf0e10cSrcweir { 780cdf0e10cSrcweir sal_uInt16 nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr( nTypeId, i )); 781cdf0e10cSrcweir aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>(GetFldMgr().GetFormatId( nTypeId, i ))); 782cdf0e10cSrcweir } 783cdf0e10cSrcweir // --> OD 2007-11-16 #i83479# 784cdf0e10cSrcweir if ( bAddCrossRefFormats ) 785cdf0e10cSrcweir { 786cdf0e10cSrcweir sal_uInt16 nFormat = FMT_REF_NUMBER - FMT_REF_BEGIN; 787cdf0e10cSrcweir sal_uInt16 nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr( nTypeId, nFormat )); 788cdf0e10cSrcweir aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>(GetFldMgr().GetFormatId( nTypeId, nFormat ))); 789cdf0e10cSrcweir nFormat = FMT_REF_NUMBER_NO_CONTEXT - FMT_REF_BEGIN; 790cdf0e10cSrcweir nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr( nTypeId, nFormat )); 791cdf0e10cSrcweir aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>(GetFldMgr().GetFormatId( nTypeId, nFormat ))); 792cdf0e10cSrcweir nFormat = FMT_REF_NUMBER_FULL_CONTEXT - FMT_REF_BEGIN; 793cdf0e10cSrcweir nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr( nTypeId, nFormat )); 794cdf0e10cSrcweir aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>(GetFldMgr().GetFormatId( nTypeId, nFormat ))); 795cdf0e10cSrcweir nSize += 3; 796cdf0e10cSrcweir } 797cdf0e10cSrcweir // <-- 798cdf0e10cSrcweir 799cdf0e10cSrcweir // select a certain entry 800cdf0e10cSrcweir if (nSize) 801cdf0e10cSrcweir { 802cdf0e10cSrcweir if (!IsFldEdit()) 803cdf0e10cSrcweir aFormatLB.SelectEntry(sOldSel); 804cdf0e10cSrcweir else 805cdf0e10cSrcweir aFormatLB.SelectEntry(SW_RESSTR(FMT_REF_BEGIN + (sal_uInt16)GetCurField()->GetFormat())); 806cdf0e10cSrcweir 807cdf0e10cSrcweir if (!aFormatLB.GetSelectEntryCount()) 808cdf0e10cSrcweir { 809cdf0e10cSrcweir aFormatLB.SelectEntryPos(nFldDlgFmtSel); 810cdf0e10cSrcweir if (!aFormatLB.GetSelectEntryCount()) 811cdf0e10cSrcweir aFormatLB.SelectEntryPos(0); 812cdf0e10cSrcweir } 813cdf0e10cSrcweir } 814cdf0e10cSrcweir 815cdf0e10cSrcweir return nSize; 816cdf0e10cSrcweir } 817cdf0e10cSrcweir 818cdf0e10cSrcweir /*-------------------------------------------------------------------- 819cdf0e10cSrcweir Beschreibung: Modify 820cdf0e10cSrcweir --------------------------------------------------------------------*/ 821cdf0e10cSrcweir 822cdf0e10cSrcweir IMPL_LINK( SwFldRefPage, ModifyHdl, Edit *, EMPTYARG ) 823cdf0e10cSrcweir { 824cdf0e10cSrcweir String aName(aNameED.GetText()); 825cdf0e10cSrcweir const sal_uInt16 nLen = aName.Len(); 826cdf0e10cSrcweir 827cdf0e10cSrcweir sal_Bool bEnable = sal_True; 828cdf0e10cSrcweir sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 829cdf0e10cSrcweir 830cdf0e10cSrcweir if ((nTypeId == TYP_SETREFFLD && !GetFldMgr().CanInsertRefMark(aName)) || 831cdf0e10cSrcweir (nLen == 0 && (nTypeId == TYP_GETREFFLD || nTypeId == TYP_SETREFFLD || 832cdf0e10cSrcweir nTypeId == REFFLDFLAG_BOOKMARK))) 833cdf0e10cSrcweir bEnable = sal_False; 834cdf0e10cSrcweir 835cdf0e10cSrcweir EnableInsert(bEnable); 836cdf0e10cSrcweir 837cdf0e10cSrcweir aSelectionLB.SelectEntry(aName); 838cdf0e10cSrcweir 839cdf0e10cSrcweir return 0; 840cdf0e10cSrcweir } 841cdf0e10cSrcweir 842cdf0e10cSrcweir /*-------------------------------------------------------------------- 843cdf0e10cSrcweir Beschreibung: 844cdf0e10cSrcweir --------------------------------------------------------------------*/ 845cdf0e10cSrcweir 846cdf0e10cSrcweir sal_Bool SwFldRefPage::FillItemSet(SfxItemSet& ) 847cdf0e10cSrcweir { 848cdf0e10cSrcweir sal_Bool bModified = sal_False; 849cdf0e10cSrcweir sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 850cdf0e10cSrcweir 851cdf0e10cSrcweir sal_uInt16 nSubType = 0; 852cdf0e10cSrcweir sal_uLong nFormat; 853cdf0e10cSrcweir 854cdf0e10cSrcweir nFormat = aFormatLB.GetSelectEntryPos(); 855cdf0e10cSrcweir 856cdf0e10cSrcweir if(nFormat == LISTBOX_ENTRY_NOTFOUND) 857cdf0e10cSrcweir nFormat = 0; 858cdf0e10cSrcweir else 859cdf0e10cSrcweir nFormat = (sal_uLong)aFormatLB.GetEntryData((sal_uInt16)nFormat); 860cdf0e10cSrcweir 861cdf0e10cSrcweir String aVal(aValueED.GetText()); 862cdf0e10cSrcweir String aName(aNameED.GetText()); 863cdf0e10cSrcweir 864cdf0e10cSrcweir switch(nTypeId) 865cdf0e10cSrcweir { 866cdf0e10cSrcweir case TYP_GETREFFLD: 867cdf0e10cSrcweir // aName = aSelectionLB.GetSelectEntry(); 868cdf0e10cSrcweir nSubType = REF_SETREFATTR; 869cdf0e10cSrcweir break; 870cdf0e10cSrcweir 871cdf0e10cSrcweir case TYP_SETREFFLD: 872cdf0e10cSrcweir { 873cdf0e10cSrcweir SwFieldType* pType = GetFldMgr().GetFldType(RES_SETEXPFLD, aName); 874cdf0e10cSrcweir 875cdf0e10cSrcweir if(!pType) // Nur einfuegen, wenn es den Namen noch nicht gibt 876cdf0e10cSrcweir { 877cdf0e10cSrcweir aSelectionLB.InsertEntry(aName); 878cdf0e10cSrcweir aSelectionLB.Enable(); 879cdf0e10cSrcweir aSelectionFT.Enable(); 880cdf0e10cSrcweir } 881cdf0e10cSrcweir break; 882cdf0e10cSrcweir } 883cdf0e10cSrcweir } 884cdf0e10cSrcweir 885cdf0e10cSrcweir SwGetRefField* pRefFld = (SwGetRefField*)GetCurField(); 886cdf0e10cSrcweir 887cdf0e10cSrcweir if (REFFLDFLAG & nTypeId) 888cdf0e10cSrcweir { 889cdf0e10cSrcweir SwWrtShell *pSh = GetWrtShell(); 890cdf0e10cSrcweir if(!pSh) 891cdf0e10cSrcweir { 892cdf0e10cSrcweir pSh = ::GetActiveWrtShell(); 893cdf0e10cSrcweir } 894cdf0e10cSrcweir if (nTypeId == REFFLDFLAG_BOOKMARK) // TextMarken! 895cdf0e10cSrcweir { 896cdf0e10cSrcweir aName = aNameED.GetText(); 897cdf0e10cSrcweir nTypeId = TYP_GETREFFLD; 898cdf0e10cSrcweir nSubType = REF_BOOKMARK; 899cdf0e10cSrcweir } 900cdf0e10cSrcweir else if (REFFLDFLAG_FOOTNOTE == nTypeId) // Fussnoten 901cdf0e10cSrcweir { 902cdf0e10cSrcweir SwSeqFldList aArr; 903cdf0e10cSrcweir _SeqFldLstElem aElem( aSelectionLB.GetSelectEntry(), 0 ); 904cdf0e10cSrcweir 905cdf0e10cSrcweir sal_uInt16 nPos; 906cdf0e10cSrcweir 907cdf0e10cSrcweir nTypeId = TYP_GETREFFLD; 908cdf0e10cSrcweir nSubType = REF_FOOTNOTE; 909cdf0e10cSrcweir aName.Erase(); 910cdf0e10cSrcweir 911cdf0e10cSrcweir if (pSh->GetSeqFtnList(aArr) && aArr.SeekEntry(aElem, &nPos)) 912cdf0e10cSrcweir { 913cdf0e10cSrcweir aVal = String::CreateFromInt32( aArr[nPos]->nSeqNo ); 914cdf0e10cSrcweir 915cdf0e10cSrcweir if (IsFldEdit() && aArr[nPos]->nSeqNo == pRefFld->GetSeqNo()) 916cdf0e10cSrcweir bModified = sal_True; // Kann bei Feldern passieren, deren Referenz geloescht wurde 917cdf0e10cSrcweir } 918cdf0e10cSrcweir else if (IsFldEdit()) 919cdf0e10cSrcweir aVal = String::CreateFromInt32( pRefFld->GetSeqNo() ); 920cdf0e10cSrcweir } 921cdf0e10cSrcweir else if (REFFLDFLAG_ENDNOTE == nTypeId) // Endnoten 922cdf0e10cSrcweir { 923cdf0e10cSrcweir SwSeqFldList aArr; 924cdf0e10cSrcweir _SeqFldLstElem aElem( aSelectionLB.GetSelectEntry(), 0 ); 925cdf0e10cSrcweir 926cdf0e10cSrcweir sal_uInt16 nPos; 927cdf0e10cSrcweir 928cdf0e10cSrcweir nTypeId = TYP_GETREFFLD; 929cdf0e10cSrcweir nSubType = REF_ENDNOTE; 930cdf0e10cSrcweir aName.Erase(); 931cdf0e10cSrcweir 932cdf0e10cSrcweir if (pSh->GetSeqFtnList(aArr, true) && aArr.SeekEntry(aElem, &nPos)) 933cdf0e10cSrcweir { 934cdf0e10cSrcweir aVal = String::CreateFromInt32( aArr[nPos]->nSeqNo ); 935cdf0e10cSrcweir 936cdf0e10cSrcweir if (IsFldEdit() && aArr[nPos]->nSeqNo == pRefFld->GetSeqNo()) 937cdf0e10cSrcweir bModified = sal_True; // Kann bei Feldern passieren, deren Referenz geloescht wurde 938cdf0e10cSrcweir } 939cdf0e10cSrcweir else if (IsFldEdit()) 940cdf0e10cSrcweir aVal = String::CreateFromInt32( pRefFld->GetSeqNo() ); 941cdf0e10cSrcweir } 942cdf0e10cSrcweir // --> OD 2007-11-16 #i83479# 943cdf0e10cSrcweir else if ( nTypeId == REFFLDFLAG_HEADING ) 944cdf0e10cSrcweir { 945cdf0e10cSrcweir SvLBoxEntry* pEntry = aSelectionToolTipLB.GetCurEntry(); 946cdf0e10cSrcweir ASSERT( pEntry, 947cdf0e10cSrcweir "<SwFldRefPage::FillItemSet(..)> - no entry selected in selection tool tip listbox!" ); 948cdf0e10cSrcweir if ( pEntry ) 949cdf0e10cSrcweir { 950cdf0e10cSrcweir const sal_uInt16 nOutlIdx( static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(pEntry->GetUserData())) ); 951cdf0e10cSrcweir pSh->getIDocumentOutlineNodesAccess()->getOutlineNodes( maOutlineNodes ); 952cdf0e10cSrcweir if ( nOutlIdx < maOutlineNodes.size() ) 953cdf0e10cSrcweir { 954cdf0e10cSrcweir ::sw::mark::IMark const * const pMark = pSh->getIDocumentMarkAccess()->getMarkForTxtNode( 955cdf0e10cSrcweir *(maOutlineNodes[nOutlIdx]), 956cdf0e10cSrcweir IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK); 957cdf0e10cSrcweir aName = pMark->GetName(); 958cdf0e10cSrcweir nTypeId = TYP_GETREFFLD; 959cdf0e10cSrcweir nSubType = REF_BOOKMARK; 960cdf0e10cSrcweir } 961cdf0e10cSrcweir } 962cdf0e10cSrcweir } 963cdf0e10cSrcweir else if ( nTypeId == REFFLDFLAG_NUMITEM ) 964cdf0e10cSrcweir { 965cdf0e10cSrcweir SvLBoxEntry* pEntry = aSelectionToolTipLB.GetCurEntry(); 966cdf0e10cSrcweir ASSERT( pEntry, 967cdf0e10cSrcweir "<SwFldRefPage::FillItemSet(..)> - no entry selected in selection tool tip listbox!" ); 968cdf0e10cSrcweir if ( pEntry ) 969cdf0e10cSrcweir { 970cdf0e10cSrcweir const sal_uInt16 nNumItemIdx( static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(pEntry->GetUserData())) ); 971cdf0e10cSrcweir pSh->getIDocumentListItemsAccess()->getNumItems( maNumItems ); 972cdf0e10cSrcweir if ( nNumItemIdx < maNumItems.size() ) 973cdf0e10cSrcweir { 974cdf0e10cSrcweir ::sw::mark::IMark const * const pMark = pSh->getIDocumentMarkAccess()->getMarkForTxtNode( 975cdf0e10cSrcweir *(maNumItems[nNumItemIdx]->GetTxtNode()), 976cdf0e10cSrcweir IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK); 977cdf0e10cSrcweir aName = pMark->GetName(); 978cdf0e10cSrcweir nTypeId = TYP_GETREFFLD; 979cdf0e10cSrcweir nSubType = REF_BOOKMARK; 980cdf0e10cSrcweir } 981cdf0e10cSrcweir } 982cdf0e10cSrcweir } 983cdf0e10cSrcweir // <-- 984cdf0e10cSrcweir else // SeqenceFelder 985cdf0e10cSrcweir { 986cdf0e10cSrcweir // zum Seq-FeldTyp die Felder besorgen: 987cdf0e10cSrcweir SwSetExpFieldType* pType = (SwSetExpFieldType*)pSh->GetFldType( 988cdf0e10cSrcweir nTypeId & ~REFFLDFLAG, RES_SETEXPFLD ); 989cdf0e10cSrcweir if( pType ) 990cdf0e10cSrcweir { 991cdf0e10cSrcweir SwSeqFldList aArr; 992cdf0e10cSrcweir _SeqFldLstElem aElem( aSelectionLB.GetSelectEntry(), 0 ); 993cdf0e10cSrcweir 994cdf0e10cSrcweir sal_uInt16 nPos; 995cdf0e10cSrcweir 996cdf0e10cSrcweir nTypeId = TYP_GETREFFLD; 997cdf0e10cSrcweir nSubType = REF_SEQUENCEFLD; 998cdf0e10cSrcweir aName = pType->GetName(); 999cdf0e10cSrcweir 1000cdf0e10cSrcweir if (pType->GetSeqFldList(aArr) && aArr.SeekEntry(aElem, &nPos)) 1001cdf0e10cSrcweir { 1002cdf0e10cSrcweir aVal = String::CreateFromInt32( aArr[nPos]->nSeqNo ); 1003cdf0e10cSrcweir 1004cdf0e10cSrcweir if (IsFldEdit() && aArr[nPos]->nSeqNo == pRefFld->GetSeqNo()) 1005cdf0e10cSrcweir bModified = sal_True; // Kann bei Feldern passieren, deren Referenz geloescht wurde 1006cdf0e10cSrcweir } 1007cdf0e10cSrcweir else if (IsFldEdit()) 1008cdf0e10cSrcweir aVal = String::CreateFromInt32( pRefFld->GetSeqNo() ); 1009cdf0e10cSrcweir } 1010cdf0e10cSrcweir } 1011cdf0e10cSrcweir } 1012cdf0e10cSrcweir 1013cdf0e10cSrcweir if (IsFldEdit() && nTypeId == TYP_GETREFFLD) 1014cdf0e10cSrcweir { 1015cdf0e10cSrcweir aVal.Insert('|', 0); 1016cdf0e10cSrcweir aVal.Insert(String::CreateFromInt32(nSubType), 0); 1017cdf0e10cSrcweir } 1018cdf0e10cSrcweir 1019cdf0e10cSrcweir if (!IsFldEdit() || bModified || 1020cdf0e10cSrcweir aNameED.GetSavedValue() != aNameED.GetText() || 1021cdf0e10cSrcweir aValueED.GetSavedValue() != aValueED.GetText() || 1022cdf0e10cSrcweir aTypeLB.GetSavedValue() != aTypeLB.GetSelectEntryPos() || 1023cdf0e10cSrcweir aSelectionLB.GetSavedValue() != aSelectionLB.GetSelectEntryPos() || 1024cdf0e10cSrcweir aFormatLB.GetSavedValue() != aFormatLB.GetSelectEntryPos()) 1025cdf0e10cSrcweir { 1026cdf0e10cSrcweir InsertFld( nTypeId, nSubType, aName, aVal, nFormat ); 1027cdf0e10cSrcweir } 1028cdf0e10cSrcweir 1029cdf0e10cSrcweir ModifyHdl(); // Insert ggf enablen/disablen 1030cdf0e10cSrcweir 1031cdf0e10cSrcweir return sal_False; 1032cdf0e10cSrcweir } 1033cdf0e10cSrcweir 1034cdf0e10cSrcweir /*-------------------------------------------------------------------- 1035cdf0e10cSrcweir Beschreibung: 1036cdf0e10cSrcweir --------------------------------------------------------------------*/ 1037cdf0e10cSrcweir 1038cdf0e10cSrcweir SfxTabPage* SwFldRefPage::Create( Window* pParent, 1039cdf0e10cSrcweir const SfxItemSet& rAttrSet ) 1040cdf0e10cSrcweir { 1041cdf0e10cSrcweir return ( new SwFldRefPage( pParent, rAttrSet ) ); 1042cdf0e10cSrcweir } 1043cdf0e10cSrcweir 1044cdf0e10cSrcweir /*-------------------------------------------------------------------- 1045cdf0e10cSrcweir Beschreibung: 1046cdf0e10cSrcweir --------------------------------------------------------------------*/ 1047cdf0e10cSrcweir 1048cdf0e10cSrcweir sal_uInt16 SwFldRefPage::GetGroup() 1049cdf0e10cSrcweir { 1050cdf0e10cSrcweir return GRP_REF; 1051cdf0e10cSrcweir } 1052cdf0e10cSrcweir 1053cdf0e10cSrcweir /* -----------------12.01.99 10:09------------------- 1054cdf0e10cSrcweir * 1055cdf0e10cSrcweir * --------------------------------------------------*/ 1056cdf0e10cSrcweir void SwFldRefPage::FillUserData() 1057cdf0e10cSrcweir { 1058cdf0e10cSrcweir String sData( String::CreateFromAscii( 1059cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( USER_DATA_VERSION ))); 1060cdf0e10cSrcweir sData += ';'; 1061cdf0e10cSrcweir sal_uInt16 nTypeSel = aTypeLB.GetSelectEntryPos(); 1062cdf0e10cSrcweir if( LISTBOX_ENTRY_NOTFOUND == nTypeSel ) 1063cdf0e10cSrcweir nTypeSel = USHRT_MAX; 1064cdf0e10cSrcweir else 1065cdf0e10cSrcweir nTypeSel = sal::static_int_cast< sal_uInt16 >(reinterpret_cast< sal_uIntPtr >(aTypeLB.GetEntryData( nTypeSel ))); 1066cdf0e10cSrcweir sData += String::CreateFromInt32( nTypeSel ); 1067cdf0e10cSrcweir SetUserData(sData); 1068cdf0e10cSrcweir } 1069cdf0e10cSrcweir 1070