1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: swuiidxmrk.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #ifdef SW_DLLIMPLEMENTATION
34 #undef SW_DLLIMPLEMENTATION
37 #include "swuiidxmrk.hxx"
38 #include <hintids.hxx>
42 #define _SVSTDARR_STRINGSSORT
43 #include <svtools/svstdarr.hxx>
44 #include <comphelper/processfactory.hxx>
45 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
46 #include <com/sun/star/beans/PropertyValue.hpp>
47 #include <com/sun/star/beans/XPropertySet.hpp>
48 #include <com/sun/star/util/SearchOptions.hpp>
49 #include <com/sun/star/util/SearchFlags.hpp>
50 #include <com/sun/star/i18n/TransliterationModules.hpp>
51 #include <svtools/stritem.hxx>
52 #ifndef _MSGBOX_HXX //autogen
53 #include <vcl/msgbox.hxx>
55 #include <sfx2/dispatch.hxx>
56 #include <svtools/eitem.hxx>
57 #include <svtools/txtcmp.hxx>
58 #include <svx/scripttypeitem.hxx>
59 #include <svtools/itemset.hxx>
60 #include <svx/langitem.hxx>
61 #include "svx/unolingu.hxx"
62 #include <swtypes.hxx>
64 #include <txttxmrk.hxx>
69 #include <multmrk.hxx>
70 #include <swundo.hxx> // fuer Undo-Ids
80 #include <swmodule.hxx>
85 #include <svtools/cjkoptions.hxx>
87 #include <breakit.hxx>
88 #include <SwRewriter.hxx>
91 #include "swuiidxmrk.hxx"
99 static sal_uInt16 nTypePos
= 1; // TOX_INDEX as standard
100 static sal_uInt16 nKey1Pos
= USHRT_MAX
;
102 static sal_uInt16 nKey2Pos
= USHRT_MAX
;
104 using namespace com::sun::star
;
105 using namespace com::sun::star::i18n
;
106 using namespace com::sun::star::lang
;
107 using namespace com::sun::star::util
;
108 using namespace com::sun::star::i18n
;
109 using ::rtl::OUString
;
110 using namespace ::comphelper
;
111 using namespace ::com::sun::star
;
113 /*--------------------------------------------------------------------
114 Beschreibung: Dialog zum Einfuegen einer Verzeichnismarkierung
115 --------------------------------------------------------------------*/
116 SwIndexMarkDlg::SwIndexMarkDlg(Window
*pParent
,
119 sal_Int32 _nOptionsId
, SwWrtShell
& rWrtShell
) :
120 Window(pParent
, rResId
),
121 aTypeFT (this, SW_RES(LBL_INDEX
)),
122 aTypeDCB(this, SW_RES(DCB_INDEX
)),
123 aNewBT(this, SW_RES(BT_NEW
)),
125 aEntryFT(this, SW_RES(LBL_ENTRY
)),
126 aEntryED(this, SW_RES(SL_ENTRY
)),
127 aPhoneticFT0(this, SW_RES(FT_PHONETIC_1
)),
128 aPhoneticED0(this, SW_RES(ED_PHONETIC_1
)),
130 aKeyFT(this, SW_RES(LBL_KEY
)),
131 aKeyDCB(this, SW_RES(DCB_KEY
)),
132 aPhoneticFT1(this, SW_RES(FT_PHONETIC_2
)),
133 aPhoneticED1(this, SW_RES(ED_PHONETIC_2
)),
135 aKey2FT(this, SW_RES(LBL_KEY2
)),
136 aKey2DCB(this, SW_RES(DCB_KEY2
)),
137 aPhoneticFT2(this, SW_RES(FT_PHONETIC_3
)),
138 aPhoneticED2(this, SW_RES(ED_PHONETIC_3
)),
140 aLevelFT(this, SW_RES(LBL_LEVEL
)),
141 aLevelED(this, SW_RES(SL_LEVEL
)),
142 aMainEntryCB(this, SW_RES(CB_MAIN_ENTRY
)),
143 aApplyToAllCB(this,SW_RES(CB_APPLY_TO_ALL
)),
144 aSearchCaseSensitiveCB(this, SW_RES(CB_CASESENSITIVE
)),
145 aSearchCaseWordOnlyCB(this, SW_RES(CB_WORDONLY
)),
147 aIndexFL(this, SW_RES(FL_INDEX
)),
149 aOKBT(this, SW_RES(BT_OK
)),
150 aCancelBT(this, SW_RES(BT_CANCEL
)),
151 aHelpBT(this, SW_RES(BT_HELP
)),
152 aDelBT(this, SW_RES(BT_DEL
)),
154 aPrevSameBT(this,SW_RES(BT_PREVSAME
)),
155 aNextSameBT(this,SW_RES(BT_NXTSAME
)),
156 aPrevBT(this, SW_RES(BT_PREV
)),
157 aNextBT(this, SW_RES(BT_NXT
)),
159 nOptionsId( _nOptionsId
),
162 bSelected(sal_False
),
164 bPhoneticED0_ChangedByUser(FALSE
),
165 bPhoneticED1_ChangedByUser(FALSE
),
166 bPhoneticED2_ChangedByUser(FALSE
),
167 nLangForPhoneticReading(2052),
168 bIsPhoneticReadingEnabled(FALSE
),
169 xExtendedIndexEntrySupplier(NULL
),
173 if( SvtCJKOptions().IsCJKFontEnabled() )
175 uno::Reference
< lang::XMultiServiceFactory
> xMSF
= getProcessServiceFactory();
177 xExtendedIndexEntrySupplier
=
178 uno::Reference
< i18n::XExtendedIndexEntrySupplier
> (
179 xMSF
->createInstance( C2U("com.sun.star.i18n.IndexEntrySupplier") ),
183 SetStyle(GetStyle()|WB_DIALOGCONTROL
);
185 aOKBT
.SetHelpId(HID_INSERT_IDX_MRK_OK
);
186 aCancelBT
.SetHelpId(HID_INSERT_IDX_MRK_CLOSE
);
187 aDelBT
.SetHelpId(HID_INSERT_IDX_MRK_DELETE
);
188 aNewBT
.SetHelpId(HID_INSERT_IDX_MRK_NEW
);
189 aPrevBT
.SetHelpId(HID_INSERT_IDX_MRK_PREV
);
190 aPrevSameBT
.SetHelpId(HID_INSERT_IDX_MRK_PREV_SAME
);
191 aNextBT
.SetHelpId(HID_INSERT_IDX_MRK_NEXT
);
192 aNextSameBT
.SetHelpId(HID_INSERT_IDX_MRK_NEXT_SAME
);
193 aTypeDCB
.SetHelpId(HID_INSERT_IDX_MRK_TYPE
);
194 aEntryED
.SetHelpId(HID_INSERT_IDX_MRK_ENTRY
);
195 aKeyDCB
.SetHelpId(HID_INSERT_IDX_MRK_PRIM_KEY
);
196 aKey2DCB
.SetHelpId(HID_INSERT_IDX_MRK_SEC_KEY
);
197 aLevelED
.SetHelpId(HID_INSERT_IDX_MRK_LEVEL
);
198 aMainEntryCB
.SetHelpId(HID_INSERT_IDX_MRK_MAIN_ENTRY
);
199 aApplyToAllCB
.SetHelpId(HID_INSERT_IDX_MRK_APPLY_ALL
);
200 aPhoneticED0
.SetHelpId(HID_INSERT_IDX_MRK_PHONETIC_READING
);
201 aPhoneticED1
.SetHelpId(HID_INSERT_IDX_MRK_PHONETIC_READING
);
202 aPhoneticED2
.SetHelpId(HID_INSERT_IDX_MRK_PHONETIC_READING
);
204 aSearchCaseSensitiveCB
.SetHelpId( HID_INSERT_IDX_MRK_SRCH_CASESENSITIVE
);
205 aSearchCaseWordOnlyCB
.SetHelpId( HID_INSERT_IDX_MRK_SRCH_WORDONLY
);
208 GetParent()->SetText( SW_RESSTR( bNewMark
? STR_IDXMRK_INSERT
: STR_IDXMRK_EDIT
));
210 aDelBT
.SetClickHdl(LINK(this,SwIndexMarkDlg
, DelHdl
));
211 aPrevBT
.SetClickHdl(LINK(this,SwIndexMarkDlg
, PrevHdl
));
212 aPrevSameBT
.SetClickHdl(LINK(this,SwIndexMarkDlg
, PrevSameHdl
));
213 aNextBT
.SetClickHdl(LINK(this,SwIndexMarkDlg
, NextHdl
));
214 aNextSameBT
.SetClickHdl(LINK(this,SwIndexMarkDlg
, NextSameHdl
));
215 //aTypeDCB.SetModifyHdl(LINK(this,SwIndexMarkDlg, ModifyHdl));
216 aTypeDCB
.SetSelectHdl(LINK(this,SwIndexMarkDlg
, ModifyHdl
));
217 aKeyDCB
.SetModifyHdl(LINK(this,SwIndexMarkDlg
, KeyDCBModifyHdl
));
218 aKey2DCB
.SetModifyHdl(LINK(this,SwIndexMarkDlg
, KeyDCBModifyHdl
));
219 aOKBT
.SetClickHdl(LINK(this,SwIndexMarkDlg
, InsertHdl
));
220 aCancelBT
.SetClickHdl(LINK(this,SwIndexMarkDlg
, CloseHdl
));
221 aEntryED
.SetModifyHdl(LINK(this,SwIndexMarkDlg
, ModifyHdl
));
222 aNewBT
.SetClickHdl(LINK(this, SwIndexMarkDlg
, NewUserIdxHdl
));
223 aApplyToAllCB
.SetClickHdl(LINK(this, SwIndexMarkDlg
, SearchTypeHdl
));
224 aPhoneticED0
.SetModifyHdl(LINK(this,SwIndexMarkDlg
, PhoneticEDModifyHdl
));
225 aPhoneticED1
.SetModifyHdl(LINK(this,SwIndexMarkDlg
, PhoneticEDModifyHdl
));
226 aPhoneticED2
.SetModifyHdl(LINK(this,SwIndexMarkDlg
, PhoneticEDModifyHdl
));
233 ImageList
aTempList( SW_RES( IMG_NAVI_ENTRYBMPH
) );
234 aNewBT
.SetModeImage( aTempList
.GetImage( SID_SW_START
+ CONTENT_TYPE_INDEX
), BMP_COLOR_HIGHCONTRAST
);
238 ImageList
aTempList( SW_RES( IMG_NAVI_ENTRYBMP
) );
239 aNewBT
.SetModeImage( aTempList
.GetImage( SID_SW_START
+ CONTENT_TYPE_INDEX
), BMP_COLOR_NORMAL
);
245 OKButton
aTmp(this, WB_HIDE
);
246 aOKBT
.SetText( aTmp
.GetText() );
249 aEntryED
.GrabFocus();
252 /*--------------------------------------------------------------------
253 Beschreibung: Controls neu initialisieren mit der aktuellen
255 --------------------------------------------------------------------*/
258 void SwIndexMarkDlg::InitControls()
260 DBG_ASSERT(pSh
&& pTOXMgr
, "Shell nicht da?");
261 // Inhalts-Verzeichnis
262 const SwTOXType
* pType
= pTOXMgr
->GetTOXType(TOX_CONTENT
, 0);
263 ASSERT(pType
, "Kein Verzeichnistyp !!");
264 String sTmpTypeSelection
;
265 if(aTypeDCB
.GetSelectEntryCount())
266 sTmpTypeSelection
= aTypeDCB
.GetSelectEntry();
268 aTypeDCB
.InsertEntry(pType
->GetTypeName());
270 // Stichwort-Verzeichnis
271 pType
= pTOXMgr
->GetTOXType(TOX_INDEX
, 0);
272 ASSERT(pType
, "Kein Verzeichnistyp !!");
273 aTypeDCB
.InsertEntry(pType
->GetTypeName());
275 // Benutzerverzeichnisse
276 sal_uInt16 nCount
= pSh
->GetTOXTypeCount(TOX_USER
);
278 for( i
= 0; i
< nCount
; ++i
)
279 aTypeDCB
.InsertEntry( pSh
->GetTOXType(TOX_USER
, i
)->GetTypeName() );
281 // KeyWords Primary einlesen
283 nCount
= pSh
->GetTOIKeys( TOI_PRIMARY
, aArr
);
284 for(i
=0; i
< nCount
; ++i
)
285 aKeyDCB
.InsertEntry( *aArr
[ i
] );
287 // KeyWords Secondary einlesen
288 nCount
= pSh
->GetTOIKeys( TOI_SECONDARY
, aArr
);
289 for(i
=0; i
< nCount
; ++i
)
290 aKey2DCB
.InsertEntry( *aArr
[ i
] );
292 UpdateLanguageDependenciesForPhoneticReading();
295 const SwTOXMark
* pMark
= pTOXMgr
->GetCurTOXMark();
296 if( pMark
&& !bNewMark
)
300 // nur wenn mehr als eins vorhanden
301 // wenn gleich landet es auf dem gleichen Eintrag
304 const SwTOXMark
* pMoveMark
;
305 sal_Bool bShow
= sal_False
;
307 pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_PRV
);
308 if( pMoveMark
!= pMark
)
309 pSh
->GotoTOXMark( *pMoveMark
, TOX_NXT
), bShow
= sal_True
;
310 aPrevBT
.Enable( pMoveMark
!= pMark
);
311 pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_NXT
);
312 if( pMoveMark
!= pMark
)
313 pSh
->GotoTOXMark( *pMoveMark
, TOX_PRV
), bShow
= sal_True
;
314 aNextBT
.Enable( pMoveMark
!= pMark
);
322 pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_SAME_PRV
);
323 if( pMoveMark
!= pMark
)
324 pSh
->GotoTOXMark( *pMoveMark
, TOX_SAME_NXT
), bShow
= sal_True
;
325 aPrevSameBT
.Enable( pMoveMark
!= pMark
);
326 pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_SAME_NXT
);
327 if( pMoveMark
!= pMark
)
328 pSh
->GotoTOXMark( *pMoveMark
, TOX_SAME_PRV
), bShow
= sal_True
;
329 aNextSameBT
.Enable( pMoveMark
!= pMark
);
339 aTypeDCB
.Enable(sal_False
);
340 aTypeFT
.Enable(sal_False
);
345 { // aktuelle Selektion (1.Element) anzeigen ????
346 sal_uInt16 nCnt
= pSh
->GetCrsrCnt();
349 bSelected
= !pSh
->HasSelection();
350 aOrgStr
= pSh
->GetView().GetSelectionTextParam(sal_True
, sal_False
);
351 aEntryED
.SetText(aOrgStr
);
353 //alle gleichen Eintraege aufzunehmen darf nur im Body und auch da nur
354 //bei vorhandener einfacher Selektion erlaubt werden
355 const sal_uInt16 nFrmType
= pSh
->GetFrmType(0,sal_True
);
356 aApplyToAllCB
.Show();
357 aSearchCaseSensitiveCB
.Show();
358 aSearchCaseWordOnlyCB
.Show();
359 aApplyToAllCB
.Enable(0 != aOrgStr
.Len() &&
360 0 == (nFrmType
& ( FRMTYPE_HEADER
| FRMTYPE_FOOTER
| FRMTYPE_FLY_ANY
)));
361 SearchTypeHdl(&aApplyToAllCB
);
364 // Verzeichnistyp ist default
365 if( sTmpTypeSelection
.Len() &&
366 LISTBOX_ENTRY_NOTFOUND
!= aTypeDCB
.GetEntryPos( sTmpTypeSelection
) )
367 aTypeDCB
.SelectEntry(sTmpTypeSelection
);
369 aTypeDCB
.SelectEntry(aTypeDCB
.GetEntry(nTypePos
));
370 ModifyHdl(&aTypeDCB
);
374 void SwIndexMarkDlg::UpdateLanguageDependenciesForPhoneticReading()
376 //no phonetic reading if no global cjk support
377 if( !xExtendedIndexEntrySupplier
.is() )
379 bIsPhoneticReadingEnabled
= FALSE
;
382 bIsPhoneticReadingEnabled
= TRUE
;
384 //get the current language
385 if(!bNewMark
) //if dialog is opened to iterate existing marks
387 ASSERT(pTOXMgr
, "need TOXMgr")
390 SwTOXMark
* pMark
= pTOXMgr
->GetCurTOXMark();
391 ASSERT(pMark
, "need current SwTOXMark");
394 SwTxtTOXMark
* pTxtTOXMark
= pMark
->GetTxtTOXMark();
395 ASSERT(pTxtTOXMark
, "need current SwTxtTOXMark");
398 const SwTxtNode
* pTxtNode
= pTxtTOXMark
->GetpTxtNd();
399 ASSERT(pTxtNode
, "need current SwTxtNode");
402 xub_StrLen nTextIndex
= *pTxtTOXMark
->GetStart();
403 nLangForPhoneticReading
= pTxtNode
->GetLang( nTextIndex
);
405 else //if dialog is opened to create a new mark
407 USHORT nScriptType
= pSh
->GetScriptType();
411 case SCRIPTTYPE_ASIAN
: nWhich
= RES_CHRATR_CJK_LANGUAGE
; break;
412 case SCRIPTTYPE_COMPLEX
:nWhich
= RES_CHRATR_CTL_LANGUAGE
; break;
413 //case SCRIPTTYPE_LATIN:
414 default:nWhich
= RES_CHRATR_LANGUAGE
; break;
416 SfxItemSet
aLangSet(pSh
->GetAttrPool(), nWhich
, nWhich
);
417 pSh
->GetCurAttr(aLangSet
);
418 nLangForPhoneticReading
= ((const SvxLanguageItem
&)aLangSet
.Get(nWhich
)).GetLanguage();
422 //enable phonetic reading dependent on the current language
424 lang::Locale aLocale( SvxCreateLocale( LanguageType( nLangForPhoneticReading ) ) );
425 bIsPhoneticReadingEnabled = xExtendedIndexEntrySupplier->usePhoneticEntry( aLocale );
430 String
SwIndexMarkDlg::GetDefaultPhoneticReading( const String
& rText
)
432 if( !bIsPhoneticReadingEnabled
)
435 lang::Locale
aLocale( SvxCreateLocale( LanguageType( nLangForPhoneticReading
) ) );
436 return xExtendedIndexEntrySupplier
->getPhoneticCandidate(rText
, aLocale
);
439 /* -----------------07.09.99 10:43-------------------
440 Change the content of aEntryED if text is selected
441 --------------------------------------------------*/
443 void SwIndexMarkDlg::Activate()
445 // aktuelle Selektion (1.Element) anzeigen ????
448 sal_uInt16 nCnt
= pSh
->GetCrsrCnt();
451 bSelected
= !pSh
->HasSelection();
452 aOrgStr
= pSh
->GetView().GetSelectionTextParam(sal_True
, sal_False
);
453 aEntryED
.SetText(aOrgStr
);
455 //alle gleichen Eintraege aufzunehmen darf nur im Body und auch da nur
456 //bei vorhandener einfacher Selektion erlaubt werden
457 const sal_uInt16 nFrmType
= pSh
->GetFrmType(0,sal_True
);
458 aApplyToAllCB
.Show();
459 aSearchCaseSensitiveCB
.Show();
460 aSearchCaseWordOnlyCB
.Show();
461 aApplyToAllCB
.Enable(0 != aOrgStr
.Len() &&
462 0 == (nFrmType
& ( FRMTYPE_HEADER
| FRMTYPE_FOOTER
| FRMTYPE_FLY_ANY
)));
463 SearchTypeHdl(&aApplyToAllCB
);
465 ModifyHdl(&aTypeDCB
);
469 /*--------------------------------------------------------------------
470 Beschreibung: Ok-Button auswerten
471 --------------------------------------------------------------------*/
472 void SwIndexMarkDlg::Apply()
476 pSh
->ResetSelect(0, sal_False
);
479 /*--------------------------------------------------------------------
480 Beschreibung: Aenderungen uebernehmen
481 --------------------------------------------------------------------*/
484 void SwIndexMarkDlg::InsertUpdate()
486 pSh
->StartUndo(bDel
? UNDO_INDEX_ENTRY_DELETE
: UNDO_INDEX_ENTRY_INSERT
);
487 pSh
->StartAllAction();
489 SwRewriter aRewriter
;
495 if ( pTOXMgr
->GetCurTOXMark())
496 aRewriter
.AddRule(UNDO_ARG1
, pTOXMgr
->GetCurTOXMark()->GetText());
498 else if( !pSh
->HasReadonlySel() )
500 if ( pTOXMgr
->GetCurTOXMark())
501 aRewriter
.AddRule(UNDO_ARG1
,
502 pTOXMgr
->GetCurTOXMark()->GetText());
505 pTOXMgr
->DeleteTOXMark();
506 else if( pTOXMgr
->GetCurTOXMark() )
511 pSh
->EndUndo(bDel
? UNDO_INDEX_ENTRY_DELETE
: UNDO_INDEX_ENTRY_INSERT
);
513 if((nTypePos
= aTypeDCB
.GetEntryPos(aTypeDCB
.GetSelectEntry())) == LISTBOX_ENTRY_NOTFOUND
)
516 nKey1Pos
= aKeyDCB
.GetEntryPos(aKeyDCB
.GetText());
517 nKey2Pos
= aKey2DCB
.GetEntryPos(aKey2DCB
.GetText());
520 /*--------------------------------------------------------------------
521 Beschreibung: Marke einfuegen
522 --------------------------------------------------------------------*/
523 static void lcl_SelectSameStrings(SwWrtShell
& rSh
, BOOL bWordOnly
, BOOL bCaseSensitive
)
527 SearchOptions
aSearchOpt(
528 SearchAlgorithms_ABSOLUTE
,
529 ( bWordOnly
? SearchFlags::NORM_WORD_ONLY
: 0 ),
530 rSh
.GetSelTxt(), OUString(),
531 SvxCreateLocale( GetAppLanguage() ),
535 : TransliterationModules_IGNORE_CASE
) );
540 //todo/mba: assuming that notes should not be searched
541 BOOL bSearchInNotes
= FALSE
;
542 rSh
.Find( aSearchOpt
, bSearchInNotes
, DOCPOS_START
, DOCPOS_END
, bCancel
,
543 (FindRanges
)(FND_IN_SELALL
|FND_IN_BODYONLY
), FALSE
);
547 void SwIndexMarkDlg::InsertMark()
549 sal_uInt16 nPos
= aTypeDCB
.GetEntryPos(aTypeDCB
.GetSelectEntry());
550 TOXTypes eType
= nPos
== POS_CONTENT
? TOX_CONTENT
:
551 nPos
== POS_INDEX
? TOX_INDEX
: TOX_USER
;
553 SwTOXMarkDescription
aDesc(eType
);
555 sal_uInt16 nLevel
= (sal_uInt16
)aLevelED
.Denormalize(aLevelED
.GetValue());
558 case POS_CONTENT
: break;
559 case POS_INDEX
: // Stichwortverzeichnismarke
562 String
aPrim(aKeyDCB
.GetText());
563 String
aSec(aKey2DCB
.GetText());
564 aDesc
.SetPrimKey(aPrim
);
565 aDesc
.SetSecKey(aSec
);
566 aDesc
.SetMainEntry(aMainEntryCB
.IsChecked());
567 aDesc
.SetPhoneticReadingOfAltStr(aPhoneticED0
.GetText());
568 aDesc
.SetPhoneticReadingOfPrimKey(aPhoneticED1
.GetText());
569 aDesc
.SetPhoneticReadingOfSecKey(aPhoneticED2
.GetText());
572 default: // Userdefinedverz.-Marke
574 String
aName(aTypeDCB
.GetSelectEntry());
575 aDesc
.SetTOUName(aName
);
578 if (aOrgStr
!= aEntryED
.GetText())
579 aDesc
.SetAltStr(aEntryED
.GetText());
580 BOOL bApplyAll
= aApplyToAllCB
.IsChecked();
581 BOOL bWordOnly
= aSearchCaseWordOnlyCB
.IsChecked();
582 BOOL bCaseSensitive
= aSearchCaseSensitiveCB
.IsChecked();
584 pSh
->StartAllAction();
585 // hier muessen alle gleichen Strings selektiert werden
586 // damit der Eintrag auf alle gleichen Strings angewandt wird
589 lcl_SelectSameStrings(*pSh
, bWordOnly
, bCaseSensitive
);
591 aDesc
.SetLevel(nLevel
);
593 aMgr
.InsertTOXMark(aDesc
);
600 /*--------------------------------------------------------------------
601 Beschreibung: Marke Updaten
602 --------------------------------------------------------------------*/
605 void SwIndexMarkDlg::UpdateMark()
607 String
aAltText(aEntryED
.GetText());
608 String
* pAltText
= aOrgStr
!= aEntryED
.GetText() ? &aAltText
: 0;
609 //empty alternative texts are not allowed
610 if(pAltText
&& !pAltText
->Len())
615 sal_uInt16 nPos
= aTypeDCB
.GetEntryPos(aTypeDCB
.GetSelectEntry());
616 TOXTypes eType
= TOX_USER
;
617 if(POS_CONTENT
== nPos
)
619 else if(POS_INDEX
== nPos
)
622 SwTOXMarkDescription
aDesc(eType
);
623 aDesc
.SetLevel( static_cast< int >(aLevelED
.GetValue()) );
625 aDesc
.SetAltStr(*pAltText
);
627 String
aPrim(aKeyDCB
.GetText());
629 aDesc
.SetPrimKey(aPrim
);
630 String
aSec(aKey2DCB
.GetText());
632 aDesc
.SetSecKey(aSec
);
634 if(eType
== TOX_INDEX
)
636 aDesc
.SetPhoneticReadingOfAltStr(aPhoneticED0
.GetText());
637 aDesc
.SetPhoneticReadingOfPrimKey(aPhoneticED1
.GetText());
638 aDesc
.SetPhoneticReadingOfSecKey(aPhoneticED2
.GetText());
640 aDesc
.SetMainEntry(aMainEntryCB
.IsVisible() && aMainEntryCB
.IsChecked());
641 pTOXMgr
->UpdateTOXMark(aDesc
);
644 /*--------------------------------------------------------------------
645 Beschreibung: Neue Keys eintragen
646 --------------------------------------------------------------------*/
649 void SwIndexMarkDlg::UpdateKeyBoxes()
651 String
aKey(aKeyDCB
.GetText());
652 sal_uInt16 nPos
= aKeyDCB
.GetEntryPos(aKey
);
654 if(nPos
== LISTBOX_ENTRY_NOTFOUND
&& aKey
.Len() > 0)
655 { // neuen Key erzeugen
656 aKeyDCB
.InsertEntry(aKey
);
659 aKey
= aKey2DCB
.GetText();
660 nPos
= aKey2DCB
.GetEntryPos(aKey
);
662 if(nPos
== LISTBOX_ENTRY_NOTFOUND
&& aKey
.Len() > 0)
663 { // neuen Key erzeugen
664 aKey2DCB
.InsertEntry(aKey
);
667 /* -----------------13.10.99 15:10-------------------
669 --------------------------------------------------*/
670 class SwNewUserIdxDlg
: public ModalDialog
673 CancelButton aCancelPB
;
679 SwIndexMarkDlg
* pDlg
;
681 DECL_LINK( ModifyHdl
, Edit
*);
684 SwNewUserIdxDlg(SwIndexMarkDlg
* pParent
) :
685 ModalDialog(pParent
, SW_RES(DLG_NEW_USER_IDX
)),
686 aOKPB(this, SW_RES( PB_OK
)),
687 aCancelPB(this, SW_RES( PB_CANCEL
)),
688 aHelpPB(this, SW_RES( PB_HELP
)),
689 aNameFL(this, SW_RES( FL_NAME
)),
690 aNameFT(this, SW_RES( FT_NAME
)),
691 aNameED(this, SW_RES( ED_NAME
)),
695 aNameED
.SetModifyHdl(LINK(this, SwNewUserIdxDlg
, ModifyHdl
));
696 aOKPB
.Enable(sal_False
);
700 virtual void Apply();
701 String
GetName(){return aNameED
.GetText();}
703 void SwNewUserIdxDlg::Apply()
707 IMPL_LINK( SwNewUserIdxDlg
, ModifyHdl
, Edit
*, pEdit
)
709 aOKPB
.Enable(pEdit
->GetText().Len() && !pDlg
->IsTOXType(pEdit
->GetText()));
713 IMPL_LINK( SwIndexMarkDlg
, NewUserIdxHdl
, Button
*, EMPTYARG
)
715 SwNewUserIdxDlg
* pDlg
= new SwNewUserIdxDlg(this);
716 if(RET_OK
== pDlg
->Execute())
718 String
sNewName(pDlg
->GetName());
719 aTypeDCB
.InsertEntry(sNewName
);
720 aTypeDCB
.SelectEntry(sNewName
);
725 /* -----------------------------17.01.00 12:18--------------------------------
727 ---------------------------------------------------------------------------*/
728 IMPL_LINK( SwIndexMarkDlg
, SearchTypeHdl
, CheckBox
*, pBox
)
730 sal_Bool bEnable
= pBox
->IsChecked() && pBox
->IsEnabled();
731 aSearchCaseWordOnlyCB
.Enable(bEnable
);
732 aSearchCaseSensitiveCB
.Enable(bEnable
);
735 /* -----------------07.09.99 10:30-------------------
737 --------------------------------------------------*/
738 IMPL_LINK( SwIndexMarkDlg
, InsertHdl
, Button
*, pButton
)
741 //close the dialog if only one entry is available
742 if(!bNewMark
&& !aPrevBT
.IsVisible() && !aNextBT
.IsVisible())
746 /* -----------------07.09.99 10:29-------------------
748 --------------------------------------------------*/
749 IMPL_LINK( SwIndexMarkDlg
, CloseHdl
, Button
*, EMPTYARG
)
753 sal_uInt16 nSlot
= FN_INSERT_IDX_ENTRY_DLG
;
754 SfxViewFrame::Current()->GetDispatcher()->Execute(nSlot
,
755 SFX_CALLMODE_ASYNCHRON
|SFX_CALLMODE_RECORD
);
759 ((SwIndexMarkModalDlg
*)GetParent())->EndDialog(RET_CANCEL
);
763 /*--------------------------------------------------------------------
764 Beschreibung: VerzeichnisTyp auswaehlen nur bei Einfuegen
765 --------------------------------------------------------------------*/
766 IMPL_LINK( SwIndexMarkDlg
, ModifyHdl
, ListBox
*, pBox
)
768 if(&aTypeDCB
== pBox
)
770 // Verzeichnistyp setzen
771 sal_uInt16 nPos
= aTypeDCB
.GetEntryPos(aTypeDCB
.GetSelectEntry());
772 sal_Bool bLevelEnable
= sal_False
,
773 bKeyEnable
= sal_False
,
774 bSetKey2
= sal_False
,
775 bKey2Enable
= sal_False
,
776 bEntryHasText
= sal_False
,
777 bKey1HasText
= sal_False
,
778 bKey2HasText
= sal_False
;
779 if(nPos
== POS_INDEX
)
781 if(aEntryED
.GetText().Len())
782 bEntryHasText
= sal_True
;
783 aPhoneticED0
.SetText(GetDefaultPhoneticReading(aEntryED
.GetText()));
785 bKeyEnable
= sal_True
;
786 aKeyDCB
.SetText(aKeyDCB
.GetEntry(nKey1Pos
));
787 aPhoneticED1
.SetText(GetDefaultPhoneticReading(aKeyDCB
.GetText()));
788 if(aKeyDCB
.GetText().Len() > 0)
790 bKey1HasText
= bSetKey2
= bKey2Enable
= sal_True
;
791 aKey2DCB
.SetText(aKey2DCB
.GetEntry(nKey2Pos
));
792 aPhoneticED2
.SetText(GetDefaultPhoneticReading(aKey2DCB
.GetText()));
793 if(aKey2DCB
.GetText().Len())
794 bKey2HasText
= sal_True
;
799 bLevelEnable
= sal_True
;
800 aLevelED
.SetMax(MAXLEVEL
);
801 aLevelED
.SetValue(aLevelED
.Normalize(0));
804 aLevelFT
.Show(bLevelEnable
);
805 aLevelED
.Show(bLevelEnable
);
806 aMainEntryCB
.Show(nPos
== POS_INDEX
);
808 aKeyFT
.Enable(bKeyEnable
);
809 aKeyDCB
.Enable(bKeyEnable
);
812 aKey2DCB
.Enable(bKey2Enable
);
813 aKey2FT
.Enable(bKey2Enable
);
815 aPhoneticFT0
.Enable(bKeyEnable
&&bEntryHasText
&&bIsPhoneticReadingEnabled
);
816 aPhoneticED0
.Enable(bKeyEnable
&&bEntryHasText
&&bIsPhoneticReadingEnabled
);
817 aPhoneticFT1
.Enable(bKeyEnable
&&bKey1HasText
&&bIsPhoneticReadingEnabled
);
818 aPhoneticED1
.Enable(bKeyEnable
&&bKey1HasText
&&bIsPhoneticReadingEnabled
);
819 aPhoneticFT2
.Enable(bKeyEnable
&&bKey2HasText
&&bIsPhoneticReadingEnabled
);
820 aPhoneticED2
.Enable(bKeyEnable
&&bKey2HasText
&&bIsPhoneticReadingEnabled
);
822 else //aEntryED !!aEntryED is not a ListBox but a Edit
824 BOOL bHasText
= (aEntryED
.GetText().Len()>0);
827 aPhoneticED0
.SetText(aEmptyStr
);
828 bPhoneticED0_ChangedByUser
= FALSE
;
830 else if(!bPhoneticED0_ChangedByUser
)
831 aPhoneticED0
.SetText(GetDefaultPhoneticReading(aEntryED
.GetText()));
833 aPhoneticFT0
.Enable(bHasText
&&bIsPhoneticReadingEnabled
);
834 aPhoneticED0
.Enable(bHasText
&&bIsPhoneticReadingEnabled
);
836 aOKBT
.Enable(!pSh
->HasReadonlySel() &&
837 (aEntryED
.GetText().Len() || pSh
->GetCrsrCnt(sal_False
)));
841 /*--------------------------------------------------------------------
843 --------------------------------------------------------------------*/
846 IMPL_LINK_INLINE_START( SwIndexMarkDlg
, NextHdl
, Button
*, EMPTYARG
)
849 pTOXMgr
->NextTOXMark();
853 IMPL_LINK_INLINE_END( SwIndexMarkDlg
, NextHdl
, Button
*, EMPTYARG
)
856 IMPL_LINK_INLINE_START( SwIndexMarkDlg
, NextSameHdl
, Button
*, EMPTYARG
)
859 pTOXMgr
->NextTOXMark(sal_True
);
863 IMPL_LINK_INLINE_END( SwIndexMarkDlg
, NextSameHdl
, Button
*, EMPTYARG
)
866 IMPL_LINK_INLINE_START( SwIndexMarkDlg
, PrevHdl
, Button
*, EMPTYARG
)
869 pTOXMgr
->PrevTOXMark();
873 IMPL_LINK_INLINE_END( SwIndexMarkDlg
, PrevHdl
, Button
*, EMPTYARG
)
876 IMPL_LINK_INLINE_START( SwIndexMarkDlg
, PrevSameHdl
, Button
*, EMPTYARG
)
879 pTOXMgr
->PrevTOXMark(sal_True
);
884 IMPL_LINK_INLINE_END( SwIndexMarkDlg
, PrevSameHdl
, Button
*, EMPTYARG
)
887 IMPL_LINK( SwIndexMarkDlg
, DelHdl
, Button
*, EMPTYARG
)
893 if(pTOXMgr
->GetCurTOXMark())
897 CloseHdl(&aCancelBT
);
898 SfxViewFrame::Current()->GetBindings().Invalidate(FN_EDIT_IDX_ENTRY_DLG
);
903 /*--------------------------------------------------------------------
904 Beschreibung: Dialoganzeige erneuern
905 --------------------------------------------------------------------*/
908 void SwIndexMarkDlg::UpdateDialog()
910 DBG_ASSERT(pSh
&& pTOXMgr
, "Shell nicht da?");
911 SwTOXMark
* pMark
= pTOXMgr
->GetCurTOXMark();
912 ASSERT(pMark
, "Keine aktuelle Markierung");
916 ViewShell::SetCareWin( GetParent() );
918 aOrgStr
= pMark
->GetText();
919 aEntryED
.SetText(aOrgStr
);
921 // Verzeichnistyp setzen
922 sal_Bool bLevelEnable
= sal_True
,
923 bKeyEnable
= sal_False
,
924 bKey2Enable
= sal_False
,
925 bEntryHasText
= sal_False
,
926 bKey1HasText
= sal_False
,
927 bKey2HasText
= sal_False
;
929 TOXTypes eCurType
= pMark
->GetTOXType()->GetType();
930 if(TOX_INDEX
== eCurType
)
932 bLevelEnable
= sal_False
;
933 bKeyEnable
= sal_True
;
934 bKey1HasText
= bKey2Enable
= 0 != pMark
->GetPrimaryKey().Len();
935 bKey2HasText
= 0 != pMark
->GetSecondaryKey().Len();
936 bEntryHasText
= 0 != pMark
->GetText().Len();
937 aKeyDCB
.SetText( pMark
->GetPrimaryKey() );
938 aKey2DCB
.SetText( pMark
->GetSecondaryKey() );
939 aPhoneticED0
.SetText( pMark
->GetTextReading() );
940 aPhoneticED1
.SetText( pMark
->GetPrimaryKeyReading() );
941 aPhoneticED2
.SetText( pMark
->GetSecondaryKeyReading() );
942 aMainEntryCB
.Check(pMark
->IsMainEntry());
944 else if(TOX_CONTENT
== eCurType
|| TOX_USER
== eCurType
)
946 aLevelED
.SetValue(aLevelED
.Normalize(pMark
->GetLevel()));
948 aKeyFT
.Enable(bKeyEnable
);
949 aKeyDCB
.Enable(bKeyEnable
);
950 aLevelED
.SetMax(MAXLEVEL
);
951 aLevelFT
.Show(bLevelEnable
);
952 aLevelED
.Show(bLevelEnable
);
953 aMainEntryCB
.Show(!bLevelEnable
);
954 aKey2FT
.Enable(bKey2Enable
);
955 aKey2DCB
.Enable(bKey2Enable
);
957 UpdateLanguageDependenciesForPhoneticReading();
958 aPhoneticFT0
.Enable(bKeyEnable
&&bEntryHasText
&&bIsPhoneticReadingEnabled
);
959 aPhoneticED0
.Enable(bKeyEnable
&&bEntryHasText
&&bIsPhoneticReadingEnabled
);
960 aPhoneticFT1
.Enable(bKeyEnable
&&bKey1HasText
&&bIsPhoneticReadingEnabled
);
961 aPhoneticED1
.Enable(bKeyEnable
&&bKey1HasText
&&bIsPhoneticReadingEnabled
);
962 aPhoneticFT2
.Enable(bKeyEnable
&&bKey2HasText
&&bIsPhoneticReadingEnabled
);
963 aPhoneticED2
.Enable(bKeyEnable
&&bKey2HasText
&&bIsPhoneticReadingEnabled
);
965 // Verzeichnis-Typ setzen
966 aTypeDCB
.SelectEntry(pMark
->GetTOXType()->GetTypeName());
968 // Next - Prev - Buttons setzen
970 if( aPrevBT
.IsVisible() )
972 const SwTOXMark
* pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_PRV
);
973 if( pMoveMark
!= pMark
)
974 pSh
->GotoTOXMark( *pMoveMark
, TOX_NXT
);
975 aPrevBT
.Enable( pMoveMark
!= pMark
);
976 pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_NXT
);
977 if( pMoveMark
!= pMark
)
978 pSh
->GotoTOXMark( *pMoveMark
, TOX_PRV
);
979 aNextBT
.Enable( pMoveMark
!= pMark
);
982 if( aPrevSameBT
.IsVisible() )
984 const SwTOXMark
* pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_SAME_PRV
);
985 if( pMoveMark
!= pMark
)
986 pSh
->GotoTOXMark( *pMoveMark
, TOX_SAME_NXT
);
987 aPrevSameBT
.Enable( pMoveMark
!= pMark
);
988 pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_SAME_NXT
);
989 if( pMoveMark
!= pMark
)
990 pSh
->GotoTOXMark( *pMoveMark
, TOX_SAME_PRV
);
991 aNextSameBT
.Enable( pMoveMark
!= pMark
);
994 sal_Bool bEnable
= !pSh
->HasReadonlySel();
995 aOKBT
.Enable( bEnable
);
996 aDelBT
.Enable( bEnable
);
997 aEntryED
.SetReadOnly( !bEnable
);
998 aLevelED
.SetReadOnly( !bEnable
);
999 aKeyDCB
.SetReadOnly( !bEnable
);
1000 aKey2DCB
.SetReadOnly( !bEnable
);
1002 pSh
->SelectTxtAttr( RES_TXTATR_TOXMARK
, pMark
->GetTxtTOXMark() );
1003 // we need the point at the start of the attribut
1009 /*--------------------------------------------------------------------
1010 Remind wether the edit boxes for Phonetic reading are changed manually
1011 --------------------------------------------------------------------*/
1013 IMPL_LINK( SwIndexMarkDlg
, PhoneticEDModifyHdl
, Edit
*, pEdit
)
1015 if(&aPhoneticED0
== pEdit
)
1017 bPhoneticED0_ChangedByUser
= pEdit
->GetText().Len()>0;
1019 else if(&aPhoneticED1
== pEdit
)
1021 bPhoneticED1_ChangedByUser
= pEdit
->GetText().Len()>0;
1023 else if(&aPhoneticED2
== pEdit
)
1025 bPhoneticED2_ChangedByUser
= pEdit
->GetText().Len()>0;
1030 /*--------------------------------------------------------------------
1031 Beschreibung: Enable Disable des 2. Schluessels
1032 --------------------------------------------------------------------*/
1034 IMPL_LINK( SwIndexMarkDlg
, KeyDCBModifyHdl
, ComboBox
*, pBox
)
1036 if(&aKeyDCB
== pBox
)
1038 sal_Bool bEnable
= pBox
->GetText().Len() > 0;
1041 aKey2DCB
.SetText(aEmptyStr
);
1042 aPhoneticED1
.SetText(aEmptyStr
);
1043 aPhoneticED2
.SetText(aEmptyStr
);
1044 bPhoneticED1_ChangedByUser
= FALSE
;
1045 bPhoneticED2_ChangedByUser
= FALSE
;
1049 if(pBox
->IsInDropDown())
1051 //reset bPhoneticED1_ChangedByUser if a completly new string is selected
1052 bPhoneticED1_ChangedByUser
= FALSE
;
1054 if(!bPhoneticED1_ChangedByUser
)
1055 aPhoneticED1
.SetText(GetDefaultPhoneticReading(pBox
->GetText()));
1057 aKey2DCB
.Enable(bEnable
);
1058 aKey2FT
.Enable(bEnable
);
1060 else if(&aKey2DCB
== pBox
)
1062 if(!(pBox
->GetText().Len()>0))
1064 aPhoneticED2
.SetText(aEmptyStr
);
1065 bPhoneticED2_ChangedByUser
= FALSE
;
1069 if(pBox
->IsInDropDown())
1071 //reset bPhoneticED1_ChangedByUser if a completly new string is selected
1072 bPhoneticED2_ChangedByUser
= FALSE
;
1074 if(!bPhoneticED2_ChangedByUser
)
1075 aPhoneticED2
.SetText(GetDefaultPhoneticReading(pBox
->GetText()));
1078 sal_Bool bKey1HasText
= (0 != aKeyDCB
.GetText().Len());
1079 sal_Bool bKey2HasText
= (0 != aKey2DCB
.GetText().Len());
1081 aPhoneticFT1
.Enable(bKey1HasText
&&bIsPhoneticReadingEnabled
);
1082 aPhoneticED1
.Enable(bKey1HasText
&bIsPhoneticReadingEnabled
);
1083 aPhoneticFT2
.Enable(bKey2HasText
&bIsPhoneticReadingEnabled
);
1084 aPhoneticED2
.Enable(bKey2HasText
&bIsPhoneticReadingEnabled
);
1089 /*-----------------25.02.94 21:19-------------------
1091 --------------------------------------------------*/
1094 SwIndexMarkDlg::~SwIndexMarkDlg()
1097 ViewShell::SetCareWin( 0 );
1099 /* -----------------07.09.99 08:41-------------------
1101 --------------------------------------------------*/
1102 void SwIndexMarkDlg::ReInitDlg(SwWrtShell
& rWrtShell
, SwTOXMark
* pCurTOXMark
)
1106 pTOXMgr
= new SwTOXMgr(pSh
);
1109 for(USHORT i
= 0; i
< pTOXMgr
->GetTOXMarkCount(); i
++)
1110 if(pTOXMgr
->GetTOXMark(i
) == pCurTOXMark
)
1112 pTOXMgr
->SetCurTOXMark(i
);
1118 /* -----------------06.10.99 10:00-------------------
1120 --------------------------------------------------*/
1121 SwIndexMarkFloatDlg::SwIndexMarkFloatDlg(SfxBindings
* _pBindings
,
1122 SfxChildWindow
* pChild
,
1124 SfxChildWinInfo
* pInfo
,
1126 SfxModelessDialog(_pBindings
, pChild
, pParent
, SvtCJKOptions().IsCJKFontEnabled()?SW_RES(DLG_INSIDXMARK_CJK
):SW_RES(DLG_INSIDXMARK
)),
1127 aDlg(this, bNew
, SW_RES(WIN_DLG
), SvtCJKOptions().IsCJKFontEnabled()?DLG_INSIDXMARK_CJK
:DLG_INSIDXMARK
, *::GetActiveWrtShell())
1130 aDlg
.ReInitDlg(*::GetActiveWrtShell());
1133 /* -----------------06.10.99 10:27-------------------
1135 --------------------------------------------------*/
1136 void SwIndexMarkFloatDlg::Activate()
1138 SfxModelessDialog::Activate();
1142 void SwIndexMarkFloatDlg::ReInitDlg(SwWrtShell
& rWrtShell
)
1144 aDlg
.ReInitDlg( rWrtShell
);
1147 /* -----------------06.10.99 10:35-------------------
1149 --------------------------------------------------*/
1150 SwIndexMarkModalDlg::SwIndexMarkModalDlg(Window
*pParent
, SwWrtShell
& rSh
, SwTOXMark
* pCurTOXMark
) :
1151 SvxStandardDialog(pParent
, SvtCJKOptions().IsCJKFontEnabled()?SW_RES(DLG_EDIT_IDXMARK_CJK
):SW_RES(DLG_EDIT_IDXMARK
)),
1152 aDlg(this, sal_False
, SW_RES(WIN_DLG
), SvtCJKOptions().IsCJKFontEnabled()?DLG_EDIT_IDXMARK_CJK
:DLG_EDIT_IDXMARK
, rSh
)
1155 aDlg
.ReInitDlg(rSh
, pCurTOXMark
);
1157 /* -----------------06.10.99 10:46-------------------
1159 --------------------------------------------------*/
1160 void SwIndexMarkModalDlg::Apply()
1164 /* -----------------16.09.99 14:19-------------------
1166 --------------------------------------------------*/
1167 class SwCreateAuthEntryDlg_Impl
: public ModalDialog
1169 FixedLine aEntriesFL
;
1171 FixedText
* pFixedTexts
[AUTH_FIELD_END
];
1172 ListBox
* pTypeListBox
;
1173 ComboBox
* pIdentifierBox
;
1174 Edit
* pEdits
[AUTH_FIELD_END
];
1177 CancelButton aCancelBT
;
1180 Link aShortNameCheckLink
;
1184 sal_Bool m_bNewEntryMode
;
1185 sal_Bool m_bNameAllowed
;
1187 DECL_LINK(IdentifierHdl
, ComboBox
*);
1188 DECL_LINK(ShortNameHdl
, Edit
*);
1189 DECL_LINK(EnableHdl
, ListBox
* pBox
);
1192 SwCreateAuthEntryDlg_Impl(Window
* pParent
,
1193 const String pFields
[],
1197 ~SwCreateAuthEntryDlg_Impl();
1199 String
GetEntryText(ToxAuthorityField eField
) const;
1201 void SetCheckNameHdl(const Link
& rLink
) {aShortNameCheckLink
= rLink
;}
1204 /*-- 15.09.99 08:43:24---------------------------------------------------
1206 -----------------------------------------------------------------------*/
1209 sal_uInt16 nToxField
;
1212 static const TextInfo aTextInfoArr
[] =
1214 {AUTH_FIELD_IDENTIFIER
, HID_AUTH_FIELD_IDENTIFIER
},
1215 {AUTH_FIELD_AUTHORITY_TYPE
, HID_AUTH_FIELD_AUTHORITY_TYPE
},
1216 {AUTH_FIELD_AUTHOR
, HID_AUTH_FIELD_AUTHOR
},
1217 {AUTH_FIELD_TITLE
, HID_AUTH_FIELD_TITLE
},
1218 {AUTH_FIELD_YEAR
, HID_AUTH_FIELD_YEAR
},
1219 {AUTH_FIELD_PUBLISHER
, HID_AUTH_FIELD_PUBLISHER
},
1220 {AUTH_FIELD_ADDRESS
, HID_AUTH_FIELD_ADDRESS
},
1221 {AUTH_FIELD_ISBN
, HID_AUTH_FIELD_ISBN
},
1222 {AUTH_FIELD_CHAPTER
, HID_AUTH_FIELD_CHAPTER
},
1223 {AUTH_FIELD_PAGES
, HID_AUTH_FIELD_PAGES
},
1224 {AUTH_FIELD_EDITOR
, HID_AUTH_FIELD_EDITOR
},
1225 {AUTH_FIELD_EDITION
, HID_AUTH_FIELD_EDITION
},
1226 {AUTH_FIELD_BOOKTITLE
, HID_AUTH_FIELD_BOOKTITLE
},
1227 {AUTH_FIELD_VOLUME
, HID_AUTH_FIELD_VOLUME
},
1228 {AUTH_FIELD_HOWPUBLISHED
, HID_AUTH_FIELD_HOWPUBLISHED
},
1229 {AUTH_FIELD_ORGANIZATIONS
, HID_AUTH_FIELD_ORGANIZATIONS
},
1230 {AUTH_FIELD_INSTITUTION
, HID_AUTH_FIELD_INSTITUTION
},
1231 {AUTH_FIELD_SCHOOL
, HID_AUTH_FIELD_SCHOOL
},
1232 {AUTH_FIELD_REPORT_TYPE
, HID_AUTH_FIELD_REPORT_TYPE
},
1233 {AUTH_FIELD_MONTH
, HID_AUTH_FIELD_MONTH
},
1234 {AUTH_FIELD_JOURNAL
, HID_AUTH_FIELD_JOURNAL
},
1235 {AUTH_FIELD_NUMBER
, HID_AUTH_FIELD_NUMBER
},
1236 {AUTH_FIELD_SERIES
, HID_AUTH_FIELD_SERIES
},
1237 {AUTH_FIELD_ANNOTE
, HID_AUTH_FIELD_ANNOTE
},
1238 {AUTH_FIELD_NOTE
, HID_AUTH_FIELD_NOTE
},
1239 {AUTH_FIELD_URL
, HID_AUTH_FIELD_URL
},
1240 {AUTH_FIELD_CUSTOM1
, HID_AUTH_FIELD_CUSTOM1
},
1241 {AUTH_FIELD_CUSTOM2
, HID_AUTH_FIELD_CUSTOM2
},
1242 {AUTH_FIELD_CUSTOM3
, HID_AUTH_FIELD_CUSTOM3
},
1243 {AUTH_FIELD_CUSTOM4
, HID_AUTH_FIELD_CUSTOM4
},
1244 {AUTH_FIELD_CUSTOM5
, HID_AUTH_FIELD_CUSTOM5
}
1247 sal_Bool
SwAuthMarkDlg::bIsFromComponent
= sal_True
;
1249 SwAuthMarkDlg::SwAuthMarkDlg( Window
*pParent
,
1250 const ResId
& rResId
,
1252 Window(pParent
, rResId
),
1253 aFromComponentRB( this, ResId(RB_FROMCOMPONENT
, *rResId
.GetResMgr() )),
1254 aFromDocContentRB( this, ResId(RB_FROMDOCCONTENT
, *rResId
.GetResMgr() )),
1256 aAuthorFT( this, ResId(FT_AUTHOR
, *rResId
.GetResMgr() )),
1257 aAuthorFI( this, ResId(FI_AUTHOR
, *rResId
.GetResMgr() )),
1258 aTitleFT( this, ResId(FT_TITLE
, *rResId
.GetResMgr() )),
1259 aTitleFI( this, ResId(FI_TITLE
, *rResId
.GetResMgr() )),
1260 aEntryFT( this, ResId(FT_ENTRY
, *rResId
.GetResMgr() )),
1261 aEntryED( this, ResId(ED_ENTRY
, *rResId
.GetResMgr() )),
1262 aEntryLB( this, ResId(LB_ENTRY
, *rResId
.GetResMgr() )),
1264 aEntryFL( this, ResId(FL_ENTRY
, *rResId
.GetResMgr() )),
1266 aOKBT( this, ResId(PB_OK
, *rResId
.GetResMgr() )),
1267 aCancelBT( this, ResId(PB_CANCEL
, *rResId
.GetResMgr() )),
1268 aHelpBT( this, ResId(PB_HELP
, *rResId
.GetResMgr() )),
1269 aCreateEntryPB(this,ResId(PB_CREATEENTRY
, *rResId
.GetResMgr())),
1270 aEditEntryPB(this, ResId(PB_EDITENTRY
, *rResId
.GetResMgr())),
1272 sChangeST( ResId(ST_CHANGE
, *rResId
.GetResMgr())),
1274 bBibAccessInitialized(sal_False
),
1278 SetStyle(GetStyle()|WB_DIALOGCONTROL
);
1281 aFromComponentRB
.SetHelpId(HID_AUTH_MARK_DLG_FROM_COMP_RB
);
1282 aFromDocContentRB
.SetHelpId(HID_AUTH_MARK_DLG_FROM_DOC_RB
);
1283 aEntryED
.SetHelpId(HID_AUTH_MARK_DLG_ID_LISTBOX
);
1284 aEntryLB
.SetHelpId(HID_AUTH_MARK_DLG_ID_LISTBOX
);
1286 aFromComponentRB
.Show(bNewEntry
);
1287 aFromDocContentRB
.Show(bNewEntry
);
1288 aFromComponentRB
.Check(bIsFromComponent
);
1289 aFromDocContentRB
.Check(!bIsFromComponent
);
1291 aOKBT
.SetHelpId(HID_INSERT_AUTH_MRK_OK
);
1292 aCancelBT
.SetHelpId(HID_INSERT_AUTH_MRK_CLOSE
);
1293 aEntryED
.SetHelpId(HID_INSERT_AUTH_MRK_ENTRY
);
1294 aCreateEntryPB
.SetHelpId(HID_INSERT_AUTH_MRK_CREATE_ENTRY
);
1295 aEditEntryPB
.SetHelpId(HID_INSERT_AUTH_MRK_EDIT_ENTRY
);
1297 aOKBT
.SetClickHdl(LINK(this,SwAuthMarkDlg
, InsertHdl
));
1298 aCancelBT
.SetClickHdl(LINK(this,SwAuthMarkDlg
, CloseHdl
));
1299 aCreateEntryPB
.SetClickHdl(LINK(this,SwAuthMarkDlg
, CreateEntryHdl
));
1300 aEditEntryPB
.SetClickHdl(LINK(this,SwAuthMarkDlg
, CreateEntryHdl
));
1301 aFromComponentRB
.SetClickHdl(LINK(this,SwAuthMarkDlg
, ChangeSourceHdl
));
1302 aFromDocContentRB
.SetClickHdl(LINK(this,SwAuthMarkDlg
, ChangeSourceHdl
));
1303 aEntryED
.SetModifyHdl(LINK(this,SwAuthMarkDlg
, EditModifyHdl
));
1305 GetParent()->SetText(String(SW_RES(
1306 bNewEntry
? STR_AUTHMRK_INSERT
: STR_AUTHMRK_EDIT
)));
1307 aEntryED
.Show(!bNewEntry
);
1308 aEntryLB
.Show(bNewEntry
);
1311 aOKBT
.SetText(sChangeST
);
1315 aEntryLB
.SetSelectHdl(LINK(this, SwAuthMarkDlg
, CompEntryHdl
));
1318 /*-- 15.09.99 08:43:25---------------------------------------------------
1320 -----------------------------------------------------------------------*/
1321 SwAuthMarkDlg::~SwAuthMarkDlg()
1324 /*-- 15.09.99 08:43:25---------------------------------------------------
1326 -----------------------------------------------------------------------*/
1327 void SwAuthMarkDlg::ReInitDlg(SwWrtShell
& rWrtShell
)
1332 /* -----------------15.09.99 08:57-------------------
1334 --------------------------------------------------*/
1335 IMPL_LINK( SwAuthMarkDlg
, CloseHdl
, PushButton
*, EMPTYARG
)
1339 sal_uInt16 nSlot
= FN_INSERT_AUTH_ENTRY_DLG
;
1340 SfxViewFrame::Current()->GetDispatcher()->Execute(nSlot
,
1341 SFX_CALLMODE_ASYNCHRON
|SFX_CALLMODE_RECORD
);
1345 ((SwAuthMarkModalDlg
*)GetParent())->EndDialog(RET_CANCEL
);
1349 /* -----------------06.12.99 13:54-------------------
1351 --------------------------------------------------*/
1352 static String
lcl_FindColumnEntry(const beans::PropertyValue
* pFields
, sal_Int32 nLen
, const String
& rColumnTitle
)
1355 OUString uColumnTitle
= rColumnTitle
;
1356 for(sal_uInt16 i
= 0; i
< nLen
; i
++)
1359 if(pFields
[i
].Name
== uColumnTitle
&&
1360 (pFields
[i
].Value
>>= uTmp
))
1362 sRet
= String(uTmp
);
1368 /* -----------------------------07.12.99 15:39--------------------------------
1370 ---------------------------------------------------------------------------*/
1371 IMPL_LINK( SwAuthMarkDlg
, CompEntryHdl
, ListBox
*, pBox
)
1373 String
sEntry(pBox
->GetSelectEntry());
1374 if(bIsFromComponent
)
1376 if(xBibAccess
.is() && sEntry
.Len())
1378 OUString
uEntry(sEntry
);
1379 if(xBibAccess
->hasByName(uEntry
))
1381 uno::Any
aEntry(xBibAccess
->getByName(uEntry
));
1382 uno::Sequence
<beans::PropertyValue
> aFieldProps
;
1383 if(aEntry
>>= aFieldProps
)
1385 const beans::PropertyValue
* pProps
= aFieldProps
.getConstArray();
1386 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
&& i
< aFieldProps
.getLength(); i
++)
1388 m_sFields
[i
] = lcl_FindColumnEntry(
1389 pProps
, aFieldProps
.getLength(), m_sColumnTitles
[i
]);
1399 const SwAuthorityFieldType
* pFType
= (const SwAuthorityFieldType
*)
1400 pSh
->GetFldType(RES_AUTHORITY
, aEmptyStr
);
1401 const SwAuthEntry
* pEntry
= pFType
? pFType
->GetEntryByIdentifier(sEntry
) : 0;
1402 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1403 m_sFields
[i
] = pEntry
?
1404 pEntry
->GetAuthorField((ToxAuthorityField
)i
) : aEmptyStr
;
1407 if(!pBox
->GetSelectEntry().Len())
1409 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1410 m_sFields
[i
] = aEmptyStr
;
1412 aAuthorFI
.SetText(m_sFields
[AUTH_FIELD_AUTHOR
]);
1413 aTitleFI
.SetText(m_sFields
[AUTH_FIELD_TITLE
]);
1417 /* -----------------15.09.99 08:57-------------------
1419 --------------------------------------------------*/
1420 IMPL_LINK( SwAuthMarkDlg
, InsertHdl
, PushButton
*, EMPTYARG
)
1422 //insert or update the SwAuthorityField...
1425 sal_Bool bDifferent
= sal_False
;
1426 DBG_ASSERT(m_sFields
[AUTH_FIELD_IDENTIFIER
].Len() , "No Id is set!");
1427 DBG_ASSERT(m_sFields
[AUTH_FIELD_AUTHORITY_TYPE
].Len() , "No authority type is set!");
1428 //check if the entry already exists with different content
1429 const SwAuthorityFieldType
* pFType
= (const SwAuthorityFieldType
*)
1430 pSh
->GetFldType(RES_AUTHORITY
, aEmptyStr
);
1431 const SwAuthEntry
* pEntry
= pFType
?
1432 pFType
->GetEntryByIdentifier( m_sFields
[AUTH_FIELD_IDENTIFIER
])
1436 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
&& !bDifferent
; i
++)
1437 bDifferent
|= m_sFields
[i
] != pEntry
->GetAuthorField((ToxAuthorityField
)i
);
1440 QueryBox
aQuery(this, SW_RES(DLG_CHANGE_AUTH_ENTRY
));
1441 if(RET_YES
!= aQuery
.Execute())
1448 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1450 sFields
+= m_sFields
[i
];
1451 sFields
+= TOX_STYLE_DELIMITER
;
1457 SwAuthEntry aNewData
;
1458 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1459 aNewData
.SetAuthorField((ToxAuthorityField
)i
, m_sFields
[i
]);
1460 pSh
->ChangeAuthorityData(&aNewData
);
1462 SwInsertFld_Data
aData(TYP_AUTHORITY
, 0, sFields
, aEmptyStr
, 0 );
1463 aMgr
.InsertFld( aData
);
1465 else if(aMgr
.GetCurFld())
1467 aMgr
.UpdateCurFld(0, sFields
, aEmptyStr
);
1474 /* -----------------17.09.99 13:06-------------------
1476 --------------------------------------------------*/
1477 IMPL_LINK(SwAuthMarkDlg
, CreateEntryHdl
, PushButton
*, pButton
)
1479 sal_Bool bCreate
= pButton
== &aCreateEntryPB
;
1480 String sOldId
= m_sCreatedEntry
[0];
1481 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1482 m_sCreatedEntry
[i
] = bCreate
? aEmptyStr
: m_sFields
[i
];
1483 SwCreateAuthEntryDlg_Impl
aDlg(pButton
,
1484 bCreate
? m_sCreatedEntry
: m_sFields
,
1485 *pSh
, bNewEntry
, bCreate
);
1488 aDlg
.SetCheckNameHdl(LINK(this, SwAuthMarkDlg
, IsEntryAllowedHdl
));
1490 if(RET_OK
== aDlg
.Execute())
1492 if(bCreate
&& sOldId
.Len())
1494 aEntryLB
.RemoveEntry(sOldId
);
1496 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1498 m_sFields
[i
] = aDlg
.GetEntryText((ToxAuthorityField
)i
);
1499 m_sCreatedEntry
[i
] = m_sFields
[i
];
1501 if(bNewEntry
&& !aFromDocContentRB
.IsChecked())
1503 aFromDocContentRB
.Check(sal_True
);
1504 ChangeSourceHdl(&aFromDocContentRB
);
1508 DBG_ASSERT(LISTBOX_ENTRY_NOTFOUND
==
1509 aEntryLB
.GetEntryPos(m_sFields
[AUTH_FIELD_IDENTIFIER
]),
1511 aEntryLB
.InsertEntry(m_sFields
[AUTH_FIELD_IDENTIFIER
]);
1512 aEntryLB
.SelectEntry(m_sFields
[AUTH_FIELD_IDENTIFIER
]);
1514 aEntryED
.SetText(m_sFields
[AUTH_FIELD_IDENTIFIER
]);
1515 aAuthorFI
.SetText(m_sFields
[AUTH_FIELD_AUTHOR
]);
1516 aTitleFI
.SetText(m_sFields
[AUTH_FIELD_TITLE
]);
1521 /* -----------------------------20.12.99 14:26--------------------------------
1523 ---------------------------------------------------------------------------*/
1524 IMPL_LINK(SwAuthMarkDlg
, ChangeSourceHdl
, RadioButton
*, pButton
)
1526 sal_Bool bFromComp
= (pButton
== &aFromComponentRB
);
1527 bIsFromComponent
= bFromComp
;
1528 aCreateEntryPB
.Enable(!bIsFromComponent
);
1530 if(bIsFromComponent
)
1532 if(!bBibAccessInitialized
)
1534 uno::Reference
< lang::XMultiServiceFactory
> xMSF
= getProcessServiceFactory();
1535 xBibAccess
= uno::Reference
< container::XNameAccess
> (
1536 xMSF
->createInstance( C2U("com.sun.star.frame.Bibliography") ),
1538 uno::Reference
< beans::XPropertySet
> xPropSet(xBibAccess
, uno::UNO_QUERY
);
1539 OUString
uPropName(C2U("BibliographyDataFieldNames"));
1540 if(xPropSet
.is() && xPropSet
->getPropertySetInfo()->hasPropertyByName(uPropName
))
1542 uno::Any aNames
= xPropSet
->getPropertyValue(uPropName
);
1543 uno::Sequence
<beans::PropertyValue
> aSeq
;
1544 if( aNames
>>= aSeq
)
1546 const beans::PropertyValue
* pArr
= aSeq
.getConstArray();
1547 for(sal_uInt16 i
= 0; i
< aSeq
.getLength(); i
++)
1549 String sTitle
= pArr
[i
].Name
;
1550 sal_Int16 nField
= 0;
1551 pArr
[i
].Value
>>= nField
;
1552 if(nField
>= 0 && nField
< AUTH_FIELD_END
)
1553 m_sColumnTitles
[nField
] = sTitle
;
1557 bBibAccessInitialized
= sal_True
;
1561 uno::Sequence
<OUString
> aIdentifiers
= xBibAccess
->getElementNames();
1562 const OUString
* pNames
= aIdentifiers
.getConstArray();
1563 for(sal_uInt16 i
= 0; i
< aIdentifiers
.getLength(); i
++)
1565 aEntryLB
.InsertEntry(pNames
[i
]);
1571 const SwAuthorityFieldType
* pFType
= (const SwAuthorityFieldType
*)
1572 pSh
->GetFldType(RES_AUTHORITY
, aEmptyStr
);
1576 pFType
->GetAllEntryIdentifiers( aIds
);
1577 for(sal_uInt16 n
= 0; n
< aIds
.Count(); n
++)
1578 aEntryLB
.InsertEntry(*aIds
.GetObject(n
));
1580 if(m_sCreatedEntry
[AUTH_FIELD_IDENTIFIER
].Len())
1581 aEntryLB
.InsertEntry(m_sCreatedEntry
[AUTH_FIELD_IDENTIFIER
]);
1583 aEntryLB
.SelectEntryPos(0);
1584 CompEntryHdl(&aEntryLB
);
1587 /* -----------------15.10.2002 13:16-----------------
1589 * --------------------------------------------------*/
1590 IMPL_LINK(SwAuthMarkDlg
, EditModifyHdl
, Edit
*, pEdit
)
1592 Link aAllowed
= LINK(this, SwAuthMarkDlg
, IsEntryAllowedHdl
);
1593 long nResult
= aAllowed
.Call(pEdit
);
1594 aOKBT
.Enable(nResult
> 0);
1597 String
sEntry(pEdit
->GetText());
1598 m_sFields
[AUTH_FIELD_IDENTIFIER
] = sEntry
;
1599 m_sCreatedEntry
[AUTH_FIELD_IDENTIFIER
] = sEntry
;
1603 /* -----------------------------20.12.99 15:11--------------------------------
1605 ---------------------------------------------------------------------------*/
1606 IMPL_LINK(SwAuthMarkDlg
, IsEntryAllowedHdl
, Edit
*, pEdit
)
1608 String sEntry
= pEdit
->GetText();
1609 sal_Bool bAllowed
= sal_False
;
1612 if(aEntryLB
.GetEntryPos(sEntry
) != LISTBOX_ENTRY_NOTFOUND
)
1614 else if(bIsFromComponent
)
1616 const SwAuthorityFieldType
* pFType
= (const SwAuthorityFieldType
*)
1617 pSh
->GetFldType(RES_AUTHORITY
, aEmptyStr
);
1618 bAllowed
= !pFType
|| !pFType
->GetEntryByIdentifier(sEntry
);
1622 bAllowed
= !xBibAccess
.is() || !xBibAccess
->hasByName(sEntry
);
1627 /* -----------------21.09.99 14:19-------------------
1629 --------------------------------------------------*/
1630 void SwAuthMarkDlg::InitControls()
1632 DBG_ASSERT(pSh
, "Shell nicht da?");
1633 SwField
* pField
= pSh
->GetCurFld();
1634 ASSERT(bNewEntry
|| pField
, "Keine aktuelle Markierung");
1637 ChangeSourceHdl(aFromComponentRB
.IsChecked() ? &aFromComponentRB
: &aFromDocContentRB
);
1638 aCreateEntryPB
.Enable(!aFromComponentRB
.IsChecked());
1639 if(!aFromComponentRB
.IsChecked() && m_sCreatedEntry
[0].Len())
1640 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1641 m_sFields
[i
] = m_sCreatedEntry
[i
];
1643 if(bNewEntry
|| !pField
|| pField
->GetTyp()->Which() != RES_AUTHORITY
)
1646 const SwAuthEntry
* pEntry
= ((SwAuthorityFieldType
*)pField
->GetTyp())->
1647 GetEntryByHandle(((SwAuthorityField
*)pField
)->GetHandle());
1649 DBG_ASSERT(pEntry
, "No authority entry found");
1652 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1653 m_sFields
[i
] = pEntry
->GetAuthorField((ToxAuthorityField
)i
);
1655 aEntryED
.SetText(pEntry
->GetAuthorField(AUTH_FIELD_IDENTIFIER
));
1656 aAuthorFI
.SetText(pEntry
->GetAuthorField(AUTH_FIELD_AUTHOR
));
1657 aTitleFI
.SetText(pEntry
->GetAuthorField(AUTH_FIELD_TITLE
));
1659 /* -----------------------------05.09.2002 09:44------------------------------
1661 ---------------------------------------------------------------------------*/
1662 void SwAuthMarkDlg::Activate()
1664 aOKBT
.Enable(!pSh
->HasReadonlySel());
1667 /* -----------------16.09.99 14:27-------------------
1669 --------------------------------------------------*/
1670 SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(Window
* pParent
,
1671 const String pFields
[],
1675 ModalDialog(pParent
, SW_RES(DLG_CREATE_AUTH_ENTRY
)),
1676 aEntriesFL(this, SW_RES(FL_ENTRIES
)),
1679 aOKBT(this, SW_RES(PB_OK
)),
1680 aCancelBT(this, SW_RES(PB_CANCEL
)),
1681 aHelpBT(this, SW_RES(PB_HELP
)),
1683 m_bNewEntryMode(bNewEntry
),
1684 m_bNameAllowed(sal_True
)
1687 Point
aFLPos(aEntriesFL
.GetPosPixel());
1689 Size
aFLSz(aEntriesFL
.GetSizePixel().Width(), GetSizePixel().Height());
1690 long nControlSpace
= aFLSz
.Width() / 4;
1691 long nControlWidth
= nControlSpace
- 2 * aTL1
.X();
1695 aTR1
.X() += nControlSpace
;
1697 aTL2
.X() += nControlSpace
;
1699 aTR2
.X() += nControlSpace
;
1700 Size
aFixedTextSize(aFLSz
);
1702 aTmpSz
= LogicToPixel(aTmpSz
, MAP_APPFONT
);
1703 aFixedTextSize
.Height() = aTmpSz
.Width();
1704 Size
aEditSize(aFixedTextSize
);
1705 aFixedTextSize
.Width() = nControlWidth
+ aFLPos
.X();
1706 aEditSize
.Height() = aTmpSz
.Height();
1707 aEditSize
.Width() = nControlWidth
;
1709 sal_uInt16 nOffset
= static_cast< sal_uInt16
>(aTmpSz
.Width() * 3 / 2);
1710 sal_Bool bLeft
= sal_True
;
1711 Window
* pRefWindow
= 0;
1712 for(sal_uInt16 nIndex
= 0; nIndex
< AUTH_FIELD_END
; nIndex
++)
1714 const TextInfo aCurInfo
= aTextInfoArr
[nIndex
];
1716 pFixedTexts
[nIndex
] = new FixedText(this);
1718 pFixedTexts
[nIndex
]->SetZOrder( pRefWindow
, WINDOW_ZORDER_BEHIND
);
1720 pFixedTexts
[nIndex
]->SetZOrder( 0, WINDOW_ZORDER_FIRST
);
1722 pRefWindow
= pFixedTexts
[nIndex
];
1724 pFixedTexts
[nIndex
]->SetSizePixel(aFixedTextSize
);
1725 pFixedTexts
[nIndex
]->SetPosPixel(bLeft
? aTL1
: aTL2
);
1726 pFixedTexts
[nIndex
]->SetText(SW_RES(STR_AUTH_FIELD_START
+ aCurInfo
.nToxField
));
1727 pFixedTexts
[nIndex
]->Show();
1729 if( AUTH_FIELD_AUTHORITY_TYPE
== aCurInfo
.nToxField
)
1731 pTypeListBox
= new ListBox(this, WB_DROPDOWN
|WB_BORDER
);
1732 pTypeListBox
->SetZOrder( pRefWindow
, WINDOW_ZORDER_BEHIND
);
1733 pRefWindow
= pTypeListBox
;
1734 for(sal_uInt16 j
= 0; j
< AUTH_TYPE_END
; j
++)
1735 pTypeListBox
->InsertEntry(String(SW_RES(STR_AUTH_TYPE_START
+ j
)));
1736 if(pFields
[aCurInfo
.nToxField
].Len())
1738 sal_uInt16 nIndexPos
= static_cast< sal_uInt16
>(pFields
[aCurInfo
.nToxField
].ToInt32());
1739 pTypeListBox
->SelectEntryPos(nIndexPos
);
1741 Size
aTmp(aEditSize
);
1743 pTypeListBox
->SetSizePixel(aTmp
);
1744 pTypeListBox
->SetPosPixel(bLeft
? aTR1
: aTR2
);
1745 pTypeListBox
->Show();
1746 pTypeListBox
->SetSelectHdl(LINK(this, SwCreateAuthEntryDlg_Impl
, EnableHdl
));
1747 pTypeListBox
->SetHelpId(aCurInfo
.nHelpId
);
1750 else if(AUTH_FIELD_IDENTIFIER
== aCurInfo
.nToxField
&& !m_bNewEntryMode
)
1752 pIdentifierBox
= new ComboBox(this, WB_BORDER
|WB_DROPDOWN
);
1753 pIdentifierBox
->SetZOrder( pRefWindow
, WINDOW_ZORDER_BEHIND
);
1754 pRefWindow
= pIdentifierBox
;
1756 pIdentifierBox
->SetSelectHdl(LINK(this,
1757 SwCreateAuthEntryDlg_Impl
, IdentifierHdl
));
1760 const SwAuthorityFieldType
* pFType
= (const SwAuthorityFieldType
*)
1761 rSh
.GetFldType(RES_AUTHORITY
, aEmptyStr
);
1765 pFType
->GetAllEntryIdentifiers( aIds
);
1766 for(sal_uInt16 n
= 0; n
< aIds
.Count(); n
++)
1767 pIdentifierBox
->InsertEntry(*aIds
.GetObject(n
));
1769 pIdentifierBox
->SetText(pFields
[aCurInfo
.nToxField
]);
1770 Size
aTmp(aEditSize
);
1772 pIdentifierBox
->SetSizePixel(aTmp
);
1773 pIdentifierBox
->SetPosPixel(bLeft
? aTR1
: aTR2
);
1774 pIdentifierBox
->Show();
1775 pIdentifierBox
->SetHelpId(aCurInfo
.nHelpId
);
1779 pEdits
[nIndex
] = new Edit(this, WB_BORDER
);
1780 pEdits
[nIndex
]->SetZOrder( pRefWindow
, WINDOW_ZORDER_BEHIND
);
1781 pRefWindow
= pEdits
[nIndex
];
1782 pEdits
[nIndex
]->SetSizePixel(aEditSize
);
1783 pEdits
[nIndex
]->SetPosPixel(bLeft
? aTR1
: aTR2
);
1784 pEdits
[nIndex
]->SetText(pFields
[aCurInfo
.nToxField
]);
1785 pEdits
[nIndex
]->Show();
1786 pEdits
[nIndex
]->SetHelpId(aCurInfo
.nHelpId
);
1787 if(AUTH_FIELD_IDENTIFIER
== aCurInfo
.nToxField
)
1789 pEdits
[nIndex
]->SetModifyHdl(LINK(this, SwCreateAuthEntryDlg_Impl
, ShortNameHdl
));
1790 m_bNameAllowed
= pFields
[nIndex
].Len() > 0;
1793 pFixedTexts
[nIndex
]->Enable(sal_False
);
1794 pEdits
[nIndex
]->Enable(sal_False
);
1800 aTL1
.Y() += nOffset
;
1801 aTR1
.Y() += nOffset
;
1805 aTL2
.Y() += nOffset
;
1806 aTR2
.Y() += nOffset
;
1810 EnableHdl(pTypeListBox
);
1812 long nHeightDiff
= - aFLSz
.Height();
1813 aFLSz
.Height() = aTL1
.Y();
1814 nHeightDiff
+= aFLSz
.Height();
1815 // aEntriesFL.SetSizePixel(aFLSz);
1816 Size
aDlgSize(GetSizePixel());
1817 aDlgSize
.Height() += nHeightDiff
;
1818 SetSizePixel(aDlgSize
);
1821 /* -----------------16.09.99 14:47-------------------
1823 --------------------------------------------------*/
1824 SwCreateAuthEntryDlg_Impl::~SwCreateAuthEntryDlg_Impl()
1826 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1828 delete pFixedTexts
[i
];
1831 delete pTypeListBox
;
1832 delete pIdentifierBox
;
1834 /* -----------------16.09.99 14:27-------------------
1836 --------------------------------------------------*/
1837 String
SwCreateAuthEntryDlg_Impl::GetEntryText(ToxAuthorityField eField
) const
1840 if( AUTH_FIELD_AUTHORITY_TYPE
== eField
)
1842 DBG_ASSERT(pTypeListBox
, "No ListBox");
1843 sRet
= String::CreateFromInt32(pTypeListBox
->GetSelectEntryPos());
1845 else if( AUTH_FIELD_IDENTIFIER
== eField
&& !m_bNewEntryMode
)
1847 DBG_ASSERT(pIdentifierBox
, "No ComboBox");
1848 sRet
= pIdentifierBox
->GetText();
1852 for(sal_uInt16 nIndex
= 0; nIndex
< AUTH_FIELD_END
; nIndex
++)
1854 const TextInfo aCurInfo
= aTextInfoArr
[nIndex
];
1855 if(aCurInfo
.nToxField
== eField
)
1857 sRet
= pEdits
[nIndex
]->GetText();
1864 /* -----------------21.09.99 13:54-------------------
1866 --------------------------------------------------*/
1867 IMPL_LINK(SwCreateAuthEntryDlg_Impl
, IdentifierHdl
, ComboBox
*, pBox
)
1869 const SwAuthorityFieldType
* pFType
= (const SwAuthorityFieldType
*)
1870 rWrtSh
.GetFldType(RES_AUTHORITY
, aEmptyStr
);
1873 const SwAuthEntry
* pEntry
= pFType
->GetEntryByIdentifier(
1877 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1879 if(AUTH_FIELD_IDENTIFIER
== i
)
1881 if(AUTH_FIELD_AUTHORITY_TYPE
== i
)
1882 pTypeListBox
->SelectEntry(
1883 pEntry
->GetAuthorField((ToxAuthorityField
)i
));
1886 pEntry
->GetAuthorField((ToxAuthorityField
)i
));
1892 /* -----------------------------20.12.99 15:07--------------------------------
1894 ---------------------------------------------------------------------------*/
1896 IMPL_LINK(SwCreateAuthEntryDlg_Impl
, ShortNameHdl
, Edit
*, pEdit
)
1898 if(aShortNameCheckLink
.IsSet())
1900 sal_Bool bEnable
= 0 != aShortNameCheckLink
.Call(pEdit
);
1901 m_bNameAllowed
|= bEnable
;
1902 aOKBT
.Enable(pTypeListBox
->GetSelectEntryCount() && bEnable
);
1906 /* -----------------------------20.12.99 15:54--------------------------------
1908 ---------------------------------------------------------------------------*/
1909 IMPL_LINK(SwCreateAuthEntryDlg_Impl
, EnableHdl
, ListBox
*, pBox
)
1911 aOKBT
.Enable(m_bNameAllowed
&& pBox
->GetSelectEntryCount());
1914 /* -----------------06.10.99 10:00-------------------
1916 --------------------------------------------------*/
1917 SwAuthMarkFloatDlg::SwAuthMarkFloatDlg(SfxBindings
* _pBindings
,
1918 SfxChildWindow
* pChild
,
1920 SfxChildWinInfo
* pInfo
,
1922 SfxModelessDialog(_pBindings
, pChild
, pParent
, SW_RES(DLG_INSAUTHMARK
)),
1923 aDlg(this, SW_RES(WIN_DLG
), bNew
)
1927 SwWrtShell
* pWrtShell
= ::GetActiveWrtShell();
1928 DBG_ASSERT(pWrtShell
, "No shell?");
1929 aDlg
.ReInitDlg(*pWrtShell
);
1931 /* -----------------06.10.99 10:27-------------------
1933 --------------------------------------------------*/
1934 void SwAuthMarkFloatDlg::Activate()
1936 SfxModelessDialog::Activate();
1940 void SwAuthMarkFloatDlg::ReInitDlg(SwWrtShell
& rWrtShell
)
1942 aDlg
.ReInitDlg( rWrtShell
);
1945 /* -----------------06.10.99 10:35-------------------
1947 --------------------------------------------------*/
1948 SwAuthMarkModalDlg::SwAuthMarkModalDlg(Window
*pParent
, SwWrtShell
& rSh
) :
1949 SvxStandardDialog(pParent
, SW_RES(DLG_EDIT_AUTHMARK
)),
1950 aDlg(this, SW_RES(WIN_DLG
), sal_False
)
1953 aDlg
.ReInitDlg(rSh
);
1955 /* -----------------06.10.99 10:46-------------------
1957 --------------------------------------------------*/
1958 void SwAuthMarkModalDlg::Apply()