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