26 #include <osl/diagnose.h>
35 #include <strings.hrc>
37 #define PATH_CASE_SENSITIVE 0x01
38 #define PATH_READONLY 0x02
40 #define RENAME_TOKEN_DELIM u'\x0001'
45 "EditCategoriesDialog")
48 , m_xNameED(m_xBuilder->weld_entry(
"name"))
49 , m_xPathLB(m_xBuilder->weld_combo_box(
"pathlb"))
50 , m_xGroupTLB(m_xBuilder->weld_tree_view(
"group"))
51 , m_xNewPB(m_xBuilder->weld_button(
"new"))
52 , m_xDelPB(m_xBuilder->weld_button(
"delete"))
53 , m_xRenamePB(m_xBuilder->weld_button(
"rename"))
55 int nWidth =
m_xGroupTLB->get_approximate_digit_width() * 34;
60 std::vector<int> aWidths;
61 aWidths.push_back(nWidth);
75 for (
size_t i = 0;
i < rPathArr.size(); ++
i)
79 sal_uInt32 nCaseReadonly = 0;
86 m_xPathLB->append(OUString::number(nCaseReadonly), sPath);
94 const OUString sMyAutoTextEnglish(
"My AutoText");
95 for(
size_t i = 0;
i < nCount; ++
i)
103 if ( sTitle == sMyAutoTextEnglish )
108 const OUString
sId(OUString::number(reinterpret_cast<sal_Int64>(pData)));
120 for (
int i = 0;
i < nCount; ++
i)
129 short nRet = SfxDialogController::run();
145 const OUString sDelGroup = removedStr.getToken(0,
'\t', nIdx);
146 if( sDelGroup == aActGroup )
155 const OUString sMsg(
SwResId(STR_QUERY_DELETE_GROUP1)
156 + removedStr.getToken(0,
'\t', nIdx)
157 +
SwResId(STR_QUERY_DELETE_GROUP2));
160 VclMessageType::Question, VclButtonsType::YesNo, sMsg));
161 xQueryBox->set_default_response(
RET_NO);
162 if (
RET_YES == xQueryBox->run())
181 OUString sNewTitle = sNewGroup.getToken(0,
GLOS_DELIM);
182 if( sNewGroup != aActGroup )
193 m_xNewPB->set_sensitive(
false);
194 int nFirstEntry = m_xGroupTLB->get_selected_index();
195 if (nFirstEntry == -1)
200 const OUString
sName(m_xNameED->get_text());
201 bool bExists =
false;
202 int nPos = m_xGroupTLB->find_text(
sName);
206 fprintf(stderr,
"comparing %s and %s\n",
212 m_xRenamePB->set_sensitive(!bExists && !
sName.isEmpty());
213 fprintf(stderr,
"one rename %d\n", !bExists && !
sName.isEmpty());
214 m_xDelPB->set_sensitive(IsDeleteAllowed(sEntry));
219 OUString sGroup = m_xNameED->get_text()
221 + OUString::number(m_xPathLB->get_active());
222 OSL_ENSURE(!pGlosHdl->FindGroupName(sGroup),
"group already available!");
223 m_InsertedArr.push_back(sGroup);
225 pData->
sPath = m_xPathLB->get_active_text();
228 OUString
sId(OUString::number(reinterpret_cast<sal_Int64>(pData)));
229 m_xGroupTLB->append(sId, m_xNameED->get_text());
230 int nEntry = m_xGroupTLB->find_id(sId);
231 m_xGroupTLB->set_text(nEntry, pData->
sPath, 1);
232 m_xGroupTLB->select(nEntry);
233 SelectHdl(*m_xGroupTLB);
234 m_xGroupTLB->scroll_to_row(nEntry);
239 std::vector<int> aWidths;
240 int x,
y, width, height;
241 if (m_xPathLB->get_extents_relative_to(*m_xGroupTLB, x, y, width, height))
243 aWidths.push_back(x);
244 m_xGroupTLB->set_column_fixed_widths(aWidths);
250 int nEntry = m_xGroupTLB->get_selected_index();
253 rButton.set_sensitive(
false);
260 auto it = std::find(m_InsertedArr.begin(), m_InsertedArr.end(), sEntry);
261 if (it != m_InsertedArr.end())
263 m_InsertedArr.erase(it);
269 it = std::find_if(m_RenamedArr.begin(), m_RenamedArr.end(),
271 if (it != m_RenamedArr.end())
273 m_RenamedArr.erase(it);
282 m_xGroupTLB->remove(nEntry);
283 if (!m_xGroupTLB->n_children())
284 rButton.set_sensitive(
false);
286 m_xNameED->set_text(OUString());
287 ModifyHdl(*m_xNameED);
292 int nEntry = m_xGroupTLB->get_selected_index();
296 const OUString sNewTitle(m_xNameED->get_text());
297 OUString sNewName = sNewTitle
299 + OUString::number(m_xPathLB->get_active());
300 OSL_ENSURE(!pGlosHdl->FindGroupName(sNewName),
"group already available!");
304 auto it = std::find(m_InsertedArr.begin(), m_InsertedArr.end(), sEntry);
305 if (it != m_InsertedArr.end())
307 m_InsertedArr.erase(it);
308 m_InsertedArr.push_back(sNewName);
315 m_RenamedArr.push_back(sEntry);
318 m_xGroupTLB->remove(nEntry);
321 pData->
sPath = m_xPathLB->get_active_text();
325 OUString
sId(OUString::number(reinterpret_cast<sal_Int64>(pData)));
326 m_xGroupTLB->append(sId, m_xNameED->get_text());
327 nEntry = m_xGroupTLB->find_id(sId);
328 m_xGroupTLB->set_text(nEntry, m_xPathLB->get_active_text(), 1);
329 m_xGroupTLB->select(nEntry);
330 SelectHdl(*m_xGroupTLB);
331 m_xGroupTLB->scroll_to_row(nEntry);
336 ModifyHdl(*m_xNameED);
341 const OUString sEntry(m_xNameED->get_text());
342 bool bEnableNew =
true;
343 bool bEnableDel =
false;
344 sal_uInt32 nCaseReadonly = m_xPathLB->get_active_id().toUInt32();
347 if (sEntry.isEmpty() || bDirReadonly)
349 else if(!sEntry.isEmpty())
351 int nPos = m_xGroupTLB->find_text(sEntry);
356 for (
int i = 0, nEntryCount = m_xGroupTLB->n_children();
i < nEntryCount; ++
i)
358 const OUString sTemp = m_xGroupTLB->get_text(
i, 0);
359 nCaseReadonly = m_xPathLB->get_id(m_xPathLB->find_text(m_xGroupTLB->get_text(
i,1))).toUInt32();
362 if( !bCase && rSCmp.isEqual( sTemp, sEntry ))
372 m_xGroupTLB->select(nPos);
373 m_xGroupTLB->scroll_to_row(nPos);
374 SelectHdl(*m_xGroupTLB);
377 int nEntry = m_xGroupTLB->get_selected_index();
381 bEnableDel = IsDeleteAllowed(pUserData->
sGroupName);
384 m_xDelPB->set_sensitive(bEnableDel);
385 m_xNewPB->set_sensitive(bEnableNew);
386 m_xRenamePB->set_sensitive(bEnableNew && nEntry != -1);
387 fprintf(stderr,
"two rename %d\n", bEnableNew && nEntry != -1);
#define LINK(Instance, Class, Member)
const ::utl::TransliterationWrapper & GetAppCmpStrIgnore()
std::unique_ptr< weld::Entry > m_xNameED
IMPL_LINK_NOARG(SwGlossaryGroupDlg, SelectHdl, weld::TreeView &, void)
std::unique_ptr< ContentProperties > pData
std::vector< OUString > m_RemovedArr
std::unique_ptr< weld::TreeView > m_xGroupTLB
virtual short run() override
size_t GetGroupCnt() const
std::unique_ptr< weld::Button > m_xRenamePB
SwGlossaryGroupDlg(weld::Window *pParent, std::vector< OUString > const &rPathArr, SwGlossaryHdl *pGlosHdl)
void SetCurGroup(const OUString &aGrp, bool bApi=false, bool bAlwaysCreateNew=false)
bool IsDeleteAllowed(const OUString &rGroup)
bool UCB_IsCaseSensitiveFileName(const OUString &rURL)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
static OUString GetCurrGroup()
std::vector< OUString > m_RenamedArr
IMPL_LINK(SwGlossaryGroupDlg, DeleteHdl, weld::Button &, rButton, void)
bool DelGroup(const OUString &)
#define RENAME_TOKEN_DELIM
OUString const & GetURL() const
bool IsReadOnly(const OUString *=nullptr) const
OUString GetGroupName(size_t, OUString *pTitle)
OUString SwResId(const char *pId)
void NewGroup(OUString &rGroupName, const OUString &rTitle)
virtual ~SwGlossaryGroupDlg() override
#define SVT_SEARCHPATH_DELIMITER
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
std::vector< OUString > m_InsertedArr
std::unique_ptr< weld::Button > m_xNewPB
std::unique_ptr< weld::Button > m_xDelPB
#define PATH_CASE_SENSITIVE
void RenameGroup(const OUString &rOld, OUString &rNew, const OUString &rNewTitle)
IMPL_STATIC_LINK(SwGlossaryGroupDlg, EditInsertTextHdl, OUString &, rText, bool)
void EnableKillingFile(bool bEnable=true)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
std::unique_ptr< weld::ComboBox > m_xPathLB