23#include <com/sun/star/container/XNamed.hpp>
29#include <osl/diagnose.h>
30#include <rtl/character.hxx>
52OUString lcl_FullPathName(std::u16string_view sPath, std::u16string_view sName)
57OUString lcl_CheckFileName(
const OUString& rNewFilePath,
58 std::u16string_view aNewGroupName )
60 const sal_Int32 nLen = aNewGroupName.size();
61 OUStringBuffer
aBuf(nLen);
63 for( sal_Int32 i=0;
i < nLen; ++
i )
66 if (rtl::isAsciiAlphanumeric(cChar) ||
67 cChar ==
'_' || cChar == 0x20)
73 const OUString sRet =
aBuf.makeStringAndClear().trim();
74 if ( !sRet.isEmpty() )
82 aTemp.EnableKillingFile();
85 return aTempURL.GetBase();
127 && rSCmp.isEqual( rGroup, sTemp.getToken( 0,
GLOS_DELIM) ) )
139 "SwGlossaries::GetGroupName: index out of bounds");
146 OUString sGroup(rGroupName);
149 std::unique_ptr<SwTextBlocks> pGroup =
GetGroupDoc(sGroup);
152 sRet = pGroup->GetName();
165 [&rName](
const OUString& rEntry) { return rEntry == rName; }))
178 sal_uInt16 nNewPath = o3tl::narrowing<sal_uInt16>(
o3tl::toInt32(sNewPath));
179 if (
static_cast<size_t>(nNewPath) >=
m_PathArr.size())
181 const OUString sNewFilePath(
m_PathArr[nNewPath]);
184 std::unique_ptr<SwTextBlocks> pBlock =
GetGlosDoc( sNewGroup );
188 pBlock->SetName(rTitle);
189 rGroupName = sNewGroup;
196 const OUString& rOldGroup, OUString& rNewGroup,
const OUString& rNewTitle )
199 if (
static_cast<size_t>(nOldPath) >=
m_PathArr.size())
202 const OUString sOldFileURL =
207 OSL_FAIL(
"group doesn't exist!");
212 if (
static_cast<size_t>(nNewPath) >=
m_PathArr.size())
215 const OUString sNewFileName = lcl_CheckFileName(
m_PathArr[nNewPath],
217 const OUString sNewFileURL = lcl_FullPathName(
m_PathArr[nNewPath], sNewFileName);
221 OSL_FAIL(
"group already exists!");
230 rNewGroup = sNewFileName + OUStringChar(
GLOS_DELIM) + OUString::number(nNewPath);
250 if (
static_cast<size_t>(nPath) >=
m_PathArr.size())
253 const OUString sFileURL = lcl_FullPathName(
m_PathArr[nPath], sBaseName);
254 const OUString
aName = sBaseName + OUStringChar(
GLOS_DELIM) + OUString::number(nPath);
259 OSL_ENSURE(bRemoved,
"file has not been removed");
273 std::unique_ptr<SwTextBlocks> pTmp;
274 if (
static_cast<size_t>(nPath) <
m_PathArr.size())
276 const OUString sFileURL =
283 if (bCreate || bExist)
287 if( pTmp->GetError() )
290 bOk = ! pTmp->GetError().IsError();
293 if( bOk && pTmp->GetName().isEmpty() )
294 pTmp->SetName( rName );
309 std::vector<OUString> aFiles;
312 for (
const OUString& aTitle : aFiles)
314 const OUString
sName( aTitle.subView( 0, aTitle.getLength() - sExt.getLength() )
315 + OUStringChar(
GLOS_DELIM) + OUString::number(
static_cast<sal_Int16
>(
i) ));
336 std::vector<OUString>::const_iterator aIt(rPaths.begin());
337 const std::vector<OUString>::const_iterator aEnd(rPaths.end());
338 OUStringBuffer aPath(*aIt);
339 for (++aIt; aIt != aEnd; ++aIt)
345 return aPath.makeStringAndClear();
352 bool bPathChanged =
m_aPath != aNewPath;
353 if (!(bFull || bPathChanged))
360 std::vector<OUString> aDirArr;
361 std::vector<OUString> aInvalidPaths;
371 if (!aDirArr.empty() &&
372 std::find(aDirArr.begin(), aDirArr.end(), sPth) != aDirArr.end())
376 aDirArr.push_back(sPth);
378 aInvalidPaths.push_back(sPth);
385 if (
m_aPath.isEmpty() || !aInvalidPaths.empty())
387 std::sort(aInvalidPaths.begin(), aInvalidPaths.end());
388 aInvalidPaths.erase(std::unique(aInvalidPaths.begin(), aInvalidPaths.end()), aInvalidPaths.end());
396 DialogMask::ButtonsOk | DialogMask::MessageError ) );
444 else if ( xNamed->getName() == rGroup )
446 xNamed->Invalidate();
463 if ( pEntry && ( pEntry->GetGroupName() == rGroup ) )
465 pEntry->Invalidate();
488 if (rGroupName == sGrpName)
507 xGroup->Invalidate();
516 pEntry->Invalidate();
523 bool _bCreate =
true;
541 if ( _rGroupName == pSwGroup->getName() )
543 if ( !sCompleteGroupName.isEmpty() )
561 if ( !xGroup.is() && _bCreate )
572 const OUString& rCompleteGroupName,
573 const OUString& rGroupName,
574 const OUString& rEntryName )
577 bool bCreate = ( rCompleteGroupName ==
GetDefName() );
578 std::unique_ptr< SwTextBlocks > pGlosGroup(
GetGroupDoc( rCompleteGroupName, bCreate ) );
580 if (!pGlosGroup || pGlosGroup->GetError())
581 throw lang::WrappedTargetException();
583 sal_uInt16 nIdx = pGlosGroup->GetIndex( rEntryName );
584 if ( USHRT_MAX == nIdx )
585 throw container::NoSuchElementException();
602 && pEntry->GetGroupName() == rGroupName
603 && pEntry->GetEntryName() == rEntryName
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
const OUString & GetAutoTextPath() const
bool NewGroupDoc(OUString &rGroupName, const OUString &rTitle)
static OUString GetDefName()
OUString GetCompleteGroupName(std::u16string_view GroupName)
SAL_DLLPRIVATE std::unique_ptr< SwTextBlocks > GetGlosDoc(const OUString &rName, bool bCreate=true) const
std::unique_ptr< SwTextBlocks > GetGroupDoc(const OUString &rName, bool bCreate=false)
OUString GetGroupTitle(const OUString &rGroupName)
css::uno::Reference< css::text::XAutoTextEntry > GetAutoTextEntry(const OUString &_rCompleteGroupName, const OUString &_rGroupName, const OUString &_rEntryName)
returns the cached AutoTextEntry (if any) for the given group/with the given name The entry is create...
std::vector< OUString > m_PathArr
std::vector< OUString > m_aInvalidPaths
UnoAutoTextGroups m_aGlossaryGroups
SAL_DLLPRIVATE void RemoveFileFromList(const OUString &rGroup)
SAL_DLLPRIVATE std::vector< OUString > & GetNameList()
UnoAutoTextEntries m_aGlossaryEntries
OUString const & GetGroupName(size_t)
static OUString GetExtension()
std::vector< OUString > m_GlosArr
css::uno::Reference< css::text::XAutoTextGroup > GetAutoTextGroup(std::u16string_view _rGroupName)
returns the cached AutoTextGroup (if any) for the given group name The group is created if it does no...
SAL_DLLPRIVATE void InvalidateUNOOjects()
void UpdateGlosPath(bool bFull)
bool DelGroupDoc(std::u16string_view)
bool FindGroupName(OUString &rGroup)
bool RenameGroupDoc(const OUString &sOldGroup, OUString &sNewGroup, const OUString &rNewTitle)
void SetName(const OUString &)
static OUString lcl_makePath(const std::vector< OUString > &rPaths)
std::vector< unotools::WeakReference< SwXAutoTextEntry > > UnoAutoTextEntries
std::vector< unotools::WeakReference< SwXAutoTextGroup > > UnoAutoTextGroups
const ::utl::TransliterationWrapper & GetAppCmpStrIgnore()
SVL_DLLPUBLIC bool IsFolder(const OUString &rURL)
SVL_DLLPUBLIC bool IsDocument(const OUString &rURL)
bool UCB_GetFileListOfFolder(const OUString &rURL, std::vector< OUString > &rList, const OUString *pExtension, std::vector< ::DateTime > *pDateTimeList)
bool UCB_DeleteFile(const OUString &rURL)
bool UCB_IsCaseSensitiveFileName(std::u16string_view rURL)
bool UCB_MoveFile(const OUString &rURL, std::u16string_view rNewURL)
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
sal_uInt32 toUInt32(std::u16string_view str, sal_Int16 radix=10)
#define SVT_SEARCHPATH_DELIMITER
#define ERR_AUTOPATH_ERROR