38 "ContentControlDialog")
39 , m_rWrtShell(rWrtShell)
40 , m_xShowingPlaceHolderCB(m_xBuilder->weld_check_button(
"showing_place_holder"))
41 , m_xAlias(m_xBuilder->weld_entry(
"aliasentry"))
42 , m_xTag(m_xBuilder->weld_entry(
"tagentry"))
43 , m_xId(m_xBuilder->weld_spin_button(
"idspinbutton"))
44 , m_xTabIndex(m_xBuilder->weld_spin_button(
"tabindexspinbutton"))
45 , m_xCheckboxFrame(m_xBuilder->weld_frame(
"checkboxframe"))
46 , m_xCheckedState(m_xBuilder->weld_entry(
"checkboxcheckedentry"))
47 , m_xCheckedStateBtn(m_xBuilder->weld_button(
"btncheckboxchecked"))
48 , m_xUncheckedState(m_xBuilder->weld_entry(
"checkboxuncheckedentry"))
49 , m_xUncheckedStateBtn(m_xBuilder->weld_button(
"btncheckboxunchecked"))
50 , m_xListItemsFrame(m_xBuilder->weld_frame(
"listitemsframe"))
51 , m_xListItems(m_xBuilder->weld_tree_view(
"listitems"))
52 , m_xListItemButtons(m_xBuilder->weld_box(
"listitembuttons"))
53 , m_xInsertBtn(m_xBuilder->weld_button(
"add"))
54 , m_xRenameBtn(m_xBuilder->weld_button(
"modify"))
55 , m_xDeleteBtn(m_xBuilder->weld_button(
"remove"))
56 , m_xMoveUpBtn(m_xBuilder->weld_button(
"moveup"))
57 , m_xMoveDownBtn(m_xBuilder->weld_button(
"movedown"))
58 , m_xDateFrame(m_xBuilder->weld_frame(
"dateframe"))
59 , m_xDateFormat(new
SwNumFormatTreeView(m_xBuilder->weld_tree_view(
"date_formats_treeview")))
60 , m_xOk(m_xBuilder->weld_button(
"ok"))
119 m_xId->set_increments(1, 10);
124 m_xId->set_editable(
false);
131 const sal_Int32 nTabIndex =
static_cast<sal_Int32
>(
m_pContentControl->GetTabIndex());
175 if (!sFormatString.isEmpty() && !sLang.isEmpty())
179 sal_uInt32 nFormat = pNumberFormatter->
GetEntryKey(sFormatString, aLangType);
182 sal_Int32 nCheckPos = 0;
184 pNumberFormatter->
PutEntry(sFormatString, nCheckPos,
nType, nFormat,
208 if (!m_pContentControl)
213 bool bChanged =
false;
214 if (m_xShowingPlaceHolderCB->get_state_changed_from_saved())
216 bool bShowingPlaceHolder = m_xShowingPlaceHolderCB->get_state() ==
TRISTATE_TRUE;
217 m_pContentControl->SetShowingPlaceHolder(bShowingPlaceHolder);
221 if (m_xAlias->get_value_changed_from_saved())
223 m_pContentControl->SetAlias(m_xAlias->get_text());
227 if (m_xTag->get_value_changed_from_saved())
229 m_pContentControl->SetTag(m_xTag->get_text());
233 if (m_xId->get_value_changed_from_saved())
235 m_pContentControl->SetId(o3tl::narrowing<sal_Int32>(m_xId->get_value()));
239 if (m_xTabIndex->get_value_changed_from_saved())
241 m_pContentControl->SetTabIndex(o3tl::narrowing<sal_uInt32>(m_xTabIndex->get_value()));
245 if (m_xCheckedState->get_value_changed_from_saved())
247 m_pContentControl->SetCheckedState(m_xCheckedState->get_text());
250 if (m_xUncheckedState->get_value_changed_from_saved())
252 m_pContentControl->SetUncheckedState(m_xUncheckedState->get_text());
255 std::vector<SwContentControlListItem> aItems;
256 for (
int i = 0;
i < m_xListItems->n_children(); ++
i)
260 aItem.
m_aValue = m_xListItems->get_text(
i, 1);
261 aItems.push_back(aItem);
263 if (aItems != m_aSavedListItems)
265 m_pContentControl->SetListItems(aItems);
269 if (m_pContentControl->GetDate())
282 if (aLanguage != m_pContentControl->GetDateLanguage())
284 m_pContentControl->SetDateLanguage(aLanguage);
292 m_rWrtShell.GetDoc()->getIDocumentState().SetModified();
295 m_rWrtShell.HideCursor();
296 m_rWrtShell.ShowCursor();
307 if (&rButton == m_xCheckedStateBtn.get())
309 cBullet = m_pContentControl->GetCheckedState().iterateCodePoints(&
nIndex);
311 else if (&rButton == m_xUncheckedStateBtn.get())
313 cBullet = m_pContentControl->GetUncheckedState().iterateCodePoints(&
nIndex);
315 aMap.SetChar(cBullet);
321 cBullet =
aMap.GetChar();
322 if (&rButton == m_xCheckedStateBtn.get())
324 m_xCheckedState->set_text(OUString(&cBullet, 1));
326 else if (&rButton == m_xUncheckedStateBtn.get())
328 m_xUncheckedState->set_text(OUString(&cBullet, 1));
334 std::shared_ptr<SwContentControlListItem> aItem = std::make_shared<SwContentControlListItem>();
337 m_xListItemDialog->StartExecuteAsync([
this, aItem](sal_Int32 nResult) {
340 if (aItem->m_aDisplayText.isEmpty() && aItem->m_aValue.isEmpty())
346 if (aItem->m_aValue.isEmpty())
348 aItem->m_aValue = aItem->m_aDisplayText;
351 int nRow = m_xListItems->n_children();
352 m_xListItems->append_text(aItem->m_aDisplayText);
353 m_xListItems->set_text(nRow, aItem->m_aValue, 1);
356 m_xListItemDialog.disposeAndClear();
362 int nRow = m_xListItems->get_selected_index();
368 std::shared_ptr<SwContentControlListItem> aItem = std::make_shared<SwContentControlListItem>();
369 aItem->m_aDisplayText = m_xListItems->get_text(nRow, 0);
370 aItem->m_aValue = m_xListItems->get_text(nRow, 1);
373 m_xListItemDialog->StartExecuteAsync([
this, aItem, nRow](sal_Int32 nResult) {
376 if (aItem->m_aDisplayText.isEmpty() && aItem->m_aValue.isEmpty())
382 if (aItem->m_aValue.isEmpty())
384 aItem->m_aValue = aItem->m_aDisplayText;
387 m_xListItems->set_text(nRow, aItem->m_aDisplayText, 0);
388 m_xListItems->set_text(nRow, aItem->m_aValue, 1);
391 m_xListItemDialog.disposeAndClear();
397 int nRow = m_xListItems->get_selected_index();
403 m_xListItems->remove(nRow);
408 int nRow = m_xListItems->get_selected_index();
416 aItem.
m_aValue = m_xListItems->get_text(nRow, 1);
417 m_xListItems->remove(nRow);
420 m_xListItems->set_text(nRow, aItem.
m_aValue, 1);
421 m_xListItems->select(nRow);
426 int nRow = m_xListItems->get_selected_index();
427 int nEndPos = m_xListItems->n_children() - 1;
428 if (nRow < 0 || nRow >= nEndPos)
435 aItem.
m_aValue = m_xListItems->get_text(nRow, 1);
436 m_xListItems->remove(nRow);
439 m_xListItems->set_text(nRow, aItem.
m_aValue, 1);
440 m_xListItems->select(nRow);
445 int nRow = m_xListItems->get_selected_index();
448 m_xRenameBtn->set_sensitive(
false);
449 m_xDeleteBtn->set_sensitive(
false);
453 m_xRenameBtn->set_sensitive(
true);
454 m_xDeleteBtn->set_sensitive(
true);
459 m_xMoveUpBtn->set_sensitive(
false);
463 m_xMoveUpBtn->set_sensitive(
true);
466 int nEndPos = m_xListItems->n_children() - 1;
467 if (nRow < 0 || nRow >= nEndPos)
469 m_xMoveDownBtn->set_sensitive(
false);
473 m_xMoveDownBtn->set_sensitive(
true);
Reference< XExecutableDialog > m_xDialog
LanguageType getLanguageType(bool bResolveSystem=true) const
const OUString & getBcp47(bool bResolveSystem=true) const
constexpr tools::Long Width() const
virtual VclPtr< AbstractSwContentControlListItemDlg > CreateSwContentControlListItemDlg(weld::Window *pParent, SwContentControlListItem &rItem)=0
The content control dialog allows editing the properties of the content control under the cursor.
std::unique_ptr< weld::Box > m_xListItemButtons
std::unique_ptr< weld::Button > m_xUncheckedStateBtn
std::unique_ptr< weld::Button > m_xRenameBtn
std::vector< SwContentControlListItem > m_aSavedListItems
std::unique_ptr< weld::Frame > m_xDateFrame
std::shared_ptr< SwContentControl > m_pContentControl
std::unique_ptr< weld::Button > m_xMoveUpBtn
std::unique_ptr< weld::SpinButton > m_xTabIndex
std::unique_ptr< weld::Button > m_xInsertBtn
std::unique_ptr< weld::TreeView > m_xListItems
std::unique_ptr< weld::Frame > m_xListItemsFrame
std::unique_ptr< weld::CheckButton > m_xShowingPlaceHolderCB
std::unique_ptr< weld::Button > m_xMoveDownBtn
std::unique_ptr< weld::SpinButton > m_xId
std::unique_ptr< weld::Frame > m_xCheckboxFrame
std::unique_ptr< weld::Entry > m_xAlias
std::unique_ptr< weld::Entry > m_xUncheckedState
SwContentControlDlg(weld::Window *pParent, SwWrtShell &rSh)
std::unique_ptr< weld::Button > m_xCheckedStateBtn
std::unique_ptr< weld::Button > m_xDeleteBtn
virtual ~SwContentControlDlg() override
std::unique_ptr< weld::Entry > m_xTag
std::unique_ptr< SwNumFormatTreeView > m_xDateFormat
std::unique_ptr< weld::Button > m_xOk
std::unique_ptr< weld::Entry > m_xCheckedState
VclPtr< VclAbstractDialog > m_xListItemDialog
Represents one list item in a content control dropdown list.
OUString m_aValue
This must not be empty.
OUString m_aDisplayText
This may be empty, ToString() falls back to m_aValue.
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
SfxPoolItem subclass that wraps an SwContentControl.
const std::shared_ptr< SwContentControl > & GetContentControl() const
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
const SwPosition * Start() const
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
const SwFormatContentControl & GetContentControl() const
SwTextAttr subclass that tracks the location of the wrapped SwFormatContentControl.
SwTextNode is a paragraph in the document model.
SwTextAttr * GetTextAttrAt(sal_Int32 const nIndex, sal_uInt16 const nWhich, ::sw::GetTextAttrMode const eMode=::sw::GetTextAttrMode::Default) const
get the innermost text attribute covering position nIndex.
Used by the UI to modify the document model.
virtual int get_height_rows(int nRows) const=0
IMPL_LINK_NOARG(SwContentControlDlg, OkHdl, weld::Button &, void)
IMPL_LINK(SwContentControlDlg, SelectCharHdl, weld::Button &, rButton, void)
constexpr TypedWhichId< SwFormatContentControl > RES_TXTATR_CONTENTCONTROL(56)
#define LANGUAGE_DONTKNOW
#define LINK(Instance, Class, Member)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
@ Parent
EXPAND : (Start < nIndex <= End)
SwAbstractDialogFactory & GetFactory()
HashMap_OWString_Interface aMap
Marks a position in the document model.
sal_Int32 GetContentIndex() const
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND