24#include <osl/file.hxx>
28#include <com/sun/star/sdbc/XResultSet.hpp>
29#include <com/sun/star/sdbc/XRow.hpp>
42using namespace ::
cppu;
60 , m_bUseCollector(false)
67 const OUString& _rName)
68 :
OIndex(_rName, OUString(), _rHeader.db_unique, false, false, true)
74 , m_bUseCollector(false)
86 ::osl::MutexGuard aGuard(
m_aMutex );
88 ::std::vector< OUString> aVector;
120 if(UCBContentHelper::Exists(sFile))
122 m_pFileStream = OFileTable::createStream_simpleError(sFile, StreamMode::READWRITE | StreamMode::NOCREATE | StreamMode::SHARE_DENYWRITE);
124 m_pFileStream = OFileTable::createStream_simpleError(sFile, StreamMode::READ | StreamMode::NOCREATE | StreamMode::SHARE_DENYNONE);
129 (*m_pFileStream) >> *
this;
135 STR_COULD_NOT_LOAD_FILE,
145 return std::make_unique<OIndexIterator>(
this);
220 return Delete(nRec, rOldValue) &&
Insert(nRec,rNewValue);
237#if OSL_DEBUG_LEVEL > 1
306 pPage =
new ONDXPage(*
this, nPagePos, pParent);
309 (*m_pFileStream) >> *pPage;
318 sal_uInt64
const nOldPos(rStream.
Tell());
372 const OUString sEntry(
m_Name +
".ndx");
379 OUString sPhysicalPath;
380 osl::FileBase::getSystemPathFromFileURL(sCfgFile, sPhysicalPath);
382 Config aInfFile(sPhysicalPath);
386 OString aNewEntry,aKeyName;
388 while (aNewEntry.isEmpty())
390 aNewEntry =
"NDX" + OString::number(++nSuffix);
394 if (bCase ? aKeyName == aNewEntry : aKeyName.equalsIgnoreAsciiCase(aNewEntry))
409 if(UCBContentHelper::Exists(sPath))
411 if(!UCBContentHelper::Kill(sPath))
420 OUString sPhysicalPath;
421 OSL_VERIFY( osl::FileBase::getSystemPathFromFileURL(sCfgFile, sPhysicalPath)
422 == osl::FileBase::E_None );
424 Config aInfFile(sPhysicalPath);
428 OUString sEntry =
m_Name +
".ndx";
431 for (sal_uInt16 nKey = 0; nKey < nKeyCnt; nKey++)
435 if (aKeyName.startsWith(
"NDX"))
449 if(UCBContentHelper::Exists(_sFile))
450 UCBContentHelper::Kill(_sFile);
458 if(UCBContentHelper::Exists(sFile))
461 STR_COULD_NOT_CREATE_INDEX_NAME,
477 m_pFileStream = OFileTable::createStream_simpleError(sFile,StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC);
481 STR_COULD_NOT_LOAD_FILE,
501 OUString aStatement(
"SELECT " + aQuote +
aName + aQuote +
" FROM " + aQuote +
m_pTable->
getName() + aQuote +
" ORDER BY " + aQuote +
aName + aQuote);
503 xSet.
set( xStmt->executeQuery(aStatement),UNO_SET_THROW );
548 sal_Int32 nRowsLeft = 0;
555 nRowsLeft = xSet->getRow();
IMPLEMENT_SERVICE_INFO(ODbaseIndex,"com.sun.star.sdbcx.driver.dbase.Index","com.sun.star.sdbcx.Index")
constexpr OStringLiteral dBASE_III_GROUP
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)
std::size_t WriteBytes(const void *pData, std::size_t nSize)
SvStream & WriteUChar(unsigned char nChar)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & WriteUInt32(sal_uInt32 nUInt32)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
sal_uInt64 Seek(sal_uInt64 nPos)
std::size_t ReadBytes(void *pData, std::size_t nSize)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
SvStream & ReadUChar(unsigned char &rChar)
OUString getString() const
OUString getResourceStringWithSubstitution(TranslateId pResId, const char *_pAsciiPatternToReplace, const OUString &_rStringToSubstitute) const
loads a string from the shared resource file, and replaces a given ASCII pattern with a given string
bool Insert(sal_uInt32 nRec, const ORowSetValue &rValue)
bool Update(sal_uInt32 nRec, const ORowSetValue &, const ORowSetValue &)
ODbaseIndex(ODbaseTable *_pTable)
std::vector< ONDXPage * > m_aCollector
virtual void refreshColumns() override
OUString getCompletePath() const
ONDXPagePtr const & getRoot()
bool Find(sal_uInt32 nRec, const ORowSetValue &rValue)
std::unique_ptr< OIndexIterator > createIterator()
bool Delete(sal_uInt32 nRec, const ORowSetValue &rValue)
bool ConvertToKey(ONDXKey *rKey, sal_uInt32 nRec, const ORowSetValue &rValue)
void Release(bool bSave=true)
ONDXPage * CreatePage(sal_uInt32 nPagePos, ONDXPage *pParent=nullptr, bool bLoad=false)
virtual ~ODbaseIndex() override
std::unique_ptr< SvStream > m_pFileStream
void impl_killFileAndthrowError_throw(TranslateId pErrorId, const OUString &_sFile)
friend SvStream & WriteODbaseIndex(SvStream &rStream, const ODbaseIndex &)
sal_Int32 getCurrentFilePos() const
virtual void setValue(const ORowSetValue &_rVal) override
void setRecord(sal_uInt32 _nRec)
void SetParent(ONDXPagePtr aPa)
void SetPagePos(sal_uInt32 nPage)
bool Find(const ONDXKey &)
void SetModified(bool bMod)
bool Insert(ONDXNode &rNode, sal_uInt32 nRowsLeft=0)
void Release(bool bSave=true)
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData() override
virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement() override
OUString SAL_CALL getName() override
const ::rtl::Reference< OSQLColumns > & getTableColumns() const
OConnection * getConnection() const
bool isCaseSensitive() const
std::unique_ptr< OCollection > m_pColumns
virtual void construct() override
mutable::osl::Mutex m_aMutex
const css::uno::Reference< INTERFACE > & getTyped() const
bool set(const css::uno::BaseReference &_rRef, css::uno::UnoReference_Query _query)
#define SAL_WARN_IF(condition, area, stream)
sal_Int32 getINT32(const Any &_rAny)
OUString getString(const Any &_rAny)
void ReadHeader(SvStream &rStream, ODbaseIndex::NDXHeader &rHeader)
SvStream & operator>>(SvStream &rStream, ODbaseIndex &)
SvStream & WriteODbaseIndex(SvStream &rStream, const ODbaseIndex &)
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
#define PROPERTY_ID_PRECISION
#define PROPERTY_ID_DELIMITER