1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "swuiidxmrk.hxx"
21 #include <hintids.hxx>
23 #include <comphelper/processfactory.hxx>
24 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 #include <com/sun/star/beans/PropertyValue.hpp>
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/frame/Bibliography.hpp>
28 #include <com/sun/star/i18n/TransliterationModules.hpp>
29 #include <com/sun/star/i18n/IndexEntrySupplier.hpp>
30 #include <com/sun/star/util/SearchOptions.hpp>
31 #include <com/sun/star/util/SearchFlags.hpp>
32 #include <svl/stritem.hxx>
33 #include <vcl/layout.hxx>
34 #include <vcl/msgbox.hxx>
35 #include <sfx2/dispatch.hxx>
36 #include <svl/eitem.hxx>
37 #include <unotools/textsearch.hxx>
38 #include <editeng/scripttypeitem.hxx>
39 #include <svl/itemset.hxx>
40 #include <editeng/langitem.hxx>
41 #include "editeng/unolingu.hxx"
42 #include <swtypes.hxx>
44 #include <txttxmrk.hxx>
47 #include <multmrk.hxx>
48 #include <swundo.hxx> // for Undo-Ids
53 #include <swmodule.hxx>
58 #include <svl/cjkoptions.hxx>
60 #include <breakit.hxx>
61 #include <SwRewriter.hxx>
69 static sal_uInt16 nTypePos
= 1; // TOX_INDEX as standard
70 static sal_uInt16 nKey1Pos
= USHRT_MAX
;
72 static sal_uInt16 nKey2Pos
= USHRT_MAX
;
74 using namespace com::sun::star
;
75 using namespace com::sun::star::i18n
;
76 using namespace com::sun::star::lang
;
77 using namespace com::sun::star::util
;
78 using namespace ::comphelper
;
79 using namespace ::com::sun::star
;
81 /*--------------------------------------------------------------------
82 Description: dialog to insert a directory selection
83 --------------------------------------------------------------------*/
84 SwIndexMarkPane::SwIndexMarkPane(Dialog
&rDialog
, sal_Bool bNewDlg
,
85 SwWrtShell
& rWrtShell
)
89 , bSelected(sal_False
)
90 , bPhoneticED0_ChangedByUser(sal_False
)
91 , bPhoneticED1_ChangedByUser(sal_False
)
92 , bPhoneticED2_ChangedByUser(sal_False
)
93 , nLangForPhoneticReading(LANGUAGE_CHINESE_SIMPLIFIED
)
94 , bIsPhoneticReadingEnabled(sal_False
)
95 , xExtendedIndexEntrySupplier(NULL
)
99 rDialog
.get(m_pFrame
, "frame");
100 rDialog
.get(m_pTypeFT
, "typeft");
101 rDialog
.get(m_pTypeDCB
, "typecb");
102 rDialog
.get(m_pNewBT
, "new");
103 m_pNewBT
->SetAccessibleRelationMemberOf(m_pFrame
->get_label_widget());
104 rDialog
.get(m_pEntryED
, "entryed");
105 rDialog
.get(m_pPhoneticFT0
, "phonetic0ft");
106 rDialog
.get(m_pPhoneticED0
, "phonetic0ed");
107 rDialog
.get(m_pKey1FT
, "key1ft");
108 rDialog
.get(m_pKey1DCB
, "key1cb");
109 rDialog
.get(m_pPhoneticFT1
, "phonetic1ft");
110 rDialog
.get(m_pPhoneticED1
, "phonetic1ed");
111 rDialog
.get(m_pKey2FT
, "key2ft");
112 rDialog
.get(m_pKey2DCB
, "key2cb");
113 rDialog
.get(m_pPhoneticFT2
, "phonetic2ft");
114 rDialog
.get(m_pPhoneticED2
, "phonetic2ed");
115 rDialog
.get(m_pLevelFT
, "levelft");
116 rDialog
.get(m_pLevelNF
, "levelnf");
117 rDialog
.get(m_pMainEntryCB
, "mainentrycb");
118 rDialog
.get(m_pApplyToAllCB
, "applytoallcb");
119 rDialog
.get(m_pSearchCaseSensitiveCB
, "searchcasesensitivecb");
120 rDialog
.get(m_pSearchCaseWordOnlyCB
, "searchcasewordonlycb");
121 rDialog
.get(m_pCloseBT
, "close");
122 rDialog
.get(m_pDelBT
, "delete");
123 rDialog
.get(m_pPrevSameBT
, "first");
124 rDialog
.get(m_pNextSameBT
, "last");
125 rDialog
.get(m_pPrevBT
, "previous");
126 rDialog
.get(m_pNextBT
, "next");
128 if (SvtCJKOptions().IsCJKFontEnabled())
130 uno::Reference
< uno::XComponentContext
> xContext
= getProcessComponentContext();
132 xExtendedIndexEntrySupplier
= i18n::IndexEntrySupplier::create(xContext
);
134 m_pPhoneticFT0
->Show();
135 m_pPhoneticED0
->Show();
136 m_pPhoneticFT1
->Show();
137 m_pPhoneticED1
->Show();
138 m_pPhoneticFT2
->Show();
139 m_pPhoneticED2
->Show();
142 rDialog
.SetText( SW_RESSTR( bNewMark
? STR_IDXMRK_INSERT
: STR_IDXMRK_EDIT
));
144 m_pDelBT
->SetClickHdl(LINK(this,SwIndexMarkPane
, DelHdl
));
145 m_pPrevBT
->SetClickHdl(LINK(this,SwIndexMarkPane
, PrevHdl
));
146 m_pPrevSameBT
->SetClickHdl(LINK(this,SwIndexMarkPane
, PrevSameHdl
));
147 m_pNextBT
->SetClickHdl(LINK(this,SwIndexMarkPane
, NextHdl
));
148 m_pNextSameBT
->SetClickHdl(LINK(this,SwIndexMarkPane
, NextSameHdl
));
149 m_pTypeDCB
->SetSelectHdl(LINK(this,SwIndexMarkPane
, ModifyHdl
));
150 m_pKey1DCB
->SetModifyHdl(LINK(this,SwIndexMarkPane
, KeyDCBModifyHdl
));
151 m_pKey2DCB
->SetModifyHdl(LINK(this,SwIndexMarkPane
, KeyDCBModifyHdl
));
152 m_pCloseBT
->SetClickHdl(LINK(this,SwIndexMarkPane
, CloseHdl
));
153 m_pEntryED
->SetModifyHdl(LINK(this,SwIndexMarkPane
, ModifyHdl
));
154 m_pNewBT
->SetClickHdl(LINK(this, SwIndexMarkPane
, NewUserIdxHdl
));
155 m_pApplyToAllCB
->SetClickHdl(LINK(this, SwIndexMarkPane
, SearchTypeHdl
));
156 m_pPhoneticED0
->SetModifyHdl(LINK(this,SwIndexMarkPane
, PhoneticEDModifyHdl
));
157 m_pPhoneticED1
->SetModifyHdl(LINK(this,SwIndexMarkPane
, PhoneticEDModifyHdl
));
158 m_pPhoneticED2
->SetModifyHdl(LINK(this,SwIndexMarkPane
, PhoneticEDModifyHdl
));
163 rDialog
.get(m_pOKBT
, "insert");
168 rDialog
.get(m_pOKBT
, "ok");
171 m_pOKBT
->SetClickHdl(LINK(this, SwIndexMarkPane
, InsertHdl
));
173 m_pEntryED
->GrabFocus();
176 /*--------------------------------------------------------------------
177 Description: Newly initialise controls with the new selection
178 --------------------------------------------------------------------*/
179 void SwIndexMarkPane::InitControls()
181 OSL_ENSURE(pSh
&& pTOXMgr
, "no shell?");
183 const SwTOXType
* pType
= pTOXMgr
->GetTOXType(TOX_CONTENT
, 0);
184 OSL_ENSURE(pType
, "Kein Verzeichnistyp !!");
185 String sTmpTypeSelection
;
186 if(m_pTypeDCB
->GetSelectEntryCount())
187 sTmpTypeSelection
= m_pTypeDCB
->GetSelectEntry();
189 m_pTypeDCB
->InsertEntry(pType
->GetTypeName());
192 pType
= pTOXMgr
->GetTOXType(TOX_INDEX
, 0);
193 OSL_ENSURE(pType
, "Kein Verzeichnistyp !!");
194 m_pTypeDCB
->InsertEntry(pType
->GetTypeName());
197 sal_uInt16 nCount
= pSh
->GetTOXTypeCount(TOX_USER
);
199 for( i
= 0; i
< nCount
; ++i
)
200 m_pTypeDCB
->InsertEntry( pSh
->GetTOXType(TOX_USER
, i
)->GetTypeName() );
202 // read keywords primary
203 std::vector
<String
> aArr
;
204 nCount
= pSh
->GetTOIKeys( TOI_PRIMARY
, aArr
);
205 std::sort(aArr
.begin(), aArr
.end());
206 for (std::vector
<String
>::iterator it
= aArr
.begin(); it
!= aArr
.end(); ++it
)
207 m_pKey1DCB
->InsertEntry( *it
);
209 // read keywords secondary
210 nCount
= pSh
->GetTOIKeys( TOI_SECONDARY
, aArr
);
211 std::sort(aArr
.begin(), aArr
.end());
212 for (std::vector
<String
>::iterator it
= aArr
.begin(); it
!= aArr
.end(); ++it
)
213 m_pKey2DCB
->InsertEntry( *it
);
215 UpdateLanguageDependenciesForPhoneticReading();
218 const SwTOXMark
* pMark
= pTOXMgr
->GetCurTOXMark();
219 if( pMark
&& !bNewMark
)
223 // only if there are more than one
224 // if equal it lands at the same entry
227 const SwTOXMark
* pMoveMark
;
230 pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_PRV
);
231 if( pMoveMark
!= pMark
)
232 pSh
->GotoTOXMark( *pMoveMark
, TOX_NXT
), bShow
= true;
233 m_pPrevBT
->Enable( pMoveMark
!= pMark
);
234 pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_NXT
);
235 if( pMoveMark
!= pMark
)
236 pSh
->GotoTOXMark( *pMoveMark
, TOX_PRV
), bShow
= true;
237 m_pNextBT
->Enable( pMoveMark
!= pMark
);
245 pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_SAME_PRV
);
246 if( pMoveMark
!= pMark
)
247 pSh
->GotoTOXMark( *pMoveMark
, TOX_SAME_NXT
), bShow
= true;
248 m_pPrevSameBT
->Enable( pMoveMark
!= pMark
);
249 pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_SAME_NXT
);
250 if( pMoveMark
!= pMark
)
251 pSh
->GotoTOXMark( *pMoveMark
, TOX_SAME_PRV
), bShow
= true;
252 m_pNextSameBT
->Enable( pMoveMark
!= pMark
);
255 m_pNextSameBT
->Show();
256 m_pPrevSameBT
->Show();
262 m_pTypeDCB
->Enable(sal_False
);
263 m_pTypeFT
->Enable(sal_False
);
268 { // display current selection (first element) ????
269 sal_uInt16 nCnt
= pSh
->GetCrsrCnt();
272 bSelected
= !pSh
->HasSelection();
273 aOrgStr
= pSh
->GetView().GetSelectionTextParam(sal_True
, sal_False
);
274 m_pEntryED
->SetText(aOrgStr
);
276 //to include all equal entries may only be allowed in the body and even there
277 //only when a simple selection exists
278 const sal_uInt16 nFrmType
= pSh
->GetFrmType(0,sal_True
);
279 m_pApplyToAllCB
->Show();
280 m_pSearchCaseSensitiveCB
->Show();
281 m_pSearchCaseWordOnlyCB
->Show();
282 m_pApplyToAllCB
->Enable(0 != aOrgStr
.Len() &&
283 0 == (nFrmType
& ( FRMTYPE_HEADER
| FRMTYPE_FOOTER
| FRMTYPE_FLY_ANY
)));
284 SearchTypeHdl(m_pApplyToAllCB
);
287 // index type is default
288 if( sTmpTypeSelection
.Len() &&
289 LISTBOX_ENTRY_NOTFOUND
!= m_pTypeDCB
->GetEntryPos( sTmpTypeSelection
) )
290 m_pTypeDCB
->SelectEntry(sTmpTypeSelection
);
292 m_pTypeDCB
->SelectEntry(m_pTypeDCB
->GetEntry(nTypePos
));
293 ModifyHdl(m_pTypeDCB
);
297 void SwIndexMarkPane::UpdateLanguageDependenciesForPhoneticReading()
299 //no phonetic reading if no global cjk support
300 if( !xExtendedIndexEntrySupplier
.is() )
302 bIsPhoneticReadingEnabled
= sal_False
;
305 bIsPhoneticReadingEnabled
= sal_True
;
307 //get the current language
308 if(!bNewMark
) //if dialog is opened to iterate existing marks
310 OSL_ENSURE(pTOXMgr
, "need TOXMgr");
313 SwTOXMark
* pMark
= pTOXMgr
->GetCurTOXMark();
314 OSL_ENSURE(pMark
, "need current SwTOXMark");
317 SwTxtTOXMark
* pTxtTOXMark
= pMark
->GetTxtTOXMark();
318 OSL_ENSURE(pTxtTOXMark
, "need current SwTxtTOXMark");
321 const SwTxtNode
* pTxtNode
= pTxtTOXMark
->GetpTxtNd();
322 OSL_ENSURE(pTxtNode
, "need current SwTxtNode");
325 xub_StrLen nTextIndex
= *pTxtTOXMark
->GetStart();
326 nLangForPhoneticReading
= pTxtNode
->GetLang( nTextIndex
);
328 else //if dialog is opened to create a new mark
330 sal_uInt16 nScriptType
= pSh
->GetScriptType();
334 case SCRIPTTYPE_ASIAN
: nWhich
= RES_CHRATR_CJK_LANGUAGE
; break;
335 case SCRIPTTYPE_COMPLEX
:nWhich
= RES_CHRATR_CTL_LANGUAGE
; break;
336 default:nWhich
= RES_CHRATR_LANGUAGE
; break;
338 SfxItemSet
aLangSet(pSh
->GetAttrPool(), nWhich
, nWhich
);
339 pSh
->GetCurAttr(aLangSet
);
340 nLangForPhoneticReading
= ((const SvxLanguageItem
&)aLangSet
.Get(nWhich
)).GetLanguage();
345 String
SwIndexMarkPane::GetDefaultPhoneticReading( const String
& rText
)
347 if( !bIsPhoneticReadingEnabled
)
350 return xExtendedIndexEntrySupplier
->getPhoneticCandidate(rText
, LanguageTag( nLangForPhoneticReading
).getLocale());
353 /* --------------------------------------------------
354 Change the content of m_pEntryED if text is selected
355 --------------------------------------------------*/
356 void SwIndexMarkPane::Activate()
358 // display current selection (first element) ????
361 sal_uInt16 nCnt
= pSh
->GetCrsrCnt();
364 bSelected
= !pSh
->HasSelection();
365 aOrgStr
= pSh
->GetView().GetSelectionTextParam(sal_True
, sal_False
);
366 m_pEntryED
->SetText(aOrgStr
);
368 //to include all equal entries may only be allowed in the body and even there
369 //only when a simple selection exists
370 const sal_uInt16 nFrmType
= pSh
->GetFrmType(0,sal_True
);
371 m_pApplyToAllCB
->Show();
372 m_pSearchCaseSensitiveCB
->Show();
373 m_pSearchCaseWordOnlyCB
->Show();
374 m_pApplyToAllCB
->Enable(0 != aOrgStr
.Len() &&
375 0 == (nFrmType
& ( FRMTYPE_HEADER
| FRMTYPE_FOOTER
| FRMTYPE_FLY_ANY
)));
376 SearchTypeHdl(m_pApplyToAllCB
);
378 ModifyHdl(m_pTypeDCB
);
382 /*--------------------------------------------------------------------
383 Description: evaluate Ok-Button
384 --------------------------------------------------------------------*/
385 void SwIndexMarkPane::Apply()
389 pSh
->ResetSelect(0, sal_False
);
392 /*--------------------------------------------------------------------
393 Description: apply changes
394 --------------------------------------------------------------------*/
395 void SwIndexMarkPane::InsertUpdate()
397 pSh
->StartUndo(bDel
? UNDO_INDEX_ENTRY_DELETE
: UNDO_INDEX_ENTRY_INSERT
);
398 pSh
->StartAllAction();
400 SwRewriter aRewriter
;
406 if ( pTOXMgr
->GetCurTOXMark())
407 aRewriter
.AddRule(UndoArg1
, pTOXMgr
->GetCurTOXMark()->GetText());
409 else if( !pSh
->HasReadonlySel() )
411 if ( pTOXMgr
->GetCurTOXMark())
412 aRewriter
.AddRule(UndoArg1
,
413 pTOXMgr
->GetCurTOXMark()->GetText());
416 pTOXMgr
->DeleteTOXMark();
417 else if( pTOXMgr
->GetCurTOXMark() )
422 pSh
->EndUndo(bDel
? UNDO_INDEX_ENTRY_DELETE
: UNDO_INDEX_ENTRY_INSERT
);
424 if((nTypePos
= m_pTypeDCB
->GetEntryPos(m_pTypeDCB
->GetSelectEntry())) == LISTBOX_ENTRY_NOTFOUND
)
427 nKey1Pos
= m_pKey1DCB
->GetEntryPos(m_pKey1DCB
->GetText());
428 nKey2Pos
= m_pKey2DCB
->GetEntryPos(m_pKey2DCB
->GetText());
431 /*--------------------------------------------------------------------
432 Description: insert mark
433 --------------------------------------------------------------------*/
434 static void lcl_SelectSameStrings(SwWrtShell
& rSh
, sal_Bool bWordOnly
, sal_Bool bCaseSensitive
)
438 SearchOptions
aSearchOpt(
439 SearchAlgorithms_ABSOLUTE
,
440 ( bWordOnly
? SearchFlags::NORM_WORD_ONLY
: 0 ),
441 rSh
.GetSelTxt(), OUString(),
442 GetAppLanguageTag().getLocale(),
446 : TransliterationModules_IGNORE_CASE
) );
451 //todo/mba: assuming that notes should not be searched
452 sal_Bool bSearchInNotes
= sal_False
;
453 rSh
.Find( aSearchOpt
, bSearchInNotes
, DOCPOS_START
, DOCPOS_END
, bCancel
,
454 (FindRanges
)(FND_IN_SELALL
|FND_IN_BODYONLY
), sal_False
);
458 void SwIndexMarkPane::InsertMark()
460 sal_uInt16 nPos
= m_pTypeDCB
->GetEntryPos(m_pTypeDCB
->GetSelectEntry());
461 TOXTypes eType
= nPos
== POS_CONTENT
? TOX_CONTENT
:
462 nPos
== POS_INDEX
? TOX_INDEX
: TOX_USER
;
464 SwTOXMarkDescription
aDesc(eType
);
466 sal_uInt16 nLevel
= (sal_uInt16
)m_pLevelNF
->Denormalize(m_pLevelNF
->GetValue());
469 case POS_CONTENT
: break;
470 case POS_INDEX
: // keyword index mark
473 String
aPrim(m_pKey1DCB
->GetText());
474 String
aSec(m_pKey2DCB
->GetText());
475 aDesc
.SetPrimKey(aPrim
);
476 aDesc
.SetSecKey(aSec
);
477 aDesc
.SetMainEntry(m_pMainEntryCB
->IsChecked());
478 aDesc
.SetPhoneticReadingOfAltStr(m_pPhoneticED0
->GetText());
479 aDesc
.SetPhoneticReadingOfPrimKey(m_pPhoneticED1
->GetText());
480 aDesc
.SetPhoneticReadingOfSecKey(m_pPhoneticED2
->GetText());
483 default: // Userdefined index mark
485 String
aName(m_pTypeDCB
->GetSelectEntry());
486 aDesc
.SetTOUName(aName
);
489 if (OUString(aOrgStr
) != m_pEntryED
->GetText())
490 aDesc
.SetAltStr(m_pEntryED
->GetText());
491 sal_Bool bApplyAll
= m_pApplyToAllCB
->IsChecked();
492 sal_Bool bWordOnly
= m_pSearchCaseWordOnlyCB
->IsChecked();
493 sal_Bool bCaseSensitive
= m_pSearchCaseSensitiveCB
->IsChecked();
495 pSh
->StartAllAction();
496 // all equal strings have to be selected here so that the
497 // entry is apllied to all equal strings
500 lcl_SelectSameStrings(*pSh
, bWordOnly
, bCaseSensitive
);
502 aDesc
.SetLevel(nLevel
);
504 aMgr
.InsertTOXMark(aDesc
);
511 /*--------------------------------------------------------------------
512 Description: update mark
513 --------------------------------------------------------------------*/
514 void SwIndexMarkPane::UpdateMark()
516 String
aAltText(m_pEntryED
->GetText());
517 String
* pAltText
= OUString(aOrgStr
) != m_pEntryED
->GetText() ? &aAltText
: 0;
518 //empty alternative texts are not allowed
519 if(pAltText
&& !pAltText
->Len())
524 sal_uInt16 nPos
= m_pTypeDCB
->GetEntryPos(m_pTypeDCB
->GetSelectEntry());
525 TOXTypes eType
= TOX_USER
;
526 if(POS_CONTENT
== nPos
)
528 else if(POS_INDEX
== nPos
)
531 SwTOXMarkDescription
aDesc(eType
);
532 aDesc
.SetLevel( static_cast< int >(m_pLevelNF
->GetValue()) );
534 aDesc
.SetAltStr(*pAltText
);
536 String
aPrim(m_pKey1DCB
->GetText());
538 aDesc
.SetPrimKey(aPrim
);
539 String
aSec(m_pKey2DCB
->GetText());
541 aDesc
.SetSecKey(aSec
);
543 if(eType
== TOX_INDEX
)
545 aDesc
.SetPhoneticReadingOfAltStr(m_pPhoneticED0
->GetText());
546 aDesc
.SetPhoneticReadingOfPrimKey(m_pPhoneticED1
->GetText());
547 aDesc
.SetPhoneticReadingOfSecKey(m_pPhoneticED2
->GetText());
549 aDesc
.SetMainEntry(m_pMainEntryCB
->IsVisible() && m_pMainEntryCB
->IsChecked());
550 pTOXMgr
->UpdateTOXMark(aDesc
);
553 /*--------------------------------------------------------------------
554 Description: insert new keys
555 --------------------------------------------------------------------*/
556 void SwIndexMarkPane::UpdateKeyBoxes()
558 String
aKey(m_pKey1DCB
->GetText());
559 sal_uInt16 nPos
= m_pKey1DCB
->GetEntryPos(aKey
);
561 if(nPos
== LISTBOX_ENTRY_NOTFOUND
&& aKey
.Len() > 0)
563 m_pKey1DCB
->InsertEntry(aKey
);
566 aKey
= m_pKey2DCB
->GetText();
567 nPos
= m_pKey2DCB
->GetEntryPos(aKey
);
569 if(nPos
== LISTBOX_ENTRY_NOTFOUND
&& aKey
.Len() > 0)
571 m_pKey2DCB
->InsertEntry(aKey
);
575 class SwNewUserIdxDlg
: public ModalDialog
580 SwIndexMarkPane
* m_pDlg
;
582 DECL_LINK( ModifyHdl
, Edit
*);
585 SwNewUserIdxDlg(SwIndexMarkPane
* pPane
)
586 : ModalDialog(&(pPane
->GetDialog()), "NewUserIndexDialog",
587 "modules/swriter/ui/newuserindexdialog.ui")
591 get(m_pNameED
, "entry");
592 m_pNameED
->SetModifyHdl(LINK(this, SwNewUserIdxDlg
, ModifyHdl
));
593 m_pOKPB
->Enable(sal_False
);
594 m_pNameED
->GrabFocus();
597 virtual void Apply();
598 String
GetName(){return m_pNameED
->GetText();}
600 void SwNewUserIdxDlg::Apply()
604 IMPL_LINK( SwNewUserIdxDlg
, ModifyHdl
, Edit
*, pEdit
)
606 m_pOKPB
->Enable(!pEdit
->GetText().isEmpty() && !m_pDlg
->IsTOXType(pEdit
->GetText()));
610 IMPL_LINK_NOARG(SwIndexMarkPane
, NewUserIdxHdl
)
612 SwNewUserIdxDlg
* pDlg
= new SwNewUserIdxDlg(this);
613 if(RET_OK
== pDlg
->Execute())
615 String
sNewName(pDlg
->GetName());
616 m_pTypeDCB
->InsertEntry(sNewName
);
617 m_pTypeDCB
->SelectEntry(sNewName
);
623 IMPL_LINK( SwIndexMarkPane
, SearchTypeHdl
, CheckBox
*, pBox
)
625 sal_Bool bEnable
= pBox
->IsChecked() && pBox
->IsEnabled();
626 m_pSearchCaseWordOnlyCB
->Enable(bEnable
);
627 m_pSearchCaseSensitiveCB
->Enable(bEnable
);
631 IMPL_LINK( SwIndexMarkPane
, InsertHdl
, Button
*, pButton
)
634 //close the dialog if only one entry is available
635 if(!bNewMark
&& !m_pPrevBT
->IsVisible() && !m_pNextBT
->IsVisible())
640 IMPL_LINK_NOARG(SwIndexMarkPane
, CloseHdl
)
644 sal_uInt16 nSlot
= FN_INSERT_IDX_ENTRY_DLG
;
645 SfxViewFrame::Current()->GetDispatcher()->Execute(nSlot
,
646 SFX_CALLMODE_ASYNCHRON
|SFX_CALLMODE_RECORD
);
650 m_rDialog
.EndDialog(RET_CANCEL
);
655 /*--------------------------------------------------------------------
656 Description: select index type only when inserting
657 --------------------------------------------------------------------*/
658 IMPL_LINK( SwIndexMarkPane
, ModifyHdl
, ListBox
*, pBox
)
660 if (m_pTypeDCB
== pBox
)
663 sal_uInt16 nPos
= m_pTypeDCB
->GetEntryPos(m_pTypeDCB
->GetSelectEntry());
664 sal_Bool bLevelEnable
= sal_False
,
665 bKeyEnable
= sal_False
,
666 bSetKey2
= sal_False
,
667 bKey2Enable
= sal_False
,
668 bEntryHasText
= sal_False
,
669 bKey1HasText
= sal_False
,
670 bKey2HasText
= sal_False
;
671 if(nPos
== POS_INDEX
)
673 if(!m_pEntryED
->GetText().isEmpty())
674 bEntryHasText
= sal_True
;
675 m_pPhoneticED0
->SetText(GetDefaultPhoneticReading(m_pEntryED
->GetText()));
677 bKeyEnable
= sal_True
;
678 m_pKey1DCB
->SetText(m_pKey1DCB
->GetEntry(nKey1Pos
));
679 m_pPhoneticED1
->SetText(GetDefaultPhoneticReading(m_pKey1DCB
->GetText()));
680 if(!m_pKey1DCB
->GetText().isEmpty())
682 bKey1HasText
= bSetKey2
= bKey2Enable
= sal_True
;
683 m_pKey2DCB
->SetText(m_pKey2DCB
->GetEntry(nKey2Pos
));
684 m_pPhoneticED2
->SetText(GetDefaultPhoneticReading(m_pKey2DCB
->GetText()));
685 if(!m_pKey2DCB
->GetText().isEmpty())
686 bKey2HasText
= sal_True
;
691 bLevelEnable
= sal_True
;
692 m_pLevelNF
->SetMax(MAXLEVEL
);
693 m_pLevelNF
->SetValue(m_pLevelNF
->Normalize(0));
696 m_pLevelFT
->Show(bLevelEnable
);
697 m_pLevelNF
->Show(bLevelEnable
);
698 m_pMainEntryCB
->Show(nPos
== POS_INDEX
);
700 m_pKey1FT
->Enable(bKeyEnable
);
701 m_pKey1DCB
->Enable(bKeyEnable
);
704 m_pKey2DCB
->Enable(bKey2Enable
);
705 m_pKey2FT
->Enable(bKey2Enable
);
707 m_pPhoneticFT0
->Enable(bKeyEnable
&&bEntryHasText
&&bIsPhoneticReadingEnabled
);
708 m_pPhoneticED0
->Enable(bKeyEnable
&&bEntryHasText
&&bIsPhoneticReadingEnabled
);
709 m_pPhoneticFT1
->Enable(bKeyEnable
&&bKey1HasText
&&bIsPhoneticReadingEnabled
);
710 m_pPhoneticED1
->Enable(bKeyEnable
&&bKey1HasText
&&bIsPhoneticReadingEnabled
);
711 m_pPhoneticFT2
->Enable(bKeyEnable
&&bKey2HasText
&&bIsPhoneticReadingEnabled
);
712 m_pPhoneticED2
->Enable(bKeyEnable
&&bKey2HasText
&&bIsPhoneticReadingEnabled
);
714 else //m_pEntryED !!m_pEntryED is not a ListBox but a Edit
716 bool bHasText
= (!m_pEntryED
->GetText().isEmpty());
719 m_pPhoneticED0
->SetText(aEmptyStr
);
720 bPhoneticED0_ChangedByUser
= sal_False
;
722 else if(!bPhoneticED0_ChangedByUser
)
723 m_pPhoneticED0
->SetText(GetDefaultPhoneticReading(m_pEntryED
->GetText()));
725 m_pPhoneticFT0
->Enable(bHasText
&&bIsPhoneticReadingEnabled
);
726 m_pPhoneticED0
->Enable(bHasText
&&bIsPhoneticReadingEnabled
);
728 m_pOKBT
->Enable(!pSh
->HasReadonlySel() &&
729 (!m_pEntryED
->GetText().isEmpty() || pSh
->GetCrsrCnt(sal_False
)));
733 IMPL_LINK_NOARG_INLINE_START(SwIndexMarkPane
, NextHdl
)
736 pTOXMgr
->NextTOXMark();
740 IMPL_LINK_NOARG_INLINE_END(SwIndexMarkPane
, NextHdl
)
742 IMPL_LINK_NOARG_INLINE_START(SwIndexMarkPane
, NextSameHdl
)
745 pTOXMgr
->NextTOXMark(sal_True
);
749 IMPL_LINK_NOARG_INLINE_END(SwIndexMarkPane
, NextSameHdl
)
751 IMPL_LINK_NOARG_INLINE_START(SwIndexMarkPane
, PrevHdl
)
754 pTOXMgr
->PrevTOXMark();
758 IMPL_LINK_NOARG_INLINE_END(SwIndexMarkPane
, PrevHdl
)
760 IMPL_LINK_NOARG_INLINE_START(SwIndexMarkPane
, PrevSameHdl
)
763 pTOXMgr
->PrevTOXMark(sal_True
);
768 IMPL_LINK_NOARG_INLINE_END(SwIndexMarkPane
, PrevSameHdl
)
770 IMPL_LINK_NOARG(SwIndexMarkPane
, DelHdl
)
776 if(pTOXMgr
->GetCurTOXMark())
780 CloseHdl(m_pCloseBT
);
781 SfxViewFrame::Current()->GetBindings().Invalidate(FN_EDIT_IDX_ENTRY_DLG
);
786 /*--------------------------------------------------------------------
787 Description: renew dialog view
788 --------------------------------------------------------------------*/
789 void SwIndexMarkPane::UpdateDialog()
791 OSL_ENSURE(pSh
&& pTOXMgr
, "no shell?");
792 SwTOXMark
* pMark
= pTOXMgr
->GetCurTOXMark();
793 OSL_ENSURE(pMark
, "no current marker");
797 ViewShell::SetCareWin(&m_rDialog
);
799 aOrgStr
= pMark
->GetText();
800 m_pEntryED
->SetText(aOrgStr
);
803 sal_Bool bLevelEnable
= sal_True
,
804 bKeyEnable
= sal_False
,
805 bKey2Enable
= sal_False
,
806 bEntryHasText
= sal_False
,
807 bKey1HasText
= sal_False
,
808 bKey2HasText
= sal_False
;
810 TOXTypes eCurType
= pMark
->GetTOXType()->GetType();
811 if(TOX_INDEX
== eCurType
)
813 bLevelEnable
= sal_False
;
814 bKeyEnable
= sal_True
;
815 bKey1HasText
= bKey2Enable
= 0 != pMark
->GetPrimaryKey().Len();
816 bKey2HasText
= 0 != pMark
->GetSecondaryKey().Len();
817 bEntryHasText
= 0 != pMark
->GetText().Len();
818 m_pKey1DCB
->SetText( pMark
->GetPrimaryKey() );
819 m_pKey2DCB
->SetText( pMark
->GetSecondaryKey() );
820 m_pPhoneticED0
->SetText( pMark
->GetTextReading() );
821 m_pPhoneticED1
->SetText( pMark
->GetPrimaryKeyReading() );
822 m_pPhoneticED2
->SetText( pMark
->GetSecondaryKeyReading() );
823 m_pMainEntryCB
->Check(pMark
->IsMainEntry());
825 else if(TOX_CONTENT
== eCurType
|| TOX_USER
== eCurType
)
827 m_pLevelNF
->SetValue(m_pLevelNF
->Normalize(pMark
->GetLevel()));
829 m_pKey1FT
->Enable(bKeyEnable
);
830 m_pKey1DCB
->Enable(bKeyEnable
);
831 m_pLevelNF
->SetMax(MAXLEVEL
);
832 m_pLevelFT
->Show(bLevelEnable
);
833 m_pLevelNF
->Show(bLevelEnable
);
834 m_pMainEntryCB
->Show(!bLevelEnable
);
835 m_pKey2FT
->Enable(bKey2Enable
);
836 m_pKey2DCB
->Enable(bKey2Enable
);
838 UpdateLanguageDependenciesForPhoneticReading();
839 m_pPhoneticFT0
->Enable(bKeyEnable
&&bEntryHasText
&&bIsPhoneticReadingEnabled
);
840 m_pPhoneticED0
->Enable(bKeyEnable
&&bEntryHasText
&&bIsPhoneticReadingEnabled
);
841 m_pPhoneticFT1
->Enable(bKeyEnable
&&bKey1HasText
&&bIsPhoneticReadingEnabled
);
842 m_pPhoneticED1
->Enable(bKeyEnable
&&bKey1HasText
&&bIsPhoneticReadingEnabled
);
843 m_pPhoneticFT2
->Enable(bKeyEnable
&&bKey2HasText
&&bIsPhoneticReadingEnabled
);
844 m_pPhoneticED2
->Enable(bKeyEnable
&&bKey2HasText
&&bIsPhoneticReadingEnabled
);
847 m_pTypeDCB
->SelectEntry(pMark
->GetTOXType()->GetTypeName());
849 // set Next - Prev - Buttons
851 if( m_pPrevBT
->IsVisible() )
853 const SwTOXMark
* pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_PRV
);
854 if( pMoveMark
!= pMark
)
855 pSh
->GotoTOXMark( *pMoveMark
, TOX_NXT
);
856 m_pPrevBT
->Enable( pMoveMark
!= pMark
);
857 pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_NXT
);
858 if( pMoveMark
!= pMark
)
859 pSh
->GotoTOXMark( *pMoveMark
, TOX_PRV
);
860 m_pNextBT
->Enable( pMoveMark
!= pMark
);
863 if( m_pPrevSameBT
->IsVisible() )
865 const SwTOXMark
* pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_SAME_PRV
);
866 if( pMoveMark
!= pMark
)
867 pSh
->GotoTOXMark( *pMoveMark
, TOX_SAME_NXT
);
868 m_pPrevSameBT
->Enable( pMoveMark
!= pMark
);
869 pMoveMark
= &pSh
->GotoTOXMark( *pMark
, TOX_SAME_NXT
);
870 if( pMoveMark
!= pMark
)
871 pSh
->GotoTOXMark( *pMoveMark
, TOX_SAME_PRV
);
872 m_pNextSameBT
->Enable( pMoveMark
!= pMark
);
875 sal_Bool bEnable
= !pSh
->HasReadonlySel();
876 m_pOKBT
->Enable( bEnable
);
877 m_pDelBT
->Enable( bEnable
);
878 m_pEntryED
->SetReadOnly( !bEnable
);
879 m_pLevelNF
->SetReadOnly( !bEnable
);
880 m_pKey1DCB
->SetReadOnly( !bEnable
);
881 m_pKey2DCB
->SetReadOnly( !bEnable
);
883 pSh
->SelectTxtAttr( RES_TXTATR_TOXMARK
, pMark
->GetTxtTOXMark() );
884 // we need the point at the start of the attribut
890 /*--------------------------------------------------------------------
891 Remind whether the edit boxes for Phonetic reading are changed manually
892 --------------------------------------------------------------------*/
893 IMPL_LINK( SwIndexMarkPane
, PhoneticEDModifyHdl
, Edit
*, pEdit
)
895 if (m_pPhoneticED0
== pEdit
)
897 bPhoneticED0_ChangedByUser
= !pEdit
->GetText().isEmpty();
899 else if (m_pPhoneticED1
== pEdit
)
901 bPhoneticED1_ChangedByUser
= !pEdit
->GetText().isEmpty();
903 else if (m_pPhoneticED2
== pEdit
)
905 bPhoneticED2_ChangedByUser
= !pEdit
->GetText().isEmpty();
910 /*--------------------------------------------------------------------
911 Description: Enable Disable of the 2nd key
912 --------------------------------------------------------------------*/
913 IMPL_LINK( SwIndexMarkPane
, KeyDCBModifyHdl
, ComboBox
*, pBox
)
915 if (m_pKey1DCB
== pBox
)
917 sal_Bool bEnable
= !pBox
->GetText().isEmpty();
920 m_pKey2DCB
->SetText(aEmptyStr
);
921 m_pPhoneticED1
->SetText(aEmptyStr
);
922 m_pPhoneticED2
->SetText(aEmptyStr
);
923 bPhoneticED1_ChangedByUser
= sal_False
;
924 bPhoneticED2_ChangedByUser
= sal_False
;
928 if(pBox
->IsInDropDown())
930 //reset bPhoneticED1_ChangedByUser if a completely new string is selected
931 bPhoneticED1_ChangedByUser
= sal_False
;
933 if(!bPhoneticED1_ChangedByUser
)
934 m_pPhoneticED1
->SetText(GetDefaultPhoneticReading(pBox
->GetText()));
936 m_pKey2DCB
->Enable(bEnable
);
937 m_pKey2FT
->Enable(bEnable
);
939 else if (m_pKey2DCB
== pBox
)
941 if(pBox
->GetText().isEmpty())
943 m_pPhoneticED2
->SetText(aEmptyStr
);
944 bPhoneticED2_ChangedByUser
= sal_False
;
948 if(pBox
->IsInDropDown())
950 //reset bPhoneticED1_ChangedByUser if a completely new string is selected
951 bPhoneticED2_ChangedByUser
= sal_False
;
953 if(!bPhoneticED2_ChangedByUser
)
954 m_pPhoneticED2
->SetText(GetDefaultPhoneticReading(pBox
->GetText()));
957 bool bKey1HasText
= (!m_pKey1DCB
->GetText().isEmpty());
958 bool bKey2HasText
= (!m_pKey2DCB
->GetText().isEmpty());
960 m_pPhoneticFT1
->Enable(bKey1HasText
&& bIsPhoneticReadingEnabled
);
961 m_pPhoneticED1
->Enable(bKey1HasText
&& bIsPhoneticReadingEnabled
);
962 m_pPhoneticFT2
->Enable(bKey2HasText
&& bIsPhoneticReadingEnabled
);
963 m_pPhoneticED2
->Enable(bKey2HasText
&& bIsPhoneticReadingEnabled
);
968 /*--------------------------------------------------
970 --------------------------------------------------*/
971 SwIndexMarkPane::~SwIndexMarkPane()
974 ViewShell::SetCareWin( 0 );
977 void SwIndexMarkPane::ReInitDlg(SwWrtShell
& rWrtShell
, SwTOXMark
* pCurTOXMark
)
981 pTOXMgr
= new SwTOXMgr(pSh
);
984 for(sal_uInt16 i
= 0; i
< pTOXMgr
->GetTOXMarkCount(); i
++)
985 if(pTOXMgr
->GetTOXMark(i
) == pCurTOXMark
)
987 pTOXMgr
->SetCurTOXMark(i
);
994 SwIndexMarkFloatDlg::SwIndexMarkFloatDlg(SfxBindings
* _pBindings
,
995 SfxChildWindow
* pChild
, Window
*pParent
,
996 SfxChildWinInfo
* pInfo
, sal_Bool bNew
)
997 : SfxModelessDialog(_pBindings
, pChild
, pParent
, "IndexEntryDialog", "modules/swriter/ui/indexentry.ui")
998 , m_aContent(*this, bNew
, *::GetActiveWrtShell())
1000 m_aContent
.ReInitDlg(*::GetActiveWrtShell());
1004 void SwIndexMarkFloatDlg::Activate()
1006 SfxModelessDialog::Activate();
1007 m_aContent
.Activate();
1010 void SwIndexMarkFloatDlg::ReInitDlg(SwWrtShell
& rWrtShell
)
1012 m_aContent
.ReInitDlg( rWrtShell
);
1015 SwIndexMarkModalDlg::SwIndexMarkModalDlg(Window
*pParent
, SwWrtShell
& rSh
, SwTOXMark
* pCurTOXMark
)
1016 : SvxStandardDialog(pParent
, "IndexEntryDialog", "modules/swriter/ui/indexentry.ui")
1017 , m_aContent(*this, sal_False
, rSh
)
1019 m_aContent
.ReInitDlg(rSh
, pCurTOXMark
);
1022 void SwIndexMarkModalDlg::Apply()
1027 class SwCreateAuthEntryDlg_Impl
: public ModalDialog
1029 FixedText
* pFixedTexts
[AUTH_FIELD_END
];
1030 ListBox
* pTypeListBox
;
1031 ComboBox
* pIdentifierBox
;
1032 Edit
* pEdits
[AUTH_FIELD_END
];
1036 Link aShortNameCheckLink
;
1040 sal_Bool m_bNewEntryMode
;
1041 sal_Bool m_bNameAllowed
;
1043 DECL_LINK(IdentifierHdl
, ComboBox
*);
1044 DECL_LINK(ShortNameHdl
, Edit
*);
1045 DECL_LINK(EnableHdl
, ListBox
* pBox
);
1048 SwCreateAuthEntryDlg_Impl(Window
* pParent
,
1049 const String pFields
[],
1053 ~SwCreateAuthEntryDlg_Impl();
1055 String
GetEntryText(ToxAuthorityField eField
) const;
1057 void SetCheckNameHdl(const Link
& rLink
) {aShortNameCheckLink
= rLink
;}
1063 ToxAuthorityField nToxField
;
1064 const char* pHelpId
;
1067 static const TextInfo aTextInfoArr
[] =
1069 {AUTH_FIELD_IDENTIFIER
, HID_AUTH_FIELD_IDENTIFIER
},
1070 {AUTH_FIELD_AUTHORITY_TYPE
, HID_AUTH_FIELD_AUTHORITY_TYPE
},
1071 {AUTH_FIELD_AUTHOR
, HID_AUTH_FIELD_AUTHOR
},
1072 {AUTH_FIELD_TITLE
, HID_AUTH_FIELD_TITLE
},
1073 {AUTH_FIELD_YEAR
, HID_AUTH_FIELD_YEAR
},
1074 {AUTH_FIELD_PUBLISHER
, HID_AUTH_FIELD_PUBLISHER
},
1075 {AUTH_FIELD_ADDRESS
, HID_AUTH_FIELD_ADDRESS
},
1076 {AUTH_FIELD_ISBN
, HID_AUTH_FIELD_ISBN
},
1077 {AUTH_FIELD_CHAPTER
, HID_AUTH_FIELD_CHAPTER
},
1078 {AUTH_FIELD_PAGES
, HID_AUTH_FIELD_PAGES
},
1079 {AUTH_FIELD_EDITOR
, HID_AUTH_FIELD_EDITOR
},
1080 {AUTH_FIELD_EDITION
, HID_AUTH_FIELD_EDITION
},
1081 {AUTH_FIELD_BOOKTITLE
, HID_AUTH_FIELD_BOOKTITLE
},
1082 {AUTH_FIELD_VOLUME
, HID_AUTH_FIELD_VOLUME
},
1083 {AUTH_FIELD_HOWPUBLISHED
, HID_AUTH_FIELD_HOWPUBLISHED
},
1084 {AUTH_FIELD_ORGANIZATIONS
, HID_AUTH_FIELD_ORGANIZATIONS
},
1085 {AUTH_FIELD_INSTITUTION
, HID_AUTH_FIELD_INSTITUTION
},
1086 {AUTH_FIELD_SCHOOL
, HID_AUTH_FIELD_SCHOOL
},
1087 {AUTH_FIELD_REPORT_TYPE
, HID_AUTH_FIELD_REPORT_TYPE
},
1088 {AUTH_FIELD_MONTH
, HID_AUTH_FIELD_MONTH
},
1089 {AUTH_FIELD_JOURNAL
, HID_AUTH_FIELD_JOURNAL
},
1090 {AUTH_FIELD_NUMBER
, HID_AUTH_FIELD_NUMBER
},
1091 {AUTH_FIELD_SERIES
, HID_AUTH_FIELD_SERIES
},
1092 {AUTH_FIELD_ANNOTE
, HID_AUTH_FIELD_ANNOTE
},
1093 {AUTH_FIELD_NOTE
, HID_AUTH_FIELD_NOTE
},
1094 {AUTH_FIELD_URL
, HID_AUTH_FIELD_URL
},
1095 {AUTH_FIELD_CUSTOM1
, HID_AUTH_FIELD_CUSTOM1
},
1096 {AUTH_FIELD_CUSTOM2
, HID_AUTH_FIELD_CUSTOM2
},
1097 {AUTH_FIELD_CUSTOM3
, HID_AUTH_FIELD_CUSTOM3
},
1098 {AUTH_FIELD_CUSTOM4
, HID_AUTH_FIELD_CUSTOM4
},
1099 {AUTH_FIELD_CUSTOM5
, HID_AUTH_FIELD_CUSTOM5
}
1102 sal_Bool
SwAuthorMarkPane::bIsFromComponent
= sal_True
;
1104 SwAuthorMarkPane::SwAuthorMarkPane(Dialog
&rDialog
, sal_Bool bNewDlg
)
1105 : m_rDialog(rDialog
)
1106 , bNewEntry(bNewDlg
)
1107 , bBibAccessInitialized(sal_False
)
1110 m_rDialog
.get(m_pFromComponentRB
, "frombibliography");
1111 m_rDialog
.get(m_pFromDocContentRB
, "fromdocument");
1112 m_rDialog
.get(m_pAuthorFI
, "author");
1113 m_rDialog
.get(m_pTitleFI
, "title");
1114 m_rDialog
.get(m_pEntryED
, "entryed");
1115 m_rDialog
.get(m_pEntryLB
, "entrylb");
1116 m_rDialog
.get(m_pActionBT
,
1117 bNewEntry
? OString("insert") : OString("modify"));
1118 m_pActionBT
->Show(true);
1119 m_rDialog
.get(m_pCloseBT
, "close");
1120 m_rDialog
.get(m_pCreateEntryPB
, "new");
1121 m_rDialog
.get(m_pEditEntryPB
, "edit");
1123 m_pFromComponentRB
->Show(bNewEntry
);
1124 m_pFromDocContentRB
->Show(bNewEntry
);
1125 m_pFromComponentRB
->Check(bIsFromComponent
);
1126 m_pFromDocContentRB
->Check(!bIsFromComponent
);
1128 m_pActionBT
->SetClickHdl(LINK(this,SwAuthorMarkPane
, InsertHdl
));
1129 m_pCloseBT
->SetClickHdl(LINK(this,SwAuthorMarkPane
, CloseHdl
));
1130 m_pCreateEntryPB
->SetClickHdl(LINK(this,SwAuthorMarkPane
, CreateEntryHdl
));
1131 m_pEditEntryPB
->SetClickHdl(LINK(this,SwAuthorMarkPane
, CreateEntryHdl
));
1132 m_pFromComponentRB
->SetClickHdl(LINK(this,SwAuthorMarkPane
, ChangeSourceHdl
));
1133 m_pFromDocContentRB
->SetClickHdl(LINK(this,SwAuthorMarkPane
, ChangeSourceHdl
));
1134 m_pEntryED
->SetModifyHdl(LINK(this,SwAuthorMarkPane
, EditModifyHdl
));
1136 m_rDialog
.SetText(SW_RESSTR(
1137 bNewEntry
? STR_AUTHMRK_INSERT
: STR_AUTHMRK_EDIT
));
1139 m_pEntryED
->Show(!bNewEntry
);
1140 m_pEntryLB
->Show(bNewEntry
);
1143 m_pEntryLB
->SetSelectHdl(LINK(this, SwAuthorMarkPane
, CompEntryHdl
));
1147 void SwAuthorMarkPane::ReInitDlg(SwWrtShell
& rWrtShell
)
1153 IMPL_LINK_NOARG(SwAuthorMarkPane
, CloseHdl
)
1157 sal_uInt16 nSlot
= FN_INSERT_AUTH_ENTRY_DLG
;
1158 SfxViewFrame::Current()->GetDispatcher()->Execute(nSlot
,
1159 SFX_CALLMODE_ASYNCHRON
|SFX_CALLMODE_RECORD
);
1163 m_rDialog
.EndDialog(RET_CANCEL
);
1168 static String
lcl_FindColumnEntry(const beans::PropertyValue
* pFields
, sal_Int32 nLen
, const String
& rColumnTitle
)
1171 OUString uColumnTitle
= rColumnTitle
;
1172 for(sal_uInt16 i
= 0; i
< nLen
; i
++)
1175 if(pFields
[i
].Name
== uColumnTitle
&&
1176 (pFields
[i
].Value
>>= uTmp
))
1178 sRet
= String(uTmp
);
1185 IMPL_LINK( SwAuthorMarkPane
, CompEntryHdl
, ListBox
*, pBox
)
1187 String
sEntry(pBox
->GetSelectEntry());
1188 if(bIsFromComponent
)
1190 if(xBibAccess
.is() && sEntry
.Len())
1192 OUString
uEntry(sEntry
);
1193 if(xBibAccess
->hasByName(uEntry
))
1195 uno::Any
aEntry(xBibAccess
->getByName(uEntry
));
1196 uno::Sequence
<beans::PropertyValue
> aFieldProps
;
1197 if(aEntry
>>= aFieldProps
)
1199 const beans::PropertyValue
* pProps
= aFieldProps
.getConstArray();
1200 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
&& i
< aFieldProps
.getLength(); i
++)
1202 m_sFields
[i
] = lcl_FindColumnEntry(
1203 pProps
, aFieldProps
.getLength(), m_sColumnTitles
[i
]);
1213 const SwAuthorityFieldType
* pFType
= (const SwAuthorityFieldType
*)
1214 pSh
->GetFldType(RES_AUTHORITY
, aEmptyStr
);
1215 const SwAuthEntry
* pEntry
= pFType
? pFType
->GetEntryByIdentifier(sEntry
) : 0;
1216 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1217 m_sFields
[i
] = pEntry
?
1218 pEntry
->GetAuthorField((ToxAuthorityField
)i
) : aEmptyStr
;
1221 if(!pBox
->GetSelectEntry().Len())
1223 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1224 m_sFields
[i
] = aEmptyStr
;
1226 m_pAuthorFI
->SetText(m_sFields
[AUTH_FIELD_AUTHOR
]);
1227 m_pTitleFI
->SetText(m_sFields
[AUTH_FIELD_TITLE
]);
1231 IMPL_LINK_NOARG(SwAuthorMarkPane
, InsertHdl
)
1233 //insert or update the SwAuthorityField...
1236 sal_Bool bDifferent
= sal_False
;
1237 OSL_ENSURE(m_sFields
[AUTH_FIELD_IDENTIFIER
].Len() , "No Id is set!");
1238 OSL_ENSURE(m_sFields
[AUTH_FIELD_AUTHORITY_TYPE
].Len() , "No authority type is set!");
1239 //check if the entry already exists with different content
1240 const SwAuthorityFieldType
* pFType
= (const SwAuthorityFieldType
*)
1241 pSh
->GetFldType(RES_AUTHORITY
, aEmptyStr
);
1242 const SwAuthEntry
* pEntry
= pFType
?
1243 pFType
->GetEntryByIdentifier( m_sFields
[AUTH_FIELD_IDENTIFIER
])
1247 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
&& !bDifferent
; i
++)
1248 bDifferent
|= m_sFields
[i
] != pEntry
->GetAuthorField((ToxAuthorityField
)i
);
1251 QueryBox
aQuery(&m_rDialog
, SW_RES(DLG_CHANGE_AUTH_ENTRY
));
1252 if(RET_YES
!= aQuery
.Execute())
1259 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1261 sFields
+= m_sFields
[i
];
1262 sFields
+= TOX_STYLE_DELIMITER
;
1268 SwAuthEntry aNewData
;
1269 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1270 aNewData
.SetAuthorField((ToxAuthorityField
)i
, m_sFields
[i
]);
1271 pSh
->ChangeAuthorityData(&aNewData
);
1273 SwInsertFld_Data
aData(TYP_AUTHORITY
, 0, sFields
, aEmptyStr
, 0 );
1274 aMgr
.InsertFld( aData
);
1276 else if(aMgr
.GetCurFld())
1278 aMgr
.UpdateCurFld(0, sFields
, aEmptyStr
);
1286 IMPL_LINK(SwAuthorMarkPane
, CreateEntryHdl
, PushButton
*, pButton
)
1288 bool bCreate
= pButton
== m_pCreateEntryPB
;
1289 String sOldId
= m_sCreatedEntry
[0];
1290 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1291 m_sCreatedEntry
[i
] = bCreate
? aEmptyStr
: m_sFields
[i
];
1292 SwCreateAuthEntryDlg_Impl
aDlg(pButton
,
1293 bCreate
? m_sCreatedEntry
: m_sFields
,
1294 *pSh
, bNewEntry
, bCreate
);
1297 aDlg
.SetCheckNameHdl(LINK(this, SwAuthorMarkPane
, IsEntryAllowedHdl
));
1299 if(RET_OK
== aDlg
.Execute())
1301 if(bCreate
&& sOldId
.Len())
1303 m_pEntryLB
->RemoveEntry(sOldId
);
1305 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1307 m_sFields
[i
] = aDlg
.GetEntryText((ToxAuthorityField
)i
);
1308 m_sCreatedEntry
[i
] = m_sFields
[i
];
1310 if(bNewEntry
&& !m_pFromDocContentRB
->IsChecked())
1312 m_pFromDocContentRB
->Check(sal_True
);
1313 ChangeSourceHdl(m_pFromDocContentRB
);
1317 OSL_ENSURE(LISTBOX_ENTRY_NOTFOUND
==
1318 m_pEntryLB
->GetEntryPos(m_sFields
[AUTH_FIELD_IDENTIFIER
]),
1320 m_pEntryLB
->InsertEntry(m_sFields
[AUTH_FIELD_IDENTIFIER
]);
1321 m_pEntryLB
->SelectEntry(m_sFields
[AUTH_FIELD_IDENTIFIER
]);
1323 m_pEntryED
->SetText(m_sFields
[AUTH_FIELD_IDENTIFIER
]);
1324 m_pAuthorFI
->SetText(m_sFields
[AUTH_FIELD_AUTHOR
]);
1325 m_pTitleFI
->SetText(m_sFields
[AUTH_FIELD_TITLE
]);
1326 m_pActionBT
->Enable();
1331 IMPL_LINK(SwAuthorMarkPane
, ChangeSourceHdl
, RadioButton
*, pButton
)
1333 sal_Bool bFromComp
= (pButton
== m_pFromComponentRB
);
1334 bIsFromComponent
= bFromComp
;
1335 m_pCreateEntryPB
->Enable(!bIsFromComponent
);
1336 m_pEntryLB
->Clear();
1337 if(bIsFromComponent
)
1339 if(!bBibAccessInitialized
)
1341 uno::Reference
< uno::XComponentContext
> xContext
= getProcessComponentContext();
1342 xBibAccess
= frame::Bibliography::create( xContext
);
1343 uno::Reference
< beans::XPropertySet
> xPropSet(xBibAccess
, uno::UNO_QUERY
);
1344 OUString
uPropName("BibliographyDataFieldNames");
1345 if(xPropSet
.is() && xPropSet
->getPropertySetInfo()->hasPropertyByName(uPropName
))
1347 uno::Any aNames
= xPropSet
->getPropertyValue(uPropName
);
1348 uno::Sequence
<beans::PropertyValue
> aSeq
;
1349 if( aNames
>>= aSeq
)
1351 const beans::PropertyValue
* pArr
= aSeq
.getConstArray();
1352 for(sal_uInt16 i
= 0; i
< aSeq
.getLength(); i
++)
1354 String sTitle
= pArr
[i
].Name
;
1355 sal_Int16 nField
= 0;
1356 pArr
[i
].Value
>>= nField
;
1357 if(nField
>= 0 && nField
< AUTH_FIELD_END
)
1358 m_sColumnTitles
[nField
] = sTitle
;
1362 bBibAccessInitialized
= sal_True
;
1366 uno::Sequence
<OUString
> aIdentifiers
= xBibAccess
->getElementNames();
1367 const OUString
* pNames
= aIdentifiers
.getConstArray();
1368 for(sal_uInt16 i
= 0; i
< aIdentifiers
.getLength(); i
++)
1370 m_pEntryLB
->InsertEntry(pNames
[i
]);
1376 const SwAuthorityFieldType
* pFType
= (const SwAuthorityFieldType
*)
1377 pSh
->GetFldType(RES_AUTHORITY
, aEmptyStr
);
1380 std::vector
<String
> aIds
;
1381 pFType
->GetAllEntryIdentifiers( aIds
);
1382 for(size_t n
= 0; n
< aIds
.size(); ++n
)
1383 m_pEntryLB
->InsertEntry(aIds
[n
]);
1385 if(m_sCreatedEntry
[AUTH_FIELD_IDENTIFIER
].Len())
1386 m_pEntryLB
->InsertEntry(m_sCreatedEntry
[AUTH_FIELD_IDENTIFIER
]);
1388 m_pEntryLB
->SelectEntryPos(0);
1389 CompEntryHdl(m_pEntryLB
);
1393 IMPL_LINK(SwAuthorMarkPane
, EditModifyHdl
, Edit
*, pEdit
)
1395 Link aAllowed
= LINK(this, SwAuthorMarkPane
, IsEntryAllowedHdl
);
1396 long nResult
= aAllowed
.Call(pEdit
);
1397 m_pActionBT
->Enable(nResult
> 0);
1400 String
sEntry(pEdit
->GetText());
1401 m_sFields
[AUTH_FIELD_IDENTIFIER
] = sEntry
;
1402 m_sCreatedEntry
[AUTH_FIELD_IDENTIFIER
] = sEntry
;
1407 IMPL_LINK(SwAuthorMarkPane
, IsEntryAllowedHdl
, Edit
*, pEdit
)
1409 String sEntry
= pEdit
->GetText();
1410 sal_Bool bAllowed
= sal_False
;
1413 if(m_pEntryLB
->GetEntryPos(sEntry
) != LISTBOX_ENTRY_NOTFOUND
)
1415 else if(bIsFromComponent
)
1417 const SwAuthorityFieldType
* pFType
= (const SwAuthorityFieldType
*)
1418 pSh
->GetFldType(RES_AUTHORITY
, aEmptyStr
);
1419 bAllowed
= !pFType
|| !pFType
->GetEntryByIdentifier(sEntry
);
1423 bAllowed
= !xBibAccess
.is() || !xBibAccess
->hasByName(sEntry
);
1429 void SwAuthorMarkPane::InitControls()
1431 OSL_ENSURE(pSh
, "no shell?");
1432 SwField
* pField
= pSh
->GetCurFld();
1433 OSL_ENSURE(bNewEntry
|| pField
, "no current marker");
1436 ChangeSourceHdl(m_pFromComponentRB
->IsChecked() ? m_pFromComponentRB
: m_pFromDocContentRB
);
1437 m_pCreateEntryPB
->Enable(!m_pFromComponentRB
->IsChecked());
1438 if(!m_pFromComponentRB
->IsChecked() && m_sCreatedEntry
[0].Len())
1439 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1440 m_sFields
[i
] = m_sCreatedEntry
[i
];
1442 if(bNewEntry
|| !pField
|| pField
->GetTyp()->Which() != RES_AUTHORITY
)
1445 const SwAuthEntry
* pEntry
= ((SwAuthorityFieldType
*)pField
->GetTyp())->
1446 GetEntryByHandle(((SwAuthorityField
*)pField
)->GetHandle());
1448 OSL_ENSURE(pEntry
, "No authority entry found");
1451 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1452 m_sFields
[i
] = pEntry
->GetAuthorField((ToxAuthorityField
)i
);
1454 m_pEntryED
->SetText(pEntry
->GetAuthorField(AUTH_FIELD_IDENTIFIER
));
1455 m_pAuthorFI
->SetText(pEntry
->GetAuthorField(AUTH_FIELD_AUTHOR
));
1456 m_pTitleFI
->SetText(pEntry
->GetAuthorField(AUTH_FIELD_TITLE
));
1459 void SwAuthorMarkPane::Activate()
1461 m_pActionBT
->Enable(!pSh
->HasReadonlySel());
1464 SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(Window
* pParent
,
1465 const String pFields
[],
1469 : ModalDialog(pParent
, "CreateAuthorEntryDialog", "modules/swriter/ui/createauthorentry.ui")
1476 m_bNewEntryMode(bNewEntry
),
1477 m_bNameAllowed(sal_True
)
1481 VclGrid
*pLeft
= get
<VclGrid
>("leftgrid");
1482 VclGrid
*pRight
= get
<VclGrid
>("rightgrid");
1485 sal_Int32
nLeftRow(0), nRightRow(0);
1486 for(sal_uInt16 nIndex
= 0; nIndex
< AUTH_FIELD_END
; nIndex
++)
1488 const TextInfo aCurInfo
= aTextInfoArr
[nIndex
];
1490 pFixedTexts
[nIndex
] = new FixedText(bLeft
? pLeft
: pRight
, WB_VCENTER
);
1492 pFixedTexts
[nIndex
]->set_grid_left_attach(0);
1493 pFixedTexts
[nIndex
]->set_grid_top_attach(bLeft
? nLeftRow
: nRightRow
);
1494 pFixedTexts
[nIndex
]->SetText(SW_RES(STR_AUTH_FIELD_START
+ aCurInfo
.nToxField
));
1495 pFixedTexts
[nIndex
]->Show();
1497 if( AUTH_FIELD_AUTHORITY_TYPE
== aCurInfo
.nToxField
)
1499 pTypeListBox
= new ListBox(bLeft
? pLeft
: pRight
, WB_DROPDOWN
|WB_BORDER
|WB_VCENTER
);
1500 for(sal_uInt16 j
= 0; j
< AUTH_TYPE_END
; j
++)
1501 pTypeListBox
->InsertEntry(SW_RESSTR(STR_AUTH_TYPE_START
+ j
));
1502 if(pFields
[aCurInfo
.nToxField
].Len())
1504 sal_uInt16 nIndexPos
= static_cast< sal_uInt16
>(pFields
[aCurInfo
.nToxField
].ToInt32());
1505 pTypeListBox
->SelectEntryPos(nIndexPos
);
1507 pTypeListBox
->set_grid_left_attach(1);
1508 pTypeListBox
->set_grid_top_attach(bLeft
? nLeftRow
: nRightRow
);
1509 pTypeListBox
->set_hexpand(true);
1510 pTypeListBox
->Show();
1511 pTypeListBox
->SetSelectHdl(LINK(this, SwCreateAuthEntryDlg_Impl
, EnableHdl
));
1512 pTypeListBox
->SetHelpId(aCurInfo
.pHelpId
);
1513 pFixedTexts
[nIndex
]->set_mnemonic_widget(pTypeListBox
);
1515 else if(AUTH_FIELD_IDENTIFIER
== aCurInfo
.nToxField
&& !m_bNewEntryMode
)
1517 pIdentifierBox
= new ComboBox(bLeft
? pLeft
: pRight
, WB_BORDER
|WB_DROPDOWN
|WB_VCENTER
);
1519 pIdentifierBox
->SetSelectHdl(LINK(this,
1520 SwCreateAuthEntryDlg_Impl
, IdentifierHdl
));
1523 const SwAuthorityFieldType
* pFType
= (const SwAuthorityFieldType
*)
1524 rSh
.GetFldType(RES_AUTHORITY
, aEmptyStr
);
1527 std::vector
<String
> aIds
;
1528 pFType
->GetAllEntryIdentifiers( aIds
);
1529 for(size_t n
= 0; n
< aIds
.size(); ++n
)
1530 pIdentifierBox
->InsertEntry(aIds
[n
]);
1532 pIdentifierBox
->SetText(pFields
[aCurInfo
.nToxField
]);
1533 pIdentifierBox
->set_grid_left_attach(1);
1534 pIdentifierBox
->set_grid_top_attach(bLeft
? nLeftRow
: nRightRow
);
1535 pIdentifierBox
->set_hexpand(true);
1536 pIdentifierBox
->Show();
1537 pIdentifierBox
->SetHelpId(aCurInfo
.pHelpId
);
1538 pFixedTexts
[nIndex
]->set_mnemonic_widget(pIdentifierBox
);
1542 pEdits
[nIndex
] = new Edit(bLeft
? pLeft
: pRight
, WB_BORDER
|WB_VCENTER
);
1543 pEdits
[nIndex
]->SetWidthInChars(14);
1544 pEdits
[nIndex
]->set_grid_left_attach(1);
1545 pEdits
[nIndex
]->set_grid_top_attach(bLeft
? nLeftRow
: nRightRow
);
1546 pEdits
[nIndex
]->set_hexpand(true);
1547 pEdits
[nIndex
]->SetText(pFields
[aCurInfo
.nToxField
]);
1548 pEdits
[nIndex
]->Show();
1549 pEdits
[nIndex
]->SetHelpId(aCurInfo
.pHelpId
);
1550 if(AUTH_FIELD_IDENTIFIER
== aCurInfo
.nToxField
)
1552 pEdits
[nIndex
]->SetModifyHdl(LINK(this, SwCreateAuthEntryDlg_Impl
, ShortNameHdl
));
1553 m_bNameAllowed
= pFields
[nIndex
].Len() > 0;
1556 pFixedTexts
[nIndex
]->Enable(sal_False
);
1557 pEdits
[nIndex
]->Enable(sal_False
);
1560 pFixedTexts
[nIndex
]->set_mnemonic_widget(pEdits
[nIndex
]);
1568 EnableHdl(pTypeListBox
);
1571 SwCreateAuthEntryDlg_Impl::~SwCreateAuthEntryDlg_Impl()
1573 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1575 delete pFixedTexts
[i
];
1578 delete pTypeListBox
;
1579 delete pIdentifierBox
;
1582 String
SwCreateAuthEntryDlg_Impl::GetEntryText(ToxAuthorityField eField
) const
1585 if( AUTH_FIELD_AUTHORITY_TYPE
== eField
)
1587 OSL_ENSURE(pTypeListBox
, "No ListBox");
1588 sRet
= OUString::number(pTypeListBox
->GetSelectEntryPos());
1590 else if( AUTH_FIELD_IDENTIFIER
== eField
&& !m_bNewEntryMode
)
1592 OSL_ENSURE(pIdentifierBox
, "No ComboBox");
1593 sRet
= pIdentifierBox
->GetText();
1597 for(sal_uInt16 nIndex
= 0; nIndex
< AUTH_FIELD_END
; nIndex
++)
1599 const TextInfo aCurInfo
= aTextInfoArr
[nIndex
];
1600 if(aCurInfo
.nToxField
== eField
)
1602 sRet
= pEdits
[nIndex
]->GetText();
1610 IMPL_LINK(SwCreateAuthEntryDlg_Impl
, IdentifierHdl
, ComboBox
*, pBox
)
1612 const SwAuthorityFieldType
* pFType
= (const SwAuthorityFieldType
*)
1613 rWrtSh
.GetFldType(RES_AUTHORITY
, aEmptyStr
);
1616 const SwAuthEntry
* pEntry
= pFType
->GetEntryByIdentifier(
1620 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; i
++)
1622 const TextInfo aCurInfo
= aTextInfoArr
[i
];
1623 if(AUTH_FIELD_IDENTIFIER
== aCurInfo
.nToxField
)
1625 if(AUTH_FIELD_AUTHORITY_TYPE
== aCurInfo
.nToxField
)
1626 pTypeListBox
->SelectEntry(
1627 pEntry
->GetAuthorField(aCurInfo
.nToxField
));
1630 pEntry
->GetAuthorField(aCurInfo
.nToxField
));
1637 IMPL_LINK(SwCreateAuthEntryDlg_Impl
, ShortNameHdl
, Edit
*, pEdit
)
1639 if(aShortNameCheckLink
.IsSet())
1641 sal_Bool bEnable
= 0 != aShortNameCheckLink
.Call(pEdit
);
1642 m_bNameAllowed
|= bEnable
;
1643 m_pOKBT
->Enable(pTypeListBox
->GetSelectEntryCount() && bEnable
);
1648 IMPL_LINK(SwCreateAuthEntryDlg_Impl
, EnableHdl
, ListBox
*, pBox
)
1650 m_pOKBT
->Enable(m_bNameAllowed
&& pBox
->GetSelectEntryCount());
1654 SwAuthMarkFloatDlg::SwAuthMarkFloatDlg(SfxBindings
* _pBindings
,
1655 SfxChildWindow
* pChild
,
1657 SfxChildWinInfo
* pInfo
,
1659 : SfxModelessDialog(_pBindings
, pChild
, pParent
,
1660 "BibliographyEntryDialog", "modules/swriter/ui/bibliographyentry.ui")
1661 , m_aContent(*this, bNew
)
1664 SwWrtShell
* pWrtShell
= ::GetActiveWrtShell();
1665 OSL_ENSURE(pWrtShell
, "No shell?");
1666 m_aContent
.ReInitDlg(*pWrtShell
);
1669 void SwAuthMarkFloatDlg::Activate()
1671 SfxModelessDialog::Activate();
1672 m_aContent
.Activate();
1675 void SwAuthMarkFloatDlg::ReInitDlg(SwWrtShell
& rWrtShell
)
1677 m_aContent
.ReInitDlg( rWrtShell
);
1680 SwAuthMarkModalDlg::SwAuthMarkModalDlg(Window
*pParent
, SwWrtShell
& rSh
)
1681 : SvxStandardDialog(pParent
, "BibliographyEntryDialog",
1682 "modules/swriter/ui/bibliographyentry.ui")
1683 , m_aContent(*this, sal_False
)
1685 m_aContent
.ReInitDlg(rSh
);
1688 void SwAuthMarkModalDlg::Apply()
1690 m_aContent
.InsertHdl(0);
1693 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */