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  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 {
965  Initialize(pInfo);
966 }
967 
969 {
972 }
973 
975 {
976  m_aContent.ReInitDlg( rWrtShell );
977 }
978 
980  : SfxDialogController(pParent, "modules/swriter/ui/indexentry.ui",
981  "IndexEntryDialog")
982  , m_aContent(m_xDialog, *m_xBuilder, false, rSh)
983 {
984  m_aContent.ReInitDlg(rSh, pCurTOXMark);
985 }
986 
988 {
990 }
991 
993 {
994  short nRet = SfxDialogController::run();
995  if (RET_OK == nRet)
996  m_aContent.Apply();
997  return nRet;
998 }
999 
1000 namespace {
1001 
1002 class SwCreateAuthEntryDlg_Impl : public weld::GenericDialogController
1003 {
1004  std::vector<std::unique_ptr<weld::Builder>> m_aBuilders;
1005 
1006  Link<weld::Entry&,bool> aShortNameCheckLink;
1007 
1008  SwWrtShell& rWrtSh;
1009 
1010  bool m_bNewEntryMode;
1011  bool m_bNameAllowed;
1012 
1013  std::vector<std::unique_ptr<weld::Container>> m_aOrigContainers;
1014  std::vector<std::unique_ptr<weld::Label>> m_aFixedTexts;
1015  std::unique_ptr<weld::Entry> pEdits[AUTH_FIELD_END];
1016  std::unique_ptr<weld::Button> m_xOKBT;
1017  std::unique_ptr<weld::Container> m_xBox;
1018  std::unique_ptr<weld::Container> m_xLeft;
1019  std::unique_ptr<weld::Container> m_xRight;
1020  std::unique_ptr<weld::ComboBox> m_xTypeListBox;
1021  std::unique_ptr<weld::ComboBox> m_xIdentifierBox;
1022 
1023  DECL_LINK(IdentifierHdl, weld::ComboBox&, void);
1024  DECL_LINK(ShortNameHdl, weld::Entry&, void);
1025  DECL_LINK(EnableHdl, weld::ComboBox&, void);
1026 
1027 public:
1028  SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
1029  const OUString pFields[],
1030  SwWrtShell& rSh,
1031  bool bNewEntry,
1032  bool bCreate);
1033 
1034  OUString GetEntryText(ToxAuthorityField eField) const;
1035 
1036  void SetCheckNameHdl(const Link<weld::Entry&,bool>& rLink) {aShortNameCheckLink = rLink;}
1037 
1038 };
1039 
1040 struct TextInfo
1041 {
1042  ToxAuthorityField nToxField;
1043  const char* pHelpId;
1044 };
1045 
1046 }
1047 
1048 const TextInfo aTextInfoArr[] =
1049 {
1081 };
1082 
1083 static OUString lcl_FindColumnEntry(const uno::Sequence<beans::PropertyValue>& rFields, const OUString& rColumnTitle)
1084 {
1085  for(const auto& rField : rFields)
1086  {
1087  OUString sRet;
1088  if(rField.Name == rColumnTitle &&
1089  (rField.Value >>= sRet))
1090  {
1091  return sRet;
1092  }
1093  }
1094  return OUString();
1095 }
1096 
1098 
1100  : m_rDialog(rDialog)
1101  , bNewEntry(bNewDlg)
1102  , bBibAccessInitialized(false)
1103  , pSh(nullptr)
1104  , m_xFromComponentRB(rBuilder.weld_radio_button("frombibliography"))
1105  , m_xFromDocContentRB(rBuilder.weld_radio_button("fromdocument"))
1106  , m_xAuthorFI(rBuilder.weld_label("author"))
1107  , m_xTitleFI(rBuilder.weld_label("title"))
1108  , m_xEntryED(rBuilder.weld_entry("entryed"))
1109  , m_xEntryLB(rBuilder.weld_combo_box("entrylb"))
1110  , m_xActionBT(rBuilder.weld_button(bNewEntry ? OString("insert") : OString("modify")))
1111  , m_xCloseBT(rBuilder.weld_button("close"))
1112  , m_xCreateEntryPB(rBuilder.weld_button("new"))
1113  , m_xEditEntryPB(rBuilder.weld_button("edit"))
1114 {
1115  m_xActionBT->show();
1116  m_xFromComponentRB->set_visible(bNewEntry);
1117  m_xFromDocContentRB->set_visible(bNewEntry);
1118  m_xFromComponentRB->set_active(bIsFromComponent);
1119  m_xFromDocContentRB->set_active(!bIsFromComponent);
1120 
1121  m_xActionBT->connect_clicked(LINK(this,SwAuthorMarkPane, InsertHdl));
1122  m_xCloseBT->connect_clicked(LINK(this,SwAuthorMarkPane, CloseHdl));
1123  m_xCreateEntryPB->connect_clicked(LINK(this,SwAuthorMarkPane, CreateEntryHdl));
1124  m_xEditEntryPB->connect_clicked(LINK(this,SwAuthorMarkPane, CreateEntryHdl));
1125  m_xFromComponentRB->connect_toggled(LINK(this,SwAuthorMarkPane, ChangeSourceHdl));
1126  m_xFromDocContentRB->connect_toggled(LINK(this,SwAuthorMarkPane, ChangeSourceHdl));
1127  m_xEntryED->connect_changed(LINK(this,SwAuthorMarkPane, EditModifyHdl));
1128 
1130  bNewEntry ? STR_AUTHMRK_INSERT : STR_AUTHMRK_EDIT));
1131 
1132  m_xEntryED->set_visible(!bNewEntry);
1133  m_xEntryLB->set_visible(bNewEntry);
1134  if (bNewEntry)
1135  {
1136  m_xEntryLB->connect_changed(LINK(this, SwAuthorMarkPane, CompEntryHdl));
1137  }
1138 }
1139 
1141 {
1142  pSh = &rWrtShell;
1143  InitControls();
1144 }
1145 
1147 {
1148  if(bNewEntry)
1149  {
1151  SfxCallMode::ASYNCHRON|SfxCallMode::RECORD);
1152  }
1153  else
1154  {
1155  m_rDialog.response(RET_CANCEL);
1156  }
1157 }
1158 
1159 IMPL_LINK( SwAuthorMarkPane, CompEntryHdl, weld::ComboBox&, rBox, void)
1160 {
1161  const OUString sEntry(rBox.get_active_text());
1162  if(bIsFromComponent)
1163  {
1164  if(xBibAccess.is() && !sEntry.isEmpty())
1165  {
1166  if(xBibAccess->hasByName(sEntry))
1167  {
1168  uno::Any aEntry(xBibAccess->getByName(sEntry));
1169  uno::Sequence<beans::PropertyValue> aFieldProps;
1170  if(aEntry >>= aFieldProps)
1171  {
1172  auto nSize = std::min(static_cast<sal_Int32>(AUTH_FIELD_END), aFieldProps.getLength());
1173  for(sal_Int32 i = 0; i < nSize; i++)
1174  {
1175  m_sFields[i] = lcl_FindColumnEntry(aFieldProps, m_sColumnTitles[i]);
1176  }
1177  }
1178  }
1179  }
1180  }
1181  else
1182  {
1183  if(!sEntry.isEmpty())
1184  {
1185  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1186  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1187  const SwAuthEntry* pEntry = pFType ? pFType->GetEntryByIdentifier(sEntry) : nullptr;
1188  for(int i = 0; i < AUTH_FIELD_END; i++)
1189  m_sFields[i] = pEntry ?
1190  pEntry->GetAuthorField(static_cast<ToxAuthorityField>(i)) : OUString();
1191  }
1192  }
1193  if (rBox.get_active_text().isEmpty())
1194  {
1195  for(OUString & s : m_sFields)
1196  s.clear();
1197  }
1198  m_xAuthorFI->set_label(m_sFields[AUTH_FIELD_AUTHOR]);
1199  m_xTitleFI->set_label(m_sFields[AUTH_FIELD_TITLE]);
1200 }
1201 
1203 {
1204  //insert or update the SwAuthorityField...
1205  if(pSh)
1206  {
1207  bool bDifferent = false;
1208  OSL_ENSURE(!m_sFields[AUTH_FIELD_IDENTIFIER].isEmpty() , "No Id is set!");
1209  OSL_ENSURE(!m_sFields[AUTH_FIELD_AUTHORITY_TYPE].isEmpty() , "No authority type is set!");
1210  //check if the entry already exists with different content
1211  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1212  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1213  const SwAuthEntry* pEntry = pFType ?
1214  pFType->GetEntryByIdentifier( m_sFields[AUTH_FIELD_IDENTIFIER])
1215  : nullptr;
1216  if(pEntry)
1217  {
1218  for(int i = 0; i < AUTH_FIELD_END && !bDifferent; i++)
1219  bDifferent |= m_sFields[i] != pEntry->GetAuthorField(static_cast<ToxAuthorityField>(i));
1220  if(bDifferent)
1221  {
1222  std::unique_ptr<weld::MessageDialog> xQuery(Application::CreateMessageDialog(m_rDialog.getDialog(),
1223  VclMessageType::Question, VclButtonsType::YesNo,
1224  SwResId(STR_QUERY_CHANGE_AUTH_ENTRY)));
1225  if (RET_YES != xQuery->run())
1226  return;
1227  }
1228  }
1229 
1230  SwFieldMgr aMgr(pSh);
1231  OUStringBuffer sFields;
1232  for(OUString & s : m_sFields)
1233  {
1234  sFields.append(s).append(TOX_STYLE_DELIMITER);
1235  }
1236  if(bNewEntry)
1237  {
1238  if(bDifferent)
1239  {
1241  for(int i = 0; i < AUTH_FIELD_END; i++)
1242  xNewData->SetAuthorField(static_cast<ToxAuthorityField>(i), m_sFields[i]);
1243  pSh->ChangeAuthorityData(xNewData.get());
1244  }
1245  SwInsertField_Data aData(SwFieldTypesEnum::Authority, 0, sFields.makeStringAndClear(), OUString(), 0 );
1246  aMgr.InsertField( aData );
1247  }
1248  else if(aMgr.GetCurField())
1249  {
1250  aMgr.UpdateCurField(0, sFields.makeStringAndClear(), OUString());
1251  }
1252  }
1253  if(!bNewEntry)
1254  CloseHdl(*m_xCloseBT);
1255 }
1256 
1257 IMPL_LINK(SwAuthorMarkPane, CreateEntryHdl, weld::Button&, rButton, void)
1258 {
1259  bool bCreate = &rButton == m_xCreateEntryPB.get();
1260  OUString sOldId = m_sCreatedEntry[0];
1261  for(int i = 0; i < AUTH_FIELD_END; i++)
1262  m_sCreatedEntry[i] = bCreate ? OUString() : m_sFields[i];
1263  SwCreateAuthEntryDlg_Impl aDlg(m_rDialog.getDialog(),
1264  bCreate ? m_sCreatedEntry : m_sFields,
1265  *pSh, bNewEntry, bCreate);
1266  if(bNewEntry)
1267  {
1268  aDlg.SetCheckNameHdl(LINK(this, SwAuthorMarkPane, IsEntryAllowedHdl));
1269  }
1270  if(RET_OK != aDlg.run())
1271  return;
1272 
1273  if(bCreate && !sOldId.isEmpty())
1274  {
1275  m_xEntryLB->remove_text(sOldId);
1276  }
1277  for(int i = 0; i < AUTH_FIELD_END; i++)
1278  {
1279  m_sFields[i] = aDlg.GetEntryText(static_cast<ToxAuthorityField>(i));
1280  m_sCreatedEntry[i] = m_sFields[i];
1281  }
1282  if(bNewEntry && !m_xFromDocContentRB->get_active())
1283  {
1284  m_xFromDocContentRB->set_active(true);
1285  ChangeSourceHdl(*m_xFromDocContentRB);
1286  }
1287  if(bCreate)
1288  {
1289  OSL_ENSURE(m_xEntryLB->find_text(m_sFields[AUTH_FIELD_IDENTIFIER]) == -1,
1290  "entry exists!");
1291  m_xEntryLB->append_text(m_sFields[AUTH_FIELD_IDENTIFIER]);
1292  m_xEntryLB->set_active_text(m_sFields[AUTH_FIELD_IDENTIFIER]);
1293  }
1294  m_xEntryED->set_text(m_sFields[AUTH_FIELD_IDENTIFIER]);
1295  m_xAuthorFI->set_label(m_sFields[AUTH_FIELD_AUTHOR]);
1296  m_xTitleFI->set_label(m_sFields[AUTH_FIELD_TITLE]);
1297  m_xActionBT->set_sensitive(true);
1298 }
1299 
1301 {
1302  bool bFromComp = m_xFromComponentRB->get_active();
1303  bIsFromComponent = bFromComp;
1304  m_xCreateEntryPB->set_sensitive(!bIsFromComponent);
1305  m_xEntryLB->clear();
1306  if(bIsFromComponent)
1307  {
1308  if(!bBibAccessInitialized)
1309  {
1310  uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext();
1311  xBibAccess = frame::Bibliography::create( xContext );
1312  uno::Reference< beans::XPropertySet > xPropSet(xBibAccess, uno::UNO_QUERY);
1313  OUString uPropName("BibliographyDataFieldNames");
1314  if(xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName(uPropName))
1315  {
1316  uno::Any aNames = xPropSet->getPropertyValue(uPropName);
1317  uno::Sequence<beans::PropertyValue> aSeq;
1318  if( aNames >>= aSeq)
1319  {
1320  for(const beans::PropertyValue& rProp : std::as_const(aSeq))
1321  {
1322  sal_Int16 nField = 0;
1323  rProp.Value >>= nField;
1324  if(nField >= 0 && nField < AUTH_FIELD_END)
1325  m_sColumnTitles[nField] = rProp.Name;
1326  }
1327  }
1328  }
1329  bBibAccessInitialized = true;
1330  }
1331  if(xBibAccess.is())
1332  {
1333  const uno::Sequence<OUString> aIdentifiers = xBibAccess->getElementNames();
1334  for(const OUString& rName : aIdentifiers)
1335  m_xEntryLB->append_text(rName);
1336  }
1337  }
1338  else
1339  {
1340  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1341  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1342  if(pFType)
1343  {
1344  std::vector<OUString> aIds;
1345  pFType->GetAllEntryIdentifiers( aIds );
1346  for(const OUString & i : aIds)
1347  m_xEntryLB->append_text(i);
1348  }
1349  if(!m_sCreatedEntry[AUTH_FIELD_IDENTIFIER].isEmpty())
1350  m_xEntryLB->append_text(m_sCreatedEntry[AUTH_FIELD_IDENTIFIER]);
1351  }
1352  m_xEntryLB->set_active(0);
1353  CompEntryHdl(*m_xEntryLB);
1354 }
1355 
1356 IMPL_LINK(SwAuthorMarkPane, EditModifyHdl, weld::Entry&, rEdit, void)
1357 {
1358  Link<weld::Entry&,bool> aAllowed = LINK(this, SwAuthorMarkPane, IsEditAllowedHdl);
1359  bool bResult = aAllowed.Call(rEdit);
1360  m_xActionBT->set_sensitive(bResult);
1361  if(bResult)
1362  {
1363  OUString sEntry(rEdit.get_text());
1364  m_sFields[AUTH_FIELD_IDENTIFIER] = sEntry;
1365  m_sCreatedEntry[AUTH_FIELD_IDENTIFIER] = sEntry;
1366  }
1367 };
1368 
1369 IMPL_LINK(SwAuthorMarkPane, IsEntryAllowedHdl, weld::Entry&, rEdit, bool)
1370 {
1371  OUString sEntry = rEdit.get_text();
1372  bool bAllowed = false;
1373  if(!sEntry.isEmpty())
1374  {
1375  if (m_xEntryLB->find_text(sEntry) != -1)
1376  return false;
1377  else if(bIsFromComponent)
1378  {
1379  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1380  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1381  bAllowed = !pFType || !pFType->GetEntryByIdentifier(sEntry);
1382  }
1383  else
1384  {
1385  bAllowed = !xBibAccess.is() || !xBibAccess->hasByName(sEntry);
1386  }
1387  }
1388  return bAllowed;
1389 }
1390 
1391 IMPL_LINK(SwAuthorMarkPane, IsEditAllowedHdl, weld::Entry&, rEdit, bool)
1392 {
1393  OUString sEntry = rEdit.get_text();
1394  bool bAllowed = false;
1395  if(!sEntry.isEmpty())
1396  {
1397  if (m_xEntryLB->find_text(sEntry) != -1)
1398  return false;
1399  else if(bIsFromComponent)
1400  {
1401  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1402  pSh->GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1403  bAllowed = !pFType || !pFType->GetEntryByIdentifier(sEntry);
1404  }
1405  else
1406  {
1407  bAllowed = !xBibAccess.is() || !xBibAccess->hasByName(sEntry);
1408  }
1409  }
1410  return bAllowed;
1411 }
1412 
1414 {
1415  OSL_ENSURE(pSh, "no shell?");
1416  SwField* pField = pSh->GetCurField();
1417  OSL_ENSURE(bNewEntry || pField, "no current marker");
1418  if(bNewEntry)
1419  {
1420  ChangeSourceHdl(m_xFromComponentRB->get_active() ? *m_xFromComponentRB : *m_xFromDocContentRB);
1421  m_xCreateEntryPB->set_sensitive(!m_xFromComponentRB->get_active());
1422  if(!m_xFromComponentRB->get_active() && !m_sCreatedEntry[0].isEmpty())
1423  for(int i = 0; i < AUTH_FIELD_END; i++)
1425  }
1426  if(bNewEntry || !pField || pField->GetTyp()->Which() != SwFieldIds::TableOfAuthorities)
1427  return;
1428 
1429  const SwAuthEntry* pEntry = static_cast<SwAuthorityField*>(pField)->GetAuthEntry();
1430 
1431  OSL_ENSURE(pEntry, "No authority entry found");
1432  if(!pEntry)
1433  return;
1434  for(int i = 0; i < AUTH_FIELD_END; i++)
1435  m_sFields[i] = pEntry->GetAuthorField(static_cast<ToxAuthorityField>(i));
1436 
1437  m_xEntryED->set_text(pEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER));
1438  m_xAuthorFI->set_label(pEntry->GetAuthorField(AUTH_FIELD_AUTHOR));
1439  m_xTitleFI->set_label(pEntry->GetAuthorField(AUTH_FIELD_TITLE));
1440 }
1441 
1443 {
1444  m_xActionBT->set_sensitive(!pSh->HasReadonlySel());
1445 }
1446 
1447 namespace
1448 {
1449  const char* STR_AUTH_FIELD_ARY[] =
1450  {
1451  STR_AUTH_FIELD_IDENTIFIER,
1452  STR_AUTH_FIELD_AUTHORITY_TYPE,
1453  STR_AUTH_FIELD_ADDRESS,
1454  STR_AUTH_FIELD_ANNOTE,
1455  STR_AUTH_FIELD_AUTHOR,
1456  STR_AUTH_FIELD_BOOKTITLE,
1457  STR_AUTH_FIELD_CHAPTER,
1458  STR_AUTH_FIELD_EDITION,
1459  STR_AUTH_FIELD_EDITOR,
1460  STR_AUTH_FIELD_HOWPUBLISHED,
1461  STR_AUTH_FIELD_INSTITUTION,
1462  STR_AUTH_FIELD_JOURNAL,
1463  STR_AUTH_FIELD_MONTH,
1464  STR_AUTH_FIELD_NOTE,
1465  STR_AUTH_FIELD_NUMBER,
1466  STR_AUTH_FIELD_ORGANIZATIONS,
1467  STR_AUTH_FIELD_PAGES,
1468  STR_AUTH_FIELD_PUBLISHER,
1469  STR_AUTH_FIELD_SCHOOL,
1470  STR_AUTH_FIELD_SERIES,
1471  STR_AUTH_FIELD_TITLE,
1472  STR_AUTH_FIELD_TYPE,
1473  STR_AUTH_FIELD_VOLUME,
1474  STR_AUTH_FIELD_YEAR,
1475  STR_AUTH_FIELD_URL,
1476  STR_AUTH_FIELD_CUSTOM1,
1477  STR_AUTH_FIELD_CUSTOM2,
1478  STR_AUTH_FIELD_CUSTOM3,
1479  STR_AUTH_FIELD_CUSTOM4,
1480  STR_AUTH_FIELD_CUSTOM5,
1481  STR_AUTH_FIELD_ISBN
1482  };
1483 }
1484 
1485 SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
1486  const OUString pFields[],
1487  SwWrtShell& rSh,
1488  bool bNewEntry,
1489  bool bCreate)
1490  : GenericDialogController(pParent, "modules/swriter/ui/createauthorentry.ui", "CreateAuthorEntryDialog")
1491  , rWrtSh(rSh)
1492  , m_bNewEntryMode(bNewEntry)
1493  , m_bNameAllowed(true)
1494  , m_xOKBT(m_xBuilder->weld_button("ok"))
1495  , m_xBox(m_xBuilder->weld_container("box"))
1496  , m_xLeft(m_xBuilder->weld_container("leftgrid"))
1497  , m_xRight(m_xBuilder->weld_container("rightgrid"))
1498 {
1499  bool bLeft = true;
1500  sal_Int32 nLeftRow(0), nRightRow(0);
1501  for(int nIndex = 0; nIndex < AUTH_FIELD_END; nIndex++)
1502  {
1503  //m_xBox parent just to have some parent during setup, added contents are not directly visible under m_xBox
1504  m_aBuilders.emplace_back(Application::CreateBuilder(m_xBox.get(), "modules/swriter/ui/bibliofragment.ui"));
1505  const TextInfo aCurInfo = aTextInfoArr[nIndex];
1506 
1507  m_aOrigContainers.emplace_back(m_aBuilders.back()->weld_container("biblioentry"));
1508  m_aFixedTexts.emplace_back(m_aBuilders.back()->weld_label("label"));
1509  if (bLeft)
1510  m_aOrigContainers.back()->move(m_aFixedTexts.back().get(), m_xLeft.get());
1511  else
1512  m_aOrigContainers.back()->move(m_aFixedTexts.back().get(), m_xRight.get());
1513  m_aFixedTexts.back()->set_grid_left_attach(0);
1514  m_aFixedTexts.back()->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
1515  m_aFixedTexts.back()->set_label(SwResId(STR_AUTH_FIELD_ARY[aCurInfo.nToxField]));
1516  m_aFixedTexts.back()->show();
1517  if( AUTH_FIELD_AUTHORITY_TYPE == aCurInfo.nToxField )
1518  {
1519  m_xTypeListBox = m_aBuilders.back()->weld_combo_box("listbox");
1520  if (bLeft)
1521  m_aOrigContainers.back()->move(m_xTypeListBox.get(), m_xLeft.get());
1522  else
1523  m_aOrigContainers.back()->move(m_xTypeListBox.get(), m_xRight.get());
1524 
1525  for (int j = 0; j < AUTH_TYPE_END; j++)
1526  m_xTypeListBox->append_text(SwAuthorityFieldType::GetAuthTypeName(static_cast<ToxAuthorityType>(j)));
1527  if(!pFields[aCurInfo.nToxField].isEmpty())
1528  {
1529  m_xTypeListBox->set_active(pFields[aCurInfo.nToxField].toInt32());
1530  }
1531  m_xTypeListBox->set_grid_left_attach(1);
1532  m_xTypeListBox->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
1533  m_xTypeListBox->set_hexpand(true);
1534  m_xTypeListBox->show();
1535  m_xTypeListBox->connect_changed(LINK(this, SwCreateAuthEntryDlg_Impl, EnableHdl));
1536  m_xTypeListBox->set_help_id(aCurInfo.pHelpId);
1537  m_aFixedTexts.back()->set_mnemonic_widget(m_xTypeListBox.get());
1538  }
1539  else if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField && !m_bNewEntryMode)
1540  {
1541  m_xIdentifierBox = m_aBuilders.back()->weld_combo_box("combobox");
1542  if (bLeft)
1543  m_aOrigContainers.back()->move(m_xIdentifierBox.get(), m_xLeft.get());
1544  else
1545  m_aOrigContainers.back()->move(m_xIdentifierBox.get(), m_xRight.get());
1546 
1547  m_xIdentifierBox->connect_changed(LINK(this,
1548  SwCreateAuthEntryDlg_Impl, IdentifierHdl));
1549 
1550  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1551  rSh.GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1552  if(pFType)
1553  {
1554  std::vector<OUString> aIds;
1555  pFType->GetAllEntryIdentifiers( aIds );
1556  for (const OUString& a : aIds)
1557  m_xIdentifierBox->append_text(a);
1558  }
1559  m_xIdentifierBox->set_entry_text(pFields[aCurInfo.nToxField]);
1560  m_xIdentifierBox->set_grid_left_attach(1);
1561  m_xIdentifierBox->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
1562  m_xIdentifierBox->set_hexpand(true);
1563  m_xIdentifierBox->show();
1564  m_xIdentifierBox->set_help_id(aCurInfo.pHelpId);
1565  m_aFixedTexts.back()->set_mnemonic_widget(m_xIdentifierBox.get());
1566  }
1567  else
1568  {
1569  pEdits[nIndex] = m_aBuilders.back()->weld_entry("entry");
1570  if (bLeft)
1571  m_aOrigContainers.back()->move(pEdits[nIndex].get(), m_xLeft.get());
1572  else
1573  m_aOrigContainers.back()->move(pEdits[nIndex].get(), m_xRight.get());
1574 
1575  pEdits[nIndex]->set_grid_left_attach(1);
1576  pEdits[nIndex]->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
1577  pEdits[nIndex]->set_hexpand(true);
1578  pEdits[nIndex]->set_text(pFields[aCurInfo.nToxField]);
1579  pEdits[nIndex]->show();
1580  pEdits[nIndex]->set_help_id(aCurInfo.pHelpId);
1581  if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField)
1582  {
1583  pEdits[nIndex]->connect_changed(LINK(this, SwCreateAuthEntryDlg_Impl, ShortNameHdl));
1584  m_bNameAllowed = !pFields[nIndex].isEmpty();
1585  if(!bCreate)
1586  {
1587  m_aFixedTexts.back()->set_sensitive(false);
1588  pEdits[nIndex]->set_sensitive(false);
1589  }
1590  }
1591  m_aFixedTexts.back()->set_mnemonic_widget(pEdits[nIndex].get());
1592  }
1593  if(bLeft)
1594  ++nLeftRow;
1595  else
1596  ++nRightRow;
1597  bLeft = !bLeft;
1598  }
1599  EnableHdl(*m_xTypeListBox);
1600 }
1601 
1602 OUString SwCreateAuthEntryDlg_Impl::GetEntryText(ToxAuthorityField eField) const
1603 {
1604  if( AUTH_FIELD_AUTHORITY_TYPE == eField )
1605  {
1606  OSL_ENSURE(m_xTypeListBox, "No ListBox");
1607  return OUString::number(m_xTypeListBox->get_active());
1608  }
1609 
1610  if( AUTH_FIELD_IDENTIFIER == eField && !m_bNewEntryMode)
1611  {
1612  OSL_ENSURE(m_xIdentifierBox, "No ComboBox");
1613  return m_xIdentifierBox->get_active_text();
1614  }
1615 
1616  for(int nIndex = 0; nIndex < AUTH_FIELD_END; nIndex++)
1617  {
1618  const TextInfo aCurInfo = aTextInfoArr[nIndex];
1619  if(aCurInfo.nToxField == eField)
1620  {
1621  return pEdits[nIndex]->get_text();
1622  }
1623  }
1624 
1625  return OUString();
1626 }
1627 
1628 IMPL_LINK(SwCreateAuthEntryDlg_Impl, IdentifierHdl, weld::ComboBox&, rBox, void)
1629 {
1630  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
1631  rWrtSh.GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
1632  if(!pFType)
1633  return;
1634 
1635  const SwAuthEntry* pEntry = pFType->GetEntryByIdentifier(
1636  rBox.get_active_text());
1637  if(!pEntry)
1638  return;
1639 
1640  for(int i = 0; i < AUTH_FIELD_END; i++)
1641  {
1642  const TextInfo aCurInfo = aTextInfoArr[i];
1643  if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField)
1644  continue;
1645  if(AUTH_FIELD_AUTHORITY_TYPE == aCurInfo.nToxField)
1646  m_xTypeListBox->set_active_text(
1647  pEntry->GetAuthorField(aCurInfo.nToxField));
1648  else
1649  pEdits[i]->set_text(
1650  pEntry->GetAuthorField(aCurInfo.nToxField));
1651  }
1652 }
1653 
1654 IMPL_LINK(SwCreateAuthEntryDlg_Impl, ShortNameHdl, weld::Entry&, rEdit, void)
1655 {
1656  if (aShortNameCheckLink.IsSet())
1657  {
1658  bool bEnable = aShortNameCheckLink.Call(rEdit);
1659  m_bNameAllowed |= bEnable;
1660  m_xOKBT->set_sensitive(m_xTypeListBox->get_active() != -1 && bEnable);
1661  }
1662 }
1663 
1664 IMPL_LINK(SwCreateAuthEntryDlg_Impl, EnableHdl, weld::ComboBox&, rBox, void)
1665 {
1666  m_xOKBT->set_sensitive(m_bNameAllowed && rBox.get_active() != -1);
1667 };
1668 
1670  SfxChildWindow* pChild,
1671  weld::Window *pParent,
1672  SfxChildWinInfo const * pInfo,
1673  bool bNew)
1674  : SfxModelessDialogController(_pBindings, pChild, pParent,
1675  "modules/swriter/ui/bibliographyentry.ui", "BibliographyEntryDialog")
1676  , m_aContent(*this, *m_xBuilder, bNew)
1677 {
1678  Initialize(pInfo);
1679  SwWrtShell* pWrtShell = ::GetActiveWrtShell();
1680  if (pWrtShell)
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:652
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:3442
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:628
#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:974
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:1718
#define TOX_STYLE_DELIMITER
Definition: tox.hxx:411
SwWrtShell * GetActiveWrtShell()
Definition: swmodul1.cxx:108
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)
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
virtual short int run() override
Definition: swuiidxmrk.cxx:992
#define FN_INSERT_AUTH_ENTRY_DLG
Definition: cmdid.h:281
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:566
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:975
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:646
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:905
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:979
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
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:669
bool HasSelection() const
Definition: wrtsh.hxx:141
int i
const char last[]
#define FN_INSERT_IDX_ENTRY_DLG
Definition: cmdid.h:218
#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:622
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:170
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:684
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:2719
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:165
#define HID_AUTH_FIELD_URL
Definition: helpids.h:93
static sal_Int32 nTypePos
Definition: swuiidxmrk.cxx:56
bool HasReadonlySel() const
Definition: crsrsh.cxx:3333
#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:640
#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
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:2490
::ucbhelper::Content m_aContent
OUString const & GetSecondaryKey() const
Definition: tox.hxx:634
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:968
OUString GetSelText() const
get selected text of a node at current cursor
Definition: crsrsh.cxx:2526
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: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:176
void SetSecKey(const OUString &rSet)
Definition: toxmgr.hxx:207
TOXTypes GetType() const
Definition: tox.hxx:687
const SwTOXMark & GotoTOXMark(const SwTOXMark &rStart, SwTOXSearch eDir)
traveling between marks
Definition: crstrvl.cxx:603
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:149
#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
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:154
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:987
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