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