21 #include <string_view>
23 #include <com/sun/star/container/XNamed.hpp>
29 #include <osl/diagnose.h>
30 #include <rtl/character.hxx>
51 OUString lcl_FullPathName(std::u16string_view sPath, std::u16string_view sName)
56 OUString lcl_CheckFileName(
const OUString& rNewFilePath,
57 const OUString& rNewGroupName )
59 const sal_Int32 nLen = rNewGroupName.getLength();
60 OUStringBuffer
aBuf(nLen);
62 for( sal_Int32 i=0;
i < nLen; ++
i )
65 if (rtl::isAsciiAlphanumeric(cChar) ||
66 cChar ==
'_' || cChar == 0x20)
72 const OUString sRet =
aBuf.makeStringAndClear().trim();
73 if ( !sRet.isEmpty() )
82 aTemp.EnableKillingFile();
109 for(
size_t i = 0;
i < nCount; ++
i)
121 for(
size_t i = 0;
i < nCount; ++
i)
124 sal_uInt16 nPath = sTemp.getToken(1,
GLOS_DELIM).toUInt32();
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; }))
177 const OUString sNewPath(rGroupName.getToken(1,
GLOS_DELIM));
178 sal_uInt16 nNewPath =
static_cast<sal_uInt16
>(sNewPath.toInt32());
179 if (static_cast<size_t>(nNewPath) >=
m_PathArr.size())
181 const OUString sNewFilePath(
m_PathArr[nNewPath]);
182 const OUString sNewGroup = lcl_CheckFileName(sNewFilePath, rGroupName.getToken(0,
GLOS_DELIM))
184 std::unique_ptr<SwTextBlocks> pBlock =
GetGlosDoc( sNewGroup );
188 pBlock->SetName(rTitle);
189 rGroupName = sNewGroup;
196 const OUString& rOldGroup, OUString& rNewGroup,
const OUString& rNewTitle )
198 sal_uInt16 nOldPath =
static_cast<sal_uInt16
>(rOldGroup.getToken(1,
GLOS_DELIM).toInt32());
199 if (static_cast<size_t>(nOldPath) >=
m_PathArr.size())
202 const OUString sOldFileURL =
207 OSL_FAIL(
"group doesn't exist!");
211 sal_uInt16 nNewPath =
static_cast<sal_uInt16
>(rNewGroup.getToken(1,
GLOS_DELIM).toInt32());
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);
240 std::unique_ptr<SwTextBlocks> pNewBlock(
new SwTextBlocks( sNewFileURL ));
241 pNewBlock->SetName(rNewTitle);
249 sal_uInt16 nPath =
static_cast<sal_uInt16
>(rName.getToken(1,
GLOS_DELIM).toInt32());
250 if (static_cast<size_t>(nPath) >=
m_PathArr.size())
252 const OUString sBaseName(rName.getToken(0,
GLOS_DELIM));
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");
272 sal_uInt16 nPath =
static_cast<sal_uInt16
>(rName.getToken(1,
GLOS_DELIM).toInt32());
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 ) );
439 Reference< container::XNamed > xNamed( aLoop->get(), UNO_QUERY );
444 else if ( xNamed->getName() == rGroup )
462 auto pEntry = comphelper::getUnoTunnelImplementation<SwXAutoTextEntry>(aLoop->get());
463 if ( pEntry && ( pEntry->GetGroupName() == rGroup ) )
465 pEntry->Invalidate();
481 const OUString sGroupName(rGroupName.getToken(0,
GLOS_DELIM, nIndex));
482 const bool bPathLen = !rGroupName.getToken(0,
GLOS_DELIM, nIndex).isEmpty();
483 for (
size_t i = 0;
i < nCount;
i++ )
488 if (rGroupName == sGrpName)
493 if (sGroupName == sGrpName.getToken(0,
GLOS_DELIM))
505 Reference< text::XAutoTextGroup > xGroup( rGroup.get(), UNO_QUERY );
507 static_cast< SwXAutoTextGroup* >( xGroup.get() )->Invalidate();
514 auto pEntry = comphelper::getUnoTunnelImplementation<SwXAutoTextEntry>(rEntry.get());
516 pEntry->Invalidate();
523 bool _bCreate =
true;
527 Reference< text::XAutoTextGroup > xGroup;
533 auto pSwGroup = comphelper::getUnoTunnelImplementation<SwXAutoTextGroup>(aSearch->get());
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 );
585 throw container::NoSuchElementException();
587 Reference< text::XAutoTextEntry > xReturn;
592 Reference< lang::XUnoTunnel > xEntryTunnel( aSearch->get(), UNO_QUERY );
595 if ( xEntryTunnel.is() )
605 && pEntry->GetGroupName() == rGroupName
606 && pEntry->GetEntryName() == rEntryName
const ::utl::TransliterationWrapper & GetAppCmpStrIgnore()
SVL_DLLPUBLIC bool IsDocument(const OUString &rURL)
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
static OUString lcl_makePath(const std::vector< OUString > &rPaths)
std::vector< OUString > m_aInvalidPaths
std::unique_ptr< SwTextBlocks > GetGroupDoc(const OUString &rName, bool bCreate=false)
static OUString GetExtension()
bool UCB_DeleteFile(const OUString &rURL)
SAL_DLLPRIVATE void RemoveFileFromList(const OUString &rGroup)
SVL_DLLPUBLIC bool IsFolder(const OUString &rURL)
bool FindGroupName(OUString &rGroup)
OUString GetCompleteGroupName(const OUString &GroupName)
bool UCB_MoveFile(const OUString &rURL, const OUString &rNewURL)
std::vector< OUString > m_GlosArr
bool UCB_IsCaseSensitiveFileName(const OUString &rURL)
bool DelGroupDoc(const OUString &)
SAL_DLLPRIVATE void InvalidateUNOOjects()
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
UnoAutoTextGroups m_aGlossaryGroups
SAL_DLLPRIVATE std::unique_ptr< SwTextBlocks > GetGlosDoc(const OUString &rName, bool bCreate=true) const
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
static OUString GetDefName()
UnoAutoTextEntries m_aGlossaryEntries
#define ERR_AUTOPATH_ERROR
css::uno::Reference< css::text::XAutoTextGroup > GetAutoTextGroup(const OUString &_rGroupName)
returns the cached AutoTextGroup (if any) for the given group name The group is created if it does no...
std::vector< css::uno::WeakReference< css::text::XAutoTextGroup > > UnoAutoTextGroups
void UpdateGlosPath(bool bFull)
#define SVT_SEARCHPATH_DELIMITER
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...
OUString const & GetGroupName(size_t)
OUString GetGroupTitle(const OUString &rGroupName)
bool RenameGroupDoc(const OUString &sOldGroup, OUString &sNewGroup, const OUString &rNewTitle)
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
bool UCB_GetFileListOfFolder(const OUString &rURL, std::vector< OUString > &rList, const OUString *pExtension, std::vector< ::DateTime > *pDateTimeList)
std::vector< OUString > m_PathArr
const OUString & GetAutoTextPath() const
SAL_DLLPRIVATE std::vector< OUString > & GetNameList()
std::vector< css::uno::WeakReference< css::text::XAutoTextEntry > > UnoAutoTextEntries
bool NewGroupDoc(OUString &rGroupName, const OUString &rTitle)
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)