33 std::unique_ptr<weld::Label>
m_xLabel;
34 std::unique_ptr<weld::Entry> m_xEdInput;
37 SwStringInputDlg(
weld::Window* pParent,
const OUString& rTitle,
38 const OUString& rEditTitle,
const OUString& rDefault)
41 ,
m_xLabel(m_xBuilder->weld_label(
"name"))
42 , m_xEdInput(m_xBuilder->weld_entry(
"edit"))
46 m_xEdInput->set_text(rDefault);
47 m_xEdInput->select_region(0, -1);
50 OUString GetInputString()
const
52 return m_xEdInput->get_text();
62 "AutoFormatTableDialog")
63 , m_aStrTitle(
SwResId(STR_ADD_AUTOFORMAT_TITLE))
64 , m_aStrLabel(
SwResId(STR_ADD_AUTOFORMAT_LABEL))
65 , m_aStrClose(
SwResId(STR_BTN_AUTOFORMAT_CLOSE))
66 , m_aStrDelTitle(
SwResId(STR_DEL_AUTOFORMAT_TITLE))
67 , m_aStrDelMsg(
SwResId(STR_DEL_AUTOFORMAT_MSG))
68 , m_aStrRenameTitle(
SwResId(STR_RENAME_AUTOFORMAT_TITLE))
69 , m_aStrInvalidFormat(
SwResId(STR_INVALID_AUTOFORMAT_NAME))
73 , m_bCoreDataChanged(false)
74 , m_bSetAutoFormat(bAutoFormat)
76 , m_xLbFormat(m_xBuilder->weld_tree_view(
"formatlb"))
77 , m_xBtnNumFormat(m_xBuilder->weld_check_button(
"numformatcb"))
78 , m_xBtnBorder(m_xBuilder->weld_check_button(
"bordercb"))
79 , m_xBtnFont(m_xBuilder->weld_check_button(
"fontcb"))
80 , m_xBtnPattern(m_xBuilder->weld_check_button(
"patterncb"))
81 , m_xBtnAlignment(m_xBuilder->weld_check_button(
"alignmentcb"))
82 , m_xBtnCancel(m_xBuilder->weld_button(
"cancel"))
83 , m_xBtnAdd(m_xBuilder->weld_button(
"add"))
84 , m_xBtnRemove(m_xBuilder->weld_button(
"remove"))
85 , m_xBtnRename(m_xBuilder->weld_button(
"rename"))
86 , m_xWndPreview(new
weld::CustomWeld(*m_xBuilder,
"preview", m_aWndPreview))
91 const int nWidth =
m_xLbFormat->get_approximate_digit_width() * 32;
92 const int nHeight =
m_xLbFormat->get_height_rows(8);
185 bool bCheck = rBtn.get_active(), bDataChgd =
true;
187 if (&rBtn == m_xBtnNumFormat.get())
189 else if (&rBtn == m_xBtnBorder.get())
191 else if (&rBtn == m_xBtnFont.get())
193 else if (&rBtn == m_xBtnPattern.get())
195 else if (&rBtn == m_xBtnAlignment.get())
202 if( !m_bCoreDataChanged )
204 m_xBtnCancel->set_label(m_aStrClose);
205 m_bCoreDataChanged =
true;
208 m_aWndPreview.NotifyChange(rData);
214 bool bOk =
false, bFormatInserted =
false;
217 SwStringInputDlg aDlg(
m_xDialog.get(), m_aStrTitle, m_aStrLabel, OUString());
220 const OUString aFormatName(aDlg.GetInputString());
222 if ( !aFormatName.isEmpty() )
225 for(
n = 0;
n < m_xTableTable->size(); ++
n )
226 if( (*m_xTableTable)[
n].
GetName() == aFormatName )
229 if(
n >= m_xTableTable->size() )
232 std::unique_ptr<SwTableAutoFormat> pNewData(
234 bool bGetOk =
m_pShell->GetTableAutoFormat( *pNewData );
235 SAL_WARN_IF(!bGetOk,
"sw.ui",
"GetTableAutoFormat failed for: " << aFormatName);
238 for(
n = 1;
n < m_xTableTable->size(); ++
n )
239 if( (*m_xTableTable)[
n ].
GetName() > aFormatName )
242 m_xTableTable->InsertAutoFormat(
n, std::move(pNewData));
243 m_xLbFormat->insert_text(m_nDfltStylePos +
n, aFormatName);
244 m_xLbFormat->select(m_nDfltStylePos +
n);
245 bFormatInserted =
true;
246 m_xBtnAdd->set_sensitive(
false);
247 if ( !m_bCoreDataChanged )
249 m_xBtnCancel->set_label(m_aStrClose);
250 m_bCoreDataChanged =
true;
253 SelFormatHdl(*m_xLbFormat);
258 if( !bFormatInserted )
271 OUString aMessage = m_aStrDelMsg +
"\n\n" +
272 m_xLbFormat->get_selected_text() +
"\n";
275 VclButtonsType::OkCancel, m_aStrDelTitle));
276 xBox->set_secondary_text(aMessage);
278 if (xBox->run() ==
RET_OK)
282 m_xLbFormat->remove(m_nDfltStylePos +
nIndex);
283 m_xLbFormat->select(m_nDfltStylePos +
nIndex - 1);
285 m_xTableTable->EraseAutoFormat(
nIndex);
290 m_xBtnRemove->set_sensitive(
false);
291 m_xBtnRename->set_sensitive(
false);
294 if( !m_bCoreDataChanged )
296 m_xBtnCancel->set_label(m_aStrClose);
297 m_bCoreDataChanged =
true;
301 SelFormatHdl(*m_xLbFormat);
309 SwStringInputDlg aDlg(
m_xDialog.get(), m_aStrRenameTitle, m_aStrLabel, m_xLbFormat->get_selected_text());
312 bool bFormatRenamed =
false;
313 const OUString aFormatName(aDlg.GetInputString());
315 if ( !aFormatName.isEmpty() )
318 for(
n = 0;
n < m_xTableTable->size(); ++
n )
319 if ((*m_xTableTable)[
n].
GetName() == aFormatName)
322 if(
n >= m_xTableTable->size() )
327 m_xLbFormat->remove(m_nDfltStylePos +
nIndex);
328 std::unique_ptr<SwTableAutoFormat>
p(
329 m_xTableTable->ReleaseAutoFormat(
nIndex));
331 p->SetName( aFormatName );
334 for(
n = 1;
n < m_xTableTable->size(); ++
n )
335 if ((*m_xTableTable)[
n].
GetName() > aFormatName)
340 m_xTableTable->InsertAutoFormat(
n, std::move(
p) );
341 m_xLbFormat->insert_text(m_nDfltStylePos +
n, aFormatName);
342 m_xLbFormat->select(m_nDfltStylePos +
n);
344 if ( !m_bCoreDataChanged )
346 m_xBtnCancel->set_label(m_aStrClose);
347 m_bCoreDataChanged =
true;
350 SelFormatHdl(*m_xLbFormat);
352 bFormatRenamed =
true;
356 if( !bFormatRenamed )
369 bool bBtnEnable =
false;
371 int nSelPos = m_xLbFormat->get_selected_index();
372 if (nSelPos >= m_nDfltStylePos)
374 m_nIndex = nSelPos - m_nDfltStylePos;
375 m_aWndPreview.NotifyChange((*m_xTableTable)[m_nIndex]);
376 bBtnEnable = 0 != m_nIndex;
377 UpdateChecks( (*m_xTableTable)[m_nIndex],
true );
391 if (nOldIdx != m_nIndex)
392 m_aWndPreview.NotifyChange(aTmp);
393 UpdateChecks( aTmp,
false );
396 m_xBtnRemove->set_sensitive(bBtnEnable);
397 m_xBtnRename->set_sensitive(bBtnEnable);
402 short nRet = SfxDialogController::run();
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
void SetTableStyle(const OUString &rStyleName)
Set table style of the current table.
static ShellResource * GetShellRes()
Used by the UI to modify the document model.
std::unique_ptr< weld::Label > m_xLabel
virtual OUString GetName() const override
#define LINK(Instance, Class, Member)
#define SAL_WARN_IF(condition, area, stream)
OUString SwResId(TranslateId aId)
IMPL_LINK_NOARG(SwAutoFormatDlg, AddHdl, weld::Button &, void)
IMPL_LINK(SwAutoFormatDlg, CheckHdl, weld::Toggleable &, rBtn, void)