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