// fill the listbox for the indexes
m_xLB_TableIndexes->clear(); for (autoconst& index : aTablePos->aIndexList)
m_xLB_TableIndexes->append_text(index.GetIndexFileName());
if (!aTablePos->aIndexList.empty())
m_xLB_TableIndexes->select(0);
// All indices are first added to a list of free indices. // Afterwards, check the index of each table in the Inf-file. // These indices are removed from the list of free indices and // entered in the indexlist of the table.
// if the string does not contain a path, cut the string
INetURLObject aURL;
aURL.SetSmartProtocol(INetProtocol::File);
{
SvtPathOptions aPathOptions;
m_aDSN = aPathOptions.SubstituteVariable(m_aDSN);
}
aURL.SetSmartURL(m_aDSN);
// open the INF file
aURL.setExtension(u"inf");
OFileNotation aTransformer(aURL.GetURLNoPass(), OFileNotation::N_URL);
Config aInfFile( aTransformer.get(OFileNotation::N_SYSTEM) );
aInfFile.SetGroup( aGroupIdent );
// fill the indexes list
OString aNDX;
sal_uInt16 nKeyCnt = aInfFile.GetKeyCount();
OString aKeyName;
OUString aEntry;
for( sal_uInt16 nKey = 0; nKey < nKeyCnt; nKey++ )
{ // does the key point to an index file ?
aKeyName = aInfFile.GetKeyName( nKey );
aNDX = aKeyName.copy(0,3);
// yes -> add to the tables index list if (aNDX == "NDX")
{
aEntry = OStringToOUString(aInfFile.ReadKey(aKeyName), osl_getThreadTextEncoding());
rTabInfo.aIndexList.emplace_back( aEntry );
// and remove it from the free index list
aUsedIndexes.push_back(aEntry); // do this later below. We may not have encountered the index file, yet, thus we may not // know the index as being free, yet
}
}
}
}
for (autoconst& usedIndex : aUsedIndexes)
RemoveFreeIndex( usedIndex, false );
if (!m_aTableInfoList.empty())
{
m_xPB_OK->set_sensitive(true);
m_xIndexes->set_sensitive(true);
}
// put the first dataset into Edit if (!m_aTableInfoList.empty())
{ const OTableInfo& rTabInfo = m_aTableInfoList.front();
m_xCB_Tables->set_entry_text(rTabInfo.aTableName);
// build ListBox of the table indices for (autoconst& index : rTabInfo.aIndexList)
m_xLB_TableIndexes->append_text(index.GetIndexFileName());
if (!rTabInfo.aIndexList.empty())
m_xLB_TableIndexes->select(0);
}
// ListBox of the free indices for (autoconst& freeIndex : m_aFreeIndexList)
m_xLB_FreeIndexes->append_text(freeIndex.GetIndexFileName());
if (!m_aFreeIndexList.empty())
m_xLB_FreeIndexes->select(0);
// first, delete all table indices
sal_uInt16 nKeyCnt = aInfFile.GetKeyCount();
sal_uInt16 nKey = 0;
while( nKey < nKeyCnt )
{ // Does the key point to an index file?...
OString aKeyName = aInfFile.GetKeyName( nKey );
OString aNDX = aKeyName.copy(0,3);
//...if yes, delete index file, nKey is at subsequent key if (aNDX == "NDX")
{
aInfFile.DeleteKey(aKeyName);
nKeyCnt--;
} else
nKey++;
}
// now add all saved indices
sal_uInt16 nPos = 0; for (autoconst& index : aIndexList)
{
OStringBuffer aKeyName("NDX"); if( nPos > 0 ) // first index contains no number
aKeyName.append(static_cast<sal_Int32>(nPos));
aInfFile.WriteKey(
aKeyName.makeStringAndClear(),
OUStringToOString(index.GetIndexFileName(),
osl_getThreadTextEncoding()));
++nPos;
}
aInfFile.Flush();
// if only [dbase] is left in INF-file, delete file if(nPos) return;
try
{
::ucbhelper::Content aContent(aURL.GetURLNoPass(),Reference<XCommandEnvironment>(), comphelper::getProcessComponentContext());
aContent.executeCommand( u"delete"_ustr, Any( true ) );
} catch (const Exception& )
{ // simply silent this. The strange algorithm here does a lot of // things even if no files at all were created or accessed, so it's // possible that the file we're trying to delete does not even // exist, and this is a valid condition.
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.