LibreOffice Module sw (master)  1
swuiidxmrk.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <swuiidxmrk.hxx>
21 #include <hintids.hxx>
22 #include <helpids.h>
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/IndexEntrySupplier.hpp>
29 #include <com/sun/star/util/SearchAlgorithms2.hpp>
30 #include <com/sun/star/util/SearchFlags.hpp>
31 #include <i18nutil/searchopt.hxx>
32 #include <svl/stritem.hxx>
33 #include <vcl/weld.hxx>
34 #include <sfx2/dispatch.hxx>
35 #include <sfx2/viewfrm.hxx>
36 #include <svl/eitem.hxx>
37 #include <unotools/textsearch.hxx>
39 #include <svl/itemset.hxx>
40 #include <editeng/langitem.hxx>
41 #include <editeng/unolingu.hxx>
42 #include <swtypes.hxx>
43 #include <idxmrk.hxx>
44 #include <toxmgr.hxx>
45 #include <txttxmrk.hxx>
46 #include <wrtsh.hxx>
47 #include <view.hxx>
48 #include <multmrk.hxx>
49 #include <swundo.hxx>
50 #include <cmdid.h>
51 #include <app.hrc>
52 #include <swmodule.hxx>
53 #include <fldmgr.hxx>
54 #include <fldbas.hxx>
55 #include <strings.hrc>
56 #include <swcont.hxx>
57 #include <svl/cjkoptions.hxx>
58 #include <ndtxt.hxx>
59 #include <breakit.hxx>
60 #include <SwRewriter.hxx>
61 
62 #include <unomid.h>
63 
64 #define POS_CONTENT 0
65 #define POS_INDEX 1
66 
67 static sal_Int32 nTypePos = 1; // TOX_INDEX as standard
68 static sal_uInt16 nKey1Pos = USHRT_MAX;
69 
70 static sal_uInt16 nKey2Pos = USHRT_MAX;
71 
72 using namespace com::sun::star;
73 using namespace com::sun::star::i18n;
74 using namespace com::sun::star::lang;
75 using namespace com::sun::star::util;
76 using namespace ::comphelper;
77 
78 // dialog to insert a directory selection
79 SwIndexMarkPane::SwIndexMarkPane(const std::shared_ptr<weld::Dialog>& rDialog, weld::Builder& rBuilder, bool bNewDlg,
80  SwWrtShell& rWrtShell)
81  : m_xDialog(rDialog)
82  , m_bDel(false)
83  , m_bNewMark(bNewDlg)
84  , m_bSelected(false)
85  , m_bPhoneticED0_ChangedByUser(false)
86  , m_bPhoneticED1_ChangedByUser(false)
87  , m_bPhoneticED2_ChangedByUser(false)
88  , m_nLangForPhoneticReading(LANGUAGE_CHINESE_SIMPLIFIED)
89  , m_bIsPhoneticReadingEnabled(false)
90  , m_pSh(&rWrtShell)
91  , m_xTypeFT(rBuilder.weld_label("typeft"))
92  , m_xTypeDCB(rBuilder.weld_combo_box("typecb"))
93  , m_xNewBT(rBuilder.weld_button("new"))
94  , m_xEntryED(rBuilder.weld_entry("entryed"))
95  , m_xSyncED(rBuilder.weld_button("sync"))
96  , m_xPhoneticFT0(rBuilder.weld_label("phonetic0ft"))
97  , m_xPhoneticED0(rBuilder.weld_entry("phonetic0ed"))
98  , m_xKey1FT(rBuilder.weld_label("key1ft"))
99  , m_xKey1DCB(rBuilder.weld_combo_box("key1cb"))
100  , m_xPhoneticFT1(rBuilder.weld_label("phonetic1ft"))
101  , m_xPhoneticED1(rBuilder.weld_entry("phonetic1ed"))
102  , m_xKey2FT(rBuilder.weld_label("key2ft"))
103  , m_xKey2DCB(rBuilder.weld_combo_box("key2cb"))
104  , m_xPhoneticFT2(rBuilder.weld_label("phonetic2ft"))
105  , m_xPhoneticED2(rBuilder.weld_entry("phonetic2ed"))
106  , m_xLevelFT(rBuilder.weld_label("levelft"))
107  , m_xLevelNF(rBuilder.weld_spin_button("levelnf"))
108  , m_xMainEntryCB(rBuilder.weld_check_button("mainentrycb"))
109  , m_xApplyToAllCB(rBuilder.weld_check_button("applytoallcb"))
110  , m_xSearchCaseSensitiveCB(rBuilder.weld_check_button("searchcasesensitivecb"))
111  , m_xSearchCaseWordOnlyCB(rBuilder.weld_check_button("searchcasewordonlycb"))
112  , m_xOKBT(bNewDlg ? rBuilder.weld_button("insert") : rBuilder.weld_button("ok"))
113  , m_xCloseBT(rBuilder.weld_button("close"))
114  , m_xDelBT(rBuilder.weld_button("delete"))
115  , m_xPrevSameBT(rBuilder.weld_button("first"))
116  , m_xNextSameBT(rBuilder.weld_button("last"))
117  , m_xPrevBT(rBuilder.weld_button("previous"))
118  , m_xNextBT(rBuilder.weld_button("next"))
119 {
120  m_xSyncED->show();
121 
122  if (SvtCJKOptions().IsCJKFontEnabled())
123  {
124  uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext();
125 
126  m_xExtendedIndexEntrySupplier = i18n::IndexEntrySupplier::create(xContext);
127 
128  m_xPhoneticFT0->show();
129  m_xPhoneticED0->show();
130  m_xPhoneticFT1->show();
131  m_xPhoneticED1->show();
132  m_xPhoneticFT2->show();
133  m_xPhoneticED2->show();
134  }
135 
136  m_xDialog->set_title(SwResId(m_bNewMark ? STR_IDXMRK_INSERT : STR_IDXMRK_EDIT));
137 
138  m_xDelBT->connect_clicked(LINK(this,SwIndexMarkPane, DelHdl));
139  m_xPrevBT->connect_clicked(LINK(this,SwIndexMarkPane, PrevHdl));
140  m_xPrevSameBT->connect_clicked(LINK(this,SwIndexMarkPane, PrevSameHdl));
141  m_xNextBT->connect_clicked(LINK(this,SwIndexMarkPane, NextHdl));
142  m_xNextSameBT->connect_clicked(LINK(this,SwIndexMarkPane, NextSameHdl));
143  m_xTypeDCB->connect_changed(LINK(this,SwIndexMarkPane, ModifyListBoxHdl));
144  m_xKey1DCB->connect_changed(LINK(this,SwIndexMarkPane, KeyDCBModifyHdl));
145  m_xKey2DCB->connect_changed(LINK(this,SwIndexMarkPane, KeyDCBModifyHdl));
146  m_xCloseBT->connect_clicked(LINK(this,SwIndexMarkPane, CloseHdl));
147  m_xEntryED->connect_changed(LINK(this,SwIndexMarkPane, ModifyEditHdl));
148  m_xNewBT->connect_clicked(LINK(this, SwIndexMarkPane, NewUserIdxHdl));
149  m_xApplyToAllCB->connect_toggled(LINK(this, SwIndexMarkPane, SearchTypeHdl));
150  m_xPhoneticED0->connect_changed(LINK(this,SwIndexMarkPane, PhoneticEDModifyHdl));
151  m_xPhoneticED1->connect_changed(LINK(this,SwIndexMarkPane, PhoneticEDModifyHdl));
152  m_xPhoneticED2->connect_changed(LINK(this,SwIndexMarkPane, PhoneticEDModifyHdl));
153  m_xSyncED->connect_clicked(LINK(this, SwIndexMarkPane, SyncSelectionHdl));
154 
155  if (m_bNewMark)
156  m_xDelBT->hide();
157  else
158  m_xNewBT->hide();
159  m_xOKBT->show();
160  m_xOKBT->connect_clicked(LINK(this, SwIndexMarkPane, InsertHdl));
161 
162  m_xEntryED->grab_focus();
163 }
164 
165 // Newly initialise controls with the new selection
167 {
168  assert(m_pSh && m_pTOXMgr && "no shell?");
169  // contents index
170  const SwTOXType* pType = m_pTOXMgr->GetTOXType(TOX_CONTENT);
171  assert(pType && "No directory type !!");
172  OUString sTmpTypeSelection;
173  if (m_xTypeDCB->get_active() != -1)
174  sTmpTypeSelection = m_xTypeDCB->get_active_text();
175  m_xTypeDCB->clear();
176  m_xTypeDCB->append_text(pType->GetTypeName());
177 
178  // keyword index
179  pType = m_pTOXMgr->GetTOXType(TOX_INDEX);
180  assert(pType && "No directory type !!");
181  m_xTypeDCB->append_text(pType->GetTypeName());
182 
183  // user index
184  sal_uInt16 nCount = m_pSh->GetTOXTypeCount(TOX_USER);
185  for (sal_uInt16 i = 0; i < nCount; ++i)
186  m_xTypeDCB->append_text(m_pSh->GetTOXType(TOX_USER, i)->GetTypeName());
187 
188  // read keywords primary
189  {
190  std::vector<OUString> aArr;
191  m_pSh->GetTOIKeys(TOI_PRIMARY, aArr);
192  std::sort(aArr.begin(), aArr.end());
193  auto last = std::unique(aArr.begin(), aArr.end());
194  for (auto it = aArr.begin(); it != last; ++it)
195  m_xKey1DCB->append_text(*it);
196  }
197 
198  // read keywords secondary
199  {
200  std::vector<OUString> aArr;
201  m_pSh->GetTOIKeys( TOI_SECONDARY, aArr );
202  std::sort(aArr.begin(), aArr.end());
203  auto last = std::unique(aArr.begin(), aArr.end());
204  for (auto it = aArr.begin(); it != last; ++it)
205  m_xKey2DCB->append_text(*it);
206  }
207 
209 
210  // current entry
211  const SwTOXMark* pMark = m_pTOXMgr->GetCurTOXMark();
212  if( pMark && !m_bNewMark)
213  {
214  // Controls-Handling
215 
216  // only if there are more than one
217  // if equal it lands at the same entry
218  m_pSh->SttCursorMove();
219 
220  const SwTOXMark* pMoveMark;
221  bool bShow = false;
222 
223  pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_PRV );
224  if( pMoveMark != pMark )
225  {
226  m_pSh->GotoTOXMark( *pMoveMark, TOX_NXT );
227  bShow = true;
228  }
229  m_xPrevBT->set_sensitive(pMoveMark != pMark);
230  pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_NXT );
231  if( pMoveMark != pMark )
232  {
233  m_pSh->GotoTOXMark( *pMoveMark, TOX_PRV );
234  bShow = true;
235  }
236  m_xNextBT->set_sensitive(pMoveMark != pMark);
237  if( bShow )
238  {
239  m_xPrevBT->show();
240  m_xNextBT->show();
241  bShow = false;
242  }
243 
244  pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_SAME_PRV );
245  if( pMoveMark != pMark )
246  {
247  m_pSh->GotoTOXMark( *pMoveMark, TOX_SAME_NXT );
248  bShow = true;
249  }
250  m_xPrevSameBT->set_sensitive(pMoveMark != pMark);
251  pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_SAME_NXT );
252  if( pMoveMark != pMark )
253  {
254  m_pSh->GotoTOXMark( *pMoveMark, TOX_SAME_PRV );
255  bShow = true;
256  }
257  m_xNextSameBT->set_sensitive(pMoveMark != pMark);
258  if( bShow )
259  {
260  m_xNextSameBT->show();
261  m_xPrevSameBT->show();
262  }
263  m_pSh->EndCursorMove();
264 
265  m_xTypeFT->show();
266 
267  m_xTypeDCB->set_sensitive(false);
268  m_xTypeFT->set_sensitive(false);
269 
270  UpdateDialog();
271  }
272  else
273  { // display current selection (first element) ????
274  if (m_pSh->GetCursorCnt() < 2)
275  {
277  m_aOrgStr = m_pSh->GetView().GetSelectionTextParam(true, false);
278  m_xEntryED->set_text(m_aOrgStr);
279 
280  //to include all equal entries may only be allowed in the body and even there
281  //only when a simple selection exists
282  const FrameTypeFlags nFrameType = m_pSh->GetFrameType(nullptr,true);
283  m_xApplyToAllCB->show();
284  m_xSearchCaseSensitiveCB->show();
285  m_xSearchCaseWordOnlyCB->show();
286  m_xApplyToAllCB->set_sensitive(!m_aOrgStr.isEmpty() &&
288  SearchTypeHdl(*m_xApplyToAllCB);
289  }
290 
291  // index type is default
292  if (!sTmpTypeSelection.isEmpty() && m_xTypeDCB->find_text(sTmpTypeSelection) != -1)
293  m_xTypeDCB->set_active_text(sTmpTypeSelection);
294  else
295  m_xTypeDCB->set_active_text(m_xTypeDCB->get_text(nTypePos));
297  }
298 }
299 
301 {
302  //no phonetic reading if no global cjk support
304  {
306  return;
307  }
309 
310  //get the current language
311  if(!m_bNewMark) //if dialog is opened to iterate existing marks
312  {
313  OSL_ENSURE(m_pTOXMgr, "need TOXMgr");
314  if(!m_pTOXMgr)
315  return;
316  SwTOXMark* pMark = m_pTOXMgr->GetCurTOXMark();
317  OSL_ENSURE(pMark, "need current SwTOXMark");
318  if(!pMark)
319  return;
320  SwTextTOXMark* pTextTOXMark = pMark->GetTextTOXMark();
321  OSL_ENSURE(pTextTOXMark, "need current SwTextTOXMark");
322  if(!pTextTOXMark)
323  return;
324  const SwTextNode* pTextNode = pTextTOXMark->GetpTextNd();
325  OSL_ENSURE(pTextNode, "need current SwTextNode");
326  if(!pTextNode)
327  return;
328  sal_Int32 nTextIndex = pTextTOXMark->GetStart();
329  m_nLangForPhoneticReading = pTextNode->GetLang( nTextIndex );
330  }
331  else //if dialog is opened to create a new mark
332  {
333  sal_uInt16 nWhich;
334  switch(m_pSh->GetScriptType())
335  {
336  case SvtScriptType::ASIAN: nWhich = RES_CHRATR_CJK_LANGUAGE; break;
337  case SvtScriptType::COMPLEX:nWhich = RES_CHRATR_CTL_LANGUAGE; break;
338  default:nWhich = RES_CHRATR_LANGUAGE; break;
339  }
340  SfxItemSet aLangSet(m_pSh->GetAttrPool(), {{nWhich, nWhich}});
341  m_pSh->GetCurAttr(aLangSet);
342  m_nLangForPhoneticReading = static_cast<const SvxLanguageItem&>(aLangSet.Get(nWhich)).GetLanguage();
343  }
344 
345 }
346 
347 OUString SwIndexMarkPane::GetDefaultPhoneticReading( const OUString& rText )
348 {
350  return OUString();
351 
353 }
354 
356 {
357  // display current selection (first element) ????
358  if (m_bNewMark)
359  {
360  m_xSyncED->set_sensitive(m_pSh->GetCursorCnt() < 2);
361  }
362 }
363 
364 IMPL_LINK_NOARG(SwIndexMarkPane, SyncSelectionHdl, weld::Button&, void)
365 {
366  m_bSelected = !m_pSh->HasSelection();
367  m_aOrgStr = m_pSh->GetView().GetSelectionTextParam(true, false);
368  m_xEntryED->set_text(m_aOrgStr);
369 
370  //to include all equal entries may only be allowed in the body and even there
371  //only when a simple selection exists
372  const FrameTypeFlags nFrameType = m_pSh->GetFrameType(nullptr,true);
373  m_xApplyToAllCB->show();
374  m_xSearchCaseSensitiveCB->show();
375  m_xSearchCaseWordOnlyCB->show();
376  m_xApplyToAllCB->set_sensitive(!m_aOrgStr.isEmpty() &&
378  SearchTypeHdl(*m_xApplyToAllCB);
379  ModifyHdl(*m_xEntryED);
380 }
381 
382 // evaluate Ok-Button
384 {
385  InsertUpdate();
386  if(m_bSelected)
387  m_pSh->ResetSelect(nullptr, false);
388 }
389 
390 // apply changes
392 {
395  SwRewriter aRewriter;
396 
397  if( m_bNewMark )
398  {
399  InsertMark();
400 
401  if ( m_pTOXMgr->GetCurTOXMark())
402  aRewriter.AddRule(UndoArg1,
403  m_pTOXMgr->GetCurTOXMark()->GetText(m_pSh->GetLayout()));
404  }
405  else if( !m_pSh->HasReadonlySel() )
406  {
407  if ( m_pTOXMgr->GetCurTOXMark())
408  aRewriter.AddRule(UndoArg1,
409  m_pTOXMgr->GetCurTOXMark()->GetText(m_pSh->GetLayout()));
410 
411  if( m_bDel )
412  m_pTOXMgr->DeleteTOXMark();
413  else if( m_pTOXMgr->GetCurTOXMark() )
414  UpdateMark();
415  }
416 
417  m_pSh->EndAllAction();
418  m_pSh->EndUndo(m_bDel ? SwUndoId::INDEX_ENTRY_DELETE : SwUndoId::INDEX_ENTRY_INSERT);
419 
420  if((nTypePos = m_xTypeDCB->find_text(m_xTypeDCB->get_active_text())) == -1)
421  nTypePos = 0;
422 
423  nKey1Pos = m_xKey1DCB->find_text(m_xKey1DCB->get_active_text());
424  nKey2Pos = m_xKey2DCB->find_text(m_xKey2DCB->get_active_text());
425 }
426 
427 // insert mark
428 static void lcl_SelectSameStrings(SwWrtShell& rSh, bool bWordOnly, bool bCaseSensitive)
429 {
430  rSh.Push();
431 
432  i18nutil::SearchOptions2 aSearchOpt(
433  SearchAlgorithms_ABSOLUTE,
434  ( bWordOnly ? SearchFlags::NORM_WORD_ONLY : 0 ),
435  rSh.GetSelText(), OUString(),
437  0, 0, 0,
438  (bCaseSensitive
439  ? TransliterationFlags::NONE
440  : TransliterationFlags::IGNORE_CASE),
441  SearchAlgorithms2::ABSOLUTE,
442  '\\' );
443 
444  rSh.ClearMark();
445  bool bCancel;
446 
447  //todo/mba: assuming that notes should not be searched
448  rSh.Find_Text(aSearchOpt, false/*bSearchInNotes*/, SwDocPositions::Start, SwDocPositions::End, bCancel,
450 }
451 
453 {
454  auto nPos = m_xTypeDCB->find_text(m_xTypeDCB->get_active_text());
457 
458  SwTOXMarkDescription aDesc(eType);
459 
460  const int nLevel = m_xLevelNF->denormalize(m_xLevelNF->get_value());
461  switch( nPos)
462  {
463  case POS_CONTENT : break;
464  case POS_INDEX: // keyword index mark
465  {
466  UpdateKeyBoxes();
467  aDesc.SetPrimKey(m_xKey1DCB->get_active_text());
468  aDesc.SetSecKey(m_xKey2DCB->get_active_text());
469  aDesc.SetMainEntry(m_xMainEntryCB->get_active());
470  aDesc.SetPhoneticReadingOfAltStr(m_xPhoneticED0->get_text());
471  aDesc.SetPhoneticReadingOfPrimKey(m_xPhoneticED1->get_text());
472  aDesc.SetPhoneticReadingOfSecKey(m_xPhoneticED2->get_text());
473  }
474  break;
475  default: // Userdefined index mark
476  {
477  aDesc.SetTOUName(m_xTypeDCB->get_active_text());
478  }
479  }
480  if (m_aOrgStr != m_xEntryED->get_text())
481  aDesc.SetAltStr(m_xEntryED->get_text());
482  bool bApplyAll = m_xApplyToAllCB->get_active();
483  bool bWordOnly = m_xSearchCaseWordOnlyCB->get_active();
484  bool bCaseSensitive = m_xSearchCaseSensitiveCB->get_active();
485 
487  // all equal strings have to be selected here so that the
488  // entry is applied to all equal strings
489  if(bApplyAll)
490  {
491  lcl_SelectSameStrings(*m_pSh, bWordOnly, bCaseSensitive);
492  }
493  aDesc.SetLevel(nLevel);
494  SwTOXMgr aMgr(m_pSh);
495  aMgr.InsertTOXMark(aDesc);
496  if(bApplyAll)
498 
499  m_pSh->EndAllAction();
500 }
501 
502 // update mark
504 {
505  OUString aAltText(m_xEntryED->get_text());
506  OUString* pAltText = m_aOrgStr != m_xEntryED->get_text() ? &aAltText : nullptr;
507  //empty alternative texts are not allowed
508  if(pAltText && pAltText->isEmpty())
509  return;
510 
511  UpdateKeyBoxes();
512 
513  auto nPos = m_xTypeDCB->find_text(m_xTypeDCB->get_active_text());
515  if(POS_CONTENT == nPos)
516  eType = TOX_CONTENT;
517  else if(POS_INDEX == nPos)
518  eType = TOX_INDEX;
519 
520  SwTOXMarkDescription aDesc(eType);
521  aDesc.SetLevel(m_xLevelNF->get_value());
522  if(pAltText)
523  aDesc.SetAltStr(*pAltText);
524 
525  OUString aPrim(m_xKey1DCB->get_active_text());
526  if(!aPrim.isEmpty())
527  aDesc.SetPrimKey(aPrim);
528  OUString aSec(m_xKey2DCB->get_active_text());
529  if(!aSec.isEmpty())
530  aDesc.SetSecKey(aSec);
531 
532  if(eType == TOX_INDEX)
533  {
534  aDesc.SetPhoneticReadingOfAltStr(m_xPhoneticED0->get_text());
535  aDesc.SetPhoneticReadingOfPrimKey(m_xPhoneticED1->get_text());
536  aDesc.SetPhoneticReadingOfSecKey(m_xPhoneticED2->get_text());
537  }
538  aDesc.SetMainEntry(m_xMainEntryCB->get_visible() && m_xMainEntryCB->get_active());
539  m_pTOXMgr->UpdateTOXMark(aDesc);
540 }
541 
542 // insert new keys
544 {
545  OUString aKey(m_xKey1DCB->get_active_text());
546  auto nPos = m_xKey1DCB->find_text(aKey);
547  if(nPos == -1 && !aKey.isEmpty())
548  { // create new key
549  m_xKey1DCB->append_text(aKey);
550  }
551 
552  aKey = m_xKey2DCB->get_active_text();
553  nPos = m_xKey2DCB->find_text(aKey);
554 
555  if(nPos == -1 && !aKey.isEmpty())
556  { // create new key
557  m_xKey2DCB->append_text(aKey);
558  }
559 }
560 
562 {
564 
565  std::unique_ptr<weld::Button> m_xOKPB;
566  std::unique_ptr<weld::Entry> m_xNameED;
567 
568  DECL_LINK(ModifyHdl, weld::Entry&, void);
569 
570 public:
571  explicit SwNewUserIdxDlg(SwIndexMarkPane* pPane, weld::Window* pParent)
572  : GenericDialogController(pParent, "modules/swriter/ui/newuserindexdialog.ui", "NewUserIndexDialog")
573  , m_pDlg(pPane)
574  , m_xOKPB(m_xBuilder->weld_button("ok"))
575  , m_xNameED(m_xBuilder->weld_entry("entry"))
576  {
577  m_xNameED->connect_changed(LINK(this, SwNewUserIdxDlg, ModifyHdl));
578  m_xOKPB->set_sensitive(false);
579  m_xNameED->grab_focus();
580  }
581  OUString GetName() const { return m_xNameED->get_text(); }
582 };
583 
584 IMPL_LINK( SwNewUserIdxDlg, ModifyHdl, weld::Entry&, rEdit, void)
585 {
586  m_xOKPB->set_sensitive(!rEdit.get_text().isEmpty() && !m_pDlg->IsTOXType(rEdit.get_text()));
587 }
588 
590 {
591  SwNewUserIdxDlg aDlg(this, m_xDialog.get());
592  if (aDlg.run() == RET_OK)
593  {
594  OUString sNewName(aDlg.GetName());
595  m_xTypeDCB->append_text(sNewName);
596  m_xTypeDCB->set_active_text(sNewName);
597  }
598 }
599 
600 IMPL_LINK( SwIndexMarkPane, SearchTypeHdl, weld::ToggleButton&, rBox, void)
601 {
602  const bool bEnable = rBox.get_active() && rBox.get_sensitive();
603  m_xSearchCaseWordOnlyCB->set_sensitive(bEnable);
604  m_xSearchCaseSensitiveCB->set_sensitive(bEnable);
605 }
606 
607 IMPL_LINK(SwIndexMarkPane, InsertHdl, weld::Button&, rButton, void)
608 {
609  Apply();
610  //close the dialog if only one entry is available
611  if(!m_bNewMark && !m_xPrevBT->get_visible() && !m_xNextBT->get_visible())
612  CloseHdl(rButton);
613 }
614 
616 {
617  if (m_bNewMark)
618  {
620  SfxCallMode::ASYNCHRON|SfxCallMode::RECORD);
621  }
622  else
623  {
624  m_xDialog->response(RET_CLOSE);
625  }
626 }
627 
628 // select index type only when inserting
629 IMPL_LINK(SwIndexMarkPane, ModifyListBoxHdl, weld::ComboBox&, rBox, void)
630 {
631  ModifyHdl(rBox);
632 }
633 
634 IMPL_LINK(SwIndexMarkPane, ModifyEditHdl, weld::Entry&, rEdit, void)
635 {
636  ModifyHdl(rEdit);
637 }
638 
640 {
641  if (m_xTypeDCB.get() == &rBox)
642  {
643  // set index type
644  auto nPos = m_xTypeDCB->find_text(m_xTypeDCB->get_active_text());
645  bool bLevelEnable = false,
646  bKeyEnable = false,
647  bSetKey2 = false,
648  bKey2Enable = false,
649  bEntryHasText = false,
650  bKey1HasText = false,
651  bKey2HasText = false;
652  if(nPos == POS_INDEX)
653  {
654  if (!m_xEntryED->get_text().isEmpty())
655  bEntryHasText = true;
656  m_xPhoneticED0->set_text(GetDefaultPhoneticReading(m_xEntryED->get_text()));
657 
658  bKeyEnable = true;
659  m_xKey1DCB->set_active_text(m_xKey1DCB->get_text(nKey1Pos));
660  m_xPhoneticED1->set_text(GetDefaultPhoneticReading(m_xKey1DCB->get_active_text()));
661  if (!m_xKey1DCB->get_active_text().isEmpty())
662  {
663  bKey1HasText = bSetKey2 = bKey2Enable = true;
664  m_xKey2DCB->set_active_text(m_xKey2DCB->get_text(nKey2Pos));
665  m_xPhoneticED2->set_text(GetDefaultPhoneticReading(m_xKey2DCB->get_active_text()));
666  if(!m_xKey2DCB->get_active_text().isEmpty())
667  bKey2HasText = true;
668  }
669  }
670  else
671  {
672  bLevelEnable = true;
673  m_xLevelNF->set_max(MAXLEVEL);
674  m_xLevelNF->set_value(m_xLevelNF->normalize(0));
675  bSetKey2 = true;
676  }
677  m_xLevelFT->set_visible(bLevelEnable);
678  m_xLevelNF->set_visible(bLevelEnable);
679  m_xMainEntryCB->set_visible(nPos == POS_INDEX);
680 
681  m_xKey1FT->set_sensitive(bKeyEnable);
682  m_xKey1DCB->set_sensitive(bKeyEnable);
683  if ( bSetKey2 )
684  {
685  m_xKey2DCB->set_sensitive(bKey2Enable);
686  m_xKey2FT->set_sensitive(bKey2Enable);
687  }
688  m_xPhoneticFT0->set_sensitive(bKeyEnable&&bEntryHasText&&m_bIsPhoneticReadingEnabled);
689  m_xPhoneticED0->set_sensitive(bKeyEnable&&bEntryHasText&&m_bIsPhoneticReadingEnabled);
690  m_xPhoneticFT1->set_sensitive(bKeyEnable&&bKey1HasText&&m_bIsPhoneticReadingEnabled);
691  m_xPhoneticED1->set_sensitive(bKeyEnable&&bKey1HasText&&m_bIsPhoneticReadingEnabled);
692  m_xPhoneticFT2->set_sensitive(bKeyEnable&&bKey2HasText&&m_bIsPhoneticReadingEnabled);
693  m_xPhoneticED2->set_sensitive(bKeyEnable&&bKey2HasText&&m_bIsPhoneticReadingEnabled);
694  }
695  else //m_xEntryED !!m_xEntryED is not a ListBox but a Edit
696  {
697  bool bHasText = !m_xEntryED->get_text().isEmpty();
698  if(!bHasText)
699  {
700  m_xPhoneticED0->set_text(OUString());
702  }
704  m_xPhoneticED0->set_text(GetDefaultPhoneticReading(m_xEntryED->get_text()));
705 
706  m_xPhoneticFT0->set_sensitive(bHasText&&m_bIsPhoneticReadingEnabled);
707  m_xPhoneticED0->set_sensitive(bHasText&&m_bIsPhoneticReadingEnabled);
708  }
709  m_xOKBT->set_sensitive(!m_pSh->HasReadonlySel() &&
710  (!m_xEntryED->get_text().isEmpty() || m_pSh->GetCursorCnt(false)));
711 }
712 
714 {
715  InsertUpdate();
716  m_pTOXMgr->NextTOXMark();
717  UpdateDialog();
718 }
719 
721 {
722  InsertUpdate();
723  m_pTOXMgr->NextTOXMark(true);
724  UpdateDialog();
725 }
726 
728 {
729  InsertUpdate();
730  m_pTOXMgr->PrevTOXMark();
731  UpdateDialog();
732 }
733 
735 {
736  InsertUpdate();
737  m_pTOXMgr->PrevTOXMark(true);
738  UpdateDialog();
739 }
740 
742 {
743  m_bDel = true;
744  InsertUpdate();
745  m_bDel = false;
746 
747  if(m_pTOXMgr->GetCurTOXMark())
748  UpdateDialog();
749  else
750  {
751  CloseHdl(*m_xCloseBT);
753  }
754 }
755 
756 // renew dialog view
758 {
759  OSL_ENSURE(m_pSh && m_pTOXMgr, "no shell?");
760  SwTOXMark* pMark = m_pTOXMgr->GetCurTOXMark();
761  OSL_ENSURE(pMark, "no current marker");
762  if(!pMark)
763  return;
764 
766 
767  m_aOrgStr = pMark->GetText(m_pSh->GetLayout());
768  m_xEntryED->set_text(m_aOrgStr);
769 
770  // set index type
771  bool bLevelEnable = true,
772  bKeyEnable = false,
773  bKey2Enable = false,
774  bEntryHasText = false,
775  bKey1HasText = false,
776  bKey2HasText = false;
777 
778  TOXTypes eCurType = pMark->GetTOXType()->GetType();
779  if(TOX_INDEX == eCurType)
780  {
781  bLevelEnable = false;
782  bKeyEnable = true;
783  bKey1HasText = bKey2Enable = !pMark->GetPrimaryKey().isEmpty();
784  bKey2HasText = !pMark->GetSecondaryKey().isEmpty();
785  bEntryHasText = !pMark->GetText(m_pSh->GetLayout()).isEmpty();
786  m_xKey1DCB->set_entry_text( pMark->GetPrimaryKey() );
787  m_xKey2DCB->set_entry_text( pMark->GetSecondaryKey() );
788  m_xPhoneticED0->set_text( pMark->GetTextReading() );
789  m_xPhoneticED1->set_text( pMark->GetPrimaryKeyReading() );
790  m_xPhoneticED2->set_text( pMark->GetSecondaryKeyReading() );
791  m_xMainEntryCB->set_active(pMark->IsMainEntry());
792  }
793  else if(TOX_CONTENT == eCurType || TOX_USER == eCurType)
794  {
795  m_xLevelNF->set_value(m_xLevelNF->normalize(pMark->GetLevel()));
796  }
797  m_xKey1FT->set_sensitive(bKeyEnable);
798  m_xKey1DCB->set_sensitive(bKeyEnable);
799  m_xLevelNF->set_max(MAXLEVEL);
800  m_xLevelFT->set_visible(bLevelEnable);
801  m_xLevelNF->set_visible(bLevelEnable);
802  m_xMainEntryCB->set_visible(!bLevelEnable);
803  m_xKey2FT->set_sensitive(bKey2Enable);
804  m_xKey2DCB->set_sensitive(bKey2Enable);
805 
807  m_xPhoneticFT0->set_sensitive(bKeyEnable&&bEntryHasText&&m_bIsPhoneticReadingEnabled);
808  m_xPhoneticED0->set_sensitive(bKeyEnable&&bEntryHasText&&m_bIsPhoneticReadingEnabled);
809  m_xPhoneticFT1->set_sensitive(bKeyEnable&&bKey1HasText&&m_bIsPhoneticReadingEnabled);
810  m_xPhoneticED1->set_sensitive(bKeyEnable&&bKey1HasText&&m_bIsPhoneticReadingEnabled);
811  m_xPhoneticFT2->set_sensitive(bKeyEnable&&bKey2HasText&&m_bIsPhoneticReadingEnabled);
812  m_xPhoneticED2->set_sensitive(bKeyEnable&&bKey2HasText&&m_bIsPhoneticReadingEnabled);
813 
814  // set index type
815  m_xTypeDCB->set_active_text(pMark->GetTOXType()->GetTypeName());
816 
817  // set Next - Prev - Buttons
818  m_pSh->SttCursorMove();
819  if( m_xPrevBT->get_visible() )
820  {
821  const SwTOXMark* pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_PRV );
822  if( pMoveMark != pMark )
823  m_pSh->GotoTOXMark( *pMoveMark, TOX_NXT );
824  m_xPrevBT->set_sensitive( pMoveMark != pMark );
825  pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_NXT );
826  if( pMoveMark != pMark )
827  m_pSh->GotoTOXMark( *pMoveMark, TOX_PRV );
828  m_xNextBT->set_sensitive( pMoveMark != pMark );
829  }
830 
831  if (m_xPrevSameBT->get_visible())
832  {
833  const SwTOXMark* pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_SAME_PRV );
834  if( pMoveMark != pMark )
835  m_pSh->GotoTOXMark( *pMoveMark, TOX_SAME_NXT );
836  m_xPrevSameBT->set_sensitive( pMoveMark != pMark );
837  pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_SAME_NXT );
838  if( pMoveMark != pMark )
839  m_pSh->GotoTOXMark( *pMoveMark, TOX_SAME_PRV );
840  m_xNextSameBT->set_sensitive( pMoveMark != pMark );
841  }
842 
843  const bool bEnable = !m_pSh->HasReadonlySel();
844  m_xOKBT->set_sensitive(bEnable);
845  m_xDelBT->set_sensitive(bEnable);
846  m_xEntryED->set_sensitive(bEnable);
847  m_xLevelNF->set_sensitive(bEnable);
848  m_xKey1DCB->set_sensitive(bEnable);
849  m_xKey2DCB->set_sensitive(bEnable);
850 
852  // we need the point at the start of the attribute
853  m_pSh->SwapPam();
854 
855  m_pSh->EndCursorMove();
856 }
857 
858 // Remind whether the edit boxes for Phonetic reading are changed manually
859 IMPL_LINK(SwIndexMarkPane, PhoneticEDModifyHdl, weld::Entry&, rEdit, void)
860 {
861  if (m_xPhoneticED0.get() == &rEdit)
862  {
863  m_bPhoneticED0_ChangedByUser = !rEdit.get_text().isEmpty();
864  }
865  else if (m_xPhoneticED1.get() == &rEdit)
866  {
867  m_bPhoneticED1_ChangedByUser = !rEdit.get_text().isEmpty();
868  }
869  else if (m_xPhoneticED2.get() == &rEdit)
870  {
871  m_bPhoneticED2_ChangedByUser = !rEdit.get_text().isEmpty();
872  }
873 }
874 
875 // Enable Disable of the 2nd key
876 IMPL_LINK( SwIndexMarkPane, KeyDCBModifyHdl, weld::ComboBox&, rBox, void )
877 {
878  if (m_xKey1DCB.get() == &rBox)
879  {
880  bool bEnable = !rBox.get_active_text().isEmpty();
881  if(!bEnable)
882  {
883  m_xKey2DCB->set_entry_text(OUString());
884  m_xPhoneticED1->set_text(OUString());
885  m_xPhoneticED2->set_text(OUString());
886  m_bPhoneticED1_ChangedByUser = false;
887  m_bPhoneticED2_ChangedByUser = false;
888  }
889  else
890  {
891  if (rBox.get_popup_shown())
892  {
893  //reset bPhoneticED1_ChangedByUser if a completely new string is selected
894  m_bPhoneticED1_ChangedByUser = false;
895  }
896  if (!m_bPhoneticED1_ChangedByUser)
897  m_xPhoneticED1->set_text(GetDefaultPhoneticReading(rBox.get_active_text()));
898  }
899  m_xKey2DCB->set_sensitive(bEnable);
900  m_xKey2FT->set_sensitive(bEnable);
901  }
902  else if (m_xKey2DCB.get() == &rBox)
903  {
904  if (rBox.get_active_text().isEmpty())
905  {
906  m_xPhoneticED2->set_text(OUString());
907  m_bPhoneticED2_ChangedByUser = false;
908  }
909  else
910  {
911  if (rBox.get_popup_shown())
912  {
913  //reset bPhoneticED1_ChangedByUser if a completely new string is selected
914  m_bPhoneticED2_ChangedByUser = false;
915  }
916  if(!m_bPhoneticED2_ChangedByUser)
917  m_xPhoneticED2->set_text(GetDefaultPhoneticReading(rBox.get_active_text()));
918  }
919  }
920 
921  bool bKey1HasText = !m_xKey1DCB->get_active_text().isEmpty();
922  bool bKey2HasText = !m_xKey2DCB->get_active_text().isEmpty();
923 
924  m_xPhoneticFT1->set_sensitive(bKey1HasText && m_bIsPhoneticReadingEnabled);
925  m_xPhoneticED1->set_sensitive(bKey1HasText && m_bIsPhoneticReadingEnabled);
926  m_xPhoneticFT2->set_sensitive(bKey2HasText && m_bIsPhoneticReadingEnabled);
927  m_xPhoneticED2->set_sensitive(bKey2HasText && m_bIsPhoneticReadingEnabled);
928 }
929 
931 {
932 }
933 
934 void SwIndexMarkPane::ReInitDlg(SwWrtShell& rWrtShell, SwTOXMark const * pCurTOXMark)
935 {
936  m_pSh = &rWrtShell;
937  m_pTOXMgr.reset( new SwTOXMgr(m_pSh) );
938  if(pCurTOXMark)
939  {
940  for(sal_uInt16 i = 0; i < m_pTOXMgr->GetTOXMarkCount(); i++)
941  if(m_pTOXMgr->GetTOXMark(i) == pCurTOXMark)
942  {
943  m_pTOXMgr->SetCurTOXMark(i);
944  break;
945  }
946  }
947  InitControls();
948 }
949 
951  SfxChildWindow* pChild, weld::Window *pParent,
952  SfxChildWinInfo const * pInfo, bool bNew)
953  : SfxModelessDialogController(_pBindings, pChild, pParent,
954  "modules/swriter/ui/indexentry.ui", "IndexEntryDialog")
955  , m_aContent(m_xDialog, *m_xBuilder, bNew, *::GetActiveWrtShell())
956 {
958  Initialize(pInfo);
959 }
960 
962 {
965 }
966 
968 {
969  m_aContent.ReInitDlg( rWrtShell );
970 }
971 
973  : SfxDialogController(pParent, "modules/swriter/ui/indexentry.ui",
974  "IndexEntryDialog")
975  , m_aContent(m_xDialog, *m_xBuilder, false, rSh)
976 {
977  m_aContent.ReInitDlg(rSh, pCurTOXMark);
978 }
979 
981 {
983 }
984 
986 {
987  short nRet = SfxDialogController::run();
988  if (RET_OK == nRet)
989  m_aContent.Apply();
990  return nRet;
991 }
992 
994 {
995  std::vector<std::unique_ptr<weld::Builder>> m_aBuilders;
996 
998 
1000 
1003 
1004  std::vector<std::unique_ptr<weld::Container>> m_aOrigContainers;
1005  std::vector<std::unique_ptr<weld::Label>> m_aFixedTexts;
1006  std::unique_ptr<weld::Entry> pEdits[AUTH_FIELD_END];
1007  std::unique_ptr<weld::Button> m_xOKBT;
1008  std::unique_ptr<weld::Container> m_xBox;
1009  std::unique_ptr<weld::Container> m_xLeft;
1010  std::unique_ptr<weld::Container> m_xRight;
1011  std::unique_ptr<weld::ComboBox> m_xTypeListBox;
1012  std::unique_ptr<weld::ComboBox> m_xIdentifierBox;
1013 
1014  DECL_LINK(IdentifierHdl, weld::ComboBox&, void);
1015  DECL_LINK(ShortNameHdl, weld::Entry&, void);
1016  DECL_LINK(EnableHdl, weld::ComboBox&, void);
1017 
1018 public:
1020  const OUString pFields[],
1021  SwWrtShell& rSh,
1022  bool bNewEntry,
1023  bool bCreate);
1024 
1025  OUString GetEntryText(ToxAuthorityField eField) const;
1026 
1027  void SetCheckNameHdl(const Link<weld::Entry&,bool>& rLink) {aShortNameCheckLink = rLink;}
1028 
1029 };
1030 
1031 struct TextInfo
1032 {
1034  const char* pHelpId;
1035 };
1036 
1037 static const TextInfo aTextInfoArr[] =
1038 {
1070 };
1071 
1072 static OUString lcl_FindColumnEntry(const uno::Sequence<beans::PropertyValue>& rFields, const OUString& rColumnTitle)
1073 {
1074  for(const auto& rField : rFields)
1075  {
1076  OUString sRet;
1077  if(rField.Name == rColumnTitle &&
1078  (rField.Value >>= sRet))
1079  {
1080  return sRet;
1081  }
1082  }
1083  return OUString();
1084 }
1085 
1087 
1089  : m_rDialog(rDialog)
1090  , bNewEntry(bNewDlg)
1091  , bBibAccessInitialized(false)
1092  , pSh(nullptr)
1093  , m_xFromComponentRB(rBuilder.weld_radio_button("frombibliography"))
1094  , m_xFromDocContentRB(rBuilder.weld_radio_button("fromdocument"))
1095  , m_xAuthorFI(rBuilder.weld_label("author"))
1096  , m_xTitleFI(rBuilder.weld_label("title"))
1097  , m_xEntryED(rBuilder.weld_entry("entryed"))
1098  , m_xEntryLB(rBuilder.weld_combo_box("entrylb"))
1099  , m_xActionBT(rBuilder.weld_button(bNewEntry ? OString("insert") : OString("modify")))
1100  , m_xCloseBT(rBuilder.weld_button("close"))
1101  , m_xCreateEntryPB(rBuilder.weld_button("new"))
1102  , m_xEditEntryPB(rBuilder.weld_button("edit"))
1103 {
1104  m_xActionBT->show();
1105  m_xFromComponentRB->set_visible(bNewEntry);
1106  m_xFromDocContentRB->set_visible(bNewEntry);
1107  m_xFromComponentRB->set_active(bIsFromComponent);
1108  m_xFromDocContentRB->set_active(!bIsFromComponent);
1109 
1110  m_xActionBT->connect_clicked(LINK(this,SwAuthorMarkPane, InsertHdl));
1111  m_xCloseBT->connect_clicked(LINK(this,SwAuthorMarkPane, CloseHdl));
1112  m_xCreateEntryPB->connect_clicked(LINK(this,SwAuthorMarkPane, CreateEntryHdl));
1113  m_xEditEntryPB->connect_clicked(LINK(this,SwAuthorMarkPane, CreateEntryHdl));
1114  m_xFromComponentRB->connect_toggled(LINK(this,SwAuthorMarkPane, ChangeSourceHdl));
1115  m_xFromDocContentRB->connect_toggled(LINK(this,SwAuthorMarkPane, ChangeSourceHdl));
1116  m_xEntryED->connect_changed(LINK(this,SwAuthorMarkPane, EditModifyHdl));
1117 
1119  bNewEntry ? STR_AUTHMRK_INSERT : STR_AUTHMRK_EDIT));
1120 
1121  m_xEntryED->set_visible(!bNewEntry);
1122  m_xEntryLB->set_visible(bNewEntry);
1123  if (bNewEntry)
1124  {
1125  m_xEntryLB->connect_changed(LINK(this, SwAuthorMarkPane, CompEntryHdl));
1126  }
1127 }
1128 
1130 {
1131  pSh = &rWrtShell;
1132  InitControls();
1133 }
1134 
1136 {
1137  if(bNewEntry)
1138  {
1140  SfxCallMode::ASYNCHRON|SfxCallMode::RECORD);
1141  }
1142  else
1143  {
1144  m_rDialog.response(RET_CANCEL);
1145  }
1146 }
1147 
1148 IMPL_LINK( SwAuthorMarkPane, CompEntryHdl, weld::ComboBox&, rBox, void)
1149 {
1150  const OUString sEntry(rBox.get_active_text());
1151  if(bIsFromComponent)
1152  {
1153  if(xBibAccess.is() && !sEntry.isEmpty())
1154  {
1155  if(xBibAccess->hasByName(sEntry))
1156  {
1157  uno::Any aEntry(xBibAccess->getByName(sEntry));
1158  uno::Sequence<beans::PropertyValue> aFieldProps;
1159  if(aEntry >>= aFieldProps)
1160  {
1161  auto nSize = std::min(static_cast<sal_Int32>(AUTH_FIELD_END), aFieldProps.getLength());
1162  for(sal_Int32 i = 0; i < nSize; i++)
1163  {
1164  m_sFields[i] = lcl_FindColumnEntry(aFieldProps, m_sColumnTitles[i]);
1165  }
1166  }
1167  }
1168  }
1169  }
1170  else
1171  {
1172  if(!sEntry.isEmpty())
1173  {
1174  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1175  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1176  const SwAuthEntry* pEntry = pFType ? pFType->GetEntryByIdentifier(sEntry) : nullptr;
1177  for(int i = 0; i < AUTH_FIELD_END; i++)
1178  m_sFields[i] = pEntry ?
1179  pEntry->GetAuthorField(static_cast<ToxAuthorityField>(i)) : OUString();
1180  }
1181  }
1182  if (rBox.get_active_text().isEmpty())
1183  {
1184  for(OUString & s : m_sFields)
1185  s.clear();
1186  }
1187  m_xAuthorFI->set_label(m_sFields[AUTH_FIELD_AUTHOR]);
1188  m_xTitleFI->set_label(m_sFields[AUTH_FIELD_TITLE]);
1189 }
1190 
1192 {
1193  //insert or update the SwAuthorityField...
1194  if(pSh)
1195  {
1196  bool bDifferent = false;
1197  OSL_ENSURE(!m_sFields[AUTH_FIELD_IDENTIFIER].isEmpty() , "No Id is set!");
1198  OSL_ENSURE(!m_sFields[AUTH_FIELD_AUTHORITY_TYPE].isEmpty() , "No authority type is set!");
1199  //check if the entry already exists with different content
1200  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1201  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1202  const SwAuthEntry* pEntry = pFType ?
1203  pFType->GetEntryByIdentifier( m_sFields[AUTH_FIELD_IDENTIFIER])
1204  : nullptr;
1205  if(pEntry)
1206  {
1207  for(int i = 0; i < AUTH_FIELD_END && !bDifferent; i++)
1208  bDifferent |= m_sFields[i] != pEntry->GetAuthorField(static_cast<ToxAuthorityField>(i));
1209  if(bDifferent)
1210  {
1211  std::unique_ptr<weld::MessageDialog> xQuery(Application::CreateMessageDialog(m_rDialog.getDialog(),
1212  VclMessageType::Question, VclButtonsType::YesNo,
1213  SwResId(STR_QUERY_CHANGE_AUTH_ENTRY)));
1214  if (RET_YES != xQuery->run())
1215  return;
1216  }
1217  }
1218 
1219  SwFieldMgr aMgr(pSh);
1220  OUStringBuffer sFields;
1221  for(OUString & s : m_sFields)
1222  {
1223  sFields.append(s).append(TOX_STYLE_DELIMITER);
1224  }
1225  if(bNewEntry)
1226  {
1227  if(bDifferent)
1228  {
1230  for(int i = 0; i < AUTH_FIELD_END; i++)
1231  xNewData->SetAuthorField(static_cast<ToxAuthorityField>(i), m_sFields[i]);
1232  pSh->ChangeAuthorityData(xNewData.get());
1233  }
1234  SwInsertField_Data aData(TYP_AUTHORITY, 0, sFields.makeStringAndClear(), OUString(), 0 );
1235  aMgr.InsertField( aData );
1236  }
1237  else if(aMgr.GetCurField())
1238  {
1239  aMgr.UpdateCurField(0, sFields.makeStringAndClear(), OUString());
1240  }
1241  }
1242  if(!bNewEntry)
1243  CloseHdl(*m_xCloseBT);
1244 }
1245 
1246 IMPL_LINK(SwAuthorMarkPane, CreateEntryHdl, weld::Button&, rButton, void)
1247 {
1248  bool bCreate = &rButton == m_xCreateEntryPB.get();
1249  OUString sOldId = m_sCreatedEntry[0];
1250  for(int i = 0; i < AUTH_FIELD_END; i++)
1251  m_sCreatedEntry[i] = bCreate ? OUString() : m_sFields[i];
1252  SwCreateAuthEntryDlg_Impl aDlg(m_rDialog.getDialog(),
1253  bCreate ? m_sCreatedEntry : m_sFields,
1254  *pSh, bNewEntry, bCreate);
1255  if(bNewEntry)
1256  {
1257  aDlg.SetCheckNameHdl(LINK(this, SwAuthorMarkPane, IsEntryAllowedHdl));
1258  }
1259  if(RET_OK == aDlg.run())
1260  {
1261  if(bCreate && !sOldId.isEmpty())
1262  {
1263  m_xEntryLB->remove_text(sOldId);
1264  }
1265  for(int i = 0; i < AUTH_FIELD_END; i++)
1266  {
1267  m_sFields[i] = aDlg.GetEntryText(static_cast<ToxAuthorityField>(i));
1268  m_sCreatedEntry[i] = m_sFields[i];
1269  }
1270  if(bNewEntry && !m_xFromDocContentRB->get_active())
1271  {
1272  m_xFromDocContentRB->set_active(true);
1273  ChangeSourceHdl(*m_xFromDocContentRB);
1274  }
1275  if(bCreate)
1276  {
1277  OSL_ENSURE(m_xEntryLB->find_text(m_sFields[AUTH_FIELD_IDENTIFIER]) == -1,
1278  "entry exists!");
1279  m_xEntryLB->append_text(m_sFields[AUTH_FIELD_IDENTIFIER]);
1280  m_xEntryLB->set_active_text(m_sFields[AUTH_FIELD_IDENTIFIER]);
1281  }
1282  m_xEntryED->set_text(m_sFields[AUTH_FIELD_IDENTIFIER]);
1283  m_xAuthorFI->set_label(m_sFields[AUTH_FIELD_AUTHOR]);
1284  m_xTitleFI->set_label(m_sFields[AUTH_FIELD_TITLE]);
1285  m_xActionBT->set_sensitive(true);
1286  }
1287 }
1288 
1290 {
1291  bool bFromComp = m_xFromComponentRB->get_active();
1292  bIsFromComponent = bFromComp;
1293  m_xCreateEntryPB->set_sensitive(!bIsFromComponent);
1294  m_xEntryLB->clear();
1295  if(bIsFromComponent)
1296  {
1297  if(!bBibAccessInitialized)
1298  {
1299  uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext();
1300  xBibAccess = frame::Bibliography::create( xContext );
1301  uno::Reference< beans::XPropertySet > xPropSet(xBibAccess, uno::UNO_QUERY);
1302  OUString uPropName("BibliographyDataFieldNames");
1303  if(xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName(uPropName))
1304  {
1305  uno::Any aNames = xPropSet->getPropertyValue(uPropName);
1306  uno::Sequence<beans::PropertyValue> aSeq;
1307  if( aNames >>= aSeq)
1308  {
1309  for(const beans::PropertyValue& rProp : aSeq)
1310  {
1311  sal_Int16 nField = 0;
1312  rProp.Value >>= nField;
1313  if(nField >= 0 && nField < AUTH_FIELD_END)
1314  m_sColumnTitles[nField] = rProp.Name;
1315  }
1316  }
1317  }
1318  bBibAccessInitialized = true;
1319  }
1320  if(xBibAccess.is())
1321  {
1322  uno::Sequence<OUString> aIdentifiers = xBibAccess->getElementNames();
1323  for(const OUString& rName : aIdentifiers)
1324  m_xEntryLB->append_text(rName);
1325  }
1326  }
1327  else
1328  {
1329  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1330  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1331  if(pFType)
1332  {
1333  std::vector<OUString> aIds;
1334  pFType->GetAllEntryIdentifiers( aIds );
1335  for(const OUString & i : aIds)
1336  m_xEntryLB->append_text(i);
1337  }
1338  if(!m_sCreatedEntry[AUTH_FIELD_IDENTIFIER].isEmpty())
1339  m_xEntryLB->append_text(m_sCreatedEntry[AUTH_FIELD_IDENTIFIER]);
1340  }
1341  m_xEntryLB->set_active(0);
1342  CompEntryHdl(*m_xEntryLB);
1343 }
1344 
1345 IMPL_LINK(SwAuthorMarkPane, EditModifyHdl, weld::Entry&, rEdit, void)
1346 {
1347  Link<weld::Entry&,bool> aAllowed = LINK(this, SwAuthorMarkPane, IsEditAllowedHdl);
1348  bool bResult = aAllowed.Call(rEdit);
1349  m_xActionBT->set_sensitive(bResult);
1350  if(bResult)
1351  {
1352  OUString sEntry(rEdit.get_text());
1353  m_sFields[AUTH_FIELD_IDENTIFIER] = sEntry;
1354  m_sCreatedEntry[AUTH_FIELD_IDENTIFIER] = sEntry;
1355  }
1356 };
1357 
1358 IMPL_LINK(SwAuthorMarkPane, IsEntryAllowedHdl, weld::Entry&, rEdit, bool)
1359 {
1360  OUString sEntry = rEdit.get_text();
1361  bool bAllowed = false;
1362  if(!sEntry.isEmpty())
1363  {
1364  if (m_xEntryLB->find_text(sEntry) != -1)
1365  return false;
1366  else if(bIsFromComponent)
1367  {
1368  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1369  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1370  bAllowed = !pFType || !pFType->GetEntryByIdentifier(sEntry);
1371  }
1372  else
1373  {
1374  bAllowed = !xBibAccess.is() || !xBibAccess->hasByName(sEntry);
1375  }
1376  }
1377  return bAllowed;
1378 }
1379 
1380 IMPL_LINK(SwAuthorMarkPane, IsEditAllowedHdl, weld::Entry&, rEdit, bool)
1381 {
1382  OUString sEntry = rEdit.get_text();
1383  bool bAllowed = false;
1384  if(!sEntry.isEmpty())
1385  {
1386  if (m_xEntryLB->find_text(sEntry) != -1)
1387  return false;
1388  else if(bIsFromComponent)
1389  {
1390  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1391  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1392  bAllowed = !pFType || !pFType->GetEntryByIdentifier(sEntry);
1393  }
1394  else
1395  {
1396  bAllowed = !xBibAccess.is() || !xBibAccess->hasByName(sEntry);
1397  }
1398  }
1399  return bAllowed;
1400 }
1401 
1403 {
1404  OSL_ENSURE(pSh, "no shell?");
1405  SwField* pField = pSh->GetCurField();
1406  OSL_ENSURE(bNewEntry || pField, "no current marker");
1407  if(bNewEntry)
1408  {
1409  ChangeSourceHdl(m_xFromComponentRB->get_active() ? *m_xFromComponentRB : *m_xFromDocContentRB);
1410  m_xCreateEntryPB->set_sensitive(!m_xFromComponentRB->get_active());
1411  if(!m_xFromComponentRB->get_active() && !m_sCreatedEntry[0].isEmpty())
1412  for(int i = 0; i < AUTH_FIELD_END; i++)
1414  }
1415  if(bNewEntry || !pField || pField->GetTyp()->Which() != SwFieldIds::TableOfAuthorities)
1416  return;
1417 
1418  const SwAuthEntry* pEntry = static_cast<SwAuthorityField*>(pField)->GetAuthEntry();
1419 
1420  OSL_ENSURE(pEntry, "No authority entry found");
1421  if(!pEntry)
1422  return;
1423  for(int i = 0; i < AUTH_FIELD_END; i++)
1424  m_sFields[i] = pEntry->GetAuthorField(static_cast<ToxAuthorityField>(i));
1425 
1426  m_xEntryED->set_text(pEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER));
1427  m_xAuthorFI->set_label(pEntry->GetAuthorField(AUTH_FIELD_AUTHOR));
1428  m_xTitleFI->set_label(pEntry->GetAuthorField(AUTH_FIELD_TITLE));
1429 }
1430 
1432 {
1433  m_xActionBT->set_sensitive(!pSh->HasReadonlySel());
1434 }
1435 
1436 namespace
1437 {
1438  const char* STR_AUTH_FIELD_ARY[] =
1439  {
1440  STR_AUTH_FIELD_IDENTIFIER,
1441  STR_AUTH_FIELD_AUTHORITY_TYPE,
1442  STR_AUTH_FIELD_ADDRESS,
1443  STR_AUTH_FIELD_ANNOTE,
1444  STR_AUTH_FIELD_AUTHOR,
1445  STR_AUTH_FIELD_BOOKTITLE,
1446  STR_AUTH_FIELD_CHAPTER,
1447  STR_AUTH_FIELD_EDITION,
1448  STR_AUTH_FIELD_EDITOR,
1449  STR_AUTH_FIELD_HOWPUBLISHED,
1450  STR_AUTH_FIELD_INSTITUTION,
1451  STR_AUTH_FIELD_JOURNAL,
1452  STR_AUTH_FIELD_MONTH,
1453  STR_AUTH_FIELD_NOTE,
1454  STR_AUTH_FIELD_NUMBER,
1455  STR_AUTH_FIELD_ORGANIZATIONS,
1456  STR_AUTH_FIELD_PAGES,
1457  STR_AUTH_FIELD_PUBLISHER,
1458  STR_AUTH_FIELD_SCHOOL,
1459  STR_AUTH_FIELD_SERIES,
1460  STR_AUTH_FIELD_TITLE,
1461  STR_AUTH_FIELD_TYPE,
1462  STR_AUTH_FIELD_VOLUME,
1463  STR_AUTH_FIELD_YEAR,
1464  STR_AUTH_FIELD_URL,
1465  STR_AUTH_FIELD_CUSTOM1,
1466  STR_AUTH_FIELD_CUSTOM2,
1467  STR_AUTH_FIELD_CUSTOM3,
1468  STR_AUTH_FIELD_CUSTOM4,
1469  STR_AUTH_FIELD_CUSTOM5,
1470  STR_AUTH_FIELD_ISBN
1471  };
1472 }
1473 
1475  const OUString pFields[],
1476  SwWrtShell& rSh,
1477  bool bNewEntry,
1478  bool bCreate)
1479  : GenericDialogController(pParent, "modules/swriter/ui/createauthorentry.ui", "CreateAuthorEntryDialog")
1480  , rWrtSh(rSh)
1481  , m_bNewEntryMode(bNewEntry)
1482  , m_bNameAllowed(true)
1483  , m_xOKBT(m_xBuilder->weld_button("ok"))
1484  , m_xBox(m_xBuilder->weld_container("box"))
1485  , m_xLeft(m_xBuilder->weld_container("leftgrid"))
1486  , m_xRight(m_xBuilder->weld_container("rightgrid"))
1487 {
1488  bool bLeft = true;
1489  sal_Int32 nLeftRow(0), nRightRow(0);
1490  for(int nIndex = 0; nIndex < AUTH_FIELD_END; nIndex++)
1491  {
1492  //m_xBox parent just to have some parent during setup, added contents are not directly visible under m_xBox
1493  m_aBuilders.emplace_back(Application::CreateBuilder(m_xBox.get(), "modules/swriter/ui/bibliofragment.ui"));
1494  const TextInfo aCurInfo = aTextInfoArr[nIndex];
1495 
1496  m_aOrigContainers.emplace_back(m_aBuilders.back()->weld_container("biblioentry"));
1497  m_aFixedTexts.emplace_back(m_aBuilders.back()->weld_label("label"));
1498  if (bLeft)
1499  m_aOrigContainers.back()->move(m_aFixedTexts.back().get(), m_xLeft.get());
1500  else
1501  m_aOrigContainers.back()->move(m_aFixedTexts.back().get(), m_xRight.get());
1502  m_aFixedTexts.back()->set_grid_left_attach(0);
1503  m_aFixedTexts.back()->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
1504  m_aFixedTexts.back()->set_label(SwResId(STR_AUTH_FIELD_ARY[aCurInfo.nToxField]));
1505  m_aFixedTexts.back()->show();
1506  if( AUTH_FIELD_AUTHORITY_TYPE == aCurInfo.nToxField )
1507  {
1508  m_xTypeListBox = m_aBuilders.back()->weld_combo_box("listbox");
1509  if (bLeft)
1510  m_aOrigContainers.back()->move(m_xTypeListBox.get(), m_xLeft.get());
1511  else
1512  m_aOrigContainers.back()->move(m_xTypeListBox.get(), m_xRight.get());
1513 
1514  for (int j = 0; j < AUTH_TYPE_END; j++)
1515  m_xTypeListBox->append_text(SwAuthorityFieldType::GetAuthTypeName(static_cast<ToxAuthorityType>(j)));
1516  if(!pFields[aCurInfo.nToxField].isEmpty())
1517  {
1518  m_xTypeListBox->set_active(pFields[aCurInfo.nToxField].toInt32());
1519  }
1520  m_xTypeListBox->set_grid_left_attach(1);
1521  m_xTypeListBox->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
1522  m_xTypeListBox->set_hexpand(true);
1523  m_xTypeListBox->show();
1524  m_xTypeListBox->connect_changed(LINK(this, SwCreateAuthEntryDlg_Impl, EnableHdl));
1525  m_xTypeListBox->set_help_id(aCurInfo.pHelpId);
1526  m_aFixedTexts.back()->set_mnemonic_widget(m_xTypeListBox.get());
1527  }
1528  else if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField && !m_bNewEntryMode)
1529  {
1530  m_xIdentifierBox = m_aBuilders.back()->weld_combo_box("combobox");
1531  if (bLeft)
1532  m_aOrigContainers.back()->move(m_xIdentifierBox.get(), m_xLeft.get());
1533  else
1534  m_aOrigContainers.back()->move(m_xIdentifierBox.get(), m_xRight.get());
1535 
1536  m_xIdentifierBox->connect_changed(LINK(this,
1537  SwCreateAuthEntryDlg_Impl, IdentifierHdl));
1538 
1539  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1540  rSh.GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1541  if(pFType)
1542  {
1543  std::vector<OUString> aIds;
1544  pFType->GetAllEntryIdentifiers( aIds );
1545  for (const OUString& a : aIds)
1546  m_xIdentifierBox->append_text(a);
1547  }
1548  m_xIdentifierBox->set_entry_text(pFields[aCurInfo.nToxField]);
1549  m_xIdentifierBox->set_grid_left_attach(1);
1550  m_xIdentifierBox->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
1551  m_xIdentifierBox->set_hexpand(true);
1552  m_xIdentifierBox->show();
1553  m_xIdentifierBox->set_help_id(aCurInfo.pHelpId);
1554  m_aFixedTexts.back()->set_mnemonic_widget(m_xIdentifierBox.get());
1555  }
1556  else
1557  {
1558  pEdits[nIndex] = m_aBuilders.back()->weld_entry("entry");
1559  if (bLeft)
1560  m_aOrigContainers.back()->move(pEdits[nIndex].get(), m_xLeft.get());
1561  else
1562  m_aOrigContainers.back()->move(pEdits[nIndex].get(), m_xRight.get());
1563 
1564  pEdits[nIndex]->set_grid_left_attach(1);
1565  pEdits[nIndex]->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
1566  pEdits[nIndex]->set_hexpand(true);
1567  pEdits[nIndex]->set_text(pFields[aCurInfo.nToxField]);
1568  pEdits[nIndex]->show();
1569  pEdits[nIndex]->set_help_id(aCurInfo.pHelpId);
1570  if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField)
1571  {
1572  pEdits[nIndex]->connect_changed(LINK(this, SwCreateAuthEntryDlg_Impl, ShortNameHdl));
1573  m_bNameAllowed = !pFields[nIndex].isEmpty();
1574  if(!bCreate)
1575  {
1576  m_aFixedTexts.back()->set_sensitive(false);
1577  pEdits[nIndex]->set_sensitive(false);
1578  }
1579  }
1580  m_aFixedTexts.back()->set_mnemonic_widget(pEdits[nIndex].get());
1581  }
1582  if(bLeft)
1583  ++nLeftRow;
1584  else
1585  ++nRightRow;
1586  bLeft = !bLeft;
1587  }
1588  EnableHdl(*m_xTypeListBox);
1589 }
1590 
1592 {
1593  if( AUTH_FIELD_AUTHORITY_TYPE == eField )
1594  {
1595  OSL_ENSURE(m_xTypeListBox, "No ListBox");
1596  return OUString::number(m_xTypeListBox->get_active());
1597  }
1598 
1599  if( AUTH_FIELD_IDENTIFIER == eField && !m_bNewEntryMode)
1600  {
1601  OSL_ENSURE(m_xIdentifierBox, "No ComboBox");
1602  return m_xIdentifierBox->get_active_text();
1603  }
1604 
1605  for(int nIndex = 0; nIndex < AUTH_FIELD_END; nIndex++)
1606  {
1607  const TextInfo aCurInfo = aTextInfoArr[nIndex];
1608  if(aCurInfo.nToxField == eField)
1609  {
1610  return pEdits[nIndex]->get_text();
1611  }
1612  }
1613 
1614  return OUString();
1615 }
1616 
1618 {
1619  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1620  rWrtSh.GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1621  if(pFType)
1622  {
1623  const SwAuthEntry* pEntry = pFType->GetEntryByIdentifier(
1624  rBox.get_active_text());
1625  if(pEntry)
1626  {
1627  for(int i = 0; i < AUTH_FIELD_END; i++)
1628  {
1629  const TextInfo aCurInfo = aTextInfoArr[i];
1630  if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField)
1631  continue;
1632  if(AUTH_FIELD_AUTHORITY_TYPE == aCurInfo.nToxField)
1633  m_xTypeListBox->set_active_text(
1634  pEntry->GetAuthorField(aCurInfo.nToxField));
1635  else
1636  pEdits[i]->set_text(
1637  pEntry->GetAuthorField(aCurInfo.nToxField));
1638  }
1639  }
1640  }
1641 }
1642 
1643 IMPL_LINK(SwCreateAuthEntryDlg_Impl, ShortNameHdl, weld::Entry&, rEdit, void)
1644 {
1645  if (aShortNameCheckLink.IsSet())
1646  {
1647  bool bEnable = aShortNameCheckLink.Call(rEdit);
1648  m_bNameAllowed |= bEnable;
1649  m_xOKBT->set_sensitive(m_xTypeListBox->get_active() != -1 && bEnable);
1650  }
1651 }
1652 
1654 {
1655  m_xOKBT->set_sensitive(m_bNameAllowed && rBox.get_active() != -1);
1656 };
1657 
1659  SfxChildWindow* pChild,
1660  weld::Window *pParent,
1661  SfxChildWinInfo const * pInfo,
1662  bool bNew)
1663  : SfxModelessDialogController(_pBindings, pChild, pParent,
1664  "modules/swriter/ui/bibliographyentry.ui", "BibliographyEntryDialog")
1665  , m_aContent(*this, *m_xBuilder, bNew)
1666 {
1667  Initialize(pInfo);
1668  SwWrtShell* pWrtShell = ::GetActiveWrtShell();
1669  if (pWrtShell)
1670  m_aContent.ReInitDlg(*pWrtShell);
1671 }
1672 
1674 {
1676  m_aContent.Activate();
1677 }
1678 
1680 {
1681  m_aContent.ReInitDlg( rWrtShell );
1682 }
1683 
1685  : SfxDialogController(pParent, "modules/swriter/ui/bibliographyentry.ui",
1686  "BibliographyEntryDialog")
1687  , m_aContent(*this, *m_xBuilder, false)
1688 {
1689  m_aContent.ReInitDlg(rSh);
1690 }
1691 
1693 {
1694  short ret = SfxDialogController::run();
1695  if (ret == RET_OK)
1696  Apply();
1697  return ret;
1698 }
1699 
1701 {
1702  m_aContent.InsertHdl(*m_aContent.m_xActionBT);
1703 }
1704 
1705 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwFieldType * GetFieldType(size_t nField, SwFieldIds nResId=SwFieldIds::Unknown) const
get field types with a ResId, if 0 get all
Definition: edfld.cxx:68
std::unique_ptr< weld::Label > m_xTypeFT
Definition: swuiidxmrk.hxx:62
std::unique_ptr< weld::RadioButton > m_xFromDocContentRB
Definition: swuiidxmrk.hxx:183
OUString const & GetAuthorField(ToxAuthorityField ePos) const
Definition: authfld.hxx:181
TOXTypes
Definition: toxe.hxx:39
#define HID_AUTH_FIELD_CUSTOM2
Definition: helpids.h:95
OUString const & GetSecondaryKeyReading() const
Definition: tox.hxx:628
void SetPrimKey(const OUString &rSet)
Definition: toxmgr.hxx:204
sal_uLong Find_Text(const i18nutil::SearchOptions2 &rSearchOpt, bool bSearchInNotes, SwDocPositions eStart, SwDocPositions eEnd, bool &bCancel, FindRanges eRng, bool bReplace=false)
Definition: crsrsh.cxx:3338
void set_title(const OUString &rTitle)
std::unique_ptr< weld::Label > m_xLevelFT
Definition: swuiidxmrk.hxx:77
OUString GetName() const
Definition: swuiidxmrk.cxx:581
#define RES_CHRATR_CJK_LANGUAGE
Definition: hintids.hxx:92
std::unique_ptr< weld::Label > m_xPhoneticFT0
Definition: swuiidxmrk.hxx:67
#define HID_AUTH_FIELD_NOTE
Definition: helpids.h:82
void UpdateLanguageDependenciesForPhoneticReading()
Definition: swuiidxmrk.cxx:300
void Initialize(SfxChildWinInfo const *pInfo)
#define HID_AUTH_FIELD_IDENTIFIER
Definition: helpids.h:69
std::unique_ptr< weld::Builder > m_xBuilder
#define RES_CHRATR_LANGUAGE
Definition: hintids.hxx:78
std::unique_ptr< weld::Label > m_xTitleFI
Definition: swuiidxmrk.hxx:185
#define POS_CONTENT
Definition: swuiidxmrk.cxx:64
OUString const & GetPrimaryKey() const
Definition: tox.hxx:604
#define HID_AUTH_FIELD_EDITOR
Definition: helpids.h:77
std::unique_ptr< weld::Label > m_xAuthorFI
Definition: swuiidxmrk.hxx:184
void ReInitDlg(SwWrtShell &rWrtShell)
Definition: swuiidxmrk.cxx:967
Definition: toxe.hxx:25
std::unique_ptr< weld::SpinButton > m_xLevelNF
Definition: swuiidxmrk.hxx:78
std::unique_ptr< weld::Entry > m_xEntryED
Definition: swuiidxmrk.hxx:65
SfxDispatcher * GetDispatcher()
Base class of all fields.
Definition: fldbas.hxx:279
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:402
std::vector< std::unique_ptr< weld::Builder > > m_aBuilders
Definition: swuiidxmrk.cxx:995
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1697
#define TOX_STYLE_DELIMITER
Definition: tox.hxx:386
SwWrtShell * GetActiveWrtShell()
Definition: swmodul1.cxx:115
void UpdateCurField(sal_uInt32 nFormat, const OUString &rPar1, const OUString &rPar2, std::unique_ptr< SwField > _pField=nullptr)
Definition: fldmgr.cxx:1528
std::unique_ptr< weld::Label > m_xPhoneticFT1
Definition: swuiidxmrk.hxx:71
SwCreateAuthEntryDlg_Impl(weld::Window *pParent, const OUString pFields[], SwWrtShell &rSh, bool bNewEntry, bool bCreate)
SwAuthMarkFloatDlg(SfxBindings *pBindings, SfxChildWindow *pChild, weld::Window *pParent, SfxChildWinInfo const *pInfo, bool bNew)
virtual short int run() override
Definition: swuiidxmrk.cxx:985
#define FN_INSERT_AUTH_ENTRY_DLG
Definition: cmdid.h:273
std::unique_ptr< weld::RadioButton > m_xFromComponentRB
Definition: swuiidxmrk.hxx:182
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:233
OUString m_aOrgStr
Definition: swuiidxmrk.hxx:45
std::unique_ptr< weld::Button > m_xOKBT
#define HID_AUTH_FIELD_ANNOTE
Definition: helpids.h:72
const SwTOXType * GetTOXType() const
Definition: tox.hxx:542
void Invalidate(sal_uInt16 nId)
bool InsertField(const SwInsertField_Data &rData)
Definition: fldmgr.cxx:895
#define HID_AUTH_FIELD_NUMBER
Definition: helpids.h:83
void EndAllAction()
Definition: edws.cxx:96
#define HID_AUTH_FIELD_ORGANIZATIONS
Definition: helpids.h:84
void ReInitDlg(SwWrtShell &rWrtShell)
RET_CANCEL
static OUString const & GetAuthTypeName(ToxAuthorityType eType)
Definition: initui.cxx:282
OUString m_sCreatedEntry[AUTH_FIELD_END]
Definition: swuiidxmrk.hxx:178
const char * pHelpId
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
SwWrtShell * m_pSh
Definition: swuiidxmrk.hxx:60
sal_uInt16 GetTOXTypeCount(TOXTypes eTyp) const
Manage types of content tables.
Definition: edws.cxx:189
SwAuthorMarkPane m_aContent
Definition: swuiidxmrk.hxx:225
void SwapPam()
Definition: crsrsh.cxx:964
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
std::unique_ptr< weld::ComboBox > m_xTypeListBox
SwAuthEntry * GetEntryByIdentifier(const OUString &rIdentifier) const
Definition: authfld.cxx:136
std::unique_ptr< SwTOXMgr > m_pTOXMgr
Definition: swuiidxmrk.hxx:59
OUString m_sFields[AUTH_FIELD_END]
Definition: swuiidxmrk.hxx:176
std::unique_ptr< weld::ComboBox > m_xKey2DCB
Definition: swuiidxmrk.hxx:74
OUString const & GetPrimaryKeyReading() const
Definition: tox.hxx:622
void ReInitDlg(SwWrtShell &rWrtShell)
const SwView & GetView() const
Definition: wrtsh.hxx:426
std::unique_ptr< weld::Button > m_xNextSameBT
Definition: swuiidxmrk.hxx:87
RET_YES
std::unique_ptr< weld::Button > m_xOKBT
Definition: swuiidxmrk.hxx:83
void SttCursorMove()
Definition: crsrsh.cxx:291
invariant for SwAuthorityField is that it is always registered at its SwAuthorityFieldType via AddFie...
Definition: authfld.hxx:148
void SetPhoneticReadingOfSecKey(const OUString &rSet)
Definition: toxmgr.hxx:222
std::unique_ptr< weld::ComboBox > m_xEntryLB
Definition: swuiidxmrk.hxx:187
std::unique_ptr< weld::CheckButton > m_xSearchCaseWordOnlyCB
Definition: swuiidxmrk.hxx:82
#define HID_AUTH_FIELD_AUTHORITY_TYPE
Definition: helpids.h:70
std::unique_ptr< weld::Button > m_xPrevSameBT
Definition: swuiidxmrk.hxx:86
#define HID_AUTH_FIELD_PAGES
Definition: helpids.h:85
#define FN_EDIT_IDX_ENTRY_DLG
Definition: cmdid.h:73
SwField * GetCurField(const bool bIncludeInputFieldAtStart=false) const
Definition: crstrvl.cxx:927
Link< weld::Entry &, bool > aShortNameCheckLink
Definition: swuiidxmrk.cxx:997
eField
Definition: fields.hxx:26
sal_Int32 GetStart() const
Definition: txatbase.hxx:82
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
SwWrtShell * pSh
Definition: swuiidxmrk.hxx:173
bool m_bPhoneticED0_ChangedByUser
Definition: swuiidxmrk.hxx:50
void SetLevel(int nSet)
Definition: toxmgr.hxx:198
#define HID_AUTH_FIELD_EDITION
Definition: helpids.h:76
IMPL_LINK_NOARG(SwIndexMarkPane, SyncSelectionHdl, weld::Button &, void)
Definition: swuiidxmrk.cxx:364
std::unique_ptr< weld::Label > m_xKey2FT
Definition: swuiidxmrk.hxx:73
static void lcl_SelectSameStrings(SwWrtShell &rSh, bool bWordOnly, bool bCaseSensitive)
Definition: swuiidxmrk.cxx:428
void SetPhoneticReadingOfPrimKey(const OUString &rSet)
Definition: toxmgr.hxx:219
SwIndexMarkModalDlg(weld::Window *pParent, SwWrtShell &rSh, SwTOXMark const *pCurTOXMark)
Definition: swuiidxmrk.cxx:972
void SetCheckNameHdl(const Link< weld::Entry &, bool > &rLink)
SwAuthorMarkPane m_aContent
Definition: swuiidxmrk.hxx:212
static bool bIsFromComponent
Definition: swuiidxmrk.hxx:165
std::unique_ptr< weld::Button > m_xActionBT
Definition: swuiidxmrk.hxx:188
void EndCursorMove(const bool bIdleEnd=false)
Definition: crsrsh.cxx:300
std::unique_ptr< weld::Entry > pEdits[AUTH_FIELD_END]
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:614
weld::DialogController & m_rDialog
Definition: swuiidxmrk.hxx:163
#define HID_AUTH_FIELD_CUSTOM3
Definition: helpids.h:96
virtual short int run() override
#define HID_AUTH_FIELD_ISBN
Definition: helpids.h:99
#define HID_AUTH_FIELD_BOOKTITLE
Definition: helpids.h:74
void GetTOIKeys(SwTOIKeyType eTyp, std::vector< OUString > &rArr) const
Key for managing index.
Definition: edtox.cxx:214
static OUString lcl_FindColumnEntry(const uno::Sequence< beans::PropertyValue > &rFields, const OUString &rColumnTitle)
SvtScriptType GetScriptType() const
returns the script type of the selection
Definition: edattr.cxx:671
bool HasSelection() const
Definition: wrtsh.hxx:139
std::unique_ptr< weld::Container > m_xRight
DECL_LINK(ModifyHdl, weld::Entry &, void)
#define FN_INSERT_IDX_ENTRY_DLG
Definition: cmdid.h:212
#define HID_AUTH_FIELD_CHAPTER
Definition: helpids.h:75
void SetAltStr(const OUString &rSet)
Definition: toxmgr.hxx:210
void ReInitDlg(SwWrtShell &rWrtShell, SwTOXMark const *pCurTOXMark=nullptr)
Definition: swuiidxmrk.cxx:934
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2145
#define HID_AUTH_FIELD_YEAR
Definition: helpids.h:92
#define HID_AUTH_FIELD_CUSTOM1
Definition: helpids.h:94
SfxBindings & GetBindings()
int i
std::unique_ptr< weld::CheckButton > m_xSearchCaseSensitiveCB
Definition: swuiidxmrk.hxx:81
sal_uInt16 GetLevel() const
Definition: tox.hxx:598
bool const m_bNewMark
Definition: swuiidxmrk.hxx:47
FrameTypeFlags
values can be combined via logical or
Definition: fesh.hxx:62
std::unique_ptr< weld::Button > m_xNewBT
Definition: swuiidxmrk.hxx:64
bool const bNewEntry
Definition: swuiidxmrk.hxx:170
#define HID_AUTH_FIELD_TITLE
Definition: helpids.h:89
bool SelectTextAttr(sal_uInt16 nWhich, const SwTextAttr *pAttr=nullptr)
Definition: move.cxx:675
LanguageType m_nLangForPhoneticReading
Definition: swuiidxmrk.hxx:53
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:222
All (only in non-body and selections).
OUString GetText(SwRootFrame const *pLayout) const
Definition: tox.cxx:169
SwField * GetCurField()
Definition: fldmgr.cxx:433
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:29
std::unique_ptr< weld::CheckButton > m_xApplyToAllCB
Definition: swuiidxmrk.hxx:80
static sal_uInt16 nKey2Pos
Definition: swuiidxmrk.cxx:70
#define HID_AUTH_FIELD_VOLUME
Definition: helpids.h:91
Object Value
const OUString & GetTypeName() const
Definition: tox.hxx:660
const SwTextNode * GetpTextNd() const
Definition: txttxmrk.hxx:44
#define LANGUAGE_CHINESE_SIMPLIFIED
Definition: toxe.hxx:24
sal_uInt16 GetCursorCnt(bool bAll=true) const
Get the number of elements in the ring of cursors.
Definition: crsrsh.cxx:2619
#define RES_TXTATR_TOXMARK
Definition: hintids.hxx:137
long ResetSelect(const Point *, bool)
Definition: select.cxx:337
std::unique_ptr< weld::Label > m_xKey1FT
Definition: swuiidxmrk.hxx:69
std::shared_ptr< weld::Dialog > m_xDialog
Definition: swuiidxmrk.hxx:40
std::vector< std::unique_ptr< weld::Container > > m_aOrigContainers
OUString GetEntryText(ToxAuthorityField eField) const
GUIDCNamePair const aData
SwIndexMarkPane * m_pDlg
Definition: swuiidxmrk.cxx:563
OUString SwResId(const char *pId)
Definition: swmodule.cxx:191
#define HID_AUTH_FIELD_URL
Definition: helpids.h:93
static sal_Int32 nTypePos
Definition: swuiidxmrk.cxx:67
bool HasReadonlySel() const
Definition: crsrsh.cxx:3229
std::unique_ptr< weld::Container > m_xBox
#define HID_AUTH_FIELD_AUTHOR
Definition: helpids.h:73
#define HID_AUTH_FIELD_ADDRESS
Definition: helpids.h:71
DocumentType const eType
std::vector< std::unique_ptr< weld::Label > > m_aFixedTexts
#define HID_AUTH_FIELD_REPORT_TYPE
Definition: helpids.h:90
OUString const & GetTextReading() const
Definition: tox.hxx:616
#define HID_AUTH_FIELD_CUSTOM4
Definition: helpids.h:97
virtual OUString get_text() const =0
std::unique_ptr< weld::Button > m_xPrevBT
Definition: swuiidxmrk.hxx:88
Find only in body - only in combination with FindRanges::InSelAll !!!
std::unique_ptr< weld::Container > m_xLeft
SwFieldType * GetTyp() const
Definition: fldbas.hxx:382
static const TextInfo aTextInfoArr[]
GenericDialogController(weld::Widget *pParent, const OUString &rUIFile, const OString &rDialogId)
void GetAllEntryIdentifiers(std::vector< OUString > &rToFill) const
Definition: authfld.cxx:127
ToxAuthorityField
Definition: toxe.hxx:82
std::unique_ptr< weld::Button > m_xEditEntryPB
Definition: swuiidxmrk.hxx:191
std::unique_ptr< weld::Entry > m_xPhoneticED1
Definition: swuiidxmrk.hxx:72
std::unique_ptr< weld::ComboBox > m_xTypeDCB
Definition: swuiidxmrk.hxx:63
const LanguageTag & GetAppLanguageTag()
Definition: init.cxx:778
#define HID_AUTH_FIELD_JOURNAL
Definition: helpids.h:80
std::unique_ptr< weld::Button > m_xDelBT
Definition: swuiidxmrk.hxx:85
std::unique_ptr< weld::Button > m_xCloseBT
Definition: swuiidxmrk.hxx:189
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
RET_CLOSE
#define POS_INDEX
Definition: swuiidxmrk.cxx:65
virtual void Activate() override
void SetPhoneticReadingOfAltStr(const OUString &rSet)
Definition: toxmgr.hxx:216
static SfxViewFrame * Current()
weld::Entry & rEdit
static void SetCareDialog(const std::shared_ptr< weld::Window > &rNew)
Definition: viewsh.cxx:2495
OUString const & GetSecondaryKey() const
Definition: tox.hxx:610
#define RES_CHRATR_CTL_LANGUAGE
Definition: hintids.hxx:97
std::unique_ptr< weld::Entry > m_xPhoneticED0
Definition: swuiidxmrk.hxx:68
ToxAuthorityField nToxField
#define HID_AUTH_FIELD_PUBLISHER
Definition: helpids.h:86
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
virtual void Activate() override
Definition: swuiidxmrk.cxx:961
OUString GetSelText() const
get selected text of a node at current cursor
Definition: crsrsh.cxx:2431
void SetTOUName(const OUString &rSet)
Definition: toxmgr.hxx:213
std::unique_ptr< weld::Button > m_xSyncED
Definition: swuiidxmrk.hxx:66
RET_OK
DECL_LINK(IdentifierHdl, weld::ComboBox &, void)
SwAuthMarkModalDlg(weld::Window *pParent, SwWrtShell &rSh)
static sal_uInt16 nKey1Pos
Definition: swuiidxmrk.cxx:68
LanguageType GetLang(const sal_Int32 nBegin, const sal_Int32 nLen=0, sal_uInt16 nScript=0) const
Definition: thints.cxx:3386
OUString GetSelectionTextParam(bool bCompleteWords, bool bEraseTrail)
Definition: view.cxx:1600
SwIndexMarkFloatDlg(SfxBindings *pBindings, SfxChildWindow *pChild, weld::Window *pParent, SfxChildWinInfo const *pInfo, bool bNew)
Definition: swuiidxmrk.cxx:950
Reference< XComponentContext > getProcessComponentContext()
std::unique_ptr< weld::ComboBox > m_xKey1DCB
Definition: swuiidxmrk.hxx:70
SwAuthorMarkPane(weld::DialogController &rDialog, weld::Builder &rBuilder, bool bNew)
#define HID_AUTH_FIELD_SERIES
Definition: helpids.h:88
std::unique_ptr< weld::CheckButton > m_xMainEntryCB
Definition: swuiidxmrk.hxx:79
#define HID_AUTH_FIELD_SCHOOL
Definition: helpids.h:87
const SwTOXType * GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const
Definition: edtox.cxx:207
std::unique_ptr< weld::Button > m_xOKPB
Definition: swuiidxmrk.cxx:565
void ClearMark()
Definition: crsrsh.cxx:927
const SvxPageUsage aArr[]
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:181
void SetSecKey(const OUString &rSet)
Definition: toxmgr.hxx:207
TOXTypes GetType() const
Definition: tox.hxx:663
const SwTOXMark & GotoTOXMark(const SwTOXMark &rStart, SwTOXSearch eDir)
traveling between marks
Definition: crstrvl.cxx:625
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
std::unique_ptr< weld::ComboBox > m_xIdentifierBox
std::unique_ptr< weld::Label > m_xPhoneticFT2
Definition: swuiidxmrk.hxx:75
css::uno::Reference< css::i18n::XExtendedIndexEntrySupplier > m_xExtendedIndexEntrySupplier
Definition: swuiidxmrk.hxx:56
bool IsMainEntry() const
Definition: tox.hxx:132
#define HID_AUTH_FIELD_INSTITUTION
Definition: helpids.h:79
virtual void Activate() override
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile)
std::unique_ptr< weld::Button > m_xNextBT
Definition: swuiidxmrk.hxx:89
void InsertTOXMark(const SwTOXMarkDescription &rDesc)
Definition: toxmgr.cxx:61
void SetMainEntry(bool bSet)
Definition: toxmgr.hxx:201
SwIndexMarkPane(const std::shared_ptr< weld::Dialog > &rDialog, weld::Builder &rBuilder, bool bNewDlg, SwWrtShell &rWrtShell)
Definition: swuiidxmrk.cxx:79
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
const SwTextTOXMark * GetTextTOXMark() const
Definition: tox.hxx:137
SwIndexMarkPane m_aContent
Definition: swuiidxmrk.hxx:152
SwNewUserIdxDlg(SwIndexMarkPane *pPane, weld::Window *pParent)
Definition: swuiidxmrk.cxx:571
#define HID_AUTH_FIELD_MONTH
Definition: helpids.h:81
void StartAllAction()
For all views of this document.
Definition: edws.cxx:85
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2072
sal_Int32 nPos
virtual ~SwIndexMarkModalDlg() override
Definition: swuiidxmrk.cxx:980
OUString GetDefaultPhoneticReading(const OUString &rText)
Definition: swuiidxmrk.cxx:347
IMPL_LINK(SwNewUserIdxDlg, ModifyHdl, weld::Entry &, rEdit, void)
Definition: swuiidxmrk.cxx:584
void ModifyHdl(const weld::Widget &rWidget)
Definition: swuiidxmrk.cxx:639
SwFieldIds Which() const
Definition: fldbas.hxx:265
std::unique_ptr< weld::Button > m_xCreateEntryPB
Definition: swuiidxmrk.hxx:190
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
Definition: fews.cxx:238
void UpdateKeyBoxes()
Definition: swuiidxmrk.cxx:543
std::unique_ptr< weld::Entry > m_xNameED
Definition: swuiidxmrk.cxx:566
std::unique_ptr< weld::Button > m_xCloseBT
Definition: swuiidxmrk.hxx:84
void SAL_CALL last(const css::awt::SpinEvent &rEvent) override
std::unique_ptr< weld::Entry > m_xEntryED
Definition: swuiidxmrk.hxx:186
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
SwIndexMarkPane m_aContent
Definition: swuiidxmrk.hxx:138
std::unique_ptr< weld::Entry > m_xPhoneticED2
Definition: swuiidxmrk.hxx:76
#define HID_AUTH_FIELD_CUSTOM5
Definition: helpids.h:98
#define HID_AUTH_FIELD_HOWPUBLISHED
Definition: helpids.h:78
bool m_bIsPhoneticReadingEnabled
Definition: swuiidxmrk.hxx:54