LibreOffice Module sw (master) 1
fldvar.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 <swtypes.hxx>
21#include <sfx2/linkmgr.hxx>
23#include <usrfld.hxx>
24#include <docufld.hxx>
25#include <expfld.hxx>
26#include <ddefld.hxx>
27#include <wrtsh.hxx>
28#include <doc.hxx>
29#include <docary.hxx>
30#include <swmodule.hxx>
31#include "fldvar.hxx"
32#include "flddinf.hxx"
33#include <calc.hxx>
34#include <svl/numformat.hxx>
35#include <svl/zformat.hxx>
36#include <o3tl/string_view.hxx>
37#include <strings.hrc>
38
39#define USER_DATA_VERSION_1 "1"
40#define USER_DATA_VERSION USER_DATA_VERSION_1
41
43 : SwFieldPage(pPage, pController, "modules/swriter/ui/fldvarpage.ui", "FieldVarPage", pCoreSet)
44 , m_xTypeLB(m_xBuilder->weld_tree_view("type"))
45 , m_xSelection(m_xBuilder->weld_widget("selectframe"))
46 , m_xSelectionLB(m_xBuilder->weld_tree_view("select"))
47 , m_xNameFT(m_xBuilder->weld_label("nameft"))
48 , m_xNameED(m_xBuilder->weld_entry("name"))
49 , m_xValueFT(m_xBuilder->weld_label("valueft"))
50 , m_xValueED(new ConditionEdit(m_xBuilder->weld_entry("value")))
51 , m_xFormat(m_xBuilder->weld_widget("formatframe"))
52 , m_xNumFormatLB(new SwNumFormatTreeView(m_xBuilder->weld_tree_view("numformat")))
53 , m_xFormatLB(m_xBuilder->weld_tree_view("format"))
54 , m_xChapterFrame(m_xBuilder->weld_widget("chapterframe"))
55 , m_xChapterLevelLB(m_xBuilder->weld_combo_box("level"))
56 , m_xInvisibleCB(m_xBuilder->weld_check_button("invisible"))
57 , m_xSeparatorFT(m_xBuilder->weld_label("separatorft"))
58 , m_xSeparatorED(m_xBuilder->weld_entry("separator"))
59 , m_xNewPB(m_xBuilder->weld_button("apply"))
60 , m_xDelPB(m_xBuilder->weld_button("delete"))
61 , m_nOldFormat(0)
62 , m_bInit(true)
63{
65 m_xSelectionLB->make_sorted();
67
68 auto nWidth = m_xTypeLB->get_approximate_digit_width() * FIELD_COLUMN_WIDTH;
69 auto nHeight = m_xTypeLB->get_height_rows(10);
70 m_xTypeLB->set_size_request(nWidth, nHeight);
71 m_xSelectionLB->set_size_request(nWidth, nHeight);
72 m_xFormatLB->set_size_request(nWidth, nHeight/2);
73
74 m_sOldValueFT = m_xValueFT->get_label();
75 m_sOldNameFT = m_xNameFT->get_label();
76
77 for (sal_uInt16 i = 1; i <= MAXLEVEL; i++)
78 m_xChapterLevelLB->append_text(OUString::number(i));
79
80 m_xChapterLevelLB->set_active(0);
81 //enable 'active' language selection
82 m_xNumFormatLB->SetShowLanguageControl(true);
83
84 // uitests
85 m_xTypeLB->set_buildable_name(m_xTypeLB->get_buildable_name() + "-var");
86 m_xNameED->set_buildable_name(m_xNameED->get_buildable_name() + "-var");
87 m_xValueED->set_buildable_name(m_xValueED->get_buildable_name() + "-var");
88 m_xNumFormatLB->set_buildable_name(m_xNumFormatLB->get_buildable_name() + "-var");
89 m_xSelectionLB->set_buildable_name(m_xSelectionLB->get_buildable_name() + "-var");
90 m_xFormatLB->set_buildable_name(m_xFormatLB->get_buildable_name() + "-var");
91}
92
94{
95}
96
98{
100
101 Init(); // general initialisation
102
103 m_xTypeLB->freeze();
104 m_xTypeLB->clear();
105
106 SwFieldTypesEnum nTypeId;
107
108 if (!IsFieldEdit())
109 {
110 // initialise TypeListBox
112
113 for (short i = rRg.nStart; i < rRg.nEnd; ++i)
114 {
115 nTypeId = SwFieldMgr::GetTypeId(i);
116 m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(i));
117 }
118 }
119 else
120 {
121 const SwField* pCurField = GetCurField();
122 assert(pCurField && "<SwFieldVarPage::Reset(..)> - <SwField> instance missing!");
123 nTypeId = pCurField->GetTypeId();
124 if (nTypeId == SwFieldTypesEnum::SetInput)
125 nTypeId = SwFieldTypesEnum::Input;
126 m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId)));
127 m_xNumFormatLB->SetAutomaticLanguage(pCurField->IsAutomaticLanguage());
128 SwWrtShell *pSh = GetWrtShell();
129 if(!pSh)
130 pSh = ::GetActiveWrtShell();
131 if(pSh)
132 {
133 const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetFormat());
134 if(pFormat)
135 m_xNumFormatLB->SetLanguage(pFormat->GetLanguage());
136 }
137 }
138
139 m_xTypeLB->thaw();
140
141 // select old Pos
143
144 m_xTypeLB->connect_row_activated(LINK(this, SwFieldVarPage, TreeViewInsertHdl));
145 m_xTypeLB->connect_changed(LINK(this, SwFieldVarPage, TypeHdl));
146 m_xSelectionLB->connect_changed(LINK(this, SwFieldVarPage, SubTypeListBoxHdl));
147 m_xSelectionLB->connect_row_activated(LINK(this, SwFieldVarPage, SubTypeInsertHdl));
148 m_xFormatLB->connect_row_activated(LINK(this, SwFieldVarPage, TreeViewInsertHdl));
149 m_xNumFormatLB->connect_row_activated(LINK(this, SwFieldVarPage, TreeViewInsertHdl));
150 m_xNameED->connect_changed(LINK(this, SwFieldVarPage, ModifyHdl));
151 m_xValueED->connect_changed(LINK(this, SwFieldVarPage, ModifyHdl));
152 m_xNewPB->connect_clicked(LINK(this, SwFieldVarPage, TBClickHdl));
153 m_xDelPB->connect_clicked(LINK(this, SwFieldVarPage, TBClickHdl));
154 m_xChapterLevelLB->connect_changed(LINK(this, SwFieldVarPage, ChapterHdl));
155 m_xSeparatorED->connect_changed(LINK(this, SwFieldVarPage, SeparatorHdl));
156
157 if( !IsRefresh() )
158 {
159 OUString sUserData = GetUserData();
160 sal_Int32 nIdx{ 0 };
161 if(!IsRefresh() && o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), u"" USER_DATA_VERSION_1))
162 {
163 std::u16string_view sVal = o3tl::getToken(sUserData, 0, ';', nIdx);
164 sal_uInt16 nVal = o3tl::narrowing<sal_uInt16>(o3tl::toInt32(sVal));
165 if (USHRT_MAX != nVal)
166 {
167 for (sal_Int32 i = 0, nEntryCount = m_xTypeLB->n_children(); i < nEntryCount; i++)
168 {
169 if (nVal == m_xTypeLB->get_id(i).toUInt32())
170 {
171 m_xTypeLB->select(i);
172 break;
173 }
174 }
175 }
176 }
177 }
178 TypeHdl(*m_xTypeLB);
179
180 if (IsFieldEdit())
181 {
182 m_xSelectionLB->save_value();
183 m_xFormatLB->save_value();
184 m_nOldFormat = m_xNumFormatLB->GetFormat();
185 m_xNameED->save_value();
186 m_xValueED->save_value();
187 m_xInvisibleCB->save_state();
188 m_xChapterLevelLB->save_value();
189 m_xSeparatorED->save_value();
190 }
191}
192
194{
195 // save old ListBoxPos
196 const sal_Int32 nOld = GetTypeSel();
197
198 // current ListBoxPos
199 SetTypeSel(m_xTypeLB->get_selected_index());
200
201 if(GetTypeSel() == -1)
202 {
203 SetTypeSel(0);
204 m_xTypeLB->select(0);
205 }
206
207 if (nOld != GetTypeSel() || nOld == -1)
208 {
209 m_bInit = true;
210 if (nOld != -1)
211 {
212 m_xNameED->set_text(OUString());
213 m_xValueED->set_text(OUString());
214 }
215
216 m_xValueED->SetDropEnable(false);
217 UpdateSubType(); // initialise selection-listboxes
218 }
219
220 m_bInit = false;
221}
222
223IMPL_LINK( SwFieldVarPage, SubTypeListBoxHdl, weld::TreeView&, rBox, void )
224{
225 SubTypeHdl(&rBox);
226}
227
228static inline sal_uInt32 lcl_getUsedNumFormat( const SwNumFormatTreeView& rNumFormatLB, bool& rbText )
229{
230 sal_uInt32 nNumberFormat = 0;
231 const sal_Int32 nNumFormatPos = rNumFormatLB.get_selected_index();
232 if (nNumFormatPos != -1)
233 {
234 nNumberFormat = rNumFormatLB.GetFormat();
235 if ((rbText = (nNumFormatPos == 0 && nNumberFormat == SAL_MAX_UINT32)))
236 nNumberFormat = 0;
237 }
238 return nNumberFormat;
239}
240
242{
243 SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
244 sal_Int32 nSelPos = m_xSelectionLB->get_selected_index();
245 size_t nSelData = SIZE_MAX;
246
247 if (nSelPos != -1)
248 nSelData = m_xSelectionLB->get_id(nSelPos).toUInt32();
249
250 if (IsFieldEdit() && (!pBox || m_bInit))
251 {
252 if (nTypeId != SwFieldTypesEnum::Formel)
254
256 }
257
258 if (m_xNameFT->get_label() != m_sOldNameFT)
259 m_xNameFT->set_label(m_sOldNameFT);
260 if (m_xValueFT->get_label() != m_sOldValueFT)
261 m_xValueFT->set_label(m_sOldValueFT);
262
263 FillFormatLB(nTypeId);
264
265 sal_Int32 nSize = m_xFormatLB->n_children();
266
267 bool bValue = false, bName = false, bNumFormat = false,
268 bInvisible = false, bShowChapterFrame = false;
269 bool bFormat = nSize != 0;
270
271 switch (nTypeId)
272 {
274 {
275 // change or create user type
276 SwUserFieldType* pType = static_cast<SwUserFieldType*>(
278
279 if (pType)
280 {
281 if (!IsFieldEdit())
282 {
283 if (pBox || (m_bInit && !IsRefresh())) // only when interacting via mouse
284 {
285 m_xNameED->set_text(pType->GetName());
286
287 if (pType->GetType() == UF_STRING)
288 {
289 m_xValueED->set_text(pType->GetContent());
290 m_xNumFormatLB->select(0);
291 }
292 else
293 {
294 bool bText = false;
295 const sal_uInt32 nNumberFormat = lcl_getUsedNumFormat( *m_xNumFormatLB, bText);
296 m_xValueED->set_text(pType->GetInputOrDateTime(nNumberFormat));
297 }
298 }
299 }
300 else
301 {
302 bool bText = false;
303 const sal_uInt32 nNumberFormat = lcl_getUsedNumFormat( *m_xNumFormatLB, bText);
304 m_xValueED->set_text(pType->GetInputOrDateTime(nNumberFormat));
305 }
306 }
307 else
308 {
309 if (pBox) // only when interacting via mouse
310 {
311 m_xNameED->set_text(OUString());
312 m_xValueED->set_text(OUString());
313 }
314 }
315 bValue = bName = bNumFormat = bInvisible = true;
316
317 m_xValueED->SetDropEnable(true);
318 break;
319 }
320
322 bValue = true;
323
324 bNumFormat = bInvisible = true;
325
326 if (!IsFieldDlgHtmlMode())
327 bName = true;
328 else
329 {
330 m_xNumFormatLB->clear();
331 m_xNumFormatLB->append(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND), SwResId(FMT_SETVAR_TEXT));
332 m_xNumFormatLB->select(0);
333 }
334 // is there a corresponding SetField
335 if (IsFieldEdit() || pBox) // only when interacting via mouse
336 {
337 if (nSelPos != -1)
338 {
339 OUString sName(m_xSelectionLB->get_selected_text());
340 m_xNameED->set_text(sName);
341
342 if (!IsFieldDlgHtmlMode())
343 {
344 SwWrtShell *pSh = GetWrtShell();
345 if(!pSh)
346 pSh = ::GetActiveWrtShell();
347 if(pSh)
348 {
349 SwSetExpFieldType* pSetTyp = static_cast<SwSetExpFieldType*>(
351
352 if (pSetTyp && pSetTyp->GetType() == nsSwGetSetExpType::GSE_STRING)
353 m_xNumFormatLB->select(0); // textual
354 }
355 }
356 }
357 }
358 if (GetCurField() != nullptr && IsFieldEdit())
359 {
360 m_xValueED->set_text(static_cast<SwSetExpField*>(GetCurField())->GetInputOrDateTime());
361 }
362 m_xValueED->SetDropEnable(true);
363 break;
364
366 {
367 bValue = true;
368 bNumFormat = true;
369 m_xValueFT->set_label(SwResId(STR_FORMULA));
370 m_xValueED->SetDropEnable(true);
371 }
372 break;
373
375 {
376 if (!IsFieldEdit())
377 {
378 m_xNameED->set_text(OUString());
379 m_xValueED->set_text(OUString());
380 }
381
382 if (nSelPos != -1)
383 {
384 OUString sName(m_xSelectionLB->get_selected_text());
385 if (!IsFieldEdit())
386 m_xNameED->set_text(sName);
387
388 // is there a corresponding SetField
389 SwWrtShell *pSh = GetWrtShell();
390 if(!pSh)
391 pSh = ::GetActiveWrtShell();
392 if(pSh)
393 {
394 SwSetExpFieldType* pSetTyp = static_cast<SwSetExpFieldType*>(
396
397 if(pSetTyp)
398 {
399 if (pSetTyp->GetType() & nsSwGetSetExpType::GSE_STRING) // textual?
400 bFormat = true;
401 else // numeric
402 bNumFormat = true;
403 }
404 }
405 }
406 else
407 bFormat = false;
408
409 EnableInsert(bFormat || bNumFormat);
410 }
411 break;
412
414 m_xValueFT->set_label(SwResId(STR_PROMPT));
415
416 if (nSelPos != -1)
417 {
418 bValue = bNumFormat = true;
419
420 OUString sName = m_xSelectionLB->get_selected_text();
421 m_xNameED->set_text( sName );
422
423 // User- or SetField ?
424 if (!GetFieldMgr().GetFieldType(SwFieldIds::User, sName)) // SetExp
425 {
426 // is there a corresponding SetField
427 SwSetExpFieldType* pSetTyp = static_cast<SwSetExpFieldType*>(
429
430 if(pSetTyp)
431 {
432 if (pSetTyp->GetType() == nsSwGetSetExpType::GSE_STRING) // textual?
433 {
434 m_xNumFormatLB->clear();
435 m_xNumFormatLB->append(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND), SwResId(FMT_USERVAR_TEXT));
436 m_xNumFormatLB->select(0);
437 }
438 }
439 if (GetCurField() && IsFieldEdit() && (!pBox || m_bInit) )
440 m_xValueED->set_text(static_cast<SwSetExpField*>(GetCurField())->GetPromptText());
441 }
442 else // USERFLD
443 bFormat = bNumFormat = false;
444 }
445 break;
446
448 m_xValueFT->set_label(SwResId(STR_DDE_CMD));
449
450 if (IsFieldEdit() || pBox) // only when interacting via mouse
451 {
452 if (nSelPos != -1)
453 {
454 SwDDEFieldType* pType =
455 static_cast<SwDDEFieldType*>( GetFieldMgr().GetFieldType(SwFieldIds::Dde, nSelData) );
456
457 if(pType)
458 {
459 m_xNameED->set_text(pType->GetName());
460
461 //JP 28.08.95: DDE-Topics/-Items can have blanks in their names!
462 // That's not considered here yet
463 OUString sCmd( pType->GetCmd() );
464 sal_Int32 nTmpPos = 0;
465 sCmd = sCmd.replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &nTmpPos );
466 sCmd = sCmd.replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &nTmpPos );
467
468 m_xValueED->set_text( sCmd );
469 m_xFormatLB->select(static_cast<int>(pType->GetType()));
470 }
471 }
472 }
473 bName = bValue = true;
474 break;
475
477 {
478 bName = bValue = bShowChapterFrame = true;
479
480 SwFieldType* pFieldTyp;
481 if( GetCurField() && IsFieldEdit() )
482 pFieldTyp = GetCurField()->GetTyp();
483 else
484 {
485 OUString sFieldTypeName(m_xSelectionLB->get_text(nSelPos));
486 if( !sFieldTypeName.isEmpty() )
488 sFieldTypeName );
489 else
490 pFieldTyp = nullptr;
491 }
492
493 if( GetCurField() && IsFieldEdit() )
494 m_xValueED->set_text( static_cast<SwSetExpField*>(GetCurField())->
495 GetFormula() );
496
497 if( IsFieldEdit() || pBox ) // only when interacting via mouse
498 m_xNameED->set_text( m_xSelectionLB->get_selected_text() );
499
500 if( pFieldTyp )
501 {
502 sal_uInt8 nLevel = static_cast<SwSetExpFieldType*>(pFieldTyp)->GetOutlineLvl();
503 if( 0x7f == nLevel )
504 m_xChapterLevelLB->set_active(0);
505 else
506 m_xChapterLevelLB->set_active(nLevel + 1);
507 OUString sDelim = static_cast<SwSetExpFieldType*>(pFieldTyp)->GetDelimiter();
508 m_xSeparatorED->set_text( sDelim );
509 ChapterHdl(*m_xChapterLevelLB);
510 }
511 }
512 break;
513
515 {
516 bValue = false;
517 m_xValueFT->set_label( SwResId( STR_OFFSET ));
518
519 if (IsFieldEdit() || pBox) // only when interacting via mouse
520 m_xNameED->set_text(OUString());
521
522 if (nSelData != 0 && nSelData != SIZE_MAX)
523 {
524 bValue = true; // SubType OFF - knows no Offset
525 if (GetCurField() && IsFieldEdit())
526 m_xValueED->set_text(OUString::number(static_cast<SwRefPageSetField*>(GetCurField())->GetOffset()));
527 }
528 }
529 break;
530
532 m_xNameED->set_text(OUString());
533 m_xValueED->set_text(OUString());
534 break;
535
536 default: break;
537 }
538
539 m_xNumFormatLB->set_visible(bNumFormat);
540 m_xFormatLB->set_visible(!bNumFormat);
541
542 if (IsFieldEdit())
543 bName = false;
544
545 m_xFormat->set_sensitive(bFormat || bNumFormat);
546 m_xNameFT->set_sensitive(bName);
547 m_xNameED->set_sensitive(bName);
548 m_xValueFT->set_sensitive(bValue);
549 m_xValueED->set_sensitive(bValue);
550
551 m_xInvisibleCB->set_visible(!bShowChapterFrame);
552 m_xChapterFrame->set_visible(bShowChapterFrame);
553 m_xInvisibleCB->set_sensitive(bInvisible);
554
555 ModifyHdl(*m_xNameED); // apply/insert/delete status update
556}
557
558IMPL_LINK(SwFieldVarPage, SubTypeInsertHdl, weld::TreeView&, rBox, bool)
559{
560 if (!m_bInit)
561 {
562 SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
563 if (nTypeId == SwFieldTypesEnum::Formel)
564 {
565 auto nSelPos = m_xSelectionLB->get_selected_index();
566 if (nSelPos != -1)
567 {
568 m_xValueED->replace_selection(m_xSelectionLB->get_text(nSelPos));
569 ModifyHdl(*m_xNameED);
570 return true;
571 }
572 }
573 }
574 TreeViewInsertHdl(rBox);
575 return true;
576}
577
578// renew types in SelectionBox
580{
581 SetSelectionSel(m_xSelectionLB->get_selected_index());
582
583 OUString sOldSel;
584 if (GetSelectionSel() != -1)
585 sOldSel = m_xSelectionLB->get_text(GetSelectionSel());
586
587 // fill Selection-Listbox
588 m_xSelectionLB->freeze();
589 m_xSelectionLB->clear();
590
591 const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
592 std::vector<OUString> aList;
593 GetFieldMgr().GetSubTypes(nTypeId, aList);
594 const size_t nCount = aList.size();
595 for (size_t i = 0; i < nCount; ++i)
596 {
597 if (nTypeId != SwFieldTypesEnum::Input || i)
598 {
599 if (!IsFieldEdit())
600 {
601 m_xSelectionLB->append(OUString::number(i), aList[i]);
602 }
603 else
604 {
605 bool bInsert = false;
606
607 switch (nTypeId)
608 {
610 if (GetCurField() && aList[i] == GetCurField()->GetPar1())
611 bInsert = true;
612 break;
613
615 bInsert = true;
616 break;
617
619 if (GetCurField() && aList[i] == static_cast<const SwFormulaField*>(GetCurField())->GetFormula())
620 bInsert = true;
621 break;
622
625 if (GetCurField() && aList[i] == GetCurField()->GetTyp()->GetName())
626 {
627 bInsert = true;
629 m_xInvisibleCB->set_active(true);
630 }
631 break;
632
634 {
635 if (GetCurField() != nullptr
636 && ((static_cast<SwRefPageSetField*>(GetCurField())->IsOn()
637 && i) || (!static_cast<SwRefPageSetField*>(GetCurField())
638 ->IsOn() && !i)))
639 {
640 sOldSel = aList[i];
641 }
642
643 // allow all entries for selection:
644 m_xSelectionLB->append(OUString::number(i), aList[i]);
645 break;
646 }
647 default:
648 if (GetCurField() && aList[i] == GetCurField()->GetPar1())
649 bInsert = true;
650 break;
651 }
652
653 if (bInsert)
654 {
655 m_xSelectionLB->append(OUString::number(i), aList[i]);
656 if (nTypeId != SwFieldTypesEnum::Formel)
657 break;
658 }
659 }
660 }
661 }
662
663 m_xSelectionLB->thaw();
664
665 const bool bEnable = m_xSelectionLB->n_children() != 0;
666 weld::TreeView* pLB = nullptr;
667
668 if (bEnable)
669 {
670 int nIndex = m_xSelectionLB->find_text(sOldSel);
671 if (nIndex != -1)
672 m_xSelectionLB->select(nIndex);
673 else
674 {
675 m_xSelectionLB->select(0);
676 pLB = m_xSelectionLB.get(); // newly initialise all controls
677 }
678 }
679
680 m_xSelection->set_sensitive(bEnable);
681
682 SubTypeHdl(pLB);
683}
684
686{
687 OUString sOldSel;
688 const sal_Int32 nFormatSel = m_xFormatLB->get_selected_index();
689 if (nFormatSel != -1)
690 sOldSel = m_xFormatLB->get_text(nFormatSel);
691
692 weld::TreeView& rWidget = dynamic_cast<weld::TreeView&>(m_xNumFormatLB->get_widget());
693
694 OUString sOldNumSel;
695 sal_uInt32 nOldNumFormat = 0;
696 sal_Int32 nNumFormatSel = rWidget.get_selected_index();
697 if (nNumFormatSel != -1)
698 {
699 sOldNumSel = rWidget.get_text(nNumFormatSel);
700 nOldNumFormat = m_xNumFormatLB->GetFormat();
701 }
702
703 // fill Format-Listbox
704 m_xFormatLB->freeze();
705 m_xFormatLB->clear();
706 m_xNumFormatLB->clear(); // flags list as dirty and needing refilling with stock entries
707 bool bSpecialFormat = false;
708
709 if( SwFieldTypesEnum::GetRefPage != nTypeId )
710 {
711 if (GetCurField() != nullptr && IsFieldEdit())
712 {
713 bSpecialFormat = GetCurField()->GetFormat() == NUMBERFORMAT_ENTRY_NOT_FOUND;
714
715 if (!bSpecialFormat)
716 {
717 m_xNumFormatLB->SetDefFormat(GetCurField()->GetFormat());
718 sOldNumSel.clear();
719 }
720 else if (nTypeId == SwFieldTypesEnum::Get || nTypeId == SwFieldTypesEnum::Formel)
721 {
722 m_xNumFormatLB->SetFormatType(SvNumFormatType::NUMBER);
723 }
724 }
725 else
726 {
727 if (nOldNumFormat && nOldNumFormat != NUMBERFORMAT_ENTRY_NOT_FOUND)
728 m_xNumFormatLB->SetDefFormat(nOldNumFormat);
729 else
730 m_xNumFormatLB->SetFormatType(SvNumFormatType::NUMBER);
731 }
732 }
733
734 switch (nTypeId)
735 {
737 {
738 if (!IsFieldEdit() || bSpecialFormat)
739 {
740 OUString sId(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND));
741 int nOldIndex = rWidget.get_selected_index();
742 rWidget.insert(0, SwResId(FMT_MARK_TEXT), &sId, nullptr, nullptr);
743 rWidget.insert(1, SwResId(FMT_USERVAR_CMD), &sId, nullptr, nullptr);
744 if (nOldIndex != -1)
745 rWidget.select(nOldIndex + 2);
746 }
747 }
748 break;
749
751 {
752 if (!IsFieldEdit() || bSpecialFormat)
753 {
754 OUString sId(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND));
755 int nOldIndex = rWidget.get_selected_index();
756 rWidget.insert(0, SwResId(FMT_SETVAR_TEXT), &sId, nullptr, nullptr);
757 if (nOldIndex != -1)
758 rWidget.select(nOldIndex + 1);
759 }
760 }
761 break;
762
764 {
765 OUString sId(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND));
766 int nOldIndex = rWidget.get_selected_index();
767 rWidget.insert(0, SwResId(FMT_GETVAR_NAME), &sId, nullptr, nullptr);
768 if (nOldIndex != -1)
769 rWidget.select(nOldIndex + 1);
770 }
771 break;
772
774 {
775 OUString sId(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND));
776 int nOldIndex = rWidget.get_selected_index();
777 rWidget.insert(0, SwResId(FMT_GETVAR_NAME), &sId, nullptr, nullptr);
778 if (nOldIndex != -1)
779 rWidget.select(nOldIndex + 1);
780 }
781 break;
782
783 default: break;
784 }
785
786 if (IsFieldEdit() && bSpecialFormat)
787 {
788 if (nTypeId == SwFieldTypesEnum::User && (GetCurField()->GetSubType() & nsSwExtendedSubType::SUB_CMD))
789 rWidget.select(1);
790 else
791 rWidget.select(0);
792 }
793 else
794 {
795 if (!nOldNumFormat && (nNumFormatSel = rWidget.find_text(sOldNumSel)) != -1)
796 rWidget.select(nNumFormatSel);
797 else if (nOldNumFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
798 rWidget.select_text(sOldSel);
799 }
800
801 const sal_uInt16 nSize = GetFieldMgr().GetFormatCount(nTypeId, IsFieldDlgHtmlMode());
802
803 OUString sSelectId;
804
805 for (sal_uInt16 i = 0; i < nSize; i++)
806 {
807 const sal_uInt16 nFieldId = GetFieldMgr().GetFormatId( nTypeId, i );
808 OUString sId(OUString::number(nFieldId));
809 m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr(nTypeId, i));
810 if (IsFieldEdit() && GetCurField() && nFieldId == GetCurField()->GetFormat())
811 sSelectId = sId;
812 }
813
814 m_xFormatLB->thaw();
815 if (!sSelectId.isEmpty())
816 m_xFormatLB->select_id(sSelectId);
817
818 if (nSize && (!IsFieldEdit() || m_xFormatLB->get_selected_index() == -1))
819 {
820 int nIndex = m_xFormatLB->find_text(sOldSel);
821 if (nIndex == -1)
822 nIndex = m_xFormatLB->find_text(SwResId(FMT_NUM_PAGEDESC));
823 if (nIndex == -1)
824 nIndex = m_xFormatLB->find_text(SwResId(FMT_NUM_ARABIC));
825 if (nIndex == -1)
826 nIndex = 0;
827 m_xFormatLB->select(nIndex);
828 }
829}
830
831// Modify
833{
834 OUString sValue(m_xValueED->get_text());
835 bool bHasValue = !sValue.isEmpty();
836 const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
837 bool bInsert = false, bApply = false, bDelete = false;
838
839 OUString sName( m_xNameED->get_text() );
840 sal_Int32 nLen = sName.getLength();
841
842 switch( nTypeId )
843 {
849 if ( sName.getLength() != nLen )
850 {
851 nLen = sName.getLength();
852 int nStartPos, nEndPos;
853 m_xNameED->get_selection_bounds(nStartPos, nEndPos);
854 m_xNameED->set_text( sName );
855 m_xNameED->select_region(nStartPos, nEndPos); // restore Cursorpos
856 }
857 break;
858 default: break;
859 }
860
861 // check buttons
862 switch (nTypeId)
863 {
865 if( nLen )
866 {
867 // is there already a corresponding type
868 bInsert = bApply = true;
869
870 SwFieldType* pType = GetFieldMgr().GetFieldType(SwFieldIds::Dde, sName);
871
872 SwWrtShell *pSh = GetWrtShell();
873 if(!pSh)
874 pSh = ::GetActiveWrtShell();
875 if(pSh && pType)
876 bDelete = !pSh->IsUsed( *pType );
877 }
878 break;
879
881 if( nLen )
882 {
883 // is there already a corresponding type
884 SwFieldType* pType = GetFieldMgr().GetFieldType(SwFieldIds::User, sName);
885
886 SwWrtShell *pSh = GetWrtShell();
887 if(!pSh)
888 pSh = ::GetActiveWrtShell();
889 if(pSh && pType)
890 bDelete = !pSh->IsUsed( *pType );
891
892 pType = GetFieldMgr().GetFieldType(SwFieldIds::SetExp, sName);
893 if (!pType) // no name conflict with variables
894 {
895 // user fields can also be inserted without content!
896 // Bug #56845
897 bInsert = bApply = true;
898 }
899 }
900 break;
901
902 default:
903 bInsert = true;
904
905 if (nTypeId == SwFieldTypesEnum::Set || nTypeId == SwFieldTypesEnum::Sequence)
906 {
907 SwSetExpFieldType* pFieldType = static_cast<SwSetExpFieldType*>(
908 GetFieldMgr().GetFieldType(SwFieldIds::SetExp, sName));
909
910 if (pFieldType)
911 {
912
913 SwWrtShell *pSh = GetWrtShell();
914 if(!pSh)
915 pSh = ::GetActiveWrtShell();
916 if(pSh)
917 {
919 sal_uInt16 i;
920
921 for (i = 0; i < INIT_FLDTYPES; i++)
922 {
923 SwFieldType* pType = (*p)[ i ].get();
924 if (pType == pFieldType)
925 break;
926 }
927
928 if (i >= INIT_FLDTYPES && !pSh->IsUsed(*pFieldType))
929 bDelete = true;
930
931 if (nTypeId == SwFieldTypesEnum::Sequence && !(pFieldType->GetType() & nsSwGetSetExpType::GSE_SEQ))
932 bInsert = false;
933
934 if (nTypeId == SwFieldTypesEnum::Set && (pFieldType->GetType() & nsSwGetSetExpType::GSE_SEQ))
935 bInsert = false;
936 }
937 }
938 if (GetFieldMgr().GetFieldType(SwFieldIds::User, sName))
939 bInsert = false;
940 }
941
942 if (!nLen && (nTypeId == SwFieldTypesEnum::Set || nTypeId == SwFieldTypesEnum::Input ||
943 (!IsFieldEdit() && nTypeId == SwFieldTypesEnum::Get ) ) )
944 bInsert = false;
945
946 if( (nTypeId == SwFieldTypesEnum::Set || nTypeId == SwFieldTypesEnum::Formel) &&
947 !bHasValue )
948 bInsert = false;
949 break;
950 }
951
952 m_xNewPB->set_sensitive(bApply);
953 m_xDelPB->set_sensitive(bDelete);
954 EnableInsert(bInsert);
955}
956
957IMPL_LINK(SwFieldVarPage, TBClickHdl, weld::Button&, rBox, void)
958{
959 const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
960
961 if (&rBox == m_xDelPB.get())
962 {
963 if( nTypeId == SwFieldTypesEnum::User )
964 GetFieldMgr().RemoveFieldType(SwFieldIds::User, m_xSelectionLB->get_selected_text());
965 else
966 {
967 SwFieldIds nWhich;
968
969 switch(nTypeId)
970 {
973 nWhich = SwFieldIds::SetExp;
974 break;
975 default:
976 nWhich = SwFieldIds::Dde;
977 break;
978 }
979
980 GetFieldMgr().RemoveFieldType(nWhich, m_xSelectionLB->get_selected_text());
981 }
982
983 UpdateSubType();
984 SwWrtShell *pSh = GetWrtShell();
985 if(!pSh)
986 pSh = ::GetActiveWrtShell();
987 if(pSh)
988 {
989 pSh->SetModified();
990 }
991 }
992 else if (&rBox == m_xNewPB.get())
993 {
994 OUString sName(m_xNameED->get_text()), sValue(m_xValueED->get_text());
995 SwFieldType* pType = nullptr;
997 sal_Int32 nNumFormatPos = m_xNumFormatLB->get_selected_index();
998
999 switch (nTypeId)
1000 {
1004 default: break;
1005 }
1006 pType = GetFieldMgr().GetFieldType(nId, sName);
1007
1008 int nFormat = m_xFormatLB->get_selected_index();
1009 if (nFormat != -1)
1010 nFormat = m_xFormatLB->get_id(nFormat).toUInt32();
1011
1012 if (pType) // change
1013 {
1014 SwWrtShell *pSh = GetWrtShell();
1015 if(!pSh)
1016 pSh = ::GetActiveWrtShell();
1017 if(pSh)
1018 {
1019 pSh->StartAllAction();
1020
1021 if (nTypeId == SwFieldTypesEnum::User)
1022 {
1023 if (nNumFormatPos != -1)
1024 {
1025 // The first listbox entry is Text and second is
1026 // Formula and both are SAL_MAX_UINT32 :-/ but only if
1027 // not another yet unlisted of Additional Formats was
1028 // selected that may claim the top position :-/
1029 bool bText = false;
1030 sal_uInt32 nNumberFormat = lcl_getUsedNumFormat( *m_xNumFormatLB, bText);
1031 if (nNumberFormat && nNumberFormat != SAL_MAX_UINT32)
1032 { // Switch language to office-language because calculator expects
1033 // String in office format and it should be fed into dialog like
1034 // that
1035 nNumberFormat = SwValueField::GetSystemFormat(pSh->GetNumberFormatter(), nNumberFormat);
1036 }
1037 static_cast<SwUserFieldType*>(pType)->SetContent(m_xValueED->get_text(), nNumberFormat);
1038 static_cast<SwUserFieldType*>(pType)->SetType(
1040 }
1041 }
1042 else
1043 {
1044 if (nFormat != -1)
1045 {
1046 // DDE-Topics/-Items can have blanks in their names!
1047 // That's not being considered here yet.
1048 sal_Int32 nTmpPos = 0;
1049 sValue = sValue.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nTmpPos );
1050 sValue = sValue.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nTmpPos );
1051 static_cast<SwDDEFieldType*>(pType)->SetCmd(sValue);
1052 static_cast<SwDDEFieldType*>(pType)->SetType(static_cast<SfxLinkUpdateMode>(nFormat));
1053 }
1054 }
1055 pType->UpdateFields();
1056
1057 pSh->EndAllAction();
1058 }
1059 }
1060 else // new
1061 {
1062 if(nTypeId == SwFieldTypesEnum::User)
1063 {
1064 SwWrtShell *pSh = GetWrtShell();
1065 if(!pSh)
1066 pSh = ::GetActiveWrtShell();
1067 if(pSh)
1068 {
1069 SwUserFieldType aType( pSh->GetDoc(), sName );
1070
1071 if (nNumFormatPos != -1)
1072 {
1073 // The first listbox entry is Text and second is
1074 // Formula and both are SAL_MAX_UINT32 :-/ but only if
1075 // not another yet unlisted of Additional Formats was
1076 // selected that may claim the top position :-/
1077 bool bText = false;
1078 sal_uInt32 nNumberFormat = lcl_getUsedNumFormat( *m_xNumFormatLB, bText);
1080 aType.SetContent( sValue, nNumberFormat );
1081 m_xSelectionLB->append_text(sName);
1082 m_xSelectionLB->select_text(sName);
1083 GetFieldMgr().InsertFieldType( aType ); // Userfld new
1084 }
1085 }
1086 }
1087 else
1088 {
1089 if (nFormat != -1)
1090 {
1091 // DDE-Topics/-Items can have blanks in their names!
1092 // That's not being considered here yet.
1093 sal_Int32 nTmpPos = 0;
1094 sValue = sValue.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nTmpPos );
1095 sValue = sValue.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nTmpPos );
1096
1097 SwDDEFieldType aType(sName, sValue, static_cast<SfxLinkUpdateMode>(nFormat));
1098 m_xSelectionLB->append_text(sName);
1099 m_xSelectionLB->select_text(sName);
1100 GetFieldMgr().InsertFieldType(aType); // DDE-Field new
1101 }
1102 }
1103 }
1104 if (IsFieldEdit())
1105 GetFieldMgr().GetCurField(); // update FieldManager
1106
1107 UpdateSubType();
1108 }
1109}
1110
1112{
1113 bool bEnable = m_xChapterLevelLB->get_active() != 0;
1114
1115 m_xSeparatorED->set_sensitive(bEnable);
1116 m_xSeparatorFT->set_sensitive(bEnable);
1117 SeparatorHdl(*m_xSeparatorED);
1118}
1119
1121{
1122 bool bEnable = !m_xSeparatorED->get_text().isEmpty() ||
1123 m_xChapterLevelLB->get_active() == 0;
1124 EnableInsert(bEnable);
1125}
1126
1128{
1129 const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
1130
1131 OUString aVal(m_xValueED->get_text());
1132 OUString aName(m_xNameED->get_text());
1133
1134 const sal_Int32 nSubPos = m_xSelectionLB->get_selected_index();
1135 sal_uInt16 nSubType = (nSubPos == -1) ? 0 : m_xSelectionLB->get_id(nSubPos).toUInt32();
1136
1137 sal_uInt32 nFormat;
1138
1139 if (!m_xNumFormatLB->get_visible())
1140 {
1141 sal_Int32 nFormatPos = m_xFormatLB->get_selected_index();
1142
1143 if(nFormatPos == -1)
1144 nFormat = 0;
1145 else
1146 nFormat = m_xFormatLB->get_id(nFormatPos).toUInt32();
1147 }
1148 else
1149 {
1150 nFormat = m_xNumFormatLB->GetFormat();
1151
1152 if (nFormat && nFormat != NUMBERFORMAT_ENTRY_NOT_FOUND && m_xNumFormatLB->IsAutomaticLanguage())
1153 {
1154 // Switch language to office language because calculator expects
1155 // String in office format and it should be fed into the dialog
1156 // like that
1157 SwWrtShell *pSh = GetWrtShell();
1158 if(!pSh)
1159 pSh = ::GetActiveWrtShell();
1160 if(pSh)
1161 {
1162 nFormat = SwValueField::GetSystemFormat(pSh->GetNumberFormatter(), nFormat);
1163 }
1164 }
1165 }
1166 sal_Unicode cSeparator = ' ';
1167 switch (nTypeId)
1168 {
1170 {
1172
1173 if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND && m_xNumFormatLB->get_selected_text() == SwResId(FMT_USERVAR_CMD))
1174 nSubType |= nsSwExtendedSubType::SUB_CMD;
1175
1176 if (m_xInvisibleCB->get_active())
1178 break;
1179 }
1181 {
1183 if (m_xNumFormatLB->get_visible() && nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
1184 nSubType |= nsSwExtendedSubType::SUB_CMD;
1185 break;
1186 }
1188 {
1189 nSubType &= 0xff00;
1190 if (m_xNumFormatLB->get_visible() && nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
1191 nSubType |= nsSwExtendedSubType::SUB_CMD;
1192 break;
1193 }
1195 {
1197 nSubType = static_cast< sal_uInt16 >((nSubType & 0xff00) | (pType ? INP_USR : INP_VAR));
1198 break;
1199 }
1200
1202 {
1203 if (IsFieldDlgHtmlMode())
1204 {
1205 nSubType = 0x0100;
1206 nSubType = (nSubType & 0xff00) | nsSwGetSetExpType::GSE_STRING;
1207 }
1208 else
1209 nSubType = (nSubType & 0xff00) | ((nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR);
1210
1211 if (m_xInvisibleCB->get_active())
1213 break;
1214 }
1216 {
1217 nSubType = static_cast< sal_uInt16 >(m_xChapterLevelLB->get_active());
1218 if (nSubType == 0)
1219 nSubType = 0x7f;
1220 else
1221 {
1222 nSubType--;
1223 OUString sSeparator(m_xSeparatorED->get_text()[0]);
1224 cSeparator = !sSeparator.isEmpty() ? sSeparator[0] : ' ';
1225 }
1226 break;
1227 }
1229 if( SVX_NUM_CHAR_SPECIAL == nFormat )
1230 aVal = m_xValueED->get_text();
1231 break;
1232 default: break;
1233 }
1234
1235 if (!IsFieldEdit() ||
1236 m_xNameED->get_value_changed_from_saved() ||
1237 m_xValueED->get_value_changed_from_saved() ||
1238 m_xSelectionLB->get_value_changed_from_saved() ||
1239 m_xFormatLB->get_value_changed_from_saved() ||
1240 m_nOldFormat != m_xNumFormatLB->GetFormat() ||
1241 m_xInvisibleCB->get_state_changed_from_saved() ||
1242 m_xChapterLevelLB->get_value_changed_from_saved() ||
1243 m_xSeparatorED->get_value_changed_from_saved())
1244 {
1245 InsertField( nTypeId, nSubType, aName, aVal, nFormat,
1246 cSeparator, m_xNumFormatLB->IsAutomaticLanguage() );
1247 }
1248
1249 UpdateSubType();
1250
1251 return false;
1252}
1253
1254std::unique_ptr<SfxTabPage> SwFieldVarPage::Create( weld::Container* pPage, weld::DialogController* pController,
1255 const SfxItemSet *const pAttrSet)
1256{
1257 return std::make_unique<SwFieldVarPage>( pPage, pController, pAttrSet );
1258}
1259
1261{
1262 return GRP_VAR;
1263}
1264
1266{
1267 OUString sData = USER_DATA_VERSION ";";
1268 sal_Int32 nTypeSel = m_xTypeLB->get_selected_index();
1269 if( -1 == nTypeSel )
1270 nTypeSel = USHRT_MAX;
1271 else
1272 nTypeSel = m_xTypeLB->get_id(nTypeSel).toUInt32();
1273 sData += OUString::number( nTypeSel );
1274 SetUserData(sData);
1275}
1276
1277/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual const SwFieldTypes * GetFieldTypes() const =0
void SetUserData(const OUString &rString)
const OUString & GetUserData() const
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
LanguageType GetLanguage() const
static SW_DLLPUBLIC bool IsValidVarName(const OUString &rStr, OUString *pValidName=nullptr)
Definition: calc.cxx:1420
OUString const & GetCmd() const
Definition: ddefld.cxx:194
SfxLinkUpdateMode GetType() const
Definition: ddefld.hxx:82
virtual OUString GetName() const override
Only in derived classes.
Definition: ddefld.cxx:178
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:371
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
Definition: editsh.cxx:756
SwFieldType * GetFieldType(size_t nField, SwFieldIds nResId=SwFieldIds::Unknown) const
get field types with a ResId, if 0 get all
Definition: edfld.cxx:64
void SetModified()
Definition: edws.cxx:70
void EndAllAction()
Definition: edws.cxx:97
bool IsUsed(const sw::BroadcastingModify &) const
Query if the paragraph-/character-/frame-/page-style is used.
Definition: edfmt.cxx:137
static const SwFieldGroupRgn & GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
Definition: fldmgr.cxx:470
sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
Definition: fldmgr.cxx:676
sal_uInt16 GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
Definition: fldmgr.cxx:773
static const OUString & GetTypeStr(sal_uInt16 nPos)
Definition: fldmgr.cxx:532
SwFieldType * GetFieldType(SwFieldIds nResId, size_t nField=0) const
Definition: fldmgr.cxx:415
void GetSubTypes(SwFieldTypesEnum nId, std::vector< OUString > &rToFill)
Definition: fldmgr.cxx:573
const OUString & GetCurFieldPar2() const
Definition: fldmgr.hxx:137
static sal_uInt16 GetPos(SwFieldTypesEnum nTypeId)
Definition: fldmgr.cxx:554
static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos)
Definition: fldmgr.cxx:526
const OUString & GetCurFieldPar1() const
Definition: fldmgr.hxx:136
void InsertField(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType, const OUString &rPar1, const OUString &rPar2, sal_uInt32 nFormatId, sal_Unicode cDelim=' ', bool bIsAutomaticLanguage=true)
Definition: fldpage.cxx:116
sal_Int32 GetTypeSel() const
Definition: fldpage.hxx:45
void Init()
Definition: fldpage.cxx:64
void SavePos(const weld::TreeView &rLst1)
Definition: fldpage.cxx:280
SwFieldMgr & GetFieldMgr()
Definition: fldpage.hxx:81
bool IsFieldEdit() const
Definition: fldpage.hxx:62
bool IsFieldDlgHtmlMode() const
Definition: fldpage.hxx:49
void RestorePos(weld::TreeView &rLst1)
Definition: fldpage.cxx:290
sal_Int32 GetSelectionSel() const
Definition: fldpage.hxx:47
void EnableInsert(bool bEnable)
Definition: fldpage.cxx:322
bool IsRefresh() const
Definition: fldpage.hxx:50
SwField * GetCurField()
Definition: fldpage.hxx:51
SwWrtShell * GetWrtShell()
Definition: fldpage.hxx:52
void SetSelectionSel(sal_Int32 nSet)
Definition: fldpage.hxx:48
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:247
virtual void UpdateFields()
Definition: fldbas.cxx:219
sal_uInt32 m_nOldFormat
Definition: fldvar.hxx:53
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: fldvar.cxx:1127
virtual void Reset(const SfxItemSet *rSet) override
Definition: fldvar.cxx:97
std::unique_ptr< weld::Entry > m_xNameED
Definition: fldvar.hxx:36
void FillFormatLB(SwFieldTypesEnum nTypeId)
Definition: fldvar.cxx:685
std::unique_ptr< weld::TreeView > m_xSelectionLB
Definition: fldvar.hxx:34
virtual ~SwFieldVarPage() override
Definition: fldvar.cxx:93
SwFieldVarPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *pSet)
Definition: fldvar.cxx:42
OUString m_sOldNameFT
Definition: fldvar.hxx:51
std::unique_ptr< weld::Label > m_xNameFT
Definition: fldvar.hxx:35
OUString m_sOldValueFT
Definition: fldvar.hxx:50
std::unique_ptr< weld::Button > m_xNewPB
Definition: fldvar.hxx:47
std::unique_ptr< weld::Button > m_xDelPB
Definition: fldvar.hxx:48
std::unique_ptr< weld::TreeView > m_xFormatLB
Definition: fldvar.hxx:41
std::unique_ptr< weld::Label > m_xValueFT
Definition: fldvar.hxx:37
virtual void FillUserData() override
Definition: fldvar.cxx:1265
void UpdateSubType()
Definition: fldvar.cxx:579
std::unique_ptr< weld::ComboBox > m_xChapterLevelLB
Definition: fldvar.hxx:43
void SubTypeHdl(const weld::TreeView *)
Definition: fldvar.cxx:241
std::unique_ptr< ConditionEdit > m_xValueED
Definition: fldvar.hxx:38
std::unique_ptr< weld::TreeView > m_xTypeLB
Definition: fldvar.hxx:32
std::unique_ptr< weld::CheckButton > m_xInvisibleCB
Definition: fldvar.hxx:44
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: fldvar.cxx:1254
std::unique_ptr< weld::Widget > m_xChapterFrame
Definition: fldvar.hxx:42
virtual sal_uInt16 GetGroup() override
Definition: fldvar.cxx:1260
std::unique_ptr< SwNumFormatTreeView > m_xNumFormatLB
Definition: fldvar.hxx:40
std::unique_ptr< weld::Entry > m_xSeparatorED
Definition: fldvar.hxx:46
std::unique_ptr< weld::Widget > m_xSelection
Definition: fldvar.hxx:33
std::unique_ptr< weld::Widget > m_xFormat
Definition: fldvar.hxx:39
bool m_bInit
Definition: fldvar.hxx:54
Base class of all fields.
Definition: fldbas.hxx:296
SwFieldTypesEnum GetTypeId() const
Definition: fldbas.cxx:270
bool IsAutomaticLanguage() const
Definition: fldbas.hxx:387
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:407
SwFieldType * GetTyp() const
Definition: fldbas.hxx:402
OUString GetInputOrDateTime() const
Query formula or formatted value for dialog.
Definition: fldbas.cxx:889
virtual sal_uInt32 GetFormat() const override
Definition: numfmtlb.cxx:362
int get_selected_index() const
Definition: numfmtlb.hxx:131
sal_uInt16 GetType() const
Definition: expfld.hxx:198
The shared part of a user field.
Definition: usrfld.hxx:35
virtual OUString GetName() const override
Only in derived classes.
Definition: usrfld.cxx:212
OUString GetContent(sal_uInt32 nFormat=0) const
Definition: usrfld.cxx:283
sal_uInt16 GetType() const
Definition: usrfld.hxx:90
void SetContent(const OUString &rStr, sal_uInt32 nFormat=0)
Definition: usrfld.cxx:299
void SetType(sal_uInt16)
Definition: usrfld.hxx:93
OUString GetInputOrDateTime(sal_uInt32 nFormat) const
Definition: usrfld.cxx:278
static sal_uInt32 GetSystemFormat(SvNumberFormatter *pFormatter, sal_uInt32 nFormat)
get format in office language
Definition: fldbas.cxx:718
SwDoc * GetDoc() const
Definition: viewsh.hxx:308
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
virtual int find_text(const OUString &rText) const=0
virtual OUString get_text(int row, int col=-1) const=0
virtual void insert(const TreeIter *pParent, int pos, const OUString *pStr, const OUString *pId, const OUString *pIconName, VirtualDevice *pImageSurface, bool bChildrenOnDemand, TreeIter *pRet)=0
virtual void select(int pos)=0
virtual int get_selected_index() const=0
void select_text(const OUString &rText)
int nCount
virtual OUString GetName() const override
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
float u
SwFieldTypesEnum
List of FieldTypes at UI.
Definition: fldbas.hxx:98
@ UF_STRING
Definition: fldbas.hxx:228
@ INP_VAR
Definition: fldbas.hxx:224
@ INP_USR
Definition: fldbas.hxx:223
SwFieldIds
Definition: fldbas.hxx:49
@ Database
For old documents the Field-Which IDs must be preserved !!!
void FillFieldSelect(weld::TreeView &rListBox)
Definition: flddinf.cxx:47
@ GRP_VAR
Definition: fldmgr.hxx:59
#define FIELD_COLUMN_WIDTH
Definition: fldpage.hxx:25
IMPL_LINK_NOARG(SwFieldVarPage, TypeHdl, weld::TreeView &, void)
Definition: fldvar.cxx:193
#define USER_DATA_VERSION_1
Definition: fldvar.cxx:39
#define USER_DATA_VERSION
Definition: fldvar.cxx:40
static sal_uInt32 lcl_getUsedNumFormat(const SwNumFormatTreeView &rNumFormatLB, bool &rbText)
Definition: fldvar.cxx:228
IMPL_LINK(SwFieldVarPage, SubTypeListBoxHdl, weld::TreeView &, rBox, void)
Definition: fldvar.cxx:223
OUString sName
sal_Int32 nIndex
OUString aName
void * p
SfxLinkUpdateMode
int i
const SwExtendedSubType SUB_CMD
Show command.
Definition: fldbas.hxx:216
const SwExtendedSubType SUB_INVISIBLE
Invisible.
Definition: fldbas.hxx:217
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:209
const SwGetSetExpType GSE_EXPR
Expression.
Definition: fldbas.hxx:208
const SwGetSetExpType GSE_FORMULA
Formula.
Definition: fldbas.hxx:210
const SwGetSetExpType GSE_STRING
String.
Definition: fldbas.hxx:207
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
const sal_Unicode cTokenSeparator
sal_Int16 nId
sal_uInt16 nStart
Definition: fldmgr.hxx:64
sal_uInt16 nEnd
Definition: fldmgr.hxx:65
SVX_NUM_CHAR_SPECIAL
SwWrtShell * GetActiveWrtShell()
Definition: swmodul1.cxx:108
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:168
#define INIT_FLDTYPES
Definition: swtypes.hxx:105
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:92
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
#define SAL_MAX_UINT32
OUString sId
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND