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 #ifdef SW_DLLIMPLEMENTATION 27cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION 28cdf0e10cSrcweir #endif 29cdf0e10cSrcweir #include <vcl/msgbox.hxx> 30cdf0e10cSrcweir #include <sfx2/basedlgs.hxx> 31cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 32cdf0e10cSrcweir #include <sfx2/request.hxx> 33cdf0e10cSrcweir #include <sfx2/app.hxx> 34cdf0e10cSrcweir #include <svx/optgenrl.hxx> 35cdf0e10cSrcweir #include <docufld.hxx> 36cdf0e10cSrcweir #ifndef _VIEW_HXX 37cdf0e10cSrcweir #include <view.hxx> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #include <dbfld.hxx> 40cdf0e10cSrcweir #include <wrtsh.hxx> 41cdf0e10cSrcweir #ifndef _FLDDB_HXX 42cdf0e10cSrcweir #include <flddb.hxx> 43cdf0e10cSrcweir #endif 44cdf0e10cSrcweir #ifndef _FLDDINF_HXX 45cdf0e10cSrcweir #include <flddinf.hxx> 46cdf0e10cSrcweir #endif 47cdf0e10cSrcweir #ifndef _FLDVAR_HXX 48cdf0e10cSrcweir #include <fldvar.hxx> 49cdf0e10cSrcweir #endif 50cdf0e10cSrcweir #ifndef _FLDDOK_HXX 51cdf0e10cSrcweir #include <flddok.hxx> 52cdf0e10cSrcweir #endif 53cdf0e10cSrcweir #ifndef _FLDFUNC_HXX 54cdf0e10cSrcweir #include <fldfunc.hxx> 55cdf0e10cSrcweir #endif 56cdf0e10cSrcweir #ifndef _FLDREF_HXX 57cdf0e10cSrcweir #include <fldref.hxx> 58cdf0e10cSrcweir #endif 59cdf0e10cSrcweir #include <fldedt.hxx> 60cdf0e10cSrcweir #include <crsskip.hxx> 61cdf0e10cSrcweir 62cdf0e10cSrcweir 63cdf0e10cSrcweir #ifndef _CMDID_H 64cdf0e10cSrcweir #include <cmdid.h> 65cdf0e10cSrcweir #endif 66cdf0e10cSrcweir #ifndef _HELPID_H 67cdf0e10cSrcweir #include <helpid.h> 68cdf0e10cSrcweir #endif 69cdf0e10cSrcweir #ifndef _GLOBALS_HRC 70cdf0e10cSrcweir #include <globals.hrc> 71cdf0e10cSrcweir #endif 72cdf0e10cSrcweir #ifndef _FLDUI_HRC 73cdf0e10cSrcweir #include <fldui.hrc> 74cdf0e10cSrcweir #endif 75cdf0e10cSrcweir #include "swabstdlg.hxx" 76cdf0e10cSrcweir #include "dialog.hrc" 77cdf0e10cSrcweir 78cdf0e10cSrcweir #include <com/sun/star/document/XDocumentProperties.hpp> 79cdf0e10cSrcweir #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> 80cdf0e10cSrcweir 81cdf0e10cSrcweir 82cdf0e10cSrcweir namespace swui 83cdf0e10cSrcweir { 84cdf0e10cSrcweir SwAbstractDialogFactory * GetFactory(); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir /*-------------------------------------------------------------------- 88cdf0e10cSrcweir Beschreibung: 89cdf0e10cSrcweir --------------------------------------------------------------------*/ 90cdf0e10cSrcweir 91cdf0e10cSrcweir SwFldEditDlg::SwFldEditDlg(SwView& rVw) : 92cdf0e10cSrcweir SfxSingleTabDialog(&rVw.GetViewFrame()->GetWindow(), 0, 0), 93cdf0e10cSrcweir pSh (rVw.GetWrtShellPtr()), 94cdf0e10cSrcweir aPrevBT (this, SW_RES(BTN_FLDEDT_PREV)), 95cdf0e10cSrcweir aNextBT (this, SW_RES(BTN_FLDEDT_NEXT)), 96cdf0e10cSrcweir aAddressBT (this, SW_RES(PB_FLDEDT_ADDRESS)) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir SwFldMgr aMgr(pSh); 99cdf0e10cSrcweir 100cdf0e10cSrcweir SwField *pCurFld = aMgr.GetCurFld(); 101cdf0e10cSrcweir if(!pCurFld) 102cdf0e10cSrcweir return; 103cdf0e10cSrcweir 104cdf0e10cSrcweir pSh->SetCareWin(this); 105cdf0e10cSrcweir 106cdf0e10cSrcweir /* #108536# Only create selection if there is none 107cdf0e10cSrcweir already. Normalize PaM instead of swapping. */ 108cdf0e10cSrcweir if ( ! pSh->HasSelection() ) 109cdf0e10cSrcweir pSh->Right(CRSR_SKIP_CHARS, sal_True, 1, sal_False ); 110cdf0e10cSrcweir 111cdf0e10cSrcweir pSh->NormalizePam(); 112cdf0e10cSrcweir 113cdf0e10cSrcweir sal_uInt16 nGroup = aMgr.GetGroup(sal_False, pCurFld->GetTypeId(), pCurFld->GetSubType()); 114cdf0e10cSrcweir 115cdf0e10cSrcweir CreatePage(nGroup); 116cdf0e10cSrcweir 117cdf0e10cSrcweir GetOKButton()->SetClickHdl(LINK(this, SwFldEditDlg, OKHdl)); 118cdf0e10cSrcweir 119cdf0e10cSrcweir // Buttons selbst positionieren, da sie sonst bei unterschiedlichen 120cdf0e10cSrcweir // Fontgroessen im Wald stehen, und da PB im SingleTabDlg feste Pixelgroessen 121cdf0e10cSrcweir // fuer seine Buttons und die Dialogbreite verwendet. 122cdf0e10cSrcweir aPrevBT.SetPosPixel(Point(GetOKButton()->GetPosPixel().X(), aPrevBT.GetPosPixel().Y())); 123cdf0e10cSrcweir sal_uInt16 nWidth = static_cast< sal_uInt16 >(GetOKButton()->GetOutputSize().Width() / 2 - 3); 124cdf0e10cSrcweir Size aNewSize(LogicToPixel(Size(nWidth, GetOKButton()->GetOutputSize().Height()))); 125cdf0e10cSrcweir aPrevBT.SetSizePixel(aNewSize); 126cdf0e10cSrcweir 127cdf0e10cSrcweir aNextBT.SetSizePixel(aPrevBT.GetSizePixel()); 128cdf0e10cSrcweir 129cdf0e10cSrcweir long nXPos = GetOKButton()->GetPosPixel().X() + GetOKButton()->GetSizePixel().Width() 130cdf0e10cSrcweir - aNextBT.GetSizePixel().Width() - 1; 131cdf0e10cSrcweir aNextBT.SetPosPixel(Point(nXPos, aNextBT.GetPosPixel().Y())); 132cdf0e10cSrcweir 133cdf0e10cSrcweir aAddressBT.SetPosPixel(Point(GetOKButton()->GetPosPixel().X(), aAddressBT.GetPosPixel().Y())); 134cdf0e10cSrcweir aAddressBT.SetSizePixel(GetOKButton()->GetSizePixel()); 135cdf0e10cSrcweir 136cdf0e10cSrcweir aPrevBT.SetClickHdl(LINK(this, SwFldEditDlg, NextPrevHdl)); 137cdf0e10cSrcweir aNextBT.SetClickHdl(LINK(this, SwFldEditDlg, NextPrevHdl)); 138cdf0e10cSrcweir 139cdf0e10cSrcweir aAddressBT.SetClickHdl(LINK(this, SwFldEditDlg, AddressHdl)); 140cdf0e10cSrcweir aAddressBT.SetHelpId(HID_FLDEDT_ADDRESS); 141cdf0e10cSrcweir 142cdf0e10cSrcweir Init(); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir 145cdf0e10cSrcweir /*-------------------------------------------------------------------- 146cdf0e10cSrcweir Beschreibung: Controlls initialisieren 147cdf0e10cSrcweir --------------------------------------------------------------------*/ 148cdf0e10cSrcweir 149cdf0e10cSrcweir void SwFldEditDlg::Init() 150cdf0e10cSrcweir { 151cdf0e10cSrcweir SwFldPage* pTabPage = (SwFldPage*)GetTabPage(); 152cdf0e10cSrcweir 153cdf0e10cSrcweir if( pTabPage ) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir SwFldMgr& rMgr = pTabPage->GetFldMgr(); 156cdf0e10cSrcweir 157cdf0e10cSrcweir SwField *pCurFld = rMgr.GetCurFld(); 158cdf0e10cSrcweir 159cdf0e10cSrcweir if(!pCurFld) 160cdf0e10cSrcweir return; 161cdf0e10cSrcweir 162cdf0e10cSrcweir // Traveling nur bei mehr als einem Feld 163cdf0e10cSrcweir pSh->StartAction(); 164cdf0e10cSrcweir pSh->CreateCrsr(); 165cdf0e10cSrcweir 166cdf0e10cSrcweir sal_Bool bMove = rMgr.GoNext(); 167cdf0e10cSrcweir if( bMove ) 168cdf0e10cSrcweir rMgr.GoPrev(); 169cdf0e10cSrcweir aNextBT.Enable(bMove); 170cdf0e10cSrcweir 171cdf0e10cSrcweir if( 0 != ( bMove = rMgr.GoPrev() ) ) 172cdf0e10cSrcweir rMgr.GoNext(); 173cdf0e10cSrcweir aPrevBT.Enable( bMove ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir if (pCurFld->GetTypeId() == TYP_EXTUSERFLD) 176cdf0e10cSrcweir aAddressBT.Show(); 177cdf0e10cSrcweir 178cdf0e10cSrcweir pSh->DestroyCrsr(); 179cdf0e10cSrcweir pSh->EndAction(); 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182cdf0e10cSrcweir GetOKButton()->Enable( !pSh->IsReadOnlyAvailable() || 183cdf0e10cSrcweir !pSh->HasReadonlySel() ); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir 186cdf0e10cSrcweir /*-------------------------------------------------------------------- 187cdf0e10cSrcweir Beschreibung: 188cdf0e10cSrcweir --------------------------------------------------------------------*/ 189cdf0e10cSrcweir 190cdf0e10cSrcweir SfxTabPage* SwFldEditDlg::CreatePage(sal_uInt16 nGroup) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir // TabPage erzeugen 193cdf0e10cSrcweir SfxTabPage* pTabPage = 0; 194cdf0e10cSrcweir const char* pHelpId = 0; 195cdf0e10cSrcweir 196cdf0e10cSrcweir switch (nGroup) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir case GRP_DOC: 199cdf0e10cSrcweir pTabPage = SwFldDokPage::Create(this, *(SfxItemSet*)0); 200cdf0e10cSrcweir pHelpId = HID_EDIT_FLD_DOK; 201cdf0e10cSrcweir break; 202cdf0e10cSrcweir case GRP_FKT: 203cdf0e10cSrcweir pTabPage = SwFldFuncPage::Create(this, *(SfxItemSet*)0); 204cdf0e10cSrcweir pHelpId = HID_EDIT_FLD_FUNC; 205cdf0e10cSrcweir break; 206cdf0e10cSrcweir case GRP_REF: 207cdf0e10cSrcweir pTabPage = SwFldRefPage::Create(this, *(SfxItemSet*)0); 208cdf0e10cSrcweir pHelpId = HID_EDIT_FLD_REF; 209cdf0e10cSrcweir break; 210cdf0e10cSrcweir case GRP_REG: 211cdf0e10cSrcweir { 212cdf0e10cSrcweir SfxObjectShell* pDocSh = SfxObjectShell::Current(); 213cdf0e10cSrcweir SfxItemSet* pSet = new SfxItemSet( pDocSh->GetPool(), SID_DOCINFO, SID_DOCINFO ); 214cdf0e10cSrcweir using namespace ::com::sun::star; 215cdf0e10cSrcweir uno::Reference<document::XDocumentPropertiesSupplier> xDPS( 216cdf0e10cSrcweir pDocSh->GetModel(), uno::UNO_QUERY_THROW); 217cdf0e10cSrcweir uno::Reference<document::XDocumentProperties> xDocProps 218cdf0e10cSrcweir = xDPS->getDocumentProperties(); 219cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xUDProps( 220cdf0e10cSrcweir xDocProps->getUserDefinedProperties(), 221cdf0e10cSrcweir uno::UNO_QUERY_THROW); 222cdf0e10cSrcweir // uno::Reference< beans::XPropertySetInfo > xSetInfo 223cdf0e10cSrcweir // = xUDProps->getPropertySetInfo(); 224cdf0e10cSrcweir // const uno::Sequence< beans::Property > props 225cdf0e10cSrcweir // = xSetInfo->getProperties(); 226cdf0e10cSrcweir // uno::Sequence< ::rtl::OUString > names(props.getLength()); 227cdf0e10cSrcweir // for (sal_Int32 i = 0; i < props.getLength(); ++i) { 228cdf0e10cSrcweir // names[i] = props[i].Name; 229cdf0e10cSrcweir // } 230cdf0e10cSrcweir pSet->Put( SfxUnoAnyItem( SID_DOCINFO, uno::makeAny(xUDProps) ) ); 231cdf0e10cSrcweir pTabPage = SwFldDokInfPage::Create(this, *pSet); 232cdf0e10cSrcweir pHelpId = HID_EDIT_FLD_DOKINF; 233cdf0e10cSrcweir break; 234cdf0e10cSrcweir } 235cdf0e10cSrcweir case GRP_DB: 236cdf0e10cSrcweir pTabPage = SwFldDBPage::Create(this, *(SfxItemSet*)0); 237cdf0e10cSrcweir static_cast<SwFldDBPage*>(pTabPage)->SetWrtShell(*pSh); 238cdf0e10cSrcweir pHelpId = HID_EDIT_FLD_DB; 239cdf0e10cSrcweir break; 240cdf0e10cSrcweir case GRP_VAR: 241cdf0e10cSrcweir pTabPage = SwFldVarPage::Create(this, *(SfxItemSet*)0); 242cdf0e10cSrcweir pHelpId = HID_EDIT_FLD_VAR; 243cdf0e10cSrcweir break; 244cdf0e10cSrcweir 245cdf0e10cSrcweir } 246cdf0e10cSrcweir 247cdf0e10cSrcweir pTabPage->SetHelpId(pHelpId); 248cdf0e10cSrcweir static_cast<SwFldPage*>(pTabPage)->SetWrtShell(pSh); 249cdf0e10cSrcweir 250cdf0e10cSrcweir SetTabPage(pTabPage); 251cdf0e10cSrcweir 252cdf0e10cSrcweir String sTitle(GetText()); 253cdf0e10cSrcweir sTitle.Insert(String::CreateFromAscii(": "), 0); 254cdf0e10cSrcweir sTitle.Insert(SW_RESSTR(STR_FLD_EDIT_DLG), 0); 255cdf0e10cSrcweir SetText(sTitle); 256cdf0e10cSrcweir 257cdf0e10cSrcweir return pTabPage; 258cdf0e10cSrcweir } 259cdf0e10cSrcweir 260cdf0e10cSrcweir /*-------------------------------------------------------------------- 261cdf0e10cSrcweir Beschreibung: 262cdf0e10cSrcweir --------------------------------------------------------------------*/ 263cdf0e10cSrcweir 264cdf0e10cSrcweir SwFldEditDlg::~SwFldEditDlg() 265cdf0e10cSrcweir { 266cdf0e10cSrcweir pSh->SetCareWin(NULL); 267cdf0e10cSrcweir pSh->EnterStdMode(); 268cdf0e10cSrcweir } 269cdf0e10cSrcweir 270cdf0e10cSrcweir /*-------------------------------------------------------------------- 271cdf0e10cSrcweir Beschreibung: 272cdf0e10cSrcweir --------------------------------------------------------------------*/ 273cdf0e10cSrcweir 274cdf0e10cSrcweir void SwFldEditDlg::EnableInsert(sal_Bool bEnable) 275cdf0e10cSrcweir { 276cdf0e10cSrcweir if( bEnable && pSh->IsReadOnlyAvailable() && pSh->HasReadonlySel() ) 277cdf0e10cSrcweir bEnable = sal_False; 278cdf0e10cSrcweir GetOKButton()->Enable( bEnable ); 279cdf0e10cSrcweir } 280cdf0e10cSrcweir 281cdf0e10cSrcweir /*-------------------------------------------------------------------- 282cdf0e10cSrcweir Beschreibung: 283cdf0e10cSrcweir --------------------------------------------------------------------*/ 284cdf0e10cSrcweir 285cdf0e10cSrcweir void SwFldEditDlg::InsertHdl() 286cdf0e10cSrcweir { 287cdf0e10cSrcweir GetOKButton()->Click(); 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir /*-------------------------------------------------------------------- 291cdf0e10cSrcweir Beschreibung: Aendern des Feldes anstossen 292cdf0e10cSrcweir --------------------------------------------------------------------*/ 293cdf0e10cSrcweir 294cdf0e10cSrcweir IMPL_LINK( SwFldEditDlg, OKHdl, Button *, EMPTYARG ) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir if (GetOKButton()->IsEnabled()) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir SfxTabPage* pTabPage = GetTabPage(); 299cdf0e10cSrcweir if (pTabPage) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir pTabPage->FillItemSet(*(SfxItemSet*)0); 302cdf0e10cSrcweir 303cdf0e10cSrcweir } 304cdf0e10cSrcweir EndDialog( RET_OK ); 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir return 0; 308cdf0e10cSrcweir } 309cdf0e10cSrcweir 310cdf0e10cSrcweir /*-------------------------------------------------------------------- 311cdf0e10cSrcweir Beschreibung: 312cdf0e10cSrcweir --------------------------------------------------------------------*/ 313cdf0e10cSrcweir 314cdf0e10cSrcweir short SwFldEditDlg::Execute() 315cdf0e10cSrcweir { 316cdf0e10cSrcweir // Ohne TabPage kein Dialog 317cdf0e10cSrcweir return GetTabPage() ? Dialog::Execute() : RET_CANCEL; 318cdf0e10cSrcweir } 319cdf0e10cSrcweir 320cdf0e10cSrcweir /*-------------------------------------------------------------------- 321cdf0e10cSrcweir Beschreibung: Traveling zwishen Feldern gleichen Typs 322cdf0e10cSrcweir --------------------------------------------------------------------*/ 323cdf0e10cSrcweir 324cdf0e10cSrcweir IMPL_LINK( SwFldEditDlg, NextPrevHdl, Button *, pButton ) 325cdf0e10cSrcweir { 326cdf0e10cSrcweir sal_Bool bNext = pButton == &aNextBT; 327cdf0e10cSrcweir 328cdf0e10cSrcweir pSh->EnterStdMode(); 329cdf0e10cSrcweir 330cdf0e10cSrcweir SwFieldType *pOldTyp = 0; 331cdf0e10cSrcweir SwFldPage* pTabPage = (SwFldPage*)GetTabPage(); 332cdf0e10cSrcweir 333cdf0e10cSrcweir //#112462# FillItemSet may delete the current field 334cdf0e10cSrcweir //that's why it has to be called before accessing the current field 335cdf0e10cSrcweir if( GetOKButton()->IsEnabled() ) 336cdf0e10cSrcweir pTabPage->FillItemSet(*(SfxItemSet*)0); 337cdf0e10cSrcweir 338cdf0e10cSrcweir SwFldMgr& rMgr = pTabPage->GetFldMgr(); 339cdf0e10cSrcweir SwField *pCurFld = rMgr.GetCurFld(); 340cdf0e10cSrcweir if (pCurFld->GetTypeId() == TYP_DBFLD) 341cdf0e10cSrcweir pOldTyp = (SwDBFieldType*)pCurFld->GetTyp(); 342cdf0e10cSrcweir 343cdf0e10cSrcweir rMgr.GoNextPrev( bNext, pOldTyp ); 344cdf0e10cSrcweir pCurFld = rMgr.GetCurFld(); 345cdf0e10cSrcweir 346cdf0e10cSrcweir /* #108536# Only create selection if there is none 347cdf0e10cSrcweir already. Normalize PaM instead of swapping. */ 348cdf0e10cSrcweir if ( ! pSh->HasSelection() ) 349cdf0e10cSrcweir pSh->Right(CRSR_SKIP_CHARS, sal_True, 1, sal_False ); 350cdf0e10cSrcweir 351cdf0e10cSrcweir pSh->NormalizePam(); 352cdf0e10cSrcweir 353cdf0e10cSrcweir sal_uInt16 nGroup = rMgr.GetGroup(sal_False, pCurFld->GetTypeId(), pCurFld->GetSubType()); 354cdf0e10cSrcweir 355cdf0e10cSrcweir if (nGroup != pTabPage->GetGroup()) 356cdf0e10cSrcweir pTabPage = (SwFldPage*)CreatePage(nGroup); 357cdf0e10cSrcweir 358cdf0e10cSrcweir pTabPage->EditNewField(); 359cdf0e10cSrcweir 360cdf0e10cSrcweir Init(); 361cdf0e10cSrcweir 362cdf0e10cSrcweir return 0; 363cdf0e10cSrcweir } 364cdf0e10cSrcweir 365cdf0e10cSrcweir /*-------------------------------------------------------------------- 366cdf0e10cSrcweir Beschreibung: 367cdf0e10cSrcweir --------------------------------------------------------------------*/ 368cdf0e10cSrcweir 369cdf0e10cSrcweir IMPL_LINK( SwFldEditDlg, AddressHdl, PushButton *, EMPTYARG ) 370cdf0e10cSrcweir { 371cdf0e10cSrcweir SwFldPage* pTabPage = (SwFldPage*)GetTabPage(); 372cdf0e10cSrcweir SwFldMgr& rMgr = pTabPage->GetFldMgr(); 373cdf0e10cSrcweir SwField *pCurFld = rMgr.GetCurFld(); 374cdf0e10cSrcweir 375cdf0e10cSrcweir SfxItemSet aSet( pSh->GetAttrPool(), 376cdf0e10cSrcweir SID_FIELD_GRABFOCUS, SID_FIELD_GRABFOCUS, 377cdf0e10cSrcweir 0L ); 378cdf0e10cSrcweir 379cdf0e10cSrcweir sal_uInt16 nEditPos = UNKNOWN_EDIT; 380cdf0e10cSrcweir 381cdf0e10cSrcweir switch(pCurFld->GetSubType()) 382cdf0e10cSrcweir { 383cdf0e10cSrcweir case EU_FIRSTNAME: nEditPos = FIRSTNAME_EDIT; break; 384cdf0e10cSrcweir case EU_NAME: nEditPos = LASTNAME_EDIT; break; 385cdf0e10cSrcweir case EU_SHORTCUT: nEditPos = SHORTNAME_EDIT; break; 386cdf0e10cSrcweir case EU_COMPANY: nEditPos = COMPANY_EDIT; break; 387cdf0e10cSrcweir case EU_STREET: nEditPos = STREET_EDIT; break; 388cdf0e10cSrcweir case EU_TITLE: nEditPos = TITLE_EDIT; break; 389cdf0e10cSrcweir case EU_POSITION: nEditPos = POSITION_EDIT; break; 390cdf0e10cSrcweir case EU_PHONE_PRIVATE:nEditPos = TELPRIV_EDIT; break; 391cdf0e10cSrcweir case EU_PHONE_COMPANY:nEditPos = TELCOMPANY_EDIT; break; 392cdf0e10cSrcweir case EU_FAX: nEditPos = FAX_EDIT; break; 393cdf0e10cSrcweir case EU_EMAIL: nEditPos = EMAIL_EDIT; break; 394cdf0e10cSrcweir case EU_COUNTRY: nEditPos = COUNTRY_EDIT; break; 395cdf0e10cSrcweir case EU_ZIP: nEditPos = PLZ_EDIT; break; 396cdf0e10cSrcweir case EU_CITY: nEditPos = CITY_EDIT; break; 397cdf0e10cSrcweir case EU_STATE: nEditPos = STATE_EDIT; break; 398cdf0e10cSrcweir 399cdf0e10cSrcweir default: nEditPos = UNKNOWN_EDIT; break; 400cdf0e10cSrcweir 401cdf0e10cSrcweir } 402cdf0e10cSrcweir aSet.Put(SfxUInt16Item(SID_FIELD_GRABFOCUS, nEditPos)); 403cdf0e10cSrcweir SwAbstractDialogFactory* pFact = swui::GetFactory(); 404cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 405cdf0e10cSrcweir 406cdf0e10cSrcweir SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( this, aSet, 407cdf0e10cSrcweir pSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface(), 408cdf0e10cSrcweir RC_DLG_ADDR ); 409cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!"); 410cdf0e10cSrcweir if(RET_OK == pDlg->Execute()) 411cdf0e10cSrcweir { 412cdf0e10cSrcweir pSh->UpdateFlds( *pCurFld ); 413cdf0e10cSrcweir } 414cdf0e10cSrcweir delete pDlg; 415cdf0e10cSrcweir return 0; 416cdf0e10cSrcweir } 417cdf0e10cSrcweir 418cdf0e10cSrcweir 419