22#include <osl/file.hxx>
23#include <osl/thread.hxx>
25#include <osl/diagnose.h>
31#include <rtl/strbuf.hxx>
44 : GenericDialogController(pParent,
"dbaccess/ui/dbaseindexdialog.ui",
"DBaseIndexDialog")
45 , m_aDSN(
std::move(aDataSrcName))
46 , m_xPB_OK(m_xBuilder->weld_button(
"ok"))
47 , m_xCB_Tables(m_xBuilder->weld_combo_box(
"table"))
48 , m_xIndexes(m_xBuilder->weld_widget(
"frame"))
49 , m_xLB_TableIndexes(m_xBuilder->weld_tree_view(
"tableindex"))
50 , m_xLB_FreeIndexes(m_xBuilder->weld_tree_view(
"freeindex"))
51 , m_xAdd(m_xBuilder->weld_button(
"add"))
52 , m_xRemove(m_xBuilder->weld_button(
"remove"))
53 , m_xAddAll(m_xBuilder->weld_button(
"addall"))
54 , m_xRemoveAll(m_xBuilder->weld_button(
"removeall"))
92 TableIndexList::iterator aSearch = std::find_if(_rList.begin(), _rList.end(),
93 [&_rName](
const OTableIndex& rIndex) { return rIndex.GetIndexFileName() == _rName; });
94 if (aSearch != _rList.end())
96 sal_Int32
nPos =
static_cast<sal_Int32
>(std::distance(_rList.begin(), aSearch));
100 _rList.erase(aSearch);
104 if (
static_cast<sal_uInt32
>(
nPos) == _rList.size())
105 _rDisplay.
select(
static_cast<sal_uInt16
>(
nPos)-1);
107 _rDisplay.
select(
static_cast<sal_uInt16
>(
nPos));
109 OSL_ENSURE(!_bMustExist || !aReturn.
GetIndexFileName().isEmpty(),
"ODbaseIndexDialog::implRemoveIndex : did not find the index!");
115 _rList.push_front(_rIndex);
126 [&] (
const OTableInfo& arg) { return arg.aTableName == _rTableName; });
137 [&] (
const OTableInfo& arg) { return arg.aTableName == _rTableName; });
149 for (
auto const& tableInfo : m_aTableInfoList)
150 tableInfo.WriteInfFile(m_aDSN);
157 OUString aSelection = m_xLB_FreeIndexes->get_selected_text();
158 OUString aTableName = m_xCB_Tables->get_active_text();
160 InsertTableIndex( aTableName,
aIndex );
167 OUString aSelection = m_xLB_TableIndexes->get_selected_text();
168 OUString aTableName = m_xCB_Tables->get_active_text();
170 InsertFreeIndex(
aIndex );
177 const sal_Int32 nCnt = m_xLB_FreeIndexes->n_children();
178 OUString aTableName = m_xCB_Tables->get_active_text();
181 InsertTableIndex(aTableName, RemoveFreeIndex(m_xLB_FreeIndexes->get_text(0),
true));
188 const sal_Int32 nCnt = m_xLB_TableIndexes->n_children();
189 OUString aTableName = m_xCB_Tables->get_active_text();
192 InsertFreeIndex(RemoveTableIndex(aTableName, m_xLB_TableIndexes->get_text(0)));
205 TableInfoList::iterator aTablePos = std::find_if(m_aTableInfoList.begin(), m_aTableInfoList.end(),
206 [&] (
const OTableInfo& arg) { return arg.aTableName == rComboBox.get_active_text() ; });
208 if (aTablePos == m_aTableInfoList.end())
212 m_xLB_TableIndexes->clear();
213 for (
auto const&
index : aTablePos->aIndexList)
214 m_xLB_TableIndexes->append_text(
index.GetIndexFileName());
216 if (!aTablePos->aIndexList.empty())
217 m_xLB_TableIndexes->select(0);
234 aURL.SetSmartProtocol(INetProtocol::File);
257 std::vector< OUString > aUsedIndexes;
259 aURL.SetSmartProtocol(INetProtocol::File);
261 for(
const OUString& rURL : aFolderUrls)
264 osl::FileBase::getSystemPathFromFileURL(rURL,
aName);
266 OUString aExt =
aURL.getExtension();
271 else if (aExt ==
"dbf")
277 aURL.setExtension(
u"inf");
288 for( sal_uInt16 nKey = 0; nKey < nKeyCnt; nKey++ )
292 aNDX = aKeyName.copy(0,3);
297 aEntry = OStringToOUString(aInfFile.
ReadKey(aKeyName), osl_getThreadTextEncoding());
301 aUsedIndexes.push_back(aEntry);
309 for (
auto const& usedIndex : aUsedIndexes)
356 aURL.SetSmartProtocol(INetProtocol::File);
357 OUString aDsn = rDSN;
362 aURL.SetSmartURL(aDsn);
364 aURL.setExtension(
u"inf");
375 while( nKey < nKeyCnt )
378 OString aKeyName = aInfFile.
GetKeyName( nKey );
379 aNDX = aKeyName.copy(0,3);
396 OStringBuffer aKeyName(
"NDX");
398 aKeyName.append(
static_cast<sal_Int32
>(
nPos));
400 aKeyName.makeStringAndClear(),
402 osl_getThreadTextEncoding()));
Reference< XExecutableDialog > m_xDialog
void DeleteKey(std::string_view rKey)
OString GetKeyName(sal_uInt16 nKey) const
void SetGroup(const OString &rGroup)
sal_uInt16 GetKeyCount() const
OString ReadKey(const OString &rKey) const
void WriteKey(const OString &rKey, const OString &rValue)
OUString SubstituteVariable(const OUString &rVar) const
virtual ~ODbaseIndexDialog() override
TableInfoList m_aTableInfoList
std::unique_ptr< weld::Button > m_xAddAll
ODbaseIndexDialog(weld::Window *pParent, OUString aDataSrcName)
std::unique_ptr< weld::Button > m_xRemoveAll
std::unique_ptr< weld::TreeView > m_xLB_FreeIndexes
void InsertTableIndex(std::u16string_view _rTableName, const OTableIndex &_rIndex)
std::unique_ptr< weld::Button > m_xRemove
static void implInsertIndex(const OTableIndex &_rIndex, TableIndexList &_rList, weld::TreeView &_rDisplay)
OTableIndex RemoveFreeIndex(const OUString &_rName, bool _bMustExist)
std::unique_ptr< weld::Button > m_xAdd
static OTableIndex implRemoveIndex(const OUString &_rName, TableIndexList &_rList, weld::TreeView &_rDisplay, bool _bMustExist)
std::unique_ptr< weld::TreeView > m_xLB_TableIndexes
OTableIndex RemoveTableIndex(std::u16string_view _rTableName, const OUString &_rIndexName)
TableIndexList m_aFreeIndexList
std::unique_ptr< weld::Button > m_xPB_OK
std::unique_ptr< weld::Widget > m_xIndexes
std::unique_ptr< weld::ComboBox > m_xCB_Tables
represents a single dbf index
const OUString & GetIndexFileName() const
holds the INF file of a table
void WriteInfFile(const OUString &rDSN) const
TableIndexList aIndexList
OUString get(NOTATION _eOutputNotation) const
css::uno::Any executeCommand(const OUString &rCommandName, const css::uno::Any &rCommandArgument)
static css::uno::Sequence< OUString > GetFolderContents(const OUString &rFolder, bool bFolder)
void append_text(const OUString &rStr)
void remove_text(const OUString &rText)
virtual void select(int pos)=0
std::deque< AttacherIndex_Impl > aIndex
#define LINK(Instance, Class, Member)
Reference< XComponentContext > getProcessComponentContext()
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
IMPL_LINK(OApplicationController, OnSelectContainer, void *, _pType, void)
constexpr OStringLiteral aGroupIdent("dBase III")
std::deque< OTableIndex > TableIndexList
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)