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* pWrtShell)
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(pWrtShell)
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  nTypePos = m_xTypeDCB->find_text(m_xTypeDCB->get_active_text());
423  if(nTypePos == -1)
424  nTypePos = 0;
425 
426  nKey1Pos = m_xKey1DCB->find_text(m_xKey1DCB->get_active_text());
427  nKey2Pos = m_xKey2DCB->find_text(m_xKey2DCB->get_active_text());
428 }
429 
430 // insert mark
431 static void lcl_SelectSameStrings(SwWrtShell& rSh, bool bWordOnly, bool bCaseSensitive)
432 {
433  rSh.Push();
434 
435  i18nutil::SearchOptions2 aSearchOpt(
436  SearchAlgorithms_ABSOLUTE,
437  ( bWordOnly ? SearchFlags::NORM_WORD_ONLY : 0 ),
438  rSh.GetSelText(), OUString(),
440  0, 0, 0,
441  (bCaseSensitive
442  ? TransliterationFlags::NONE
443  : TransliterationFlags::IGNORE_CASE),
444  SearchAlgorithms2::ABSOLUTE,
445  '\\' );
446 
447  rSh.ClearMark();
448  bool bCancel;
449 
450  //todo/mba: assuming that notes should not be searched
451  rSh.Find_Text(aSearchOpt, false/*bSearchInNotes*/, SwDocPositions::Start, SwDocPositions::End, bCancel,
453 }
454 
456 {
457  auto nPos = m_xTypeDCB->find_text(m_xTypeDCB->get_active_text());
460 
461  SwTOXMarkDescription aDesc(eType);
462 
463  const int nLevel = m_xLevelNF->denormalize(m_xLevelNF->get_value());
464  switch( nPos)
465  {
466  case POS_CONTENT : break;
467  case POS_INDEX: // keyword index mark
468  {
469  UpdateKeyBoxes();
470  aDesc.SetPrimKey(m_xKey1DCB->get_active_text());
471  aDesc.SetSecKey(m_xKey2DCB->get_active_text());
472  aDesc.SetMainEntry(m_xMainEntryCB->get_active());
473  aDesc.SetPhoneticReadingOfAltStr(m_xPhoneticED0->get_text());
474  aDesc.SetPhoneticReadingOfPrimKey(m_xPhoneticED1->get_text());
475  aDesc.SetPhoneticReadingOfSecKey(m_xPhoneticED2->get_text());
476  }
477  break;
478  default: // Userdefined index mark
479  {
480  aDesc.SetTOUName(m_xTypeDCB->get_active_text());
481  }
482  }
483  if (m_aOrgStr != m_xEntryED->get_text())
484  aDesc.SetAltStr(m_xEntryED->get_text());
485  bool bApplyAll = m_xApplyToAllCB->get_active();
486  bool bWordOnly = m_xSearchCaseWordOnlyCB->get_active();
487  bool bCaseSensitive = m_xSearchCaseSensitiveCB->get_active();
488 
490  // all equal strings have to be selected here so that the
491  // entry is applied to all equal strings
492  if(bApplyAll)
493  {
494  lcl_SelectSameStrings(*m_pSh, bWordOnly, bCaseSensitive);
495  }
496  aDesc.SetLevel(nLevel);
497  SwTOXMgr aMgr(m_pSh);
498  aMgr.InsertTOXMark(aDesc);
499  if(bApplyAll)
501 
502  m_pSh->EndAllAction();
503 }
504 
505 // update mark
507 {
508  OUString aAltText(m_xEntryED->get_text());
509  OUString* pAltText = m_aOrgStr != m_xEntryED->get_text() ? &aAltText : nullptr;
510  //empty alternative texts are not allowed
511  if(pAltText && pAltText->isEmpty())
512  return;
513 
514  UpdateKeyBoxes();
515 
516  auto nPos = m_xTypeDCB->find_text(m_xTypeDCB->get_active_text());
518  if(POS_CONTENT == nPos)
519  eType = TOX_CONTENT;
520  else if(POS_INDEX == nPos)
521  eType = TOX_INDEX;
522 
523  SwTOXMarkDescription aDesc(eType);
524  aDesc.SetLevel(m_xLevelNF->get_value());
525  if(pAltText)
526  aDesc.SetAltStr(*pAltText);
527 
528  OUString aPrim(m_xKey1DCB->get_active_text());
529  if(!aPrim.isEmpty())
530  aDesc.SetPrimKey(aPrim);
531  OUString aSec(m_xKey2DCB->get_active_text());
532  if(!aSec.isEmpty())
533  aDesc.SetSecKey(aSec);
534 
535  if(eType == TOX_INDEX)
536  {
537  aDesc.SetPhoneticReadingOfAltStr(m_xPhoneticED0->get_text());
538  aDesc.SetPhoneticReadingOfPrimKey(m_xPhoneticED1->get_text());
539  aDesc.SetPhoneticReadingOfSecKey(m_xPhoneticED2->get_text());
540  }
541  aDesc.SetMainEntry(m_xMainEntryCB->get_visible() && m_xMainEntryCB->get_active());
542  m_pTOXMgr->UpdateTOXMark(aDesc);
543 }
544 
545 // insert new keys
547 {
548  OUString aKey(m_xKey1DCB->get_active_text());
549  auto nPos = m_xKey1DCB->find_text(aKey);
550  if(nPos == -1 && !aKey.isEmpty())
551  { // create new key
552  m_xKey1DCB->append_text(aKey);
553  }
554 
555  aKey = m_xKey2DCB->get_active_text();
556  nPos = m_xKey2DCB->find_text(aKey);
557 
558  if(nPos == -1 && !aKey.isEmpty())
559  { // create new key
560  m_xKey2DCB->append_text(aKey);
561  }
562 }
563 
564 namespace {
565 
566 class SwNewUserIdxDlg : public weld::GenericDialogController
567 {
568  SwIndexMarkPane* m_pDlg;
569 
570  std::unique_ptr<weld::Button> m_xOKPB;
571  std::unique_ptr<weld::Entry> m_xNameED;
572 
573  DECL_LINK(ModifyHdl, weld::Entry&, void);
574 
575 public:
576  explicit SwNewUserIdxDlg(SwIndexMarkPane* pPane, weld::Window* pParent)
577  : GenericDialogController(pParent, "modules/swriter/ui/newuserindexdialog.ui", "NewUserIndexDialog")
578  , m_pDlg(pPane)
579  , m_xOKPB(m_xBuilder->weld_button("ok"))
580  , m_xNameED(m_xBuilder->weld_entry("entry"))
581  {
582  m_xNameED->connect_changed(LINK(this, SwNewUserIdxDlg, ModifyHdl));
583  m_xOKPB->set_sensitive(false);
584  m_xNameED->grab_focus();
585  }
586  OUString GetName() const { return m_xNameED->get_text(); }
587 };
588 
589 }
590 
591 IMPL_LINK( SwNewUserIdxDlg, ModifyHdl, weld::Entry&, rEdit, void)
592 {
593  m_xOKPB->set_sensitive(!rEdit.get_text().isEmpty() && !m_pDlg->IsTOXType(rEdit.get_text()));
594 }
595 
597 {
598  SwNewUserIdxDlg aDlg(this, m_xDialog.get());
599  if (aDlg.run() == RET_OK)
600  {
601  OUString sNewName(aDlg.GetName());
602  m_xTypeDCB->append_text(sNewName);
603  m_xTypeDCB->set_active_text(sNewName);
604  }
605 }
606 
607 IMPL_LINK( SwIndexMarkPane, SearchTypeHdl, weld::ToggleButton&, rBox, void)
608 {
609  const bool bEnable = rBox.get_active() && rBox.get_sensitive();
610  m_xSearchCaseWordOnlyCB->set_sensitive(bEnable);
611  m_xSearchCaseSensitiveCB->set_sensitive(bEnable);
612 }
613 
614 IMPL_LINK(SwIndexMarkPane, InsertHdl, weld::Button&, rButton, void)
615 {
616  Apply();
617  //close the dialog if only one entry is available
618  if(!m_bNewMark && !m_xPrevBT->get_visible() && !m_xNextBT->get_visible())
619  CloseHdl(rButton);
620 }
621 
623 {
624  if (m_bNewMark)
625  {
627  SfxCallMode::ASYNCHRON|SfxCallMode::RECORD);
628  }
629  else
630  {
631  m_xDialog->response(RET_CLOSE);
632  }
633 }
634 
635 // select index type only when inserting
636 IMPL_LINK(SwIndexMarkPane, ModifyListBoxHdl, weld::ComboBox&, rBox, void)
637 {
638  ModifyHdl(rBox);
639 }
640 
641 IMPL_LINK(SwIndexMarkPane, ModifyEditHdl, weld::Entry&, rEdit, void)
642 {
643  ModifyHdl(rEdit);
644 }
645 
647 {
648  if (m_xTypeDCB.get() == &rBox)
649  {
650  // set index type
651  auto nPos = m_xTypeDCB->find_text(m_xTypeDCB->get_active_text());
652  bool bLevelEnable = false,
653  bKeyEnable = false,
654  bSetKey2 = false,
655  bKey2Enable = false,
656  bEntryHasText = false,
657  bKey1HasText = false,
658  bKey2HasText = false;
659  if(nPos == POS_INDEX)
660  {
661  if (!m_xEntryED->get_text().isEmpty())
662  bEntryHasText = true;
663  m_xPhoneticED0->set_text(GetDefaultPhoneticReading(m_xEntryED->get_text()));
664 
665  bKeyEnable = true;
666  m_xKey1DCB->set_active_text(m_xKey1DCB->get_text(nKey1Pos));
667  m_xPhoneticED1->set_text(GetDefaultPhoneticReading(m_xKey1DCB->get_active_text()));
668  if (!m_xKey1DCB->get_active_text().isEmpty())
669  {
670  bKey1HasText = bSetKey2 = bKey2Enable = true;
671  m_xKey2DCB->set_active_text(m_xKey2DCB->get_text(nKey2Pos));
672  m_xPhoneticED2->set_text(GetDefaultPhoneticReading(m_xKey2DCB->get_active_text()));
673  if(!m_xKey2DCB->get_active_text().isEmpty())
674  bKey2HasText = true;
675  }
676  }
677  else
678  {
679  bLevelEnable = true;
680  m_xLevelNF->set_max(MAXLEVEL);
681  m_xLevelNF->set_value(m_xLevelNF->normalize(0));
682  bSetKey2 = true;
683  }
684  m_xLevelFT->set_visible(bLevelEnable);
685  m_xLevelNF->set_visible(bLevelEnable);
686  m_xMainEntryCB->set_visible(nPos == POS_INDEX);
687 
688  m_xKey1FT->set_sensitive(bKeyEnable);
689  m_xKey1DCB->set_sensitive(bKeyEnable);
690  if ( bSetKey2 )
691  {
692  m_xKey2DCB->set_sensitive(bKey2Enable);
693  m_xKey2FT->set_sensitive(bKey2Enable);
694  }
695  m_xPhoneticFT0->set_sensitive(bKeyEnable&&bEntryHasText&&m_bIsPhoneticReadingEnabled);
696  m_xPhoneticED0->set_sensitive(bKeyEnable&&bEntryHasText&&m_bIsPhoneticReadingEnabled);
697  m_xPhoneticFT1->set_sensitive(bKeyEnable&&bKey1HasText&&m_bIsPhoneticReadingEnabled);
698  m_xPhoneticED1->set_sensitive(bKeyEnable&&bKey1HasText&&m_bIsPhoneticReadingEnabled);
699  m_xPhoneticFT2->set_sensitive(bKeyEnable&&bKey2HasText&&m_bIsPhoneticReadingEnabled);
700  m_xPhoneticED2->set_sensitive(bKeyEnable&&bKey2HasText&&m_bIsPhoneticReadingEnabled);
701  }
702  else //m_xEntryED !!m_xEntryED is not a ListBox but an Edit
703  {
704  bool bHasText = !m_xEntryED->get_text().isEmpty();
705  if(!bHasText)
706  {
707  m_xPhoneticED0->set_text(OUString());
709  }
711  m_xPhoneticED0->set_text(GetDefaultPhoneticReading(m_xEntryED->get_text()));
712 
713  m_xPhoneticFT0->set_sensitive(bHasText&&m_bIsPhoneticReadingEnabled);
714  m_xPhoneticED0->set_sensitive(bHasText&&m_bIsPhoneticReadingEnabled);
715  }
716  m_xOKBT->set_sensitive(!m_pSh->HasReadonlySel() &&
717  (!m_xEntryED->get_text().isEmpty() || m_pSh->GetCursorCnt(false)));
718 }
719 
721 {
722  InsertUpdate();
723  m_pTOXMgr->NextTOXMark();
724  UpdateDialog();
725 }
726 
728 {
729  InsertUpdate();
730  m_pTOXMgr->NextTOXMark(true);
731  UpdateDialog();
732 }
733 
735 {
736  InsertUpdate();
737  m_pTOXMgr->PrevTOXMark();
738  UpdateDialog();
739 }
740 
742 {
743  InsertUpdate();
744  m_pTOXMgr->PrevTOXMark(true);
745  UpdateDialog();
746 }
747 
749 {
750  m_bDel = true;
751  InsertUpdate();
752  m_bDel = false;
753 
754  if(m_pTOXMgr->GetCurTOXMark())
755  UpdateDialog();
756  else
757  {
758  CloseHdl(*m_xCloseBT);
760  }
761 }
762 
763 // renew dialog view
765 {
766  OSL_ENSURE(m_pSh && m_pTOXMgr, "no shell?");
767  SwTOXMark* pMark = m_pTOXMgr->GetCurTOXMark();
768  OSL_ENSURE(pMark, "no current marker");
769  if(!pMark)
770  return;
771 
773 
774  m_aOrgStr = pMark->GetText(m_pSh->GetLayout());
775  m_xEntryED->set_text(m_aOrgStr);
776 
777  // set index type
778  bool bLevelEnable = true,
779  bKeyEnable = false,
780  bKey2Enable = false,
781  bEntryHasText = false,
782  bKey1HasText = false,
783  bKey2HasText = false;
784 
785  TOXTypes eCurType = pMark->GetTOXType()->GetType();
786  if(TOX_INDEX == eCurType)
787  {
788  bLevelEnable = false;
789  bKeyEnable = true;
790  bKey1HasText = bKey2Enable = !pMark->GetPrimaryKey().isEmpty();
791  bKey2HasText = !pMark->GetSecondaryKey().isEmpty();
792  bEntryHasText = !pMark->GetText(m_pSh->GetLayout()).isEmpty();
793  m_xKey1DCB->set_entry_text( pMark->GetPrimaryKey() );
794  m_xKey2DCB->set_entry_text( pMark->GetSecondaryKey() );
795  m_xPhoneticED0->set_text( pMark->GetTextReading() );
796  m_xPhoneticED1->set_text( pMark->GetPrimaryKeyReading() );
797  m_xPhoneticED2->set_text( pMark->GetSecondaryKeyReading() );
798  m_xMainEntryCB->set_active(pMark->IsMainEntry());
799  }
800  else if(TOX_CONTENT == eCurType || TOX_USER == eCurType)
801  {
802  m_xLevelNF->set_value(m_xLevelNF->normalize(pMark->GetLevel()));
803  }
804  m_xKey1FT->set_sensitive(bKeyEnable);
805  m_xKey1DCB->set_sensitive(bKeyEnable);
806  m_xLevelNF->set_max(MAXLEVEL);
807  m_xLevelFT->set_visible(bLevelEnable);
808  m_xLevelNF->set_visible(bLevelEnable);
809  m_xMainEntryCB->set_visible(!bLevelEnable);
810  m_xKey2FT->set_sensitive(bKey2Enable);
811  m_xKey2DCB->set_sensitive(bKey2Enable);
812 
814  m_xPhoneticFT0->set_sensitive(bKeyEnable&&bEntryHasText&&m_bIsPhoneticReadingEnabled);
815  m_xPhoneticED0->set_sensitive(bKeyEnable&&bEntryHasText&&m_bIsPhoneticReadingEnabled);
816  m_xPhoneticFT1->set_sensitive(bKeyEnable&&bKey1HasText&&m_bIsPhoneticReadingEnabled);
817  m_xPhoneticED1->set_sensitive(bKeyEnable&&bKey1HasText&&m_bIsPhoneticReadingEnabled);
818  m_xPhoneticFT2->set_sensitive(bKeyEnable&&bKey2HasText&&m_bIsPhoneticReadingEnabled);
819  m_xPhoneticED2->set_sensitive(bKeyEnable&&bKey2HasText&&m_bIsPhoneticReadingEnabled);
820 
821  // set index type
822  m_xTypeDCB->set_active_text(pMark->GetTOXType()->GetTypeName());
823 
824  // set Next - Prev - Buttons
825  m_pSh->SttCursorMove();
826  if( m_xPrevBT->get_visible() )
827  {
828  const SwTOXMark* pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_PRV );
829  if( pMoveMark != pMark )
830  m_pSh->GotoTOXMark( *pMoveMark, TOX_NXT );
831  m_xPrevBT->set_sensitive( pMoveMark != pMark );
832  pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_NXT );
833  if( pMoveMark != pMark )
834  m_pSh->GotoTOXMark( *pMoveMark, TOX_PRV );
835  m_xNextBT->set_sensitive( pMoveMark != pMark );
836  }
837 
838  if (m_xPrevSameBT->get_visible())
839  {
840  const SwTOXMark* pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_SAME_PRV );
841  if( pMoveMark != pMark )
842  m_pSh->GotoTOXMark( *pMoveMark, TOX_SAME_NXT );
843  m_xPrevSameBT->set_sensitive( pMoveMark != pMark );
844  pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_SAME_NXT );
845  if( pMoveMark != pMark )
846  m_pSh->GotoTOXMark( *pMoveMark, TOX_SAME_PRV );
847  m_xNextSameBT->set_sensitive( pMoveMark != pMark );
848  }
849 
850  const bool bEnable = !m_pSh->HasReadonlySel();
851  m_xOKBT->set_sensitive(bEnable);
852  m_xDelBT->set_sensitive(bEnable);
853  m_xEntryED->set_sensitive(bEnable);
854  m_xLevelNF->set_sensitive(bEnable);
855  m_xKey1DCB->set_sensitive(bEnable);
856  m_xKey2DCB->set_sensitive(bEnable);
857 
859  // we need the point at the start of the attribute
860  m_pSh->SwapPam();
861 
862  m_pSh->EndCursorMove();
863 }
864 
865 // Remind whether the edit boxes for Phonetic reading are changed manually
866 IMPL_LINK(SwIndexMarkPane, PhoneticEDModifyHdl, weld::Entry&, rEdit, void)
867 {
868  if (m_xPhoneticED0.get() == &rEdit)
869  {
870  m_bPhoneticED0_ChangedByUser = !rEdit.get_text().isEmpty();
871  }
872  else if (m_xPhoneticED1.get() == &rEdit)
873  {
874  m_bPhoneticED1_ChangedByUser = !rEdit.get_text().isEmpty();
875  }
876  else if (m_xPhoneticED2.get() == &rEdit)
877  {
878  m_bPhoneticED2_ChangedByUser = !rEdit.get_text().isEmpty();
879  }
880 }
881 
882 // Enable Disable of the 2nd key
883 IMPL_LINK( SwIndexMarkPane, KeyDCBModifyHdl, weld::ComboBox&, rBox, void )
884 {
885  if (m_xKey1DCB.get() == &rBox)
886  {
887  bool bEnable = !rBox.get_active_text().isEmpty();
888  if(!bEnable)
889  {
890  m_xKey2DCB->set_entry_text(OUString());
891  m_xPhoneticED1->set_text(OUString());
892  m_xPhoneticED2->set_text(OUString());
893  m_bPhoneticED1_ChangedByUser = false;
894  m_bPhoneticED2_ChangedByUser = false;
895  }
896  else
897  {
898  if (rBox.get_popup_shown())
899  {
900  //reset bPhoneticED1_ChangedByUser if a completely new string is selected
901  m_bPhoneticED1_ChangedByUser = false;
902  }
903  if (!m_bPhoneticED1_ChangedByUser)
904  m_xPhoneticED1->set_text(GetDefaultPhoneticReading(rBox.get_active_text()));
905  }
906  m_xKey2DCB->set_sensitive(bEnable);
907  m_xKey2FT->set_sensitive(bEnable);
908  }
909  else if (m_xKey2DCB.get() == &rBox)
910  {
911  if (rBox.get_active_text().isEmpty())
912  {
913  m_xPhoneticED2->set_text(OUString());
914  m_bPhoneticED2_ChangedByUser = false;
915  }
916  else
917  {
918  if (rBox.get_popup_shown())
919  {
920  //reset bPhoneticED1_ChangedByUser if a completely new string is selected
921  m_bPhoneticED2_ChangedByUser = false;
922  }
923  if(!m_bPhoneticED2_ChangedByUser)
924  m_xPhoneticED2->set_text(GetDefaultPhoneticReading(rBox.get_active_text()));
925  }
926  }
927 
928  bool bKey1HasText = !m_xKey1DCB->get_active_text().isEmpty();
929  bool bKey2HasText = !m_xKey2DCB->get_active_text().isEmpty();
930 
931  m_xPhoneticFT1->set_sensitive(bKey1HasText && m_bIsPhoneticReadingEnabled);
932  m_xPhoneticED1->set_sensitive(bKey1HasText && m_bIsPhoneticReadingEnabled);
933  m_xPhoneticFT2->set_sensitive(bKey2HasText && m_bIsPhoneticReadingEnabled);
934  m_xPhoneticED2->set_sensitive(bKey2HasText && m_bIsPhoneticReadingEnabled);
935 }
936 
938 {
939 }
940 
941 void SwIndexMarkPane::ReInitDlg(SwWrtShell& rWrtShell, SwTOXMark const * pCurTOXMark)
942 {
943  m_pSh = &rWrtShell;
944  m_pTOXMgr.reset( new SwTOXMgr(m_pSh) );
945  if(pCurTOXMark)
946  {
947  for(sal_uInt16 i = 0; i < m_pTOXMgr->GetTOXMarkCount(); i++)
948  if(m_pTOXMgr->GetTOXMark(i) == pCurTOXMark)
949  {
950  m_pTOXMgr->SetCurTOXMark(i);
951  break;
952  }
953  }
954  InitControls();
955 }
956 
958  SfxChildWindow* pChild, weld::Window *pParent,
959  SfxChildWinInfo const * pInfo, bool bNew)
960  : SfxModelessDialogController(_pBindings, pChild, pParent,
961  "modules/swriter/ui/indexentry.ui", "IndexEntryDialog")
962  , m_aContent(m_xDialog, *m_xBuilder, bNew, ::GetActiveWrtShell())
963 {
964  if (SwWrtShell* pWrtShell = ::GetActiveWrtShell())
965  m_aContent.ReInitDlg(*pWrtShell);
966  Initialize(pInfo);
967 }
968 
970 {
973 }
974 
976 {
977  m_aContent.ReInitDlg( rWrtShell );
978 }
979 
981  : SfxDialogController(pParent, "modules/swriter/ui/indexentry.ui",
982  "IndexEntryDialog")
983  , m_aContent(m_xDialog, *m_xBuilder, false, &rSh)
984 {
985  m_aContent.ReInitDlg(rSh, pCurTOXMark);
986 }
987 
989 {
991 }
992 
994 {
995  short nRet = SfxDialogController::run();
996  if (RET_OK == nRet)
997  m_aContent.Apply();
998  return nRet;
999 }
1000 
1001 namespace {
1002 
1003 class SwCreateAuthEntryDlg_Impl : public weld::GenericDialogController
1004 {
1005  std::vector<std::unique_ptr<weld::Builder>> m_aBuilders;
1006 
1007  Link<weld::Entry&,bool> aShortNameCheckLink;
1008 
1009  SwWrtShell& rWrtSh;
1010 
1011  bool m_bNewEntryMode;
1012  bool m_bNameAllowed;
1013 
1014  std::vector<std::unique_ptr<weld::Container>> m_aOrigContainers;
1015  std::vector<std::unique_ptr<weld::Label>> m_aFixedTexts;
1016  std::unique_ptr<weld::Entry> pEdits[AUTH_FIELD_END];
1017  std::unique_ptr<weld::Button> m_xOKBT;
1018  std::unique_ptr<weld::Container> m_xBox;
1019  std::unique_ptr<weld::Container> m_xLeft;
1020  std::unique_ptr<weld::Container> m_xRight;
1021  std::unique_ptr<weld::ComboBox> m_xTypeListBox;
1022  std::unique_ptr<weld::ComboBox> m_xIdentifierBox;
1023 
1024  DECL_LINK(IdentifierHdl, weld::ComboBox&, void);
1025  DECL_LINK(ShortNameHdl, weld::Entry&, void);
1026  DECL_LINK(EnableHdl, weld::ComboBox&, void);
1027 
1028 public:
1029  SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
1030  const OUString pFields[],
1031  SwWrtShell& rSh,
1032  bool bNewEntry,
1033  bool bCreate);
1034 
1035  OUString GetEntryText(ToxAuthorityField eField) const;
1036 
1037  void SetCheckNameHdl(const Link<weld::Entry&,bool>& rLink) {aShortNameCheckLink = rLink;}
1038 
1039 };
1040 
1041 struct TextInfo
1042 {
1043  ToxAuthorityField nToxField;
1044  const char* pHelpId;
1045 };
1046 
1047 }
1048 
1049 const TextInfo aTextInfoArr[] =
1050 {
1082 };
1083 
1084 static OUString lcl_FindColumnEntry(const uno::Sequence<beans::PropertyValue>& rFields, std::u16string_view rColumnTitle)
1085 {
1086  for(const auto& rField : rFields)
1087  {
1088  OUString sRet;
1089  if(rField.Name == rColumnTitle &&
1090  (rField.Value >>= sRet))
1091  {
1092  return sRet;
1093  }
1094  }
1095  return OUString();
1096 }
1097 
1099 
1101  : m_rDialog(rDialog)
1102  , bNewEntry(bNewDlg)
1103  , bBibAccessInitialized(false)
1104  , pSh(nullptr)
1105  , m_xFromComponentRB(rBuilder.weld_radio_button("frombibliography"))
1106  , m_xFromDocContentRB(rBuilder.weld_radio_button("fromdocument"))
1107  , m_xAuthorFI(rBuilder.weld_label("author"))
1108  , m_xTitleFI(rBuilder.weld_label("title"))
1109  , m_xEntryED(rBuilder.weld_entry("entryed"))
1110  , m_xEntryLB(rBuilder.weld_combo_box("entrylb"))
1111  , m_xActionBT(rBuilder.weld_button(bNewEntry ? OString("insert") : OString("modify")))
1112  , m_xCloseBT(rBuilder.weld_button("close"))
1113  , m_xCreateEntryPB(rBuilder.weld_button("new"))
1114  , m_xEditEntryPB(rBuilder.weld_button("edit"))
1115 {
1116  m_xActionBT->show();
1117  m_xFromComponentRB->set_visible(bNewEntry);
1118  m_xFromDocContentRB->set_visible(bNewEntry);
1119  m_xFromComponentRB->set_active(bIsFromComponent);
1120  m_xFromDocContentRB->set_active(!bIsFromComponent);
1121 
1122  m_xActionBT->connect_clicked(LINK(this,SwAuthorMarkPane, InsertHdl));
1123  m_xCloseBT->connect_clicked(LINK(this,SwAuthorMarkPane, CloseHdl));
1124  m_xCreateEntryPB->connect_clicked(LINK(this,SwAuthorMarkPane, CreateEntryHdl));
1125  m_xEditEntryPB->connect_clicked(LINK(this,SwAuthorMarkPane, CreateEntryHdl));
1126  m_xFromComponentRB->connect_toggled(LINK(this,SwAuthorMarkPane, ChangeSourceHdl));
1127  m_xFromDocContentRB->connect_toggled(LINK(this,SwAuthorMarkPane, ChangeSourceHdl));
1128  m_xEntryED->connect_changed(LINK(this,SwAuthorMarkPane, EditModifyHdl));
1129 
1131  bNewEntry ? STR_AUTHMRK_INSERT : STR_AUTHMRK_EDIT));
1132 
1133  m_xEntryED->set_visible(!bNewEntry);
1134  m_xEntryLB->set_visible(bNewEntry);
1135  if (bNewEntry)
1136  {
1137  m_xEntryLB->connect_changed(LINK(this, SwAuthorMarkPane, CompEntryHdl));
1138  }
1139 }
1140 
1142 {
1143  pSh = &rWrtShell;
1144  InitControls();
1145 }
1146 
1148 {
1149  if(bNewEntry)
1150  {
1152  SfxCallMode::ASYNCHRON|SfxCallMode::RECORD);
1153  }
1154  else
1155  {
1156  m_rDialog.response(RET_CANCEL);
1157  }
1158 }
1159 
1160 IMPL_LINK( SwAuthorMarkPane, CompEntryHdl, weld::ComboBox&, rBox, void)
1161 {
1162  const OUString sEntry(rBox.get_active_text());
1163  if(bIsFromComponent)
1164  {
1165  if(xBibAccess.is() && !sEntry.isEmpty())
1166  {
1167  if(xBibAccess->hasByName(sEntry))
1168  {
1169  uno::Any aEntry(xBibAccess->getByName(sEntry));
1170  uno::Sequence<beans::PropertyValue> aFieldProps;
1171  if(aEntry >>= aFieldProps)
1172  {
1173  auto nSize = std::min(static_cast<sal_Int32>(AUTH_FIELD_END), aFieldProps.getLength());
1174  for(sal_Int32 i = 0; i < nSize; i++)
1175  {
1176  m_sFields[i] = lcl_FindColumnEntry(aFieldProps, m_sColumnTitles[i]);
1177  }
1178  }
1179  }
1180  }
1181  }
1182  else
1183  {
1184  if(!sEntry.isEmpty())
1185  {
1186  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1187  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1188  const SwAuthEntry* pEntry = pFType ? pFType->GetEntryByIdentifier(sEntry) : nullptr;
1189  for(int i = 0; i < AUTH_FIELD_END; i++)
1190  m_sFields[i] = pEntry ?
1191  pEntry->GetAuthorField(static_cast<ToxAuthorityField>(i)) : OUString();
1192  }
1193  }
1194  if (rBox.get_active_text().isEmpty())
1195  {
1196  for(OUString & s : m_sFields)
1197  s.clear();
1198  }
1199  m_xAuthorFI->set_label(m_sFields[AUTH_FIELD_AUTHOR]);
1200  m_xTitleFI->set_label(m_sFields[AUTH_FIELD_TITLE]);
1201 }
1202 
1204 {
1205  //insert or update the SwAuthorityField...
1206  if(pSh)
1207  {
1208  bool bDifferent = false;
1209  OSL_ENSURE(!m_sFields[AUTH_FIELD_IDENTIFIER].isEmpty() , "No Id is set!");
1210  OSL_ENSURE(!m_sFields[AUTH_FIELD_AUTHORITY_TYPE].isEmpty() , "No authority type is set!");
1211  //check if the entry already exists with different content
1212  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1213  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1214  const SwAuthEntry* pEntry = pFType ?
1215  pFType->GetEntryByIdentifier( m_sFields[AUTH_FIELD_IDENTIFIER])
1216  : nullptr;
1217  if(pEntry)
1218  {
1219  for(int i = 0; i < AUTH_FIELD_END && !bDifferent; i++)
1220  bDifferent |= m_sFields[i] != pEntry->GetAuthorField(static_cast<ToxAuthorityField>(i));
1221  if(bDifferent)
1222  {
1223  std::unique_ptr<weld::MessageDialog> xQuery(Application::CreateMessageDialog(m_rDialog.getDialog(),
1224  VclMessageType::Question, VclButtonsType::YesNo,
1225  SwResId(STR_QUERY_CHANGE_AUTH_ENTRY)));
1226  if (RET_YES != xQuery->run())
1227  return;
1228  }
1229  }
1230 
1231  SwFieldMgr aMgr(pSh);
1232  OUStringBuffer sFields;
1233  for(OUString & s : m_sFields)
1234  {
1235  sFields.append(s).append(TOX_STYLE_DELIMITER);
1236  }
1237  if(bNewEntry)
1238  {
1239  if(bDifferent)
1240  {
1242  for(int i = 0; i < AUTH_FIELD_END; i++)
1243  xNewData->SetAuthorField(static_cast<ToxAuthorityField>(i), m_sFields[i]);
1244  pSh->ChangeAuthorityData(xNewData.get());
1245  }
1246  SwInsertField_Data aData(SwFieldTypesEnum::Authority, 0, sFields.makeStringAndClear(), OUString(), 0 );
1247  aMgr.InsertField( aData );
1248  }
1249  else if(aMgr.GetCurField())
1250  {
1251  aMgr.UpdateCurField(0, sFields.makeStringAndClear(), OUString());
1252  }
1253  }
1254  if(!bNewEntry)
1255  CloseHdl(*m_xCloseBT);
1256 }
1257 
1258 IMPL_LINK(SwAuthorMarkPane, CreateEntryHdl, weld::Button&, rButton, void)
1259 {
1260  bool bCreate = &rButton == m_xCreateEntryPB.get();
1261  OUString sOldId = m_sCreatedEntry[0];
1262  for(int i = 0; i < AUTH_FIELD_END; i++)
1263  m_sCreatedEntry[i] = bCreate ? OUString() : m_sFields[i];
1264  SwCreateAuthEntryDlg_Impl aDlg(m_rDialog.getDialog(),
1265  bCreate ? m_sCreatedEntry : m_sFields,
1266  *pSh, bNewEntry, bCreate);
1267  if(bNewEntry)
1268  {
1269  aDlg.SetCheckNameHdl(LINK(this, SwAuthorMarkPane, IsEntryAllowedHdl));
1270  }
1271  if(RET_OK != aDlg.run())
1272  return;
1273 
1274  if(bCreate && !sOldId.isEmpty())
1275  {
1276  m_xEntryLB->remove_text(sOldId);
1277  }
1278  for(int i = 0; i < AUTH_FIELD_END; i++)
1279  {
1280  m_sFields[i] = aDlg.GetEntryText(static_cast<ToxAuthorityField>(i));
1281  m_sCreatedEntry[i] = m_sFields[i];
1282  }
1283  if(bNewEntry && !m_xFromDocContentRB->get_active())
1284  {
1285  m_xFromDocContentRB->set_active(true);
1286  ChangeSourceHdl(*m_xFromDocContentRB);
1287  }
1288  if(bCreate)
1289  {
1290  OSL_ENSURE(m_xEntryLB->find_text(m_sFields[AUTH_FIELD_IDENTIFIER]) == -1,
1291  "entry exists!");
1292  m_xEntryLB->append_text(m_sFields[AUTH_FIELD_IDENTIFIER]);
1293  m_xEntryLB->set_active_text(m_sFields[AUTH_FIELD_IDENTIFIER]);
1294  }
1295  m_xEntryED->set_text(m_sFields[AUTH_FIELD_IDENTIFIER]);
1296  m_xAuthorFI->set_label(m_sFields[AUTH_FIELD_AUTHOR]);
1297  m_xTitleFI->set_label(m_sFields[AUTH_FIELD_TITLE]);
1298  m_xActionBT->set_sensitive(true);
1299 }
1300 
1302 {
1303  bool bFromComp = m_xFromComponentRB->get_active();
1304  bIsFromComponent = bFromComp;
1305  m_xCreateEntryPB->set_sensitive(!bIsFromComponent);
1306  m_xEntryLB->clear();
1307  if(bIsFromComponent)
1308  {
1309  if(!bBibAccessInitialized)
1310  {
1311  uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext();
1312  xBibAccess = frame::Bibliography::create( xContext );
1313  uno::Reference< beans::XPropertySet > xPropSet(xBibAccess, uno::UNO_QUERY);
1314  OUString uPropName("BibliographyDataFieldNames");
1315  if(xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName(uPropName))
1316  {
1317  uno::Any aNames = xPropSet->getPropertyValue(uPropName);
1318  uno::Sequence<beans::PropertyValue> aSeq;
1319  if( aNames >>= aSeq)
1320  {
1321  for(const beans::PropertyValue& rProp : std::as_const(aSeq))
1322  {
1323  sal_Int16 nField = 0;
1324  rProp.Value >>= nField;
1325  if(nField >= 0 && nField < AUTH_FIELD_END)
1326  m_sColumnTitles[nField] = rProp.Name;
1327  }
1328  }
1329  }
1330  bBibAccessInitialized = true;
1331  }
1332  if(xBibAccess.is())
1333  {
1334  const uno::Sequence<OUString> aIdentifiers = xBibAccess->getElementNames();
1335  for(const OUString& rName : aIdentifiers)
1336  m_xEntryLB->append_text(rName);
1337  }
1338  }
1339  else
1340  {
1341  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1342  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1343  if(pFType)
1344  {
1345  std::vector<OUString> aIds;
1346  pFType->GetAllEntryIdentifiers( aIds );
1347  for(const OUString & i : aIds)
1348  m_xEntryLB->append_text(i);
1349  }
1350  if(!m_sCreatedEntry[AUTH_FIELD_IDENTIFIER].isEmpty())
1351  m_xEntryLB->append_text(m_sCreatedEntry[AUTH_FIELD_IDENTIFIER]);
1352  }
1353  m_xEntryLB->set_active(0);
1354  CompEntryHdl(*m_xEntryLB);
1355 }
1356 
1357 IMPL_LINK(SwAuthorMarkPane, EditModifyHdl, weld::Entry&, rEdit, void)
1358 {
1359  Link<weld::Entry&,bool> aAllowed = LINK(this, SwAuthorMarkPane, IsEditAllowedHdl);
1360  bool bResult = aAllowed.Call(rEdit);
1361  m_xActionBT->set_sensitive(bResult);
1362  if(bResult)
1363  {
1364  OUString sEntry(rEdit.get_text());
1365  m_sFields[AUTH_FIELD_IDENTIFIER] = sEntry;
1366  m_sCreatedEntry[AUTH_FIELD_IDENTIFIER] = sEntry;
1367  }
1368 };
1369 
1370 IMPL_LINK(SwAuthorMarkPane, IsEntryAllowedHdl, weld::Entry&, rEdit, bool)
1371 {
1372  OUString sEntry = rEdit.get_text();
1373  bool bAllowed = false;
1374  if(!sEntry.isEmpty())
1375  {
1376  if (m_xEntryLB->find_text(sEntry) != -1)
1377  return false;
1378  else if(bIsFromComponent)
1379  {
1380  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1381  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1382  bAllowed = !pFType || !pFType->GetEntryByIdentifier(sEntry);
1383  }
1384  else
1385  {
1386  bAllowed = !xBibAccess.is() || !xBibAccess->hasByName(sEntry);
1387  }
1388  }
1389  return bAllowed;
1390 }
1391 
1392 IMPL_LINK(SwAuthorMarkPane, IsEditAllowedHdl, weld::Entry&, rEdit, bool)
1393 {
1394  OUString sEntry = rEdit.get_text();
1395  bool bAllowed = false;
1396  if(!sEntry.isEmpty())
1397  {
1398  if (m_xEntryLB->find_text(sEntry) != -1)
1399  return false;
1400  else if(bIsFromComponent)
1401  {
1402  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1403  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1404  bAllowed = !pFType || !pFType->GetEntryByIdentifier(sEntry);
1405  }
1406  else
1407  {
1408  bAllowed = !xBibAccess.is() || !xBibAccess->hasByName(sEntry);
1409  }
1410  }
1411  return bAllowed;
1412 }
1413 
1415 {
1416  OSL_ENSURE(pSh, "no shell?");
1417  SwField* pField = pSh->GetCurField();
1418  OSL_ENSURE(bNewEntry || pField, "no current marker");
1419  if(bNewEntry)
1420  {
1421  ChangeSourceHdl(m_xFromComponentRB->get_active() ? *m_xFromComponentRB : *m_xFromDocContentRB);
1422  m_xCreateEntryPB->set_sensitive(!m_xFromComponentRB->get_active());
1423  if(!m_xFromComponentRB->get_active() && !m_sCreatedEntry[0].isEmpty())
1424  for(int i = 0; i < AUTH_FIELD_END; i++)
1426  }
1427  if(bNewEntry || !pField || pField->GetTyp()->Which() != SwFieldIds::TableOfAuthorities)
1428  return;
1429 
1430  const SwAuthEntry* pEntry = static_cast<SwAuthorityField*>(pField)->GetAuthEntry();
1431 
1432  OSL_ENSURE(pEntry, "No authority entry found");
1433  if(!pEntry)
1434  return;
1435  for(int i = 0; i < AUTH_FIELD_END; i++)
1436  m_sFields[i] = pEntry->GetAuthorField(static_cast<ToxAuthorityField>(i));
1437 
1438  m_xEntryED->set_text(pEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER));
1439  m_xAuthorFI->set_label(pEntry->GetAuthorField(AUTH_FIELD_AUTHOR));
1440  m_xTitleFI->set_label(pEntry->GetAuthorField(AUTH_FIELD_TITLE));
1441 }
1442 
1444 {
1445  m_xActionBT->set_sensitive(!pSh->HasReadonlySel());
1446 }
1447 
1448 namespace
1449 {
1450  const char* STR_AUTH_FIELD_ARY[] =
1451  {
1452  STR_AUTH_FIELD_IDENTIFIER,
1453  STR_AUTH_FIELD_AUTHORITY_TYPE,
1454  STR_AUTH_FIELD_ADDRESS,
1455  STR_AUTH_FIELD_ANNOTE,
1456  STR_AUTH_FIELD_AUTHOR,
1457  STR_AUTH_FIELD_BOOKTITLE,
1458  STR_AUTH_FIELD_CHAPTER,
1459  STR_AUTH_FIELD_EDITION,
1460  STR_AUTH_FIELD_EDITOR,
1461  STR_AUTH_FIELD_HOWPUBLISHED,
1462  STR_AUTH_FIELD_INSTITUTION,
1463  STR_AUTH_FIELD_JOURNAL,
1464  STR_AUTH_FIELD_MONTH,
1465  STR_AUTH_FIELD_NOTE,
1466  STR_AUTH_FIELD_NUMBER,
1467  STR_AUTH_FIELD_ORGANIZATIONS,
1468  STR_AUTH_FIELD_PAGES,
1469  STR_AUTH_FIELD_PUBLISHER,
1470  STR_AUTH_FIELD_SCHOOL,
1471  STR_AUTH_FIELD_SERIES,
1472  STR_AUTH_FIELD_TITLE,
1473  STR_AUTH_FIELD_TYPE,
1474  STR_AUTH_FIELD_VOLUME,
1475  STR_AUTH_FIELD_YEAR,
1476  STR_AUTH_FIELD_URL,
1477  STR_AUTH_FIELD_CUSTOM1,
1478  STR_AUTH_FIELD_CUSTOM2,
1479  STR_AUTH_FIELD_CUSTOM3,
1480  STR_AUTH_FIELD_CUSTOM4,
1481  STR_AUTH_FIELD_CUSTOM5,
1482  STR_AUTH_FIELD_ISBN
1483  };
1484 }
1485 
1486 SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
1487  const OUString pFields[],
1488  SwWrtShell& rSh,
1489  bool bNewEntry,
1490  bool bCreate)
1491  : GenericDialogController(pParent, "modules/swriter/ui/createauthorentry.ui", "CreateAuthorEntryDialog")
1492  , rWrtSh(rSh)
1493  , m_bNewEntryMode(bNewEntry)
1494  , m_bNameAllowed(true)
1495  , m_xOKBT(m_xBuilder->weld_button("ok"))
1496  , m_xBox(m_xBuilder->weld_container("box"))
1497  , m_xLeft(m_xBuilder->weld_container("leftgrid"))
1498  , m_xRight(m_xBuilder->weld_container("rightgrid"))
1499 {
1500  bool bLeft = true;
1501  sal_Int32 nLeftRow(0), nRightRow(0);
1502  for(int nIndex = 0; nIndex < AUTH_FIELD_END; nIndex++)
1503  {
1504  //m_xBox parent just to have some parent during setup, added contents are not directly visible under m_xBox
1505  m_aBuilders.emplace_back(Application::CreateBuilder(m_xBox.get(), "modules/swriter/ui/bibliofragment.ui"));
1506  const TextInfo aCurInfo = aTextInfoArr[nIndex];
1507 
1508  m_aOrigContainers.emplace_back(m_aBuilders.back()->weld_container("biblioentry"));
1509  m_aFixedTexts.emplace_back(m_aBuilders.back()->weld_label("label"));
1510  if (bLeft)
1511  m_aOrigContainers.back()->move(m_aFixedTexts.back().get(), m_xLeft.get());
1512  else
1513  m_aOrigContainers.back()->move(m_aFixedTexts.back().get(), m_xRight.get());
1514  m_aFixedTexts.back()->set_grid_left_attach(0);
1515  m_aFixedTexts.back()->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
1516  m_aFixedTexts.back()->set_label(SwResId(STR_AUTH_FIELD_ARY[aCurInfo.nToxField]));
1517  m_aFixedTexts.back()->show();
1518  if( AUTH_FIELD_AUTHORITY_TYPE == aCurInfo.nToxField )
1519  {
1520  m_xTypeListBox = m_aBuilders.back()->weld_combo_box("listbox");
1521  if (bLeft)
1522  m_aOrigContainers.back()->move(m_xTypeListBox.get(), m_xLeft.get());
1523  else
1524  m_aOrigContainers.back()->move(m_xTypeListBox.get(), m_xRight.get());
1525 
1526  for (int j = 0; j < AUTH_TYPE_END; j++)
1527  m_xTypeListBox->append_text(SwAuthorityFieldType::GetAuthTypeName(static_cast<ToxAuthorityType>(j)));
1528  if(!pFields[aCurInfo.nToxField].isEmpty())
1529  {
1530  m_xTypeListBox->set_active(pFields[aCurInfo.nToxField].toInt32());
1531  }
1532  m_xTypeListBox->set_grid_left_attach(1);
1533  m_xTypeListBox->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
1534  m_xTypeListBox->set_hexpand(true);
1535  m_xTypeListBox->show();
1536  m_xTypeListBox->connect_changed(LINK(this, SwCreateAuthEntryDlg_Impl, EnableHdl));
1537  m_xTypeListBox->set_help_id(aCurInfo.pHelpId);
1538  m_aFixedTexts.back()->set_mnemonic_widget(m_xTypeListBox.get());
1539  }
1540  else if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField && !m_bNewEntryMode)
1541  {
1542  m_xIdentifierBox = m_aBuilders.back()->weld_combo_box("combobox");
1543  if (bLeft)
1544  m_aOrigContainers.back()->move(m_xIdentifierBox.get(), m_xLeft.get());
1545  else
1546  m_aOrigContainers.back()->move(m_xIdentifierBox.get(), m_xRight.get());
1547 
1548  m_xIdentifierBox->connect_changed(LINK(this,
1549  SwCreateAuthEntryDlg_Impl, IdentifierHdl));
1550 
1551  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1552  rSh.GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1553  if(pFType)
1554  {
1555  std::vector<OUString> aIds;
1556  pFType->GetAllEntryIdentifiers( aIds );
1557  for (const OUString& a : aIds)
1558  m_xIdentifierBox->append_text(a);
1559  }
1560  m_xIdentifierBox->set_entry_text(pFields[aCurInfo.nToxField]);
1561  m_xIdentifierBox->set_grid_left_attach(1);
1562  m_xIdentifierBox->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
1563  m_xIdentifierBox->set_hexpand(true);
1564  m_xIdentifierBox->show();
1565  m_xIdentifierBox->set_help_id(aCurInfo.pHelpId);
1566  m_aFixedTexts.back()->set_mnemonic_widget(m_xIdentifierBox.get());
1567  }
1568  else
1569  {
1570  pEdits[nIndex] = m_aBuilders.back()->weld_entry("entry");
1571  if (bLeft)
1572  m_aOrigContainers.back()->move(pEdits[nIndex].get(), m_xLeft.get());
1573  else
1574  m_aOrigContainers.back()->move(pEdits[nIndex].get(), m_xRight.get());
1575 
1576  pEdits[nIndex]->set_grid_left_attach(1);
1577  pEdits[nIndex]->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
1578  pEdits[nIndex]->set_hexpand(true);
1579  pEdits[nIndex]->set_text(pFields[aCurInfo.nToxField]);
1580  pEdits[nIndex]->show();
1581  pEdits[nIndex]->set_help_id(aCurInfo.pHelpId);
1582  if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField)
1583  {
1584  pEdits[nIndex]->connect_changed(LINK(this, SwCreateAuthEntryDlg_Impl, ShortNameHdl));
1585  m_bNameAllowed = !pFields[nIndex].isEmpty();
1586  if(!bCreate)
1587  {
1588  m_aFixedTexts.back()->set_sensitive(false);
1589  pEdits[nIndex]->set_sensitive(false);
1590  }
1591  }
1592  m_aFixedTexts.back()->set_mnemonic_widget(pEdits[nIndex].get());
1593  }
1594  if(bLeft)
1595  ++nLeftRow;
1596  else
1597  ++nRightRow;
1598  bLeft = !bLeft;
1599  }
1600  EnableHdl(*m_xTypeListBox);
1601 }
1602 
1603 OUString SwCreateAuthEntryDlg_Impl::GetEntryText(ToxAuthorityField eField) const
1604 {
1605  if( AUTH_FIELD_AUTHORITY_TYPE == eField )
1606  {
1607  OSL_ENSURE(m_xTypeListBox, "No ListBox");
1608  return OUString::number(m_xTypeListBox->get_active());
1609  }
1610 
1611  if( AUTH_FIELD_IDENTIFIER == eField && !m_bNewEntryMode)
1612  {
1613  OSL_ENSURE(m_xIdentifierBox, "No ComboBox");
1614  return m_xIdentifierBox->get_active_text();
1615  }
1616 
1617  for(int nIndex = 0; nIndex < AUTH_FIELD_END; nIndex++)
1618  {
1619  const TextInfo aCurInfo = aTextInfoArr[nIndex];
1620  if(aCurInfo.nToxField == eField)
1621  {
1622  return pEdits[nIndex]->get_text();
1623  }
1624  }
1625 
1626  return OUString();
1627 }
1628 
1629 IMPL_LINK(SwCreateAuthEntryDlg_Impl, IdentifierHdl, weld::ComboBox&, rBox, void)
1630 {
1631  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1632  rWrtSh.GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1633  if(!pFType)
1634  return;
1635 
1636  const SwAuthEntry* pEntry = pFType->GetEntryByIdentifier(
1637  rBox.get_active_text());
1638  if(!pEntry)
1639  return;
1640 
1641  for(int i = 0; i < AUTH_FIELD_END; i++)
1642  {
1643  const TextInfo aCurInfo = aTextInfoArr[i];
1644  if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField)
1645  continue;
1646  if(AUTH_FIELD_AUTHORITY_TYPE == aCurInfo.nToxField)
1647  m_xTypeListBox->set_active_text(
1648  pEntry->GetAuthorField(aCurInfo.nToxField));
1649  else
1650  pEdits[i]->set_text(
1651  pEntry->GetAuthorField(aCurInfo.nToxField));
1652  }
1653 }
1654 
1655 IMPL_LINK(SwCreateAuthEntryDlg_Impl, ShortNameHdl, weld::Entry&, rEdit, void)
1656 {
1657  if (aShortNameCheckLink.IsSet())
1658  {
1659  bool bEnable = aShortNameCheckLink.Call(rEdit);
1660  m_bNameAllowed |= bEnable;
1661  m_xOKBT->set_sensitive(m_xTypeListBox->get_active() != -1 && bEnable);
1662  }
1663 }
1664 
1665 IMPL_LINK(SwCreateAuthEntryDlg_Impl, EnableHdl, weld::ComboBox&, rBox, void)
1666 {
1667  m_xOKBT->set_sensitive(m_bNameAllowed && rBox.get_active() != -1);
1668 };
1669 
1671  SfxChildWindow* pChild,
1672  weld::Window *pParent,
1673  SfxChildWinInfo const * pInfo,
1674  bool bNew)
1675  : SfxModelessDialogController(_pBindings, pChild, pParent,
1676  "modules/swriter/ui/bibliographyentry.ui", "BibliographyEntryDialog")
1677  , m_aContent(*this, *m_xBuilder, bNew)
1678 {
1679  Initialize(pInfo);
1680  if (SwWrtShell* pWrtShell = ::GetActiveWrtShell())
1681  m_aContent.ReInitDlg(*pWrtShell);
1682 }
1683 
1685 {
1687  m_aContent.Activate();
1688 }
1689 
1691 {
1692  m_aContent.ReInitDlg( rWrtShell );
1693 }
1694 
1696  : SfxDialogController(pParent, "modules/swriter/ui/bibliographyentry.ui",
1697  "BibliographyEntryDialog")
1698  , m_aContent(*this, *m_xBuilder, false)
1699 {
1700  m_aContent.ReInitDlg(rSh);
1701 }
1702 
1704 {
1705  short ret = SfxDialogController::run();
1706  if (ret == RET_OK)
1707  Apply();
1708  return ret;
1709 }
1710 
1712 {
1713  m_aContent.InsertHdl(*m_aContent.m_xActionBT);
1714 }
1715 
1716 /* 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:666
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:3445
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:642
#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:975
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:289
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:398
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1715
#define TOX_STYLE_DELIMITER
Definition: tox.hxx:425
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:1524
std::unique_ptr< weld::Label > m_xPhoneticFT1
Definition: swuiidxmrk.hxx:71
SwAuthMarkFloatDlg(SfxBindings *pBindings, SfxChildWindow *pChild, weld::Window *pParent, SfxChildWinInfo const *pInfo, bool bNew)
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
virtual short int run() override
Definition: swuiidxmrk.cxx:993
#define FN_INSERT_AUTH_ENTRY_DLG
Definition: cmdid.h:282
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:580
void Invalidate(sal_uInt16 nId)
bool InsertField(const SwInsertField_Data &rData)
Definition: fldmgr.cxx:890
#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:975
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
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:660
tools::Long ResetSelect(const Point *, bool)
Definition: select.cxx:332
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:301
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
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
#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:904
static OUString lcl_FindColumnEntry(const uno::Sequence< beans::PropertyValue > &rFields, std::u16string_view rColumnTitle)
int nCount
eField
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:431
void SetPhoneticReadingOfPrimKey(const OUString &rSet)
Definition: toxmgr.hxx:219
SwIndexMarkModalDlg(weld::Window *pParent, SwWrtShell &rSh, SwTOXMark const *pCurTOXMark)
Definition: swuiidxmrk.cxx:980
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:310
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:612
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
SvtScriptType GetScriptType() const
returns the script type of the selection
Definition: edattr.cxx:673
bool HasSelection() const
Definition: wrtsh.hxx:141
SwAuthEntry * GetEntryByIdentifier(std::u16string_view rIdentifier) const
Definition: authfld.cxx:135
int i
const char last[]
#define FN_INSERT_IDX_ENTRY_DLG
Definition: cmdid.h:219
#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:941
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2237
#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:636
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:192
SwField * GetCurField()
Definition: fldmgr.cxx:425
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:27
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:698
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:2723
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:165
#define HID_AUTH_FIELD_URL
Definition: helpids.h:93
static sal_Int32 nTypePos
Definition: swuiidxmrk.cxx:56
bool HasReadonlySel() const
Definition: crsrsh.cxx:3336
#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:654
#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:392
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:735
#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:2552
::ucbhelper::Content m_aContent
OUString const & GetSecondaryKey() const
Definition: tox.hxx:648
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:254
virtual void Activate() override
Definition: swuiidxmrk.cxx:969
OUString GetSelText() const
get selected text of a node at current cursor
Definition: crsrsh.cxx:2530
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:3418
OUString GetSelectionTextParam(bool bCompleteWords, bool bEraseTrail)
Definition: view.cxx:1594
Reference< XExecutableDialog > m_xDialog
SwIndexMarkFloatDlg(SfxBindings *pBindings, SfxChildWindow *pChild, weld::Window *pParent, SfxChildWinInfo const *pInfo, bool bNew)
Definition: swuiidxmrk.cxx:957
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:938
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:177
void SetSecKey(const OUString &rSet)
Definition: toxmgr.hxx:207
TOXTypes GetType() const
Definition: tox.hxx:701
const SwTOXMark & GotoTOXMark(const SwTOXMark &rStart, SwTOXSearch eDir)
traveling between marks
Definition: crstrvl.cxx:602
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:157
#define HID_AUTH_FIELD_INSTITUTION
Definition: helpids.h:79
virtual void Activate() override
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
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:162
SwIndexMarkPane m_aContent
Definition: swuiidxmrk.hxx:152
SwIndexMarkPane(const std::shared_ptr< weld::Dialog > &rDialog, weld::Builder &rBuilder, bool bNewDlg, SwWrtShell *pWrtShell)
Definition: swuiidxmrk.cxx:68
#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:2071
virtual ~SwIndexMarkModalDlg() override
Definition: swuiidxmrk.cxx:988
OUString GetDefaultPhoneticReading(const OUString &rText)
Definition: swuiidxmrk.cxx:349
IMPL_LINK(SwNewUserIdxDlg, ModifyHdl, weld::Entry &, rEdit, void)
Definition: swuiidxmrk.cxx:591
void ModifyHdl(const weld::Widget &rWidget)
Definition: swuiidxmrk.cxx:646
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:236
void UpdateKeyBoxes()
Definition: swuiidxmrk.cxx:546
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CJK_LANGUAGE(24)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
std::unique_ptr< weld::Button > m_xCloseBT
Definition: swuiidxmrk.hxx:84
sal_uInt16 nPos
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